com.sas.visuals
Class StyledLabelView

com.sas.visuals.StyledLabelView
All Implemented Interfaces:
com.sas.awt.print.PrintableInterface, VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.lang.StringDataInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.PublicClonable, com.sas.ViewDefaultModelInterface, com.sas.ViewInterface, Alignment, com.sas.visuals.IconInterface, MultipleValueEventSourceInterface, com.sas.visuals.PainterInterface, ResizeToFitInterface, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class StyledLabelView

StyledLabelView is a sub-class of LabelView that parses the text into TextElements and paints it based on tags placed in the text. The StyledLabelView also supports sending ActionEvents when text between action tags is clicked on by the mouse.

Notes:


See Also:
TextElement, Serialized Form

Field Summary
 
Fields inherited from class com.sas.visuals.LabelView
BOTTOM, CENTER_LEFT, CENTER_RIGHT, LEFT, RIGHT, TOP
 
Fields inherited from interface com.sas.visuals.Alignment
BEGIN, CENTER, END
 
Constructor Summary
StyledLabelView()
          Default constructor.
StyledLabelView(java.lang.String text)
          Constructor that sets the text displayed.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Add an ActionListener to listen for ActionEvents on the StyledLabelView
protected  java.awt.Dimension calculateTextDisplay()
          Parse the textElements and determine their locations and sizes based on the font and text.
static int getDefaultHeight()
           
static int getDefaultWidth()
           
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
protected  java.awt.Point getInitialPoint(int x, int y, int width, int height)
          Get the initial point to start calling paintTextElements().
 void paint(java.awt.Component component, java.awt.Graphics g, int x, int y, int width, int height)
          Paint of the text on the labelView.
protected  void paintTextElement(java.awt.Graphics g, TextElement element, int x, int y)
          Paint the text element based on its properties.
protected  void paintTextElements(java.awt.Graphics g, TextElement element, int x, int y)
          Paint the text element at the specified position.
protected  void parseText()
          Parse the text into the appropriate elements for display.
protected  void processActionEvent(java.awt.event.ActionEvent e)
          Process ActionEvents.
protected  void processEvent(java.awt.AWTEvent e)
          Process events.
 void removeActionListener(java.awt.event.ActionListener listener)
          Remove an ActionListener from the list of listeners to be notified of an ActionEvent.
static void setDefaultHeight(int newHeight)
           
 void setDefaultValues()
          Set the default internal values for the AnimationIconView.
static void setDefaultWidth(int newWidth)
           
 void setFont(java.awt.Font font)
          Sets the font of the LabelView.
 void setForeground(java.awt.Color fgColor)
           
 void setHorizontalAlignment(int align)
          Set the horizontal alignment of the text.
 
Methods inherited from class com.sas.visuals.LabelView
addNotify, attachModel, clone, computePreferredSize, detachModel, getHorizontalAlignment, getInsets, getMinimumSize, getRequiredInterfaces, getTabSpace, getText, getVerticalAlignment, isDefaultModelAttached, isResizeToFit, isWordWrap, paint, print, print, propertyChange, refresh, refresh, resizeToFit, setBounds, setEnabled, setInsets, setResizeToFit, setTabSpace, setText, setVerticalAlignment, setWordWrap, wordWrap
 
Methods inherited from class com.sas.awt.ComponentVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachView, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getModelInterface, getPageBounds, getPreferredSize, getPrePainter, getPrintOptionsPanel, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, initialize, initializeComponent, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, pageExists, printFinalize, printInitialize, queryLinks, queryLinks, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setComponentDescription, setComponentSupportInfo, setFocus, setForegroundColor, setHeight, setHorizontalPosition, setLinkInfo, setModelInterface, setPreferredSize, setPrePainter, setRequiredInterfaces, setTransparent, setVerticalPosition, setViewInterfaceSupportInfo, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, update, validateObject
 
Methods inherited from interface com.sas.visuals.IconInterface
getPreferredSize
 

Constructor Detail

StyledLabelView

public StyledLabelView()
Default constructor.


StyledLabelView

