From 2ed9935f118cc69b0da06980e1f7e9f449119072 Mon Sep 17 00:00:00 2001 From: Joshua Tharp Date: Tue, 11 Sep 2018 16:43:10 -0500 Subject: [PATCH] Fixes for screen guard and cover. Now the segments that end in the middle will point to pt1 which represents the middle of the line segment. Before they were not ending / pointing to the middle when rotated. --- .../main/java/JavaLineArray/DISMSupport.java | 40 ++++++++----------- .../java/JavaTacticalRenderer/Modifier2.java | 14 +++++-- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/core/JavaLineArray/src/main/java/JavaLineArray/DISMSupport.java b/core/JavaLineArray/src/main/java/JavaLineArray/DISMSupport.java index f1f8399f..34de5691 100644 --- a/core/JavaLineArray/src/main/java/JavaLineArray/DISMSupport.java +++ b/core/JavaLineArray/src/main/java/JavaLineArray/DISMSupport.java @@ -341,7 +341,7 @@ protected static int GetDISMCoverDouble(POINT2[] points, int counter = 0; try { // switch points[1] and points[2] if they are backwards - double dAngle0, dDeltaX0, dDeltaY0, dDeltaX1, dDeltaY1; + double dAngle0, dAngle1, dDeltaX0, dDeltaY0, dDeltaX1, dDeltaY1; double iLengthPt0Pt1 = 0; double iLengthPt0Pt2 = 0; double iDelta = 0; @@ -352,8 +352,6 @@ protected static int GetDISMCoverDouble(POINT2[] points, POINT2[] savepoints = new POINT2[3]; POINT2[] pts = new POINT2[2]; POINT2[] ptsJaggyLine = new POINT2[4]; - //float scale = 1; - boolean goLeftThenRight=false; int sign=1; //added section for jaggy line orientation M. Deutch 6-24-11 @@ -380,14 +378,9 @@ else if(pt1.x > pt2.x && quadrant == 3) else if(pt1.x < pt2.x && quadrant == 4) sign=-1; //end section - - //System.out.print(Integer.toString(quadrant)); - //System.out.print("\n"); + if(linetype==TacticalLines.SARA) t=0; - - if(points[1].x<=points[2].x) - goLeftThenRight=true; //save the points in the correct order for (j = 0; j < 3; j++) { @@ -418,17 +411,19 @@ else if(pt1.x < pt2.x && quadrant == 4) iDelta = minLength; } + dAngle0 = Math.atan2(savepoints[0].y - savepoints[1].y, savepoints[0].x - savepoints[1].x); + dAngle1 = Math.atan2(savepoints[0].y - savepoints[2].y, savepoints[0].x - savepoints[2].x); + // left side: draw letter in from the jaggy line - if(goLeftThenRight) - savepoints[0].x-=30*t; //was 20 - else - savepoints[0].x+=30*t; //was 20 + + savepoints[0].x -= 30 * Math.cos(dAngle0); //was 20 + savepoints[0].y -= 30 * Math.sin(dAngle0); iLetterOffset = 0; ptsJaggyLine[0].x = savepoints[0].x - iLetterOffset * 2;//was - ptsJaggyLine[0].y = savepoints[0].y; ptsJaggyLine[0].x -= iLetterOffset; - dAngle0 = Math.atan2(ptsJaggyLine[0].y - savepoints[1].y, ptsJaggyLine[0].x - savepoints[1].x); + pts[0].x = (ptsJaggyLine[0].x + savepoints[1].x) / 2; pts[0].y = (ptsJaggyLine[0].y + savepoints[1].y) / 2; dDeltaX0 = Math.cos(dAngle0 + sign*CONST_PI / 4) * iDelta; //was + @@ -472,19 +467,18 @@ else if(pt1.x < pt2.x && quadrant == 4) } // right side: draw letter and jaggy line - if(goLeftThenRight) - savepoints[0].x+=60*t; //was 40 - else - savepoints[0].x-=60*t; //wass 40 + + savepoints[0].x += 30 * (Math.cos(dAngle0) - Math.cos(dAngle1)); //was 20 + savepoints[0].y += 30 * (Math.sin(dAngle0) - Math.sin(dAngle1)); ptsJaggyLine[0].x = savepoints[0].x + iLetterOffset * 2; ptsJaggyLine[0].y = savepoints[0].y; ptsJaggyLine[0].x += iLetterOffset; - dAngle0 = Math.atan2(ptsJaggyLine[0].y - savepoints[2].y, ptsJaggyLine[0].x - savepoints[2].x); + pts[0].x = (ptsJaggyLine[0].x + savepoints[2].x) / 2; pts[0].y = (ptsJaggyLine[0].y + savepoints[2].y) / 2; - dDeltaX0 = Math.cos(dAngle0 - sign*CONST_PI / 4) * iDelta; //was - - dDeltaY0 = Math.sin(dAngle0 - sign*CONST_PI / 4) * iDelta; //was - + dDeltaX0 = Math.cos(dAngle1 - sign*CONST_PI / 4) * iDelta; //was - + dDeltaY0 = Math.sin(dAngle1 - sign*CONST_PI / 4) * iDelta; //was - ptsJaggyLine[1].x = pts[0].x - dDeltaX0; //was - ptsJaggyLine[1].y = pts[0].y - dDeltaY0; //was - ptsJaggyLine[2].x = pts[0].x + dDeltaX0; //was + @@ -496,8 +490,8 @@ else if(pt1.x < pt2.x && quadrant == 4) } points[counter - 1].style = 5; // draw arrow at end of line - dDeltaX1 = Math.cos(dAngle0 + sign*CONST_PI / 4) * iDelta; //was + - dDeltaY1 = Math.sin(dAngle0 + sign*CONST_PI / 4) * iDelta; //was + + dDeltaX1 = Math.cos(dAngle1 + sign*CONST_PI / 4) * iDelta; //was + + dDeltaY1 = Math.sin(dAngle1 + sign*CONST_PI / 4) * iDelta; //was + ptsJaggyLine[0].x = savepoints[2].x + dDeltaX0; ptsJaggyLine[0].y = savepoints[2].y + dDeltaY0; ptsJaggyLine[1] = savepoints[2]; diff --git a/core/JavaLineArray/src/main/java/JavaTacticalRenderer/Modifier2.java b/core/JavaLineArray/src/main/java/JavaTacticalRenderer/Modifier2.java index fb846b10..56e3bd87 100644 --- a/core/JavaLineArray/src/main/java/JavaTacticalRenderer/Modifier2.java +++ b/core/JavaLineArray/src/main/java/JavaTacticalRenderer/Modifier2.java @@ -3017,6 +3017,9 @@ public static void AddModifiersGeo(TGLight tg, Line2D line = null; //double dist=0; //int startIndex = 0; + double dAngle0, dAngle1; + int stringHeight; + switch (linetype) { case TacticalLines.GENERIC: AddIntegralModifier(tg, tg.get_Name(), aboveMiddle, 0, middleSegment, middleSegment + 1, true); @@ -3073,11 +3076,16 @@ public static void AddModifiersGeo(TGLight tg, case TacticalLines.SCREEN: case TacticalLines.COVER: case TacticalLines.GUARD: - stringWidth = (int) (1.5 * (double) metrics.stringWidth(label)); + //stringWidth = (int) (1.5 * (double) metrics.stringWidth(label)); + stringHeight = (int) (0.5 * (double) metrics.getHeight()); + dAngle0 = Math.atan2(tg.Pixels.get(0).y - tg.Pixels.get(1).y, tg.Pixels.get(0).x - tg.Pixels.get(1).x); + dAngle1 = Math.atan2(tg.Pixels.get(0).y - tg.Pixels.get(2).y, tg.Pixels.get(0).x - tg.Pixels.get(2).x); pt0 = new POINT2(tg.Pixels.get(0)); - pt0.x += 2 * stringWidth; + pt0.x -= 30 * Math.cos(dAngle0); + pt0.y -= 30 * Math.sin(dAngle0) + stringHeight; pt1 = new POINT2(tg.Pixels.get(0)); - pt1.x -= 2 * stringWidth; + pt1.x -= 30 * Math.cos(dAngle1); + pt1.y -= 30 * Math.sin(dAngle1) + stringHeight; AddIntegralAreaModifier(tg, label, area, 0, pt0, pt0, true); AddIntegralAreaModifier(tg, label, area, 0, pt1, pt1, true); break;