Package org.netbeans.api.visual.widget

Examples of org.netbeans.api.visual.widget.Widget


        if (nodeType.equals(EDITOR_NODE))
            isEditor = true;
        else
            isEditor = false;

        Widget widget = super.addNode(node);
        if (nodeType.equals(RECTANGLE_NODE)) {
            widget.setFont(new Font("", 0, 15));
            widget.setBorder(new RectangleBorder(5, 5, 5, 5, backgroundColor));
            // widget.setBorder(BorderFactory.createLineBorder (10));
        } else if (nodeType.equals(LOZENGE_NODE)) {
            // int len = ((LabelWidget)widget).getLabel().length();
            widget.setFont(new Font("", Font.ITALIC, 15));
            widget
                    .setBorder(new LozengeBorder(10, 10, 10, 10,
                            backgroundColor));
        } else if (nodeType.equals(TRIANGLE_NODE)) {
            widget.setFont(new Font("", Font.BOLD, 15));
            widget
                    .setBorder(new TriangleBorder(20, 30, 20, 30,
                            backgroundColor));
        } else if (nodeType.equals(EDITOR_NODE)) {
            widget.setFont(new Font("", Font.BOLD, 15));
            widget.setBorder(new EditorBorder(5, 5, 5, 5, backgroundColor));
            // widget.setBorder(new RectangleBorder(5,5,5,5,null));
        } else if (nodeType.equals(EDGETIP_NODE)) {
            widget.setFont(new Font("", 0, 10));
            widget.setBorder(new EditorBorder(5, 5, 5, 5, backgroundColor));
            // widget.setBorder(BorderFactory.createLineBorder (10));
        }
        return widget;
    }
View Full Code Here


    }

    protected void attachEdgeSourceAnchor(String edge, String oldSourceNode,
            String sourceNode) {
        ConnectionWidget widget = (ConnectionWidget) findWidget(edge);
        Widget sourceNodeWidget = findWidget(sourceNode);
        widget.setSourceAnchor(sourceNodeWidget != null ? AnchorFactory
                .createFreeRectangularAnchor(sourceNodeWidget, true) : null);
    }
View Full Code Here

    }

    protected void attachEdgeTargetAnchor(String edge, String oldTargetNode,
            String targetNode) {
        ConnectionWidget widget = (ConnectionWidget) findWidget(edge);
        Widget targetNodeWidget = findWidget(targetNode);
        widget.setTargetAnchor(targetNodeWidget != null ? AnchorFactory
                .createFreeRectangularAnchor(targetNodeWidget, true) : null);
    }
View Full Code Here

import org.netbeans.api.visual.widget.Widget;

