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(); }
@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; }
private void disposeImage( Image image ) { if ( image != null && !image.isDisposed() ) { image.dispose(); } }
public static Image makeImageTransparent( Display display, Image tempImage, RGB transparentColor ) { ImageData imageData = tempImage.getImageData(); int pixelIndex = imageData.palette.getPixel( transparentColor ); imageData.transparentPixel = pixelIndex; Image image = new Image( display, imageData ); tempImage.dispose(); return image; }
public int open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX ); props.setLook( shell ); formLayout.marginHeight = 15; shell.setLayout( formLayout ); Image image = display.getSystemImage( SWT.ICON_WARNING ); Label wIcon = new Label( shell, SWT.NONE ); props.setLook( wIcon ); wIcon.setImage( image ); FormData fdIcon = new FormData(); fdIcon.left = new FormAttachment( 0, 0 ); fdIcon.top = new FormAttachment( 0, 0 ); fdIcon.right = new FormAttachment( 0, image.getBounds().width ); fdIcon.bottom = new FormAttachment( 0, image.getBounds().height ); wIcon.setLayoutData( fdIcon ); Composite wcMessage = new Composite( shell, SWT.NONE ); props.setLook( wcMessage ); wcMessage.setLayout( new GridLayout() ); if ( !display.readAndDispatch() ) { display.sleep();
public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX ); props.setLook( shell ); setShellImage( shell, input ); formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout( formLayout ); int margin = Const.MARGIN; Rectangle imageBounds = GUIResource.getInstance().getImageInfoHop().getBounds(); wlStepname = new Label( shell, SWT.RIGHT ); wlStepname.setText( BaseMessages.getString( PKG, "ValidatorDialog.Stepname.Label" ) ); props.setLook( wlStepname ); fdlStepname = new FormData(); wSComp.setLayoutData( fdComp ); wComp.layout(); if ( !display.readAndDispatch() ) { display.sleep();
shell.setText(RedisClient.i18nFile.getText(I18nFile.ABOUTREDISCLIENT)); shell.setLayout(new GridLayout(1, false)); Composite composite = new Composite(shell, SWT.NONE); composite.setLayout(new GridLayout(3, false)); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); final int width = image.getBounds().width; final int height = image.getBounds().height; final Image scaled050 = new Image(shell.getDisplay(), image.getImageData().scaledTo((int)(width*0.5),(int)(height*0.5))); Label btnNewButton_1 = new Label(composite, SWT.FLAT); btnNewButton_1.setBounds(0, 0, 80, 27); btnNewButton_1.setImage(scaled050); lblNewLabel.addSelectionListener(openUrl); lblNewLabel.setFont(SWTResourceManager.getFont("Arial", 20, SWT.NORMAL)); lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); lblNewLabel.setBounds(0, 0, 61, 17); lblNewLabel.setText("<a href=\"https://github.com/caoxinyu/RedisClient\">RedisClient for Windows</a>"); Label label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); new Label(composite, SWT.NONE);
public int open() { Display display = parent.getDisplay(); shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.RESIZE ); shell.setImage( GUIResource.getInstance().getImageSpoon() ); image = display.getSystemImage( SWT.ICON_WARNING ); image = display.getSystemImage( SWT.ICON_INFORMATION ); image = display.getSystemImage( SWT.ICON_QUESTION ); wIcon = new Label( shell, SWT.NONE ); props.setLook( wIcon ); wIcon.setImage( image ); FormData fdIcon = new FormData(); fdIcon.left = new FormAttachment( 0, 0 ); fdIcon.top = new FormAttachment( 0, 0 ); fdIcon.right = new FormAttachment( 0, image.getBounds().width ); fdIcon.bottom = new FormAttachment( 0, image.getBounds().height ); wIcon.setLayoutData( fdIcon );
messageComposite = new Composite(parent, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginHeight = 0; messageLayout.makeColumnsEqualWidth = false; messageComposite.setLayout(messageLayout); messageImageLabel = new Label(messageComposite, SWT.NONE); GridData imageData = new GridData(GridData.VERTICAL_ALIGN_CENTER); Image sizingImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); Rectangle imageBounds; if(sizingImage == null) imageBounds = new Rectangle(0,0,IDialogConstants.VERTICAL_MARGIN * 2,IDialogConstants.VERTICAL_MARGIN * 2); else imageBounds = sizingImage.getBounds(); imageData.heightHint = imageBounds.height + IDialogConstants.VERTICAL_SPACING; imageData.widthHint = imageBounds.width + IDialogConstants.HORIZONTAL_SPACING; messageImageLabel.setLayoutData(imageData); messageText.setBackground(parent.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND)); GridData textData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); messageText.setLayoutData(textData);
@Override public CTabItem init() { server = service.listById(id); Image subImage = new Image(tabFolder.getShell().getDisplay(), getClass().getResourceAsStream("/subscribe.png")); Composite composite_4 = new Composite(composite_3, SWT.NONE); composite_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); composite_4.setLayout(new GridLayout(3, false)); lblNewLabel = new Label(composite_4, SWT.NONE); lblNewLabel.setBounds(0, 0, 55, 15); lblNewLabel.setText(RedisClient.i18nFile.getText(I18nFile.CHANNEL)); channel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); channel.setBounds(0, 0, 88, 23); channel.addControlListener(new ControlAdapter() { btnNewButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnNewButton.setBounds(0, 0, 75, 25); btnNewButton.setText(RedisClient.i18nFile.getText(I18nFile.SUBSCRIBE)); tabFolder_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tabFolder_2.setBounds(0, 0, 156, 125); tabFolder_2.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
Label label = new Label(imageComposite, SWT.NONE); label.setText(mLastPlugin); label.setBackground(label.getParent().getBackground()); mPluginImageContainer.layout(); mPluginImageContainer = new Composite(imageComposite, SWT.NONE); mPluginImageContainer.setLayout(mRowLayout); mPluginImageContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); mPluginImageContainer.setBackground(mPluginImageContainer.getParent().getBackground()); Image image = new Image(getViewSite().getShell().getDisplay(), element.getImageData()); displayedImages.add(image); button.setImage(image);
public CTabItem init(){ server = service.listById(id); Image pubImage = new Image(tabFolder.getShell().getDisplay(), getClass().getResourceAsStream("/publish.png")); composite_3 = new Composite(tabFolder, SWT.NONE); tbtmNewItem.setControl(composite_3); composite_3.setLayout(new GridLayout(1, false)); tbtmNewItem.setText(server.getName() +" "+RedisClient.i18nFile.getText(I18nFile.PUBLISH)); tbtmNewItem.setImage(pubImage); sashForm_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite composite_4 = new Composite(sashForm_2, SWT.NONE); composite_4.setLayout(new GridLayout(1, false)); Composite composite_5 = new Composite(composite_4, SWT.NONE); composite_5.setLayout(new GridLayout(3, false)); composite_5.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); label = new Label(composite_5, SWT.NONE); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); label.setText(RedisClient.i18nFile.getText(I18nFile.CHANNEL));
boolean can_popout = shell == null && public_chat; Composite top_right = new Composite(rhs, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.marginWidth = 0; top_right.setLayout(layout); GridData grid_data = new GridData( GridData.FILL_HORIZONTAL ); top_right.setLayoutData(grid_data); Label label = new Label( top_right, SWT.NULL ); grid_data = new GridData( GridData.FILL_HORIZONTAL ); grid_data.horizontalSpan=can_popout?1:2; label.setLayoutData(grid_data); Label pop_out = new Label( top_right, SWT.NULL ); Image image = ImageLoader.getInstance().getImage( "popout_window" ); pop_out.setImage( image ); GridData grid_data = new GridData(); grid_data.widthHint=image.getBounds().width; grid_data.heightHint=image.getBounds().height; pop_out.setLayoutData(grid_data); pop_out.setCursor(pop_out.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
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 { oldImage.dispose(); Shell shell = new Shell(display); try { shell.setSize(200, 100); shell.setLayout(new FillLayout()); createComponents(shell); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { imageGradient.dispose();
@Override public CTabItem init(){ server = service.listById(id); Image runImage = new Image(tabFolder.getShell().getDisplay(), getClass().getResourceAsStream("/run.png")); Image consoleImage = new Image(tabFolder.getShell().getDisplay(), getClass().getResourceAsStream("/console.png")); Composite composite_3 = new Composite(tabFolder, SWT.NONE); tbtmNewItem.setControl(composite_3); composite_3.setLayout(new GridLayout(1, false)); tbtmNewItem.setText(server.getName() +" "+RedisClient.i18nFile.getText(I18nFile.CONSOLE)); tbtmNewItem.setImage(consoleImage); composite_4 = new Composite(composite_3, SWT.NONE); composite_4.setLayout(new GridLayout(3, false)); composite_4.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); sashForm3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); cmdResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); cmdResult.setEditable(false); cmdResult.addMouseListener(new MouseAdapter() {
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 freeze() { release(); if (sourceViewer instanceof SourceViewer) { Control viewerControl = ((SourceViewer) sourceViewer).getControl(); if (viewerControl instanceof Composite) { Composite composite = (Composite) viewerControl; Display display = composite.getDisplay(); // Flush pending redraw requests: while (!display.isDisposed() && display.readAndDispatch()) { } // Copy editor area: GC gc = new GC(composite); Point size; try { size = composite.getSize(); image = new Image(gc.getDevice(), size.x, size.y); gc.copyArea(image, 0, 0); } finally { gc.dispose(); gc = null; } // Persist editor area while executing refactoring: label = new Label(composite, SWT.NONE); label.setImage(image); label.setBounds(0, 0, size.x, size.y); label.moveAbove(null); } } }
private void createText() { Label textLabel = new Label( shell, SWT.WRAP ); if( markupEnabled ) { textLabel.setData( RWT.MARKUP_ENABLED, Boolean.TRUE ); } GridData data = new GridData( GridData.HORIZONTAL_ALIGN_FILL ); int imageWidth = image == null ? 0 : image.getBounds().width; int maxTextWidth = MAX_WIDTH - imageWidth - SPACING; int maxLineWidth = getMaxMessageLineWidth(); if( maxLineWidth > maxTextWidth ) { data.widthHint = maxTextWidth; } textLabel.setLayoutData( data ); textLabel.setText( message ); }
private void captureScreenshotContentFromSelection() { Display display = getShell().getDisplay(); Image image = new Image(display, currentSelection); GC gc = new GC(image); gc.drawImage(workImage, currentSelection.x, currentSelection.y, currentSelection.width, currentSelection.height, 0, 0, currentSelection.width, currentSelection.height); gc.dispose(); disposeImageResources(); originalImage = image; Rectangle displayBounds = originalImage.getBounds(); workImage = new Image(display, displayBounds.width, displayBounds.height); gc = new GC(workImage); gc.drawImage(originalImage, 0, 0); gc.dispose(); workImageGC = new GC(workImage); workImageGC.setLineCap(SWT.CAP_ROUND); scrolledComposite.setEnabled(true); clearSelection(); refreshCanvasSize(); stateChanged(); }
@Override protected void updateContents(Object value) { RGB rgb = (RGB) value; // XXX: We don't have a value the first time this method is called". if (rgb == null) { rgb = new RGB(0, 0, 0); } // XXX: Workaround for 1FMQ0P3: SWT:ALL - TableItem.setImage doesn't work if using the identical image." if (image != null) { image.dispose(); } ImageData id = createColorImage(colorLabel.getParent().getParent(), rgb); ImageData mask = id.getTransparencyMask(); image = new Image(colorLabel.getDisplay(), id, mask); colorLabel.setImage(image); rgbLabel .setText("(" + rgb.red + "," + rgb.green + "," + rgb.blue + ")");//$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ } }