use of course_generator.CgData in project Course_Generator by patrovite.
the class JPanelProfil method RefreshProfilInfo.
/**
* Refresh the fields in the profil info panel
*
* @param index
* Index of the line in the track data list
*/
public void RefreshProfilInfo(int index) {
if (track == null)
return;
if ((index < 0) || (index >= track.data.size()))
return;
// -- Get the data
CgData d = track.data.get(index);
lbProfilDistance.setText(" " + bundle.getString("frmMain.lbProfilDistance.text") + "= " + d.getTotalString(settings.Unit, true) + " ");
lbProfilTime.setText(" " + bundle.getString("frmMain.lbProfilTime.text") + "= " + d.getTimeString() + " ");
lbProfilSlope.setText(" " + bundle.getString("frmMain.lbProfilSlope.text") + "= " + d.getSlopeString(true) + " ");
lbProfilName.setText(" " + bundle.getString("frmMain.lbProfilName.text") + "= " + d.getName() + " ");
lbProfilElevation.setText(" " + bundle.getString("frmMain.lbProfilElevation.text") + "= " + d.getElevationString(settings.Unit, true) + " ");
lbProfilHour.setText(" " + bundle.getString("frmMain.lbProfilHour.text") + "= " + d.getHourString() + " ");
lbProfilSpeed.setText(" " + bundle.getString("frmMain.lbProfilSpeed.text") + "= " + d.getSpeedString(settings.Unit, true) + " ");
lbProfilComment.setText(" " + bundle.getString("frmMain.lbProfilComment.text") + "= " + d.getComment() + " ");
}
use of course_generator.CgData in project Course_Generator by patrovite.
the class JPanelProfil method RefreshProfilChart.
/**
* Update the profil chart
*/
public void RefreshProfilChart() {
if (track == null)
return;
if (track.data.isEmpty())
return;
// -- Clear all series
if (datasetProfil.getSeriesCount() > 0)
datasetProfil.removeAllSeries();
XYPlot plot = chartProfil.getXYPlot();
plot.clearDomainMarkers();
// -- Populate the serie
XYSeries serie1 = new XYSeries("Elevation/Distance");
int cmpt = 1;
for (CgData r : track.data) {
double x = r.getTotal(settings.Unit) / 1000;
double y = r.getElevation(settings.Unit);
serie1.add(x, y);
if (((r.getTag() & CgConst.TAG_MARK) != 0) & showProfilMarker) {
Marker m = new ValueMarker(x);
m.setPaint(Color.GRAY);
m.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
m.setLabel(String.valueOf(cmpt));
m.setLabelOffset(new RectangleInsets(5, 0, 0, 2));
m.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
m.setLabelTextAnchor(TextAnchor.TOP_LEFT);
plot.addDomainMarker(m);
cmpt++;
}
}
datasetProfil.addSeries(serie1);
if (track.getMaxElev(settings.Unit) > track.getMinElev(settings.Unit)) {
// XYPlot plot = chart.getXYPlot();
ValueAxis axisY = plot.getRangeAxis();
axisY.setRange(Math.floor(track.getMinElev(settings.Unit) / 100.0) * 100.0, Math.ceil(track.getMaxElev(settings.Unit) / 100.0) * 100.0);
}
}
use of course_generator.CgData in project Course_Generator by patrovite.
the class PanelProfilMRB method DrawRoadPathProfile.
/**
* Draw the road/path type profile
*
* @param g2d
* Graphic context
* @param xmin
* Minimum x axis value
* @param ymin
* Minimum y axis value
* @param resx
* x axis resolution
* @param resy
* y axis resolution
* @param TabY
* Array of y value for each x pixel
*/
private void DrawRoadPathProfile(Graphics2D g2d, Double xmin, Double ymin, double resx, double resy, int[] TabY) {
int cmpt = 0;
boolean first = true;
int[] xCurvePts = { 0, 0, 0, 0 };
int[] yCurvePts = { 0, 0, 0, 0 };
CalcLineResult res = new CalcLineResult();
CgData oldr = new CgData();
oldr.setElevation(track.data.get(0).getElevation(CgConst.UNIT_METER));
oldr.setTotal(track.data.get(0).getTotal(CgConst.UNIT_METER));
// path
for (CgData r : track.data) {
// Point on botton left (old point)
xCurvePts[0] = (int) Math.round((offx + 1 + ((oldr.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[0] = height - offy;
// Point on top left (old point)
xCurvePts[1] = (int) Math.round((offx + 1 + ((oldr.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[1] = (int) (height - offy - ((oldr.getElevation(settings.Unit) - ymin) * resy));
// Point on top right (new point)
xCurvePts[2] = (int) Math.round((offx + 1 + ((r.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[2] = (int) (height - offy - ((r.getElevation(settings.Unit) - ymin) * resy));
// Point on bottom right (new point)
xCurvePts[3] = (int) Math.round((offx + 1 + ((r.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[3] = height - offy;
g2d.setColor(track.clProfil_RS_Path);
if (r.getDiff() == 100)
cmpt++;
if (// Filtre
(xCurvePts[2] - xCurvePts[0]) > track.CurveFilter) {
if (cmpt > 0)
g2d.setColor(track.clProfil_RS_Road);
g2d.fillPolygon(xCurvePts, yCurvePts, 4);
res = Utils.CalcLine(xCurvePts[1], yCurvePts[1], xCurvePts[2], yCurvePts[2], res);
for (int tf = xCurvePts[1]; tf < xCurvePts[2]; tf++) {
TabY[(int) tf] = (int) (res.a * tf + res.b);
// First pass. Allow to draw the first line
if ((first) && (tf > 0)) {
TabY[(int) tf - 1] = TabY[(int) tf];
first = false;
}
}
oldr.setElevation(r.getElevation(CgConst.UNIT_METER));
oldr.setTotal(r.getTotal(CgConst.UNIT_METER));
cmpt = 0;
}
}
// for
// -- Draw the line on the profile
oldr.setElevation(track.data.get(0).getElevation(CgConst.UNIT_METER));
oldr.setTotal(track.data.get(0).getTotal(CgConst.UNIT_METER));
for (CgData r : track.data) {
// Point on bottom left (old point)
xCurvePts[0] = (int) Math.round((offx + 1 + ((oldr.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[0] = height - offy;
// Point on top left (old point)
xCurvePts[1] = (int) Math.round((offx + 1 + ((oldr.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[1] = (int) (height - offy - ((oldr.getElevation(settings.Unit) - ymin) * resy));
// Point on top right (new point)
xCurvePts[2] = (int) Math.round((offx + 1 + ((r.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[2] = (int) (height - offy - ((r.getElevation(settings.Unit) - ymin) * resy));
// Point on bottom right (new point)
xCurvePts[3] = (int) Math.round((offx + 1 + ((r.getTotal(settings.Unit) - xmin) * resx)));
yCurvePts[3] = height - offy;
g2d.setColor(track.clProfil_RS_Path);
g2d.setColor(track.clProfil_RS_Border);
g2d.setStroke(PenRP_Border);
if (// Filtre
(xCurvePts[2] - xCurvePts[0]) > track.CurveFilter) {
g2d.drawLine(xCurvePts[1], yCurvePts[1], xCurvePts[2], yCurvePts[2]);
oldr.setElevation(r.getElevation(CgConst.UNIT_METER));
oldr.setTotal(r.getTotal(CgConst.UNIT_METER));
}
}
// for
// Last point
g2d.fillPolygon(xCurvePts, yCurvePts, 4);
g2d.drawLine(xCurvePts[1], yCurvePts[1], xCurvePts[2], yCurvePts[2]);
}
use of course_generator.CgData in project Course_Generator by patrovite.
the class FrmMiniroadbook method showDialog.
/**
* Show the dialog
*
* @param settings
* Object containing the settings
* @param track
* Object containing the track
* @param start_line
* Line number where to start
* @param end_line
* Line number where to end
* @return Object containing the result
*/
public boolean showDialog(TrackData track) {
this.track = track;
DupLine = -1;
// -- Set the content of the model
// We add here the roadbook points after filtering them
datalist.data.clear();
for (CgData r : track.data) {
if ((r.getTag() & CgConst.TAG_ROADBOOK) != 0) {
MrbData d = new MrbData(r.getNum(), r.getLatitude(), r.getLongitude(), r.getElevation(CgConst.UNIT_METER), r.getElevationMemo(), r.getTag(), r.getDist(CgConst.UNIT_METER), r.getTotal(CgConst.UNIT_METER), r.getDiff(), r.getCoeff(), r.getRecovery(), r.getSlope(), r.getSpeed(CgConst.UNIT_METER), r.getdElevation(CgConst.UNIT_METER), r.getTime(), r.getdTime_f(), r.getTimeLimit(), r.getHour(), r.getStation(), r.getName(), r.getComment(), 0, 0, r.FmtLbMiniRoadbook, r.OptionMiniRoadbook, r.VPosMiniRoadbook, r.CommentMiniRoadbook, r.FontSizeMiniRoadbook, 0, 0);
datalist.data.add(d);
}
}
// -- Calculate the fields
if (datalist.data.size() >= 1) {
for (int i = 1; i < datalist.data.size(); i++) {
MrbData d = datalist.data.get(i);
MrbData p = datalist.data.get(i - 1);
d.setDeltaDist(d.getTotal(CgConst.UNIT_METER) - p.getTotal(CgConst.UNIT_METER));
d.setDeltaTime(d.getTime() - p.getTime());
}
}
// -- Set profil
pnlProfil.setData(datalist);
pnlProfil.setTrack(track);
pnlProfil.setSettings(settings);
pnlProfil.setWidth(track.MrbSizeW);
pnlProfil.setHeight(track.MrbSizeH);
// -- Set the position of the split bar
SplitPane.setDividerLocation(settings.MRB_SplitPosition);
// -- Set profil size
spinWidth.setValue(track.MrbSizeW);
spinHeight.setValue(track.MrbSizeH);
// -- Set profile type
cbProfilType.setSelectedIndex(track.MRBType);
memoFormat[0] = settings.MemoFormat[0];
memoFormat[1] = settings.MemoFormat[1];
memoFormat[2] = settings.MemoFormat[2];
memoFormat[3] = settings.MemoFormat[3];
memoFormat[4] = settings.MemoFormat[4];
RefreshBtLabel();
RefreshTooltips();
RefreshTableData();
RefreshProperties();
btNightAndDayHighlight.setSelected(track.bShowNightDay);
// End set field
ok = false;
// -- Update the display
// Refresh();
// -- Show the dialog
setVisible(true);
// Memorize the last position of the splitbar
settings.MRB_SplitPosition = SplitPane.getDividerLocation();
ok = true;
if (ok) {
settings.MemoFormat[0] = memoFormat[0];
settings.MemoFormat[1] = memoFormat[1];
settings.MemoFormat[2] = memoFormat[2];
settings.MemoFormat[3] = memoFormat[3];
settings.MemoFormat[4] = memoFormat[4];
track.MRBType = cbProfilType.getSelectedIndex();
track.MrbSizeW = spinWidth.getValueAsInt();
track.MrbSizeH = spinHeight.getValueAsInt();
}
return ok;
}
use of course_generator.CgData 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()));
}
}
Aggregations