|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.YLabel
public abstract class YLabel
This class encapsulates a multi-line text label. There are specialized classes handling labels for nodes and edges.
| Nested Class Summary | |
|---|---|
static interface |
YLabel.BoundsProvider
The interface that is used by a specific label configuration that calculates the union bounds of a label and a given rectangle. |
static class |
YLabel.Factory
This class is used for managing the different configurations for YLabel
instances. |
static interface |
YLabel.Layout
The interface that is used by a specific label configuration that calculates the layout size and determines whether a given point is contained in a label's geometry. |
static interface |
YLabel.Painter
The interface that is used by a specific label configuration that performs the painting. |
static interface |
YLabel.UserDataHandler
This interface is used during YGF serialization to delegate the copying and serialization/deserialization of any user-defined data to. |
| 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 byte |
AUTOSIZE_CONTENT
Autosize policy specifier. |
static byte |
AUTOSIZE_NONE
Autosize policy specifier. |
static byte |
BOTTOM_TEXT_POSITION
Vertical text position specifier that places text below the icon. |
static byte |
CENTER_TEXT_POSITION
Vertical and horizontal text position specifier that aligns the center of text and icon either vertically or horizontally. |
protected double |
contentHeight
(including icons, text, etc, rotation not included!) |
protected double |
contentWidth
(including icons, text, etc, rotation not included!) |
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 (including icons, text, etc, rotation considered) |
static byte |
LEFT_ALIGNED_TEXT_POSITION
Horizontal text position specifier that aligns the left border of the icon and the text. |
static byte |
LEFT_TEXT_POSITION
Horizontal text position specifier that places text to the left of the icon. |
protected byte |
model
The model constant for the label model. |
protected boolean |
offsetDirty
Whether the offset of the label is up to date or not. |
protected double |
offsetX
The x-coordinate of the label offset. |
protected double |
offsetY
The y-coordinate of the label offset. |
protected byte |
placement
The placement constant for the label model. |
static byte |
RIGHT_ALIGNED_TEXT_POSITION
Horizontal text position specifier that aligns the right border of the icon and the text. |
static byte |
RIGHT_TEXT_POSITION
Horizontal text position specifier that places text to the right of the icon. |
protected boolean |
sizeDirty
Whether the size of the label is up to date or not. |
static byte |
TOP_TEXT_POSITION
Vertical text position specifier that places text above the icon. |
protected double |
width
the width of this label. |
| Constructor Summary | |
|---|---|
protected |
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. |
boolean |
contains(double x,
double y)
Determines whether the given point in world coordinates is contained within the label's graphics. |
byte |
getAlignment()
Returns the currently set alignment style for multiple lines of label text. |
byte |
getAutoSizePolicy()
Returns the currently set autosize policy for this label. |
Color |
getBackgroundColor()
Returns the background color to be used for painting this label. |
abstract YRectangle |
getBox()
Returns the bounding box of this label. |
String |
getConfiguration()
Returns the string identifier of the current configuration this label is in. |
double |
getContentHeight()
Gets the height of the content area. |
double |
getContentWidth()
Gets the width of the content area. |
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 the bounding box of this label. |
byte |
getHorizontalTextPosition()
Returns the horizontal position of text relative to the icon. |
Icon |
getIcon()
Returns the icon that is displayed by this label and If no icon is associated with this label null is returned. |
YPoint |
getIconLocation()
Returns the absolute coordinate of the label icon. |
byte |
getIconTextGap()
Returns the gap between text and icon |
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-coordinate of the positional offset for this label. |
double |
getOffsetY()
Returns the y-coordinate of the positional offset for this label. |
byte |
getPosition()
Returns the position specifier for this label. |
double |
getRotationAngle()
Returns the rotation angle 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. |
Object |
getUserData()
Retrieves the user data object that can be used by the configurations. |
byte |
getVerticalTextPosition()
Returns the vertical position of text relative ot the icon. |
double |
getWidth()
Returns the width of the bounding box of this label. |
void |
internalSetAutoSizePolicy(byte autoSize)
This method is for internal use only and shall not be used by developers. |
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 |
isOffsetDirty()
Returns true if the label offset is
not valid yet. |
boolean |
isSelected()
Whether or not this label is in a selected state. |
boolean |
isSizeDirty()
Returns true if the label size is
not valid yet. |
boolean |
isUnderlinedTextEnabled()
Returns whether or not the text of the label should be underlined. |
boolean |
isVisible()
Whether of not this label is visible. |
void |
paint(Graphics2D gfx)
Paints the YLabel on the given graphics object. |
protected void |
paintBox(Graphics2D gfx,
double x,
double y,
double width,
double height)
Paints the background of the label into the graphics context. |
protected void |
paintContent(Graphics2D gfx,
double x,
double y,
double width,
double height)
Paints the contents of the label into the graphics context. |
protected void |
paintImpl(Graphics2D gfx,
double x,
double y,
double width,
double height)
Called by paint(java.awt.Graphics2D)
Calls paintBox(java.awt.Graphics2D, double, double, double, double)
and paintContent(java.awt.Graphics2D, double, double, double, double)
in order. |
void |
read(ObjectInputStream in)
Reads in the serialized form of this label. |
abstract void |
repaint()
Triggers a repaint of the bounds in the views for this label. |
void |
setAlignment(byte a)
Sets the vertical alignment style for label text that spreads over multiple lines. |
void |
setAutoSizePolicy(byte autoSize)
Sets the autosize policy for this label. |
void |
setBackgroundColor(Color bgColor)
Sets the background color to be used. |
abstract void |
setConfiguration(String name)
Configures this instance to use the configuration specified by the given name. |
void |
setContentHeight(double contentHeight)
Sets the height of the content area. |
void |
setContentSize(double width,
double height)
Sets the size of the content area of this label and updates the width and height properties according
to the current rotation angle. |
void |
setContentWidth(double contentWidth)
Sets the width of the content area. |
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 |
setHorizontalTextPosition(byte pos)
Sets the horizontal position of text relative to the icon. |
static void |
setHTMLRenderingEnabled(boolean enabled)
Whether or not to enable HTML rendering for labels whose text starts with the html tag <html>. |
void |
setIcon(Icon icon)
Sets the icon that is displayed by this label. |
void |
setIconTextGap(byte gap)
Sets the size of the gap between text and icon |
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 for this label. |
abstract void |
setModelParameter(Object value)
Sets the current parameters for the label model implementation. |
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-coordinate of the positional offset for this label. |
void |
setOffsetY(double y)
Sets the y-coordinate of the positional offset for this label. |
void |
setPosition(byte b)
Sets a position specifier for this label. |
void |
setRotationAngle(double angle)
Sets the rotation angle for this label. |
void |
setSelected(boolean s)
Sets the selected state 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 |
setUnderlinedTextEnabled(boolean u)
Sets whether or not to underline the text of the label |
void |
setUserData(Object userData)
Sets the user data object that can be used by the configurations. |
void |
setVerticalTextPosition(byte pos)
Sets the vertical position of text relative to the icon. |
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 |
|---|
public static final byte ALIGN_LEFT
public static final byte ALIGN_CENTER
public static final byte ALIGN_RIGHT
public static final byte TOP_TEXT_POSITION
setVerticalTextPosition(byte),
Constant Field Valuespublic static final byte CENTER_TEXT_POSITION
setVerticalTextPosition(byte),
setHorizontalTextPosition(byte),
Constant Field Valuespublic static final byte BOTTOM_TEXT_POSITION
setVerticalTextPosition(byte),
Constant Field Valuespublic static final byte LEFT_TEXT_POSITION
setHorizontalTextPosition(byte),
Constant Field Valuespublic static final byte RIGHT_TEXT_POSITION
setHorizontalTextPosition(byte),
Constant Field Valuespublic static final byte LEFT_ALIGNED_TEXT_POSITION
setHorizontalTextPosition(byte),
Constant Field Valuespublic static final byte RIGHT_ALIGNED_TEXT_POSITION
setHorizontalTextPosition(byte),
Constant Field Valuesprotected double offsetX
protected double offsetY
protected double width
protected double height
protected double contentWidth
protected double contentHeight
protected byte model
protected byte placement
protected boolean sizeDirty
protected boolean offsetDirty
public static final byte AUTOSIZE_CONTENT
YLabel.Layout implementation should use its own logic to
determine the content size.
public static final byte AUTOSIZE_NONE
setContentSize(double, double) method to
specify the desired size of the content of the label.
In that case the YLabel.Layout implementation should use the getContentWidth()
and getContentHeight() to determine the size.
public static final Insets defaultInsets
| Constructor Detail |
|---|
protected YLabel()
| Method Detail |
|---|
public Object getUserData()
configurations.
YLabel.UserDataHandlerpublic void setUserData(Object userData)
configurations.
userData - the new user data objectYLabel.UserDataHandlerpublic double getContentWidth()
getWidth()public void setContentWidth(double contentWidth)
YLabel.Layout implementation for this label
if auto size policy is set to AUTOSIZE_NONE.
contentWidth - the new width of the contentpublic boolean isSelected()
false.
public void setSelected(boolean s)
false.
isSelected()public double getContentHeight()
getHeight()public void setContentHeight(double contentHeight)
YLabel.Layout implementation for this label
if auto size policy is set to AUTOSIZE_NONE.
contentHeight - the new height of the content
public void setContentSize(double width,
double height)
width and height properties according
to the current rotation angle.
Calling this method without specifying the AUTOSIZE_NONE value for the
auto size policy will not result in the desired effect.
This method will be called by implementations of the YLabel.Layout interface as
a response to the YLabel.Layout.calculateContentSize(YLabel, java.awt.font.FontRenderContext)
method.
width - the width of the content areaheight - the height of the content areaAUTOSIZE_NONEpublic void paint(Graphics2D gfx)
configuration
to perform the actual painting in YLabel.Painter.paint(YLabel, java.awt.Graphics2D).
The default implementation will then configure the graphics context to consider rotation
and call paintImpl(java.awt.Graphics2D, double, double, double, double).
gfx - the context to paint into
protected void paintBox(Graphics2D gfx,
double x,
double y,
double width,
double height)
paintImpl(java.awt.Graphics2D, double, double, double, double), which
itself gets called by paint(java.awt.Graphics2D)
This implementation delegates to the configuration
to perform the actual painting in YLabel.Painter.paintBox(YLabel, java.awt.Graphics2D, double, double, double, double).
gfx - the graphics context (pre-configured to consider rotationx - the top left x-coordinate of the drawing areay - the top left y-coordinate of the drawing areawidth - the width of the drawing areaheight - the height of the drawing area
public boolean contains(double x,
double y)
getBox().
This implementation delegates to the configuration
to perform the check in YLabel.Layout.contains(YLabel, double, double).
x - the x world coordinate to checky - the x world coordinate to check
protected void paintContent(Graphics2D gfx,
double x,
double y,
double width,
double height)
paintImpl(java.awt.Graphics2D, double, double, double, double), which
itself gets called by paint(java.awt.Graphics2D)
This implementation delegates to the configuration
to perform the actual painting in YLabel.Painter.paintContent(YLabel, java.awt.Graphics2D, double, double, double, double).
gfx - the graphics context (pre-configured to consider rotationx - the top left x-coordinate of the drawing areay - the top left y-coordinate of the drawing areawidth - the width of the drawing areaheight - the height of the drawing area
protected void paintImpl(Graphics2D gfx,
double x,
double y,
double width,
double height)
paint(java.awt.Graphics2D)
Calls paintBox(java.awt.Graphics2D, double, double, double, double)
and paintContent(java.awt.Graphics2D, double, double, double, double)
in order.
gfx - the graphics context (pre-configured to consider rotation)x - the top left x-coordinate of the drawing areay - the top left y-coordinate of the drawing areawidth - the width of the drawing areaheight - the height of the drawing areapublic static void setHTMLRenderingEnabled(boolean enabled)
public boolean isSizeDirty()
true if the label size is
not valid yet.
public boolean isOffsetDirty()
true if the label offset is
not valid yet.
public void setSizeDirty()
public void setOffsetDirty()
public abstract void calculateOffset()
public void calculateSize()
public void calculateSize(FontRenderContext frc)
public abstract YRectangle getBox()
public abstract void repaint()
getBox(),
View.updateView(double, double, double, double)public void setVerticalTextPosition(byte pos)
pos - one of TOP_TEXT_POSITION, CENTER_TEXT_POSITION
and BOTTOM_TEXT_POSITION.public byte getVerticalTextPosition()
setVerticalTextPosition(byte)public void setHorizontalTextPosition(byte pos)
pos - one of LEFT_TEXT_POSITION, CENTER_TEXT_POSITION
and RIGHT_TEXT_POSITION.public byte getHorizontalTextPosition()
setHorizontalTextPosition(byte)public void setIconTextGap(byte gap)
public byte getIconTextGap()
public void setUnderlinedTextEnabled(boolean u)
public boolean isUnderlinedTextEnabled()
public void setRotationAngle(double angle)
public double getRotationAngle()
setRotationAngle(double)public void setInsets(Insets insets)
public Insets getInsets()
null will
be returned. In this case the default insets defaultInsets will be used.
public void setIcon(Icon icon)
public Icon getIcon()
null is returned.
public void setTextColor(Color c)
public Color getTextColor()
public boolean isVisible()
public void setVisible(boolean vis)
public byte getPosition()
public void setPosition(byte b)
public byte getModel()
public void setModel(byte m)
public void setBackgroundColor(Color bgColor)
public Color getBackgroundColor()
public void setLineColor(Color lineColor)
null is given as an argument.
By default no border will be drawn.
public Color getLineColor()
setLineColor(Color)public void setText(String text)
public String getText()
public void setOffset(double x,
double y)
public void setOffsetX(double x)
public void setOffsetY(double y)
public double getOffsetX()
public double getOffsetY()
public void setAlignment(byte a)
ALIGN_CENTER is set.
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHTpublic byte getAlignment()
setAlignment(byte)public abstract YPoint getLocation()
public YPoint getTextLocation()
public YPoint getIconLocation()
public boolean intersects(double x,
double y,
double width,
double height)
true iff the bounding box of this label
intersects with the given box.
public void calcUnionRect(Rectangle2D r)
YLabel.BoundsProvider instance
registered with this instance's configuration.
public abstract void setModelParameter(Object value)
public double getWidth()
getContentWidth() yields the width of the content area of the label.
public double getHeight()
getContentHeight() yields the height of the content area of the label.
public String toString()
toString in class Objectpublic Font getFont()
public void setFont(Font f)
public void setFontName(String name)
public String getFontName()
public int getFontSize()
public void setFontSize(int s)
public int getFontStyle()
public void setFontStyle(int s)
public void adoptValues(YLabel label)
public void write(ObjectOutputStream out)
throws IOException
IOException
public void read(ObjectInputStream in)
throws IOException,
ClassNotFoundException
write(ObjectOutputStream) method.
IOException
ClassNotFoundExceptionpublic abstract void setConfiguration(String name)
NodeLabel.getFactory()
and EdgeLabel.getFactory() respectively.
name - the name of the configuration as it has been specified in YLabel.Factory.addConfiguration(String, java.util.Map)YLabel.Factory,
YLabel.Factory.addConfiguration(String, java.util.Map)public String getConfiguration()
null if no specific configuration is used.setConfiguration(String),
YLabel.Factorypublic void setAutoSizePolicy(byte autoSize)
AUTOSIZE_CONTENT is set.
autoSize - one of the specifiers AUTOSIZE_CONTENT or AUTOSIZE_NONEpublic void internalSetAutoSizePolicy(byte autoSize)
setAutoSizePolicy(byte) instead.
public byte getAutoSizePolicy()
setAutoSizePolicy(byte).
|
© Copyright 2000-2008, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||