Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.image
Class WebImage

java.lang.Object
  extended by org.hyperic.image.WebImage
Direct Known Subclasses:
AvailabilityReport, Chart, ResourceTree

public class WebImage
extends java.lang.Object


Field Summary
protected  boolean antiAliased
          Use an IndexColorModel.
protected static java.lang.String ARG_CANNOT_BE_NULL
           
 java.awt.Color backgroundColor
          Background color for the image.
 int bottomBorder
          Height of the image border on the bottom side of the image
protected static java.awt.Color DEFAULT_BACKGROUND_COLOR
           
protected static java.lang.String DEFAULT_BOLD_TYPEFACE
           
protected static java.awt.Color DEFAULT_BORDER_COLOR
           
protected static int DEFAULT_BORDER_SIZE
           
protected static java.awt.Font DEFAULT_FONT
           
protected static java.awt.FontMetrics DEFAULT_FONT_METRICS
           
protected static int DEFAULT_HEIGHT
           
protected static java.lang.String DEFAULT_PLAIN_TYPEFACE
           
protected static int DEFAULT_SHADOW_WIDTH
           
protected static java.awt.Color DEFAULT_TEXT_COLOR
           
protected static int DEFAULT_WIDTH
           
 java.awt.Font font
          Text font.
 boolean frameImage
          Draws a two pixel light gray frame at the edge of the image
 int height
          Height of the image.
protected  boolean indexColors
          Anti-alias shapes and text.
 int leftBorder
          Width of the image border on the left side of the image
protected  java.awt.Graphics2D m_graphics
           
 int rightBorder
          Width of the image border on the right side of the image
 int shadowWidth
          Width of the shadow around the image.
static java.awt.Font SMALL_FONT
           
 java.awt.Color textColor
          Color for text in the image.
 int topBorder
          Height of the image border on the top side of the image
 int width
          Width of the image.
 
Constructor Summary
protected WebImage(int width, int height)
           
 
Method Summary
protected  void draw(java.awt.Graphics2D g)
           
 java.awt.FontMetrics getFontMetrics()
          Retrieves the font metrics.
 java.awt.Image getImage()
          Retrieves the image as a java.awt.Image object.
protected  java.awt.Point getTextCenter(java.lang.String text)
           
protected  java.awt.Point getTextCenter(java.lang.String text, java.awt.Rectangle rect)
           
protected static java.awt.Point getTextCenter(java.lang.String text, java.awt.Rectangle rect, java.awt.FontMetrics metrics)
           
static boolean isRunnable()
          Determine if a graphics environment is available.
protected  void postInit(java.awt.Graphics2D graphics)
           
protected  void preInit()
           
 void setBorder(int border)
          Sets the size of the top, left, right and bottom borders.
 void writeJpegImage(java.io.OutputStream stream)
          Writes the chart image as a JPEG image.
 void writeJpegImage(java.lang.String filename)
          Writes the chart image as a JPEG image.
 void writePngImage(java.io.OutputStream stream)
          Writes the chart image as a PNG image.
 void writePngImage(java.lang.String filename)
          Writes the chart image as a PNG image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARG_CANNOT_BE_NULL

protected static final java.lang.String ARG_CANNOT_BE_NULL
See Also:
Constant Field Values

DEFAULT_HEIGHT

protected static final int DEFAULT_HEIGHT
See Also:
Constant Field Values

DEFAULT_WIDTH

protected static final int DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_BACKGROUND_COLOR

protected static final java.awt.Color DEFAULT_BACKGROUND_COLOR

DEFAULT_BORDER_SIZE

protected static final int DEFAULT_BORDER_SIZE
See Also:
Constant Field Values

DEFAULT_BORDER_COLOR

protected static final java.awt.Color DEFAULT_BORDER_COLOR

DEFAULT_TEXT_COLOR

protected static final java.awt.Color DEFAULT_TEXT_COLOR

DEFAULT_SHADOW_WIDTH

protected static final int DEFAULT_SHADOW_WIDTH
See Also:
Constant Field Values

DEFAULT_BOLD_TYPEFACE

protected static final java.lang.String DEFAULT_BOLD_TYPEFACE
See Also:
Constant Field Values

DEFAULT_PLAIN_TYPEFACE

protected static final java.lang.String DEFAULT_PLAIN_TYPEFACE
See Also:
Constant Field Values

DEFAULT_FONT

protected static final java.awt.Font DEFAULT_FONT

DEFAULT_FONT_METRICS

