Updated French translations
[debian/openrocket] / src / net / sf / openrocket / gui / plot / PlotDialog.java
index 77d5338e35f585207e20f6965924145ccb1deaee..da775482d640041a26a4c37e546c4a206497d89d 100644 (file)
@@ -27,13 +27,17 @@ import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JDialog;
+import javax.swing.JLabel;
 import javax.swing.JPanel;
 
 import net.miginfocom.swing.MigLayout;
 import net.sf.openrocket.document.Simulation;
+import net.sf.openrocket.gui.components.StyledLabel;
+import net.sf.openrocket.l10n.Translator;
 import net.sf.openrocket.simulation.FlightDataBranch;
 import net.sf.openrocket.simulation.FlightDataType;
 import net.sf.openrocket.simulation.FlightEvent;
+import net.sf.openrocket.startup.Application;
 import net.sf.openrocket.unit.Unit;
 import net.sf.openrocket.unit.UnitGroup;
 import net.sf.openrocket.util.BugException;
@@ -64,6 +68,7 @@ import org.jfree.ui.TextAnchor;
 public class PlotDialog extends JDialog {
        
        private static final float PLOT_STROKE_WIDTH = 1.5f;
+       private static final Translator trans = Application.getTranslator();
        
        private static final Color DEFAULT_EVENT_COLOR = new Color(0, 0, 0);
        private static final Map<FlightEvent.Type, Color> EVENT_COLORS =
@@ -124,7 +129,8 @@ public class PlotDialog extends JDialog {
                        new ArrayList<ModifiedXYItemRenderer>();
        
        private PlotDialog(Window parent, Simulation simulation, PlotConfiguration config) {
-               super(parent, "Flight data plot");
+               //// Flight data plot
+               super(parent, trans.get("PlotDialog.title.Flightdataplot"));
                this.setModalityType(ModalityType.DOCUMENT_MODAL);
                
                final boolean initialShowPoints = Prefs.getBoolean(Prefs.PLOT_SHOW_POINTS, false);
@@ -193,7 +199,8 @@ public class PlotDialog extends JDialog {
 
                // Create the chart using the factory to get all default settings
                JFreeChart chart = ChartFactory.createXYLineChart(
-                               "Simulated flight",
+                               //// Simulated flight
+                               trans.get("PlotDialog.Chart.Simulatedflight"),
                                null,
                                null,
                                null,
@@ -342,13 +349,12 @@ public class PlotDialog extends JDialog {
                                        tindex = 0;
                                        a = 0;
                                } else {
-                                       assert (tindex > 0);
                                        tindex--;
                                        double t1 = time.get(tindex);
                                        double t2 = time.get(tindex + 1);
                                        
                                        if ((t1 > t) || (t2 < t)) {
-                                               throw new BugException("BUG: t1=" + t1 + " t2=" + t2 + " t=" + t);
+                                               throw new BugException("t1=" + t1 + " t2=" + t2 + " t=" + t);
                                        }
                                        
                                        if (MathUtil.equals(t1, t2)) {
@@ -358,7 +364,7 @@ public class PlotDialog extends JDialog {
                                        }
                                }
                                
-                               final double xcoord;
+                               double xcoord;
                                if (a == 0) {
                                        xcoord = domain.get(tindex);
                                } else {
@@ -369,15 +375,25 @@ public class PlotDialog extends JDialog {
                                        FlightDataType type = config.getType(index);
                                        List<Double> range = branch.get(type);
                                        
-                                       final double ycoord;
+                                       // Image annotations are not supported on the right-side axis
+                                       // TODO: LOW: Can this be achieved by JFreeChart?
+                                       if (filled.getAxis(index) != SimulationPlotPanel.LEFT) {
+                                               continue;
+                                       }
+                                       
+                                       double ycoord;
                                        if (a == 0) {
                                                ycoord = range.get(tindex);
                                        } else {
                                                ycoord = a * range.get(tindex) + (1 - a) * range.get(tindex + 1);
                                        }
                                        
+                                       // Convert units
+                                       xcoord = config.getDomainAxisUnit().toUnit(xcoord);
+                                       ycoord = config.getUnit(index).toUnit(ycoord);
+                                       
                                        XYImageAnnotation annotation =
-                                                       new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
+                                                               new XYImageAnnotation(xcoord, ycoord, image, RectangleAnchor.CENTER);
                                        annotation.setToolTipText(event);
                                        plot.addAnnotation(annotation);
                                }
@@ -404,7 +420,8 @@ public class PlotDialog extends JDialog {
                
                panel.add(chartPanel, "grow, wrap 20lp");
                
-               final JCheckBox check = new JCheckBox("Show data points");
+               //// Show data points
+               final JCheckBox check = new JCheckBox(trans.get("PlotDialog.CheckBox.Showdatapoints"));
                check.setSelected(initialShowPoints);
                check.addActionListener(new ActionListener() {
                        @Override
@@ -418,9 +435,15 @@ public class PlotDialog extends JDialog {
                });
                panel.add(check, "split, left");
                
+
+               JLabel label = new StyledLabel(trans.get("PlotDialog.lbl.Chart"), -2);
+               panel.add(label, "gapleft para");
+               
+
                panel.add(new JPanel(), "growx");
                
-               JButton button = new JButton("Close");
+               //// Close button
+               JButton button = new JButton(trans.get("dlg.but.close"));
                button.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
@@ -435,7 +458,6 @@ public class PlotDialog extends JDialog {
                GUIUtil.setDisposableDialogOptions(this, button);
        }
        
-       
        private String getLabel(FlightDataType type, Unit unit) {
                String name = type.getName();
                if (unit != null && !UnitGroup.UNITS_NONE.contains(unit) &&