]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/gui/profile/ProfileChart.java
Version 18.5, July 2016
[GpsPrune.git] / tim / prune / gui / profile / ProfileChart.java
index 732669a956dcd48bf719848e5223b2b77bf989fe..6e219967ad60748f460b416dc0539e3725cb4e52 100644 (file)
@@ -4,10 +4,13 @@ import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
+
 import javax.swing.JLabel;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
@@ -86,6 +89,9 @@ public class ProfileChart extends GenericDisplay implements MouseListener
        public void paint(Graphics g)
        {
                super.paint(g);
+               // Set antialiasing depending on Config
+               ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                       Config.getConfigBoolean(Config.KEY_ANTIALIAS) ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
                ColourScheme colourScheme = Config.getColourScheme();
                paintBackground(g, colourScheme);
                if (_track != null && _track.getNumPoints() > 0)
@@ -130,8 +136,7 @@ public class ProfileChart extends GenericDisplay implements MouseListener
 
                        // horizontal lines for scale - set to round numbers eg 500
                        int lineScale = getLineScale(minValue, maxValue);
-                       int scaleValue = (int) (minValue/lineScale + 1) * lineScale;
-                       if (minValue < 0.0) {scaleValue -= lineScale;}
+                       double scaleValue = Math.ceil(minValue/lineScale) * lineScale;
                        int x = 0, y = 0;
                        final int zeroY = height - BORDER_WIDTH - (int) (yScaleFactor * (0.0 - minValue));
 
@@ -217,7 +222,7 @@ public class ProfileChart extends GenericDisplay implements MouseListener
                                        if (y < (BORDER_WIDTH + textHeight)) {
                                                y = BORDER_WIDTH + textHeight;
                                        }
-                                       g.drawString(""+scaleValue, BORDER_WIDTH + 5, y);
+                                       g.drawString(""+(int)scaleValue, BORDER_WIDTH + 5, y);
                                        scaleValue += lineScale;
                                }
                        }
@@ -259,7 +264,7 @@ public class ProfileChart extends GenericDisplay implements MouseListener
        /**
         * Make the popup menu for right-clicking the chart
         */
-       private void makePopup()
+       private synchronized void makePopup()
        {
                _popup = new JPopupMenu();
                JMenuItem altItem = new JMenuItem(I18nManager.getText("fieldname.altitude"));