Java Code Examples for org.eclipse.draw2d.Graphics#getFont()

The following examples show how to use org.eclipse.draw2d.Graphics#getFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessFigure.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void drawTexts(Graphics g, String single, String total) {
	Point loc = getLocation();
	Font normalFont = g.getFont();
	Font boldFont = getBoldFont(normalFont);
	g.setFont(boldFont);
	Color black = g.getForegroundColor();
	g.setForegroundColor(Colors.white());
	String name = Strings.cut(node.getName(), 30);
	g.drawText(name, loc.x + 5, loc.y + 5);
	g.setFont(normalFont);
	g.drawText(M.DirectContribution + ":", loc.x + 5, loc.y + 35);
	g.drawText(single, loc.x + 5, loc.y + 50);
	g.drawText(M.UpstreamTotal + ":", loc.x + 5, loc.y + 80);
	g.drawText(total, loc.x + 5, loc.y + 95);
	g.setForegroundColor(black);
}
 
Example 2
Source File: ProductSystemFigure.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void paintInfoBox(Graphics g) {
	g.pushState();
	Font normalFont = g.getFont();
	Font infoFont = getInfoFont(normalFont);
	g.setFont(infoFont);
	Object selection = node.selection;
	double cutoffValue = node.cutoff * 100;
	String cutoffText = M.DontShowSmallerThen + " "
			+ Numbers.format(cutoffValue, 3) + "%";
	if (selection != null) {
		g.drawText(M.ProductSystem + ": "
				+ node.productSystem.name, new Point(5, 5));
		String label = selectionLabel(selection);
		g.drawText(label, new Point(5, 30));
		g.drawText(cutoffText, new Point(5, 60));

	} else {
		g.drawText(M.NoAnalysisOptionsSet, new Point(5, 5));
		g.drawText(M.ClickHereToChangeDisplay, new Point(5, 30));
	}
	g.setFont(normalFont);
	drawColorScale(g);
	g.popState();
}
 
Example 3
Source File: SyntaxColoringLabel.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void paintText(Graphics g, String draw, int x, int y, int bidiLevel) {
	if (!highlight) {
		super.paintText(g, draw, x, y, bidiLevel);
		return;
	}
	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, Math.min(fromIndex, getText().length() - 1));
		fromIndex += originalDraw.length();
		if (lineOffset == -1) {
			// This may happen if the string is truncated with '..'
			originalDraw = replaceTabs(originalDraw);
			super.paintText(g, originalDraw, x, y, bidiLevel);
			return;
		}
		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);
	}
}