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

(-)graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java (+1 lines)
Lines 35-40 Link Here
35
        "javaone.demo6.LODDemo",
35
        "javaone.demo6.LODDemo",
36
        "test.action.ActionMapActionTest",
36
        "test.action.ActionMapActionTest",
37
        "test.action.SelectLockedActionTest",
37
        "test.action.SelectLockedActionTest",
38
        "test.alignwith.AlignWithClientAreaTest",
38
        "test.alignwith.AlignWithMoveGuideLinesTest",
39
        "test.alignwith.AlignWithMoveGuideLinesTest",
39
        "test.alignwith.AlignWithTest",
40
        "test.alignwith.AlignWithTest",
40
        "test.alignwith.AlignWithResizeTest",
41
        "test.alignwith.AlignWithResizeTest",
(-)graph/examples/src/test/alignwith/AlignWithClientAreaTest.java (+71 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-2007 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package test.alignwith;
21
22
import org.netbeans.api.visual.action.ActionFactory;
23
import org.netbeans.api.visual.action.WidgetAction;
24
import org.netbeans.api.visual.border.Border;
25
import org.netbeans.api.visual.border.BorderFactory;
26
import org.netbeans.api.visual.widget.LabelWidget;
27
import org.netbeans.api.visual.widget.LayerWidget;
28
import org.netbeans.api.visual.widget.Scene;
29
import test.SceneSupport;
30
31
import java.awt.*;
32
33
/**
34
 * @author David Kaspar
35
 */
36
public class AlignWithClientAreaTest {
37
38
    public static void main (String[] args) {
39
        Scene scene = new Scene ();
40
41
        LayerWidget mainLayer = new LayerWidget (scene);
42
        scene.addChild (mainLayer);
43
        LayerWidget interractionLayer = new LayerWidget (scene);
44
        scene.addChild (interractionLayer);
45
46
        Border resizeBorder = BorderFactory.createResizeBorder (8);
47
        WidgetAction moveAction = ActionFactory.createAlignWithMoveAction (mainLayer, interractionLayer, null, false);
48
        WidgetAction resizeAction = ActionFactory.createAlignWithResizeAction (mainLayer, interractionLayer, null, false);
49
50
        createWidget (mainLayer, 100, 100, "Label 1 - Move, Resize", resizeBorder, resizeAction, moveAction);
51
        createWidget (mainLayer, 200, 150, "Label 2 - Move, Resize", resizeBorder, resizeAction, moveAction);
52
        createWidget (mainLayer, 100, 200, "Label 3 - Move, Resize", resizeBorder, resizeAction, moveAction);
53
54
        SceneSupport.show (scene);
55
    }
56
57
58
    private static void createWidget (LayerWidget mainLayer, int x, int y, String label, Border resizeBorder, WidgetAction resizeAction, WidgetAction moveAction) {
59
        LabelWidget widget = new LabelWidget (mainLayer.getScene (), label);
60
        widget.setAlignment (LabelWidget.Alignment.CENTER);
61
        widget.setVerticalAlignment (LabelWidget.VerticalAlignment.CENTER);
62
        widget.setPreferredLocation (new Point (x, y));
63
        widget.setOpaque (true);
64
        widget.setBackground (Color.YELLOW);
65
        widget.setBorder (resizeBorder);
66
        widget.getActions ().addAction (resizeAction);
67
        widget.getActions ().addAction (moveAction);
68
        mainLayer.addChild (widget);
69
    }
70
71
}
(-)graph/lib/apichanges.xml (+15 lines)
Lines 330-335 Link Here
330
            <class package="org.netbeans.api.visual.vmd" name="VMDColorScheme" link="yes"/>
330
            <class package="org.netbeans.api.visual.vmd" name="VMDColorScheme" link="yes"/>
331
            <issue number="105929"/>
331
            <issue number="105929"/>
332
        </change>
332
        </change>
333
334
        <change>
335
            <api name="general"/>
336
            <summary>Added support to checking AlignWith-actions with client areas</summary>
337
            <version major="2" minor="7"/>
338
            <date day="26" month="7" year="2007"/>
339
            <author login="dkaspar"/>
340
            <compatibility addition="yes"/>
341
            <description>
342
                AlignWithMoveAction and AlignWithResizeAction allow checking client area of widget (widget boundary without border insets).
343
                There are 4 new methods in ActionFactory class introduces to allow specifying outerBounds parameter.
344
            </description>
345
            <class package="org.netbeans.api.visual.action" name="ActionFactory" link="yes"/>
346
            <issue number="105285"/>
347
        </change>
333
    </changes>
348
    </changes>
334
349
335
    <htmlcontents>
350
    <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.5
4
OpenIDE-Module-Specification-Version: 2.7
(-)graph/lib/src/org/netbeans/api/visual/action/ActionFactory.java (-4 / +60 lines)
Lines 191-198 Link Here
191
     * @return the align-with move action
191
     * @return the align-with move action
192
     */
192
     */
193
    public static WidgetAction createAlignWithMoveAction (LayerWidget collectionLayer, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
193
    public static WidgetAction createAlignWithMoveAction (LayerWidget collectionLayer, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
194
        return createAlignWithMoveAction (collectionLayer, interractionLayer, decorator, true);
195
    }
196
197
    /**
198
     * Creates a align-with move action.
199
     * @param collectionLayer the layer with objects that the alignment is checked against.
200
     * @param interractionLayer the interraction layer where the align-with hint lines are placed
201
     * @param decorator the align-with move decorator
202
     * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
203
     *      if false, then the align-with is check against client area (widget bounds without border insets
204
     * @return the align-with move action
205
     * @since 2.7
206
     */
207
    public static WidgetAction createAlignWithMoveAction (LayerWidget collectionLayer, LayerWidget interractionLayer, AlignWithMoveDecorator decorator, boolean outerBounds) {
194
        assert collectionLayer != null;
208
        assert collectionLayer != null;
195
        return createAlignWithMoveAction (new SingleLayerAlignWithWidgetCollector (collectionLayer), interractionLayer, decorator != null ? decorator : ALIGN_WITH_MOVE_DECORATOR_DEFAULT);
209
        return createAlignWithMoveAction (new SingleLayerAlignWithWidgetCollector (collectionLayer, outerBounds), interractionLayer, decorator != null ? decorator : ALIGN_WITH_MOVE_DECORATOR_DEFAULT, outerBounds);
196
    }
210
    }
197
211
198
    /**
212
    /**
Lines 203-210 Link Here
203
     * @return the align-with move action
217
     * @return the align-with move action
204
     */
218
     */
205
    public static WidgetAction createAlignWithMoveAction (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
219
    public static WidgetAction createAlignWithMoveAction (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
220
        return createAlignWithMoveAction (collector, interractionLayer, decorator, true);
221
    }
222
223
    /**
224
     * Creates a align-with move action.
225
     * @param collector the collector of objects that the alignment is checked against.
226
     * @param interractionLayer the interraction layer where the align-with hint lines are placed
227
     * @param decorator the align-with move decorator
228
     * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
229
     *      if false, then the align-with is check against client area (widget bounds without border insets
230
     * @return the align-with move action
231
     * @since 2.7
232
     */
233
    public static WidgetAction createAlignWithMoveAction (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator, boolean outerBounds) {
206
        assert collector != null  &&  interractionLayer != null  &&  decorator != null;
234
        assert collector != null  &&  interractionLayer != null  &&  decorator != null;
207
        AlignWithMoveStrategyProvider sp = new AlignWithMoveStrategyProvider (collector, interractionLayer, decorator);
235
        AlignWithMoveStrategyProvider sp = new AlignWithMoveStrategyProvider (collector, interractionLayer, decorator, outerBounds);
208
        return createMoveAction (sp, sp);
236
        return createMoveAction (sp, sp);
209
    }
237
    }
210
238
Lines 216-223 Link Here
216
     * @return the align-with resize action
244
     * @return the align-with resize action
217
     */
245
     */
218
    public static WidgetAction createAlignWithResizeAction (LayerWidget collectionLayer, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
246
    public static WidgetAction createAlignWithResizeAction (LayerWidget collectionLayer, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
247
        return createAlignWithResizeAction (collectionLayer, interractionLayer, decorator, true);
248
    }
249
250
    /**
251
     * Creates a align-with resize action.
252
     * @param collectionLayer the layer with objects that the alignment is checked against.
253
     * @param interractionLayer the interraction layer where the align-with hint lines are placed
254
     * @param decorator the align-with move decorator
255
     * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
256
     *      if false, then the align-with is check against client area (widget bounds without border insets
257
     * @return the align-with resize action
258
     * @since 2.7
259
     */
260
    public static WidgetAction createAlignWithResizeAction (LayerWidget collectionLayer, LayerWidget interractionLayer, AlignWithMoveDecorator decorator, boolean outerBounds) {
219
        assert collectionLayer != null;
261
        assert collectionLayer != null;
220
        return createAlignWithResizeAction (new SingleLayerAlignWithWidgetCollector (collectionLayer), interractionLayer, decorator != null ? decorator : ALIGN_WITH_MOVE_DECORATOR_DEFAULT);
262
        return createAlignWithResizeAction (new SingleLayerAlignWithWidgetCollector (collectionLayer, outerBounds), interractionLayer, decorator != null ? decorator : ALIGN_WITH_MOVE_DECORATOR_DEFAULT, outerBounds);
221
    }
263
    }
222
264
223
    /**
265
    /**
Lines 228-235 Link Here
228
     * @return the align-with resize action
270
     * @return the align-with resize action
229
     */
271
     */
230
    public static WidgetAction createAlignWithResizeAction (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
272
    public static WidgetAction createAlignWithResizeAction (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
273
        return createAlignWithResizeAction (collector, interractionLayer, decorator, true);
274
    }
275
276
    /**
277
     * Creates a align-with resize action.
278
     * @param collector the collector of objects that the alignment is checked against.
279
     * @param interractionLayer the interraction layer where the align-with hint lines are placed
280
     * @param decorator the align-with move decorator
281
     * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
282
     *      if false, then the align-with is check against client area (widget bounds without border insets
283
     * @return the align-with resize action
284
     * @since 2.7
285
     */
286
    public static WidgetAction createAlignWithResizeAction (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator, boolean outerBounds) {
231
        assert collector != null && interractionLayer != null && decorator != null;
287
        assert collector != null && interractionLayer != null && decorator != null;
232
        AlignWithResizeStrategyProvider sp = new AlignWithResizeStrategyProvider (collector, interractionLayer, decorator);
288
        AlignWithResizeStrategyProvider sp = new AlignWithResizeStrategyProvider (collector, interractionLayer, decorator, outerBounds);
233
        return createResizeAction (sp, sp);
289
        return createResizeAction (sp, sp);
234
    }
290
    }
235
291
(-)graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html (+6 lines)
Lines 858-863 Link Here
858
<p>
858
<p>
859
The action is similar to MoveAction but it allows snapping feature similar to <strong>Form Editor</strong> module. The <code>AlignWithMoveDecorator</code> supplies a graphic for snapping lines and the <code>AlignWithWidgetCollector</code> gathers all widgets that the snapping has to be checked against.
859
The action is similar to MoveAction but it allows snapping feature similar to <strong>Form Editor</strong> module. The <code>AlignWithMoveDecorator</code> supplies a graphic for snapping lines and the <code>AlignWithWidgetCollector</code> gathers all widgets that the snapping has to be checked against.
860
860
861
<p>
862
The outerBounds boolean parameter allows to specify whether client area or bounds of widgets is going to be checked.
863
861
<h3><a name="AlignWithResizeAction">AlignWithResizeAction</a></h3>
864
<h3><a name="AlignWithResizeAction">AlignWithResizeAction</a></h3>
862
865
863
<p>
866
<p>
Lines 865-870 Link Here
865
868
866
<p>
869
<p>
867
The action is similar to <code>ResizeAction</code> but it allows snapping feature similar to <strong>Form Editor</strong> module. The <code>AlignWithMoveDecorator</code> supplies a graphic for snapping lines and the <code>AlignWithWidgetCollector</code> gathers all widgets that the snapping has to be checked against.
870
The action is similar to <code>ResizeAction</code> but it allows snapping feature similar to <strong>Form Editor</strong> module. The <code>AlignWithMoveDecorator</code> supplies a graphic for snapping lines and the <code>AlignWithWidgetCollector</code> gathers all widgets that the snapping has to be checked against.
871
872
<p>
873
The outerBounds boolean parameter allows to specify whether client area or bounds of widgets is going to be checked.
868
874
869
<h3><a name="CycleFocusAction">CycleFocusAction</a></h3>
875
<h3><a name="CycleFocusAction">CycleFocusAction</a></h3>
870
876
(-)graph/lib/src/org/netbeans/modules/visual/action/AlignWithMoveStrategyProvider.java (-2 / +14 lines)
Lines 29-44 Link Here
29
 */
29
 */
30
public final class AlignWithMoveStrategyProvider extends AlignWithSupport implements MoveStrategy, MoveProvider {
30
public final class AlignWithMoveStrategyProvider extends AlignWithSupport implements MoveStrategy, MoveProvider {
31
31
32
    public AlignWithMoveStrategyProvider (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
32
    private boolean outerBounds;
33
34
    public AlignWithMoveStrategyProvider (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator, boolean outerBounds) {
33
        super (collector, interractionLayer, decorator);
35
        super (collector, interractionLayer, decorator);
36
        this.outerBounds = outerBounds;
34
    }
37
    }
35
38
36
    public Point locationSuggested (Widget widget, Point originalLocation, Point suggestedLocation) {
39
    public Point locationSuggested (Widget widget, Point originalLocation, Point suggestedLocation) {
37
        Point widgetLocation = widget.getLocation ();
40
        Point widgetLocation = widget.getLocation ();
38
        Rectangle widgetBounds = widget.getBounds ();
41
        Rectangle widgetBounds = outerBounds ? widget.getBounds () : widget.getClientArea ();
39
        Rectangle bounds = widget.convertLocalToScene (widgetBounds);
42
        Rectangle bounds = widget.convertLocalToScene (widgetBounds);
40
        bounds.translate (suggestedLocation.x - widgetLocation.x, suggestedLocation.y - widgetLocation.y);
43
        bounds.translate (suggestedLocation.x - widgetLocation.x, suggestedLocation.y - widgetLocation.y);
44
        Insets insets = widget.getBorder ().getInsets ();
45
        if (! outerBounds) {
46
            suggestedLocation.x += insets.left;
47
            suggestedLocation.y += insets.top;
48
        }
41
        Point point = super.locationSuggested (widget, bounds, suggestedLocation, true, true, true, true);
49
        Point point = super.locationSuggested (widget, bounds, suggestedLocation, true, true, true, true);
50
        if (! outerBounds) {
51
            point.x -= insets.left;
52
            point.y -= insets.top;
53
        }
42
        return widget.getParentWidget ().convertSceneToLocal (point);
54
        return widget.getParentWidget ().convertSceneToLocal (point);
43
    }
55
    }
44
56
(-)graph/lib/src/org/netbeans/modules/visual/action/AlignWithResizeStrategyProvider.java (-1 / +60 lines)
Lines 32-39 Link Here
32
 */
32
 */
33
public final class AlignWithResizeStrategyProvider extends AlignWithSupport implements ResizeStrategy, ResizeProvider {
33
public final class AlignWithResizeStrategyProvider extends AlignWithSupport implements ResizeStrategy, ResizeProvider {
34
34
35
    public AlignWithResizeStrategyProvider (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) {
35
    private boolean outerBounds;
36
37
    public AlignWithResizeStrategyProvider (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator, boolean outerBounds) {
36
        super (collector, interractionLayer, decorator);
38
        super (collector, interractionLayer, decorator);
39
        this.outerBounds = outerBounds;
37
    }
40
    }
38
41
39
    public Rectangle boundsSuggested (Widget widget, Rectangle originalBounds, Rectangle suggestedBounds, ControlPoint controlPoint) {
42
    public Rectangle boundsSuggested (Widget widget, Rectangle originalBounds, Rectangle suggestedBounds, ControlPoint controlPoint) {
Lines 49-64 Link Here
49
        switch (controlPoint) {
52
        switch (controlPoint) {
50
            case BOTTOM_CENTER:
53
            case BOTTOM_CENTER:
51
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y + suggestedBounds.height);
54
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y + suggestedBounds.height);
55
                if (! outerBounds)
56
                    suggestedLocation.y -= insets.bottom;
52
57
53
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false);
58
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false);
54
59
60
                if (! outerBounds)
61
                    point.y += insets.bottom;
62
55
                suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y);
63
                suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y);
56
                break;
64
                break;
57
            case BOTTOM_LEFT:
65
            case BOTTOM_LEFT:
58
                suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height);
66
                suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height);
67
                if (! outerBounds) {
68
                    suggestedLocation.y -= insets.bottom;
69
                    suggestedLocation.x += insets.left;
70
                }
59
71
60
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
72
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
61
73
74
                if (! outerBounds) {
75
                    point.y += insets.bottom;
76
                    point.x -= insets.left;
77
                }
78
62
                suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y);
