com.sas.graphics.components.radarchart
Class RadarChart

com.sas.graphics.components.radarchart.RadarChart
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class RadarChart

The RadarChart component is a Swing component that produces radar charts that show the relative frequency of data measures in quality control or market research problems. Chart statistics are displayed along spokes that radiate from the center of the chart.

Note. This class can be used to render client-side graphs in Java applications or applets. The com.sas.servlet.tbeans.graphics.html.RadarChart class can be used to render server-side graphs in Java servlets or JavaServer Pages (JSP). Both classes use the models in the com.sas.graphics.components package.

Topics:
Minimum Specification
Functional Overview
Data Access
Display Properties
Titles and Footnotes
Usage Examples
Behavior

Swing-based Samples

Since:
SAS 9.1
See Also:
Graph, GraphStyle, NoteModel, RadarChartModel, RadarChartDataModel, RadarChartTableDataModel, RadarChartOLAPDataModel, Serialized Form

Field Summary
 
Fields inherited from class com.sas.graphics.components.Graph
footnoteContainer, RB_KEY, titleContainer
 
Constructor Summary
RadarChart()
          Construct a RadarChart using the default GraphStyle (GraphStyle.STYLE_CONVENTION).
RadarChart(RadarChartDataModel radarChartDataModel)
          Construct a RadarChart, assigning radarChartDataModel, and using the default GraphStyle (GraphStyle.STYLE_CONVENTION).
RadarChart(RadarChartDataModel radarChartDataModel, GraphStyle defaultGraphStyle)
          Construct a RadarChart assigning radarChartDataModel and applying graphStyle.
 
Method Summary
 void applyColorScheme(ColorScheme scheme)
          Apply a color scheme to this graph's display attributes.
protected  void applyDataModel()
          Intended for internalUse only
protected  void applyGraphModel()
          For internal use only.
 void applyGraphStyle(GraphStyle graphStyle)
          Apply the GraphStyle display properties onto the RadarChart.
 RadarChartDataModel getDataModel()
          Returns the RadarChartDataModel that provides data properties.
 RadarChartModel getGraphModel()
          Returns the RadarChartModel that encapsulates most of the RadarChart's display properties.
 boolean isAutoRepaintEnabled()
          Returns whether or not the graph automatically repaints when any of its properties (contained in associated models GraphModel, DataModel, NoteModel, etc) has changed.
 void prepareToPaint()
          Notify this component that an application is about to call paint directly.
protected  void selectionChanged()
          Internal use only.
 void setAutoRepaintEnabled(boolean b)
          Sets whether or not the graph automatically repaints when any of its properties (contained in associated models GraphModel, DataModel, NoteModel, etc) has changed.
 void setDataModel(RadarChartDataModel newDataModel)
          Sets the RadarChartDataModel which provides data properties along with any associated mapping properties to define the number and arrangement of data elements, legend and axes.
 void setGraphModel(RadarChartModel newRadarChartModel)
          Sets a RadarChartModel to define most of the RadarChart's display properties.
protected  void updateDataModelListeners()
          Internal use only.
 
Methods inherited from class com.sas.graphics.components.Graph
addActionListener, addMouseListener, addMouseMotionListener, addMouseMotionListener, clearSelection, firePropertyChange, getActionProvider, getAppliedColorSchemeName, getAppliedGraphStyleName, getBackground, getBrushBounds, getChannel, getContentsChangedListener, getDefaultGraphStyle, getDefaultHeight, getDefaultWidth, getDisplayPolicy, getFooter, getFootnote, getFootnote1, getFootnote2, getHeader, getListSelectionListener, getLocale, getMessageModel, getMinimumSize, getPreferredSize, getTableModelListener, getTitle, getTitle1, getTitle2, getTitle3, getTitle4, isAppliedGraphStyleModified, paint, paintAll, paintBackground, pick, pick, pickSelected, removeActionListener, select, select, select, select, setActionProvider, setBackground, setBounds, setDisplayPolicy, setFooter, setFootnote, setFootnote1, setFootnote2, setHeader, setMessageModel, setPaintContext, setTitle, setTitle1, setTitle2, setTitle3, setTitle4, update, updateDataModelListeners, validateTree
 

Constructor Detail

RadarChart

public RadarChart()
Construct a RadarChart using the default GraphStyle (GraphStyle.STYLE_CONVENTION).

See Also:
GraphStyle

RadarChart

public RadarChart(RadarChartDataModel radarChartDataModel)
Construct a RadarChart, assigning radarChartDataModel, and using the default GraphStyle (GraphStyle.STYLE_CONVENTION). The RadarChartDataModel is accessible via the getDataModel method.

A null RadarChartDataModel parameter is equivalent to using the default constructor.

Parameters:
radarChartDataModel - the data to be used by this graph
See Also:
GraphStyle, RadarChartTableDataModel, RadarChartOLAPDataModel

RadarChart

public RadarChart(RadarChartDataModel radarChartDataModel,
                  GraphStyle defaultGraphStyle)
Construct a RadarChart assigning radarChartDataModel and applying graphStyle. The RadarChartDataModel is accessible via the getDataModel method. The RadarChartModel (whose properties are affected by the GraphStyle application) is accessible via the getGraphModel method. The NoteModels (whose properties are affected by the GraphStyle application) are accessible via the getTitle and getFootnote methods. A null RadarChartDataModel parameter is equivalent to setDataModel(null); If graphStyle is null then GraphStyle.STYLE_CONVENTION will be applied.

Parameters:
radarChartDataModel - provides data properties
defaultGraphStyle - the set of graph display properties
See Also:
NoteModel, RadarChartModel, RadarChartTableDataModel, RadarChartOLAPDataModel
Method Detail

prepareToPaint

public void prepareToPaint()
Notify this component that an application is about to call paint directly. This method is useful when attempting to get the Graph to draw into an image (or other application provided GraphicsContext).

As per java standard practices; "paint" should never be called directly by an application. However if it is necessary to render the Graph directly then the use of paintAll(Graphics) or printAll(Graphics) is acceptable.

Graphs asynchronously update to keep their view in sync with their model properties (Graphmodel, DataModel, NoteModel etc.). A direct call to paintAll or printAll does not allow for the graph to asynchronously sync up with their model proeprties. prepareToPaint provides this synchronization point necessary for the Graphs to update their component structure as needed.

Note: Used in a headless environment, Graphs will never asynchronously update and therefore require a call to prepareToPaint to render into a GraphicsContext.

The headless and non-headless cases can be handled slightly differently. In the non-headless case the asynchronous updating needs to be halted. This is done by setting the "autoRepaintEnabled" property to false. The default for autoRepaintEnabled is true, allowing the graph to automatically resync and repaint as model properties are modified.

Example writing to an image. Note for readability exception handling has been ignored.

 static public void main(String args[])
 {
    BufferedImage bi = new BufferedImage(640,480,BufferedImage.TYPE_INT_RGB);
    Graphics ig = bi.createGraphics();

    // Create Graph
    RadarChart graph = new RadarChart();
 
    // This call is not necessary if you are running in a headless environment.
    graph.setAutoRepaintEnabled(false);
    
    // ... assign data and model properties here ...
    graph.setDataModel(newGraphData());
    
    {// Render sequence
        graph.setBounds(0,0,bi.getWidth(null),bi.getHeight(null)); // Define the size of the Graph
        graph.addNotify(); // Makes the component displayable.
        graph.prepareToPaint(); // do property synchronization
        graph.paintAll(ig); // render into some graphics context
    }
 
    // Dispose of image graphics context
    ig.dispose();                
    
    // Save immage to disk
    File file = new File("graph.jpg");
    try
    {
        ImageIO.write(bi, "jpg", file);
    }
    catch (IOException e)
    {
        System.out.println("ImageIO.write failed.");
    }
 }
 

Specified by:
prepareToPaint in class Graph

setAutoRepaintEnabled

public void setAutoRepaintEnabled(boolean b)
Sets whether or not the graph automatically repaints when any of its properties (contained in associated models GraphModel, DataModel, NoteModel, etc) has changed. The default value is true.

