|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.alchemy.core.AlcUtil
public class AlcUtil
Static utility methods used in Alchemy Used to manipulate strings, load images, and general stuff
Field Summary |
---|
Constructor Summary | |
---|---|
AlcUtil()
|
Method Summary | |
---|---|
static java.io.File |
addFileExtension(java.io.File file,
java.lang.String ext)
Checks a name for a file extension and adds one if not present |
static java.net.URL |
appendStringToUrl(java.net.URL url,
java.lang.String append)
Function to append a string to the end of a given URL |
static java.awt.Point |
calculateCenter(java.awt.Container popup)
Calculate the centre of the screen with multiple monitors |
static java.awt.Point |
calculateCenter(java.awt.Container popup,
boolean palette)
Calculate the centre of the screen with multiple monitors |
static void |
copyFile(java.io.InputStream in,
java.io.File dst)
Copies the source file to destination file. |
static java.lang.String |
dateStamp(java.lang.String format)
Returns a string date stamp according to the format given |
static void |
drawSoftRect(java.awt.Graphics g,
int x,
int y,
int width,
int height)
|
static java.awt.image.BufferedImage |
getBufferedImage(java.awt.Image image)
Convert an Image into a BufferedImage |
static java.awt.image.BufferedImage |
getBufferedImage(java.lang.String name)
Returns a BufferedImage from a String, or null if the name was invalid. |
static java.awt.image.BufferedImage |
getBufferedImage(java.net.URL imgUrl)
Returns a BufferedImage from a URL, or null if the name was invalid. |
static java.lang.String |
getClassName(java.lang.Object object)
Returns just the class name -- no package info. |
static int |
getColorBrightness(int rgb)
Get the brightness of a color |
static java.awt.Cursor |
getCursor(java.lang.String name)
Create a custom cursor from a given image file |
static java.awt.Image |
getImage(java.lang.String name)
Returns an Image from the Alchemy data folder, or null if the name was invalid. |
static java.awt.Image |
getImage(java.net.URL imgUrl)
Returns an Image from a URL, or null if the name was invalid. |
static javax.swing.ImageIcon |
getImageIcon(java.lang.String name)
Returns an ImageIcon from the Alchemy data folder, or null if the name was invalid. |
static javax.swing.ImageIcon |
getImageIcon(java.net.URL imgUrl)
Returns an ImageIcon from a URL, or null if the name was invalid. |
static java.util.Collection<AlcShape> |
getPDFShapes(java.io.File file,
boolean resetLocation)
Get a set of vector paths (shapes) from a PDF file. |
static AlcShape[] |
getPDFShapesAsArray(java.io.File file,
boolean resetLocation)
Get a set of vector paths (shapes) from a PDF file. |
static AlcShape[] |
getShapes()
Return an array of AlcShape from PDF files in the shapes folder If no shapes are found a dialog is displayed telling the user to add some shapes to their shapes folder |
static java.net.URL |
getUrlPath(java.lang.String path)
Returns a URL from a String, or null if the name was invalid. |
static java.net.URL |
getUrlPath(java.lang.String path,
java.lang.ClassLoader classLoader)
Returns a URL from a String, or null if the name was invalid. |
static java.lang.String |
hex(byte i)
Converts a byte, char, int, or color to a String containing the equivalent hexadecimal notation. |
static java.lang.String |
hex(char c)
|
static java.lang.String |
hex(int i)
|
static java.lang.String |
hex(int i,
int digits)
|
static java.io.File[] |
listFilesAsArray(java.io.File directory,
java.io.FilenameFilter filter,
boolean recurse)
List all files within a folder and all its sub folders |
static void |
openPDF(java.io.File pdf)
Open a local pdf in the default application |
static void |
openURL(java.lang.String url)
Launch a url in the default browser Adapted from: http://www.centerkey.com/java/browser/ |
static void |
printFloatArray(float[] array)
Print a float array |
static void |
printStringArray(java.lang.String[] array)
Print a string array |
static void |
registerWindowCloseKeys(javax.swing.JRootPane root,
javax.swing.Action closeAction)
Registers key events for a Ctrl-W and ESC with an ActionListener that will take care of disposing the window. |
static boolean |
setClipboard(java.awt.datatransfer.Transferable contents,
java.awt.datatransfer.ClipboardOwner owner)
Sets the current contents of the clipboard to the specified transferable object and registers the specified clipboard owner as the owner of the new contents. |
static boolean |
showConfirmDialog(java.lang.String title,
java.lang.String message)
Show a confirmation dialog specific to the OS style The title and message are taken from the localised Alchemy bundle |
static boolean |
showConfirmDialog(java.lang.String winTitle,
java.lang.String winMessage,
java.lang.String macTitle,
java.lang.String macMessage)
Show a confirmation dialog specific to the OS style The title and message are taken from the localised Alchemy bundle |
static boolean |
showConfirmDialogFromBundle(java.lang.String title,
java.lang.String message)
Show a confirmation dialog specific to the OS style The title and message are taken from the localised Alchemy bundle |
static boolean |
showConfirmDialogFromBundle(java.lang.String winTitle,
java.lang.String winMessage,
java.lang.String macTitle,
java.lang.String macMessage)
Show a confirmation dialog specific to the OS style The title and message are taken from the localised Alchemy bundle |
static java.io.File |
showFileChooser()
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(boolean foldersOnly)
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(boolean foldersOnly,
java.awt.Component parent)
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(java.io.File defaultDir)
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(java.io.File defaultDir,
boolean foldersOnly)
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(java.lang.String title)
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(java.lang.String title,
boolean foldersOnly)
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(java.lang.String title,
java.io.File defaultDir)
Ask for a location with a file chooser. |
static java.io.File |
showFileChooser(java.lang.String title,
java.io.File defaultDir,
boolean foldersOnly,
java.awt.Component parent)
Ask for a location with a file chooser. |
static void |
showNoShapesDialog()
Show a dialog informing the user there are no shapes loaded |
static int |
unhex(java.lang.String s)
|
static java.lang.String |
zeroPad(int i,
int len)
Zero Pad an int |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AlcUtil()
Method Detail |
---|
public static java.io.File addFileExtension(java.io.File file, java.lang.String ext)
file
- The file to add the extenstion toext
- The extension to add (without the leading dot)
public static java.lang.String getClassName(java.lang.Object object)
object
- The object
public static java.net.URL appendStringToUrl(java.net.URL url, java.lang.String append)
url
- The urlappend
- The string to append
public static java.lang.String dateStamp(java.lang.String format) throws java.lang.IllegalArgumentException
format
- Format for the date stamp see: SimpleDateFormat
java.lang.IllegalArgumentException
- if the given pattern is invalidpublic static java.lang.String zeroPad(int i, int len)
i
- The number to padlen
- The length required
public static java.net.URL getUrlPath(java.lang.String path)
path
- The name to the resource
public static java.net.URL getUrlPath(java.lang.String path, java.lang.ClassLoader classLoader)
path
- The name to the resourceclassLoader
- The classloader
public static javax.swing.ImageIcon getImageIcon(java.lang.String name)
name
- The name to the image
public static javax.swing.ImageIcon getImageIcon(java.net.URL imgUrl)
imgUrl
- The URL to the image
public static java.awt.Image getImage(java.lang.String name)
name
- The name to the image
public static java.awt.Image getImage(java.net.URL imgUrl)
imgUrl
- The URL to the image
public static java.awt.image.BufferedImage getBufferedImage(java.net.URL imgUrl)
imgUrl
- The URL to the image
public static java.awt.image.BufferedImage getBufferedImage(java.lang.String name)
name
- The name to the image
public static java.awt.image.BufferedImage getBufferedImage(java.awt.Image image)
image
- The Image to be converted
public static java.awt.Cursor getCursor(java.lang.String name)
name
- The image file to use as the cursor
public static AlcShape[] getShapes()
public static void showNoShapesDialog()
public static AlcShape[] getPDFShapesAsArray(java.io.File file, boolean resetLocation)
file
- The PDF file to retrive the shapes fromresetLocation
- Reset the location of each path to 0,0
public static java.util.Collection<AlcShape> getPDFShapes(java.io.File file, boolean resetLocation)
file
- The PDF file to retrive the shapes fromresetLocation
- Reset the location of each path to 0,0
public static void copyFile(java.io.InputStream in, java.io.File dst) throws java.io.IOException
in
- The source file as an InputStreamdst
- The destination file
java.io.IOException
public static java.io.File[] listFilesAsArray(java.io.File directory, java.io.FilenameFilter filter, boolean recurse)
directory
- The directory to listfilter
- The filter to userecurse
- To list all sub folders or not
public static java.awt.Point calculateCenter(java.awt.Container popup)
popup
- The popup window
public static java.awt.Point calculateCenter(java.awt.Container popup, boolean palette)
popup
- The popup windowpalette
- Popup in the window of the palette
public static void openURL(java.lang.String url)
url
- The url to be launchedpublic static void openPDF(java.io.File pdf)
pdf
- A file pointing to the pdf to openpublic static boolean setClipboard(java.awt.datatransfer.Transferable contents, java.awt.datatransfer.ClipboardOwner owner)
contents
- owner
-
public static boolean showConfirmDialog(java.lang.String title, java.lang.String message)
title
- Title of the dialogmessage
- Message of the dialog
public static boolean showConfirmDialogFromBundle(java.lang.String title, java.lang.String message)
title
- Title of the dialogmessage
- Message of the dialog
public static boolean showConfirmDialog(java.lang.String winTitle, java.lang.String winMessage, java.lang.String macTitle, java.lang.String macMessage)
winTitle
- Title of the windows dialogwinMessage
- Message of the windows dialogmacTitle
- Title of the mac dialogmacMessage
- Message of the mac dialog
public static boolean showConfirmDialogFromBundle(java.lang.String winTitle, java.lang.String winMessage, java.lang.String macTitle, java.lang.String macMessage)
winTitle
- Title of the windows dialogwinMessage
- Message of the windows dialogmacTitle
- Title of the mac dialogmacMessage
- Message of the mac dialog
public static java.io.File showFileChooser()
public static java.io.File showFileChooser(java.lang.String title)
title
- the name of the popup title
public static java.io.File showFileChooser(java.io.File defaultDir)
defaultDir
- the default directory
public static java.io.File showFileChooser(boolean foldersOnly)
foldersOnly
- to select only folders or not
public static java.io.File showFileChooser(boolean foldersOnly, java.awt.Component parent)
foldersOnly
- to select only folders or notparent
- the parent component of the dialog, can be null; see showDialog for details
public static java.io.File showFileChooser(java.io.File defaultDir, boolean foldersOnly)
defaultDir
- the default directoryfoldersOnly
- to select only folders or not
public static java.io.File showFileChooser(java.lang.String title, boolean foldersOnly)
title
- the name of the popup titlefoldersOnly
- to select only folders or not
public static java.io.File showFileChooser(java.lang.String title, java.io.File defaultDir)
title
- the name of the popup titledefaultDir
- the default directory
public static java.io.File showFileChooser(java.lang.String title, java.io.File defaultDir, boolean foldersOnly, java.awt.Component parent)
title
- the name of the popup titlefoldersOnly
- to select only folders or notdefaultDir
- the default directoryparent
- the parent component of the dialog, can be null; see showDialog for details
public static void registerWindowCloseKeys(javax.swing.JRootPane root, javax.swing.Action closeAction)
root
- The windowcloseAction
- The action to be calledpublic static void drawSoftRect(java.awt.Graphics g, int x, int y, int width, int height)
public static int getColorBrightness(int rgb)
rgb
- An rgb color (bit-shifted int format)
public static java.lang.String hex(byte i)
i
-
public static java.lang.String hex(char c)
public static java.lang.String hex(int i)
public static java.lang.String hex(int i, int digits)
public static int unhex(java.lang.String s)
public static void printFloatArray(float[] array)
array
- Float arraypublic static void printStringArray(java.lang.String[] array)
array
- String array
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |