⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 immutablenodeinst.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: ImmutableNodeInst.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.id.IdReader;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.geometry.ERectangle;import com.sun.electric.database.geometry.Orientation;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.id.CellId;import com.sun.electric.database.id.ExportId;import com.sun.electric.database.id.IdWriter;import com.sun.electric.database.id.NodeProtoId;import com.sun.electric.database.id.PortProtoId;import com.sun.electric.database.id.PrimitiveNodeId;import com.sun.electric.database.text.ArrayIterator;import com.sun.electric.database.text.ImmutableArrayList;import com.sun.electric.database.text.Name;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Schematics;import java.awt.geom.AffineTransform;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.io.IOException;import java.util.Arrays;import java.util.Iterator;import java.util.NoSuchElementException;/** * Immutable class ImmutableNodeInst represents a node instance. * * @promise "requiresColor DBChanger;" for with*(**) | newInstance(**) * @promise "requiresColor (DBChanger | DBExaminer | AWT);" for check() */public class ImmutableNodeInst extends ImmutableElectricObject {    /**     * Class to access user bits of ImmutableNodeInst.     */    public static class Flag {        private final int mask;        private Flag(int mask) {            this.mask = mask;        }        /**         * 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 --------------------------------//	/** node is not in use */								private static final int DEADN =                     01;//	/** node has text that is far away */					private static final int NHASFARTEXT =               02;//	/** if on, draw node expanded */						private static final int NEXPAND =                   04;//	/** set if node not drawn due to wiping arcs */			private static final int NWIPED =                   010;//	/** set if node is to be drawn shortened */				private static final int NSHORT =                   020;	//  used by database:                                                                                      0140//	/** if on, this nodeinst is marked for death */			private static final int KILLN =                   0200;//	/** nodeinst re-drawing is scheduled */					private static final int REWANTN =                 0400;//	/** only local nodeinst re-drawing desired */			private static final int RELOCLN =                01000;//	/** transparent nodeinst re-draw is done */				private static final int RETDONN =                02000;//	/** opaque nodeinst re-draw is done */					private static final int REODONN =                04000;//	/** general flag used in spreading and highlighting */	private static final int NODEFLAGBIT =           010000;//	/** if on, nodeinst wants to be (un)expanded */			private static final int WANTEXP =               020000;//	/** temporary flag for nodeinst display */				private static final int TEMPFLG =               040000;	/** set if hard to select */							private static final int HARDSELECTN =          0100000;	/** set if node only visible inside cell */				private static final int NVISIBLEINSIDE =     040000000;	/** technology-specific bits for primitives */			private static final int NTECHBITS =          037400000;	/** right-shift of NTECHBITS */							private static final int NTECHBITSSH =               17;	/** set if node is locked (can't be changed) */			private static final int NILOCKED =          0100000000; 	private static final int FLAG_BITS = HARDSELECTN | NVISIBLEINSIDE | NILOCKED;//    private static final int HARD_SELECT_MASK = 0x01;//    private static final int VIS_INSIDE_MASK  = 0x02;//    private static final int LOCKED_MASK      = 0x04;//    private static final int DATABASE_FLAGS   = 0x07;	/**	 * Method to set an ImmutableNodeInst to be hard-to-select.	 * Hard-to-select ImmutableNodeInsts cannot be selected by clicking on them.	 * Instead, the "special select" command must be given.	 */	public static final Flag HARD_SELECT = new Flag(HARDSELECTN);	/**	 * Flag to set an ImmutableNodeInst to be visible-inside.	 * An ImmutableNodeInst that is "visible inside" is only drawn when viewing inside of the Cell.	 * It is not visible from outside (meaning from higher-up the hierarchy).	 */	public static final Flag VIS_INSIDE = new Flag(NVISIBLEINSIDE);	/**	 * Method to set this ImmutableNodeInst to be locked.	 * Locked ImmutableNodeInsts cannot be modified or deleted.	 */	public static final Flag LOCKED = new Flag(NILOCKED);    public final static ImmutableNodeInst[] NULL_ARRAY = {};    public final static ImmutableArrayList<ImmutableNodeInst> EMPTY_LIST = new ImmutableArrayList<ImmutableNodeInst>(NULL_ARRAY);    /** id of this NodeInst in parent. */                           public final int nodeId;	/** Prototype id. */                                            public final NodeProtoId protoId;	/** name of this ImmutableNodeInst. */							public final Name name;	/** The text descriptor of name of ImmutableNodeInst. */		public final TextDescriptor nameDescriptor;	/** Orientation of this ImmutableNodeInst. */                   public final Orientation orient;	/** anchor coordinate of this ImmutableNodeInst. */				public final EPoint anchor;	/** size of this ImmutableNodeInst. */                          public final EPoint size;    /** Tech specifiic bits for this ImmutableNodeInsts. */         public final byte techBits;	/** Text descriptor of prototype name. */                       public final TextDescriptor protoDescriptor;    /** Variables on PortInsts. */                                  final ImmutablePortInst[] ports;	/**	 * The private constructor of ImmutableNodeInst. Use the factory "newInstance" instead.     * @param nodeId id of this NodeInst in parent.	 * @param protoId the NodeProtoId of which this is an instance.	 * @param name name of new ImmutableNodeInst.     * @param nameDescriptor TextDescriptor of name of this ImmutableNodeInst.     * @param orient Orientation of this ImmutableNodeInst.	 * @param anchor the anchor location of this ImmutableNodeInst.	 * @param size the size of this ImmutableNodeInst.     * @param flags flag bits for thisImmutableNdoeIsnt.	 * @param techBits tech speicfic bits of this ImmutableNodeInst.     * @param protoDescriptor TextDescriptor of prototype name of this ImmutableNodeInst     * @param vars array of Variables of this ImmutableNodeInst     * @param ports array of ImmutablePortInsts of this ImmutableNodeInst	 */    ImmutableNodeInst(int nodeId, NodeProtoId protoId, Name name, TextDescriptor nameDescriptor,            Orientation orient, EPoint anchor, EPoint size,            int flags, byte techBits, TextDescriptor protoDescriptor, Variable[] vars, ImmutablePortInst[] ports) {        super(vars, flags);        this.nodeId = nodeId;        this.protoId = protoId;        this.name = name;        this.nameDescriptor = nameDescriptor;        this.orient = orient;        this.anchor = anchor;        this.size = size;        this.techBits = techBits;        this.protoDescriptor = protoDescriptor;        this.ports = ports;//        check();    }	/**	 * Returns new ImmutableNodeInst or ImmutableIconInst object.     * @param nodeId id of this NodeInst in parent.	 * @param protoId the NodeProtoId of which this is an instance.	 * @param name name of new ImmutableNodeInst.     * @param nameDescriptor TextDescriptor of name of this ImmutableNodeInst.     * @param orient Orientation of this ImmutableNodeInst.	 * @param anchor the anchor location of this ImmutableNodeInst.	 * @param size the size of this ImmutableNodeInst.     * @param flags flag bits for thisImmutableNdoeIsnt.	 * @param techBits tech speicfic bits of this ImmutableNodeInst.     * @param protoDescriptor TextDescriptor of prototype name of this ImmutableNodeInst     * @param vars array of Variables of this ImmutableNodeInst     * @param params a map of parameter values of this ImmutableNodeInst	 * @return new ImmutableNodeInst object.	 */    static ImmutableNodeInst newInstance(int nodeId, NodeProtoId protoId, Name name, TextDescriptor nameDescriptor,            Orientation orient, EPoint anchor, EPoint size,            int flags, byte techBits, TextDescriptor protoDescriptor,            Variable[] vars, ImmutablePortInst[] ports, Variable[] params) {        if (protoId instanceof CellId && ((CellId)protoId).isIcon()) {            return new ImmutableIconInst(nodeId, protoId, name, nameDescriptor,                orient, anchor, size, flags, (byte)techBits, protoDescriptor,                vars, ports, params);        } else {            assert params == Variable.NULL_ARRAY;            return new ImmutableNodeInst(nodeId, protoId, name, nameDescriptor,                orient, anchor, size, flags, (byte)techBits, protoDescriptor,                vars, ports);        }    }	/**	 * Returns new ImmutableNodeInst or ImmutableIconInst object.     * @param nodeId id of this NodeInst in parent.	 * @param protoId the NodeProtoId of which this is an instance.	 * @param name name of new ImmutableNodeInst.     * @param nameDescriptor TextDescriptor of name of this ImmutableNodeInst.     * @param orient Orientation of this ImmutableNodeInst.	 * @param anchor the anchor location of this ImmutableNodeInst.	 * @param size the size of this ImmutableNodeInst.     * @param flags flags of this NodeInst.	 * @param techBits bits associated to different technologies     * @param protoDescriptor TextDescriptor of name of this ImmutableNodeInst	 * @return new ImmutableNodeInst object.	 * @throws NullPointerException if protoId, name, orient or anchor is null.     * @throws IllegalArgumentException if nodeId or size is bad.	 */    public static ImmutableNodeInst newInstance(int nodeId, NodeProtoId protoId, Name name, TextDescriptor nameDescriptor,            Orientation orient, EPoint anchor, EPoint size,            int flags, int techBits, TextDescriptor protoDescriptor) {        if (nodeId < 0) throw new IllegalArgumentException("nodeId");		if (protoId == null) throw new NullPointerException("protoId");		if (name == null) throw new NullPointerException("name");        if (!name.isValid() || name.hasEmptySubnames() || name.isTempname() && name.isBus())        	throw new IllegalArgumentException("bad name: "+name);        if (name.hasDuplicates()) throw new IllegalArgumentException("name");        if (nameDescriptor != null)            nameDescriptor = nameDescriptor.withDisplayWithoutParam();        if (orient == null) throw new NullPointerException("orient");		if (anchor == null) throw new NullPointerException("anchor");        if (size == null) throw new NullPointerException("size");//        if (size.getGridX() < 0 || size.getGridY() < 0) throw new IllegalArgumentException("size");        if (protoId instanceof CellId)            size = EPoint.ORIGIN;        if (isCellCenter(protoId)) {            orient = Orientation.IDENT;            anchor = EPoint.ORIGIN;            size = EPoint.ORIGIN;        }        flags &= FLAG_BITS;        techBits &= NTECHBITS >> NTECHBITSSH;        if (protoDescriptor != null)            protoDescriptor = protoDescriptor.withDisplayWithoutParam();        return newInstance(nodeId, protoId, name, nameDescriptor,                orient, anchor, size, flags, (byte)techBits, protoDescriptor,                Variable.NULL_ARRAY, ImmutablePortInst.NULL_ARRAY, Variable.NULL_ARRAY);    }//	/**//	 * Returns ImmutableNodeInst which differs from this ImmutableNodeInst by protoId.//	 * @param protoId node protoId.//	 * @return ImmutableNodeInst which differs from this ImmutableNodeInst by protoId.//	 * @throws ArrayIndexOutOfBoundsException if protoId is negative.//	 *///	public ImmutableNodeInst withProto(int protoId) {//		if (this.protoId == protoId) return this;//		if (protoId < 0) throw new ArrayIndexOutOfBoundsException(protoId);//		return new ImmutableNodeInst(protoId, this.name, this.duplicate, this.nameDescriptor,//                this.orient, this.anchor, this.width, this.height, this.userBits, this.protoDescriptor);//	}	/**	 * Returns ImmutableNodeInst which differs from this ImmutableNodeInst by name.	 * @param name node name key.	 * @return ImmutableNodeInst which differs from this ImmutableNodeInst by name.	 * @throws NullPointerException if name is null.	 */	public ImmutableNodeInst withName(Name name) {		if (this.name.toString().equals(name.toString())) return this;		if (name == null) throw new NullPointerException("name");        if (!name.isValid() || name.hasEmptySubnames() || name.isTempname() && name.isBus()) throw new IllegalArgumentException("name");        if (name.hasDuplicates()) throw new IllegalArgumentException("name");		return newInstance(this.nodeId, this.protoId, name, this.nameDescriptor,                this.orient, this.anchor, this.size, this.flags, this.techBits, this.protoDescriptor,                getVars(), this.ports, getDefinedParams());	}	/**	 * Returns ImmutableNodeInst which differs from this ImmutableNodeInst by name descriptor.     * @param nameDescriptor TextDescriptor of name	 * @return ImmutableNodeInst which differs from this ImmutableNodeInst by name descriptor.	 */	public ImmutableNodeInst withNameDescriptor(TextDescriptor nameDescriptor) {        if (nameDescriptor != null)            nameDescriptor = nameDescriptor.withDisplayWithoutParam();        if (this.nameDescriptor == nameDescriptor) return this;		return newInstance(this.nodeId, this.protoId, this.name, nameDescriptor,                this.orient, this.anchor, this.size, this.flags, this.techBits, this.protoDescriptor,                getVars(), this.ports, getDefinedParams());	}	/**	 * Returns ImmutableNodeInst which differs from this ImmutableNodeInst by orientation.     * @param orient Orientation.	 * @return ImmutableNodeInst which differs from this ImmutableNodeInst by orientation.	 * @throws NullPointerException if orient is null.	 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -