static {
   PATH_INDETERMINATE_HORIZONTAL_RECT1_TRANSLATE_X.moveTo(-522.6F, 0.0F);
   PATH_INDETERMINATE_HORIZONTAL_RECT1_TRANSLATE_X.rCubicTo(
       48.89972F, 0.0F, 166.02657F, 0.0F, 301.2173F, 0.0F);
   PATH_INDETERMINATE_HORIZONTAL_RECT1_TRANSLATE_X.rCubicTo(
       197.58128F, 0.0F, 420.9827F, 0.0F, 420.9827F, 0.0F);
   PATH_INDETERMINATE_HORIZONTAL_RECT1_SCALE_X = new Path();
   PATH_INDETERMINATE_HORIZONTAL_RECT1_SCALE_X.moveTo(0.0F, 0.1F);
   PATH_INDETERMINATE_HORIZONTAL_RECT1_SCALE_X.lineTo(1.0F, 0.8268492F);
   PATH_INDETERMINATE_HORIZONTAL_RECT1_SCALE_X.lineTo(2.0F, 0.1F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_TRANSLATE_X = new Path();
   PATH_INDETERMINATE_HORIZONTAL_RECT2_TRANSLATE_X.moveTo(-197.6F, 0.0F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_TRANSLATE_X.rCubicTo(
       14.28182F, 0.0F, 85.07782F, 0.0F, 135.54689F, 0.0F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_TRANSLATE_X.rCubicTo(
       54.26191F, 0.0F, 90.42461F, 0.0F, 168.24332F, 0.0F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_TRANSLATE_X.rCubicTo(
       144.72154F, 0.0F, 316.40982F, 0.0F, 316.40982F, 0.0F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_SCALE_X = new Path();
   PATH_INDETERMINATE_HORIZONTAL_RECT2_SCALE_X.moveTo(0.0F, 0.1F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_SCALE_X.lineTo(1.0F, 0.5713795F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_SCALE_X.lineTo(2.0F, 0.90995026F);
   PATH_INDETERMINATE_HORIZONTAL_RECT2_SCALE_X.lineTo(3.0F, 0.1F);
 }
  private void parsePath() {
    mPath = new Path();
    char method;

    Scanner in = new Scanner(mPathData);

    while (in.hasNextLine()) {
      // Handle first string, which is a letter indicating which path method to use
      method = in.next().charAt(0);

      switch (method) {
        case 'M':
          mPath.moveTo(in.nextFloat(), in.nextFloat());
          break;
        case 'c':
          mPath.rCubicTo(
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat());
          break;
        case 'C':
          mPath.cubicTo(
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat(),
              in.nextFloat());
          break;
        case 'L':
          mPath.lineTo(in.nextFloat(), in.nextFloat());
          break;
        case 'l':
          mPath.rLineTo(in.nextFloat(), in.nextFloat());
          break;
        case 'z':
          mPath.close();
          break;
      }
    }
  }
Exemple #3
0
  // draw path 96x96
  public static void calcTurnPath(Path pathForTurn, TurnType turnType, Matrix transform) {
    if (turnType == null) {
      return;
    }
    pathForTurn.reset();

    int c = 48;
    int w = 16;
    pathForTurn.moveTo(c, 94);
    float sarrowL = 30; // side of arrow
    float harrowL = (float) Math.sqrt(2) * sarrowL; // hypotenuse of arrow
    float spartArrowL = (float) ((sarrowL - w / Math.sqrt(2)) / 2);
    float hpartArrowL = (float) (harrowL - w) / 2;

    if (TurnType.C.equals(turnType.getValue())) {
      int h = 65;

      pathForTurn.rMoveTo(w / 2, 0);
      pathForTurn.rLineTo(0, -h);
      pathForTurn.rLineTo(hpartArrowL, 0);
      pathForTurn.rLineTo(-harrowL / 2, -harrowL / 2); // center
      pathForTurn.rLineTo(-harrowL / 2, harrowL / 2);
      pathForTurn.rLineTo(hpartArrowL, 0);
      pathForTurn.rLineTo(0, h);
    } else if (TurnType.TR.equals(turnType.getValue()) || TurnType.TL.equals(turnType.getValue())) {
      int b = TurnType.TR.equals(turnType.getValue()) ? 1 : -1;
      int h = 36;
      float quadShiftX = 22;
      float quadShiftY = 22;

      pathForTurn.rMoveTo(-b * 8, 0);
      pathForTurn.rLineTo(0, -h);
      pathForTurn.rQuadTo(0, -quadShiftY, b * quadShiftX, -quadShiftY);
      pathForTurn.rLineTo(0, hpartArrowL);
      pathForTurn.rLineTo(b * harrowL / 2, -harrowL / 2); // center
      pathForTurn.rLineTo(-b * harrowL / 2, -harrowL / 2);
      pathForTurn.rLineTo(0, hpartArrowL);
      pathForTurn.rQuadTo(-b * (quadShiftX + w), 0, -b * (quadShiftX + w), quadShiftY + w);
      pathForTurn.rLineTo(0, h);
    } else if (TurnType.TSLR.equals(turnType.getValue())
        || TurnType.TSLL.equals(turnType.getValue())) {
      int b = TurnType.TSLR.equals(turnType.getValue()) ? 1 : -1;
      int h = 40;
      int quadShiftY = 22;
      float quadShiftX = (float) (quadShiftY / (1 + Math.sqrt(2)));
      float nQuadShiftX = (sarrowL - 2 * spartArrowL) - quadShiftX - w;
      float nQuadShifty = quadShiftY + (sarrowL - 2 * spartArrowL);

      pathForTurn.rMoveTo(-b * 4, 0);
      pathForTurn.rLineTo(0, -h /* + partArrowL */);
      pathForTurn.rQuadTo(
          0,
          -quadShiftY + quadShiftX /*- partArrowL*/,
          b * quadShiftX,
          -quadShiftY /*- partArrowL*/);
      pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
      pathForTurn.rLineTo(0, -sarrowL); // center
      pathForTurn.rLineTo(-b * sarrowL, 0);
      pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
      pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty);
      pathForTurn.rLineTo(0, h);
    } else if (TurnType.TSHR.equals(turnType.getValue())
        || TurnType.TSHL.equals(turnType.getValue())) {
      int b = TurnType.TSHR.equals(turnType.getValue()) ? 1 : -1;
      int h = 45;
      float quadShiftX = 22;
      float quadShiftY = -(float) (quadShiftX / (1 + Math.sqrt(2)));
      float nQuadShiftX = -(sarrowL - 2 * spartArrowL) - quadShiftX - w;
      float nQuadShiftY = -quadShiftY + (sarrowL - 2 * spartArrowL);

      pathForTurn.rMoveTo(-b * 8, 0);
      pathForTurn.rLineTo(0, -h);
      pathForTurn.rQuadTo(0, -(quadShiftX - quadShiftY), b * quadShiftX, quadShiftY);
      pathForTurn.rLineTo(-b * spartArrowL, spartArrowL);
      pathForTurn.rLineTo(b * sarrowL, 0); // center
      pathForTurn.rLineTo(0, -sarrowL);
      pathForTurn.rLineTo(-b * spartArrowL, spartArrowL);
      pathForTurn.rCubicTo(
          b * nQuadShiftX / 2,
          nQuadShiftX / 2,
          b * nQuadShiftX,
          nQuadShiftX / 2,
          b * nQuadShiftX,
          nQuadShiftY);
      pathForTurn.rLineTo(0, h);
    } else if (TurnType.TU.equals(turnType.getValue())) {
      int h = 54;
      float quadShiftX = 13;
      float quadShiftY = 13;

      pathForTurn.rMoveTo(28, 0);
      pathForTurn.rLineTo(0, -h);
      pathForTurn.rQuadTo(0, -(quadShiftY + w), -(quadShiftX + w), -(quadShiftY + w));
      pathForTurn.rQuadTo(-(quadShiftX + w), 0, -(quadShiftX + w), (quadShiftY + w));
      pathForTurn.rLineTo(-hpartArrowL, 0);
      pathForTurn.rLineTo(harrowL / 2, harrowL / 2); // center
      pathForTurn.rLineTo(harrowL / 2, -harrowL / 2);
      pathForTurn.rLineTo(-hpartArrowL, 0);
      pathForTurn.rQuadTo(0, -quadShiftX, quadShiftX, -quadShiftY);
      pathForTurn.rQuadTo(quadShiftX, 0, quadShiftX, quadShiftY);
      pathForTurn.rLineTo(0, h);
    } else if (turnType != null && turnType.isRoundAbout()) {
      float t = turnType.getTurnAngle();
      if (t >= 170 && t < 220) {
        t = 220;
      } else if (t > 160 && t < 170) {
        t = 160;
      }
      float sweepAngle = (t - 360) - 180;
      if (sweepAngle < -360) {
        sweepAngle += 360;
      }
      float r1 = 32f;
      float r2 = 24f;
      float angleToRot = 0.3f;

      pathForTurn.moveTo(48, 48 + r1 + 8);
      pathForTurn.lineTo(48, 48 + r1);
      RectF r = new RectF(48 - r1, 48 - r1, 48 + r1, 48 + r1);
      pathForTurn.arcTo(r, 90, sweepAngle);
      float angleRad = (float) ((180 + sweepAngle) * Math.PI / 180f);

      pathForTurn.lineTo(
          48 + (r1 + 4) * FloatMath.sin(angleRad), 48 - (r1 + 4) * FloatMath.cos(angleRad));
      pathForTurn.lineTo(
          48 + (r1 + 6) * FloatMath.sin(angleRad + angleToRot / 2),
          48 - (r1 + 6) * FloatMath.cos(angleRad + angleToRot / 2));
      pathForTurn.lineTo(
          48 + (r1 + 12) * FloatMath.sin(angleRad - angleToRot / 2),
          48 - (r1 + 12) * FloatMath.cos(angleRad - angleToRot / 2));
      pathForTurn.lineTo(
          48 + (r1 + 6) * FloatMath.sin(angleRad - 3 * angleToRot / 2),
          48 - (r1 + 6) * FloatMath.cos(angleRad - 3 * angleToRot / 2));
      pathForTurn.lineTo(
          48 + (r1 + 4) * FloatMath.sin(angleRad - angleToRot),
          48 - (r1 + 4) * FloatMath.cos(angleRad - angleToRot));
      pathForTurn.lineTo(
          48 + r2 * FloatMath.sin(angleRad - angleToRot),
          48 - r2 * FloatMath.cos(angleRad - angleToRot));

      r.set(48 - r2, 48 - r2, 48 + r2, 48 + r2);
      pathForTurn.arcTo(r, 360 + sweepAngle + 90, -sweepAngle);
      pathForTurn.lineTo(40, 48 + r2);
      pathForTurn.lineTo(40, 48 + r1 + 8);
      pathForTurn.close();
    }
    pathForTurn.close();
    if (transform != null) {
      pathForTurn.transform(transform);
    }
  }