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
+84
-15
No files matched your search
+32
-1
@@ -69,7 +69,6 @@ public abstract class FullCanvasOverlay extends CanvasOverlay {
|
||||
context2d.closePath();
|
||||
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
|
||||
* @param x
|
||||
|
||||
+14
-5
@@ -27,6 +27,9 @@ import com.sap.sailing.gwt.ui.shared.racemap.FullCanvasOverlay;
|
||||
*/
|
||||
public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
||||
|
||||
public String racecourseColor = "White";
|
||||
public double racecourseBuoySize = 5;
|
||||
|
||||
public LatLng startPoint;
|
||||
public LatLng endPoint;
|
||||
private Marker startMarker;
|
||||
@@ -101,7 +104,8 @@ public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
||||
|
||||
if (startPoint != null) {
|
||||
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) {
|
||||
startMarker.setLatLng(startPoint);
|
||||
} else {
|
||||
@@ -132,9 +136,13 @@ public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
||||
|
||||
if (endPoint != null) {
|
||||
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) {
|
||||
endMarker.setLatLng(endPoint);
|
||||
} else {
|
||||
@@ -205,11 +213,12 @@ public class RaceCourseCanvasOverlay extends FullCanvasOverlay {
|
||||
|
||||
@Override
|
||||
protected void redraw(boolean force) {
|
||||
System.out.println("method: RaceCourseCanvasOverlay.redraw().");
|
||||
if (startPoint != null && endPoint != null) {
|
||||
setCanvasSettings();
|
||||
// drawCanvas();
|
||||
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() {
|
||||
wl = null;
|
||||
windFieldPoints = new HashMap<ToolTip, WindDTO>();
|
||||
|
||||
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) {
|
||||
clear();
|
||||
if (windDTOList != null && windDTOList.size() > 0) {
|
||||
@@ -160,13 +170,8 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
int index = 0;
|
||||
while (windDTOIter.hasNext()) {
|
||||
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);
|
||||
drawArrow(windDTO, dbi.getRadians(), aLength, aWidth, ++index);
|
||||
|
||||
drawScaledArrow(windDTO, dbi.getRadians(), ++index);
|
||||
}
|
||||
String title = "Wind Field at " + windDTOList.size() + " points.";
|
||||
getCanvas().setTitle(title);
|
||||
@@ -199,7 +204,7 @@ public class WindFieldCanvasOverlay extends FullCanvasOverlay implements TimeLis
|
||||
double theta = Math.atan2(-dy, dx);
|
||||
|
||||
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);
|
||||
//String text = "P" + index;// + NumberFormat.getFormat("0.00").format(windDTO.trueWindBearingDeg) + "°";
|
||||
//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;
|
||||
for (int i = 0; i <= midPoint; ++i) {
|
||||
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) {
|
||||
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