Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse GEF
3.3

org.eclipse.gef
Class SnapToGeometry

java.lang.Object
  extended by

org.eclipse.gef.SnapToHelper
      extended by
org.eclipse.gef.SnapToGeometry
All Implemented Interfaces:
PositionConstants

public class SnapToGeometry
extends SnapToHelper

A temporary helper used to perform snapping to existing elements. This helper can be used in conjunction with the DragEditPartsTracker when dragging editparts within a graphical viewer. Snapping is based on the existing children of a container. When snapping a rectangle, the edges of the rectangle will snap to edges of other rectangles generated from the children of the given container. Similarly, the centers and middles of rectangles will snap to each other.

If the snap request is being made during a Move, Reparent or Resize, then the figures of the participants of that request will not be used for snapping. If the request is a Clone, then the figures for the parts being cloned will be used as possible snap locations.

This helper does not keep up with changes made to the container editpart. Clients should instantiate a new helper each time one is requested and not hold on to instances of the helper.

Since:
3.0

Nested Class Summary
protected static class SnapToGeometry.Entry
          A vertical or horizontal snapping point.
 
Field Summary
protected   SnapToGeometry.Entry[] cols
          The vertical columnd being snapped to.
protected   GraphicalEditPart container
          The container editpart providing the coordinates and the children to which snapping occurs.
static java.lang.String KEY_EAST_ANCHOR
          The key used to identify the East anchor point in the extended data of a request.
static java.lang.String KEY_NORTH_ANCHOR
          The key used to identify the North anchor point in the extended data of a request.
static java.lang.String KEY_SOUTH_ANCHOR
          The key used to identify the South anchor point in the extended data of a request.
static java.lang.String KEY_WEST_ANCHOR
          The key used to identify the West anchor point in the extended data of a request.
static java.lang.String PROPERTY_SNAP_ENABLED
          A property indicating whether this helper should be used.
protected   SnapToGeometry.Entry[] rows
          The horizontal rows being snapped to.
protected static double THRESHOLD
          The sensitivity of the snapping.
 
Fields inherited from interface org.eclipse.draw2d. PositionConstants
ALWAYS_LEFT, ALWAYS_RIGHT, BOTTOM, CENTER, EAST, EAST_WEST, HORIZONTAL, LEFT, LEFT_CENTER_RIGHT, MIDDLE, NONE, NORTH, NORTH_EAST, NORTH_SOUTH, NORTH_WEST, NSEW, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TOP_MIDDLE_BOTTOM, VERTICAL, WEST
 
Constructor Summary
SnapToGeometry ( GraphicalEditPart container)
          Constructs a helper that will use the given part as its basis for snapping.
 
Method Summary
protected  java.util.List generateSnapPartsList (java.util.List exclusions)
          Generates a list of parts which should be snapped to.
protected  double getCorrectionFor ( SnapToGeometry.Entry[] entries, java.util.Map extendedData, boolean vert, double near, double far)
          Returns the correction value for the given entries and sides.
protected  double getCorrectionFor ( SnapToGeometry.Entry[] entries, java.util.Map extendedData, boolean vert, double value, int side)
          Returns the correction value between ? getThreshold(), or the #getThreshold () if no corrections were found.
protected   Rectangle getFigureBounds ( GraphicalEditPart part)
          Returns the rectangular contribution for the given editpart.
protected  double getThreshold ()
          Get the sensitivity of the snapping.
protected  void populateRowsAndCols (java.util.List parts)
          Updates the cached row and column Entries using the provided parts.
protected  void setThreshold (double newThreshold)
          Set the sensitivity of the snapping.
 int snapRectangle ( Request request, int snapOrientation, PrecisionRectangle baseRect, PrecisionRectangle result)
          Applies a snap correction to a Rectangle based on a given Rectangle.
 
Methods inherited from class org.eclipse.gef. SnapToHelper
makeAbsolute, makeRelative, snapPoint, snapPoint, snapRectangle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_SNAP_ENABLED

public static final java.lang.String PROPERTY_SNAP_ENABLED
A property indicating whether this helper should be used. The value should be an instance of Boolean. Currently, this class does not check to see if the viewer property is set to true.

See Also:
EditPartViewer.setProperty(String, Object), Constant Field Values

KEY_NORTH_ANCHOR

public static final java.lang.String KEY_NORTH_ANCHOR
The key used to identify the North anchor point in the extended data of a request. The north anchor may be set to an Integer value indicating where the snapping is occurring. This is used for feedback purposes.

See Also:
Constant Field Values

KEY_SOUTH_ANCHOR