79
                suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y);
63
80
64
                tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx);
81
                tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx);
Lines 67-109 Link Here
67
                break;
84
                break;
68
            case BOTTOM_RIGHT:
85
            case BOTTOM_RIGHT:
69
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height);
86
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height);
87
                if (! outerBounds) {
88
                    suggestedLocation.y -= insets.bottom;
89
                    suggestedLocation.x -= insets.right;
90
                }
70
91
71
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
92
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
72
93
94
                if (! outerBounds) {
95
                    point.y += insets.bottom;
96
                    point.x += insets.right;
97
                }
98
73
                suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y);
99
                suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y);
74
100
75
                suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x);
101
                suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x);
76
                break;
102
                break;
77
            case CENTER_LEFT:
103
            case CENTER_LEFT:
78
                suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height / 2);
104
                suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height / 2);
105
                if (! outerBounds)
106
                    suggestedLocation.x += insets.left;
79
107
80
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false);
108
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false);
81
109
110
                if (! outerBounds)
111
                    point.x -= insets.left;
112
                
82
                tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx);
113
                tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx);
83
                suggestedBounds.width = suggestedBounds.x + suggestedBounds.width - tempx;
114
                suggestedBounds.width = suggestedBounds.x + suggestedBounds.width - tempx;
84
                suggestedBounds.x = tempx;
