コード例 #1
0
 public static Shape createLineRegion(Line2D line, float width)
 {
   GeneralPath generalPath = new GeneralPath();
   float num1 = (float) line.getX1();
   float num2 = (float) line.getX2();
   float num3 = (float) line.getY1();
   float num4 = (float) line.getY2();
   if ((double) (num2 - num1) != 0.0)
   {
     double num5 = Math.atan((double) ((num4 - num3) / (num2 - num1)));
     float num6 = (float) Math.sin(num5) * width;
     float num7 = (float) Math.cos(num5) * width;
     ((Path2D.Float) generalPath).moveTo(num1 - num6, num3 + num7);
     ((Path2D.Float) generalPath).lineTo(num1 + num6, num3 - num7);
     ((Path2D.Float) generalPath).lineTo(num2 + num6, num4 - num7);
     ((Path2D.Float) generalPath).lineTo(num2 - num6, num4 + num7);
     ((Path2D) generalPath).closePath();
   }
   else
   {
     ((Path2D.Float) generalPath).moveTo(num1 - width / 2f, num3);
     ((Path2D.Float) generalPath).lineTo(num1 + width / 2f, num3);
     ((Path2D.Float) generalPath).lineTo(num2 + width / 2f, num4);
     ((Path2D.Float) generalPath).lineTo(num2 - width / 2f, num4);
     ((Path2D) generalPath).closePath();
   }
   return (Shape) generalPath;
 }