All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class figPac.fEnv

java.lang.Object
   |
   +----figPac.fEnv

public class fEnv
extends Object
implements fElement, fInteractive, ItemListener
Each figure comes with a hash table, called env, that stores the drawing environment for that figure. A hash table is just a general structure that contains pairs consisting of a name (which Figure assumes is a string) and a value (which is an arbitrary object). The figure element fEnv is used to modify values in env and to introduce new entries in the table. At the present time the following entries have been used
Name:		bgColor        
Type of value:	Color       
Default value:	Color.white         
Significance:	Screen background color

Name: fgColor Type of value: Color Default value: Color.black Significance: Screen foreground color

Name: fillColor Type of value: Color Default value: Color.black Significance: Color used to fill polygons etc on screen

Name: arrowHeadColor Type of value: Color Default value: Color.black Significance: Color used to fill arrowheads on screen

Name: psFillGray Type of value: Double Default value: 0 Significance: Controls density of fill for polygons etc. in postscript (0=black, 1=white)

Name: useColorPs Type of value: String Default value: false Significance: Determines whether colour or grayscale fill is used in PostScript

Name: arrowHeadGray Type of value: Double Default value: 0 Significance: Controls density of fill for arrowheads in postscript

Name: headHalfWidth Type of value: Double Default value: 2 Significance: Half the width of arrowheads in points

Name: headLength Type of value: Double Default value: 6 Significance: Length of arrowheads in points

Name: lineWidth Type of value: Double Default value: 0 Significance: Width of lines drawn in points

Name: font Type of value: Font Default value: Font("Lucidasanstypewriter",Font.PLAIN, 14) Significance: The font used by labels on the screen

Name: psFont Type of value: String Default value: "Helvetica 10" Significance: The font and font size (in points) used in postscript labels.

It is up to the drawgfx and drawps methods of each figure element to extract and use the entries in the table that are appropriate for it.


Variable Index

 o key
 o keys
A list of standard keys.
 o value

Constructor Index

 o fEnv()
 o fEnv(Object, double)
Puts an Double wrapper on the value and then creates the pair (key, Double(value) ).
 o fEnv(Object, int)
Puts an Integer wrapper on the value and then creates the pair (key, Integer(value) ) or, if key is known to be of type double, (key, Double(value) ).
 o fEnv(Object, Object)
Creates the pair (key,value).

Method Index

 o configure(String, double)
 o configure(String, double[])
 o configure(String, String)
 o drawgfx(Figure, Hashtable, V2V)
Inserts the pair (key,value) into the hash table env.
 o drawps(Figure, Hashtable, V2V)
Inserts the pair (key,value) into the hash table env.
 o endEdit()
 o endEditAndDelete()
 o itemStateChanged(ItemEvent)
 o startEdit(figEdit)
 o toColor(String)
Converts a String to a Color.
 o toDouble(String)
 o toFont(String)
 o toString()

Variables

 o key
 public Object key
 o value
 public Object value
 o keys
 public String keys[]
A list of standard keys.

Constructors

 o fEnv
 public fEnv()
 o fEnv
 public fEnv(Object key,
             Object value)
Creates the pair (key,value).

 o fEnv
 public fEnv(Object key,
             int value)
Puts an Integer wrapper on the value and then creates the pair (key, Integer(value) ) or, if key is known to be of type double, (key, Double(value) ). Entries in hash tables must be objects (i.e. classes) not primitive data types. Java has built in a class, called Integer, to mirror the primitive data type int.

 o fEnv
 public fEnv(Object key,
             double value)
Puts an Double wrapper on the value and then creates the pair (key, Double(value) ). Entries in hash tables must be objects (i.e. classes) not primitive data types. Java has built in a class, called Double, to mirror the primitive data type double.

Methods

 o drawgfx
 public void drawgfx(Figure fig,
                     Hashtable env,
                     V2V usr2pxl)
Inserts the pair (key,value) into the hash table env. Where appropriate, it also tells the Graphics controller gfx of the Figure fig to change its drawing environment. Here is are three typical statements that are extracting values from the table env
Color fillColor = (Color)( env.get("fillColor") );
double lineWidth = ((Double)( env.get("lineWidth") )).doubleValue();
int arrowMode = ((Integer)( env.get("arrowMode") )).intValue();
The output of env.get() is always of class Object (the superclass of all classes in Java). It has to be cast to whatever class the value is really supposed to represent. That is the role of (Color) in the first example and (Double) in the second. The method doubleValue() in the second example converts the object of class Double to the primitive data type double, that you actually want to compute with. Similarly, The method intValue() in the third example converts the object of class Integer to the primitive data type int.

 o drawps
 public String drawps(Figure fig,
                      Hashtable env,
                      V2V usr2ps)
Inserts the pair (key,value) into the hash table env. Where appropriate, it also returns the string of postscript that makes the corresponding change in the postscript drawing environment.

 o startEdit
 public void startEdit(figEdit applet)
 o endEdit
 public void endEdit()
 o endEditAndDelete
 public void endEditAndDelete()
 o configure
 public void configure(String name,
                       String Value)
 o configure
 public void configure(String name,
                       double Value)
 o configure
 public void configure(String name,
                       double Value[])
 o toColor
 public Color toColor(String color)
Converts a String to a Color. If the string is not a standard color (e.g. black) and is not a sequence of three integers in the range 0-255 (e.g. 20 0 255) and is not of the standard java form (e.g. java.awt.Color[r=30,g=40,b=50]) Color.white is returned.

 o toFont
 public Font toFont(String font)
 o toDouble
 public Double toDouble(String number)
 o itemStateChanged
 public void itemStateChanged(ItemEvent e)
 o toString
 public String toString()
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index