0ea535129b68a9aff0ad78029ddca8fd59d7fe06
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
.maps
.elements
;
21 import org
.netxms
.base
.NXCPMessage
;
24 * Network map element.
27 public class NetworkMapElement
29 public static final int MAP_ELEMENT_GENERIC
= 0;
30 public static final int MAP_ELEMENT_OBJECT
= 1;
31 public static final int MAP_ELEMENT_DECORATION
= 2;
39 * Factory method for creating map element from NXCP message.
41 * @param msg NXCP message
42 * @param baseId base variable ID
43 * @return map element object
45 public static NetworkMapElement
createMapElement(NXCPMessage msg
, long baseId
)
47 int type
= msg
.getVariableAsInteger(baseId
+ 1);
50 case MAP_ELEMENT_OBJECT
:
51 return new NetworkMapObject(msg
, baseId
);
52 case MAP_ELEMENT_DECORATION
:
53 return new NetworkMapDecoration(msg
, baseId
);
55 return new NetworkMapElement(msg
, baseId
);
60 * Create element from NXCP message.
62 * @param msg NXCP message
63 * @param baseId base variable ID
65 protected NetworkMapElement(NXCPMessage msg
, long baseId
)
67 id
= msg
.getVariableAsInt64(baseId
);
68 type
= msg
.getVariableAsInteger(baseId
+ 1);
69 x
= msg
.getVariableAsInteger(baseId
+ 2);
70 y
= msg
.getVariableAsInteger(baseId
+ 3);
74 * Create new generic element
76 public NetworkMapElement(long id
)
79 type
= MAP_ELEMENT_GENERIC
;
85 * Fill NXCP message with element data
87 * @param msg NXCP message
88 * @param baseId base variable ID
90 public void fillMessage(NXCPMessage msg
, long baseId
)
92 msg
.setVariableInt32(baseId
, (int)id
);
93 msg
.setVariableInt16(baseId
+ 1, type
);
94 msg
.setVariableInt32(baseId
+ 2, x
);
95 msg
.setVariableInt32(baseId
+ 3, y
);
131 * @see java.lang.Object#equals(java.lang.Object)
134 public boolean equals(Object obj
)
136 if (obj
instanceof NetworkMapElement
)
137 return ((NetworkMapElement
)obj
).id
== id
;
138 return super.equals(obj
);
142 * @see java.lang.Object#hashCode()
145 public int hashCode()