Package org.opensourcephysics.tools
Class Resource
java.lang.Object
org.opensourcephysics.tools.Resource
This represents a resource obtained from a URL or File.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the absolute path.Gets an AudioClip.Gets a buffered image.getBufferedImage
(int bufferedImageType) Gets a buffered image.static Charset
Gets the character set used for reading input streams.getFile()
Gets the file associated with this resource.getImage()
Gets an Image.Gets an ImageIcon.Gets an object of the specified type.Gets a ResizableIcon.Gets a String.Gets a String encoded with a specified encoding.getURL()
Gets the url associated with this resource.Gets the short name of the XMLControl class.static Resource
newImageResource
(byte[] bytes) Just for a Video imageOpens an InputStream.Opens a BufferedReader for the default character set (UTF-8).toString()
-
Constructor Details
-
Resource
Constructs a resource from a url.- Parameters:
url
- the URL
-
Resource
Constructs a resource from a file.- Parameters:
file
- the file
-
Resource
Constructs a resource from a ZIP [url]!/[content].- Parameters:
zipURL
- the URLcontent
- the path of the contents relative to the ZIP file
-
-
Method Details
-
getCharset
Gets the character set used for reading input streams.- Returns:
- the character set
-
getAbsolutePath
Gets the absolute path.- Returns:
- the absolute path
-
getURL
Gets the url associated with this resource.- Returns:
- the URL
-
getFile
Gets the file associated with this resource.- Returns:
- the File
-
getObject
Gets an object of the specified type. Currently the only types recognized are String and ImageIcon.- Parameters:
type
- the desired class type- Returns:
- the object, or null
-
openInputStream
Opens an InputStream.- Returns:
- the stream
-
openReader
Opens a BufferedReader for the default character set (UTF-8).- Returns:
- the reader
-
getImageIcon
Gets an ImageIcon.- Returns:
- the icon
-
getResizableIcon
Gets a ResizableIcon.- Returns:
- the icon
-
getImage
Gets an Image.- Returns:
- the image
-
getBufferedImage
Gets a buffered image.- Returns:
- the image
-
getBufferedImage
Gets a buffered image.- Parameters:
bufferedImageType
- one of the types defined by the BufferedImage class- Returns:
- the image
-
getString
Gets a String.- Returns:
- the string
-
getString
Gets a String encoded with a specified encoding.- Parameters:
encoding
- the encoding (eg "ISO-8859-1" for properties files)- Returns:
- the string
-
getXMLClassName
Gets the short name of the XMLControl class. May be null.- Returns:
- the class name
-
getAudioClip
Gets an AudioClip.- Returns:
- the audio clip
-
toString
-
newImageResource
Just for a Video image- Parameters:
bytes
-- Returns:
-