Package diva.canvas

Examples of diva.canvas.Figure


        // clear the caches
        _recreateFigure();

        // Update the painted list, if necessary
        Figure figure;

        try {
            String text = _smallIconDescription.value();
            Reader in = new StringReader(text);
View Full Code Here


                Object origEdge = i.next();
                Object origTail = model.getTail(origEdge);
                Object origHead = model.getHead(origEdge);

                if ((origHead != null) && (origTail != null)) {
                    Figure tailFigure = (Figure) target
                            .getVisualObject(origTail);
                    Figure headFigure = (Figure) target
                            .getVisualObject(origHead);

                    // Swap the head and the tail if it will improve the
                    // layout, since LevelLayout only uses directed edges.
                    if (tailFigure instanceof Terminal) {
View Full Code Here

                double[] location = ((Locatable) node).getLocation();

                if (location == null) {
                    location = new double[2];

                    Figure figure = getController().getFigure(node);
                    location[0] = figure.getBounds().getCenterX();
                    location[1] = figure.getBounds().getCenterY();
                } else {
                    location[0] += dx;
                    location[1] += dy;
                }
View Full Code Here

                int direction) {
            Iterator ports = portList.iterator();
            int number = 0;
            int count = portList.size();

            Figure background = figure.getBackgroundFigure();

            if (background == null) {
                // This could occur if the icon has a _hide parameter.
                background = figure;
            }

            while (ports.hasNext()) {
                Port port = (Port) ports.next();
                Figure portFigure = getController().getFigure(port);

                // If there is no figure, then ignore this port.  This may
                // happen if the port hasn't been rendered yet.
                if (portFigure == null) {
                    continue;
                }

                Rectangle2D portBounds = portFigure.getShape().getBounds2D();
                PortSite site = new PortSite(background, port, number, count,
                        direction);
                number++;

                // NOTE: previous expression for port location was:
                //    100.0 * number / (count+1)
                // But this leads to squished ports with uneven spacing.
                // Note that we don't use CanvasUtilities.translateTo because
                // we want to only get the bounds of the background of the
                // port figure.
                double x = site.getX() - portBounds.getCenterX();
                double y = site.getY() - portBounds.getCenterY();
                portFigure.translate(x, y);

                // If the actor contains a variable named "_showRate",
                // with value true, then visualize the rate information.
                // NOTE: Showing rates only makes sense for IOPorts.
                Attribute showRateAttribute = port.getAttribute("_showRate");
View Full Code Here

                throw new InternalErrorException("could not create icon "
                        + "in " + object + " even "
                        + "though one did not exist");
            }

            Figure figure = icon.createFigure();
            figure.setToolTipText(object.getName());
            return figure;
        }
View Full Code Here

            polygon.lineTo(0, height / 2);
            polygon.lineTo(-width / 2, 0);
            polygon.lineTo(0, -height / 2);
            polygon.closePath();

            Figure figure = new BasicFigure(polygon, Color.black);

            if (node != null) {
                ActorGraphModel model = (ActorGraphModel) getController()
                        .getGraphModel();
                figure
                        .setToolTipText(relation.getName(model
                                .getPtolemyModel()));
                // Old way to set the color.
                try {
                    StringAttribute colorAttr = (StringAttribute) (relation
                            .getAttribute("_color", StringAttribute.class));

                    if (colorAttr != null) {
                        String color = colorAttr.getExpression();
                        ((BasicFigure) figure).setFillPaint(SVGUtilities
                                .getColor(color));
                    }
                } catch (IllegalActionException e) {
                    // Ignore.
                }
                // New way to set the color
                try {
                    ColorAttribute colorAttr = (ColorAttribute) (relation
                            .getAttribute("_color", ColorAttribute.class));
                    if (colorAttr != null) {
                        Color color = colorAttr.asColor();
                        ((BasicFigure) figure).setFillPaint(color);
                    }
                } catch (IllegalActionException e) {
                    // Ignore.
                }
            }

            CompositeFigure result = new CompositeFigure(figure);

            if (relation instanceof IORelation) {
                if (((IORelation) relation).getWidth() > 1) {
                    // Restore width and height to the default to get a reasonable slash.
                    width = 12.0;
                    height = 12.0;

                    Line2D.Double line = new Line2D.Double(-width / 2,
                            height / 2, width / 2, -height / 2);
                    Figure lineFigure = new BasicFigure(line, Color.black);
                    result.add(lineFigure);

                    LabelFigure label = new LabelFigure(""
                            + ((IORelation) relation).getWidth(),
                            _relationLabelFont, 0, SwingConstants.SOUTH_WEST);
View Full Code Here

         * detach the edge as appropriate.
         * @param evt The connector event.
         */
        public void connectorDropped(ConnectorEvent evt) {
            Connector c = evt.getConnector();
            Figure f = evt.getTarget();
            Link link = (Link) c.getUserObject();
            Object node = (f == null) ? null : f.getUserObject();
            ActorGraphModel model = (ActorGraphModel) getController()
                    .getGraphModel();

            switch (evt.getEnd()) {
            case ConnectorEvent.HEAD_END:
View Full Code Here

    /** Make a persistent record of the new size by issuing a change request.
     *  @param e The mouse event.
     */
    public void mouseReleased(LayerEvent e) {
        Figure child = getChild();

        // FIXME: Diva has a bug where this method is called on the
        // prototype rather than the instance that has a child.
        // We work around this by getting access to the instance.
        if ((child == null) && (_instanceDecorator != null)) {
            child = _instanceDecorator.getChild();
        }

        if (child != null) {
            // NOTE: Calling getBounds() on the child itself yields an
            // inaccurate bounds, for some reason.
            // Weirdly, to get the size right, we need to use this.
            // But to get the location right, we need the other!
            Rectangle2D bounds = child.getShape().getBounds2D();
            Rectangle2D childBounds = child.getBounds();

            // Use a MoMLChangeRequest here so that the resize can be
            // undone and so that a repaint occurs.
            Attribute widthParameter = _container.getAttribute("width");
            Attribute heightParameter = _container.getAttribute("height");
View Full Code Here

            if (state != null) {
                Object location = state.getAttribute("_location");

                if (location != null) {
                    Figure figure = getFigure(location);

                    if (figure != null) {
                        if (_animationRenderer == null) {
                            _animationRenderer = new AnimationRenderer();
                        }
View Full Code Here

                }

                Object location = objToHighlight.getAttribute("_location");

                if (location != null) {
                    Figure figure = graphController.getFigure(location);

                    if (figure != null) {
                        // If the user has chosen to break on one of
                        // the firing events, highlight the actor and
                        // wait for the user to press the Resume
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.