Java Graphics Draw drawFleche1(Graphics g, double x, double y, double x1, double y1, int L)

Here you can find the source of drawFleche1(Graphics g, double x, double y, double x1, double y1, int L)

Description

draw Fleche

License

Open Source License

Declaration

static private void drawFleche1(Graphics g, double x, double y, double x1, double y1, int L) 

Method Source Code


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

import java.awt.*;

public class Main {

    static private void drawFleche1(Graphics g, double x, double y, double x1, double y1, int L) {
        g.drawLine((int) x, (int) y, (int) x1, (int) y1);

        double theta, delta;
        if (x != x1) {
            theta = Math.atan((y1 - y) / (x1 - x));
            if (x > x1)
                theta += Math.PI;
        } else {/*  ww  w .  jav  a 2  s. c  o m*/
            if (y < y1)
                theta = Math.PI / 2;
            else
                theta = -Math.PI / 2;
        }
        delta = 3.0 * Math.PI / 4;
        double dx1 = L * Math.cos(theta + delta);
        double dy1 = L * Math.sin(theta + delta);
        double dx2 = L * Math.cos(theta - delta);
        double dy2 = L * Math.sin(theta - delta);

        g.drawLine((int) (x1 + dx1), (int) (y1 + dy1), (int) x1, (int) y1);
        g.drawLine((int) x1, (int) y1, (int) (x1 + dx2), (int) (y1 + dy2));

    }
}

Related

  1. drawEdge(Graphics g, int w, int h)
  2. drawEtchedRect(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
  3. drawFilledBox(Graphics2D g, int x, int y, int width, int height)
  4. drawFilledOctagon(Graphics2D g, int x, int y, float size)
  5. drawFilter(Graphics g, Color c, double transparency, int midx, int midy, int rx, int ry)
  6. drawFocus(Graphics g, int x, int y, int w, int h)
  7. drawFocus(Graphics2D g2, int iX, int iY, int iWidth, int iHeight)
  8. drawFrank(Graphics g, int x, int y)
  9. drawGatter(Graphics g, int xDist, int yDist)