java.lang.Object
de.turnertech.tz.swing.TacticalSymbol
- All Implemented Interfaces:
Transferable
A Swing version of the Tactical Symbol class. This class uses lazy
instantiation for its ImageIcon, only creating it the first time it is
requested. The class is backed by a cache system, so allways use this
class for creating scaled copies of your symbols!
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DataFlavor
ADataFlavor
representing the TacticalSymbol class, allowing the entire class to be part of Drag and Drop actions.static final int
The default java.awt.Image scaling to use for rescaling images -
Method Summary
Modifier and TypeMethodDescriptionboolean
Simple getter for the ImageIcon.getImageIcon
(int width, int height) Gets anImageIcon
scaled to the desired height and width.getImageIcon
(int width, int height, int method) Gets anImageIcon
scaled to the desired height and width.Gets the symbols underlying class path resource URL.getTags()
Returns the collection of tags associated with this symbolgetTransferData
(DataFlavor dataFlavor) int
hashCode()
We are hard coding the hashcode in the constructor.boolean
isDataFlavorSupported
(DataFlavor dataFlavor) toString()
-
Field Details
-
DATA_FLAVOR
ADataFlavor
representing the TacticalSymbol class, allowing the entire class to be part of Drag and Drop actions. -
DEFAULT_SCALING_METHOD
public static final int DEFAULT_SCALING_METHODThe default java.awt.Image scaling to use for rescaling images- See Also:
-
-
Method Details
-
getTags
Returns the collection of tags associated with this symbol- Returns:
- an unmodifiable collection.
- Since:
- 1.2
-
getImageIcon
Simple getter for the ImageIcon. This method will instantiate the ImageIcon if it was not already created.- Returns:
- The ImageIcon at the origional file resolution.
-
getImageIcon
Gets anImageIcon
scaled to the desired height and width. This method is backed with a cache so that subsequent calls with the same three parameters will return already instantiated copies.- Parameters:
width
- The desired width of the returned image.height
- The desired height of the returned image.- Returns:
- A scaled instance. This instance will also hold a copy of the reference.
- See Also:
-
getImageIcon
Gets anImageIcon
scaled to the desired height and width. This method is backed with a cache so that subsequent calls with the same three parameters will return already instantiated copies.- Parameters:
width
- The desired width of the returned image.height
- The desired height of the returned image.method
- The scaling method as per java.awt.Image constants.- Returns:
- A scaled instance. This instance will also hold a copy of the reference.
- See Also:
-
getImageURL
Gets the symbols underlying class path resource URL. This should be avoided where possible, as we have already loaded the image once. It can however be usefull for certain applications where direct access to the resource is needed.- Returns:
- The URL to the image resource (as provided by the class loader)
-
toString
-
getTransferData
- Specified by:
getTransferData
in interfaceTransferable
- Throws:
UnsupportedFlavorException
IOException
-
getTransferDataFlavors
- Specified by:
getTransferDataFlavors
in interfaceTransferable
-
isDataFlavorSupported
- Specified by:
isDataFlavorSupported
in interfaceTransferable
-
equals
-
hashCode
public int hashCode()We are hard coding the hashcode in the constructor. It is ecpected to be the hash of the origional file path
-