com.sun.electric.database.variable
Class TextDescriptor

java.lang.Object
  extended by com.sun.electric.database.variable.TextDescriptor
All Implemented Interfaces:
java.io.Serializable

public class TextDescriptor
extends java.lang.Object

This class describes how variable text appears.

This class should be thread-safe

See Also:
Serialized Form

Nested Class Summary
static class AbstractTextDescriptor.ActiveFont
          ActiveFont is a class that describes fonts currently in use.
static class AbstractTextDescriptor.Display
          enumeration which represents text visibility .
static class AbstractTextDescriptor.DispPos
          DispPos is a typesafe enum class that describes text's display position on a Variable.
static class AbstractTextDescriptor.Position
          Position is a typesafe enum class that describes the text position of a Variable.
static class AbstractTextDescriptor.Rotation
          Rotation is a typesafe enum class that describes text's rotation in a Variable.
static class AbstractTextDescriptor.Size
          Size is a class that describes text's size on a Variable.
static class AbstractTextDescriptor.TextType
           
static class AbstractTextDescriptor.Unit
          Unit is a typesafe enum class that describes text's units on a Variable.
 
Field Summary
static TextDescriptor EMPTY
          empty text descriptor.
 
Method Summary
static int cacheSize()
           
 boolean equals(java.lang.Object anObject)
          Compares this text descriptor to the specified object.
static TextDescriptor getAnnotationTextDescriptor()
          Method to return a displayable TextDescriptor that is a default for Variables on Annotations.
static TextDescriptor getArcTextDescriptor()
          Method to return a displayable TextDescriptor that is a default for Variables on ArcInsts.
static TextDescriptor getCellTextDescriptor()
          Method to return a displayable TextDescriptor that is a default for Variables on Cell Variables.
 int getColorIndex()
          Method to return the color index of the TextDescriptor.
static java.awt.Font getDefaultFont()
          Method to get a default Font to use.
static int getDefaultFontSize()
           
 AbstractTextDescriptor.Display getDisplay()
          Method to return mode how this TextDescriptor is displayable.
 AbstractTextDescriptor.DispPos getDispPart()
          Method to return the text display part of the TextDescriptor.
static TextDescriptor getExportTextDescriptor()
          Method to return a displayable TextDescriptor that is a default for Variables on Exports.
 int getFace()
          Method to return the text font of the TextDescriptor.
 java.awt.Font getFont(EditWindow0 wnd, int minimalTextSize)
          Method to get a Font to use for this TextDescriptor in a given EditWindow.
static java.awt.font.GlyphVector getGlyphs(java.lang.String text, java.awt.Font font)
          Method to convert a string and descriptor to a GlyphVector.
static TextDescriptor getInstanceTextDescriptor()
          Method to return a displayable TextDescriptor that is a default for Variables on Cell Instance Names.
static TextDescriptor getNodeTextDescriptor()
          Method to return a displayable TextDescriptor that is a default for Variables on NodeInsts.
static TextDescriptor getPortInstTextDescriptor()
          Method to return a displayable TextDescriptor that is a default for Variables on PortInsts.
 AbstractTextDescriptor.Position getPos()
          Method to return the text position of the TextDescriptor.
 AbstractTextDescriptor.Rotation getRotation()
          Method to return the text rotation of the TextDescriptor.
 AbstractTextDescriptor.Size getSize()
          Method to return the text size of the text in this TextDescriptor.
 double getTrueSize(double scale, EditWindow0 wnd)
          Method to find the true size in points for this TextDescriptor in a given scale.
 double getTrueSize(EditWindow0 wnd)
          Method to find the true size in points for this TextDescriptor in a given EditWindow0.
 AbstractTextDescriptor.Unit getUnit()
          Method to return the Unit of the TextDescriptor.
 double getXOff()
          Method to return the X offset of the text in the TextDescriptor.
 double getYOff()
          Method to return the Y offset of the text in the TextDescriptor.
 int hashCode()
          Returns a hash code for this TextDescriptor.
 boolean isAbsoluteSize()
          Returns true if this ImmutableTextDescriptor describes absolute text.
 boolean isBold()
          Method to return true if the text in the TextDescriptor is bold.
 boolean isDisplay()
          Method to return true if this TextDescriptor is displayable.
 boolean isInherit()
          Method to return true if the text in the TextDescriptor is inheritable.
 boolean isInterior()
          Method to return true if the text in the TextDescriptor is interior.
 boolean isItalic()
          Method to return true if the text in the TextDescriptor is italic.
 boolean isParam()
          Method to return true if the text in the TextDescriptor is a parameter.
 boolean isUnderline()
          Method to return true if the text in the TextDescriptor is underlined.
 long lowLevelGet()
          Low-level method to get the bits in the TextDescriptor.
 int lowLevelGet0()
          Low-level method to get the first word of the bits in the TextDescriptor.
 int lowLevelGet1()
          Low-level method to get the second word of the bits in the TextDescriptor.
