com.sas.graphics.components.scatterplot
Class ScatterPlotTableDataModel

com.sas.graphics.components.scatterplot.ScatterPlotTableDataModel

public class ScatterPlotTableDataModel

A ScatterPlotTableDataModel encapsulates relational data from a javax.swing.table.TableModel and maps the TableModel's data columns onto a ScatterPlot component. To do the mapping, it assigns variable roles to the columns that will be used in the graph, and the assigned roles determine how the ScatterPlot displays the data.

When generating a graph, a ScatterPlot does not summarize the data from a ScatterPlotTableDataModel.

Topics:
Basic Plots
Plot Markers
Labels for Plot Points
Data Groups
High, Low, and Error Values
Multiple Plots, Same Axes
Multiple Plots in Columns and/or Rows
Valid Variable Roles for a ScatterPlotTableDataModel
Behavior
Events
Error Handling
Samples:
Swing-based Samples
Servlet-based Samples

Since:
SAS 9.1
See Also:
ScatterPlot, Variable, PlotVariable, PlotVariableList, Variable, VariableList

Constructor Summary
ScatterPlotTableDataModel()
          Default Constructor
ScatterPlotTableDataModel(javax.swing.table.TableModel newModel)
          Constructor with assigned data model
 
Method Summary
 void apply(ScatterPlotTableDataModel theOtherModel)
          Utility method to convey properties contained in "theOtherObject" to this object.
 boolean equals(java.lang.Object obj)
          Determines whether another object is equal to this ScatterPlotTableDataModel.
 Variable[] getAuxiliaryVariable()
          Returns the array of data columns that was most recently set by the setAuxiliaryVariable() method.
 Variable getBottomMarkerLabelVariable()
          Returns the data column that was most recently set in the BottomMarkerLabel role by the setBottomMarkerLabelVariable() method.
 Variable getColorVariable()
          Returns the data column that was most recently set in the Color role by the setColorVariable() method.
 ClassificationVariable getColumnVariable()
          Returns the data column that was most recently set in the Column role by the setColumnVariable() method.
 Variable[] getDataTipVariable()
          Returns the array of data columns that was most recently set by the setDataTipVariable() method.
 ClassificationVariable getGroupVariable()
          Returns the data column that was most recently set in the Group role by the setGroupVariable() method.
 javax.swing.table.TableModel getModel()
          Returns the data model
 ClassificationVariable getRowVariable()
          Returns the data column that was most recently set in the Row role by the setRowVariable() method.
 javax.swing.ListSelectionModel getSelectionModel()
          Returns the ListSelectionModel that indicates which data values are selected.
 ClassificationVariable getShapeVariable()
          Returns the data column that was most recently set in the Shape role by the setShapeVariable() method.
 Variable getSizeVariable()
          Returns the data column that was most recently set in the Size role by the setSizeVariable() method.
 Variable getSortVariable()
          Returns the data column that was most recently set in the Sort role by the setSortVariable() method.
 Variable getTopMarkerLabelVariable()
          Returns the data column that was most recently set in the TopMarkerLabel role by the setTopMarkerLabelVariable() method.
 PlotVariable getXVariable()
          Returns the data column that was most recently set in the X role by the setXVariable() method.
 PlotVariable getY2Variable()
          Returns the data column that was most recently set in the Y2 role by the setY2Variable() method.
 PlotVariable getYVariable()
          Returns the data column that was most recently set in the Y role by the setYVariable() method.
 int hashCode()
          Computes the hash code for this LinePlotTableDataModel.
 void setAuxiliaryVariable(Variable[] newVariables)
          Specifies an array of Variables that are included among the variables that are passed in the events on the ScatterPlot data elements.
 void setBottomMarkerLabelVariable(Variable newVariable)
          Returns the variable definition used to identify the data column for the label contents which are placed below the data points.
 void setColorVariable(Variable newColorVariable)
          Specifies the data column in the attached TableModel whose values are used to determine the color of the markers.
 void setColumnVariable(ClassificationVariable newColumnVariable)
          Specifies the data column(s) in the attached TableModel whose values are used to create horizontal graph cells.
 void setDataTipVariable(Variable[] newVariables)
          Specifies an array of Variables to be displayed in the data tip.
 void setGroupVariable(ClassificationVariable newGroupVariable)
          Specifies the data column in the attached TableModel whose values are used to group the markers.
 void setModel(javax.swing.table.TableModel newModel)
          Sets the data model to be used as data source.
 void setRowVariable(ClassificationVariable newRowVariable)
          Specifies the data column(s) in the attached TableModel whose values are used to vertically place the cell in the graph matrix.
 void setSelectionModel(javax.swing.ListSelectionModel newModel)
          Sets the ListSelectionModel which indicates which data values are selected.
 void setShapeVariable(ClassificationVariable newShapeVariable)
          Specifies the data column in the attached TableModel whose values are used to determine the shape (symbol) of the markers.
 void setSizeVariable(Variable newSizeVariable)
          Specifies the data column in the attached TableModel whose values are used to determine the size of the markers.
 void setSortVariable(Variable newSortVariable)
          Sets the variable that will define the order in which the plot points are connected when a line interpolation is applied.
 void setTopMarkerLabelVariable(Variable newVariable)
          Sets the variable definition used to identify the data column for the label contents which are placed above the data points.
 void setXVariable(PlotVariable newXVariable)
          Specifies the data column(s) in the attached TableModel whose values are to be used to position the markers horizontally following the primary (bottom) horizontal axis scale.
 void setY2Variable(PlotVariable newY2Variable)
          Specifies the data column(s) in the attached TableModel whose values are used to position the markers vertically following the secondary (right) vertical axis scale.
 void setYVariable(PlotVariable newYVariable)
          Specifies the data column(s) in the attached TableModel whose values are to be used to position the markers vertically following the primary (left) vertical axis scale.
 
Methods inherited from class com.sas.graphics.components.DataModel
apply, getLocale, getRulesContext, getSortStrategy, setLocale, setRulesContext, setSortStrategy
 
Methods inherited from class com.sas.graphics.components.ModelBase
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, setContainedModel
 

Constructor Detail

ScatterPlotTableDataModel

public ScatterPlotTableDataModel()
Default Constructor


ScatterPlotTableDataModel

public ScatterPlotTableDataModel(javax.swing.table.TableModel newModel)
Constructor with assigned data model

Parameters:
newModel - input data
Method Detail

apply

public void apply(ScatterPlotTableDataModel theOtherModel)
Utility method to convey properties contained in "theOtherObject" to this object.
Note: Contained "models" (i.e. properties that are subclasses of ModelBase) will in turn be called on to convey their properties to the like contained models in the other object. In that respect this can be considered a "tree" type copy.
Also Note: This is a deep copy. Thus after the copy, mutable properties will not be shared by the two instances.


setModel

public void setModel(javax.swing.table.TableModel newModel)
Sets the data model to be used as data source.

Parameters:
newModel - data source
See Also:
getModel()

getModel

public javax.swing.table.TableModel getModel()
Returns the data model

Returns:
javax.swing.table.TableModel current data model associated with the plot
See Also:
setModel(javax.swing.table.TableModel)

setSelectionModel

public void setSelectionModel(javax.swing.ListSelectionModel newModel)
Sets the ListSelectionModel which indicates which data values are selected.

Parameters:
newModel - the ListSelectionModel containing the indicies of the selected data values.
Throws:
java.lang.IllegalArgumentException - if newModel is null.
See Also:
getSelectionModel()

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
Returns the ListSelectionModel that indicates which data values are selected.

Returns:
the ListSelectionModel containing the indicies of the selected data values.
See Also:
setSelectionModel(javax.swing.ListSelectionModel)

setSortVariable

public void setSortVariable(Variable newSortVariable)
Sets the variable that will define the order in which the plot points are connected when a line interpolation is applied. By default this is null and the points are connected in the same order as they are found in the table model. A typical use of this property is to assign the same variable to both the xVariable and the sortVariable properties causing the line to flow in the same direction as the x axis. (ex. scatterPlotTableDataModel.setSortVariable(scatterPlotTableDataModel.getXVariable());)

Parameters:
newSortVariable - The variable that defines the order in which the plot points are connected when a line interpolation is applied.
See Also:
getSortVariable()

getSortVariable

public Variable getSortVariable()
Returns the data column that was most recently set in the Sort role by the setSortVariable() method. Returns null if the variable role has not been set.

Returns:
Variable the sort variable
See Also:
setSortVariable(com.sas.graphics.components.Variable)

setColumnVariable

public void setColumnVariable(ClassificationVariable newColumnVariable)
Specifies the data column(s) in the attached TableModel whose values are used to create horizontal graph cells. The values specify the horizontal position of the cell in the graph matrix. For multiple variable definitions, an instance of PlotVariableList with all the variable definitions should be used. For multiple variables, it creates nested tree of variables with the first variable in the list as root of the tree and rest following the same ordering as the variable definitions in the PlotVariableList.

Note: No checking is done for the validity of variable role with the data table at this time. Note: null is valid value and this implies that the plot has no column variable

Parameters:
newColumnVariable - variable for column in Graph Matrix
See Also:
getColumnVariable()

getColumnVariable

public ClassificationVariable getColumnVariable()
Returns the data column that was most recently set in the Column role by the setColumnVariable() method. Returns null if the variable role has not been set. If multiple variable definitions are used then it returns an instance of PlotVariableList with all the variable definitions.

Returns:
ClassificationVariable Column variable in the graph matrix
See Also:
setColumnVariable(com.sas.graphics.components.ClassificationVariable)

setRowVariable

public void setRowVariable(ClassificationVariable newRowVariable)
Specifies the data column(s) in the attached TableModel whose values are used to vertically place the cell in the graph matrix. For multiple variable definitions, an instance of PlotVariableList with all the variable definitions should be used. A nested tree is created in such cases with the first variable in the list as root of the tree and rest following the same ordering as the variable definitions in the PlotVariableList.

Note: No checking is done for the validity of variable role with the data table at this time. Note: null is valid value and this implies that the plot has no row variable

Parameters:
newRowVariable - variable for row in Graph Matrix
See Also:
getRowVariable()

getRowVariable

public ClassificationVariable getRowVariable()
Returns the data column that was most recently set in the Row role by the setRowVariable() method. Returns null if the variable role has not been set. If multiple variable definitions are used then it returns an instance of PlotVariableList with all the variable definitions.

Returns:
ClassificationVariable variable in the graph matrix
See Also:
setRowVariable(com.sas.graphics.components.ClassificationVariable)

setXVariable

public void setXVariable(PlotVariable newXVariable)
Specifies the data column(s) in the attached TableModel whose values are to be used to position the markers horizontally following the primary (bottom) horizontal axis scale. For multiple variable definitions, an instance of PlotVariableList with all the variable definitions should be used. Different Colors/symbols are assigned to markers belonging to different variables.

Note: No checking is done for the validity of the variable role(s) with the data table at this time. Note: null is valid value and it removes the X variable currently assigned to plot. Note: A valid X variable is required to get a scatter plot.

Parameters:
newXVariable - Variable associated with the horizontal x axis
See Also:
getXVariable()

getXVariable

public PlotVariable getXVariable()
Returns the data column that was most recently set in the X role by the setXVariable() method. Returns null if the variable role has not been set. If multiple variable definitions are used then it returns an instance of PlotVariableList with all the variable definitions.

Returns:
PlotVariable horizontal variable
See Also:
setXVariable(com.sas.graphics.components.PlotVariable)

setYVariable

public void setYVariable(PlotVariable newYVariable)
Specifies the data column(s) in the attached TableModel whose values are to be used to position the markers vertically following the primary (left) vertical axis scale. For multiple variable definitions, an instance of PlotVariableList with all the variable definitions should be used. Different Colors/symbols are assigned to markers belonging to different variables.

Note: No checking is done for the validity of the variable role(s) with the data table at this time. Note: null is valid value and it removes the Y variable currently assigned to plot. Note: A valid Y variable is required to get a scatter plot.

Parameters:
newYVariable - PlotVariable associated with vertical Y axis
See Also:
getYVariable()

getYVariable

public PlotVariable getYVariable()
Returns the data column that was most recently set in the Y role by the setYVariable() method. Returns null if the variable role has not been set. If multiple variable definitions are used then it returns an instance of PlotVariableList with all the variable definitions.

Returns:
PlotVariable y variable
See Also:
setYVariable(com.sas.graphics.components.PlotVariable)

setY2Variable

public void setY2Variable(PlotVariable newY2Variable)
Specifies the data column(s) in the attached TableModel whose values are used to position the markers vertically following the secondary (right) vertical axis scale. For multiple variable definitions, an instance of PlotVariableList with all the variable definitions should be used. Different Colors/symbols are assigned to markers belonging to different variables.

