Java Code Examples for org.eclipse.draw2d.Graphics#drawImage()
The following examples show how to use
org.eclipse.draw2d.Graphics#drawImage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExchangeFigure.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override protected void paintFigure(Graphics graphics) { if (node.parent().isMinimized() && !Animation.isRunning()) return; if (node.isDummy() || !node.exchange.isAvoided) { super.paintFigure(graphics); return; } int x = getLocation().x; int y = getLocation().y; int width = getSize().width; int margin = 5; Image iconLeft = Icon.EXCHANGE_BG_LEFT.get(); Image iconMiddle = Icon.EXCHANGE_BG_MIDDLE.get(); Image iconRight = Icon.EXCHANGE_BG_RIGHT.get(); graphics.drawImage(iconLeft, new Point(x, y + 2)); for (int i = margin; i < width - margin; i++) graphics.drawImage(iconMiddle, new Point(x + i, y + 2)); graphics.drawImage(iconRight, new Point(x + width - margin, y + 2)); super.paintFigure(graphics); }
Example 2
Source File: StyledLabel.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void paintFigure(Graphics graphics) { Rectangle bounds = getBounds(); graphics.translate(bounds.x, bounds.y); updateImage(); if (image == null || ranges == null || ranges.length == 0 || isOpaque()) { return; } if (getIcon() != null) graphics.drawImage(getIcon(), getIconLocation()); // if (!isEnabled()) { // graphics.translate(1, 1); // graphics.drawImage(image, getTextLocation()); // graphics.translate(-1, -1); // } graphics.drawImage(image, getTextLocation()); graphics.translate(-bounds.x, -bounds.y); }
Example 3
Source File: ProcessFigure.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void paintTop(Graphics graphics) { Image file = null; if (node.isMarked()) file = Icon.PROCESS_BG_MARKED.get(); if (node.process instanceof ProductSystemDescriptor) file = Icon.PROCESS_BG_SYS.get(); else if (isLCI()) file = Icon.PROCESS_BG_LCI.get(); else file = Icon.PROCESS_BG.get(); int x = getLocation().x; int y = getLocation().y; int width = getSize().width; for (int i = 0; i < width - 20; i++) graphics.drawImage(file, new Point(x + i, y)); graphics.setForegroundColor(LINE_COLOR); graphics.drawLine(new Point(x, y + MINIMUM_HEIGHT), new Point(x + width - 1, y + MINIMUM_HEIGHT)); graphics.setForegroundColor(TEXT_COLOR); }
Example 4
Source File: CustomResizeHandle.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Draws the handle with fill color and outline color dependent on the * primary selection status of the owner editpart. * * @param g * The graphics used to paint the figure. */ public void paintFigure(Graphics g) { Rectangle r = getBounds() ; switch (cursorDirection) { case PositionConstants.SOUTH_EAST: g.drawImage(Pics.getImage("resize_SE.gif"),r.getLocation()) ; break; case PositionConstants.NORTH: g.drawImage(Pics.getImage("resize_N.gif"),r.getLocation().translate(0, -2)) ; break; case PositionConstants.SOUTH: g.drawImage(Pics.getImage("resize_S.gif"),r.getLocation().translate(0, 5)) ; break; case PositionConstants.WEST: g.drawImage(Pics.getImage("resize_W.gif"),r.getLocation().translate(-2, 0)) ; break; case PositionConstants.EAST: g.drawImage(Pics.getImage("resize_E.gif"),r.getLocation().translate(5, 0)) ; break; default: break; } }
Example 5
Source File: DesignerRepresentation.java From birt with Eclipse Public License 1.0 | 6 votes |
public final void paintClientArea( Graphics g ) { if ( bPainting ) // PREVENT RE-ENTRANCY { return; } final Rectangle r = getClientArea( ).getCopy( ); if ( r.width <= 0 || r.height <= 0 ) { return; } bPainting = true; if ( bDirty ) { bDirty = false; imgChart = paintChart( g, r.getSize( ) ); } if ( imgChart != null ) { g.drawImage( imgChart, r.x, r.y ); } bPainting = false; }
Example 6
Source File: SVGFigure.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void paintFigure(final Graphics graphics) { super.paintFigure(graphics); Document document = getDocument(); if (document == null) { return; } Image image = null; try { final Rectangle r = getClientArea(); transcoder.setCanvasSize(specifyCanvasWidth ? r.width : -1, specifyCanvasHeight ? r.height : -1); updateRenderingHints(graphics); final BufferedImage awtImage = transcoder.getBufferedImage(); if (awtImage != null) { image = toSWT(Display.getCurrent(), awtImage); graphics.drawImage(image, r.x, r.y); } } finally { if (image != null) { image.dispose(); } document = null; } }
Example 7
Source File: GraphicsUtil.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Draw vertical text. * * @param graphics * draw2D graphics. * @param text * text to be drawn. * @param x * the x coordinate of the text, which is the left upper corner. * @param y * the y coordinate of the text, which is the left upper corner. */ public static final void drawVerticalText(Graphics graphics, String text, int x, int y, boolean upToDown) { try { if (SWT.getPlatform().startsWith("rap")) //$NON-NLS-1$ throw new Exception(); try { graphics.pushState(); graphics.translate(x, y); if (upToDown) { graphics.rotate(90); graphics.drawText(text, 0, -FigureUtilities.getTextExtents(text, graphics.getFont()).height); } else { graphics.rotate(270); graphics.drawText(text, -FigureUtilities.getTextWidth(text, graphics.getFont()), 0); } } finally { graphics.popState(); } } catch (Exception e) {// If rotate is not supported by the graphics. // final Dimension titleSize = FigureUtilities.getTextExtents(text, // graphics.getFont()); // final int w = titleSize.height; // final int h = titleSize.width + 1; Image image = null; try { image = SingleSourceHelper2.createVerticalTextImage(text, graphics.getFont(), graphics.getForegroundColor().getRGB(), upToDown); graphics.drawImage(image, x, y); } finally { if (image != null) image.dispose(); } } }
Example 8
Source File: InsertedImageFigure.java From ermaster-b with Apache License 2.0 | 5 votes |
@Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); graphics.setAlpha(alpha); Rectangle area = getClientArea(); if (this.fixAspectRatio) { Rectangle destination = new Rectangle(); double dw = (double) this.imageSize.width / (double) area.width; double dh = (double) this.imageSize.height / (double) area.height; if (dw > dh) { // we must limit the size by the width destination.width = area.width; destination.height = (int) (this.imageSize.height / dw); } else { // we must limit the size by the height destination.width = (int) (this.imageSize.width / dh); destination.height = area.height; } destination.x = (area.width - destination.width) / 2 + area.x; destination.y = (area.height - destination.height) / 2 + area.y; graphics.drawImage(this.image, new Rectangle(this.image.getBounds()), destination); } else { graphics.drawImage(this.image, new Rectangle(this.image.getBounds()), area); } }
Example 9
Source File: RotatedTextFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void paintClientArea( Graphics graphics ) { final Rectangle r = getClientArea( ).getCopy( ); String text = textItem.getText( ); int angle = textItem.getRotationAngle( ); if ( text == null ) { text = ""; //$NON-NLS-1$ } if ( !text.equals( lastText ) || angle != lastAngle || cachedImage == null || cachedImage.isDisposed( ) ) { lastText = text; lastAngle = angle; if ( cachedImage != null && !cachedImage.isDisposed( ) ) { cachedImage.dispose( ); } cachedImage = SwtGraphicsUtil.createRotatedTextImage( text, angle, null ); } if ( cachedImage != null && !cachedImage.isDisposed( ) ) { graphics.drawImage( cachedImage, r.x, r.y ); } }
Example 10
Source File: ImageFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
private void paintStretched( Graphics g ) { Image image = getImage( ); Rectangle area = getClientArea( ); if ( area.height > 0 && area.width > 0 ) { g.drawImage( image, new Rectangle( image.getBounds( ) ), area ); } }
Example 11
Source File: InsertedImageFigure.java From erflute with Apache License 2.0 | 5 votes |
@Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); graphics.setAlpha(alpha); final Rectangle area = getClientArea(); if (fixAspectRatio) { final Rectangle destination = new Rectangle(); final double dw = (double) imageSize.width / (double) area.width; final double dh = (double) imageSize.height / (double) area.height; if (dw > dh) { // we must limit the size by the width destination.width = area.width; destination.height = (int) (imageSize.height / dw); } else { // we must limit the size by the height destination.width = (int) (imageSize.width / dh); destination.height = area.height; } destination.x = (area.width - destination.width) / 2 + area.x; destination.y = (area.height - destination.height) / 2 + area.y; graphics.drawImage(image, new Rectangle(image.getBounds()), destination); } else { graphics.drawImage(image, new Rectangle(image.getBounds()), area); } }
Example 12
Source File: ColorMapRamp.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void paintClientArea(Graphics graphics) { super.paintClientArea(graphics); ImageData data = imageData==null ? colorMap.drawImage(mapData, 1, 256, max, min) : imageData; final Rectangle ca = getClientArea(); data = data.scaledTo(ca.width, ca.height); final Image image = new Image(Display.getDefault(), data); graphics.drawImage(image, ca.x, ca.y); image.dispose(); }
Example 13
Source File: ListBandControlFigure.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void paintFigure( Graphics graphics ) { Rectangle rect = getClientArea( ).getCopy( ); graphics.drawImage( getImage( ), rect.x, rect.y ); }
Example 14
Source File: ReportElementFigure.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure( Graphics graphics ) { if ( isOpaque( ) ) { if ( getBorder( ) instanceof BaseBorder ) { graphics.fillRectangle( getBounds( ).getCopy().crop( ( (BaseBorder) getBorder( ) ).getBorderInsets( ) ) ); } else { graphics.fillRectangle( getBounds( ) ); } } Image image = getImage( ); if ( image == null ) { return; } int x, y; Rectangle area = getBounds( ); graphics.getClip( PRIVATE_RECT ); //graphics.setClip( area ); // Calculates X if ( position != null && position.x != -1 ) { x = area.x + position.x; } else { switch ( alignment & PositionConstants.EAST_WEST ) { case PositionConstants.EAST : x = area.x + area.width - size.width; break; case PositionConstants.WEST : x = area.x; break; default : x = ( area.width - size.width ) / 2 + area.x; break; } } // Calculates Y if ( position != null && position.y != -1 ) { y = area.y + position.y; } else { switch ( alignment & PositionConstants.NORTH_SOUTH ) { case PositionConstants.NORTH : y = area.y; break; case PositionConstants.SOUTH : y = area.y + area.height - size.height; break; default : y = ( area.height - size.height ) / 2 + area.y; break; } } ArrayList xyList = createImageList( x, y ); Iterator iter = xyList.iterator( ); Dimension imageSize = new Rectangle( image.getBounds( ) ).getSize( ); while ( iter.hasNext( ) ) { Point point = (Point) iter.next( ); graphics.drawImage( image, 0, 0, imageSize.width, imageSize.height, point.x, point.y, size.width, size.height); } xyList.clear( ); graphics.setClip( PRIVATE_RECT ); }
Example 15
Source File: ImageFigure.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure( Graphics graphics ) { if ( isOpaque( ) ) { if ( getBorder( ) instanceof BaseBorder ) { graphics.fillRectangle( getBounds( ).getCopy( ) .crop( ( (BaseBorder) getBorder( ) ).getBorderInsets( ) ) ); } else { graphics.fillRectangle( getBounds( ) ); } } if ( getImage( ) == null || getImage( ).isDisposed( ) ) { return; } if ( stretch ) { paintStretched( graphics ); return; } int x, y; Rectangle area = getClientArea( ); switch ( alignment & PositionConstants.NORTH_SOUTH ) { case PositionConstants.NORTH : y = area.y; break; case PositionConstants.SOUTH : y = area.y + area.height - size.height; break; default : y = ( area.height - size.height ) / 2 + area.y; break; } switch ( alignment & PositionConstants.EAST_WEST ) { case PositionConstants.EAST : x = area.x + area.width - size.width; break; case PositionConstants.WEST : x = area.x; break; default : x = ( area.width - size.width ) / 2 + area.x; break; } graphics.drawImage( getImage( ), x, y ); }
Example 16
Source File: TableFigure.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure( Graphics graphics ) { if ( isOpaque( ) ) { if ( getBorder( ) instanceof BaseBorder ) { graphics.fillRectangle( getBounds( ).getCopy( ) .crop( ( (BaseBorder) getBorder( ) ).getBorderInsets( ) ) ); } else { graphics.fillRectangle( getBounds( ) ); } } Image image = getImage( ); if ( image == null ) { return; } int x, y; Rectangle area = getBounds( ); // Calculates X if ( position != null && position.x != -1 ) { x = area.x + position.x; } else { switch ( alignment & PositionConstants.EAST_WEST ) { case PositionConstants.EAST : x = area.x + area.width - size.width; break; case PositionConstants.WEST : x = area.x; break; default : x = ( area.width - size.width ) / 2 + area.x; break; } } // Calculates Y if ( position != null && position.y != -1 ) { y = area.y + position.y; } else { switch ( alignment & PositionConstants.NORTH_SOUTH ) { case PositionConstants.NORTH : y = area.y; break; case PositionConstants.SOUTH : y = area.y + area.height - size.height; break; default : y = ( area.height - size.height ) / 2 + area.y; break; } } ArrayList xyList = createImageList( x, y ); Iterator iter = xyList.iterator( ); while ( iter.hasNext( ) ) { Point point = (Point) iter.next( ); graphics.drawImage( image, point ); } xyList.clear( ); }
Example 17
Source File: RowHandle.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void paintFigure( Graphics graphics ) { if ( isSelect( ) ) { graphics.setBackgroundColor( ReportColorConstants.SelctionFillColor ); } else { graphics.setBackgroundColor( ReportColorConstants.TableGuideFillColor ); } graphics.setLineStyle( SWT.LINE_SOLID ); Rectangle bounds = getBounds( ).getCopy( ).resize( -1, -1 ); graphics.fillRectangle( bounds ); Font font = FontManager.getFont( "Dialog", 7, SWT.NORMAL );//$NON-NLS-1$ graphics.setFont( font ); Image image = getImage( ); if ( image == null ) return; graphics.setForegroundColor( ColorConstants.white ); graphics.setXORMode( true ); org.eclipse.swt.graphics.Rectangle rect = image.getBounds( ); int x = bounds.x + ( bounds.width - rect.width ) / 2; int y = bounds.y + ( bounds.height - rect.height ) / 2; graphics.drawImage( image, x, y ); TableEditPart part = (TableEditPart) getOwner( ); RowHandleAdapter rowHandleAdapter = HandleAdapterFactory.getInstance( ) .getRowHandleAdapter( part.getRow( getRowNumber( ) ) ); String type = rowHandleAdapter.getType( ); String displayName = rowHandleAdapter.getDisplayName( ); if ( TableHandleAdapter.TABLE_GROUP_HEADER.equals( type ) || TableHandleAdapter.TABLE_GROUP_FOOTER.equals( type ) ) { graphics.drawString( displayName, x + rect.width + 2, y + 2 ); } graphics.setBackgroundColor( ColorConstants.black ); // ReportFigureUtilities.paintBevel( graphics, // getBounds( ).getCopy( ), // true ); graphics.setXORMode( false ); }
Example 18
Source File: CustomSVGFigure.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override protected void paintFigure(Graphics graphics) { double stroke = getPreferredSize().width *(strokeWidth > 0 ? strokeWidth : 2.0)/ getClientArea().getSize().width ; Document document = getDocument(); if(document!= null && foregroundColor != null && backgroundColor != null){ if(!foundBgElement) { border = document.getElementById("BORDER"); Element svgid_1_ = document.getElementById("SVGID_1_"); NodeList stop = svgid_1_.getElementsByTagName("stop"); bgStyleNode = stop.item(0).getAttributes().getNamedItem("style"); foundBgElement = true; } if(border != null){ border.setAttribute("stroke", foregroundColor) ; if(stroke > 0){ border.setAttribute("stroke-width", String.valueOf(stroke)) ; } } if(bgStyleNode != null){ bgStyleNode.setNodeValue("stop-color:"+backgroundColor) ; } } if(document != null) { Image image = null; try { Rectangle r = this.getClientArea(); this.transcoder.setCanvasSize(this.specifyCanvasWidth?r.width:-1, this.specifyCanvasHeight?r.height:-1); this.updateRenderingHints(graphics); BufferedImage awtImage = this.transcoder.getBufferedImage(); if(awtImage != null) { image = toSWT(Display.getCurrent(), awtImage); graphics.drawImage(image, r.x, r.y); } } finally { if(image != null) { image.dispose(); } document = null; } } }
Example 19
Source File: CrosstabFirstCellEditPart.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void paintFigure( Graphics graphics ) { graphics.setBackgroundColor( ReportColorConstants.greyFillColor ); graphics.fillRectangle( getClientArea( ) ); graphics.drawImage( image, getImagePoint( ) ); }
Example 20
Source File: InsertedImageFigure.java From ermasterr with Apache License 2.0 | 3 votes |
@Override protected void paintFigure(final Graphics graphics) { super.paintFigure(graphics); graphics.setAlpha(alpha); final Rectangle area = getClientArea(); if (fixAspectRatio) { final Rectangle destination = new Rectangle(); final double dw = (double) imageSize.width / (double) area.width; final double dh = (double) imageSize.height / (double) area.height; if (dw > dh) { // we must limit the size by the width destination.width = area.width; destination.height = (int) (imageSize.height / dw); } else { // we must limit the size by the height destination.width = (int) (imageSize.width / dh); destination.height = area.height; } destination.x = (area.width - destination.width) / 2 + area.x; destination.y = (area.height - destination.height) / 2 + area.y; graphics.drawImage(image, new Rectangle(image.getBounds()), destination); } else { graphics.drawImage(image, new Rectangle(image.getBounds()), area); } }