Eclipse GEF
3.0

org.eclipse.gef
Class SnapToGrid

java.lang.Object
  extended byorg.eclipse.gef.SnapToHelper
      extended byorg.eclipse.gef.SnapToGrid

public class SnapToGrid
extends SnapToHelper


Field Summary
protected  GraphicalEditPart container
          The graphical part whose content's figure defines the grid.
static int DEFAULT_GAP
          Deprecated. use DEFAULT_GRID_SIZE
static int DEFAULT_GRID_SIZE
          The default grid size if the viewer does not specify a size.
protected  int gridX
          The horizontal interval for the grid
protected  int gridY
          The vertical interval for the grid
protected  Point origin
          The origin of the grid.
static String PROPERTY_GRID_ENABLED
          A viewer property indicating whether the snap function is enabled.
static String PROPERTY_GRID_ORIGIN
          A viewer property indicating the grid's origin.
static String PROPERTY_GRID_SPACING
          A viewer property indicating the grid spacing.
static String PROPERTY_GRID_VISIBLE
          A viewer property indicating whether the grid should be displayed.
 
Constructor Summary
SnapToGrid(GraphicalEditPart container)
          Constructs a gridded snap helper on the given editpart.
 
Method Summary
 int snapRectangle(Request request, int snapLocations, PrecisionRectangle rect, PrecisionRectangle result)
           
 
Methods inherited from class org.eclipse.gef.SnapToHelper
makeAbsolute, makeRelative, snapPoint, snapRectangle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_GRID_ENABLED

public static final String PROPERTY_GRID_ENABLED
A viewer property indicating whether the snap function is enabled. The value must be a Boolean.

See Also:
Constant Field Values

PROPERTY_GRID_VISIBLE

public static final String PROPERTY_GRID_VISIBLE
A viewer property indicating whether the grid should be displayed. The value must be a Boolean.

See Also:
Constant Field Values

PROPERTY_GRID_SPACING

public static final String PROPERTY_GRID_SPACING
A viewer property indicating the grid spacing. The value must be a Dimension.

See Also:
Constant Field Values

PROPERTY_GRID_ORIGIN

public static final String PROPERTY_GRID_ORIGIN
A viewer property indicating the grid's origin. The value must be a Point.

See Also:
Constant Field Values

DEFAULT_GRID_SIZE

public static final int DEFAULT_GRID_SIZE
The default grid size if the viewer does not specify a size.

See Also:
PROPERTY_GRID_SPACING, Constant Field Values

DEFAULT_GAP

public static final int DEFAULT_GAP
Deprecated. use DEFAULT_GRID_SIZE

See Also:
Constant Field Values

container

protected GraphicalEditPart container
The graphical part whose content's figure defines the grid.


gridX

protected int gridX
The horizontal interval for the grid


gridY

protected int gridY
The vertical interval for the grid


origin

protected Point origin
The origin of the grid.

Constructor Detail

SnapToGrid

public SnapToGrid(GraphicalEditPart container)
Constructs a gridded snap helper on the given editpart. The editpart should be the graphical editpart whose contentspane figure is used as the reference for the grid.

Parameters:
container - the editpart which the grid is on
Method Detail

snapRectangle

public int snapRectangle(Request request,
                         int snapLocations,
                         PrecisionRectangle rect,
                         PrecisionRectangle result)
Overrides:
snapRectangle in class SnapToHelper
Parameters:
request - the request or null
rect - the prioritized rectangles to snap to
result - the output
snapLocations - the input snap locations
Returns:
the remaining snap locations
See Also:
SnapToHelper#snapRectangle(Request, int, PrecisionRectangle, PrecisionRectangle)

Eclipse GEF
3.0

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.