org.basex.gui.layout
Class BaseXLayout

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

public final class BaseXLayout
extends Object

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

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

Method Summary
static void addInteraction(Component comp, byte[] hlp, Window win)
          Adds default interactions to the specified component.
static int chopString(Graphics g, byte[] s, int x, int y, int w, int fs)
          Draws the specified string.
static void drawCell(Graphics g, int xs, int xe, int ys, int ye, boolean focus)
          Draws a colored cell.
static void drawCenter(Graphics g, String text, int w, int y)
          Draws a centered string to the panel.
static void drawTooltip(Graphics g, String tt, int x, int y, int w, int c)
          Draws a visualization tooltip.
static void fill(Graphics gg, Color c1, Color c2, int xs, int ys, int xe, int ye)
          Fills the specified area with a color gradient.
static void focus(Component cont, byte[] help)
          Sets the help text for the specified component.
static ImageIcon icon(String name)
          Returns the specified image as icon.
static Image image(String name)
          Returns the specified image.
static URL imageURL(String name)
          Returns the image url.
static void setHeight(Component comp, int h)
          Sets the component height, adopting the original component width.
static void setWidth(Component comp, int w)
          Sets the component width, adopting the original component height.
static String value(double val, boolean size, boolean date)
          Returns the value of the specified pre value and attribute.
static int width(Graphics g, byte[] s)
          Returns the width of the specified text.
static int width(Graphics g, int[] cw, int c)
          Returns the character width of the specified character.
static int width(Graphics g, 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

focus

public static void focus(Component cont,
                         byte[] help)
Sets the help text for the specified component.

Parameters:
cont - input container
help - help text

setWidth

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

Parameters:
comp - component
w - width

setHeight

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

Parameters:
comp - component
h - height

addInteraction

public static void addInteraction(Component comp,
                                  byte[] hlp,
                                  Window win)
Adds default interactions to the specified component.

Parameters:
comp - component
hlp - help text
win - parent window

icon

public static ImageIcon icon(String name)
Returns the specified image as icon.

Parameters:
name - name of icon
Returns:
icon

image

public static Image image(String name)
Returns the specified image.

Parameters:
name - name of image
Returns:
image

imageURL

public static URL imageURL(String name)
Returns the image url.

Parameters:
name - name of image
Returns:
url

value

public static 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(Graphics gg,
                        Color c1,
                        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(Graphics g,
                            int xs,
                            int xe,
                            int ys,
                            int ye,
                            boolean focus)
Draws a colored cell.

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

drawCenter

public static void drawCenter(Graphics g,
                              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(Graphics g,
                               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(Graphics g,
                        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(Graphics g,
                             byte[] s,
                             int x,
                             int y,
                             int w,
                             int fs)
Draws the specified string.

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

width

public static int width(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(Graphics g,
                        int[] cw,
                        int c)
Returns the character width of the specified character.

Parameters:
g - graphics reference
cw - array with character widths
c - character
Returns:
character width