RiskMapPlotModel: Plot Markers

A RiskMapPlotModel can modify plot markers by


As an alternative to using these techniques for changing plot markers, the ColorVariable, ShapeVariable, and SizeVariable variable roles in a RiskMapPlotTableDataModel can be used to control the markers according to the values of corresponding data columns in the graph's data source.

Assigning a MarkerStyle

To use the MarkerStyle class to set plot marker attributes (color, visibility, symbol, size),

  1. create a MarkerStyle array with the desired properties
  2. call the RiskMapPlotModel's getDataElementStyles() method to retrieve the DataElementStyles that encapsulate the visual properties of the plot markers
  3. call the DataElementStyles' setMarkerStyles() method to assign the defined MarkerStyle to the plot.

For example, the following code fragment specifies a filled square as the marker shape:

 
RiskMapPlotModel graphModel=riskMapPlot.getGraphModel();
MarkerStyle[] markerStyle=new MarkerStyle[] {
              new MarkerStyle(MarkerStyle.SYMBOL_SQUARE_FILLED)};
graphModel.getDataElementStyles().setMarkerStyles(markerStyle);

Example
Changing Markers in a RiskMap Plot: Swing-based code, Servlet-based code

Hiding Plot Markers

To hide plot markers, call the RiskMapPlotModel's setMarkerEnabled() method with the argument value false.

RiskMapPlotModel: Interpolation Lines

By default for a RiskMapPlotModel, plot markers are displayed but interpolation lines are not. To display interpolation lines, you must do both of the following:


For example, the following code fragment specifies interpolation lines:


RiskMapPlot riskMapPlot = new RiskMapPlot();
RiskMapPlotModel riskMapPlotModel = riskMapPlot.getGraphModel();

// Set interplations enabled so that data points are connected to each other.
   riskMapPlotModel.setInterpolationEnabled(true);

// Define a marker style
   MarkerStyle[] markerStyle=new MarkerStyle[] {
     new MarkerStyle(MarkerStyle.SYMBOL_SQUARE_FILLED)};

   riskMapPlotModel.getDataElementStyles().setMarkerStyles(markerStyle);
   markerStyle[0].setInterpolation(MarkerStyle.INTERPOLATION_VERTICAL_NEEDLES);
   riskMapPlotModel.getDataElementStyles().setMarkerStyles(markerStyles);

Example
Interpolation Lines: Swing-based code, Servlet-based code

RiskMapPlotModel: Line Styles

A RiskMapPlotModel can be used to modify the line style (color, width, visibility, ...) of any of the various lines in a RiskMapPlot.

The following table shows the lines you can set and the method(s) to call to access and/or set the line attributes.

To change ... Call ...
marker outlines getDataElementStyles().setOutlineLineStyle(LineStyle)
needle lines setNeedleLineStyle(LineStyle)
X axis lines
(axis, grid, tick, and reference lines)
getXAxisModel() and use the returned AxisModel to set axis line style, grid line styles, major tick styles, minor tick styles, and reference line models
Y axis lines
(axis, grid, tick, and reference lines)
getYAxisModel() and use the returned AxisModel to set axis line style, grid line styles, major tick styles, minor tick styles, and reference line models
legend frame getColorLegendModel().setFrameLineStyle(LineStyle)
missing-values lines getDataElementStyles().setMissingLineStyle(StrokeLineStyle)
column axis lines
(available when ColumnVariable role is used)
getColumnAxisModel().setFrameLineStyle(LineStyle)
row axis lines
(available when RowVariable role is used)
getRowAxisModel().setFrameLineStyle(LineStyle)
frame lines around column/row cells
(available when ColumnVariable and/or RowVariable roles are used)
setFrameLineStyle(LineStyle)

The following code fragment specifies 3-point gray lines for a plot's needle lines:


RiskMapPlotModel graphModel=riskMapPlot.getGraphModel();

LineStyle lineStyle = new LineStyle(
          Color.gray,
          new BaseLength(3, "pt"),
          GraphConstants.TRUE);

graphModel.setNeedleLineStyle(lineStyle);

Example
Change the Needle Lines: Swing-based code, Servlet-based code

RiskMapPlotModel: Behavior

RiskMapPlotModel properties are bound properties. Modifying a property triggers a PropertyChangeEvent. The RiskMapPlot asynchronously updates when a PropertyChangeEvent is received from the RiskMapPlotModel. Similarly, modifying a property in any of the RiskMapPlotModel's contained models triggers a PropertyChangeEvent. A PropertyChangeEvent from contained models will bubble up to cause a PropertyChangeEvent to be fired from the RiskMapPlotModel.

For example, the following call

 
riskMapPlotModel.getColorLegendModel().getValueTextStyle().setColor(java.awt.Color.yellow);

would cause the legend's value text style model to fire a "color" PropertyChangeEvent, causing legend model to fire a "valueTextStyle" PropertyChangeEvent, causing the RiskMapPlotModel to fire a "colorLegendModel" PropertyChangeEvent. This bubbling up of events enables the graph or any other listener to manage updates at a higher level of containment.