net.sourceforge.chart2d
Class TitledArea

java.lang.Object
  |
  +--net.sourceforge.chart2d.Area
        |
        +--net.sourceforge.chart2d.FontArea
              |
              +--net.sourceforge.chart2d.TitledArea
Direct Known Subclasses:
AxisArea, ChartArea

class TitledArea
extends FontArea

A bordered area with a title and auto calculations for left over space. This class uses all the customizability of the bordered area class, adds a text area for the title, automatic gap below title functionality and title within area justification. The title can be located at the top, bottom, left or right, and sometimes centered. With any of these scenarios, the title can be rotated left. The left over space will be computed and is availabe through a get method.
Note: Do not pass any null values; instead pass an empty string if need be.


Fields inherited from class net.sourceforge.chart2d.Area
BETWEEN, BOTTOM, CENTER, CENTERED, CONTINUOUS, DASHED, DOTTED, FLOAT, HEIGHT, HORIZONTAL, INTEGER, LABELSBOTTOM, LABELSLEFT, LEFT, LEFTBOTTOM, LEFTRIGHT, LEFTTOP, LESSER, MAX, MAXMODEL, MIN, RIGHT, RIGHTBOTTOM, RIGHTTOP, TOP, TOPBOTTOM, VERTICAL, WIDTH
 
Constructor Summary
(package private) TitledArea()
          Creates a new titled area with the default values:
setTitleExistence (true);
setFontPointModel (14);
setBetweenTitleAndSpaceGapExistence (true);
setBetweenTitleAndSpaceGapThicknessModel (5);
setTitleJustifications (CENTER, TOP);
setTitleAutoLocate (true);
title.setAutoJustifys (false, false);
title.setBorderExistences (false, false, false, false);
title.setGapExistences (false, false, false, false);
title.setBackgroundExistence (false);
resetTitledAreaModel (true);
 
Method Summary
(package private)  int getBetweenTitleAndSpaceGapThickness(java.awt.Graphics2D g2D)
          Returns the gap between the title and the available space.
(package private)  int getBetweenTitleAndSpaceGapThicknessModel()
          Returns the model gap thickness between the title and the bounds.
(package private)  java.awt.Rectangle getMaxEntitledSpaceBounds(java.awt.Graphics2D g2D)
          Returns the available space and location of that space.
(package private)  TextArea getTitle()
          Gets the title.
(package private)  boolean getTitleAutoLocate()
          Indicates whether the title will locate itself automatically within the area according to the title justifications.
(package private)  boolean getTitledAreaNeedsUpdate()
          Indicates whether some property of this class has changed.
(package private)  boolean getTitleExistence()
          Returns the existence of the title; whether the title exists or not.
(package private)  int getTitleJustifications(int which)
          Returns the horizontal or vertical justification of this title within the area.
(package private)  java.awt.Dimension getTitleSize(int which, java.awt.Graphics2D g2D)
          Returns the size of this title.
(package private)  java.lang.String getTitleText()
          Gets the text of the title.
(package private)  void paintComponent(java.awt.Graphics2D g2D)
          Paints all the components of this class.
(package private)  void resetTitledAreaModel(boolean reset)
          Resets the model for this class.
(package private)  void setBetweenTitleAndSpaceGapExistence(boolean existence)
          Specifies whether there should exist a gap between title and the available space.
(package private)  void setBetweenTitleAndSpaceGapThicknessModel(int gap)
          Specifies how large the model gap should be.
(package private)  void setTitle(java.lang.String title)
          Changes the text of the title.
(package private)  void setTitleAutoLocate(boolean auto)
          Changes whether the title will locate itself automatically within the area according to the title justifications.
(package private)  void setTitleExistence(boolean existence)
          Changes the existence of the title; whether the title exists or not.
(package private)  void setTitleJustifications(int horizontal, int vertical)
          Specifies the horizontal and vertical justification for the title text respective to the size of the area.
(package private)  void setTitleLocation(java.awt.Point location)
          Changes the location of the title.
(package private)  void setTitleRotateLeft(boolean rotate)
          Changes whether this title should be rotated left of not.
