*
* @return JSlider
*/
private JSlider getTpsSlider() {
if (tpsSlider == null) {
final ISettingsManager props = properties;
int tps = Math.max(props.getOptionsBattleDesiredTPS(), 1);
tpsSlider = new JSlider(0, MAX_TPS_SLIDER_VALUE, tpsToSliderValue(tps));
tpsSlider.setPaintLabels(true);
tpsSlider.setPaintTicks(true);
tpsSlider.setMinorTickSpacing(1);
tpsSlider.addChangeListener(eventHandler);
Dictionary<Integer, JLabel> labels = new Hashtable<Integer, JLabel>();
labels.put(0, new JLabel("0"));
labels.put(5, new JLabel("5"));
labels.put(10, new JLabel("10"));
labels.put(15, new JLabel("15"));
labels.put(20, new JLabel("20"));
labels.put(25, new JLabel("25"));
labels.put(30, new JLabel("30"));
labels.put(35, new JLabel("40"));
labels.put(40, new JLabel("50"));
labels.put(45, new JLabel("65"));
labels.put(50, new JLabel("90"));
labels.put(55, new JLabel("150"));
labels.put(60, new JLabel("1000"));
tpsSlider.setMajorTickSpacing(5);
tpsSlider.setLabelTable(labels);
WindowUtil.setFixedSize(tpsSlider, new Dimension((MAX_TPS_SLIDER_VALUE + 1) * 6, 40));
props.addPropertyListener(new ISettingsListener() {
public void settingChanged(String property) {
if (property.equals(ISettingsManager.OPTIONS_BATTLE_DESIREDTPS)) {
setTpsOnSlider(props.getOptionsBattleDesiredTPS());
}
}
});
}
return tpsSlider;