y.layout
Class DiscreteNodeLabelModel

java.lang.Object
  |
  +--y.layout.DiscreteNodeLabelModel
All Implemented Interfaces:
NodeLabelModel

public class DiscreteNodeLabelModel
extends Object
implements NodeLabelModel

A node label model that allows placement of labels at eight positions around a node and at four positions inside the node.

It's possible to specify an inset value that controls the distance between label and node. Furthermore there's the possibility to mask out arbitrary node 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 BOTTOM
          Symbolic position specifier.
static int BOTTOM_LEFT
          Symbolic position specifier.
static int BOTTOM_RIGHT
          Symbolic position specifier.
static int CENTER
          Symbolic position specifier.
static int CORNER_MASK
          Position mask that constrains the positions to DiscreteNodeLabelModel.NORTH_EAST, DiscreteNodeLabelModel.NORTH_WEST, DiscreteNodeLabelModel.SOUTH_EAST and DiscreteNodeLabelModel.SOUTH_WEST.
static int EAST
          Symbolic position specifier.
static int EIGHT_POS_MASK
          Position mask that allows only the eight node-external positions.
static int INTERNAL_MASK
          Position mask that allows only the eight node-internal positions.
static int LEFT
          Symbolic position specifier.
static int NORTH
          Symbolic position specifier.
static int NORTH_EAST
          Symbolic position specifier.
static int NORTH_WEST
          Symbolic position specifier.
static int RIGHT
          Symbolic position specifier.
static int SANDWICH_MASK
          Position mask that constrains the positions to DiscreteNodeLabelModel.NORTH and DiscreteNodeLabelModel.SOUTH.
static int SIDES_MASK
          Position mask that constrains the positions to DiscreteNodeLabelModel.EAST, DiscreteNodeLabelModel.WEST, DiscreteNodeLabelModel.NORTH and DiscreteNodeLabelModel.SOUTH.
static int SOUTH
          Symbolic position specifier.
static int SOUTH_EAST
          Symbolic position specifier.
static int SOUTH_WEST
          Symbolic position specifier.
static int TOP
          Symbolic position specifier.
static int TOP_LEFT
          Symbolic position specifier.
static int TOP_RIGHT
          Symbolic position specifier.
static int WEST
          Symbolic position specifier.
 
Constructor Summary
DiscreteNodeLabelModel()
          Returns a new instance of DiscreteNodeLabelModel.
DiscreteNodeLabelModel(int candidateMask)
          Returns a new instance of DiscreteNodeLabelModel.
DiscreteNodeLabelModel(int candidateMask, double inset)
          Returns a new instance of DiscreteNodeLabelModel.
 
Method Summary
 Object getDefaultParameter()
          Returns the default position.
 YList getLabelCandidates(NodeLabelLayout nl, NodeLayout nodeLayout)
          Returns a list of candidate positions for label.
protected  YPoint getLabelPlacement(YDimension labelSize, NodeLayout nodeLayout, int pos)
          Returns the position for a given label model parameter
 YPoint getLabelPlacement(YDimension labelSize, NodeLayout nodeLayout, Object param)
          Returns the positions of the lower upper corner of the label with given parameter.
 boolean isParameterValid(Object parameter)
          Returns if a given parameter is valid in the model.
 void setDistance(double distance)
          Sets the distance of the label to the node for external label positions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH

public static final int NORTH
Symbolic position specifier. Places the label north of the node.

See Also:
Constant Field Values

NORTH_WEST

public static final int NORTH_WEST
Symbolic position specifier. Places the label north-west of the node.

See Also:
Constant Field Values

NORTH_EAST

public static final int NORTH_EAST
Symbolic position specifier. Places the label north-east of the node.

See Also:
Constant Field Values

EAST

public static final int EAST
Symbolic position specifier. Places the label east of the node.

See Also:
Constant Field Values

WEST

public static final int WEST
Symbolic position specifier. Places the label west of the node.

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
Symbolic position specifier. Places the label south of the node.

See Also:
Constant Field Values

SOUTH_WEST

public static final int SOUTH_WEST
Symbolic position specifier. Places the label south-west of the node.

See Also:
Constant Field Values

