Class lineutility

java.lang.Object
armyc2.c5isr.JavaLineArray.lineutility

public final class lineutility extends Object
A class to provide the utility functions required for calculating the line points.
  • Field Details

  • Constructor Details

  • Method Details

    • ResizeArray

      protected static POINT2[] ResizeArray(POINT2[] pLinePoints, int length)
      Resizes the array to the length speicifed, called by the Channels class.
      Parameters:
      pLinePoints - the array to resize
      length - the length to which to resize the array.
      Returns:
      the resized array
    • SegmentLineShape

      protected static void SegmentLineShape(POINT2 pt0, POINT2 pt1, Shape2 shape)
      post-segments a line segment into 50 pixel intervals
      Parameters:
      pt0 -
      pt1 -
      shape -
    • GetDirAtkAirMiddleSegment

      public static int GetDirAtkAirMiddleSegment(POINT2[] pLinePoints, int vblSaveCounter)
      Calculates the middle segment for the Direction of Attack Aviation symbol
      Parameters:
      pLinePoints - the point array
      vblSaveCounter - the size of the point array
      Returns:
      the middle segment
    • CalcSegmentAngleDouble

      protected static double CalcSegmentAngleDouble(POINT2 pt0, POINT2 pt1)
      Computes the angle in radians between two points
      Parameters:
      pt0 - the first point
      pt1 - the last point
      Returns:
      the angle in radians
    • InitializePOINT2Array

      protected static void InitializePOINT2Array(POINT2[] pts)
      POINT2 in previous applications has been a struct that did not require initialization.
      Parameters:
      pts - array of points to instantiate.
    • CalcCenterPointDouble

      protected static POINT2 CalcCenterPointDouble(POINT2[] pLinePoints, int vblCounter)
      Calculates the center point of an area using the first vblCounter points in the array.
      Parameters:
      pLinePoints - the client points
      vblCounter - the number of points in the array to use
      Returns:
      the center point
    • CalcCenterPointDouble2

      public static POINT2 CalcCenterPointDouble2(Object[] pLinePoints, int vblCounter)
      Called by renderer Modifier2 class after ArrayList.ToArray was called, which produces an array of objects.
      Parameters:
      pLinePoints -
      vblCounter -
      Returns:
    • CalcDistanceDouble

      public static double CalcDistanceDouble(POINT2 p1, POINT2 p2)
      Calculates the distance in pixels between two points
      Parameters:
      p1 - the first point
      p2 - the last point
      Returns:
      the distance between p1 and p2 in pixels
    • CalcDistanceDouble

      public static double CalcDistanceDouble(Point2D p1, Point2D p2)
      Calculates the distance in pixels between two points
      Parameters:
      p1 - the first point
      p2 - the last point
      Returns:
      the distance between p1 and p2 in pixels
    • CalcTrueSlopeDouble

      protected static int CalcTrueSlopeDouble(POINT2 firstLinePoint, POINT2 lastLinePoint, ref<double[]> slope)
      Computes the slope of a line
      Parameters:
      firstLinePoint - the first line point
      lastLinePoint - the last line point
      slope - OUT - object with member to hold the slope of the line
      Returns:
      1 if successful, else return 0
    • WriteFile

      public static void WriteFile(String str)
    • ReversePointsDouble2

      protected static void ReversePointsDouble2(POINT2[] pLowerLinePoints, int vblCounter)
      reverses the first vblCounter points
      Parameters:
      pLowerLinePoints - OUT - points to reverse
      vblCounter -
    • CalcTrueSlopeDoubleForRoutes

      public static boolean CalcTrueSlopeDoubleForRoutes(POINT2 firstLinePoint, POINT2 lastLinePoint, ref<double[]> slope)
    • CalcTrueSlopeDouble2

      public static boolean CalcTrueSlopeDouble2(POINT2 firstLinePoint, POINT2 lastLinePoint, ref<double[]> slope)
      Computes the slope of a line
      Parameters:
      firstLinePoint - the first line point
      lastLinePoint - the last line point
      slope - OUT - object with member to hold the slope of the line
      Returns:
      true if successful
    • CalcTrueLinesDouble

      protected static int CalcTrueLinesDouble(long nDistance, POINT2 linePoint1, POINT2 linePoint2, ref<double[]> pdResult)
      Calculates the slopes and y intercepts in pixels for the line from pt1 to pt2 and a parallel line a vertical distance from the line
      Parameters:
      nDistance - the distance in pixels
      linePoint1 - first point on the line
      linePoint2 - last point on the line
      pdResult - OUT - array to hold m, b for both lines
      Returns:
      1 if the lines are not vertical, else return 0
    • CalcTrueIntersectDouble2

      public static POINT2 CalcTrueIntersectDouble2(double m1, double b1, double m2, double b2, int bolVertical1, int bolVertical2, double X1, double X2)
      Calculates the intersection of two lines.
      Parameters:
      m1 - slope of first line
      b1 - Y intercept of first line
      m2 - slope of second line
      b2 - Y intercept of second line
      bolVertical1 - 0 if first line is vertical, else 1
      bolVertical2 - 0 if second line is vertical, else 1
      X1 - X intercept if first line is vertical
      X2 - X intercept if 2nd line is vertical.
      Returns:
      intersection point
    • GetOffsetPointDouble

      protected static POINT2 GetOffsetPointDouble(POINT2 startLinePoint, POINT2 endLinePoint, long nOffset)
      Calculates an offset point for channel types which require arrows.
      Parameters:
      startLinePoint - the first point
      endLinePoint - the last point
      nOffset - the offset in pixels
      Returns:
      the offset point
    • LineOfXPoints

      protected static ArrayList LineOfXPoints(TGLight tg, POINT2[] pLinePoints)
      Used for DMAF
      Parameters:
      pLinePoints - the client points
      Returns:
      ArrayList of X points
    • CalcDistanceToLineDouble

      public static double CalcDistanceToLineDouble(POINT2 pt1, POINT2 pt2, POINT2 pt3)
      Computes the distance in pixels of pt3 to the line from pt1 to pt2.
      Parameters:
      pt1 - first line point
      pt2 - last line point
      pt3 - point distance to compute
      Returns:
      distance to pt3
    • ExtendLineDouble

      public static POINT2 ExtendLineDouble(POINT2 pt1, POINT2 pt2, double dist)
      Calculates a point along a line. Returns the past point if the distance is 0.
      Parameters:
      pt1 - first line point
      pt2 - last line point
      dist - extension distance in pixels from the beginning of the line
      Returns:
      the extension point
    • ExtendAlongLineDouble

      public static POINT2 ExtendAlongLineDouble(POINT2 pt1, POINT2 pt2, double dist)
      Extends a point along a line. If dist is 0 returns last point.
      Parameters:
      pt1 - first point on the line
      pt2 - last point on the line
      dist - the distance in pixels from pt1
      Returns:
      the extended point
    • ExtendAlongLineDouble2

      public static POINT2 ExtendAlongLineDouble2(POINT2 pt1, POINT2 pt2, double dist)
    • ExtendAlongLineDouble2

      public static Point2D ExtendAlongLineDouble2(Point2D pt1, Point2D pt2, double dist)
    • ExtendAlongLineDouble

      public static POINT2 ExtendAlongLineDouble(POINT2 pt1, POINT2 pt2, double dist, int styl)
    • ExtendLineAbove

      protected static int ExtendLineAbove(POINT2 pt1, POINT2 pt2, POINT2 pt3, double d, ref<double[]> X, ref<double[]> Y, int direction)
      Extends a point above a line
      Parameters:
      pt1 - first line point
      pt2 - last line point
      pt3 - point at which to extend
      d - distance in pixels to extend above the line
      X - OUT - extended point x value
      Y - OUT - extended point y value
      direction - direction to extend the line
      Returns:
      1 if successful, else return 0
    • ExtendLineLeft

      protected static int ExtendLineLeft(POINT2 pt1, POINT2 pt2, POINT2 pt3, double d, ref<double[]> X, ref<double[]> Y, int direction)
      Extends a point to the left of a line
      Parameters:
      pt1 - first line point
      pt2 - last line point
      pt3 - point at which to extend
      d - distance in pixels to extend above the line
      X - OUT - extended point x value
      Y - OUT - extended point y value
      direction - direction to extend the line
      Returns:
      1 if successful, else return 0
    • CalcDirectionFromLine

      protected static int CalcDirectionFromLine(POINT2 pt0, POINT2 pt1, POINT2 pt2)
      Deprecated.
      Calculates the direction of a point relative to a line
      Parameters:
      pt0 - first point fo the line
      pt1 - last point of the line
      pt2 - relative point
      Returns:
      0 if left, 1 if right, 2 if above, 3 if below
    • ExtendDirectedLine

      public static POINT2 ExtendDirectedLine(POINT2 pt1, POINT2 pt2, POINT2 pt0, int direction, double d)
      Returns a point extended perpendicularly from a line at a given direction
      Parameters:
      pt1 - first line point
      pt2 - last line point
      pt0 - on line from which to extend
      direction - the direction to extend: above, below, left, right
      d - the length to extend in pixels
    • ExtendDirectedLineText

      public static POINT2 ExtendDirectedLineText(POINT2 pt1, POINT2 pt2, POINT2 pt0, int direction, double d)
      Deprecated.
      Returns a point extended perpendicularly from a line at a given direction same as original function except it accounts for vertical lines and negative d values
      Parameters:
      pt1 - first line point
      pt2 - last line point
      pt0 - on line from which to extend
      direction - the direction to extend: above, below, left, right
      d - the length to extend in pixels
    • ExtendDirectedLine

      public static POINT2 ExtendDirectedLine(POINT2 pt1, POINT2 pt2, POINT2 pt0, int direction, double d, int style)
      Returns a point extended perpendicularly from a line at a given direction
      Parameters:
      pt1 - first line point
      pt2 - last line point
      pt0 - on line from which to extend
      direction - the direction to extend: above, below, left, right
      d - the length to extend in pixels
      style - the style to assign the return point
    • ExtendLine2Double

      protected static POINT2 ExtendLine2Double(POINT2 pt1, POINT2 pt2, double dist, int styl)
      Calculates a point along a line
      Parameters:
      pt1 - first line point
      pt2 - last line point
      dist - extension distance in pixels from the beginning of the line
      styl - the line style to assign the point
      Returns:
      the extension point
    • ExtendAngledLine

      public static POINT2 ExtendAngledLine(POINT2 pt0, POINT2 pt1, POINT2 pt2, double alpha, double d)
      Extends a point at an angle from a line.
      Parameters:
      pt0 - the first line point
      pt1 - the second line point
      pt2 - point on line from which to extend
      alpha - angle of extension in degrees
      d - the distance in pixels to extend
      Returns:
      the extension point
    • GetQuadrantDouble

      public static int GetQuadrantDouble(POINT2 pt1, POINT2 pt2)
      Returns an integer indicating the quadrant for the direction of the line from pt1 to pt2
      Parameters:
      pt1 - first line point
      pt2 - second line point
      Returns:
      the quadrant
    • GetQuadrantDouble

      public static int GetQuadrantDouble(double x1, double y1, double x2, double y2)
    • GetPixelsMin

      public static void GetPixelsMin(POINT2[] ptsSeize, int vblCounter, ref<double[]> x, ref<double[]> y)
      Returns the smallest x and y pixel values from an array of points
      Parameters:
      ptsSeize - array of points from which to find minimum vaules
      vblCounter - the number of points to test in the array
      x - OUT - an object with a member to hold the xminimum
      y - OUT - an object with a member to hold the y minimum value
    • GetPixelsMax

      public static void GetPixelsMax(POINT2[] ptsSeize, int vblCounter, ref<double[]> x, ref<double[]> y)
      Returns the largest x and y pixel values from an array of points
      Parameters:
      ptsSeize - array of points from which to find maximum values
      vblCounter - the number of points to test in the array
      x - OUT - an object with a member to hold the x maximum value
      y - OUT - an object with a member to hold the y maximum value
    • CalcClockwiseCenterDouble

      protected static double CalcClockwiseCenterDouble(POINT2[] ptsSeize)
      Returns center point for a clockwise arc to connect pts 1 and 2. Also returns an extended point on the line between pt1 and the new center Caller passes a POINT1 array of size 2 for ptsSeize, passes pt1 and pt2 in ptsSeize Returns the radius of the 90 degree arc between C (arc center) and pt1
      Parameters:
      ptsSeize - OUT - two point array also used for the returned two points
      Returns:
      the radius
    • GetArrowHead4Double

      protected static void GetArrowHead4Double(POINT2 startLinePoint, POINT2 endLinePoint, int nBiSector, int nBase, POINT2[] pResultLinePoints, int styl)
      Computes the points for an arrowhead based on a line segment
      Parameters:
      startLinePoint - segment start point
      endLinePoint - segment end point
      nBiSector - bisecotr in pixels
      nBase - base size in pixels
      pResultLinePoints - OUT - the arrowhead points
      styl - the line style to assign the last aroowhead point
    • MidPointDouble

      public static POINT2 MidPointDouble(POINT2 pt0, POINT2 pt1, int styl)
      Returns the midpoint between two points.
      Parameters:
      pt0 - the first point
      pt1 - the second point
      styl - the style to assign the mid point
      Returns:
      the mid point
    • RotateGeometryDoubleOrigin

      protected static POINT2[] RotateGeometryDoubleOrigin(POINT2[] pLinePoints, int vblCounter, int lAngle)
      Rotates an the first vblCounter points in the array about its first point
      Parameters:
      pLinePoints - OUT - the points to rotate
      vblCounter - the number of points to rotate
      lAngle - the angle in degrees to rotate
      Returns:
      pLinePoints
    • ExtendTrueLinePerpDouble

      public static POINT2 ExtendTrueLinePerpDouble(POINT2 pt0, POINT2 pt1, POINT2 pt2, double d, int styl)
      Returns a point a distance d pixels perpendicular to the pt0-pt1 line and going toward pt2
      Parameters:
      pt0 - the first line point
      pt1 - the second line point
      pt2 - the relative line point
      d - the distance in pixels
      styl - the linestyle to assign the computed point
      Returns:
      the extended point
    • CalcTrueIntersectDouble

      protected static int CalcTrueIntersectDouble(double m1, double b1, double m2, double b2, POINT2 p2, int bolVerticalSlope1, int bolVerticalSlope2, double dWidth, int lOrient, ref<double[]> X, ref<double[]> Y)
      Calculates the intersection of 2 lines pelative to a point. if one of the lines is vertical use a distance dWidth above or below the line. pass bolVertical1 = 1, or bolVertical2 = 1 if either line segment is vertical, else pass 0. return the unique intersection in X,Y pointers. p2 is the point that connects the 2 line segments to which the intersecting lines are related, i.e. the intersecting lines are a distance dWidth pixels above or below p2. uses dWidth and lOrient for cases in which at least one of the lines is vertical. for normal lines this function assumes the caller has passed the m, b for the appropriate upper or lower lines to get the desired intgercept. this function is used for calculating the upper and lower channel lines for channel types. For lOrient: see comments in Channels.ConnectTrueDouble2
      Parameters:
      m1 - slope of the first line
      b1 - intercept of the first line
      m2 - slope of the second line
      b2 - y intercept of the second line
      p2 - point that connects the 2 line segments to which the intersecting lines are related
      bolVerticalSlope1 - 1 if first segment is vertical, else 0
      bolVerticalSlope2 - 1 if second line segment is vertical, else 0
      dWidth - the distance of the intersecting lines from p2 in pixels
      lOrient - the orientation of the intersecting lines relative to the segments connecting p2
      X - OUT - object holds the x value of the intersection point
      Y - OUT - object holds the y value of the intersection point
    • CalcDistance2

      protected static double CalcDistance2(long x1, long y1, long x2, long y2)
      Returns the distance in pixels from x1,y1 to x2,y2
      Parameters:
      x1 - first point x location in pixels
      y1 - first point y location in pixels
      x2 - second point x location in pixels
      y2 - second point y location in pixels
      Returns:
      the distance
    • GetSAAFRMiddleLine

      protected static POINT2[] GetSAAFRMiddleLine(POINT2[] pLinePoints)
      gets the middle line for Rev B air corridors AC, LLTR, MRR, UAV Middle line is handled separately now because the line may have been segmented
      Parameters:
      pLinePoints -
      Returns:
    • GetSAAFRSegment

      protected static void GetSAAFRSegment(POINT2[] pLinePoints, int lineType, double dMRR)
      Computes the points for a SAAFR segment
      Parameters:
      pLinePoints - OUT - the client points also used for the returned points
      lineType - the line type
      dMRR - the symbol width
    • GetSAAFRFillSegment

      protected static void GetSAAFRFillSegment(POINT2[] pLinePoints, double dMRR)
      Called by arraysupport for SAAFR and AC fill shapes
      Parameters:
      pLinePoints -
      dMRR -
    • ArcArrayDouble

      protected static POINT2[] ArcArrayDouble(POINT2[] pResultLinePoints, int vblCounter, double dRadius, int linetype, IPointConversion converter)
      Computes an arc.
      Parameters:
      pResultLinePoints - OUT - contains center and start point and holds the result arc points
      vblCounter - the number of client points
      dRadius - the arc radius in pixels
      linetype - the linetype determines start andgle and end angle for the arc
    • CalcCircleDouble2

      protected static void CalcCircleDouble2(POINT2 Center, POINT2 pt1, int numpts, POINT2[] CirclePoints, IPointConversion converter)
      Gets geodesic circle using the converter
      Parameters:
      Center - in pixels
      pt1 - a point on the radius in pixels
      numpts - number of points to return
      CirclePoints - the result points
      converter -
    • CalcCircleDouble

      protected static void CalcCircleDouble(POINT2 Center, double radius, int numpts, POINT2[] CirclePoints, int styl)
      Computes the points for a circle. Assumes CirclePoints has been allocated with size numpts.
      Parameters:
      Center - the cicle center
      radius - the circle radius in pixels
      numpts - the number of circle points
      CirclePoints - - OUT - array of circle points
      styl - the style to set the last circle point
    • CalcCircleShape

      protected static Shape2 CalcCircleShape(POINT2 Center, double radius, int numpts, POINT2[] CirclePoints, int styl)
    • GetSquallSegment

      protected static int GetSquallSegment(POINT2 StartPt, POINT2 EndPt, POINT2[] pSquallPts, ref<int[]> sign, double amplitude, int quantity, double length)
      Gets the squall curves for a line segment Assumes pSquallPts has been allocated the proper number of points.
      Parameters:
      StartPt - segment start point
      EndPt - segment end point
      pSquallPts - OUT - the squall points
      sign - OUT - an object with a member to hold the starting curve sign for the segment.
      amplitude - the sin curve amplitutde
      quantity - the number of points for each sin curve
      length - the desired length of the curve along the segment for each sin curve
      Returns:
      segment squall points count
    • BoundOneSegment

      public static POINT2[] BoundOneSegment(POINT2 pt0, POINT2 pt1, POINT2 ul, POINT2 lr)
      side 1 ----- | | side 0 | | side 2 | | ------ side 3 bounds one segment for autoshapes that need it: bydif, fordif, fix, mnfldfix if null is returned the client should conect the original line points (i.e. no jaggies)
      Parameters:
      pt0 -
      pt1 -
      ul -
      lr -
      Returns:
      bounded segment or null
    • GetDitchSpikeDouble

      protected static int GetDitchSpikeDouble(TGLight tg, POINT2[] pLinePoints, int nOldCounter, int bWayIs)
      Computes Ditch spikes for the ATDITCH line types. This function uses linestyles provided by the caller to skip segments.
      Parameters:
      pLinePoints - OUT - the client points also used for the return points
      nOldCounter - the number of client points
      bWayIs - the parallel line to use (0) for inner or outer spikes
      linetype - the line type
      Returns:
      the symbol point count
    • MoveChannelPixels

      protected static void MoveChannelPixels(POINT2[] pLinePoints)
      Moves pixels if points are identical, used for the channel types
      Parameters:
      pLinePoints - OUT - client points also for returned points
    • moveSingleCPixels

      protected static void moveSingleCPixels(int linetype, POINT2[] pLinePoints)
      Single Concertina cannot have horizontal first segment
      Parameters:
      linetype -
      pLinePoints -
    • RotateGeometryDouble

      protected static void RotateGeometryDouble(POINT2[] pLinePoints, int vblCounter, double lAngle)
      Rotates an the first vblCounter points in the array about its first point
      Parameters:
      pLinePoints - OUT - the points to rotate
      vblCounter - the number of points to rotate
      lAngle - the angle in degrees to rotate
    • PointRelativeToLine

      protected static POINT2 PointRelativeToLine(POINT2 pt0, POINT2 pt1, POINT2 ptRelative)
      Returns the point perpendicular to the line (pt0 to pt1) at the midpoint the same distance from (and on the same side of) the the line as ptRelative.
      Parameters:
      pt0 - the first point
      pt1 - the second point
      ptRelative - the point to use for computing the return point
      Returns:
      the point perpendicular to the line at the midpoint
    • adjustCATKBYFIREControlPoint

      public static void adjustCATKBYFIREControlPoint(int linetype, ArrayList<POINT2> pLinePoints, double dist)
      shift the control point to match the shift that occurs in Channels.GetAXADDouble for CATKBYFIRE. This is because the rotary feature arrow tip must align with the anchor point
      Parameters:
      linetype -
      pLinePoints - the anchor points including the control point
      dist - the minimum required distance from the front of the rotary arrow
    • PointRelativeToLine

      public static POINT2 PointRelativeToLine(POINT2 pt0, POINT2 pt1, POINT2 atPoint, POINT2 ptRelative)
      Returns the point perpendicular to the line (pt0 to pt1) at atPoint the same distance from (and on the same side of) the the line as ptRelative.
      Parameters:
      pt0 - the first point
      pt1 - the second point
      atPoint - the point on the line at which to compute the extended point
      ptRelative - the point to use for computing the return point
      Returns:
      the point perpendicular to the line at ptRelative
    • LineRelativeToLine

      public static void LineRelativeToLine(POINT2 pt0, POINT2 pt1, POINT2 ptRelative, POINT2 pt2, POINT2 pt3)
      Returns in pt2 and pt3 the line segment parallel to segment pt0-pt1 which would contain ptRelative. pt2 corresponds to pt0 and pt3 corresponds to pt1.
      Parameters:
      pt0 - first line point
      pt1 - second line point
      ptRelative - relative line point
      pt2 - OUT - first computed relative line point
      pt3 - OUT - second computed relative line point
    • CalcMBRPoints

      public static void CalcMBRPoints(POINT2[] pLinePoints, int numpts, POINT2 ul, POINT2 lr)
    • MBRDistance

      protected static double MBRDistance(POINT2[] pLinePoints, int numpts)
      Computes the distance in pixels from upper left to lower right of the minimum bounding rectangle for the first numpts of pLinePoints
      Parameters:
      pLinePoints - the inpupt point array
      numpts - the number of points to use
      Returns:
      the distance in pixels
    • Reverse2Points

      protected static void Reverse2Points(POINT2 pt1, POINT2 pt2)
      Swaps two points.
      Parameters:
      pt1 - OUT - first point
      pt2 - OUT - second point
    • createStrokedShape

      public static Shape createStrokedShape(Shape shape)
      Creates a GeneralPath from a Path2D
      Parameters:
      shape -
      Returns:
    • cHull

      public static ArrayList<Point> cHull(ArrayList<Point> array)
      Deprecated.
      Parameters:
      array -
      Returns:
    • cHull2

      public static ArrayList<POINT2> cHull2(ArrayList<POINT2> array)
      Deprecated.
      Parameters:
      array -
      Returns:
    • getExteriorPoints

      public static void getExteriorPoints(POINT2[] pLinePoints, int vblCounter, int lineType, boolean interior)
    • getDeepCopy

      public static ArrayList<POINT2> getDeepCopy(ArrayList<POINT2> pts)