public class SGUI
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SGUI.TextCopyPasteMouseListener
Listener for copy-paste menu.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTO_ADJUST
This property can be set on components to be automatically adjusted to equal sizes.
|
protected static java.util.Set<java.lang.String> |
BROKEN_UI_IDS
IDs of potentially broken UIs that override behavior like setBackground().
|
Constructor and Description |
---|
SGUI() |
Modifier and Type | Method and Description |
---|---|
static void |
addCopyPasteMenu(javax.swing.text.JTextComponent textcomponent)
Adds a copy & paste menu to a text component.
|
static void |
adjustComponentHorizontalSizes(javax.swing.JComponent[] components)
Adjust components to equal sizes according to their
miminum, maximum, and preferred sizes horizontally.
|
static void |
adjustComponentSizes(java.awt.Component[] components)
Adjust components to equal sizes according to their
miminum, maximum, and preferred sizes.
|
static void |
adjustComponentSizes(java.awt.Container parent)
Adjust all marked components to equal sizes according to their
miminum, maximum, and preferred sizes.
|
static void |
adjustComponentSizes(javax.swing.JComponent[] components)
Adjust components to equal sizes according to their
miminum, maximum, and preferred sizes.
|
static void |
adjustComponentVerticalSizes(javax.swing.JComponent[] components)
Adjust components to equal sizes according to their
miminum, maximum, and preferred sizes vertically.
|
static java.awt.Point |
calculateMiddlePosition(java.awt.Window win)
Calculate the middle position of a window relativ to
|
static java.awt.Point |
calculateMiddlePosition(java.awt.Window outer,
java.awt.Window win)
Calculate the middle position of a window relativ to
|
static java.lang.String |
colorToHTML(java.awt.Color color)
Convert a color to an html representation.
|
static double[] |
colorToRgba(java.awt.Color color)
Converts a color to RGBA array.
|
static java.awt.image.BufferedImage |
convertBufferedImageType(java.awt.image.BufferedImage original,
int type)
Converts a buffered image to a new image type.
|
static javax.swing.Action |
createAction(java.lang.String name,
javax.swing.Icon icon,
java.awt.event.ActionListener listener)
Create an action.
|
static boolean |
createDialog(java.lang.String title,
javax.swing.JComponent content,
javax.swing.JComponent comp)
Create a dialog with a specific content panel.
|
static boolean |
createDialog(java.lang.String title,
javax.swing.JComponent content,
javax.swing.JComponent comp,
boolean info)
Create a dialog with a specific content panel.
|
static void |
createEdgelessHorizontalGroupLayout(java.awt.Container container,
javax.swing.JComponent[] components,
boolean fixedsize)
Creates a simple edgeless, vertical arrangement using group layout.
|
static void |
createEdgelessHorizontalGroupLayout(java.awt.Container container,
javax.swing.JComponent[] components,
boolean fixedsize,
boolean rightalign)
Creates a simple edgeless, vertical arrangement using group layout.
|
static void |
createHorizontalGroupLayout(java.awt.Container container,
javax.swing.JComponent[] components,
boolean fixedsize)
Creates a simple vertical arrangement using group layout with gaps.
|
static javax.swing.JMenuBar |
createMenuBar(javax.swing.Action[] actions)
Create a menu bar, given a list of actions.
|
static javax.swing.JTable |
createReadOnlyTable()
Create a table that displays its contents using nto editable text fields.
|
static javax.swing.JToolBar |
createToolBar(java.lang.String name,
javax.swing.Action[] actions)
Create a tool bar, given a list of actions.
|
static void |
createVerticalGroupLayout(java.awt.Container container,
javax.swing.JComponent[] components,
boolean fixedsize)
Creates a simple vertical arrangement using group layout with gaps.
|
static java.lang.String |
fontToHTML(java.awt.Font font)
Convert a font to an html representation.
|
static double |
getProportionalDividerLocation(javax.swing.JSplitPane pane)
Get the proportional split location.
|
static int |
getSelectedButton(javax.swing.ButtonGroup bg)
Gets the index of the selected button in a button group.
|
static java.lang.String |
getText(javax.swing.JTextArea area)
Shortcut method.
|
static java.awt.Window |
getWindowParent(java.awt.Component comp)
Get the window parent if any.
|
static void |
invokeLater(java.lang.Runnable runnable)
Use SwingUtilities to put the given runnable in the AWT Event queue.
|
static void |
invokeLaterSimBlock(java.lang.Runnable runnable)
Invoke on swing thread and sync with simulation if any.
|
static java.lang.Object |
makeIcon(java.lang.Class baseclass,
java.lang.String imgloc)
Utility method that creates a UIDefaults.LazyValue that creates
an ImageIcon for the specified
gifFile filename. |
static void |
removeCopyPasteMenu(javax.swing.text.JTextComponent textcomponent)
Removes copy & paste menu from a text component.
|
static void |
renderObject(java.awt.Graphics g,
java.awt.Component comp,
double cellw,
double cellh,
int x,
int y,
int gridwidth)
Render an object on a grid.
|
static java.awt.Color |
rgbaToColor(double[] rgba)
Converts a RGBA array to color.
|
static java.awt.image.BufferedImage |
scaleBufferedImage(java.awt.image.BufferedImage original,
int w,
int h)
Scales a buffered image.
|
static java.awt.image.BufferedImage |
scaleImage(java.awt.Image src,
int w,
int h,
int type)
Scale an image.
|
static void |
setAllEnabled(javax.swing.ButtonGroup bg,
boolean enabled)
Sets the enabled state of all buttons in a button group.
|
static void |
setMinimumSize(javax.swing.JComponent c,
int w,
int h)
Sets the minimum size along with the preferred size.
|
static void |
setText(javax.swing.JTextArea area,
java.lang.String text)
Shortcut method.
|
static void |
showError(java.awt.Component parent,
java.lang.String errortitle,
java.lang.String errormessage,
java.lang.Exception exception)
Display an error dialog.
|
static void |
showMessageDialog(java.awt.Component parent,
java.lang.Object message,
java.lang.String title,
int msgtype)
Show an non-model message dialog.
|
static java.awt.Color |
stringToColor(java.lang.String str)
Color conversion method for "web-style" color definitions.
|
public static final java.lang.String AUTO_ADJUST
protected static final java.util.Set<java.lang.String> BROKEN_UI_IDS
public static javax.swing.JMenuBar createMenuBar(javax.swing.Action[] actions)
actions
- The actions (null is mapped to separator).public static javax.swing.JToolBar createToolBar(java.lang.String name, javax.swing.Action[] actions)
name
- The name of the toolbar.actions
- The actions (null is mapped to separator).public static javax.swing.Action createAction(java.lang.String name, javax.swing.Icon icon, java.awt.event.ActionListener listener)
name
- The name.icon
- The path to the icon.listener
- The action listener.public static boolean createDialog(java.lang.String title, javax.swing.JComponent content, javax.swing.JComponent comp)
public static boolean createDialog(java.lang.String title, javax.swing.JComponent content, javax.swing.JComponent comp, boolean info)
public static java.lang.Object makeIcon(java.lang.Class baseclass, java.lang.String imgloc)
gifFile
filename.public static void renderObject(java.awt.Graphics g, java.awt.Component comp, double cellw, double cellh, int x, int y, int gridwidth)
g
- The graphics object.comp
- The object to render.cellw
- The cell width.cellh
- The cell height.public static java.awt.Point calculateMiddlePosition(java.awt.Window win)
public static java.awt.Point calculateMiddlePosition(java.awt.Window outer, java.awt.Window win)
public static java.awt.Window getWindowParent(java.awt.Component comp)
comp
- The component.public static void showMessageDialog(java.awt.Component parent, java.lang.Object message, java.lang.String title, int msgtype)
public static void showError(java.awt.Component parent, java.lang.String errortitle, java.lang.String errormessage, java.lang.Exception exception)
errortitle
- The title to use for an error dialog (required).errormessage
- An optional error message displayed before the exception.exception
- The exception (if any).public static void adjustComponentSizes(java.awt.Component[] components)
public static void adjustComponentSizes(javax.swing.JComponent[] components)
public static void adjustComponentHorizontalSizes(javax.swing.JComponent[] components)
public static void adjustComponentVerticalSizes(javax.swing.JComponent[] components)
public static void adjustComponentSizes(java.awt.Container parent)
AUTO_ADJUST
property
to an arbitrary value.public static void setMinimumSize(javax.swing.JComponent c, int w, int h)
c
- Component.w
- Width.h
- Height.public static void createVerticalGroupLayout(java.awt.Container container, javax.swing.JComponent[] components, boolean fixedsize)
container
- The container.components
- The components.public static void createHorizontalGroupLayout(java.awt.Container container, javax.swing.JComponent[] components, boolean fixedsize)
container
- The container.components
- The components.public static void createEdgelessHorizontalGroupLayout(java.awt.Container container, javax.swing.JComponent[] components, boolean fixedsize)
container
- The container.components
- The components.public static void createEdgelessHorizontalGroupLayout(java.awt.Container container, javax.swing.JComponent[] components, boolean fixedsize, boolean rightalign)
container
- The container.components
- The components.public static javax.swing.JTable createReadOnlyTable()
public static double getProportionalDividerLocation(javax.swing.JSplitPane pane)
public static java.awt.Color stringToColor(java.lang.String str)
public static java.lang.String colorToHTML(java.awt.Color color)
color
- The color.public static java.lang.String fontToHTML(java.awt.Font font)
font
- The font.public static final java.awt.image.BufferedImage scaleImage(java.awt.Image src, int w, int h, int type)
scr
- The src image.w
- The width.h
- The height.type
- The type (Image.SCALE_XYZ).public static final java.awt.image.BufferedImage convertBufferedImageType(java.awt.image.BufferedImage original, int type)
original
- Original image.type
- New type.public static int getSelectedButton(javax.swing.ButtonGroup bg)
bg
- The button group.public static void setAllEnabled(javax.swing.ButtonGroup bg, boolean enabled)
bg
- The button group.enabled
- True, if enabledpublic static final java.awt.image.BufferedImage scaleBufferedImage(java.awt.image.BufferedImage original, int w, int h)
original
- Original image.w
- New width.h
- New height.public static void invokeLater(java.lang.Runnable runnable)
runnable
- public static void invokeLaterSimBlock(java.lang.Runnable runnable)
public static final java.lang.String getText(javax.swing.JTextArea area)
doc
- The text area.public static final void setText(javax.swing.JTextArea area, java.lang.String text)
doc
- The document.public static void addCopyPasteMenu(javax.swing.text.JTextComponent textcomponent)
textcomponent
- The text component.public static void removeCopyPasteMenu(javax.swing.text.JTextComponent textcomponent)
textcomponent
- The text component.public static double[] colorToRgba(java.awt.Color color)
public static java.awt.Color rgbaToColor(double[] rgba)