public static final java.lang.String KEY_SOUTH_ANCHOR
The key used to identify the South anchor point in the extended data of a request. The south anchor may be set to an Integer value indicating where the snapping is occurring. This is used for feedback purposes.

See Also:
Constant Field Values

KEY_WEST_ANCHOR

public static final java.lang.String KEY_WEST_ANCHOR
The key used to identify the West anchor point in the extended data of a request. The west anchor may be set to an Integer value indicating where the snapping is occurring. This is used for feedback purposes.

See Also:
Constant Field Values

KEY_EAST_ANCHOR

public static final java.lang.String KEY_EAST_ANCHOR
The key used to identify the East anchor point in the extended data of a request. The east anchor may be set to an Integer value indicating where the snapping is occurring. This is used for feedback purposes.

See Also:
Constant Field Values

THRESHOLD

protected static final double THRESHOLD
The sensitivity of the snapping. Corrections greater than this value will not occur.

See Also:
Constant Field Values

rows

protected 
SnapToGeometry.Entry[] rows
The horizontal rows being snapped to.


cols

protected 
SnapToGeometry.Entry[] cols
The vertical columnd being snapped to.


container

protected 
GraphicalEditPart container
The container editpart providing the coordinates and the children to which snapping occurs.

Constructor Detail

SnapToGeometry

public SnapToGeometry(
GraphicalEditPart container)
Constructs a helper that will use the given part as its basis for snapping. The part's contents pane will provide the coordinate system and its children determine the existing elements.

Parameters:
container - the container editpart
Since:
3.0
Method Detail

getThreshold

protected double getThreshold()
Get the sensitivity of the snapping. Corrections greater than this value will not occur.

Returns:
the snapping threshold
Since:
3.4

setThreshold

protected void setThreshold(double newThreshold)
Set the sensitivity of the snapping.

Parameters:
newThreshold - the new snapping threshold
Since:
3.4
See Also:
getThreshold()

generateSnapPartsList

protected java.util.List generateSnapPartsList(java.util.List exclusions)
Generates a list of parts which should be snapped to. The list is the original children, minus the given exclusions, minus and children whose figures are not visible.

Parameters:
exclusions - the children to exclude
Returns:
a list of parts which should be snapped to
Since:
3.0

getCorrectionFor

protected double getCorrectionFor(
SnapToGeometry.Entry[] entries,
                                  java.util.Map extendedData,
                                  boolean vert,
                                  double near,
                                  double far)
Returns the correction value for the given entries and sides. During a move, the left, right, or center is free to snap to a location.

Parameters:
entries - the entries
extendedData - the requests extended data
vert - true if the correction is vertical
near - the left/top side of the rectangle
far - the right/bottom side of the rectangle
Returns:
the correction amount or #getThreshold () if no correction was made

getCorrectionFor

protected double getCorrectionFor(
SnapToGeometry.Entry[] entries,
                                  java.util.Map extendedData,
                                  boolean vert,
                                  double value,
                                  int side)
Returns the correction value between ? getThreshold(), or the #getThreshold () if no corrections were found.

Parameters:
entries - the entries
extendedData - the map for setting values
vert - true if vertical
value - the value being corrected
side - which sides should be considered
Returns:
the correction or #getThreshold () if no correction was made

getFigureBounds

protected 
Rectangle getFigureBounds(
GraphicalEditPart part)
Returns the rectangular contribution for the given editpart. This is the rectangle with which snapping is performed.

Parameters:
part - the child
Returns:
the rectangular guide for that part
Since:
3.0

populateRowsAndCols

protected void populateRowsAndCols(java.util.List parts)
Updates the cached row and column Entries using the provided parts.

Parameters:
parts - a List of EditParts
Since:
3.0

snapRectangle

public int snapRectangle(
Request request,
                         int snapOrientation,
                         
PrecisionRectangle baseRect,
                         
PrecisionRectangle result)
Description copied from class: SnapToHelper
Applies a snap correction to a Rectangle based on a given Rectangle. The provided baseRect will be used as a reference for snapping. The types of snapping to be performed are indicated by the snapOrientation parameter. The correction is applied to the result field.

The baseRect is not modified. The correction is applied to the result. The request's extended data may contain additional information about the snapping which was performed.

All coordinate information received and returned by this method should be in absolute coordinates.

Specified by:
snapRectangle in class SnapToHelper
Parameters:
request - the request or null
baseRect - the input rectangle
result - the correction is applied to this rectangle
snapOrientation - the input snap locations
Returns:
the remaining snap locations
See Also:
SnapToHelper.snapRectangle(Request, int, PrecisionRectangle, PrecisionRectangle)

Eclipse GEF
3.3

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

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire