Tabnine Logo
GC.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.eclipse.swt.graphics.GC
constructor

Best Java code snippets using org.eclipse.swt.graphics.GC.<init> (Showing top 20 results out of 873)

Refine searchRefine arrow

  • GC.dispose
origin: pentaho/pentaho-kettle

 private String truncateName( String name ) {
  GC gc = new GC( toolBar );
  Point size = gc.textExtent( name );
  if ( size.x <= MAX_REPO_NAME_PIXEL_LENGTH ) { // repository name is small enough to fit just return it.
   gc.dispose();
   return name;
  }
  String originalName = name;
  while ( gc.textExtent( name + "..." ).x > MAX_REPO_NAME_PIXEL_LENGTH ) {
   name = name.substring( 0, name.length() - 1 );
  }
  gc.dispose();
  name = name + "...";
  return name;
 }
}
origin: pentaho/pentaho-kettle

@Override
protected Image renderSimple( Device device, int width, int height ) {
 int xsize = bitmap.getBounds().width;
 int ysize = bitmap.getBounds().height;
 Image result = new Image( device, width, height );
 GC gc = new GC( result );
 gc.drawImage( bitmap, 0, 0, xsize, ysize, 0, 0, width, height );
 gc.dispose();
 return result;
}
origin: pentaho/pentaho-kettle

String leftText = newText.substring( 0, e.start );
String rightText = newText.substring( e.end, newText.length() );
GC gc = new GC( text );
Point size = gc.textExtent( leftText + e.text + rightText );
gc.dispose();
size = text.computeSize( size.x, SWT.DEFAULT );
editor.horizontalAlignment = SWT.LEFT;
origin: pentaho/pentaho-kettle

String leftText = newText.substring( 0, e.start );
String rightText = newText.substring( e.end, newText.length() );
GC gc = new GC( text );
Point size = gc.textExtent( leftText + e.text + rightText );
gc.dispose();
size = text.computeSize( size.x, SWT.DEFAULT );
editor.horizontalAlignment = SWT.LEFT;
origin: pentaho/pentaho-kettle

String leftText = newText.substring( 0, e.start );
String rightText = newText.substring( e.end, newText.length() );
GC gc = new GC( text );
Point size = gc.textExtent( leftText + e.text + rightText );
gc.dispose();
size = text.computeSize( size.x, SWT.DEFAULT );
editor.horizontalAlignment = SWT.LEFT;
origin: caoxinyu/RedisClient

/**
 * @return the small {@link Image} that can be used as placeholder for missing image.
 */
private static Image getMissingImage() {
  Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
  //
  GC gc = new GC(image);
  gc.setBackground(getColor(SWT.COLOR_RED));
  gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
  gc.dispose();
  //
  return image;
}
/**
origin: caoxinyu/RedisClient

GC gc = new GC(result);
gc.drawImage(baseImage, 0, 0);
if (corner == TOP_LEFT) {
  gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height);
gc.dispose();
origin: pentaho/pentaho-kettle

 @Override
 protected Image renderRotated( Device device, int width, int height, double angleRadians ) {
  Image result = new Image( device, width * 2, height * 2 );

  GC gc = new GC( result );

  int bw = bitmap.getBounds().width;
  int bh = bitmap.getBounds().height;
  Transform affineTransform = new Transform( device );
  affineTransform.translate( width, height );
  affineTransform.rotate( (float) Math.toDegrees( angleRadians ) );
  affineTransform.scale( (float) 1.0 * width / bw, (float) 1.0 * height / bh );
  gc.setTransform( affineTransform );

  gc.drawImage( bitmap, 0, 0, bw, bh, -bw / 2, -bh / 2, bw, bh );

  gc.dispose();

  return result;
 }
}
origin: pentaho/pentaho-kettle

void layout() {
 Composite parent = canvas.getParent();
 Rectangle rect = parent.getClientArea();
 int width = 0;
 String[] items = list.getItems();
 GC gc = new GC( list );
 for ( int i = 0; i < objects.length; i++ ) {
  width = Math.max( width, gc.stringExtent( items[i] ).x );
 }
 gc.dispose();
 Point size1 = start.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size2 = stop.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size3 = check.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 Point size4 = label.computeSize( SWT.DEFAULT, SWT.DEFAULT );
 width = Math.max( size1.x, Math.max( size2.x, Math.max( size3.x, width ) ) );
 width = Math.max( 64, Math.max( size4.x, list.computeSize( width, SWT.DEFAULT ).x ) );
 start.setBounds( 0, 0, width, size1.y );
 stop.setBounds( 0, size1.y, width, size2.y );
 check.setBounds( 0, size1.y + size2.y, width, size3.y );
 label.setBounds( 0, rect.height - size4.y, width, size4.y );
 int height = size1.y + size2.y + size3.y;
 list.setBounds( 0, height, width, rect.height - height - size4.y );
 text.setBounds( width, 0, rect.width - width, rect.height );
 canvas.setBounds( width, 0, rect.width - width, rect.height );
}
origin: pentaho/pentaho-kettle

/**
 * Get the image for when all other fallbacks have failed.  This is an image
 * drawn on the canvas, a square with a red X.
 *
 * @param display the device to render the image to
 * @return the missing image
 */
