All Packages Class Hierarchy This Package Previous Next Index
Class att.grappa.GraphicContext
java.lang.Object
|
+----att.grappa.GraphicContext
- public class GraphicContext
- extends Object
- implements Cloneable
This class provides a repository for drawing information such as foreground
and background colors, font, font size and so on.
Class methods associating color names with RGB values are also included.
- Version:
- 1.1, 30 Sep 1999; Copyright 1996 - 1999 by AT&T Corp.
- Author:
- John Mocenigo, Research @ AT&T Labs
-
defaultBackground
- The default background color (white).
-
defaultColor
- The default color of last resort in all cases (black).
-
defaultFont
- The default font resulting from Font(defaultFontname,defaultFontstyle,defaultFontsize)
-
defaultFontcolor
- The default font color (black).
-
defaultFontname
- The default font name (serif).
-
defaultFontsize
- The default font size (14).
-
defaultFontstyle
- The default font style (Font.PLAIN).
-
defaultForeground
- The default foreground color (black).
-
defaultXOR
- The default XOR color (light gray).
-
GraphicContext()
- Create a
GraphicContext
instance initialized with the
default values.
-
addColor(String, Color)
- Adds a color to the application color table.
-
clone()
- Creates a new object of the same class as this object.
-
equals(Object)
- Determines whether two contexts are equal.
-
getBackground()
- Get the background color of this graphic context.
-
getClipRect()
- Get the clipping rectangle of this graphic context.
-
getColor(String, Color)
- Return the color in the color table with the given name.
-
getColorName(Color)
- Return the name of the supplied color.
-
getFillMode()
- Get the fill mode of this graphic context.
-
getFont()
- Get the font currently associated with this graphic context.
-
getFontcolor()
- Get the font color of this graphic context.
-
getFontname()
- Get the font name of this graphic context.
-
getFontsize()
- Get the font size of this graphic context.
-
getFontstyle()
- Get the font style of this graphic context.
-
getForeground()
- Get the foreground color of this graphic context.
-
getLineStyle()
- Get the line style of this graphic context (as an int).
-
getLineStyleString()
- Get the line style of this graphic context (as a string).
-
getXORColor()
- Get the XOR color of this graphic context.
-
getXORMode()
- Get the XOR mode of this graphic context.
-
setBackground(Color)
- Set the background color to the supplied color.
-
setBackground(String)
- Set the background color to the named color.
-
setClipRect(int, int, int, int)
- Set the clipping rectangle as specified.
-
setClipRect(Rectangle)
- Set the clipping rectangle to the specified value.
-
setFillMode(boolean)
- Set the fill mode as specified.
-
setFont()
- Set the font as specified.
-
setFont(Font)
- Set the font to the supplied font.
-
setFontcolor(Color)
- Set the font color to the specified color.
-
setFontcolor(String)
- Set the font color to the named color.
-
setFontname(String)
- Set the font name.
-
setFontsize(int)
- Set the font size.
-
setFontsize(String)
- Set the font size.
-
setFontstyle(int)
- Set the font style.
-
setForeground(Color)
- Set the foreground color to the supplied color.
-
setForeground(String)
- Set the foreground color to the named color.
-
setLineStyle(int)
- Set the line style as specified.
-
setLineStyle(String)
- Set the line style as specified.
-
setXORColor(Color)
- Set the x-or color to the specified color.
-
setXORColor(String)
- Set the x-or color to the named color.
-
setXORMode(boolean)
- Set the x-or mode as specified.
-
xlateFontStyle(String)
- Converts a string to an integer font style.
defaultForeground
public static final Color defaultForeground
- The default foreground color (black).
defaultBackground
public static final Color defaultBackground
- The default background color (white).
defaultXOR
public static final Color defaultXOR
- The default XOR color (light gray).
defaultFontcolor
public static final Color defaultFontcolor
- The default font color (black).
defaultColor
public static final Color defaultColor
- The default color of last resort in all cases (black).
defaultFontstyle
public static final int defaultFontstyle
- The default font style (Font.PLAIN).
defaultFontsize
public static final int defaultFontsize
- The default font size (14).
defaultFontname
public static final String defaultFontname
- The default font name (serif).
defaultFont
public static final Font defaultFont
- The default font resulting from Font(defaultFontname,defaultFontstyle,defaultFontsize)
GraphicContext
public GraphicContext()
- Create a
GraphicContext
instance initialized with the
default values.
addColor
public static void addColor(String name,
Color color) throws IllegalArgumentException
- Adds a color to the application color table. For search purposes, names
are canonicalized by converting to lower case and stripping
non-alphanumerics. A name must contains at least one alphabetic.
Once in the table, colors can be set by name, and names can be
retrieved by color (although a single color referred to by multiple names
only causes the retrieval of the last name mapped to that color).
- Parameters:
- name - the name to be used to reference the color.
- color - the Color value.
getColor
public static Color getColor(String name,
Color color)
- Return the color in the color table with the given name.
If the color is not found, the supplied default is returned.
If the supplied default is null, the class default is returned.
If the name consists of three comma or space separated floating
point numbers in the range 0 to 1 inclusive, then it is assumed
to represent an HSB color specification and generated directly.
The name search is case insensitive and looks at alphanumerics only.
- Parameters:
- name - the name of the color to be retrieved.
- color - the color value to return if requested color
is not found.
- Returns:
- the color matching the name or the default.
getColorName
public static String getColorName(Color color)
- Return the name of the supplied color.
- Parameters:
- color - the color whose name is to be retrieved.
- Returns:
- the color's (most recently entered) name, if it is in the
color table, or null.
setForeground
public Color setForeground(String color)
- Set the foreground color to the named color.
- Parameters:
- color - the name of the color to be used as the foreground color.
- Returns:
- the previous value of the foreground color.
setForeground
public Color setForeground(Color color)
- Set the foreground color to the supplied color.
- Parameters:
- color - the value of the color to be used as the foreground color.
- Returns:
- the previous value of the foreground color.
setBackground
public Color setBackground(String color)
- Set the background color to the named color.
- Parameters:
- color - the name of the color to be used as the background color.
- Returns:
- the previous value of the background color.
setBackground
public Color setBackground(Color color)
- Set the background color to the supplied color.
- Parameters:
- color - the value of the color to be used as the background color.
- Returns:
- the previous value of the background color.
setXORColor
public Color setXORColor(String color)
- Set the x-or color to the named color.
- Parameters:
- color - the name of the color to be used as the x-or color.
- Returns:
- the previous value of the x-or color.
setXORColor
public Color setXORColor(Color color)
- Set the x-or color to the specified color.
- Parameters:
- color - the value of the color to be used as the x-or color.
- Returns:
- the previous value of the x-or color.
setFontcolor
public Color setFontcolor(String color)
- Set the font color to the named color.
- Parameters:
- color - the name of the color to be used as the font color.
- Returns:
- the previous value of the font color.
setFontcolor
public Color setFontcolor(Color color)
- Set the font color to the specified color.
- Parameters:
- color - the value of the color to be used as the font color.
- Returns:
- the previous value of the font color.
setFontname
public String setFontname(String name)
- Set the font name. A call to setFont() is needed to actually
change the font setting.
- Parameters:
- name - the new font name.
- Returns:
- the previous font name.
- See Also:
- setFont
setFontsize
public int setFontsize(String size)
- Set the font size. A call to setFont() is needed to actually
change the font setting.
- Parameters:
- size - the new font size.
- Returns:
- the previous font size.
- See Also:
- setFont
setFontsize
public int setFontsize(int size)
- Set the font size. A call to setFont() is needed to actually
change the font setting.
- Parameters:
- size - the new font size.
- Returns:
- the previous font size.
- See Also:
- setFont
setFontstyle
public int setFontstyle(int style)
- Set the font style. A call to setFont() is needed to actually
change the font setting.
- Parameters:
- style - the new font style.
- Returns:
- the previous font style.
- See Also:
- setFont, PLAIN, BOLD, ITALIC
setFont
public Font setFont()
- Set the font as specified. The specification was set by calls to
setFontname, setFontsize and setFontstyle.
- Returns:
- the previous font value.
- See Also:
- setFontname, setFontsize, setFontstyle
setFont
public Font setFont(Font newFont)
- Set the font to the supplied font.
- Parameters:
- font - the new font value to use.
- Returns:
- the previous font value.
setXORMode
public boolean setXORMode(boolean mode)
- Set the x-or mode as specified.
- Parameters:
- mode - the new x-or mode value.
- Returns:
- the previous x-or mode value;
setClipRect
public Rectangle setClipRect(int x,
int y,
int width,
int height)
- Set the clipping rectangle as specified.
- Parameters:
- x - the x coordinate.
- y - the y coordinate.
- width - the width of the rectangle.
- height - the height of the rectangle.
- Returns:
- the previous value of the clipping rectangle.
setClipRect
public Rectangle setClipRect(Rectangle rect)
- Set the clipping rectangle to the specified value.
- Parameters:
- rect - the new clipping rectangle to use.
- Returns:
- the previous value of the clipping rectangle.
setFillMode
public boolean setFillMode(boolean mode)
- Set the fill mode as specified.
- Parameters:
- mode - the new fill mode value.
- Returns:
- the previous fill mode value;
setLineStyle
public int setLineStyle(int style)
- Set the line style as specified.
- Parameters:
- style - the new line style value.
- Returns:
- the previous line style value;
setLineStyle
public String setLineStyle(String style)
- Set the line style as specified.
- Parameters:
- style - the new line style value.
- Returns:
- the previous line style value;
getForeground
public Color getForeground()
- Get the foreground color of this graphic context.
- Returns:
- the foreground color.
getBackground
public Color getBackground()
- Get the background color of this graphic context.
- Returns:
- the background color.
getXORColor
public Color getXORColor()
- Get the XOR color of this graphic context.
- Returns:
- the XOR color.
getFontcolor
public Color getFontcolor()
- Get the font color of this graphic context.
- Returns:
- the fontcolor.
getFontname
public String getFontname()
- Get the font name of this graphic context.
- Returns:
- the font name.
getFontsize
public int getFontsize()
- Get the font size of this graphic context.
- Returns:
- the font size.
getFontstyle
public int getFontstyle()
- Get the font style of this graphic context.
- Returns:
- the font style.
getFont
public Font getFont()
- Get the font currently associated with this graphic context.
Calls setFont() before returning the font, if needed.
- Returns:
- the font.
getXORMode
public boolean getXORMode()
- Get the XOR mode of this graphic context.
- Returns:
- the XOR mode.
getClipRect
public Rectangle getClipRect()
- Get the clipping rectangle of this graphic context.
- Returns:
- the clipping rectangle.
getFillMode
public boolean getFillMode()
- Get the fill mode of this graphic context.
- Returns:
- the fill mode.
getLineStyle
public int getLineStyle()
- Get the line style of this graphic context (as an int).
- Returns:
- the line style as an int.
getLineStyleString
public String getLineStyleString()
- Get the line style of this graphic context (as a string).
- Returns:
- the line style as a String.
equals
public boolean equals(Object obj)
- Determines whether two contexts are equal. Two instances of
GraphicContext
are equal if the values of their
foreground color, background color, XOR color, font color, font,
XOR mode and clipping rectangle are all equal.
- Parameters:
- obj - an object to be compared with this point.
- Returns:
-
true
if the object to be compared is
an instance of Point
and has
the same values; false
otherwise.
- Overrides:
- equals in class Object
xlateFontStyle
public static int xlateFontStyle(String fontstyle)
- Converts a string to an integer font style.
The string is first canonicalized (converted to lower case and
non-alphanumerics are removed) then compared to italic, bold or
bolditalic. A match returns Font.ITALIC, Font.BOLD, or a bitwise
OR-ing of the two, respectively. When there is no match, Font.PLAIN
is returned.
- Parameters:
- fontstyle - a string representing a font style
- Returns:
- an integer representation of the supplied font style string
clone
public Object clone()
- Creates a new object of the same class as this object.
The object is initialized with the current values of this context.
- Returns:
- a new object which is an instance of GraphicContext
- Overrides:
- clone in class Object
All Packages Class Hierarchy This Package Previous Next Index