mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 23:07:11 +00:00
Backup changes
This commit is contained in:
1 parent
772965736d
commit
02f51b1805
5 files changed
+85
-16
No files matched your search
+33
-2
@@ -67,8 +67,7 @@ public abstract class FullCanvasOverlay extends CanvasOverlay {
|
|||||||
context2d.moveTo(x-1, y-1);
|
context2d.moveTo(x-1, y-1);
|
||||||
context2d.lineTo(x+1, y+1);
|
context2d.lineTo(x+1, y+1);
|
||||||
context2d.closePath();
|
context2d.closePath();
|
||||||
context2d.stroke();
|
context2d.stroke();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +86,38 @@ public abstract class FullCanvasOverlay extends CanvasOverlay {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a circle centred at x,y with given radius
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param radius
|
||||||
|
*/
|
||||||
|
protected void drawCircle(double x, double y, double radius, String color) {
|
||||||
|
Context2d context2d = canvas.getContext2d();
|
||||||
|
context2d.setLineWidth(3);
|
||||||
|
context2d.setStrokeStyle(color);
|
||||||
|
context2d.beginPath();
|
||||||
|
context2d.arc(x,y,radius,0,2*Math.PI);
|
||||||
|
context2d.closePath();
|
||||||
|
context2d.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a circle centred at x,y with given radius
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
|
protected void drawCircleWithText(double x, double y, double radius, String color, String text) {
|
||||||
|
|
||||||
|
Context2d context2d = canvas.getContext2d();
|
||||||
|
drawCircle(x, y,radius,color);
|
||||||
|
context2d.setFillStyle(textColor);
|
||||||
|
context2d.setFont("normal 12pt Calibri");
|
||||||
|
context2d.fillText(text, x + 10., y + 4.);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a line from (x,y) to (x1,y1) on the canvas
|
* Draw a line from (x,y) to (x1,y1) on the canvas
|
||||||
* @param x
|
* @param x
|
||||||
|
|||||||
+14
-5
@@ -27,6 +27,9 @@ import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
|
|||||||
*/
|
*/
|
||||||
public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
||||||
|
|
||||||
|
public String racecourseColor = "White";
|
||||||
|
public double racecourseBuoySize = 5;
|
||||||
|
|
||||||
public LatLng startPoint;
|
public LatLng startPoint;
|
||||||
public LatLng endPoint;
|
public LatLng endPoint;
|
||||||
private Marker startMarker;
|
private Marker startMarker;
|
||||||
@@ -101,7 +104,8 @@ public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
|||||||
|
|
||||||
if (startPoint != null) {
|
if (startPoint != null) {
|
||||||
Point point = getMap().convertLatLngToDivPixel(startPoint);
|
Point point = getMap().convertLatLngToDivPixel(startPoint);
|
||||||
drawPointWithText(point.getX() - getWidgetPosLeft(), point.getY() - getWidgetPosTop(), "Start");
|
//drawPointWithText(point.getX() - getWidgetPosLeft(), point.getY() - getWidgetPosTop(), "Start");
|
||||||
|
drawCircleWithText(point.getX() - getWidgetPosLeft(),point.getY() - getWidgetPosTop(),racecourseBuoySize,racecourseColor,"Start");
|
||||||
if (startMarker != null) {
|
if (startMarker != null) {
|
||||||
startMarker.setLatLng(startPoint);
|
startMarker.setLatLng(startPoint);
|
||||||
} else {
|
} else {
|
||||||
@@ -132,9 +136,13 @@ public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
|||||||
|
|
||||||
if (endPoint != null) {
|
if (endPoint != null) {
|
||||||
Point point = getMap().convertLatLngToDivPixel(endPoint);
|
Point point = getMap().convertLatLngToDivPixel(endPoint);
|
||||||
drawPointWithText(point.getX() - getWidgetPosLeft(), point.getY() - getWidgetPosTop(), "End");
|
//drawPointWithText(point.getX() - getWidgetPosLeft(), point.getY() - getWidgetPosTop(), "End");
|
||||||
|
drawCircleWithText(point.getX() - getWidgetPosLeft(),point.getY() - getWidgetPosTop(),racecourseBuoySize,racecourseColor,"End");
|
||||||
|
double cLat = (startPoint.getLatitude() + ((endPoint.getLatitude() - startPoint.getLatitude())%180.)/2. + 90.)%180. - 90.;
|
||||||
|
double cLon = (startPoint.getLongitude() + ((endPoint.getLongitude() - startPoint.getLongitude())%360.)/2. + 180.)%360. -180;
|
||||||
|
LatLng centerPoint = LatLng.newInstance(cLat, cLon);
|
||||||
|
//System.out.println("center: "+cLat+","+cLon);
|
||||||
|
getMap().panTo(centerPoint);
|
||||||
if (endMarker != null) {
|
if (endMarker != null) {
|
||||||
endMarker.setLatLng(endPoint);
|
endMarker.setLatLng(endPoint);
|
||||||
} else {
|
} else {
|
||||||
@@ -205,11 +213,12 @@ public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void redraw(boolean force) {
|
protected void redraw(boolean force) {
|
||||||
|
System.out.println("method: RaceCourseCanvasOverlay.redraw().");
|
||||||
if (startPoint != null && endPoint != null) {
|
if (startPoint != null && endPoint != null) {
|
||||||
setCanvasSettings();
|
setCanvasSettings();
|
||||||
// drawCanvas();
|
// drawCanvas();
|
||||||
setStartEndPoint(startPoint, endPoint);
|
setStartEndPoint(startPoint, endPoint);
|
||||||
drawLine(endPoint, "White");
|
drawLine(endPoint, racecourseColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-7
@@ -69,6 +69,7 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
wl = null;
|
||||||
windFieldPoints = new HashMap<ToolTip, WindDTO>();
|
windFieldPoints = new HashMap<ToolTip, WindDTO>();
|
||||||
|
|
||||||
mmHandler = new WindFieldMapMouseMoveHandler(this);
|
mmHandler = new WindFieldMapMouseMoveHandler(this);
|
||||||
@@ -153,6 +154,15 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void drawScaledArrow(WindDTO windDTO, double angle, int index) {
|
||||||
|
|
||||||
|
double aWidth = Math.max(1., (windDTO.trueWindSpeedInMetersPerSecond/2.));
|
||||||
|
double aLength = Math.max(10., (4.*windDTO.trueWindSpeedInMetersPerSecond));
|
||||||
|
//System.out.println("windspeed: "+windDTO.trueWindSpeedInMetersPerSecond+", aWidth: "+aWidth+", aLength: "+aLength);
|
||||||
|
drawArrow(windDTO, angle, aLength, aWidth, index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected void drawWindField(final List<WindDTO> windDTOList) {
|
protected void drawWindField(final List<WindDTO> windDTOList) {
|
||||||
clear();
|
clear();
|
||||||
if (windDTOList != null && windDTOList.size() > 0) {
|
if (windDTOList != null && windDTOList.size() > 0) {
|
||||||
@@ -160,13 +170,8 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
while (windDTOIter.hasNext()) {
|
while (windDTOIter.hasNext()) {
|
||||||
WindDTO windDTO = windDTOIter.next();
|
WindDTO windDTO = windDTOIter.next();
|
||||||
//int aWidth = (int) Math.max(1, Math.min(2, Math.round(windDTO.trueWindSpeedInMetersPerSecond)));
|
|
||||||
double aWidth = Math.max(1., (windDTO.trueWindSpeedInMetersPerSecond/3.));
|
|
||||||
double aLength = Math.max(10., (3.*windDTO.trueWindSpeedInMetersPerSecond));
|
|
||||||
logger.info("windspeed: "+windDTO.trueWindSpeedInMetersPerSecond+", aWidth: "+aWidth+", aLength: "+aLength);
|
|
||||||
DegreeBearingImpl dbi = new DegreeBearingImpl(windDTO.trueWindBearingDeg);
|
DegreeBearingImpl dbi = new DegreeBearingImpl(windDTO.trueWindBearingDeg);
|
||||||
drawArrow(windDTO, dbi.getRadians(), aLength, aWidth, ++index);
|
drawScaledArrow(windDTO, dbi.getRadians(), ++index);
|
||||||
|
|
||||||
}
|
}
|
||||||
String title = "Wind Field at " + windDTOList.size() + " points.";
|
String title = "Wind Field at " + windDTOList.size() + " points.";
|
||||||
getCanvas().setTitle(title);
|
getCanvas().setTitle(title);
|
||||||
@@ -199,7 +204,7 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
|||||||
double theta = Math.atan2(-dy, dx);
|
double theta = Math.atan2(-dy, dx);
|
||||||
|
|
||||||
double hLength = Math.max(6.,6.+(10./(60.-10.))*Math.max(length-6.,0));
|
double hLength = Math.max(6.,6.+(10./(60.-10.))*Math.max(length-6.,0));
|
||||||
logger.info("headlength: "+hLength+", arrowlength: "+length);
|
logger.finer("headlength: "+hLength+", arrowlength: "+length);
|
||||||
drawHead(x1, y1, theta, hLength, weight);
|
drawHead(x1, y1, theta, hLength, weight);
|
||||||
//String text = "P" + index;// + NumberFormat.getFormat("0.00").format(windDTO.trueWindBearingDeg) + "°";
|
//String text = "P" + index;// + NumberFormat.getFormat("0.00").format(windDTO.trueWindBearingDeg) + "°";
|
||||||
//drawPointWithText(x, y, text);
|
//drawPointWithText(x, y, text);
|
||||||
|
|||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.sap.sailing.gwt.ui.simulator.util;
|
||||||
|
|
||||||
|
public class ColorPaletteGenerator implements ColorPalette {
|
||||||
|
|
||||||
|
//private String[] colors = {"Green","Red","Blue","Yellow","Black"};
|
||||||
|
private String[] colors = {"#00ED00","#FFBB00","Blue","Yellow","Black"};
|
||||||
|
private int currentIndex = -1;
|
||||||
|
|
||||||
|
public ColorPaletteGenerator() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNextColor() {
|
||||||
|
currentIndex++;
|
||||||
|
return colors[currentIndex % colors.length];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
currentIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+2
-2
@@ -60,11 +60,11 @@ public class WindFieldGeneratorOscillationImpl extends WindFieldGeneratorImpl im
|
|||||||
int midPoint = ncol/2;
|
int midPoint = ncol/2;
|
||||||
for (int i = 0; i <= midPoint; ++i) {
|
for (int i = 0; i <= midPoint; ++i) {
|
||||||
speed[i] = new KnotSpeedImpl(leftSpeed + i*(middleSpeed-leftSpeed)/(midPoint));
|
speed[i] = new KnotSpeedImpl(leftSpeed + i*(middleSpeed-leftSpeed)/(midPoint));
|
||||||
logger.info("index: "+i+"speed: "+speed[i]);
|
//logger.info("index: "+i+"speed: "+speed[i]);
|
||||||
}
|
}
|
||||||
for (int i = 1; i < ncol - midPoint; ++i) {
|
for (int i = 1; i < ncol - midPoint; ++i) {
|
||||||
speed[midPoint + i] = new KnotSpeedImpl(middleSpeed + i*(rightSpeed-middleSpeed)/(ncol - midPoint -1));
|
speed[midPoint + i] = new KnotSpeedImpl(middleSpeed + i*(rightSpeed-middleSpeed)/(ncol - midPoint -1));
|
||||||
logger.info("index: "+(midPoint+i)+"speed: "+speed[midPoint-1+i]);
|
//logger.info("index: "+(midPoint+i)+"speed: "+speed[midPoint-1+i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user