Mercurial > hg > ccmiandroid
comparison src/uk/ac/qmul/eecs/ccmi/xmlparser/Edge.java @ 0:e0ee6ac3a45f
first import
author | Fiore Martin <fiore@eecs.qmul.ac.uk> |
---|---|
date | Thu, 13 Dec 2012 20:00:21 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e0ee6ac3a45f |
---|---|
1 /* | |
2 CCmI Diagram Editor for Android | |
3 | |
4 Copyright (C) 2012 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/) | |
5 | |
6 This program is free software: you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation, either version 3 of the License, or | |
9 (at your option) any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 */ | |
19 package uk.ac.qmul.eecs.ccmi.xmlparser; | |
20 | |
21 | |
22 import java.util.ArrayList; | |
23 | |
24 import org.simpleframework.xml.Attribute; | |
25 import org.simpleframework.xml.ElementList; | |
26 import org.simpleframework.xml.Root; | |
27 | |
28 @Root(name="Edge",strict=false) | |
29 public class Edge implements HierarchyItem { | |
30 private static int idCounter = 0; | |
31 @Attribute(name="Name") | |
32 private String name; | |
33 @Attribute(name="Type") | |
34 private String type; | |
35 @Attribute(name="id") | |
36 private int id; | |
37 | |
38 private Edge(){ | |
39 id = ++idCounter; | |
40 name = "New Edge "+id; | |
41 } | |
42 | |
43 public Edge(String type){ | |
44 this(); | |
45 this.type = type; | |
46 name = "New "+type+" "+id; | |
47 } | |
48 | |
49 | |
50 @ElementList(name="Nodes") | |
51 private ArrayList<EdgeNode> attachedNodes=new ArrayList<EdgeNode>(); | |
52 | |
53 public String getName() { | |
54 return name; | |
55 } | |
56 | |
57 public void setName(String name) { | |
58 this.name = name; | |
59 } | |
60 | |
61 public String getType() { | |
62 return type; | |
63 } | |
64 | |
65 public int getId() { | |
66 return id; | |
67 } | |
68 | |
69 public void setId(int id) { | |
70 /* catch up with the highest value entered */ | |
71 if(id > idCounter){ | |
72 idCounter = id; | |
73 } | |
74 this.id = id; | |
75 } | |
76 | |
77 public ArrayList<EdgeNode> getAttachedNodes() { | |
78 return attachedNodes; | |
79 } | |
80 | |
81 public void setAttachedNodes(ArrayList<EdgeNode> cEPro) { | |
82 this.attachedNodes = cEPro; | |
83 } | |
84 | |
85 @Override | |
86 public String toString(){ | |
87 return name; | |
88 } | |
89 | |
90 } |