20
19
private static final long serialVersionUID = -5155964364065651381L;
23
// Value of the capacity restriction; 0 means no capacity restriction
24
protected Integer capacity = 0;
26
21
protected static final int DIAMETER = Pipe.PLACE_TRANSITION_HEIGHT;
28
23
// Token Width and Height
41
36
protected static Ellipse2D.Double placeEllipse = new Ellipse2D.Double(0, 0, DIAMETER, DIAMETER);
42
37
protected static Shape proximityPlace = (new BasicStroke(Pipe.PLACE_TRANSITION_PROXIMITY_RADIUS)).createStrokedShape(placeEllipse);
47
super(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput);
48
componentWidth = DIAMETER;
49
componentHeight = DIAMETER;
44
53
public Place(double positionXInput, double positionYInput, String idInput,
45
Double nameOffsetXInput, Double nameOffsetYInput) {
46
super(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput);
47
componentWidth = DIAMETER;
48
componentHeight = DIAMETER;
49
setCentre((int) positionX, (int) positionY);
54
double nameOffsetXInput, double nameOffsetYInput) {
55
this((int)positionXInput, (int)positionYInput, idInput, (int)nameOffsetXInput, (int)nameOffsetYInput);
53
59
public Place(double positionXInput, double positionYInput) {
54
super(positionXInput, positionYInput);
55
componentWidth = DIAMETER;
56
componentHeight = DIAMETER;
57
setCentre((int) positionX, (int) positionY);
60
this((int)positionXInput, (int)positionYInput, null, 0,0);
63
public Place(int positionXInput, int positionYInput) {
64
this(positionXInput, positionYInput, null, 0,0);
89
96
* Returns the diameter of this Place at the current zoom
91
98
private int getDiameter() {
92
return (Zoomer.getZoomedValue(DIAMETER, zoom));
99
return (Zoomer.getZoomedValue(DIAMETER, getZoom()));
96
103
public boolean contains(int x, int y) {
97
double unZoomedX = Zoomer.getUnzoomedValue(x - COMPONENT_DRAW_OFFSET, zoom);
98
double unZoomedY = Zoomer.getUnzoomedValue(y - COMPONENT_DRAW_OFFSET, zoom);
104
double unZoomedX = Zoomer.getUnzoomedValue(x - COMPONENT_DRAW_OFFSET, getZoom());
105
double unZoomedY = Zoomer.getUnzoomedValue(y - COMPONENT_DRAW_OFFSET, getZoom());
100
Arc someArc = CreateGui.getDrawingSurface().createArc;
101
if (someArc != null) { // Must be drawing a new Arc if non-NULL.
102
if ((proximityPlace.contains((int) unZoomedX, (int) unZoomedY) || placeEllipse
103
.contains((int) unZoomedX, (int) unZoomedY))
104
&& areNotSameType(someArc.getSource())) {
105
// assume we are only snapping the target...
106
if (someArc.getTarget() != this) {
107
someArc.setTarget(this);
109
someArc.updateArcPosition();
112
if (someArc.getTarget() == this) {
113
someArc.setTarget(null);
107
Arc createArc = CreateGui.getDrawingSurface().createArc;
108
if (createArc != null) { // Must be drawing a new Arc if non-NULL.
109
return (proximityPlace.contains((int) unZoomedX, (int) unZoomedY) ||
110
placeEllipse.contains((int) unZoomedX, (int) unZoomedY));
119
112
return placeEllipse.contains((int) unZoomedX, (int) unZoomedY);
149
public void toggleAttributesVisible() {
150
attributesVisible = !attributesVisible;
155
public void addedToGui() {
161
142
public void update(boolean displayConstantNames) {
162
143
if (attributesVisible) {
144
getNameLabel().setText("");
146
getNameLabel().setText("");
167
pnName.zoomUpdate(zoom);
168
148
super.update(displayConstantNames);