*/
@Override
public void relocate(IFigure target) {
IFigure reference = getReferenceFigure();
Rectangle targetBounds = new PrecisionRectangle(getReferenceBox()
.getResized(-1, -1));
reference.translateToAbsolute(targetBounds);
target.translateToRelative(targetBounds);
targetBounds.resize(1, 1);
Dimension targetSize = target.getPreferredSize();
switch (fLocation & PositionConstants.EAST_WEST) {
case PositionConstants.WEST:
targetBounds.x -= (targetSize.width) / 2;
targetBounds.x += fHorizontalInset;
break;
case PositionConstants.EAST:
targetBounds.x += targetBounds.width - (targetSize.width) / 2;
targetBounds.x -= fHorizontalInset;
break;
// Only North || South is given
default :
targetBounds.x += targetBounds.width/2 ;
break;
}
switch (fLocation & PositionConstants.NORTH_SOUTH) {
case PositionConstants.NORTH:
targetBounds.y -= (targetSize.height) / 2;
targetBounds.y += fVerticalInset;
break;
case PositionConstants.SOUTH:
targetBounds.y += targetBounds.height - (targetSize.height + 2) / 2;
targetBounds.y -= fVerticalInset;
break;
// Only West || East is given
default :
targetBounds.y += targetBounds.height/2 ;
break;
}
targetBounds.setSize(targetSize);
target.setBounds(targetBounds);
}