public final class Tools
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Tools.PortSearchParameters
This class contains parameters used when searching for ports and port pairs.
|
static class |
Tools.SectorSearchParameters
This class contains parameters used when searching for sectors.
|
static class |
Tools.TextRange
This class contains the start and end index for a text range.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
centerWindow(java.awt.Window window)
Centers a window on the screen.
|
static java.awt.Frame |
createFrame(java.lang.String title,
int width,
int height)
Creates an AWT window frame.
|
static javax.swing.JFrame |
createJFrame(java.lang.String title,
int width,
int height)
Creates a Swing window frame.
|
static javax.swing.JPanel |
createJPanel()
Creates a Swing panel.
|
static java.awt.Panel |
createPanel()
Creates an AWT panel.
|
static int[][] |
findPortPairs(Tools.PortSearchParameters params1,
Tools.PortSearchParameters params2,
boolean fighterSearch,
int maxDistance)
Finds port pairs in the SWATH database that matches the given parameters.
|
static int[] |
findPorts(Tools.PortSearchParameters params,
boolean fighterSearch,
int maxDistance)
Finds ports in the SWATH database that matches the given parameters.
|
static int[] |
findRoute(int fromSector,
int toSector)
Deprecated.
Use the other
findRoute method instead. |
static int[] |
findRoute(int fromSector,
int toSector,
boolean ignoreAvoids)
Finds the route between two sectors by using the SWATH database.
|
static int[] |
findSectors(Tools.SectorSearchParameters params)
Finds sectors in the SWATH database that matches the given parameters.
|
static Tools.TextRange |
findText(java.lang.String str,
java.lang.String text)
Searches for a given text in a string.
|
static Tools.TextRange |
findText(java.lang.String str,
java.lang.String start,
java.lang.String end)
Searches for a text in a string given its start and end.
|
static java.lang.String |
getClassName(java.lang.Class cls)
Gets the class name.
|
static int |
getDistance(int fromSector,
int toSector,
boolean ignoreAvoids)
Gets the distance between two sectors by using the SWATH database.
|
static int |
getInteger(java.lang.String str)
Gets the integer value of a given text string.
|
java.lang.String |
getProductName(int type)
Gets the product name for a given product type (Fuel Ore, Organics or Equipment).
|
static java.net.URL |
getResource(java.lang.String resource)
Finds a resource with a given name.
|
static java.lang.String |
getText(java.lang.String str,
Tools.TextRange range)
Gets text from a string given a text range.
|
static java.lang.String[] |
getWords(java.lang.String str)
Splits a given text string into words.
|
static java.lang.String[] |
parseText(java.lang.String str,
java.lang.String pattern)
Parses a text string using a given pattern.
|
static void |
playSoundFile(java.io.File file)
Plays the sound from a given file.
|
static void |
playSoundFileAsync(java.io.File file)
Plays the sound from a given file asynchronously.
|
static void |
playSoundURL(java.net.URL url)
Plays the sound from a given URL.
|
static void |
playSoundURLAsync(java.net.URL url)
Plays the sound from a given URL asynchronously.
|
public java.lang.String getProductName(int type)
type - The product type.Swath.FUEL_ORE,
Swath.ORGANICS,
Swath.EQUIPMENTpublic static int[] findRoute(int fromSector,
int toSector)
throws java.lang.Exception
findRoute method instead.fromSector - The start sector.toSector - The end sector.java.lang.ExceptionfindRoute(int, int, boolean)public static int[] findRoute(int fromSector,
int toSector,
boolean ignoreAvoids)
throws java.lang.Exception
fromSector - The start sector.toSector - The end sector.ignoreAvoids - true to ignore avoided sectors,
otherwise false.java.lang.ExceptiongetDistance(int, int, boolean)public static int getDistance(int fromSector,
int toSector,
boolean ignoreAvoids)
throws java.lang.Exception
fromSector - The start sector.toSector - The end sector.ignoreAvoids - true to ignore avoided sectors,
otherwise false.java.lang.ExceptionfindRoute(int, int, boolean)public static int[] findSectors(Tools.SectorSearchParameters params) throws java.lang.Exception
params - The sector parameters.java.lang.ExceptionTools.SectorSearchParameterspublic static int[] findPorts(Tools.PortSearchParameters params, boolean fighterSearch, int maxDistance) throws java.lang.Exception
params - The port parameters.fighterSearch - true to include fighters in the search,
otherwise false.maxDistance - The maximum distance to search from the current sector
or -1 for no limit.java.lang.ExceptionTools.PortSearchParameters,
findPortPairs(com.swath.Tools.PortSearchParameters, com.swath.Tools.PortSearchParameters, boolean, int)public static int[][] findPortPairs(Tools.PortSearchParameters params1, Tools.PortSearchParameters params2, boolean fighterSearch, int maxDistance) throws java.lang.Exception
params1 - The first port parameters.params2 - The second port parameters.fighterSearch - true to include fighters in the search,
otherwise false.maxDistance - The maximum distance to search from the current sector
or -1 for no limit.java.lang.ExceptionTools.PortSearchParameters,
findPorts(com.swath.Tools.PortSearchParameters, boolean, int)public static java.lang.String getClassName(java.lang.Class cls)
cls - The class.public static java.net.URL getResource(java.lang.String resource)
resource - The name of the wanted resource.null if not found.public static Tools.TextRange findText(java.lang.String str, java.lang.String text)
str - The string to search in.text - The text to search for.null if not found.findText(String, String, String),
getText(java.lang.String, com.swath.Tools.TextRange),
getWords(java.lang.String),
getInteger(java.lang.String),
parseText(java.lang.String, java.lang.String)public static Tools.TextRange findText(java.lang.String str, java.lang.String start, java.lang.String end)
str - The string to search in.start - The first part of the text to search for.end - The last part of the text to search for.null if not found.findText(String, String),
getText(java.lang.String, com.swath.Tools.TextRange),
getWords(java.lang.String),
getInteger(java.lang.String),
parseText(java.lang.String, java.lang.String)public static java.lang.String getText(java.lang.String str,
Tools.TextRange range)
str - The string that contains the text.range - The given text range.findText(String, String),
findText(String, String, String),
getWords(java.lang.String),
getInteger(java.lang.String),
parseText(java.lang.String, java.lang.String)public static java.lang.String[] getWords(java.lang.String str)
throws java.lang.Exception
str - The string to split.java.lang.ExceptionfindText(String, String),
findText(String, String, String),
getText(java.lang.String, com.swath.Tools.TextRange),
getInteger(java.lang.String),
parseText(java.lang.String, java.lang.String)public static int getInteger(java.lang.String str)
str - The string.findText(String, String),
findText(String, String, String),
getText(java.lang.String, com.swath.Tools.TextRange),
getWords(java.lang.String),
parseText(java.lang.String, java.lang.String)public static java.lang.String[] parseText(java.lang.String str,
java.lang.String pattern)
throws java.lang.Exception
{0} to mark the first string part and
{1} to mark the second etc. The extracted strings
will then be placed at index 0 and 1 etc. in the resulting string array.parseText("How many [45]?", "{0} [{1}]?") will result in "How many" and "45"str - The string to parse.pattern - The pattern to follow when parsing.java.lang.ExceptionfindText(String, String),
findText(String, String, String),
getText(java.lang.String, com.swath.Tools.TextRange),
getWords(java.lang.String),
getInteger(java.lang.String)public static void playSoundFile(java.io.File file)
throws java.lang.Exception
file - The sound file to play.java.lang.ExceptionplaySoundFileAsync(java.io.File),
playSoundURL(java.net.URL),
playSoundURLAsync(java.net.URL)public static void playSoundFileAsync(java.io.File file)
throws java.lang.Exception
file - The sound file to play.java.lang.ExceptionplaySoundFile(java.io.File),
playSoundURL(java.net.URL),
playSoundURLAsync(java.net.URL)public static void playSoundURL(java.net.URL url)
throws java.lang.Exception
url - The URL with the sound to play.java.lang.ExceptionplaySoundFile(java.io.File),
playSoundFileAsync(java.io.File),
playSoundURLAsync(java.net.URL)public static void playSoundURLAsync(java.net.URL url)
throws java.lang.Exception
url - The URL with the sound to play.java.lang.ExceptionplaySoundFile(java.io.File),
playSoundFileAsync(java.io.File),
playSoundURL(java.net.URL)public static java.awt.Panel createPanel()
throws java.lang.Exception
java.lang.ExceptioncreateJPanel()public static javax.swing.JPanel createJPanel()
throws java.lang.Exception
java.lang.ExceptioncreatePanel()public static java.awt.Frame createFrame(java.lang.String title,
int width,
int height)
throws java.lang.Exception
title - The window title.width - The width of the window.height - The height of the window.java.lang.ExceptioncreateJFrame(java.lang.String, int, int),
centerWindow(java.awt.Window)public static javax.swing.JFrame createJFrame(java.lang.String title,
int width,
int height)
throws java.lang.Exception
title - The window title.width - The width of the window.height - The height of the window.java.lang.ExceptioncreateFrame(java.lang.String, int, int),
centerWindow(java.awt.Window)public static void centerWindow(java.awt.Window window)
window - The window to center.