public static SwtUniversalImage getMissingImage( Display display ) {
 Image img = new Image( display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE );
 GC gc = new GC( img );
 gc.setForeground( new Color( display, 0, 0, 0 ) );
 gc.drawRectangle( 4, 4, ConstUI.ICON_SIZE - 8, ConstUI.ICON_SIZE - 8 );
 gc.setForeground( new Color( display, 255, 0, 0 ) );
 gc.drawLine( 4, 4, ConstUI.ICON_SIZE - 4, ConstUI.ICON_SIZE - 4 );
 gc.drawLine( ConstUI.ICON_SIZE - 4, 4, 4, ConstUI.ICON_SIZE - 4 );
 gc.dispose();
 return new SwtUniversalImageBitmap( img );
}
origin: pentaho/pentaho-kettle

public static final void setOptimalWidthOnColumns( Tree tree ) {
 int nrCols = tree.getColumnCount();
 int[] max = new int[nrCols];
 Image image = new Image( tree.getDisplay(), 10, 10 );
 GC gc = new GC( image );
 for ( int i = 0; i < max.length; i++ ) {
  TreeColumn treeColumn = tree.getColumn( i );
  Point point = gc.textExtent( treeColumn.getText() );
  max[i] = point.x;
 }
 getMaxWidths( tree.getItems(), max, gc );
 gc.dispose();
 image.dispose();
 for ( int i = 0; i < max.length; i++ ) {
  TreeColumn treeColumn = tree.getColumn( i );
  treeColumn.setWidth( max[i] + 30 );
 }
}
origin: pentaho/pentaho-kettle

GC gc_printer = new GC( printer );
gc_printer.dispose();
origin: pentaho/pentaho-kettle

 GC gc = new GC( cache_image );
 gc.dispose();
GC gc = new GC( image );
gc.dispose();
image.dispose();
origin: pentaho/pentaho-kettle

 GC gc = new GC( cache_image );
 gc.dispose();
GC gc = new GC( image );
gc.dispose();
image.dispose();
origin: pentaho/pentaho-kettle

GC gc = new GC( text );
FontMetrics fm = gc.getFontMetrics();
int charWidth = fm.getAverageCharWidth();
int fieldWidth = text.computeSize( charWidth * 20, SWT.DEFAULT ).x;
gc.dispose();
origin: org.eclipse.platform/org.eclipse.jface

Point getExtent() {
  GC gc = new GC(hoverShell);
  Point e = gc.textExtent(text);
  gc.dispose();
  e.x += hm * 2;
  e.y += hm * 2;
  return e;
}
origin: org.eclipse.platform/org.eclipse.ui.workbench

private static void createSpace(Composite parent) {
  Label vfiller = new Label(parent, SWT.LEFT);
  GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
  gridData.horizontalSpan= 2;
  GC gc = new GC(parent);
  gridData.heightHint = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), 1) / 2;
  gc.dispose();
  vfiller.setLayoutData(gridData);
}
origin: org.eclipse/org.eclipse.compare

public void repaint() {
  if (!isDisposed()) {
    GC gc= new GC(this);
    doubleBufferPaint(gc);
    gc.dispose();
  }
}
origin: org.eclipse/org.eclipse.wst.server.ui

public StatusLineLabel(Composite parent, int style) {
  super(parent, style);
  
  GC gc= new GC(parent);
  gc.setFont(parent.getFont());
  Point extent= gc.textExtent("MMMMMMMMM"); //$NON-NLS-1$
  gc.dispose();
  
  fFixedSize= new Point(extent.x + INDENT * 2, 10);
}

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();
  }
}
org.eclipse.swt.graphicsGC<init>

Javadoc

Prevents uninitialized instances from being created outside the package.

Popular methods of GC

  • dispose
  • setBackground
    Sets the background color. The background color is used for fill operations and as the background co
  • getFontMetrics
    Returns a FontMetrics which contains information about the font currently being used by the receiver
  • setForeground
    Sets the foreground color. The foreground color is used for drawing operations including when text i
  • setFont
    Sets the font which will be used by the receiver to draw and measure text to the argument. If the ar
  • drawImage
  • fillRectangle
    Fills the interior of the specified rectangle, using the receiver's background color.
  • textExtent
    Returns the extent of the given string. Tab expansion, line delimiter and mnemonic processing are pe
  • drawLine
    Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
  • drawRectangle
    Draws the outline of the specified rectangle, using the receiver's foreground color. The left and ri
  • drawText
    Draws the given string, using the receiver's current font and foreground color. Tab expansion and ca
  • setLineWidth
    Sets the width that will be used when drawing lines for all of the figure drawing operations (that i
  • drawText,
  • setLineWidth,
  • stringExtent,
  • getForeground,
  • getBackground,
  • getDevice,
  • setAlpha,
  • fillPolygon,
  • drawString

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • getSupportFragmentManager (FragmentActivity)
  • getSystemService (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now