y.view
Class YLabel

java.lang.Object
  |
  +--y.view.YLabel
Direct Known Subclasses:
EdgeLabel, NodeLabel

public abstract class YLabel
extends Object

This class encapsulates a multi-line text label. There are specialized classes handling labels for nodes and edges.


Field Summary
static byte ALIGN_CENTER
          Vertical text alignment constant.
static byte ALIGN_LEFT
          Vertical text alignment constant.
static byte ALIGN_RIGHT
          Vertical text alignment constant.
static Insets defaultInsets
          Default insets that define the distance between the bounding box of the label and its content.
protected  double height
          The height of this label
protected  byte model
           
protected  boolean offsetDirty
           
protected  double offsetX
          The x-coordinate of the label offset.
protected  double offsetY
          The y-coordinate of the label offset.
protected  byte placement
           
protected  boolean sizeDirty
           
protected  double width
          the width of this label.
 
Constructor Summary
YLabel()
          Instantiates a new YLabel.
 
Method Summary
 void adoptValues(YLabel label)
          Adopts the values from the given label.
abstract  void calculateOffset()
          Calculates the offset of this label.
 void calculateSize()
          Calculates the size of this label
 void calculateSize(FontRenderContext frc)
          Calculates the size of this label with the help of the given FontRenderContext.
 void calcUnionRect(Rectangle2D r)
          Enlarges the given rectangle such that it will contain the bounding box of this label
 byte getAlignment()
          Returns the currently set alignment style for multiple lines of label text.
 Color getBackgroundColor()
          Returns the background color to be used for painting this label.
abstract  YRectangle getBox()
          Returns the bounding box of this label.
 Font getFont()
          Returns the font used for this label.
 String getFontName()
          Returns the font name of this label.
 int getFontSize()
          Returns the font size of this label.
 int getFontStyle()
          Sets the font style for this label.
 double getHeight()
          Returns the height of this label.
 Icon getIcon()
          Returns the icon that is displayed by this label and If no icon is associated with this label null is returned.
 Insets getInsets()
          Returns the insets for this label.
 Color getLineColor()
          Returns the color used to draw a border around the bounding box of this label.
abstract  YPoint getLocation()
          Returns the absolute coordinates of the labels location.
 byte getModel()
          Returns the model specifier for this label.
 double getOffsetX()
          Returns the x-coord of the positional offset for this label.
 double getOffsetY()
          Returns the y-coord of the positional offset for this label.
 byte getPosition()
          Returns the position specifier for this label.
 String getText()
          Returns the text of this label
 Color getTextColor()
          Returns the text color of this label.
 YPoint getTextLocation()
          Returns the absolute coordinate of the label text.
 double getWidth()
          Returns the with of this label.
 boolean intersects(double x, double y, double width, double height)
          Returns true iff the bounding box of this label intersects with the given box.
 boolean isBackgroundOn()
          Deprecated. use YLabel.getBackgroundColor()} instead
 boolean isBackgroundPainted()
          Deprecated. use YLabel.getBackgroundColor()} instead
 boolean isOffsetDirty()
          Returns true if the label offset is not valid yet.
 boolean isSizeDirty()
          Returns true if the label size is not valid yet.
 boolean isVisible()
          Whether of not this label is visible.
 void paint(Graphics2D gfx)
          Paints the YLabel on the given graphics object.
 void read(ObjectInputStream in)
          Reads in the serialized form of this label.
 void setAlignment(byte a)
          Sets the vertical alignment style for label text that spreads over multiple lines.
 void setBackground(boolean b)
          Deprecated. use YLabel.setBackgroundColor(Color) instead
 void setBackgroundColor(Color bgColor)
          Sets the background color to be used.
 void setBackgroundPainted(boolean b)
          Deprecated. use YLabel.setBackgroundColor(Color) instead
 void setFont(Font f)
          Sets the font in which the text of this label gets displayed.
 void setFontName(String name)
          Sets the font name of this label.
 void setFontSize(int s)
          Sets the font size for this label.
 void setFontStyle(int s)
          Sets the font style for this label.
 void setIcon(Icon icon)
          Sets the icon that is displayed by this label.
 void setInsets(Insets insets)
          Sets the insets for this label.
 void setLineColor(Color lineColor)
          Sets the color used to draw a border around the bounding box of this label.
 void setModel(byte m)
          Sets a model specifier fo this label.
