Example usage for java.awt.geom AffineTransform concatenate

List of usage examples for java.awt.geom AffineTransform concatenate

Introduction

In this page you can find the example usage for java.awt.geom AffineTransform concatenate.

Prototype

@SuppressWarnings("fallthrough")
public void concatenate(AffineTransform Tx) 

Source Link

Document

Concatenates an AffineTransform Tx to this AffineTransform Cx in the most commonly useful way to provide a new user space that is mapped to the former user space by Tx .

Usage

From source file:view.BackgroundImageController.java

public void setGraphBackgroundImage(final VisualizationViewer vv, final ImageIcon background,
        final double xOffset, final double yOffset) {

    removeBackgroundImage(vv);// w w  w .j  a v a  2s  .co 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();
}