All Packages Class Hierarchy This Package Previous Next Index
Class guinea.ui.BaseGrader
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----guinea.ui.BaseGrader
- public abstract class BaseGrader
- extends Container
- implements AdjustmentListener, QuestionInterface, ControlInterface, PropertyLoader
BaseGrader is a base class for UI components that implement a
continuous scale with an adjustable component (slider, scrollbar,
etc.). A sub-class defines which component exactly is used to
implement adjustement.
The minimum and maximum values of the grade can be specified as
well as number of decimal places and possible "anchors".
- See Also:
- LineScale, GradeBar
Variable Index
- ·
answered
- Is question answered.
- ·
bar
- The adjustable component.
- ·
barComp
- The adjustable AWT Component object.
- ·
cfp
- A ChoiceFormat pattern for displaying adjectives.
- ·
controlCommand
- The control command name that is sent in the control event if
this component is acting as a controller.
- ·
dec
- A multiplier used internally to scale floating point grades to
integers that the adjustable component uses.
- ·
decimals
- Number of decimals in the grade.
- ·
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
- Is this component used as a control component.
- ·
isQuestion
- Is this component used as a question component.
- ·
lab
- The label that is used to display the current grade and/or the
adjective.
- ·
maxVal
- Maximum value of the grade.
- ·
mf
- Message formatting object for generating the grade/adjective
display.
- ·
mfp
- The message formatting pattern of the 'mf' variable.
- ·
minVal
- Minimum value of the grade.
- ·
qid
- Question ID of this component.
- ·
showLabels
- Show labels (grade and/or adjective)? Default is
true.
- ·
showValue
- Whether to show the numeric grade to the subject.
- ·
text
- Text of the question.
- ·
tl
- Label used to display the question text.
- ·
value
- Current value of the grade.
Constructor Index
- ·
BaseGrader()
- Create a new grade bar with default grade parameters and no
question.
- ·
BaseGrader(double, double, int)
- Create a new grade bar with given parameters.
- ·
BaseGrader(double, double, int, String)
- Create a new grade bar with given parameters.
- ·
BaseGrader(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 adjustable component.
- ·
d2i(double)
-
- ·
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.
- ·
getAdjustable()
-
- ·
getAdjustable(Component)
-
- ·
getAdjustableComponent()
-
- ·
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.
- ·
i2d(int)
-
- ·
init()
-
- ·
initAdjustable(Adjustable)
-
- ·
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.
- ·
pos2value(int)
- Convert an adjustable's value to a grade.
- ·
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.
- ·
setAdjustableValues()
- Update values for the adjustable component.
- ·
setAdjustableValues(int)
- Update values for the adjustable component.
- ·
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.
- ·
setMinMax(double, double)
- Set minimum and maximum of the scale.
- ·
setPreferredHeight(int)
-
- ·
setPreferredWidth(int)
-
- ·
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.
- ·
value2pos(double)
- Convert a grade to an adjustable's value.
Variables
·
bar
protected Adjustable bar
- The adjustable component.
- See Also:
- barComp
·
barComp
protected Component barComp
- The adjustable AWT Component object. This component is used
to display the adjustable component. Usually they are the
same object, but it may be different.
- See Also:
- bar
·
value
protected transient int value
- Current value of the grade. This is the value that is used as
the position in the adjustable component. This has to be
converted to the actual answer object before sending it
out.
·
minVal
protected double minVal
- Minimum value of the grade. Default is 0.0.
·
maxVal
protected double maxVal
- Maximum value of the grade. Default is 5.0.
·
decimals
protected int decimals
- Number of decimals in the grade. If zero, integer values are
returned, otherwise, doubles are returned. Default is
one decimal.
·
dec
protected int dec
- A multiplier used internally to scale floating point grades to
integers that the adjustable component uses. This is
calculated as 10^decimals.
- See Also:
- decimals
·
lab
protected Label lab
- The label that is used to display the current grade and/or the
adjective.
·
text
protected String text
- Text of the question.
·
tl
protected Label tl
- Label used to display the question text.
- See Also:
- text
·
answered
protected transient boolean answered
- Is question answered.
·
qid
protected String qid
- Question ID of this component.
·
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
- Is this component used as a question component. Default is
true.
- See Also:
- isControl
·
isControl
protected boolean isControl
- Is this component used as a control component. Default is
false.
- See Also:
- isQuestion
·
controlCommand
protected String controlCommand
- The control command name that is sent in the control event if
this component is acting as a controller.
- See Also:
- isControl
·
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
·
BaseGrader
public BaseGrader()
- Create a new grade bar with default grade parameters and no
question.
·
BaseGrader
public BaseGrader(String qtext)
- Create a new grade bar with default grade parameters.
- Parameters:
- qtext - Text of question.
·
BaseGrader
public BaseGrader(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.
·
BaseGrader
public BaseGrader(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
·
init
protected void init()
·
getAdjustableComponent
public abstract Component getAdjustableComponent()
·
getAdjustable
public Adjustable getAdjustable(Component c)
·
getAdjustable
public Adjustable getAdjustable()
·
initAdjustable
public void initAdjustable(Adjustable adj)
·
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.
·
setMinMax
protected void setMinMax(double minVal,
double maxVal)
- Set minimum and maximum of the scale.
- Parameters:
- minVal - Minimum value of scale.
- maxVal - Maximum value of scale.
·
setAdjustableValues
protected void setAdjustableValues()
- Update values for the adjustable component. This sets the
current value, minimum and maximum of the scale, and unit and
block increments for the adjustable. The current value is
taken from the value parameter.
·
setAdjustableValues
protected void setAdjustableValues(int value)
- Update values for the adjustable component. This sets the
current value, minimum and maximum of the scale, and unit and
block increments for the adjustable.
- Parameters:
- value - The current position value (position) for the
adjustable component.
·
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.
·
i2d
protected double i2d(int i)
·
d2i
protected int d2i(double d)
·
pos2value
protected double pos2value(int pos)
- Convert an adjustable's value to a grade.
- Parameters:
- pos - A value received from the adjustable component.
- Returns:
- Value converted to a grade.
·
value2pos
protected int value2pos(double value)
- Convert a grade to an adjustable's value.
- Parameters:
- value - A grade to convert to adjustable's value.
- Returns:
- The grade converted to a value that can be given to
the adjustable component.
·
paint
public void paint(Graphics g)
- Paint component. Currently just calls super's paint()
method.
- Overrides:
- paint in class Container
·
adjustmentValueChanged
public void adjustmentValueChanged(AdjustmentEvent e)
- Handle adjustment events from the adjustable component.
- 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
BaseGrader, 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
·
setPreferredWidth
protected void setPreferredWidth(int width)
·
setPreferredHeight
protected void setPreferredHeight(int height)
·
propertyLoad
public void propertyLoad(Properties p,
String name) throws IllegalArgumentException
All Packages Class Hierarchy This Package Previous Next Index