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


Java GC.setFont方法代码示例

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


在下文中一共展示了GC.setFont方法的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();
	final boolean time = model.getStateMachine().isTime();
	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 = time ? calendar : clock_o;
	gc.setForeground(theme.getToolBarBackground(false));
	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,代码行数:22,代码来源:XCalendarSelectTimeWidget.java

示例2: paintElement

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
void paintElement(PaintEvent e) {
	GC g = e.gc;
	g.setBackground(this.getBackground());
	int width  = this.getBounds().width;
	int height = this.getBounds().height;
	
	// clear entire canvas where button will be painted
	g.fillRectangle(0, 0, width, height);
	
	// draw text
	g.setForeground(this.meColorForeground);
	FontData fd = new FontData();
	fd.setHeight(8);
	if(textIsBold){
		fd.setStyle(SWT.BOLD);
	}else{
		fd.setStyle(SWT.NORMAL);
	}
	g.setFont(new Font(this.getDisplay(), fd));
	Point textPt = g.textExtent(this.meLabel);			
	g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
 
开发者ID:avoCADo-3d,项目名称:avoCADo,代码行数:24,代码来源:MELabel.java

示例3: render

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * Render
 */
@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 = trash_o;
	gc.setForeground(theme.getToolBarBackground(false));
	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,代码来源:XCalendarClearWidget.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();
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(true, false, false, false));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());

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

示例5: render

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final boolean hovered = mouse.isEntered();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final XVirtualCalendar calendar = model.getCalendar();
	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 = model.getState().text(theme, calendar);
	gc.setForeground(theme.getForeground(true, false, true));
	gc.setFont(theme.getBold()); final Point size = extent(gc, text);
	gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1));
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:22,代码来源:XCalendarSelectWidget.java

示例6: render

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final boolean hovered = mouse.isEntered();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final XVirtualCalendar calendar = model.getCalendar();
	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 t1 = this.type.text(theme, calendar);
	gc.setForeground(theme.getForeground(true, false, true));
	gc.setFont(theme.getBold()); final Point s1 = extent(gc, t1);
	gc.drawText(t1, x + 1 + ((w - s1.x) >> 1), y + 1 + ((h - s1.y) >> 1));
	
	if(this.type == XCalendarTime.HOUR || this.type == XCalendarTime.MINUTE) {
		String t2 = ":"; Point s2 = extent(gc, t2);
		gc.setBackground(theme.getBackground(true, false, false, false));
		gc.drawText(t2, x + 1 + w + (getMargin().x >> 2), y + 1 + ((h - s2.y) >> 1));
	}
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:28,代码来源:XCalendarTimeWidget.java

示例7: 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.getMinuteTheme()[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,代码来源:XCalendarMinuteWidget.java

示例8: 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

示例9: 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_right;
	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,代码来源:XCalendarNextWidget.java

示例10: 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

示例11: 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.getHourTheme()[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,代码来源:XCalendarHourWidget.java

示例12: render

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
/**
 * 
 */
@Override
public void render(XCalendarFrame frame) {
	// Background
	final GC gc = frame.getGc();
	final boolean hovered = mouse.isEntered();
	final XCalendarModel model = popup.getModel();
	final XCalendarTheme theme = model.getTheme();
	final XVirtualCalendar calendar = model.getCalendar();
	
	ZoneId zoneId = model.getZoneId();
	final int year = calendar.getYear();
	final int month = query(calendar, zoneId, col, row);
	final ZonedDateTime d2 = calendar.getTravelDateTime();
	final ZonedDateTime d1 = calendar.getCalendarDateTime();
	boolean selected = isSameYear(d1, d2) && month == d1.getMonthValue();
	this.enabled = isValidYearMonth(year, month, zoneId, calendar::isValid);
	int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
	gc.setBackground(theme.getBackground(enabled, selected, false, hovered));
	gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc());
	
	// Foreground
	String text = theme.getMonthTheme()[row][col];
	gc.setForeground(theme.getForeground(enabled, selected, 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,代码行数:30,代码来源:XCalendarMonthWidget.java

示例13: draw

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
@Override
public void draw(int paintX, int paintSpaceLeadingX, int paintY, GC gc) {
	StyledText styledText = super.getTextViewer().getTextWidget();
	Rectangle client = styledText.getClientArea();
	gc.setBackground(styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	styledText.drawBackground(gc, paintX, paintY, client.width, super.getHeightInPx());
	gc.setForeground(styledText.getDisplay().getSystemColor(SWT.COLOR_GRAY));

	Font font = new Font(styledText.getDisplay(), "Arial", 9, SWT.ITALIC);
	gc.setFont(font);
	gc.drawText(this.getText(), paintX, paintY + 4);
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:13,代码来源:DefaultViewZone.java

示例14: saveEditorContentsAsImage

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
private static void saveEditorContentsAsImage(IEditorPart editorPart, GraphicalViewer viewer, String saveFilePath, int format) {

		ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID);
		IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);// rootEditPart.getFigure();
		Rectangle rootFigureBounds = rootFigure.getBounds();

		Control figureCanvas = viewer.getControl();
		GC figureCanvasGC = new GC(figureCanvas);

		Image img = new Image(null, rootFigureBounds.width, rootFigureBounds.height);
		GC imageGC = new GC(img);
		imageGC.setBackground(figureCanvasGC.getBackground());
		imageGC.setForeground(figureCanvasGC.getForeground());
		imageGC.setFont(figureCanvasGC.getFont());
		imageGC.setLineStyle(figureCanvasGC.getLineStyle());
		imageGC.setLineWidth(figureCanvasGC.getLineWidth());
		imageGC.setXORMode(figureCanvasGC.getXORMode());
		Graphics imgGraphics = new SWTGraphics(imageGC);

		rootFigure.paint(imgGraphics);

		ImageData[] imgData = new ImageData[1];
		imgData[0] = img.getImageData();

		ImageLoader imgLoader = new ImageLoader();
		imgLoader.data = imgData;
		imgLoader.save(saveFilePath, format);

		figureCanvasGC.dispose();
		imageGC.dispose();
		img.dispose();
	}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:33,代码来源:ImageSaveUtil.java

示例15: setHeight

import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类
public static int setHeight(FormData fd, Control control, int rowcount) {
	int height = 0;
	if (control != null && !control.isDisposed()) {
		GC gc = new GC(control);
		try {
			gc.setFont(JFaceResources.getDialogFont());
			fd.height = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), rowcount);
		} finally {
			gc.dispose();
		}
	}
	return height;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:14,代码来源:EdgeJavaScriptSection.java


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