All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sgi.sysadm.ui.FtrIcon

java.lang.Object
   |
   +----com.sgi.sysadm.ui.FtrIcon

public abstract class FtrIcon
extends Object
implements Icon
FtrIcon is the base class for Icons generated by the $TOOLROOT/usr/sbin/ftrjava program. ftrjava parses .ftr files and generates java source code for rendering File Typing Rule (FTR) icons.

An .ftr file defines a file type. The Indigo Magic desktop uses FTRs to determine the types of files and to display appropriate icons for files. ftrjava ignores the file typing part of an FTR and turns the icon part of the FTR into a .java file implementing a subclass of FtrIcon.

Here is an example of a filetyping rule (Clock.ftr):

TYPE Clock
    ICON {
        include("iconlib/Clock.fti");
    }
The ftrjava program will translate Clock.ftr into Clock.java, which will define a class named Clock as a subclass of FtrIcon. The Clock class will render the icon defined in Clock.fti. Clock.fti is an icon created using the iconsmith(1) Irix program.

FtrIcon's set and get methods can be used to provide conditional rendering:

TYPE Cluster
    ICON {
        if (get("CAM_STATUS").equals("ACTIVE")) {
            include("iconlib/clusterok.fti");
        } else if (get("CAM_STATUS").equals("INACTIVE")) {
            include("iconlib/clusternotok.fti");
        } else {
            include("iconlib/cluster.fti");
        }
    }
The conditional rendering is controlled by calling set on an instance of FtrIcon. Since ftrjava translates .ftr files to java, any legal java code may be put into the ICON rule of a .ftr file. Additionally, the -i and -b options to ftrjava may be used to import a package and implement interfaces so that static final variables from other classes can be used in .ftr files. This may be used to avoid hard-coding strings such as in the Cluster example above.

Only the public methods of FtrIcon are of interest to a developer writing java code. The protected methods and variables exist to facilitate the translation of .fti files into java code. FtrIcons are typically rendered by JLabels.

See Also:
JLabel

Variable Index

 o iconcolor
iconcolor is a special color which is drawn differently depending on whether an icon is open or located.
 o opened
true if the icon should be rendered in an opened state.
 o outlinecolor
color for rendering outlines.
 o shadowcolor
color for rendering shadows.

Constructor Index

 o FtrIcon()

Method Index

 o bgnclosedline()
Start drawing a series of closed lines.
 o bgnline()
Start drawing a series of connected lines.
 o bgnoutlinepolygon()
Start drawing an outlined polygon.
 o bgnpoint()
Start drawing a series of points.
 o bgnpolygon()
Start drawing a polygon.
 o color(int)
Set the current color.
 o color(Object)
Set the current color.
 o createIcon(String)
Dynamically load a subclass of FtrIcon.
 o draw()
Called to draw the icon.
 o endclosedline()
Finish drawing a series of closed lines.
 o endline()
Finish drawing a series of connected lines.
 o endoutlinepolygon(int)
Finish drawing an outlined polygon.
 o endoutlinepolygon(Object)
Finish drawing an outlined polygon.
 o endpoint()
Finish drawing a series of points.
 o endpolygon()
Finish drawing a polygon.
 o get(String)
Get attribute to affect rendering.
 o getIconColor()
Get the current icon color.
 o getIconHeight()
Icon method that gets called to query the height of the icon.
 o getIconWidth()
Icon method that gets called to query the width of the icon.
 o paintIcon(Component, Graphics, int, int)
Icon method that gets called at render time.
 o set(AttrBundle)
Interface for setting a bundle of attributes that affect rendering.
 o set(Attribute)
Interface for setting attributes to affect rendering.
 o set(String, String)
Interface for setting attributes to affect rendering.
 o setDefaultIconColor()
Set the icon color back to its default value.
 o setIconColor(Color)
Set the icon color to iconColor.
 o setLocated(boolean)
Set the located flag.
 o setSelected(boolean)
Set the selected flag.
 o setSize(int, int)
Set the size which should be used for rendering.
 o vertex(double, double)
Add a vertex to the list of vertices for the current shape.

Variables

 o opened
 protected boolean opened
true if the icon should be rendered in an opened state. This variable is only of interest to subclasses generated by the ftrjava program.

 o iconcolor
 protected final Object iconcolor
iconcolor is a special color which is drawn differently depending on whether an icon is open or located. This variable is only of interest to subclasses generated by the ftrjava program.

 o shadowcolor
 protected final int shadowcolor
color for rendering shadows. This variable is only of interest to subclasses generated by the ftrjava program.

 o outlinecolor
 protected final int outlinecolor
color for rendering outlines. This variable is only of interest to subclasses generated by the ftrjava program.

Constructors

 o FtrIcon
 public FtrIcon()

Methods

 o createIcon
 public static FtrIcon createIcon(String className)
