126
// create node/arc connections and place them properly
127
tailPortInst = tailPort;
135
// create node/arc connections and place them properly
136
tailPortInst = tailPort;
128
137
// tailEnd = new TailConnection(this);
130
headPortInst = headPort;
139
headPortInst = headPort;
131
140
// headEnd = new HeadConnection(this);
134
private Object writeReplace() { return new ArcInstKey(this); }
143
private Object writeReplace() {
144
return new ArcInstKey(this);
136
147
private static class ArcInstKey extends EObjectInputStream.Key<ArcInst> {
137
public ArcInstKey() {}
138
private ArcInstKey(ArcInst ai) { super(ai); }
149
public ArcInstKey() {
152
private ArcInstKey(ArcInst ai) {
141
157
public void writeExternal(EObjectOutputStream out, ArcInst ai) throws IOException {
142
if (ai.getDatabase() != out.getDatabase() || !ai.isLinked())
158
if (ai.getDatabase() != out.getDatabase() || !ai.isLinked()) {
143
159
throw new NotSerializableException(ai + " not linked");
144
out.writeObject(ai.getParent());
161
out.writeObject(ai.topology.cell);
145
162
out.writeInt(ai.getArcId());
149
166
public ArcInst readExternal(EObjectInputStream in) throws IOException, ClassNotFoundException {
150
Cell cell = (Cell)in.readObject();
167
Cell cell = (Cell) in.readObject();
151
168
int arcId = in.readInt();
152
169
ArcInst ai = cell.getArcById(arcId);
154
171
throw new InvalidObjectException("ArcInst from " + cell);
178
* Comparator class for sorting ArcInst by their length.
180
public static class ArcsByLength implements Comparator<ArcInst> {
183
* Method to sort ArcInst by their length.
185
public int compare(ArcInst a1, ArcInst a2) {
186
double len1 = a1.getHeadLocation().distance(a1.getTailLocation());
187
double len2 = a2.getHeadLocation().distance(a2.getTailLocation());
159
198
/****************************** CREATE, DELETE, MODIFY ******************************/
162
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts.
163
* Since no coordinates are given, the ArcInst connects to the center of the PortInsts.
164
* @param type the prototype of the new ArcInst.
165
* @param head the head end PortInst.
166
* @param tail the tail end PortInst.
167
* @return the newly created ArcInst, or null if there is an error.
169
public static ArcInst makeInstance(ArcProto type, PortInst head, PortInst tail)
200
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts.
201
* Since no coordinates are given, the ArcInst connects to the center of the PortInsts.
202
* @param type the prototype of the new ArcInst.
203
* @param head the head end PortInst.
204
* @param tail the tail end PortInst.
205
* @return the newly created ArcInst, or null if there is an error.
207
public static ArcInst makeInstance(ArcProto type, PortInst head, PortInst tail) {
171
208
EditingPreferences ep = tail.getEditingPreferences();
172
209
ImmutableArcInst a = type.getDefaultInst(ep);
173
210
return newInstanceBase(type, type.getDefaultLambdaBaseWidth(ep), head, tail, null, null, null, 0, a.flags);
177
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts.
178
* Since no coordinates are given, the ArcInst connects to the center of the PortInsts.
179
* @param type the prototype of the new ArcInst.
180
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
181
* @param head the head end PortInst.
182
* @param tail the tail end PortInst.
183
* @return the newly created ArcInst, or null if there is an error.
185
public static ArcInst makeInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail)
214
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts.
215
* Since no coordinates are given, the ArcInst connects to the center of the PortInsts.
216
* @param type the prototype of the new ArcInst.
217
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
218
* @param head the head end PortInst.
219
* @param tail the tail end PortInst.
220
* @return the newly created ArcInst, or null if there is an error.
222
public static ArcInst makeInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail) {
187
223
EditingPreferences ep = tail.getEditingPreferences();
188
224
ImmutableArcInst a = type.getDefaultInst(ep);
189
225
return newInstanceBase(type, baseWidth, head, tail, null, null, null, 0, a.flags);
193
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts at specified locations.
194
* This is more general than the version that does not take coordinates.
195
* @param type the prototype of the new ArcInst.
196
* @param head the head end PortInst.
197
* @param tail the tail end PortInst.
198
* @param headPt the coordinate of the head end PortInst.
199
* @param tailPt the coordinate of the tail end PortInst.
200
* @param name the name of the new ArcInst
201
* @return the newly created ArcInst, or null if there is an error.
203
public static ArcInst makeInstance(ArcProto type, PortInst head, PortInst tail,
204
Point2D headPt, Point2D tailPt, String name)
206
EditingPreferences ep = tail.getEditingPreferences();
207
ImmutableArcInst a = type.getDefaultInst(ep);
208
return newInstanceBase(type, type.getDefaultLambdaBaseWidth(ep), head, tail, headPt, tailPt, name, 0, a.flags);
212
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts at specified locations.
213
* This is more general than the version that does not take coordinates.
214
* @param type the prototype of the new ArcInst.
215
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
216
* @param head the head end PortInst.
217
* @param tail the tail end PortInst.
218
* @param headPt the coordinate of the head end PortInst.
219
* @param tailPt the coordinate of the tail end PortInst.
220
* @param name the name of the new ArcInst
221
* @return the newly created ArcInst, or null if there is an error.
223
public static ArcInst makeInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail,
224
Point2D headPt, Point2D tailPt, String name)
226
EditingPreferences ep = tail.getEditingPreferences();
227
ImmutableArcInst a = type.getDefaultInst(ep);
228
return newInstanceBase(type, baseWidth, head, tail, headPt, tailPt, name, 0, a.flags);
232
* Method to create a new ArcInst connecting two PortInsts.
233
* Since no coordinates are given, the ArcInst connects to the center of the PortInsts.
234
* @param type the prototype of the new ArcInst.
235
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
236
* @param head the head end PortInst.
237
* @param tail the tail end PortInst.
238
* @return the newly created ArcInst, or null if there is an error.
240
public static ArcInst newInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail)
242
return newInstanceBase(type, baseWidth, head, tail, null, null, null, 0, ImmutableArcInst.DEFAULT_FLAGS);
246
* Method to create a new ArcInst connecting two PortInsts at specified locations.
247
* This is more general than the version that does not take coordinates.
248
* @param type the prototype of the new ArcInst.
249
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
250
* @param head the head end PortInst.
251
* @param tail the tail end PortInst.
252
* @param headPt the coordinate of the head end PortInst.
253
* @param tailPt the coordinate of the tail end PortInst.
254
* @param name the name of the new ArcInst
255
* @param defAngle default angle in case port points coincide
256
* @return the newly created ArcInst, or null if there is an error.
258
public static ArcInst newInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail,
259
Point2D headPt, Point2D tailPt, String name, int defAngle)
229
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts at specified locations.
230
* This is more general than the version that does not take coordinates.
231
* @param type the prototype of the new ArcInst.
232
* @param head the head end PortInst.
233
* @param tail the tail end PortInst.
234
* @param headPt the coordinate of the head end PortInst.
235
* @param tailPt the coordinate of the tail end PortInst.
236
* @param name the name of the new ArcInst
237
* @return the newly created ArcInst, or null if there is an error.
239
public static ArcInst makeInstance(ArcProto type, PortInst head, PortInst tail,
240
Point2D headPt, Point2D tailPt, String name) {
241
EditingPreferences ep = tail.getEditingPreferences();
242
ImmutableArcInst a = type.getDefaultInst(ep);
243
return newInstanceBase(type, type.getDefaultLambdaBaseWidth(ep), head, tail, headPt, tailPt, name, 0, a.flags);
247
* Method to create a new ArcInst with appropriate defaults, connecting two PortInsts at specified locations.
248
* This is more general than the version that does not take coordinates.
249
* @param type the prototype of the new ArcInst.
250
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
251
* @param head the head end PortInst.
252
* @param tail the tail end PortInst.
253
* @param headPt the coordinate of the head end PortInst.
254
* @param tailPt the coordinate of the tail end PortInst.
255
* @param name the name of the new ArcInst
256
* @return the newly created ArcInst, or null if there is an error.
258
public static ArcInst makeInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail,
259
Point2D headPt, Point2D tailPt, String name) {
260
EditingPreferences ep = tail.getEditingPreferences();
261
ImmutableArcInst a = type.getDefaultInst(ep);
262
return newInstanceBase(type, baseWidth, head, tail, headPt, tailPt, name, 0, a.flags);
266
* Method to create a new ArcInst connecting two PortInsts.
267
* Since no coordinates are given, the ArcInst connects to the center of the PortInsts.
268
* @param type the prototype of the new ArcInst.
269
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
270
* @param head the head end PortInst.
271
* @param tail the tail end PortInst.
272
* @return the newly created ArcInst, or null if there is an error.
274
public static ArcInst newInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail) {
275
return newInstanceBase(type, baseWidth, head, tail, null, null, null, 0, ImmutableArcInst.DEFAULT_FLAGS);
279
* Method to create a new ArcInst connecting two PortInsts at specified locations.
280
* This is more general than the version that does not take coordinates.
281
* @param type the prototype of the new ArcInst.
282
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
283
* @param head the head end PortInst.
284
* @param tail the tail end PortInst.
285
* @param headPt the coordinate of the head end PortInst.
286
* @param tailPt the coordinate of the tail end PortInst.
287
* @param name the name of the new ArcInst
288
* @param defAngle default angle in case port points coincide
289
* @return the newly created ArcInst, or null if there is an error.
291
public static ArcInst newInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail,
292
Point2D headPt, Point2D tailPt, String name, int defAngle) {
261
293
return newInstanceBase(type, baseWidth, head, tail, headPt, tailPt, name, defAngle, ImmutableArcInst.DEFAULT_FLAGS);
265
* Method to create a new ArcInst connecting two PortInsts at specified locations.
266
* This is more general than the version that does not take coordinates.
267
* @param type the prototype of the new ArcInst.
268
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
269
* @param head the head end PortInst.
270
* @param tail the tail end PortInst.
271
* @param headPt the coordinate of the head end PortInst.
272
* @param tailPt the coordinate of the tail end PortInst.
273
* @param name the name of the new ArcInst
274
* @param defAngle default angle in case port points coincide
297
* Method to create a new ArcInst connecting two PortInsts at specified locations.
298
* This is more general than the version that does not take coordinates.
299
* @param type the prototype of the new ArcInst.
300
* @param baseWidth the base width of the new ArcInst. The width must be > 0.
301
* @param head the head end PortInst.
302
* @param tail the tail end PortInst.
303
* @param headPt the coordinate of the head end PortInst.
304
* @param tailPt the coordinate of the tail end PortInst.
305
* @param name the name of the new ArcInst
306
* @param defAngle default angle in case port points coincide
275
307
* @param flags flags of thew new ArcInst
276
308
* @return the newly created ArcInst, or null if there is an error.
278
public static ArcInst newInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail,
279
Point2D headPt, Point2D tailPt, String name, int defAngle, int flags)
310
public static ArcInst newInstanceBase(ArcProto type, double baseWidth, PortInst head, PortInst tail,
311
Point2D headPt, Point2D tailPt, String name, int defAngle, int flags) {
281
312
// if (type.isNotUsed())
283
314
//// System.out.println("Cannot create arc instance of " + type + " because prototype is unused");
284
315
//// return null;
287
long gridExtendOverMin = DBMath.lambdaToGrid(0.5*baseWidth) - type.getGridBaseExtend();
318
long gridExtendOverMin = DBMath.lambdaToGrid(0.5 * baseWidth) - type.getGridBaseExtend();
288
319
// if (gridFullWidth < type.getMaxLayerGridOffset())
289
320
// gridFullWidth = type.getDefaultGridFullWidth();
291
322
// if points are null, create them as would newInstance
324
if (headPt == null) {
295
325
// Rectangle2D headBounds = head.getBounds();
296
326
headP = head.getCenter(); //new EPoint(headBounds.getCenterX(), headBounds.getCenterY());
299
headP = EPoint.snap(headPt);
328
headP = EPoint.snap(headPt);
331
if (tailPt == null) {
304
332
// Rectangle2D tailBounds = tail.getBounds();
305
333
tailP = tail.getCenter(); // new EPoint(tailBounds.getCenterX(), tailBounds.getCenterY());
308
tailP = EPoint.snap(tailPt);
335
tailP = EPoint.snap(tailPt);
311
// make sure points are valid
312
Cell parent = head.getNodeInst().getParent();
338
// make sure points are valid
339
Cell parent = head.getNodeInst().topology.cell;
313
340
Poly headPoly = head.getPoly();
314
341
if (!stillInPoly(headP, headPoly)) {
315
System.out.println("Error in " + parent + ": head of " + type.getName() +
316
" arc at (" + headP.getX() + "," + headP.getY() + ") does not fit in " +
317
head + " which is centered at (" + headPoly.getCenterX() + "," + headPoly.getCenterY() + ")");
342
System.out.println("Error in " + parent + ": head of " + type.getName()
343
+ " arc at (" + headP.getX() + "," + headP.getY() + ") does not fit in "
344
+ head + " which is centered at (" + headPoly.getCenterX() + "," + headPoly.getCenterY() + ")");
320
347
Poly tailPoly = tail.getPoly();
321
if (!stillInPoly(tailP, tailPoly))
323
System.out.println("Error in " + parent + ": tail of " + type.getName() +
324
" arc at (" + tailP.getX() + "," + tailP.getY() + ") does not fit in " +
325
tail + " which is centered at (" + tailPoly.getCenterX() + "," + tailPoly.getCenterY() + ")");
348
if (!stillInPoly(tailP, tailPoly)) {
349
System.out.println("Error in " + parent + ": tail of " + type.getName()
350
+ " arc at (" + tailP.getX() + "," + tailP.getY() + ") does not fit in "
351
+ tail + " which is centered at (" + tailPoly.getCenterX() + "," + tailPoly.getCenterY() + ")");
329
355
TextDescriptor nameDescriptor = TextDescriptor.getArcTextDescriptor();
330
356
Name nameKey = name != null ? Name.findName(name) : null;
331
if (nameKey != null && !nameKey.isTempname()) {
332
// adjust the name descriptor for "smart" text placement
333
long gridBaseWidth = 2*(gridExtendOverMin + type.getGridBaseExtend());
334
nameDescriptor = getSmartTextDescriptor(defAngle, DBMath.gridToLambda(gridBaseWidth), nameDescriptor, parent.getEditingPreferences());
357
if (nameKey != null && !nameKey.isTempname()) {
358
// adjust the name descriptor for "smart" text placement
359
long gridBaseWidth = 2 * (gridExtendOverMin + type.getGridBaseExtend());
360
nameDescriptor = getSmartTextDescriptor(defAngle, DBMath.gridToLambda(gridBaseWidth), nameDescriptor, parent.getEditingPreferences());
336
362
return newInstance(parent, type, name, nameDescriptor, head, tail, headP, tailP, gridExtendOverMin, defAngle, flags);
340
366
* Method to create a new ArcInst connecting two PortInsts at specified locations.
341
367
* This is more general than the version that does not take coordinates.
342
368
* @param parent the parent Cell of this ArcInst
426
456
gridExtendOverMin, angle, flags);
427
457
ArcInst ai = new ArcInst(topology, d, headPort, tailPort);
429
// attach this arc to the two nodes it connects
430
headPort.getNodeInst().redoGeometric();
431
tailPort.getNodeInst().redoGeometric();
433
// add this arc to the cell
436
// handle change control, constraint, and broadcast
437
Constraints.getCurrent().newObject(ai);
459
// attach this arc to the two nodes it connects
460
headPort.getNodeInst().redoGeometric();
461
tailPort.getNodeInst().redoGeometric();
463
// add this arc to the cell
466
// handle change control, constraint, and broadcast
467
Constraints.getCurrent().newObject(ai);
442
* Method to delete this ArcInst.
448
System.out.println("ArcInst already killed");
472
* Method to delete this ArcInst.
476
System.out.println("ArcInst already killed");
453
// remove this arc from the two nodes it connects
454
headPortInst.getNodeInst().redoGeometric();
455
tailPortInst.getNodeInst().redoGeometric();
457
// remove this arc from the cell
458
topology.removeArc(this);
460
// handle change control, constraint, and broadcast
461
Constraints.getCurrent().killObject(this);
465
* Method to change the width and end locations of this ArcInst.
466
* @param dHeadX the change to the X coordinate of the head of this ArcInst.
467
* @param dHeadY the change to the Y coordinate of the head of this ArcInst.
468
* @param dTailX the change to the X coordinate of the tail of this ArcInst.
469
* @param dTailY the change to the Y coordinate of the tail of this ArcInst.
471
public void modify(double dHeadX, double dHeadY, double dTailX, double dTailY)
473
// save old arc state
481
// remove this arc from the two nodes it connects
482
headPortInst.getNodeInst().redoGeometric();
483
tailPortInst.getNodeInst().redoGeometric();
485
// remove this arc from the cell
486
topology.removeArc(this);
488
// handle change control, constraint, and broadcast
489
Constraints.getCurrent().killObject(this);
493
* Method to change the width and end locations of this ArcInst.
494
* @param dHeadX the change to the X coordinate of the head of this ArcInst.
495
* @param dHeadY the change to the Y coordinate of the head of this ArcInst.
496
* @param dTailX the change to the X coordinate of the tail of this ArcInst.
497
* @param dTailY the change to the Y coordinate of the tail of this ArcInst.
499
public void modify(double dHeadX, double dHeadY, double dTailX, double dTailY) {
500
// save old arc state
474
501
ImmutableArcInst oldD = d;
477
504
EPoint tail = d.tailLocation;
478
if (dTailX != 0 || dTailY != 0)
479
tail = new EPoint(tail.getX() + dTailX, tail.getY() + dTailY);
505
if (dTailX != 0 || dTailY != 0) {
506
tail = new EPoint(tail.getX() + dTailX, tail.getY() + dTailY);
480
508
EPoint head = d.headLocation;
481
if (dHeadX != 0 || dHeadY != 0)
509
if (dHeadX != 0 || dHeadY != 0) {
482
510
head = new EPoint(head.getX() + dHeadX, head.getY() + dHeadY);
483
lowLevelModify(d.withLocations(tail, head));
512
lowLevelModify(d.withLocations(tail, head));
486
515
Constraints.getCurrent().modifyArcInst(this, oldD);
490
* Method to change the width this ArcInst.
491
* @param lambdaBaseWidth new base width of the ArcInst in lambda units.
519
* Method to change the width this ArcInst.
520
* @param lambdaBaseWidth new base width of the ArcInst in lambda units.
493
522
public void setLambdaBaseWidth(double lambdaBaseWidth) {
494
523
setGridBaseWidth(DBMath.lambdaToSizeGrid(lambdaBaseWidth));
498
* Method to change the width this ArcInst.
499
* @param gridBaseWidth new base width of the ArcInst in lambda units.
527
* Method to change the width this ArcInst.
528
* @param gridBaseWidth new base width of the ArcInst in lambda units.
501
530
public void setGridBaseWidth(long gridBaseWidth) {
502
if (gridBaseWidth == getGridBaseWidth()) return;
531
if (gridBaseWidth == getGridBaseWidth()) {
504
535
// save old arc state
505
536
ImmutableArcInst oldD = d;
507
538
// change the arc
508
lowLevelModify(d.withGridExtendOverMin(gridBaseWidth/2 - getProto().getGridBaseExtend()));
539
lowLevelModify(d.withGridExtendOverMin(gridBaseWidth / 2 - getProto().getGridBaseExtend()));
510
541
// track the change
511
542
Constraints.getCurrent().modifyArcInst(this, oldD);
515
* Method to replace this ArcInst with one of another type.
516
* @param ap the new type of arc.
517
* @return the new ArcInst (null on error).
519
public ArcInst replace(ArcProto ap)
521
// check for connection allowance
522
if (!headPortInst.getPortProto().connectsTo(ap) || !tailPortInst.getPortProto().connectsTo(ap))
524
System.out.println("Cannot replace " + this + " with one of type " + ap.getName() +
525
" because the nodes cannot connect to it");
529
// first create the new nodeinst in place
530
ArcInst newar = ArcInst.newInstanceBase(ap, getLambdaBaseWidth(), headPortInst, tailPortInst, d.headLocation, d.tailLocation, null, 0);
533
System.out.println("Cannot replace " + this + " with one of type " + ap.getName() +
534
" because the new arc failed to create");
538
// copy all variables on the arcinst
539
newar.copyPropertiesFrom(this);
541
// now delete the original nodeinst
543
newar.setName(getName());
547
/****************************** LOW-LEVEL IMPLEMENTATION ******************************/
546
* Method to replace this ArcInst with one of another type.
547
* @param ap the new type of arc.
548
* @return the new ArcInst (null on error).
550
public ArcInst replace(ArcProto ap) {
551
// check for connection allowance
552
if (!headPortInst.getPortProto().connectsTo(ap) || !tailPortInst.getPortProto().connectsTo(ap)) {
553
System.out.println("Cannot replace " + this + " with one of type " + ap.getName()
554
+ " because the nodes cannot connect to it");
558
// first create the new nodeinst in place
559
ArcInst newar = ArcInst.newInstanceBase(ap, getLambdaBaseWidth(), headPortInst, tailPortInst, d.headLocation, d.tailLocation, null, 0);
561
System.out.println("Cannot replace " + this + " with one of type " + ap.getName()
562
+ " because the new arc failed to create");
566
// copy all variables on the arcinst
567
newar.copyPropertiesFrom(this);
569
// now delete the original nodeinst
571
newar.setName(getName());
575
/****************************** LOW-LEVEL IMPLEMENTATION ******************************/
550
577
* Returns persistent data of this ArcInst.
551
578
* @return persistent data of this ArcInst.
554
public ImmutableArcInst getD() { return d; }
581
public ImmutableArcInst getD() {
557
586
* Modifies persistend data of this ArcInst.
944
993
public EPoint getLocation(int connIndex) {
945
994
switch (connIndex) {
946
case ImmutableArcInst.TAILEND: return d.tailLocation;
947
case ImmutableArcInst.HEADEND: return d.headLocation;
948
default: throw new IllegalArgumentException("Bad end " + connIndex);
995
case ImmutableArcInst.TAILEND:
996
return d.tailLocation;
997
case ImmutableArcInst.HEADEND:
998
return d.headLocation;
1000
throw new IllegalArgumentException("Bad end " + connIndex);
953
* Method to tell whether a tail connection on this ArcInst contains a port location.
954
* @param pt the point in question.
955
* @param reduceForArc if true reduce width by width offset of it proto.
956
* @return true if the point is inside of the port.
1005
* Method to tell whether a tail connection on this ArcInst contains a port location.
1006
* @param pt the point in question.
1007
* @param reduceForArc if true reduce width by width offset of it proto.
1008
* @return true if the point is inside of the port.
958
1010
public boolean tailStillInPort(Point2D pt, boolean reduceForArc) {
959
1011
return stillInPort(ImmutableArcInst.TAILEND, pt, reduceForArc);
963
* Method to tell whether a head connection on this ArcInst contains a port location.
964
* @param pt the point in question.
965
* @param reduceForArc if true reduce width by width offset of it proto.
966
* @return true if the point is inside of the port.
1015
* Method to tell whether a head connection on this ArcInst contains a port location.
1016
* @param pt the point in question.
1017
* @param reduceForArc if true reduce width by width offset of it proto.
1018
* @return true if the point is inside of the port.
968
1020
public boolean headStillInPort(Point2D pt, boolean reduceForArc) {
969
1021
return stillInPort(ImmutableArcInst.HEADEND, pt, reduceForArc);
973
* Method to tell whether a connection on this ArcInst contains a port location.
974
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
975
* @param pt the point in question.
976
* @param reduceForArc if true reduce width by width offset of it proto.
977
* @return true if the point is inside of the port.
979
public boolean stillInPort(int connIndex, Point2D pt, boolean reduceForArc)
981
// determine the area of the nodeinst
982
PortInst pi = getPortInst(connIndex);
983
Poly poly = pi.getPoly();
986
double wid = getLambdaBaseWidth();
987
poly.reducePortPoly(pi, wid, getAngle());
1025
* Method to tell whether a connection on this ArcInst contains a port location.
1026
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1027
* @param pt the point in question.
1028
* @param reduceForArc if true reduce width by width offset of it proto.
1029
* @return true if the point is inside of the port.
1031
public boolean stillInPort(int connIndex, Point2D pt, boolean reduceForArc) {
1032
// determine the area of the nodeinst
1033
PortInst pi = getPortInst(connIndex);
1034
Poly poly = pi.getPoly();
1036
double wid = getLambdaBaseWidth();
1037
poly.reducePortPoly(pi, wid, getAngle());
989
1039
return stillInPoly(pt, poly);
990
1040
// if (poly.isInside(pt)) return true;
991
1041
// if (poly.polyDistance(pt.getX(), pt.getY()) < MINPORTDISTANCE) return true;
994
1044
// return false;
997
private static boolean stillInPoly(Point2D pt, Poly poly) { return poly.isInside(pt) || poly.polyDistance(pt.getX(), pt.getY()) < MINPORTDISTANCE; }
1047
private static boolean stillInPoly(Point2D pt, Poly poly) {
1048
return poly.isInside(pt) || poly.polyDistance(pt.getX(), pt.getY()) < MINPORTDISTANCE;
999
1051
/****************************** TEXT ******************************/
1002
* Method to return the name of this ArcInst.
1003
* @return the name of this ArcInst.
1005
public String getName() { return d.name.toString(); }
1008
* Retruns true if this ArcInst was named by user.
1009
* @return true if this ArcInst was named by user.
1011
public boolean isUsernamed() { return d.isUsernamed(); }
1014
* Method to return the name key of this ArcInst.
1015
* @return the name key of this ArcInst, null if there is no name.
1017
public Name getNameKey() { return d.name; }
1020
* Method to rename this ArcInst.
1021
* This ArcInst must be linked to database.
1022
* @param name new name of this geometric.
1023
* @return true on error
1025
public boolean setName(String name)
1029
boolean doSmart = false;
1030
if (name != null && name.length() > 0)
1032
if (name.equals(getName())) return false;
1033
if (!isUsernamed()) doSmart = true;
1034
key = Name.findName(name);
1037
if (!isUsernamed()) return false;
1038
key = topology.getArcAutoname();
1040
if (checkNameKey(key, topology)) return true;
1053
* Method to return the name of this ArcInst.
1054
* @return the name of this ArcInst.
1056
public String getName() {
1057
return d.name.toString();
1061
* Retruns true if this ArcInst was named by user.
1062
* @return true if this ArcInst was named by user.
1064
public boolean isUsernamed() {
1065
return d.isUsernamed();
1069
* Method to return the name key of this ArcInst.
1070
* @return the name key of this ArcInst, null if there is no name.
1072
public Name getNameKey() {
1077
* Method to rename this ArcInst.
1078
* This ArcInst must be linked to database.
1079
* @param name new name of this geometric.
1080
* @return true on error
1082
public boolean setName(String name) {
1085
boolean doSmart = false;
1086
if (name != null && name.length() > 0) {
1087
if (name.equals(getName())) {
1090
if (!isUsernamed()) {
1093
key = Name.findName(name);
1095
if (!isUsernamed()) {
1098
key = topology.getArcAutoname();
1100
if (checkNameKey(key, topology) || key.isBus() && getProto() != Schematics.tech().bus_arc) {
1041
1103
ImmutableArcInst oldD = d;
1042
1104
lowLevelModify(d.withName(key));
1045
TextDescriptor td = TextDescriptor.getArcTextDescriptor();
1046
TextDescriptor smartDescriptor = getSmartTextDescriptor(getAngle(), getLambdaBaseWidth(), td, getEditingPreferences());
1047
setTextDescriptor(ARC_NAME, smartDescriptor);
1106
TextDescriptor td = TextDescriptor.getArcTextDescriptor();
1107
TextDescriptor smartDescriptor = getSmartTextDescriptor(getAngle(), getLambdaBaseWidth(), td, getEditingPreferences());
1108
setTextDescriptor(ARC_NAME, smartDescriptor);
1050
1111
// apply constraints
1051
1112
Constraints.getCurrent().modifyArcInst(this, oldD);
1056
* Method to return a "smart" text descriptor for an arc.
1057
* @param angle the angle of the arc (in tenths of a degree).
1058
* @param width the width of the arc.
1059
* @param prev the former text descriptor of the arc.
1060
* @return a new text descriptor that handles smart placement.
1062
private static TextDescriptor getSmartTextDescriptor(int angle, double width, TextDescriptor prev, EditingPreferences ep)
1064
// assigning valid name: do smart text placement
1065
if ((angle%1800) == 0)
1068
int smart = ep.smartHorizontalPlacementArc;
1072
return prev.withPos(TextDescriptor.Position.UP).withOff(0, width/2);
1073
} else if (smart == 2)
1076
return prev.withPos(TextDescriptor.Position.DOWN).withOff(0, -width/2);
1078
} else if ((angle%1800) == 900)
1081
int smart = ep.smartVerticalPlacementArc;
1084
// arc text to the left
1085
return prev.withPos(TextDescriptor.Position.LEFT).withOff(-width/2, 0);
1086
} else if (smart == 2)
1088
// arc text to the right
1089
return prev.withPos(TextDescriptor.Position.RIGHT).withOff(width/2, 0);
1096
* Method to check the new name key of an ArcInst.
1097
* @param name new name key of this ArcInst.
1117
* Method to return a "smart" text descriptor for an arc.
1118
* @param angle the angle of the arc (in tenths of a degree).
1119
* @param width the width of the arc.
1120
* @param prev the former text descriptor of the arc.
1121
* @return a new text descriptor that handles smart placement.
1123
private static TextDescriptor getSmartTextDescriptor(int angle, double width, TextDescriptor prev, EditingPreferences ep) {
1124
// assigning valid name: do smart text placement
1125
if ((angle % 1800) == 0) {
1127
int smart = ep.smartHorizontalPlacementArc;
1130
return prev.withPos(TextDescriptor.Position.UP).withOff(0, width / 2);
1131
} else if (smart == 2) {
1133
return prev.withPos(TextDescriptor.Position.DOWN).withOff(0, -width / 2);
1135
} else if ((angle % 1800) == 900) {
1137
int smart = ep.smartVerticalPlacementArc;
1139
// arc text to the left
1140
return prev.withPos(TextDescriptor.Position.LEFT).withOff(-width / 2, 0);
1141
} else if (smart == 2) {
1142
// arc text to the right
1143
return prev.withPos(TextDescriptor.Position.RIGHT).withOff(width / 2, 0);
1150
* Method to check the new name key of an ArcInst.
1151
* @param name new name key of this ArcInst.
1098
1152
* @param parent parent Cell used for error message
1099
* @return true on error.
1101
private static boolean checkNameKey(Name name, Topology topology)
1153
* @return true on error.
1155
private static boolean checkNameKey(Name name, Topology topology) {
1103
1156
Cell parent = topology.cell;
1104
if (!name.isValid())
1106
System.out.println(parent + ": Invalid name \""+name+"\" wasn't assigned to arc" + " :" + Name.checkName(name.toString()));
1109
if (name.isTempname() && name.getBasename() != ImmutableArcInst.BASENAME)
1111
System.out.println(parent + ": Temporary arc name \""+name+"\" must have prefix net@");
1114
if (name.hasEmptySubnames())
1117
System.out.println(parent + ": Name \""+name+"\" with empty subnames wasn't assigned to arc");
1119
System.out.println(parent + ": Cannot assign empty name \""+name+"\" to arc");
1122
if (topology.hasTempArcName(name))
1124
System.out.println(parent + " already has ArcInst with temporary name \""+name+"\"");
1131
* Returns the TextDescriptor on this ArcInst selected by variable key.
1132
* This key may be a key of variable on this ArcInst or the
1134
* <code>ArcInst.ARC_NAME</code>
1135
* The TextDescriptor gives information for displaying the Variable.
1136
* @param varKey key of variable or special key.
1137
* @return the TextDescriptor on this ArcInst.
1139
public TextDescriptor getTextDescriptor(Variable.Key varKey)
1141
if (varKey == ARC_NAME) return d.nameDescriptor;
1142
return super.getTextDescriptor(varKey);
1146
* Updates the TextDescriptor on this ArcInst selected by varKey.
1147
* The varKey may be a key of variable on this ArcInst or
1157
if (!name.isValid()) {
1158
System.out.println(parent + ": Invalid name \"" + name + "\" wasn't assigned to arc" + " :" + Name.checkName(name.toString()));
1162
if (name.isTempname()) {
1163
System.out.println(parent + ": Temporary name \"" + name + "\" can't be bus");
1166
if (!parent.busNamesAllowed()) {
1167
System.out.println(parent + ": Bus name \"" + name + "\" can be in icons and schematics only");
1171
if (name.isTempname() && name.getBasename() != ImmutableArcInst.BASENAME) {
1172
System.out.println(parent + ": Temporary arc name \"" + name + "\" must have prefix net@");
1175
if (name.hasEmptySubnames()) {
1177
System.out.println(parent + ": Name \"" + name + "\" with empty subnames wasn't assigned to arc");
1179
System.out.println(parent + ": Cannot assign empty name \"" + name + "\" to arc");
1183
if (topology.hasTempArcName(name)) {
1184
System.out.println(parent + " already has ArcInst with temporary name \"" + name + "\"");
1191
* Returns the TextDescriptor on this ArcInst selected by variable key.
1192
* This key may be a key of variable on this ArcInst or the
1194
* <code>ArcInst.ARC_NAME</code>
1195
* The TextDescriptor gives information for displaying the Variable.
1196
* @param varKey key of variable or special key.
1197
* @return the TextDescriptor on this ArcInst.
1199
public TextDescriptor getTextDescriptor(Variable.Key varKey) {
1200
if (varKey == ARC_NAME) {
1201
return d.nameDescriptor;
1203
return super.getTextDescriptor(varKey);
1207
* Updates the TextDescriptor on this ArcInst selected by varKey.
1208
* The varKey may be a key of variable on this ArcInst or
1148
1209
* the special key ArcInst.ARC_NAME.
1149
* If varKey doesn't select any text descriptor, no action is performed.
1150
* The TextDescriptor gives information for displaying the Variable.
1151
* @param varKey key of variable or special key.
1152
* @param td new value TextDescriptor
1210
* If varKey doesn't select any text descriptor, no action is performed.
1211
* The TextDescriptor gives information for displaying the Variable.
1212
* @param varKey key of variable or special key.
1213
* @param td new value TextDescriptor
1155
public void setTextDescriptor(Variable.Key varKey, TextDescriptor td)
1216
public void setTextDescriptor(Variable.Key varKey, TextDescriptor td) {
1157
1217
if (varKey == ARC_NAME) {
1158
setD(d.withNameDescriptor(td), true);
1218
setD(d.withNameDescriptor(td), true);
1161
1221
super.setTextDescriptor(varKey, td);
1165
* Method to determine whether a variable key on ArcInst is deprecated.
1166
* Deprecated variable keys are those that were used in old versions of Electric,
1167
* but are no longer valid.
1168
* @param key the key of the variable.
1169
* @return true if the variable key is deprecated.
1171
public boolean isDeprecatedVariable(Variable.Key key)
1173
if (key == ARC_NAME) return true;
1174
return super.isDeprecatedVariable(key);
1225
* Method to determine whether a variable key on ArcInst is deprecated.
1226
* Deprecated variable keys are those that were used in old versions of Electric,
1227
* but are no longer valid.
1228
* @param key the key of the variable.
1229
* @return true if the variable key is deprecated.
1231
public boolean isDeprecatedVariable(Variable.Key key) {
1232
if (key == ARC_NAME) {
1235
return super.isDeprecatedVariable(key);
1178
* Method to describe this ArcInst as a string.
1239
* Method to describe this ArcInst as a string.
1179
1240
* @param withQuotes to wrap description between quotes
1180
* @return a description of this ArcInst.
1182
public String describe(boolean withQuotes)
1184
String description = getProto().describe();
1185
String name = (withQuotes) ? "'"+getName()+"'" : getName();
1186
if (name != null) description += "[" + name + "]";
1241
* @return a description of this ArcInst.
1243
public String describe(boolean withQuotes) {
1244
String description = getProto().describe();
1245
String name = (withQuotes) ? "'" + getName() + "'" : getName();
1247
description += "[" + name + "]";
1191
1253
* Compares ArcInsts by their Cells and names.
1192
1254
* @param that the other ArcInst.
1193
1255
* @return a comparison between the ArcInsts.
1195
public int compareTo(ArcInst that)
1198
if (this.parent != that.parent)
1200
cmp = this.parent.compareTo(that.parent);
1201
if (cmp != 0) return cmp;
1203
cmp = this.getName().compareTo(that.getName());
1204
if (cmp != 0) return cmp;
1205
return this.d.arcId - that.d.arcId;
1257
public int compareTo(ArcInst that) {
1259
if (this.topology != that.topology) {
1260
cmp = this.topology.cell.compareTo(that.topology.cell);
1265
cmp = this.getName().compareTo(that.getName());
1269
return this.d.arcId - that.d.arcId;
1209
* Returns a printable version of this ArcInst.
1210
* @return a printable version of this ArcInst.
1212
public String toString()
1273
* Returns a printable version of this ArcInst.
1274
* @return a printable version of this ArcInst.
1276
public String toString() {
1214
1277
return "arc " + describe(true);
1217
/****************************** CONSTRAINTS ******************************/
1280
/****************************** CONSTRAINTS ******************************/
1219
1281
private void setFlag(ImmutableArcInst.Flag flag, boolean state) {
1220
1282
checkChanging();
1221
if (setD(d.withFlag(flag, state), true))
1226
* Method to set this ArcInst to be rigid.
1227
* Rigid arcs cannot change length or the angle of their connection to a NodeInst.
1230
public void setRigid(boolean state) { setFlag(ImmutableArcInst.RIGID, state); }
1233
* Method to tell whether this ArcInst is rigid.
1234
* Rigid arcs cannot change length or the angle of their connection to a NodeInst.
1235
* @return true if this ArcInst is rigid.
1237
public boolean isRigid() { return d.isRigid(); }
1240
* Method to set this ArcInst to be fixed-angle.
1241
* Fixed-angle arcs cannot change their angle, so if one end moves,
1242
* the other may also adjust to keep the arc angle constant.
1245
public void setFixedAngle(boolean state) { setFlag(ImmutableArcInst.FIXED_ANGLE, state); }
1248
* Method to tell whether this ArcInst is fixed-angle.
1249
* Fixed-angle arcs cannot change their angle, so if one end moves,
1250
* the other may also adjust to keep the arc angle constant.
1251
* @return true if this ArcInst is fixed-angle.
1253
public boolean isFixedAngle() { return d.isFixedAngle(); }
1256
* Method to set this ArcInst to be slidable.
1257
* Arcs that slide will not move their connected NodeInsts if the arc's end is still within the port area.
1258
* Arcs that cannot slide will force their NodeInsts to move by the same amount as the arc.
1259
* Rigid arcs cannot slide but nonrigid arcs use this state to make a decision.
1262
public void setSlidable(boolean state) { setFlag(ImmutableArcInst.SLIDABLE, state); }
1265
* Method to tell whether this ArcInst is slidable.
1266
* Arcs that slide will not move their connected NodeInsts if the arc's end is still within the port area.
1267
* Arcs that cannot slide will force their NodeInsts to move by the same amount as the arc.
1268
* Rigid arcs cannot slide but nonrigid arcs use this state to make a decision.
1269
* @return true if this ArcInst is slidable.
1271
public boolean isSlidable() { return d.isSlidable(); }
1273
/****************************** PROPERTIES ******************************/
1276
* Method to determine whether this ArcInst is directional, with an arrow on one end.
1277
* Directional arcs have an arrow drawn on them to indicate flow.
1278
* It is only for documentation purposes and does not affect the circuit.
1279
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1280
* @return true if that end has a directional arrow on it.
1282
public boolean isArrowed(int connIndex) { return d.isArrowed(connIndex); }
1285
* Method to determine whether this ArcInst is directional, with an arrow on the tail.
1286
* Directional arcs have an arrow drawn on them to indicate flow.
1287
* It is only for documentation purposes and does not affect the circuit.
1288
* @return true if the arc's tail has a directional arrow on it.
1290
public boolean isTailArrowed() { return d.isTailArrowed(); }
1293
* Method to determine whether this ArcInst is directional, with an arrow on the head.
1294
* Directional arcs have an arrow drawn on them to indicate flow.
1295
* It is only for documentation purposes and does not affect the circuit.
1296
* @return true if the arc's head has a directional arrow on it.
1298
public boolean isHeadArrowed() { return d.isHeadArrowed(); }
1301
* Method to determine whether this ArcInst is directional, with an arrow line drawn down the center.
1302
* Directional arcs have an arrow drawn on them to indicate flow.
1303
* It is only for documentation purposes and does not affect the circuit.
1304
* The body is typically drawn when one of the ends has an arrow on it, but it may be
1305
* drawin without an arrow head in order to continue an attached arc that has an arrow.
1306
* @return true if the arc's tail has an arrow line on it.
1308
public boolean isBodyArrowed() { return d.isBodyArrowed(); }
1311
* Method to set this ArcInst to be directional, with an arrow on one end.
1312
* Directional arcs have an arrow drawn on them to indicate flow.
1313
* It is only for documentation purposes and does not affect the circuit.
1314
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1283
if (setD(d.withFlag(flag, state), true)) {
1284
topology.setArcsDirty();
1289
* Method to set this ArcInst to be rigid.
1290
* Rigid arcs cannot change length or the angle of their connection to a NodeInst.
1293
public void setRigid(boolean state) {
1294
setFlag(ImmutableArcInst.RIGID, state);
1298
* Method to tell whether this ArcInst is rigid.
1299
* Rigid arcs cannot change length or the angle of their connection to a NodeInst.
1300
* @return true if this ArcInst is rigid.
1302
public boolean isRigid() {
1307
* Method to set this ArcInst to be fixed-angle.
1308
* Fixed-angle arcs cannot change their angle, so if one end moves,
1309
* the other may also adjust to keep the arc angle constant.
1312
public void setFixedAngle(boolean state) {
1313
setFlag(ImmutableArcInst.FIXED_ANGLE, state);
1317
* Method to tell whether this ArcInst is fixed-angle.
1318
* Fixed-angle arcs cannot change their angle, so if one end moves,
1319
* the other may also adjust to keep the arc angle constant.
1320
* @return true if this ArcInst is fixed-angle.
1322
public boolean isFixedAngle() {
1323
return d.isFixedAngle();
1327
* Method to set this ArcInst to be slidable.
1328
* Arcs that slide will not move their connected NodeInsts if the arc's end is still within the port area.
1329
* Arcs that cannot slide will force their NodeInsts to move by the same amount as the arc.
1330
* Rigid arcs cannot slide but nonrigid arcs use this state to make a decision.
1333
public void setSlidable(boolean state) {
1334
setFlag(ImmutableArcInst.SLIDABLE, state);
1338
* Method to tell whether this ArcInst is slidable.
1339
* Arcs that slide will not move their connected NodeInsts if the arc's end is still within the port area.
1340
* Arcs that cannot slide will force their NodeInsts to move by the same amount as the arc.
1341
* Rigid arcs cannot slide but nonrigid arcs use this state to make a decision.
1342
* @return true if this ArcInst is slidable.
1344
public boolean isSlidable() {
1345
return d.isSlidable();
1348
/****************************** PROPERTIES ******************************/
1350
* Method to determine whether this ArcInst is directional, with an arrow on one end.
1351
* Directional arcs have an arrow drawn on them to indicate flow.
1352
* It is only for documentation purposes and does not affect the circuit.
1353
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1354
* @return true if that end has a directional arrow on it.
1356
public boolean isArrowed(int connIndex) {
1357
return d.isArrowed(connIndex);
1361
* Method to determine whether this ArcInst is directional, with an arrow on the tail.
1362
* Directional arcs have an arrow drawn on them to indicate flow.
1363
* It is only for documentation purposes and does not affect the circuit.
1364
* @return true if the arc's tail has a directional arrow on it.
1366
public boolean isTailArrowed() {
1367
return d.isTailArrowed();
1371
* Method to determine whether this ArcInst is directional, with an arrow on the head.
1372
* Directional arcs have an arrow drawn on them to indicate flow.
1373
* It is only for documentation purposes and does not affect the circuit.
1374
* @return true if the arc's head has a directional arrow on it.
1376
public boolean isHeadArrowed() {
1377
return d.isHeadArrowed();
1381
* Method to determine whether this ArcInst is directional, with an arrow line drawn down the center.
1382
* Directional arcs have an arrow drawn on them to indicate flow.
1383
* It is only for documentation purposes and does not affect the circuit.
1384
* The body is typically drawn when one of the ends has an arrow on it, but it may be
1385
* drawin without an arrow head in order to continue an attached arc that has an arrow.
1386
* @return true if the arc's tail has an arrow line on it.
1388
public boolean isBodyArrowed() {
1389
return d.isBodyArrowed();
1393
* Method to set this ArcInst to be directional, with an arrow on one end.
1394
* Directional arcs have an arrow drawn on them to indicate flow.
1395
* It is only for documentation purposes and does not affect the circuit.
1396
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1315
1397
* @param state true to show a directional arrow on the specified end.
1317
1399
public void setArrowed(int connIndex, boolean state) {
1318
1400
switch (connIndex) {
1319
case ImmutableArcInst.TAILEND: setTailArrowed(state); break;
1320
case ImmutableArcInst.HEADEND: setHeadArrowed(state); break;
1321
default: throw new IllegalArgumentException("Bad end " + connIndex);
1401
case ImmutableArcInst.TAILEND:
1402
setTailArrowed(state);
1404
case ImmutableArcInst.HEADEND:
1405
setHeadArrowed(state);
1408
throw new IllegalArgumentException("Bad end " + connIndex);
1326
* Method to set this ArcInst to be directional, with an arrow on the tail.
1327
* Directional arcs have an arrow drawn on them to indicate flow.
1328
* It is only for documentation purposes and does not affect the circuit.
1413
* Method to set this ArcInst to be directional, with an arrow on the tail.
1414
* Directional arcs have an arrow drawn on them to indicate flow.
1415
* It is only for documentation purposes and does not affect the circuit.
1329
1416
* @param state true to show a directional arrow on the tail.
1331
public void setTailArrowed(boolean state) { setFlag(ImmutableArcInst.TAIL_ARROWED, state); }
1418
public void setTailArrowed(boolean state) {
1419
setFlag(ImmutableArcInst.TAIL_ARROWED, state);
1334
* Method to set this ArcInst to be directional, with an arrow on the head.
1335
* Directional arcs have an arrow drawn on them to indicate flow.
1336
* It is only for documentation purposes and does not affect the circuit.
1423
* Method to set this ArcInst to be directional, with an arrow on the head.
1424
* Directional arcs have an arrow drawn on them to indicate flow.
1425
* It is only for documentation purposes and does not affect the circuit.
1337
1426
* @param state true to show a directional arrow on the head.
1339
public void setHeadArrowed(boolean state) { setFlag(ImmutableArcInst.HEAD_ARROWED, state); }
1428
public void setHeadArrowed(boolean state) {
1429
setFlag(ImmutableArcInst.HEAD_ARROWED, state);
1342
* Method to set this ArcInst to be directional, with an arrow line drawn down the center.
1343
* Directional arcs have an arrow drawn on them to indicate flow.
1344
* It is only for documentation purposes and does not affect the circuit.
1345
* The body is typically drawn when one of the ends has an arrow on it, but it may be
1346
* drawin without an arrow head in order to continue an attached arc that has an arrow.
1433
* Method to set this ArcInst to be directional, with an arrow line drawn down the center.
1434
* Directional arcs have an arrow drawn on them to indicate flow.
1435
* It is only for documentation purposes and does not affect the circuit.
1436
* The body is typically drawn when one of the ends has an arrow on it, but it may be
1437
* drawin without an arrow head in order to continue an attached arc that has an arrow.
1347
1438
* @param state true to show a directional line on this arc.
1349
public void setBodyArrowed(boolean state) { setFlag(ImmutableArcInst.BODY_ARROWED, state); }
1352
* Method to tell whether an end of ArcInst has its ends extended.
1353
* Extended arcs continue past their endpoint by half of their width.
1354
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1355
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1356
* @return true if that end of this ArcInst iss extended.
1358
public boolean isExtended(int connIndex) { return d.isExtended(connIndex); }
1361
* Method to tell whether the tail of this arc is extended.
1362
* Extended arcs continue past their endpoint by half of their width.
1363
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1364
* @return true if the tail of this arc is extended.
1366
public boolean isTailExtended() { return d.isTailExtended(); }
1369
* Method to tell whether the head of this arc is extended.
1370
* Extended arcs continue past their endpoint by half of their width.
1371
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1372
* @return true if the head of this arc is extended.
1374
public boolean isHeadExtended() { return d.isHeadExtended(); }
1377
* Method to set whether an end of this arc is extended.
1378
* Extended arcs continue past their endpoint by half of their width.
1379
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1380
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1381
* @param e true to set that end of this arc to be extended.
1440
public void setBodyArrowed(boolean state) {
1441
setFlag(ImmutableArcInst.BODY_ARROWED, state);
1445
* Method to tell whether an end of ArcInst has its ends extended.
1446
* Extended arcs continue past their endpoint by half of their width.
1447
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1448
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1449
* @return true if that end of this ArcInst iss extended.
1451
public boolean isExtended(int connIndex) {
1452
return d.isExtended(connIndex);
1456
* Method to tell whether the tail of this arc is extended.
1457
* Extended arcs continue past their endpoint by half of their width.
1458
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1459
* @return true if the tail of this arc is extended.
1461
public boolean isTailExtended() {
1462
return d.isTailExtended();
1466
* Method to tell whether the head of this arc is extended.
1467
* Extended arcs continue past their endpoint by half of their width.
1468
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1469
* @return true if the head of this arc is extended.
1471
public boolean isHeadExtended() {
1472
return d.isHeadExtended();
1476
* Method to set whether an end of this arc is extended.
1477
* Extended arcs continue past their endpoint by half of their width.
1478
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1479
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1480
* @param e true to set that end of this arc to be extended.
1383
1482
public void setExtended(int connIndex, boolean e) {
1384
1483
switch (connIndex) {
1385
case ImmutableArcInst.TAILEND: setTailExtended(e); break;
1386
case ImmutableArcInst.HEADEND: setHeadExtended(e); break;
1387
default: throw new IllegalArgumentException("Bad end " + connIndex);
1484
case ImmutableArcInst.TAILEND:
1487
case ImmutableArcInst.HEADEND:
1491
throw new IllegalArgumentException("Bad end " + connIndex);
1392
* Method to set whether the tail of this arc is extended.
1393
* Extended arcs continue past their endpoint by half of their width.
1394
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1395
* @param e true to set the tail of this arc to be extended.
1397
public void setTailExtended(boolean e) {
1496
* Method to set whether the tail of this arc is extended.
1497
* Extended arcs continue past their endpoint by half of their width.
1498
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1499
* @param e true to set the tail of this arc to be extended.
1501
public void setTailExtended(boolean e) {
1398
1502
setFlag(ImmutableArcInst.TAIL_EXTENDED, e);
1399
1503
// if (isLinked()) updateGeometric();
1403
* Method to set whether the head of this arc is extended.
1404
* Extended arcs continue past their endpoint by half of their width.
1405
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1406
* @param e true to set the head of this arc to be extended.
1408
public void setHeadExtended(boolean e) {
1507
* Method to set whether the head of this arc is extended.
1508
* Extended arcs continue past their endpoint by half of their width.
1509
* Most layout arcs want this so that they make clean connections to orthogonal arcs.
1510
* @param e true to set the head of this arc to be extended.
1512
public void setHeadExtended(boolean e) {
1409
1513
setFlag(ImmutableArcInst.HEAD_EXTENDED, e);
1410
1514
// if (isLinked()) updateGeometric();
1414
* Method to tell whether an end of this arc is negated.
1415
* Negated arc have a negating bubble on them to indicate negation.
1416
* This is only valid in schematics technologies.
1417
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1418
* @return true if set that end of this arc is negated.
1420
public boolean isNegated(int connIndex) { return d.isNegated(connIndex); }
1423
* Method to tell whether the tail of this arc is negated.
1424
* Negated arc have a negating bubble on them to indicate negation.
1425
* This is only valid in schematics technologies.
1426
* @return true if set the tail of this arc is negated.
1428
public boolean isTailNegated() { return d.isTailNegated(); }
1431
* Method to tell whether the head of this arc is negated.
1432
* Negated arc have a negating bubble on them to indicate negation.
1433
* This is only valid in schematics technologies.
1434
* @return true if set the head of this arc is negated.
1436
public boolean isHeadNegated() { return d.isHeadNegated(); }
1439
* Method to set whether an end of this arc is negated.
1440
* Negated arc have a negating bubble on them to indicate negation.
1441
* This is only valid in schematics technologies.
1442
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1443
* @param n true to set that end of this arc to be negated.
1518
* Method to tell whether an end of this arc is negated.
1519
* Negated arc have a negating bubble on them to indicate negation.
1520
* This is only valid in schematics technologies.
1521
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1522
* @return true if set that end of this arc is negated.
1524
public boolean isNegated(int connIndex) {
1525
return d.isNegated(connIndex);
1529
* Method to tell whether the tail of this arc is negated.
1530
* Negated arc have a negating bubble on them to indicate negation.
1531
* This is only valid in schematics technologies.
1532
* @return true if set the tail of this arc is negated.
1534
public boolean isTailNegated() {
1535
return d.isTailNegated();
1539
* Method to tell whether the head of this arc is negated.
1540
* Negated arc have a negating bubble on them to indicate negation.
1541
* This is only valid in schematics technologies.
1542
* @return true if set the head of this arc is negated.
1544
public boolean isHeadNegated() {
1545
return d.isHeadNegated();
1549
* Method to set whether an end of this arc is negated.
1550
* Negated arc have a negating bubble on them to indicate negation.
1551
* This is only valid in schematics technologies.
1552
* @param connIndex TAILEND (0) for the tail of this ArcInst, HEADEND (1) for the head.
1553
* @param n true to set that end of this arc to be negated.
1445
1555
public void setNegated(int connIndex, boolean n) {
1446
1556
switch (connIndex) {
1447
case ImmutableArcInst.TAILEND: setTailNegated(n); break;
1448
case ImmutableArcInst.HEADEND: setHeadNegated(n); break;
1449
default: throw new IllegalArgumentException("Bad end " + connIndex);
1557
case ImmutableArcInst.TAILEND:
1560
case ImmutableArcInst.HEADEND:
1564
throw new IllegalArgumentException("Bad end " + connIndex);
1454
* Method to set whether the tail of this arc is negated.
1455
* Negated arc have a negating bubble on them to indicate negation.
1456
* This is only valid in schematics technologies.
1457
* @param n true to set the tail of this arc to be negated.
1459
public void setTailNegated(boolean n) {
1460
if (!(d.tailPortId instanceof PrimitivePortId && getTechPool().getPrimitivePort((PrimitivePortId)d.tailPortId).isNegatable()))
1462
if (getProto().getTechnology().isNoNegatedArcs())
1569
* Method to set whether the tail of this arc is negated.
1570
* Negated arc have a negating bubble on them to indicate negation.
1571
* This is only valid in schematics technologies.
1572
* @param n true to set the tail of this arc to be negated.
1574
public void setTailNegated(boolean n) {
1575
if (!(d.tailPortId instanceof PrimitivePortId && getTechPool().getPrimitivePort((PrimitivePortId) d.tailPortId).isNegatable())) {
1578
if (getProto().getTechnology().isNoNegatedArcs()) {
1464
1581
setFlag(ImmutableArcInst.TAIL_NEGATED, n);
1468
* Method to set whether the head of this arc is negated.
1469
* Negated arc have a negating bubble on them to indicate negation.
1470
* This is only valid in schematics technologies.
1471
* @param n true to set the head of this arc to be negated.
1473
public void setHeadNegated(boolean n) {
1474
if (!(d.headPortId instanceof PrimitivePortId && getTechPool().getPrimitivePort((PrimitivePortId)d.headPortId).isNegatable()))
1476
if (getProto().getTechnology().isNoNegatedArcs())
1478
setFlag(ImmutableArcInst.HEAD_NEGATED, n);
1481
/****************************** MISCELLANEOUS ******************************/
1484
* Method to check and repair data structure errors in this ArcInst.
1486
public int checkAndRepair(boolean repair, List<Geometric> list, ErrorLogger errorLogger)
1585
* Method to set whether the head of this arc is negated.
1586
* Negated arc have a negating bubble on them to indicate negation.
1587
* This is only valid in schematics technologies.
1588
* @param n true to set the head of this arc to be negated.
1590
public void setHeadNegated(boolean n) {
1591
if (!(d.headPortId instanceof PrimitivePortId && getTechPool().getPrimitivePort((PrimitivePortId) d.headPortId).isNegatable())) {
1594
if (getProto().getTechnology().isNoNegatedArcs()) {
1597
setFlag(ImmutableArcInst.HEAD_NEGATED, n);
1600
/****************************** MISCELLANEOUS ******************************/
1602
* Method to check and repair data structure errors in this ArcInst.
1604
public int checkAndRepair(boolean repair, List<Geometric> list, ErrorLogger errorLogger) {
1489
1606
ArcProto ap = getProto();
1608
Cell parent = topology.cell;
1609
if (ap.isNotUsed()) {
1494
if (errorLogger != null)
1611
if (errorLogger != null) {
1496
1612
String msg = "Prototype of arc " + getName() + " is unused";
1498
1614
// Can't put this arc into error logger because it will be deleted.