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

(-)graph/examples/src/org/netbeans/modules/visual/examples/RunDialog.java (+1 lines)
Lines 44-49 Link Here
44
        "test.anchor.InvalidAnchorNegativeTest",
44
        "test.anchor.InvalidAnchorNegativeTest",
45
        "test.animator.AnimatorTest",
45
        "test.animator.AnimatorTest",
46
        "test.animator.ColorAnimatorTest",
46
        "test.animator.ColorAnimatorTest",
47
        "test.bird.BirdViewTest",
47
        "test.card.CardContainerWidget",
48
        "test.card.CardContainerWidget",
48
        "test.component.ComponentTest",
49
        "test.component.ComponentTest",
49
        "test.component.ComponentModeTest",
50
        "test.component.ComponentModeTest",
(-)graph/examples/src/test/SceneSupport.java (+8 lines)
Lines 67-70 Link Here
67
        }, delay);
67
        }, delay);
68
    }
68
    }
69
69
70
    public static void sleep (int delay) {
71
        try {
72
            Thread.sleep (delay);
73
        } catch (InterruptedException e) {
74
            e.printStackTrace ();
75
        }
76
    }
77
70
}
78
}
(-)graph/examples/src/test/bird/BirdViewTest.java (+56 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.bird;
21
22
import org.netbeans.api.visual.widget.BirdViewController;
23
import test.SceneSupport;
24
import test.general.StringGraphScene;
25
26
import java.awt.*;
27
28
/**
29
 * @author David Kaspar
30
 */
31
public class BirdViewTest {
32
33
    public static void main (String[] args) {
34
        StringGraphScene scene = new StringGraphScene ();
35
        for (int a = 0; a < 100; a ++)
36
            scene.addNode ("node" + String.valueOf (a)).setPreferredLocation (new Point (SceneSupport.randInt (1000), SceneSupport.randInt (1000)));
37
38
        BirdViewController birdViewController = scene.createBirdView ();
39
40
        scene.createView (); // main view has to be created before showing the bird view
41
        birdViewController.show ();
42
43
        SceneSupport.show (scene);
44
45
        SceneSupport.sleep (2000);
46
        birdViewController.setZoomFactor (5.0);
47
        birdViewController.setWindowSize (new Dimension (400, 400));
48
49
        SceneSupport.sleep (2000);
50
        birdViewController.hide ();
51
52
        SceneSupport.sleep (2000);
53
        birdViewController.show ();
54
    }
55
56
}
(-)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>Bird view support added</summary>
337
            <version major="2" minor="7"/>
338
            <date day="27" month="7" year="2007"/>
339
            <author login="dkaspar"/>
340
            <compatibility addition="yes"/>
341
            <description>
342
                Bird view is a window that is always under your mouse-cursor and shows the scene with a specified zoom factor.
343
                A bird view can be created using Scene.createBirdView method. To enable bird view you need to call the show method on returned controller instance.
344
            </description>
345
            <class package="org.netbeans.api.visual.widget" name="Scene" link="yes"/>
346
            <issue number="108510"/>
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/widget/BirdViewController.java (+84 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 org.netbeans.api.visual.widget;
21
22
import org.netbeans.modules.visual.widget.BirdViewWindow;
23
24
import java.awt.*;
25
26
/**
27
 * This class controls a bird view created for a specific scene. The bird is tracking mouse-cursor over the main scene view.
28
 * You can specify a separate zoom-factor and you can enable and disable it by calling <code>show</code> and <code>hide</code> methods.
29
 * <p>
30
 * When a bird view is enabled then it consumes all events of a main scene view therefore you cannot do anything except
31
 * watch the scene with bird view.
32
 *
33
 * @since 2.7
34
 * @author David Kaspar
35
 */
36
public final class BirdViewController {
37
38
    private BirdViewWindow birdView;
39
40
    BirdViewController (Scene scene) {
41
        birdView = new BirdViewWindow (scene);
42
    }
43
44
    /**
45
     * Sets a zoom factor of the bird view.
46
     * @param zoomFactor the zoom factor
47
     * @since 2.7
48
     */
49
    public void setZoomFactor (double zoomFactor) {
50
        birdView.setZoomFactor (zoomFactor);
51
    }
52
53
    /**
54
     * Sets a size of the bird view window.
55
     * @param size the window size
56
     * @since 2.7
57
     */
58
    public void setWindowSize (Dimension size) {
59
        birdView.setWindowSize (size);
60
    }
61
62
    /**
63
     * Enables the bird view. It means that the bird view window will be visible while a mouse cursor is over the visible
64
     * area of the main scene view.
65
     * <p>
66
     * Note: Has to be invoked after <code>Scene.createView</code> method.
67
     * <p>
68
     * Note: An user has to initially move cursor over the visible area of the main scene view
69
     * to show the window up for the first time after the method call.
70
     * @since 2.7
71
     */
72
    public void show () {
73
        birdView.invokeShow ();
74
    }
75
76
    /**
77
     * Disables the bird view. It means the bird view window is hidden and the main scene view is not blocked for events.
78
     * @since 2.7
79
     */
80
    public void hide () {
81
        birdView.invokeHide ();
82
    }
83
84
}
(-)graph/lib/src/org/netbeans/api/visual/widget/Scene.java (-2 / +11 lines)
Lines 22-29 Link Here
22
import org.netbeans.api.visual.action.TwoStateHoverProvider;
22
import org.netbeans.api.visual.action.TwoStateHoverProvider;
23
import org.netbeans.api.visual.action.WidgetAction;
23
import org.netbeans.api.visual.action.WidgetAction;
24
import org.netbeans.api.visual.animator.SceneAnimator;
24
import org.netbeans.api.visual.animator.SceneAnimator;
25
import org.netbeans.api.visual.laf.LookFeel;
26
import org.netbeans.api.visual.laf.InputBindings;
25
import org.netbeans.api.visual.laf.InputBindings;
26
import org.netbeans.api.visual.laf.LookFeel;
27
import org.netbeans.modules.visual.util.GeomUtil;
27
import org.netbeans.modules.visual.util.GeomUtil;
28
import org.netbeans.modules.visual.widget.SatelliteComponent;
28
import org.netbeans.modules.visual.widget.SatelliteComponent;
29
29
Lines 126-137 Link Here
126
        return component;
126
        return component;
127
    }
127
    }
