/* * (non-Javadoc) * * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics) */ protected void paintFigure(Graphics graphics) { Rectangle area = new Rectangle(); area.setBounds(getBounds()); // area.crop(getInsets()); if (useLocalCoordinates()) area.setLocation(0, 0); // Rectangle area = getClientArea().getCopy(); RenderInfo rndInfo = getRenderedImage().getRenderInfo(); if (!useOriginalColors()) { RGB backgroundColor = getBackgroundColor().getRGB(); RGB foregroundColor = getForegroundColor().getRGB(); if ((backgroundColor != null && !backgroundColor.equals(rndInfo.getBackgroundColor())) || (foregroundColor != null && !foregroundColor.equals(rndInfo.getForegroundColor()))) { rndInfo.setValues( rndInfo.getWidth(), rndInfo.getHeight(), rndInfo.shouldMaintainAspectRatio(), rndInfo.shouldAntiAlias(), getBackgroundColor().getRGB(), getForegroundColor().getRGB()); setRenderedImage(getRenderedImage().getNewRenderedImage(rndInfo)); } } setRenderedImage( RenderHelper.getInstance( DiagramMapModeUtil.getScale(MapModeUtil.getMapMode(this)), false, false, null) .drawRenderedImage(graphics, getRenderedImage(), area, renderingListener)); }
/** * Gets the <code>RenderedImage</code> that is the for the specified <code>Dimension</code> * * @param dim * @return the <code>RenderedImage</code> */ private RenderedImage getRenderedImage(Dimension dim) { Color fill = getBackgroundColor(); Color outline = getForegroundColor(); RenderInfo newRenderInfo = getRenderedImage().getRenderInfo(); newRenderInfo.setValues( dim.width, dim.height, isMaintainAspectRatio(), // maintain aspect ratio isAntiAlias(), useOriginalColors() ? (RGB) null : new RGB(fill.getRed(), fill.getGreen(), fill.getBlue()), useOriginalColors() ? (RGB) null : new RGB(outline.getRed(), outline.getGreen(), outline.getBlue())); // antialias RenderedImage newRenderedImage = getRenderedImage().getNewRenderedImage(newRenderInfo); return newRenderedImage; }