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-08, ISC License, Christian Gruen

Field Summary
static java.text.SimpleDateFormat DATE
          Date Format.
 
Method Summary
static void addDefaultKeys(java.awt.Container c, Dialog l)
          Adds default notifiers for ENTER and ESCAPE to the specified component.
static void addHelp(java.awt.Component comp, byte[] hlp)
          Adds a help notifier to the specified component.
static void antiAlias(java.awt.Graphics g)
          Enables/Disables anti-aliasing.
static int calcHeight(java.awt.Graphics g, MapRect r, byte[] s)
          Calculates the height of the specified text.
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 focus)
          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 int drawText(java.awt.Graphics g, MapRect r, byte[] s)
          Draws a text.
static int drawText(java.awt.Graphics g, MapRect r, byte[] s, int m, boolean draw)
          Draws a text.
static void drawThumbnails(java.awt.Graphics g, MapRect r, byte[] s)
          Draws a text using thumbnail visualization.
static void drawTooltip(java.awt.Graphics g, java.lang.String tt, int x, int y, int w, int c)
          Draws a visualization tooltip.
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, java.awt.Color c1, java.awt.Color c2, 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 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 java.lang.String value(double val, boolean size, boolean date)
          Returns the value of the specified pre value and attribute.
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
 

Field Detail

DATE

public static final java.text.SimpleDateFormat DATE
Date Format.

Method Detail

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

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

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

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

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

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

addHelp

public static void addHelp(java.awt.Component comp,
                           byte[] hlp)
Adds a help notifier to the specified component.

Parameters:
comp - component
hlp - help text

enable

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

Parameters:
comp - component
enable - boolean flag

select

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

Parameters:
but - component
select - selection flag

value

public static java.lang.String value(double val,
                                     boolean size,
                                     boolean date)
Returns the value of the specified pre value and attribute.

Parameters:
val - value to be evaluated
size - size flag
date - date flag
Returns:
value as string

fill

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

Parameters:
gg - graphics reference
c1 - first color
c2 - second color
xs - horizontal start position
ys - vertical start position
xe - horizontal end position
ye - vertical end position

drawCell

public static void drawCell(java.awt.Graphics g,
                            int xs,
                            int xe,
                            int ys,
                            int ye,
                            boolean focus)
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
focus - highlighting flag

antiAlias

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

Parameters:
g - graphics reference

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

drawTooltip

public static void drawTooltip(java.awt.Graphics g,
                               java.lang.String tt,
                               int x,
                               int y,
                               int w,
                               int c)
Draws a visualization tooltip.

Parameters:
g - graphics reference
tt - tooltip label
x - horizontal position
y - vertical position
w - width
c - color color depth

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

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

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

calcHeight

public static int calcHeight(java.awt.Graphics g,
                             MapRect r,
                             byte[] s)
Calculates the height of the specified text.

Parameters:
g - graphics reference
r - rectangle
s - text to be drawn
Returns:
last height that was occupied

drawText

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

Parameters:
g - graphics reference
r - rectangle
s - text to be drawn
Returns:
last height that was occupied

drawText

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

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

drawThumbnails

public static void drawThumbnails(java.awt.Graphics g,
                                  MapRect r,
                                  byte[] s)
Draws a text using thumbnail visualization.

Parameters:
g - graphics reference
r - rectangle
s - text to be drawn

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