The setting of this property to false implies that the application will be responsible for synchronizing the graph with its models using the prepareToPaint method.

This method was added to suport rendering into an off screen graphics context such as an image.

Specified by:
setAutoRepaintEnabled in class Graph
Parameters:
b - true means to automatically update
See Also:
isAutoRepaintEnabled()

isAutoRepaintEnabled

public boolean isAutoRepaintEnabled()
Returns whether or not the graph automatically repaints when any of its properties (contained in associated models GraphModel, DataModel, NoteModel, etc) has changed.

Specified by:
isAutoRepaintEnabled in class Graph
See Also:
setAutoRepaintEnabled(boolean)

setGraphModel

public void setGraphModel(RadarChartModel newRadarChartModel)
                   throws java.lang.IllegalArgumentException
Sets a RadarChartModel to define most of the RadarChart's display properties. Modifying any RadarChartModel property triggers the RadarChart 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 RadarChart's paint behavior is necessary.

Typically applyGraphStyle is used to modify the graphs display properties.

Parameters:
newRadarChartModel - the RadarChartModel that encapsulates the RadarChart's display properties
Throws:
java.lang.IllegalArgumentException - if newRadarChartModel is null.
See Also:
getGraphModel(), RadarChartModel.apply(com.sas.graphics.components.radarchart.RadarChartModel), GraphStyle

getGraphModel

public RadarChartModel getGraphModel()
Returns the RadarChartModel that encapsulates most of the RadarChart's display properties.

Returns:
the RadarChartModel that encapsulates most of the RadarChart's display properties
See Also:
setGraphModel(com.sas.graphics.components.radarchart.RadarChartModel), RadarChartModel.apply(com.sas.graphics.components.radarchart.RadarChartModel)

setDataModel

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

Any change in the RadarChartDataModel properties will cause the RadarChart 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 RadarChart's paint behavior is needed.

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

A valid RadarChartDataModel is required to draw a graph.

Parameters:
newDataModel - provides data properties
See Also:
getDataModel(), RadarChartTableDataModel, RadarChartOLAPDataModel

getDataModel

public RadarChartDataModel getDataModel()
Returns the RadarChartDataModel that provides data properties.

Returns:
the RadarChartDataModel that provides data properties
See Also:
setDataModel(com.sas.graphics.components.radarchart.RadarChartDataModel), RadarChartTableDataModel, RadarChartOLAPDataModel

applyDataModel

protected void applyDataModel()
Description copied from class: Graph
Intended for internalUse only

Specified by:
applyDataModel in class Graph

applyGraphModel

protected void applyGraphModel()
For internal use only.

Overrides:
applyGraphModel in class Graph

applyGraphStyle

public void applyGraphStyle(GraphStyle graphStyle)
Apply the GraphStyle display properties onto the RadarChart. The use of this method is a convenient way to quickly and easily affect the RadarChart's appearance. The RadarChartModel (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 (RadarChartModel and NoteModels). For example only one value text color may be specified on the GraphStyle, whereas the RadarChartModel supports setting 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 RadarChartModel and the title and footnote NoteModels. The RadarChart 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 RadarChart. Similarly modifying any of RadarChart's display properties after this method has been called will have no affect on the GraphStyle properties. To affect any change in the RadarChart display appearance the modified GraphStyle or a different GraphStyle would need to be applied again.

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

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

Overrides:
applyGraphStyle in class Graph
Parameters:
graphStyle - the GraphStyle whose properties are conveyed to the RadarChart
See Also:
NoteModel, RadarChartModel

applyColorScheme

public void applyColorScheme(ColorScheme scheme)
Apply a color scheme to this graph's display attributes.

Overrides:
applyColorScheme in class Graph
Parameters:
scheme - ColorScheme object containing a set of colors for the charts.

selectionChanged

protected void selectionChanged()
Internal use only.

Specified by:
selectionChanged in class Graph

updateDataModelListeners

protected void updateDataModelListeners()
Internal use only.

Specified by:
updateDataModelListeners in class Graph
See Also:
Graph.updateDataModelListeners(Object model, Object selectionModel)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.