com.sas.servlet.tbeans.graphics
Class BasePieChart

com.sas.servlet.tbeans.graphics.BasePieChart
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:
PieChart

public class BasePieChart

The PieChart is a Swing component that uses a PieChartDataModel (data handle) and a PieChartModel (display properties) to produce a graphical, circular representation of the data.

Data

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

Display Properties

The PieChartModel properties define the display appearance. The PieChartModel contains PieChart 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 PieChart guarantees a non-null PieChartModel via the getGraphModel method. Passing a null parameter to the PieChart's setGraphModel method triggers an IllegalArgumentException. The PieChartModel properties can be modified directly.

For example:

 PieChart pieChart = new PieChart();
 PieChartModel pieChartModel = pieChart.getGraphModel();

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

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

However it may be simpler to modify the properties indirectly, by applying a GraphStyle via the applyGraphStyle method. The PieChartModel allows for a high degree of control over the PieChart'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 value text in the legend, subgroup and data element values), applying a GraphStyle on the PieChart 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 modified to provide the desired presentation. Applying a GraphStyle on a PieChart will modify some of the PieChartModel properties.

See Also:
Serialized Form

Constructor Summary
BasePieChart()
          Construct a PieChart using the default GraphStyle (GraphStyle.CONVENTION_STYLE).
 
Method Summary
 void applyColorScheme(ColorScheme scheme)
          Apply a color scheme to this graph's display attributes.
 void applyGraphStyle(GraphStyle graphStyle)
          Apply the GraphStyle display properties onto the PieChart.
 PieChartModel getGraphModel()
          Returns the PieChartModel that encapsulates most of the PieChart's display properties.
 ChartImageMapInfo getImageMapInfo()
          
Returns the image mapping of the pie chart.
 void setDataModel(PieChartDataModel newDataModel)
          Sets the PieChartDataModel which provides a handle to the data, along with associated mapping properties, to define the number and arrangement of data elements (i.e. slices).
 void setGraphModel(PieChartModel newPieChartModel)
          Sets a PieChartModel to define most of the PieChart'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

BasePieChart

public BasePieChart()
Construct a PieChart using the default GraphStyle (GraphStyle.CONVENTION_STYLE).

See Also:
GraphStyle
Method Detail

setGraphModel

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

Typically, applyGraphStyle is used to modify the graph's display properties.

Parameters:
newPieChartModel - the PieChartModel that encapsulates the PieChart's display properties
Throws:
java.lang.IllegalArgumentException - if newPieChartModel is null.
See Also:
getGraphModel(), PieChartModel.apply(com.sas.graphics.components.piechart.PieChartModel), GraphStyle

getGraphModel

public PieChartModel getGraphModel()
Returns the PieChartModel that encapsulates most of the PieChart's display properties.

Returns:
the PieChartModel that encapsulates most of the PieChart's display properties
See Also:
setGraphModel(com.sas.graphics.components.piechart.PieChartModel), PieChartModel.apply(com.sas.graphics.components.piechart.PieChartModel)

setDataModel

public void setDataModel(PieChartDataModel newDataModel)
Sets the PieChartDataModel which provides a handle to the data, along with associated mapping properties, to define the number and arrangement of data elements (i.e. slices).

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

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

A valid PieChartDataModel is required to draw a graph.

Parameters:
newDataModel - provides a handle to the data along with any associated mapping properties
See Also:
PieChartTableDataModel, PieChartOLAPDataModel

getImageMapInfo

public ChartImageMapInfo getImageMapInfo()

Returns the image mapping of the pie chart. The PieChartImageMapInfo class encapsulates the mapping of regions associated with pie elements, labels and values as projected onto the display area along with their associated data. This is particularly useful with creating html imagemap information if the graph is used to create an image for an html document.

Returns:
the mapping of regions associated with graph elements

applyColorScheme

public void applyColorScheme(ColorScheme scheme)
Apply a color scheme to this graph's display attributes. Note: ColorScheme is currently geared towards solid fill colors only. Changing gradient and image fills will have to be handled by the user directly on the graph models.

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

A blind PropertyChangeEvent is fired by the PieChart 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 PieChart
See Also:
NoteModel, PieChartModel



Copyright © 2009 SAS Institute Inc. All Rights Reserved.