Package org.eclipse.draw2d
Class RelativeLocator
java.lang.Object
org.eclipse.draw2d.RelativeLocator
- All Implemented Interfaces:
Locator
Places a handle relative to a figure's bounds. The placement is determined by
indicating the figure to which the placement is relative, and two
floating-point value indicating the horizontal and vertical offset from that
figure's top-left corner. The values (0.0, 0.0) would indicate the figure's
top-left corner, while the values (1.0, 1.0) would indicate the figure's
bottom-right corner.
Constants such as NORTH
and
SOUTH
can be used to set the placement.
-
Constructor Summary
ConstructorsConstructorDescriptionNull constructor.RelativeLocator
(IFigure reference, double relativeX, double relativeY) Constructs a RelativeLocator with the given reference Figure and offset ratios.RelativeLocator
(IFigure reference, int location) Constructs a RelativeLocator with the given reference figure and relative location. -
Method Summary
Modifier and TypeMethodDescriptionprotected Rectangle
Returns the Reference Box in the Reference Figure's coordinate system.protected IFigure
Returns the Figure this locator is relative to.void
Relocates the target using the relative offset locations.void
setReferenceFigure
(IFigure reference) Sets the reference figure this locator uses to place the target figure.
-
Constructor Details
-
RelativeLocator
public RelativeLocator()Null constructor. The reference figure must be set before use. The relative locations will default to (0.0, 0.0).- Since:
- 2.0
-
RelativeLocator
Constructs a RelativeLocator with the given reference figure and relative location. The location is a constant fromPositionConstants
used as a convenient and readable way to set both the relativeX and relativeY values.- Parameters:
reference
- the reference figurelocation
- one of NORTH, NORTH_EAST, etc.- Since:
- 2.0
-
RelativeLocator
Constructs a RelativeLocator with the given reference Figure and offset ratios.- Parameters:
reference
- the reference figurerelativeX
- the relative X offsetrelativeY
- the relative Y offset- Since:
- 2.0
-
-
Method Details
-
getReferenceBox
Returns the Reference Box in the Reference Figure's coordinate system. The returned Rectangle may be by reference, and should not be modified.- Returns:
- the reference box
- Since:
- 2.0
-
getReferenceFigure
Returns the Figure this locator is relative to.- Returns:
- the reference figure
- Since:
- 2.0
-
relocate
Relocates the target using the relative offset locations. -
setReferenceFigure
Sets the reference figure this locator uses to place the target figure.- Parameters:
reference
- the reference figure- Since:
- 2.0
-