com.sas.graphics.components.lineplot
Class LinePlotTableDataModel

com.sas.graphics.components.lineplot.LinePlotTableDataModel

public class LinePlotTableDataModel

A LinePlotTableDataModel encapsulates relational data from a javax.swing.table.TableModel and maps the TableModel's data columns onto a LinePlot 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 LinePlot displays the data.

The data values identified by the X variable(s), Y variable(s), and Y2 variable(s) determine the location of the markers in the graph. A marker is produced for each pair of (X, Y) values as well as for each pair of (X, Y2) values. If multiple Y variables are assigned, then the line plot for each variable may get a different color and style, based on the StyleBy property in the LinePlotModel. The TopMarkerLabelVariable and BottomMarkerLabelVariable roles can be used to display labels above and below the data points.

When generating a graph, a LinePlot does not summarize the data from a LinePlotTableDataModel.

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

Since:
SAS 9.1
See Also:
LinePlot, LinePlotModel, Variable, PlotVariable, PlotVariableList, Variable, VariableList

Constructor Summary
LinePlotTableDataModel()
          Default Constructor
LinePlotTableDataModel(javax.swing.table.TableModel newModel)
          Constructor with a data model
 
Method Summary
 void apply(LinePlotTableDataModel 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 LinePlotTableDataModel.
 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 table associated with this 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.
 Variable getSortVariable()
          Returns the data column that was most recently set in the Sort role by the setSortVariable() method.
 ClassificationVariable getStyleVariable()
          Returns the data column that was most recently set in the Style role by the setStyleVariable() 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 LinePlot 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 newVariable)
          Sets the data column(s) in the attached TableModel whose values are to be used to determine the color of the lines and markers.
 void setColumnVariable(ClassificationVariable newVariable)
          Sets the data column(s) in the attached TableModel whose values are used to horizontally group the charts.
 void setDataTipVariable(Variable[] newVariables)
          Specifies an array of Variables to be displayed in the data tip.
 void setGroupVariable(ClassificationVariable newVariable)
          Sets the data column(s) in the attached TableModel whose values are to be used to group the line/markers.
 void setModel(javax.swing.table.TableModel newModel)
          Sets the data model for this model.
 void setRowVariable(ClassificationVariable newVariable)
          Sets the data column(s) in the attached TableModel whose values are used to vertically group the charts.
 void setSelectionModel(javax.swing.ListSelectionModel newModel)
          Sets the ListSelectionModel which indicates which data values are selected.
 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 setStyleVariable(ClassificationVariable newVariable)
          Sets the data column(s) in the attached TableModel whose values are to be used to determine the style of the lines and shapes of the markers.
 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 newVariable)
          Sets the data column(s) in the attached TableModel whose values are to be used to produce the markers along the the primary (below) horizontal axis.
 void setY2Variable(PlotVariable newVariable)
          Sets the data column(s) in the attached TableModel whose values are to be used to determine the secondary (right) vertical position of the markers.
 void setYVariable(PlotVariable newVariable)
          Sets the data column(s) in the attached TableModel whose values are to be used to determine the primary (left) vertical position of the markers.
 
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

LinePlotTableDataModel

public LinePlotTableDataModel()
Default Constructor


LinePlotTableDataModel

public LinePlotTableDataModel(javax.swing.table.TableModel newModel)
Constructor with a data model

Parameters:
newModel - data source
Method Detail

apply

public void apply(LinePlotTableDataModel 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.

Parameters:
theOtherModel - the LinePlotModel to copy the properties from.

setModel

public void setModel(javax.swing.table.TableModel newModel)
Sets the data model for this model.

Parameters:
newModel - the data table model to be assigned to this model.
See Also:
getModel()

getModel

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

Returns:
table model associated with this data model.
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 a null pointer exception 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 newVariable)
Sets the data column(s) in the attached TableModel whose values are used to horizontally group the charts.

Parameters:
newVariable - variable associated with the 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.

Returns:
variable for column.
See Also:
setColumnVariable(com.sas.graphics.components.ClassificationVariable)

setRowVariable

public void setRowVariable(ClassificationVariable newVariable)
Sets the data column(s) in the attached TableModel whose values are used to vertically group the charts.

Parameters:
newVariable - variable associated with the 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.

Returns:
variable for row.
See Also:
setRowVariable(com.sas.graphics.components.ClassificationVariable)

setXVariable

public void setXVariable(PlotVariable newVariable)
Sets the data column(s) in the attached TableModel whose values are to be used to produce the markers along the the primary (below) horizontal axis.

Parameters:
newVariable - variable associated with the x.
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.

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

setYVariable

public void setYVariable(PlotVariable newVariable)
Sets the data column(s) in the attached TableModel whose values are to be used to determine the primary (left) vertical position of the markers.

Parameters:
newVariable - variable definition associated with Y.
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.

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

setY2Variable

public void setY2Variable(PlotVariable newVariable)
Sets the data column(s) in the attached TableModel whose values are to be used to determine the secondary (right) vertical position of the markers.

Parameters:
newVariable - variable associated with y2.
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.

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

setColorVariable

public void setColorVariable(Variable newVariable)
Sets the data column(s) in the attached TableModel whose values are to be used to determine the color of the lines and 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.

Parameters:
newVariable - variable definition associated with the 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 the color.
See Also:
setColorVariable(com.sas.graphics.components.Variable)

setStyleVariable

public void setStyleVariable(ClassificationVariable newVariable)
Sets the data column(s) in the attached TableModel whose values are to be used to determine the style of the lines and shapes of the markers. The values from the styleVariable are mapped to the styles defined in StrokeLineStyle. DataElementStyles contains a list of MarkerStyles which depends on the current GraphStyle. Each unique value of the newShapeVariable is mapped to a StrokeLineStyle from this LineStyles list. If the number of unique values in the variable are more than the number of items in the LineStyles list, then they are wrapped around.

Parameters:
newVariable - variable used for assigning styles.
See Also:
getStyleVariable()

getStyleVariable

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

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

setGroupVariable

public void setGroupVariable(ClassificationVariable newVariable)
Sets the data column(s) in the attached TableModel whose values are to be used to group the line/markers.

Parameters:
newVariable - variable used for grouping.
See Also:
getGroupVariable()

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. Based on the styleBy property, each group gets a different style and/or color.

Returns:
Variable used for grouping.
See Also:
setGroupVariable(com.sas.graphics.components.ClassificationVariable), setColorVariable(com.sas.graphics.components.Variable), setStyleVariable(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");
    linePlot.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 LinePlot 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 LinePlotTableDataModel.

The result is true if and only if the argument is not null and is a LinePlotTableDataModel 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 LinePlotTableDataModel
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.