protected static final java.awt.FontMetrics DEFAULT_FONT_METRICS

SMALL_FONT

public static final java.awt.Font SMALL_FONT

m_graphics

protected java.awt.Graphics2D m_graphics

font

public java.awt.Font font
Text font.


height

public int height
Height of the image.


width

public int width
Width of the image.


leftBorder

public int leftBorder
Width of the image border on the left side of the image


topBorder

public int topBorder
Height of the image border on the top side of the image


rightBorder

public int rightBorder
Width of the image border on the right side of the image


bottomBorder

public int bottomBorder
Height of the image border on the bottom side of the image


frameImage

public boolean frameImage
Draws a two pixel light gray frame at the edge of the image


backgroundColor

public java.awt.Color backgroundColor
Background color for the image.


textColor

public java.awt.Color textColor
Color for text in the image.


shadowWidth

public int shadowWidth
Width of the shadow around the image.


antiAliased

protected boolean antiAliased
Use an IndexColorModel.


indexColors

protected boolean indexColors
Anti-alias shapes and text.

Constructor Detail

WebImage

protected WebImage(int width,
                   int height)
Method Detail

draw

protected void draw(java.awt.Graphics2D g)

preInit

protected void preInit()

postInit

protected void postInit(java.awt.Graphics2D graphics)

setBorder

public void setBorder(int border)
Sets the size of the top, left, right and bottom borders.

Parameters:
border - The size to set the borders to.
See Also:
#LeftBorder

getFontMetrics

public java.awt.FontMetrics getFontMetrics()
Retrieves the font metrics.

Returns:
A java.awt.Font object that contains the label font.
See Also:
Font

getImage

public java.awt.Image getImage()
Retrieves the image as a java.awt.Image object. The image is redrawn with the latest data and properties each time this method is called.

Returns:
A java.awt.Image that contains the drawn chart image.
See Also:
Image

writeJpegImage

public void writeJpegImage(java.lang.String filename)
                    throws java.io.FileNotFoundException,
                           java.io.IOException
Writes the chart image as a JPEG image. The chart is redrawn with the latest data and properties each time this method is called.

Parameters:
filename - The path and filename that specifies where the PNG image should be written.
Throws:
java.io.FileNotFoundException - If the filename is not a valid name for a file.
java.io.IOException - If there is an IO error while writing to the file.
java.lang.IllegalArgumentException - If the filename parameter is null.

writeJpegImage

public void writeJpegImage(java.io.OutputStream stream)
                    throws java.io.IOException
Writes the chart image as a JPEG image. The chart is redrawn with the latest data and properties each time this method is called.

Parameters:
stream - The java.io.OutputStream to write the PNG image to.
Throws:
java.io.IOException - If there is an IO error while streaming the PNG image.
java.lang.IllegalArgumentException - If the stream parameter is null.
See Also:
OutputStream

writePngImage

public void writePngImage(java.lang.String filename)
                   throws java.io.FileNotFoundException,
                          java.io.IOException
Writes the chart image as a PNG image. The chart is redrawn with the latest data and properties each time this method is called.

Parameters:
filename - The path and filename that specifies where the PNG image should be written.
Throws:
java.io.FileNotFoundException - If the filename is not a valid name for a file.
java.io.IOException - If there is an IO error while writing to the file.
java.lang.IllegalArgumentException - If the filename parameter is null.

writePngImage

public void writePngImage(java.io.OutputStream stream)
                   throws java.io.IOException
Writes the chart image as a PNG image. The chart is redrawn with the latest data and properties each time this method is called.

Parameters:
stream - The java.io.OutputStream to write the PNG image to.
Throws:
java.io.IOException - If there is an IO error while streaming the PNG image.
java.lang.IllegalArgumentException - If the stream parameter is null.
See Also:
OutputStream

getTextCenter

protected java.awt.Point getTextCenter(java.lang.String text)

getTextCenter

protected java.awt.Point getTextCenter(java.lang.String text,
                                       java.awt.Rectangle rect)

getTextCenter

protected static java.awt.Point getTextCenter(java.lang.String text,
                                              java.awt.Rectangle rect,
                                              java.awt.FontMetrics metrics)

isRunnable

public static boolean isRunnable()
Determine if a graphics environment is available. The graphics environment would be X on Unix. GDI on Windows, Mac, etc. This is primarily used as a check for X because it is very difficult to run without a graphics environment on the Windows and Mac operating systems.

Returns:
A boolean that is true if a graphics environment is available, false otherwise.

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.