本文整理汇总了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));
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
}
示例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));
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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();
}
示例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;
}