Note: No checking is done for the validity of the variable role(s) with the data table at this time. Note: null is valid value and it removes the Y2 variable currently assigned to the plot.

Parameters:
newY2Variable - PlotVariable associated with second vertical axis
See Also:
getY2Variable()

getY2Variable

public PlotVariable getY2Variable()
Returns the data column that was most recently set in the Y2 role by the setY2Variable() method. Returns null if the variable role has not been set. If multiple variable definitions are used then it returns an instance of PlotVariableList with all the variable definitions.

Returns:
PlotVariable associated with Y2 axis
See Also:
setY2Variable(com.sas.graphics.components.PlotVariable)

setColorVariable

public void setColorVariable(Variable newColorVariable)
Specifies the data column in the attached TableModel whose values are used to determine the color of the markers. These values are mapped to the colors defined in DataElementColors, which is contained in the ColorScheme class. If the newColorVariable is string type then its each unique value is mapped to a color from DiscreteContrastColors list. On the other hand, if the newColorVariable is a numeric type, then the minimum value is mapped to ContinuousContrastTwoColorStartColor. and the maximum value is mapped to ContinuousContrastTwoColorEndColor. All other values are interpolated to the colors between these two colors.

Note: No checking is done for the validity of the variable role with the data table at this time. Note: null is valid value and it removes the color variable currently assigned to the plot.

Parameters:
newColorVariable - Variable associated with color
See Also:
getColorVariable()

getColorVariable

public Variable getColorVariable()
Returns the data column that was most recently set in the Color role by the setColorVariable() method. Returns null if the variable role has not been set.

Returns:
Variable associated with color
See Also:
setColorVariable(com.sas.graphics.components.Variable)

setShapeVariable

public void setShapeVariable(ClassificationVariable newShapeVariable)
Specifies the data column in the attached TableModel whose values are used to determine the shape (symbol) of the markers. The values from the shapeVariable are mapped to the shapes defined in MarkerStyle. DataElementStyles contains a list of MarkerStyles which depends on the current GraphStyle. Each unique value of the newShapeVariable is mapped to a MarkerStyle from this list. If the number of unique values in the variable are more than the number of items in the MarkerStyles list, then they are wrapped around.

Note: No checking is done for the validity of the variable role with the data table at this time. Note: null is valid value and it removes the shape variable currently assigned to the plot.

Parameters:
newShapeVariable - Variable used for assigning shapes
See Also:
getShapeVariable()

getShapeVariable

public ClassificationVariable getShapeVariable()
Returns the data column that was most recently set in the Shape role by the setShapeVariable() method. Returns null if the variable role has not been set.

Returns:
Variable used for assigning shapes
See Also:
setShapeVariable(com.sas.graphics.components.ClassificationVariable)

setSizeVariable

public void setSizeVariable(Variable newSizeVariable)
Specifies the data column in the attached TableModel whose values are used to determine the size of the markers. The values for this variable are expected to be numeric type and the minimum value is mapped to the Minimum Marker Size and the maximum value is mapped to the Maximum Marker Size. All other values are interpolated between these two sizes.

Parameters:
newSizeVariable - used for size
See Also:
getSizeVariable()

getSizeVariable

public Variable getSizeVariable()
Returns the data column that was most recently set in the Size role by the setSizeVariable() method. Returns null if the variable role has not been set.

Note: No checking is done for the validity of the variable role with the data table at this time. Note: null is valid value and it removes the size variable currently assigned to the plot.

Returns:
Variable used for size
See Also:
setSizeVariable(com.sas.graphics.components.Variable)

setGroupVariable

public void setGroupVariable(ClassificationVariable newGroupVariable)
Specifies the data column in the attached TableModel whose values are used to group the markers. Based on the styleBy property, each group gets a different shape and/or color.

Note: No checking is done for the validity of the variable role with the data table at this time. Note: null is valid value and it removes the group variable currently assigned to the plot.

Parameters:
newGroupVariable - ClassificationVariable used for grouping
See Also:
getGroupVariable(), setColorVariable(com.sas.graphics.components.Variable), setShapeVariable(com.sas.graphics.components.ClassificationVariable)

getGroupVariable

public ClassificationVariable getGroupVariable()
Returns the data column that was most recently set in the Group role by the setGroupVariable() method. Returns null if the variable role has not been set.

