Search this API

y.view
Class SnapLine

java.lang.Object
  extended by y.view.SnapLine
All Implemented Interfaces:
Drawable

public class SnapLine
extends java.lang.Object
implements Drawable

Models a snap line that is an line segment in the world coordinate system that is parallel to the x or y axis and to which other items (lines or points) snap to during interactive movements. AbstractSnapContext makes use of this class to interactively snap moving elements to snap lines.

 

Field Summary
static byte BOTTOM
          Constant that describes a special snap type.
static byte CENTER
          Constant that describes a special snap type.
static byte HORIZONTAL
          Constant that describes a horizontal orientation of a snap line.
static byte LEFT
          Constant that describes a special snap type.
static byte RIGHT
          Constant that describes a special snap type.
static byte TOP
          Constant that describes a special snap type.
static byte VERTICAL
          Constant that describes a vertical orientation of a snap line.
 
Constructor Summary
SnapLine(byte orientation, byte snapType, YPoint coordinates, double from, double to, java.lang.Object tag, double weight)
          Creates a new snap line using the provided attributes.
SnapLine(byte orientation, byte snapType, YPoint coordinates, java.lang.Object tag, double weight)
          Creates a new snap line using the provided attributes.
 
Method Summary
 java.awt.Rectangle getBounds()
          Yields the bounds of the canonical drawable of this snap line.
 YPoint getCoordinates()
          Gets the coordinates of the snap line.
 double getFrom()
          Yields the smaller coordinate this snap line starts from.
 byte getOrientation()
          Yields the orientation of this snap line.
 byte getSnapType()
          Yields the snapping type of this snap line.
 java.lang.Object getTag()
          Yields the tag that is associated with this snap line.
 double getTo()
          Yields the greater coordinate this snap line starts from.
 double getWeight()
          Gets the weight/importance of this snap line.
 void paint(java.awt.Graphics2D g)
          Renders a canonical drawable of this snap line.
 void setFrom(double from)
          Sets the smaller coordinate this snap line starts from.
 void setTo(double to)
          Sets the greater coordinate this snap line starts from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final byte HORIZONTAL
Constant that describes a horizontal orientation of a snap line.

See Also:
getOrientation(), Constant Field Values

VERTICAL

public static final byte VERTICAL
Constant that describes a vertical orientation of a snap line.

See Also:
getOrientation(), Constant Field Values

TOP

public static final byte TOP
Constant that describes a special snap type. This is typically used to describe snap lines to which the top sides of rectangular elements will snap.

See Also:
Constant Field Values

BOTTOM

public static final byte BOTTOM
Constant that describes a special snap type. This is typically used to describe snap lines to which the bottom sides of rectangular elements will snap.

See Also:
Constant Field Values

LEFT

public static final byte LEFT
Constant that describes a special snap type. This is typically used to describe snap lines to which the left sides of rectangular elements will snap.

See Also:
Constant Field Values

RIGHT

public static final byte RIGHT
Constant that describes a special snap type. This is typically used to describe snap lines to which the right sides of rectangular elements will snap.

See Also:
Constant Field Values

CENTER

public static final byte CENTER
Constant that describes a special snap type. This is typically used to describe snap lines to which the horizontal or vertical center lines of elements will snap.

See Also:
Constant Field Values
Constructor Detail

SnapLine

public SnapLine(byte orientation,
                byte snapType,
                YPoint coordinates,
                java.lang.Object tag,
                double weight)
Creates a new snap line using the provided attributes.

Parameters:
orientation - The orientation of the snap line. This is one of HORIZONTAL or VERTICAL
snapType - The type of the line that describes how other items will snap to this line. This is one of TOP, BOTTOM, LEFT, RIGHT, or CENTER.
coordinates - The coordinates of the center point of the snap line.
tag - A tag that is associated with this snap line - see SnapResult.getTag() for a typical use of this value.
weight - The weight (importance) of this snap line. If more than one snap line is snapped to, the one with the greater weight will be used.

SnapLine

public SnapLine(byte orientation,
                byte snapType,
                YPoint coordinates,
                double from,
                double to,
                java.lang.Object tag,
                double weight)
Creates a new snap line using the provided attributes.

Parameters:
orientation - The orientation of the snap line. One of HORIZONTAL or VERTICAL.
snapType - The type of the line that describes how other items will snap to this line. One of TOP, BOTTOM, LEFT, RIGHT, or CENTER.
coordinates - The coordinates of the center point of the snap line.
tag - A tag that is associated with this snap line - see SnapResult.getTag() for a typical use of this value.
from - The smaller value of the coordinate that delimits this snap line
to - The greater value of the coordinate that delimits this snap line
weight - The weight (importance) of this snap line. If more than one snap line is snapped to, the one with the greater weight will be used.
Method Detail

getWeight

public double getWeight()
Gets the weight/importance of this snap line. Greater values indicate greater importance.


getCoordinates

public YPoint getCoordinates()
Gets the coordinates of the snap line. This is an anchor for the line segment (typically at the center of the line).


getOrientation

public byte getOrientation()
Yields the orientation of this snap line. Either HORIZONTAL or VERTICAL.


getSnapType

public byte getSnapType()
Yields the snapping type of this snap line. Either TOP, BOTTOM, RIGHT, LEFT, or CENTER.


getFrom

public double getFrom()
Yields the smaller coordinate this snap line starts from. This is the x coordinate in case of a horizontally oriented snap line, otherwise the y coordinate.

See Also:
getOrientation(), setFrom(double), getTo(), setTo(double)

getTo

public double getTo()
Yields the greater coordinate this snap line starts from. This is the x coordinate in case of a horizontally oriented snap line, otherwise the y coordinate.

See Also:
getOrientation(), setTo(double), getFrom(), setFrom(double)

setFrom

public void setFrom(double from)
Sets the smaller coordinate this snap line starts from. This is the x coordinate in case of a horizontally oriented snap line, otherwise the y coordinate.

See Also:
getOrientation(), getFrom(), getTo(), setTo(double)

setTo

public void setTo(double to)
Sets the greater coordinate this snap line starts from. This is the x coordinate in case of a horizontally oriented snap line, otherwise the y coordinate.

See Also:
getOrientation(), getTo(), getFrom(), setFrom(double)

getBounds

public java.awt.Rectangle getBounds()
Yields the bounds of the canonical drawable of this snap line.

Specified by:
getBounds in interface Drawable

paint

public void paint(java.awt.Graphics2D g)
Renders a canonical drawable of this snap line. This implementation uses the currently set color/paint from the Graphics2D context.

Specified by:
paint in interface Drawable

getTag

public java.lang.Object getTag()
Yields the tag that is associated with this snap line. The tag is most commonly used for the snap result tag.


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