All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.util.JCString

java.lang.Object
   |
   +----java.util.Vector
           |
           +----jclass.util.JCVector
                   |
                   +----jclass.util.JCString

public class JCString
extends JCVector
JCString is a Vector used to display a combination of text and images in mixed fonts and colors.

HTML examples:

Default[COLOR=red][font=TimesRoman-ITALIC-20] red[DEFAULT_FONT][Color=orange] orange\nAn [UL]orange[/UL] line[RESET]\nWhoops\, a [STRIKETHROUGH][Color=red]mistake<

HELLO[HREF=jclass.util.JCCache.html]see cache\nnline 5[/HREF]GOODBYE\nAnother link: [HREF=file:/8/java-extra/api/javag1.htm TARGET=_top][IMAGE=images/term4.gif] see BorderLayout[/HREF]


Variable Index

 o ALIGN_CENTER
 o ALIGN_LEFT
 o ALIGN_RIGHT
 o BOTTOM
 o CENTER
 o DEFAULT_COLOR
 o DEFAULT_FONT
 o END_HREF
 o END_STRIKETHROUGH
 o END_UNDERLINE
 o HORIZ_SPACE
 o HREF
 o LEFT
 o MIDDLE
 o NEWLINE
 o RESET
 o RIGHT
 o STRIKETHROUGH
 o STRING_BOTTOM
 o STRING_LEFT
 o STRING_RIGHT
 o STRING_TOP
 o TOP
 o UNDERLINE
 o VERT_SPACE

Constructor Index

 o JCString()
Constructs an empty JCString with a 10-element capacity.
 o JCString(int)
Constructs a JCString with an initial capacity.
 o JCString(String)
Constructs a JCString with an initial String.
 o JCString(String, Image, int)
Constructs a JCString from a String and an Image.

Method Index

 o add(int)
Adds an element.
 o add(int, Object)
Adds an attribute and value.
 o add(Object)
Adds an object.
 o addImage(Applet, String)
Creates and adds an image, using a name relative to the applet through Applet.getDocumentBase().
 o addImage(Applet, String, String)
Creates and adds an image, using the URL.
 o draw(Component, Graphics, Rectangle, int)
Draws the JCString.
 o getApplet(Component)
Given an AWT component, follows the component's parents until a parent applet is found.
 o getHeight(Component, Font)
Returns the height.
 o getImage()
Gets the first image.
 o getLineSize(Component, Font, int, Dimension)
Calculates the size of a particular line in a JCString.
 o getSize(Component, Font)
Returns the size of the JCString.
 o getString()
Concatenates all string items.
 o getURL(Applet, Object, int, int)
Checks whether the point is within an URL stored in a JCString within the active cell.
 o getURL(int, int)
Determines whether the point is within the HREF's URL.
 o getWidth(Component, Font)
Returns the width.
 o parse(Component, String)
 o setURLoffset(int, int)
Sets the offset for URL rectangle tracking.
 o showURL(String, AppletContext, Applet)
If a URL is present, displays it at the specified location.

Variables

 o UNDERLINE
 public static final Integer UNDERLINE
 o STRIKETHROUGH
 public static final Integer STRIKETHROUGH
 o END_UNDERLINE
 public static final Integer END_UNDERLINE
 o END_STRIKETHROUGH
 public static final Integer END_STRIKETHROUGH
 o HORIZ_SPACE
 public static final Integer HORIZ_SPACE
 o VERT_SPACE
 public static final Integer VERT_SPACE
 o NEWLINE
 public static final Integer NEWLINE
 o RESET
 public static final Integer RESET
 o DEFAULT_FONT
 public static final Integer DEFAULT_FONT
 o DEFAULT_COLOR
 public static final Integer DEFAULT_COLOR
 o TOP
 public static final Integer TOP
 o MIDDLE
 public static final Integer MIDDLE
 o BOTTOM
 public static final Integer BOTTOM
 o LEFT
 public static final Integer LEFT
 o CENTER
 public static final Integer CENTER
 o RIGHT
 public static final Integer RIGHT
 o HREF
 public static final Integer HREF
 o END_HREF
 public static final Integer END_HREF
 o STRING_LEFT
 public static final int STRING_LEFT
 o STRING_RIGHT
 public static final int STRING_RIGHT
 o STRING_TOP
 public static final int STRING_TOP
 o STRING_BOTTOM
 public static final int STRING_BOTTOM
 o ALIGN_LEFT
 public static final int ALIGN_LEFT
 o ALIGN_CENTER
 public static final int ALIGN_CENTER
 o ALIGN_RIGHT
 public static final int ALIGN_RIGHT

