public static Font GetCorrectedFont(Graphics g, String name, int style, int size) {
    Font newFont = new Font(name, style, size);
    FontMetrics metrics = g.getFontMetrics(newFont);
    int fontHeight = metrics.getHeight();

    float ratio = (float) fontHeight / (float) size;
    if (ratio < 0.9 || ratio > 1.1) {
      size = (int) (size / ratio + 0.5);
      if (size < 5) size = 5;
      newFont = new Font(name, style, size);
    }

    return newFont;
  }
  /**
   * draw arrows for the directions of movement and destination waypoint
   *
   * @param ctrl the control to paint on
   * @param moveDir degrees of movement
   * @param destDir degrees of destination waypoint
   */
  public void doDraw(Graphics g, int options) {
    g.setColor(Color.White);
    g.fillRect(0, 0, location.width, location.height);

    int fontSize = location.width / 17;
    mainFont = GetCorrectedFont(g, "Verdana", Font.BOLD, fontSize);
    g.setFont(mainFont);
    fm = g.getFontMetrics(mainFont);
    lineHeight = fm.getHeight() + 1;
    roseRadius = java.lang.Math.min((location.width * 3) / 4, location.height) / 2;

    if (northCentered) {
      // scale(location.width, location.height, null, 0);
      // super.doDraw(g, options);
      drawFullRose(
          g,
          0,
          new Color(255, 255, 255),
          new Color(200, 200, 200),
          new Color(255, 255, 255),
          new Color(200, 200, 200),
          new Color(150, 150, 150),
          new Color(75, 75, 75),
          1.0f,
          true,
          true);
    } else {
      int radius = (int) (roseRadius * 0.75f);

      g.setPen(new Pen(new Color(150, 150, 150), Pen.SOLID, 3));
      g.drawEllipse(
          location.width / 2 - radius, location.height / 2 - radius, 2 * radius, 2 * radius);
    }

    drawArrows(g);
    drawWayPointData(g);
    drawGpsData(g);
    drawLuminaryData(g);
    drawGpsStatus(g);
  }
  private void drawRosePart(
      Graphics g,
      float angle,
      Color colLeft,
      Color colRight,
      Color colBorder,
      Color colText,
      float scale,
      float innerScale,
      String strDir,
      boolean bDrawText) {
    float angleRad = angle * (float) java.lang.Math.PI / 180;
    float angleRadText = (angle + 7.5f) * (float) java.lang.Math.PI / 180;
    int centerX = location.width / 2, centerY = location.height / 2;

    float arrowLength = roseRadius * scale;
    float halfArrowWidth = arrowLength * innerScale;

    int[] pointsX = new int[3];
    int[] pointsY = new int[3];

    pointsX[0] = centerX;
    pointsY[0] = centerY;
    pointsX[1] = centerX + new Float(arrowLength * java.lang.Math.sin(angleRad)).intValue();
    pointsY[1] = centerY - new Float(arrowLength * java.lang.Math.cos(angleRad)).intValue();
    pointsX[2] =
        centerX
            + new Float(halfArrowWidth * java.lang.Math.sin(angleRad - java.lang.Math.PI / 4.0))
                .intValue();
    pointsY[2] =
        centerY
            - new Float(halfArrowWidth * java.lang.Math.cos(angleRad - java.lang.Math.PI / 4.0))
                .intValue();

    g.setPen(new Pen(colBorder, Pen.SOLID, 1));
    g.setBrush(new Brush(colLeft, Brush.SOLID));
    g.fillPolygon(pointsX, pointsY, 3);

    pointsX[2] =
        centerX
            + new Float(halfArrowWidth * java.lang.Math.sin(angleRad + java.lang.Math.PI / 4.0))
                .intValue();
    pointsY[2] =
        centerY
            - new Float(halfArrowWidth * java.lang.Math.cos(angleRad + java.lang.Math.PI / 4.0))
                .intValue();

    g.setBrush(new Brush(colRight, Brush.SOLID));
    g.fillPolygon(pointsX, pointsY, 3);

    if (bDrawText) {
      int tempFontSize = new Float(scale * mainFont.getSize()).intValue();
      Font tempFont = new Font(mainFont.getName(), Font.BOLD, tempFontSize);
      g.setFont(tempFont);
      FontMetrics tempFm = g.getFontMetrics(tempFont);
      float stringHeight = tempFm.getHeight();
      float stringWidth = tempFm.getTextWidth(strDir);
      float stringGap =
          (float) java.lang.Math.sqrt(stringHeight * stringHeight + stringWidth * stringWidth);

      float stringPosition = arrowLength - stringGap / 2.0f;
      g.setColor(colText);
      g.drawText(
          strDir,
          centerX
              + new Float(stringPosition * java.lang.Math.sin(angleRadText) - stringWidth / 2.0f)
                  .intValue(),
          centerY
              - new Float(stringPosition * java.lang.Math.cos(angleRadText) + stringHeight / 2.0f)
                  .intValue());

      g.setFont(mainFont);
    }
  }