All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class guinea.ui.GradeBar

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----guinea.ui.GradeBar

public class GradeBar
extends Container
implements AdjustmentListener, QuestionInterface, ControlInterface, PropertyLoader
Gradebar is a UI component with a continuous scale. The minimum and maximum values of the grade can be specified as well as number of decimal places and possible "anchors".


Variable Index

· cfp
A ChoiceFormat pattern for displaying adjectives.
· controlCommand
· defaultAnswer
The default answer.
· DEFAULTANSWER_MIDDLE
Default answer is the midpoint of minimum and maximum.
· DEFAULTANSWER_RANDOM
Default answer is a random point between the minimum and maximum.
· DEFAULTANSWER_SET
Default answer is set explicitly.
· defaultAnswerRandomMax
Maximum of grade's random initial value.
· defaultAnswerRandomMin
Minimum of grade's random initial value.
· defaultAnswerType
The type of the default answer.
· dfp
Formatting pattern for formatting numeric grade display.
· isControl
· isQuestion
· mf
Message formatting object for generating the grade/adjective display.
· mfp
The message formatting pattern of the 'mf' variable.
· showLabels
Show labels (grade and/or adjective)? Default is true.
· showValue
Whether to show the numeric grade to the subject.

Constructor Index

· GradeBar()
Create a new grade bar with default grade parameters and no question.
· GradeBar(double, double, int)
Create a new grade bar with given parameters.
· GradeBar(double, double, int, String)
Create a new grade bar with given parameters.
· GradeBar(String)
Create a new grade bar with default grade parameters.

Method Index

· addAnswerListener(AnswerListener)
Add a listener that is interested to receive answer events.
· addControlListener(ControlListener)
Add a control listener to receive events from this control component.
· adjustmentValueChanged(AdjustmentEvent)
Handle adjustment events from the scrollbar.
· formatMessage(double)
Format the current grade to string for displaying grade/adjective below the scrollbar.
· formatMessage(Object)
Format the current grade to string for displaying grade/adjective below the scrollbar.
· getAnswer()
Get answer for question.
· getAnswer_internal()
Return the answer object for this component.
· getControlValue()
Get the value of this controller.
· getDecimals()
Get number of decimals in the scale.
· getGradeMessageFormat()
Get the message formatting object that is used to create the grade/adjective display below the scrollbar.
· getMaximum()
Get the maximum value of grade.
· getMinimum()
Get the minimum value of grade.
· getPreferredSize()
Returns the preferred size of this container.
· getQuestion()
Get the text of the question.
· getQuestionFont()
Get font of the question text.
· getQuestionID()
Get the ID of the question.
· isAnswered()
See if an aswer has been given.
· isControlEnabled()
Test whether control is enabled or disabled.
· isQuestionEnabled()
Test whether question is enabled or disabled.
· paint(Graphics)
Paint component.
· propertyLoad(Properties, String)
· removeAnswerListener(AnswerListener)
Removes the specified listener so it no longer receives control motion events from this component.
· removeControlListener(ControlListener)
Remove a control listener so that control events are no longer sent to that listener.
· reset()
Reset question to default answer and/or to unanswered state.
· setAnswer(Object)
Set answer of question.
· setChoiceFormat(String)
Set the choice format for showing an adjective corresponding to a grade using a pattern.
· setControlEnabled(boolean)
Enable or disable control component.
· setControlValue(Object)
Set the value of this controller.
· setDecimals(int)
Set number of decimals to show and return in answer.
· setEnabled(boolean)
Fix an error in java's setEnabled for Containers
· setGradeFormat(String)
Set the number formatting pattern for formatting the numeric grade if custom grade message format is used.
· setGradeMessageFormat(Format)
Set custom message formatting pattern used for formatting the grade/adjective label.
· setGradeMessageFormat(String)
Set custom message formatting pattern used for formatting the grade/adjective label.
· setMaximum(double)
Set maximum value of grade.
· setMinimum(double)
Set minimum value of grade.
· setQuestion(String)
Set the text of the question.
· setQuestionEnabled(boolean)
Enable or disable question component.
· setQuestionFont(Font)
Set font of the question text.
· setQuestionID(String)
Set the ID of this question.

Variables

· showValue
 protected boolean showValue
Whether to show the numeric grade to the subject. Default is true.

· showLabels
 protected boolean showLabels
