public abstract class SnapResult extends Object implements Comparable<SnapResult>
SnapContext to model the result of the mouse being
snapped to a certain location.
It carries a Weight and can be used to obtain a IVisualCreator that will be included in the
view if the result is actually snapped after all other results with higher weight
have been snapped.
| Constructor and Description |
|---|
SnapResult() |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(SnapResult other)
Implements the
Comparable interface using Weight. |
static SnapResult |
createLabelSnapResult(ILabelModelParameter layoutParameter,
double weight,
PointD delta,
Object tag,
SnapLine snapLine,
PointD snappedCoordinates,
Object movedObject)
|
static SnapResult |
createPointSnapResult(PointD location,
double weight,
Object tag,
IVisualCreator visualCreator,
SnapTypes snapType)
Factory method that creates a
SnapResult that snaps to a given location. |
static SnapResult |
createResizeSnapResult(double weight,
double delta,
Object tag,
Iterable<IRectangle> rectangles,
double size,
boolean horizontal)
Factory method that creates a
SnapResult which snaps to a given size through a resize operation. |
static SnapResult |
createSnapLineSnapResult(double weight,
PointD delta,
Object tag,
SnapLine snapLine,
PointD snappedLocation,
Object movedObject)
Factory method that creates a
SnapResult which represents a SnapLine to which the current moved item
will potentially snap. |
static SnapResult |
getNullResult()
Gets a
SnapResult representing that there is no snapping of the x or y coordinate. |
Object |
getTag()
Gets the tag associated with this result.
|
abstract IVisualCreator |
getVisualCreator()
Returns a
IVisualCreator instance that can be used to create a Node for this result. |
double |
getWeight()
Gets the weight of this result.
|
boolean |
isSnapped(PointD unsnappedLocation,
SnapState finalSnapState)
Checks whether this instance is still snapped given the final mouse location.
|
protected void |
setTag(Object value)
Sets the tag associated with this result.
|
protected void |
setWeight(double value)
Sets the weight of this result.
|
void |
snap(PointD unsnappedLocation,
SnapState currentSnapState)
Core method that performs the actual snapping.
|
public final int compareTo(SnapResult other)
Comparable interface using Weight.compareTo in interface Comparable<SnapResult>other - The second SnapResultpublic static SnapResult createLabelSnapResult(ILabelModelParameter layoutParameter, double weight, PointD delta, Object tag, SnapLine snapLine, PointD snappedCoordinates, Object movedObject)
layoutParameter - The ILabelModelParameter which represents the position to snap to.weight - The weight of this result. The higher the weight, the more important it is.delta - The value to add to the mouse coordinates to snap to this result.tag - The tag associated with this result. If more than one result uses the same tag (not null), only the one with the
highest Weight will be rendered.snapLine - The snap line this class would snap to or null if it doesn't snap to a SnapLine.snappedCoordinates - The coordinates at the moved item at which the drawn snap line should end.movedObject - The moved object for which this result is created.public static SnapResult createPointSnapResult(PointD location, double weight, Object tag, IVisualCreator visualCreator, SnapTypes snapType)
SnapResult that snaps to a given location.location - The location to snap to.weight - The weight to assign to the result.tag - The tag associated with this result. If more than one result uses the same tag (not null), only the one with the
highest Weight will be rendered.visualCreator - The visual creator to use.snapType - The type of the snapping operation to apply.public static SnapResult createResizeSnapResult(double weight, double delta, Object tag, Iterable<IRectangle> rectangles, double size, boolean horizontal)
SnapResult which snaps to a given size through a resize operation.weight - The weight of this result. The higher the weight, the more important it is.delta - The value to add to the mouse coordinates to snap to this result.tag - The tag associated with this result. If more than one result uses the same tag (not null), only the one with the
highest Weight will be rendered.rectangles - The rectangles that have the same width or height as the node will. The rectangle are used for visualization and should
include all objects for which a visualization should be displayed. Typically, these are all objects which have the same
size and the object which is currently reshaped.size - The target size to which the resized object will snap.horizontal - Indicates whether width or height should snap. true if the width should snap.public static SnapResult createSnapLineSnapResult(double weight, PointD delta, Object tag, SnapLine snapLine, PointD snappedLocation, Object movedObject)
SnapResult which represents a SnapLine to which the current moved item
will potentially snap.weight - The weight of this result. The higher the weight, the more important it is.delta - The value to add to the mouse coordinates to snap to this result.tag - The tag associated with this result. If more than one result uses the same tag (not null), only the one with the
highest Weight will be rendered.snapLine - The snap line this class would snap to or null if it doesn't snap to a SnapLine.snappedLocation - The coordinates at the moved item at which the drawn snap line should end.movedObject - The moved object for which this result is created.public static final SnapResult getNullResult()
SnapResult representing that there is no snapping of the x or y coordinate.public final Object getTag()
If more than one result uses the same tag (not null), only the one with the highest Weight
will be rendered.
setTag(Object)public abstract IVisualCreator getVisualCreator()
IVisualCreator instance that can be used to create a Node for this result.VoidVisualCreator.INSTANCEpublic final double getWeight()
Higher weights represent more important results.
setWeight(double)public boolean isSnapped(PointD unsnappedLocation, SnapState finalSnapState)
This implementation simply returns false.
unsnappedLocation - The unsnapped location.finalSnapState - The final snap state that has been used by the client.protected final void setTag(Object value)
If more than one result uses the same tag (not null), only the one with the highest Weight
will be rendered.
value - The Tag to set.getTag()protected final void setWeight(double value)
Higher weights represent more important results.
value - The Weight to set.getWeight()public void snap(PointD unsnappedLocation, SnapState currentSnapState)
This implementation does nothing.
unsnappedLocation - The location prior to the snapping.currentSnapState - The currently snapped location and the state of the snapping. This instance can be modified by subclasses.