2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2010 Victor Kirhenshtein
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 package org
.netxms
.client
.objects
;
21 import java
.util
.ArrayList
;
22 import java
.util
.List
;
23 import java
.util
.UUID
;
24 import org
.netxms
.base
.GeoLocation
;
25 import org
.netxms
.base
.NXCPCodes
;
26 import org
.netxms
.base
.NXCPMessage
;
27 import org
.netxms
.client
.NXCSession
;
28 import org
.netxms
.client
.maps
.NetworkMapLink
;
29 import org
.netxms
.client
.maps
.NetworkMapPage
;
30 import org
.netxms
.client
.maps
.elements
.NetworkMapElement
;
36 public class NetworkMap
extends GenericObject
38 public static final UUID GEOMAP_BACKGROUND
= UUID
.fromString("ffffffff-ffff-ffff-ffff-ffffffffffff");
40 public static final int TYPE_CUSTOM
= 0;
41 public static final int TYPE_LAYER2_TOPOLOGY
= 1;
42 public static final int TYPE_IP_TOPOLOGY
= 2;
44 public static final int LAYOUT_MANUAL
= 0x7FFF;
45 public static final int LAYOUT_SPRING
= 0;
46 public static final int LAYOUT_RADIAL
= 1;
47 public static final int LAYOUT_HTREE
= 2;
48 public static final int LAYOUT_VTREE
= 3;
49 public static final int LAYOUT_SPARSE_VTREE
= 4;
51 public static final int MF_SHOW_STATUS_ICON
= 0x000001;
52 public static final int MF_SHOW_STATUS_FRAME
= 0x000002;
53 public static final int MF_SHOW_STATUS_BKGND
= 0x000004;
54 public static final int MF_SHOW_END_NODES
= 0x000008;
59 private UUID background
;
60 private GeoLocation backgroundLocation
;
61 private int backgroundZoom
;
62 private long seedObjectId
;
63 private int defaultLinkColor
;
64 private int defaultLinkRouting
;
65 private int backgroundColor
;
66 private int discoveryRadius
;
67 private List
<NetworkMapElement
> elements
;
68 private List
<NetworkMapLink
> links
;
74 public NetworkMap(NXCPMessage msg
, NXCSession session
)
77 mapType
= msg
.getVariableAsInteger(NXCPCodes
.VID_MAP_TYPE
);
78 layout
= msg
.getVariableAsInteger(NXCPCodes
.VID_LAYOUT
);
79 flags
= msg
.getVariableAsInteger(NXCPCodes
.VID_FLAGS
);
80 background
= msg
.getVariableAsUUID(NXCPCodes
.VID_BACKGROUND
);
81 backgroundLocation
= new GeoLocation(msg
.getVariableAsReal(NXCPCodes
.VID_BACKGROUND_LATITUDE
), msg
.getVariableAsReal(NXCPCodes
.VID_BACKGROUND_LONGITUDE
));
82 backgroundZoom
= msg
.getVariableAsInteger(NXCPCodes
.VID_BACKGROUND_ZOOM
);
83 seedObjectId
= msg
.getVariableAsInt64(NXCPCodes
.VID_SEED_OBJECT
);
84 defaultLinkColor
= msg
.getVariableAsInteger(NXCPCodes
.VID_LINK_COLOR
);
85 defaultLinkRouting
= msg
.getVariableAsInteger(NXCPCodes
.VID_LINK_ROUTING
);
86 backgroundColor
= msg
.getVariableAsInteger(NXCPCodes
.VID_BACKGROUND_COLOR
);
87 discoveryRadius
= msg
.getVariableAsInteger(NXCPCodes
.VID_DISCOVERY_RADIUS
);
89 int count
= msg
.getVariableAsInteger(NXCPCodes
.VID_NUM_ELEMENTS
);
90 elements
= new ArrayList
<NetworkMapElement
>(count
);
91 long varId
= NXCPCodes
.VID_ELEMENT_LIST_BASE
;
92 for(int i
= 0; i
< count
; i
++)
94 elements
.add(NetworkMapElement
.createMapElement(msg
, varId
));
98 count
= msg
.getVariableAsInteger(NXCPCodes
.VID_NUM_LINKS
);
99 links
= new ArrayList
<NetworkMapLink
>(count
);
100 varId
= NXCPCodes
.VID_LINK_LIST_BASE
;
101 for(int i
= 0; i
< count
; i
++)
103 links
.add(new NetworkMapLink(msg
, varId
));
109 * @see org.netxms.client.objects.GenericObject#getObjectClassName()
112 public String
getObjectClassName()
118 * @return the mapType
120 public int getMapType()
128 public int getLayout()
134 * @return the background
136 public UUID
getBackground()
142 * @return the seedObjectId
144 public long getSeedObjectId()
150 * Create map page from map object's data
152 * @return new map page
154 public NetworkMapPage
createMapPage()
156 NetworkMapPage page
= new NetworkMapPage(getObjectName());
157 page
.addAllElements(elements
);
158 page
.addAllLinks(links
);
163 * @return the backgroundLocation
165 public GeoLocation
getBackgroundLocation()
167 return backgroundLocation
;
171 * @return the backgroundZoom
173 public int getBackgroundZoom()
175 return backgroundZoom
;
181 public int getFlags()
187 * @return the defaultLinkColor
189 public int getDefaultLinkColor()
191 return defaultLinkColor
;
195 * @return the defaultLinkRouting
197 public int getDefaultLinkRouting()
199 return defaultLinkRouting
;
203 * @return the backgroundColor
205 public int getBackgroundColor()
207 return backgroundColor
;
211 * @return the discoveryRadius
213 public final int getDiscoveryRadius()
215 return discoveryRadius
;