All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.graphics.components
Class TextStyle

    com.sas.graphics.components.TextStyle

Direct Known Subclasses:
  AdvancedTextStyle

    @SASScope(value="ALL")
    public class TextStyle

A TextStyle encapsulates the set of display properties applicable to text within a graph. Properties include: font, visibility, color, justification, frame and shadow.

Graphs contain NoteModels, AxisModels, LegendModels etc. that contain TextStyles. For instance a Legend has value text and label text hence the LegendModel has a ValueTextStyle and LabelTextStyle whereby the display properties of text can be specified.

Note that null is not an acceptable parameter value for the properties of this class and will result in an IllegalArgumentException being thrown. Due to the nature of the way GraphStyles are applied to graphs and the ways that various pieces of text are used differently in a graph there is not a good set of common default text properties. Some defaults are chosen when a TextStyle object is constructed but most of these are overridden by the graph's constructor or when a GraphStyle is applied to a Graph. Since there is not an acceptable default this class does not support any "revert to default" via null parameters.

## Usage

Ex. Set a bar chart's category axis label to dark blue.

     BarChart barChart = new BarChart();
     barChart.getBarChartModel().getCategoryAxisModel().getLabelTextStyle().setColor(Color.blue.darker());

## Behavior

This apply() method is a convenience to convey the properties from one TextStyle to another.

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

Constructor Summary
`TextStyle()` A TextStyle encapsulates the set of display properties applicable to text used in graphs.
`TextStyle(java.awt.Font newFont, java.awt.Color newColor, int newJustification, boolean newVisible)` Constructor allowing specification of Font, color, justification and visibility.

Method Summary
`void` | `apply(TextStyle 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 `TextStyle`.
`java.awt.Color` | `getColor()` Get the color used to draw the text.
`java.awt.Font` | `getFont()` Returns the font used to draw the text.
`int` | `getJustification()` Returns the type of horizontal justification.
`java.awt.Font` | `getRowSelectionFontStlye()` This method is for internal use only.
`java.awt.Color` | `getRowSelectionTextColorStlye()` This method is for internal use only.
`ShadowStyle` | `getShadowStyle()` Returns the text's drop shadow style.
`int` | `hashCode()` Computes the hash code for this `TextStyle`.
`boolean` | `isVisible()` Get whether or not the text is displayed.
`void` | `setColor(java.awt.Color newColor)` Set the color used to draw the text.
`void` | `setFont(java.awt.Font newFont)` Sets the font used when the text is drawn.
`void` | `setJustification(int newJustification)` Set the text's horizontal justification.
`void` | `setRowSelectionFontStyle(java.awt.Font newRowSelectionFont)` This method is for internal use only.
`void` | `setRowSelectionTextColorStyle(java.awt.Color newRowSelectionColor)` This method is for internal use only.
`void` | `setShadowStyle(ShadowStyle newShadow)` Set the text's drop shadow style.
`void` | `setVisible(boolean newVisible)` Set whether or not the text is displayed.

Methods inherited from class com.sas.graphics.components.ModelBase
`addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, setContainedModel`

Constructor Detail

### TextStyle

    public TextStyle()

  A TextStyle encapsulates the set of display properties applicable to text used in graphs. 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.

### TextStyle

    public TextStyle(java.awt.Font newFont,
                     java.awt.Color newColor,
                     int newJustification,
                     boolean newVisible)

  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.

  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

Method Detail

### apply

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

### setFont

    public void setFont(java.awt.Font newFont)
                 throws java.lang.IllegalArgumentException

  Sets the font used when the text is drawn.

  Parameters:
    `newFont` - the font to be used when drawing the text
  Throws:
    `java.lang.IllegalArgumentException` - if newFont is null.
  See Also:
    `getFont()`

### getFont

    public java.awt.Font getFont()

  Returns the font used to draw the text.

  Returns:
    Font used when drawing the text
  See Also:
    `setFont(java.awt.Font)`

### setColor

    public void setColor(java.awt.Color newColor)
                  throws java.lang.IllegalArgumentException

  Set the color used to draw the text.

  Parameters:
    `newColor` - the color used to draw the text.
  Throws:
    `java.lang.IllegalArgumentException` - if newColor is null.
  See Also:
    `getColor()`

### getColor

    public java.awt.Color getColor()

  Get the color used to draw the text.

  Returns:
    Color used to draw the text
  See Also:
    `setColor(java.awt.Color)`

### setJustification

    public void setJustification(int newJustification)
                          throws java.lang.IllegalArgumentException

  Set the text's horizontal justification.

       Valid values are
          javax.swing.SwingConstants.LEFT,
          javax.swing.SwingConstants.CENTER,
          javax.swing.SwingConstants.RIGHT

  Parameters:
    `newJustification` - new Justification setting
  Throws:
    `java.lang.IllegalArgumentException` - if an invalid value is passed in.
  See Also:
    `getJustification()`

### getJustification

    public int getJustification()

  Returns the type of horizontal justification.

       Valid values are:
          javax.swing.SwingConstants.LEFT,
          javax.swing.SwingConstants.CENTER,
          javax.swing.SwingConstants.RIGHT

  Returns:
    justification setting, javax.swing.SwingConstants.CENTER is default
  See Also:
    `setJustification(int)`

### setVisible

    public void setVisible(boolean newVisible)

  Set whether or not the text is displayed.

  Parameters:
    `newVisible` - true means text is displayed
  See Also:
    `isVisible()`

### isVisible

    public boolean isVisible()

  Get whether or not the text is displayed.

  Returns:
    boolean true means text is displayed
  See Also:
    `setVisible(boolean)`

### setShadowStyle

    public void setShadowStyle(ShadowStyle newShadow)
                        throws java.lang.IllegalArgumentException

  Set the text's drop shadow style.

  Parameters:
    `newShadow` - the shadow attributes
  Throws:
    `java.lang.IllegalArgumentException` - if newShadow is null.
  See Also:
    `getShadowStyle()`, `ShadowStyle.apply(com.sas.graphics.components.ShadowStyle)`

### getShadowStyle

    public ShadowStyle getShadowStyle()

  Returns the text's drop shadow style.

  Returns:
    Shadow attributes for this text.
  See Also:
    `setShadowStyle(com.sas.graphics.components.ShadowStyle)`

### getRowSelectionFontStlye

    public java.awt.Font getRowSelectionFontStlye()

  This method is for internal use only. Returns the font used to draw the text.

  Returns:
    Font used when drawing the text
  See Also:
    `setFont(java.awt.Font)`

### setRowSelectionFontStyle

    public void setRowSelectionFontStyle(java.awt.Font newRowSelectionFont)
                                  throws java.lang.IllegalArgumentException

  This method is for internal use only. Sets the font used when the text is drawn.

  Parameters:
    `newRowSelectionFont` - the font to be used when drawing the text
  Throws:
    `java.lang.IllegalArgumentException` - if newRowSelectionFont is null.
  See Also:
    `getFont()`

### getRowSelectionTextColorStlye

    public java.awt.Color getRowSelectionTextColorStlye()

  This method is for internal use only. Returns the font used to draw the text.

  Returns:
    Font used when drawing the text
  See Also:
    `setFont(java.awt.Font)`

### setRowSelectionTextColorStyle

    public void setRowSelectionTextColorStyle(java.awt.Color newRowSelectionColor)
                                       throws java.lang.IllegalArgumentException

  This method is for internal use only. Sets the color used when the text is drawn.

  Parameters:
    `newRowSelectionColor` - the color to be used when drawing the text
  Throws:
    `java.lang.IllegalArgumentException` - if newRowSelectionColor is null.
  See Also:
    `getFont()`

### equals

    public boolean equals(java.lang.Object obj)

  Determines whether another object is equal to this `TextStyle`.

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

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

### hashCode

    public int hashCode()

  Computes the hash code for this `TextStyle`.

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

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.