com.sas.servlet.tbeans.graphics
Class BaseLinePlot

com.sas.servlet.tbeans.graphics.BaseLinePlot
All Implemented Interfaces:
ActionProviderViewInterface, HttpActionProviderInterface, HttpActionProviderViewInterface, com.sas.beans.PropertyChangeSource, com.sas.lang.ObjectDataInterface, com.sas.servlet.tbeans.features.FeatureListInterface, RenderableInterface, TransformationInterface, com.sas.util.WriteToPrintWriterInterface, java.io.Serializable
Direct Known Subclasses:
LinePlot

public class BaseLinePlot

The LinePlot is a Swing component that uses a LinePlotDataModel (data handle) and a LinePlotModel (display properties) to produce a interpolated line. Markers can be used to represent data points.

Data

The number and arrangement of data elements (i.e. markers and lines), axes and legend is determined by the LinePlotDataModel (assigned via the setDataModel method) which provides a handle to data and associated mapping properties. To illustrate the LinePlotTableDataModel is used to assign a Swing TableModel along with a collection of variable properties to define the data column mapping onto the graph. The LinePlotOLAPDataModel is used to assign OLAP data via a com.sas.storage.olap.OLAPDataSetInterface.

Display Properties

The LinePlotModel properties define the display appearance. The LinePlotModel contains LinePlot specific properties, common graph properties and a collection of contained models (which provide display properties for sub-portions of the graph such as the legend). The LinePlot guarantees a non-null LinePlotModel via the getGraphModel method. Passing a null parameter to the LinePlot's setGraphModel method triggers an IllegalArgumentException. The LinePlotModel properties can be modified directly.

For example:

 LinePlot linePlot = new LinePlot();
 LinePlotModel linePlotModel = linePlot.getGraphModel();

 // Assign background color
 linePlotModel.setBackgroundFillStyle(new FillStyle(Color.lightGray));

 // Assign data element outline color
 linePlotModel.getDataElementStyles().getOutlineLineStyle().setColor(Color.yellow);

 // Define a new set of line styles and set their width to 3 pixels and colors to [red, blue, green].
 StrokeLineStyle[] lineStyles = new LineStyle[] { new StrokeLineStyle(new BasicStroke(3), Color.red)
                                                , new StrokeLineStyle(new BasicStroke(3), Color.green)
                                                , new StrokeLineStyle(new BasicStroke(3), Color.blue)
                                                };
 linePlotModel.getDataElementStyles().setLineStyles(lineStyles);
  
 // Set markers enabled so that markers are displayed at the data points.
 linePlotModel.setMarkerEnabled(true);

 // Define a new set of marker styles and modify interpolation
 MarkerStyle[] markerStyles = new MarkerStyle[] { new MarkerStyle(MarkerStyle.UP_BOLD, Color.red)
                                                , new MarkerStyle(MarkerStyle.DOWN_BOLD, Color.green)
                                                , new MarkerStyle(MarkerStyle.X_BOLD, Color.blue)
                                                };
 markerStyle[0].setInterpolation(com.sas.graphics.components.MarkerStyle.INTERPOLATION_STRAIGHT);
 linePlotModel.getDataElementStyles().setMarkerStyles(markerStyles);
 

However it may be simpler to modify the properties indirectly by applying a GraphStyle via the applyGraphStyle method. The LinePlotModel allows for a high degree of control over the LinePlot's appearance. Because of the large number of display properties and the repetitive nature of some of the properties (for example: there are text style properties for the values text in the legend, x axis, y axis and data element values) applying a GraphStyle on the LinePlot may be the simplest way to obtain the desired results. A GraphStyle is a collection of graph properties that can be applied to any graph. Several predefined GraphStyles are provided and can be used as is or tweaked to provide the desired presentation. Applying a GraphStyle on a LinePlot will modify some of the LinePlotModel properties.

See Also:
Serialized Form

Constructor Summary
BaseLinePlot()
          Construct a LinePlot using the default GraphStyle (GraphStyle.CONVENTION_STYLE).
 
Method Summary
 void applyColorScheme(ColorScheme scheme)
          Apply a color scheme on this Graph.
 void applyGraphStyle(GraphStyle graphStyle)
          Apply the GraphStyle display properties onto the LinePlot.
 LinePlotModel getGraphModel()
          Returns the LinePlotModel that encapsulates most of the LinePlot's display properties.
 PlotImageMapInfo getImageMapInfo()
          
The LinePlotImageMapInfo class encapsulates the mapping of regions associated with marker and line elements, labels (for both axes and legends) and values (for both axes and legends) as projected onto the display area along with their associated data.
 void setDataModel(LinePlotDataModel newDataModel)
          Sets the LinePlotDataModel which provides the data properties along with any associated mapping properties to define the number and arrangement of data elements (markers and lines), legends and axes.
 void setGraphModel(LinePlotModel newLinePlotModel)
          Sets a LinePlotModel to define most of the LinePlot's display properties.
 
Methods inherited from class com.sas.servlet.tbeans.BaseActionTransformation
dispose, getActionProvider, getActionSupportType, getUniqueId, isActionVisible, listActionTypes, listAreaTypes, setActionProvider, setActionSupportType, setActionVisible, setUniqueId, write
 
Methods inherited from class com.sas.servlet.tbeans.BaseTransformation
addPropertyChangeListener, addPropertyChangeListener, cleanUpResources, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCustomAttributes, getDescription, getId, getInputTransform, getLocale, getName, getObjectData, getObjectDataProperty, getOutputTransform, getRequest, getResponse, getTagEpilog, getTagProlog, hasListeners, isCleanUpResourcesOn, isVisible, removePropertyChangeListener, removePropertyChangeListener, setCleanUpResourcesOn, setCustomAttributes, setDescription, setId, setInputTransform, setLocale, setLocaleDependentProperties, setName, setObjectData, setObjectDataProperty, setOutputTransform, setRequest, setResponse, setTagEpilog, setTagProlog, setVisible, toString, write, write, write
 
Methods inherited from interface com.sas.actionprovider.HttpActionProviderViewInterface
getRequest, setRequest
 

Constructor Detail

BaseLinePlot

public BaseLinePlot()
Construct a LinePlot using the default GraphStyle (GraphStyle.CONVENTION_STYLE).

See Also:
GraphStyle
Method Detail

setGraphModel

public void setGraphModel(LinePlotModel newLinePlotModel)
                   throws java.lang.IllegalArgumentException
Sets a LinePlotModel to define most of the LinePlot's display properties. Modifying any LinePlotModel property triggers the LinePlot to update. The update is asynchronous and delayed so modifying multiple properties in quick succession will result in only a single update. Use the FullPaintInterface if greater control over the LinePlot's paint behavior is necessary.

Typically applyGraphStyle is used to modify the graphs display properties.

Parameters:
newLinePlotModel - the LinePlotModel that encapsulates the LinePlot's display properties
Throws:
java.lang.IllegalArgumentException - if newLinePlotModel is null.
See Also:
getGraphModel(), LinePlotModel.apply(com.sas.graphics.components.lineplot.LinePlotModel), GraphStyle

setDataModel

public void setDataModel(LinePlotDataModel newDataModel)
Sets the LinePlotDataModel which provides the data properties along with any associated mapping properties to define the number and arrangement of data elements (markers and lines), legends and axes.

Any change in the LinePlotDataModel properties will cause the LinePlot to update. The update is asynchronous and delayed so modifying multiple properties in quick succession will result in only a single update. The FullPaintInterface can be used if greater control over the LinePlot's paint behavior is needed.

Note: Data value changes will also trigger LinePlot to update.

A valid LinePlotDataModel is required to draw a graph.

Parameters:
newDataModel - provides the data properties along with any associated mapping properties
See Also:
LinePlotTableDataModel, LinePlotOLAPDataModel

getGraphModel

public LinePlotModel getGraphModel()
Returns the LinePlotModel that encapsulates most of the LinePlot's display properties.

Returns:
the LinePlotModel that encapsulates most of the LinePlot's display properties
See Also:
setGraphModel(com.sas.graphics.components.lineplot.LinePlotModel), LineChartModel.apply(com.sas.graphics.components.linechart.LineChartModel)

getImageMapInfo

public PlotImageMapInfo getImageMapInfo()

The LinePlotImageMapInfo class encapsulates the mapping of regions associated with marker and line elements, labels (for both axes and legends) and values (for both axes and legends) as projected onto the display area along with their associated data.

Returns:
the mapping of regions associated with marker and line elements, labels (for both axes and legends) and values (for both axes and legends) as projected onto the display area along with their associated data.

applyColorScheme

public void applyColorScheme(ColorScheme scheme)
Apply a color scheme on this Graph.

Overrides:
applyColorScheme in class com.sas.servlet.tbeans.graphics.BaseGraph
Parameters:
scheme - class containing a set of colors for the charts.

applyGraphStyle

public void applyGraphStyle(GraphStyle graphStyle)
Apply the GraphStyle display properties onto the LinePlot. The use of this method is a convenient way to quickly and easily affect the LinePlot's appearance. The LinePlotModel (accessible via the getGraphModel method) properties and the NoteModels (accessible via the getTitle and getFootnote methods) properties are modified by this method.

The GraphStyle enforces certain constraints that are not enforced on the Graph's display models (LinePlotModel and NoteModels). For example only one value text color may be specified on the GraphStyle, whereas the LinePlotModel supports se tting different value text colors between axes, legends and data element text. Most presentations only require a single color for all types of value text, which is easily achieved by applying a GraphStyle.

Applying a GraphStyle will modify the display properties of the LinePlotModel and the title and footnote NoteModels. The LinePlot does not retain a link to the GraphStyle after this method has been called. Modifying any of the GraphStyle properties after this method has been called will have no affect on the LinePlot. Similarly modifying any of LinePlot's display properties after this method has been called will have no affect on the GraphStyle properties. To affect any change in the LinePlot display appearance the modified GraphStyle or a different GraphStyle would need to be applied again.

A blind PropertyChangeEvent is fired by the LinePlot after the apply is made.

No action is taken if a null GraphStyle is passed in.

Overrides:
applyGraphStyle in class com.sas.servlet.tbeans.graphics.BaseGraph
Parameters:
graphStyle - the GraphStyle whose properties are conveyed to the LinePlot
See Also:
NoteModel, LinePlotModel



Copyright © 2009 SAS Institute Inc. All Rights Reserved.