Java Graphics Draw Arrow paintArrow(Graphics g, Color color, int startX, int startY, int width, int orientation)

Here you can find the source of paintArrow(Graphics g, Color color, int startX, int startY, int width, int orientation)

Description

paint Arrow

License

Open Source License

Declaration

public static void paintArrow(Graphics g, Color color,
                int startX, int startY, int width, int orientation)
        

Method Source Code

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

import java.awt.Color;

import java.awt.Graphics;

import javax.swing.JComponent;

public class Main {
    public static void paintArrow(Graphics g, Color color, int startX,
            int startY, int width, int orientation)
    /*      */{//from   w  ww .  j  av  a2  s .c o  m
        /*  204 */Color oldColor = g.getColor();
        /*  205 */g.setColor(color);
        /*  206 */width = width / 2 * 2 + 1;
        /*  207 */if (orientation == 0) {
            /*  208 */for (int i = 0; i < (width + 1) / 2; i++) {
                /*  209 */g.drawLine(startX + i, startY + i, startX
                        + width - i - 1, startY + i);
                /*      */}
            /*      */}
        /*  212 */else if (orientation == 1) {
            /*  213 */for (int i = 0; i < (width + 1) / 2; i++) {
                /*  214 */g.drawLine(startX + i, startY + i, startX + i,
                        startY + width - i - 1);
                /*      */}
            /*      */}
        /*  217 */g.setColor(oldColor);
        /*      */}

    public static void paintArrow(JComponent c, Graphics g, Color color,
            int startX, int startY, int width, int orientation)
    /*      */{
        /*  232 */if (!c.getComponentOrientation().isLeftToRight()) {
            /*  233 */Color oldColor = g.getColor();
            /*  234 */g.setColor(color);
            /*  235 */width = width / 2 * 2 + 1;
            /*  236 */for (int i = 0; i < (width + 1) / 2; i++) {
                /*  237 */g.drawLine(startX + width - i, startY + i,
                        startX + width - i, startY + width - i - 1);
                /*      */}
            /*  239 */g.setColor(oldColor);
            /*  240 */return;
            /*      */}
        /*      */
        /*  243 */paintArrow(g, color, startX, startY, width, orientation);
        /*      */}
}

Related

  1. paintArrow(Graphics g, int x0, int y0, int x1, int y1)