JCCKit logo

1.3 Curves, Points, and Hints

In JCCKit the data to be visualized are organized in a collection of curves (represented by an instance of DataPlot). Curves (instances of DataCurve) are collections of 2-dimensional data points.

To generate a visual representation of a curve a concrete implementation of a CurveFactory is needed. SimpleCurveFactory is currently the only implemention.

With the help of CurveFactory an initially empty Curve will be generated. This is done inside Plot when either Plot is connected with a DataPlot or some data of the connected DataPlot has been changed. Currently SimpleCurve is the only implementation of the Curve interface.

Inside Plot, a curve is always (re)created from scratch even if only a single point in the curve has been changed. This is done by first removing all points in the Curve. Then, the points are added in the same sequence as they are stored in DataCurve. The concrete implementation of Curve creates a graphical representation which will be obtained with the method getView().

Generating a visual representations of DataCurve needs as input

  • the two-dimensional point (in device-independent coordinates),
  • information common for all curve points (like line color), and
  • optionally individual information for each point.
This individual information is needed, for example, in a bar chart. This is especially obvious in the case of stacked bars: Here the individual bar position depends on the size of the bar below.

Such individual informations are stored in a Hint object. For example, PositionHints are used to create bars at the correct positions. The Curve method addPoint() takes such a Hint for the calculation of the graphical representation of the added point. In addition it returns a Hint object for the point of the next curve with the same point index. This is illustrated by the upward arrows in the following diagram:

The initial Hint is the same for each point index. Its default value is null. In the case of bar charts it has to be specified in the Plot constructor.

How Hints are used depend on the actual implementation of Curve. Here we will discuss briefly SimpleCurve. In a SimpleCurve the curve points may connected by a Polygon. In addition each point may be decorated by a symbol. Hints are only needed for calculation of these symbols. In addition to curve-to-curve Hints they may be point-to-point Hints represented by horizontal arrows in the diagram above.

Symbols are generated by a SymbolFactory. It takes the point and the Hints from the previous point and curve to generate a symbol and Hints for the next point and curve. The result is wrapped in the returned Symbol object.