com.jrefinery.chart
Class DateTitle

java.lang.Object
  extended by com.jrefinery.chart.AbstractTitle
      extended by com.jrefinery.chart.TextTitle
          extended by com.jrefinery.chart.DateTitle
All Implemented Interfaces:
java.lang.Cloneable

public class DateTitle
extends TextTitle

DateTitle (an extension of TextTitle) is a simple convenience class to easily add the text of the date to a chart. Keep in mind that a chart can have several titles, and that they can appear at the top, left, right or bottom of the chart - a DateTitle will commonly appear at the bottom of a chart (although you can place it anywhere).

By specifying the locale, dates are formatted to the correct standard for the given Locale. For example, a date would appear as "January 17, 2000" in the US, but "17 January 2000" in most European locales.


Field Summary
 
Fields inherited from class com.jrefinery.chart.TextTitle
DEFAULT_FONT, DEFAULT_TEXT_PAINT, font, paint, text
 
Fields inherited from class com.jrefinery.chart.AbstractTitle
BOTTOM, CENTER, DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_POSITION, DEFAULT_SPACER, DEFAULT_VERTICAL_ALIGNMENT, EAST, horizontalAlignment, LEFT, listeners, MIDDLE, NORTH, notify, position, RIGHT, SOUTH, spacer, TOP, verticalAlignment, WEST
 
Constructor Summary
DateTitle()
          Constructs a new DateTitle that displays the current date in the default (LONG) format for the locale, positioned to the bottom right of the chart.
DateTitle(int dateStyle)
          Constructs a new DateTitle with the specified style.
DateTitle(int dateStyle, java.util.Locale locale, java.awt.Font font, java.awt.Paint paint)
          Constructs a new DateTitle object with the specified attributes and the following defaults: location = BOTTOM, alignment = RIGHT, insets = new Insets(2, 2, 2, 2).
DateTitle(int dateStyle, java.util.Locale locale, java.awt.Font font, java.awt.Paint paint, int position, int horizontalAlignment, int verticalAlignment, Spacer spacer)
          Constructs a new DateTitle with the specified attributes.
 
Method Summary
 void setDateFormat(int dateStyle, java.util.Locale locale)
          Set the format of the date.
 
Methods inherited from class com.jrefinery.chart.TextTitle
draw, drawHorizontal, getFont, getPaint, getPreferredHeight, getPreferredWidth, getText, isValidPosition, setFont, setPaint, setText
 
Methods inherited from class com.jrefinery.chart.AbstractTitle
addChangeListener, clone, getHorizontalAlignment, getNotify, getPosition, getSpacer, getVerticalAlignment, isValidHorizontalAlignment, isValidVerticalAlignment, notifyListeners, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setSpacer, setVerticalAlignment
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTitle

public DateTitle()
Constructs a new DateTitle that displays the current date in the default (LONG) format for the locale, positioned to the bottom right of the chart.

The color will be black in 12 point, plain Helvetica font (maps to Arial on Win32 systems without Helvetica).


DateTitle

public DateTitle(int dateStyle)
Constructs a new DateTitle with the specified style.


DateTitle

public DateTitle(int dateStyle,
                 java.util.Locale locale,
                 java.awt.Font font,
                 java.awt.Paint paint,
                 int position,
                 int horizontalAlignment,
                 int verticalAlignment,
                 Spacer spacer)
Constructs a new DateTitle with the specified attributes.

Parameters:
location - the relative location of this title (use constants in AbstractTitle).
alignment - the text alignment of this title (use constants in AbstractTitle).
dateStyle - the Date style to use (SHORT, MEDIUM, LONG, or FULL constants from java.text.DateFormat).
locale - the locale to use to format this date (if you are unsure what to use here, use Locale.getDefault() for your default locale).
font - the font used to display the date.
paint - the paint used to display the date.
spacer - Determines the blank space around the outside of the title.

DateTitle

public DateTitle(int dateStyle,
                 java.util.Locale locale,
                 java.awt.Font font,
                 java.awt.Paint paint)
Constructs a new DateTitle object with the specified attributes and the following defaults: location = BOTTOM, alignment = RIGHT, insets = new Insets(2, 2, 2, 2).

Parameters:
dateStyle - the Date style to use (SHORT, MEDIUM, LONG, or FULL constants from java.util.DateFormat);
locale - the locale to use to format this date (if you are unsure what to use here, use Locale.getDefault() for your default locale);
font - the font used to display the date;
paint - the paint used to display the date;
Method Detail

setDateFormat

public void setDateFormat(int dateStyle,
                          java.util.Locale locale)
Set the format of the date.

Parameters:
dateStyle - the Date style to use (SHORT, MEDIUM, LONG, or FULL constants from java.util.DateFormat);
locale - the locale to use to format this date (if you are unsure what to use here, use Locale.getDefault() for your default locale);


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.