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


Java GC类代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.GC的典型用法代码示例。如果您正苦于以下问题:Java GC类的具体用法?Java GC怎么用?Java GC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GC类属于org.eclipse.swt.graphics包,在下文中一共展示了GC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final boolean hovered = this.mouse.isEntered();
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(true, false, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());

	// Foreground
	String text = chevron_up;
	gc.setForeground(theme.getToolBarBackground(hovered));
	gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text);
	gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:21,代码来源:XCalendarIncrWidget.java

示例2: drawString

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
public static void drawString(GC gc, String str, float x, float y, float width, float height, int bgAlpha) {
	if (str == null)
		return;

	org.eclipse.swt.graphics.Point size = gc.stringExtent(str);
	int posX = Math.round(x + width / 2 - size.x / 2);
	int posY = Math.round(y + height / 2 - size.y / 2);

	if (bgAlpha >= 255) {
		gc.drawString(str, posX, posY);
	} else {
		gc.drawString(str, posX, posY, true);
		if (bgAlpha > 0) {
			gc.setAlpha(bgAlpha);
			gc.fillRectangle(posX, posY, size.x, size.y);
			gc.setAlpha(255);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:GraphUtils.java

示例3: arcSelf

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * Paints an looping arc from scr to tgt.
 * <p/>
 * <b>Assumption:</b> The tgt is located right/below of the src.
 */
public static float[] arcSelf(GC gc, Point src, Point tgt) {
	Path path = new Path(gc.getDevice());
	int diffH = 10;
	int diff = diffH * 3;
	path.moveTo((int) src.x, (int) src.y);
	path.cubicTo(
			(int) src.x + diff, (int) src.y - diffH,
			(int) tgt.x, (int) tgt.y - diff,
			(int) tgt.x, (int) tgt.y);

	gc.drawPath(path);

	float[] pp = path.getPathData().points;
	return pp;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:GraphUtils.java

示例4: render

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final boolean hovered = this.mouse.isEntered();
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(true, false, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());

	// Foreground
	String text = chevron_left;
	gc.setForeground(theme.getForeground(true, false, true));
	gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text);
	gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:21,代码来源:XCalendarPrevWidget.java

示例5: computeColumnWidths

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * Pre-compute column widths for the file tab.
 * These can and are over-ridden by user sizing.
 */
protected void computeColumnWidths(int format) {
	List headers = disks[0].getFileColumnHeaders(format);
	int[] headerWidths = new int[headers.size()];
	GC gc = new GC(shell);
	for (int i=0; i<headers.size(); i++) {
		FileColumnHeader header = (FileColumnHeader) headers.get(i);
		if (header.getTitle().length() >= header.getMaximumWidth()) {
			headerWidths[i] = gc.stringExtent(header.getTitle()).x + 
				2 * gc.stringExtent(textBundle.get("WidestCharacter")).x;  //$NON-NLS-1$
		} else {
			headerWidths[i] = gc.stringExtent(
					textBundle.get("WidestCharacter")).x  //$NON-NLS-1$
					* header.getMaximumWidth();
		}
	}
	gc.dispose();
	gc = null;
	columnWidths.put(new Integer(format), headerWidths);
}
 
开发者ID:marvinmalkowskijr,项目名称:applecommander,代码行数:24,代码来源:DiskExplorerTab.java

示例6: drawTemporaryLabels

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * draw temporary labels for external nodes (and save their bounds for later)
 */
private List<Rectangle> drawTemporaryLabels(GC gc) {
	final List<Rectangle> nodesExternalBounds = new ArrayList<>();
	final Rectangle clip = GraphUtils.getClip(gc);
	float px = clip.x + clip.width;
	float py = clip.y + clip.height;
	for (String currNE : endNodesExternal) {
		final org.eclipse.swt.graphics.Point size = gc.stringExtent(currNE);
		py -= size.y + 4;
		final float rx = px - (size.x + 4);
		final Rectangle b = new Rectangle(rx, py, size.x, size.y);
		nodesExternalBounds.add(b);
		// TODO string extent will be computed twice :(
		GraphUtils.drawString(gc, currNE, b.x + b.width / 2, b.y + b.height / 2);
	}
	return nodesExternalBounds;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:Edge.java

示例7: paintEdge

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/** Paints an edge */
void paintEdge(GC gc, Node srcN, Node tgtN) {
	setColor(gc);

	Point src = srcN.getCenter();
	Point tgt = tgtN.getCenter();
	Point tgtB;

	if (srcN == tgtN) {
		tgtB = paintSelfArc(gc, tgtN, tgt);
	} else if (isReverseArc(src, tgt)) {
		tgtB = paintReverseArc(gc, srcN, tgtN, src, tgt);
	} else {
		tgtB = paintArc(gc, srcN, tgtN, src, tgt);
	}

	drawArrowHead(gc, tgt, tgtB);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:CFEdge.java

示例8: render

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final boolean hovered = this.mouse.isEntered();
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(true, false, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());

	// Foreground
	String text = chevron_down;
	gc.setForeground(theme.getToolBarBackground(hovered));
	gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text);
	gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:21,代码来源:XCalendarDecrWidget.java

示例9: drawLabel

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/** Draws the label between jumping control flow elements. */
void drawLabel(GC gc, Point p) {
	label = "";
	for (ControlFlowType cfType : cfTypes) {
		switch (cfType) {
		case Break:
		case Continue:
		case Return:
		case Throw:
		case LoopEnter:
		case LoopReenter:
		case LoopInfinite:
			if (!label.isEmpty())
				label += "|";
			label += cfType.name();
			break;
		default:
		}
	}

	org.eclipse.swt.graphics.Point size = gc.stringExtent(label);
	float x = p.x - size.x / 2;
	float y = p.y - size.y / 2;
	GraphUtils.drawString(gc, label, x, y);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:CFEdge.java

示例10: paint

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * Paints the Node
 */
public void paint(GC gc) {
	gc.setBackground(getBackgroundColor());
	gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK));

	gc.fillRoundRectangle(Math.round(x), Math.round(y), Math.round(width), Math.round(height), 5, 5);
	GraphUtils.drawString(gc, title, x, y, width, height, 0);

	if (hasOutgoingCrossLinksInternal || hasOutgoingCrossLinksExternal) {
		Color colorRed = gc.getDevice().getSystemColor(SWT.COLOR_RED);
		gc.setBackground(colorRed);
		gc.setForeground(colorRed);

		int ovalX = Math.round(x + width - SIZE_CROSS_LINKS_MARKER - 2);
		int ovalY = Math.round(y + 2);
		int ovalSize = Math.round(SIZE_CROSS_LINKS_MARKER);
		if (hasOutgoingCrossLinksInternal) {
			gc.fillOval(ovalX, ovalY, ovalSize, ovalSize);
		} else {
			gc.drawOval(ovalX, ovalY, ovalSize, ovalSize);
		}
	}

	gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:28,代码来源:Node.java

示例11: resize

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
@Override
public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle )
{
    if ( this.title == null || this.title.isEmpty () )
    {
        return null;
    }

    final GC gc = new GC ( resourceManager.getDevice () );
    gc.setFont ( createFont ( resourceManager ) );

    try
    {
        final Point size = gc.textExtent ( this.title );
        this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, size.y + this.padding * 2 );
        return new Rectangle ( clientRectangle.x, this.rect.y + this.rect.height, clientRectangle.width, clientRectangle.height - this.rect.height );
    }
    finally
    {
        gc.dispose ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:TitleRenderer.java

示例12: refreshLabel

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
void refreshLabel () {
	int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 0;
	for (int i=0; i<objects.length; i++) {
		Object object = objects [i];
		if (object instanceof Color) colors++;
		if (object instanceof Cursor) cursors++;
		if (object instanceof Font) fonts++;
		if (object instanceof GC) gcs++;
		if (object instanceof Image) images++;
		if (object instanceof Region) regions++;
	}
	String string = ""; //$NON-NLS-1$
	if (colors != 0) string += colors + " Color(s)\n"; //$NON-NLS-1$
	if (cursors != 0) string += cursors + " Cursor(s)\n"; //$NON-NLS-1$
	if (fonts != 0) string += fonts + " Font(s)\n"; //$NON-NLS-1$
	if (gcs != 0) string += gcs + " GC(s)\n"; //$NON-NLS-1$
	if (images != 0) string += images + " Image(s)\n"; //$NON-NLS-1$
	if (regions != 0) string += regions + " Region(s)\n"; //$NON-NLS-1$
	if (string.length () != 0) {
		string = string.substring (0, string.length () - 1);
	}
	label.setText (string);
}
 
开发者ID:marvinmalkowskijr,项目名称:applecommander,代码行数:24,代码来源:Sleak.java

示例13: getInsertionBounds

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
public Rectangle getInsertionBounds(Control control) {
	// This doesn't take horizontal scrolling into affect. 
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204599
	CCombo combo = (CCombo) control;
	int position = combo.getSelection().y;
	String contents = combo.getText();
	GC gc = new GC(combo);
	gc.setFont(combo.getFont());
	Point extent = gc.textExtent(contents.substring(0, Math.min(position,
			contents.length())));
	gc.dispose();
	if (COMPUTE_TEXT_USING_CLIENTAREA) {
		return new Rectangle(combo.getClientArea().x + extent.x, combo
			.getClientArea().y, 1, combo.getClientArea().height);
	}
	return new Rectangle(extent.x, 0, 1, combo.getSize().y);
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:18,代码来源:CComboContentAdapter.java

示例14: render

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final boolean hovered = this.mouse.isEntered();
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(true, false, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());

	// Foreground
	String text = theme.getSecondTheme()[row][col];
	gc.setForeground(theme.getForeground(true, false, true));
	gc.setFont(theme.getFont()); final Point size = extent(gc, text);
	gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:21,代码来源:XCalendarSecondWidget.java

示例15: drawButtonDeepDown

import org.eclipse.swt.graphics.GC; //导入依赖的package包/类
public static void drawButtonDeepDown(GC gc, String text, int textAlign,
      Image image, int imageAlign, int x, int y, int w, int h) {
    Display display = Display.getCurrent();
    gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
    gc.drawLine(x, y, x + w - 2, y);
    gc.drawLine(x, y, x, y + h - 2);
    gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
    gc.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
    gc.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
    gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
    gc.drawLine(x + w - 2, y + h - 2, x + w - 2, y + 1);
    //
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(x + 2, y + 2, w - 4, 1);
gc.fillRectangle(x + 1, y + 2, 2, h - 4);
//
    gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    drawTextImage(gc, text, textAlign, image, imageAlign, x + 2 + 1,
        y + 2 + 1, w - 4, h - 3 - 1);
  }
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:23,代码来源:SWTX.java


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