y.layout
Class DiscreteEdgeLabelModel

java.lang.Object
  |
  +--y.layout.DiscreteEdgeLabelModel
All Implemented Interfaces:
EdgeLabelModel

public class DiscreteEdgeLabelModel
extends Object
implements EdgeLabelModel

An edge label model that allows placement of labels at some positions along an edge.

It's possible to specify an distance value that controls the distance between label and edge. Furthermore there's the possibility to mask out arbitrary edge label candidates. This can either be done by specifing predefined candidate masks or by or-ing allowed label candidates to a user defined mask.


Field Summary
static int CENTER
           
static int CENTERED
           
static int HEAD
           
static int SCENTER
           
static int SHEAD
           
static int SIX_POS
           
static int STAIL
           
static int TAIL
           
static int TCENTER
           
static int THEAD
           
static int THREE_CENTER
           
static int TTAIL
           
static int TWO_POS
           
 
Constructor Summary
DiscreteEdgeLabelModel()
          Returns a new instance of DiscreteEdgeLabelModel.
DiscreteEdgeLabelModel(int candidateMask)
          Returns a new instance of DiscreteEdgeLabelModel.
 
Method Summary
 Object createModelParameter(YRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode)
          Creates a model parameter that represents the given edge label context best within this model.
 Object getDefaultParameter()
          Returns the default position.
 YList getLabelCandidates(EdgeLabelLayout label, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode)
          Returns a list of instances of EdgeLabelCandidates representing the label candidates.
protected  YPoint getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode, int pos)
          Return the position for a given label model parameter
 YPoint getLabelPlacement(YDimension labelSize, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode, Object para)
          Returns the location of the upper left corner of the label according to a certain parameter.
 boolean isParameterValid(Object parameter)
          Returns if a given parameter is valid in the model.
 void setDistance(double value)
          Sets the distance from the edge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHEAD

public static final int SHEAD
See Also:
Constant Field Values

HEAD

public static final int HEAD
See Also:
Constant Field Values

THEAD

public static final int THEAD
See Also:
Constant Field Values

STAIL

public static final int STAIL
See Also:
Constant Field Values

TAIL

public static final int TAIL
See Also:
Constant Field Values

TTAIL

public static final int TTAIL
See Also:
Constant Field Values

SCENTER

public static final int SCENTER
See Also:
Constant Field Values

CENTER

public static final int CENTER
See Also:
Constant Field Values

TCENTER

public static final int TCENTER
See Also:
Constant Field Values

TWO_POS

public static final int TWO_POS
See Also:
Constant Field Values

CENTERED

public static final int CENTERED
See Also:
Constant Field Values

SIX_POS

public static final int SIX_POS
See Also:
Constant Field Values

THREE_CENTER

public static final int THREE_CENTER
See Also:
Constant Field Values
Constructor Detail

DiscreteEdgeLabelModel

public DiscreteEdgeLabelModel()
Returns a new instance of DiscreteEdgeLabelModel. Default Model is SIX_POS.


DiscreteEdgeLabelModel

public DiscreteEdgeLabelModel(int candidateMask)
Returns a new instance of DiscreteEdgeLabelModel.

Parameters:
candidateMask - the allowed positions for the label.
Method Detail

setDistance

public void setDistance(double value)
Sets the distance from the edge.


getDefaultParameter

public Object getDefaultParameter()
Returns the default position.

Specified by:
getDefaultParameter in interface EdgeLabelModel

createModelParameter

public Object createModelParameter(YRectangle labelBounds,
                                   EdgeLayout edgeLayout,
                                   NodeLayout sourceNode,
                                   NodeLayout targetNode)
Description copied from interface: EdgeLabelModel
Creates a model parameter that represents the given edge label context best within this model. The created model parameter represents the closest parameter representation of the given label location that can be achived within the model.

Specified by:
createModelParameter in interface EdgeLabelModel
Parameters:
labelBounds - the bounds of the label for which a parameter representation is sought.
edgeLayout - the layout of the edge to which the label belongs.
sourceNode - the layout of the source node of the label owning edge.
targetNode - the layout of the target node of the label owning edge.

isParameterValid

public boolean isParameterValid(Object parameter)
Returns if a given parameter is valid in the model.


getLabelPlacement

public YPoint getLabelPlacement(YDimension labelSize,
                                EdgeLayout edgeLayout,
                                NodeLayout sourceNode,
                                NodeLayout targetNode,
                                Object para)
Returns the location of the upper left corner of the label according to a certain parameter.

Specified by:
getLabelPlacement in interface EdgeLabelModel
Parameters:
labelSize - the size of the label that should be placed
edgeLayout - the layout of the edge to which the label belongs.
sourceNode - the layout of the source node of the label owning edge.
targetNode - the layout of the target node of the label owning edge.
para - the model paramter that describes the abstract position of the label within this model. The parameter must have been generated by this model.

getLabelCandidates

public YList getLabelCandidates(EdgeLabelLayout label,
                                EdgeLayout edgeLayout,
                                NodeLayout sourceNode,
                                NodeLayout targetNode)
Returns a list of instances of EdgeLabelCandidates representing the label candidates.

Specified by:
getLabelCandidates in interface EdgeLabelModel
Parameters:
label - label for which candidates should be generated
edgeLayout - the layout of the edge to which the label belongs.
sourceNode - the layout of the source node of the label owning edge.
targetNode - the layout of the target node of the label owning edge.

getLabelPlacement

protected YPoint getLabelPlacement(YDimension labelSize,
                                   EdgeLayout edgeLayout,
                                   NodeLayout sourceNode,
                                   NodeLayout targetNode,
                                   int pos)
Return the position for a given label model parameter


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

2003