|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.graphics.components.ReferenceLineModel
public class ReferenceLineModel
A ReferenceLineModel class stores the label, location and the line style for the
reference line.
A ReferenceLineModel is normally attached to an
AxisModel
and the orientation of the lines are same as the axis for the AxisModel.
// Create the reference lines ReferenceLineModel[] myReferenceLineModels = new ReferenceLineModel[3]; BasicStroke stroke = new BasicStroke(3f); java.awt.Font font = new java.awt.Font("Arial", java.awt.Font.PLAIN, 8); StrokeLineStyle greenLine = new StrokeLineStyle(stroke, java.awt.Color.green); AdvancedTextStyle greenText = new AdvancedTextStyle(font, java.awt.Color.green); StrokeLineStyle redLine = new StrokeLineStyle(stroke, java.awt.Color.red); AdvancedTextStyle redText = new AdvancedTextStyle(font, java.awt.Color.red); // Define the ideal line myReferenceLineModels[0] = new ReferenceLineModel(); myReferenceLineModels[0].setPosition(130.0); myReferenceLineModels[0].setLineStyle(greenLine); myReferenceLineModels[0].setTextStyle( greenText); myReferenceLineModels[0].setLabel("Ideal Weight"); // Now the range myReferenceLineModels[1] = new ReferenceLineModel(); myReferenceLineModels[1].setPosition(180.0); myReferenceLineModels[1].setLineStyle(redLine); myReferenceLineModels[1].setTextStyle( redText); myReferenceLineModels[1].setLabel("Over Weight"); myReferenceLineModels[2] = new ReferenceLineModel(); myReferenceLineModels[2].setPosition(100.0); myReferenceLineModels[2].setLineStyle(redLine); myReferenceLineModels[2].setTextStyle( redText); myReferenceLineModels[2].setLabel("Under Weight"); // Attach them to the chart AxisModel axisModel = barChartModel.getResponseAxisModel(); axisModel.setReferenceLineModels(myReferenceLineModels);
By default, label, lineStyle and textStyle are null and the position property is displayed as label using the axis's valueTextStyle and lineStyle.
When you set a property on a ReferenceLineModel, any change to that property generates an event that propagates to the top of the object chain so that appropriate actions can be taken. For example, for an existing ReferenceLineModel named refLine, if you set a LineStyle by calling refLine.setLineStyle(), the refLine becomes a listener to the events from the new LineStyle. A change to the LineStyle generates a propertyChangeEvent for the line, and refLine responds to that event to pick up the change and generate its own propertyChangeEvent. If the refLine is attached to a ScatterPlotModel, then the ScatterPlotModel responds to the refLine event to pick up the change and generate its own propertyChangeEvent. If the ScatterPlotModel is attached to a ScatterPlot, then the ScatterPlot responds to the event to pick up the change and redraw its reference line.
AxisModel
,
ModelBase
,
AdvancedTextStyle
,
StrokeLineStyle
Constructor Summary | |
---|---|
ReferenceLineModel()
Default constructor. |
|
ReferenceLineModel(double newPosition)
Constructor with a defined position. |
|
ReferenceLineModel(java.lang.Object newPositionAsObject)
Constructor with a defined position. |
|
ReferenceLineModel(java.lang.String newLabel,
double newPosition)
Constructor with a defined label and position. |
Method Summary | |
---|---|
void |
apply(ReferenceLineModel theOtherObject)
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 ReferenceLineModel . |
java.lang.String |
getLabel()
Get the text style for the label. |
int |
getLabelPlacement()
Returns the placement of the label. |
StrokeLineStyle |
getLineStyle()
Returns the reference line style. |
double |
getPosition()
Get the position of the reference line on the axis. |
java.lang.Object |
getPositionAsObject()
|
AdvancedTextStyle |
getTextStyle()
Get the text style for the label. |
int |
hashCode()
Computes the hash code for this ReferenceLineModel . |
boolean |
isInFront()
Returns true if the reference line is drawn in front of the chart. |
boolean |
isVisible()
Query if the reference line is visible or not. |
static ReferenceLineModel[] |
rangeToArray(double minPosition,
double maxPosition,
int interval)
Convience method to return an array of reference line models containing reference lines positioned starting from minPosition and ending on or before maxPosition incremented by the amount specified in the interval parameter. |
static ReferenceLineModel[] |
rangeToArrayByDate(double minPosition,
double maxPosition,
int timeInterval,
int multiplier)
Convience method to return an array of reference line models containing reference lines positioned starting from minPosition and ending on or before maxPosition incremented by the amount specified in the timeInterval parameter multiplied by the multiplier parameter. |
static ReferenceLineModel[] |
rangeToArrayByTime(double minPosition,
double maxPosition,
int timeInterval,
int multiplier)
Convience method to return an array of reference line models containing reference lines positioned starting from minPosition and ending on or before maxPosition incremented by the amount specified in the timeInterval parameter multiplied by the multiplier parameter. |
void |
setInFront(boolean newInFront)
Sets whether of not the reference line is drawn in front of the chart. |
void |
setLabel(java.lang.String newLabel)
Sets the text for the label. |
void |
setLabelPlacement(int newPlacement)
Sets the placement of the label. |
void |
setLineStyle(StrokeLineStyle newLineStyle)
Sets the reference line style. |
void |
setPosition(double newPosition)
Sets the value at which the reference line is placed. |
void |
setPositionAsObject(java.lang.Object newPositionAsObject)
|
void |
setTextStyle(AdvancedTextStyle newTextStyle)
Sets the text style for the label. |
void |
setVisible(boolean visible)
Set whether the reference line is visible or not. |
Methods inherited from class com.sas.graphics.components.ModelBase |
---|
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, setContainedModel |
Constructor Detail |
---|
public ReferenceLineModel()
public ReferenceLineModel(double newPosition)
public ReferenceLineModel(java.lang.Object newPositionAsObject)
public ReferenceLineModel(java.lang.String newLabel, double newPosition)
Method Detail |
---|
public void apply(ReferenceLineModel theOtherObject)
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. With the exception of the Object set in setPositionAsObject(Object). If the Object is implements cloneable, then the object is cloned and the deep copy holds true, however, if it is not, then a reference to the Object is assigned and the mutable properties will be shared by the two instances. Since it is expected that only immutable classes will be set, non-sharing rule should hold true and be the expected behavior.
theOtherObject
- a model whose properties to be conveyedpublic void setLineStyle(StrokeLineStyle newLineStyle)
Note: Any modification done to the ReferenceLineModel after attaching it to the AxisModel will be lost. AxisModel does not keep the pointer to the ReferenceLineModel but creates it own copy from the model.
Note: If lineStyle is set to null, then the line style from the axismodel is used.
newLineStyle
- the new repository for the line display attributesgetLineStyle()
,
StrokeLineStyle.apply(com.sas.graphics.components.StrokeLineStyle)
public StrokeLineStyle getLineStyle()
Note: If the lineStyle is null, then the line style from the axismodel is used.
setLineStyle(com.sas.graphics.components.StrokeLineStyle)
public void setTextStyle(AdvancedTextStyle newTextStyle)
Note: Any modification done to the ReferenceLineModel after attaching it to the AxisModel will be lost. AxisModel does not keep the pointer to the ReferenceLineModel but creates it own copy from the model.
Note: If null is passed as newTextStyle then the label uses the the valueTextStyle from the axis model.
newTextStyle
- the new repository for the label's text display attributesgetTextStyle()
,
AdvancedTextStyle.apply(com.sas.graphics.components.AdvancedTextStyle)
public AdvancedTextStyle getTextStyle()
Note: The default value for the textStyle is null and in that case the label uses the the valueTextStyle from the axis model.
AdvancedTextStyle.apply(com.sas.graphics.components.AdvancedTextStyle)
,
setTextStyle(com.sas.graphics.components.AdvancedTextStyle)
public void setLabel(java.lang.String newLabel)
Note: Any modification done to the ReferenceLineModel after attaching it to the AxisModel will be lost. AxisModel does not keep the pointer to the ReferenceLineModel but creates it own copy from the model.
Note: null is a valid value for the newLabel parameter and in this case value of the position property is displayed. Default value for the label is also null.
newLabel
- String the new text for the labelgetLabel()
public java.lang.String getLabel()
Note: The label may be null (default) and in that case the label uses the position value as label.
setLabel(java.lang.String)
public void setPosition(double newPosition)
Note: Any modification done to the ReferenceLineModel after attaching it to the AxisModel will be lost. AxisModel does not keep the pointer to the ReferenceLineModel but creates it own copy from the model.
newPosition
- Anchor point for the linegetPosition()
public java.lang.Object getPositionAsObject()
public void setPositionAsObject(java.lang.Object newPositionAsObject)
public double getPosition()
setPosition(double)
public void setInFront(boolean newInFront)
Note: You need to modify the line style before attaching to AxisModel as AxisModel does not keep the pointer to the ReferenceLineModel but creates it own copy from the model. So any change done to the model after the setter will be lost.
newInFront
- true if reference line is in frontisInFront()
public boolean isInFront()
setInFront(boolean)
public void setLabelPlacement(int newPlacement) throws java.lang.IllegalArgumentException
Valid values are:
newPlacement
- new placement from GraphConstants
java.lang.IllegalArgumentException
- if newPlacement is not a valid valuegetLabelPlacement()
public int getLabelPlacement()
setLabelPlacement(int)
public boolean isVisible()
setVisible(boolean)
public void setVisible(boolean visible)
visible
- set axis visibilityisVisible()
public boolean equals(java.lang.Object obj)
ReferenceLineModel
.
The result is true
if and only if the argument is not
null
and is a ReferenceLineModel
object that has the same
property values as this object.
equals
in class ModelBase
obj
- the object to test for equality with this
ReferenceLineModel
true
if the objects are the same;
false
otherwise.public int hashCode()
ReferenceLineModel
.
hashCode
in class ModelBase
public static ReferenceLineModel[] rangeToArray(double minPosition, double maxPosition, int interval) throws java.lang.IllegalArgumentException
minPosition
- beginning of the periodmaxPosition
- end of the periodinterval
- amount to move forward with each advance
java.lang.IllegalArgumentException
- if interval <= 0, minPosition <= 0, minPosition or maxPosition are Positive_infinity or Nan, minPositon > maxPosition.public static ReferenceLineModel[] rangeToArrayByTime(double minPosition, double maxPosition, int timeInterval, int multiplier) throws java.lang.IllegalArgumentException
Note: minPosition & maxPosition are number of seconds (SAS DATETIME and TIME format).
Only predefined values are accepted for timeInterval parameter:
minPosition
- number of seconds for beginning of the periodmaxPosition
- number of seconds for end of the periodtimeInterval
- time interval to advance bymultiplier
- number of intervals forward with each advance
java.lang.IllegalArgumentException
- if multiplier <= 0, minPosition <= 0, minPosition or maxPosition are Positive_infinity or Nan, minPositon > maxPosition, or timeInterval not valid.public static ReferenceLineModel[] rangeToArrayByDate(double minPosition, double maxPosition, int timeInterval, int multiplier) throws java.lang.IllegalArgumentException
Note: minPosition & maxPosition are number of days (SAS DATE format).
Only predefined values are accepted for timeInterval parameter:
minPosition
- beginning of the periodmaxPosition
- end of the periodtimeInterval
- time interval to advance bymultiplier
- number of intervals forward with each advance
java.lang.IllegalArgumentException
- if multiplier <= 0, minPosition <= 0, minPosition or maxPosition are Positive_infinity or Nan, minPositon > maxPosition, or timeInterval not valid.
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |