本文整理汇总了Java中org.eclipse.gef.handles.HandleBounds类的典型用法代码示例。如果您正苦于以下问题:Java HandleBounds类的具体用法?Java HandleBounds怎么用?Java HandleBounds使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HandleBounds类属于org.eclipse.gef.handles包,在下文中一共展示了HandleBounds类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
Rectangle tempRect = figure.getBounds();
if (figure instanceof HandleBounds)
tempRect = ((HandleBounds) figure).getHandleBounds();
Graphics2D g = ComponentFigure.getG2D(graphics);
if (g != null) {
Stroke oldStroke = g.getStroke();
g.setStroke(new BasicStroke(0.1f));
if (getColor() != null)
g.setColor((J2DGraphics.toAWTColor(getColor())));
g.drawRect(tempRect.x, tempRect.y, tempRect.width - 1, tempRect.height - 1);
g.setStroke(oldStroke);
}
}
示例2: paint
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
@Override
public void paint(Graphics graphics) {
Rectangle b = (this instanceof HandleBounds) ? ((HandleBounds) this).getHandleBounds() : this.getBounds();
try {
graphics.translate(b.x, b.y);
Graphics2D graphics2d = getG2D(graphics);
if (graphics2d != null) {
if (drawVisitor != null) {
drawVisitor.setGraphics2D(graphics2d);
draw(drawVisitor, jrElement);
} else
graphics2d.drawRect(b.x, b.y, b.width, b.height);
} else {
System.out.println("not a 2d");
}
} catch (Exception e) {
// when a font is missing exception is thrown by DrawVisitor
// FIXME: maybe draw something, else?
e.printStackTrace();
} finally {
graphics.translate(-b.x, -b.y);
}
paintBorder(graphics);
paintDecorators(graphics);
}
示例3: PreferredSizeSquareHandle
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
public PreferredSizeSquareHandle(GraphicalEditPart editpart) {
super(editpart, new RelativeLocator(getHostFigure(), 0.75, 1) {
protected Rectangle getReferenceBox() {
IFigure f = getReferenceFigure();
if (f instanceof HandleBounds)
return ((HandleBounds) f).getHandleBounds();
return super.getReferenceBox();
}
});
}
示例4: paint
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
@Override
public void paint(Graphics graphics) {
Rectangle b = (this instanceof HandleBounds) ? ((HandleBounds) this).getHandleBounds() : this.getBounds();
Graphics2D g = ComponentFigure.getG2D(graphics);
if (g != null) {
g.setPaint(tp);
g.fillRect(b.x, b.y, b.width - 1, b.height - 1);
}
paintBorder(graphics);
}
示例5: relocate
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
@Override
public void relocate(IFigure target) {
IFigure reference = getReferenceFigure();
Rectangle referenceBox = ((HandleBounds) reference).getHandleBounds();
Rectangle targetBounds = new PrecisionRectangle(referenceBox.getResized(-1, -1));
reference.translateToAbsolute(targetBounds);
target.translateToRelative(targetBounds);
targetBounds.resize(1, 1);
int w = 2;
int h = 2;
switch (direction & PositionConstants.NORTH_SOUTH) {
case PositionConstants.NORTH:
w = targetBounds.width;
targetBounds.y += (int) (targetBounds.height * relativeY - ((h / 2))) + 1;
break;
case PositionConstants.SOUTH:
w = targetBounds.width;
targetBounds.y += (int) (targetBounds.height * relativeY - (h / 2)) - 1;
targetBounds.x += -1;
break;
}
switch (direction & PositionConstants.EAST_WEST) {
case PositionConstants.WEST:
h = targetBounds.height;
targetBounds.y += (int) relativeY - 1;
targetBounds.x += (int) (targetBounds.width * relativeX - (w / 2)) - 1;
break;
case PositionConstants.EAST:
h = targetBounds.height;
targetBounds.y += (int) relativeY - 1;
targetBounds.x += (int) (targetBounds.width * relativeX - (w / 2) - 1);
break;
}
targetBounds.setSize(w, h);
target.setBounds(targetBounds);
}
示例6: getConstraintFor
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
@Override
protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
// if (child instanceof IContainerPart) {
// return ((IContainerPart) child).getConstraintFor(request, child);
// }
// If we are dragging a band, we need to check the bounds and suggest a
// proper
// new location accordingly with the max and min band size.
IFigure figure = child.getFigure();
Rectangle bounds = figure.getBounds();
if (figure instanceof HandleBounds) {
bounds = ((HandleBounds) figure).getHandleBounds();
// if (request.getResizeDirection() == PositionConstants.NORTH
// || request.getResizeDirection() == PositionConstants.SOUTH)
bounds.width--;
// if (request.getResizeDirection() == PositionConstants.EAST
// || request.getResizeDirection() == PositionConstants.WEST)
bounds.height--;
}
Rectangle rect = new PrecisionRectangle(bounds);
figure.translateToAbsolute(rect);
rect = request.getTransformedRectangle(rect);
figure.translateToRelative(rect);
rect.translate(getLayoutOrigin().getNegated());
if (request.getSizeDelta().width == 0 && request.getSizeDelta().height == 0) {
Rectangle cons = getCurrentConstraintFor(child);
if (cons != null) // Bug 86473 allows for unintended use of this method
rect.setSize(cons.width, cons.height);
} else { // resize
Dimension minSize = getMinimumSizeFor(child);
if (rect.width < minSize.width) {
rect.width = minSize.width;
}
if (rect.height < minSize.height) {
rect.height = minSize.height;
}
}
return getConstraintFor(rect);
}
示例7: paint
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
public void paint(IFigure figure, Graphics graphics, Insets insets) {
Graphics2D g = ComponentFigure.getG2D(graphics);
if (g != null) {
org.eclipse.draw2d.geometry.Rectangle bounds = figure.getBounds();
if (figure instanceof HandleBounds)
bounds = ((HandleBounds) figure).getHandleBounds();
paintShadowBorder(g, bounds.x - insets.left, bounds.y - insets.top, bounds.width + insets.right + insets.left,
bounds.height + insets.top + insets.bottom);
}
}
示例8: paint
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
Rectangle bounds = figure.getBounds();
if (figure instanceof HandleBounds)
bounds = ((HandleBounds) figure).getHandleBounds();
Graphics2D g = ComponentFigure.getG2D(graphics);
if (g != null) {
Stroke oldStroke = g.getStroke();
g.setStroke(new BasicStroke(0.1f));
if (getColor() != null)
g.setColor((J2DGraphics.toAWTColor(getColor())));
int bottom = bounds.y + bounds.height - 1;
int right = bounds.x + bounds.width - 1;
// top left
g.drawLine(bounds.x, bounds.y, bounds.x + o, bounds.y);
g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + o);
// top right
g.drawLine(right - o, bounds.y, right, bounds.y);
g.drawLine(right, bounds.y, right, bounds.y + o);
// bottom left
g.drawLine(bounds.x, bottom, bounds.x + o, bottom);
g.drawLine(bounds.x, bottom, bounds.x, bottom - o);
// bottom right
g.drawLine(right - o, bottom, right, bottom);
g.drawLine(right, bottom, right, bottom - o);
if (bounds.width > 50) {
g.drawLine(bounds.x + bounds.width / 2 - o / 2, bounds.y, bounds.x + bounds.width / 2 + o / 2, bounds.y);
g.drawLine(bounds.x + bounds.width / 2 - o / 2, bottom, bounds.x + bounds.width / 2 + o / 2, bottom);
}
g.setStroke(oldStroke);
}
}
示例9: paint
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
public void paint(IFigure figure, Graphics graphics, Insets insets) {
org.eclipse.draw2d.geometry.Rectangle bounds = figure.getBounds();
if (figure instanceof HandleBounds)
bounds = ((HandleBounds) figure).getHandleBounds();
paintShadowBorder(graphics, bounds.x - insets.left, bounds.y - insets.top, bounds.width + insets.right
+ insets.left, bounds.height + insets.top + insets.bottom);
}
示例10: showFocus
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
/**
* Shows a focus rectangle around the host's figure. The focus rectangle is
* expanded by 5 pixels from the figure's bounds.
*
* @see org.eclipse.gef.editpolicies.SelectionEditPolicy#showFocus()
*/
protected void showFocus() {
focusRect = new AbstractHandle((GraphicalEditPart) getHost(),
new Locator() {
public void relocate(IFigure target) {
IFigure figure = getHostFigure();
Rectangle r;
if (figure instanceof HandleBounds)
r = ((HandleBounds) figure).getHandleBounds()
.getCopy();
else
r = getHostFigure().getBounds().getResized(-1, -1);
getHostFigure().translateToAbsolute(r);
target.translateToRelative(r);
target.setBounds(r.expand(5, 5).resize(1, 1));
}
}) {
{
setBorder(new FocusBorder());
}
protected DragTracker createDragTracker() {
return null;
}
};
addFeedback(focusRect);
}
示例11: relocate
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
@Override
public void relocate(IFigure target) {
IFigure reference = getReferenceFigure();
Rectangle referenceBox = ((HandleBounds) reference).getHandleBounds();
Rectangle targetBounds = new PrecisionRectangle(referenceBox.getResized(-1, -1));
reference.translateToAbsolute(targetBounds);
target.translateToRelative(targetBounds);
targetBounds.resize(1, 1);
double xzoom = GEFUtil.getZoom(editPart);
Dimension targetSize = target.getPreferredSize();
Dimension d = targetSize;
if (editPart instanceof IContainerPart) {
d = ((IContainerPart) editPart).getContaierSize();
// Commented for back-compatibility in 3.6.
// Replaced with the following 3 lines.
// d = d.getCopy().setHeight(d.height + 18).scale(xzoom);
Dimension dcopy = d.getCopy();
dcopy.height = d.height + 18;
d = dcopy.scale(xzoom);
}
int w = 4;
int h = 4;
switch (direction & PositionConstants.NORTH_SOUTH) {
case PositionConstants.NORTH:
w = d.width + 1;
targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height)));// + 1;
targetBounds.x = (int) Math.floor(10 * xzoom);
break;
case PositionConstants.SOUTH:
w = d.width + 1;
targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height))) - 1;// + 1) / 2)) + 1;
targetBounds.x = (int) Math.floor(10 * xzoom);
break;
}
switch (direction & PositionConstants.EAST_WEST) {
case PositionConstants.WEST:
h = d.height - (int) Math.floor(10 * xzoom);
targetBounds.y = (int) Math.floor(7 * xzoom);// += (int) relativeY - 1;
targetBounds.x += (int) (targetBounds.width * relativeX - (targetSize.width));// + 1;// + 1;
break;
case PositionConstants.EAST:
h = d.height - (int) Math.floor(10 * xzoom);
targetBounds.y = (int) Math.floor(7 * xzoom);// += (int) relativeY - 1;
targetBounds.x += (int) (targetBounds.width * relativeX - (targetSize.width)) - 1;// / 2);// + 1;
break;
}
targetBounds.setSize(w + 1, h + 1);
target.setBounds(targetBounds);
}
示例12: TextOverlay
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
public TextOverlay() {
super((GraphicalEditPart) getHost(), new MoveHandleLocator(getHostFigure()) {
@Override
public void relocate(IFigure target) {
if (!getHostFigure().isShowing()
|| nodeText == null || nodeText.length() == 0) {
super.relocate(target);
return;
}
Rectangle figureBounds;
if (getReference() instanceof HandleBounds) {
figureBounds = ((HandleBounds)getReference()).getHandleBounds();
} else {
figureBounds = getReference().getBounds();
}
figureBounds = new Rectangle(figureBounds.getResized(-1, -1));
int xInset = 3;
switch (getDesiredAlignment()) {
case TRUNCATE:
figureBounds.x += xInset;
figureBounds.width = figureBounds.width - 2*xInset;
break;
case LEFT:
figureBounds.x += xInset;
figureBounds.width = textSize.width + 2*xInset;
break;
case CENTER:
figureBounds.x = figureBounds.x + figureBounds.width/2 - textSize.width/2;
figureBounds.width = textSize.width + 2*xInset;
break;
case RIGHT:
figureBounds.x = figureBounds.x + figureBounds.width - textSize.width - xInset;
figureBounds.width = textSize.width + 2*xInset;
break;
case TRAILING:
figureBounds.x = figureBounds.x + figureBounds.width + xInset;
figureBounds.width = textSize.width + 2*xInset;
break;
}
figureBounds.y = figureBounds.y + figureBounds.height/2 - textSize.height/2;
Insets insets = target.getInsets();
figureBounds.translate(-insets.left, -insets.top);
figureBounds.resize(insets.getWidth() + 1, insets.getHeight() + 1);
if (!CommonUtils.equals(target.getBounds(), figureBounds)) {
target.setBounds(figureBounds);
}
}
});
}
示例13: getInitialFeedbackBounds
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
/**
* Returns the bounds of the host's figure by reference to be used to
* calculate the initial location of the feedback. The returned Rectangle
* should not be modified. Uses handle bounds if available.
*
* @return the host figure's bounding Rectangle
*/
protected Rectangle getInitialFeedbackBounds() {
if (((GraphicalEditPart) getHost()).getFigure() instanceof HandleBounds)
return ((HandleBounds) ((GraphicalEditPart) getHost()).getFigure())
.getHandleBounds();
return ((GraphicalEditPart) getHost()).getFigure().getBounds();
}
示例14: getFigureBounds
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
/**
* Returns the rectangular contribution for the given editpart. This is the
* rectangle with which snapping is performed.
*
* @since 3.0
* @param part
* the child
* @return the rectangular guide for that part
*/
protected Rectangle getFigureBounds(GraphicalEditPart part) {
IFigure fig = part.getFigure();
if (fig instanceof HandleBounds)
return ((HandleBounds) fig).getHandleBounds();
return fig.getBounds();
}
示例15: getInitialFeedbackBounds
import org.eclipse.gef.handles.HandleBounds; //导入依赖的package包/类
/**
* Returns the bounds of the host's figure by reference to be used to
* calculate the initial location of the feedback. The returned Rectangle
* should not be modified. Uses handle bounds if available.
*
* @return the host figure's bounding Rectangle
*/
protected Rectangle getInitialFeedbackBounds() {
if (((GraphicalEditPart) getHost()).getFigure() instanceof HandleBounds)
return ((HandleBounds) ((GraphicalEditPart) getHost()).getFigure()).getHandleBounds();
return ((GraphicalEditPart) getHost()).getFigure().getBounds();
}