1 package org.molwind.graph;
2
3 /*
4 * This file is part of Molwind.
5 *
6 * Molwind 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 * Molwind 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 Molwind. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 import java.util.UUID;
21
22 import org.molwind.model.WorldEntity;
23 import java.awt.geom.Point2D;
24 import org.molwind.model.PlacedWorldEntity;
25 import java.awt.Color;
26 import java.awt.Paint;
27
28
29 /**
30 * DefaultEntityVertex represents the default vertex of a DefaultEntityGraph
31 * object.
32 *
33 * @author <a href="mailto:oliver.karch@molwind.org">Oliver Karch</a>
34 * @version 1.0
35 */
36 public class DefaultEntityVertex implements EntityVertex {
37
38 private String id;
39 private WorldEntity entity;
40 public Color color = Color.YELLOW;
41
42
43 /**
44 * DefaultEntityVertex constructor, creates a new vertex.
45 */
46 public DefaultEntityVertex() {
47 super();
48 id = String.valueOf(UUID.randomUUID().toString());
49 entity = null;
50 }
51
52
53
54
55
56 /**
57 * Get the Id value.
58 *
59 * @return
60 * the Id value
61 */
62 public String getId() {
63 return id;
64 }
65
66 /**
67 * Set the Id value.
68 *
69 * @param newId
70 * the new Id value
71 */
72 public void setId(final String newId) {
73 this.id = newId;
74 }
75
76 /**
77 * Get the Entity value.
78 *
79 * @return
80 * the Entity value
81 */
82 public WorldEntity getEntity() {
83 return entity;
84 }
85
86 /**
87 * Set the Entity value.
88 *
89 * @param newEntity
90 * the new Entity value
91 */
92 public void setEntity(final WorldEntity newEntity) {
93 this.entity = newEntity;
94 }
95
96
97 /**
98 * Returns the position of the vertex
99 *
100 * @return
101 * The layout position
102 *
103 */
104 public Point2D.Double getPosition(){
105 PlacedWorldEntity pwe = (PlacedWorldEntity)entity;
106 double x = pwe.getX();
107 double y = pwe.getY();
108
109 return new Point2D.Double(x,y);
110
111
112 }
113
114 /**
115 * Sets the layout position
116 *
117 * @param
118 * The posion to be set
119 *
120 */
121 public void setPosition(Point2D.Double position){
122 PlacedWorldEntity pwe = (PlacedWorldEntity)entity;
123 pwe.setX(position.getX());
124 pwe.setY(position.getY());
125
126
127 }
128
129 /**
130 * VertexId to String
131 *
132 * @return
133 * VetexId
134 *
135 */
136 public String toString(){
137 return getId();
138
139 }
140
141
142
143 }