(package private)  void updateTitledArea(java.awt.Graphics2D g2D)
          Updates all the variables in this parent's classes, then all of this' variables.
 
Methods inherited from class net.sourceforge.chart2d.FontArea
getFont, getFontAreaNeedsUpdate, getFontColor, getFontName, getFontPointModel, getFontStyle, resetFontAreaModel, setFontColor, setFontName, setFontPointModel, setFontStyle, updateFontArea
 
Methods inherited from class net.sourceforge.chart2d.Area
applyRatio, getAreaNeedsUpdate, getAutoSize, getBackgroundColor, getBackgroundExistence, getBorderColor, getBorderColor, getBorderExistence, getBorderExistence, getBorderThickness, getBorderThickness, getBorderThicknessModel, getBorderThicknessModel, getGapThickness, getGapThicknessModel, getJustifications, getRatio, getResetAreaModel, getSize, getSizeLocation, getSpaceSize, getSpaceSizeLocation, resetAreaModel, setAutoJustifys, setAutoSizes, setBackgroundColor, setBackgroundExistence, setBorderAssociations, setBorderColor, setBorderColors, setBorderCornerAssociations, setBorderExistence, setBorderExistences, setBorderThicknessModel, setBorderThicknessModels, setCustomRatio, setGapAssociations, setGapExistence, setGapExistences, setGapThicknessModel, setGapThicknessModels, setJustifications, setLockRatios, setSize, setSizeLocation, setSpaceSize, setSpaceSizeLocation, updateArea
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TitledArea

TitledArea()
Creates a new titled area with the default values:
setTitleExistence (true);
setFontPointModel (14);
setBetweenTitleAndSpaceGapExistence (true);
setBetweenTitleAndSpaceGapThicknessModel (5);
setTitleJustifications (CENTER, TOP);
setTitleAutoLocate (true);
title.setAutoJustifys (false, false);
title.setBorderExistences (false, false, false, false);
title.setGapExistences (false, false, false, false);
title.setBackgroundExistence (false);
resetTitledAreaModel (true);
Method Detail

setTitleExistence

void setTitleExistence(boolean existence)
Changes the existence of the title; whether the title exists or not. Otherwise, title will not be included in calculations and will not be painted.
Parameters:
existence - If true, then title exists.

setTitle

void setTitle(java.lang.String title)
Changes the text of the title.
Parameters:
title - The new text of this title.

setTitleAutoLocate

void setTitleAutoLocate(boolean auto)
Changes whether the title will locate itself automatically within the area according to the title justifications. Otherwise, the title location must be set manually using the title set location method.
Parameters:
auto - true if the title will locate itself

setTitleLocation

void setTitleLocation(java.awt.Point location)
Changes the location of the title. The top, left part of the title no matter what title orientation.
Parameters:
location - The top left part of the title's location.

setTitleRotateLeft

void setTitleRotateLeft(boolean rotate)
Changes whether this title should be rotated left of not. When rotating left, the text will be rotated -90 degrees. However, the origin and the size of the label will not be rotated. It will encapsulate the newly rotated text.
Parameters:
rotate - If true, then text will be rotated -90 degrees whenever painted. However, values are updated immediately.

setTitleJustifications

void setTitleJustifications(int horizontal,
                            int vertical)
Specifies the horizontal and vertical justification for the title text respective to the size of the area. Note: A non rotated title cannot be vertically centered. And a rotated title cannot be horizontally centered.
Parameters:
horizontal - How to justify the title horizontally. Possible values area LEFT, RIGHT, and CENTER. [see note above for more detail about centering]
vertical - How to justify the title vertically. Possible values area TOP, BOTTOM, and CENTER. [see note above for more detail about centering]

setBetweenTitleAndSpaceGapExistence

void setBetweenTitleAndSpaceGapExistence(boolean existence)
Specifies whether there should exist a gap between title and the available space. Part of the functionality of this class is to calculate space not used by the title. Setting this gap, makes the available space less so drawing can begin exactly in the space, and look good becuase its spaced nicely from the title.
Parameters:
existence - If true, then gap is subtracted from space; else gap model thickness is ignored.

