Java Draw Arrow drawArrowLine(Graphics g, int x1, int y1, int x2, int y2, int dist, boolean arrowLeft, boolean arrowRight)

Here you can find the source of drawArrowLine(Graphics g, int x1, int y1, int x2, int y2, int dist, boolean arrowLeft, boolean arrowRight)

Description

draw Arrow Line

License

Open Source License

Declaration

public static void drawArrowLine(Graphics g, int x1, int y1, int x2, int y2, int dist, boolean arrowLeft,
            boolean arrowRight) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w .j a  v a 2s .c o m*/
 *  File: GraphicsHelper.java 
 *  Copyright (c) 2004-2007  Peter Kliem (Peter.Kliem@jaret.de)
 *  A commercial license is available, see http://www.jaret.de.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 */

import java.awt.Graphics;

public class Main {
    public static void drawArrowLine(Graphics g, int x1, int y1, int x2, int y2, int dist, boolean arrowLeft,
            boolean arrowRight) {
        int off = 3;
        g.drawLine(x1 + off + 1, y1, x2 - off - 1, y2);
        if (arrowLeft) {
            g.drawLine(x1, y1, x1 + dist, y1 - off);
            g.drawLine(x1, y1, x1 + dist, y1 + off);
            g.drawLine(x1 + dist, y1 - off, x1 + dist, y1 + off);
        }
        if (arrowRight) {
            g.drawLine(x2, y2, x2 - dist, y2 - off);
            g.drawLine(x2, y2, x2 - dist, y2 + off);
            g.drawLine(x2 - dist, y2 - off, x2 - dist, y2 + off);
        }
    }
}

Related

  1. drawArrow(Graphics2D g2d, double x1, double y1, double x2, double y2)
  2. drawArrow(Graphics2D g2d, int xCenter, int yCenter, int x, int y, float stroke)
  3. drawArrowHead(final Graphics2D aG, final int aXpos, final int aYpos, final int aFactor, final int aArrowWidth, final int aArrowHeight)
  4. drawArrowHead(Graphics g, double c1, double c2, double phi, int l, int grad, boolean fill)
  5. drawArrowLine(Graphics g, int x1, int y1, int x2, int y2, int d, int h, boolean capOnly)
  6. drawDoubleHeadedArrow(final Graphics aG, final int aX1, final int aY, final int aX2)
  7. drawHorizontalArrow(Graphics g, Rectangle r, boolean direction)