|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
java.lang.Object
|
+--com.sas.graphics.components.ModelBase
|
+--com.sas.graphics.components.ContentsModel
|
+--com.sas.graphics.components.AxisModel
The AxisModel class stores general appearance settings for a graph axis, such as a category or response axis in a BarChart. For information on the appearance settings of an axis in the graph matrix that is generated by a Column or Row variable, see the GraphMatrixAxisModel class.
BarChart barChart = new BarChart(); BarChartModel barChartModel = barChart.getBarChartModel(); AxisModel categoryAxisModel = barChartModel.getCategoryAxisModel();Once you get the AxisModel, you can modify its properties. Continuing on our previous example, say we want to set the axis's title as "Revenue in Millions" and its range from 0.0 to 1000.0.
responseAxisModel.setLabel("Revenue in Millions");
responseAxisModel.setMinimum(0.0);
responseAxisModel.setMaximum(1000.0);
The labels placed along the axis are called tick values and the the little
line to mark the place of the labels on the axis are called tickmarks or just
ticks. These are controlled by MajorTickStyles and MinorTickStyles. For example, say
you want to change axis major ticks such that they are anchored
at zero and the major tick interval is 100.
responseAxisModel.setContinuousMajorTickPositionPolicy(GraphConstants.TICK_POSITION_ANCHORED_INTERVAL); responseAxisModel.setContinuousMajorTickInterval(100.0); responseAxisModel.setContinuousMajorTickAnchor(0.0);For some reason you are more interested in finding out what lies outside the range {225.0, 550.0}. That calls for adding reference lines. Building on the top of our current example: ReferenceLine Example:
ReferenceLineModel[] references = new ReferenceLineModel[2];
BasicStroke stroke = new BasicStroke(4f);
// Set the reference line for the low level
references[0] = new ReferenceLineModel();
references[0].setPosition(225.0);
references[0].setLineStyle( new StrokeLineStyle(stroke, java.awt.Color.green));
// Set the appropriate label and its properties
AdvancedTextStyle lowLabel = new AdvancedTextStyle();
lowLabel.setColor(java.awt.Color.green);
lowLabel..setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 8));
references[0].setTextStyle( lowLabel);
references[0].setLabel("Low");
references[0].setLabelPlacement(GraphConstants.PLACEMENT_OUTSIDE);
// Set the higher reference line
references[1] = new ReferenceLineModel();
references[1].setPosition(550.0);
AdvancedTextStyle highLabel = new AdvancedTextStyle();
highLabel.setColor(java.awt.Color.red);
highLabel..setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 8));
references[1].setTextStyle( highLabel);
references[1].setLabel("High");
references[1].setLabelPlacement(GraphConstants.PLACEMENT_OUTSIDE);
references[1].setLineStyle( new StrokeLineStyle(stroke, java.awt.Color.red));
// Attach the reference lines to axis
responseAxisModel.setReferenceLineModels(references);
Changing a property in the AxisModel will cause a PropertyChangeEvent to be fired.
Changing a property in any of the contained models will also cause the AxisModel to
fire a PropertyChangeEvent. No matter how deep the contained model is the event will
cascade up the containment chain to finally reach the AxisModel which will fire an
event. Graph to which the AxisModel is attached, listens to these events and the
changes are applied to the chart immediately.
GraphMatrixAxisModel
is used for Row and Column axis.
Tick Marks Display Policy:
There are times when a graph’s size is too small to display all of the tick values that are
needed on an axis. This can happen with a graph’s default tick display, and also when you set
an anchor and/or interval for the tick marks.
If a graph is too small to display tick values, a fitting algorithm applies several techniques that
attempt to fit tick values on the axis. If one technique fails, the next technique is attempted.
The algorithm varies, depending on whether the axis values are string values or numeric values.
If the axis values are string values, the following techniques are attempted in the order that
they are listed:
If the axis values are numeric values, the first and last tick values are always displayed, but the axis skips other values. At first attempt, axis skips every other tick value. If the remaining tick values still do not fit, then the axis tries skipping two values between each tick mark, and then three, and so on until the axis values fit on the axis.
ModelBase,
TickStyle,
StrokeLineStyle,
TextStyle,
AdvancedTextStyle,
ReferenceLineModel,
GraphMatrixAxisModel,
BarChartModel,
ScatterPlotModel,
LinePlotModel,
BaseLength| Constructor Summary | |
AxisModel()
|
|
| Method Summary | |
void |
apply(AxisModel theOtherObject)
Utility method to convey properties contained in "theOtherObject" to this object. |
boolean |
equals(Object obj)
Determines whether another object is equal to this AxisModel.
|
StrokeLineStyle |
getAxisLineStyle()
Return the line style attributes for the axis line. |
String[] |
getCategories()
Return the user defined categories (also known as midpoint labels displayed on the axis) for use with a non-continuous axis. |
double |
getContinuousMajorTickAnchor()
Returns the anchored location for the major ticks in the axis. |
int |
getContinuousMajorTickCount()
Returns the number of the major tick count for the axis. |
double |
getContinuousMajorTickInterval()
Returns the major tick interval for the axis. |
int |
getContinuousMajorTickPositionPolicy()
Returns the continuous major tick placement policy. |
double[] |
getContinuousMajorTickValues()
Return the positions of the anchors for major ticks on the axis. |
int |
getContinuousMinorTickCount()
Returns the number of the minor tick count for the axis. |
BaseLength |
getEndOffset()
Returns the length of the offset from the last major tick mark to the end of the axis line. |
StrokeLineStyle |
getGridLineStyle()
Returns the line style for grid lines. |
int |
getLabelPlacementPolicy()
Returns the label placement policy to determine the placement of the axis label. |
TickStyle |
getMajorTickStyle()
Return the major ticks appearance attributes. |
int |
getMajorTickTimeInterval()
Returns the major tick time interval for the time axis. |
double |
getMaximum()
Returns the maximum value to display on the axis. |
double |
getMinimum()
Returns the minimum value to display on the axis. |
TickStyle |
getMinorTickStyle()
Returns the minor ticks appearance attributes. |
ReferenceLineModel[] |
getReferenceLineModels()
Return the properties for the reference lines. |
boolean |
getReverseDirection()
Deprecated. As of SAS version 9.1.3, replaced by isReverseDirection(). |
BaseLength |
getStartOffset()
Returns the starting offset for the first tick on the axis. |
int |
getValueFitPolicy()
Returns the value fit policy which identifies how the axis values are moved/sized and manipulated in order to make them fit in the available space. |
int |
hashCode()
Computes the hash code for this AxisModel. |
boolean |
isDrillIconVisible()
Returns true if a drill-down icon should appear next to the subgroup label (if present). |
boolean |
isGridInFront()
Returns true if the grid drawn in front of the graph elements. |
boolean |
isReverseDirection()
Returns whether or not the values are placed in reverse order. |
void |
setAxisLineStyle(StrokeLineStyle axisLineStyle)
Set the line style attributes for the axis line. |
void |
setCategories(String[] newCategories)
Set the user defined categories (also known as midpoint labels displayed on the axis) for use with a non-continuous axis. |
void |
setContinuousMajorTickAnchor(double newMajorTickAnchor)
Sets the anchored location for the major ticks in the axis. |
void |
setContinuousMajorTickCount(int newContinuousMajorTickCount)
Sets the number of the major tick counts for the axis. |
void |
setContinuousMajorTickInterval(double newMajorTickInterval)
Sets the major tick interval for the axis. |
void |
setContinuousMajorTickPositionPolicy(int newMajorTickPlacementType)
Sets the continuous major tick placement policy. |
void |
setContinuousMajorTickValues(double[] newContinuousMajorTickValues)
Set the positions of the major ticks on the axis to these custom positions. |
void |
setContinuousMinorTickCount(int newContinuousMinorTickCount)
Sets the number of the minor tick count for the axis. |
void |
setDrillIconVisible(boolean newVis)
Set if a drill-down icon should appear next to the subgroup label (if present). |
void |
setEndOffset(BaseLength endOffset)
Set the length of the offset from the last major tick mark to the end of the axis line. |
void |
setGridInFront(boolean inFront)
Sets grid lines in front or back of the graph elements. |
void |
setGridLineStyle(StrokeLineStyle newLineStyle)
Set the line style for grid lines. |
void |
setLabelPlacementPolicy(int newLabelPlacementPolicy)
Sets the label placement policy to determine the placement of the axis label. |
void |
setMajorTickStyle(TickStyle newMajorTickStyle)
Set the major ticks appearance attributes. |
void |
setMajorTickTimeInterval(int newMajorTickTimeInterval)
Sets the major tick time interval for the time axis. |
void |
setMaximum(double maxValue)
Sets the the maximum value to display on the axis. |
void |
setMinimum(double minValue)
Sets the the minimum value to display on the axis. |
void |
setMinorTickStyle(TickStyle newMinorTickStyle)
Set the minor ticks appearance attributes. |
void |
setReferenceLineModels(ReferenceLineModel[] newReferenceLineModels)
Set the reference line definitions. |
void |
setReverseDirection(boolean reverse)
Sets the axis values in reverse order. |
void |
setStartOffset(BaseLength newStartOffset)
Sets the offset for the first axis tickmark. |
void |
setValueFitPolicy(int newValueFitPolicy)
Sets the value fit policy which specifies how the axis values are moved/sized and manipulated in order to make them fit in the available space. |
| Methods inherited from class com.sas.graphics.components.ContentsModel |
apply, getLabel, getLabelTextStyle, getValueTextStyle, isVisible, setLabel, setLabelTextStyle, setValueTextStyle, setVisible |
| Methods inherited from class com.sas.graphics.components.ModelBase |
addPropertyChangeListener, removePropertyChangeListener |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public AxisModel()
| Method Detail |
public final void apply(AxisModel 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.
theOtherObject - properties applied to this instancepublic final BaseLength getEndOffset()
setEndOffset(com.sas.measures.BaseLength)public final void setEndOffset(BaseLength endOffset)
BaseLength - offset for the last tickmark.getEndOffset()public final StrokeLineStyle getGridLineStyle()
setGridLineStyle(com.sas.graphics.components.StrokeLineStyle)
public final void setGridLineStyle(StrokeLineStyle newLineStyle)
throws IllegalArgumentException
newLineStyle - the new repository for the grid's line attributesIllegalArgumentException - if newLineStyle is null.getGridLineStyle(),
StrokeLineStyle.apply(com.sas.graphics.components.StrokeLineStyle)public final boolean isGridInFront()
setGridInFront(boolean)public final void setGridInFront(boolean inFront)
boolean - grid drawn in front of the chart elements?isGridInFront()public final StrokeLineStyle getAxisLineStyle()
setAxisLineStyle(com.sas.graphics.components.StrokeLineStyle)
public final void setAxisLineStyle(StrokeLineStyle axisLineStyle)
throws IllegalArgumentException
axisLineStyle - the new repository for the axis' line attributesIllegalArgumentException - if axisLineStyle is null.getAxisLineStyle(),
StrokeLineStyle.apply(com.sas.graphics.components.StrokeLineStyle)public final ReferenceLineModel[] getReferenceLineModels()
Note: A copy of the array parameter is made when this method is called. Thus changing the array values after the set will have no effect on the set of reference lines maintained by this axis model. To affect that it would be necessary to call this method again with the appropriate settings.
Also Note: Modifying a property on any of the ReferencLineModels maintained by this axis model will affect the reference line appearance.
setReferenceLineModels(com.sas.graphics.components.ReferenceLineModel[])public final void setReferenceLineModels(ReferenceLineModel[] newReferenceLineModels)
A copy of the passed array is made so any modifications made to the passed array will not affect the chart.
Note: Modifying a property on any of the ReferencLineModels in the array will affect the reference line appearance. However modifying the array will have no effect on the set of reference lines maintained by the axis. To affect the the set of reference lines maintained by the axis it is necessary to call setReferenceLineModels with the appropriate settings.
Note: null is an acceptable parameter and means
no reference lines.
getReferenceLineModels()public final BaseLength getStartOffset()
setStartOffset(com.sas.measures.BaseLength)public final void setStartOffset(BaseLength newStartOffset)
BaseLength - offset for first axis tick.getStartOffset()public final String[] getCategories()
If this AxisModel is associated with a continuous axis (such as an axis that is displaying a numeric range) then this setting will not be applicable and is simply ignored at that time.
A value of null indicates that the chart
will adhere to its default behavior of determining
the axis categories (a.k.a. midpoints) based upon the
applicable data values used by the chart.
Note: Modifying the returned array will have no effect on the axis behavior. To affect a change in the axis's category setting it is necessary to call setCategories.
setCategories(java.lang.String[])public final void setCategories(String[] newCategories)
If this AxisModel is associated with a continuous axis (such as an axis that is displaying a numeric range) then this setting will not be applicable and is simply ignored at that time.
A value of null indicates that the chart
should adhere to its default behavior of determining
the axis categories (a.k.a. midpoints) based upon the
applicable data values used by the chart.
Note: If the array is applicable and non-null then only those values in the array will appear on the axis. If the chart has a category that is not in this list then that category will not be displayed. Ex. If the BarChart has bars for categories "A", "B" and "C" but the BarChart's category axis "categories" property is set to ["B","C","D"] then the BarChart's category axis will display "B","C" and "D". That is, no "A" bar will appear.
Please don't confuse the property name "categories" with only being applicable to a "Category" axis (as in the BarChart example). The same behavior is applicable to the Scatter and line plot axes when they are non-continuous.
Also Note: a copy of the array parameter is made when this method is called. Thus changing the array values after the set will have no effect on the chart. To affect a change in the chart it is necessary to call this method again.
newCategories - new Categories to be set on axisgetCategories()public final int getContinuousMajorTickPositionPolicy()
GraphConstants.TICK_POSITION_DEFAULT:
Place tickmarks by computing the appropriate
interval based on data range.
GraphConstants.TICK_POSITION_COUNT,
Divide the data range by count to get the interval
and then place the ticks at the increment of
interval starting at the beginning of the axis.
GraphConstants.TICK_POSITION_INTERVAL,
Place the ticks at the increment of interval starting
at the beginning of the axis.
GraphConstants.TICK_POSITION_ANCHORED_INTERVAL,
Place a tick at the anchor and then place additional
ticks at the increment of interval in both directions.
GraphConstants.TICK_POSITION_USER_DEFINED
Place a ticks at the values given in the
majorTickUserDefinedValue property.
setContinuousMajorTickPositionPolicy(int)
public final void setContinuousMajorTickPositionPolicy(int newMajorTickPlacementType)
throws IllegalArgumentException
Note: An IllegalArgumentException is thrown if an invalid value is passed in.
Possible values are:
GraphConstants.TICK_POSITION_DEFAULT:
Place tickmarks by computing the appropriate
interval based on data range.
GraphConstants.TICK_POSITION_COUNT,
Divide the data range by count given by the property
continuousMajorTickCount to get the interval
and then place the ticks at the increment of
interval starting at the beginning of the axis.
If no continuousMajorTickCount is set, then default
value, which is 5, is used.
GraphConstants.TICK_POSITION_INTERVAL,
Place the ticks at the increment of interval starting
at the beginning of the axis. If no interval is assigned
using continuousMajorTickInterval, then an error message
is produced and there will be no major tick value.
GraphConstants.TICK_POSITION_ANCHORED_INTERVAL,
Place a tick at the anchor and then place additional
ticks at the increment of interval in both directions.
If no interval is assigned using continuousMajorTickInterval,
then an error message is produced and there will be no
major tick value.
GraphConstants.TICK_POSITION_USER_DEFINED
Place a ticks at the values given in the
continuousMajorTickValues property.
If no values are assigned using continuousMajorTickValues,
then an error message is produced and there will be no
major tick value.
For GraphConstants.TICK_POSITION_INTERVAL and GraphConstants.TICK_POSITION_ANCHORED_INTERVAL
values, continuousMajorTickInterval should be set to positive value, otherwise
a error message will be produced and there will be no major tick values.
int - Placement type valueIllegalArgumentException - if newScaleType is not a valid value.getContinuousMajorTickPositionPolicy()public final int getContinuousMajorTickCount()
Default value for continuousMajorTickCount is 5.
setContinuousMajorTickCount(int)
public final void setContinuousMajorTickCount(int newContinuousMajorTickCount)
throws IllegalArgumentException
Default value for continuousMajorTickCount is 5.
If the axis size is smaller than its preferred size then some tick mark values are omitted. This will result in different number of ticks than the count set here. See tick marks display policy for detail.
the - major tick countIllegalArgumentException - if newContinuousMajorTickCount < 1.getContinuousMajorTickCount()public final int getContinuousMinorTickCount()
Default value for continuousMinorTickCount is 5.
setContinuousMinorTickCount(int)
public final void setContinuousMinorTickCount(int newContinuousMinorTickCount)
throws IllegalArgumentException
Default value is 4.
Note: Set visibility TRUE in MinorTickStyle to make minor ticks visible. By default they are turned off.
the - continuousMinorTickCountIllegalArgumentException - if newContinuousMinorTickCount < 1.getContinuousMinorTickCount()public final double getContinuousMajorTickInterval()
Default value is Double.MAX_VALUE, which basically implies that there are no major ticks except at the anchor.
setContinuousMajorTickInterval(double)
public final void setContinuousMajorTickInterval(double newMajorTickInterval)
throws IllegalArgumentException
If the axis size is smaller than its preferred size then some tick mark values are omitted. This will result in different interval than the value set here. See tick marks display policy for detail.
the - continuousMajorTickIntervalIllegalArgumentException - if newMajorTickInterval < 1
or newMajorTickInterval = Double.POSITIVE_INFINITY.getContinuousMajorTickInterval()public final int getMajorTickTimeInterval()
Default value is TIME_INTERVAL_NONE, which basically implies that time interval is based on the time values.
setMajorTickTimeInterval(int)
public final void setMajorTickTimeInterval(int newMajorTickTimeInterval)
throws IllegalArgumentException
Default value is TIME_INTERVAL_NONE, which basically implies that time interval is based on the time values.
the - majorTickTimeIntervalIllegalArgumentException - if newMajorTickTimeInterval is not one of the predefined values.getMajorTickTimeInterval()public final double getContinuousMajorTickAnchor()
Default is 0.
If the anchor value does not lie in the data range, it won't be visible on screen but visible ticks will be still placed as if it was an anchor.
setContinuousMajorTickAnchor(double)public final void setContinuousMajorTickAnchor(double newMajorTickAnchor)
Default is 0.
If the anchor value does not lie in the data range, it won't be visible on screen but visible ticks will be still placed as if it was an anchor.
If the axis size is smaller than its preferred size then anchor values may be omitted. See tick marks display policy for detail.
the - anchor valueIllegalArgumentException - if newMajorTickAnchor is
Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY.getContinuousMajorTickAnchor()public final double[] getContinuousMajorTickValues()
Note: Modifying the array will have no effect on the chart. To affect a change in the chart's user defined MajorTick layout it is necessary to call "setMajorTickUserDefinedValues" with the desired settings.
Default value is null.
Note: If placement is GraphConstants.TICK_POSITION_USER_DEFINED and there is no value inside MajorTickUserDefinedValues which is inside the axis range, then there won't be any major ticks. This may happen either MajorTickValues were left to default(null) or all the values in the array lie outside the data range of axis.
Default value is null.
setContinuousMajorTickValues(double[])
public final void setContinuousMajorTickValues(double[] newContinuousMajorTickValues)
throws IllegalArgumentException
Note: a copy of the array is made when it is set here. Modifying the array after the set will have no effect on the chart. To affect a change in the chart's user defined MajorTick layout it will be necessary to call this method again with the desired settings.
Note: If placement is GraphConstants.TICK_POSITION_USER_DEFINED and there is no value which is inside the axis range, then there won't be any major ticks. This may happen either MajorTickValues were left to default which is null or all the values in the array lie outside the range.
Default value is null.
If the axis size is smaller than its preferred size then some of tick mark values are omitted. See tick marks display policy for detail.
double[] - array of all user defined tick values.IllegalArgumentException - if newContinuousMajorTickValues is null.getContinuousMajorTickValues()
public final void setMajorTickStyle(TickStyle newMajorTickStyle)
throws IllegalArgumentException
newMajorTickStyle - the new repository for the major tick mark attributesIllegalArgumentException - if newMajorTickStyle is null.getMajorTickStyle(),
TickStyle.apply(com.sas.graphics.components.TickStyle)public final TickStyle getMajorTickStyle()
By default, major ticks are visible.
setMajorTickStyle(com.sas.graphics.components.TickStyle)
public final void setMinorTickStyle(TickStyle newMinorTickStyle)
throws IllegalArgumentException
newMinorTickStyle - the new repository for the minor tick mark attributesIllegalArgumentException - if newMinorTickStyle is null.getMinorTickStyle(),
TickStyle.apply(com.sas.graphics.components.TickStyle)public final TickStyle getMinorTickStyle()
By default, minor ticks are invisible.
setMinorTickStyle(com.sas.graphics.components.TickStyle)public final int getLabelPlacementPolicy()
Default value is GraphConstants.PLACEMENT_AUTOMATIC.
setLabelPlacementPolicy(int)
public final void setLabelPlacementPolicy(int newLabelPlacementPolicy)
throws IllegalArgumentException
GraphConstants.PLACEMENT_AUTOMATIC Place axis label in the most appropriate location.
GraphConstants.PLACEMENT_INSIDE Place the label at the end of axis and on the same side as chart.
GraphConstants.PLACEMENT_OUTSIDE Place the label at the end of axis and on the other side of the
chart.
GraphConstants.PLACEMENT_ACROSS Place the label at the end of axis with centrally justified.
GraphConstants.PLACEMENT_CENTER Place the label at the center of the axis. Default value is GraphConstants.PLACEMENT_AUTOMATIC.
the - labelPlacementPolicyIllegalArgumentException - if newLabelPlacementPolicy is not one of the predefined values.getLabelPlacementPolicy()public final int getValueFitPolicy()
Default value is GraphConstants.FIT_AUTOMATIC.
setValueFitPolicy(int)
public final void setValueFitPolicy(int newValueFitPolicy)
throws IllegalArgumentException
GraphConstants.FIT_AUTOMATIC
GraphConstants.FIT_BEST
Make the label appear as best as possible given even extreme situations.
GraphConstants.FIT_FAST
Attempt to display a label but give up without too much effort to support a faster paint time.
Default value is GraphConstants.FIT_AUTOMATIC.
the - valueFitPolicyIllegalArgumentException - if newValueFitPolicy is not one of the predefined values.getValueFitPolicy()public final double getMinimum()
setMinimum(double),
getMaximum()public final void setMinimum(double minValue)
IllegalArgumentException - if minValue is
Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY.getMinimum(),
setMaximum(double)public final double getMaximum()
setMaximum(double),
getMinimum()public final void setMaximum(double maxValue)
IllegalArgumentException - if maxValue is
Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY.getMaximum(),
setMinimum(double)public final boolean isDrillIconVisible()
setDrillIconVisible(boolean)public final void setDrillIconVisible(boolean newVis)
newDir - Should the drill-down icon be displayed?isDrillIconVisible()public boolean equals(Object obj)
AxisModel.
The result is true if and only if the argument is not
null and is a AxisModel object that has the same
property values as this object.
equals in class ContentsModelobj - the object to test for equality with this
AxisModeltrue if the objects are the same;
false otherwise.public int hashCode()
AxisModel.hashCode in class ContentsModelpublic final void setReverseDirection(boolean reverse)
reverse - true is reverse ordering for values is desired, else false.isReverseDirection()public final boolean getReverseDirection()
isReverseDirection().
public final boolean isReverseDirection()
setReverseDirection(boolean)
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||