From b305b9ae7e44ce00d947b44f9cc516cac74f6d70 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 29 Sep 2014 10:33:41 +0200 Subject: Merge vertex gui classes into main collection package to simplify --- .../java/com/c2kernel/collection/Aggregation.java | 2 - .../collection/AggregationVertexFactory.java | 36 ++++++++++++++++++ .../AggregationVertexOutlineCreator.java | 44 ++++++++++++++++++++++ .../gui/model/AggregationVertexFactory.java | 37 ------------------ .../gui/model/AggregationVertexOutlineCreator.java | 44 ---------------------- 5 files changed, 80 insertions(+), 83 deletions(-) create mode 100644 src/main/java/com/c2kernel/collection/AggregationVertexFactory.java create mode 100644 src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java delete mode 100644 src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java delete mode 100644 src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java (limited to 'src/main/java/com/c2kernel') diff --git a/src/main/java/com/c2kernel/collection/Aggregation.java b/src/main/java/com/c2kernel/collection/Aggregation.java index 12b24be..4b2b429 100644 --- a/src/main/java/com/c2kernel/collection/Aggregation.java +++ b/src/main/java/com/c2kernel/collection/Aggregation.java @@ -1,7 +1,5 @@ package com.c2kernel.collection; - -import com.c2kernel.collection.gui.model.AggregationVertexOutlineCreator; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.graph.model.GraphModel; import com.c2kernel.graph.model.GraphPoint; diff --git a/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java b/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java new file mode 100644 index 0000000..2c27a06 --- /dev/null +++ b/src/main/java/com/c2kernel/collection/AggregationVertexFactory.java @@ -0,0 +1,36 @@ +package com.c2kernel.collection; + +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; + + +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, + GraphPoint location, + TypeNameAndConstructionInfo typeNameAndConstructionInfo + ) throws Exception + { + if (typeNameAndConstructionInfo.mInfo.equals("AggregationMember")) { + mAggregation.addMember(null, new CastorHashMap(), "",location, 40, 40); + } + } +} + diff --git a/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java b/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java new file mode 100644 index 0000000..536566e --- /dev/null +++ b/src/main/java/com/c2kernel/collection/AggregationVertexOutlineCreator.java @@ -0,0 +1,44 @@ +package com.c2kernel.collection; + +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) + + } + ); + } +} diff --git a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java deleted file mode 100644 index 1a20c5e..0000000 --- a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.c2kernel.collection.gui.model; - -import com.c2kernel.collection.Aggregation; -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; - - -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, - GraphPoint location, - TypeNameAndConstructionInfo typeNameAndConstructionInfo - ) throws Exception - { - if (typeNameAndConstructionInfo.mInfo.equals("AggregationMember")) { - mAggregation.addMember(null, new CastorHashMap(), "",location, 40, 40); - } - } -} - diff --git a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java deleted file mode 100644 index b28af2e..0000000 --- a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java +++ /dev/null @@ -1,44 +0,0 @@ -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) - - } - ); - } -} -- cgit v1.2.3