public StyledLabelView(java.lang.String text)
Constructor that sets the text displayed.

Parameters:
text - the text displayed by the StyledLabelView
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

getDefaultHeight

public static int getDefaultHeight()

getDefaultWidth

public static int getDefaultWidth()

setDefaultHeight

public static void setDefaultHeight(int newHeight)

setDefaultWidth

public static void setDefaultWidth(int newWidth)

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Add an ActionListener to listen for ActionEvents on the StyledLabelView

Parameters:
listener - the ActionListener to send the ActionEvents to.
See Also:
ActionListener, removeActionListener(java.awt.event.ActionListener)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Remove an ActionListener from the list of listeners to be notified of an ActionEvent.

See Also:
ActionListener, addActionListener(java.awt.event.ActionListener)

paint

public void paint(java.awt.Component component,
                  java.awt.Graphics g,
                  int x,
                  int y,
                  int width,
                  int height)
Paint of the text on the labelView.

Specified by:
paint in interface com.sas.visuals.PainterInterface
Overrides:
paint in class LabelView
Parameters:
comp - the Component to paint the IconInterface with.
g - Graphics context
x - the x coordinate
y - the y coordinate
width - the width to be painted.
height - the height to be painted.

paintTextElements

protected void paintTextElements(java.awt.Graphics g,
                                 TextElement element,
                                 int x,
                                 int y)
Paint the text element at the specified position. Recursive function that calls paintTextElement for non-recursive elements.

Parameters:
g - the Graphics context
element - the text element
x - the x coordinate
y - the coordinate

paintTextElement

protected void paintTextElement(java.awt.Graphics g,
                                TextElement element,
                                int x,
                                int y)
Paint the text element based on its properties. This handles font, color, and underline properties.

Parameters:
g - the Graphics context
element - the TextElement
x - the x coordinate
y - the y coordinate

getInitialPoint

protected java.awt.Point getInitialPoint(int x,
                                         int y,
                                         int width,
                                         int height)
Get the initial point to start calling paintTextElements(). The initial point is based on the horizontal and vertical alignment and the overall size of the text.

Parameters:
x - the x coordinate
y - the y coordinate
width - the width of the component
height - the height of the component
Returns:
the initial Point to start painting the text.

parseText

protected void parseText()
Parse the text into the appropriate elements for display. The tags are:
<u> underlined </u>
<font:name-type-size>font</font>
<color:#fffffff>color</color>
<action:ActionCommand>action text</action>

Overrides:
parseText in class LabelView

calculateTextDisplay

protected java.awt.Dimension calculateTextDisplay()
Parse the textElements and determine their locations and sizes based on the font and text.

Overrides:
calculateTextDisplay in class LabelView
Returns:
the overall dimension of the text to be displayed

processEvent

protected void processEvent(java.awt.AWTEvent e)
Process events.

Overrides:
processEvent in class java.awt.Component

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent e)
Process ActionEvents.


setDefaultValues

public void setDefaultValues()
Set the default internal values for the AnimationIconView.

Specified by:
setDefaultValues in interface VisualInterface
Specified by:
setDefaultValues in interface com.sas.ComponentInterface
Overrides:
setDefaultValues in class LabelView
See Also:
ComponentInterface.setDefaultValues()

setForeground

public void setForeground(java.awt.Color fgColor)
Overrides:
setForeground in class java.awt.Component

setFont

public void setFont(java.awt.Font font)
Description copied from class: LabelView
Sets the font of the LabelView. Calculates the new text dimensions after this new font has been set.

Specified by:
setFont in interface VisualInterface
Overrides:
setFont in class LabelView
Parameters:
font - the font to be used when displaying text in this LabelView
See Also:
VisualInterface.setFont(java.awt.Font)

setHorizontalAlignment

public void setHorizontalAlignment(int align)
Set the horizontal alignment of the text.

Overrides:
setHorizontalAlignment in class LabelView
Parameters:
align - the horizontal alignment values: LEFT, RIGHT, or CENTER
See Also:
LabelView.getHorizontalAlignment()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.