|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.magicproject.tools.MToolKit
public final class MToolKit
MToolKit.java Created on 18 d�c. 2003
Field Summary | |
---|---|
static java.lang.String |
CHARSET
The default charset used by this application. |
static java.awt.Font |
defaultFont
Represents the default font |
static javax.swing.JFileChooser |
fileChooser
represents the file chooser |
static java.lang.String |
mdbFile
Represents the MDB file corresponding to the current TBS name. |
static java.util.Random |
random
The current random sequence. |
static java.lang.String |
tbsName
Represents the default mdb name. |
static XmlDeckTranslator |
translator
The translator tranforming a card name into a file-serializable value. |
Method Summary | |
---|---|
static void |
addOverlay(javax.swing.JComponent superPanel)
Specifies that a component should have overlay functionality. |
static javax.swing.LookAndFeel |
geLookAndFeel(java.lang.String laf)
Return the L&F instance from the givent name. |
static java.awt.Point |
getAbsoluteLocation(javax.swing.JComponent component)
Return absolute location of given component. |
static int |
getConstant(int idToken)
|
static java.lang.String |
getDeckFile()
Return the deck file choosen with an "open" dialog. |
static java.lang.String |
getDeckFile(int type)
Return the deck file choosen |
static java.lang.String |
getDeckFile(javax.swing.JFrame parent,
int type)
Return the deck file choosen |
static java.lang.String |
getExactKeyName(java.lang.String cardName)
Return the specified card name without any special char. |
static java.io.File |
getFile(java.lang.String fileName)
Return the File associated to the given fileName. |
static java.lang.String |
getHtmlMana(int idColor,
int amount)
Return the mana picture specific to the current TBS |
static java.net.URLConnection |
getHttpConnection(java.net.URL url)
Create, and return the connection etablished with a http server. |
static java.lang.String |
getIconPath(java.lang.String fileName)
Returns the absolute path of an icon used for the UI. |
static java.lang.String |
getKeyName(java.lang.String cardName)
Return the specified card name without any special char. |
static java.awt.Image |
getLocalPicture(java.lang.String localFile)
Return the loaded picture from a local place. |
static java.lang.String |
getLogCardInfo(MCard card)
Return logging info of the given card. |
static java.lang.String |
getMdbFile(java.lang.String oldFile,
javax.swing.JFrame parent)
Open a DialogFile dialog and return the choosen mdb file. |
static java.lang.String |
getPictureFile(java.lang.String oldFile,
javax.swing.JFrame parent)
return the picture file choosen |
static int |
getRandom()
Return 0 or 1 at random way |
static int |
getRandom(int length)
Return a number [0,length[ at random way |
static java.lang.String |
getRelativePath()
Return the canonical path of working directory. |
static java.lang.String |
getRelativePath(java.lang.String canonicalPath)
Returns the given path with '\' char replaced by '/' char. |
static java.net.URL |
getResource(java.lang.String resource,
boolean mustExist)
Return the URL associated to the given resource. |
static java.io.InputStream |
getResourceAsStream(java.lang.String resource)
Return the stream associated to the given resource. |
static java.lang.String |
getShortDeckFile(java.lang.String deckFile)
Return the given deck file without the current path off application. |
static java.util.Properties |
getSmtpProperties()
Create, and return the connection etablished with a http server. |
static java.lang.String |
getSoundFile(java.lang.String soundFile)
Return the sound specific to the current TBS |
static javax.swing.ImageIcon |
getTbsBigManaPicture(int idColor)
Return the mana picture specific to the current TBS |
static java.lang.String |
getTbsFile(java.lang.String file)
Return the file specific to the current TBS |
static java.lang.String |
getTbsFile(java.lang.String file,
boolean mustExist)
Return the file specific to the current TBS |
static java.lang.String |
getTbsHtmlPicture(java.lang.String pictureFile)
Return the picture specific to the current TBS |
static java.lang.String |
getTbsPicture(java.lang.String pictureFile)
Return the picture specific to the current TBS |
static java.lang.String |
getTbsPicture(java.lang.String pictureFile,
boolean mustExist)
Return the picture specific to the current TBS |
static boolean |
isAvailableLookAndFeel(java.lang.String laf)
An utility function that layers on top of the LookAndFeel's isSupportedLookAndFeel() method. |
static void |
loadClip(java.lang.String soundFile)
loadClip loads the sound-file into a clip. |
static int |
manaPool(int[] registers)
Sum the mana. |
static int |
parseInt(java.lang.String s)
Parses the string argument as a signed integer in the radix specified by the second argument. |
static byte[] |
readByteArray(java.io.InputStream inputStream)
Read a byte array 256*256*256 bytes maximum sized from the given stream. |
static java.awt.Image |
readImage(java.io.InputStream inputStream)
Read an image from the given stream. |
static javax.swing.ImageIcon |
readImageIcon(java.io.InputStream inputStream)
Read an icon from the given stream. |
static int |
readInt16(java.io.InputStream inputFile)
Read the next 2 bytes from the specified input stream and return the integer value coded with 32bits |
static int |
readInt24(java.io.InputStream inputFile)
Read the next 3 bytes from the specified input stream and return the integer value coded with 48bits |
static java.lang.String |
readString(java.io.InputStream inputStream)
read a string from inputStream ending with \0. |
static java.lang.String |
readText(java.io.InputStream inputStream)
read a string from inputFile The strings read end with \0 with no limit of size |
static java.lang.String |
replaceAll(java.lang.String data,
java.lang.String from,
java.lang.String to)
Replace occurrences into a string. |
static java.lang.String |
replaceWhiteSpaces(java.lang.String string)
Return the specfied string without any local white spaces. |
static java.io.File |
showDialogFile(java.lang.String titreBoite,
java.lang.String etiquetteBouton,
java.lang.String infoBulle,
char raccourciBouton,
java.io.File fichier,
FileFilterPlus fileFilter,
javax.swing.JFrame parent,
int type,
int mode)
Disp a file dialog with many options |
static void |
writeFile(java.io.File src,
java.io.OutputStream out)
Copy the src file throw the output stream. |
static void |
writeInt16(java.io.OutputStream out,
int int16)
Write the specified positive short coded on 2 bytes to the specified input stream |
static void |
writeInt24(java.io.OutputStream out,
int int24)
Write the specified positive int coded on 3 bytes to the specified input stream |
static void |
writeString(java.io.OutputStream out,
java.lang.String string)
write a string to output stream ending with \0. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CHARSET
public static java.awt.Font defaultFont
public static java.lang.String mdbFile
public static java.lang.String tbsName
public static javax.swing.JFileChooser fileChooser
public static java.util.Random random
public static XmlDeckTranslator translator
null
while not used.
Method Detail |
---|
public static java.lang.String replaceAll(java.lang.String data, java.lang.String from, java.lang.String to)
data
- the string to replace occurrences intofrom
- the occurrence to replace.to
- the occurrence to be used as a replacement.
public static int getConstant(int idToken)
idToken
- the value to translate.
public static java.lang.String readString(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- is the input stream
java.io.IOException
- If some other I/O error occurspublic static void writeString(java.io.OutputStream out, java.lang.String string)
out
- is the input streamstring
- the string to writepublic static java.lang.String readText(java.io.InputStream inputStream)
inputStream
- is the input stream containing content
public static byte[] readByteArray(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- is the input stream containing content.
java.io.IOException
- If some other I/O error occurspublic static javax.swing.ImageIcon readImageIcon(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- is the input stream containing content.
java.io.IOException
- If some other I/O error occurspublic static java.awt.Image readImage(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- is the input stream containing content.
java.io.IOException
- If some other I/O error occurspublic static int getRandom()
public static int getRandom(int length)
length
- maximum+1 value to return.
public static void writeFile(java.io.File src, java.io.OutputStream out) throws java.io.IOException
src
- the source file.out
- the output stream.
java.io.IOException
public static java.lang.String getDeckFile()
public static java.lang.String getDeckFile(int type)
type
- open or save option
public static java.lang.String getDeckFile(javax.swing.JFrame parent, int type)
parent
- is parent of this dialogtype
- open or save option
public static java.lang.String getMdbFile(java.lang.String oldFile, javax.swing.JFrame parent)
oldFile
- the old mdb file, will be returned if user cancel operationparent
- is parent of this dialog
public static java.lang.String getPictureFile(java.lang.String oldFile, javax.swing.JFrame parent)
oldFile
- the old picture, will be returned if user cancel operationparent
- is parent of this dialog
public static java.io.File showDialogFile(java.lang.String titreBoite, java.lang.String etiquetteBouton, java.lang.String infoBulle, char raccourciBouton, java.io.File fichier, FileFilterPlus fileFilter, javax.swing.JFrame parent, int type, int mode)
titreBoite
- title of this dialog boxetiquetteBouton
- button "yes"infoBulle
- tooltipraccourciBouton
- shortcut for "yes" buttonfichier
- old filefileFilter
- file filter to applyparent
- is parent of this dialogtype
- the dialog typemode
-
JFileChooser.setDialogType(int)
public static boolean isAvailableLookAndFeel(java.lang.String laf)
laf
- L1F name
public static javax.swing.LookAndFeel geLookAndFeel(java.lang.String laf) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException
laf
- the L&F class name
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
public static int readInt16(java.io.InputStream inputFile) throws java.io.IOException
inputFile
- is the file containing the short (2bytes)to read
java.io.IOException
- if error occurred during the reading process from the specified
input streampublic static int readInt24(java.io.InputStream inputFile) throws java.io.IOException
inputFile
- is the file containing the short (3bytes)to read
java.io.IOException
- if error occurred during the reading process from the specified
input streampublic static void writeInt16(java.io.OutputStream out, int int16)
out
- is the output stream where the specified integer would be writtenint16
- the 2 bytes integer to writepublic static void writeInt24(java.io.OutputStream out, int int24)
out
- is the output stream where the specified integer would be writtenint24
- the 3 bytes integer to writepublic static java.util.Properties getSmtpProperties()
public static java.net.URLConnection getHttpConnection(java.net.URL url)
url
- the requested url.
public static java.awt.Image getLocalPicture(java.lang.String localFile) throws java.lang.InterruptedException
localFile
- the local file name.
java.lang.InterruptedException
public static java.lang.String getTbsHtmlPicture(java.lang.String pictureFile)
pictureFile
- the path of picture to load. This file must not begin with '/'
public static java.lang.String getTbsPicture(java.lang.String pictureFile)
pictureFile
- the path of picture to load. This file must not begin with '/'
public static java.lang.String getTbsPicture(java.lang.String pictureFile, boolean mustExist)
pictureFile
- the path of picture to load. This file must not begin with '/'mustExist
- true
if the ressource to search must exists,
false
either
public static javax.swing.ImageIcon getTbsBigManaPicture(int idColor)
idColor
- the color of mana
public static java.lang.String getHtmlMana(int idColor, int amount)
idColor
- the color of manaamount
- requested amount.
public static java.lang.String getTbsFile(java.lang.String file)
file
- the path of file to load. This file must not begin with '/'
public static java.lang.String getTbsFile(java.lang.String file, boolean mustExist)
file
- the path of file to load. This file must not begin with '/'mustExist
- true
if the ressource to search must exists,
false
either
public static java.lang.String getSoundFile(java.lang.String soundFile)
soundFile
- the path of picture to load. This file must not begin with '/'
public static void loadClip(java.lang.String soundFile)
soundFile
- file to be loaded and played.public static java.awt.Point getAbsoluteLocation(javax.swing.JComponent component)
component
- the component to locate
public static int parseInt(java.lang.String s)
Character.digit(char, int)
returns a nonnegative value),
except that the first character may be an ASCII minus sign '-'
('\u002D'
)
to indicate a negative value. The resulting integer value is returned.
The Integer#MIN_VALUE
value is returned if any of the
following situations occurs:
null
or is a string of length
zero.
'-'
('\u002D'
)
provided that the string is longer than length 1.
int
.
Examples:
parseInt("0") returns 0
parseInt("473") returns 473
parseInt("-0") returns 0
parseInt("2147483647") returns 2147483647
parseInt("-2147483648") returns -2147483648
parseInt("2147483648") returns Integer#MIN_VALUE
parseInt("Kona") returns Integer#MIN_VALUE
s
- the String
containing the integer representation to
be parsed
Integer.MIN_VALUE
public static java.lang.String getRelativePath() throws java.io.IOException
java.io.IOException
public static java.lang.String getKeyName(java.lang.String cardName)
cardName
- the card name as it is displayed.
public static java.lang.String getExactKeyName(java.lang.String cardName)
cardName
- the card name as it is displayed.
public static java.lang.String getRelativePath(java.lang.String canonicalPath) throws java.io.IOException
canonicalPath
-
java.io.IOException
public static java.lang.String getLogCardInfo(MCard card)
card
- the card to Log.
public static java.lang.String replaceWhiteSpaces(java.lang.String string)
StringUtils.deleteWhitespace(String)
would
work.
string
- the string to normalize.
Character.isWhitespace(char)
public static java.io.InputStream getResourceAsStream(java.lang.String resource)
resource
- the resource path to search.
public static java.net.URL getResource(java.lang.String resource, boolean mustExist)
resource
- the resource path to search.mustExist
- true
if the ressource to search must exists,
false
either
public static java.io.File getFile(java.lang.String fileName)
fileName
- the file name path to search.
public static java.lang.String getIconPath(java.lang.String fileName)
fileName
- the icon path relative to the images dir
public static java.lang.String getShortDeckFile(java.lang.String deckFile)
deckFile
- the full deck file.
public static void addOverlay(javax.swing.JComponent superPanel)
superPanel
- the panel to overlay.public static int manaPool(int[] registers)
registers
- teh array of mana.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |