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

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

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

GC.setFont介绍

[英]Sets the font which will be used by the receiver to draw and measure text to the argument. If the argument is null, then a default font appropriate for the platform will be used instead.
[中]设置接收者将用于绘制和测量参数文本的字体。如果参数为null,则将使用适合平台的默认字体。

代码示例

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

public static void setGCFont( GC gc, Device device, FontData fontData ) {
 if ( Const.getOS().startsWith( "Windows" ) ) {
  Font font = new Font( device, fontData );
  gc.setFont( font );
  font.dispose();
 } else {
  gc.setFont( device.getSystemFont() );
 }
}

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

public void setFont( String fontName, int fontSize, boolean fontBold, boolean fontItalic ) {
 int swt = SWT.NORMAL;
 if ( fontBold ) {
  swt = SWT.BOLD;
 }
 if ( fontItalic ) {
  swt = swt | SWT.ITALIC;
 }
 Font font = new Font( PropsUI.getDisplay(), fontName, fontSize, swt );
 int index = fonts.indexOf( font );
 if ( index < 0 ) {
  fonts.add( font );
 } else {
  font.dispose();
  font = fonts.get( index );
 }
 gc.setFont( font );
}

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

public void setFont( String fontName, int fontSize, boolean fontBold, boolean fontItalic ) {
 int swt = SWT.NORMAL;
 if ( fontBold ) {
  swt = SWT.BOLD;
 }
 if ( fontItalic ) {
  swt = swt | SWT.ITALIC;
 }
 Font font = new Font( PropsUI.getDisplay(), fontName, fontSize, swt );
 int index = fonts.indexOf( font );
 if ( index < 0 ) {
  fonts.add( font );
 } else {
  font.dispose();
  font = fonts.get( index );
 }
 gc.setFont( font );
}

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

public void setFont( EFont font ) {
 switch ( font ) {
  case GRAPH:
   gc.setFont( GUIResource.getInstance().getFontGraph() );
   break;
  case NOTE:
   gc.setFont( GUIResource.getInstance().getFontNote() );
   break;
  case SMALL:
   gc.setFont( GUIResource.getInstance().getFontSmall() );
   break;
  default:
   break;
 }
}

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

public void setFont( EFont font ) {
 switch ( font ) {
  case GRAPH:
   gc.setFont( GUIResource.getInstance().getFontGraph() );
   break;
  case NOTE:
   gc.setFont( GUIResource.getInstance().getFontNote() );
   break;
  case SMALL:
   gc.setFont( GUIResource.getInstance().getFontSmall() );
   break;
  default:
   break;
 }
}

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

public void paintControl( PaintEvent pe ) {
  pe.gc.setFont( fixedFont );
  Rectangle max = wFFont.getBounds();
  String name = fixedFontData.getName() + " - " + fixedFontData.getHeight();
  Point size = pe.gc.textExtent( name );
  pe.gc.drawText( name, ( max.width - size.x ) / 2, ( max.height - size.y ) / 2, true );
 }
} );

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

public void paintControl( PaintEvent pe ) {
  pe.gc.setFont( graphFont );
  Rectangle max = wGFont.getBounds();
  String name = graphFontData.getName() + " - " + graphFontData.getHeight();
  Point size = pe.gc.textExtent( name );
  pe.gc.drawText( name, ( max.width - size.x ) / 2, ( max.height - size.y ) / 2, true );
 }
} );

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

public void paintControl( PaintEvent pe ) {
  pe.gc.setFont( noteFont );
  Rectangle max = wNFont.getBounds();
  String name = noteFontData.getName() + " - " + noteFontData.getHeight();
  Point size = pe.gc.textExtent( name );
  pe.gc.drawText( name, ( max.width - size.x ) / 2, ( max.height - size.y ) / 2, true );
 }
} );

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

private void drawVersionWarning( GC gc, Display display ) {
 gc.setBackground( versionWarningBackgroundColor );
 gc.setForeground( new Color( display, 65, 65, 65 ) );
 // gc.fillRectangle(290, 231, 367, 49);
 // gc.drawRectangle(290, 231, 367, 49);
 gc.drawImage( exclamation_image, 304, 243 );
 gc.setFont( devWarningFont );
 gc.drawText( BaseMessages.getString( PKG, "SplashDialog.DevelopmentWarning" ), 335, 241, true );
}

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

