|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.graphics.components.tilechart.TileChart
public class TileChart
The TileChart component is a Swing component that produces a rectangular tree-based representation of data. Tile charts represent requested statistics that are based on a list of categorical variables. They are useful for displaying relative magnitudes within the hierachy.
For example, a tile chart might be used to represent sales data where the tile sizes vary according to the size of product inventories and the tile colors are derived from a color gradient that represents low to high sales figures.
Tile charts are well suited to representing strucured data because they automatically provide the capability to zoom to detail levels in the data. For example, in a tile chart that graphs sales data for the categorical variables Region, Product, and Subsidiary, the top-layer chart would show sales regions. When you select one of the regions, the chart will zoom in to show the products sold within that regions. When you select one of the products, the chart will zoom to show the subsidiaries that sell that product.
Note. This class can be used to render client-side graphs in Java applications or applets. The com.sas.servlet.tbeans.graphics.html.TileChart 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.
Graph
,
GraphStyle
,
NoteModel
,
TileChartModel
,
TileChartDataModel
,
TileChartTableDataModel
,
Serialized FormField Summary |
---|
Fields inherited from class com.sas.graphics.components.Graph |
---|
footnoteContainer, RB_KEY, titleContainer |
Constructor Summary | |
---|---|
TileChart()
Construct a TileChart using the default GraphStyle (GraphStyle.STYLE_CONVENTION). |
|
TileChart(TileChartDataModel tileChartDataModel)
Construct a TileChart, assigning tileChartDataModel, and using the default GraphStyle (GraphStyle.STYLE_CONVENTION). |
|
TileChart(TileChartDataModel tileChartDataModel,
GraphStyle defaultGraphStyle)
Construct a TileChart assigning tileChartDataModel 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 display properties in the GraphStyle to the TileChart. |
java.lang.String[] |
getCurrentRootTile()
Deprecated. use getRootPath() |
TileChartDataModel |
getDataModel()
Returns the TileChartDataModel that provides a handle to the data along with any associated mapping properties. |
TileChartModel |
getGraphModel()
Returns the TileChartModel that encapsulates most of the TileChart's display properties. |
java.lang.String[] |
getIDLabels()
Returns a list of TILE labels (either user-set TILE or auto selected). |
ChartImageMapInfo |
getImageMapInfo()
Returns the image mapping of the tile chart. |
javax.swing.tree.DefaultMutableTreeNode |
getRootNode()
|
java.lang.String[] |
getRootPath()
Returns the list of tiles from the base of the data tree to the current visible root tile. |
java.lang.String[] |
getRootTile()
Deprecated. use setCurrentRootTile() |
java.lang.String[] |
getTileAtPosition(java.awt.geom.Point2D p)
Deprecated. Let me know if you need this |
java.lang.String[] |
getTileValues()
Returns a list of lowest level tile values, with duplicate values removed. |
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 |
setCurrentRootTile(java.lang.String[] tileValues)
Deprecated. use setRootPath() |
void |
setDataModel(TileChartDataModel newDataModel)
Sets the TileChartDataModel which provides a data source along with associated mapping properties to define the number and arrangement of data elements (tiles), legend and axes. |
void |
setDisplayPolicy(int newDisplayPolicy)
setDisplayPolicy is unsupported by TileChart, since it is always assumed to be DISPLAY_FIT_TO_SCREEN. |
void |
setGraphModel(TileChartModel newTileChartModel)
Sets a TileChartModel to define most of the TileChart's display properties. |
void |
setLocale(java.util.Locale locale)
Sets the locale of this component. |
void |
setRootPath(java.lang.String[] tileValues)
Set the tile to display as the root of the chart. |
void |
setRootTile(java.lang.String[] tileValues)
Deprecated. use setCurrentRootTile() |
protected void |
updateDataModelListeners()
Internal use only. |
Constructor Detail |
---|
public TileChart()
GraphStyle
public TileChart(TileChartDataModel tileChartDataModel)
A null TileChartDataModel parameter is equivalent to using the default constructor.
tileChartDataModel
- the data to be used by this graphGraphStyle
,
TileChartTableDataModel
public TileChart(TileChartDataModel tileChartDataModel, GraphStyle defaultGraphStyle)
tileChartDataModel
- provides a data handle with associated mapping propertiesdefaultGraphStyle
- the set of graph display propertiesNoteModel
,
TileChartModel
,
TileChartTableDataModel
Method Detail |
---|
public void prepareToPaint()
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 TileChart graph = new TileChart(); // 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."); } }
prepareToPaint
in class Graph
public void setAutoRepaintEnabled(boolean b)
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.
setAutoRepaintEnabled
in class Graph
b
- true means to automatically updateisAutoRepaintEnabled()
public boolean isAutoRepaintEnabled()
isAutoRepaintEnabled
in class Graph
setAutoRepaintEnabled(boolean)
public void setLocale(java.util.Locale locale)
setLocale
in class java.awt.Component
locale
- the locale to become this component's localeGraph.getLocale()
public void setGraphModel(TileChartModel newTileChartModel) throws java.lang.IllegalArgumentException
Typically applyGraphStyle is used to modify the graphs display properties.
newTileChartModel
- the TileChartModel that encapsulates the TileChart's display properties
java.lang.IllegalArgumentException
- if newTileChartModel is null.getGraphModel()
,
TileChartModel.apply(com.sas.graphics.components.tilechart.TileChartModel)
,
GraphStyle
public TileChartModel getGraphModel()
setGraphModel(com.sas.graphics.components.tilechart.TileChartModel)
,
TileChartModel.apply(com.sas.graphics.components.tilechart.TileChartModel)
protected void applyGraphModel()
applyGraphModel
in class Graph
public void setDataModel(TileChartDataModel newDataModel)
Any change in the TileChartDataModel properties will cause the TileChart 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 TileChart's paint behavior is needed.
Note: Data value changes will also trigger TileChart to update.
A valid TileChartDataModel is required to draw a graph.
newDataModel
- provides a handle to the data
along with any associated mapping propertiesgetDataModel()
,
TileChartTableDataModel
public TileChartDataModel getDataModel()
setDataModel(com.sas.graphics.components.tilechart.TileChartDataModel)
,
TileChartTableDataModel
public ChartImageMapInfo getImageMapInfo()
public void setRootPath(java.lang.String[] tileValues)
tileValues
- a String array with one level name contained in each string, from the base of the
tree to the desired, current root tile.getRootPath()
public java.lang.String[] getRootPath()
setRootPath(java.lang.String[])
public javax.swing.tree.DefaultMutableTreeNode getRootNode()
public void setCurrentRootTile(java.lang.String[] tileValues)
public java.lang.String[] getCurrentRootTile()
public void setRootTile(java.lang.String[] tileValues)
public java.lang.String[] getRootTile()
public java.lang.String[] getTileAtPosition(java.awt.geom.Point2D p)
protected void applyDataModel()
Graph
applyDataModel
in class Graph
public void applyGraphStyle(GraphStyle graphStyle)
Some GraphStyle properties like the background fill style will be applied to the TileChart's TileChartModel (thus affecting the TileChartAppearance). Other GraphStyle properties like the title1 text style will be applied to properties on other TileChart models such as the TileChart's title1 NoteModel.
The GraphStyle enforces certain constraints that are not enforced on a Graph. For example the TileChart supports setting different value text styles at different id levels, whereas a GraphStyle only supports a single display value text style property. When a GraphStyle is applied to a TileChart all of the TileChart's display values use the GraphStyle axis value setting (thus easily enforcing that all display values are represented in the same font and color). The use of the GraphStyle allows for easier graph customizations while the TileChart models allow for greater customization when desired.
Modifying any of the properties in the GraphStyle after this call will have no affect on the TileChart. Likewise modifying any TileChart properties after this call will have no affect on the GraphStyle. This method simply conveys the properties in the GraphStyle onto the TileChart properties.
A blind PropertyChangeEvent will be fired by the TileChart after the apply is made.
No action will be taken if a null GraphStyle is passed in.
applyGraphStyle
in class Graph
graphStyle
- the GraphStyle whose properties are conveyed to the TileChartpublic void applyColorScheme(ColorScheme scheme)
applyColorScheme
in class Graph
scheme
- ColorScheme object containing a set of colors for the charts.public java.lang.String[] getTileValues()
public java.lang.String[] getIDLabels()
protected void selectionChanged()
selectionChanged
in class Graph
protected void updateDataModelListeners()
updateDataModelListeners
in class Graph
Graph.updateDataModelListeners(Object model, Object selectionModel)
public void setDisplayPolicy(int newDisplayPolicy) throws java.lang.IllegalArgumentException
setDisplayPolicy
in class Graph
newDisplayPolicy
- how the Graph should utilize the dislay area
java.lang.IllegalArgumentException
- if newDisplayPolicy is invalid.Graph.getDisplayPolicy()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |