|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.sahits.game.graphic.layout.AbstractSahitsComponent
ch.sahits.game.graphic.layout.AbstractMultiselectableComponent<String>
ch.sahits.game.graphic.layout.Slider
public class Slider
A slider component. The slider has either all labels painted or just the active
| Field Summary | |
|---|---|
private IIndexChangeListener |
changeListener
|
private Polygon |
handle
|
private FontMetrics |
metric
|
private boolean |
paintLabels
|
| Fields inherited from class ch.sahits.game.graphic.layout.AbstractMultiselectableComponent |
|---|
selectables |
| Fields inherited from class ch.sahits.game.graphic.layout.AbstractSahitsComponent |
|---|
painter |
| Constructor Summary | |
|---|---|
Slider(FontMetrics fm)
|
|
| Method Summary | |
|---|---|
void |
addChangeListeners(IIndexChangeListener listener)
|
private int |
angleToIndex(double angle)
Compute the closest index from an angle |
private float |
castIntoRange(int index)
compute the angle for an index |
private float |
castValue()
Cast the selected index into a percentage |
private float |
castValue(double val)
Cast the value into a persentage |
Dimension |
getPreferredSize()
Retrieve the preferred size of the component. |
void |
paint(Graphics g)
Draw the component with the appropriate graphic context. |
private void |
paintCurrentLabel(Graphics g,
int value)
Paint the label of the closest labeled value over the handle. |
private void |
paintHorizontalLabel(Graphics g,
int value)
Paint the label over the center of the tracker handle (commonly known as thumb) |
private void |
paintLabelAt(Graphics g,
Label label,
Rectangle rect)
Paint a label a specific position |
private boolean |
paintLabels()
Check if the labels are to be painted |
private void |
paintLabels(Graphics g)
Print all the labels |
void |
setBounds(int x,
int y,
int width,
int height)
Define the measurements of the component |
void |
setPaintLabels(boolean paintLabels)
Set the flag to paint the label |
void |
setSelected(int index)
set the selected index to specified value. |
void |
testClick(MouseEvent e)
|
void |
testClick(Point p)
Test if there was a mouse click on the component |
private double |
valueForXPosition(int x)
|
| Methods inherited from class ch.sahits.game.graphic.layout.AbstractMultiselectableComponent |
|---|
add, decSelection, gameRender, gameUpdate, getFont, getItem, getItemCount, getSelected, getSelectedIndex, incSelection, setFont, testKeyPress |
| Methods inherited from class ch.sahits.game.graphic.layout.AbstractSahitsComponent |
|---|
createVisualBounds, getBounds, getInsets, setInsets |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface ch.sahits.game.graphic.display.IUpdatableComponent |
|---|
gameRender, gameUpdate, testKeyPress |
| Field Detail |
|---|
private final FontMetrics metric
private boolean paintLabels
private Polygon handle
private IIndexChangeListener changeListener
| Constructor Detail |
|---|
public Slider(FontMetrics fm)
| Method Detail |
|---|
public void testClick(MouseEvent e)
public void testClick(Point p)
IUpdatableComponent
testClick in interface IUpdatableComponentprivate double valueForXPosition(int x)
private float castValue()
private float castValue(double val)
val -
private float castIntoRange(int index)
index -
private int angleToIndex(double angle)
angle -
public void paint(Graphics g)
ISahitsComponent
paint in interface ISahitsComponentpublic Dimension getPreferredSize()
ISahitsComponent
getPreferredSize in interface ISahitsComponentprivate boolean paintLabels()
public void setPaintLabels(boolean paintLabels)
paintLabels -
private void paintCurrentLabel(Graphics g,
int value)
g - value -
private void paintLabelAt(Graphics g,
Label label,
Rectangle rect)
g - label - rect -
private void paintHorizontalLabel(Graphics g,
int value)
private void paintLabels(Graphics g)
g - public void setSelected(int index)
setSelected in class AbstractMultiselectableComponent<String>
public void setBounds(int x,
int y,
int width,
int height)
ISahitsComponent
setBounds in interface ISahitsComponentsetBounds in class AbstractSahitsComponentx - position along the x axisy - position along the y axiswidth - of the componentheight - of the componentpublic void addChangeListeners(IIndexChangeListener listener)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||