com.ijchart.xychart.title
Class ImageTitle

java.lang.Object
  extended by com.ijchart.xychart.title.AbstractTitle
      extended by com.ijchart.xychart.title.ImageTitle
All Implemented Interfaces:
ITitle, java.io.Serializable, java.lang.Cloneable

public class ImageTitle
extends AbstractTitle
implements java.lang.Cloneable, java.io.Serializable

Title: IJChart

Description: a chart library for the Java(tm) platform.

A chart title that displays an image. This is useful, for example, if you have an image of your corporate logo and want to use as a footnote or part of a title in a chart you create.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Field Summary
static boolean DEFAULT_IMAGE_FILL_TITLE_AREA
           A default flag controls whether or not to fill the title area by image.
 
Fields inherited from class com.ijchart.xychart.title.AbstractTitle
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_BORDER_VISIBLE, DEFAULT_FILL_BACKGROUND, DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_NOTIFY, DEFAULT_PADDING, DEFAULT_TITLE_POSITION, DEFAULT_VERTICAL_ALIGNMENT
 
Constructor Summary
ImageTitle(java.awt.Image image)
           Creates a new image title.
ImageTitle(java.awt.Image image, int imageDrawWidth, int imageDrawHeight)
           Creates a new image title with the given image scaled to the given width and height in the given location.
 
Method Summary
 java.lang.Object clone()
           Returns a clone of this object.
 Rectangle draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D chartArea, ChartShapeCollection shapeCollection)
           Draw the title on chart area(chartArea).All title shape is stored in shapeCollection.
 boolean equals(java.lang.Object obj)
           Tests this title for equality with another object.
 java.awt.Image getImage()
           Returns the image for the title.
 int getImageDrawHeight()
           Returns the height used to draw the image.
 int getImageDrawWidth()
           Returns the width used to draw the image.
 int hashCode()
           Returns a hash code.
 boolean isImageFill()
           Returns whether or not fill title area by image.
protected  java.awt.Image scaleImage()
           Creates a scaled version of this image.
 void setImage(java.awt.Image image)
           Sets the image for the title and notifies registered listeners that the title has been modified.
 void setImageDrawHeight(int imageDrawHeight)
           Sets the height used to draw the image,and sends a TitleChangeEvent to all registered listeners.
 void setImageDrawWidth(int imageDrawWidth)
           Sets the width used to draw the image,and sends a TitleChangeEvent to all registered listeners.
 void setImageFill(boolean fill)
           Sets whether or not fill title area by image,and sends a TitleChangeEvent to all registered listeners.
 
Methods inherited from class com.ijchart.xychart.title.AbstractTitle
addChangeListener, fireTitleChanged, getBackgroundAlpha, getBackgroundPaint, getBorderPaint, getBorderStroke, getHorizontalAlignment, getNotify, getPadding, getPosition, getToolTipText, getURLText, getVerticalAlignment, hasListener, isBorderVisible, isFillBackground, notifyListeners, removeAllChangeListener, removeChangeListener, setBackgroundAlpha, setBackgroundPaint, setBorderPaint, setBorderStroke, setBorderVisible, setFillBackground, setHorizontalAlignment, setNotify, setPadding, setPosition, setToolTipText, setURLText, setVerticalAlignment
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_IMAGE_FILL_TITLE_AREA

public static final boolean DEFAULT_IMAGE_FILL_TITLE_AREA
A default flag controls whether or not to fill the title area by image.

See Also:
Constant Field Values
Constructor Detail

ImageTitle

public ImageTitle(java.awt.Image image)
Creates a new image title.

Parameters:
image - Image The image,you must have already loaded this image from its source.

ImageTitle

public ImageTitle(java.awt.Image image,
                  int imageDrawWidth,
                  int imageDrawHeight)
Creates a new image title with the given image scaled to the given width and height in the given location.

Parameters:
image - Image The image,you must have already loaded this image from its source.
imageDrawWidth - int The width used to draw the image.
imageDrawHeight - int The height used to draw the image.
Method Detail

getImage

public java.awt.Image getImage()
Returns the image for the title.

Returns:
Image The image for the title (maybe null).

setImage

public void setImage(java.awt.Image image)
Sets the image for the title and notifies registered listeners that the title has been modified.

Parameters:
image - Image The new image (null permitted).

getImageDrawWidth

public int getImageDrawWidth()
Returns the width used to draw the image.

Returns:
int The width used to draw the image.

setImageDrawWidth

public void setImageDrawWidth(int imageDrawWidth)
Sets the width used to draw the image,and sends a TitleChangeEvent to all registered listeners.

Parameters:
imageDrawWidth - int The width used to draw the image.

getImageDrawHeight

public int getImageDrawHeight()
Returns the height used to draw the image.

Returns:
int The height used to draw the image.

setImageDrawHeight

public void setImageDrawHeight(int imageDrawHeight)
Sets the height used to draw the image,and sends a TitleChangeEvent to all registered listeners.

Parameters:
imageDrawHeight - int The height used to draw the image.

isImageFill

public boolean isImageFill()
Returns whether or not fill title area by image.

Returns:
boolean A boolean.

setImageFill

public void setImageFill(boolean fill)
Sets whether or not fill title area by image,and sends a TitleChangeEvent to all registered listeners.

Parameters:
fill - boolean A boolean.

draw

public Rectangle draw(java.awt.Graphics2D g2,
                      java.awt.geom.Rectangle2D chartArea,
                      ChartShapeCollection shapeCollection)
Draw the title on chart area(chartArea).All title shape is stored in shapeCollection.

Specified by:
draw in interface ITitle
Parameters:
g2 - Graphics2D The graphics device (null not permitted).
chartArea - Rectangle2D The area within which the chart should be drawn.
shapeCollection - ChartShapeCollection Collects information about the plot (null permitted).
Returns:
Rectangle The area within which the title should be drawn.

scaleImage

protected java.awt.Image scaleImage()
Creates a scaled version of this image.

Returns:
Image

equals

public boolean equals(java.lang.Object obj)
Tests this title for equality with another object.

Overrides:
equals in class AbstractTitle
Parameters:
obj - the object (null permitted).
Returns:
true or false.

hashCode

public int hashCode()
Returns a hash code.

Overrides:
hashCode in class AbstractTitle
Returns:
A hash code.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of this object.

Overrides:
clone in class AbstractTitle
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - never.