~ubuntu-branches/ubuntu/maverick/electric/maverick

« back to all changes in this revision

Viewing changes to com/sun/electric/database/topology/IconNodeInst.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-01-09 16:26:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109162604-1ypvmy8ijmlc6oq7
Tags: 8.10-1
* New upstream version.
* debian/control
  - Add libjava3d-java and quilt build dependencies.
  - Update standards version to 3.8.3.
  - Add libjava3d-java as recommends to binary package.
* debian/rules
  - Use quilt patch system instead of simple patchsys.
  - Add java3d related jar files to DEB_JARS.
* debian/patches/*
  - Update as per current upstream source. Convert to quilt.
* debian/ant.properties
  - Do not disable 3D plugin anymore.
  - Use new property to disable compilation of OS X related classes.
* debian/wrappers/electric
  - Add java3d related jar files to runtime classpath.
* debian/README.source
  - Change text to the appropriate one for quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import com.sun.electric.database.ImmutableIconInst;
27
27
import com.sun.electric.database.ImmutableNodeInst;
28
28
import com.sun.electric.database.hierarchy.Cell;
 
29
import com.sun.electric.database.hierarchy.Nodable;
 
30
import com.sun.electric.database.prototype.NodeProto;
29
31
import com.sun.electric.database.text.ArrayIterator;
 
32
import com.sun.electric.database.text.Name;
30
33
import com.sun.electric.database.variable.CodeExpression;
31
34
import com.sun.electric.database.variable.ElectricObject;
32
35
import com.sun.electric.database.variable.TextDescriptor;
38
41
/**
39
42
 * Class defines NodeInsts that are icons.
40
43
 */
41
 
class IconNodeInst extends NodeInst
42
 
{
43
 
        /**
44
 
         * The constructor of IconNodeInst. Use the factory "newInstance" instead.
 
44
public class IconNodeInst extends NodeInst {
 
45
 
 
46
    private IconNodable[] nodables;
 
47
 
 
48
    /**
 
49
     * The constructor of IconNodeInst. Use the factory "newInstance" instead.
45
50
     * @param d persistent data of this IconNodeInst.
46
 
         * @param parent the Cell in which this IconNodeInst will reside.
47
 
         */
48
 
    IconNodeInst(ImmutableNodeInst d, Cell parent) {
49
 
        super(d, parent);
 
51
     * @param topology the Topology in which this IconNodeInst will reside.
 
52
     */
 
53
    IconNodeInst(ImmutableNodeInst d, Topology topology) {
 
54
        super(d, topology);
50
55
    }
51
56
 
52
57
    /**
54
59
     * @return persistent data of this IconNodeInst.
55
60
     */
56
61
    @Override
57
 
    public ImmutableIconInst getD() { return (ImmutableIconInst)super.getD(); }
58
 
 
59
 
        /**
60
 
         * Method to add a Variable on this IconNodeInst.
61
 
         * It may add a repaired copy of this Variable in some cases.
62
 
         * @param var Variable to add.
63
 
         */
64
 
    @Override
65
 
        public void addVar(Variable var) {
66
 
        if (isParam(var.getKey()))
 
62
    public ImmutableIconInst getD() {
 
63
        return (ImmutableIconInst) super.getD();
 
64
    }
 
65
 
 
66
    /**
 
67
     * Modifies persistend data of this NodeInst.
 
68
     * @param newD new persistent data.
 
69
     * @param notify true to notify Undo system.
 
70
     * @return true if persistent data was modified.
 
71
     */
 
72
    @Override
 
73
    public boolean setD(ImmutableNodeInst newD, boolean notify) {
 
74
        ImmutableIconInst oldD = getD();
 
75
        if (newD.name != oldD.name) {
 
76
            nodables = null;
 
77
        }
 
78
        return super.setD(newD, notify);
 
79
    }
 
80
 
 
81
    @Override
 
82
    public void setDInUndo(ImmutableNodeInst newD) {
 
83
        ImmutableIconInst oldD = getD();
 
84
        if (newD.name != oldD.name) {
 
85
            nodables = null;
 
86
        }
 
87
        super.setDInUndo(newD);
 
88
    }
 
89
 
 
90
    /**
 
91
     * Method to return the prototype of this IconNodeInst.
 
92
     * @return the prototype of this IconNodeInst.
 
93
     */
 
94
    @Override
 
95
    public Cell getProto() {
 
96
        return (Cell) super.getProto();
 
97
    }
 
98
 
 
99
    /**
 
100
     * Method to add a Variable on this IconNodeInst.
 
101
     * It may add a repaired copy of this Variable in some cases.
 
102
     * @param var Variable to add.
 
103
     */
 
104
    @Override
 
105
    public void addVar(Variable var) {
 
106
        if (isParam(var.getKey())) {
67
107
            throw new IllegalArgumentException(this + " already has a variable with name " + var);
 
108
        }
68
109
        super.addVar(var.withParam(false).withInherit(false));
69
110
    }
70
111
 
71
 
        /**
72
 
         * Method to return the Variable on this ElectricObject with a given key.
73
 
         * @param key the key of the Variable.
74
 
         * @return the Variable with that key and type, or null if there is no such Variable
75
 
         * or default Variable value.
 
112
    /**
 
113
     * Method to return the Variable on this ElectricObject with a given key.
 
114
     * @param key the key of the Variable.
 
115
     * @return the Variable with that key and type, or null if there is no such Variable
 
116
     * or default Variable value.
76
117
     * @throws NullPointerException if key is null
77
 
         */
 
118
     */
78
119
    @Override
79
 
        public Variable getVar(Variable.Key key)
80
 
        {
81
 
                checkExamine();
 
120
    public Variable getVar(Variable.Key key) {
 
121
        checkExamine();
82
122
        if (key.isAttribute()) {
83
123
            // ToDo: delete
84
 
            Variable param = getParameter((Variable.AttrKey)key);
85
 
            if (param != null)
 
124
            Variable param = getParameter((Variable.AttrKey) key);
 
125
            if (param != null) {
86
126
                return param;
 
127
            }
87
128
        }
88
 
                return getD().getVar(key);
89
 
        }
 
129
        return getD().getVar(key);
 
130
    }
90
131
 
91
 
        /**
92
 
         * Method to return the Parameter or Variable on this ElectricObject with a given key.
93
 
         * @param key the key of the Parameter or Variable.
94
 
         * @return the Parameter or Variable with that key, or null if there is no such Parameter or Variable Variable.
 
132
    /**
 
133
     * Method to return the Parameter or Variable on this ElectricObject with a given key.
 
134
     * @param key the key of the Parameter or Variable.
 
135
     * @return the Parameter or Variable with that key, or null if there is no such Parameter or Variable Variable.
95
136
     * @throws NullPointerException if key is null
96
 
         */
 
137
     */
97
138
    @Override
98
 
        public Variable getParameterOrVariable(Variable.Key key) {
 
139
    public Variable getParameterOrVariable(Variable.Key key) {
99
140
        checkExamine();
100
141
        if (key.isAttribute()) {
101
 
            Variable param = getParameter((Variable.AttrKey)key);
102
 
            if (param != null)
 
142
            Variable param = getParameter((Variable.AttrKey) key);
 
143
            if (param != null) {
103
144
                return param;
 
145
            }
104
146
        }
105
 
                return getD().getVar(key);
106
 
        }
 
147
        return getD().getVar(key);
 
148
    }
107
149
 
108
 
        /**
109
 
         * Method to return an Iterator over all Parameters and Variables on this ElectricObject.
110
 
         * @return an Iterator over all Parameters and Variables on this ElectricObject.
111
 
         */
 
150
    /**
 
151
     * Method to return an Iterator over all Parameters and Variables on this ElectricObject.
 
152
     * @return an Iterator over all Parameters and Variables on this ElectricObject.
 
153
     */
112
154
    @Override
113
 
        public Iterator<Variable> getParametersAndVariables() {
114
 
        if (getD().getNumDefinedParameters() == 0)
 
155
    public Iterator<Variable> getParametersAndVariables() {
 
156
        if (getD().getNumDefinedParameters() == 0) {
115
157
            return getVariables();
 
158
        }
116
159
 
117
160
        ArrayList<Variable> vars = new ArrayList<Variable>();
118
 
        for (Iterator<Variable> it = getDefinedParameters(); it.hasNext(); )
 
161
        for (Iterator<Variable> it = getDefinedParameters(); it.hasNext();) {
119
162
            vars.add(it.next());
120
 
        for (Iterator<Variable> it = getVariables(); it.hasNext(); ) {
 
163
        }
 
164
        for (Iterator<Variable> it = getVariables(); it.hasNext();) {
121
165
            vars.add(it.next());
122
166
        }
123
167
        return vars.iterator();
133
177
     */
134
178
    @Override
135
179
    public Variable getParameter(Variable.Key key) {
136
 
        if (!(key instanceof Variable.AttrKey))
 
180
        if (!(key instanceof Variable.AttrKey)) {
137
181
            return null;
138
 
        Variable instParam = getD().getDefinedParameter((Variable.AttrKey)key);
139
 
        if (instParam != null)
 
182
        }
 
183
        Variable instParam = getD().getDefinedParameter((Variable.AttrKey) key);
 
184
        if (instParam != null) {
140
185
            return instParam;
141
 
        Cell icon = (Cell)getProto();
 
186
        }
 
187
        Cell icon = (Cell) getProto();
142
188
        Variable iconParam = icon.getParameter(key);
143
189
        return iconParam != null ? composeInstParam(iconParam, null) : null;
144
190
    }
151
197
     */
152
198
    @Override
153
199
    public boolean isDefinedParameter(Variable.Key key) {
154
 
        if (!(key instanceof Variable.AttrKey))
 
200
        if (!(key instanceof Variable.AttrKey)) {
155
201
            return false;
156
 
        return getD().getDefinedParameter((Variable.AttrKey)key) != null;
 
202
        }
 
203
        return getD().getDefinedParameter((Variable.AttrKey) key) != null;
157
204
    }
158
205
 
159
206
    /**
163
210
     */
164
211
    @Override
165
212
    public Iterator<Variable> getParameters() {
166
 
        Cell icon = (Cell)getProto();
167
 
        if (!icon.hasParameters())
 
213
        Cell icon = (Cell) getProto();
 
214
        if (!icon.hasParameters()) {
168
215
            return ArrayIterator.emptyIterator();
 
216
        }
169
217
 
170
218
        ArrayList<Variable> params = new ArrayList<Variable>();
171
219
        // get all parameters on this object
172
 
        for (Iterator<Variable> it = icon.getParameters(); it.hasNext(); ) {
 
220
        for (Iterator<Variable> it = icon.getParameters(); it.hasNext();) {
173
221
            Variable iconParam = it.next();
174
 
            Variable instVar = getD().getDefinedParameter((Variable.AttrKey)iconParam.getKey());
 
222
            Variable instVar = getD().getDefinedParameter((Variable.AttrKey) iconParam.getKey());
175
223
            params.add(composeInstParam(iconParam, instVar));
176
224
        }
177
225
        return params.iterator();
190
238
    /**
191
239
     * Method to add a Parameter to this NodeInst.
192
240
     * Overridden in IconNodeInst
193
 
     * @param key the key of the Variable to delete.
 
241
     * @param param the Variable to delete.
194
242
     */
195
243
    public void addParameter(Variable param) {
196
 
        if (!isParam(param.getKey()))
 
244
        if (!isParam(param.getKey())) {
197
245
            throw new IllegalArgumentException("Parameter " + param + " is not defined on " + getProto());
198
 
        Cell icon = (Cell)getProto();
 
246
        }
 
247
        Cell icon = (Cell) getProto();
199
248
        Variable iconParam = icon.getParameter(param.getKey());
200
249
        param = composeInstParam(iconParam, param);
201
 
        if (setD(getD().withParam(param), true))
202
 
            // check for side-effects of the change
 
250
        if (setD(getD().withParam(param), true)) // check for side-effects of the change
 
251
        {
203
252
            checkPossibleVariableEffects(param.getKey());
 
253
        }
204
254
    }
205
255
 
206
256
    /**
210
260
     */
211
261
    @Override
212
262
    public void delParameter(Variable.Key key) {
213
 
        if (key instanceof Variable.AttrKey && setD(getD().withoutParam((Variable.AttrKey)key), true))
214
 
            // check for side-effects of the change
 
263
        if (key instanceof Variable.AttrKey && setD(getD().withoutParam((Variable.AttrKey) key), true)) // check for side-effects of the change
 
264
        {
215
265
            checkPossibleVariableEffects(key);
 
266
        }
216
267
    }
217
268
 
218
 
        /**
219
 
         * Method to return true if the Variable on this NodeInst with given key is a parameter.
220
 
         * Parameters are those Variables that have values on instances which are
221
 
         * passed down the hierarchy into the contents.
 
269
    /**
 
270
     * Method to return true if the Variable on this NodeInst with given key is a parameter.
 
271
     * Parameters are those Variables that have values on instances which are
 
272
     * passed down the hierarchy into the contents.
222
273
     * @param varKey key to test
223
 
         * @return true if the Variable with given key is a parameter.
224
 
         */
 
274
     * @return true if the Variable with given key is a parameter.
 
275
     */
225
276
    @Override
226
277
    public boolean isParam(Variable.Key varKey) {
227
 
        Cell icon = (Cell)getProto();
 
278
        Cell icon = (Cell) getProto();
228
279
        return icon.isParam(varKey);
229
280
    }
230
281
 
231
 
        /**
232
 
         * Updates the TextDescriptor on this NodeInst selected by varKey.
233
 
         * The varKey may be a key of variable on this NodeInst or one of the
234
 
         * special keys:
235
 
         * NodeInst.NODE_NAME
236
 
         * NodeInst.NODE_PROTO
237
 
         * If varKey doesn't select any text descriptor, no action is performed.
238
 
         * The TextDescriptor gives information for displaying the Variable.
239
 
         * @param varKey key of variable or special key.
240
 
         * @param td new value TextDescriptor
241
 
         */
 
282
    /**
 
283
     * Updates the TextDescriptor on this NodeInst selected by varKey.
 
284
     * The varKey may be a key of variable on this NodeInst or one of the
 
285
     * special keys:
 
286
     * NodeInst.NODE_NAME
 
287
     * NodeInst.NODE_PROTO
 
288
     * If varKey doesn't select any text descriptor, no action is performed.
 
289
     * The TextDescriptor gives information for displaying the Variable.
 
290
     * @param varKey key of variable or special key.
 
291
     * @param td new value TextDescriptor
 
292
     */
242
293
    @Override
243
 
        public void setTextDescriptor(Variable.Key varKey, TextDescriptor td)
244
 
        {
 
294
    public void setTextDescriptor(Variable.Key varKey, TextDescriptor td) {
245
295
        Variable param = getParameter(varKey);
246
296
        if (param != null) {
247
297
            td = td.withParam(true).withInherit(false).withUnit(param.getUnit());
251
301
        super.setTextDescriptor(varKey, td);
252
302
    }
253
303
 
254
 
        /**
255
 
         * Method to create a Variable on this ElectricObject with the specified values.
256
 
         * @param key the key of the Variable.
257
 
         * @param value the object to store in the Variable.
258
 
         * @param td text descriptor of the Variable
259
 
         * @return the Variable that has been created.
260
 
         */
 
304
    /**
 
305
     * Method to create a Variable on this ElectricObject with the specified values.
 
306
     * @param key the key of the Variable.
 
307
     * @param value the object to store in the Variable.
 
308
     * @param td text descriptor of the Variable
 
309
     * @return the Variable that has been created.
 
310
     */
261
311
    @Override
262
 
        public Variable newVar(Variable.Key key, Object value, TextDescriptor td)
263
 
        {
 
312
    public Variable newVar(Variable.Key key, Object value, TextDescriptor td) {
264
313
        if (isParam(key)) {
265
314
            addParameter(getParameter(key).withObject(value).withTextDescriptor(td));
266
315
            return getParameter(key);
267
316
        }
268
 
                return super.newVar(key, value, td);
269
 
        }
270
 
 
271
 
        /**
272
 
         * Method to update a Variable on this ElectricObject with the specified values.
273
 
         * If the Variable already exists, only the value is changed; the displayable attributes are preserved.
274
 
         * @param key the key of the Variable.
275
 
         * @param value the object to store in the Variable.
276
 
         * @return the Variable that has been updated.
277
 
         */
278
 
    @Override
279
 
        public Variable updateVar(Variable.Key key, Object value)
280
 
        {
281
 
        if (isParam(key)) {
282
 
                Variable param = getParameter(key);
283
 
            addParameter(getParameter(key).withObject(value));
284
 
            return getParameter(key);
285
 
        }
286
 
                return super.updateVar(key, value);
287
 
        }
288
 
 
289
 
        /**
290
 
         * Method to update a Parameter on this ElectricObject with the specified values.
291
 
         * If the Variable already exists, only the value is changed; the displayable attributes are preserved.
292
 
         * @param key the key of the Variable.
293
 
         * @param value the object to store in the Variable.
294
 
         * @return the Variable that has been updated.
295
 
         */
296
 
    @Override
297
 
        public Variable updateParam(Variable.Key key, Object value)
298
 
        {
299
 
        if (isParam(key)) {
300
 
                Variable param = getParameter(key);
301
 
            addParameter(getParameter(key).withObject(value));
302
 
            return getParameter(key);
303
 
        }
304
 
                return super.updateVar(key, value);
305
 
        }
306
 
 
307
 
        /**
308
 
         * Method to update a text Variable on this ElectricObject with the specified values.
309
 
         * If the Variable already exists, only the value is changed;
 
317
        return super.newVar(key, value, td);
 
318
    }
 
319
 
 
320
    /**
 
321
     * Method to update a Variable on this ElectricObject with the specified values.
 
322
     * If the Variable already exists, only the value is changed; the displayable attributes are preserved.
 
323
     * @param key the key of the Variable.
 
324
     * @param value the object to store in the Variable.
 
325
     * @return the Variable that has been updated.
 
326
     */
 
327
    @Override
 
328
    public Variable updateVar(Variable.Key key, Object value) {
 
329
        if (isParam(key)) {
 
330
            Variable param = getParameter(key);
 
331
            addParameter(getParameter(key).withObject(value));
 
332
            return getParameter(key);
 
333
        }
 
334
        return super.updateVar(key, value);
 
335
    }
 
336
 
 
337
    /**
 
338
     * Method to update a Parameter on this ElectricObject with the specified values.
 
339
     * If the Variable already exists, only the value is changed; the displayable attributes are preserved.
 
340
     * @param key the key of the Variable.
 
341
     * @param value the object to store in the Variable.
 
342
     * @return the Variable that has been updated.
 
343
     */
 
344
    @Override
 
345
    public Variable updateParam(Variable.Key key, Object value) {
 
346
        if (isParam(key)) {
 
347
            Variable param = getParameter(key);
 
348
            addParameter(getParameter(key).withObject(value));
 
349
            return getParameter(key);
 
350
        }
 
351
        return super.updateVar(key, value);
 
352
    }
 
353
 
 
354
    /**
 
355
     * Method to update a text Variable on this ElectricObject with the specified values.
 
356
     * If the Variable already exists, only the value is changed;
310
357
     * the displayable attributes and Code are preserved.
311
 
         * @param key the key of the Variable.
312
 
         * @param text the text to store in the Variable.
313
 
         * @return the Variable that has been updated.
314
 
         */
 
358
     * @param key the key of the Variable.
 
359
     * @param text the text to store in the Variable.
 
360
     * @return the Variable that has been updated.
 
361
     */
315
362
    @Override
316
 
        public Variable updateVarText(Variable.Key key, String text)
317
 
        {
 
363
    public Variable updateVarText(Variable.Key key, String text) {
318
364
        if (isParam(key)) {
319
 
                Variable param = getParameter(key);
 
365
            Variable param = getParameter(key);
320
366
            addParameter(getParameter(key).withText(text));
321
367
            return getParameter(key);
322
368
        }
323
 
                return super.updateVarText(key, text);
324
 
        }
 
369
        return super.updateVarText(key, text);
 
370
    }
325
371
 
326
 
        /**
327
 
         * Method to update a Variable on this ElectricObject with the specified code.
328
 
         * If the Variable already exists, only the code is changed;
 
372
    /**
 
373
     * Method to update a Variable on this ElectricObject with the specified code.
 
374
     * If the Variable already exists, only the code is changed;
329
375
     * the displayable attributes and value are preserved.
330
 
         * @param key the key of the Variable.
331
 
         * @param code the new code of the Variable.
332
 
         * @return the Variable that has been updated.
333
 
         */
 
376
     * @param key the key of the Variable.
 
377
     * @param code the new code of the Variable.
 
378
     * @return the Variable that has been updated.
 
379
     */
334
380
    @Override
335
 
        public Variable updateVarCode(Variable.Key key, CodeExpression.Code code)
336
 
        {
 
381
    public Variable updateVarCode(Variable.Key key, CodeExpression.Code code) {
337
382
        if (isParam(key)) {
338
 
                Variable param = getParameter(key);
 
383
            Variable param = getParameter(key);
339
384
            addParameter(getParameter(key).withCode(code));
340
385
            return getParameter(key);
341
386
        }
342
 
                return super.updateVarCode(key, code);
343
 
        }
 
387
        return super.updateVarCode(key, code);
 
388
    }
344
389
 
345
 
        /**
346
 
         * Method to copy all variables from another ElectricObject to this ElectricObject.
347
 
         * @param other the other ElectricObject from which to copy Variables.
348
 
         */
 
390
    /**
 
391
     * Method to copy all variables from another ElectricObject to this ElectricObject.
 
392
     * @param other the other ElectricObject from which to copy Variables.
 
393
     */
349
394
    @Override
350
 
        public void copyVarsFrom(ElectricObject other)
351
 
        {
352
 
                checkChanging();
353
 
                for (Iterator<Variable> it = other.getParametersAndVariables(); it.hasNext(); ) {
 
395
    public void copyVarsFrom(ElectricObject other) {
 
396
        checkChanging();
 
397
        for (Iterator<Variable> it = other.getParametersAndVariables(); it.hasNext();) {
354
398
            Variable var = it.next();
355
 
            if (isParam(var.getKey()))
 
399
            if (isParam(var.getKey())) {
356
400
                addParameter(var.withParam(true));
357
 
            else
 
401
            } else {
358
402
                addVar(var.withParam(false));
 
403
            }
359
404
        }
360
 
        }
 
405
    }
361
406
 
362
407
//    public void addParam(Variable var) {
363
408
//        assert var.getTextDescriptor().isParam() && var.isInherit();
373
418
//
374
419
    private static Variable composeInstParam(Variable iconParam, Variable instVar) {
375
420
        boolean display = !iconParam.isInterior();
376
 
        if (instVar != null)
 
421
        if (instVar != null) {
377
422
            return instVar.withParam(true).withInherit(false).withInterior(false).withDisplay(display).withUnit(iconParam.getUnit());
 
423
        }
378
424
        return iconParam.withInherit(false).withInterior(false).withDisplay(display);
379
425
    }
 
426
 
 
427
    /**
 
428
     * Get Nodable by array index.
 
429
     * @param arrayIndex the Nodable index.
 
430
     * @return the desired Nodable.
 
431
     */
 
432
    @Override
 
433
    public Nodable getNodable(int arrayIndex) {
 
434
        if (nodables == null) {
 
435
            nodables = new IconNodable[getNameKey().busWidth()];
 
436
            for (int i = 0; i < nodables.length; i++) {
 
437
                nodables[i] = new IconNodable(i);
 
438
            }
 
439
        }
 
440
        return nodables[arrayIndex];
 
441
    }
 
442
 
 
443
    private class IconNodable implements Nodable {
 
444
 
 
445
        int arrayIndex;
 
446
 
 
447
        IconNodable(int arrayIndex) {
 
448
            this.arrayIndex = arrayIndex;
 
449
        }
 
450
 
 
451
        /**
 
452
         * Method to return the prototype of this Nodable.
 
453
         * @return the prototype of this Nodable.
 
454
         */
 
455
        public NodeProto getProto() {
 
456
            Cell iconCell = IconNodeInst.this.getProto();
 
457
            Cell mainSchematics = iconCell.getCellGroup().getMainSchematics();
 
458
            return mainSchematics != null ? mainSchematics : iconCell;
 
459
        }
 
460
 
 
461
        /**
 
462
         * Method to tell whether this is a cell instance.
 
463
         * @return true becaue NetSchem objects are always cell instances.
 
464
         */
 
465
        public boolean isCellInstance() {
 
466
            return true;
 
467
        }
 
468
 
 
469
        /**
 
470
         * Method to return the Cell that contains this Nodable.
 
471
         * @return the Cell that contains this Nodable.
 
472
         */
 
473
        public Cell getParent() {
 
474
            return IconNodeInst.this.getParent();
 
475
        }
 
476
 
 
477
        /**
 
478
         * Method to return the name of this Nodable.
 
479
         * @return the name of this Nodable.
 
480
         */
 
481
        public String getName() {
 
482
            return getNameKey().toString();
 
483
        }
 
484
 
 
485
        /**
 
486
         * Method to return the name key of this Nodable.
 
487
         * @return the name key of this Nodable.
 
488
         */
 
489
        public Name getNameKey() {
 
490
            return IconNodeInst.this.getNameKey().subname(arrayIndex);
 
491
        }
 
492
 
 
493
        /**
 
494
         * Method to return the Variable on this ElectricObject with a given key.
 
495
         * @param key the key of the Variable.
 
496
         * @return the Variable with that key, or null if there is no such Variable.
 
497
         */
 
498
        public Variable getVar(Variable.Key key) {
 
499
            return IconNodeInst.this.getVar(key);
 
500
        }
 
501
 
 
502
        /**
 
503
         * Method to return the Parameter on this Nodable with the given key.
 
504
         * If the parameter is not found on this Nodable, it
 
505
         * is also searched for on the default var owner.
 
506
         * @param key the key of the parameter
 
507
         * @return the Parameter with that key, that may exist either on this Nodable
 
508
         * or the default owner.  Returns null if none found.
 
509
         */
 
510
        public Variable getParameter(Variable.Key key) {
 
511
            return IconNodeInst.this.getParameter(key);
 
512
        }
 
513
 
 
514
        /**
 
515
         * Method to return the Parameter or Variable on this Nodable with a given key.
 
516
         * @param key the key of the Parameter or Variable.
 
517
         * @return the Parameter or Variable with that key, or null if there is no such Parameter or Variable Variable.
 
518
         * @throws NullPointerException if key is null
 
519
         */
 
520
        public Variable getParameterOrVariable(Variable.Key key) {
 
521
            return IconNodeInst.this.getParameterOrVariable(key);
 
522
        }
 
523
 
 
524
        /**
 
525
         * Method to tell if the Variable.Key is a defined parameters of this Nodable.
 
526
         * Parameters which are not defined on Nodable take default values from Icon Cell.
 
527
         * @param key the key of the parameter
 
528
         * @return true if the key is a definded parameter of this Nodable
 
529
         */
 
530
        public boolean isDefinedParameter(Variable.Key key) {
 
531
            return IconNodeInst.this.isDefinedParameter(key);
 
532
        }
 
533
 
 
534
        /**
 
535
         * Method to return an Iterator over all Parameters on this Nodable.
 
536
         * This may also include any Parameters on the defaultVarOwner object that are not on this Nodable.
 
537
         * @return an Iterator over all Parameters on this Nodable.
 
538
         */
 
539
        public Iterator<Variable> getParameters() {
 
540
            return IconNodeInst.this.getParameters();
 
541
        }
 
542
 
 
543
        /**
 
544
         * Method to return an Iterator over defined Parameters on this Nodable.
 
545
         * This doesn't include any Parameters on the defaultVarOwner object that are not on this Nodable.
 
546
         * @return an Iterator over defined Parameters on this Nodable.
 
547
         */
 
548
        public Iterator<Variable> getDefinedParameters() {
 
549
            return IconNodeInst.this.getDefinedParameters();
 
550
        }
 
551
 
 
552
        /**
 
553
         * Returns a printable version of this Nodable.
 
554
         * @return a printable version of this Nodable.
 
555
         */
 
556
        @Override
 
557
        public String toString() {
 
558
            return "IconNodable " + getName();
 
559
        }
 
560
 
 
561
        // JKG: trying this out
 
562
        public boolean contains(NodeInst ni, int arrayIndex) {
 
563
            if (IconNodeInst.this == ni && this.arrayIndex == arrayIndex) {
 
564
                return true;
 
565
            }
 
566
            return false;
 
567
        }
 
568
 
 
569
        public NodeInst getNodeInst() {
 
570
            return IconNodeInst.this;
 
571
        }
 
572
 
 
573
        /**
 
574
         * Get array index of this Nodable
 
575
         * @return the array index of this Nodable
 
576
         */
 
577
        public int getNodableArrayIndex() {
 
578
            return arrayIndex;
 
579
        }
 
580
    }
380
581
}