001: package org.enhydra.jawe.components.graph;
002:
003: /**
004: * Info structure for start/end element description.
005: *
006: * @author Sasa Bojanic
007: */
008: import java.awt.Point;
009:
010: import org.enhydra.shark.xpdl.elements.ExtendedAttribute;
011:
012: public final class StartEndDescription {
013:
014: private String actSetId = null;
015: private String participantId = FreeTextExpressionParticipant
016: .getInstance().getId();
017: private String actId = null;
018: private Point offset = new Point(0, 0);
019: private String transitionStyle = GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_NO_ROUTING_ORTHOGONAL;
020: private String type = GraphEAConstants.START_TYPE_DEFAULT;
021: private String eaname;
022:
023: boolean isStart = true;
024:
025: public StartEndDescription() {
026:
027: }
028:
029: public StartEndDescription(ExtendedAttribute ea) {
030: this (ea.getName(), ea.getVValue());
031: }
032:
033: public StartEndDescription(String eaname, String eaval) {
034: try {
035: setEAName(eaname);
036:
037: // System.out.println("ean="+eaname+", eaval="+eaval);
038: // String[] startOrEndD=Utils.tokenize(eaval, ",");
039: int ind = 0;
040: int ind2 = 0;
041: if (eaname.indexOf("BLOCK") >= 0) {
042: ind = eaval
043: .indexOf(GraphEAConstants.EA_PART_ACTIVITY_SET_ID
044: + "=");
045: ind2 = eaval.indexOf(","
046: + GraphEAConstants.EA_JAWE_GRAPH_PARTICIPANT_ID
047: + "=", ind);
048: String asId = eaval
049: .substring(
050: ind
051: + (GraphEAConstants.EA_PART_ACTIVITY_SET_ID + "=")
052: .length(), ind2);
053: setActSetId(asId);
054: ind = ind2 + 1;
055: }
056:
057: ind2 = eaval.indexOf(","
058: + GraphEAConstants.EA_PART_CONNECTING_ACTIVITY_ID
059: + "=", ind);
060: String parId = eaval
061: .substring(
062: ind
063: + (GraphEAConstants.EA_JAWE_GRAPH_PARTICIPANT_ID + "=")
064: .length(), ind2);
065: setParticipantId(parId);
066: ind = ind2 + 1;
067:
068: ind2 = eaval.indexOf(","
069: + GraphEAConstants.EA_PART_GRAPH_OFFSET_X + "=",
070: ind);
071: String aId = eaval
072: .substring(
073: ind
074: + (GraphEAConstants.EA_PART_CONNECTING_ACTIVITY_ID + "=")
075: .length(), ind2);
076: if (!(aId == null || aId.equals(""))) {
077: setActId(aId);
078: }
079: ind = ind2 + 1;
080:
081: Point temp_offset = new Point(0, 0);
082: ind2 = eaval.indexOf(","
083: + GraphEAConstants.EA_PART_GRAPH_OFFSET_Y + "=",
084: ind);
085: String off = eaval.substring(ind
086: + (GraphEAConstants.EA_PART_GRAPH_OFFSET_X + "=")
087: .length(), ind2);
088: temp_offset.x = Integer.parseInt(off);
089: ind = ind2 + 1;
090:
091: ind2 = eaval.indexOf(","
092: + GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE
093: + "=", ind);
094: off = eaval.substring(ind
095: + (GraphEAConstants.EA_PART_GRAPH_OFFSET_Y + "=")
096: .length(), ind2);
097: temp_offset.y = Integer.parseInt(off);
098: setOffset(temp_offset);
099: ind = ind2 + 1;
100:
101: ind2 = eaval.indexOf("," + GraphEAConstants.EA_PART_TYPE
102: + "=", ind);
103: String ts = eaval
104: .substring(
105: ind
106: + (GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE + "=")
107: .length(), ind2);
108: setTransitonStyle(ts);
109: ind = ind2 + 1;
110:
111: String temp_type = eaval.substring(ind
112: + (GraphEAConstants.EA_PART_TYPE + "=").length());
113: setType(temp_type);
114: } catch (Exception ex) {
115: System.err.println("Exception while parsing start/end ea");
116: ex.printStackTrace();
117: }
118: }
119:
120: public String getActId() {
121: return this .actId;
122: }
123:
124: public void setActId(String actId) {
125: this .actId = actId;
126: }
127:
128: public String getActSetId() {
129: return this .actSetId;
130: }
131:
132: public void setActSetId(String actSetId) {
133: this .actSetId = actSetId;
134: }
135:
136: public String getParticipantId() {
137: return this .participantId;
138: }
139:
140: public void setParticipantId(String participantId) {
141: this .participantId = participantId;
142: }
143:
144: public String getTransitionStyle() {
145: return this .transitionStyle;
146: }
147:
148: public void setTransitonStyle(String transitionStyle) {
149: this .transitionStyle = transitionStyle;
150: }
151:
152: public Point getOffset() {
153: return this .offset;
154: }
155:
156: public void setOffset(Point offset) {
157: this .offset = offset;
158: }
159:
160: public void setType(String type) {
161: this .type = type;
162: }
163:
164: public String getType() {
165: return this .type;
166: }
167:
168: public String getEAName() {
169: return eaname;
170: }
171:
172: public void setEAName(String eaname) {
173: this .eaname = eaname;
174: }
175:
176: public boolean isStart() {
177: return eaname.indexOf("START") >= 0;
178: }
179:
180: public String toString() {
181: String ret = "";
182: if (actSetId != null)
183: ret += GraphEAConstants.EA_PART_ACTIVITY_SET_ID + "="
184: + actSetId + ",";
185: ret += GraphEAConstants.EA_JAWE_GRAPH_PARTICIPANT_ID + "="
186: + participantId + ",";
187: ret += GraphEAConstants.EA_PART_CONNECTING_ACTIVITY_ID + "=";
188: if (actId != null) {
189: ret += actId;
190: }
191: ret += ",";
192: ret += GraphEAConstants.EA_PART_GRAPH_OFFSET_X + "="
193: + String.valueOf(offset.x) + ",";
194: ret += GraphEAConstants.EA_PART_GRAPH_OFFSET_Y + "="
195: + String.valueOf(offset.y) + ",";
196: ret += GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE + "="
197: + transitionStyle + ",";
198: ret += GraphEAConstants.EA_PART_TYPE + "=" + type;
199: return ret;
200: }
201: }
|