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


Java Graphics.drawText方法代码示例

本文整理汇总了Java中org.eclipse.draw2d.Graphics.drawText方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawText方法的具体用法?Java Graphics.drawText怎么用?Java Graphics.drawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.draw2d.Graphics的用法示例。


在下文中一共展示了Graphics.drawText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
	super.paintFigure(g);
	final int LEG = 5;
	Rectangle r = getBounds();
	g.setLineWidth(1);
	g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR);
	
	g.drawLine(r.x, r.y, r.x, r.y+r.height-1);
	g.drawLine(r.x, r.y, r.x+LEG, r.y);
	g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1);

	g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height);
	g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y);
	g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1);

	if(!valid) {
		g.setForegroundColor(PandionJConstants.Colors.ERROR);
		String text = "Invalid matrix";
		int textWidth = FigureUtilities.getTextWidth(text, g.getFont());
		Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5);
		g.drawText(text, p);
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:25,代码来源:MatrixWidget.java

示例3: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void draw(TextAttribute textAttr, Graphics graphics, ResourceManager resourceManager) {
  Color fgColor = graphics.getForegroundColor();
  java.awt.Color color = textAttr.textColor.asColor();
  if (color != null) {
    Color rgb = resourceManager.createColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
    graphics.setForegroundColor(rgb);
  }

  try {
    String text = textAttr.text.getExpression();
    int fontSize = ((IntToken) textAttr.textSize.getToken()).intValue();
    String fontFamily = textAttr.fontFamily.stringValue();
    boolean italic = ((BooleanToken) textAttr.italic.getToken()).booleanValue();
    boolean bold = ((BooleanToken) textAttr.bold.getToken()).booleanValue();
    int style = SWT.NORMAL | (italic ? SWT.ITALIC : SWT.NORMAL) | (bold ? SWT.BOLD : SWT.NORMAL);
    Font f = resourceManager.createFont(FontDescriptor.createFrom(fontFamily, fontSize, style));
    graphics.setFont(f);

    Point tlp = getTopLeftLocation(textAttr);
    graphics.drawText(text, tlp);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading properties for " + textAttr.getFullName(), e);
  }
  graphics.setForegroundColor(fgColor);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:27,代码来源:TextDrawingStrategy.java

示例4: drawYTick

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Draw the Y tick.
 * 
 * @param grahpics
 *            the graphics context
 */
private void drawYTick(Graphics grahpics) {
    // draw tick labels
    grahpics.setFont(scale.getFont());
    int fontHeight = tickLabelMaxHeight;
    for (int i = 0; i < tickLabelPositions.size(); i++) {
        if (tickVisibilities.size() == 0 || tickLabels.size() == 0) {
            break;
        }

        if (tickVisibilities.get(i) == true) {
            String text = tickLabels.get(i);
            int x = 0;
            if (tickLabels.get(0).startsWith("-") && !text.startsWith("-")) {
                x += FigureUtilities.getTextExtents("-", getFont()).width;
            }
            int y = (int) Math.ceil(scale.getLength() - tickLabelPositions.get(i)
                    - fontHeight / 2.0);
            grahpics.drawText(text, x, y);
        }
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:28,代码来源:LinearScaleTickLabels.java

示例5: fillShape

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void fillShape(Graphics graphics) {
	super.fillShape(graphics);

	int h = graphics.getFontMetrics().getHeight();

	Rectangle r = getBounds();
	if (text != null) {
		graphics.setForegroundColor(getForegroundColor());
		int y = r.y + 2;
		int x = r.x + 2;
		for (String txt : text) {
			graphics.drawText(txt, x, y);
			y += h + 3;
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:18,代码来源:CalloutFigure.java

示例6: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics graphics) {
	super.paintFigure(graphics);
	if(isWatched)
		setBackgroundColor(watchColor);
	Rectangle r = getBounds().getCopy();
	if(PortAlignmentEnum.LEFT.equals(portAlignment)){
		graphics.fillRectangle(getBounds().getLocation().x-20, getBounds()
				.getLocation().y-1, r.width, r.height-2);
	}else if(PortAlignmentEnum.RIGHT.equals(portAlignment)){
		graphics.fillRectangle(getBounds().getLocation().x+20, getBounds()
				.getLocation().y-1, r.width, r.height-2);
	}else if(PortAlignmentEnum.BOTTOM.equals(portAlignment)){
		graphics.fillRectangle(getBounds().getLocation().x-16, getBounds()
				.getLocation().y+10, r.width,r.height);
	}
		
		
	if(isDisplayPortlabels()){
		if(PortAlignmentEnum.LEFT.equals(portAlignment)){
			graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x+8,getBounds()
					.getLocation().y-0.2));
		}else if(PortAlignmentEnum.RIGHT.equals(portAlignment)){
			graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x,getBounds()
					.getLocation().y-0.2));
		}else if(PortAlignmentEnum.BOTTOM.equals(portAlignment)){
			graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x,getBounds()
					.getLocation().y-0.2));
		}	
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:32,代码来源:PortFigure.java

示例7: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
	Rectangle r = getBounds();
	if(valid) {
		ImageData data = getImageData();
		Image img = new Image(Display.getDefault(), data);
		g.drawImage(img, 0, 0, width, height, r.x+1, r.y+1, width, height);
		img.dispose();
	}
	else {
		g.drawText("Invalid matrix", r.getLocation().translate(5, 15));
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:14,代码来源:ImageFigure.java

示例8: paintCompose

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintCompose(Graphics graphics) {
	graphics.setBackgroundColor(getBarColor());
	Rectangle rect = new Rectangle(2, 2, resolution.width - 4, 30);
	graphics.fillRectangle(rect);
	graphics.setForegroundColor(ColorConstants.white);
	graphics.drawText("Compose", new Point(6, 6));
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:8,代码来源:EmailDialogFigure.java

示例9: paindButtonsBar

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * @param graphics
 */
private void paindButtonsBar(Graphics graphics) {
	int panelHeight = 42;
	graphics.setBackgroundColor(defaultBarColor);
	Rectangle rect = new Rectangle(2, resolution.height - 2 - panelHeight,
			resolution.width - 4, panelHeight);
	graphics.fillRectangle(rect);
			
	int buttonWidth = (resolution.width - 20) / 7 ;
	int space = (resolution.width - buttonWidth * 7) / 7;
		
	graphics.setBackgroundColor(background2);
	graphics.setForegroundColor(border);
	rect = new Rectangle(5 + space, resolution.height - panelHeight + 2, buttonWidth*2, panelHeight - 10);
	graphics.fillRoundRectangle(rect, radius, radius);
	graphics.drawRoundRectangle(rect, radius, radius);
	
	rect.translate(buttonWidth*5 + space*2, 0);
	graphics.fillRoundRectangle(rect, radius, radius);
	graphics.drawRoundRectangle(rect, radius, radius);
	
	rect.translate(-buttonWidth*3 - space, 0);
	rect.width = buttonWidth*3;
	graphics.fillRoundRectangle(rect, radius, radius);
	graphics.drawRoundRectangle(rect, radius, radius);
	
	graphics.setForegroundColor(ColorConstants.black);
	graphics.drawText("Send", new Point(22 + space, resolution.height - panelHeight + 7));
	graphics.drawText("Save as Draft", new Point(12 + space*2 + buttonWidth*2, resolution.height - panelHeight + 7));
	graphics.drawText("Discard", new Point(14 + space*3 + buttonWidth*5, resolution.height - panelHeight + 7));
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:34,代码来源:EmailDialogFigure.java

示例10: paintText

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintText(Graphics g, String draw, int x, int y, int bidiLevel) {
	if (ranges.length == 0) {
		draw = replaceTabs(draw);
		super.paintText(g, draw, x, y, bidiLevel);
		return;
	}
	if (bidiLevel == -1) {
		String originalDraw = draw;
		int paintOffset = 0;
		int lineOffset = getText().indexOf(originalDraw);
		try {
			g.pushState();
			g.setFont(getFont());
			for (StyleRange range : ranges) {
				int beginIndex = range.start - lineOffset;
				if (beginIndex > draw.length()) {
					break;
				}
				Font font = SWT.BOLD == (range.fontStyle & SWT.BOLD) ? boldFont : getFont();
				if (font != g.getFont()) {
					g.setFont(font);
				}
				g.setForegroundColor(range.foreground != null ? range.foreground : getForegroundColor());
				g.setBackgroundColor(range.background != null ? range.background : getBackgroundColor());
				int endIndex = beginIndex + range.length;
				String substring = draw.substring(beginIndex > 0 ? beginIndex : 0,
						Math.min(endIndex > 0 ? endIndex : 0, draw.length()));
				substring = replaceTabs(substring);
				g.drawText(substring, x + paintOffset, y);
				int offset = getTextExtend(g.getFont(), substring);
				paintOffset += offset;
			}
		} finally {
			g.popState();
		}
	} else {
		super.paintText(g, draw, x, y, bidiLevel);
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:41,代码来源:SyntaxColoringLabel.java

示例11: drawXTick

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Draw the X tick.
 * 
 * @param grahics
 *            the graphics context
 */
private void drawXTick(Graphics grahics) {
    // draw tick labels
    grahics.setFont(scale.getFont());
    for (int i = 0; i < tickLabelPositions.size(); i++) {
        if (tickVisibilities.get(i) == true) {
            String text = tickLabels.get(i);
            int fontWidth = FigureUtilities.getTextExtents(text, getFont()).width;
            int x = (int) Math.ceil(tickLabelPositions.get(i) - fontWidth / 2.0);// + offset);
            grahics.drawText(text, x, 0);
        }
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:19,代码来源:LinearScaleTickLabels.java

示例12: paintClientArea

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
	protected void paintClientArea(final Graphics graphics) {
		// Don't do anything when hidden
		if (!isVisible())
			return;

		super.paintClientArea(graphics);

//		graphics.pushState();
		graphics.setFont(titleFont);
		final Dimension titleSize = FigureUtilities.getTextExtents(title, titleFont);
		if(isHorizontal()){
			if(getTickLablesSide() == LabelSide.Primary)
				graphics.drawText(title,
						bounds.x + bounds.width/2 - titleSize.width/2,
						bounds.y + bounds.height - titleSize.height);
			else
				graphics.drawText(title,
						bounds.x + bounds.width/2 - titleSize.width/2,
						bounds.y);
		}else{
		    final int w = titleSize.height;
		    final int h = titleSize.width +1;

			if(getTickLablesSide() == LabelSide.Primary){
				GraphicsUtil.drawVerticalText(graphics, title,
							bounds.x, bounds.y + bounds.height/2 - h/2, false);
			}else {
				GraphicsUtil.drawVerticalText(graphics, title,
								bounds.x + bounds.width - w, bounds.y + bounds.height/2 - h/2, true);
			}
		}

//		graphics.popState();

		// Show the start/end cursor or the 'rubberband' of a zoom operation?
		if(armed && end != null && start != null){
			switch (zoomType) {
			case RUBBERBAND_ZOOM:
			case HORIZONTAL_ZOOM:
			case VERTICAL_ZOOM:
				graphics.setLineStyle(SWTConstants.LINE_DOT);
				graphics.setLineWidth(1);
				graphics.setForegroundColor(revertBackColor);
				graphics.drawRectangle(start.x, start.y, end.x - start.x-1, end.y - start.y-1);
				break;

			default:
				break;
			}
		}
	}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:53,代码来源:Axis.java

示例13: drawTraceLagend

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawTraceLagend(Trace trace, Graphics graphics, int hPos, int vPos){
		graphics.pushState();
        if (Preferences.useAdvancedGraphics())
            graphics.setAntialias(SWT.ON);
		graphics.setForegroundColor(trace.getTraceColor());
		///********************************** Removed by scouter.project
// draw symbol
//		switch (trace.getTraceType()) {
//		case BAR:
//			trace.drawLine(graphics, new Point(hPos + ICON_WIDTH / 2, vPos + trace.getPointSize() / 2), new Point(hPos + ICON_WIDTH / 2, vPos + ICON_WIDTH));
//			trace.drawPoint(graphics, new Point(hPos + ICON_WIDTH / 2, vPos + trace.getPointSize() / 2));
//			break;
//		case AREA:
//			graphics.setBackgroundColor(trace.getTraceColor());
//			if (Preferences.useAdvancedGraphics())
//				graphics.setAlpha(trace.getAreaAlpha());
//			graphics.fillPolygon(new int[] { hPos, vPos + ICON_WIDTH / 2, hPos + ICON_WIDTH / 2, vPos + trace.getPointSize() / 2, hPos + ICON_WIDTH, vPos + ICON_WIDTH / 2, hPos + ICON_WIDTH,
//					vPos + ICON_WIDTH, hPos, vPos + ICON_WIDTH });
//			if (Preferences.useAdvancedGraphics())
//				graphics.setAlpha(255);
//			trace.drawPoint(graphics, new Point(hPos + ICON_WIDTH / 2, vPos + trace.getPointSize() / 2));
//			break;
//		default:
//			trace.drawLine(graphics, new Point(hPos, vPos + ICON_WIDTH / 2), new Point(hPos + ICON_WIDTH, vPos + ICON_WIDTH / 2));
//			trace.drawPoint(graphics, new Point(hPos + ICON_WIDTH / 2, vPos + ICON_WIDTH / 2));
//			break;
//		}
		//**************************************/

		// Added by scouter.project
		// Draw rectangle and name
		graphics.setBackgroundColor(trace.getTraceColor());
		int rectangleX = hPos+ INNER_GAP*2;
		int rectangleY = vPos+ INNER_GAP;
		graphics.fillRectangle(rectangleX, rectangleY ,10 ,10 );
		int textX = hPos + ICON_WIDTH + INNER_GAP;
		int textY = vPos + ICON_WIDTH / 2 - FigureUtilities.getTextExtents(trace.getName(), getFont()).height / 2;
		graphics.drawText(trace.getName(), textX, textY);
		int x2 = textX + FigureUtilities.getTextExtents(trace.getName(), getFont()).width;
		int y2 = textY + FigureUtilities.getTextExtents(trace.getName(), getFont()).height;
		positionList.add(new LegendPosition(rectangleX, rectangleY, x2, y2));
		graphics.popState();
	}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:44,代码来源:Legend.java

示例14: drawVerticalText

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
	 * Draw vertical text.
	 * 
	 * @param graphics
	 *            draw2D graphics.
	 * @param text
	 *            text to be drawn.
	 * @param x
	 *            the x coordinate of the text, which is the left upper corner.
	 * @param y
	 *            the y coordinate of the text, which is the left upper corner.
	 */
	public static final void drawVerticalText(Graphics graphics, String text,
			int x, int y, boolean upToDown) {
		try {
			if(SWT.getPlatform().startsWith("rap")) //$NON-NLS-1$
				throw new Exception();
			try {
				graphics.pushState();
				graphics.translate(x, y);
				if (upToDown) {
					graphics.rotate(90);
					graphics.drawText(
							text,
							0,
							-FigureUtilities.getTextExtents(text,
									graphics.getFont()).height);
				} else {
					graphics.rotate(270);
					graphics.drawText(
							text,
							-FigureUtilities.getTextWidth(text, graphics.getFont()),
							0);
				}
			}finally{
				graphics.popState();
			}
		} catch (Exception e) {// If rotate is not supported by the graphics.
//			final Dimension titleSize = FigureUtilities.getTextExtents(text,
//					graphics.getFont());

//			final int w = titleSize.height;
//			final int h = titleSize.width + 1;
			Image image = null;
			try {
				image = SingleSourceHelper.createVerticalTextImage(text,
						graphics.getFont(), graphics.getForegroundColor().getRGB(), upToDown);
				graphics.drawImage(image, x, y);

			} finally {
				if (image != null)
					image.dispose();
			}
		}
	}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:56,代码来源:GraphicsUtil.java


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