org.basex.gui.layout
Class BaseXLayout

java.lang.Object
  extended by org.basex.gui.layout.BaseXLayout

public final class BaseXLayout
extends java.lang.Object

This class assembles layout and paint methods which are frequently used in the GUI.

Author:
Workgroup DBIS, University of Konstanz 2005-07, ISC License, Christian Gruen

Method Summary
static void addDefaultKeys(java.awt.Container c, Dialog l)
          Adds default notifiers for ENTER and ESCAPE to the specified component.
static void antiAlias(java.awt.Graphics g)
          Enables/Disables anti-aliasing.
static int centerPos(java.awt.Graphics g, byte[] s, int ww)
          Calculates if the string fits in one line; if yes, returns the horizontal start position.
static int chopString(java.awt.Graphics g, byte[] s, int x, int y, int w)
          Draws the specified string.
static void drawCell(java.awt.Graphics g, int xs, int xe, int ys, int ye, boolean high)
          Draw the header of the scrollbar.
static void drawCenter(java.awt.Graphics g, java.lang.String text, int w, int y)
          Draws a centered string to the panel.
static void drawRight(java.awt.Graphics g, java.lang.String text, int w, int y)
          Draws a right aligned string to the panel.
static int drawText(java.awt.Graphics g, MapRect r, byte[] s, int wrap, boolean draw)
          Draws a text.
static int drawText(java.awt.Graphics g, MapRect r, byte[] s, int m, int wrap, boolean draw)
          Draws a text.
static void enable(java.awt.Container comp, boolean enable)
          Enables or disables the specified component.
static void enableOK(javax.swing.JComponent panel, boolean enabled)
          Enables/disables the OK button in the specified panel.
static void fill(java.awt.Graphics gg, GUIConstants.FILL mode, int xs, int ys, int xe, int ye)
          Fills the specified area with a color gradient.
static BaseXBack newButtons(Dialog dialog, boolean hor, java.lang.String[] texts, byte[][] help)
          Creates a new button list.
static BaseXBack okCancel(Dialog dialog)
          Creates a OK and CANCEL button.
static void rect(java.awt.Graphics g, boolean active, int xs, int ys, int xe, int ye)
          Draws a shadowed rectangle.
static void select(javax.swing.AbstractButton but, boolean select)
          Selects or de-selects the specified component.
static void setHeight(java.awt.Container comp, int h)
          Sets the component height, adopting the original component width.
static void setSize(java.awt.Container comp, int w, int h)
          Sets the component size.
static void setWidth(java.awt.Container comp, int w)
          Sets the component width, adopting the original component height.
static int width(java.awt.Graphics g, byte[] s)
          Returns the width of the specified text.
static int width(java.awt.Graphics g, java.lang.String s)
          Returns the width of the specified text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addDefaultKeys

public static void addDefaultKeys(java.awt.Container c,
                                  Dialog l)
Adds default notifiers for ENTER and ESCAPE to the specified component.

Parameters:
c - the component that receives default notifications.
l - the parent dialog

antiAlias

public static void antiAlias(java.awt.Graphics g)
Enables/Disables anti-aliasing.

Parameters:
g - graphics reference

centerPos

public static int centerPos(java.awt.Graphics g,
                            byte[] s,
                            int ww)
Calculates if the string fits in one line; if yes, returns the horizontal start position. Otherwise, returns -1.

Parameters:
g - graphics reference
s - string to be checked
ww - maximum width
Returns:
result of check

chopString

public static int chopString(java.awt.Graphics g,
                             byte[] s,
                             int x,
                             int y,
                             int w)
Draws the specified string.

Parameters:
g - graphics reference
s - text
x - x coordinate
y - y coordinate
w - width
Returns:
width of printed string

drawCell

public static void drawCell(java.awt.Graphics g,
                            int xs,
                            int xe,
                            int ys,
                            int ye,
                            boolean high)
Draw the header of the scrollbar.

