public class GuiUtilities
extends java.lang.Object
These utility methods should not be used in a headless environment, i.e., when the jawa.awt.headless system property is true.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ALPHA
Default alpha.
|
static java.lang.String |
DEFAULT_POD_TOOL
The default POD conversion tool.
|
static java.lang.String |
HICOMMAND_OUTPUT_DIRECTORY
The directory containing output HiRISE command files generated by
HiCommand.
|
static java.lang.Class |
HIPLAN_REFERENCE_CLASS
The HiPlan reference class: The HOGG.
|
static java.lang.String |
ID
Class identification name with source code version and date.
|
static java.lang.String |
POD_TOOL_PROPERTY
The system property for setting the POD conversion tool.
|
static java.lang.String |
RELEASE_NOTES_FILENAME
The name of the HiPlan release notes file.
|
static float |
SMALL_FONT_FACTOR
The scaling factor for the
small label font. |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
getFileChooserDirectory()
Gets the current directory for the file chooser.
|
static java.io.File |
getFileToOpen(java.awt.Component parent,
javax.swing.filechooser.FileFilter... filters) |
static java.io.File |
getFileToOpen(java.awt.Component parent,
java.lang.String title,
java.lang.String approveButtonText,
java.io.File selectedFile,
boolean fileHidingEnabled,
javax.swing.filechooser.FileFilter... filters) |
static java.io.File |
getFileToSave(java.awt.Component parent,
javax.swing.filechooser.FileFilter... filters) |
static java.io.File |
getFileToSave(java.awt.Component parent,
java.lang.String title,
java.lang.String approveButtonText,
java.io.File selectedFile,
boolean fileHidingEnabled,
boolean confirmOverwrite,
java.lang.String extension,
javax.swing.JComponent accessory,
javax.swing.filechooser.FileFilter... filters) |
static javax.swing.Action |
getLoggingEnableAction()
Creates an action that enables or disables HiPlan logging.
|
static java.awt.image.BufferedImage |
loadImage(java.lang.Class refClass,
java.lang.String filename) |
static javax.swing.ImageIcon |
loadImageIcon(java.lang.Class refClass,
java.lang.String filename) |
static javax.swing.KeyStroke |
makeAccelerator(int k,
int... m)
Creates an accelerator key stroke using the default menu shortcut key mask.
|
static java.awt.Color |
makeAlphaColor(java.awt.Color c) |
static java.awt.Color |
makeAlphaColor(java.awt.Color c,
int alpha) |
static javax.swing.JFileChooser |
makeFileChooser()
Creates a new file chooser.
|
static javax.swing.Action |
makePodViewerAction(java.lang.Class refClass,
java.awt.Component viewerParent) |
static javax.swing.Action |
makePodViewerAction(java.lang.Class refClass,
java.lang.String filename,
java.lang.String title,
java.awt.Component viewerParent) |
static javax.swing.Action |
makeReleaseNotesAction(java.awt.Component viewerParent)
Creates an action that displays the HiPlan release notes in a simple
viewing window.
|
static java.awt.Font |
makeSmallFont(java.awt.Font font)
Creates a smaller version of an input font by scaling its size by a factor
of
SMALL_FONT_FACTOR . |
static javax.swing.JLabel |
makeSmallLabel(double value)
Creates a numeric label with a small, plain font.
|
static javax.swing.JLabel |
makeSmallLabel(int value)
Creates a numeric label with a small, plain font.
|
static javax.swing.JLabel |
makeSmallLabel(java.lang.String text)
Creates a label with a small, plain font.
|
static javax.swing.JComponent |
makeTextComponent(java.lang.String text)
Creates a reasonably sized text dialog text component.
|
static javax.swing.Action |
makeTextFileAction(java.lang.String label,
java.lang.Class refClass,
java.lang.String filename,
java.lang.String viewerTitle,
java.awt.Component viewerParent)
Creates an action that displays a text file in a simple viewing window.
|
static javax.swing.Action |
makeTextFileAction(java.lang.String label,
java.net.URL url,
java.lang.String viewerTitle,
java.awt.Component viewerParent)
Creates an action that displays a text file in a simple viewing window.
|
static void |
setFileChooserDirectory(java.io.File fileChooserDirectory)
Sets the current directory for the file chooser.
|
static void |
showReleaseNotes(java.awt.Component parent)
Displays the HiPlan release notes in a simple viewing window.
|
static void |
showTextFile(java.lang.Class refClass,
java.lang.String filename,
java.lang.String title,
java.awt.Component parent)
Displays a text file in a simple viewing window.
|
static void |
showTextFile(java.net.URL url,
java.lang.String title,
java.awt.Component parent)
Displays a text file in a simple viewing window.
|
static void |
viewParameter(java.awt.Component parent,
java.lang.String title,
PIRL.PVL.Parameter parameter)
Displays a PVL parameter in a modal dialog viewer with a given parent
component and title.
|
static void |
viewParameter(java.awt.Component parent,
java.lang.String title,
PIRL.PVL.Parameter parameter,
java.lang.String message)
Displays a PVL parameter in a modal dialog viewer with a given parent
component, title, and explanatory message.
|
static void |
viewParameter(java.lang.String title,
PIRL.PVL.Parameter parameter)
Displays a PVL parameter in a modal dialog viewer with a gien title.
|
static void |
viewParameter(java.lang.String title,
PIRL.PVL.Parameter parameter,
java.lang.String message)
Displays a PVL parameter in a modal dialog viewer with a given title and
explanatory message.
|
static void |
viewPod(java.io.File perlFile,
java.lang.String title,
java.awt.Component parent) |
static void |
viewText(java.lang.String text,
java.lang.String title,
boolean isError,
java.awt.Component parent) |
static void |
viewText(java.lang.String text,
java.lang.String title,
boolean isError,
int width,
int height,
java.awt.Component parent) |
public static final java.lang.String ID
public static final java.lang.String RELEASE_NOTES_FILENAME
HOGG
's location as determined by the class loader.public static final java.lang.Class HIPLAN_REFERENCE_CLASS
public static final java.lang.String POD_TOOL_PROPERTY
default value
is "pod2text -l." Note that the POD viewer
expects plain text, so the POD conversion tool should be one that generates
plain text instead of styled.public static final java.lang.String DEFAULT_POD_TOOL
public static final float SMALL_FONT_FACTOR
small label
font.public static final java.lang.String HICOMMAND_OUTPUT_DIRECTORY
public static final int DEFAULT_ALPHA
public static javax.swing.KeyStroke makeAccelerator(int k, int... m)
SHIFT_MASK
, for example. The default
key mask is system-dependent.k
- the base key, modified by the default shortcut key mask.m
- the additional, optional modifiers.InputEvent
,
Toolkit.getMenuShortcutKeyMask()
public static void showTextFile(java.net.URL url, java.lang.String title, java.awt.Component parent)
JEditorPane
is set non-editable and uses a monospaced font. It is embedded
in a JScrollPane
and displayed as a modal dialog via a JOptionPane
.
If the text file's URL cannot be resolved for any reason, "Unable to load file" is displayed instead.
url
- the text file's URL.title
- the viewer's title.parent
- the parent component for the viewer.public static void showTextFile(java.lang.Class refClass, java.lang.String filename, java.lang.String title, java.awt.Component parent)
The named file is expected to be found by the class loader in a location relative to the reference class.
refClass
- the reference class used by the class loader to find
filename.filename
- the text file, located relative to refClass.title
- the viewer's title.parent
- the parent component for the viewer.showTextFile(URL,String,Component)
public static void showReleaseNotes(java.awt.Component parent)
Release_Notes.txt
,
are expected to be found one directory up from the location of the HiPlan reference class
, the HOGG.parent
- the parent component for the viewer.showTextFile(URL,String,Component)
public static javax.swing.Action makeTextFileAction(java.lang.String label, java.net.URL url, java.lang.String viewerTitle, java.awt.Component viewerParent)
label
- the action's label.url
- the text file's URL.viewerTitle
- the viewer's title.viewerParent
- the viewer's parent component.showTextFile(URL,String,Component)
public static javax.swing.Action makeTextFileAction(java.lang.String label, java.lang.Class refClass, java.lang.String filename, java.lang.String viewerTitle, java.awt.Component viewerParent)
The named file is expected to be found by the class loader in a location relative to the reference class.
label
- the action's label.refClass
- the reference class used by the class loader to find
filename.filename
- the text file, located relative to refClass.viewerTitle
- the viewer's title.viewerParent
- the viewer's parent component.showTextFile(Class,String,String,Component)
,
showTextFile(URL,String,Component)
public static javax.swing.Action makeReleaseNotesAction(java.awt.Component viewerParent)
Release_Notes.txt
, are expected to be found one
directory up from the location of the HiPlan
reference class
, the HOGG.viewerParent
- the viewer's parent component.showReleaseNotes(Component)
,
showTextFile(URL,String,Component)
public static void viewPod(java.io.File perlFile, java.lang.String title, java.awt.Component parent)
public static javax.swing.Action makePodViewerAction(java.lang.Class refClass, java.lang.String filename, java.lang.String title, java.awt.Component viewerParent)
public static javax.swing.Action makePodViewerAction(java.lang.Class refClass, java.awt.Component viewerParent)
public static javax.swing.Action getLoggingEnableAction()
LoggingUtilities.isLoggingEnabled()
value.
If logging is enabled, then the action's name is "Disable Logging," and
activating it fires the LoggingUtilities.disableLogging()
method.
If logging is not enabled, the action's name is "Enable Logging," and
activating it fires the LoggingUtilities.enableLogging()
method.
The action is stored for later use by repeated invocations of this method.
public static javax.swing.JComponent makeTextComponent(java.lang.String text)
JLabel
is returned. If it is 33 to
64 characters in length, a JTextArea
is returned. If it is longer, a
JTextArea in a JScrollPane
is returned.
The number of visible rows in the scroll pane is determined by the length of the text. If fewer than 512 characters, five rows will be visible. Otherwise ten will be visible.
text
- the text to be displayed by the component.public static javax.swing.ImageIcon loadImageIcon(java.lang.Class refClass, java.lang.String filename)
public static java.awt.image.BufferedImage loadImage(java.lang.Class refClass, java.lang.String filename)
public static java.awt.Font makeSmallFont(java.awt.Font font)
SMALL_FONT_FACTOR
.font
- the input font.public static javax.swing.JLabel makeSmallLabel(java.lang.String text)
SMALL_FONT_FACTOR
.text
- the text for the label.public static javax.swing.JLabel makeSmallLabel(int value)
SMALL_FONT_FACTOR
.value
- the integer value of the label.public static javax.swing.JLabel makeSmallLabel(double value)
SMALL_FONT_FACTOR
. The
label is formatted with one decimal place.value
- the double value of the label.public static void viewParameter(java.awt.Component parent, java.lang.String title, PIRL.PVL.Parameter parameter, java.lang.String message)
default title
is
used. If the explanatory message is null, no such message
is shown and the dialog shows only the Parameter
.
If the input parameter appears to be derived from a HiCat planned
observation record, the viewer includes a button to view the observation's
HiCommand-generated command file. A check for an enclosed parameter named
COMMAND_FILE_PATHNAME
determines whether to display the button. Note that
if there is no local access to the production HiRISE command file directory
(HICOMMAND_OUTPUT_DIRECTORY
), the button is not displayed even if the
parameter is determined to be from an observation record.
parent
- a parent component for the dialog.title
- the dialog's title.parameter
- the PVL parameter to display.message
- an optional explanatory message to include with the dialog.Parameter_Pane
public static void viewParameter(java.awt.Component parent, java.lang.String title, PIRL.PVL.Parameter parameter)
default title
is used.parent
- a parent component for the dialog.title
- the dialog's title.parameter
- the PVL parameter to display.Parameter_Pane
public static void viewParameter(java.lang.String title, PIRL.PVL.Parameter parameter, java.lang.String message)
default title
is used. If the explanatory
message is null, no such message is shown and the dialog
shows only the Parameter
. A shared frame is used for the dialog,
displaying it in the center of the primary monitor.title
- the dialog's title.parameter
- the PVL parameter to display.message
- an optional explanatory message to include with the dialog.Parameter_Pane
public static void viewParameter(java.lang.String title, PIRL.PVL.Parameter parameter)
default title
is used. A shared frame is used for the dialog, displaying it
in the center of the primary monitor.title
- the dialog's title.parameter
- the PVL parameter to display.Parameter_Pane
public static void viewText(java.lang.String text, java.lang.String title, boolean isError, int width, int height, java.awt.Component parent)
public static void viewText(java.lang.String text, java.lang.String title, boolean isError, java.awt.Component parent)
public static javax.swing.JFileChooser makeFileChooser()
getFileChooserDirectory()
; if null, the
current directory is set to the operator's current working directory (the
value of System.getProperty("user.dir")).
For Mac-like file chooser behavior, setFileChooserDirectory(File)
should be invoked with the chooser's new current directory if the file
chooser is approved.
public static java.io.File getFileChooserDirectory()
makeFileChooser()
public static void setFileChooserDirectory(java.io.File fileChooserDirectory)
fileChooserDirectory
- the new current directory for the file
chooser.makeFileChooser()
public static java.io.File getFileToOpen(java.awt.Component parent, java.lang.String title, java.lang.String approveButtonText, java.io.File selectedFile, boolean fileHidingEnabled, javax.swing.filechooser.FileFilter... filters)
public static java.io.File getFileToOpen(java.awt.Component parent, javax.swing.filechooser.FileFilter... filters)
public static java.io.File getFileToSave(java.awt.Component parent, java.lang.String title, java.lang.String approveButtonText, java.io.File selectedFile, boolean fileHidingEnabled, boolean confirmOverwrite, java.lang.String extension, javax.swing.JComponent accessory, javax.swing.filechooser.FileFilter... filters)
public static java.io.File getFileToSave(java.awt.Component parent, javax.swing.filechooser.FileFilter... filters)
public static java.awt.Color makeAlphaColor(java.awt.Color c, int alpha)
public static java.awt.Color makeAlphaColor(java.awt.Color c)
Copyright \ (C) Arizona Board of Regents on behalf of the \ Planetary Image Research Laboratory, Lunar and \ Planetary Laboratory at the University of Arizona