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

📄 abstracttextdescriptor.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		 */		/*private*/ int getBits() { return bits; }		/**		 * Method to return a Size object that describes a relative text size (in grid units).		 * The size must be between 1 and 63 points.		 * @param size the size in units.		 * Returns null if the size is invalid.		 */		public static Size newAbsSize(int size)		{			if (size < TXTMINPOINTS || size > TXTMAXPOINTS) return null;			return new Size(size, true);		}		/**		 * Method to return a Size object that describes an absolute point text size.		 * The size must be between 0.25 and 127.75 grid units (in .25 increments).		 * @param size the size in points.		 * Returns null if the size is invalid.		 */		public static Size newRelSize(double size)		{			if (size < TXTMINQGRID || size > TXTMAXQGRID) return null;			return new Size(size, false);		}		/**		 * Method to return text Size value (in points or units).		 * @return the text Size value (in points or units).		 */		public double getSize() { return size; }		/**		 * Method to tell whether this text Size is absolute or relative.		 * @return true if this text size is absolute		 */		public boolean isAbsolute() { return absolute; }		/**		 * Method to tell whether this Size is the same as another.		 * @return true if they are equal.		 */		public boolean equals(Object that)		{            if (that instanceof Size) {                Size other = (Size)that;                return this.absolute == other.absolute && DBMath.doublesEqual(this.size, other.size);            }			return false;		}		/**		 * Returns a printable version of this Size.		 * @return a printable version of this Size.		 */		public String toString() { return "Text Size"; }	}	/**	 * Rotation is a typesafe enum class that describes text's rotation in a Variable.	 */	public static class Rotation	{		private final int angle;		private final int index;		private final String name;		private static final List<Rotation> rotations = new ArrayList<Rotation>();		private Rotation(int angle, int index, String name)		{			this.angle = angle;			this.index = index;			this.name = name;			rotations.add(index, this);		}		/**		 * Method to return the integer equivalent of this DispPos.		 * This is zero-based.		 * @return the integer equivalent of this DispPos.		 */		public int getIndex() { return index; }		/**		 * Method to return the description of this DispPos.		 * It appears in popup menus.		 * @return the description of this DispPos.		 */		public String getDescription() { return name; }        /**         * Get the angle of this rotation.         * @return the angle of this rotation.         */        public int getAngle() { return angle; }        /**         * Get the Rotation for the given angle.         * @param angle the angle.         * @return a Rotation for the given angle, or null if non exists.         */        public static Rotation getRotation(int angle)        {            for (Rotation rot : rotations)            {                if (rot.getAngle() == angle) return rot;            }            return null;        }		/**		 * Method to return the number Rotations.		 * @return the number Rotations.		 */		public static int getNumRotations() { return rotations.size(); }		/**		 * Method to return the Rotation at a given index.		 * @param index the Rotation number desired.		 * @return the Rotation at a given index.		 */		public static Rotation getRotationAt(int index) { return rotations.get(index); }        /**         * Get an iterator over all rotations         * @return an iterator over all rotations         */        public static Iterator<Rotation> getRotations() { return Collections.unmodifiableList(rotations).iterator(); }		/**		 * Returns a printable version of this Rotation.		 * @return a printable version of this Rotation.		 */		public String toString() { return "Text Rotation "+angle; }		/** Describes a Rotation of 0 degrees. */	public static final Rotation ROT0 =														new Rotation(0, 0, "None");		/** Describes a Rotation of 90 degrees. */	public static final Rotation ROT90 =														new Rotation(90, 1, "90 degrees counterclockwise");		/** Describes a Rotation of 180 degrees. */	public static final Rotation ROT180 =														new Rotation(180, 2, "180 degrees");		/** Describes a Rotation of 270 degrees. */	public static final Rotation ROT270 =														new Rotation(270, 3, "90 degrees clockwise");	}	/**	 * Unit is a typesafe enum class that describes text's units on a Variable.	 */	public static class Unit	{		private final String name;		private final int index;		private static final List<Unit> units = new ArrayList<Unit>();		private Unit(String name, int index)		{			this.name = name;			this.index = index;			units.add(index, this);		}		/**		 * Method to return the integer equivalent of this Unit.		 * This is zero-based.		 * @return the integer equivalent of this Unit.		 */		public int getIndex() { return index; }		/**		 * Method to return the description of this Unit.		 * It appears in popup menus.		 * @return the description of this Unit.		 */		public String getDescription() { return name; }		/**		 * Method to return the number Units.		 * @return the number Units.		 */        public static int getNumUnits() { return units.size(); }		/**		 * Method to return the Unit at a given index.		 * @param index the Unit number desired.		 * @return the Unit at a given index.		 */        public static Unit getUnitAt(int index) { return units.get(index); }        /**         * Get an iterator over all units.         * @return an iterator over the list of unit types.         */        public static Iterator<Unit> getUnits() { return Collections.unmodifiableList(units).iterator(); }		/**		 * Returns a printable version of this Unit.		 * @return a printable version of this Unit.		 */		public String toString() { return name; }		/** Describes no units. */				public static final Unit NONE =        new Unit("none", VTUNITSNONE);		/** Describes resistance units. */		public static final Unit RESISTANCE =  new Unit("resistance", VTUNITSRES);		/** Describes capacitance units. */		public static final Unit CAPACITANCE = new Unit("capacitance", VTUNITSCAP);		/** Describes inductance units. */		public static final Unit INDUCTANCE =  new Unit("inductance", VTUNITSIND);		/** Describes current units. */			public static final Unit CURRENT =     new Unit("current", VTUNITSCUR);		/** Describes voltage units. */			public static final Unit VOLTAGE =     new Unit("voltage", VTUNITSVOLT);		/** Describes distance units. */		public static final Unit DISTANCE =    new Unit("distance", VTUNITSDIST);		/** Describes time units. */			public static final Unit TIME =        new Unit("time", VTUNITSTIME);	}	/**	 * ActiveFont is a class that describes fonts currently in use.	 */	public static class ActiveFont	{		private String fontName;		private int index;		private static int indexCount = 0;		private static final Map<String,ActiveFont> fontMap = new HashMap<String,ActiveFont>();		private static final List<ActiveFont> fontList = new ArrayList<ActiveFont>();		private ActiveFont(String fontName)		{			indexCount++;			this.index = indexCount;			this.fontName = fontName;			fontMap.put(fontName, this);			fontList.add(this);		}		/**		 * Method to return the maximum index value for ActiveFonts.		 * @return the maximum index value.		 * ActiveFonts will have indices ranging from 1 to this value.		 */		public static int getMaxIndex() { return indexCount; }		/**		 * Method to return the index for this ActiveFont.		 * @return the index of this ActiveFont.		 * The index value is 1-based, because font 0 is the "default font".		 */		public int getIndex() { return index; }		/**		 * Method to return the font name associated with this ActiveFont.		 * @return the font name associated with this ActiveFont.		 */		public String getName() { return fontName; }		/**		 * Method to return the ActiveFont with a given name.		 * @param fontName the name of the font.		 * @return an ActiveFont object.  If there is no ActiveFont		 * associated with this fontname, one is created.		 */		public static ActiveFont findActiveFont(String fontName)		{			ActiveFont af = fontMap.get(fontName);            if (af != null) return af;            if (indexCount >= VTMAXFACE)            {                System.out.println("Too many fonts. Using default instead of " + fontName);                return null;            }            return new ActiveFont(fontName);		}		/**		 * Method to return the ActiveFont with a given index.		 * @param index the index number (1-based) of the ActiveFont.		 * @return the ActiveFont with this index.  Returns null if there is none.		 */		public static ActiveFont findActiveFont(int index)		{			if (index <= 0) return null;			if (index > fontList.size()) return null;			ActiveFont af = fontList.get(index-1);			return af;		}		/**		 * Returns a printable version of this ActiveFont.		 * @return a printable version of this ActiveFont.		 */		public String toString() { return fontName; }	}	/**	 * DescriptorPref is a factory for creating text descriptors for a definite purpose.	 */	static class DescriptorPref	{		final Pref cacheBits;		final Pref cacheColor;		final Pref cacheFont;        long oldBits;        int oldColor;        String oldFontName;        TextDescriptor tdF, tdT;		/**		 * Constructs DescriptorPref for a definite purpose.		 * @param purpose purpose of new text descriptor.		 * @param initialSize relative size for new text descriptor.		 */		DescriptorPref(String purpose, int initialSize)		{    		cacheBits = Pref.makeLongPref("TextDescriptorFor" + purpose, prefs, swap((((long)initialSize) << Size.TXTQGRIDSH) << VTSIZESH));			cacheColor = Pref.makeIntPref("TextDescriptorColorFor" + purpose, prefs, 0);			cacheFont = Pref.makeStringPref("TextDescriptorFontFor" + purpose, prefs, "");		}		/**		 * Method to restore this DescriptorPref to its factory values.		 */		public void factoryReset()		{			if (cacheBits.getLongFactoryValue() != cacheBits.getLong())				cacheBits.setLong(cacheBits.getLongFactoryValue());			if (cacheColor.getIntFactoryValue() != cacheColor.getInt())				cacheColor.setInt(cacheColor.getIntFactoryValue());			if (!cacheFont.getStringFactoryValue().equals(cacheFont.getString()))				cacheFont.setString(cacheFont.getStringFactoryValue());		}		private long swap(long value)        {            int v0 = (int)value;            return (value >>> 32) | ((long)v0 << 32);        }		/**		 * Creates new TextDescriptor for this purpose.		 * @return new TextDescripor.		 */		synchronized TextDescriptor newTextDescriptor(boolean display)		{            long bits = swap(cacheBits.getLong());            int color = cacheColor.getInt();            String fontName = cacheFont.getString();            if (oldFontName != null && bits == oldBits && color == oldColor && fontName.equals(oldFontName))                return display ? tdT : tdF;            oldBits = bits;            oldColor = color;            oldFontName = fontName;            int face = 0;            if (fontName.length() > 0)            {                ActiveFont af = ActiveFont.findActiveFont(fontName);                if (af != null)                    face = af.getIndex();            }            bits = (bits & ~VTFACE) | (face << VTFACESH);            bits = bits & ~(VTISPARAMETER|VTINHERIT);            tdF = TextDescriptor.newTextDescriptor(new MutableTextDescriptor(bits, color, false));            tdT = TextDescriptor.newTextDescriptor(new MutableTextDescriptor(bits, color, true));			return display ? tdT : tdF;		}		/**		 * Creates new displayable MutableTextDescriptor for this purpose.		 * @return new MutableTextDescripor.		 */		MutableTextDescriptor newMutableTextDescriptor()		{			return new MutableTextDescriptor(newTextDescriptor(true));		}		/**		 * Changed default TextDescriptor for this purpose.		 * @param td default TextDescriptor		 */		synchronized void setTextDescriptor(AbstractTextDescriptor td)		{			MutableTextDescriptor mtd = new MutableTextDescriptor(td);			mtd.setFace(0);			cacheBits.setLong(swap(mtd.lowLevelGet()));			cacheColor.setInt(mtd.getColorIndex());			ActiveFont af = ActiveFont.findActiveFont(td.getFace());			cacheFont.setString(af != null ? af.getName() : "");		}	}	/** preferences for all descriptors */	private static final Pref.Group prefs = Pref.groupForPackage(AbstractTextDescriptor.class);    AbstractTextDescriptor() {}	/**	 * Default TextDescriptor for NodeInsts is 1 unit tall.	 */	/*package*/ static final DescriptorPref cacheNodeDescriptor = new DescriptorPref("Node", 4);	/**	 * Method to set a TextDescriptor that is a default for Variables on NodeInsts.	 * @param td the default TextDescriptor for Variables on NodeInsts.	 */

⌨️ 快捷键说明

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