Class TacticalSymbol

java.lang.Object
de.turnertech.tz.swing.TacticalSymbol
All Implemented Interfaces:
Transferable

public class TacticalSymbol extends Object implements 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 Details

    • DATA_FLAVOR

      public static final DataFlavor DATA_FLAVOR
      A DataFlavor 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_METHOD
      The default java.awt.Image scaling to use for rescaling images
      See Also:
  • Method Details

    • getTags

      public Collection<TacticalSymbolTag> getTags()
      Returns the collection of tags associated with this symbol
      Returns:
      an unmodifiable collection.
      Since:
      1.2
    • getImageIcon

      public ImageIcon 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

      public ImageIcon getImageIcon(int width, int height)
      Gets an ImageIcon 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

      public ImageIcon getImageIcon(int width, int height, int method)
      Gets an ImageIcon 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

      public URL 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

      public String toString()
      Overrides:
      toString in class Object
    • getTransferData

      public Object getTransferData(DataFlavor dataFlavor) throws UnsupportedFlavorException, IOException
      Specified by:
      getTransferData in interface Transferable
      Throws:
      UnsupportedFlavorException
      IOException
    • getTransferDataFlavors

      public DataFlavor[] getTransferDataFlavors()
      Specified by:
      getTransferDataFlavors in interface Transferable
    • isDataFlavorSupported

      public boolean isDataFlavorSupported(DataFlavor dataFlavor)
      Specified by:
      isDataFlavorSupported in interface Transferable
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • 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
      Overrides:
      hashCode in class Object