Class BaseXLayout

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

public final class BaseXLayout extends Object
This class provides static layout and paint helper methods which are used all over the GUI.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Method Details

    • hints

      public static void hints(Graphics g)
      Set desktop hints (not supported by all platforms).
      Parameters:
      g - graphics reference
    • antiAlias

      public static Graphics2D antiAlias(Graphics g)
      Activates graphics anti-aliasing.
      Parameters:
      g - graphics reference
      Returns:
      graphics reference
    • setWidth

      public static void setWidth(Component comp, int w)
      Sets the scaled component width, adopting the original component height.
      Parameters:
      comp - component
      w - width
    • setHeight

      public static void setHeight(Component comp, int h)
      Sets the scaled component height, adopting the original component width.
      Parameters:
      comp - component
      h - height
    • border

      public static EmptyBorder border(int t, int l, int b, int r)
      Returns a border with the specified insets.
      Parameters:
      t - top distance
      l - left distance
      b - bottom distance
      r - right distance
      Returns:
      border
    • addDrop

      public static void addDrop(JComponent comp, BaseXLayout.DropHandler dnd)
      Adds drag and drop functionality.
      Parameters:
      comp - component
      dnd - drag and drop handler
    • keyStroke

      public static KeyStroke keyStroke(GUICommand cmd)
      Returns a keystroke for the specified string.
      Parameters:
      cmd - command
      Returns:
      keystroke or null
    • setMnemonic

      public static void setMnemonic(AbstractButton b, StringBuilder mnem)
      Sets a mnemomic for the specified button.
      Parameters:
      b - button
      mnem - mnemonics that have already been assigned
    • contents

      public static ArrayList<Object> contents(Transferable tr)
      Returns the contents of the specified transferable.
      Parameters:
      tr - transferable
      Returns:
      contents
    • copy

      public static void copy(String text)
      Copies the specified string to the clipboard.
      Parameters:
      text - text
    • copyPath

      public static void copyPath(String path)
      Copies the specified file path to the clipboard.
      Parameters:
      path - path
    • addInteraction

      public static void addInteraction(Component comp, BaseXWindow win)
      Adds default listeners to the specified component.
      Parameters:
      comp - component
      win - parent window
    • addShortcut

      public static String addShortcut(String string, String sc)
      Adds human readable shortcuts to the specified string.
      Parameters:
      string - tooltip string
      sc - shortcut
      Returns:
      tooltip
    • value

      public static String value(double val)
      Returns the value of the specified pre value and attribute.
      Parameters:
      val - value to be evaluated
      Returns:
      value as string
    • 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 string, int w, int y)
      Draws a centered string to the panel.
      Parameters:
      g - graphics reference
      string - string to be drawn
      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 void chopString(Graphics g, byte[] string, int x, int y, int w, int fs)
      Draws the specified string and chops the last characters if there is not enough space.
      Parameters:
      g - graphics reference
      string - string
      x - x coordinate
      y - y coordinate
      w - width
      fs - font size
    • width

      public static int width(Graphics g, byte[] string)
      Returns the width of the specified string. Cached font widths are used to speed up calculation.
      Parameters:
      g - graphics reference
      string - string
      Returns:
      string width
    • width

      public static int width(Graphics g, int cp)
      Returns the character width of the specified character.
      Parameters:
      g - graphics reference
      cp - code point
      Returns:
      character width
    • resizeFont

      public static void resizeFont(JComponent comp, float factor)
      Resizes a font.
      Parameters:
      comp - component
      factor - resize factor
    • boldFont

      public static void boldFont(JComponent comp)
      Uses a bold font for the specified component.
      Parameters:
      comp - component