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 org.jfree.ui.StandardGradientPaintTransformer;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.Color;
import static java.awt.Color.GREEN;
import static java.awt.Color.ORANGE;
@ -49,16 +50,24 @@ public final class DialGaugeStyle implements GaugeStyle {
}
public void refreshTitle() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
chart.setTitle(loggerData.getName());
unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits());
}
});
}
public void updateValue(double value) {
public void updateValue(final double value) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
dataset.setValue(value);
}
});
}
public void resetValue() {
dataset.setValue(0);
updateValue(0.0);
}
private JFreeChart buildChart(DefaultValueDataset dataset, DialTextAnnotation unitsLabel) {
@ -82,7 +91,7 @@ public final class DialGaugeStyle implements GaugeStyle {
DialValueIndicator dvi = new DialValueIndicator(0);
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.setTickLabelOffset(0.15);
scale.setTickLabelFont(new Font("Dialog", PLAIN, 14));

View File

@ -77,8 +77,12 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
}
public void refreshTitle() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
title.setText(loggerData.getName() + " (" + loggerData.getSelectedConvertor().getUnits() + ')');
}
});
}
public void updateValue(double value) {
refreshValue(value);
@ -92,6 +96,8 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
}
public void resetValue() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
liveValueLabel.setText(zeroText);
max = Double.MIN_VALUE;
maxLabel.setText(zeroText);
@ -101,6 +107,8 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
progressBar.setMaximum(scaleForProgressBar(max));
progressBar.setValue(scaleForProgressBar(min));
}
});
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == warnCheckBox) {