public class WholeDragAction implements WidgetAction {
    public WholeDragAction(DemoGraphScene scene) {
        this.scene = scene;
        this.area = new Widget(scene);
        area.setBorder(new SelectionBorder(0, 0, 0, 0, null));
        scene.setSelectedArea(area);
        selectedAreaStart = new Point(0, 0);
        selectedAreaEnd = new Point(0, 0);
        lastPosition = new Point(0, 0);
View Full Code Here

        if (isSelecting) {
            selectedAreaEnd.x = event.getPoint().x;
            selectedAreaEnd.y = event.getPoint().y;
            Collection<String> nodes = scene.getNodes();
            for (String id: nodes) {
                Widget lw = scene.findWidget(id);
                Rectangle rect = lw.getPreferredBounds();
                Point location = lw.getPreferredLocation();
                Point pa = new Point(location.x + rect.x, location.y + rect.y);
                Point pb = new Point(location.x + rect.x + rect.width,
                        location.y + rect.y + rect.height);
                if (isInSelectedArea(pa) && isInSelectedArea(pb)) {
                    nodeList.add(lw);
                }
            }

            Collection<String> edges = scene.getEdges();
            for (String id: edges) {
                ConnectionWidget cw = (ConnectionWidget) scene.findWidget(id);
                boolean isSourceIn;
                boolean isTargetIn;

                LabelWidget source = (LabelWidget) scene.findWidget(scene
                        .getEdgeSource(id));
                Rectangle rect = source.getPreferredBounds();
                Point location = source.getPreferredLocation();
                Point pa = new Point(location.x + rect.x, location.y + rect.y);
                Point pb = new Point(location.x + rect.x + rect.width,
                        location.y + rect.y + rect.height);
                isSourceIn = isInSelectedArea(pa) && isInSelectedArea(pb);

                LabelWidget target = (LabelWidget) scene.findWidget(scene
                        .getEdgeTarget(id));
                rect = target.getPreferredBounds();
                location = target.getPreferredLocation();
                pa = new Point(location.x + rect.x, location.y + rect.y);
                pb = new Point(location.x + rect.x + rect.width, location.y
                        + rect.y + rect.height);
                isTargetIn = isInSelectedArea(pa) && isInSelectedArea(pb);

                if (!isSourceIn && !isTargetIn)
                    continue;
                cwList.add(cw);
                List<Point> cps = cw.getControlPoints();
                boolean isCpIn[] = new boolean[cps.size()];
                cpsList.add(cps);
                for (int i = 0; i < cps.size(); ++i) {
                    if (isInSelectedArea(cps.get(i)))
                        isCpIn[i] = true;
                    else
                        isCpIn[i] = false;
                }
                if (!isSourceIn)
                    isCpIn[0] = false;
                if (!isTargetIn)
                    isCpIn[cps.size() - 1] = false;

                isCpsValid.add(isCpIn);
            }

            for (Widget lw: nodeList) {
                Border border = lw.getBorder();
                if (border instanceof LozengeBorder)
                    ((LozengeBorder) border).setColor(Color.blue);
                if (border instanceof TriangleBorder)
                    ((TriangleBorder) border).setColor(Color.blue);
                if (border instanceof RectangleBorder)
                    ((RectangleBorder) border).setColor(Color.blue);
                lw.setForeground(Color.blue);
                lw.repaint();
            }
            for (ConnectionWidget cw: cwList) {
                cw.setLineColor(Color.blue);
                cw.setPaintControlPoints(true);
            }
View Full Code Here

    }

    public void actionPerformed(ActionEvent e) {
        if (ADD_NEW_RECTANGLE_NODE_ACTION.equals(e.getActionCommand())) {
            String hm = "Node" + System.currentTimeMillis();
            Widget newNode = scene.addNode(hm, DemoGraphScene.RECTANGLE_NODE);
            newNode.setPreferredLocation(point);
            // scene.getSceneAnimator().animatePreferredLocation(newNode,point);
            scene.validate();
        } else if (ADD_NEW_LOZENGE_NODE_ACTION.equals(e.getActionCommand())) {
            String hm = "Node" + System.currentTimeMillis();;
            Widget newNode = scene.addNode(hm, DemoGraphScene.LOZENGE_NODE);
            newNode.setPreferredLocation(point);
            // scene.getSceneAnimator().animatePreferredLocation(newNode,point);
            scene.validate();
        } else if (ADD_NEW_TRIANGLE_NODE_ACTION.equals(e.getActionCommand())) {
            String hm = "Node" + System.currentTimeMillis();;
            Widget newNode = scene.addNode(hm, DemoGraphScene.TRIANGLE_NODE);
            newNode.setPreferredLocation(point);
            // scene.getSceneAnimator().animatePreferredLocation(newNode,point);
            scene.validate();
        }
    }
View Full Code Here

        e = nodes.iterator();
        while (e.hasNext()) {
            String node = (String) e.next();
            outNodes.writeObject(node);

            Widget w = scene.findWidget(node);
            String str = null;
            if (w instanceof LabelWidget)
                str = new String((((LabelWidget) w).getLabel())
                        .getBytes("GB2312"), "8859_1");
            else if (w instanceof EditorWidget)
                str = new String((((EditorWidget) w).getLabel())
                        .getBytes("GB2312"), "8859_1");
            outNodes.writeObject(str);
            str = new String((w.getToolTipText()).getBytes("GB2312"), "8859_1");
            outNodes.writeObject(str);

            outNodes.writeObject(w.getLocation());
            if (w.getBorder() instanceof LozengeBorder)
                outNodes.writeObject(DemoGraphScene.LOZENGE_NODE);
            else if (w.getBorder() instanceof TriangleBorder)
                outNodes.writeObject(DemoGraphScene.TRIANGLE_NODE);
            else if (w.getBorder() instanceof RectangleBorder)
                outNodes.writeObject(DemoGraphScene.RECTANGLE_NODE);
            else
                // if(w.getBorder() == null)
                outNodes.writeObject(DemoGraphScene.EDITOR_NODE);
View Full Code Here

            label = new String(label.getBytes("8859_1"), "GB2312");
            String fullText = (String) inNodes.readObject();
            fullText = new String(fullText.getBytes("8859_1"), "GB2312");
            Point location = (Point) inNodes.readObject();
            String border = (String) inNodes.readObject();
            Widget w;
            if (border.equals(DemoGraphScene.LOZENGE_NODE))
                w = scene.addNode(node, DemoGraphScene.LOZENGE_NODE);
            else if (border.equals(DemoGraphScene.TRIANGLE_NODE))
                w = scene.addNode(node, DemoGraphScene.TRIANGLE_NODE);
            else if (border.equals(DemoGraphScene.EDITOR_NODE)) {
                w = scene.addNode(node, DemoGraphScene.EDITOR_NODE);
            } else
                w = scene.addNode(node, DemoGraphScene.RECTANGLE_NODE);
            if (w instanceof LabelWidget)
                ((LabelWidget) w).setLabel(label);
            else if (w instanceof EditorWidget)
                ((EditorWidget) w).setLabel(label);
            w.setToolTipText(fullText);
            w.setPreferredLocation(location);
            System.out.println("readnode: " + node + "  " + location);

        }

        int edgeNum = inEdges.readInt();
View Full Code Here

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane scrollPane;
    // End of variables declaration//GEN-END:variables

    public void addNode(String string) {
        Widget widget = scene.addNewNode(string, popupPoint);
    }
View Full Code Here

        PartiturEditor.getInstance().keyPressed(ev);
        if (PartiturEditor.getInstance().getBuffer()!=null) {
           if(ScorePanel.this.getNodes().contains(bufferNode))
                ScorePanel.this.removeNode(bufferNode);
            bufferNode.text= PartiturEditor.getInstance().getBuffer();
             Widget w = ScorePanel.this.addNode(bufferNode);
            
                w.setPreferredLocation(new Point(current.getlayoutObject().centre.x,current.getlayoutObject().centre.y));//widget.convertLocalToScene(new Point (10,10)));
              //  bufferWidget = new LabelWidget(this, PartiturEditor.getInstance().getBuffer());
                //widget.addChild(bufferWidget);
               
//                mainLayer.addChild(bufferWidget);
   
View Full Code Here

TOP

Related Classes of org.netbeans.api.visual.widget.Widget

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.