setBetweenTitleAndSpaceGapThicknessModel

void setBetweenTitleAndSpaceGapThicknessModel(int gap)
Specifies how large the model gap should be. Part of the functionality of this class is to calculate space not used by the title. This gap, makes the available space less so drawing can begin exactly in the space, and look good becuase its spaced nicely from the title.
Parameters:
gap - The thickness of the model gap. If model max size autosizing is disabled, then a ratio based on max size / model max size will be applied to this thickness to obtain the actual thickness; otherwise, the thickness will be this model thickness. Also, if gap existence is false, this thickness will be ignored.

getBetweenTitleAndSpaceGapThicknessModel

int getBetweenTitleAndSpaceGapThicknessModel()
Returns the model gap thickness between the title and the bounds.
Returns:
The thickness of the model gap.

getMaxEntitledSpaceBounds

java.awt.Rectangle getMaxEntitledSpaceBounds(java.awt.Graphics2D g2D)
Returns the available space and location of that space. The available space is the area less the title and the gap. Updates all variables before calculating the bounds.
Parameters:
g2D - The graphics context for calculations and painting.
Returns:
The bounds of the available space.

getTitleExistence

boolean getTitleExistence()
Returns the existence of the title; whether the title exists or not.
Returns:
If true, then title exists.

getTitleText

java.lang.String getTitleText()
Gets the text of the title.
Returns:
The new text of this title.

getTitle

TextArea getTitle()
Gets the title.
Returns:
The title's TextArea.

getTitleSize

java.awt.Dimension getTitleSize(int which,
                                java.awt.Graphics2D g2D)
Returns the size of this title. Even if the title is rotated, the width of this dimension will correspond to width on the monitor screen, and not height. The same is true for the height of the dimension.
Parameters:
which - Which size MAXMODEL, MAX, or MIN.
g2D - The graphics context for calculations and painting.
Returns:
The size of the title.

getTitleJustifications

int getTitleJustifications(int which)
Returns the horizontal or vertical justification of this title within the area.
Parameters:
which - Which type of justification to return. Possible values are HORIZONTAL and VERTICAL.
Returns:
The justification of this title. Possible values of horizontal justification area LEFT, RIGHT, and CENTER. Possible values of vertical justification are TOP, BOTTOM, and CENTER.

getTitleAutoLocate

boolean getTitleAutoLocate()
Indicates whether the title will locate itself automatically within the area according to the title justifications. Otherwise, the title location must be set manually using the title set location method.
Returns:
True if the title will locate itself

getBetweenTitleAndSpaceGapThickness

int getBetweenTitleAndSpaceGapThickness(java.awt.Graphics2D g2D)
Returns the gap between the title and the available space. This is not the model gap thickness but the actual thickness, after applying the ratio when relevant. All variables area updated before returning this size.
Parameters:
g2D - The graphics context to use for calculations.
Returns:
The thickness of the gap between the title and the available space.

getTitledAreaNeedsUpdate

boolean getTitledAreaNeedsUpdate()
Indicates whether some property of this class has changed.
Returns:
True if some property has changed.

updateTitledArea

void updateTitledArea(java.awt.Graphics2D g2D)
Updates all the variables in this parent's classes, then all of this' variables.
Parameters:
g2D - The graphics context to use for calculations.

resetTitledAreaModel

void resetTitledAreaModel(boolean reset)
Resets the model for this class. The model is used for shrinking and growing of its components based on the maximum size of this class. If this method is called, then the next time the maximum size is set, this classes model maximum size will be made equal to the new maximum size. Effectively what this does is ensure that whenever this objects maximum size is equal to the one given, then all of the components will take on their default model sizes. Note: This is only useful when auto model max sizing is disabled.
Parameters:
reset - True sets the max model size on the next max sizing.

paintComponent

void paintComponent(java.awt.Graphics2D g2D)
Paints all the components of this class. First all variables are updated.
Overrides:
paintComponent in class FontArea
Parameters:
g2D - The graphics context for calculations and painting.