Search this API

y.view
Class HotSpotSnapContext

java.lang.Object
  extended by y.view.AbstractSnapContext
      extended by y.view.HotSpotSnapContext

public class HotSpotSnapContext
extends AbstractSnapContext

The context that is used by HotSpotMode and the like that manages snap lines and the snapping of node bounds during a node resize operation.

 

Constructor Summary
HotSpotSnapContext()
          Creates a new instance of this class using no initial view.
HotSpotSnapContext(Graph2DView view)
          Creates a new instance of this class using the provided view for the initial view.
 
Method Summary
protected  void addFixedSnapLines(Node node, java.util.Collection snapLines)
          Callback used by getFixedSnapLines(java.util.Collection) that collects SnapLine instances for a given fixed node.
protected  void addFixedSnapLines(NodeRealizer realizer, java.util.Collection result)
          Simple method that will add SnapLine methods to the result Collection for the given NodeRealizer.
 YPoint adjustMouseCoordinates(YPoint currentLocation, byte hotSpotType, boolean aspectRatioResize, boolean centerResize)
          Main method used by clients to actually perform the snapping of the mouse coordinates after this instances has been initialized.
 void cleanUp()
          Called after the snapping operation is done to clean up internal data structures.
protected  java.util.List getFixedSnapLines(java.util.Collection fixedNodes)
          Collects the SnapLines of the nodes that will not be resized during the current resize operation.
 void initializeResize(YPoint initialCoordinates, java.util.Collection nodesToResize, DataProvider originalNodeBoundsDP)
          Initializes this context object for a node resize operation.
 
Methods inherited from class y.view.AbstractSnapContext
addSnapLine, addSnapResult, clearAdditionalSnapLines, clearAdditionalSnapResults, collectFixedNodes, getAdditionalSnapLines, getDrawable, getInitialCoordinates, getSnapDistance, getSnapLineColor, getView, initialize, intersectsView, intersectsView, isRenderingSnapLines, processSnapResults, removeSnapResult, resetResults, setInitialCoordinates, setRenderingSnapLines, setSnapDistance, setSnapLineColor, setView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HotSpotSnapContext

public HotSpotSnapContext()
Creates a new instance of this class using no initial view. The view needs to be set before this context can be initializeResize(y.geom.YPoint, java.util.Collection, y.base.DataProvider) initialized}.


HotSpotSnapContext

public HotSpotSnapContext(Graph2DView view)
Creates a new instance of this class using the provided view for the initial view.

Parameters:
view - the view to use.
See Also:
initializeResize(y.geom.YPoint, java.util.Collection, y.base.DataProvider)
Method Detail

cleanUp

public void cleanUp()
Description copied from class: AbstractSnapContext
Called after the snapping operation is done to clean up internal data structures. This should be paired with calls to AbstractSnapContext.initialize(). Note that subclasses provide more specialized initialization and cleanup methods.

Overrides:
cleanUp in class AbstractSnapContext

initializeResize

public void initializeResize(YPoint initialCoordinates,
                             java.util.Collection nodesToResize,
                             DataProvider originalNodeBoundsDP)
Initializes this context object for a node resize operation.

Parameters:
initialCoordinates - The initial mouse coordinates.
nodesToResize - The collections of Nodes to resize during the resize operation
originalNodeBoundsDP - The bounds of the nodes before the operation. This DataProvider needs to yield for each Node an instance of Rectangle2D that describes the bounds of the node at the beginning of the resize operation.

getFixedSnapLines

protected java.util.List getFixedSnapLines(java.util.Collection fixedNodes)
Collects the SnapLines of the nodes that will not be resized during the current resize operation.

Parameters:
fixedNodes - The collection of Nodes that will stay fixed during the operation.
Returns:
A list of SnapLines that are induced by the fixed nodes.
See Also:
addFixedSnapLines(y.base.Node, java.util.Collection)

addFixedSnapLines

protected void addFixedSnapLines(Node node,
                                 java.util.Collection snapLines)
Callback used by getFixedSnapLines(java.util.Collection) that collects SnapLine instances for a given fixed node. This will only add the lines of the node to the collection if the node intersects the view.

Parameters:
node - The node to collect lines for.
snapLines - The collection to add the SnapLine instances to.
See Also:
addFixedSnapLines(NodeRealizer, java.util.Collection)

addFixedSnapLines

protected void addFixedSnapLines(NodeRealizer realizer,
                                 java.util.Collection result)
Simple method that will add SnapLine methods to the result Collection for the given NodeRealizer.

Parameters:
realizer - The realizer of a fixed node
result - The collection to add SnapLine instances to.

adjustMouseCoordinates

public YPoint adjustMouseCoordinates(YPoint currentLocation,
                                     byte hotSpotType,
                                     boolean aspectRatioResize,
                                     boolean centerResize)
Main method used by clients to actually perform the snapping of the mouse coordinates after this instances has been initialized.

Parameters:
currentLocation - The actual location of the mouse in the world coordinate system.
hotSpotType - The type of the hot spot the mouse is adjusting, see HotSpotMode.
aspectRatioResize - Whether the resize operation is an aspect ratio fixed resize.
centerResize - Whether the resize operation keeps the center of the nodes fixed.
Returns:
The snapped location of the mouse.
See Also:
AbstractSnapContext.resetResults()

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