From 1c31acfc45286a4f24526fc6485aa881e46ac0f6 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Tue, 12 Nov 2024 10:41:25 +0000 Subject: [PATCH 1/4] renderer2d/InteractionAdapter: Distance and angle string rendering are now made via RenderStringUtils. --- .../neptus/renderer2d/InteractionAdapter.java | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java index 921441ad1c..80e3769b22 100644 --- a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java +++ b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java @@ -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; /** @@ -140,28 +141,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, 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); } From 0e9aff107e0cee7910ab616da9d9d92c6709d328 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Tue, 12 Nov 2024 10:46:22 +0000 Subject: [PATCH 2/4] renderer2d/InteractionAdapter: Distance is now converted from meters to kilometers when equal or above 1000 meters. --- src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java index 80e3769b22..39cc20a92a 100644 --- a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java +++ b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java @@ -112,6 +112,10 @@ 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); + } 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); From 2a5246734a571e70e55bbdc7a3e5ccd63e442ed1 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Tue, 12 Nov 2024 10:52:03 +0000 Subject: [PATCH 3/4] renderer2d/InteractionAdapter: Distance is now also converted from meters to nautical miles being rendered alongside meters/kilometers. --- src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java index 39cc20a92a..00d98cf997 100644 --- a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java +++ b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java @@ -116,6 +116,9 @@ else if (measuring) { 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); @@ -147,7 +150,7 @@ else if (measuring) { g.setStroke(origStroke); Font font = new Font("Arial", Font.BOLD, 17); - RenderStringUtils.drawStringWOutline(g, font, Color.WHITE, Color.BLACK, txt, lastDragPoint.getX() + 10, lastDragPoint.getY() + 10); + RenderStringUtils.drawStringWOutline(g, font, Color.WHITE, Color.BLACK, txt + " / " + milesTxt, lastDragPoint.getX() + 10, 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); From 1bf04c17c588df3655bc5989d986c473e1df3915 Mon Sep 17 00:00:00 2001 From: Paulo Dias Date: Tue, 12 Nov 2024 13:46:42 +0000 Subject: [PATCH 4/4] renderer2d/InteractionAdapter: Small tweak for unit string. --- src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java index 00d98cf997..03259f6701 100644 --- a/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java +++ b/src/java/pt/lsts/neptus/renderer2d/InteractionAdapter.java @@ -114,7 +114,7 @@ else if (measuring) { String txt = String.format("%.2f m", distance); if (distance/1000 >= 1) { double distanceKm = distance/1000; - txt = String.format("%.2f Km", distanceKm); + txt = String.format("%.2f km", distanceKm); } double distanceNMiles = distance/1852; String milesTxt = String.format("%.2f NM", distanceNMiles);