Java Graphics Draw Arrow paintArrow(Graphics g, int x0, int y0, int x1, int y1)

Here you can find the source of paintArrow(Graphics g, int x0, int y0, int x1, int y1)

Description

paint Arrow

License

Open Source License

Declaration

public static void paintArrow(Graphics g, int x0, int y0, int x1, int y1) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

public class Main {
    public static void paintArrow(Graphics g, int x0, int y0, int x1, int y1) {
        int deltaX = x1 - x0;
        int deltaY = y1 - y0;
        double frac = 0.2;

        g.drawLine(x0, y0, x1, y1);/*from w  w  w .j ava2  s  .c  o  m*/
        g.drawLine(x0 + (int) ((1 - frac) * deltaX + frac * deltaY),
                y0 + (int) ((1 - frac) * deltaY - frac * deltaX), x1, y1);
        g.drawLine(x0 + (int) ((1 - frac) * deltaX - frac * deltaY),
                y0 + (int) ((1 - frac) * deltaY + frac * deltaX), x1, y1);

    }
}

Related

  1. paintArrow(Graphics g, Color color, int startX, int startY, int width, int orientation)