This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 105929
Collapse All | Expand All

(-)graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java (+1 lines)
Lines 106-111 Link Here
106
        "test.tool.ToolTest",
106
        "test.tool.ToolTest",
107
        "test.visible.VisibilityTest",
107
        "test.visible.VisibilityTest",
108
        "test.vmd.VMDCollisionTest",
108
        "test.vmd.VMDCollisionTest",
109
        "test.vmd.VMDColorSchemeTest",
109
        "test.vmd.VMDTest",
110
        "test.vmd.VMDTest",
110
        "test.widget.AnimatedImageTest",
111
        "test.widget.AnimatedImageTest",
111
        "test.zoom.FitToViewTest",
112
        "test.zoom.FitToViewTest",
(-)graph/examples/src/test/vmd/VMDCollisionTest.java (-28 / +6 lines)
Lines 19-26 Link Here
19
package test.vmd;
19
package test.vmd;
20
20
21
import org.netbeans.api.visual.vmd.VMDGraphScene;
21
import org.netbeans.api.visual.vmd.VMDGraphScene;
22
import org.netbeans.api.visual.vmd.VMDNodeWidget;
23
import org.netbeans.api.visual.vmd.VMDPinWidget;
24
import org.openide.util.Utilities;
22
import org.openide.util.Utilities;
25
import test.SceneSupport;
23
import test.SceneSupport;
26
24
Lines 46-81 Link Here
46
    public static void main (String[] args) {
44
    public static void main (String[] args) {
47
        VMDGraphScene scene = new VMDGraphScene ();
45
        VMDGraphScene scene = new VMDGraphScene ();
48
46
49
        String mobile = createNode (scene, 100, 100, IMAGE_LIST, "menu", "List", null);
47
        String mobile = VMDTest.createNode (scene, 100, 100, IMAGE_LIST, "menu", "List", null);
50
        createPin (scene, mobile, "start", IMAGE_ITEM, "Start", "Element");
48
        VMDTest.createPin (scene, mobile, "start", IMAGE_ITEM, "Start", "Element");
51
49
52
        String game = createNode (scene, 600, 100, IMAGE_CANVAS, "gameCanvas", "MyCanvas", Arrays.asList (GLYPH_PRE_CODE, GLYPH_CANCEL, GLYPH_POST_CODE));
50
        String game = VMDTest.createNode (scene, 600, 100, IMAGE_CANVAS, "gameCanvas", "MyCanvas", Arrays.asList (GLYPH_PRE_CODE, GLYPH_CANCEL, GLYPH_POST_CODE));
53
        createPin (scene, game, "ok", IMAGE_COMMAND, "okCommand1", "Command");
51
        VMDTest.createPin (scene, game, "ok", IMAGE_COMMAND, "okCommand1", "Command");
54
52
55
        createEdge (scene, "start", game);
53
        VMDTest.createEdge (scene, "start", game);
56
        createEdge (scene, "ok", mobile);
54
        VMDTest.createEdge (scene, "ok", mobile);
57
55
58
        SceneSupport.show (scene);
56
        SceneSupport.show (scene);
59
    }
60
61
    private static String createNode (VMDGraphScene scene, int x, int y, Image image, String name, String type, java.util.List<Image> glyphs) {
62
        String nodeID = "node" + VMDCollisionTest.nodeID ++;
63
        VMDNodeWidget widget = (VMDNodeWidget) scene.addNode (nodeID);
64
        widget.setPreferredLocation (new Point (x, y));
65
        widget.setNodeProperties (image, name, type, glyphs);
66
        scene.addPin (nodeID, nodeID + VMDGraphScene.PIN_ID_DEFAULT_SUFFIX);
67
        return nodeID;
68
    }
69
70
    private static void createPin (VMDGraphScene scene, String nodeID, String pinID, Image image, String name, String type) {
71
        ((VMDPinWidget) scene.addPin (nodeID, pinID)).setProperties (name, null);
72
    }
73
74
    private static void createEdge (VMDGraphScene scene, String sourcePinID, String targetNodeID) {
75
        String edgeID = "edge" + VMDCollisionTest.edgeID ++;
76
        scene.addEdge (edgeID);
77
        scene.setEdgeSource (edgeID, sourcePinID);
78
        scene.setEdgeTarget (edgeID, targetNodeID + VMDGraphScene.PIN_ID_DEFAULT_SUFFIX);
79
    }
57
    }
