List of usage examples for java.awt Graphics2D getTransform
public abstract AffineTransform getTransform();
From source file:view.BackgroundImageController.java
public void setGraphBackgroundImage(final VisualizationViewer vv, final ImageIcon background, final double xOffset, final double yOffset) { removeBackgroundImage(vv);//from www .ja va 2 s .c o m preRender = new VisualizationViewer.Paintable() { public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; AffineTransform oldXform = g2d.getTransform(); AffineTransform lat = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT) .getTransform(); AffineTransform vat = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW) .getTransform(); AffineTransform at = new AffineTransform(); at.concatenate(g2d.getTransform()); at.concatenate(vat); at.concatenate(lat); g2d.setTransform(at); g.drawImage(background.getImage(), (int) Math.round(-background.getIconWidth() / xOffset), (int) Math.round(-background.getIconHeight() / yOffset), background.getIconWidth(), background.getIconHeight(), vv); g2d.setTransform(oldXform); } public boolean useTransform() { return false; } }; vv.addPreRenderPaintable(preRender); background.getImage().flush(); Runtime.getRuntime().gc(); }