| NetworkModel.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.networkmonitoring;
29
30 import y.view.Graph2D;
31
32 /**
33 * Interface for a network model
34 */
35 public interface NetworkModel {
36
37 /**
38 * Key to register a {@link y.base.DataProvider} that contains an unique id object for every network node and connection.
39 */
40 public static final Object ELEMENT_ID_DPKEY = "demo.view.networkmonitoring.NetworkModelImpl.ELEMENT_ID_DPKEY";
41
42 /**
43 * Key to register a {@link y.base.DataProvider} that contains a type for each network node. The type must be one of the
44 * following:
45 * {@link #PC}, {@link #LAPTOP}, {@link #SMARTPHONE}, {@link #SWITCH}, {@link #WLAN}, {@link #SERVER},
46 * {@link #DATABASE}.
47 */
48 public static final Object NODE_TYPE_DPKEY = "demo.view.networkmonitoring.NetworkModelImpl.NODE_TYPE_DPKEY";
49
50 /** Specifier for the network element PC.*/
51 public static final int PC = 1;
52 /** Specifier for the network element laptop.*/
53 public static final int LAPTOP = 2;
54 /** Specifier for the network element smartphone.*/
55 public static final int SMARTPHONE = 3;
56 /** Specifier for the network element switch.*/
57 public static final int SWITCH = 4;
58 /** Specifier for the network element wlan router.*/
59 public static final int WLAN = 5;
60 /** Specifier for the network element server.*/
61 public static final int SERVER = 6;
62 /** Specifier for the network element database.*/
63 public static final int DATABASE = 7;
64
65 /**
66 * Key to register a {@link y.base.DataProvider} that contains a capacity for each connection. The capacity must be an
67 * integer value.
68 */
69 public static final Object ELEMENT_CAPACITY_DPKEY = "demo.view.networkmonitoring.NetworkModelImpl.ELEMENT_CAPACITY_DPKEY";
70 /**
71 * Key to register a {@link y.base.DataProvider} that contains some additional information
72 * for a Node {@link NetworkNodeInfo}
73 */
74 public static final Object NODE_INFO_DPKEY = "demo.view.networkmonitoring.NetworkModelImpl.NODE_INFO_DPKEY";
75
76 /**
77 * Add the given {@link NetworkModelObserver observer} to the observer list.
78 * The observer get informed when a status changed, e.g. when a new network
79 * status where calculated or a element where deactivated.
80 * @param observer observer
81 */
82 public void addObserver(NetworkModelObserver observer);
83
84 /**
85 * Remove the given {@link NetworkModelObserver observer} from the observer list.
86 * @param observer observer
87 */
88 public void removeObserver(NetworkModelObserver observer);
89
90 /**
91 * Return the graph representing the network.
92 * @return network graph
93 */
94 public Graph2D getNetworkModel();
95
96 /**
97 * Enable the given network node.
98 * @param id network node
99 */
100 public void enableNetworkNode(Object id);
101
102 /**
103 * Disable the given network node.
104 * @param id network node
105 */
106 public void disableNetworkNode(Object id);
107
108 /**
109 * Enable the given connection.
110 * @param id connection
111 */
112 public void enableConnection(Object id);
113
114 /**
115 * Disable the given connection.
116 * @param id connection
117 */
118 public void disableConnection(Object id);
119
120 /**
121 * Repair the given network node.
122 * @param id network node
123 */
124 public void repairNetworkNode(Object id);
125
126 /**
127 * Repair the given connection.
128 * @param id connection
129 */
130 public void repairEdge(Object id);
131
132 /**
133 * Set if network errors may happen
134 * @param errorsEnabled true if network errors may happen
135 */
136 public void setNetworkErrorsEnabled(boolean errorsEnabled);
137
138 /**
139 * Return if network errors may happen
140 * @return true if errors may happen
141 */
142 public boolean isNetworkErrorsEnabled();
143
144 /**
145 * Set duration until a new status should be calculated
146 * @param duration time in milliseconds
147 */
148 public void setUpdateCycle(final int duration);
149
150 /**
151 * Return duration of a network cycle
152 * @return duration of a network cycle in milliseconds
153 */
154 public int getUpdateCycle();
155
156 }
157