当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.translate方法代码示例

本文整理汇总了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);
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:21,代码来源:CollapsedLabel.java

示例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;
    }
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:29,代码来源:PrintERDiagramOperation.java

示例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;
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:29,代码来源:PrintERDiagramOperation.java

示例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);
	}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:20,代码来源:StyledLabel.java

示例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);
     }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:17,代码来源:LinearScaleTickMarks.java

示例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;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:29,代码来源:NotMovablePartDragTracker.java

示例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);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:27,代码来源:ComponentFigure.java

示例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;
    }
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:26,代码来源:PrintERDiagramOperation.java

示例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());
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:44,代码来源:CommentBoxFeedbackFigure.java

示例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());
 }
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:39,代码来源:BentCornerFigure.java

示例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();
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:14,代码来源:TableViewFigure.java

示例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());
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:35,代码来源:PtolemyModelElementShape.java

示例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();
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:30,代码来源:StateFigure.java

示例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);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:12,代码来源:LinearScaleTickLabels.java

示例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);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:9,代码来源:LinearScaledMarker.java


注:本文中的org.eclipse.draw2d.Graphics.translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。