public abstract class IlvBasicTimeScaleRow extends IlvTimeScaleRow implements SwingConstants
IlvTimeScaleRow
and provides
additional utilities. All painting operations are defined at this level. You should
extend this class to determine the time unit management by overriding the
createTimeIncrementPolicy()
method. The drawing operations are done in the
paint(Graphics, Rectangle, IlvTimeScale.PaintContext)
method, which
displays ticks to separate each unit interval. These ticks are drawn using the
paintTick(java.awt.Graphics, java.awt.Point, int, java.awt.FontMetrics, int)
method. In the intervals, text representing the time is drawn by
the paintText(java.awt.Graphics, java.lang.String, java.awt.Point, java.awt.Point, java.awt.Rectangle, java.awt.FontMetrics, int)
method. By default, the text is displayed to the left of the
interval.Modifier and Type | Field and Description |
---|---|
static int |
LEADING_TICK
The text is centered on the leading tick of the interval.
|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Constructor and Description |
---|
IlvBasicTimeScaleRow()
Creates an instance of
IlvBasicTimeScale . |
Modifier and Type | Method and Description |
---|---|
protected String |
computeDateText(Date time)
Computes and returns the text that should be drawn for the interval
beginning at the specified
time . |
protected abstract IlvTimeIncrementPolicy |
createTimeIncrementPolicy()
Creates the time increment policy for the row.
|
String |
getAdditionalString()
This method returns the additional string displayed in the first interval.
|
Format |
getDateFormat()
This method returns the appropriate format to display text.
|
String |
getFormatString()
This method returns the default string for creating the
SimpleDateFormat object. |
int |
getHeight()
Returns the height that was explicitly set for this row.
|
int |
getIntervalMinWidth()
This method returns the minimum interval required to draw a text between two ticks.
|
int |
getPreferredHeight()
Returns the preferred height of the row.
|
Color |
getTextColor()
This method returns the color of the text labels.
|
Font |
getTextFont()
This method returns the font of the text labels.
|
int |
getTextPosition()
This method returns the position of the text in its interval.
|
Color |
getTickColor()
This method returns the color of the ticks.
|
IlvTimeIncrementPolicy |
getTimeIncrementPolicy()
Returns the time increment policy for the row.
|
protected Date |
incrementTime(Date time)
Returns an incremented value of the scale time unit.
|
protected void |
invalidateDateTextCache()
Invalidates the date text cache by clearing it of all entries.
|
boolean |
isOverlappingLabelAllowed()
Indicates whether overlapping labels are allowed.
|
Date |
nextUnitTime(Date time)
Returns the next unit value after the specified time.
|
protected void |
paint(Graphics dst,
Rectangle rect,
IlvTimeScale.PaintContext context)
This method is overridden to draw the scale row to the specified
Graphics and in the specified PaintContext . |
protected void |
paintRow(Graphics dst,
Rectangle rect)
Deprecated.
Beginning with Perforce JViews 8.5 use
paint(Graphics, Rectangle,
IlvTimeScale.PaintContext) instead. |
protected void |
paintText(Graphics dst,
Point topLeft,
Point bottomRight,
String text)
Deprecated.
Beginning with Perforce JViews 8.5 use and override the
paintText(Graphics, String, Point, Point, Rectangle, FontMetrics, int)
method instead. |
protected void |
paintText(Graphics dst,
String text,
Point topLeft,
Point bottomRight,
Rectangle rowRect,
FontMetrics fm,
int textBaseline)
This method is called to draw text corresponding to a scale time interval.
|
protected void |
paintTick(Graphics dst,
Point pos,
int height)
Deprecated.
Beginning with Perforce JViews 8.5 use and override the
paintTick(Graphics, Point, int, FontMetrics, int)
method instead. |
protected void |
paintTick(Graphics dst,
Point pos,
int height,
FontMetrics fm,
int textBaseline)
This method is called to draw a tick in the scale.
|
Date |
previousUnitTime(Date time)
Returns the previous unit value before the specified time.
|
void |
setAdditionalString(String text)
This method lets you change the additional string displayed in the first interval.
|
void |
setFormatString(String format)
This method allows you to change the default date format string.
|
void |
setHeight(int height)
Sets the height of the row.
|
void |
setIntervalMinWidth(int value)
This method lets you change the minimum interval required to draw a text between two
ticks.
|
void |
setOverlappingLabelAllowed(boolean overlap)
Specifies whether overlapping labels are allowed.
|
void |
setTextColor(Color color)
This method changes the color of all text labels.
|
void |
setTextFont(Font font)
This method changes the font of the current row.
|
void |
setTextPosition(int position)
This method changes the position of the text in its interval.
|
void |
setTickColor(Color color)
This method changes the color of all ticks.
|
getComponentOrientation, getLocale, getTimeScale, getULocale, isVisible, setVisible
public static final int LEADING_TICK
setTextPosition(int)
,
Constant Field Valuespublic IlvBasicTimeScaleRow()
IlvBasicTimeScale
.public void setTickColor(Color color)
IlvTimeScale
object is used.color
- The new color.public Color getTickColor()
IlvTimeScale
object.public void setTextColor(Color color)
IlvTimeScale
object is used.color
- The new color.public Color getTextColor()
IlvTimeScale
object.public void setTextFont(Font font)
IlvTimeScale
object is used. Started with the JViews 6.0 release,
this method can change the height of the IlvTimeScale
object.font
- The new font.public Font getTextFont()
IlvTimeScale
object.public void setTextPosition(int position)
position
- Can take the value SwingConstants.LEFT
, SwingConstants.RIGHT
, SwingConstants.LEADING
,
SwingConstants.TRAILING
, SwingConstants.CENTER
, or LEADING_TICK
.getTextPosition()
public int getTextPosition()
LEADING
.SwingConstants.LEFT
, SwingConstants.RIGHT
, SwingConstants.LEADING
,
SwingConstants.TRAILING
, SwingConstants.CENTER
, or LEADING_TICK
.setTextPosition(int)
public String getAdditionalString()
public void setAdditionalString(String text)
text
- The additional text.public void setIntervalMinWidth(int value)
value
- The interval to be set, in pixels.public int getIntervalMinWidth()
-1
and the width of the first
text displayed is used as the minimum width.public int getHeight()
-1
indicates that the row's height will depend upon the text font
size. The default value is -1
.setHeight(int)
,
setTextFont(java.awt.Font)
,
getPreferredHeight()
public void setHeight(int height)
-1
indicates that the row's
height will depend upon the text font size.height
- The height of the row.setTextFont(java.awt.Font)
,
getHeight()
,
getPreferredHeight()
public int getPreferredHeight()
getPreferredHeight
in class IlvTimeScaleRow
setHeight(int)
,
setTextFont(java.awt.Font)
public boolean isOverlappingLabelAllowed()
public void setOverlappingLabelAllowed(boolean overlap)
overlap
- true
if overlapping labels are allowed.protected void paint(Graphics dst, Rectangle rect, IlvTimeScale.PaintContext context)
Graphics
and in the specified PaintContext
.
It calls paintTick(java.awt.Graphics, java.awt.Point, int, java.awt.FontMetrics, int)
to perform tick drawings
and paintText(java.awt.Graphics, java.lang.String, java.awt.Point, java.awt.Point, java.awt.Rectangle, java.awt.FontMetrics, int)
to label the intervals.
It also uses nextUnitTime(java.util.Date)
to increment the intervals.
This method is called by IlvTimeScale.paint(Graphics, Rectangle, IlvTimeScale.PaintContext)
to paint the scale row. In the case that the scale is drawn on the screen, the cached
PaintContext
of the time scale is used.
This method can also be used to print the scale row. In this case,
an external PaintContext
must be provided in order
to print the portion specified by the programmer.
paint
in class IlvTimeScaleRow
dst
- The destination Graphics
.rect
- The rectangle in which the scale row should be drawn. The
rectangle should be in the destination (Graphics) coordinates.context
- The paint context in which the scale row paints.IlvTimeScaleRow.getTimeScale()
,
IlvTimeScale.getTime(long)
,
IlvTimeScale.getLocation(java.util.Date)
@Deprecated protected void paintRow(Graphics dst, Rectangle rect)
paint(Graphics, Rectangle,
IlvTimeScale.PaintContext)
instead.paint
to paint the time scale. The cached
PaintContext
of the time scale is used.paintRow
in class IlvTimeScaleRow
dst
- The destination Graphics
.rect
- The rectangle in which the scale row should be drawn.IlvTimeScale.getPaintContext()
protected void paintTick(Graphics dst, Point pos, int height, FontMetrics fm, int textBaseline)
setTickColor(Color)
.dst
- The destination Graphics
.pos
- The bottom point of the tick.height
- The maximum height of the tick.fm
- The metrics for the text font that is
currently set on dst
and is being used to label the
scale row.textBaseline
- The baseline Y position at which the text for the time interval
is being drawn.@Deprecated protected void paintTick(Graphics dst, Point pos, int height)
paintTick(Graphics, Point, int, FontMetrics, int)
method instead.dst
- The destination Graphics
.pos
- The bottom point of the tick.height
- The maximum height of the tick.setTickColor(java.awt.Color)
protected void paintText(Graphics dst, String text, Point topLeft, Point bottomRight, Rectangle rowRect, FontMetrics fm, int textBaseline)
topLeft
,
bottomRight
). The parameter topLeft.x
is the
starting location of the time interval or the left edge of the time scale
row, whichever is greater.
The bottomRight.x
parameter is the ending location of the time
interval and the starting location of the next time interval. Therefore,
when this method is invoked to paint the last interval in the row,
bottomRight.x
may be greater than the right edge of
rowRect
.
The text can be centered using the setTextPosition(int)
method. The color can be changed using the setTextColor(java.awt.Color)
method. The text String
representing the time is returned by the computeDateText(java.util.Date)
method. This String
will be preceded by an
additional string set using the setAdditionalString(java.lang.String)
method if the
interval begins before the visible part of the scale.
dst
- The destination Graphics
. The text font is already set on the
Graphics
.text
- The text to paint.topLeft
- The top-left corner of the time scale interval.bottomRight
- The bottom-right corner of the time scale interval.rowRect
- The visible bounds of the time scale row.fm
- The metrics for the text font that is
currently set on dst
.textBaseline
- The baseline Y position at which the text should be drawn.@Deprecated protected void paintText(Graphics dst, Point topLeft, Point bottomRight, String text)
paintText(Graphics, String, Point, Point, Rectangle, FontMetrics, int)
method instead.prevPos
, nextPos
). The text
can be centered using the setTextPosition(int)
method. The color can be changed
using the setTextColor(java.awt.Color)
method. The text String
representing the
time is returned by the computeDateText(java.util.Date)
method and can be preceded by an
additional string set using the setAdditionalString(java.lang.String)
method if the interval
begins before the visible part of the scale.dst
- The destination Graphics
.topLeft
- The top-left corner of the rectangle.bottomRight
- The bottom-right corner of the rectangle.text
- The text to paint.public Format getDateFormat()
SimpleDateFormat
object constructed
with the locale / time zone of the scale and a string specified with the
setFormatString
method (see the
java.text.SimpleDate
JDK class).
Generally, the subclass of IlvBasicTimeScaleRow
is responsible
for setting this string.setFormatString(java.lang.String)
,
Component.getLocale()
public void setFormatString(String format)
java.text.SimpleDateFormat
object returned by default by the getDateFormat
method.format
- A String
object that is passed to the
constructor of a java.text.SimpleDateFormat
object.getDateFormat()
public String getFormatString()
SimpleDateFormat
object.protected void invalidateDateTextCache()
computeDateText(java.util.Date)
formats the text for a given time.protected String computeDateText(Date time)
time
. The row's current
DateFormat
is used to format the time. Subclasses can override
this method as needed. invalidateDateTextCache()
must be invoked
whenever there is a change in a row property that affects how this method
formats the text.time
- The time.getDateFormat()
protected abstract IlvTimeIncrementPolicy createTimeIncrementPolicy()
getTimeIncrementPolicy()
public IlvTimeIncrementPolicy getTimeIncrementPolicy()
createTimeIncrementPolicy()
public Date previousUnitTime(Date time)
time
is
already an integer unit value, this method returns a copy of it.
For example, in a minute-unit time scale row, the previous unit time of
January 14th, 2001, 8:12:34 is January 14th, 2001, 8:12:00
and the previous unit time of January 14th, 2001, 9:01:00 is
January 14th, 2001, 9:01:00. This method uses the row's
time increment policy to compute the previous
unit time.previousUnitTime
in class IlvTimeScaleRow
time
- The time to floor.nextUnitTime(java.util.Date)
,
incrementTime(java.util.Date)
public Date nextUnitTime(Date time)
time
is already
an integer unit value, this method returns a copy of it.
For example, in a minute-unit time scale row, the next unit time of
January 14th, 2001, 8:12:34 is January 14th, 2001, 8:13:00
and the next unit time of January 14th, 2001, 9:01:00 is
January 14th, 2001, 9:01:00. This method uses the row's
time increment policy to compute the next
unit time.nextUnitTime
in class IlvTimeScaleRow
time
- The time to compute the ceiling.previousUnitTime(java.util.Date)
,
incrementTime(java.util.Date)
protected Date incrementTime(Date time)
time
- The time to increment.previousUnitTime(java.util.Date)
,
nextUnitTime(java.util.Date)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.