80
58
81
}
59
}
(-)graph/examples/src/test/vmd/VMDColorSchemeTest.java (+33 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
package test.vmd;
20
21
import org.netbeans.api.visual.vmd.VMDFactory;
22
import org.netbeans.api.visual.vmd.VMDGraphScene;
23
24
/**
25
 * @author David Kaspar
26
 */
27
public class VMDColorSchemeTest {
28
29
    public static void main (String[] args) {
30
        VMDTest.runScene (new VMDGraphScene (VMDFactory.getNetBeans60Scheme ()));
31
    }
32
33
}
(-)graph/examples/src/test/vmd/VMDTest.java (-3 / +6 lines)
Lines 50-56 Link Here
50
50
51
    public static void main (String[] args) {
51
    public static void main (String[] args) {
52
        final VMDGraphScene scene = new VMDGraphScene ();
52
        final VMDGraphScene scene = new VMDGraphScene ();
53
        runScene (scene);
54
    }
53
55
56
    static void runScene (final VMDGraphScene scene) {
54
        String mobile = createNode (scene, 100, 100, IMAGE_LIST, "menu", "List", null);
57
        String mobile = createNode (scene, 100, 100, IMAGE_LIST, "menu", "List", null);
55
        createPin (scene, mobile, "start", IMAGE_ITEM, "Start", "Element");
58
        createPin (scene, mobile, "start", IMAGE_ITEM, "Start", "Element");
56
        createPin (scene, mobile, "resume", IMAGE_ITEM, "Resume", "Element");
59
        createPin (scene, mobile, "resume", IMAGE_ITEM, "Resume", "Element");
Lines 91-97 Link Here
91
        SceneSupport.show (scene);
94
        SceneSupport.show (scene);
92
    }
95
    }
93
96
94
    private static String createNode (VMDGraphScene scene, int x, int y, Image image, String name, String type, List<Image> glyphs) {
97
    static String createNode (VMDGraphScene scene, int x, int y, Image image, String name, String type, List<Image> glyphs) {
95
        String nodeID = "node" + VMDTest.nodeID ++;
98
        String nodeID = "node" + VMDTest.nodeID ++;
96
        VMDNodeWidget widget = (VMDNodeWidget) scene.addNode (nodeID);
99
        VMDNodeWidget widget = (VMDNodeWidget) scene.addNode (nodeID);
97
        widget.setPreferredLocation (new Point (x, y));
100
        widget.setPreferredLocation (new Point (x, y));
Lines 100-110 Link Here
100
        return nodeID;
103
        return nodeID;
101
    }
104
    }
102
105
103
    private static void createPin (VMDGraphScene scene, String nodeID, String pinID, Image image, String name, String type) {
106
    static void createPin (VMDGraphScene scene, String nodeID, String pinID, Image image, String name, String type) {
104
        ((VMDPinWidget) scene.addPin (nodeID, pinID)).setProperties (name, null);
107
        ((VMDPinWidget) scene.addPin (nodeID, pinID)).setProperties (name, null);
105
    }
108
    }
106
109
107
    private static void createEdge (VMDGraphScene scene, String sourcePinID, String targetNodeID) {
110
    static void createEdge (VMDGraphScene scene, String sourcePinID, String targetNodeID) {
108
        String edgeID = "edge" + VMDTest.edgeID ++;
111
        String edgeID = "edge" + VMDTest.edgeID ++;
109
        scene.addEdge (edgeID);
112
        scene.addEdge (edgeID);
110
        scene.setEdgeSource (edgeID, sourcePinID);
113
        scene.setEdgeSource (edgeID, sourcePinID);
(-)graph/lib/apichanges.xml (+15 lines)
Lines 299-304 Link Here
299
            <class package="org.netbeans.api.visual.layout" name="LayoutFactory" link="yes"/>
299
            <class package="org.netbeans.api.visual.layout" name="LayoutFactory" link="yes"/>
300
            <issue number="105390"/>
300
            <issue number="105390"/>
301
        </change>
301
        </change>
302
303
        <change>
304
            <api name="general"/>
305
            <summary>VMDColorScheme introduced</summary>
306
            <version major="2" minor="4"/>
307
            <date day="12" month="6" year="2007"/>
308
            <author login="dkaspar"/>
309
            <compatibility addition="yes"/>
310
            <description>
311
                VMDColorScheme abstract class has been introduced to define a UI of VMD widget.
312
                There are two predefined schemes available in VMDFactory class. Use them as a paratemer in widget constructors.
313
            </description>
314
            <class package="org.netbeans.api.visual.vmd" name="VMDColorScheme" link="yes"/>
315
            <issue number="105929"/>
316
        </change>
302
    </changes>
317
    </changes>
303
318
304
    <htmlcontents>
319
    <htmlcontents>
(-)graph/lib/manifest.mf (-1 / +1 lines)
Lines 1-4 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.visual
2
OpenIDE-Module: org.netbeans.api.visual
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/visual/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/visual/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 2.4
4
OpenIDE-Module-Specification-Version: 2.5
(-)graph/lib/src/org/netbeans/api/visual/vmd/VMDColorScheme.java (+104 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
package org.netbeans.api.visual.vmd;
20
21
import org.netbeans.api.visual.model.ObjectState;
22
import org.netbeans.api.visual.widget.Widget;
23
24
/**
25
 * This class specifies look and feel of vmd widgets. There are predefined schemes in VMDFactory class.
26
 *
27
 * @author David Kaspar
28
 * @since 2.5
29
 */
30
public abstract class VMDColorScheme {
31
32
    /**
33
     * Creates a new vmd color scheme.
34
     * @since 2.5
35
     */
36
    protected VMDColorScheme () {
37
    }
38
39
    /**
40
     * Called to install UI to a node widget.
41
     * @param widget the node widget
42
     * @since 2.5
43
     */
44
    public abstract void installUI (VMDNodeWidget widget);
45
46
    /**
47
     * Called to update UI of a node widget. Called from VMDNodeWidget.notifyStateChanged method.
48
     * @param widget the node widget
49
     * @param previousState the previous state
50
     * @param state the new state
51
     * @since 2.5
52
     */
53
    public abstract void updateUI (VMDNodeWidget widget, ObjectState previousState, ObjectState state);
54
55
    /**
56
     * Returns whether the node minimize button is on the right side of the node header.
57
     * @param widget the node widget
58
     * @return true, if the button is on the right side; false, if the button is on the left side
59
     * @since 2.5
60
     */
61
    public abstract boolean isNodeMinimizeButtonOnRight (VMDNodeWidget widget);
62
63
    /**
64
     * Called to create a pin-category widget.
65
     * @param widget the node widget
66
     * @param categoryDisplayName the category display name
67
     * @return the pin-category widget
68
     * @since 2.5
69
     */
70
    public abstract Widget createPinCategoryWidget (VMDNodeWidget widget, String categoryDisplayName);
71
72
    /**
73
     * Called to install UI to a connection widget.
74
     * @param widget the connection widget
75
     * @since 2.5
76
     */
77
    public abstract void installUI (VMDConnectionWidget widget);
78
79
    /**
80
     * Called to update UI of a connection widget. Called from VMDConnectionWidget.notifyStateChanged method.
81
     * @param widget the connection widget
82
     * @param previousState the previous state
83
     * @param state the new state
84
     * @since 2.5
85
     */
86
    public abstract void updateUI (VMDConnectionWidget widget, ObjectState previousState, ObjectState state);
87
88
    /**
89
     * Called to install UI to a pin widget.
90
     * @param widget the pin widget
91
     * @since 2.5
92
     */
93
    public abstract void installUI (VMDPinWidget widget);
94
95
    /**
96
     * Called to update UI of a pin widget. Called from VMDPinWidget.notifyStateChanged method.
97
     * @param widget the pin widget
98
     * @param previousState the previous state
99
     * @param state the new state
100
     * @since 2.5
101
     */
102
    public abstract void updateUI (VMDPinWidget widget, ObjectState previousState, ObjectState state);
103
104
}
(-)graph/lib/src/org/netbeans/api/visual/vmd/VMDConnectionWidget.java (-35 / +18 lines)
Lines 18-33 Link Here
18
 */
18
 */
19
package org.netbeans.api.visual.vmd;
19
package org.netbeans.api.visual.vmd;
20
20
21
import org.netbeans.api.visual.anchor.AnchorShape;
22
import org.netbeans.api.visual.anchor.PointShape;
23
import org.netbeans.api.visual.anchor.PointShapeFactory;
24
import org.netbeans.api.visual.model.ObjectState;
21
import org.netbeans.api.visual.model.ObjectState;
25
import org.netbeans.api.visual.router.Router;
22
import org.netbeans.api.visual.router.Router;
26
import org.netbeans.api.visual.widget.ConnectionWidget;
23
import org.netbeans.api.visual.widget.ConnectionWidget;
27
import org.netbeans.api.visual.widget.Scene;
24
import org.netbeans.api.visual.widget.Scene;
28
import org.openide.util.Utilities;
29
30
import java.awt.*;
31
25
32
/**
26
/**
33
 * This class represents a connection widget in the VMD visualization style. Can be combined with any other widget.
27
 * This class represents a connection widget in the VMD visualization style. Can be combined with any other widget.
Lines 36-58 Link Here
36
 */
30
 */
37
public class VMDConnectionWidget extends ConnectionWidget {
31
public class VMDConnectionWidget extends ConnectionWidget {
38
32
39
    private static final PointShape POINT_SHAPE_IMAGE = PointShapeFactory.createImagePointShape (Utilities.loadImage ("org/netbeans/modules/visual/resources/vmd-pin.png")); // NOI18N
33
    private VMDColorScheme scheme;
40
41
    private static final Color COLOR_NORMAL = VMDNodeBorder.COLOR_BORDER;
42
    private static final Color COLOR_HOVERED = Color.BLACK;
43
    private static final Color COLOR_HIGHLIGHTED = new Color (49, 106, 197);
44
34
45
    /**
35
    /**
46
     * Creates a connection widget.
36
     * Creates a connection widget with a specific router.
47
     * @param scene the scene
37
     * @param scene the scene
48
     * @param router
38
     * @param router the router
49
     */
39
     */
50
    public VMDConnectionWidget (Scene scene, Router router) {
40
    public VMDConnectionWidget (Scene scene, Router router) {
41
        this (scene, VMDFactory.getOriginalScheme ());
42
        if (router != null)
43
            setRouter (router);
44
    }
45
46
    /**
47
     * Creates a connection widget with a specific color scheme.
48
     * @param scene the scene
49
     * @param scheme the color scheme
50
     */
51
    public VMDConnectionWidget (Scene scene, VMDColorScheme scheme) {
51
        super (scene);
52
        super (scene);
52
        setRouter (router);
53
        assert scheme != null;
53
        setSourceAnchorShape (AnchorShape.NONE);
54
        this.scheme = scheme;
54
        setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
55
        scheme.installUI (this);
55
        setPaintControlPoints (true);
56
        setState (ObjectState.createNormal ());
56
        setState (ObjectState.createNormal ());
57
    }
57
    }
58
58
Lines 62-85 Link Here
62
     * @param state the new state
62
     * @param state the new state
63
     */
63
     */
64
    public void notifyStateChanged (ObjectState previousState, ObjectState state) {
64
    public void notifyStateChanged (ObjectState previousState, ObjectState state) {
65
        if (state.isHovered ())
65
        scheme.updateUI (this, previousState, state);
66
            setForeground (COLOR_HOVERED);
67
        else if (state.isSelected ())
68
            setForeground (VMDNodeWidget.COLOR_SELECTED);
69
        else if (state.isHighlighted ())
70
            setForeground (COLOR_HIGHLIGHTED);
71
        else if (state.isFocused ())
72
            setForeground (COLOR_HOVERED);
73
        else
74
            setForeground (COLOR_NORMAL);
75
76
        if (state.isSelected ()) {
77
            setControlPointShape (PointShape.SQUARE_FILLED_SMALL);
78
            setEndPointShape (PointShape.SQUARE_FILLED_BIG);
79
        } else {
80
            setControlPointShape (PointShape.NONE);
81
            setEndPointShape (POINT_SHAPE_IMAGE);
82
        }
83
    }
66
    }
84
67
85
}
68
}
(-)graph/lib/src/org/netbeans/api/visual/vmd/VMDFactory.java (-2 / +41 lines)
Lines 19-24 Link Here
19
package org.netbeans.api.visual.vmd;
19
package org.netbeans.api.visual.vmd;
20
20
21
import org.netbeans.api.visual.border.Border;
21
import org.netbeans.api.visual.border.Border;
22
import org.netbeans.modules.visual.vmd.VMDNetBeans60ColorScheme;
23
import org.netbeans.modules.visual.vmd.VMDOriginalColorScheme;
24
25
import java.awt.*;
22
26
23
/**
27
/**
24
 * Used as a factory class for objects defined in VMD visualization style.
28
 * Used as a factory class for objects defined in VMD visualization style.
Lines 27-43 Link Here
27
 */
31
 */
28
public final class VMDFactory {
32
public final class VMDFactory {
29
33
30
    private static final Border BORDER_NODE = new VMDNodeBorder ();
34
    private static VMDColorScheme SCHEME_ORIGINAL = new VMDOriginalColorScheme ();
35
    private static VMDColorScheme SCHEME_NB60 = new VMDNetBeans60ColorScheme ();
31
36
32
    private VMDFactory () {
37
    private VMDFactory () {
33
    }
38
    }
34
39
35
    /**
40
    /**
41
     * Creates the original vmd color scheme. Used by default.
42
     * @return the color scheme
43
     * @since 2.5
44
     */
45
    public static VMDColorScheme getOriginalScheme () {
46
        return SCHEME_ORIGINAL;
47
    }
48
49
    /**
50
     * Creates the NetBeans 6.0 vmd color scheme.
51
     * @return the color scheme
52
     * @since 2.5
53
     */
54
    public static VMDColorScheme getNetBeans60Scheme () {
55
        return SCHEME_NB60;
56
    }
57
58
    /**
36
     * Creates a border used by VMD node.
59
     * Creates a border used by VMD node.
37
     * @return the VMD node border
60
     * @return the VMD node border
38
     */
61
     */
39
    public static Border createVMDNodeBorder () {
62
    public static Border createVMDNodeBorder () {
40
        return BORDER_NODE;
63
        return VMDOriginalColorScheme.BORDER_NODE;
64
    }
65
66
    /**
67
     * Creates a border used by VMD node with a specific colors.
68
     * @return the VMD node border
69
     * @param borderColor the border color
70
     * @param borderThickness the border thickness
71
     * @param color1 1. color of gradient background
72
     * @param color2 2. color of gradient background
73
     * @param color3 3. color of gradient background
74
     * @param color4 4. color of gradient background
75
     * @param color5 5. color of gradient background
76
     * @since 2.5
77
     */
78
    public static Border createVMDNodeBorder (Color borderColor, int borderThickness, Color color1, Color color2, Color color3, Color color4, Color color5) {
79
        return new VMDNodeBorder (borderColor, borderThickness, color1, color2, color3, color4, color5);
41
    }
80
    }
42
81
43
}
82
}
(-)graph/lib/src/org/netbeans/api/visual/vmd/VMDGraphScene.java (-3 / +14 lines)
Lines 58-68 Link Here
58
    private WidgetAction moveAction = ActionFactory.createMoveAction ();
58
    private WidgetAction moveAction = ActionFactory.createMoveAction ();
59
59
60
    private SceneLayout sceneLayout;
60
    private SceneLayout sceneLayout;
61
    private VMDColorScheme scheme;
61
62
62
    /**
63
    /**
63
     * Creates a VMD graph scene.
64
     * Creates a VMD graph scene.
64
     */
65
     */
65
    public VMDGraphScene () {
66
    public VMDGraphScene () {
67
        this (VMDFactory.getOriginalScheme ());
68
    }
69
70
    /**
71
     * Creates a VMD graph scene with a specific color scheme.
72
     * @param scheme the color scheme
73
     */
74
    public VMDGraphScene (VMDColorScheme scheme) {
75
        this.scheme = scheme;
66
        setKeyEventProcessingType (EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS);
76
        setKeyEventProcessingType (EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS);
67
77
68
        addChild (backgroundLayer);
78
        addChild (backgroundLayer);
Lines 85-91 Link Here
85
     * @return the widget attached to the node
95
     * @return the widget attached to the node
86
     */
96
     */
87
    protected Widget attachNodeWidget (String node) {
97
    protected Widget attachNodeWidget (String node) {
88
        VMDNodeWidget widget = new VMDNodeWidget (this);
98
        VMDNodeWidget widget = new VMDNodeWidget (this, scheme);
89
        mainLayer.addChild (widget);
99
        mainLayer.addChild (widget);
90
100
91
        widget.getHeader ().getActions ().addAction (createObjectHoverAction ());
101
        widget.getHeader ().getActions ().addAction (createObjectHoverAction ());
Lines 106-112 Link Here
106
        if (pin.endsWith (PIN_ID_DEFAULT_SUFFIX))
116
        if (pin.endsWith (PIN_ID_DEFAULT_SUFFIX))
107
            return null;
117
            return null;
108
118
109
        VMDPinWidget widget = new VMDPinWidget (this);
119
        VMDPinWidget widget = new VMDPinWidget (this, scheme);
110
        ((VMDNodeWidget) findWidget (node)).attachPinWidget (widget);
120
        ((VMDNodeWidget) findWidget (node)).attachPinWidget (widget);
111
        widget.getActions ().addAction (createObjectHoverAction ());
121
        widget.getActions ().addAction (createObjectHoverAction ());
112
        widget.getActions ().addAction (createSelectAction ());
122
        widget.getActions ().addAction (createSelectAction ());
Lines 120-126 Link Here
120
     * @return the widget attached to the edge
130
     * @return the widget attached to the edge
121
     */
131
     */
122
    protected Widget attachEdgeWidget (String edge) {
132
    protected Widget attachEdgeWidget (String edge) {
123
        VMDConnectionWidget connectionWidget = new VMDConnectionWidget (this, router);
133
        VMDConnectionWidget connectionWidget = new VMDConnectionWidget (this, scheme);
134
        connectionWidget.setRouter (router);
124
        connectionLayer.addChild (connectionWidget);
135
        connectionLayer.addChild (connectionWidget);
125
136
126
        connectionWidget.getActions ().addAction (createObjectHoverAction ());
137
        connectionWidget.getActions ().addAction (createObjectHoverAction ());
(-)graph/lib/src/org/netbeans/api/visual/vmd/VMDNodeBorder.java (-17 / +29 lines)
Lines 28-60 Link Here
28
 */
28
 */
29
class VMDNodeBorder implements Border {
29
class VMDNodeBorder implements Border {
30
30
31
    static final Color COLOR_BORDER = new Color (0xBACDF0);
31
    private Color colorBorder;
32
    private static final Insets INSETS = new Insets (1, 1, 1, 1);
32
    private Insets insets;
33
//    private static final Color COLOR0 = new Color (169, 197, 235);
33
    private Stroke stroke;
34
    private static final Color COLOR1 = new Color (221, 235, 246);
34
    private Color color1;
35
    private static final Color COLOR2 = new Color (255, 255, 255);
35
    private Color color2;
36
    private static final Color COLOR3 = new Color (214, 235, 255);
36
    private Color color3;
37
    private static final Color COLOR4 = new Color (241, 249, 253);
37
    private Color color4;
38
    private static final Color COLOR5 = new Color (255, 255, 255);
38
    private Color color5;
39
39
40
    VMDNodeBorder () {
40
    VMDNodeBorder (Color colorBorder, int thickness, Color color1, Color color2, Color color3, Color color4, Color color5) {
41
        this.colorBorder = colorBorder;
42
        this.insets = new Insets (thickness, thickness, thickness, thickness);
43
        this.stroke = new BasicStroke (thickness);
44
        this.color1 = color1;
45
        this.color2 = color2;
46
        this.color3 = color3;
47
        this.color4 = color4;
48
        this.color5 = color5;
41
    }
49
    }
42
50
43
    public Insets getInsets () {
51
    public Insets getInsets () {
44
        return INSETS;
52
        return insets;
45
    }
53
    }
46
54
47
    public void paint (Graphics2D gr, Rectangle bounds) {
55
    public void paint (Graphics2D gr, Rectangle bounds) {
48
        Shape previousClip = gr.getClip ();
56
        Shape previousClip = gr.getClip ();
49
        gr.clip (new RoundRectangle2D.Float (bounds.x, bounds.y, bounds.width, bounds.height, 4, 4));
57
        gr.clip (new RoundRectangle2D.Float (bounds.x, bounds.y, bounds.width, bounds.height, 4, 4));
50
58
51
        drawGradient (gr, bounds, COLOR1, COLOR2, 0f, 0.3f);
59
        drawGradient (gr, bounds, color1, color2, 0f, 0.3f);
52
        drawGradient (gr, bounds, COLOR2, COLOR3, 0.3f, 0.764f);
60
        drawGradient (gr, bounds, color2, color3, 0.3f, 0.764f);
53
        drawGradient (gr, bounds, COLOR3, COLOR4, 0.764f, 0.927f);
61
        drawGradient (gr, bounds, color3, color4, 0.764f, 0.927f);
54
        drawGradient (gr, bounds, COLOR4, COLOR5, 0.927f, 1f);
62
        drawGradient (gr, bounds, color4, color5, 0.927f, 1f);
55
63
56
        gr.setColor (COLOR_BORDER);
64
        gr.setColor (colorBorder);
65
        Stroke previousStroke = gr.getStroke ();
66
        gr.setStroke (stroke);
57
        gr.draw (new RoundRectangle2D.Float (bounds.x + 0.5f, bounds.y + 0.5f, bounds.width - 1, bounds.height - 1, 4, 4));
67
        gr.draw (new RoundRectangle2D.Float (bounds.x + 0.5f, bounds.y + 0.5f, bounds.width - 1, bounds.height - 1, 4, 4));
68
        gr.setStroke (previousStroke);
58
69
59
        gr.setClip (previousClip);
70
        gr.setClip (previousClip);
60
    }
71
    }
Lines 69-72 Link Here
69
    public boolean isOpaque () {
80
    public boolean isOpaque () {
70
        return true;
81
        return true;
71
    }
82
    }
83
72
}
84
}
(-)graph/lib/src/org/netbeans/api/visual/vmd/VMDNodeWidget.java (-32 / +43 lines)
Lines 21-28 Link Here
21
import org.netbeans.api.visual.action.WidgetAction;
21
import org.netbeans.api.visual.action.WidgetAction;
22
import org.netbeans.api.visual.anchor.Anchor;
22
import org.netbeans.api.visual.anchor.Anchor;
23
import org.netbeans.api.visual.anchor.AnchorFactory;
23
import org.netbeans.api.visual.anchor.AnchorFactory;
24
import org.netbeans.api.visual.border.Border;
25
import org.netbeans.api.visual.border.BorderFactory;
26
import org.netbeans.api.visual.layout.LayoutFactory;
24
import org.netbeans.api.visual.layout.LayoutFactory;
27
import org.netbeans.api.visual.model.ObjectState;
25
import org.netbeans.api.visual.model.ObjectState;
28
import org.netbeans.api.visual.model.StateModel;
26
import org.netbeans.api.visual.model.StateModel;
Lines 46-57 Link Here
46
 */
44
 */
47
public class VMDNodeWidget extends Widget implements StateModel.Listener, VMDMinimizeAbility {
45
public class VMDNodeWidget extends Widget implements StateModel.Listener, VMDMinimizeAbility {
48
46
49
    private static final Color BORDER_CATEGORY_BACKGROUND = new Color (0xCDDDF8);
50
    private static final Border BORDER_MINIMIZE = BorderFactory.createRoundedBorder (2, 2, null, VMDNodeBorder.COLOR_BORDER);
51
    static final Color COLOR_SELECTED = new Color (0x748CC0);
52
    static final Border BORDER = BorderFactory.createOpaqueBorder (2, 8, 2, 8);
53
    static final Border BORDER_HOVERED = BorderFactory.createLineBorder (2, 8, 2, 8, Color.BLACK);
54
55
    private Widget header;
47
    private Widget header;
56
    private ImageWidget minimizeWidget;
48
    private ImageWidget minimizeWidget;
57
    private ImageWidget imageWidget;
49
    private ImageWidget imageWidget;
Lines 62-96 Link Here
62
    private SeparatorWidget pinsSeparator;
54
    private SeparatorWidget pinsSeparator;
63
55
64
    private HashMap<String, Widget> pinCategoryWidgets = new HashMap<String, Widget> ();
56
    private HashMap<String, Widget> pinCategoryWidgets = new HashMap<String, Widget> ();
65
    private Font fontPinCategory = getScene ().getFont ().deriveFont (10.0f);
66
57
67
    private StateModel stateModel = new StateModel (2);
58
    private StateModel stateModel = new StateModel (2);
68
    private Anchor nodeAnchor = new VMDNodeAnchor (this);
59
    private Anchor nodeAnchor = new VMDNodeAnchor (this);
60
    private VMDColorScheme scheme;
69
61
70
    /**
62
    /**
71
     * Creates a node widget.
63
     * Creates a node widget.
72
     * @param scene the scene
64
     * @param scene the scene
73
     */
65
     */
74
    public VMDNodeWidget (Scene scene) {
66
    public VMDNodeWidget (Scene scene) {
67
        this (scene, VMDFactory.getOriginalScheme ());
68
    }
69
70
    /**
71
     * Creates a node widget with a specific color scheme.
72
     * @param scene the scene
73
     * @param scheme the color scheme
74
     */
75
    public VMDNodeWidget (Scene scene, VMDColorScheme scheme) {
75
        super (scene);
76
        super (scene);
77
        assert scheme != null;
78
        this.scheme = scheme;
76
79
77
        setOpaque (false);
78
        setBorder (VMDFactory.createVMDNodeBorder ());
79
        setLayout (LayoutFactory.createVerticalFlowLayout ());
80
        setLayout (LayoutFactory.createVerticalFlowLayout ());
80
        setMinimumSize (new Dimension (128, 8));
81
        setMinimumSize (new Dimension (128, 8));
81
82
82
        header = new Widget (scene);
83
        header = new Widget (scene);
83
        header.setBorder (BORDER);
84
        header.setBackground (COLOR_SELECTED);
85
        header.setOpaque (false);
86
        header.setLayout (LayoutFactory.createHorizontalFlowLayout (LayoutFactory.SerialAlignment.CENTER, 8));
84
        header.setLayout (LayoutFactory.createHorizontalFlowLayout (LayoutFactory.SerialAlignment.CENTER, 8));
87
        addChild (header);
85
        addChild (header);
88
86
89
        minimizeWidget = new ImageWidget (scene, Utilities.loadImage ("org/netbeans/modules/visual/resources/vmd-collapse.png"));
87
        boolean right = scheme.isNodeMinimizeButtonOnRight (this);
88
89
        minimizeWidget = new ImageWidget (scene, Utilities.loadImage ("org/netbeans/modules/visual/resources/vmd-collapse.png")); // NOI18N
90
        minimizeWidget.setCursor (Cursor.getPredefinedCursor (Cursor.HAND_CURSOR));
90
        minimizeWidget.setCursor (Cursor.getPredefinedCursor (Cursor.HAND_CURSOR));
91
        minimizeWidget.setBorder (BORDER_MINIMIZE);
92
        minimizeWidget.getActions ().addAction (new ToggleMinimizedAction ());
91
        minimizeWidget.getActions ().addAction (new ToggleMinimizedAction ());
93
        header.addChild (minimizeWidget);
92
        if (! right)
93
            header.addChild (minimizeWidget);
94
94
95
        imageWidget = new ImageWidget (scene);
95
        imageWidget = new ImageWidget (scene);
96
        header.addChild (imageWidget);
96
        header.addChild (imageWidget);
Lines 106-113 Link Here
106
        glyphSetWidget = new VMDGlyphSetWidget (scene);
106
        glyphSetWidget = new VMDGlyphSetWidget (scene);
107
        header.addChild (glyphSetWidget);
107
        header.addChild (glyphSetWidget);
108
108
109
        if (right) {
110
            Widget widget = new Widget (scene);
111
            widget.setOpaque (false);
112
            header.addChild (widget, 1000);
113
            header.addChild (minimizeWidget);
114
        }
115
109
        pinsSeparator = new SeparatorWidget (scene, SeparatorWidget.Orientation.HORIZONTAL);
116
        pinsSeparator = new SeparatorWidget (scene, SeparatorWidget.Orientation.HORIZONTAL);
110
        pinsSeparator.setForeground (BORDER_CATEGORY_BACKGROUND);
111
        addChild (pinsSeparator);
117
        addChild (pinsSeparator);
112
118
113
        Widget topLayer = new Widget (scene);
119
        Widget topLayer = new Widget (scene);
Lines 116-121 Link Here
116
        stateModel = new StateModel ();
122
        stateModel = new StateModel ();
117
        stateModel.addListener (this);
123
        stateModel.addListener (this);
118
124
125
        scheme.installUI (this);
119
        notifyStateChanged (ObjectState.createNormal (), ObjectState.createNormal ());
126
        notifyStateChanged (ObjectState.createNormal (), ObjectState.createNormal ());
120
    }
127
    }
121
128
Lines 175-187 Link Here
175
     * @param state the new state
182
     * @param state the new state
176
     */
183
     */
177
    protected void notifyStateChanged (ObjectState previousState, ObjectState state) {
184
    protected void notifyStateChanged (ObjectState previousState, ObjectState state) {
178
        if (! previousState.isSelected ()  &&  state.isSelected ())
185
        scheme.updateUI (this, previousState, state);
179
            bringToFront ();
180
        else if (! previousState.isHovered ()  &&  state.isHovered ())
181
            bringToFront ();
182
183
        header.setOpaque (state.isSelected ());
184
        header.setBorder (state.isFocused () || state.isHovered () ? VMDNodeWidget.BORDER_HOVERED : VMDNodeWidget.BORDER);
185
    }
186
    }
186
187
187
    /**
188
    /**
Lines 331-343 Link Here
331
        Widget w = pinCategoryWidgets.get (categoryDisplayName);
332
        Widget w = pinCategoryWidgets.get (categoryDisplayName);
332
        if (w != null)
333
        if (w != null)
333
            return w;
334
            return w;
334
        LabelWidget label = new LabelWidget (getScene (), categoryDisplayName);
335
        Widget label = scheme.createPinCategoryWidget (this, categoryDisplayName);
335
        label.setOpaque (true);
336
        label.setBackground (BORDER_CATEGORY_BACKGROUND);
337
        label.setForeground (Color.GRAY);
338
        label.setFont (fontPinCategory);
339
        label.setAlignment (LabelWidget.Alignment.CENTER);
340
        label.setCheckClipping (true);
341
        if (stateModel.getBooleanState ())
336
        if (stateModel.getBooleanState ())
342
            label.setPreferredBounds (new Rectangle ());
337
            label.setPreferredBounds (new Rectangle ());
343
        pinCategoryWidgets.put (categoryDisplayName, label); 
338
        pinCategoryWidgets.put (categoryDisplayName, label); 
Lines 364-369 Link Here
364
     */
359
     */
365
    public Widget getHeader () {
360
    public Widget getHeader () {
366
        return header;
361
        return header;
362
    }
363
364
    /**
365
     * Returns a minimize button widget.
366
     * @return the miminize button widget
367
     */
368
    public Widget getMinimizeButton () {
369
        return minimizeWidget;
370
    }
371
372
    /**
373
     * Returns a pins separator.
374
     * @return the pins separator
375
     */
376
    public Widget getPinsSeparator () {
377
        return pinsSeparator;
367
    }
378
    }
368
379
369
    private final class ToggleMinimizedAction extends WidgetAction.Adapter {
380
    private final class ToggleMinimizedAction extends WidgetAction.Adapter {
(-)graph/lib/src/org/netbeans/api/visual/vmd/VMDPinWidget.java (-8 / +15 lines)
Lines 36-41 Link Here
36
 */
36
 */
37
public class VMDPinWidget extends Widget {
37
public class VMDPinWidget extends Widget {
38
38
39
    private VMDColorScheme scheme;
40
39
    private LabelWidget nameWidget;
41
    private LabelWidget nameWidget;
40
    private VMDGlyphSetWidget glyphsWidget;
42
    private VMDGlyphSetWidget glyphsWidget;
41
    private VMDNodeAnchor anchor;
43
    private VMDNodeAnchor anchor;
Lines 45-59 Link Here
45
     * @param scene the scene
47
     * @param scene the scene
46
     */
48
     */
47
    public VMDPinWidget (Scene scene) {
49
    public VMDPinWidget (Scene scene) {
50
        this (scene, VMDFactory.getOriginalScheme ());
51
    }
52
53
    /**
54
     * Creates a pin widget with a specific color scheme.
55
     * @param scene the scene
56
     * @param scheme the color scheme
57
     */
58
    public VMDPinWidget (Scene scene, VMDColorScheme scheme) {
48
        super (scene);
59
        super (scene);
60
        assert scheme != null;
61
        this.scheme = scheme;
49
62
50
        setBorder (VMDNodeWidget.BORDER);
51
        setBackground (VMDNodeWidget.COLOR_SELECTED);
52
        setOpaque (false);
53
        setLayout (LayoutFactory.createHorizontalFlowLayout (LayoutFactory.SerialAlignment.CENTER, 8));
63
        setLayout (LayoutFactory.createHorizontalFlowLayout (LayoutFactory.SerialAlignment.CENTER, 8));
54
        addChild (nameWidget = new LabelWidget (scene));
64
        addChild (nameWidget = new LabelWidget (scene));
55
        addChild (glyphsWidget = new VMDGlyphSetWidget (scene));
65
        addChild (glyphsWidget = new VMDGlyphSetWidget (scene));
56
66
67
        scheme.installUI (this);
57
        notifyStateChanged (ObjectState.createNormal (), ObjectState.createNormal ());
68
        notifyStateChanged (ObjectState.createNormal (), ObjectState.createNormal ());
58
    }
69
    }
59
70
Lines 63-73 Link Here
63
     * @param state the new state
74
     * @param state the new state
64
     */
75
     */
65
    protected void notifyStateChanged (ObjectState previousState, ObjectState state) {
76
    protected void notifyStateChanged (ObjectState previousState, ObjectState state) {
66
        setOpaque (state.isSelected ());
77
        scheme.updateUI (this, previousState, state);
67
        setBorder (state.isFocused () || state.isHovered () ? VMDNodeWidget.BORDER_HOVERED : VMDNodeWidget.BORDER);
68
//        LookFeel lookFeel = getScene ().getLookFeel ();
69
//        setBorder (BorderFactory.createCompositeBorder (BorderFactory.createEmptyBorder (8, 2), lookFeel.getMiniBorder (state)));
70
//        setForeground (lookFeel.getForeground (state));
71
    }
78
    }
72
79
73
    /**
80
    /**
(-)graph/lib/src/org/netbeans/api/visual/widget/ConnectionWidget.java (+1 lines)
Lines 328-333 Link Here
328
     * @param router the path router
328
     * @param router the path router
329
     */
329
     */
330
    public final void setRouter (Router router) {
330
    public final void setRouter (Router router) {
331
        assert router != null;
331
        this.router = router;
332
        this.router = router;
332
        reroute ();
333
        reroute ();
333
    }
334
    }
(-)graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html (+3 lines)
Lines 2099-2104 Link Here
2099
<p>
2099
<p>
2100
The <code>VMDGraphScene.layoutGraph</code> method layouts nodes on a scene using <code>GridGraphLayout</code> class. After calling the method, you have to call <code>Scene.validate</code> method manually to trigger the scene validation and therefore graph-oriented layout of a scene.
2100
The <code>VMDGraphScene.layoutGraph</code> method layouts nodes on a scene using <code>GridGraphLayout</code> class. After calling the method, you have to call <code>Scene.validate</code> method manually to trigger the scene validation and therefore graph-oriented layout of a scene.
2101
2101
2102
<p>
2103
The VMDColorScheme class defines a UI of VMD widgets. There are two implementations available using <code>VMDFactory.createOriginalColorScheme</code>, <code>VMDFactory.createNetBeans60ColorScheme</code> method calls. The color scheme can be used as a parameter in widget constructors.
2104
2102
<h3><a name="MinimizeAbility">Minimize Ability</a></h3>
2105
<h3><a name="MinimizeAbility">Minimize Ability</a></h3>
2103
2106
2104
<p>
2107
<p>
(-)graph/lib/src/org/netbeans/modules/visual/vmd/VMDNetBeans60ColorScheme.java (+124 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
package org.netbeans.modules.visual.vmd;
20
21
import org.netbeans.api.visual.border.Border;
22
import org.netbeans.api.visual.border.BorderFactory;
23
import org.netbeans.api.visual.vmd.*;
24
import org.netbeans.api.visual.widget.Widget;
25
import org.netbeans.api.visual.model.ObjectState;
26
import org.netbeans.api.visual.anchor.AnchorShape;
27
import org.netbeans.api.visual.anchor.PointShape;
28
29
import java.awt.*;
30
31
/**
32
 * @author David Kaspar
33
 */
34
public class VMDNetBeans60ColorScheme extends VMDColorScheme {
35
36
    public static final Color COLOR60_SELECT = new Color (0xFF8500);
37
    public static final Color COLOR60_HOVER = new Color (0x5B67B0);
38
    public static final Color COLOR60_HOVER_BACKGROUND = new Color (0xB0C3E1);
39
40
    private static final Border BORDER_MINIMIZE = BorderFactory.createRoundedBorder (2, 2, null, COLOR60_HOVER);
41
42
    private static final Border BORDER60 = VMDFactory.createVMDNodeBorder (VMDOriginalColorScheme.COLOR_NORMAL, 2, VMDOriginalColorScheme.COLOR1, VMDOriginalColorScheme.COLOR2, VMDOriginalColorScheme.COLOR3, VMDOriginalColorScheme.COLOR4, VMDOriginalColorScheme.COLOR5);
43
    private static final Border BORDER60_SELECT = VMDFactory.createVMDNodeBorder (COLOR60_SELECT, 2, VMDOriginalColorScheme.COLOR1, VMDOriginalColorScheme.COLOR2, VMDOriginalColorScheme.COLOR3, VMDOriginalColorScheme.COLOR4, VMDOriginalColorScheme.COLOR5);
44
    private static final Border BORDER60_HOVER = VMDFactory.createVMDNodeBorder (COLOR60_HOVER, 2, VMDOriginalColorScheme.COLOR1, VMDOriginalColorScheme.COLOR2, VMDOriginalColorScheme.COLOR3, VMDOriginalColorScheme.COLOR4, VMDOriginalColorScheme.COLOR5);
45
46
    private static final Border BORDER60_PIN_SELECT = BorderFactory.createCompositeBorder (BorderFactory.createLineBorder (0, 1, 0, 1, COLOR60_SELECT), BorderFactory.createLineBorder (2, 7, 2, 7, COLOR60_SELECT));
47
//        private static final Border BORDER60_PIN_HOVER = BorderFactory.createLineBorder (2, 8, 2, 8, COLOR60_HOVER);
48
49
    public void installUI (VMDNodeWidget widget) {
50
        widget.setBorder (BORDER60);
51
52
        Widget header = widget.getHeader ();
53
        header.setBackground (COLOR60_HOVER_BACKGROUND);
54
        header.setBorder (VMDOriginalColorScheme.BORDER_PIN);
55
56
        Widget minimize = widget.getMinimizeButton ();
57
        minimize.setBorder (BORDER_MINIMIZE);
58
59
        Widget pinsSeparator = widget.getPinsSeparator ();
60
        pinsSeparator.setForeground (VMDOriginalColorScheme.BORDER_CATEGORY_BACKGROUND);
61
    }
62
63
    public void updateUI (VMDNodeWidget widget, ObjectState previousState, ObjectState state) {
64
        if (! previousState.isSelected ()  &&  state.isSelected ())
65
            widget.bringToFront ();
66
67
        widget.getHeader ().setOpaque (state.isHovered ()  ||  state.isFocused ());
68
        if (state.isSelected ())
69
            widget.setBorder (BORDER60_SELECT);
70
        else if (state.isHovered ())
71
            widget.setBorder (BORDER60_HOVER);
72
        else if (state.isFocused ())
73
            widget.setBorder (BORDER60_HOVER);
74
        else
75
            widget.setBorder (BORDER60);
76
    }
77
78
    public void installUI (VMDConnectionWidget widget) {
79
        widget.setSourceAnchorShape (AnchorShape.NONE);
80
        widget.setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
81
        widget.setPaintControlPoints (true);
82
    }
83
84
    public void updateUI (VMDConnectionWidget widget, ObjectState previousState, ObjectState state) {
85
        if (state.isSelected ())
86
            widget.setForeground (COLOR60_SELECT);
87
        else if (state.isHighlighted ())
88
            widget.setForeground (VMDOriginalColorScheme.COLOR_HIGHLIGHTED);
89
        else if (state.isHovered ()  ||  state.isFocused ())
90
            widget.setForeground (COLOR60_HOVER);
91
        else
92
            widget.setForeground (VMDOriginalColorScheme.COLOR_NORMAL);
93
94
        if (state.isSelected ()  ||  state.isHovered ()) {
95
            widget.setControlPointShape (PointShape.SQUARE_FILLED_SMALL);
96
            widget.setEndPointShape (PointShape.SQUARE_FILLED_BIG);
97
        } else {
98
            widget.setControlPointShape (PointShape.NONE);
99
            widget.setEndPointShape (VMDOriginalColorScheme.POINT_SHAPE_IMAGE);
100
        }
101
    }
102
103
    public void installUI (VMDPinWidget widget) {
104
        widget.setBorder (VMDOriginalColorScheme.BORDER_PIN);
105
        widget.setBackground (COLOR60_HOVER_BACKGROUND);
106
    }
107
108
    public void updateUI (VMDPinWidget widget, ObjectState previousState, ObjectState state) {
109
        widget.setOpaque (state.isHovered ()  ||  state.isFocused ());
110
        if (state.isSelected ())
111
            widget.setBorder (BORDER60_PIN_SELECT);
112
        else
113
            widget.setBorder (VMDOriginalColorScheme.BORDER_PIN);
114
    }
115
116
    public boolean isNodeMinimizeButtonOnRight (VMDNodeWidget widget) {
117
        return true;
118
    }
119
120
    public Widget createPinCategoryWidget (VMDNodeWidget widget, String categoryDisplayName) {
121
        return VMDFactory.getOriginalScheme ().createPinCategoryWidget (widget, categoryDisplayName);
122
    }
123
124
}
(-)graph/lib/src/org/netbeans/modules/visual/vmd/VMDOriginalColorScheme.java (+151 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
package org.netbeans.modules.visual.vmd;
20
21
import org.netbeans.api.visual.border.Border;
22
import org.netbeans.api.visual.border.BorderFactory;
23
import org.netbeans.api.visual.model.ObjectState;
24
import org.netbeans.api.visual.widget.Widget;
25
import org.netbeans.api.visual.widget.LabelWidget;
26
import org.netbeans.api.visual.widget.Scene;
27
import org.netbeans.api.visual.anchor.AnchorShape;
28
import org.netbeans.api.visual.anchor.PointShape;
29
import org.netbeans.api.visual.anchor.PointShapeFactory;
30
import org.netbeans.api.visual.vmd.*;
31
import org.openide.util.Utilities;
32
33
import java.awt.*;
34
35
/**
36
 * This class specifies look and feel of vmd widgets. There are predefined schemes in VMDFactory class.
37
 *
38
 * @author David Kaspar
39
 */
40
public class VMDOriginalColorScheme extends VMDColorScheme {
41
42
    static final Color COLOR_NORMAL = new Color (0xBACDF0);
43
    private static final Color COLOR_HOVERED = Color.BLACK;
44
    private static final Color COLOR_SELECTED = new Color (0x748CC0);
45
    static final Color COLOR_HIGHLIGHTED = new Color (0x316AC5);
46
47
//    private static final Color COLOR0 = new Color (169, 197, 235);
48
    static final Color COLOR1 = new Color (221, 235, 246);
49
    static final Color COLOR2 = new Color (255, 255, 255);
50
    static final Color COLOR3 = new Color (214, 235, 255);
51
    static final Color COLOR4 = new Color (241, 249, 253);
52
    static final Color COLOR5 = new Color (255, 255, 255);
53
54
    public static final Border BORDER_NODE = VMDFactory.createVMDNodeBorder (COLOR_NORMAL, 1, COLOR1, COLOR2, COLOR3, COLOR4, COLOR5);
55
56
    static final Color BORDER_CATEGORY_BACKGROUND = new Color (0xCDDDF8);
57
    static final Border BORDER_MINIMIZE = BorderFactory.createRoundedBorder (2, 2, null, COLOR_NORMAL);
58
    static final Border BORDER_PIN = BorderFactory.createOpaqueBorder (2, 8, 2, 8);
59
    private static final Border BORDER_PIN_HOVERED = BorderFactory.createLineBorder (2, 8, 2, 8, Color.BLACK);
60
61
    static final PointShape POINT_SHAPE_IMAGE = PointShapeFactory.createImagePointShape (Utilities.loadImage ("org/netbeans/modules/visual/resources/vmd-pin.png")); // NOI18N
62
63
    public VMDOriginalColorScheme () {
64
    }
65
66
    public void installUI (VMDNodeWidget widget) {
67
        widget.setBorder (VMDFactory.createVMDNodeBorder ());
68
        widget.setOpaque (false);
69
70
        Widget header = widget.getHeader ();
71
        header.setBorder (BORDER_PIN);
72
        header.setBackground (COLOR_SELECTED);
73
        header.setOpaque (false);
74
75
        Widget minimize = widget.getMinimizeButton ();
76
        minimize.setBorder (BORDER_MINIMIZE);
77
78
        Widget pinsSeparator = widget.getPinsSeparator ();
79
        pinsSeparator.setForeground (BORDER_CATEGORY_BACKGROUND);
80
    }
81
82
    public void updateUI (VMDNodeWidget widget, ObjectState previousState, ObjectState state) {
83
        if (! previousState.isSelected ()  &&  state.isSelected ())
84
            widget.bringToFront ();
85
        else if (! previousState.isHovered ()  &&  state.isHovered ())
86
            widget.bringToFront ();
87
88
        Widget header = widget.getHeader ();
89
        header.setOpaque (state.isSelected ());
90
        header.setBorder (state.isFocused () || state.isHovered () ? BORDER_PIN_HOVERED : BORDER_PIN);
91
    }
92
93
    public boolean isNodeMinimizeButtonOnRight (VMDNodeWidget widget) {
94
        return false;
95
    }
96
97
    public Widget createPinCategoryWidget (VMDNodeWidget widget, String categoryDisplayName) {
98
        Scene scene = widget.getScene ();
99
        LabelWidget label = new LabelWidget (scene, categoryDisplayName);
100
        label.setOpaque (true);
101
        label.setBackground (BORDER_CATEGORY_BACKGROUND);
102
        label.setForeground (Color.GRAY);
103
        Font fontPinCategory = scene.getDefaultFont ().deriveFont (10.0f);
104
        label.setFont (fontPinCategory);
105
        label.setAlignment (LabelWidget.Alignment.CENTER);
106
        label.setCheckClipping (true);
107
        return label;
108
    }
109
110
    public void installUI (VMDConnectionWidget widget) {
111
        widget.setSourceAnchorShape (AnchorShape.NONE);
112
        widget.setTargetAnchorShape (AnchorShape.TRIANGLE_FILLED);
113
        widget.setPaintControlPoints (true);
114
    }
115
116
    public void updateUI (VMDConnectionWidget widget, ObjectState previousState, ObjectState state) {
117
        if (state.isHovered ())
118
            widget.setForeground (COLOR_HOVERED);
119
        else if (state.isSelected ())
120
            widget.setForeground (COLOR_SELECTED);
121
        else if (state.isHighlighted ())
122
            widget.setForeground (COLOR_HIGHLIGHTED);
123
        else if (state.isFocused ())
124
            widget.setForeground (COLOR_HOVERED);
125
        else
126
            widget.setForeground (COLOR_NORMAL);
127
128
        if (state.isSelected ()) {
129
            widget.setControlPointShape (PointShape.SQUARE_FILLED_SMALL);
130
            widget.setEndPointShape (PointShape.SQUARE_FILLED_BIG);
131
        } else {
132
            widget.setControlPointShape (PointShape.NONE);
133
            widget.setEndPointShape (POINT_SHAPE_IMAGE);
134
        }
135
    }
136
137
    public void installUI (VMDPinWidget widget) {
138
        widget.setBorder (BORDER_PIN);
139
        widget.setBackground (COLOR_SELECTED);
140
        widget.setOpaque (false);
141
    }
142
143
    public void updateUI (VMDPinWidget widget, ObjectState previousState, ObjectState state) {
144
        widget.setOpaque (state.isSelected ());
145
        widget.setBorder (state.isFocused () || state.isHovered () ? BORDER_PIN_HOVERED : BORDER_PIN);
146
//        LookFeel lookFeel = getScene ().getLookFeel ();
147
//        setBorder (BorderFactory.createCompositeBorder (BorderFactory.createEmptyBorder (8, 2), lookFeel.getMiniBorder (state)));
148
//        setForeground (lookFeel.getForeground (state));
149
    }
150
151
}
(-)graph/www/documentation.html (+1 lines)
Lines 177-182 Link Here
177
<li><strong>test.visible.NotifyAddedRemovedTest</strong> - test of <code>Widget.notifyAdded</code> and <code>Widget.notifyRemoved</code> methods
177
<li><strong>test.visible.NotifyAddedRemovedTest</strong> - test of <code>Widget.notifyAdded</code> and <code>Widget.notifyRemoved</code> methods
178
<li><strong>test.visible.VisibilityTest</strong> - compatibility test of <code>Layout</code> implementations with <code>Widget.visible</code> property
178
<li><strong>test.visible.VisibilityTest</strong> - compatibility test of <code>Layout</code> implementations with <code>Widget.visible</code> property
179
<li><strong>test.vmd.VMDCollisionTest</strong> - test of <code>WidgetCollisionCollector</code>
179
<li><strong>test.vmd.VMDCollisionTest</strong> - test of <code>WidgetCollisionCollector</code>
180
<li><strong>test.vmd.VMDColorSchemeTest</strong> - how to use <strong>VMDColorScheme</strong>
180
<li><strong>test.vmd.VMDTest</strong> - how to use <strong>VMD</strong> plug-in
181
<li><strong>test.vmd.VMDTest</strong> - how to use <strong>VMD</strong> plug-in
181
<li><strong>test.widget.AnimatedImageTest</strong> - test of animated image in ImageWidget
182
<li><strong>test.widget.AnimatedImageTest</strong> - test of animated image in ImageWidget
182
<li><strong>test.zoom.CenteredZoomTest</strong> - how to use <code>CenteredZoomAction</code>
183
<li><strong>test.zoom.CenteredZoomTest</strong> - how to use <code>CenteredZoomAction</code>

Return to bug 105929