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 113456
Collapse All | Expand All

(-)api.visual/apichanges.xml (+15 lines)
Lines 757-762 Link Here
757
            <class package="org.netbeans.api.visual.graph.layout" name="GraphLayoutSupport" link="yes"/>
757
            <class package="org.netbeans.api.visual.graph.layout" name="GraphLayoutSupport" link="yes"/>
758
            <issue number="178705"/>
758
            <issue number="178705"/>
759
        </change>
759
        </change>
760
        <change>
761
            <api name="general"/>
762
            <summary>Support for rotating widgets</summary>
763
            <version major="2" minor="34"/>
764
            <date day="2" month="9" year="2012"/>
765
            <author login="jhavlin"/>
766
            <compatibility addition="yes"/>
767
            <description>
768
                Added support for rotating widgets. Patch provided by user
769
                bcallebaut.
770
            </description>
771
            <class package="org.netbeans.api.visual.widget" name="Widget" link="yes"/>
772
            <class package="org.netbeans.api.visual.action" name="WidgetAction" link="yes"/>
773
            <issue number="113456"/>
774
        </change>
760
    </changes>
775
    </changes>
761
776
762
    <htmlcontents>
777
    <htmlcontents>
(-)api.visual/manifest.mf (-1 / +1 lines)
Lines 1-6 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.33
4
OpenIDE-Module-Specification-Version: 2.34
5
AutoUpdate-Essential-Module: true
5
AutoUpdate-Essential-Module: true
6
6
(-)api.visual/nbproject/project.xml (+9 lines)
Lines 59-64 Link Here
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
62
                    <code-name-base>org.netbeans.spi.palette</code-name-base>
63
                    <build-prerequisite/>
64
                    <compile-dependency/>
65
                    <run-dependency>
66
                        <release-version>1</release-version>
67
                        <specification-version>1.33</specification-version>
68
                    </run-dependency>
69
                </dependency>
70
                <dependency>
62
                    <code-name-base>org.openide.util</code-name-base>
71
                    <code-name-base>org.openide.util</code-name-base>
63
                    <build-prerequisite/>
72
                    <build-prerequisite/>
64
                    <compile-dependency/>
73
                    <compile-dependency/>
(-)api.visual/src/org/netbeans/api/visual/action/WidgetAction.java (+58 lines)
Lines 1087-1092 Link Here
1087
    }
1087
    }
1088
1088
1089
    /**
1089
    /**
1090
     * @since 2.34
1091
     * @author bcallebaut
1092
     */
1093
    public static final class ChainProvider{
1094
1095
        private String name = "";
1096
1097
    /**
1098
         * Get the value of name
1099
         *
1100
         * @return the value of name
1101
         */
1102
        public String getName() {
1103
            return name;
1104
        }
1105
1106
        /**
1107
         * Set the value of name
1108
         *
1109
         * @param name new value of name
1110
         */
1111
        public void setName(String name) {
1112
            this.name = name;
1113
        }
1114
1115
        private Chain chain;
1116
1117
        /**
1118
         * Get the value of chain
1119
         *
1120
         * @return the value of chain
1121
         */
1122
        public Chain getChain() {
1123
            return chain;
1124
        }
1125
1126
        /**
1127
         * Set the value of chain
1128
         *
1129
         * @param chain new value of chain
1130
         */
1131
        public void setChain(Chain chain) {
1132
            this.chain = chain;
1133
        }
1134
1135
        public ChainProvider() {
1136
        }
1137
1138
        public ChainProvider(Chain chain) {
1139
            this.chain = chain;
1140
        }
1141
1142
        public ChainProvider(String name,Chain chain) {
1143
            this.name = name;
1144
            this.chain = chain;
1145
        }
1146
    }
1147
    /**
1090
     * Represents an widget event.
1148
     * Represents an widget event.
1091
     */
1149
     */
1092
    public static interface WidgetEvent {
1150
    public static interface WidgetEvent {
(-)api.visual/src/org/netbeans/api/visual/widget/Widget.java (-7 / +64 lines)
Lines 89-99 Link Here
89
 * and actions. Yherefore you can define your own look and feel directly in the that method.
89
 * and actions. Yherefore you can define your own look and feel directly in the that method.
90
 *
90
 *
91
 * Since version 2.6 Widget class implements Accessible interface.
91
 * Since version 2.6 Widget class implements Accessible interface.
92
 * Since version 2.34 Widget class implements Lookup.Provider interface and
93
 * tries to initialize itself using the lookup passed in the constructor.
92
 *
94
 *
93
 * @author David Kaspar
95
 * @author David Kaspar
96
 * @author Benoit Callebaut
94
 */
97
 */
95
// TODO - Should Widget be an abstract class?
98
// TODO - Should Widget be an abstract class?
96
public class Widget implements Accessible {
99
public class Widget implements Accessible, Lookup.Provider {
97
100
98
    static final String MESSAGE_NULL_BOUNDS = "Scene.validate was not called after last change. Widget is not validated. See first Q/A at http://graph.netbeans.org/faq.html page.";
101
    static final String MESSAGE_NULL_BOUNDS = "Scene.validate was not called after last change. Widget is not validated. See first Q/A at http://graph.netbeans.org/faq.html page.";
99
102
Lines 145-150 Link Here
145
148
146
    private Point location;
149
    private Point location;
147
    private Rectangle bounds;
150
    private Rectangle bounds;
151
    private Shape shape;
148
    private Rectangle calculatedPreferredBounds;
152
    private Rectangle calculatedPreferredBounds;
149
153
150
    private boolean requiresFullValidation;
154
    private boolean requiresFullValidation;
Lines 158-183 Link Here
158
     * a property is set by using using resources.  
162
     * a property is set by using using resources.  
159
     */
163
     */
160
    private ResourceTable resourceTable = null;
164
    private ResourceTable resourceTable = null;
165
    protected final Lookup lookup;
166
    private AffineTransform transform = new AffineTransform();
161
    
167
    
162
    /**
168
    /**
163
     * Creates a new widget which will be used in a specified scene.
169
     * Creates a new widget which will be used in a specified scene.
164
     * @param scene the scene where the widget is going to be used
170
     * @param scene the scene where the widget is going to be used
171
     * @since 2.34
165
     */
172
     */
166
    public Widget (Scene scene) {
173
    public Widget (Scene scene, Lookup lookup) {
167
        if (scene == null)
174
        if (scene == null) {
168
            scene = (Scene) this;
175
            scene = (Scene) this;
176
        }
169
        this.scene = scene;
177
        this.scene = scene;
178
        this.lookup = lookup;
170
        children = new ArrayList<Widget> ();
179
        children = new ArrayList<Widget> ();
171
        childrenUm = Collections.unmodifiableList (children);
180
        childrenUm = Collections.unmodifiableList (children);
172
181
173
        actionsChain = new WidgetAction.Chain ();
182
        actionsChain = new WidgetAction.Chain ();
174
183
184
        toolsActions = new HashMap<String, WidgetAction.Chain>();
185
        toolsActions.put(null, actionsChain);
186
187
        for (WidgetAction.ChainProvider provider : lookup.lookupAll(WidgetAction.ChainProvider.class)) {
188
            toolsActions.put(provider.getName(), provider.getChain());
189
        }
175
        opaque = false;
190
        opaque = false;
176
        font = null;
191
        font = null;
177
        background = Color.WHITE;
192
        background = Color.WHITE;
178
        foreground = Color.BLACK;
193
        foreground = Color.BLACK;
194
195
        border = lookup.lookup(Border.class);
196
        if (border == null) {
179
        border = BorderFactory.createEmptyBorder ();
197
        border = BorderFactory.createEmptyBorder ();
198
        }
199
        layout = lookup.lookup(Layout.class);
200
        if (layout == null) {
180
        layout = LayoutFactory.createAbsoluteLayout ();
201
        layout = LayoutFactory.createAbsoluteLayout ();
202
        }
181
        preferredLocation = null;
203
        preferredLocation = null;
182
        preferredBounds = null;
204
        preferredBounds = null;
183
        checkClipping = false;
205
        checkClipping = false;
Lines 191-196 Link Here
191
    }
213
    }
192
214
193
    /**
215
    /**
216
     * Creates a new widget which will be used in a specified scene.
217
     *
218
     * @param scene the scene where the widget is going to be used
219
     */
220
    public Widget(Scene scene) {
221
        this(scene, Lookup.EMPTY);
222
    }
223
224
    /** 
225
     * @since 2.34
226
     */
227
    public Shape getShape() {
228
        shape = getTransform().createTransformedShape (getBounds());
229
        return shape;
230
    }
231
232
    /**
194
     * Returns a scene where the widget is assigned
233
     * Returns a scene where the widget is assigned
195
     * @return the scene
234
     * @return the scene
196
     */
235
     */
Lines 493-500 Link Here
493
     * Returns a lookup of the widget.
532
     * Returns a lookup of the widget.
494
     * @return the lookup
533
     * @return the lookup
495
     */
534
     */
496
    public Lookup getLookup () {
535
    @Override
497
        return Lookup.EMPTY;
536
    public Lookup getLookup() {
537
        return lookup;
498
    }
538
    }
499
539
500
    /**
540
    /**
Lines 840-845 Link Here
840
    }
880
    }
841
    
881
    
842
    /**
882
    /**
883
     * @since 2.34
884
     * @return Widget transform
885
     */
886
    public AffineTransform getTransform() {
887
        return transform;
888
    }
889
890
    /** 
891
     * @since 2.34
892
     */
893
    public void setTransform(AffineTransform transform) {
894
        this.transform = transform;
895
        this.revalidate();
896
    }
897
898
    /**
843
     * Returns the border of the widget.
899
     * Returns the border of the widget.
844
     * @return the border
900
     * @return the border
845
     */
901
     */
Lines 1276-1282 Link Here
1276
     * @return true, if the location belong to the widget
1332
     * @return true, if the location belong to the widget
1277
     */
1333
     */
1278
    public boolean isHitAt (Point localLocation) {
1334
    public boolean isHitAt (Point localLocation) {
1279
        return visible  &&  getBounds ().contains (localLocation);
1335
        return visible  && getShape().contains (localLocation);
1280
    }
1336
    }
1281
1337
1282
    /**
1338
    /**
Lines 1399-1408 Link Here
1399
            return;
1455
            return;
1400
1456
1401
        assert bounds != null : MESSAGE_NULL_BOUNDS; // NOI18N
1457
        assert bounds != null : MESSAGE_NULL_BOUNDS; // NOI18N
1402
        Graphics2D gr = scene.getGraphics ();
1458
        Graphics2D gr = getGraphics ();
1403
1459
1404
        AffineTransform previousTransform = gr.getTransform();
1460
        AffineTransform previousTransform = gr.getTransform();
1405
        gr.translate (location.x, location.y);
1461
        gr.translate (location.x, location.y);
1462
        gr.transform (transform);
1406
1463
1407
        Shape tempClip = null;
1464
        Shape tempClip = null;
1408
        if (checkClipping) {
1465
        if (checkClipping) {
(-)api.visual/src/org/netbeans/modules/visual/graph/layout/HierarchicalLayout.java (-1 / +1 lines)
Lines 659-665 Link Here
659
659
660
        protected void run() {
660
        protected void run() {
661
661
662
            layers = new List[layerCount];
662
            layers = (List<HierarchicalLayout<N,E>.LayoutNode>[])new List[layerCount];
663
663
664
            for (int i = 0; i < layerCount; i++) {
664
            for (int i = 0; i < layerCount; i++) {
665
                layers[i] = new ArrayList<LayoutNode>();
665
                layers[i] = new ArrayList<LayoutNode>();

Return to bug 113456