abstract  void setModelParameter(Object value)
           
 void setOffset(double x, double y)
          Sets the positional offset for this label.
 void setOffsetDirty()
          Marks the label offsets as dirty.
 void setOffsetX(double x)
          Sets the x-coord of the positional offset for this label.
 void setOffsetY(double y)
          Sets the y-coord of the positional offset for this label.
static void setOldStyleDrawer(boolean old)
          Whether or not to use the old style drawer which was the default before yFiles version 1.3.0.2.
 void setPosition(byte b)
          Sets a position specifier for this label.
 void setSize(double w, double h)
          Sets the size of this label.
 void setSizeDirty()
          Marks the size of the label as dirty
 void setText(String text)
          Sets the text being displayed by this label.
 void setTextColor(Color c)
          Sets the text color of this label.
 void setVisible(boolean vis)
          Sets the visibility state of this label.
 String toString()
          Returns a string representation of this label.
 void write(ObjectOutputStream out)
          Writes out this label in a serialized form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALIGN_LEFT

public static final byte ALIGN_LEFT
Vertical text alignment constant. This alignment type left aligns multiple lines of label text.

See Also:
Constant Field Values

ALIGN_CENTER

public static final byte ALIGN_CENTER
Vertical text alignment constant. This alignment type center aligns multiple lines of label text.

See Also:
Constant Field Values

ALIGN_RIGHT

public static final byte ALIGN_RIGHT
Vertical text alignment constant. This alignment type right aligns multiple lines of label text.

See Also:
Constant Field Values

offsetX

protected double offsetX
The x-coordinate of the label offset.


offsetY

protected double offsetY
The y-coordinate of the label offset.


width

protected double width
the width of this label.


height

protected double height
The height of this label


model

protected byte model

placement

protected byte placement

sizeDirty

protected boolean sizeDirty

offsetDirty

protected boolean offsetDirty

defaultInsets

public static final Insets defaultInsets
Default insets that define the distance between the bounding box of the label and its content.

Constructor Detail

YLabel

public YLabel()
Instantiates a new YLabel.

Method Detail

paint

public void paint(Graphics2D gfx)
Paints the YLabel on the given graphics object.


setOldStyleDrawer

public static void setOldStyleDrawer(boolean old)
Whether or not to use the old style drawer which was the default before yFiles version 1.3.0.2.


isSizeDirty

public boolean isSizeDirty()
Returns true if the label size is not valid yet.


isOffsetDirty

public boolean isOffsetDirty()
Returns true if the label offset is not valid yet.


setSizeDirty

public void setSizeDirty()
Marks the size of the label as dirty


setOffsetDirty

public void setOffsetDirty()
Marks the label offsets as dirty.


calculateOffset

public abstract void calculateOffset()
Calculates the offset of this label.


calculateSize

public void calculateSize()
Calculates the size of this label


calculateSize

public void calculateSize(FontRenderContext frc)
Calculates the size of this label with the help of the given FontRenderContext.


getBox

public abstract YRectangle getBox()
Returns the bounding box of this label.


setInsets

public void setInsets(Insets insets)
Sets the insets for this label. The insets define the distance between the label border and the label content.


getInsets

public Insets getInsets()
Returns the insets for this label. If no insets are set null will be returned. In this case the default insets YLabel.defaultInsets.


setIcon

public void setIcon(Icon icon)
Sets the icon that is displayed by this label.


getIcon

public Icon getIcon()
Returns the icon that is displayed by this label and If no icon is associated with this label null is returned.


setTextColor

public void setTextColor(Color c)
Sets the text color of this label.


getTextColor

public Color getTextColor()
Returns the text color of this label.


isVisible

public boolean isVisible()
Whether of not this label is visible.


setVisible

public void setVisible(boolean vis)
Sets the visibility state of this label.


getPosition

public byte getPosition()
Returns the position specifier for this label.


setPosition

public void setPosition(byte b)
Sets a position specifier for this label.


getModel

public byte getModel()
Returns the model specifier for this label.


setModel

public void setModel(byte m)
Sets a model specifier fo this label.


setBackground

public void setBackground(boolean b)
Deprecated. use YLabel.setBackgroundColor(Color) instead

Whether or not to paint a white background for the label.


setBackgroundPainted

public void setBackgroundPainted(boolean b)
Deprecated. use YLabel.setBackgroundColor(Color) instead

Whether or not to paint a white background for the label.


isBackgroundOn

public boolean isBackgroundOn()
Deprecated. use YLabel.getBackgroundColor()} instead

Whether or not to paint the background of this label.


isBackgroundPainted

public boolean isBackgroundPainted()
Deprecated. use YLabel.getBackgroundColor()} instead

Whether or not to paint the background of this label.


setBackgroundColor

public void setBackgroundColor(Color bgColor)
Sets the background color to be used.


getBackgroundColor

public Color getBackgroundColor()
Returns the background color to be used for painting this label.


setLineColor

public void setLineColor(Color lineColor)
Sets the color used to draw a border around the bounding box of this label. No border will be painted if null is given as an argument. By default no border will be drawn.


getLineColor

public Color getLineColor()
Returns the color used to draw a border around the bounding box of this label.

See Also:
YLabel.setLineColor(Color)

setText

public void setText(String text)
Sets the text being displayed by this label.


getText

public String getText()
Returns the text of this label


setOffset

public void setOffset(double x,
                      double y)
Sets the positional offset for this label.


setOffsetX

public void setOffsetX(double x)
Sets the x-coord of the positional offset for this label.


setOffsetY

public void setOffsetY(double y)
Sets the y-coord of the positional offset for this label.


getOffsetX

public double getOffsetX()
Returns the x-coord of the positional offset for this label.


getOffsetY

public double getOffsetY()
Returns the y-coord of the positional offset for this label.


setAlignment

public void setAlignment(byte a)
Sets the vertical alignment style for label text that spreads over multiple lines. By default ALIGN_CENTER is set.

See Also:
YLabel.ALIGN_LEFT, YLabel.ALIGN_CENTER, YLabel.ALIGN_RIGHT

getAlignment

public byte getAlignment()
Returns the currently set alignment style for multiple lines of label text.

See Also:
YLabel.setAlignment(byte)

getLocation

public abstract YPoint getLocation()
Returns the absolute coordinates of the labels location.


getTextLocation

public YPoint getTextLocation()
Returns the absolute coordinate of the label text. This will take into account insets, alignment and other text placement settings.


intersects

public boolean intersects(double x,
                          double y,
                          double width,
                          double height)
Returns true iff the bounding box of this label intersects with the given box.


calcUnionRect

public void calcUnionRect(Rectangle2D r)
Enlarges the given rectangle such that it will contain the bounding box of this label


setModelParameter

public abstract void setModelParameter(Object value)

setSize

public void setSize(double w,
                    double h)
Sets the size of this label.


getWidth

public double getWidth()
Returns the with of this label.


getHeight

public double getHeight()
Returns the height of this label.


toString

public String toString()
Returns a string representation of this label.

Overrides:
toString in class Object

getFont

public Font getFont()
Returns the font used for this label.


setFont

public void setFont(Font f)
Sets the font in which the text of this label gets displayed.


setFontName

public void setFontName(String name)
Sets the font name of this label. The style and size of this font will stay unchanged if possible.


getFontName

public String getFontName()
Returns the font name of this label.


getFontSize

public int getFontSize()
Returns the font size of this label.


setFontSize

public void setFontSize(int s)
Sets the font size for this label.


getFontStyle

public int getFontStyle()
Sets the font style for this label.


setFontStyle

public void setFontStyle(int s)
Sets the font style for this label.


adoptValues

public void adoptValues(YLabel label)
Adopts the values from the given label.


write

public void write(ObjectOutputStream out)
           throws IOException
Writes out this label in a serialized form.

IOException

read

public void read(ObjectInputStream in)
          throws IOException,
                 ClassNotFoundException
Reads in the serialized form of this label. The label must have been written out before by it's YLabel.write(ObjectOutputStream) method.

IOException
ClassNotFoundException

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003