]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/save/ImageExporter.java
Version 19, May 2018
[GpsPrune.git] / tim / prune / save / ImageExporter.java
index 41bc0e6d0e7f186bc884ad98b080de4b0474bef6..ea188921d8b75b4612de63cd1c9335771216d2ed 100644 (file)
@@ -36,9 +36,12 @@ import tim.prune.data.Track;
 import tim.prune.gui.BaseImageDefinitionPanel;
 import tim.prune.gui.GuiGridLayout;
 import tim.prune.gui.WholeNumberField;
+import tim.prune.gui.colour.PointColourer;
 import tim.prune.gui.map.MapSource;
 import tim.prune.gui.map.MapSourceLibrary;
 import tim.prune.gui.map.MapUtils;
+import tim.prune.gui.map.WpIconDefinition;
+import tim.prune.gui.map.WpIconLibrary;
 import tim.prune.load.GenericFileFilter;
 import tim.prune.threedee.ImageDefinition;
 
@@ -289,9 +292,11 @@ public class ImageExporter extends GenericFunction implements BaseImageConsumer
                final int zoomFactor = 1 << _baseImagePanel.getImageDefinition().getZoom();
                Graphics g = inImage.getImage().getGraphics();
                // TODO: Set line width, style etc
-               g.setColor(Config.getColourScheme().getColour(ColourScheme.IDX_POINT));
+               final PointColourer pointColourer = _app.getPointColourer();
+               final Color defaultPointColour = Config.getColourScheme().getColour(ColourScheme.IDX_POINT);
+               g.setColor(defaultPointColour);
 
-               // Loop over points
+               // Loop to draw all track points
                final Track track = _app.getTrackInfo().getTrack();
                final int numPoints = track.getNumPoints();
                int prevX = 0, prevY = 0;
@@ -300,6 +305,12 @@ public class ImageExporter extends GenericFunction implements BaseImageConsumer
                        DataPoint point = track.getPoint(i);
                        if (!point.isWaypoint())
                        {
+                               // Determine what colour to use to draw the track point
+                               if (pointColourer != null)
+                               {
+                                       Color c = pointColourer.getColour(i);
+                                       g.setColor(c == null ? defaultPointColour : c);
+                               }
                                double x = track.getX(i) - xRange.getMinimum();
                                double y = track.getY(i) - yRange.getMinimum();
                                // use zoom level to calculate pixel coords on image
@@ -318,21 +329,37 @@ public class ImageExporter extends GenericFunction implements BaseImageConsumer
                                prevX = px; prevY = py;
                        }
                }
-               // Draw waypoints
+
+               // Now the waypoints
                final Color textColour = Config.getColourScheme().getColour(ColourScheme.IDX_TEXT);
                g.setColor(textColour);
-               // Loop over points
+               WpIconDefinition wpIconDefinition = null;
+               final int wpType = Config.getConfigInt(Config.KEY_WAYPOINT_ICONS);
+               if (wpType != WpIconLibrary.WAYPT_DEFAULT)
+               {
+                       wpIconDefinition = WpIconLibrary.getIconDefinition(wpType, WpIconLibrary.SIZE_MEDIUM);
+               }
+               // Loop again to draw waypoints
                for (int i=0; i<numPoints; i++)
                {
                        DataPoint point = track.getPoint(i);
                        if (point.isWaypoint())
                        {
-                               // draw blob for each waypoint
+                               // use zoom level to calculate pixel coords on image
                                double x = track.getX(i) - xRange.getMinimum();
                                double y = track.getY(i) - yRange.getMinimum();
-                               // use zoom level to calculate pixel coords on image
                                int px = (int) (x * zoomFactor * 256), py = (int) (y * zoomFactor * 256);
+                               // Fill Rect or draw icon image?
                                g.fillRect(px-3, py-3, 6, 6);
+                               if (wpIconDefinition == null)
+                               {
+                                       g.fillRect(px-3, py-3, 6, 6);
+                               }
+                               else
+                               {
+                                       g.drawImage(wpIconDefinition.getImageIcon().getImage(), px-wpIconDefinition.getXOffset(),
+                                               py-wpIconDefinition.getYOffset(), null);
+                               }
                        }
                }
                // Set text size according to input