Package bs.bs2d.gui.plot

Examples of bs.bs2d.gui.plot.Plottable


        mitSStoCB.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PlotPanel content = (PlotPanel)contentPanel.getTopComponent();
                Plottable plot = content.getPlotObject();
               
                Rectangle2D plotBounds = plot.getBounds();
                Rectangle2D imgBounds = new Rectangle2D.Float(0, 0, 400, 400);
               
                AffineTransform t1 = AffineTransform.getTranslateInstance(-plotBounds.getX(), -plotBounds.getY());
                double scale = Math.min(imgBounds.getWidth()/plotBounds.getWidth(), imgBounds.getHeight()/plotBounds.getHeight());
                AffineTransform s = AffineTransform.getScaleInstance(scale, -scale);
                AffineTransform t2 = AffineTransform.getTranslateInstance(0, plotBounds.getHeight()*scale + 1);
                s.concatenate(t1);
                t2.concatenate(s);
               
                Rectangle2D tbounds = t2.createTransformedShape(plotBounds).getBounds2D();
               
                BufferedImage img = new BufferedImage((int)tbounds.getWidth()+2, (int)tbounds.getHeight()+2, BufferedImage.TYPE_INT_ARGB);
                Graphics2D g = (Graphics2D)img.getGraphics();
                g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                plot.paint(g, t2);
               
                TransferableImage ti = new TransferableImage(img);
                Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
                c.setContents( ti, null );
                System.out.println("An image of plot has been copied to the clipboard.");
View Full Code Here

TOP

Related Classes of bs.bs2d.gui.plot.Plottable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.