Show labels (grade and/or adjective)? Default is true.

· isQuestion
 protected boolean isQuestion
· isControl
 protected boolean isControl
· controlCommand
 protected String controlCommand
· mf
 protected Format mf
Message formatting object for generating the grade/adjective display.

· mfp
 protected String mfp
The message formatting pattern of the 'mf' variable.

· cfp
 protected String cfp
A ChoiceFormat pattern for displaying adjectives.

· dfp
 protected String dfp
Formatting pattern for formatting numeric grade display.

· DEFAULTANSWER_MIDDLE
 public static final int DEFAULTANSWER_MIDDLE
Default answer is the midpoint of minimum and maximum.

· DEFAULTANSWER_RANDOM
 public static final int DEFAULTANSWER_RANDOM
Default answer is a random point between the minimum and maximum.

· DEFAULTANSWER_SET
 public static final int DEFAULTANSWER_SET
Default answer is set explicitly.

· defaultAnswerType
 protected int defaultAnswerType
The type of the default answer. The default is DEFAULTANSWER_MIDDLE.

See Also:
DEFAULTANSWER_MIDDLE, DEFAULTANSWER_RANDOM, DEFAULTANSWER_SET
· defaultAnswer
 protected double defaultAnswer
The default answer. This is used if default answer type is DEFAULTANSWER_SET.

See Also:
defaultAnswerType
· defaultAnswerRandomMax
 protected double defaultAnswerRandomMax
Maximum of grade's random initial value.

· defaultAnswerRandomMin
 protected double defaultAnswerRandomMin
Minimum of grade's random initial value.

Constructors

· GradeBar
 public GradeBar()
Create a new grade bar with default grade parameters and no question.

· GradeBar
 public GradeBar(String qtext)
Create a new grade bar with default grade parameters.

Parameters:
qtext - Text of question.
· GradeBar
 public GradeBar(double minVal,
                 double maxVal,
                 int decimals)
Create a new grade bar with given parameters.

Parameters:
minVal - minimum value of grade.
maxVal - maximum value of grade.
decimals - number of decimals.
· GradeBar
 public GradeBar(double minVal,
                 double maxVal,
                 int decimals,
                 String qtext)
Create a new grade bar with given parameters.

Parameters:
minVal - minimum value of grade.
maxVal - maximum value of grade.
decimals - number of decimals.
qtext - text of question.

Methods

· setMinimum
 public void setMinimum(double minVal)
Set minimum value of grade.

Parameters:
minVal - minimum value of grade.
· getMinimum
 public double getMinimum()
Get the minimum value of grade.

Returns:
minimum value of grade.
· setMaximum
 public void setMaximum(double maxVal)
Set maximum value of grade.

Parameters:
maxVal - maximum value of grade.
· getMaximum
 public double getMaximum()
Get the maximum value of grade.

Returns:
maximum value of grade.
· paint
 public void paint(Graphics g)
Paint component.

Overrides:
paint in class Container
· setDecimals
 public synchronized void setDecimals(int decimals)
Set number of decimals to show and return in answer.

Parameters:
decimals - number of decimals or 0 if no decimals wanted.
· getDecimals
 public int getDecimals()
Get number of decimals in the scale.

Returns:
The number of decimals used in scale.
· getGradeMessageFormat
 public Format getGradeMessageFormat()
Get the message formatting object that is used to create the grade/adjective display below the scrollbar. The formatter expects the numeric grade given as the first argument given to the formatter ({0} in the pattern).

Returns:
A message formatting object.
See Also:
mf, mfp, dfp, cfp
· setGradeMessageFormat
 public void setGradeMessageFormat(Format format)
Set custom message formatting pattern used for formatting the grade/adjective label.

Parameters:
format - A formatting pattern. The grade is passed as the {0} argument to the formatter.
· setGradeMessageFormat
 public void setGradeMessageFormat(String format)
Set custom message formatting pattern used for formatting the grade/adjective label.

Parameters:
format - Message formatting pattern. The grade is passed as the {0} argument to the formatter.
See Also:
MessageFormat
· setGradeFormat
 public void setGradeFormat(String format)
Set the number formatting pattern for formatting the numeric grade if custom grade message format is used.

Parameters:
format - A java.text.DecimalFormat pattern.
See Also:
DecimalFormat, setGradeMessageFormat
· setChoiceFormat
 public void setChoiceFormat(String pattern)
