org.eclipse.swt.graphics.GC.getFont()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.eclipse.swt.graphics.GC.getFont()方法的一些代码示例,展示了GC.getFont()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.getFont()方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:getFont

GC.getFont介绍

[英]Returns the font currently being used by the receiver to draw and measure text.
[中]返回接收者当前用于绘制和测量文本的字体。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

FontData[] array = gc.getFont().getFontData();
String string = "";
String lf = text.getLineDelimiter();

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

try {
  gc= new GC(parent); 
  gc.setFont(gc.getFont()); 
  gd.heightHint= Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), 6); // 6 characters tall
} finally {

代码示例来源:origin: org.microemu/microemu-javase-swt

public Font getFont() 
{
  return gc.getFont();
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/**
 * Returns the advance width of the character provided in the current font.
 * 
 * @param ch character to calculate the advance width of.
 * 
 * @return advance width of the character in the current font
 */
public int getAdvanceWidth(final char ch) {
  final org.eclipse.swt.graphics.Font scaledFont = gc.getFont();
  gc.setFont(curFont);
  final int width = gc.getAdvanceWidth(ch);
  gc.setFont(scaledFont);
  return width;
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/**
 * Returns the width of the character provided in the current font.
 * 
 * @param ch character to calculate the width of.
 * 
 * @return width of the character in the current font
 */
public int getCharWidth(final char ch) {
  final org.eclipse.swt.graphics.Font scaledFont = gc.getFont();
  gc.setFont(curFont);
  final int width = gc.getCharWidth(ch);
  gc.setFont(scaledFont);
  return width;
}

代码示例来源:origin: org.jfree/swtgraphics2d

/**
 * Returns the font in form of an AWT font created
 * with the parameters of the font of the SWT graphic
 * composite.
 * @return The font.
 * @see java.awt.Graphics#getFont()
 */
@Override
public Font getFont() {
  // retrieve the swt font description in an os indept way
  FontData[] fontData = this.gc.getFont().getFontData();
  // create a new AWT font with the appropiate data
  return SWTUtils.toAwtFont(this.gc.getDevice(), fontData[0], true);
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/**
 * Returns the extent of the provided string in the current font.
 * 
 * @param str string to calculate the extent of.
 * 
 * @return extent of the string in the current font
 */
public org.eclipse.swt.graphics.Point stringExtent(final String str) {
  final org.eclipse.swt.graphics.Font scaledFont = gc.getFont();
  gc.setFont(curFont);
  final org.eclipse.swt.graphics.Point extent = gc.stringExtent(str);
  gc.setFont(scaledFont);
  return extent;
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/**
 * Returns the extent of the provided text in the current font.
 * 
 * @param str string to calculate the extent of.
 * 
 * @return extent of the string in the current font
 */
public org.eclipse.swt.graphics.Point textExtent(final String str) {
  final org.eclipse.swt.graphics.Font scaledFont = gc.getFont();
  gc.setFont(curFont);
  final org.eclipse.swt.graphics.Point extent = gc.textExtent(str);
  gc.setFont(scaledFont);
  return extent;
}

代码示例来源:origin: org.piccolo2d/piccolo2d-swt

/**
 * Returns the extent of the provided text in the current font assuming the
 * flags given.
 * 
 * @param str string to calculate the extent of
 * @param flags flags to apply to the rendered font before calculation of
 *            extent takes place
 * @return extent of the string in the current font assuming flags provided
 */
public org.eclipse.swt.graphics.Point textExtent(final String str, final int flags) {
  final org.eclipse.swt.graphics.Font scaledFont = gc.getFont();
  gc.setFont(curFont);
  final org.eclipse.swt.graphics.Point extent = gc.textExtent(str, flags);
  gc.setFont(scaledFont);
  return extent;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.forms

@Override
public void computeSelection(GC gc, Hashtable<String, Object> resourceTable, SelectionData selData) {
  Font oldFont = null;
  if (fontId != null) {
    oldFont = gc.getFont();
    Font newFont = (Font) resourceTable.get(fontId);
    if (newFont != null)
      gc.setFont(newFont);
  }
  for (int i = 0; i < areaRectangles.size(); i++) {
    AreaRectangle areaRectangle = areaRectangles.get(i);
    Rectangle rect = areaRectangle.rect;
    String text = areaRectangle.getText();
    Point extent = gc.textExtent(text);
    computeSelection(gc, text, extent.x, selData,
        rect);
  }
  // restore GC resources
  if (oldFont != null) {
    gc.setFont(oldFont);
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.forms

@Override
public void computeSelection(GC gc, Hashtable<String, Object> resourceTable, SelectionData selData) {
  Font oldFont = null;
  if (fontId != null) {
    oldFont = gc.getFont();
    Font newFont = (Font) resourceTable.get(fontId);
    if (newFont != null)
      gc.setFont(newFont);
  }
  for (int i = 0; i < areaRectangles.size(); i++) {
    AreaRectangle areaRectangle = areaRectangles.get(i);
    Rectangle rect = areaRectangle.rect;
    String text = areaRectangle.getText();
    Point extent = gc.textExtent(text);
    computeSelection(gc, text, extent.x, selData,
        rect);
  }
  // restore GC resources
  if (oldFont != null) {
    gc.setFont(oldFont);
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

public static Font getAnyFontItalic(GC gc) {
  if (fontItalic == null || fontItalic.isDisposed()) {
    FontData[] fontData = gc.getFont().getFontData();
    for (FontData fd : fontData) {
      fd.setStyle(SWT.ITALIC);
    }
    fontItalic = new Font(gc.getDevice(), fontData);
  }
  return fontItalic;
}

代码示例来源:origin: BiglySoftware/BiglyBT

public static Font getAnyFontBold(GC gc) {

  if (fontBold == null || fontBold.isDisposed()) {
    FontData[] fontData = gc.getFont().getFontData();
    for (FontData fd : fontData) {
      fd.setStyle(SWT.BOLD);
    }
    fontBold = new Font(gc.getDevice(), fontData);
  }
  return fontBold;
}

代码示例来源:origin: BiglySoftware/BiglyBT

public static Font getAnyFontBoldItalic(GC gc) {
  if (fontBoldItalic == null || fontBoldItalic.isDisposed()) {
    FontData[] fontData = gc.getFont().getFontData();
    for (FontData fd : fontData) {
      fd.setStyle(SWT.BOLD | SWT.ITALIC);
    }
    fontBoldItalic = new Font(gc.getDevice(), fontData);
  }
  return fontBoldItalic;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

@Override
  public void addDamagedRegion(FigureDrawContext fdc, Region region) {
    Font oldFont = fdc.gc.getFont();
    fdc.gc.setFont(font);
    Point textExtent = fdc.gc.textExtent(text);
    fdc.gc.setFont(oldFont);
    region.add(fdc.toClientRectangle(x, y, x + textExtent.x, y + textExtent.y));
  }
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer

public int getWidth(FontContext context, FSFont font, String string) {
  GC gc = ((SWTFontContext) context).getGC();
  Font previous = gc.getFont();
  gc.setFont(((SWTFSFont) font).getSWTFont());
  int width = gc.stringExtent(string).x;
  gc.setFont(previous);
  return width;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.tips.ui

private Point getTipCountTextSize(Composite providerButton, int tipCount) {
    GC gc2 = new GC(providerButton);
    gc2.setAdvanced(true);
    gc2.setFont(SWTResourceManager.getBoldFont(gc2.getFont()));
    Point textExtent = gc2.textExtent(tipCount + ""); //$NON-NLS-1$
    gc2.dispose();
    return textExtent;
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

private GCStringPrinter setupStringPrinter(GC gc, TableCellSWT cell) {
  ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
  String text = entry.getText();
  Rectangle drawBounds = getDrawBounds(cell);
  entry.setViewed();
  if (!entry.isRead()) {
    if (font == null) {
      FontData[] fontData = gc.getFont().getFontData();
      fontData[0].setStyle(SWT.BOLD);
      font = new Font(gc.getDevice(), fontData);
    }
    gc.setFont(font);
  }
  int style = SWT.WRAP;
  GCStringPrinter sp = new GCStringPrinter(gc, text, drawBounds, true, true,
      style);
  sp.calculateMetrics();
  return sp;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.tips.ui

gc.setFont(SWTResourceManager.getBoldFont(gc.getFont()));
gc.setAlpha(200);
gc.setTextAntialias(SWT.ON);

代码示例来源:origin: BiglySoftware/BiglyBT

});
e.gc.setAlpha(180);
Font lastFont = e.gc.getFont();
e.gc.setFont(fontCount);
spCount = new GCStringPrinter(e.gc, sCount, printArea, true, false,

相关文章

GC类方法