auto-sync

This commit is contained in:
rusEfi 2014-11-15 14:03:43 -06:00
parent c64a27e5bd
commit ca07547e76
5 changed files with 29 additions and 13 deletions

View File

@ -2,12 +2,12 @@ package com.rusefi;
import com.irnems.FileLog;
import com.irnems.core.EngineState;
import com.rusefi.io.LinkManager;
import com.rusefi.ui.RpmModel;
import com.rusefi.ui.UiUtils;
import com.rusefi.ui.WavePanel;
import com.rusefi.ui.widgets.URLLabel;
import com.rusefi.ui.widgets.UpDownImage;
import com.rusefi.io.LinkManager;
import javax.swing.*;
import java.awt.*;
@ -52,7 +52,7 @@ public class AnalogChartPanel extends JPanel {
}
);
JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
final JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
JButton imageButton = new JButton(WavePanel.SAVE_IMAGE);
imageButton.setMnemonic('s');
@ -64,7 +64,8 @@ public class AnalogChartPanel extends JPanel {
public void actionPerformed(ActionEvent e) {
int rpm = RpmModel.getInstance().getValue();
String fileName = FileLog.getDate() + "rpm_" + rpm + "_analog" + ".png";
UiUtils.saveImage(fileName, analogChart);
UiUtils.saveImageWithPrompt(fileName, upperPanel, analogChart);
}
}
);
@ -142,4 +143,4 @@ public class AnalogChartPanel extends JPanel {
values.put(Double.parseDouble(key), Double.parseDouble(value));
}
}
}
}

View File

@ -14,7 +14,7 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.rusefi.io.tcp.TcpConnector.*;
import static com.rusefi.io.tcp.TcpConnector.parseIntWithReason;
/**
* Date: 1/22/13
@ -25,7 +25,7 @@ public class ChartHelper {
}
public static JPanel create3DControl(final XYData data, SurfaceModel surfaceModel, String title) {
JPanel result = new JPanel(new BorderLayout());
final JPanel result = new JPanel(new BorderLayout());
result.setBorder(BorderFactory.createLineBorder(Color.red));
final JSurfacePanel jsp = new JSurfacePanel(surfaceModel);
@ -40,7 +40,9 @@ public class ChartHelper {
saveImageButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UiUtils.saveImage(FileLog.getDate() + "_3d.png", jsp);
String fileName = FileLog.getDate() + "_3d.png";
UiUtils.saveImageWithPrompt(fileName, result, jsp);
}
});

View File

@ -2,6 +2,8 @@ package com.rusefi.ui;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
@ -12,6 +14,18 @@ import java.io.IOException;
* (c) Andrey Belomutskiy
*/
public class UiUtils {
public static void saveImageWithPrompt(String fileName, Component parent, Component component) {
JFileChooser fc = new JFileChooser();
FileFilter filter = new FileNameExtensionFilter("PNG files", "png");
fc.setFileFilter(filter);
fc.addChoosableFileFilter(filter);
fc.setSelectedFile(new File(fileName));
if (fc.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {
fileName = fc.getSelectedFile().getAbsolutePath();
UiUtils.saveImage(fileName, component);
}
}
public static void saveImage(String fileName, Component component) {
BufferedImage img = getScreenShot(component);
try {

View File

@ -249,7 +249,8 @@ public class WavePanel {
int rpm = RpmModel.getInstance().getValue();
double maf = SensorCentral.getInstance().getValue(Sensor.MAF);
String fileName = FileLog.getDate() + "rpm_" + rpm + "_maf_" + maf + ".png";
UiUtils.saveImage(fileName, imagePanel);
UiUtils.saveImageWithPrompt(fileName, panel, imagePanel);
}
private UpDownImage createImage(String name) {

View File

@ -71,16 +71,14 @@ public class SensorGauge {
private static void showPopupMenu(MouseEvent e, JPanel wrapper, GaugeChangeListener listener) {
JPopupMenu pm = new JPopupMenu();
JMenu gauges = new JMenu("Gauges...");
fillGaugeItems(gauges, wrapper, listener);
pm.add(gauges);
fillGaugeItems(pm, wrapper, listener);
pm.show(e.getComponent(), e.getX(), e.getY());
}
private static void fillGaugeItems(JMenu gauges, final JPanel wrapper, final GaugeChangeListener listener) {
private static void fillGaugeItems(JPopupMenu popupMenu, final JPanel wrapper, final GaugeChangeListener listener) {
for (final SensorCategory sc : SensorCategory.values()) {
JMenuItem cmi = new JMenu(sc.getName());
gauges.add(cmi);
popupMenu.add(cmi);
for (final Sensor s : Sensor.getSensorsForCategory(sc.getName())) {
JMenuItem mi = new JMenuItem(s.getName());