115
                suggestedBounds.x = tempx;
85
                break;
116
                break;
86
            case CENTER_RIGHT:
117
            case CENTER_RIGHT:
87
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height / 2);
118
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height / 2);
119
                if (! outerBounds)
120
                    suggestedLocation.x -= insets.right;
88
121
89
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false);
122
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false);
90
123
124
                if (! outerBounds)
125
                    point.x += insets.right;
126
                
91
                suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x);
127
                suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x);
92
                break;
128
                break;
93
            case TOP_CENTER:
129
            case TOP_CENTER:
94
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y);
130
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y);
131
                if (! outerBounds)
132
                    suggestedLocation.y += insets.top;
95
133
96
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false);
134
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false);
97
135
136
                if (! outerBounds)
137
                    point.y -= insets.top;
138
98
                tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny);
139
                tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny);
99
                suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy;
140
                suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy;
100
                suggestedBounds.y = tempy;
141
                suggestedBounds.y = tempy;
101
                break;
142
                break;
102
            case TOP_LEFT:
143
            case TOP_LEFT:
103
                suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y);
144
                suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y);
145
                if (! outerBounds) {
146
                    suggestedLocation.y += insets.top;
147
                    suggestedLocation.x += insets.left;
148
                }
104
149
105
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
150
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
106
151
152
                if (! outerBounds) {
153
                    point.y -= insets.top;
154
                    point.x -= insets.left;
155
                }
