|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.AbstractSnapContext
public class AbstractSnapContext
The common base class of MoveSnapContext
and HotSpotSnapContext
that stores the context and manages the snapping related data for ViewMode
implementations
and the like.
SnapResult
Constructor Summary | |
---|---|
AbstractSnapContext(Graph2DView view)
Instantiates a new instance for the given Graph2DView . |
Method Summary | |
---|---|
void |
addSnapLine(SnapLine snapLine)
Adds a snap line that will be used by this context in addition to the automatically generated ones. |
void |
addSnapResult(SnapResult result)
Adds a SnapResult to this instance that will be honored during calls to
processSnapResults(java.util.List,y.geom.YPoint) |
void |
cleanUp()
Called after the snapping operation is done to clean up internal data structures. |
void |
clearAdditionalSnapLines()
Clears the set of additional SnapLine s. |
void |
clearAdditionalSnapResults()
Clears additionally added snap results that have been previously added to this instance via addSnapResult(SnapResult) |
protected void |
collectFixedNodes(java.util.Collection nodesToBeChanged,
java.util.Collection fixedNodes)
Collects all nodes in the current view's graph into the provided
collection that will have their bounds fixed during the upcoming operation. |
protected java.util.List |
getAdditionalSnapLines()
Yields the list of additional SnapLine s. |
Drawable |
getDrawable()
The Drawable that will be placed into the view. |
YPoint |
getInitialCoordinates()
Gets the initial mouse coordinates at the beginning of the operation that uses this context. |
double |
getSnapDistance()
Gets the global snap distance, which is the maximum distance between the current mouse coordinates and the coordinates to which the mouse will snap. |
java.awt.Color |
getSnapLineColor()
Gets the color to use for the rendering of the snap lines. |
Graph2DView |
getView()
Gets the view associated with this context. |
protected void |
initialize()
Base method for the initialization of this context. |
protected boolean |
intersectsView(EdgeRealizer realizer,
YPoint p1,
YPoint p2)
Convenience method that determines whether a segment that is indicated by the two given endpoints and belongs to the path of the provided edge realizer is deemed visible in the current view . |
protected boolean |
intersectsView(NodeRealizer realizer)
Convenience method that determines whether the given realizer intersect the current view . |
boolean |
isRenderingSnapLines()
Indicates whether this instance will be rendering the snap lines. |
protected YPoint |
processSnapResults(java.util.List snapResults,
YPoint mouseCoordinates)
Main method of this class that processes a list of SnapResult given the current set
of mouse coordinates. |
void |
removeSnapResult(SnapResult result)
Removes a result that has previously been added to this instance via addSnapResult(SnapResult) |
void |
resetResults()
Alternative method to processSnapResults(java.util.List, y.geom.YPoint)
if no snapping should be performed. |
void |
setInitialCoordinates(YPoint initialCoordinates)
Sets the initial mouse coordinates at the beginning of the operation that uses this context. |
void |
setRenderingSnapLines(boolean renderingSnapLines)
Determines whether this instance will be rendering the snap lines. |
void |
setSnapDistance(double snapDistance)
Sets the global snap distance, which is the maximum distance between the current mouse coordinates and the coordinates to which the mouse will snap. |
void |
setSnapLineColor(java.awt.Color snapLineColor)
Sets the color to use for the rendering of the snap lines. |
void |
setView(Graph2DView view)
Sets the view instance this context will be working on. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractSnapContext(Graph2DView view)
Graph2DView
.
view
- the view, which can be null, in which case it has to be set at a later point
in time using setView(Graph2DView)
initialize()
,
cleanUp()
Method Detail |
---|
public java.awt.Color getSnapLineColor()
Color.LIGHT_GRAY
public void setSnapLineColor(java.awt.Color snapLineColor)
snapLineColor
- the new color to use - the default is Color.LIGHT_GRAY
public boolean isRenderingSnapLines()
processSnapResults(java.util.List,y.geom.YPoint)
this instance will collect all SnapResult
instances that
are currently snapped
and will display their drawable
if this flag is set to true
.
public void setRenderingSnapLines(boolean renderingSnapLines)
processSnapResults(java.util.List,y.geom.YPoint)
this instance will collect all SnapResult
instances that
are currently snapped
and will display their drawable
if this flag is set to true
.
public void addSnapResult(SnapResult result)
SnapResult
to this instance that will be honored during calls to
processSnapResults(java.util.List,y.geom.YPoint)
result
- The result to add to the processing.clearAdditionalSnapResults()
public void removeSnapResult(SnapResult result)
addSnapResult(SnapResult)
result
- the result to remove from this instance.clearAdditionalSnapResults()
public void clearAdditionalSnapResults()
addSnapResult(SnapResult)
protected YPoint processSnapResults(java.util.List snapResults, YPoint mouseCoordinates)
SnapResult
given the current set
of mouse coordinates.
This method will sort the results according to their weight
and
for set of results that share the same non-null
tag
,
the one with the greatest weight will be chosen for rendering.
This method will yield the final mouse coordinate for which the most important SnapResult
instances
have snapped
.
snapResults
- A list of SnapResult
instances that will be processed by this methodmouseCoordinates
- The coordinates to snap
resetResults()
public Graph2DView getView()
snap result
Drawable
s.
public Drawable getDrawable()
Drawable
that will be placed into the view.
This drawable will be updated after calls to processSnapResults(java.util.List, y.geom.YPoint)
and resetResults()
.
public void setView(Graph2DView view)
drawable
.
view
- the new view, which may be null
.protected boolean intersectsView(NodeRealizer realizer)
view
.
realizer
- The realizer to check.
protected boolean intersectsView(EdgeRealizer realizer, YPoint p1, YPoint p2)
view
.
realizer
- The realizer to check.p1
- The first point of the segment.p2
- The second point of the segment.
protected void collectFixedNodes(java.util.Collection nodesToBeChanged, java.util.Collection fixedNodes)
view's
graph into the provided
collection that will have their bounds fixed during the upcoming operation.
This method will use the hierarchy manager
to determine which nodes will actually be changed due to one of their children being changed.
For this the isAdjustingToChild(y.base.Node)
method will be used as a callback to
determine whether bounds changes of a child will possibly influence the bounds of a given parent node.
nodesToBeChanged
- The collection of nodes that will change their bounds during the upcoming operation.fixedNodes
- The collection to which the fixed nodes will be added by this method.public double getSnapDistance()
5.0d
public void setSnapDistance(double snapDistance)
5.0d
snapDistance
- The new snap distance.public void cleanUp()
initialize()
. Note that subclasses
provide more specialized initialization and cleanup methods.
protected void initialize()
view
has to be set on this instance.
cleanUp()
public void resetResults()
processSnapResults(java.util.List, y.geom.YPoint)
if no snapping should be performed. This will temporarily disable snapping
and clear the drawable
to not draw snap lines.
public void clearAdditionalSnapLines()
SnapLine
s.
addSnapLine(SnapLine)
public void addSnapLine(SnapLine snapLine)
clearAdditionalSnapLines()
protected java.util.List getAdditionalSnapLines()
additional
SnapLine
s.
The list of the SnapLine
instances.
public void setInitialCoordinates(YPoint initialCoordinates)
initialCoordinates
- The world coordinates of the mouse at the beginning of the operation.public YPoint getInitialCoordinates()
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |