/* Based on Sun's javax/swing/plaf/metal/MetalUtils.java */ package com.rle.monitor; /* * RLE Surface Crack Detector Graphing Software * * Copyright (C) 2002 RLE Technologies * For more information visit http://www.rletech.com/ * * 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 * of the License, 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ /** * @author Andy Goth * @author Eric Peterson * @author Matt Lane * @version 0.1 */ import java.awt.*; import javax.swing.*; import javax.swing.plaf.*; import javax.swing.plaf.metal.*; /** Some drawing stuff. */ public class MyUtils { public static void drawGrooveBorder(Graphics g, Rectangle r) { drawGrooveBorder(g, r.x, r.y, r.width, r.height); } public static void drawGrooveBorder(Graphics g, int x, int y, int w, int h) { g.setColor(MetalLookAndFeel.getControlHighlight()); g.drawRect(x + 1, y + 1, w - 2, h - 2); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(x, y, w - 2, h - 2); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(x, y + h - 1, x + 1, y + h - 2); g.drawLine(x + w - 1, y, x + w - 2, y + 1); } public static void drawRaisedBorder(Graphics g, Rectangle r) { drawRaisedBorder(g, r.x, r.y, r.width, r.height); } public static void drawRaisedBorder(Graphics g, int x, int y, int w, int h) { g.setColor(MetalLookAndFeel.getControlHighlight()); g.drawLine(x, y, x + w - 2, y); g.drawLine(x, y, x, y + h - 2); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawLine(x + w - 1, y + h - 1, x + 1, y + h - 1); g.drawLine(x + w - 1, y + h - 1, x + w - 1, y + 1); g.setColor(MetalLookAndFeel.getControl()); g.fillRect(x, y + h - 1, 1, 1); g.fillRect(x + w - 1, y, 1, 1); } public static void drawSunkenBorder(Graphics g, Rectangle r) { drawSunkenBorder(g, r.x, r.y, r.width, r.height); } public static void drawSunkenBorder(Graphics g, int x, int y, int w, int h) { g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawLine(x, y, x + w - 2, y); g.drawLine(x, y, x, y + h - 2); g.setColor(MetalLookAndFeel.getControlHighlight()); g.drawLine(x + w - 1, y + h - 1, x + 1, y + h - 1); g.drawLine(x + w - 1, y + h - 1, x + w - 1, y + 1); g.setColor(MetalLookAndFeel.getControl()); g.fillRect(x, y + h - 1, 1, 1); g.fillRect(x + w - 1, y, 1, 1); } public static void drawPressedBorder(Graphics g, Rectangle r) { drawPressedBorder(g, r.x, r.y, r.width, r.height); } public static void drawPressedBorder(Graphics g, int x, int y, int w, int h) { g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(x, y, x + w - 1, y); g.drawLine(x, y, x, y + h - 1); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawLine(x + w - 1, y + h - 1, x + 1, y + h - 1); g.drawLine(x + w - 1, y + h - 1, x + w - 1, y + 1); } }