summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/collection/gui/model/AggregationVertexFactory.java
blob: d99ef3cddbeaf27a74e5189025f8316c5c20d344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;


    public void setCreationContext(Object aggregation)
    {
        if (aggregation != null && aggregation instanceof Aggregation)
            mAggregation = (Aggregation)aggregation;
    }


    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);
            }
        }
    }
}