y.layout
Class SliderEdgeLabelModel

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

public class SliderEdgeLabelModel
extends Object
implements EdgeLabelModel

This class implements the slider labeling model for edges.


Nested Class Summary
static class SliderEdgeLabelModel.ModelParameter
          The model parameters for the slider model.
 
Field Summary
static byte CENTER_RATIO
           
static byte CENTER_SLIDER
           
static byte HEAD_RATIO
           
static byte LEFT_RATIO
           
static byte RIGHT_RATIO
           
static byte SIDE_SLIDER
           
static byte TAIL_RATIO
           
 
Constructor Summary
SliderEdgeLabelModel(byte mode)
          Returns a new slider edge model.
 
Method Summary
 Object createModelParameter(YRectangle labelBounds, EdgeLayout edgeLayout, NodeLayout sourceNode, NodeLayout targetNode)
          Returns a model parameter that suits the given edge label context best.
 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.
 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.
 YVector getOffsetVec(double dx, double dy, double width, double height, byte labelPosition)
          Returns the offset vector for distances to the edge.
 void setDensity(double density)
          Set the density to generate label candidate positions.
 void setDistances(double minDistance, double maxDistance)
          Set the minimum and maximum distance for the label to the edge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER_SLIDER

public static final byte CENTER_SLIDER
See Also:
Constant Field Values

SIDE_SLIDER

public static final byte SIDE_SLIDER
See Also:
Constant Field Values

CENTER_RATIO

public static final byte CENTER_RATIO
See Also:
Constant Field Values

TAIL_RATIO

public static final byte TAIL_RATIO
See Also:
Constant Field Values

HEAD_RATIO

public static final byte HEAD_RATIO
See Also:
Constant Field Values

LEFT_RATIO

public static final byte LEFT_RATIO
See Also:
Constant Field Values

RIGHT_RATIO

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

SliderEdgeLabelModel

public SliderEdgeLabelModel(byte mode)
Returns a new slider edge model.

Parameters:
mode - which slider model to use.
Method Detail

setDistances

public void setDistances(double minDistance,
                         double maxDistance)
Set the minimum and maximum distance for the label to the edge.

Parameters:
minDistance - the minimal distance from the label to the edge.
maxDistance - the maximal distance from the label to the edge.

setDensity

public void setDensity(double density)
Set the density to generate label candidate positions. A density of 1 generates the most possible candidate positions without overlap.

Parameters:
density - the density factor.

getDefaultParameter

public Object getDefaultParameter()
Returns the default position.

Specified by:
getDefaultParameter in interface EdgeLabelModel

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. This method assumes the sliding positioning model. The number and location of candidates is computed depending on the geometry of edge and label.

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.

createModelParameter

public Object createModelParameter(YRectangle labelBounds,
                                   EdgeLayout edgeLayout,
                                   NodeLayout sourceNode,
                                   NodeLayout targetNode)
Returns a model parameter that suits the given edge label context best. This implementation is based on choosing from all generated label candidates. The parameter associated with the candidate closest to the given labelBound is returned. Note that the returned paramter does not necessarily produce a label location that is identical with the given labelBound location. It is just the best appoximation within this label 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.

getOffsetVec

public YVector getOffsetVec(double dx,
                            double dy,
                            double width,
                            double height,
                            byte labelPosition)
Returns the offset vector for distances to the edge. The offset vector decribes where to move label candidates such that they keep a certain distance to the edge.


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

2003