Dynamically load a subclass of FtrIcon.

Parameters:
className - Name of the class to load.
Returns:
FtrIcon instance corresponding to className.
Throws: IllegalArgumentException
Thrown if className is not the name of a subclass of FtrIcon.
 o setSelected
 public void setSelected(boolean selected)
Set the selected flag. The selected and located flags determine the color of the icon.

Parameters:
selected - true if this icon should be draw selected.
 o setLocated
 public void setLocated(boolean located)
Set the located flag. The selected and located flags determine the color of the icon.

Parameters:
located - true if this icon should be draw located.
 o setSize
 public void setSize(int width,
                     int height)
Set the size which should be used for rendering.

Parameters:
width - horizontal size.
height - vertical size.
 o paintIcon
 public void paintIcon(Component component,
                       Graphics graphics,
                       int x,
                       int y)
Icon method that gets called at render time.

Parameters:
component - component in which we are drawing.
graphics - for drawing.
x - horizontal location.
y - vertical location.
See Also:
paintIcon
 o setIconColor
 public void setIconColor(Color iconColor)
Set the icon color to iconColor.

Parameters:
iconColor - New icon color.
 o getIconColor
 public Color getIconColor()
Get the current icon color.

Returns:
current icon color.
 o setDefaultIconColor
 public void setDefaultIconColor()
Set the icon color back to its default value.

 o getIconHeight
 public int getIconHeight()
Icon method that gets called to query the height of the icon.

Returns:
vertical size.
See Also:
getIconHeight
 o getIconWidth
 public int getIconWidth()
Icon method that gets called to query the width of the icon.

Returns:
horizontal size.
See Also:
getIconWidth
 o set
 public void set(String key,
                 String value)
Interface for setting attributes to affect rendering.

Parameters:
key - key of attr to set.
value - value of attr to set.
 o set
 public void set(Attribute attr)
Interface for setting attributes to affect rendering.

Parameters:
attr - The attribute to set
 o set
 public void set(AttrBundle bundle)
Interface for setting a bundle of attributes that affect rendering. Each attribute must be of type string.

Parameters:
bundle - An AttrBundle
 o get
 public String get(String key)
Get attribute to affect rendering.

Parameters:
key - key of attr to get.
Returns:
value for attr.
 o color
 protected void color(Object color)
Set the current color. This method is only of interest to subclasses generated by the ftrjava program.

Parameters:
color - The current color. Should be set to iconcolor.
 o color
 protected void color(int color)
Set the current color. This method is only of interest to subclasses generated by the ftrjava program.

Parameters:
color - The current color. Indexes into our colormap.
 o bgnpolygon
 protected void bgnpolygon()
Start drawing a polygon. This method is only of interest to subclasses generated by the ftrjava program.

 o endpolygon
 protected void endpolygon()
Finish drawing a polygon. This method is only of interest to subclasses generated by the ftrjava program.

 o bgnpoint
 protected void bgnpoint()
Start drawing a series of points. This method is only of interest to subclasses generated by the ftrjava program.

 o endpoint
 protected void endpoint()
Finish drawing a series of points. This method is only of interest to subclasses generated by the ftrjava program.

 o bgnline
 protected void bgnline()
Start drawing a series of connected lines. This method is only of interest to subclasses generated by the ftrjava program.

 o endline
 protected void endline()
Finish drawing a series of connected lines. This method is only of interest to subclasses generated by the ftrjava program.

 o bgnclosedline
 protected void bgnclosedline()
Start drawing a series of closed lines. This method is only of interest to subclasses generated by the ftrjava program.

 o endclosedline
 protected void endclosedline()
Finish drawing a series of closed lines. This method is only of interest to subclasses generated by the ftrjava program.

 o bgnoutlinepolygon
 protected void bgnoutlinepolygon()
Start drawing an outlined polygon. This method is only of interest to subclasses generated by the ftrjava program.

 o endoutlinepolygon
 protected void endoutlinepolygon(int color)
Finish drawing an outlined polygon. This method is only of interest to subclasses generated by the ftrjava program.

Parameters:
color - Color for the outline.
 o endoutlinepolygon
 protected void endoutlinepolygon(Object color)
Finish drawing an outlined polygon. This method is only of interest to subclasses generated by the ftrjava program.

Parameters:
color - Color for the polygon.
 o vertex
 protected void vertex(double x,
                       double y)
Add a vertex to the list of vertices for the current shape. This method is only of interest to subclasses generated by the ftrjava program.

Parameters:
x - horizontal coordinate.
y - vertical coordinate.
 o draw
 protected abstract void draw()
Called to draw the icon. Subclass calls the bgn* end*, and vertex methods. This method is only of interest to subclasses generated by the ftrjava program.


All Packages  Class Hierarchy  This Package  Previous  Next  Index