SOUTH_EAST

public static final int SOUTH_EAST
Symbolic position specifier. Places the label south-east of the node.

See Also:
Constant Field Values

CENTER

public static final int CENTER
Symbolic position specifier. Places the label in the center of the node.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Symbolic position specifier. Places the label at the bottom inside of the node.

See Also:
Constant Field Values

TOP

public static final int TOP
Symbolic position specifier. Places the label at the top inside of the node.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Symbolic position specifier. Places the label at the left inside of the node.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Symbolic position specifier. Places the label at the right inside of the node.

See Also:
Constant Field Values

TOP_LEFT

public static final int TOP_LEFT
Symbolic position specifier. Places the label at the top-left inside of the node.

See Also:
Constant Field Values

TOP_RIGHT

public static final int TOP_RIGHT
Symbolic position specifier. Places the label at the top-right inside of the node.

See Also:
Constant Field Values

BOTTOM_LEFT

public static final int BOTTOM_LEFT
Symbolic position specifier. Places the label at the bottom-left inside of the node.

See Also:
Constant Field Values

BOTTOM_RIGHT

public static final int BOTTOM_RIGHT
Symbolic position specifier. Places the label at the bottom-right inside of the node.

See Also:
Constant Field Values

SANDWICH_MASK

public static final int SANDWICH_MASK
Position mask that constrains the positions to DiscreteNodeLabelModel.NORTH and DiscreteNodeLabelModel.SOUTH.

See Also:
Constant Field Values

INTERNAL_MASK

public static final int INTERNAL_MASK
Position mask that allows only the eight node-internal positions.

See Also:
Constant Field Values

SIDES_MASK

public static final int SIDES_MASK
Position mask that constrains the positions to DiscreteNodeLabelModel.EAST, DiscreteNodeLabelModel.WEST, DiscreteNodeLabelModel.NORTH and DiscreteNodeLabelModel.SOUTH.

See Also:
Constant Field Values

CORNER_MASK

public static final int CORNER_MASK
Position mask that constrains the positions to DiscreteNodeLabelModel.NORTH_EAST, DiscreteNodeLabelModel.NORTH_WEST, DiscreteNodeLabelModel.SOUTH_EAST and DiscreteNodeLabelModel.SOUTH_WEST.

See Also:
Constant Field Values

EIGHT_POS_MASK

public static final int EIGHT_POS_MASK
Position mask that allows only the eight node-external positions.

See Also:
Constant Field Values
Constructor Detail

DiscreteNodeLabelModel

public DiscreteNodeLabelModel()
Returns a new instance of DiscreteNodeLabelModel. Default mask is INTERNAL and the distance to the node is set to 4.


DiscreteNodeLabelModel

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

Parameters:
candidateMask - the allowed positions for the label.

DiscreteNodeLabelModel

public DiscreteNodeLabelModel(int candidateMask,
                              double inset)
Returns a new instance of DiscreteNodeLabelModel.

Parameters:
candidateMask - the allowed positions for the label.
inset - the distance of the label to the node.
Method Detail

setDistance

public void setDistance(double distance)
Sets the distance of the label to the node for external label positions.

Parameters:
distance - a nonnegative integer.

getDefaultParameter

public Object getDefaultParameter()
Returns the default position.

Specified by:
getDefaultParameter in interface NodeLabelModel

isParameterValid

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


getLabelPlacement

public YPoint getLabelPlacement(YDimension labelSize,
                                NodeLayout nodeLayout,
                                Object param)
Returns the positions of the lower upper corner of the label with given parameter.

Specified by:
getLabelPlacement in interface NodeLabelModel
Parameters:
labelSize - the size of the label.
nodeLayout - the geometric description of the labeled node.
param - an instance of Integer containing a vaild position.

getLabelCandidates

public YList getLabelCandidates(NodeLabelLayout nl,
                                NodeLayout nodeLayout)
Returns a list of candidate positions for label.

Specified by:
getLabelCandidates in interface NodeLabelModel

getLabelPlacement

protected YPoint getLabelPlacement(YDimension labelSize,
                                   NodeLayout nodeLayout,
                                   int pos)
Returns the position for a given label model parameter


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

2003