@Override protected Image renderRotated( Device device, int width, int height, double angleRadians ) { BufferedImage doubleArea = SwingUniversalImage.createDoubleBitmap( width, height ); Graphics2D gc = SwingUniversalImage.createGraphics( doubleArea ); SwingUniversalImageSvg.render( gc, svgGraphicsNode, svgGraphicsSize, doubleArea.getWidth() / 2, doubleArea .getHeight() / 2, width, height, angleRadians ); gc.dispose(); return swing2swt( device, doubleArea ); } }
/** * Draw rotated image on double canvas size. It required against lost corners on rotate. */ public synchronized BufferedImage getAsBitmapForSize( int width, int height, double angleRadians ) { int angleDegree = (int) Math.round( Math.toDegrees( angleRadians ) ); while ( angleDegree < 0 ) { angleDegree += 360; } angleDegree %= 360; angleRadians = Math.toRadians( angleDegree ); String key = width + "x" + height + "/" + Integer.toString( angleDegree ); BufferedImage result = cache.get( key ); if ( result == null ) { result = createDoubleBitmap( width, height ); Graphics2D gc = createGraphics( result ); render( gc, result.getWidth() / 2, result.getHeight() / 2, width, height, angleRadians ); gc.dispose(); cache.put( key, result ); } return result; }
@Override protected Image renderSimple( Device device, int width, int height ) { BufferedImage area = SwingUniversalImage.createBitmap( width, height ); Graphics2D gc = SwingUniversalImage.createGraphics( area ); SwingUniversalImageSvg.render( gc, svgGraphicsNode, svgGraphicsSize, width / 2, height / 2, width, height, 0 ); gc.dispose(); return swing2swt( device, area ); }