mirror of https://github.com/rusefi/RomRaider.git
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:
parent
8ad520f41b
commit
e7ab308286
|
@ -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() {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
chart.setTitle(loggerData.getName());
|
chart.setTitle(loggerData.getName());
|
||||||
unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits());
|
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);
|
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));
|
||||||
|
|
|
@ -77,8 +77,12 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshTitle() {
|
public void refreshTitle() {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
title.setText(loggerData.getName() + " (" + loggerData.getSelectedConvertor().getUnits() + ')');
|
title.setText(loggerData.getName() + " (" + loggerData.getSelectedConvertor().getUnits() + ')');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void updateValue(double value) {
|
public void updateValue(double value) {
|
||||||
refreshValue(value);
|
refreshValue(value);
|
||||||
|
@ -92,6 +96,8 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetValue() {
|
public void resetValue() {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
liveValueLabel.setText(zeroText);
|
liveValueLabel.setText(zeroText);
|
||||||
max = Double.MIN_VALUE;
|
max = Double.MIN_VALUE;
|
||||||
maxLabel.setText(zeroText);
|
maxLabel.setText(zeroText);
|
||||||
|
@ -101,6 +107,8 @@ public class PlainGaugeStyle implements GaugeStyle, ActionListener {
|
||||||
progressBar.setMaximum(scaleForProgressBar(max));
|
progressBar.setMaximum(scaleForProgressBar(max));
|
||||||
progressBar.setValue(scaleForProgressBar(min));
|
progressBar.setValue(scaleForProgressBar(min));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (e.getSource() == warnCheckBox) {
|
if (e.getSource() == warnCheckBox) {
|
||||||
|
|
Loading…
Reference in New Issue