|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.SnapResult
public abstract class SnapResult
This is the abstract base class used by AbstractSnapContext and the subclasses
to model the result of the mouse being snapped to a certain coordinate.
It carries a weight and can be used to obtain a Drawable that will
be included in the view if the result is actually snapped
after all other results with higher weight have been snapped.
![]() |
![]() |
| Field Summary | |
|---|---|
static byte |
NOT_SNAPPED
Constant for use in snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has not been snapped
to its x or y values. |
static SnapResult |
NULL_RESULT
A null-object implementation of the SnapResult abstract class. |
static byte |
SNAPPED_X
Constant for use in snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has been snapped
to its x value. |
static byte |
SNAPPED_XY
Constant for use in snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has been snapped
to its x and y values. |
static byte |
SNAPPED_Y
Constant for use in snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has been snapped
to its y value. |
| Constructor Summary | |
|---|---|
protected |
SnapResult(double weight)
Constructor that takes a weight and an empty drawable. |
protected |
SnapResult(double weight,
Drawable drawable)
Constructor that takes a weight and a drawable. |
protected |
SnapResult(double weight,
Drawable drawable,
java.lang.Object tag)
Constructor that takes a weight and a drawable and a tag. |
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object o)
Implements the Comparable interface using getWeight() |
static SnapResult |
createOrthogonalSnapResult(double weight,
Drawable drawable,
boolean adjustX,
double snappedValue)
Convenience factory method that creates a simple snap result that snaps to a given x or y coordinates orthogonally. |
static SnapResult |
createOrthogonalSnapResult(double weight,
Drawable drawable,
boolean adjustX,
double snappedValue,
java.lang.Object tag)
Convenience factory method that creates a simple snap result that snaps to a given x or y coordinates orthogonally. |
Drawable |
getDrawable(AbstractSnapContext snapContext,
YPoint mouseCoordinates)
Creates a drawable that indicates the snapping of this instance. |
java.lang.Object |
getTag()
The tag associated with this result. |
double |
getWeight()
Yields the weight of this result, the higher the weight, the more important it is. |
abstract boolean |
isSnapped(YPoint unsnappedMouseCoordinates,
YPoint mouseCoordinates,
byte finalSnappingState)
Checks whether this instance is still snapped given the final mouse coordinates. |
protected void |
setTag(java.lang.Object tag)
Sets the tag to return in getTag() |
abstract byte |
snap(YPoint unsnappedCoordinates,
java.awt.geom.Point2D.Double mouseCoordinates,
byte snapState)
Core method that performs the actual snapping. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte SNAPPED_X
snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has been snapped
to its x value.
The methods can take a bitwise combination of this field and SNAPPED_Y, SNAPPED_XY,
and NOT_SNAPPED.
public static final byte SNAPPED_Y
snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has been snapped
to its y value.
The methods can take a bitwise combination of this field and SNAPPED_X, SNAPPED_XY,
and NOT_SNAPPED.
public static final byte SNAPPED_XY
snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has been snapped
to its x and y values. This is a bitwise combination of SNAPPED_X, and SNAPPED_Y.
public static final byte NOT_SNAPPED
snap(y.geom.YPoint, java.awt.geom.Point2D.Double, byte)
and isSnapped(y.geom.YPoint, y.geom.YPoint, byte) that indicates that the coordinate has not been snapped
to its x or y values.
public static final SnapResult NULL_RESULT
SnapResult abstract class.
| Constructor Detail |
|---|
protected SnapResult(double weight)
weight - the weight to yield in getWeight()
protected SnapResult(double weight,
Drawable drawable)
weight - the weight to yield in getWeight()drawable - the drawable to return in getDrawable(AbstractSnapContext,y.geom.YPoint)
protected SnapResult(double weight,
Drawable drawable,
java.lang.Object tag)
drawn.
weight - the weight to yield in getWeight()drawable - the drawable to return in getDrawable(AbstractSnapContext,y.geom.YPoint)tag - the tag to associate with this result.| Method Detail |
|---|
public java.lang.Object getTag()
null), only the one with the highest
weight will be rendered.
nullprotected void setTag(java.lang.Object tag)
getTag()
tag - the tag to use which may be null.public double getWeight()
public abstract byte snap(YPoint unsnappedCoordinates,
java.awt.geom.Point2D.Double mouseCoordinates,
byte snapState)
unsnappedCoordinates - The coordinates prior to the snapping.mouseCoordinates - The currently snapped coordinates, the result needs to be placed in here.snapState - The current snap state, which is a combination of SNAPPED_X,SNAPPED_Y,SNAPPED_XY,
or NOT_SNAPPED.
SNAPPED_X,SNAPPED_Y,SNAPPED_XY,
or NOT_SNAPPED.
public abstract boolean isSnapped(YPoint unsnappedMouseCoordinates,
YPoint mouseCoordinates,
byte finalSnappingState)
unsnappedMouseCoordinates - the unsnapped coordinatesmouseCoordinates - the resulting mouse coordinatesfinalSnappingState - the final snapping state.
public int compareTo(java.lang.Object o)
Comparable interface using getWeight()
compareTo in interface java.lang.Comparable
public Drawable getDrawable(AbstractSnapContext snapContext,
YPoint mouseCoordinates)
snapContext - The context in which this result is being used.mouseCoordinates - The final snapped mouse coordinates.
null.NULL_RESULT,
AbstractSnapContext.getInitialCoordinates()
public static SnapResult createOrthogonalSnapResult(double weight,
Drawable drawable,
boolean adjustX,
double snappedValue)
weight - The weight of the result.drawable - The drawable to use, may be null.adjustX - Whether to adjust the x coordinate.snappedValue - The value to set the coordinate to.
AbstractSnapContext.processSnapResults(java.util.List,y.geom.YPoint)
public static SnapResult createOrthogonalSnapResult(double weight,
Drawable drawable,
boolean adjustX,
double snappedValue,
java.lang.Object tag)
weight - The weight of the result.drawable - The drawable to use, may be null.adjustX - Whether to adjust the x coordinate.snappedValue - The value to set the coordinate to.tag - the tag to use for the result.
AbstractSnapContext.processSnapResults(java.util.List,y.geom.YPoint)
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||