128
128
129
    /**
129
        /**
130
     * Creates a satellite view.
130
     * Creates a satellite view.
131
     * @return the satellite view
131
     * @return the satellite view
132
     */
132
     */
133
    public JComponent createSatelliteView () {
133
    public JComponent createSatelliteView () {
134
        return new SatelliteComponent (this);
134
        return new SatelliteComponent (this);
135
    }
136
137
    /**
138
     * Creates a bird view with specific zoom factor.
139
     * @return the bird view controller
140
     * @since 2.7
141
     */
142
    public BirdViewController createBirdView () {
143
        return new BirdViewController (this);
135
    }
144
    }
136
145
137
    void setViewShowing (boolean viewShowing) {
146
    void setViewShowing (boolean viewShowing) {
(-)graph/lib/src/org/netbeans/api/visual/widget/doc-files/documentation.html (+3 lines)
Lines 509-514 Link Here
509
<td>createSatelliteView
509
<td>createSatelliteView
510
<td>Creates a satellite view of the scene. It is showing an overview of the scene. In case the JComponent view is placed in a JScrollPane and the scene does not fit into the panel, then the satellite view paints an viewport rectangle which representing visible area. It also allows user to move with the actual viewport of the scene.
510
<td>Creates a satellite view of the scene. It is showing an overview of the scene. In case the JComponent view is placed in a JScrollPane and the scene does not fit into the panel, then the satellite view paints an viewport rectangle which representing visible area. It also allows user to move with the actual viewport of the scene.
511
<tr>
511
<tr>
512
<td>createBirdView
513
<td>Creates a bird view of the scene. It is enough to create one bird view and reuse it all the time. The bird view is tracking mouse cursor and when the cursor is over visible area of the scene view, then an additional always-on-top window is shown and shows pointed part of the scene with specified zoom factor. The method returns <code>BirdViewController</code> which allows control over the bird view. When the bird view is enabled, then it consumes all events of the scene view.
514
<tr>
512
<td>getGraphics
515
<td>getGraphics
513
<td>Returns an instance of <code>Graphics2D</code> used by whole scene. The instance is the one that was available during the last JComponent.addNotify or JComponent.paint method call on the JComponent view.
516
<td>Returns an instance of <code>Graphics2D</code> used by whole scene. The instance is the one that was available during the last JComponent.addNotify or JComponent.paint method call on the JComponent view.
514
<tr>
517
<tr>
(-)graph/lib/src/org/netbeans/modules/visual/widget/BirdViewWindow.java (+259 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 org.netbeans.modules.visual.widget;
21
22
import org.netbeans.api.visual.action.WidgetAction;
23
import org.netbeans.api.visual.widget.Scene;
24
import org.netbeans.api.visual.widget.Widget;
25
26
import javax.swing.*;
27
import javax.swing.border.BevelBorder;
28
import javax.swing.border.CompoundBorder;
29
import javax.swing.border.EmptyBorder;
30
import javax.swing.border.LineBorder;
31
import javax.swing.event.AncestorEvent;
32
import javax.swing.event.AncestorListener;
33
import java.awt.*;
34
import java.awt.event.MouseEvent;
35
import java.awt.event.MouseMotionListener;
36
import java.awt.geom.AffineTransform;
37
38
/**
39
 * @author David Kaspar
40
 */
41
public class BirdViewWindow extends JWindow implements MouseMotionListener {
42
43
    private Scene scene;
44
    private BirdViewComponent birdView;
45
46
    private boolean shown = false;
47
    private double zoomFactor = 3.0;
48
    private Point scenePoint;
49
50
    private WidgetAction action = new SceneTrackAction ();
51
    private ViewAncestorListener ancestorListener = new ViewAncestorListener ();
52
53
    public BirdViewWindow (final Scene scene) {
54
        this.scene = scene;
55
        setSize (new Dimension (256, 256));
56
        setLayout (new BorderLayout ());
57
        setAlwaysOnTop (true);
58
59
        JPanel pane = new JPanel ();
60
        pane.setBorder (new CompoundBorder (new LineBorder (Color.BLACK, 1), new EmptyBorder (1, 1, 1, 1)));
61
        pane.setLayout (new BorderLayout ());
62
        add (pane, BorderLayout.CENTER);
63
64
        birdView = new BirdViewComponent ();
65
        birdView.setDoubleBuffered (true);
66
        birdView.setBorder (new BevelBorder (BevelBorder.RAISED));
67
        pane.add (birdView, BorderLayout.CENTER);
68
    }
69
70
    public void invokeShow () {
71
        if (scene.getView () == null)
72
            return;
73
        if (shown)
74
            return;
75
        shown = true;
76
        birdView.addMouseMotionListener (this);
77
        scene.getPriorActions ().addAction (action);
78
        scene.getView ().addAncestorListener (ancestorListener);
79
        updateForViewPoint (null);
80
    }
81
82
    public void invokeHide () {
83
        if (! shown)
84
            return;
85
        shown = false;
86
        birdView.removeMouseMotionListener (this);
87
        scene.getPriorActions ().removeAction (action);
88
        scene.getView ().removeAncestorListener (ancestorListener);
89
        updateForViewPoint (null);
90
    }
91
92
    public void invokeRepaint () {
93
        birdView.repaint ();
94
    }
95
96
    public void setZoomFactor (double zoomFactor) {
97
        this.zoomFactor = zoomFactor;
98
        invokeRepaint ();
99
    }
100
101
    public void setWindowSize (Dimension size) {
102
        Dimension previousSize = getSize ();
103
        setSize (size);
104
        if (isShowing ()) {
105
            Point location = getLocation ();
106
            setLocation (location.x + (previousSize.width - size.width) / 2, location.y + (previousSize.height - size.height) / 2);
107
            validate ();
108
        }
109
    }
110
111
    private void updateForViewPoint (Point viewPoint) {
112
        JComponent view = scene.getView ();
113
        if (! shown  ||  viewPoint == null  ||  ! view.getVisibleRect ().contains (viewPoint)) {
114
            scenePoint = null;
115
            setVisible (false);
116
            dispose ();
117
            return;
118
        }
119
        scenePoint = scene.convertViewToScene (viewPoint);
120
        Point viewOrigin = view.getLocationOnScreen ();
121
        Dimension size = getSize ();
122
        setBounds (viewOrigin.x + viewPoint.x - size.width / 2, viewOrigin.y + viewPoint.y - size.height / 2, size.width, size.height);
123
        setVisible (true);
124
        birdView.repaint();
125
    }
126
127
    private void updateForBirdViewPoint (Point birdViewPoint) {
128
        JComponent view = scene.getView ();
129
        if (view.isShowing ()  &&  isShowing ()) {
130
            Point viewOrigin = view.getLocationOnScreen ();
131
            Point birdViewOrigin = getLocationOnScreen ();
132
            Dimension size = getSize ();
133
            updateForViewPoint (new Point (birdViewPoint.x + birdViewOrigin.x - viewOrigin.x, birdViewPoint.y + birdViewOrigin.y - viewOrigin.y));
134
        } else
135
            updateForViewPoint (null);
136
    }
137
138
    public void mouseDragged (MouseEvent e) {
139
        updateForBirdViewPoint (e.getPoint ());
140
    }
141
142
    public void mouseMoved (MouseEvent e) {
143
        updateForBirdViewPoint (e.getPoint ());
144
    }
145
146
    private class SceneTrackAction implements WidgetAction {
147
148
        public State mouseClicked (Widget widget, WidgetMouseEvent event) {
149
            return State.CONSUMED;
150
        }
151
152
        public State mousePressed (Widget widget, WidgetMouseEvent event) {
153
            return State.CONSUMED;
154
        }
155
156
        public State mouseReleased (Widget widget, WidgetMouseEvent event) {
157
            return State.CONSUMED;
158
        }
159
160
        public State mouseEntered (Widget widget, WidgetMouseEvent event) {
161
            return State.CONSUMED;
162
        }
163
164
        public State mouseExited (Widget widget, WidgetMouseEvent event) {
165
            return State.CONSUMED;
166
        }
167
168
        public State mouseDragged (Widget widget, WidgetMouseEvent event) {
169
            updateForViewPoint (widget.getScene ().convertSceneToView (widget.convertLocalToScene (event.getPoint ())));
170
            return State.CONSUMED;
171
        }
172
173
        public State mouseMoved (Widget widget, WidgetMouseEvent event) {
174
            updateForViewPoint (widget.getScene ().convertSceneToView (widget.convertLocalToScene (event.getPoint ())));
175
            return State.CONSUMED;
176
        }
177
178
        public State mouseWheelMoved (Widget widget, WidgetMouseWheelEvent event) {
179
            return State.CONSUMED;
180
        }
181
182
        public State keyTyped (Widget widget, WidgetKeyEvent event) {
183
            return State.CONSUMED;
184
        }
185
186
        public State keyPressed (Widget widget, WidgetKeyEvent event) {
187
            return State.CONSUMED;
188
        }
189
190
        public State keyReleased (Widget widget, WidgetKeyEvent event) {
191
            return State.CONSUMED;
192
        }
193
194
        public State focusGained (Widget widget, WidgetFocusEvent event) {
195
            return State.CONSUMED;
196
        }
197
198
        public State focusLost (Widget widget, WidgetFocusEvent event) {
199
            return State.CONSUMED;
200
        }
201
202
        public State dragEnter (Widget widget, WidgetDropTargetDragEvent event) {
203
            return State.CONSUMED;
204
        }
205
206
        public State dragOver (Widget widget, WidgetDropTargetDragEvent event) {
207
            return State.CONSUMED;
208
        }
209
210
        public State dropActionChanged (Widget widget, WidgetDropTargetDragEvent event) {
211
            return State.CONSUMED;
212
        }
213
214
        public State dragExit (Widget widget, WidgetDropTargetEvent event) {
215
            return State.CONSUMED;
216
        }
217
218
        public State drop (Widget widget, WidgetDropTargetDropEvent event) {
219
            return State.CONSUMED;
220
        }
221
222
    }
223
224
    private class BirdViewComponent extends JComponent {
225
226
        public void paint (Graphics g) {
227
            Graphics2D gr = (Graphics2D) g;
228
            super.paint (g);
229
            if (scenePoint == null) {
230
                gr.setColor (Color.BLACK);
231
                gr.fill (getBounds ());
232
                return;
233
            }
234
            Dimension size = getSize ();
235
            AffineTransform previousTransform = gr.getTransform ();
236
            gr.translate (size.width / 2, size.height / 2);
237
            gr.scale (zoomFactor, zoomFactor);
238
            gr.translate (- scenePoint.x, - scenePoint.y);
239
            scene.paint (gr);
240
            gr.setTransform (previousTransform);
241
        }
242
243
    }
244
245
    private class ViewAncestorListener implements AncestorListener {
246
247
        public void ancestorAdded (AncestorEvent event) {
248
        }
249
250
        public void ancestorRemoved (AncestorEvent event) {
251
            invokeHide ();
252
        }
253
254
        public void ancestorMoved (AncestorEvent event) {
255
        }
256
257
    }
258
259
}
(-)graph/www/documentation.html (+1 lines)
Lines 115-120 Link Here
115
<li><strong>test.anchor.InvalidAnchorNegativeTest</strong> - negative test of invalid anchor (its related widget is not added into scene)
115
<li><strong>test.anchor.InvalidAnchorNegativeTest</strong> - negative test of invalid anchor (its related widget is not added into scene)
116
<li><strong>test.animator.AnimatorTest</strong> - how to use preferred-location animator
116
<li><strong>test.animator.AnimatorTest</strong> - how to use preferred-location animator
117
<li><strong>test.animator.ColorAnimatorTest</strong> - how to use background/foreground animator
117
<li><strong>test.animator.ColorAnimatorTest</strong> - how to use background/foreground animator
118
<li><strong>test.bird.BirdViewTest</strong> - how to use bird view
118
<li><strong>test.card.CardContainerWidget</strong> - how to use <code>CardLayout</code>
119
<li><strong>test.card.CardContainerWidget</strong> - how to use <code>CardLayout</code>
119
<li><strong>test.component.ComponentTest</strong> - shows AWT/Swing integration
120
<li><strong>test.component.ComponentTest</strong> - shows AWT/Swing integration
120
<li><strong>test.component.ComponentModeTest</strong> - shows adding/removing modes of <code>ComponentWidget</code>
121
<li><strong>test.component.ComponentModeTest</strong> - shows adding/removing modes of <code>ComponentWidget</code>
(-)graph/www/index.html (-1 / +2 lines)
Lines 118-127 Link Here
118
<li>Object states
118
<li>Object states
119
<li>Selection/focus model
119
<li>Selection/focus model
120
<li>Satelite view
120
<li>Satelite view
121
<li>In-place editing
121
<li>Bird view
122
</ul>
122
</ul>
123
<td valign=top>
123
<td valign=top>
124
<ul>
124
<ul>
125
<li>In-place editing
125
<li>ReconnectAction
126
<li>ReconnectAction
126
<li>ScrollWidget
127
<li>ScrollWidget
127
<li>Action tools
128
<li>Action tools

Return to bug 108510