Returns:
ClassificationVariable used for grouping
See Also:
setGroupVariable(com.sas.graphics.components.ClassificationVariable)

setTopMarkerLabelVariable

public void setTopMarkerLabelVariable(Variable newVariable)
Sets the variable definition used to identify the data column for the label contents which are placed above the data points.

Parameters:
newVariable - variable definition for the label contents above the data points.
See Also:
getTopMarkerLabelVariable()

getTopMarkerLabelVariable

public Variable getTopMarkerLabelVariable()
Returns the data column that was most recently set in the TopMarkerLabel role by the setTopMarkerLabelVariable() method. Returns null if the variable role has not been set.

Returns:
Variable definition associated with the above label contents.
See Also:
setTopMarkerLabelVariable(com.sas.graphics.components.Variable)

setBottomMarkerLabelVariable

public void setBottomMarkerLabelVariable(Variable newVariable)
Returns the variable definition used to identify the data column for the label contents which are placed below the data points.

Parameters:
newVariable - variable definition for label contents below the data points.
See Also:
getBottomMarkerLabelVariable()

getBottomMarkerLabelVariable

public Variable getBottomMarkerLabelVariable()
Returns the data column that was most recently set in the BottomMarkerLabel role by the setBottomMarkerLabelVariable() method. Returns null if the variable role has not been set.

Returns:
Variable definition associated with the below label contents.
See Also:
setBottomMarkerLabelVariable(com.sas.graphics.components.Variable)

setDataTipVariable

public void setDataTipVariable(Variable[] newVariables)
Specifies an array of Variables to be displayed in the data tip. By default, the variables specified on setDataTipVariable() are appended to the end of the default data tip display. To replace the default display with the list of variables in the Variable[] array, use the GraphModel to get the DataTipModel , and the call the DataTipModel's setContent() method with the value GraphConstants.DATA_TIP_REPLACE.

The following code fragment specifies two variables for the data tip display and uses them to replace the default data tip display:


 // Create an array of variables to set in the data tip display
    Variable dataTipVars[] = new Variable[2];
      dataTipVars[0] = new Variable("Task");
      dataTipVars[1] = new Variable("Duration");
    scatterPlot.getGraphModel().getDataTipModel().setContent(GraphConstants.DATA_TIP_REPLACE);
 

Parameters:
newVariables - array of Variables to display in data tip
Throws:
java.lang.IllegalArgumentException - if a non-null array of zero length is passed in.
See Also:
getDataTipVariable(), setAuxiliaryVariable(com.sas.graphics.components.Variable[])

getDataTipVariable

public Variable[] getDataTipVariable()
Returns the array of data columns that was most recently set by the setDataTipVariable() method. Returns null if the data tip variables were not set.

Returns:
variables for data tip values
See Also:
setDataTipVariable(com.sas.graphics.components.Variable[])

setAuxiliaryVariable

public void setAuxiliaryVariable(Variable[] newVariables)
Specifies an array of Variables that are included among the variables that are passed in the events on the ScatterPlot data elements. Auxiliary variables are not represented in the chart. By default, they are not displayed in the datatip, although they can be included in the array of variables set by setDataTipVariable().

Parameters:
newVariables - contains Variables for GraphActionEvent return.
Throws:
java.lang.IllegalArgumentException - if a non-null array of zero length is passed in.
See Also:
getAuxiliaryVariable(), setDataTipVariable(com.sas.graphics.components.Variable[])

getAuxiliaryVariable

public Variable[] getAuxiliaryVariable()
Returns the array of data columns that was most recently set by the setAuxiliaryVariable() method. Returns null if the auxiliary variables were not set.

Returns:
variables for Auxiliary values
See Also:
setAuxiliaryVariable(com.sas.graphics.components.Variable[]), setDataTipVariable(com.sas.graphics.components.Variable[])

equals

public boolean equals(java.lang.Object obj)
Determines whether another object is equal to this ScatterPlotTableDataModel.

The result is true if and only if the argument is not null and is a ScatterPlotTableDataModel object that has the same property values as this object.

Overrides:
equals in class DataModel
Parameters:
obj - the object to test for equality with this ScatterPlotTableDataModel
Returns:
true if the objects are same; false otherwise.

hashCode

public int hashCode()
Computes the hash code for this LinePlotTableDataModel.

Overrides:
hashCode in class DataModel
Returns:
a hash code value for this object.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.