use of org.openstreetmap.gui.jmapviewer.Coordinate in project Course_Generator by patrovite.
the class JPanelMaps method RefreshTrack.
/**
* Display track stored in a TrackData class
*
* @param tdata
* TrackData object to display
* @param zoom2fit
* If true the zoom is set have the complete display of the track
*/
public void RefreshTrack(TrackData tdata, boolean zoom2fit) {
if (tdata == null)
return;
// Enabling the map tools
btMapAddMarker.setEnabled(true);
btMapMark.setEnabled(true);
btMapEat.setEnabled(true);
btMapDrink.setEnabled(true);
// -- Remove the previous track
MapViewer.removeAllMapPolygons();
MapViewer.removeAllMapMarkers();
MapMarker = null;
CurrentPosMarker = null;
// -- Create the route
List<Coordinate> route1 = new ArrayList<Coordinate>();
double last_diff = tdata.data.get(0).getDiff();
for (CgData r : tdata.data) {
if (r.getDiff() == last_diff) {
route1.add(new Coordinate(r.getLatitude(), r.getLongitude()));
} else {
route1.add(new Coordinate(r.getLatitude(), r.getLongitude()));
MapPolyLine polyLine1 = new MapPolyLine(route1);
// -- Set the line color
if (last_diff == 100.0)
polyLine1.setColor(CgConst.CL_MAP_DIFF_VERYEASY);
else if (last_diff >= 98.0)
polyLine1.setColor(CgConst.CL_MAP_DIFF_EASY);
else if (last_diff >= 95.0)
polyLine1.setColor(CgConst.CL_MAP_DIFF_AVERAGE);
else if (last_diff >= 88)
polyLine1.setColor(CgConst.CL_MAP_DIFF_HARD);
else
polyLine1.setColor(CgConst.CL_MAP_DIFF_VERYHARD);
// -- Track width
polyLine1.setStroke(new BasicStroke(CgConst.TRACK_TICKNESS));
// -- Upddate the viewer
MapViewer.addMapPolygon(polyLine1);
route1 = new ArrayList<Coordinate>();
route1.add(new Coordinate(r.getLatitude(), r.getLongitude()));
}
last_diff = r.getDiff();
}
// -- Add the last polyline
MapPolyLine polyLine1 = new MapPolyLine(route1);
// -- Set the line color
if (last_diff >= 98.0)
polyLine1.setColor(Color.GREEN);
else if (last_diff >= 95.0)
polyLine1.setColor(Color.BLUE);
else if (last_diff >= 88)
polyLine1.setColor(Color.RED);
else
polyLine1.setColor(Color.BLACK);
// -- Set the stroke
polyLine1.setStroke(new BasicStroke(3));
// -- Upddate the viewer
MapViewer.addMapPolygon(polyLine1);
// -- Zoom to display the track
if (zoom2fit)
MapViewer.setDisplayToFitMapPolygons();
for (CgData r : tdata.data) {
int t = r.getTag();
int v = 0;
if ((t & CgConst.TAG_MARK) != 0)
v = v + 1;
if ((t & CgConst.TAG_EAT_PT) != 0)
v = v + 2;
if ((t & CgConst.TAG_WATER_PT) != 0)
v = v + 4;
if (v != 0)
MapViewer.addMapMarker(new MapMarkerImg(new Coordinate(r.getLatitude(), r.getLongitude()), createImageIcon("/course_generator/images/markers_" + v + ".png", "").getImage()));
}
}
use of org.openstreetmap.gui.jmapviewer.Coordinate in project Course_Generator by patrovite.
the class JPanelMaps method MapViewerMouseClicked.
private void MapViewerMouseClicked(java.awt.event.MouseEvent evt) {
if (Track == null)
return;
if (Track.data == null)
return;
if (Track.data.size() <= 0)
return;
selectedPosition = MapViewer.getPosition(evt.getX(), evt.getY());
notifyMouseClicked(evt);
// Find the nearest point
Coordinate c = MapViewer.getPosition(evt.getX(), evt.getY());
// int i = Track.FindNearestPoint(c.getLat(), c.getLon());
// //Selection the position on the data grid
// panelTrackData.setSelectedRow(i);
//
// //Refresh profil position
// panelProfil.RefreshProfilInfo(i);
// panelProfil.setCrosshairPosition(Track.data.get(i).getTotal(Settings.Unit) / 1000.0, Track.data.get(i).getElevation(Settings.Unit));
// Refresh position marker on the map
int i = Track.FindNearestPoint(c.getLat(), c.getLon());
RefreshCurrentPosMarker(Track.data.get(i).getLatitude(), Track.data.get(i).getLongitude());
}
Aggregations