Package diva.canvas

Examples of diva.canvas.Figure


     * as its event source is selected. By selected, we mean that
     * figure has a SelectionInteractor as its interactor, and that
     * the figure is in the SelectionModel of that interactor.
     */
    public static boolean isSelected(LayerEvent e) {
        Figure f = e.getFigureSource();

        if (f.getInteractor() instanceof SelectionInteractor) {
            SelectionInteractor i = (SelectionInteractor) f.getInteractor();
            return i.getSelectionModel().containsSelection(f);
        }

        return false;
    }
View Full Code Here


    public void mousePressed(LayerEvent event) {
        if (!isEnabled()) {
            return;
        }

        Figure figure = event.getFigureSource();
        boolean isChanged = false;

        if (_selectionFilter.accept(event)) {
            // If the item is not already in the selection, clear
            // the selection and then add this one.
View Full Code Here

    /** Create a composite figure that does not have a background
     */
    public void createCompositeFigure() {
        CompositeFigure tc = new CompositeFigure();
        Figure bg = new BasicRectangle(100.0, 100.0, 100.0, 100.0, Color.green);
        tc.add(bg);
        layer.add(tc);
        tc.setInteractor(defaultInteractor);
        addPorts(tc);
    }
View Full Code Here

    /** Create a composite figure that uses the background facility.
     * Generally, for figures of this nature, this is a better thing to do.
     */
    public void createBackgroundedCompositeFigure() {
        CompositeFigure tc = new CompositeFigure();
        Figure bg = new BasicRectangle(100.0, 100.0, 100.0, 100.0, Color.blue);
        tc.setBackgroundFigure(bg);
        layer.add(tc);
        tc.setInteractor(defaultInteractor);
        addPorts(tc);
        tc.translate(200.0, 0);
View Full Code Here

    }

    /** Utility function to add the "ports" to the composite figure.
     */
    public void addPorts(CompositeFigure tc) {
        Figure p1 = new BasicEllipse(150.0, 100.0, 20.0, 20.0, Color.red);
        p1.translate(-10, -10);

        Figure p2 = new BasicEllipse(200.0, 150.0, 20.0, 20.0, Color.blue);
        p2.translate(-10, -10);

        Figure p3 = new BasicEllipse(150.0, 200.0, 20.0, 20.0, Color.yellow);
        p3.translate(-10, -10);

        Figure p4 = new BasicEllipse(100.0, 150.0, 20.0, 20.0, Color.magenta);
        p4.translate(-10, -10);

        tc.add(p1);
        tc.add(p2);
        tc.add(p3);
        tc.add(p4);

        p1.setInteractor(defaultInteractor);
        p2.setInteractor(defaultInteractor);
        p3.setInteractor(defaultInteractor);
        p4.setInteractor(defaultInteractor);
    }
View Full Code Here

        // Create an interactor to do the work.
        Interactor dragger = new DragInteractor();

        // Create the figure
        Figure one = new CloudFigure(10.0, 10.0, 80.0, 80.0);
        layer.add(one);
        one.setInteractor(dragger);

        Figure two = new CloudFigure(150, 150, 200, 180);
        layer.add(two);
        two.setInteractor(dragger);
    }
View Full Code Here

        super.setChild(f);
        clearGrabHandles();
        _geometry = null;

        // Process new child
        Figure child = getChild();

        if (child != null) {
            // Check that we can mess with this figure
            if (!(child instanceof ShapedFigure)) {
                throw new IllegalArgumentException(
View Full Code Here

     * within the region.
     */
    public void setup(LayerEvent e) {
        // Get the size of the figure and calculate bounds
        // FIXME: how to parameterize for figure sets?
        Figure f = e.getFigureSource();
        double ex = e.getLayerX();
        double ey = e.getLayerY();
        Rectangle2D b = f.getBounds();

        double x = (_bounds.getX() + ex) - b.getX();
        double y = (_bounds.getY() + ey) - b.getY();

        double w = (_bounds.getX() + _bounds.getWidth() + ex)
View Full Code Here

    public static class CompositeFigureFactory1 implements
            FigureTest.FigureFactory {
        // 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);
            Figure cf = new CompositeFigure(bg);
            return cf;
        }
View Full Code Here

    public static class PaneWrapperFactory implements FigureTest.FigureFactory {
        // 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);
View Full Code Here

TOP

Related Classes of diva.canvas.Figure

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.