156
107
                tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny);
157
                tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny);
108
                suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy;
158
                suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy;
109
                suggestedBounds.y = tempy;
159
                suggestedBounds.y = tempy;
Lines 114-121 Link Here
114
                break;
164
                break;
115
            case TOP_RIGHT:
165
            case TOP_RIGHT:
116
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y);
166
                suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y);
167
                if (! outerBounds) {
168
                    suggestedLocation.y += insets.top;
169
                    suggestedLocation.x -= insets.right;
170
                }
117
171
118
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
172
                point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false);
173
174
                if (! outerBounds) {
175
                    point.y -= insets.top;
176
                    point.x += insets.right;
177
                }
119
178
120
                tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny);
179
                tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny);
121
                suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy;
180
                suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy;
(-)graph/lib/src/org/netbeans/modules/visual/action/SingleLayerAlignWithWidgetCollector.java (-2 / +4 lines)
Lines 31-39 Link Here
31
public final class SingleLayerAlignWithWidgetCollector implements AlignWithWidgetCollector {
31
public final class SingleLayerAlignWithWidgetCollector implements AlignWithWidgetCollector {
32
32
33
    private LayerWidget collectionLayer;
33
    private LayerWidget collectionLayer;
34
    private boolean outerBounds;
34
35
35
    public SingleLayerAlignWithWidgetCollector (LayerWidget collectionLayer) {
36
    public SingleLayerAlignWithWidgetCollector (LayerWidget collectionLayer, boolean outerBounds) {
36
        this.collectionLayer = collectionLayer;
37
        this.collectionLayer = collectionLayer;
38
        this.outerBounds = outerBounds;
37
    }
39
    }
38
40
39
    public java.util.List<Rectangle> getRegions (Widget movingWidget) {
41
    public java.util.List<Rectangle> getRegions (Widget movingWidget) {
Lines 41-47 Link Here
41
        ArrayList<Rectangle> regions = new ArrayList<Rectangle> (children.size ());
43
        ArrayList<Rectangle> regions = new ArrayList<Rectangle> (children.size ());
42
        for (Widget widget : children)
44
        for (Widget widget : children)
43
            if (widget != movingWidget)
45
            if (widget != movingWidget)
44
                regions.add (widget.convertLocalToScene (widget.getBounds ()));
46
                regions.add (widget.convertLocalToScene (outerBounds ? widget.getBounds () : widget.getClientArea ()));
45
        return regions;
47
        return regions;
46
    }
48
    }
47
49
(-)graph/www/documentation.html (+1 lines)
Lines 106-111 Link Here
106
<li><strong>javaone.demo6.LODDemo</strong> - how to use <code>LevelOfDetailsWidget</code>. Zoom-in to see more.
106
<li><strong>javaone.demo6.LODDemo</strong> - how to use <code>LevelOfDetailsWidget</code>. Zoom-in to see more.
107
<li><strong>test.action.ActionMapActionTest</strong> - how to use <code>ActionMapAction</code>
107
<li><strong>test.action.ActionMapActionTest</strong> - how to use <code>ActionMapAction</code>
108
<li><strong>test.action.SelectLockedActionTest</strong> - example of proper cooperation of select (which opens another Swing windows) and locking action
108
<li><strong>test.action.SelectLockedActionTest</strong> - example of proper cooperation of select (which opens another Swing windows) and locking action
109
<li><strong>test.alignwith.AlignWithClientAreaTest</strong> - test of #105285 - align-with action with checking client area of widgets only
109
<li><strong>test.alignwith.AlignWithMoveGuideLinesTest</strong> - test of #97034 - incorrectly painted guide-lines for <code>MoveAlignWithAction</code>
110
<li><strong>test.alignwith.AlignWithMoveGuideLinesTest</strong> - test of #97034 - incorrectly painted guide-lines for <code>MoveAlignWithAction</code>
110
<li><strong>test.alignwith.AlignWithTest</strong> - how to use <code>MoveAlignWithAction</code>
111
<li><strong>test.alignwith.AlignWithTest</strong> - how to use <code>MoveAlignWithAction</code>
111
<li><strong>test.alignwith.AlignWithResizeTest</strong> - how to use <code>AlignWithMoveAction</code> and <code>AlignWithResizeAction</code>
112
<li><strong>test.alignwith.AlignWithResizeTest</strong> - how to use <code>AlignWithMoveAction</code> and <code>AlignWithResizeAction</code>

Return to bug 105285