summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/collection/gui/model/AggregationVertexOutlineCreator.java
blob: ed19f9cdbfcb882c611b6c93d67479ead47670d7 (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
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
{
    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)

                }
            );
    }
}