Java Draw 3D draw3DOne(Graphics g, int which, int x, int y, int fmWidth, int fmHeight)

Here you can find the source of draw3DOne(Graphics g, int which, int x, int y, int fmWidth, int fmHeight)

Description

draw D One

License

Open Source License

Declaration

public static void draw3DOne(Graphics g, int which, int x, int y, int fmWidth, int fmHeight) 

Method Source Code

//package com.java2s;
/**//from   w ww .  j ava2  s .co  m
 * Title: tn5250J
 * Copyright:   Copyright (c) 2001,202,2003
 * Company:
 * @author  Kenneth J. Pouncey
 * @version 0.4
 *
 * Description:
 *
 * 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, 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 software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA
 *
 */

import java.awt.Color;

import java.awt.Graphics;

public class Main {
    public static final int RAISED = 1;
    public static final int INSET = 2;

    public static void draw3DOne(Graphics g, int which, int x, int y, int fmWidth, int fmHeight) {

        Color oldColor = g.getColor(); // make sure we leave it as we found it
        //      g.translate(x, y);

        if (which == INSET) {

            g.setColor(Color.black);
            // --  horizontal top
            g.drawLine(x, y, x + fmWidth - 2, y);

            // --  horizontal top
            g.drawLine(x, y + 1, x + fmWidth - 3, y + 1);

            // | vertical
            g.drawLine(x, y, x, y + fmHeight - 2);

            // | vertical
            g.drawLine(x + 1, y, x + 1, y + fmHeight - 2);

            g.setColor(Color.white);

            // --  horizontal bottom
            g.drawLine(x, y + fmHeight - 2, x + fmWidth - 2, y + fmHeight - 2);

            // | vertical right
            g.drawLine(x + fmWidth - 1, y, x + fmWidth - 1, y + fmHeight - 2);

            g.setColor(Color.lightGray);

            // | vertical right
            g.drawLine(x + fmWidth - 2, y + 1, x + fmWidth - 2, y + fmHeight - 3);

            // --  horizontal bottom
            g.drawLine(x + 1, y + fmHeight - 3, x + fmWidth - 2, y + fmHeight - 3);

        }
        if (which == RAISED) {

            g.setColor(Color.white);
            // --  horizontal top
            g.drawLine(x, y, x + fmWidth - 2, y);

            // --  horizontal top
            g.drawLine(x, y + 1, x + fmWidth - 3, y + 1);

            // | vertical
            g.drawLine(x, y, x, y + fmHeight - 2);

            // | vertical
            g.drawLine(x + 1, y, x + 1, y + fmHeight - 2);

            g.setColor(Color.darkGray);

            // --  horizontal bottom
            g.drawLine(x, y + fmHeight - 2, x + fmWidth - 2, y + fmHeight - 2);

            // | vertical right
            g.drawLine(x + fmWidth - 1, y, x + fmWidth - 1, y + fmHeight - 2);

            g.setColor(Color.lightGray);

            // | vertical right
            g.drawLine(x + fmWidth - 2, y + 1, x + fmWidth - 2, y + fmHeight - 3);

            // --  horizontal bottom
            g.drawLine(x + 1, y + fmHeight - 3, x + fmWidth - 2, y + fmHeight - 3);

        }

        //      g.translate(-x, -y);
        g.setColor(oldColor);

    }
}

Related

  1. draw3DMiddle(Graphics g, int which, int x, int y, int fmWidth, int fmHeight)