JClass Chart 3D

PreviousNextIndex

6

Advanced JClass Chart 3D Programming

4D Surface Graphs  4D Bar Charts  Customizing the Contour Levels

Customizing Contour Styles  Internationalization Support

All elements mentioned in this chapter refer to both the Java 2 API and the
Java 3D API, unless specifically noted.


This section covers topics that programmers of advanced JClass Chart 3D applications will find useful. It assumes that you are already familiar with JClass Chart 3D.


6.1 4D Surface Graphs

For surface and bar charts, JClass Chart 3D can be used to display 4D charts using color as a fourth dimension. The additional color information is provided to JClass Chart 3D as a second data source using the Chart3dDataView class' zoneDataSource property.

A full description of data sources, including grid data sources, is provided in Data Sources, in Chapter 5.

For zone data, use the Chart3dGridDataModel interface. The Chart3dGridDataModel interface, which extends Chart3dDataModel, is the core grid data model interface. In JClass Chart 3D, grid data is specified in terms of an X-array of grid values, a Y-array of grid values, and a doubly subscripted array of z data values.

To create a 4D chart:

If the zone data has a hole that is not in the surface data, the surface in the region of the hole will be displayed as if the zone data were not attached.

Figure 21 :  4D chart - zone/contour data is different from surface data.


6.2 4D Bar Charts

When a zone data source is supplied for a bar chart, the values in the zone data are used in conjunction with the contour levels to apply zone colors to the bars in the grid.

When zone data is supplied and the Zoned property of the JCContour class is true, the bar is not broken up into separate colored segments. Rather, each bar is individually colored according to the zoned height of the bar. Contours are never drawn when zone data is supplied. Figure 22 gives an example of a 4D bar chart.

Figure 22 :  A 4D Bar Chart.

In a bar chart, the zone data structure is only referenced when Zoned is true. A legend is generated based on the contour levels. The legend labels can be replaced by supplying a list of labels to the JCChart3dLegend class via its labels property.

Please see Legends, in Chapter 2 for full details on legend Strings.


6.3 Customizing the Contour Levels

To customize contour levels, manipulate the JCContourLevels class. This object deals with contour levels; it calculates default levels (if isDefault is true) but also allows users to set their own levels.

The JCContourLevels class has five properties:

To specify your own contour levels, set the levels property to a new array of doubles. This array must be in strictly increasing order. You can also manipulate the levels using the addlevel() and removeLevel() methods. Changing the levels in any of the above ways has the side effect of setting the isDefault property to false. When isDefault is false, the numLevels property automatically takes on the value of the length of the levels array and hence becomes read only. If isDefault is set to true, the numLevels property can be changed to specify the number of default levels to calculate.

In user-specified contour levels, the default is to display just the range of data that is spanned by the data (JCChart3dLegend.RANGE_DATA). If the distributionRange property of the JCChart3dLegend class is set to JCChart3dLegend.Range_ALL, the entire contour level array is shown in the legend.


6.4 Customizing Contour Styles

To customize contour styles, manipulate the contourStyles property of the JCContour class. The contourStyles property reference an ArrayList of JCContourStyle objects. The JCContourStyle class defines the style used to draw contours and zones.

The JCContourStyle class has three properties:

6.4.1 Default Contour Styles

By default, for surface and bar charts, JClass Chart 3D provides an array of 100 contour styles. By default, the fill styles are solid, the contour lines are black lines of width 1, and the symbols are of type JCSymbolStyle.DOT of size 6. The fill colors and symbol colors are chosen from a predefined array of colors chosen to provide a pleasing color distribution.

You will need to provide custom contour styles if:

It is usually easiest to specify more contour styles than will be needed for the number of contour levels. If nstyles contour styles are provided, and the number of contour levels is nlevels, JClass Chart 3D will calculate the index into the contour styles array for level i (0 £ i £ nlevels) as follows:

(int)Math.round(i * (nstyles - 1)/nlevels)

If you wish to change this index calculation, implement the JCContourMapping interface by creating the method:

public int contourIndex(int level);

Then set the object that implements the interface on the contourMapping property of the JCContour class.

The JCContourStyle class contains information about how JClass Chart 3D should display contour style objects. The fields are broken down as follows:

fillcolor

The color used to demarcate the level when zoned is true.

fillpattern

The pattern used to fill the zones. Valid values include JCLineStyle.NONE, JCLineStyle.SOLID, JCLineStyle.LONG_DASH, JCLineStyle.SHORT_DASH, JCLineStyle.LSL_DASH, and JCLineStyle.DASH_DOT.

linecolor

The color used to demarcate the level's contour line when contoured is true.

linewidth

The line width used to demarcate the level's contour line when contoured is true. Must be greater than or equal to 0. When linewidth is zero, no line is drawn.

linepattern

The line pattern used to demarcate the level's contour line when contoured is true. Line patterns are only honored for surface plots that are 2D projections (available in the Java 2 API version of JClass Chart 3D by setting the meshed and shaded properties of the JCElevation class to false). The line pattern must be one of the patterns listed in Figure 23.

Figure 23 :  Different Line Patterns.

Here is a code sample that doubles the line width of the 50th contour style.

JCContour contour=dataView.getContour();
ArrayList contourStyles=getContourStyles();
JContourStyle style=(JCContourStyle)contourStyles.get(49);
style.setLineWidth(2*style.getLineWidth());

6.5 Internationalization Support

6.5.1 Internationalization

Internationalization is the process of making software that is ready for adaptation to various languages and regions without engineering changes. JClass products have been internationalized.

Localization is the process of making internationalized software run appropriately in a particular environment. All Strings used by JClass that need to be localized (that is, Strings that will be seen by a typical user) have been internationalized and are ready for localization. Thus, while localization stubs are in place for JClass, this step must be implemented by the developer of the localized software. These Strings are in resource bundles in every package that requires them. Therefore, the developer of the localized software who has purchased source code should augment all .java files within the /resource/ directory with the .java file specific for the relevant region; for example, for France, LocaleInfo.java becomes LocaleInfo_fr.java, and needs to contain the translated French versions of the Strings in the source LocaleInfo.java file. (Usually the file is called LocaleInfo.java, but can also have another name, such as LocaleBeanInfo.java or BeanLocaleInfo.java.)

Essentially, developers of the localized software create their own resource bundles for their own locale. Developers should check every package for a /resources/ directory; if one is found, then the .java files in it will need to be localized.

For more information on internationalization, go to: http://java.sun.com/j2se/1.4.2/docs/guide/intl/index.html.


PreviousNextIndex