@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; }
public void paintControl( final PaintEvent event ) { if ( transGraph.trans != null && transGraph.trans.isFinished() ) { refreshImage( event.gc ); if ( image != null && !image.isDisposed() ) { event.gc.drawImage( image, 0, 0 ); } } else { Rectangle bounds = canvas.getBounds(); if ( bounds.width <= 0 || bounds.height <= 0 ) { return; } event.gc.setForeground( GUIResource.getInstance().getColorWhite() ); event.gc.setBackground( GUIResource.getInstance().getColorWhite() ); event.gc.fillRectangle( new Rectangle( 0, 0, bounds.width, bounds.height ) ); event.gc.setForeground( GUIResource.getInstance().getColorBlack() ); String metricsMessage = BaseMessages.getString( PKG, "TransMetricsDelegate.TransformationIsNotRunning.Message" ); org.eclipse.swt.graphics.Point extent = event.gc.textExtent( metricsMessage ); event.gc.drawText( metricsMessage, ( bounds.width - extent.x ) / 2, ( bounds.height - extent.y ) / 2 ); } } } );
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 ); }
private void drawMarker( GC gc, int x, int maxy ) { int[] triangle = new int[] { LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 }; gc.fillPolygon( triangle ); gc.drawPolygon( triangle ); gc .drawLine( LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy ); }
public void switchForegroundBackgroundColors() { Color fg = gc.getForeground(); Color bg = gc.getBackground(); gc.setForeground( bg ); gc.setBackground( fg ); }
public void drawUp( GC gc ) { if ( hover_up ) { gc.setBackground( gray ); gc.fillRectangle( size_up ); } gc.drawRectangle( size_up ); gc.drawText( STRING_UP, size_up.x + 1 + offsetx, size_up.y + 1 + offsety, SWT.DRAW_TRANSPARENT ); }
public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN ); props.setLook( shell ); setShellImage( shell, input ); formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout( formLayout ); shell.setText( BaseMessages.getString( PKG, "MonetDBBulkLoaderDialog.Shell.Title" ) ); .setText( BaseMessages.getString( PKG, "MonetDBBulkLoaderDialog.Tab.GeneralSettings.Label" ) ); wGeneralSettingsComp = new Composite( wTabFolder, SWT.NONE ); props.setLook( wGeneralSettingsComp ); wGeneralSettingsComp.layout(); wGeneralSettingsTab.setControl( wGeneralSettingsComp ); GC gc = new GC( text ); FontMetrics fm = gc.getFontMetrics(); int charWidth = fm.getAverageCharWidth(); int fieldWidth = text.computeSize( charWidth * 20, SWT.DEFAULT ).x; gc.dispose();
composite.addListener(SWT.Resize, new Listener() { public void handleEvent(Event e) { changeImage(); composite.setLayout(new FormLayout()); composite.setBackgroundMode(SWT.INHERIT_DEFAULT); Color color2 = new Color(display, 255, 255, 255); try { gc.setForeground(color1); gc.setBackground(color2); gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true); } finally { gc.dispose(); composite.setBackgroundImage(imageGradient); oldImage.dispose(); imageGradient.dispose();
final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NONE); composite.setLayout(new FillLayout()); treeItem.setText(String.format("item %d long name", i)); tree.addListener(SWT.DefaultSelection, new Listener() { @Override public void handleEvent(Event event) { loader.data = new ImageData[]{image.getImageData()}; final String pathToSave = "out.png"; System.out.println(new File(pathToSave).getAbsolutePath()); loader.save(pathToSave, SWT.IMAGE_PNG); gc.dispose(); image.dispose(); tree.getParent().setRedraw(true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep();
Display display = new Display (); Shell shell = new Shell (display, SWT.SHELL_TRIM | SWT.DOUBLE_BUFFERED); shell.setLayout(new FillLayout ()); final Image image = new Image(display, "C:\\temp\\flyimage1.png"); shell.addListener (SWT.Paint, new Listener () gc.drawImage (image, x, y); gc.dispose(); shell.setSize (600, 400); shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); if(image != null && !image.isDisposed()) image.dispose(); display.dispose ();
final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); final Image image = display.getSystemImage(SWT.ICON_ERROR); final String text = "Button"; float fontHeight = shell.getFont().getFontData()[0].height; data.heightHint = image.getImageData().height + (int)fontHeight + 20; data.widthHint = 100; button.addListener(SWT.Paint, new Listener() { Point textSize = gc.textExtent(text); gc.drawText(text, width / 2 - textSize.x / 2, image.getImageData().height - image.getImageData().height / 2 - textSize.y, true); gc.drawImage(image, width / 2 - image.getImageData().width / 2, height / 2 - image.getImageData().height / 2 + textSize.y / 2); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep();
public void setBackground (Color color) { super.setBackground(color); table.setBackground(color); if (sizeImage != null) { GC gc = new GC (sizeImage); gc.setBackground(getBackground()); Rectangle size = sizeImage.getBounds(); gc.fillRectangle(size); gc.dispose(); } } public void setEnabled (boolean enabled) {
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(); }
public static void main(String[] args) { final Display display = Display.getDefault(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); GC gc = new GC(display); System.out.println(gc.textExtent("Hi").y); gc.dispose(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
@Override public void initialize(AnimationEngine engine) { display = getAnimationShell().getDisplay(); Rectangle psRect = getAnimationShell().getBounds(); theShell = new Shell(getAnimationShell(), SWT.NO_TRIM | SWT.ON_TOP); theShell.setBounds(getAnimationShell().getBounds()); // Capture the background image backingStore = new Image(theShell.getDisplay(), psRect); GC gc = new GC(display); gc.copyArea(backingStore, psRect.x, psRect.y); gc.dispose(); // changeCoordinates(); // captureImages(); theShell.setBackgroundImage(backingStore); theShell.setVisible(true); display.update(); }
public Overlay(Shell shell) { baseShell = shell; Rectangle cr = baseShell.getClientArea(); Rectangle trim = baseShell.computeTrim(cr.x, cr.y, cr.width, cr.height); offsetX = -trim.x; offsetY = -trim.y; overlayShell = new Shell(baseShell, SWT.NO_TRIM | SWT.ON_TOP); overlayShell.setBounds(baseShell.getBounds()); overlayShell.setBackground(baseShell.getDisplay().getSystemColor( SWT.COLOR_DARK_GREEN)); overlayShell.setAlpha(128); blue = new Color(baseShell.getDisplay(), 0, 0, 128); overlayShell.addPaintListener(e -> { e.gc.setForeground(blue); e.gc.setBackground(blue); for (Adornment adornment : adornments) { adornment.drawAdornment(e.gc); } }); }
public void printImage( Shell sh, Image img ) { if ( printerdata != null ) { Rectangle imgbounds = img.getBounds(); Point max = new Point( imgbounds.width, imgbounds.height ); Point dpi_screen = Display.getCurrent().getDPI(); GC gc_printer = new GC( printer ); gc_printer.drawImage( img, fromx, fromy, imx, imy, (int) page_left, (int) page_top, (int) printx, (int) printy ); System.out.println( "img dept = " + img.getImageData().depth ); System.out.println( "prn dept = " + printer.getDepth() ); System.out.println( "img size = (" + img.getBounds().x + "," + img.getBounds().y + ") : (" + img.getBounds().width + "," + img.getBounds().height + ")" ); System.out.println( "fromx=" gc_printer.dispose();
/** * @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; } /**
/** * Build a 1x1 px gray image to be used as separator. This color, halfway * between white and black, looks good both in Classic and in Dark Theme */ private Image getSeparatorBgImage() { Image backgroundImage = new Image(Display.getDefault(), 1, 1); GC gc = new GC(backgroundImage); gc.setBackground(new Color(dialog.getDisplay(), 127, 127, 127)); gc.fillRectangle(0, 0, 1, 1); gc.dispose(); return backgroundImage; }
public PixelConverter(Font font) { GC gc = new GC(font.getDevice()); gc.setFont(font); fFontMetrics= gc.getFontMetrics(); gc.dispose(); }