Parameters:
g - graphics reference
xs - horizontal start position
xe - horizontal end position
ys - vertical start position
ye - vertical end position
high - highlighting flag

drawCenter

public static void drawCenter(java.awt.Graphics g,
                              java.lang.String text,
                              int w,
                              int y)
Draws a centered string to the panel.

Parameters:
g - graphics reference
text - text to be painted
w - panel width
y - vertical position

drawRight

public static void drawRight(java.awt.Graphics g,
                             java.lang.String text,
                             int w,
                             int y)
Draws a right aligned string to the panel.

Parameters:
g - graphics reference
text - text to be painted
w - panel width
y - vertical position

drawText

public static int drawText(java.awt.Graphics g,
                           MapRect r,
                           byte[] s,
                           int wrap,
                           boolean draw)
Draws a text.

Parameters:
g - graphics reference
r - rectangle
s - text to be drawn
wrap - number of lines after which text is wrapped
draw - draw text (otherwise: just calculate space)
Returns:
last height that was occupied

drawText

public static int drawText(java.awt.Graphics g,
                           MapRect r,
                           byte[] s,
                           int m,
                           int wrap,
                           boolean draw)
Draws a text.

Parameters:
g - graphics reference
r - rectangle
s - text to be drawn
m - length of text
wrap - number of lines after which text is wrapped
draw - draw text (otherwise: just calculate space)
Returns:
last height that was occupied

enable

public static void enable(java.awt.Container comp,
                          boolean enable)
Enables or disables the specified component.

Parameters:
comp - component
enable - boolean flag

enableOK

public static void enableOK(javax.swing.JComponent panel,
                            boolean enabled)
Enables/disables the OK button in the specified panel.

Parameters:
panel - button panel
enabled - enabled/disabled

fill

public static void fill(java.awt.Graphics gg,
                        GUIConstants.FILL mode,
                        int xs,
                        int ys,
                        int xe,
                        int ye)
Fills the specified area with a color gradient.

Parameters:
gg - graphics reference
mode - mode for filling the component
xs - horizontal start position
ys - vertical start position
xe - horizontal end position
ye - vertical end position

newButtons

public static BaseXBack newButtons(Dialog dialog,
                                   boolean hor,
                                   java.lang.String[] texts,
                                   byte[][] help)
Creates a new button list.

Parameters:
dialog - reference to the component, reacting on button clicks.
hor - horizontal alignment
texts - button names
help - help texts
Returns:
button list

okCancel

public static BaseXBack okCancel(Dialog dialog)
Creates a OK and CANCEL button.

Parameters:
dialog - reference to the component, reacting on button clicks.
Returns:
button list

rect

public static void rect(java.awt.Graphics g,
                        boolean active,
                        int xs,
                        int ys,
                        int xe,
                        int ye)
Draws a shadowed rectangle.

Parameters:
g - graphics reference
active - active flag
xs - horizontal start position
ys - vertical start position
xe - horizontal end position
ye - vertical end position

select

public static void select(javax.swing.AbstractButton but,
                          boolean select)
Selects or de-selects the specified component.

Parameters:
but - component
select - selection flag

setHeight

public static void setHeight(java.awt.Container comp,
                             int h)
Sets the component height, adopting the original component width.

Parameters:
comp - component
h - height

setSize

public static void setSize(java.awt.Container comp,
                           int w,
                           int h)
Sets the component size.

Parameters:
comp - component
w - width
h - height

setWidth

public static void setWidth(java.awt.Container comp,
                            int w)
Sets the component width, adopting the original component height.

Parameters:
comp - component
w - width

width

public static int width(java.awt.Graphics g,
                        byte[] s)
Returns the width of the specified text. Cached font widths are used to speed up calculation.

Parameters:
g - graphics reference
s - string to be evaluated
Returns:
string width

width

public static int width(java.awt.Graphics g,
                        java.lang.String s)
Returns the width of the specified text.

Parameters:
g - graphics reference
s - string to be evaluated
Returns:
string width