Constructors

 o JCString
 public JCString()
Constructs an empty JCString with a 10-element capacity.

 o JCString
 public JCString(int capacity)
Constructs a JCString with an initial capacity.

 o JCString
 public JCString(String s)
Constructs a JCString with an initial String.

 o JCString
 public JCString(String s,
                 Image image,
                 int layout)
Constructs a JCString from a String and an Image.

Parameters:
layout - the relative position of the string with respect to the image: STRING_LEFT, STRING_RIGHT, STRING_TOP or STRING_BOTTOM

Methods

 o add
 public void add(Object o)
Adds an object. If the object is not one of the following classes, its toString() method is called:
String      Adds text
Color       The text that follows is drawn using this color
Font        The text that follows is drawn using this font
Image       Adds an image

Overrides:
add in class JCVector
 o add
 public void add(int element)
Adds an element. Must be one of the following:
TAB                 Adds a tab
UNDERLINE           Underlines the text that follows
END_UNDERLINE       Ends the underlining of text
END_HREF            Ends the underlining of text
STRIKETHROUGH       The following text is struckthrough
END_STRIKETHROUGH   Ends the strikethrough of text
NEWLINE             Adds a newline
DEFAULT_COLOR       The following text is drawn using the foreground color of the component
DEFAULT_FONT        The following text is drawn using the font of the component
RESET               The following text is drawn using the font and forground color of the component using default values

 o add
 public void add(int attr,
                 Object value)
Adds an attribute and value. Its attributes and accompanying value are provided below:
Attribute			Value
HREF           String              Sets a link anchor. The string may contain a TARGET=
HORIZ_SPACE    Integer             Adds a horizontal space
VERT_SPACE     Integer             Offsets the next line by a vertical space
ALIGN          TOP,MIDDLE, BOTTOM  The vertical alignment within each line

 o parse
 public static JCString parse(Component c,
                              String s)
 o getApplet
 public static Applet getApplet(Component comp)
Given an AWT component, follows the component's parents until a parent applet is found. Returns null if no applet is found.

 o addImage
 public boolean addImage(Applet app,
                         String name)
Creates and adds an image, using a name relative to the applet through Applet.getDocumentBase(). The routine waits until the image has been downloaded.

Returns:
false if an error occurred
See Also:
getDocumentBase
 o addImage
 public boolean addImage(Applet app,
                         String url,
                         String name)
Creates and adds an image, using the URL. The routine waits until the image has been downloaded.

Returns:
false if an error occurred
 o getHeight
 public int getHeight(Component comp,
                      Font default_font)
Returns the height.

Parameters:
comp - this is used to obtain the default font
 o getWidth
 public int getWidth(Component comp,
                     Font default_font)
Returns the width.

Parameters:
comp - this is used to obtain the default font
 o getSize
 public Dimension getSize(Component comp,
                          Font default_font)
Returns the size of the JCString.

Parameters:
comp - this is used to obtain the default font
 o getLineSize
 public int getLineSize(Component comp,
                        Font default_font,
                        int index,
                        Dimension size)
Calculates the size of a particular line in a JCString.

Parameters:
comp - used to obtain and set font information
default_font - default font to use if no font specified
index - index of first item on the current line
size - size information is returned inside this object
Returns:
index in the JCString of the first item on the next line
 o draw
 public void draw(Component comp,
                  Graphics gc,
                  Rectangle rect,
                  int align)
Draws the JCString.

Parameters:
comp - used to obtain the default font
gc - the gc to be used
rect - string drawn within the rectangle, clipped to the gc's clipRect
align - alignment: ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT
 o setURLoffset
 public void setURLoffset(int x,
                          int y)
Sets the offset for URL rectangle tracking.

 o getURL
 public String getURL(int x,
                      int y)
Determines whether the point is within the HREF's URL.

 o getURL
 public static String getURL(Applet applet,
                             Object value,
                             int x,
                             int y)
Checks whether the point is within an URL stored in a JCString within the active cell.

Parameters:
row,col - the cell position
x,y - the unscrolled co-ordinates
Returns:
the URL, or null if none was found
 o showURL
 public static boolean showURL(String url_string,
                               AppletContext context,
                               Applet applet)
If a URL is present, displays it at the specified location.

 o getString
 public String getString()
Concatenates all string items.

 o getImage
 public Image getImage()
Gets the first image.


All Packages  Class Hierarchy  This Package  Previous  Next  Index