Java Graphics Draw drawScrollBar(Graphics g, int which, int direction, int x, int y, int fmWidth, int fmHeight, Color fg, Color bg)

Here you can find the source of drawScrollBar(Graphics g, int which, int direction, int x, int y, int fmWidth, int fmHeight, Color fg, Color bg)

Description

draw Scroll Bar

License

Open Source License

Declaration

public static void drawScrollBar(Graphics g, int which, int direction, int x, int y, int fmWidth, int fmHeight,
            Color fg, Color bg) 

Method Source Code

//package com.java2s;
/**/*from   ww  w  .ja v a  2 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 drawScrollBar(Graphics g, int which, int direction, int x, int y, int fmWidth, int fmHeight,
            Color fg, Color bg) {

        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) ;
            g.setColor(bg);
            g.fillRect(x, y, fmWidth, fmHeight);
            g.setColor(fg);
            g.drawLine(x, y, x, y + fmHeight);
            g.drawLine(x + fmWidth - 1, y, x + fmWidth - 1, y + fmHeight);

            //            g.drawRect(x,y,fmWidth-2,fmHeight);
        }
        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.setColor(bg);
            g.fillRect(x, y, fmWidth, fmHeight);
            g.setColor(fg);
            g.drawLine(x, y, x, y + fmHeight);
            g.drawLine(x + fmWidth - 1, y, x + fmWidth - 1, y + fmHeight);

            //            g.drawRect(x,y,fmWidth-2,fmHeight);

        }

        if (direction == 1) {
            g.setColor(fg.brighter());
            g.drawLine(x + (fmWidth / 2), y + 2, x + 2, y + fmHeight - 4);

            g.setColor(fg.darker());

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

            g.drawLine(x + 2, y + fmHeight - 4, x + fmWidth - 2, y + fmHeight - 4);

            g.setColor(fg);
            g.drawLine(x, y, x + fmWidth - 1, y);

            g.drawLine(x, y + fmHeight - 1, x + fmWidth - 1, y + fmHeight - 1);

        }

        if (direction == 2) {
            g.setColor(fg.brighter());
            g.drawLine(x + (fmWidth / 2), y + fmHeight - 4, x + 2, y + 2);
            g.drawLine(x + 2, y + 2, x + fmWidth - 2, y + 2);

            g.setColor(fg.darker());

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

            g.setColor(fg);
            g.drawLine(x, y, x + fmWidth, y);

            g.drawLine(x, y + fmHeight - 1, x + fmWidth, y + fmHeight - 1);

        }

        if (direction == 3) {

            g.setColor(fg);
            g.fillRect(x + 2, y, fmWidth - 4, fmHeight);

            //            g.setColor(bg);
            //            g.fillOval(x + 3,
            //                        y + 2,
            //                        fmWidth -4,
            //                        fmHeight - 4);

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

    }
}

Related

  1. drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height, final Color main, final Color progress, final int alpha, final int percentage)
  2. drawRainbow(Graphics2D g2, int x, int y, int Width, int Height, int Mode)
  3. drawRequiredMarker(Graphics2D g2, int x, int y, int iconSize)
  4. drawRTriangle(Graphics g, Color color, int x, int y, int r)
  5. drawScaleTick(Graphics g, int x, int y, boolean yAxisP, int length)
  6. drawSelectionBox(Graphics g)
  7. drawSelectionPoint(Graphics g, Point p)
  8. drawSpline(Graphics graphics, int x1, int y1, int x2, int y2, int x3, int y3)
  9. drawSquarePoint(Graphics2D g2, Point2D.Double pt, int ptSize, Color color)