com.sas.graphics.components
Class AdvancedTextStyle

com.sas.graphics.components.AdvancedTextStyle

public class AdvancedTextStyle

The AdvancedTextStyle extends TextStyle to support rotatable text in graphs. Properties include: baseline angle, font, visibility, color, justification, frame and shadow.

Graphs contain various models that use AdvancedTextStyle such as the bar chart's OutsideBarLabel which denotes the attributes to be applied to these labels. The angle is in degrees where 0 degrees would be considered at 3:00 on an analog clock. The angle will be pivoted about the text's anchor whose location may vary based upon what is displaying the text. The angle value is specified in degrees and is normalized to the 0-360 range when set.

Usage

To adjust the angle of the BarChart's data labels to appear at a 60 degree angle (upward sloping from left to right):
 BarChart barChart = new BarChart();
 AdvancedTextStyle barLabelTextStyle = new AdvancedTextStyle();
 barLabelTextStyle.apply(barChart.getGraphModel().getOutsideBarLabelTextStyle());
 barLabelTextStyle.setBaselineAngle(60);
 barChart.getGraphModel().setOutsideBarLabelTextStyle(barLabelTextStyle);
 barChart.getGraphModel().setOutsideBarLabelContent(GraphConstants.DATA_LABEL_CATEGORY);
 

Behavior

Note: Not all properties in the graph honor text rotation, even though you can set an AdvancedTextStyle on any property in the graph that expect a TextStyle parameter. Also, some properties only allow {0, 90, 270} angles.

The apply() method is a convenience to convey the properties from one AdvancedTextStyle to another.

Since:
SAS 9.1
See Also:
TextStyle, GraphStyle, ModelBase

Constructor Summary
AdvancedTextStyle()
          A AdvancedTextStyle encapsulates the set of display properties applicable to text used in graphs that support some baseline angle specification for rotating the text.
AdvancedTextStyle(java.awt.Font newFont, java.awt.Color newColor, int newJustification, boolean newVisible, double newBaselineAngle)
          Constructor allowing specification of Font, color, justification and visibility.
 
Method Summary
 void apply(AdvancedTextStyle 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 AdvancedTextStyle.
 double getBaselineAngle()
          Get the baseline angle for the text.
 int hashCode()
          Computes the hash code for this AdvancedTextStyle.
 void setBaselineAngle(double newAngle)
          Set the baseline angle for the text.
 
Methods inherited from class com.sas.graphics.components.TextStyle
apply, getColor, getFont, getJustification, getRowSelectionFontStlye, getRowSelectionTextColorStlye, getShadowStyle, isVisible, setColor, setFont, setJustification, setRowSelectionFontStyle, setRowSelectionTextColorStyle, setShadowStyle, setVisible
 
Methods inherited from class com.sas.graphics.components.ModelBase
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, setContainedModel
 

Constructor Detail

AdvancedTextStyle

public AdvancedTextStyle()
A AdvancedTextStyle encapsulates the set of display properties applicable to text used in graphs that support some baseline angle specification for rotating the text. The default font is a 12 point "TimesRoman" font. The default color is SystemColor.textText. The default visibility is true (means it is visible). The default justification is javax.swing.SwingConstants.CENTER. The default frameLineStyle is [color=java.awt.SystemColor.windowBorder; thickness=1 pixel; visibility=false] The default shadowStyle is the ShadowStyle defaults. The default baseline angle is 0 degrees.


AdvancedTextStyle

public AdvancedTextStyle(java.awt.Font newFont,
                         java.awt.Color newColor,
                         int newJustification,
                         boolean newVisible,
                         double newBaselineAngle)
Constructor allowing specification of Font, color, justification and visibility. If newFont is null then it is ignored, the default font is ("TimesRoman",PLAIN,12). If newColor is null then it is ignored, the default color is SystemColor.textText. If newJustification is invalid then it is ignored, the default color is javax.swing.SwingConstants.CENTER. If newVisible is true then the text will be visible when displayed. For newBaselineAngle, if the graph property allows rotating text, sets the baseline angle for the text.

Parameters:
newFont - the text font, null is ignored
newColor - the text color, null is ignored
newJustification - the text justification, invalid value are ignored
newVisible - the text visibility, true means visible
newBaselineAngle - the text angle of rotation, default is 0 degrees
Method Detail

apply

public void apply(AdvancedTextStyle theOtherObject)
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:
theOtherObject - properties applied to this instance

setBaselineAngle

public void setBaselineAngle(double newAngle)
Set the baseline angle for the text. The angle is in degrees where 0 degrees would be considered at 3:00 on an analog clock. The angle will be pivoted about the text's anchor whose location may vary based upon what is displaying the text. The angle value is specified in degrees and is normalized to 0-360 when set.

Parameters:
newAngle - angle for text baseline
See Also:
getBaselineAngle()

getBaselineAngle

public double getBaselineAngle()
Get the baseline angle for the text. The angle value is specified in degrees and is normalized to the 0-360 range when set.

Returns:
double baseline angle setting
See Also:
setBaselineAngle(double)

equals

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

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

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

hashCode

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

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



Copyright © 2009 SAS Institute Inc. All Rights Reserved.