y.view
Class EdgeLabel

java.lang.Object
  |
  +--y.view.YLabel
        |
        +--y.view.EdgeLabel
All Implemented Interfaces:
EdgeLabelLayout, LabelLayout, LabelLayoutConstants

public class EdgeLabel
extends YLabel
implements EdgeLabelLayout

This class represents a label associated with an EdgeRealizer.

EdgeLabel has special label models and positions that are suitable for placing the label along an edgepath.


Field Summary
static byte ANYWHERE
          Edge label position specifier.
static byte CENTER
          Edge label position specifier.
static byte CENTER_RATIO
          Edge label position specifier.
static byte CENTER_SLIDER
          Edge label model specifier.
static byte CENTERED
          Edge label model specifier.
static byte DYNAMIC
          Edge label position specifier for label models EdgeLabel.SIDE_SLIDER and EdgeLabel.CENTER_SLIDER.
static byte FREE
          Edge label model specifier.
static byte HEAD
          Edge label position specifier.
static byte HEAD_RATIO
          Edge label position specifier.
static byte SCENTR
          Edge label position specifier.
static byte SHEAD
          Edge label position specifier.
static byte SIDE_SLIDER
          Edge label model specifier.
static byte SIX_POS
          Edge label model specifier.
static byte STAIL
          Edge label position specifier.
static byte TAIL
          Edge label position specifier.
static byte TAIL_RATIO
          Edge label position specifier.
static byte TCENTR
          Edge label position specifier.
static byte THEAD
          Edge label position specifier.
static byte THREE_CENTER
          Edge label model specifier.
static byte TTAIL
          Edge label position specifier.
static byte TWO_POS
          Edge label model specifier.
static byte UNDEFINED
           
 
Fields inherited from class y.view.YLabel
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, defaultInsets, height, model, offsetDirty, offsetX, offsetY, placement, sizeDirty, width
 
Fields inherited from interface y.layout.LabelLayoutConstants
PLACE_ANYWHERE, PLACE_AT_CENTER, PLACE_AT_SOURCE, PLACE_AT_TARGET, PLACE_LEFT_OF_EDGE, PLACE_ON_EDGE, PLACE_RIGHT_OF_EDGE, PLACEMENT_ALONG_EDGE_MASK, PLACEMENT_ON_SIDE_OF_EDGE_MASK
 
Constructor Summary
EdgeLabel()
          Default is visible label with empty text, model 2-pos
EdgeLabel(String str)
          Default: CENTERED labelling and visible.
EdgeLabel(String st, byte mode)
          Edge Label with positioning model mode.
 
Method Summary
 void adoptValues(YLabel label)
          Adopts the values from the given label.
static Vector availablePositions(Byte model)
           
 void bindRealizer(EdgeRealizer r)
           
 void calculateOffset()
          Calculates the offset coordinates of this label.
 Object clone()
          Returns a copy of this instance
 Object getBestModelParameterForLocation(double x, double y)
          Returns the best model parameter for this label at the given location.
 Object getBestModelParameterForOffset(double offsetX, double offsetY)
          Returns the best model parameter for this label with the given offset.
 YRectangle getBox()
          Returns the bounding box of the label
 double getDistance()
          Returns the distance of the label to the edge.
 Edge getEdge()
           
protected  Graph2D getGraph2D()
           
 EdgeLabelModel getLabelModel()
          Returns the edge label model associated with this label layout
 YPoint getLocation()
          Returns the absolute coordinates of the labels locaalcOffion.
 Object getModelParameter()
          Returns the label model parameter that describes the position of this label.
 byte[] getModelPositions()
           
static byte[] getModelPositions(byte model)
           
 EdgeRealizer getOwner()
           
 byte getPosition()
          Returns the actual position of the label.
 byte getPreferredPlacement()
          Returns the preferred placement of this label.
 double getRatio()
          Returns the source-target distance ratio of the label
 boolean hasFreePositioning()
          Whether or not this label has free positioning.
 boolean hasSliderPositioning()
           
static Map modelToStringMap()
           
static Map positionToStringMap()
           
static Map preferredPlacementsToStringMap()
           
 void read(ObjectInputStream in)
          Reads in the serialized form of this label.
 void setDistance(double _distance)
          Sets the distance of the label to the edge.
 void setLabelModel(EdgeLabelModel m)
           
 void setModel(byte mo)
          Sets the placement model for this label.
 void setModelParameter(Object param)
          Sets the label model parameter that describes the position of this label.
 void setOffset(double x, double y)
          Sets the offset coordinats of this label.
 void setOffsetDirty()
          Marks the label offsets as dirty.
 void setPosition(byte p)
          Determines which position the label should have in relation to the node.
 void setPreferredPlacement(byte placement)
           
 void setRatio(double rat)
          Sets the source-target distance ratio of the label
 void setSizeDirty()
          Marks the size of the label as dirty
 void setText(String text)
          Sets the text of this edge label.
 void write(ObjectOutputStream out)
          Writes out this label in a serialized form.
 
Methods inherited from class y.view.YLabel
calculateSize, calculateSize, calcUnionRect, getAlignment, getBackgroundColor, getFont, getFontName, getFontSize, getFontStyle, getHeight, getIcon, getInsets, getLineColor, getModel, getOffsetX, getOffsetY, getText, getTextColor, getTextLocation, getWidth, intersects, isBackgroundOn, isBackgroundPainted, isOffsetDirty, isSizeDirty, isVisible, paint, setAlignment, setBackground, setBackgroundColor, setBackgroundPainted, setFont, setFontName, setFontSize, setFontStyle, setIcon, setInsets, setLineColor, setOffsetX, setOffsetY, setOldStyleDrawer, setSize, setTextColor, setVisible, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEAD

public static final byte HEAD
Edge label position specifier. Places the label at the center of the longest edge segment above the segment.

See Also:
Constant Field Values

TAIL

public static final byte TAIL
Edge label position specifier. Places the label at the center of the longest edge segment below the segment.

See Also:
Constant Field Values

CENTER

public static final byte CENTER
Edge label position specifier. Places the label at the center of the longest edge segment.

See Also:
Constant Field Values

SHEAD

public static final byte SHEAD
Edge label position specifier. Places the label at the source node above the edge segment.

See Also:
Constant Field Values

THEAD

public static final byte THEAD
Edge label position specifier. Places the label at the target node above the edge segment.

See Also:
Constant Field Values

STAIL

public static final byte STAIL
Edge label position specifier. Places the label at the source node below the edge segment.

See Also:
Constant Field Values

TTAIL

public static final byte TTAIL
Edge label position specifier. Places the label at the target node below the edge segment.

See Also:
Constant Field Values

SCENTR

public static final byte SCENTR
Edge label position specifier. Places the label at the source node centered on the edge segment.

See Also:
Constant Field Values

TCENTR

public static final byte TCENTR
Edge label position specifier. Places the label at the target node centered on the edge segment.

See Also:
Constant Field Values

ANYWHERE

public static final byte ANYWHERE
Edge label position specifier. The position can be anywhere and depends on the specified label offset.

See Also:
Constant Field Values

CENTER_RATIO

public static final byte CENTER_RATIO
Edge label position specifier. Places the label on the edge path. The actual placement depends on a ratio value between 0.0 and 1.0.

See Also:
Constant Field Values

TAIL_RATIO

public static final byte TAIL_RATIO
Edge label position specifier. Places the label below the edge path. The actual placement depends on a ratio value between 0.0 and 1.0.

See Also:
Constant Field Values

HEAD_RATIO

public static final byte HEAD_RATIO
Edge label position specifier. Places the label above the edge path. The actual placement depends on a ratio value between 0.0 and 1.0.

See Also:
Constant Field Values

DYNAMIC

public static final byte DYNAMIC
Edge label position specifier for label models EdgeLabel.SIDE_SLIDER and EdgeLabel.CENTER_SLIDER. Places the label dynamically.

See Also:
Constant Field Values

TWO_POS

public static final byte TWO_POS
Edge label model specifier. Valid positions for this model are HEAD and TAIL.

See Also:
Constant Field Values

CENTERED

public static final byte CENTERED
Edge label model specifier. Valid position for this model is CENTER.

See Also:
Constant Field Values

SIX_POS

public static final byte SIX_POS
Edge label model specifier. Valid positions for this model are HEAD, SHEAD, THEAD, TAIL, STAIL and TTAIL.

See Also:
Constant Field Values

THREE_CENTER

public static final byte THREE_CENTER
Edge label model specifier. Valid positions for this model are CENTER, SCENTR and TCENTR.

See Also:
Constant Field Values

FREE

public static final byte FREE
Edge label model specifier. Valid position for this model is ANYWHERE.

See Also:
Constant Field Values

CENTER_SLIDER

public static final byte CENTER_SLIDER
Edge label model specifier. Valid position for this model is DYNAMIC.

See Also:
Constant Field Values

SIDE_SLIDER

public static final byte SIDE_SLIDER
Edge label model specifier. Valid position for this model is DYNAMIC.

See Also:
Constant Field Values

UNDEFINED

public static final byte UNDEFINED
See Also:
Constant Field Values
Constructor Detail

EdgeLabel

public EdgeLabel(String st,
                 byte mode)
Edge Label with positioning model mode. Default for 2-pos is head.


EdgeLabel

public EdgeLabel(String str)
Default: CENTERED labelling and visible.


EdgeLabel

public EdgeLabel()
Default is visible label with empty text, model 2-pos

Method Detail

clone

public Object clone()
Returns a copy of this instance

Overrides:
clone in class Object

adoptValues

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

Overrides:
adoptValues in class YLabel

calculateOffset

public void calculateOffset()
Calculates the offset coordinates of this label. The location of a label depends on its model and model position.

Specified by:
calculateOffset in class YLabel

setText

public void setText(String text)
Sets the text of this edge label. If this label is bound to a Graph2D the a Graph2DEvent with this label as the subject will be emitted to all registered Graph2DListeners.

Overrides:
setText in class YLabel

setDistance

public void setDistance(double _distance)
Sets the distance of the label to the edge.


setOffset

public void setOffset(double x,
                      double y)
Sets the offset coordinats of this label. Setting the offset directly does only make sense if the active label model is EdgeLabel.FREE. Otherwise this method has no effect.

Overrides:
setOffset in class YLabel

getDistance

public double getDistance()
Returns the distance of the label to the edge.


setPreferredPlacement

public void setPreferredPlacement(byte placement)

getPreferredPlacement

public byte getPreferredPlacement()
Description copied from interface: EdgeLabelLayout
Returns the preferred placement of this label. This feature is being interpreted by label aware layout algorithms.

Specified by:
getPreferredPlacement in interface EdgeLabelLayout
Returns:
an ORed combination of LabelLayoutConstants.PLACE_ANYWHERE, LabelLayoutConstants.PLACE_AT_SOURCE, LabelLayoutConstants.PLACE_AT_TARGET or LabelLayoutConstants.PLACE_AT_CENTER and LabelLayoutConstants.PLACE_LEFT_OF_EDGE, LabelLayoutConstants.PLACE_RIGHT_OF_EDGE and LabelLayoutConstants.PLACE_ON_EDGE
See Also:
LabelLayoutConstants

setRatio

public void setRatio(double rat)
Sets the source-target distance ratio of the label


getBestModelParameterForOffset

public Object getBestModelParameterForOffset(double offsetX,
                                             double offsetY)
Returns the best model parameter for this label with the given offset.


getBestModelParameterForLocation

public Object getBestModelParameterForLocation(double x,
                                               double y)
Returns the best model parameter for this label at the given location.


getRatio

public double getRatio()
Returns the source-target distance ratio of the label


hasFreePositioning

public boolean hasFreePositioning()
Whether or not this label has free positioning. A label with free positioning can be placed by setting its offset coordinates. A non-free label will be positioned according to its model and model position.


hasSliderPositioning

public boolean hasSliderPositioning()

setModel

public void setModel(byte mo)
Sets the placement model for this label. Each model defines a set of legal positions for a label and each position defines an coordinate where the label will be placed.

Overrides:
setModel in class YLabel

getPosition

public byte getPosition()
Returns the actual position of the label.

Overrides:
getPosition in class YLabel

setPosition

public void setPosition(byte p)
Determines which position the label should have in relation to the node. (e.g. CENTER). The position has to be valid in the current model.

Overrides:
setPosition in class YLabel

modelToStringMap

public static Map modelToStringMap()

positionToStringMap

public static Map positionToStringMap()

preferredPlacementsToStringMap

public static Map preferredPlacementsToStringMap()

getModelPositions

public static final byte[] getModelPositions(byte model)

getModelPositions

public byte[] getModelPositions()

availablePositions

public static Vector availablePositions(Byte model)

getEdge

public Edge getEdge()

getGraph2D

protected Graph2D getGraph2D()

getOwner

public EdgeRealizer getOwner()

bindRealizer

public void bindRealizer(EdgeRealizer r)

getLabelModel

public EdgeLabelModel getLabelModel()
Description copied from interface: EdgeLabelLayout
Returns the edge label model associated with this label layout

Specified by:
getLabelModel in interface EdgeLabelLayout

getModelParameter

public Object getModelParameter()
Description copied from interface: LabelLayout
Returns the label model parameter that describes the position of this label.

Specified by:
getModelParameter in interface LabelLayout

setModelParameter

public void setModelParameter(Object param)
Description copied from interface: LabelLayout
Sets the label model parameter that describes the position of this label.

Specified by:
setModelParameter in interface LabelLayout
Specified by:
setModelParameter in class YLabel

setLabelModel

public void setLabelModel(EdgeLabelModel m)

setOffsetDirty

public void setOffsetDirty()
Description copied from class: YLabel
Marks the label offsets as dirty.

Overrides:
setOffsetDirty in class YLabel

setSizeDirty

public void setSizeDirty()
Description copied from class: YLabel
Marks the size of the label as dirty

Overrides:
setSizeDirty in class YLabel

getBox

public YRectangle getBox()
Description copied from interface: LabelLayout
Returns the bounding box of the label

Specified by:
getBox in interface LabelLayout
Specified by:
getBox in class YLabel

getLocation

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

Specified by:
getLocation in class YLabel

write

public void write(ObjectOutputStream out)
           throws IOException
Description copied from class: YLabel
Writes out this label in a serialized form.

Overrides:
write in class YLabel
IOException

read

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

Overrides:
read in class YLabel
IOException
ClassNotFoundException

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

2003