static TextDescriptor newTextDescriptor(com.sun.electric.database.variable.AbstractTextDescriptor td)
           
 TextDescriptor withAbsSize(int s)
          Returns TextDescriptor which differs from this TextDescriptor by text size.
 TextDescriptor withBold(boolean state)
          Returns TextDescriptor which differs from this TextDescriptor by bold flag.
 TextDescriptor withColorIndex(int colorIndex)
          Returns TextDescriptor which differs from this TextDescriptor by colorIndex.
 TextDescriptor withDisplay(AbstractTextDescriptor.Display display)
          Returns TextDescriptor which differs from this TextDescriptor by displayable mode.
 TextDescriptor withDisplay(boolean state)
          Returns TextDescriptor which differs from this TextDescriptor by displayable flag.
 TextDescriptor withDisplayWithoutParam()
           
 TextDescriptor withDispPart(AbstractTextDescriptor.DispPos dispPos)
          Returns TextDescriptor which differs from this TextDescriptor by dislay part.
 TextDescriptor withFace(int f)
          Returns TextDescriptor which differs from this TextDescriptor by text font.
 TextDescriptor withInherit(boolean state)
          Returns TextDescriptor which differs from this TextDescriptor by inheritable flag.
 TextDescriptor withInterior(boolean state)
          Returns TextDescriptor which differs from this TextDescriptor by interior flag.
 TextDescriptor withItalic(boolean state)
          Returns TextDescriptor which differs from this TextDescriptor by italic flag.
 TextDescriptor withOff(double xd, double yd)
          Returns TextDescriptor which differs from this TextDescriptor by X and Y offsets of the text in the Variable's TextDescriptor.
 TextDescriptor withParam(boolean state)
          Returns TextDescriptor which deffers from this TextDescriptor by parameter flag.
 TextDescriptor withPos(AbstractTextDescriptor.Position p)
          Returns TextDescriptor which differs from this TextDescriptor by position.
 TextDescriptor withRelSize(double s)
          Returns TextDescriptor which differs from this TextDescriptor by text size.
 TextDescriptor withRotation(AbstractTextDescriptor.Rotation r)
          Returns TextDescriptor which differs from this TextDescriptor by rotation.
 TextDescriptor withUnderline(boolean state)
          Returns TextDescriptor which differs from this TextDescriptor by underline flag.
 TextDescriptor withUnit(AbstractTextDescriptor.Unit u)
          Returns TextDescriptor which differs from this TextDescriptor by unit.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final TextDescriptor EMPTY
empty text descriptor. Size is relative 1.0. isDisplay is true.

Method Detail

newTextDescriptor

public static TextDescriptor newTextDescriptor(com.sun.electric.database.variable.AbstractTextDescriptor td)

withDisplay

public TextDescriptor withDisplay(boolean state)
Returns TextDescriptor which differs from this TextDescriptor by displayable flag. Displayable Variables are shown with the object.

Parameters:
state - true, if new TextDescriptor is displayable.
Returns:
TextDescriptor which differs from this TextDescriptor by displayable flag.

withDisplay

public TextDescriptor withDisplay(AbstractTextDescriptor.Display display)
Returns TextDescriptor which differs from this TextDescriptor by displayable mode. Displayable Variables are shown with the object.

Parameters:
display - new displayable mode.
Returns:
TextDescriptor which differs from this TextDescriptor by displayable mode.

withPos

public TextDescriptor withPos(AbstractTextDescriptor.Position p)
Returns TextDescriptor which differs from this TextDescriptor by position. The text position describes the "anchor point" of the text, which is the point on the text that is attached to the object and does not move.

Parameters:
p - the text position of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by position.
Throws:
java.lang.NullPointerException - if p is null.

withAbsSize

public TextDescriptor withAbsSize(int s)
Returns TextDescriptor which differs from this TextDescriptor by text size. New size is absolute size (in points). The size must be between 1 and 63 points.

