Source Code Cross Referenced for ActionFactory.java in  » IDE-Netbeans » api » org » netbeans » api » visual » action » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » api » org.netbeans.api.visual.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.api.visual.action;
042:
043:        import org.netbeans.api.visual.widget.ConnectionWidget;
044:        import org.netbeans.api.visual.widget.LayerWidget;
045:        import org.netbeans.api.visual.widget.Scene;
046:        import org.netbeans.api.visual.widget.Widget;
047:        import org.netbeans.api.visual.model.ObjectScene;
048:        import org.netbeans.api.visual.anchor.Anchor;
049:        import org.netbeans.api.visual.anchor.AnchorFactory;
050:        import org.netbeans.api.visual.anchor.AnchorShape;
051:        import org.netbeans.modules.visual.action.*;
052:
053:        import javax.swing.*;
054:        import java.awt.*;
055:        import java.awt.event.MouseEvent;
056:        import java.util.EnumSet;
057:
058:        /**
059:         * The factory class of all built-in actions. Action creation usually requires some parameter like decorator
060:         * (cares about the visualization) and provider (cares about the logic of an action).
061:         * <p>
062:         * Instances of the built-in actions could be shared by multiple widgets.
063:         *
064:         * @author David Kaspar
065:         */
066:        public final class ActionFactory {
067:
068:            private static final BasicStroke STROKE = new BasicStroke(1.0f,
069:                    BasicStroke.JOIN_BEVEL, BasicStroke.CAP_BUTT, 5.0f,
070:                    new float[] { 6.0f, 3.0f }, 0.0f);
071:
072:            private static final MoveStrategy MOVE_STRATEGY_FREE = new MoveStrategy() {
073:                public Point locationSuggested(Widget widget,
074:                        Point originalLocation, Point suggestedLocation) {
075:                    return suggestedLocation;
076:                }
077:            };
078:
079:            private static final MoveProvider MOVE_PROVIDER_DEFAULT = new MoveProvider() {
080:                public void movementStarted(Widget widget) {
081:                }
082:
083:                public void movementFinished(Widget widget) {
084:                }
085:
086:                public Point getOriginalLocation(Widget widget) {
087:                    return widget.getPreferredLocation();
088:                }
089:
090:                public void setNewLocation(Widget widget, Point location) {
091:                    widget.setPreferredLocation(location);
092:                }
093:            };
094:
095:            private static final AlignWithMoveDecorator ALIGN_WITH_MOVE_DECORATOR_DEFAULT = new AlignWithMoveDecorator() {
096:                public ConnectionWidget createLineWidget(Scene scene) {
097:                    ConnectionWidget widget = new ConnectionWidget(scene);
098:                    widget.setStroke(STROKE);
099:                    widget.setForeground(Color.BLUE);
100:                    return widget;
101:                }
102:            };
103:
104:            private static final MoveControlPointProvider MOVE_CONTROL_POINT_PROVIDER_FREE = new FreeMoveControlPointProvider();
105:
106:            private static final MoveControlPointProvider MOVE_CONTROL_POINT_PROVIDER_ORTHOGONAL = new OrthogonalMoveControlPointProvider();
107:
108:            private static final ConnectDecorator CONNECT_DECORATOR_DEFAULT = new ConnectDecorator() {
109:                public ConnectionWidget createConnectionWidget(Scene scene) {
110:                    ConnectionWidget widget = new ConnectionWidget(scene);
111:                    widget.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
112:                    return widget;
113:                }
114:
115:                public Anchor createSourceAnchor(Widget sourceWidget) {
116:                    return AnchorFactory.createCenterAnchor(sourceWidget);
117:                }
118:
119:                public Anchor createTargetAnchor(Widget targetWidget) {
120:                    return AnchorFactory.createCenterAnchor(targetWidget);
121:                }
122:
123:                public Anchor createFloatAnchor(Point location) {
124:                    return AnchorFactory.createFixedAnchor(location);
125:                }
126:            };
127:
128:            private static final ReconnectDecorator RECONNECT_DECORATOR_DEFAULT = new ReconnectDecorator() {
129:                public Anchor createReplacementWidgetAnchor(
130:                        Widget replacementWidget) {
131:                    return AnchorFactory.createCenterAnchor(replacementWidget);
132:                }
133:
134:                public Anchor createFloatAnchor(Point location) {
135:                    return AnchorFactory.createFixedAnchor(location);
136:                }
137:            };
138:
139:            private static final ResizeProvider RESIZE_PROVIDER_DEFAULT = new ResizeProvider() {
140:                public void resizingStarted(Widget widget) {
141:                }
142:
143:                public void resizingFinished(Widget widget) {
144:                }
145:            };
146:
147:            private static final ResizeStrategy RESIZE_STRATEGY_FREE = new ResizeStrategy() {
148:                public Rectangle boundsSuggested(Widget widget,
149:                        Rectangle originalBounds, Rectangle suggestedBounds,
150:                        ResizeProvider.ControlPoint controlPoint) {
151:                    return suggestedBounds;
152:                }
153:            };
154:
155:            private static final ResizeControlPointResolver RESIZE_CONTROL_POINT_RESOLVER_DEFAULT = new ResizeCornersControlPointResolver();
156:
157:            private static final ActionMapAction ACTION_MAP_ACTION = new ActionMapAction(
158:                    null, null);
159:
160:            private static final WidgetAction MOVE_CONTROL_POINT_ACTION_FREE = createMoveControlPointAction(createFreeMoveControlPointProvider());
161:
162:            private static final WidgetAction MOVE_CONTROL_POINT_ACTION_ORTHOGONAL = createMoveControlPointAction(createOrthogonalMoveControlPointProvider());
163:
164:            private static final WidgetAction MOVE_ACTION = createMoveAction(
165:                    null, null);
166:
167:            private static final WidgetAction RESIZE_ACTION = createResizeAction(
168:                    null, null);
169:
170:            private static final WidgetAction CYCLE_FOCUS_OBJECT_SCENE = createCycleFocusAction(new CycleObjectSceneFocusProvider());
171:
172:            private static final PanAction PAN_ACTION = new PanAction();
173:
174:            private static final WheelPanAction WHEEL_PAN_ACTION = new WheelPanAction();
175:
176:            private ActionFactory() {
177:            }
178:
179:            /**
180:             * Creates a accept action with a specified accept logic provider.
181:             * @param provider the accept logic provider
182:             * @return the accept action
183:             */
184:            public static WidgetAction createAcceptAction(
185:                    AcceptProvider provider) {
186:                assert provider != null;
187:                return new AcceptAction(provider);
188:            }
189:
190:            /**
191:             * Creates an action which handles keys and popup menu.
192:             * The key-to-action binding is obtained from the InputMap of a view JComponent of a scene.
193:             * The actions for popup menu are obtained from the ActionMap of a view JComponent of a scene.
194:             * @return the action-map action
195:             */
196:            public static WidgetAction createActionMapAction() {
197:                return ACTION_MAP_ACTION;
198:            }
199:
200:            /**
201:             * Creates an action which handles keys and popup menu.
202:             * The key-to-action binding and popup menu items are obtained from specified ActionMap and InputMap.
203:             * @param inputMap the input map
204:             * @param actionMap the action map
205:             * @return the action-map action
206:             */
207:            public static WidgetAction createActionMapAction(InputMap inputMap,
208:                    ActionMap actionMap) {
209:                assert inputMap != null && actionMap != null;
210:                return new ActionMapAction(inputMap, actionMap);
211:            }
212:
213:            /**
214:             * Creates a add-remove control point action with a default sensitivity. The action is assigned to a FreeConnectionWidget.
215:             * @return the add-remove control point action
216:             */
217:            public static WidgetAction createAddRemoveControlPointAction() {
218:                return createAddRemoveControlPointAction(3.0, 5.0);
219:            }
220:
221:            /**
222:             * Creates a add-remove control point action with a specified sensitivity.
223:             * @param createSensitivity the create sensitivity
224:             * @param deleteSensitivity the delete sensitivity
225:             * @return the add-remove control point action
226:             */
227:            public static WidgetAction createAddRemoveControlPointAction(
228:                    double createSensitivity, double deleteSensitivity) {
229:                return createAddRemoveControlPointAction(createSensitivity,
230:                        deleteSensitivity, null);
231:            }
232:
233:            /**
234:             * Creates a add-remove control point action with a specified sensitivity.
235:             * @param createSensitivity the create sensitivity
236:             * @param deleteSensitivity the delete sensitivity
237:             * @param routingPolicy the routing policy that is automatically set to a connection widget with control points modified by this action;
238:             *     if null, then routing policy is not set
239:             * @return the add-remove control point action
240:             * @since 2.9
241:             */
242:            public static WidgetAction createAddRemoveControlPointAction(
243:                    double createSensitivity, double deleteSensitivity,
244:                    ConnectionWidget.RoutingPolicy routingPolicy) {
245:                return new AddRemoveControlPointAction(createSensitivity,
246:                        deleteSensitivity, routingPolicy);
247:            }
248:
249:            /**
250:             * Creates a align-with move action.
251:             * @param collectionLayer the layer with objects that the alignment is checked against.
252:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
253:             * @param decorator the align-with move decorator
254:             * @return the align-with move action
255:             */
256:            public static WidgetAction createAlignWithMoveAction(
257:                    LayerWidget collectionLayer, LayerWidget interractionLayer,
258:                    AlignWithMoveDecorator decorator) {
259:                return createAlignWithMoveAction(collectionLayer,
260:                        interractionLayer, decorator, true);
261:            }
262:
263:            /**
264:             * Creates a align-with move action.
265:             * @param collectionLayer the layer with objects that the alignment is checked against.
266:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
267:             * @param decorator the align-with move decorator
268:             * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
269:             *      if false, then the align-with is check against client area (widget bounds without border insets
270:             * @return the align-with move action
271:             * @since 2.7
272:             */
273:            public static WidgetAction createAlignWithMoveAction(
274:                    LayerWidget collectionLayer, LayerWidget interractionLayer,
275:                    AlignWithMoveDecorator decorator, boolean outerBounds) {
276:                assert collectionLayer != null;
277:                return createAlignWithMoveAction(
278:                        new SingleLayerAlignWithWidgetCollector(
279:                                collectionLayer, outerBounds),
280:                        interractionLayer, decorator != null ? decorator
281:                                : ALIGN_WITH_MOVE_DECORATOR_DEFAULT,
282:                        outerBounds);
283:            }
284:
285:            /**
286:             * Creates a align-with move action.
287:             * @param collector the collector of objects that the alignment is checked against.
288:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
289:             * @param decorator the align-with move decorator
290:             * @return the align-with move action
291:             */
292:            public static WidgetAction createAlignWithMoveAction(
293:                    AlignWithWidgetCollector collector,
294:                    LayerWidget interractionLayer,
295:                    AlignWithMoveDecorator decorator) {
296:                return createAlignWithMoveAction(collector, interractionLayer,
297:                        decorator, true);
298:            }
299:
300:            /**
301:             * Creates a align-with move action.
302:             * @param collector the collector of objects that the alignment is checked against.
303:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
304:             * @param decorator the align-with move decorator
305:             * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
306:             *      if false, then the align-with is check against client area (widget bounds without border insets
307:             * @return the align-with move action
308:             * @since 2.7
309:             */
310:            public static WidgetAction createAlignWithMoveAction(
311:                    AlignWithWidgetCollector collector,
312:                    LayerWidget interractionLayer,
313:                    AlignWithMoveDecorator decorator, boolean outerBounds) {
314:                assert collector != null && interractionLayer != null
315:                        && decorator != null;
316:                AlignWithMoveStrategyProvider sp = new AlignWithMoveStrategyProvider(
317:                        collector, interractionLayer, decorator, outerBounds);
318:                return createMoveAction(sp, sp);
319:            }
320:
321:            /**
322:             * Creates a align-with resize action.
323:             * @param collectionLayer the layer with objects that the alignment is checked against.
324:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
325:             * @param decorator the align-with move decorator
326:             * @return the align-with resize action
327:             */
328:            public static WidgetAction createAlignWithResizeAction(
329:                    LayerWidget collectionLayer, LayerWidget interractionLayer,
330:                    AlignWithMoveDecorator decorator) {
331:                return createAlignWithResizeAction(collectionLayer,
332:                        interractionLayer, decorator, true);
333:            }
334:
335:            /**
336:             * Creates a align-with resize action.
337:             * @param collectionLayer the layer with objects that the alignment is checked against.
338:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
339:             * @param decorator the align-with move decorator
340:             * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
341:             *      if false, then the align-with is check against client area (widget bounds without border insets
342:             * @return the align-with resize action
343:             * @since 2.7
344:             */
345:            public static WidgetAction createAlignWithResizeAction(
346:                    LayerWidget collectionLayer, LayerWidget interractionLayer,
347:                    AlignWithMoveDecorator decorator, boolean outerBounds) {
348:                assert collectionLayer != null;
349:                return createAlignWithResizeAction(
350:                        new SingleLayerAlignWithWidgetCollector(
351:                                collectionLayer, outerBounds),
352:                        interractionLayer, decorator != null ? decorator
353:                                : ALIGN_WITH_MOVE_DECORATOR_DEFAULT,
354:                        outerBounds);
355:            }
356:
357:            /**
358:             * Creates a align-with resize action.
359:             * @param collector the collector of objects that the alignment is checked against.
360:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
361:             * @param decorator the align-with move decorator
362:             * @return the align-with resize action
363:             */
364:            public static WidgetAction createAlignWithResizeAction(
365:                    AlignWithWidgetCollector collector,
366:                    LayerWidget interractionLayer,
367:                    AlignWithMoveDecorator decorator) {
368:                return createAlignWithResizeAction(collector,
369:                        interractionLayer, decorator, true);
370:            }
371:
372:            /**
373:             * Creates a align-with resize action.
374:             * @param collector the collector of objects that the alignment is checked against.
375:             * @param interractionLayer the interraction layer where the align-with hint lines are placed
376:             * @param decorator the align-with move decorator
377:             * @param outerBounds if true, then the align-with is check against whole bounds of widgets in collection layer;
378:             *      if false, then the align-with is check against client area (widget bounds without border insets
379:             * @return the align-with resize action
380:             * @since 2.7
381:             */
382:            public static WidgetAction createAlignWithResizeAction(
383:                    AlignWithWidgetCollector collector,
384:                    LayerWidget interractionLayer,
385:                    AlignWithMoveDecorator decorator, boolean outerBounds) {
386:                assert collector != null && interractionLayer != null
387:                        && decorator != null;
388:                AlignWithResizeStrategyProvider sp = new AlignWithResizeStrategyProvider(
389:                        collector, interractionLayer, decorator, outerBounds);
390:                return createResizeAction(sp, sp);
391:            }
392:
393:            /**
394:             * Creates a connect action with a default decorator.
395:             * @param interractionLayer the interraction layer where the temporary connection is visualization placed.
396:             * @param provider the connect logic provider
397:             * @return the connect action
398:             */
399:            public static WidgetAction createConnectAction(
400:                    LayerWidget interractionLayer, ConnectProvider provider) {
401:                return createConnectAction(null, interractionLayer, provider);
402:            }
403:
404:            /**
405:             * Creates a connect action with a specific decorator.
406:             * @param decorator the connect decorator; if null, then the default decorator is used
407:             * @param interractionLayer the interraction layer where the temporary connection is visualization placed.
408:             * @param provider the connect logic provider
409:             * @return the connect action
410:             */
411:            public static WidgetAction createConnectAction(
412:                    ConnectDecorator decorator, LayerWidget interractionLayer,
413:                    ConnectProvider provider) {
414:                assert interractionLayer != null && provider != null;
415:                return new ConnectAction(decorator != null ? decorator
416:                        : createDefaultConnectDecorator(), interractionLayer,
417:                        provider);
418:            }
419:
420:            /**
421:             * Creates an extended connect action with a default decorator. User can invoke the action only with pressed CTRL key.
422:             * @param interractionLayer the interraction layer where the temporary connection is visualization placed.
423:             * @param provider the connect logic provider
424:             * @return the extended connect action
425:             */
426:            public static WidgetAction createExtendedConnectAction(
427:                    LayerWidget interractionLayer, ConnectProvider provider) {
428:                return createExtendedConnectAction(null, interractionLayer,
429:                        provider);
430:            }
431:
432:            /**
433:             * Creates an extended connect action with a specific decorator. User can invoke the action only with pressed CTRL key.
434:             * @param decorator the connect decorator; if null, then the default decorator is used
435:             * @param interractionLayer the interraction layer where the temporary connection is visualization placed.
436:             * @param provider the connect logic provider
437:             * @return the extended connect action
438:             */
439:            public static WidgetAction createExtendedConnectAction(
440:                    ConnectDecorator decorator, LayerWidget interractionLayer,
441:                    ConnectProvider provider) {
442:                assert interractionLayer != null && provider != null;
443:                return new ExtendedConnectAction(decorator != null ? decorator
444:                        : createDefaultConnectDecorator(), interractionLayer,
445:                        provider, MouseEvent.CTRL_MASK);
446:            }
447:
448:            /**
449:             * Creates an extended connect action with a specific decorator which can be invoked only with specified modifiers (usually it is <code>MouseEvent.CTRL_MASK</code>).
450:             * @param decorator the connect decorator; if null, then the default decorator is used
451:             * @param interractionLayer the interraction layer where the temporary connection is visualization placed.
452:             * @param provider the connect logic provider
453:             * @param modifiers the invocation modifiers
454:             * @return the extended connect action
455:             * @since 2.3
456:             */
457:            public static WidgetAction createExtendedConnectAction(
458:                    ConnectDecorator decorator, LayerWidget interractionLayer,
459:                    ConnectProvider provider, int modifiers) {
460:                assert interractionLayer != null && provider != null
461:                        && modifiers != 0;
462:                return new ExtendedConnectAction(decorator != null ? decorator
463:                        : createDefaultConnectDecorator(), interractionLayer,
464:                        provider, modifiers);
465:            }
466:
467:            /**
468:             * Creates an edit action.
469:             * @param provider the edit logic provider.
470:             * @return the edit action
471:             */
472:            public static WidgetAction createEditAction(EditProvider provider) {
473:                assert provider != null;
474:                return new EditAction(provider);
475:            }
476:
477:            /**
478:             * Creates a hover action using a hover provider.
479:             * Usually the Scene.createWidgetHoverAction and ObjectScene.createObjectHoverAction methods are used instead of this method.
480:             * @param provider the hover logic provider
481:             * @return the hover action
482:             */
483:            public static WidgetAction createHoverAction(HoverProvider provider) {
484:                assert provider != null;
485:                return new MouseHoverAction(provider);
486:            }
487:
488:            /**
489:             * Creates a hover action using a two-stated hover provider.
490:             * Usually the Scene.createWidgetHoverAction and ObjectScene.createObjectHoverAction methods are used instead of this method.
491:             * @param provider the two-stated hover logic provider
492:             * @return the hover action.
493:             */
494:            public static WidgetAction createHoverAction(
495:                    TwoStateHoverProvider provider) {
496:                assert provider != null;
497:                return new TwoStatedMouseHoverAction(provider);
498:            }
499:
500:            /**
501:             * Creates a text in-place editor action visualized using JTextField.
502:             * @param editor the editor logic
503:             * @return the in-place editor action
504:             */
505:            public static WidgetAction createInplaceEditorAction(
506:                    TextFieldInplaceEditor editor) {
507:                return createInplaceEditorAction(editor, null);
508:            }
509:
510:            /**
511:             * Creates a text in-place editor action visualized using JTextField.
512:             * @param editor the editor logic
513:             * @param expansionDirections the expansion directions
514:             * @return the in-place editor action
515:             */
516:            public static WidgetAction createInplaceEditorAction(
517:                    TextFieldInplaceEditor editor,
518:                    EnumSet<InplaceEditorProvider.ExpansionDirection> expansionDirections) {
519:                return createInplaceEditorAction(new TextFieldInplaceEditorProvider(
520:                        editor, expansionDirections));
521:            }
522:
523:            /**
524:             * Creates an in-place editor action for a specific provider.
525:             * @param provider the in-place editor provider
526:             * @return the in-place editor action
527:             */
528:            public static <C extends JComponent> WidgetAction createInplaceEditorAction(
529:                    InplaceEditorProvider<C> provider) {
530:                return new InplaceEditorAction<C>(provider);
531:            }
532:
533:            /**
534:             * Creates a move action with a default (free) strategy. The action provides movement for a widget where it is assigned.
535:             * @return the move action
536:             */
537:            public static WidgetAction createMoveAction() {
538:                return MOVE_ACTION;
539:            }
540:
541:            /**
542:             * Creates a move action with a specified strategy and provider.
543:             * @param strategy the move strategy; if null, then default (free) move strategy is used.
544:             * @param provider the move logic provider; if null, then defaual move logic provider is used
545:             *            (provides movement for a widget where it is assigned).
546:             * @return the move action
547:             */
548:            public static WidgetAction createMoveAction(MoveStrategy strategy,
549:                    MoveProvider provider) {
550:                return new MoveAction(strategy != null ? strategy
551:                        : createFreeMoveStrategy(), provider != null ? provider
552:                        : createDefaultMoveProvider());
553:            }
554:
555:            /**
556:             * Creates a move control point (of a connection widget) action with no movement restriction.
557:             * @return the move control point action
558:             */
559:            public static WidgetAction createFreeMoveControlPointAction() {
560:                return MOVE_CONTROL_POINT_ACTION_FREE;
561:            }
562:
563:            /**
564:             * Creates a move control point (of a connection widget) action with is used at ConnectionWidget with OrthogonalSearchRouter.
565:             * @return the move control point action
566:             */
567:            public static WidgetAction createOrthogonalMoveControlPointAction() {
568:                return MOVE_CONTROL_POINT_ACTION_ORTHOGONAL;
569:            }
570:
571:            /**
572:             * Creates a move control point (of a connection widget) action with a specified provider.
573:             * @param provider the move control point provider
574:             * @return the move control point action
575:             */
576:            public static WidgetAction createMoveControlPointAction(
577:                    MoveControlPointProvider provider) {
578:                return createMoveControlPointAction(provider, null);
579:            }
580:
581:            /**
582:             * Creates a move control point (of a connection widget) action with a specified provider.
583:             * @param provider the move control point provider
584:             * @param routingPolicy the routing policy that is automatically set to a connection widget with control points modified by this action;
585:             *     if null, then routing policy is not set
586:             * @return the move control point action
587:             * @since 2.9
588:             */
589:            public static WidgetAction createMoveControlPointAction(
590:                    MoveControlPointProvider provider,
591:                    ConnectionWidget.RoutingPolicy routingPolicy) {
592:                assert provider != null;
593:                return new MoveControlPointAction(provider, routingPolicy);
594:            }
595:
596:            /**
597:             * Creates a scene view panning action.
598:             * @return the pan action
599:             */
600:            public static WidgetAction createPanAction() {
601:                return PAN_ACTION;
602:            }
603:
604:            /**
605:             * Creates a scene view panning action using mouse-wheel.
606:             * @return the wheel pan action
607:             * @since 2.7
608:             */
609:            public static WidgetAction createWheelPanAction() {
610:                return WHEEL_PAN_ACTION;
611:            }
612:
613:            /**
614:             * Creates a popup menu action with a speicied provider.
615:             * @param provider the popup menu provider
616:             * @return the popup menu action
617:             */
618:            public static WidgetAction createPopupMenuAction(
619:                    final PopupMenuProvider provider) {
620:                assert provider != null;
621:                return new PopupMenuAction(provider);
622:            }
623:
624:            /**
625:             * Creates a reconnect action with a default decorator.
626:             * @param provider the reconnect logic provider
627:             * @return the reconnect action
628:             */
629:            public static WidgetAction createReconnectAction(
630:                    ReconnectProvider provider) {
631:                return createReconnectAction(null, provider);
632:            }
633:
634:            /**
635:             * Creates a reconnect action with a specific decorator and logic provider.
636:             * @param decorator the reccont decorator
637:             * @param provider the reconnect logic provider
638:             * @return the reconnect action
639:             */
640:            public static WidgetAction createReconnectAction(
641:                    ReconnectDecorator decorator, ReconnectProvider provider) {
642:                return new ReconnectAction(decorator != null ? decorator
643:                        : createDefaultReconnectDecorator(), provider);
644:            }
645:
646:            /**
647:             * Creates a rectangular select action for a specified object scene with a default decorator.
648:             * @param scene the object scene which the selection will be controlled by the action
649:             * @param interractionLayer the interraction layer where the selection rectangle will be visualized
650:             * @return the rectangular select action
651:             */
652:            public static WidgetAction createRectangularSelectAction(
653:                    ObjectScene scene, LayerWidget interractionLayer) {
654:                assert scene != null;
655:                return createRectangularSelectAction(
656:                        ActionFactory
657:                                .createDefaultRectangularSelectDecorator(scene),
658:                        interractionLayer,
659:                        ActionFactory
660:                                .createObjectSceneRectangularSelectProvider(scene));
661:            }
662:
663:            /**
664:             * Creates a rectangular select action with a specified decorator and logic provider.
665:             * @param decorator the rectangular select decorator
666:             * @param interractionLayer the interraction layer where the selection rectangle will be visualized
667:             * @param provider the rectangular select logic provider
668:             * @return the rectangular select action
669:             */
670:            public static WidgetAction createRectangularSelectAction(
671:                    RectangularSelectDecorator decorator,
672:                    LayerWidget interractionLayer,
673:                    RectangularSelectProvider provider) {
674:                assert decorator != null && interractionLayer != null
675:                        && provider != null;
676:                return new RectangularSelectAction(decorator,
677:                        interractionLayer, provider);
678:            }
679:
680:            /**
681:             * Creates a resize action with a default (free without any restriction) strategy and default logic provider (the action affect preferredBounds of a widget where it is assigned)
682:             * default resize control point resolver.
683:             * @return the resize action
684:             */
685:            public static WidgetAction createResizeAction() {
686:                return RESIZE_ACTION;
687:            }
688:
689:            /**
690:             * Creates a resize action with a specified resize strategy and provider and default resize control point resolver.
691:             * @param strategy the resize strategy; if null, then the default (free without any restriction) strategy is used
692:             * @param provider the resize logic provider; if null, then the default logic provider is used
693:             *            (the action affect preferredBounds of a widget where it is assigned)
694:             * @return the resize action
695:             */
696:            public static WidgetAction createResizeAction(
697:                    ResizeStrategy strategy, ResizeProvider provider) {
698:                return createResizeAction(strategy, null, provider);
699:            }
700:
701:            /**
702:             * Creates a resize action with a specified resize strategy and provider.
703:             * @param strategy the resize strategy; if null, then the default (free without any restriction) strategy is used
704:             * @param resolver the resize control point resolver; if null, then the default (points are at corners and center of edges) is used
705:             * @param provider the resize logic provider; if null, then the default logic provider is used
706:             *            (the action affect preferredBounds of a widget where it is assigned)
707:             * @return the resize action
708:             */
709:            public static WidgetAction createResizeAction(
710:                    ResizeStrategy strategy,
711:                    ResizeControlPointResolver resolver, ResizeProvider provider) {
712:                return new ResizeAction(strategy != null ? strategy
713:                        : createFreeResizeStategy(),
714:                        resolver != null ? resolver
715:                                : createDefaultResizeControlPointResolver(),
716:                        provider != null ? provider
717:                                : createDefaultResizeProvider());
718:            }
719:
720:            /**
721:             * Creates a select action. Usually the ObjectScene.createSelectAction method is used instead of this method.
722:             * @param provider the select logic provider
723:             * @return the select action
724:             */
725:            public static WidgetAction createSelectAction(
726:                    SelectProvider provider) {
727:                assert provider != null;
728:                return new SelectAction(provider);
729:            }
730:
731:            /**
732:             * Creates a switch card action with controls an active card of a widget where a card layout is used.
733:             * @param cardLayoutWidget the widget where a card layout is used
734:             * @return the switch card action
735:             */
736:            public static WidgetAction createSwitchCardAction(
737:                    Widget cardLayoutWidget) {
738:                assert cardLayoutWidget != null;
739:                return new SelectAction(
740:                        new SwitchCardProvider(cardLayoutWidget));
741:            }
742:
743:            /**
744:             * Creates a action that controls a zoom factor of a scene where the action is assigned.
745:             * @return the zoom action
746:             */
747:            public static WidgetAction createZoomAction() {
748:                return createZoomAction(1.2, true);
749:            }
750:
751:            /**
752:             * Creates a action that controls a zoom factor of a scene where the action is assigned.
753:             * @param zoomMultiplier the zoom multiplier of each zoom step
754:             * @param animated if true, then the zoom factor changed is animated
755:             * @return the zoom action
756:             */
757:            public static WidgetAction createZoomAction(double zoomMultiplier,
758:                    boolean animated) {
759:                return new ZoomAction(zoomMultiplier, animated);
760:            }
761:
762:            /**
763:             * Creates a free (without any restriction) move strategy
764:             * @return the move strategy
765:             */
766:            public static MoveStrategy createFreeMoveStrategy() {
767:                return MOVE_STRATEGY_FREE;
768:            }
769:
770:            /**
771:             * Creates a snap-to-grid move strategy.
772:             * @param horizontalGridSize the horizontal grid size
773:             * @param verticalGridSize the vertical grid size
774:             * @return the move strategy
775:             */
776:            public static MoveStrategy createSnapToGridMoveStrategy(
777:                    int horizontalGridSize, int verticalGridSize) {
778:                assert horizontalGridSize > 0 && verticalGridSize > 0;
779:                return new SnapToGridMoveStrategy(horizontalGridSize,
780:                        verticalGridSize);
781:            }
782:
783:            /**
784:             * Creates a default move provider where the logic controls the preferredLocation of a widget where the action is assigned to.
785:             * @return the move provider
786:             */
787:            public static MoveProvider createDefaultMoveProvider() {
788:                return MOVE_PROVIDER_DEFAULT;
789:            }
790:
791:            /**
792:             * Creates a default align-with move decorator.
793:             * @return the move decorator
794:             */
795:            public static AlignWithMoveDecorator createDefaultAlignWithMoveDecorator() {
796:                return ALIGN_WITH_MOVE_DECORATOR_DEFAULT;
797:            }
798:
799:            /**
800:             * Creates a free (without any restriction) move control point (of a ConnectionWidget) provider.
801:             * @return the move control point action
802:             */
803:            public static MoveControlPointProvider createFreeMoveControlPointProvider() {
804:                return MOVE_CONTROL_POINT_PROVIDER_FREE;
805:            }
806:
807:            /**
808:             * Creates a orthogonal move control point provider which is usually used with ConnectionWidget with OrthogonalSearchRouter.
809:             * @return the move control point provider
810:             */
811:            public static MoveControlPointProvider createOrthogonalMoveControlPointProvider() {
812:                return MOVE_CONTROL_POINT_PROVIDER_ORTHOGONAL;
813:            }
814:
815:            /**
816:             * Creates a default rectangular select decorator.
817:             * @param scene the scene where an action is used
818:             * @return the rectangular select decorator
819:             */
820:            public static RectangularSelectDecorator createDefaultRectangularSelectDecorator(
821:                    Scene scene) {
822:                assert scene != null;
823:                return new DefaultRectangularSelectDecorator(scene);
824:            }
825:
826:            /**
827:             * Creates a rectangular select provider which controls a selection of an object scene.
828:             * @param scene the object scene where an action is used
829:             * @return the rectangular select provider
830:             */
831:            public static RectangularSelectProvider createObjectSceneRectangularSelectProvider(
832:                    ObjectScene scene) {
833:                assert scene != null;
834:                return new ObjectSceneRectangularSelectProvider(scene);
835:            }
836:
837:            /**
838:             * Creates a default connect decorator
839:             * @return the connect decorator
840:             */
841:            public static ConnectDecorator createDefaultConnectDecorator() {
842:                return CONNECT_DECORATOR_DEFAULT;
843:            }
844:
845:            /**
846:             * Creates a default reconnect decorator
847:             * @return the reconnect decorator
848:             */
849:            public static ReconnectDecorator createDefaultReconnectDecorator() {
850:                return RECONNECT_DECORATOR_DEFAULT;
851:            }
852:
853:            /**
854:             * Creates a free (without any restriction) resize strategy
855:             * @return the resize strategy
856:             */
857:            public static ResizeStrategy createFreeResizeStategy() {
858:                return RESIZE_STRATEGY_FREE;
859:            }
860:
861:            /**
862:             * Creates a default resize provider which controls preferredBounds of a widget where an action is assigned.
863:             * @return the resize provider
864:             */
865:            public static ResizeProvider createDefaultResizeProvider() {
866:                return RESIZE_PROVIDER_DEFAULT;
867:            }
868:
869:            /**
870:             * Creates a default resize control point resolver which is used in resize action.
871:             * @return the resize control point resolver
872:             */
873:            public static ResizeControlPointResolver createDefaultResizeControlPointResolver() {
874:                return RESIZE_CONTROL_POINT_RESOLVER_DEFAULT;
875:            }
876:
877:            /**
878:             *
879:             * Creates a cycle focus action which switches focused object on a object scene.
880:             * @return the cycle object scene focus action
881:             */
882:            public static WidgetAction createCycleObjectSceneFocusAction() {
883:                return CYCLE_FOCUS_OBJECT_SCENE;
884:            }
885:
886:            /**
887:             * Creates a cycle focus action.
888:             * @param provider the cycle focus provider
889:             * @return the cycle focus action
890:             */
891:            public static WidgetAction createCycleFocusAction(
892:                    CycleFocusProvider provider) {
893:                assert provider != null;
894:                return new CycleFocusAction(provider);
895:            }
896:
897:            /**
898:             * This action is used for forwarding key events to another widget.
899:             * Usually it could be used to forwarding a key event from a node widget to node-label widget when
900:             * a scene is using process-focused-widget-and-its-parents event processing type.
901:             * @param forwardToWidget the widget to which events are forwarded
902:             * @param forwardToTool the tool to which events are forwarded; if null, then default action chain is used
903:             * @return the forward key events action; assign this action to widget from which the forwarding should be done
904:             */
905:            public static WidgetAction createForwardKeyEventsAction(
906:                    Widget forwardToWidget, String forwardToTool) {
907:                assert forwardToWidget != null;
908:                return new ForwardKeyEventsAction(forwardToWidget,
909:                        forwardToTool);
910:            }
911:
912:            /**
913:             * Returns an editor controller for a specified inplace-editor-action created by <code>ActionFactory.createInplaceEditorAction</code> method.
914:             * @param inplaceEditorAction the inplace-editor action
915:             * @return the editor controller
916:             */
917:            public static InplaceEditorProvider.EditorController getInplaceEditorController(
918:                    WidgetAction inplaceEditorAction) {
919:                return (InplaceEditorProvider.EditorController) inplaceEditorAction;
920:            }
921:
922:            /**
923:             * Creates a action that controls a zoom factor of a scene where the action is assigned.
924:             * During zooming the view will be centered still.  
925:             * @param zoomMultiplier the zoom multiplier
926:             * @return the zoom action
927:             */
928:            public static WidgetAction createCenteredZoomAction(
929:                    double zoomMultiplier) {
930:                return new CenteredZoomAction(zoomMultiplier);
931:            }
932:
933:            /**
934:             * Creates a action that controls a zoom factor of a scene where the action is assigned.
935:             * During zooming the view will be centered to the mouse cursor.
936:             * @param zoomMultiplier the zoom multiplier
937:             * @return the zoom action
938:             * @since 2.3
939:             */
940:            public static WidgetAction createMouseCenteredZoomAction(
941:                    double zoomMultiplier) {
942:                return new MouseCenteredZoomAction(zoomMultiplier);
943:            }
944:
945:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.