summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/collection/gui/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/collection/gui/model')
-rw-r--r--src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java46
-rw-r--r--src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java44
2 files changed, 90 insertions, 0 deletions
diff --git a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java
new file mode 100644
index 0000000..cd4963f
--- /dev/null
+++ b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java
@@ -0,0 +1,46 @@
+package com.c2kernel.collection.gui.model;
+
+import java.awt.Point;
+
+import com.c2kernel.collection.Aggregation;
+import com.c2kernel.collection.MembershipException;
+import com.c2kernel.graph.model.GraphModelManager;
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
+import com.c2kernel.graph.model.VertexFactory;
+import com.c2kernel.utils.CastorHashMap;
+import com.c2kernel.utils.Logger;
+
+
+public class AggregationVertexFactory implements VertexFactory
+{
+ private Aggregation mAggregation = null;
+
+
+ @Override
+ public void setCreationContext(Object aggregation)
+ {
+ if (aggregation != null && aggregation instanceof Aggregation)
+ mAggregation = (Aggregation)aggregation;
+ }
+
+
+ @Override
+ public void create
+ (
+ GraphModelManager graphModelManager,
+ Point location,
+ TypeNameAndConstructionInfo typeNameAndConstructionInfo
+ )
+ {
+ if (typeNameAndConstructionInfo.mInfo.equals("AggregationMember")) {
+ try {
+ mAggregation.addMember(-1, new CastorHashMap(), "", new GraphPoint(location.x, location.y), 40, 40);
+ } catch (MembershipException ex) {
+ Logger.error(ex);
+ Logger.exceptionDialog(ex);
+ }
+ }
+ }
+}
+
diff --git a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java
new file mode 100644
index 0000000..b28af2e
--- /dev/null
+++ b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java
@@ -0,0 +1,44 @@
+package com.c2kernel.collection.gui.model;
+
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.graph.model.Vertex;
+import com.c2kernel.graph.model.VertexOutlineCreator;
+
+
+public class AggregationVertexOutlineCreator implements VertexOutlineCreator
+{
+ @Override
+ public void setOutline(Vertex vertex)
+ {
+ GraphPoint centre = vertex.getCentrePoint();
+ int height = vertex.getHeight();
+ int width = vertex.getWidth();
+
+
+ if (height==0 || width==0)
+ vertex.setOutlinePoints
+ (
+ new GraphPoint[]
+ {
+ new GraphPoint(centre.x-20, centre.y-20),
+ new GraphPoint(centre.x+20, centre.y-20),
+ new GraphPoint(centre.x+20, centre.y+20),
+ new GraphPoint(centre.x-20, centre.y+20)
+
+ }
+ );
+ else
+
+ vertex.setOutlinePoints
+ (
+ new GraphPoint[]
+ {
+ new GraphPoint(centre.x-width/2, centre.y-height/2),
+ new GraphPoint(centre.x+width/2, centre.y-height/2),
+ new GraphPoint(centre.x+width/2, centre.y+height/2),
+ new GraphPoint(centre.x-width/2, centre.y+height/2)
+
+ }
+ );
+ }
+}