Esempio n. 1
0
  /**
   * Draws a single arrow head
   *
   * @param aG the canvas to draw on;
   * @param aXpos the X position of the arrow head;
   * @param aYpos the (center) Y position of the arrow head;
   * @param aFactor +1 to have a left-facing arrow head, -1 to have a right-facing arrow head;
   * @param aArrowWidth the total width of the arrow head;
   * @param aArrowHeight the total height of the arrow head.
   */
  public static final void drawArrowHead(
      final Graphics2D aG,
      final int aXpos,
      final int aYpos,
      final int aFactor,
      final int aArrowWidth,
      final int aArrowHeight) {
    final double halfHeight = aArrowHeight / 2.0;
    final int x1 = aXpos + (aFactor * aArrowWidth);
    final int y1 = (int) Math.ceil(aYpos - halfHeight);
    final int y2 = (int) Math.floor(aYpos + halfHeight);

    final Polygon arrowHead = new Polygon();
    arrowHead.addPoint(aXpos, aYpos);
    arrowHead.addPoint(x1, y1);
    arrowHead.addPoint(x1, y2);

    aG.fill(arrowHead);
  }