-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathInstCell.java
106 lines (87 loc) · 2.32 KB
/
InstCell.java
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.variamos.dynsup.instance;
import java.io.Serializable;
import com.mxgraph.model.mxCell;
/**
* A class to support clones of instance elements with shared values. Part of
* PhD work at University of Paris 1
*
* @author Juan C. Mu�oz Fern�ndez <[email protected]>
*
* @version 1.1
* @since 2015-01-29 *
*/
public class InstCell implements Serializable, Cloneable {
/**
*
*/
private static final long serialVersionUID = 2175833122091796227L;
private InstElement originalInstElement;
private InstElement volatileInstElement;
private boolean cloned;
private mxCell mxCellinst;
public InstCell() {
}
public InstCell(mxCell mxCellinst) {
this.mxCellinst = mxCellinst;
}
public InstCell(mxCell mxCellinst, InstElement instElement, boolean cloned) {
this.cloned = cloned;
if (cloned)
volatileInstElement = instElement;
else
originalInstElement = instElement;
this.mxCellinst = mxCellinst;
}
@Override
public InstCell clone() throws CloneNotSupportedException {
InstCell out = (InstCell) super.clone();
if (originalInstElement != null)
out.originalInstElement = originalInstElement.clone();
if (volatileInstElement != null)
out.volatileInstElement = volatileInstElement.clone();
return out;
}
public InstElement getOriginalInstElement() {
return originalInstElement;
}
public void setOriginalInstElement(InstElement originalInstElement) {
this.originalInstElement = originalInstElement;
}
public InstElement getInstElement() {
if (cloned)
return volatileInstElement;
else
return originalInstElement;
}
public boolean equals(Object o) {
if (getInstElement() != null && o != null
&& ((InstCell) o).getInstElement() != null)
return getInstElement().equals(((InstCell) o).getInstElement());
else
return false;
}
public void setInstElement(InstElement instElement) {
if (cloned)
this.volatileInstElement = instElement;
else
originalInstElement = instElement;
}
public boolean isCloned() {
return cloned;
}
public void setCloned(boolean cloned) {
this.cloned = cloned;
}
public String toString() {
if (getInstElement() != null)
return getInstElement().toString();
else
return null;
}
public double getWidth() {
return mxCellinst.getGeometry().getWidth();
}
public void setMxCell(mxCell cell) {
mxCellinst = cell;
}
}