Parameters:
s - the point size of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by text size.

withRelSize

public TextDescriptor withRelSize(double s)
Returns TextDescriptor which differs from this TextDescriptor by text size. New size is a relative size (in units). The size must be between 0.25 and 127.75 grid units (in .25 increments).

Parameters:
s - the unit size of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by text size.

withFace

public TextDescriptor withFace(int f)
Returns TextDescriptor which differs from this TextDescriptor by text font.

Parameters:
f - the text font of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by text font.

withRotation

public TextDescriptor withRotation(AbstractTextDescriptor.Rotation r)
Returns TextDescriptor which differs from this TextDescriptor by rotation. There are only 4 rotations: 0, 90 degrees, 180 degrees, and 270 degrees.

Parameters:
r - the text rotation of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by rotation.

withDispPart

public TextDescriptor withDispPart(AbstractTextDescriptor.DispPos dispPos)
Returns TextDescriptor which differs from this TextDescriptor by dislay part.

Parameters:
dispPos - the text display part of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by dislay part.
Throws:
java.lang.NullPointerException - if dispPos is null

withItalic

public TextDescriptor withItalic(boolean state)
Returns TextDescriptor which differs from this TextDescriptor by italic flag.

Parameters:
state - true if text of new TextDescriptor is italic.
Returns:
TextDescriptor which differs from this TextDescriptor by italic flag.

withBold

public TextDescriptor withBold(boolean state)
Returns TextDescriptor which differs from this TextDescriptor by bold flag.

Parameters:
state - true if text of new TextDescriptor is bold.
Returns:
TextDescriptor which differs from this TextDescriptor by bold flag.

withUnderline

public TextDescriptor withUnderline(boolean state)
Returns TextDescriptor which differs from this TextDescriptor by underline flag.

Parameters:
state - true if text of new TextDescriptor is underlined.
Returns:
TextDescriptor which differs from this TextDescriptor by underline flag.

withInterior

public TextDescriptor withInterior(boolean state)
Returns TextDescriptor which differs from this TextDescriptor by interior flag. Interior text is not seen at higher levels of the hierarchy.

Parameters:
state - true if text with new TextDescriptor is interior.
Returns:
TextDescriptor which differs from this TextDescriptor by interior flag.

withInherit

public TextDescriptor withInherit(boolean state)
Returns TextDescriptor which differs from this TextDescriptor by inheritable flag. Inheritable variables copy their contents from prototype to instance. Only Variables on NodeProto and PortProto objects can be inheritable. When a NodeInst is created, any inheritable Variables on its NodeProto are automatically created on that NodeInst.

Parameters:
state - true if Variable with new TextDescriptor is inheritable.
Returns:
TextDescriptor which differs from this TextDescriptor by inheritable flag.

withParam

public TextDescriptor withParam(boolean state)
Returns TextDescriptor which deffers from this TextDescriptor by parameter flag. Parameters are those Variables that have values on instances which are passed down the hierarchy into the contents. Parameters can only exist on Cell objects.

Parameters:
state - true if Variable with new TextDescriptor is parameter.
Returns:
TextDescriptor which deffers from this TextDescriptor by parameter flag.

withOff

public TextDescriptor withOff(double xd,
                              double yd)
Returns TextDescriptor which differs from this TextDescriptor by X and Y offsets of the text in the Variable's TextDescriptor. The values are scaled by 4, so a value of 3 indicates a shift of 0.75 and a value of 4 shifts by 1.

Parameters:
xd - the X offset of the text in new Variable's TextDescriptor.
yd - the Y offset of the text in new Variable's TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by X and Y offsets of the text in the Variable's TextDescriptor.

withUnit

public TextDescriptor withUnit(AbstractTextDescriptor.Unit u)
Returns TextDescriptor which differs from this TextDescriptor by unit. Unit describe the type of real-world unit to apply to the value. For example, if this value is in volts, the Unit tells whether the value is volts, millivolts, microvolts, etc.

Parameters:
u - the Unit of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by unit.

withColorIndex

public TextDescriptor withColorIndex(int colorIndex)
Returns TextDescriptor which differs from this TextDescriptor by colorIndex. Color indices are more general than colors, because they can handle transparent layers, C-Electric-style opaque layers, and full color values. Methods in "EGraphics" manipulate color indices.

Parameters:
colorIndex - color index of new TextDescriptor.
Returns:
TextDescriptor which differs from this TextDescriptor by colorIndex.

