Here you can find the source of drawArrowHead(final Graphics2D aG, final int aXpos, final int aYpos, final int aFactor, final int aArrowWidth, final int aArrowHeight)
Parameter | Description |
---|---|
aG | the canvas to draw on; |
aXpos | the X position of the arrow head; |
aYpos | the (center) Y position of the arrow head; |
aFactor | +1 to have a left-facing arrow head, -1 to have a right-facing arrow head; |
aArrowWidth | the total width of the arrow head; |
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)
//package com.java2s; /*/*from w ww.j a v a2 s . c o m*/ * OpenBench LogicSniffer / SUMP project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * * * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl */ import java.awt.*; public class Main { /** * 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); } }