fullVersionText =  fullVersionText + " "  + buildVersion;
e.gc.setFont( verFont );
e.gc.setForeground( new Color( display, 65, 65, 65 ) );
e.gc.drawText( fullVersionText, 290, 205, true );
e.gc.setFont( licFont );
e.gc.setForeground( new Color( display, 65, 65, 65 ) );
 e.gc.setFont( licFont );

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

public void paintControl( PaintEvent e ) {
 Point area = getArea();
 if ( area.x == 0 || area.y == 0 ) {
  return; // nothing to do!
 }
 Display disp = shell.getDisplay();
 Image img = getTransformationImage( disp, area.x, area.y, magnification );
 e.gc.drawImage( img, 0, 0 );
 if ( transMeta.nrSteps() == 0 ) {
  e.gc.setForeground( GUIResource.getInstance().getColorCrystalTextPentaho() );
  e.gc.setFont( GUIResource.getInstance().getFontMedium() );
  Image pentahoImage = GUIResource.getInstance().getImageTransCanvas();
  int leftPosition = ( area.x - pentahoImage.getBounds().width ) / 2;
  int topPosition = ( area.y - pentahoImage.getBounds().height ) / 2;
  e.gc.drawImage( pentahoImage, leftPosition, topPosition );
 }
 img.dispose();
 // spoon.setShellText();
}

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

public void paintControl( PaintEvent e ) {
 Point area = getArea();
 if ( area.x == 0 || area.y == 0 ) {
  return; // nothing to do!
 }
 Display disp = shell.getDisplay();
 Image img = getJobImage( disp, area.x, area.y, magnification );
 e.gc.drawImage( img, 0, 0 );
 if ( jobMeta.nrJobEntries() == 0 ) {
  e.gc.setForeground( GUIResource.getInstance().getColorCrystalTextPentaho() );
  e.gc.setBackground( GUIResource.getInstance().getColorBackground() );
  e.gc.setFont( GUIResource.getInstance().getFontMedium() );
  Image pentahoImage = GUIResource.getInstance().getImageJobCanvas();
  int leftPosition = ( area.x - pentahoImage.getBounds().width ) / 2;
  int topPosition = ( area.y - pentahoImage.getBounds().height ) / 2;
  e.gc.drawImage( pentahoImage, leftPosition, topPosition );
 }
 img.dispose();
}

代码示例来源:origin: stackoverflow.com

GC gc = new GC(text);
try
{
  gc.setFont(text.getFont());
  FontMetrics fm = gc.getFontMetrics();

  /* Set the height to 5 rows of characters */
  data.heightHint = 5 * fm.getHeight();
}
finally
{
  gc.dispose();
}

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

gc.setFont( fixed );

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

return;
gc.setFont( (Font) object );
FontData[] array = gc.getFont().getFontData();
String string = "";

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

TableView.dummyGC.setFont( gridFont );

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

@Override
  public Point computeSizeConstraints(int widthInChars, int heightInChars) {
    GC gc= new GC(fText);
    gc.setFont(fTextFont);
    int width= gc.getFontMetrics().getAverageCharWidth();
    int height= fText.getLineHeight(); //https://bugs.eclipse.org/bugs/show_bug.cgi?id=377109
    gc.dispose();

    return new Point(widthInChars * width, heightInChars * height);
  }
}

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

public static int getFontHeightInPX(Font font) {
  GC gc = new GC(font.getDevice());
  try {
    gc.setFont(font);
    return gc.textExtent(Utils.GOOD_STRING).y;
  } finally {
    gc.dispose();
  }
}

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

public PixelConverter(Control control) {
  GC gc = new GC(control);
  gc.setFont(control.getFont());
  fFontMetrics= gc.getFontMetrics();
  gc.dispose();
}

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

private static int getButtonWidthHint(Button button) {
    button.setFont(JFaceResources.getDialogFont());
    
    GC gc = new GC(button);
    gc.setFont(button.getFont());
    FontMetrics fontMetrics= gc.getFontMetrics();
    gc.dispose();
    
    int widthHint= Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
  }
}

相关文章

GC类方法