|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.graphics.components.scatterplot.ScatterPlot
public class ScatterPlot
The ScatterPlot component is a Swing component that produces scatter plots that support the visualization of multiple response variables by multiple independent variables. Two-dimensional scatter plots show the relationship of one variable to another, often revealing concentrations or trends in the data. Typically, each variable value on the horizontal axis can have any number of corresponding values on the vertical axis.
A ScatterPlot is similar to a LinePlot and differs as * follows:
Note. This class can be used to render client-side graphs in Java applications or applets. The com.sas.servlet.tbeans.graphics.html.ScatterPlot 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.
Variable
,
VariableList
,
PlotVariable
,
PlotVariableList
,
ClassificationVariable
,
ClassificationVariableList
,
ScatterPlotModel
,
ScatterPlotDataModel
,
ScatterPlotTableDataModel
,
ScatterPlotOLAPDataModel
,
Serialized FormField Summary | |
---|---|
static java.lang.String |
RB_KEY
|
protected java.awt.event.MouseListener |
scrollBarListener
|
Fields inherited from class com.sas.graphics.components.Graph |
---|
footnoteContainer, titleContainer |
Constructor Summary | |
---|---|
ScatterPlot()
Construct a ScatterPlot applying the default GraphStyle (GraphStyle.STYLE_CONVENTION). |
|
ScatterPlot(ScatterPlotDataModel scatterPlotDataModel)
Construct a ScatterPlot, assigning scatterPlotDataModel, and using the default GraphStyle (GraphStyle.STYLE_CONVENTION). |
|
ScatterPlot(ScatterPlotDataModel scatterPlotDataModel,
GraphStyle defaultGraphStyle)
Construct a ScatterPlot assigning scatterPlotDataModel and applying graphStyle. |
Method Summary | |
---|---|
void |
applyColorScheme(ColorScheme scheme)
Apply a color scheme on this Graph. |
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 ScatterPlot. |
ScatterPlotDataModel |
getDataModel()
Returns the ScatterPlotDataModel that provides a handle to the data along with any associated mapping properties. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to
augment the automatically introspected information about this ScatterPlot. |
ScatterPlotModel |
getGraphModel()
Returns the ScatterPlotModel that encapsulates most of the ScatterPlot's display properties. |
PlotImageMapInfo |
getImageMapInfo()
The PlotImageMapInfo 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. |
boolean |
isAnimationEnabled()
|
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 |
setAnimationEnabled(boolean enabled)
|
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(ScatterPlotDataModel newDataModel)
Sets the ScatterPlotDataModel which provides a handle to the data along with any associated mapping properties to define the number and arrangement of data elements (that is markers and lines), legend and axes. |
void |
setDisplayPolicy(int newDisplayPolicy)
Set how the graph is to utilize the display area. |
void |
setGraphModel(ScatterPlotModel newScatterPlotModel)
Sets a ScatterPlotModel to define most of the ScatterPlot's display properties. |
void |
setLocale(java.util.Locale locale)
Sets the locale of this component. |
protected void |
updateDataModelListeners()
Internal use only. |
Field Detail |
---|
public static final java.lang.String RB_KEY
protected java.awt.event.MouseListener scrollBarListener
Constructor Detail |
---|
public ScatterPlot()
public ScatterPlot(ScatterPlotDataModel scatterPlotDataModel)
A null ScatterPlotDataModel parameter is equivalent to using the default constructor.
scatterPlotDataModel
- the data to be used by this graphGraphStyle
,
ScatterPlotTableDataModel
,
ScatterPlotOLAPDataModel
public ScatterPlot(ScatterPlotDataModel scatterPlotDataModel, GraphStyle defaultGraphStyle)
scatterPlotDataModel
- provides a data handle with associated mapping propertiesdefaultGraphStyle
- the set of graph display propertiesNoteModel
,
ScatterPlotModel
,
ScatterPlotTableDataModel
,
ScatterPlotOLAPDataModel
Method Detail |
---|
public void setAnimationEnabled(boolean enabled)
public boolean isAnimationEnabled()
public void setDisplayPolicy(int newDisplayPolicy) throws java.lang.IllegalArgumentException
On the occasion when insufficient display area is available, the graph has to decide whether to use scroll bars and only display a portion of the graph or to draw the entire graph into the available space (shrinking and adjusting portions of the graph as best it can).
To allow scroll bars use the GraphConstants.DISPLAY_SCROLL_AS_NEEDED or specify GraphConstants.DISPLAY_FIT_TO_SCREEN to force the entire graph into the available display area. Specify GraphConstants.DISPLAY_SCROLL_ENABLED shows zoom scrollbars which appear when the display area is moused over and the chart is forced to show the entire graph in the available display area, however the use can then zoom and scroll to investigate the data further.
The default value is GraphConstants.DISPLAY_AUTOMATIC.
Valid values are:
GraphConstants.DISPLAY_FIT_TO_SCREEN
GraphConstants.DISPLAY_SCROLL_AS_NEEDED
GraphConstants.DISPLAY_SCROLL_ENABLED:
GraphConstants.DISPLAY_AUTOMATIC:
setDisplayPolicy
in class Graph
newDisplayPolicy
- how the Graph should utilize the dislay area
java.lang.IllegalArgumentException
- if newDisplayPolicy is invalid.Graph.getDisplayPolicy()
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 ScatterPlot graph = new ScatterPlot(); // 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 support 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 static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
com.sas.beans.Introspector
to
augment the automatically introspected information about this ScatterPlot.
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(ScatterPlotModel newScatterPlotModel) throws java.lang.IllegalArgumentException
Typically applyGraphStyle is used to modify the graphs display properties.
newScatterPlotModel
- the model that encapsulates the ScatterPlot's display properties
java.lang.IllegalArgumentException
- if newScatterPlotModel is null.getGraphModel()
,
ScatterPlotModel.apply(com.sas.graphics.components.scatterplot.ScatterPlotModel)
,
GraphStyle
public ScatterPlotModel getGraphModel()
setGraphModel(com.sas.graphics.components.scatterplot.ScatterPlotModel)
,
ScatterPlotModel.apply(com.sas.graphics.components.scatterplot.ScatterPlotModel)
public void setDataModel(ScatterPlotDataModel newDataModel)
Any change in the ScatterPlotDataModel properties will cause the ScatterPlot 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 ScatterPlot's paint behavior is needed.
Note: Data value changes will also trigger ScatterPlot to update.
A valid ScatterPlotDataModel is required to draw a graph.
newDataModel
- provides a handle to the data
along with any associated mapping propertiesgetDataModel()
,
ScatterPlotTableDataModel
,
ScatterPlotOLAPDataModel
public ScatterPlotDataModel getDataModel()
setDataModel(com.sas.graphics.components.scatterplot.ScatterPlotDataModel)
,
ScatterPlotTableDataModel
,
ScatterPlotOLAPDataModel
public void applyGraphStyle(GraphStyle graphStyle)
Some GraphStyle properties like the background fill style will be applied to the ScatterPlot's ScatterPlotModel (thus affecting the ScatterPlotAppearance). Other GraphStyle properties like the title1 text style will be applied to properties on other ScatterPlot models such as the ScatterPlot's title1 NoteModel in this example.
The GraphStyle enforces certain constraints that are not enforced on a Graph. For example the ScatterPlot supports setting different axis value text styles on different axes (via the ScatterPlotModel's x and y AxisModels) whereas a GraphStyle only supports a single axis value text style property. When a GraphStyle is applied to a ScatterPlot all of the ScatterPlot's axes values use the GraphStyle axis value setting (thus easily enforcing that all axes values are represented in the same font and color). The use of the GraphStyle allows for easier graph customizations while the ScatterPlot models allow for greater customizations when desired.
Modifying any of the properties in the GraphStyle after this call will have no affect on the ScatterPlot. Likewise modifying any ScatterPlot properties after this call will have no affect on the GraphStyle. This method simply conveys the properties in the GraphStyle onto the ScatterPlot properties.
A blind PropertyChangeEvent will be fired by the ScatterPlot after the apply is made.
No action will be taken if a null GraphStyle is passed in.
applyGraphStyle
in class Graph
graphStyle
- the set of graph display propertiespublic void applyColorScheme(ColorScheme scheme)
applyColorScheme
in class Graph
scheme
- ColorScheme object containing a set of colors for the charts.public PlotImageMapInfo getImageMapInfo()
protected void applyDataModel()
Graph
applyDataModel
in class Graph
protected void applyGraphModel()
applyGraphModel
in class Graph
protected void selectionChanged()
selectionChanged
in class Graph
protected void updateDataModelListeners()
updateDataModelListeners
in class Graph
Graph.updateDataModelListeners(Object model, Object selectionModel)
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |