com.jrefinery.ui
Class RefineryUtilities

java.lang.Object
  extended by com.jrefinery.ui.RefineryUtilities

public class RefineryUtilities
extends java.lang.Object

A collection of utility methods relating to user interfaces.


Constructor Summary
RefineryUtilities()
           
 
Method Summary
static void centerDialogInParent(java.awt.Dialog dialog)
          Positions the specified dialog within its parent.
static void centerFrameOnScreen(java.awt.Window frame)
          Positions the specified frame in the middle of the screen.
static javax.swing.JButton createJButton(java.lang.String label, java.awt.Font font)
           
static javax.swing.JLabel createJLabel(java.lang.String text, java.awt.Font font)
          Creates a label with a specific font.
static javax.swing.JLabel createJLabel(java.lang.String text, java.awt.Font font, java.awt.Color color)
          Creates a label with a specific font and color.
static javax.swing.JPanel createTablePanel(javax.swing.table.TableModel model)
          Creates a panel that contains a table based on the specified table model.
static void drawRotatedString(java.lang.String text, java.awt.Graphics2D g2, float x, float y, double rotation)
          A utility method for drawing rotated text.
static java.awt.geom.Point2D getPointInRectangle(double x, double y, java.awt.geom.Rectangle2D area)
          Returns a point based on (x, y) but constrained to be within the bounds of a given rectangle.
static void positionDialogRelativeToParent(java.awt.Dialog dialog, double horizontalPercent, double verticalPercent)
          Positions the specified dialog at a position relative to its parent.
static void positionFrameOnScreen(java.awt.Window frame, double horizontalPercent, double verticalPercent)
          Positions the specified frame at a relative position in the screen, where 50% is considered to be the center of the screen.
static void positionFrameRandomly(java.awt.Window frame)
          Positions the specified frame at a random location on the screen while ensuring that the entire frame is visible (provided that the frame is smaller than the screen).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RefineryUtilities

public RefineryUtilities()
Method Detail

centerFrameOnScreen

public static void centerFrameOnScreen(java.awt.Window frame)
Positions the specified frame in the middle of the screen.

Parameters:
frame - The frame to be centered on the screen.

positionFrameOnScreen

public static void positionFrameOnScreen(java.awt.Window frame,
                                         double horizontalPercent,
                                         double verticalPercent)
Positions the specified frame at a relative position in the screen, where 50% is considered to be the center of the screen.

Parameters:
frame - The frame.
horizontalPercent - The relative horizontal position of the frame (0.0 to 1.0, where 0.5 is the center of the screen).
verticalPercent - The relative vertical position of the frame (0.0 to 1.0, where 0.5 is the center of the screen).

positionFrameRandomly

public static void positionFrameRandomly(java.awt.Window frame)
Positions the specified frame at a random location on the screen while ensuring that the entire frame is visible (provided that the frame is smaller than the screen).

Parameters:
frame - The frame.

centerDialogInParent

public static void centerDialogInParent(java.awt.Dialog dialog)
Positions the specified dialog within its parent.

Parameters:
dialog - The dialog to be positioned on the screen.

positionDialogRelativeToParent

public static void positionDialogRelativeToParent(java.awt.Dialog dialog,
                                                  double horizontalPercent,
                                                  double verticalPercent)
Positions the specified dialog at a position relative to its parent.

Parameters:
dialog - The dialog to be positioned.
horizontalPercent. -
verticalPercent. -

createTablePanel

public static javax.swing.JPanel createTablePanel(javax.swing.table.TableModel model)
Creates a panel that contains a table based on the specified table model.

Parameters:
model - The table model to use when constructing the table.

createJLabel

public static javax.swing.JLabel createJLabel(java.lang.String text,
                                              java.awt.Font font)
Creates a label with a specific font.

Parameters:
text - The text for the label.
font - The font.

createJLabel

public static javax.swing.JLabel createJLabel(java.lang.String text,
                                              java.awt.Font font,
                                              java.awt.Color color)
Creates a label with a specific font and color.

Parameters:
text - The text for the label.
font - The font.
color - The color.

createJButton

public static javax.swing.JButton createJButton(java.lang.String label,
                                                java.awt.Font font)

drawRotatedString

public static void drawRotatedString(java.lang.String text,
                                     java.awt.Graphics2D g2,
                                     float x,
                                     float y,
                                     double rotation)
A utility method for drawing rotated text.

A common rotation is -Math.PI/2 which draws text 'vertically' (with the top of the characters on the left).

Parameters:
text - The text.
g2 - The graphics device.
x - The x-coordinate.
y - The y-coordinate.
rotation - The clockwise rotation (in radians).

getPointInRectangle

public static java.awt.geom.Point2D getPointInRectangle(double x,
                                                        double y,
                                                        java.awt.geom.Rectangle2D area)
Returns a point based on (x, y) but constrained to be within the bounds of a given rectangle.

Parameters:
x - The x-coordinate.
y - The y-coordinate.
area - The constraining rectangle.
Returns:
A point within the rectangle.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.