Package diva.canvas

Examples of diva.canvas.GraphicsPane


        // FindBugs suggests making this class static so as to decrease
        // the size of instances and avoid dangling references.

        public Figure createFigure() {
            Figure bg = new BasicRectangle(10, 10, 20, 20, Color.blue);
            CanvasPane pane = new GraphicsPane();
            pane.setSize(300.0, 300.0);

            PaneWrapper wrapper = new PaneWrapper(pane);
            wrapper.setBackground(bg);
            return wrapper;
        }
View Full Code Here


        // Lastly drop the canvas in the frame.
        if (_canvas != null) {
            _container.remove(_canvas);
        }

        GraphicsPane pane = new GraphicsPane();
        _layer = pane.getForegroundLayer();
        _overlayLayer = new OverlayLayer();

        _canvas = new JCanvas(pane);

        _container.add("Center", _canvas);
        _canvas.setMinimumSize(new Dimension(horizontalDimension,
                verticalDimension));
        _canvas.setMaximumSize(new Dimension(horizontalDimension,
                verticalDimension));
        _canvas.setPreferredSize(new Dimension(horizontalDimension,
                verticalDimension));

        if (_frame != null) {
            _frame.pack();
        }

        double upperLeftXValue = ((IntToken) upperLeftX.getToken())
                .doubleValue();
        double upperLeftYValue = ((IntToken) upperLeftY.getToken())
                .doubleValue();
        double lowerRightXValue = ((IntToken) lowerRightX.getToken())
                .doubleValue();
        double lowerRightYValue = ((IntToken) lowerRightY.getToken())
                .doubleValue();
        java.awt.geom.Rectangle2D visibleRect = new java.awt.geom.Rectangle2D.Double(
                upperLeftXValue, upperLeftYValue, lowerRightXValue
                        - upperLeftXValue, lowerRightYValue - upperLeftYValue);

        if ((visibleRect.getHeight() == 0) || (visibleRect.getWidth() == 0)) {
            throw new IllegalActionException(this, "The width and height "
                    + "of the visible rectangle cannot be zero.");
        }

        AffineTransform transform = CanvasUtilities.computeTransform(
                visibleRect, _canvas.getBounds());
        System.out.println("transform = " + transform);

        //       _origin = new Point2D.Double(
        //                 _container.getWidth()/2, _container.getHeight()/2);
        //         pane.translate(_origin.x, _origin.y);
        pane.setTransform(transform);
        pane.setAntialiasing(true);

        _crosshairX = new BasicFigure(new java.awt.geom.Line2D.Double(0, 2, 0,
                -2));
        _crosshairY = new BasicFigure(new java.awt.geom.Line2D.Double(2, 0, -2,
                0));
        _overlayLayer.add(_crosshairX.getShape());
        _overlayLayer.add(_crosshairY.getShape());

        _eventHandler = new ViewScreen2DListener();
        _eventLayer = new EventLayer();
        _eventLayer.addLayerListener(_eventHandler);
        _eventLayer.addLayerMotionListener(_eventHandler);

        pane.setOverlayLayer(_overlayLayer);
        pane.setForegroundEventLayer(_eventLayer);

        if (_frame != null) {
            _frame.addKeyListener(_eventHandler);
        }
View Full Code Here

        mbandDiagText = new LabelFigure(" ");
        mbandDiagText.setFillPaint(Color.blue);
        mbandDiagText.setFont(font);
        mband.add(mbandDiagText);

        GraphicsPane gpane = (GraphicsPane) imageDisplay.getCanvasPane();
        setFigureLayer(gpane.getForegroundLayer());
        setEventLayer(gpane.getBackgroundEventLayer());

        // Bind to mouse button 3 (and 2, in case there are only 2 buttons)
        dragFilter = new MouseFilter(InputEvent.BUTTON3_MASK | InputEvent.BUTTON2_MASK, 0, 0);
    }
View Full Code Here

    /**
     * Default constructor. Note that you need to call setParentFrame() if you use this version).
     */
    public DivaMainImageDisplay() {
        this(new GraphicsPane());
    }
View Full Code Here

     *
     * @param imageProcessor Object managing the image
     * @param name name to associate with this instance
     */
    public DivaGraphicsImageDisplay(ImageProcessor imageProcessor, String name) {
        this(new GraphicsPane(), imageProcessor, name);
    }
View Full Code Here

TOP

Related Classes of diva.canvas.GraphicsPane

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.