withDisplayWithoutParam

public TextDescriptor withDisplayWithoutParam()

cacheSize

public static int cacheSize()

getDisplay

public AbstractTextDescriptor.Display getDisplay()
Method to return mode how this TextDescriptor is displayable.

Returns:
Display mode how this TextDescriptor is displayable.

lowLevelGet

public long lowLevelGet()
Low-level method to get the bits in the TextDescriptor. These bits are a collection of flags that are more sensibly accessed through special methods. This general access to the bits is required because the ELIB file format stores it as a full integer. This should not normally be called by any other part of the system.

Returns:
the bits in the TextDescriptor.

getColorIndex

public int getColorIndex()
Method to return the color index of the TextDescriptor. Color indices are more general than colors, because they can handle transparent layers, C-Electric-style opaque layers, and full color values. Methods in "EGraphics" manipulate color indices.

Returns:
the color index of the TextDescriptor.

getNodeTextDescriptor

public static TextDescriptor getNodeTextDescriptor()
Method to return a displayable TextDescriptor that is a default for Variables on NodeInsts.

Returns:
a new TextDescriptor that can be stored in a Variable on a NodeInsts.

getArcTextDescriptor

public static TextDescriptor getArcTextDescriptor()
Method to return a displayable TextDescriptor that is a default for Variables on ArcInsts.

Returns:
a new TextDescriptor that can be stored in a Variable on a ArcInsts.

getExportTextDescriptor

public static TextDescriptor getExportTextDescriptor()
Method to return a displayable TextDescriptor that is a default for Variables on Exports.

Returns:
a new TextDescriptor that can be stored in a Variable on a Exports.

getPortInstTextDescriptor

public static TextDescriptor getPortInstTextDescriptor()
Method to return a displayable TextDescriptor that is a default for Variables on PortInsts.

Returns:
a new TextDescriptor that can be stored in a Variable on a PortInsts.

getAnnotationTextDescriptor

public static TextDescriptor getAnnotationTextDescriptor()
Method to return a displayable TextDescriptor that is a default for Variables on Annotations.

Returns:
a new TextDescriptor that can be stored in a Variable on a Annotations.

getInstanceTextDescriptor

public static TextDescriptor getInstanceTextDescriptor()
Method to return a displayable TextDescriptor that is a default for Variables on Cell Instance Names.

Returns:
a new TextDescriptor that can be stored in a Variable on a Cell Instance Names.

getCellTextDescriptor

public static TextDescriptor getCellTextDescriptor()
Method to return a displayable TextDescriptor that is a default for Variables on Cell Variables.

Returns:
a new TextDescriptor that can be stored in a Variable on a Cell Variables.

hashCode

public int hashCode()
Returns a hash code for this TextDescriptor.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this TextDescriptor.

equals

public boolean equals(java.lang.Object anObject)
Compares this text descriptor to the specified object. The result is true if and only if the argument is not null and is a TextDescriptor object with the same fields.

Overrides:
equals in class java.lang.Object
Parameters:
anObject - the object to compare this TextDescriptor against.
Returns:
true if the TextDescriptor are equal; false otherwise.

lowLevelGet0

public int lowLevelGet0()
Low-level method to get the first word of the bits in the TextDescriptor. These bits are a collection of flags that are more sensibly accessed through special methods. This general access to the bits is required because the ELIB file format stores it as a full integer. This should not normally be called by any other part of the system.

Returns:
the first word of the bits in the TextDescriptor.

lowLevelGet1

public int lowLevelGet1()
Low-level method to get the second word of the bits in the TextDescriptor. These bits are a collection of flags that are more sensibly accessed through special methods. This general access to the bits is required because the ELIB file format stores it as a full integer. This should not normally be called by any other part of the system.

Returns:
the second word of the bits in the TextDescriptor.

isDisplay

public boolean isDisplay()
Method to return true if this TextDescriptor is displayable.

Returns:
true if this TextDescriptor is displayable.

getPos

public AbstractTextDescriptor.Position getPos()
Method to return the text position of the TextDescriptor. The text position describes the "anchor point" of the text, which is the point on the text that is attached to the object and does not move.

Returns:
the text position of the TextDescriptor.

isAbsoluteSize

public boolean isAbsoluteSize()
Returns true if this ImmutableTextDescriptor describes absolute text. Text may be either absolute text (in points) or relative text (in quarter units).

Returns:
true if this ImmutableTextDescriptor describes absolute text.

