Package ca.nengo.ui.lib.world.piccolo.primitives

Examples of ca.nengo.ui.lib.world.piccolo.primitives.Universe


        restoreDefaultTitle();

        actionManager = new ReversableActionManager(this);
        getContentPane().setLayout(new BorderLayout());

        universe = new Universe();
        universe.setMinimumSize(new Dimension(200, 200));
        universe.setPreferredSize(new Dimension(400, 400));
        universe.initialize(createWorld());
        universe.setFocusable(true);
View Full Code Here


        Component ng = NengoGraphics.getInstance();
       
        if (fileChooser.showSaveDialog(ng)==JFileChooser.APPROVE_OPTION) {
            File file = fileChooser.getSelectedFile();

            Universe universe = ((NengoGraphics) ng).getUniverse();
            double w = universe.getSize().getWidth();
            double h = universe.getSize().getHeight();

            // Top of page method: prints to the top of the page
            float pw = 550;
            float ph = 800;
   
            // create PDF document and writer
           Document doc = new Document();
           try{
             PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(file));
             doc.open();

            PdfContentByte cb = writer.getDirectContent();

            // create a template
            PdfTemplate tp = cb.createTemplate(pw,ph);
            Graphics2D g2 = tp.createGraphicsShapes(pw,ph);

            // scale the template to fit the page
            AffineTransform at = new AffineTransform();
            float s = (float) Math.min(pw/w,ph/h);
            at.scale(s,s);
            g2.setTransform(at);

            // print the image to the template
            // turning off setUseGreekThreshold allows small text to print
            Text.setUseGreekThreshold(false);
            universe.paint(g2);
            Text.setUseGreekThreshold(true);
            g2.dispose();

            // add the template
            cb.addTemplate(tp,20,0);
View Full Code Here

TOP

Related Classes of ca.nengo.ui.lib.world.piccolo.primitives.Universe

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.