3.4.9 - Progress Bar - JdlProgressBar

John W. Campbell

3.4.9.1 Introduction

This class provides a progress bar object to indicate the progress of a process.

Class, fields, constructor and methods:

Class Details
Accessible Fields
Constructors
Set Progress
Set Resources
Standard Positioning and Sizing
Overriden Superclass Methods

3.4.9.2 Class Details

Package:
Jdl.JdlView;
Class name:
JdlProgressBar
Class definition:
public class JdlProgressBar
Extends:
JdlDrawPanel
Implements:
JdlDrawPanelDrawer
JdlProgressHandler
JdlViewObject
Actions:
none

3.4.9.3 Accessible Fields

The following accessible fields have been defined:

public final static int PREFERRED
Size Constraint: preferred size.
public final static int FREE
Size/Location Constraint: free.
static final long serialVersionUID

3.4.9.4 Constructors

3.4.9.4.1 Introduction

A single constructor is available.

Constructor:

Standard constructor

3.4.9.4.2 Standard constructor

Constructs a JdlProgressBar object.

Constructor Definition:
public JdlProgressBar(String str, int lab_w, Color colr, int minbw, int minbh, JdlViewOptions view_opts)
Parameters List:
labstr
An initial label string - may be null if not required (in this case setting new labels will have no effect).
lab_w
A pre-calculated width for the labels text in pixels. If set, thios will remain fixed even if labels are changed; if 0 then the label width will be calculated from the current label string and will change if this is changed. Note that the label string is output using the strandard bold font.
colr
Colour for the progress bar.
minbw
Minimum bar width (e.g. 200).
minbh
Minimum bar height (e.g. 20).
view_opts
Object to set non-default options for borders, active strip, colours and fonts.

3.4.9.5 Set Progress

3.4.9.5.1 Introduction

This section has a single method to set the current progress status so that it may be displayed. This is also the method invoked when the progress bar object is used as a JdlProgressHandler interface.

Method:

Set progress - progress
Create popup - createPopup

3.4.9.5.2 Set progress - progress

This method sets the current state of progress of the process being monitored by the progress bar.

Method Definition:
public void progress(int ip, int nmax, int n)
Parameters List:
ip
Flag:
= 0, Process started (Using current label and bar colour)
= 1, Process in progress
= 2, Process completed
>100, If multiple steps have been defined, give 100 + the step number e.g. 101 for step 1, 102 for step 2 to indicate the start of the new step. If a label has not been defined for the step, the current label will be used instead and similarly for the colour.
nmax
The maximum value to be reached when the process is complete.
n
The current value reached for the process.

3.4.9.5.3 Create popup - createPopup

This method enables a popup to be created containing a progress bar.

Method Definition:
public Popup createPopup(Component parent, int x, int y)
Parameters List:
parent
The parent view object (or Component).
x
The 'x' coordinate of the popup relative to the parent.
y
The 'y' coordinate of the popup relative to the parent.
Method Return:
The popup.

3.4.9.6 Set Resources

3.4.9.6.1 Introduction

This section has methods to set the progress bar resources.

Methods:

Set bar colour - setColour
Set label - setLabelString
Multiple steps - setMultipleSteps
Set label alignment - setLabelAlignment
Clear progress bar - clearBar
Set inset width - setInsetBorder
Set surround width - setSurroundWidth
Set surround height - setSurroundHeight

3.4.9.6.2 Set bar colour - setColour

This method sets a new bar colour.

Method Definition:
public void setColour(Color colr)
Parameters List:
colr
The bar colour.

3.4.9.6.3 Set label - setLabelString

This method sets a new label string.

Method Definition:
public void setLabelString(String str)
Parameters List:
str
The new label string.

3.4.9.6.4 Multiple steps - setMultipleSteps

This method enables labels and colours to be set for multiple steps in a process.

Method Definition:
public void setMultipleSteps (String[] labels, Color[] colrs)
Parameters List:
labels
Label strings for the steps (at least 1).
colrs
Colours for the steps (at least 1).

3.4.9.6.5 Set label alignment - setLabelAlignment

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 JdlLabel.CENTER, JdlLabel.LEFT, JdlLabel.RIGHT)

3.4.9.6.6 Clear progress bar - clearBar

This method clears the contents of the progress bar.

Method Definition:
public void clearBar(boolean lbl)
Parameters List:
lbl
If true then set label string to blank as well as the bar area.

3.4.9.6.7 Set inset width - setInsetBorder

This method sets a new bar inset border width.

Method Definition:
public void setInsetBorder(int iw)
Parameters List:
iw
The inset border width.

3.4.9.6.8 Set surround width - setSurroundWidth

This method sets a new surround width.

Method Definition:
public void setSurroundWidth(int iw)
Parameters List:
iw
The border surround width (between view-border & label or bar).

3.4.9.6.9 Set surround height - setSurroundHeight

This method sets a new surround height.

Method Definition:
public void setSurroundHeight(int ih)
Parameters List:
iw
The border surround height (between view-border & label or bar).

3.4.9.7 Standard Positioning and Sizing

3.4.9.7.1 Introduction

This section contains the standard methods for positioning and sizing JdlView objects and getting the current minimum height and width values.

Methods:

Set position constraints - setLocationConstraints
Set size constraints - setSizeConstraints
Set minimum height - setMinimumHeight
Set minimum width - setMinimumWidth

3.4.9.7.2 Set position constraints - setLocationConstraints

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.

3.4.9.7.3 Set size constraints - setSizeConstraints

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.

3.4.9.7.4 Set minimum height - setMinimumHeight

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).

3.4.9.7.5 Set minimum width - setMinimumWidth

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).

3.4.9.8 Overriden Superclass Methods

3.4.9.8.1 Introduction

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 and setSize methods are also over-ridden but they are 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

3.4.9.8.2 Set background - setBackground

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.

3.4.9.8.3 Set background colours - setBackground

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.

3.4.9.8.4 Set foreground - setForeground

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.

3.4.9.8.5 Get minimum size - getMinimumSize

This method returns the minimum size of the component.

Method Definition:
public Dimension getMinimumSize()
Parameters List:
none

3.4.9.8.6 Get preferred size - getPreferredSize

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