getSize

public AbstractTextDescriptor.Size getSize()
Method to return the text size of the text in this TextDescriptor. This is a Size object that can describe either absolute text (in points) or relative text (in quarter units).

Returns:
the text size of the text in this TextDescriptor.

getDefaultFontSize

public static int getDefaultFontSize()

getTrueSize

public double getTrueSize(EditWindow0 wnd)
Method to find the true size in points for this TextDescriptor in a given EditWindow0. If the TextDescriptor is already Absolute (in points) nothing needs to be done. Otherwise, the scale of the EditWindow0 is used to determine the acutal point size.

Parameters:
wnd - the EditWindow0 in which drawing will occur.
Returns:
the point size of the text described by this TextDescriptor.

getTrueSize

public double getTrueSize(double scale,
                          EditWindow0 wnd)
Method to find the true size in points for this TextDescriptor in a given scale. If the TextDescriptor is already Absolute (in points) nothing needs to be done. Otherwise, the scale is used to determine the acutal point size.

Parameters:
scale - scale to draw.
wnd - the EditWindow0 in which drawing will occur.
Returns:
the point size of the text described by this TextDescriptor.

getFace

public int getFace()
Method to return the text font of the TextDescriptor.

Returns:
the text font of the TextDescriptor.

getFont

public java.awt.Font getFont(EditWindow0 wnd,
                             int minimalTextSize)
Method to get a Font to use for this TextDescriptor in a given EditWindow.

Parameters:
wnd - the EditWindow0 in which drawing will occur.
minimalTextSize - Return null for texts smaller than this
Returns:
the Font to use (returns null if the text is too small to display).

getDefaultFont

public static java.awt.Font getDefaultFont()
Method to get a default Font to use.

Returns:
the Font to use (returns null if the text is too small to display).

getGlyphs

public static java.awt.font.GlyphVector getGlyphs(java.lang.String text,
                                                  java.awt.Font font)
Method to convert a string and descriptor to a GlyphVector.

Parameters:
text - the string to convert.
font - the Font to use.
Returns:
a GlyphVector describing the text.

getRotation

public AbstractTextDescriptor.Rotation getRotation()
Method to return the text rotation of the TextDescriptor. There are only 4 rotations: 0, 90 degrees, 180 degrees, and 270 degrees.

Returns:
the text rotation of the TextDescriptor.

getDispPart

public AbstractTextDescriptor.DispPos getDispPart()
Method to return the text display part of the TextDescriptor.

Returns:
the text display part of the TextDescriptor.

isItalic

public boolean isItalic()
Method to return true if the text in the TextDescriptor is italic.

Returns:
true if the text in the TextDescriptor is italic.

isBold

public boolean isBold()
Method to return true if the text in the TextDescriptor is bold.

Returns:
true if the text in the TextDescriptor is bold.

isUnderline

public boolean isUnderline()
Method to return true if the text in the TextDescriptor is underlined.

Returns:
true if the text in the TextDescriptor is underlined.

isInterior

public boolean isInterior()
Method to return true if the text in the TextDescriptor is interior. Interior text is not seen at higher levels of the hierarchy.

Returns:
true if the text in the TextDescriptor is interior.

isInherit

public boolean isInherit()
Method to return true if the text in the TextDescriptor is inheritable. Inheritable variables copy their contents from prototype to instance. Only Variables on NodeProto and PortProto objects can be inheritable. When a NodeInst is created, any inheritable Variables on its NodeProto are automatically created on that NodeInst.

Returns:
true if the text in the TextDescriptor is inheritable.

isParam

public boolean isParam()
Method to return true if the text in the TextDescriptor is a parameter. Parameters are those Variables that have values on instances which are passed down the hierarchy into the contents. Parameters can only exist on NodeInst objects.

Returns:
true if the text in the TextDescriptor is a parameter.

getXOff

public double getXOff()
Method to return the X offset of the text in the TextDescriptor.

Returns:
the X offset of the text in the TextDescriptor.

getYOff

public double getYOff()
Method to return the Y offset of the text in the TextDescriptor.

Returns:
the Y offset of the text in the TextDescriptor.

getUnit

public AbstractTextDescriptor.Unit getUnit()
Method to return the Unit of the TextDescriptor. Unit describes the type of real-world unit to apply to the value. For example, if this value is in volts, the Unit tells whether the value is volts, millivolts, microvolts, etc.

Returns:
the Unit of the TextDescriptor.