net.mtu.eggplant.util.gui
Class GraphicsUtils

java.lang.Object
  extended by net.mtu.eggplant.util.gui.GraphicsUtils

public final class GraphicsUtils
extends Object

graphics functions that should exist in java, but don't

Version:
$Revision$
Author:
Jon Schewe

Method Summary
static Window basicGUIMain(Component c, boolean dialog)
          Defaults title to null.
static Window basicGUIMain(Component c, boolean dialog, String title)
          a basic main for testing a graphical class.
static void centerWindow(Window window)
          Centers the window on the screen.
static void drawPolygons(Graphics g, Collection<?> v)
          draw a bunch of polygons
static void drawPolygons(Graphics g, Iterator<?> iter)
          draw a bunch of polygons
static void drawPolyLine(Graphics g, Collection<?> points)
          draw the points on the Graphics Context.
static void error(String message)
          Popup an error dialog with message in it.
static void fillPolygons(Graphics g, Collection<?> v)
          fill a bunch of polygons
static void fillPolygons(Graphics g, Iterator<?> iter)
          fill a bunch of polygons
static ImageIcon getIcon(String path)
          Create an icon from the resource at path.
static int getMaxWidth(JComboBox combo, FontMetrics fm)
           
static void notImplemented(String message)
          Popup a warning dialog displaying message.
static void setVisibleRowCount(JTable table, int rows)
          Set the preferred viewport size on a table based upon the number of rows that should be visible and the current heights of the rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

basicGUIMain

public static Window basicGUIMain(Component c,
                                  boolean dialog)
Defaults title to null.

See Also:
basicGUIMain(Component, boolean, String)

basicGUIMain

public static Window basicGUIMain(Component c,
                                  boolean dialog,
                                  String title)
a basic main for testing a graphical class. Takes the component and puts in in a JFrame or JDialog and shows the window.

Parameters:
c - the component to display
dialog - if true put in a JDialog, otherwise put in a JFrame
title - the title for the window

centerWindow

public static void centerWindow(Window window)
Centers the window on the screen.


drawPolyLine

public static void drawPolyLine(Graphics g,
                                Collection<?> points)
draw the points on the Graphics Context. Uses Graphics.drawPolyLine.

Parameters:
g - the graphics context
points - a collection of points, anything other than a point in this vector is simply skipped

drawPolygons

public static void drawPolygons(Graphics g,
                                Collection<?> v)
draw a bunch of polygons

Parameters:
g - the graphics context
v - a Container of polygons, other classes are ignored

drawPolygons

public static void drawPolygons(Graphics g,
                                Iterator<?> iter)
draw a bunch of polygons

Parameters:
g - the graphics context
iter - an Enumeration of polygons, other classes are ignored

fillPolygons

public static void fillPolygons(Graphics g,
                                Collection<?> v)
fill a bunch of polygons

Parameters:
g - the graphics context
v - a Container of polygons, other classes are ignored

fillPolygons

public static void fillPolygons(Graphics g,
                                Iterator<?> iter)
fill a bunch of polygons

Parameters:
g - the graphics context
iter - an Enumeration of polygons, other classes are ignored

getMaxWidth

public static int getMaxWidth(JComboBox combo,
                              FontMetrics fm)

getIcon

public static ImageIcon getIcon(String path)
Create an icon from the resource at path.

PreConditions
(path != null)

notImplemented

public static void notImplemented(String message)
Popup a warning dialog displaying message.


error

public static void error(String message)
Popup an error dialog with message in it.


setVisibleRowCount

public static void setVisibleRowCount(JTable table,
                                      int rows)
Set the preferred viewport size on a table based upon the number of rows that should be visible and the current heights of the rows. Based upon code from http://www.javalobby.org/java/forums/t19559.html

Parameters:
table - the table
rows - number of rows to have visible without scrolling