本文整理汇总了Java中org.eclipse.draw2d.geometry.PrecisionRectangle类的典型用法代码示例。如果您正苦于以下问题:Java PrecisionRectangle类的具体用法?Java PrecisionRectangle怎么用?Java PrecisionRectangle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrecisionRectangle类属于org.eclipse.draw2d.geometry包,在下文中一共展示了PrecisionRectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showGradient
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
protected void showGradient(Graphics graphics, PrecisionRectangle tempRect,
float internalRadius) {
Color backgroundColor = getBackgroundColor();
//top gradient
Image gradientImage = Drawer.getGradientRectangle(
tempRect, backgroundColor.getRGB(), ColorUtils.darker(ColorUtils.darker(ColorUtils.darker(
backgroundColor.getRGB()))), internalRadius, 50, SWT.TOP);
graphics.drawImage(gradientImage, tempRect.x, tempRect.y);
gradientImage.dispose();
//bottom gradient
gradientImage = Drawer.getGradientRectangle(
tempRect, ColorUtils.darker(ColorUtils.darker(ColorUtils.darker(
backgroundColor.getRGB()))), backgroundColor.getRGB(), internalRadius, 50, SWT.BOTTOM);
graphics.drawImage(gradientImage, tempRect.x, tempRect.bottom() - gradientImage.getBounds().height);
gradientImage.dispose();
}
示例2: paingImage
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
/**
* @param graphics
*/
private void paingImage(Graphics graphics) {
if (image != null){
PrecisionRectangle tempRect = new PrecisionRectangle(getBounds().crop(insets));
float r = getBorder().getActualBorderRadius(tempRect);
// must use paths to process not integer values
// the difference is visible with zoom
graphics.setBackgroundColor(getBackgroundColor());
float borderWidth = Math.min(Math.min(tempRect.height, tempRect.width)/2, getBorder().getBorderWidth());
float internalRadius = Math.max(0, r - borderWidth);
tempRect.shrink(borderWidth, borderWidth);
Image roundedImage = getBorder().getRoundedImage(new Image(null, image.getImageData().scaledTo(tempRect.width, tempRect.height)),
internalRadius);
graphics.drawImage(roundedImage, tempRect.x, tempRect.y);
roundedImage.dispose();
}
}
示例3: paintFigure
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
@Override
protected void paintFigure(Graphics graphics) {
if (image == null){//draw border to make the component visible
if (getBorder().getBorderWidth() <= 1){
getBorder().setBorderWidth(1f);
}
}
super.paintFigure(graphics);
if(image != null){
PrecisionRectangle tempRect = new PrecisionRectangle(getBounds().crop(insets));
float r = getBorder().getActualBorderRadius(tempRect);
// must use paths to process not integer values
// the difference is visible with zoom
graphics.setBackgroundColor(getBackgroundColor());
float borderWidth = Math.min(Math.min(tempRect.height, tempRect.width)/2, getBorder().getBorderWidth());
float internalRadius = Math.max(0, r - borderWidth);
tempRect.shrink(borderWidth, borderWidth);
Image roundedImage = getBorder().getRoundedImage(new Image(null, image.getImageData().scaledTo(tempRect.width, tempRect.height)),
internalRadius);
graphics.drawImage(roundedImage, tempRect.x, tempRect.y);
roundedImage.dispose();
}
}
示例4: paintTitaniumFigure
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
@Override
protected void paintTitaniumFigure(Graphics graphics) {
if (isON()){
graphics.setForegroundColor(ColorConstants.white);
}
super.paintTitaniumFigure(graphics);
Rectangle rect = getBounds().getCopy();
//rect.shrink((int)getBorder().getBorderWidth(), (int)getBorder().getBorderWidth());
if (isON()){
rect.x = rect.right() - rect.height;
}
rect.width = rect.height;
Image image = Drawer.getGradientRectangle(new PrecisionRectangle(rect.getCopy()),
RECT_B_RGB, RECT_T_RGB, rect.height / 2, rect.height, rect.height);
graphics.drawImage(image, rect.getLocation());
image.dispose();
}
示例5: showCreateBendpointFeedback
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
/**
* @see org.eclipse.gef.editpolicies.BendpointEditPolicy#showCreateBendpointFeedback(org.eclipse.gef.requests.BendpointRequest)
*/
@Override
protected void showCreateBendpointFeedback(BendpointRequest request) {
IFigure feedback = getDragSourceFeedbackFigure();
Rectangle bounds = new Rectangle(getInitialFeedbackBounds().getCopy());
PrecisionRectangle rect = new PrecisionRectangle(bounds);
getHostFigure().translateToAbsolute(rect);
Point movePoint = request.getLocation();
movePoint.x = ((GraphicalEditPart) getHost()).getFigure().getBounds().x;//movePoint.x - rect.getSize().width / 2;
rect.setLocation(movePoint);
feedback.translateToRelative(rect);
feedback.setBounds(rect);
}
示例6: calculateFeedbackBounds
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private Rectangle calculateFeedbackBounds(ChangeBoundsRequest request, Rectangle feedbackBounds, int level,
IFigure containerFigure) {
Rectangle result = feedbackBounds.getCopy();
List<IGraphicalEditPart> editParts = request.getEditParts();
for (IGraphicalEditPart editPart : editParts) {
PrecisionRectangle transformedRect = new PrecisionRectangle(editPart.getFigure().getBounds());
editPart.getFigure().translateToAbsolute(transformedRect);
transformedRect.translate(request.getMoveDelta());
transformedRect.resize(request.getSizeDelta());
transformedRect.expand(SPACEING * level, SPACEING * level);
result.union(transformedRect);
Dimension preferredSize = containerFigure.getPreferredSize().getCopy();
editPart.getFigure().translateToAbsolute(preferredSize);
Dimension max = Dimension.max(result.getSize(), preferredSize);
result.setSize(max);
if (result.x < feedbackBounds.x || result.y < feedbackBounds.y) {
return feedbackBounds;
}
}
return result;
}
示例7: showChangeBoundsFeedback
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
@Override
protected void showChangeBoundsFeedback(final ChangeBoundsRequest request) {
final IFigure feedback = getDragSourceFeedbackFigure();
final PrecisionRectangle rect = new PrecisionRectangle(
getInitialFeedbackBounds().getCopy());
getHostFigure().translateToAbsolute(rect);
rect.translate(request.getMoveDelta());
rect.resize(request.getSizeDelta());
// the unchanged value can be set to zero, because
// the size will be recalculated later
checkAndPrepareConstraint(request, rect);
feedback.translateToRelative(rect);
feedback.setBounds(rect);
}
示例8: getResizeCommand
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
@Override
protected Command getResizeCommand(final ChangeBoundsRequest request) {
GraphicalEditPart editPart = (IGraphicalEditPart) getHost();
Rectangle locationAndSize = new PrecisionRectangle(editPart.getFigure()
.getBounds());
editPart.getFigure().translateToAbsolute(locationAndSize);
final Rectangle origRequestedBounds = request
.getTransformedRectangle(locationAndSize);
final Rectangle modified = origRequestedBounds.getCopy();
checkAndPrepareConstraint(request, modified);
// final Dimension sizeDelta = request.getSizeDelta();
Dimension newDelta = new Dimension(modified.width
- locationAndSize.width, modified.height
- locationAndSize.height);
// ((IGraphicalEditPart) getHost()).getFigure()
// .translateToAbsolute(newDelta);
request.setSizeDelta(newDelta);
final Point moveDelta = request.getMoveDelta();
request.setMoveDelta(new Point(moveDelta.x - origRequestedBounds.x
+ modified.x, moveDelta.y - origRequestedBounds.y + modified.y));
return super.getResizeCommand(request);
}
示例9: paintFigure
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
@Override
public void paintFigure(Graphics g) {
PrecisionRectangle b = new PrecisionRectangle(getBounds().getCopy());
if (request.getType().equals(REQ_RESIZE)) {
super.paintFigure(g);
Graphics2D gr = ComponentFigure.getG2D(g);
if (gr != null) {
gr.fillRect(b.x, b.y, b.width, b.height);
AlphaComposite ac = AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 1f);
gr.setComposite(ac);
gr.fillOval(b.x + (b.width) / 2 - 3, b.y - 3, 7, 7);
gr.fillOval(b.x + (b.width) / 2 - 3, b.y + b.height - 4, 7,
7);
gr.drawLine(b.x + (b.width) / 2, b.y, b.x + (b.width) / 2,
b.y + b.height - 2);
}
}
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:22,代码来源:CrosstabCellResizableEditPolicy.java
示例10: snapPoint
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
/**
* This method can be overridden by clients to customize the snapping behavior.
*
* @param request
* the <code>ChangeBoundsRequest</code> from which the move delta can be extracted and updated
* @since 3.4
*/
protected void snapPoint(ChangeBoundsRequest request) {
Point moveDelta = request.getMoveDelta();
if (editpart != null && getOperationSet().size() > 0)
snapToHelper = (SnapToHelper) editpart.getParent().getAdapter(SnapToHelper.class);
if (snapToHelper != null && !getCurrentInput().isModKeyDown(MODIFIER_NO_SNAPPING)) {
PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();
PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy();
baseRect.translate(moveDelta);
jointRect.translate(moveDelta);
PrecisionPoint preciseDelta = new PrecisionPoint(moveDelta);
snapToHelper.snapPoint(request, PositionConstants.HORIZONTAL | PositionConstants.VERTICAL,
new PrecisionRectangle[] { baseRect, jointRect }, preciseDelta);
request.setMoveDelta(preciseDelta);
}
}
示例11: relocate
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
@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();
targetBounds.x += 7;
targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height + 1) / 2));
targetBounds.setSize(targetBounds.width - 14, 7);
target.setBounds(targetBounds);
}
示例12: showChangeBoundsFeedback
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
if (getHost().getModel() instanceof IGraphicElement) {
// if (getHost() instanceof BandEditPart
// && ((BandEditPart) getHost()).getModelNode().getValue() instanceof JRDesignBand) {
APropertyNode n = (APropertyNode) getHost().getModel();
int bandHeight = (Integer) n.getPropertyValue(JRDesignElement.PROPERTY_HEIGHT);
Integer bWidth = (Integer) n.getPropertyValue(JRDesignElement.PROPERTY_WIDTH);
Rectangle oldBounds = new Rectangle(0, 0, bWidth != null ? bWidth : 0, bandHeight);
PrecisionRectangle rect2 = new PrecisionRectangle(new Rectangle(0, 0, request.getSizeDelta().width,
request.getSizeDelta().height));
getHostFigure().translateToRelative(rect2);
oldBounds.resize(rect2.width, rect2.height);
setFeedbackText(oldBounds.height + (bWidth != null ? "," + oldBounds.width : "") + " px");
}
super.showChangeBoundsFeedback(request);
}
示例13: snapPoint
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
/**
* This method can be overridden by clients to customize the snapping
* behavior.
*
* @param request
* the <code>ChangeBoundsRequest</code> from which the move delta
* can be extracted and updated
* @since 3.4
*/
protected void snapPoint(ChangeBoundsRequest request) {
Point moveDelta = request.getMoveDelta();
if (snapToHelper != null && request.isSnapToEnabled()) {
PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();
PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy();
baseRect.translate(moveDelta);
jointRect.translate(moveDelta);
PrecisionPoint preciseDelta = new PrecisionPoint(moveDelta);
snapToHelper.snapPoint(request, PositionConstants.HORIZONTAL
| PositionConstants.VERTICAL, new PrecisionRectangle[] {
baseRect, jointRect }, preciseDelta);
request.setMoveDelta(preciseDelta);
}
}
示例14: enforceConstraintsForSizeOnDropCreate
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
/**
* Ensures size constraints (by default minimum and maximum) are respected
* by the given request. May be overwritten by clients to enforce additional
* constraints.
*
* @since 3.7
*/
protected void enforceConstraintsForSizeOnDropCreate(CreateRequest request) {
CreateRequest createRequest = (CreateRequest) getTargetRequest();
if (createRequest.getSize() != null) {
// ensure create request respects minimum and maximum size
// constraints
PrecisionRectangle constraint = new PrecisionRectangle(
createRequest.getLocation(), createRequest.getSize());
((GraphicalEditPart) getTargetEditPart()).getContentPane()
.translateToRelative(constraint);
constraint.setSize(Dimension.max(constraint.getSize(),
getMinimumSizeFor(createRequest)));
constraint.setSize(Dimension.min(constraint.getSize(),
getMaximumSizeFor(createRequest)));
((GraphicalEditPart) getTargetEditPart()).getContentPane()
.translateToAbsolute(constraint);
createRequest.setSize(constraint.getSize());
}
}
示例15: getTransformedRectangle
import org.eclipse.draw2d.geometry.PrecisionRectangle; //导入依赖的package包/类
/**
* @see ChangeBoundsRequest#getTransformedRectangle(Rectangle)
*/
public Rectangle getTransformedRectangle(Rectangle rect) {
Rectangle result = rect.getCopy();
Rectangle reference = getAlignmentRectangle();
if (result instanceof PrecisionRectangle) {
if (reference instanceof PrecisionRectangle)
doPrecisionAlignment((PrecisionRectangle) result,
(PrecisionRectangle) reference);
else
doPrecisionAlignment((PrecisionRectangle) result,
new PrecisionRectangle(reference));
} else
doNormalAlignment(result, reference);
return result;
}