| PortEditMode.java |
1 /****************************************************************************
2 * This demo file is part of yFiles for Java 2.14.
3 * Copyright (c) 2000-2017 by yWorks GmbH, Vor dem Kreuzberg 28,
4 * 72070 Tuebingen, Germany. All rights reserved.
5 *
6 * yFiles demo files exhibit yFiles for Java functionalities. Any redistribution
7 * of demo files in source code or binary form, with or without
8 * modification, is not permitted.
9 *
10 * Owners of a valid software license for a yFiles for Java version that this
11 * demo is shipped with are allowed to use the demo source code as basis
12 * for their own yFiles for Java powered applications. Use of such programs is
13 * governed by the rights and conditions as set out in the yFiles for Java
14 * license agreement.
15 *
16 * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 * NO EVENT SHALL yWorks BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 ***************************************************************************/
28 package demo.view.advanced.ports;
29
30 import y.view.CreateEdgeMode;
31 import y.view.EditMode;
32 import y.view.MouseInputMode;
33 import y.view.MovePortMode;
34 import y.view.SelectionBoxMode;
35 import y.view.ViewMode;
36
37 /**
38 * Customized {@link y.view.EditMode} that takes {@link y.view.NodePort}s
39 * into account.
40 *
41 */
42 class PortEditMode extends EditMode {
43 PortEditMode() {
44 setCyclicSelectionEnabled(true);
45 }
46
47 /**
48 * Overwritten to create a {@link demo.view.advanced.ports.NodePortPopupMode}
49 * instance.
50 * @return a {@link demo.view.advanced.ports.NodePortPopupMode}
51 * instance.
52 */
53 protected ViewMode createPopupMode() {
54 return new NodePortPopupMode();
55 }
56
57 /**
58 * Overwritten to create a {@link y.view.MovePortMode} instance that allows
59 * reassigning edges to new nodes.
60 * @return a {@link y.view.MovePortMode} instance.
61 */
62 protected ViewMode createMovePortMode() {
63 final MovePortMode mpm = new MovePortMode();
64 mpm.setChangeEdgeEnabled(true);
65 return mpm;
66 }
67
68 /**
69 * Overwritten to create a {@link y.view.CreateEdgeMode} instance that
70 * visually indicates target nodes and ports for newly created edges.
71 * @return a {@link y.view.CreateEdgeMode} instance.
72 */
73 protected ViewMode createCreateEdgeMode() {
74 final CreateEdgeMode cem = new PortCreateEdgeMode();
75 cem.setIndicatingTargetNode(true);
76 return cem;
77 }
78
79 /**
80 * Overwritten to create a {@link y.view.MouseInputMode} instance
81 * that supports interactive selecting/deselecting and moving of
82 * {@link y.view.NodePort} instances.
83 * @return a {@link y.view.MouseInputMode} instance.
84 */
85 protected MouseInputMode createMouseInputMode() {
86 final MouseInputMode mim = new MouseInputMode();
87 mim.setNodeSearchingEnabled(true);
88 return mim;
89 }
90
91 /**
92 * Overwritten to create a {@link y.view.SelectionBoxMode} instance
93 * that supports selecting {@link y.view.NodePort} instances and
94 * {@link y.view.YLabel} instances as well as {@link y.base.Node},
95 * {@link y.base.Edge}, and {@link y.view.Bend} instances.
96 * @return a {@link y.view.SelectionBoxMode} instance.
97 */
98 protected ViewMode createSelectionBoxMode() {
99 final SelectionBoxMode sbm = new SelectionBoxMode();
100 sbm.setExtendedTypeSelectionEnabled(true);
101 return sbm;
102 }
103 }
104