本文整理汇总了Java中org.eclipse.draw2d.Graphics.translate方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.translate方法的具体用法?Java Graphics.translate怎么用?Java Graphics.translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @see Figure#paintFigure(Graphics)
*/
protected void paintFigure(Graphics graphics) {
if (isOpaque())
super.paintFigure(graphics);
Rectangle bounds = getBounds();
graphics.translate(bounds.x, bounds.y);
if (icon != null)
graphics.drawImage(icon, getIconLocation());
if (!isEnabled()) {
graphics.translate(1, 1);
graphics.setForegroundColor(ColorConstants.buttonLightest);
graphics.drawText(getSubStringText(), getTextLocation());
graphics.translate(-1, -1);
graphics.setForegroundColor(ColorConstants.buttonDarker);
}
graphics.drawText(getSubStringText(), getTextLocation());
graphics.translate(-bounds.x, -bounds.y);
}
示例2: printPages
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void printPages() {
final Graphics graphics = getFreshPrinterGraphics();
final IFigure figure = getPrintSource();
setupPrinterGraphicsFor(graphics, figure);
final Rectangle bounds = figure.getBounds();
int x = bounds.x, y = bounds.y;
final Rectangle clipRect = new Rectangle();
while (y < bounds.y + bounds.height) {
while (x < bounds.x + bounds.width) {
graphics.pushState();
getPrinter().startPage();
graphics.translate(-x, -y);
graphics.getClip(clipRect);
clipRect.setLocation(x, y);
graphics.clipRect(clipRect);
figure.paint(graphics);
getPrinter().endPage();
graphics.popState();
x += clipRect.width;
}
x = bounds.x;
y += clipRect.height;
}
}
示例3: printPages
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void printPages() {
Graphics graphics = getFreshPrinterGraphics();
IFigure figure = getPrintSource();
setupPrinterGraphicsFor(graphics, figure);
Rectangle bounds = figure.getBounds();
int x = bounds.x, y = bounds.y;
Rectangle clipRect = new Rectangle();
while (y < bounds.y + bounds.height) {
while (x < bounds.x + bounds.width) {
graphics.pushState();
getPrinter().startPage();
graphics.translate(-x, -y);
graphics.getClip(clipRect);
clipRect.setLocation(x, y);
graphics.clipRect(clipRect);
figure.paint(graphics);
getPrinter().endPage();
graphics.popState();
x += clipRect.width;
}
x = bounds.x;
y += clipRect.height;
}
}
示例4: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintFigure(Graphics graphics) {
Rectangle bounds = getBounds();
graphics.translate(bounds.x, bounds.y);
updateImage();
if (image == null || ranges == null || ranges.length == 0 || isOpaque()) {
return;
}
if (getIcon() != null)
graphics.drawImage(getIcon(), getIconLocation());
// if (!isEnabled()) {
// graphics.translate(1, 1);
// graphics.drawImage(image, getTextLocation());
// graphics.translate(-1, -1);
// }
graphics.drawImage(image, getTextLocation());
graphics.translate(-bounds.x, -bounds.y);
}
示例5: paintClientArea
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintClientArea(Graphics graphics) {
graphics.translate(bounds.x, bounds.y);
ArrayList<Integer> tickLabelPositions = scale
.getScaleTickLabels().getTickLabelPositions();
int width = getSize().width;
int height = getSize().height;
if (scale.isHorizontal()) {
drawXTickMarks(graphics, tickLabelPositions, scale.getTickLablesSide(), width,
height);
} else {
drawYTickMarks(graphics, tickLabelPositions, scale.getTickLablesSide(), width,
height);
}
}
示例6: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Paint a semi-transparent rectangle
*/
protected void paintFigure(Graphics graphics) {
Rectangle bounds = getBounds().getCopy();
graphics.translate(getLocation());
Graphics2D gr = ((J2DGraphics) graphics).getGraphics2D();
// gr.setColor(new java.awt.Color(168,202,236,128));
gr.setColor(fillColor);
gr.fillRect(0, 0, bounds.width - 1, bounds.height - 1);
gr.setStroke(new BasicStroke(2.0f));
gr.setColor(borderColor);
gr.drawRect(0, 0, bounds.width - 1, bounds.height - 1);
if (schedulePaint) {
Display.getCurrent().timerExec(DELAY, new Runnable() {
public void run() {
offset++;
if (offset > 5)
offset = 0;
schedulePaint = true;
repaint();
}
});
}
schedulePaint = false;
}
示例7: paint
import org.eclipse.draw2d.Graphics; //导入方法依赖的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);
}
示例8: printPages
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void printPages() {
final Graphics graphics = getFreshPrinterGraphics();
final IFigure figure = getPrintSource();
setupPrinterGraphicsFor(graphics, figure);
final Rectangle bounds = figure.getBounds();
int x = bounds.x, y = bounds.y;
final Rectangle clipRect = new Rectangle();
while (y < bounds.y + bounds.height) {
while (x < bounds.x + bounds.width) {
graphics.pushState();
getPrinter().startPage();
graphics.translate(-x, -y);
graphics.getClip(clipRect);
clipRect.setLocation(x, y);
graphics.clipRect(clipRect);
figure.paint(graphics);
getPrinter().endPage();
graphics.popState();
x += clipRect.width;
}
x = bounds.x;
y += clipRect.height;
}
}
示例9: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Paints this Figure's primary representation, or background
*
* @param graphics
* The Graphics used to paint
*/
protected void paintFigure(Graphics graphics) {
Rectangle rect = getBounds().getCopy();
graphics.setXORMode(true);
graphics.setForegroundColor(ColorConstants.white);
graphics.setBackgroundColor(CustomColorRegistry.INSTANCE.getColorFromRegistry( 31, 31, 31));
graphics.translate(getLocation());
PointList outline = new PointList();
outline.addPoint(0, 0);
outline.addPoint(rect.width - getCornerSize(), 0);
outline.addPoint(rect.width - 1, getCornerSize());
outline.addPoint(rect.width - 1, rect.height - 1);
outline.addPoint(0, rect.height - 1);
graphics.fillPolygon(outline);
// draw the inner outline
PointList innerLine = new PointList();
innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
innerLine.addPoint(rect.width - getCornerSize() - 1, getCornerSize());
innerLine.addPoint(rect.width - 1, getCornerSize());
innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
innerLine.addPoint(0, 0);
innerLine.addPoint(0, rect.height - 1);
innerLine.addPoint(rect.width - 1, rect.height - 1);
innerLine.addPoint(rect.width - 1, getCornerSize());
graphics.drawPolygon(innerLine);
graphics.drawLine(rect.width - getCornerSize() - 1, 0, rect.width - 1, getCornerSize());
graphics.translate(getLocation().getNegated());
}
示例10: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Paints this Figure's primary representation, or background. Changes made
*to the graphics to the graphics current state will not affect the
* @param graphics
* The Graphics used to paint
*/
protected void paintFigure(Graphics graphics) {
Rectangle rect = getBounds().getCopy();
graphics.translate(getLocation());
// fill the note
PointList outline = new PointList();
outline.addPoint(0, 0);
outline.addPoint(rect.width - cornerSize, 0);
outline.addPoint(rect.width - 1, cornerSize);
outline.addPoint(rect.width - 1, rect.height - 1);
outline.addPoint(0, rect.height - 1);
graphics.fillPolygon(outline);
// draw the inner outline
PointList innerLine = new PointList();
innerLine.addPoint(rect.width - cornerSize - 1, 0);
innerLine.addPoint(rect.width - cornerSize - 1, cornerSize);
innerLine.addPoint(rect.width - 1, cornerSize);
innerLine.addPoint(rect.width - cornerSize - 1, 0);
innerLine.addPoint(0, 0);
innerLine.addPoint(0, rect.height - 1);
innerLine.addPoint(rect.width - 1, rect.height - 1);
innerLine.addPoint(rect.width - 1, cornerSize);
graphics.drawPolygon(innerLine);
graphics.translate(getLocation().getNegated());
}
示例11: paintClientArea
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintClientArea(Graphics graphics) {
if (getChildren().isEmpty())
return;
graphics.translate(getBounds().x + getInsets().left, getBounds().y
+ getInsets().top);
graphics.clipRect(getFullArea());
graphics.pushState();
paintChildren(graphics);
graphics.popState();
graphics.restoreState();
}
示例12: fillShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void fillShape(Graphics graphics) {
LOGGER.trace("Ptolemy fillShape - entry - for {}", getIconURI());
try {
iconDef = iconDef != null ? iconDef : (EditorIcon) WorkflowUtils.readFrom(URI.create(getIconURI()));
// As Ptolemy II icon definitions often use negative coordinates,
// while draw2d graphics assumes a top-left corner at (0,0),
// the overall icon shape drawing must first determine the most extreme
// boundaries as defined in the icon MOML and translate the draw2d coordinates space
// accordingly before starting the effective drawing.
ptShapeBounds = ptShapeBounds != null ? ptShapeBounds : determineExtremeBounds(iconDef, graphics);
LOGGER.debug("Extreme bounds for {} : {}", getIconURI(), ptShapeBounds);
int width = ptShapeBounds.width;
int height = ptShapeBounds.height;
Rectangle bnds = getBounds();
graphics.setAntialias(SWT.ON);
graphics.setTextAntialias(SWT.ON);
graphics.drawRectangle(bnds.x, bnds.y, width, height);
graphics.translate(getLocation());
graphics.translate(ptShapeBounds.getTopLeft().getNegated().getTranslated(1, 1));
for (VisibleAttribute a : iconDef.attributeList(VisibleAttribute.class)) {
DrawingStrategy drawingStrategy = drawingStrategies.get(a.getClass());
if (drawingStrategy != null) {
drawingStrategy.draw(a, graphics, resourceManager);
}
}
setInitialSize(ga, width + 2, height + 2);
} catch (Exception e) {
LOGGER.error("Error drawing ptolemy shape " + getIconURI(), e);
}
LOGGER.trace("Ptolemy fillShape - exit - for {}", getIconURI());
}
示例13: drawBlurredShadow
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawBlurredShadow(Graphics graphics) {
// draw the shadow...
graphics.pushState();
int size = MapModeUtil.getMapMode(this).DPtoLP(BLUR_SHADOW_WIDTH);
int step = MapModeUtil.getMapMode(this).DPtoLP(-1);
graphics.setForegroundColor(ColorConstants.gray);
graphics.setLineWidth(MapModeUtil.getMapMode(this).DPtoLP(2));
graphics.translate(size, size);
graphics.setClip(graphics.getClip(new Rectangle(getBounds())).expand(
size, size));
graphics.setAlpha(20);
outlineShape(graphics);
graphics.translate(step, step);
graphics.setAlpha(30);
outlineShape(graphics);
graphics.translate(step, step);
graphics.setAlpha(60);
outlineShape(graphics);
graphics.translate(step, step);
graphics.setAlpha(100);
outlineShape(graphics);
graphics.translate(step, step);
graphics.setAlpha(150);
outlineShape(graphics);
graphics.popState();
}
示例14: paintClientArea
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintClientArea(Graphics graphics) {
graphics.translate(bounds.x, bounds.y);
if (scale.isHorizontal()) {
drawXTick(graphics);
} else {
drawYTick(graphics);
}
super.paintClientArea(graphics);
}
示例15: paintClientArea
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintClientArea(Graphics graphics) {
//use relative coordinate
graphics.translate(bounds.x, bounds.y);
updateTick();
drawMarkerTick(graphics);
super.paintClientArea(graphics);
}