Set the choice format for showing an adjective corresponding to a grade using a pattern.

Parameters:
pattern - Formatting pattern used to display adjectives.
See Also:
ChoiceFormat, applyPattern
· formatMessage
 protected String formatMessage(Object value)
Format the current grade to string for displaying grade/adjective below the scrollbar.

Parameters:
value - The value to format.
· formatMessage
 protected String formatMessage(double value)
Format the current grade to string for displaying grade/adjective below the scrollbar.

Parameters:
value - The value to format.
· adjustmentValueChanged
 public void adjustmentValueChanged(AdjustmentEvent e)
Handle adjustment events from the scrollbar.

Parameters:
e - An adjustment event.
· setQuestionEnabled
 public void setQuestionEnabled(boolean enabled)
Enable or disable question component.

Parameters:
enabled - Use true to enable, false to disable the question.
· isQuestionEnabled
 public boolean isQuestionEnabled()
Test whether question is enabled or disabled.

Returns:
true if question is enabled, false if not.
· getAnswer
 public Object getAnswer()
Get answer for question. This method calls the getAnswer_internal() method to get the actual object to return.

Returns:
the answer object (usually as java.lang.Number) or null if question hasn't been answered.
· getAnswer_internal
 protected Object getAnswer_internal()
Return the answer object for this component. In the case of GradeBar, the answers are numbers but other types could also be used. If number of decimals is 0, returns a java.lang.Integer, otherwise returns a java.lang.Double.

Returns:
An Java Object.
· setAnswer
 public void setAnswer(Object answer)
Set answer of question.

Parameters:
answer - the answer as a java.lang.Number. null clears answer (question becomes unanswered. Same as reset().
· reset
 public void reset()
Reset question to default answer and/or to unanswered state.

· isAnswered
 public boolean isAnswered()
See if an aswer has been given.

Returns:
true if user has given an answer.
· setQuestion
 public void setQuestion(String question)
Set the text of the question.

Parameters:
question - text of the question.
· getQuestion
 public String getQuestion()
Get the text of the question.

Returns:
text of the question.
· setQuestionID
 public void setQuestionID(String id)
Set the ID of this question.

Parameters:
id - ID label of question.
· getQuestionID
 public String getQuestionID()
Get the ID of the question.

Returns:
ID label of the question.
· setQuestionFont
 public void setQuestionFont(Font f)
Set font of the question text.

Parameters:
f - An AWT font object.
· getQuestionFont
 public Font getQuestionFont()
Get font of the question text.

Returns:
An AWT font object.
· addAnswerListener
 public synchronized void addAnswerListener(AnswerListener listener)
Add a listener that is interested to receive answer events.

Parameters:
listener - A listener.
· removeAnswerListener
 public synchronized void removeAnswerListener(AnswerListener listener)
Removes the specified listener so it no longer receives control motion events from this component.

Parameters:
listener - A control listener.
· setControlEnabled
 public void setControlEnabled(boolean enabled)
Enable or disable control component.

Parameters:
enabled - Use true to enable, false to disable the controller.
· isControlEnabled
 public boolean isControlEnabled()
Test whether control is enabled or disabled.

Returns:
true if controller is enabled, false if not.
· setControlValue
 public void setControlValue(Object value)
Set the value of this controller. Can be used to set initial value of controlled variable.

Parameters:
value - the value to set.
· getControlValue
 public Object getControlValue()
Get the value of this controller. Can be used to get initial value of controlled variable.

Parameters:
value - The value to get.
· addControlListener
 public void addControlListener(ControlListener listener)
Add a control listener to receive events from this control component.

Parameters:
listener - a listener
· removeControlListener
 public void removeControlListener(ControlListener listener)
Remove a control listener so that control events are no longer sent to that listener.

Parameters:
listener - a listener
· setEnabled
 public void setEnabled(boolean enable)
Fix an error in java's setEnabled for Containers

Parameters:
enable - enable or disable component.
Overrides:
setEnabled in class Component
· getPreferredSize
 public Dimension getPreferredSize()
Returns the preferred size of this container.

Overrides:
getPreferredSize in class Container
· propertyLoad
 public void propertyLoad(Properties p,
                          String name) throws IllegalArgumentException

All Packages  Class Hierarchy  This Package  Previous  Next  Index