X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2Fcharts%2FCharter.java;h=ef3cc955f61f260f6ce3ed724424631d6a2c7a53;hb=a6197ddcaac11c0b943183da7d46169742d024af;hp=a3348c8ce0e35e8da11c4aa39062b9b18abdab28;hpb=54b9d8bc8f0025ccf97a67d9dd217ef1f9cf082f;p=GpsPrune.git diff --git a/tim/prune/function/charts/Charter.java b/tim/prune/function/charts/Charter.java index a3348c8..ef3cc95 100644 --- a/tim/prune/function/charts/Charter.java +++ b/tim/prune/function/charts/Charter.java @@ -25,17 +25,17 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; import tim.prune.App; -import tim.prune.Config; import tim.prune.ExternalTools; import tim.prune.GenericFunction; import tim.prune.I18nManager; -import tim.prune.data.Altitude; +import tim.prune.config.Config; import tim.prune.data.DataPoint; import tim.prune.data.Distance; import tim.prune.data.Field; import tim.prune.data.Timestamp; import tim.prune.data.Track; -import tim.prune.data.Distance.Units; +import tim.prune.gui.profile.SpeedData; +import tim.prune.gui.profile.VerticalSpeedData; import tim.prune.load.GenericFileFilter; /** @@ -87,6 +87,12 @@ public class Charter extends GenericFunction */ public void begin() { + // First check if gnuplot is available + if (!ExternalTools.isToolInstalled(ExternalTools.TOOL_GNUPLOT)) + { + _app.showErrorMessage(getNameKey(), "dialog.charts.gnuplotnotfound"); + return; + } // Make dialog window if (_dialog == null) { @@ -183,14 +189,15 @@ public class Charter extends GenericFunction // button panel on bottom JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); - // Gnuplot button - JButton gnuplotButton = new JButton(I18nManager.getText("button.gnuplotpath")); - gnuplotButton.addActionListener(new ActionListener() { + // ok button + JButton okButton = new JButton(I18nManager.getText("button.ok")); + okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - setGnuplotPath(); + showChart(_app.getTrackInfo().getTrack()); + _dialog.setVisible(false); } }); - buttonPanel.add(gnuplotButton); + buttonPanel.add(okButton); // Cancel button JButton cancelButton = new JButton(I18nManager.getText("button.cancel")); cancelButton.addActionListener(new ActionListener() { @@ -199,15 +206,6 @@ public class Charter extends GenericFunction } }); buttonPanel.add(cancelButton); - // ok button - JButton okButton = new JButton(I18nManager.getText("button.ok")); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - showChart(_app.getTrackInfo().getTrack()); - _dialog.setVisible(false); - } - }); - buttonPanel.add(okButton); dialogPanel.add(buttonPanel, BorderLayout.SOUTH); return dialogPanel; } @@ -221,7 +219,7 @@ public class Charter extends GenericFunction private boolean setupDialog(Track inTrack) { boolean hasTimes = inTrack.hasData(Field.TIMESTAMP); - boolean hasAltitudes = inTrack.getAltitudeRange().hasRange(); + boolean hasAltitudes = inTrack.hasAltitudeData(); _timeRadio.setEnabled(hasTimes); // Add checks to prevent choosing unavailable combinations @@ -277,7 +275,8 @@ public class Charter extends GenericFunction OutputStreamWriter writer = null; try { - Process process = Runtime.getRuntime().exec(Config.getGnuplotPath() + " -persist"); + final String gnuplotPath = Config.getConfigString(Config.KEY_GNUPLOT_PATH); + Process process = Runtime.getRuntime().exec(gnuplotPath + " -persist"); writer = new OutputStreamWriter(process.getOutputStream()); if (showSvg) { @@ -285,6 +284,9 @@ public class Charter extends GenericFunction + getSvgValue(_svgHeightField, DEFAULT_SVG_HEIGHT) + "\n"); writer.write("set out '" + svgFile.getAbsolutePath() + "'\n"); } + else { + // For screen output, gnuplot should use the default terminal (windows or x11 or wxt or something) + } if (numCharts > 1) { writer.write("set multiplot layout " + numCharts + ",1\n"); } @@ -375,13 +377,13 @@ public class Charter extends GenericFunction break; } // Make a temporary data file for the output (one per subchart) - File tempFile = File.createTempFile("prunedata", null); + File tempFile = File.createTempFile("gpsprunedata", null); tempFile.deleteOnExit(); // write out values for x and y to temporary file FileWriter tempFileWriter = null; try { tempFileWriter = new FileWriter(tempFile); - tempFileWriter.write("# Temporary data file for Prune charts\n\n"); + tempFileWriter.write("# Temporary data file for GpsPrune charts\n\n"); for (int i=0; i