📄 immutablearcinst.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: ImmutableArcInst.java * Written by: Dmitry Nadezhin, Sun Microsystems. * * Copyright (c) 2005 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.database;import com.sun.electric.database.geometry.DBMath;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.geometry.GenMath;import com.sun.electric.database.id.ArcProtoId;import com.sun.electric.database.id.ExportId;import com.sun.electric.database.id.IdReader;import com.sun.electric.database.id.IdWriter;import com.sun.electric.database.id.PortProtoId;import com.sun.electric.database.id.PrimitivePortId;import com.sun.electric.database.text.ImmutableArrayList;import com.sun.electric.database.text.Name;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.TechPool;import java.io.IOException;/** * Immutable class ImmutableArcInst represents an arc instance. */public class ImmutableArcInst extends ImmutableElectricObject { /** The index of the tail of this ArcInst. */ public static final int TAILEND = 0; /** The index of the head of this ArcInst. */ public static final int HEADEND = 1; /** Key of Varible holding arc curvature. */ public static final Variable.Key ARC_RADIUS = Variable.newKey("ARC_radius"); /** Maximal extend of arc over minimal-width arc */ private static final int MAX_EXTEND = Integer.MAX_VALUE/8; /** * Class to access a flag in user bits of ImmutableNodeInst. */ public static class Flag { final int mask; final char jelibChar; final boolean jelibDefault; private Flag(int mask, char jelibChar, boolean jelibDefault) { this.mask = mask; this.jelibChar = jelibChar; this.jelibDefault = jelibDefault; } /** * Returns true if this Flag is set in userBits. * @param userBits user bits. * @return true if this Flag is set in userBits; */ public boolean is(int userBits) { return (userBits & mask) != 0; } /** * Updates this flag in userBits. * @param userBits old user bits. * @param value new value of flag. * @return updates userBits. */ public int set(int userBits, boolean value) { return value ? userBits | mask : userBits & ~mask; } } // -------------------------- constants -------------------------------- /** fixed-length arc */ private static final int ELIB_FIXED = 01; /** fixed-angle arc */ private static final int ELIB_FIXANG = 02;// /** arc has text that is far away */ private static final int AHASFARTEXT = 04;// /** arc is not in use */ private static final int DEADA = 020; /** DISK: angle of arc from end 0 to end 1 */ private static final int ELIB_AANGLE = 037740; /** DISK: bits of right shift for DISK_AANGLE field */ private static final int ELIB_AANGLESH = 5;// /** set if arc is to be drawn shortened */ private static final int ASHORT = 040000; /** set if head end of ArcInst is negated */ private static final int ELIB_ISHEADNEGATED = 0200000; /** DISK: set if ends do not extend by half width */ private static final int ELIB_NOEXTEND = 0400000; /** set if tail end of ArcInst is negated */ private static final int ELIB_ISTAILNEGATED = 01000000; /** DISK: set if arc aims from end 0 to end 1 */ private static final int ELIB_ISDIRECTIONAL = 02000000; /** DISK: no extension/negation/arrows on end 0 */ private static final int ELIB_NOTEND0 = 04000000; /** DISK: no extension/negation/arrows on end 1 */ private static final int ELIB_NOTEND1 = 010000000; /** DISK: reverse extension/negation/arrow ends */ private static final int ELIB_REVERSEEND = 020000000; /** set if arc can't slide around in ports */ private static final int ELIB_CANTSLIDE = 040000000;// /** set if afixed arc was changed */ private static final int FIXEDMOD = 0100000000;// /** only local arcinst re-drawing desired */ private static final int RELOCLA = 01000000000;// /**transparent arcinst re-draw is done */ private static final int RETDONA = 02000000000;// /** opaque arcinst re-draw is done */ private static final int REODONA = 04000000000;// /** general flag for spreading and highlighting */ private static final int ARCFLAGBIT = 010000000000; /** set if hard to select */ private static final int ELIB_HARDSELECTA =020000000000; private static final int TAIL_ARROWED_MASK = 0x001; private static final int HEAD_ARROWED_MASK = 0x002; private static final int TAIL_EXTENDED_MASK = 0x004; private static final int HEAD_EXTENDED_MASK = 0x008; private static final int TAIL_NEGATED_MASK = 0x010; private static final int HEAD_NEGATED_MASK = 0x020; private static final int BODY_ARROWED_MASK = 0x040; private static final int RIGID_MASK = 0x080; private static final int FIXED_ANGLE_MASK = 0x100; private static final int SLIDABLE_MASK = 0x200; private static final int HARD_SELECT_MASK = 0x400; private static final int DATABASE_FLAGS = 0x7ff; private static final int MANHATTAN_MASK = 0x800; /** * Flag to set an ImmutableArcInst to be rigid. * Rigid arcs cannot change length or the angle of their connection to a NodeInst. */ public static final Flag RIGID = new Flag(RIGID_MASK, 'R', false); /** * Flag to set an ImmutableArcInst to be fixed-angle. * Fixed-angle arcs cannot change their angle, so if one end moves, * the other may also adjust to keep the arc angle constant. */ public static final Flag FIXED_ANGLE = new Flag(FIXED_ANGLE_MASK, 'F', true); /** * Flag to set an ImmutableArcInst to be slidable. * Arcs that slide will not move their connected NodeInsts if the arc's end is still within the port area. * Arcs that cannot slide will force their NodeInsts to move by the same amount as the arc. * Rigid arcs cannot slide but nonrigid arcs use this state to make a decision. */ public static final Flag SLIDABLE = new Flag(SLIDABLE_MASK, 'S', false); /** * Flag to set an ImmutableArcInst to be directional, with an arrow on the tail. * Directional arcs have an arrow drawn on them to indicate flow. * It is only for documentation purposes and does not affect the circuit. */ public static final Flag TAIL_ARROWED = new Flag(TAIL_ARROWED_MASK, 'Y', false); /** * Flag to set an ImmutableArcInst to be directional, with an arrow on the head. * Directional arcs have an arrow drawn on them to indicate flow. * It is only for documentation purposes and does not affect the circuit. */ public static final Flag HEAD_ARROWED = new Flag(HEAD_ARROWED_MASK, 'X', false); /** * Flag to set an ImmutableArcInst to be directional, with an arrow line drawn down the center. * Directional arcs have an arrow drawn on them to indicate flow. * It is only for documentation purposes and does not affect the circuit. * The body is typically drawn when one of the ends has an arrow on it, but it may be * drawin without an arrow head in order to continue an attached arc that has an arrow. */ public static final Flag BODY_ARROWED = new Flag(BODY_ARROWED_MASK, 'B', false); /** * Flag to set the tail of an ImmutableArcInst to be is extended. * Extended arcs continue past their endpoint by half of their width. * Most layout arcs want this so that they make clean connections to orthogonal arcs. */ public static final Flag TAIL_EXTENDED = new Flag(TAIL_EXTENDED_MASK, 'J', true); /** * Flag to set the head of an ImmutableArcInst to be extended. * Extended arcs continue past their endpoint by half of their width. * Most layout arcs want this so that they make clean connections to orthogonal arcs. */ public static final Flag HEAD_EXTENDED = new Flag(HEAD_EXTENDED_MASK, 'I', true); /** * Flag to set the tail of an ImmutableArcInst to be negated. * Negated arc have a negating bubble on them to indicate negation. * This is only valid in schematics technologies. */ public static final Flag TAIL_NEGATED = new Flag(TAIL_NEGATED_MASK, 'N', false); /** * Flag to set the head of an ImmutableArcInst to be negated. * Negated arc have a negating bubble on them to indicate negation. * This is only valid in schematics technologies. */ public static final Flag HEAD_NEGATED = new Flag(HEAD_NEGATED_MASK, 'G', false); /** * Flag to set an ImmutableArcInst to be hard-to-select. * Hard-to-select ArcInsts cannot be selected by clicking on them. * Instead, the "special select" command must be given. */ public static final Flag HARD_SELECT = new Flag(HARD_SELECT_MASK, 'A', false); /** initial bits */ public static final int DEFAULT_FLAGS = SLIDABLE.mask | HEAD_EXTENDED.mask | TAIL_EXTENDED.mask; /** prefix for autonameing. */ public static final Name BASENAME = Name.findName("net@0"); public final static ImmutableArcInst[] NULL_ARRAY = {}; public final static ImmutableArrayList<ImmutableArcInst> EMPTY_LIST = new ImmutableArrayList<ImmutableArcInst>(NULL_ARRAY); /** id of this ArcInst in parent. */ public final int arcId; /** Arc prototype. */ public final ArcProtoId protoId; /** name of this ImmutableArcInst. */ public final Name name; /** The text descriptor of name of ImmutableArcInst. */ public final TextDescriptor nameDescriptor; /** NodeId on tail end of this ImmutableArcInst. */ public final int tailNodeId; /** PortProtoId on tail end of this ImmutableArcInst. */ public final PortProtoId tailPortId; /** Location of tail end of this ImmutableArcInst. */ public final EPoint tailLocation; /** NodeId on head end of this ImmutableArcInst. */ public final int headNodeId; /** PortProtoId on head end of this ImmutableArcInst. */ public final PortProtoId headPortId; /** Location of head end of this ImmutableArcInst. */ public final EPoint headLocation; /** extend of this ImmutableArcInst over minimal-width arc in grid units. */ private final int gridExtendOverMin; /** Angle if this ImmutableArcInst (in tenth-degrees). */ private final short angle; /** * The private constructor of ImmutableArcInst. Use the factory "newInstance" instead. * * @param arcId id of this ArcInst in parent. * @param protoId Id pf arc prototype. * @param name name of this ImmutableArcInst. * @param nameDescriptor TextDescriptor of name of this ImmutableArcInst. * @param tailNodeId NodeId on tail end of this ImmutableArcInst. * @param tailPortProtoId PortProtoId on tail end of this ImmutableArcInst. * @param tailLocation Location of tail end of this ImmutableArcInst. * @param headNodeId NodeId on head end of this ImmutableArcInst. * @param headPortProtoId PortProtoId on head end of this ImmutableArcInst. * @param headLocation Location of head end of this ImmutableArcInst. * @param gridExtendOverMin the extend of this ImmutableArcInst over minimal-width arc of this type in grid units. * @param angle the angle if this ImmutableArcInst (in tenth-degrees). * @param flags flag bits of this ImmutableArcInst. * @param vars array of Variables of this ImmutableArcInst */ ImmutableArcInst(int arcId, ArcProtoId protoId, Name name, TextDescriptor nameDescriptor, int tailNodeId, PortProtoId tailPortId, EPoint tailLocation, int headNodeId, PortProtoId headPortId, EPoint headLocation, int gridExtendOverMin, short angle, int flags, Variable[] vars) { super(vars, flags); this.arcId = arcId; this.protoId = protoId; this.name = name;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -