ClusterInputSlotNode.java revision 1472:c18cbe5936b8
1829SN/A/*
27424SN/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
3829SN/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4829SN/A *
5829SN/A * This code is free software; you can redistribute it and/or modify it
6829SN/A * under the terms of the GNU General Public License version 2 only, as
72362SN/A * published by the Free Software Foundation.
8829SN/A *
92362SN/A * This code is distributed in the hope that it will be useful, but WITHOUT
10829SN/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11829SN/A * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12829SN/A * version 2 for more details (a copy is included in the LICENSE file that
13829SN/A * accompanied this code).
14829SN/A *
15829SN/A * You should have received a copy of the GNU General Public License version
16829SN/A * 2 along with this work; if not, write to the Free Software Foundation,
17829SN/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18829SN/A *
19829SN/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20829SN/A * or visit www.oracle.com if you need additional information or have any
212362SN/A * questions.
222362SN/A *
232362SN/A */
24829SN/Apackage com.sun.hotspot.igv.hierarchicallayout;
2515409Sserb
26829SN/Aimport com.sun.hotspot.igv.layout.Cluster;
27829SN/Aimport com.sun.hotspot.igv.layout.Port;
28829SN/Aimport com.sun.hotspot.igv.layout.Vertex;
2913629Savstepanimport java.awt.Dimension;
30829SN/Aimport java.awt.Point;
31829SN/A
32829SN/A/**
337424SN/A *
34829SN/A * @author Thomas Wuerthinger
35829SN/A */
3614781Sdmarkovpublic class ClusterInputSlotNode implements Vertex {
3713629Savstepan
3813629Savstepan    private final int SIZE = 0;
39829SN/A    private Point position;
40829SN/A    private Port inputSlot;
41829SN/A    private Port outputSlot;
42829SN/A    private ClusterNode blockNode;
43829SN/A    private InterClusterConnection interBlockConnection;
44829SN/A    private Cluster cluster;
45829SN/A    private ClusterIngoingConnection conn;
46829SN/A
47829SN/A    public void setIngoingConnection(ClusterIngoingConnection c) {
482713SN/A        conn = c;
492713SN/A    }
502713SN/A
512713SN/A    public ClusterIngoingConnection getIngoingConnection() {
522713SN/A        return conn;
532713SN/A    }
54829SN/A    private String id;
55829SN/A
56829SN/A    @Override
57829SN/A    public String toString() {
58829SN/A        return id;
59829SN/A    }
60829SN/A
61829SN/A    public ClusterInputSlotNode(ClusterNode n, String id) {
62829SN/A        this.blockNode = n;
63829SN/A        this.id = id;
6413629Savstepan
65829SN/A        n.addSubNode(this);
66829SN/A
67829SN/A        final Vertex thisNode = this;
68829SN/A        final ClusterNode thisBlockNode = blockNode;
6913629Savstepan
7013629Savstepan        outputSlot = new Port() {
71829SN/A
729980SN/A            public Point getRelativePosition() {
73829SN/A                return new Point(0, 0);
74829SN/A            }
7513629Savstepan
76829SN/A            public Vertex getVertex() {
77829SN/A                return thisNode;
78829SN/A            }
79829SN/A
80829SN/A            @Override
81            public String toString() {
82                return "OutPort of " + thisNode.toString();
83            }
84        };
85
86        inputSlot = new Port() {
87
88            public Point getRelativePosition() {
89                Point p = new Point(thisNode.getPosition());
90                p.x += ClusterNode.BORDER;
91                p.y = 0;
92                return p;
93            }
94
95            public Vertex getVertex() {
96                return thisBlockNode;
97            }
98
99            @Override
100            public String toString() {
101                return "InPort of " + thisNode.toString();
102            }
103        };
104    }
105
106    public Port getInputSlot() {
107        return inputSlot;
108    }
109
110    public InterClusterConnection getInterBlockConnection() {
111        return interBlockConnection;
112    }
113
114    public Port getOutputSlot() {
115        return outputSlot;
116    }
117
118    public Dimension getSize() {
119        return new Dimension(SIZE, SIZE);
120    }
121
122    public void setPosition(Point p) {
123        this.position = p;
124    }
125
126    public Point getPosition() {
127        return position;
128    }
129
130    public void setInterBlockConnection(InterClusterConnection interBlockConnection) {
131        this.interBlockConnection = interBlockConnection;
132    }
133
134    public Cluster getCluster() {
135        return cluster;
136    }
137
138    public boolean isRoot() {
139        return true;
140    }
141
142    public int compareTo(Vertex o) {
143        return toString().compareTo(o.toString());
144    }
145}
146