experimental dial gauge updated (unfinished)

git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@94 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
kascade 2008-06-01 04:49:10 +00:00
parent 8ad520f41b
commit e7ab308286
2 changed files with 32 additions and 15 deletions

View File

@ -18,6 +18,7 @@ import org.jfree.data.general.DefaultValueDataset;
import static org.jfree.ui.GradientPaintTransformType.VERTICAL; import static org.jfree.ui.GradientPaintTransformType.VERTICAL;
import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.ui.StandardGradientPaintTransformer;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.Color; import java.awt.Color;
import static java.awt.Color.GREEN; import static java.awt.Color.GREEN;
import static java.awt.Color.ORANGE; import static java.awt.Color.ORANGE;
@ -49,16 +50,24 @@ public final class DialGaugeStyle implements GaugeStyle {
} }
public void refreshTitle() { public void refreshTitle() {
chart.setTitle(loggerData.getName()); SwingUtilities.invokeLater(new Runnable() {
unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits()); public void run() {
chart.setTitle(loggerData.getName());
unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits());
}
});
} }
public void updateValue(double value) { public void updateValue(final double value) {
dataset.setValue(value); SwingUtilities.invokeLater(new Runnable() {
public void run() {
dataset.setValue(value);
}
});
} }
public void resetValue() { public void resetValue() {
dataset.setValue(0); updateValue(0.0);
} }
private JFreeChart buildChart(DefaultValueDataset dataset, DialTextAnnotation unitsLabel) { private JFreeChart buildChart(DefaultValueDataset dataset, DialTextAnnotation unitsLabel) {
@ -82,7 +91,7 @@ public final class DialGaugeStyle implements GaugeStyle {
DialValueIndicator dvi = new DialValueIndicator(0); DialValueIndicator dvi = new DialValueIndicator(0);
plot.addLayer(dvi); plot.addLayer(dvi);
StandardDialScale scale = new StandardDialScale(); StandardDialScale scale = new StandardDialScale(0.0, 100.0, 210.0, -240.0, 10.0, 5);
scale.setTickRadius(0.88); scale.setTickRadius(0.88);
scale.setTickLabelOffset(0.15); scale.setTickLabelOffset(0.15);
scale.setTickLabelFont(new Font("Dialog", PLAIN, 14)); scale.setTickLabelFont(new Font("Dialog", PLAIN, 14));

View File

@ -77,7 +77,11 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
} }
public void refreshTitle() { public void refreshTitle() {
title.setText(loggerData.getName() + " (" + loggerData.getSelectedConvertor().getUnits() + ')'); SwingUtilities.invokeLater(new Runnable() {
public void run() {
title.setText(loggerData.getName() + " (" + loggerData.getSelectedConvertor().getUnits() + ')');
}
});
} }
public void updateValue(double value) { public void updateValue(double value) {
@ -92,14 +96,18 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
} }
public void resetValue() { public void resetValue() {
liveValueLabel.setText(zeroText); SwingUtilities.invokeLater(new Runnable() {
max = Double.MIN_VALUE; public void run() {
maxLabel.setText(zeroText); liveValueLabel.setText(zeroText);
min = Double.MAX_VALUE; max = Double.MIN_VALUE;
minLabel.setText(zeroText); maxLabel.setText(zeroText);
progressBar.setMinimum(scaleForProgressBar(min)); min = Double.MAX_VALUE;
progressBar.setMaximum(scaleForProgressBar(max)); minLabel.setText(zeroText);
progressBar.setValue(scaleForProgressBar(min)); progressBar.setMinimum(scaleForProgressBar(min));
progressBar.setMaximum(scaleForProgressBar(max));
progressBar.setValue(scaleForProgressBar(min));
}
});
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {