Repository navigation
Expand file tree
/
Copy pathGeneralObj.java
More file actions
executable file
·341 lines (264 loc) · 7.35 KB
/
Copy pathGeneralObj.java
File metadata and controls
executable file
·341 lines (264 loc) · 7.35 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
import java.awt.*;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.LinkedList;
//Written by: Michael Zimmer - mike@zimmerdesignservices.com
/*
Copyright 2007 Zimmer Design Services
This file is part of Fizzim.
Fizzim is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Fizzim is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public abstract class GeneralObj implements Cloneable {
public abstract void paintComponent(Graphics g);
public abstract boolean setSelectStatus(int x, int y);
//for select multiple
public abstract boolean setBoxSelectStatus(int x0, int y0, int x1, int y1);
public abstract void adjustShapeOrPosition(int x, int y);
public abstract int getSelectStatus();
public Object clone ()
throws CloneNotSupportedException
{
return super.clone();
}
public abstract Point getStart();
public abstract boolean containsParent(GeneralObj oldObj);
public abstract int getType();
public abstract boolean isModified();
public boolean modified = false;
public void setModified(boolean b)
{
modified = b;
}
public abstract void updateObj();
public abstract void unselect();
public boolean isParentModified()
{
return modifiedParent;
}
public boolean modifiedParent = false;
public void setParentModified(boolean b)
{
modifiedParent = b;
}
public abstract Point getCenter(int page);
public abstract void notifyChange(GeneralObj oldObj, GeneralObj clonedObj);
String objName;
//list of obj attributes for the object
LinkedList<ObjAttribute> attrib = new LinkedList<ObjAttribute>();
LinkedList<ObjAttribute> global;
LinkedList<LinkedList<ObjAttribute>> allGlobal;
public LinkedList<ObjAttribute> getAttributeList()
{
return attrib;
}
public int jumpCount = 0;
// updates the attribute list for a particular object by reading in the global list
public void updateAttrib(LinkedList<LinkedList<ObjAttribute>> glist, int a) {
global = glist.get(a);
allGlobal = glist;
for(int i = 0; i < global.size();i++)
{
ObjAttribute obj = global.get(i);
}
for(int i = 0; i < global.size(); i++)
{
ObjAttribute g = global.get(i);
ObjAttribute l = null;
if(attrib.size() > i)
l = attrib.get(i);
// if names match for current index
if(l != null && g.getName().equals(l.getName()))
{
//global attribute name can't be local
if(l.getEditable(0) == l.LOCAL)
l.setEditable(0,l.GLOBAL_FIXED);
//if blank string, make global variable
if(l.get(1).equals(""))
l.setEditable(1,l.GLOBAL_VAR);
if(l.get(3).equals(""))
l.setEditable(3,l.GLOBAL_VAR);
for(int j = 0; j < 7; j++)
{
// if value in field isn't locally set variable, replace with global
if(l.getEditable(j) != l.LOCAL)
l.set(j,g.get(j));
}
// checking for changed non-default value
if(l.getEditable(1) == ObjAttribute.LOCAL && g.getValue().equals(l.getValue()))
l.setEditable(1, ObjAttribute.GLOBAL_VAR);
}
//TODO rerun check on swapped lists
else
{
boolean breaker = false;
// look for attribute in wrong place
for(int k = 0; k < attrib.size(); k++)
{
ObjAttribute l2 = attrib.get(k);
//if one is found, fix it
if(g.getName().equals(l2.getName()))
{
attrib.addLast((ObjAttribute) attrib.get(i));
attrib.set(i,l2);
attrib.remove(k);
breaker = true;
break;
}
}
// if wasnt fixed, then it doesnt exist and needs to be created
if(!breaker)
{
ObjAttribute cloned = null;
try {
cloned = (ObjAttribute) g.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
if(cloned.getName().equals("name"))
{
cloned.setValue(objName);
cloned.setEditable(1, ObjAttribute.LOCAL);
}
attrib.add(i,cloned);
}
}
}
//delete attributes that were removed in global
if(attrib.size() > global.size())
{
for(int i = attrib.size()-1; i > global.size()-1; i--)
{
ObjAttribute obj = attrib.get(i);
if(obj.getEditable(0) != ObjAttribute.LOCAL)
attrib.remove(i);
}
}
// set up correct pages
for(int i = 0; i < attrib.size();i++)
{
ObjAttribute l = attrib.get(i);
l.setPage(myPage,"update");
// l.setOutputTypeFlag(true);
if(l.getType().equals("output"))
{
boolean b = false;
boolean f = false;
for(int j = 0; j < allGlobal.get(2).size(); j++)
{
ObjAttribute obj = allGlobal.get(2).get(j);
if(obj.getName().equals(l.getName()))
{
if(obj.getType().equals("reg") || obj.getType().equals("regdp"))
b = true;
if(obj.getType().equals("flag"))
f = true;
break;
}
}
l.setOutputTypeReg(b);
l.setOutputTypeFlag(f);
}
else
{
l.setOutputTypeReg(false);
l.setOutputTypeFlag(false);
}
}
}
public String getOutputType(String name)
{
LinkedList<ObjAttribute> list = allGlobal.get(2);
/// find output with matching name, and return its type
for(int i = 0; i < list.size(); i++)
{
ObjAttribute obj = list.get(i);
if(obj.getName().equals(name))
return obj.getType();
}
return "";
}
public String toString()
{
return objName;
}
public String getName()
{
return objName;
}
public void setName(String str)
{
objName = str;
}
public abstract void save(BufferedWriter writer) throws IOException;
//pages
int currPage = 1;
int myPage = 1;
public void paintComponent(Graphics g, int i)
{
currPage = i;
paintComponent(g);
if(attrib != null)
{
int step = -1;
for (int j = 0; j < attrib.size(); j++)
{
ObjAttribute obj = attrib.get(j);
if(obj.getVisible())
step++;
obj.paintComponent(g,currPage,getCenter(currPage),getSelectStatus(),step);
}
}
}
public int getPage()
{
return myPage;
}
public void setPage(int i)
{
myPage = i;
if(attrib != null)
{
for(int j = 0; j < attrib.size(); j++)
{
ObjAttribute obj = attrib.get(j);
if(getType() != 1)
obj.setPage(i);
}
}
}
public void decrementPage() {
myPage = myPage - 1;
if(attrib != null)
{
for(int i = 0; i < attrib.size(); i++)
{
ObjAttribute obj = attrib.get(i);
obj.setPage(myPage);
}
}
}
public boolean setBoxSelectStatus(int x, int y) {
return false;
}
public void setSelectStatus(boolean b) {
}
//indentation (also exits in FizzimGui.java and ObjAttribute.java
public String i(int indent)
{
String ind = "";
for(int i=0; i<indent; i++)
{
ind = ind + " ";
}
return ind;
}
}