John W. Campbell
This class provides a label with an optional border. The label may contain a
user supplied string and/or have its drawing area filled by a user supplied
JdlLabelDrawer object.
Class, fields, constructor and methods:
Class Details
Accessible Fields
Constructor
Class Methods
Operational Methods
Resource Methods
Standard Positioning and Sizing
Overriden Superclass Methods
- Package:
- Jdl.JdlView;
- Class name:
- JdlLabel
- Class definition:
- public class JdlLabel
- Extends:
- JPanel
- Implements:
- none
- Actions:
- none
The following accessible fields have been defined:
- public final static int SOLID
- Border type option: Solid.
- public final static int INSET
- Border type option: Three dimensional (inset).
- public final static int RAISED
- Border type option: Three dimensional (raised).
- public final static int CENTER
- Label alignment: centred.
- public final static int LEFT
- Label alignment: left justified.
- public final static int RIGHT
- Label alignment: right justified.
- public final static int STRING_SIZE
- Size Constraint: string size (width or height).
- public final static int DEFAULT_LABEL_BORDER
- Default label border.
- public final static int DEFAULT_LABEL_SURROUND_HEIGHT
- Default label surround height.
- public final static int DEFAULT_LABEL_SURROUND_WIDTH
- Default label surround width.
- static final long serialVersionUID
- public final static int PREFERRED
- Size Constraint: preferred size.
- public final static int FREE
- Size/Location Constraint: free.
Four constructors are available.
Constructor:
Default constructor
Constructor 2
Constructor 3
Constructor 4
Constructs a label with default resources.
- Constructor Definition:
- public JdlLabel()
- Parameters List:
- none
Constructs a label with a requested label string and the default font.
- Constructor Definition:
- public JdlLabel(String string)
- Parameters List:
- string
- The label string.
Constructs a label with a requested label string and font.
- Constructor Definition:
- public JdlLabel(String string, Font font)
- Parameters List:
- string
- The label string.
- font
- The font for the label string.
Constructs a blank label of a given size
- Constructor Definition:
- public JdlLabel(int w, int h)
- Parameters List:
- w
- Label width
- h
- Label height
This section has methods to determine the required size for
the object.
Method:
Find size - findStartSize
Find size - findStartSize
Find size - findStartSize
Determine the required starting (minimum) size for the JdlLabel object based on
the relevant parameters (from string & font with default border & surround
parameters).
- Method Definition:
- public static Dimension findStartSize (String str, Font font)
- Parameters List:
- str
- Label string.
- font
- Label font.
- Method Return:
-
The calculated size (width, height).
Determine the required starting (minimum) size for the JdlLabel object based on
the relevant parameters (from pre-determined string size with default border
& surround parameters).
- Method Definition:
- public static Dimension findStartSize (int w, int h)
- Parameters List:
- w
- Pre-calculated string width.
- h
- Pre-calculated string height.
- Method Return:
-
The calculated size (width, height).
Determine the required starting (minimum) size for the JdlLabel object based on
the relevant parameters (from pre-determined string size, border & surround
parameters).
- Method Definition:
- public static Dimension findStartSize (int w, int h, int brdr, int surround_w, int surround_h)
- Parameters List:
- w
- Pre-calculated string width.
- h
- Pre-calculated string height.
- brdr
- Border width.
- surround_w
- The surround width.
- surround_h
- The surround height.
- Method Return:
-
The calculated size (width, height).
This section contains the main methods used with normal operation
of the object.
Methods:
Set label - setLabelString
This method sets the label string resource.
- Method Definition:
- public void setLabelString(String str)
- Parameters List:
- str
- The label string (default = null).
This section has methods to set/get the resources associated with the
object determining its appearance and mode of action.
Methods:
Set border - setLabelBorder
Get border - getLabelBorder
Set border colour - setBorderColor
Set border colour - setBorderColor
Get border colour - getBorderColor
Set border type - setBorderType
Get border type - getBorderType
Set label drawer - setDrawer
Get label drawer - getDrawer
Get drawer identifier - getDrawerId
Set fill colour - setFillColor
Get fill colour - getFillColor
Set string width - setInputStringWidth
Set label alignment - setLabelAlignment
Get label alignment - getLabelAlignment
Set font - setLabelFont
Get font - getLabelFont
Set surround height - setSurroundHeight
Get surround height - getSurroundHeight
Set surround width - setSurroundWidth
Get surround width - getSurroundWidth
This method sets the label border resource.
- Method Definition:
- public void setLabelBorder(int thickness)
- Parameters List:
- thickness
- This is the required Label border thickness in pixels.
(default = 0 - no border)
This method returns the current value of the label border resource.
- Method Definition:
- public int getLabelBorder()
- Parameters List:
- none
- Method Return:
-
Returns the arrow border thickness in pixels.
This method sets the border colour resource.
- Method Definition:
- public void setBorderColor (Color colr)
- Parameters List:
- colr
- The border colour - sets this colour for a solid border or
lighter and darker shades of if for a three dimensional label border.
If null (the default), use the background colour if a three dimensional
label or black if the label has a solid border.
This method sets the border colour resources.
- Method Definition:
- public void setBorderColor (Color colr, Color brighter, Color darker)
- Parameters List:
- colr
- The border colour - sets the colour for a solid border.
- brighter
- A brighter colour for a three dimensional label border.
- darker
- A darker colour for a three dimensional label border.
This method returns the border colour resource.
- Method Definition:
- public Color getBorderColor()
- Parameters List:
- none
- Method Return:
-
Returns the border colour resource as set.
This method sets the border type resource.
- Method Definition:
- public void setBorderType (int type)
- Parameters List:
- type
- Border type flag:
= 0, solid
= 1, inset (3-D)
= 2, raised (3D)
(May use variables SOLID, INSET, RAISED)
This method returns the border type resource.
- Method Definition:
- public int getBorderType()
- Parameters List:
- none
- Method Return:
-
Returns the border type flag:
= 0, solid
= 1, inset (3-D)
= 2, raised (3D)
This method sets the JdlLabelDrawer object resource.
- Method Definition:
- public void setDrawer (JdlLabelDrawer dr, int id)
- Parameters List:
- dr
- A JdlLabelDrawer interfaced object to carry out the
drawing on the label (default = null). Its jdl_label_drawer method
is called from the paint routine after the border has been drawn. The
parameters include details of the label size and state. Unless suppressed
the label string (if defined) will be drawn on the label after the
drawing routine has been invoked.
- id
- Identifier to be passed to the drawing method when called.
This method returns the JdlLabelDrawer object resource.
- Method Definition:
- public JdlLabelDrawer getDrawer()
- Parameters List:
- none
- Method Return:
-
Returns the currently installed JdlLabelDrawer object or
null if none has been set up.
This method returns the JdlLabelDrawer identifier resource.
- Method Definition:
- public int getDrawerId()
- Parameters List:
- none
- Method Return:
-
Returns the identifier of the currently installed JdlLabelDrawer
object.
This method sets the label fill colour resource.
- Method Definition:
- public void setFillColor (Color colr)
- Parameters List:
- colr
- The fill colour for the label. If null (the default), then the
background colour will be used.
This method returns the label fill colour resource.
- Method Definition:
- public Color getFillColor()
- Parameters List:
- none
- Method Return:
-
Returns the current value of the label fill colour resource.
This method sets a pre-calculated string width to override the string
width calculated from the current label string.
- Method Definition:
- public void setInputStringWidth (int width)
- Parameters List:
- string_width
- The pre-calculated string width (default =0, ignore).
This method sets the label alignment resource.
- Method Definition:
- public void setLabelAlignment (int align)
- Parameters List:
- align
- A flag indicating the required label alignment:
= 0, to centre
= 1, for left justification
= 2, for right justification
(May use the variables CENTER, LEFT, RIGHT)
This method returns the label alignment resource.
- Method Definition:
- public int getLabelAlignment()
- Parameters List:
- none
- Method Return:
-
Returns the label alignment flag:
= 0, centre
= 1, left justification
= 2, right justification
This method sets the label font resource.
- Method Definition:
- public void setLabelFont (Font font)
- Parameters List:
- font
- The font for a label label
This method returns the label font resource.
- Method Definition:
- public Font getLabelFont()
- Parameters List:
- none
- Method Return:
-
Returns the label font.
This method sets the surround height resource.
- Method Definition:
- public void setSurroundHeight(int minh)
- Parameters List:
- minh
- The minimum height required between the label border and the
top and bottom of the label text (default = 2)
This method returns the surround height resource.
- Method Definition:
- public int getSurroundHeight()
- Parameters List:
- none
- Method Return:
-
Returns the surround height.
This method sets the surround width resource.
- Method Definition:
- public void setSurroundWidth(int minw)
- Parameters List:
- minw
- The minimum width required between the label border and the
left and right of the label text (default = 2)
This method returns the surround width resource.
- Method Definition:
- public int getSurroundWidth()
- Parameters List:
- none
- Method Return:
-
Returns the surround width.
This section contains the standard methods for positioning and sizing
the object.
Methods:
Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints
Set minimum height - setMinimumHeight
Set minimum width - setMinimumWidth
Set constraints on the Jdl object positioning.
- Method Definition:
- public void setLocationConstraints (int constraint_x, int constraint_y)
- Parameters List:
- constraint_x
- Constrain the Jdl Object 'x' position = the required
Jdl Object 'x' position (overrides setLocation method) or FREE if the 'x'
position may be set by the setLocation method and hence possibly by the
layout manager.
- constraint_y
- Constrain the Jdl Object 'y' position = the required
the Jdl Object 'y'position (overrides setLocation method) or FREE if the 'y'
position may be set by the setLocation method and hence possibly by the
layout manager.
Set constraints on the Jdl Object resizing permitted.
- Method Definition:
- public void setSizeConstraints (int constraint_w, int constraint_h)
- Parameters List:
- constraint_w
- Constrain the Jdl Object width = the required
Jdl Object width, or PREFERRED (default) if the width is to be calculated
from the current resources, or FREE if the width may be resized to anything
greater than the minimum width required.
- constraint_h
- Constrain the Jdl Object height = the required
Jdl Object height, or PREFERRED (default) if the height is to be calculated
from the current resources, or FREE if the height may be resized to anything
greater than the minimum height required.
Set the minimum height resource.
- Method Definition:
- public void setMinimumHeight(int minh)
- Parameters List:
- minh
- The minimum height required for the object (ignored if less
than that required by the minimum layout) (default = 0).
Set the minimum width resource.
- Method Definition:
- public void setMinimumWidth(int minw)
- Parameters List:
- minh
- The minimum width required for the object (ignored if less
than that required by the minimum layout) (default = 0).
This section contains methods which override the corresponding superclass
methods. These are basically standard for JdlView objects and comprise
methods to set background and foreground colours and to get the minimum
and preferred sizes for the object. (The paintComponent method is also
over-ridden but is not normally called by the user).
Methods:
Set background - setBackground
Set background colours - setBackground
Set foreground - setForeground
Get minimum size - getMinimumSize
Get preferred size - getPreferredSize
This method sets the background colour resource.
- Method Definition:
- public void setBackground (Color c)
- Parameters List:
- c
- The color to become this object's background color.
This method sets the background colour resource and brighter and darker shades
of that colour (e.g. for 3-D frames).
- Method Definition:
- public void setBackground (Color c, Color brighter, Color darker)
- Parameters List:
- c
- The background colour.
- brighter
- A brighter shade of the background colour.
- darker
- A darker shade of the background colour.
This method sets the foreground colour resource.
- Method Definition:
- public void setForeground (Color c)
- Parameters List:
- c
- The color to become this object's foreground color.
This method returns the minimum size of the component.
- Method Definition:
- public Dimension getMinimumSize()
- Parameters List:
- none
This method returns the preferred size of the component.
- Method Definition:
- public Dimension getPreferredSize()
- Parameters List:
- none
⇑ Up 3
⇑ Up 2
⇑ Up 1
⇑ Top of this