Skip to content

Commit

Permalink
Merge branch 'feature/map-measurement' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
paulosousadias committed Nov 12, 2024
2 parents 0350ceb + 1bf04c1 commit d145d98
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import pt.lsts.neptus.util.FileUtil;
import pt.lsts.neptus.util.GuiUtils;
import pt.lsts.neptus.util.ImageUtils;
import pt.lsts.neptus.util.RenderStringUtils;
import pt.lsts.neptus.util.conf.ConfigFetch;

/**
Expand Down Expand Up @@ -111,6 +112,13 @@ else if (measuring) {
LocationType end = source.getRealWorldLocation(lastDragPoint);
double distance = end.getDistanceInMeters(firstDragPoint);
String txt = String.format("%.2f m", distance);
if (distance/1000 >= 1) {
double distanceKm = distance/1000;
txt = String.format("%.2f km", distanceKm);
}
double distanceNMiles = distance/1852;
String milesTxt = String.format("%.2f NM", distanceNMiles);

g.setStroke(new BasicStroke(5.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g.setColor(new Color(0, 0, 0, 100));
Point2D start = source.getScreenPosition(firstDragPoint);
Expand Down Expand Up @@ -140,28 +148,12 @@ else if (measuring) {
g.setColor(Color.green.brighter().brighter());
g.draw(new Line2D.Double(start, lastDragPoint));
g.setStroke(origStroke);

g.setFont(new Font("Arial", Font.BOLD, 17));
g.setColor(new Color(0, 0, 0, 100));
g.drawString(txt, (int) (lastDragPoint.getX() + 12), (int) (lastDragPoint.getY() + 11));
g.drawString(txt, (int) (lastDragPoint.getX() + 12), (int) (lastDragPoint.getY() + 12));

g.drawString(txt, (int) (lastDragPoint.getX() + 9), (int) (lastDragPoint.getY() + 8));
g.drawString(txt, (int) (lastDragPoint.getX() + 9), (int) (lastDragPoint.getY() + 9));

g.setFont(new Font("Arial", Font.BOLD, 15));
g.drawString(angleTxt, (int) (lastDragPoint.getX() + 12), (int) (lastDragPoint.getY() + 31));
g.drawString(angleTxt, (int) (lastDragPoint.getX() + 13), (int) (lastDragPoint.getY() + 31));
g.drawString(angleTxt, (int) (lastDragPoint.getX() + 9), (int) (lastDragPoint.getY() + 29));
g.drawString(angleTxt, (int) (lastDragPoint.getX() + 8), (int) (lastDragPoint.getY() + 29));

g.setFont(new Font("Arial", Font.BOLD, 15));
g.setColor(Color.white);
g.drawString(angleTxt, (int) (lastDragPoint.getX() + 10), (int) (lastDragPoint.getY() + 30));
Font font = new Font("Arial", Font.BOLD, 17);
RenderStringUtils.drawStringWOutline(g, font, Color.WHITE, Color.BLACK, txt + " / " + milesTxt, lastDragPoint.getX() + 10, lastDragPoint.getY() + 10);

g.setColor(Color.white);
g.setFont(new Font("Arial", Font.BOLD, 17));
g.drawString(txt, (int) (lastDragPoint.getX() + 10), (int) (lastDragPoint.getY() + 10));
font = new Font("Arial", Font.BOLD, 15);
RenderStringUtils.drawStringWOutline(g, font, Color.WHITE, Color.BLACK, angleTxt, lastDragPoint.getX() + 10, lastDragPoint.getY() + 30);
}
g.drawImage(rulerIcon, 20, 50, null);
}
Expand Down

0 comments on commit d145d98

Please sign in to comment.