Class TLcdSVGIcon

java.lang.Object
com.luciad.gui.TLcdSVGIcon
All Implemented Interfaces:
ILcdIcon, ILcdResizeableIcon, ILcdCloneable, Serializable, Cloneable

public class TLcdSVGIcon extends Object implements ILcdIcon, ILcdResizeableIcon
Icon implementation based on a Scalable Vector Graphics (SVG) file or XML document. The size and the color of the icon can be overridden.
Since:
2015.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new TLcdSVGIcon object to display the given SVG file.
    TLcdSVGIcon(String aSource, int aWidth, int aHeight)
    Constructs a new TLcdSVGIcon object to display an SVG (Scalable Vector Graphics) icon.
    TLcdSVGIcon(Document aDocument)
    Constructs a new TLcdSVGIcon object to display the given SVG document.
  • Method Summary

    Modifier and Type
    Method
    Description
    Makes Object.clone() public.
    boolean
     
    Returns the color that will be used to paint the SVG icon.
    int
    Returns the fixed height of the icon.
    int
    Returns the fixed width of the icon.
    Returns the XML content of this icon.
    double
    Get the world-height of the icon,
    double
    Get the ratio of the icon's world-width to the icon's width in pixels.
    double
    Get the world-width of the icon,
    int
     
    boolean
    Determines whether this icon is assumed to be world-sized.
    void
    paintIcon(Component aComponent, Graphics aGraphics, int aX, int aY)
    Draw the ILcdIcon at the specified location.
    void
    setColor(Color aColor)
    Specifies a color to be used to paint the SVG icon.
    void
    setIconHeight(int aHeight)
    Specifies the height of the SVG icon to be displayed.
    void
    setIconWidth(int aWidth)
    Specifies the width of the SVG icon to be displayed.
    void
    setSize(int aWidth, int aHeight)
    Specifies the width and height of the SVG icon to be displayed.
     

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TLcdSVGIcon

      public TLcdSVGIcon(String aSource)
      Constructs a new TLcdSVGIcon object to display the given SVG file. The size of the icon will be the bounds of the SVG content in SVG user space (typically pixels). This includes primitive paint, filtering, clipping and masking.
      Parameters:
      aSource - the source of the icon to be displayed
    • TLcdSVGIcon

      public TLcdSVGIcon(Document aDocument)
      Constructs a new TLcdSVGIcon object to display the given SVG document. The size of the icon will be the bounds of the SVG content in SVG user space (typically pixels). This includes primitive paint, filtering, clipping and masking.
      Parameters:
      aDocument - the XML document containing the SVG content
    • TLcdSVGIcon

      public TLcdSVGIcon(String aSource, int aWidth, int aHeight)
      Constructs a new TLcdSVGIcon object to display an SVG (Scalable Vector Graphics) icon. The displayed icon is retrieved from the given source and its size will be as specified in aWidth and aHeight.
      Parameters:
      aSource - the source of the icon to be displayed
      aWidth - the width of the icon to be displayed
      aHeight - the height of the icon to be displayed
  • Method Details

    • getSVGDocument

      public Document getSVGDocument()
      Returns the XML content of this icon.
      Returns:
      the XML content
    • paintIcon

      public void paintIcon(Component aComponent, Graphics aGraphics, int aX, int aY)
      Description copied from interface: ILcdIcon
      Draw the ILcdIcon at the specified location. ILcdIcon implementations may use the Component argument to get properties useful for painting, e.g. the foreground or background color.
      Specified by:
      paintIcon in interface ILcdIcon
      Parameters:
      aComponent - a Component to retrieve properties from.
      aGraphics - the Graphics on which the icon will be painted.
      aX - the x position where the icon will be painted. x is the first coordinate of the top left corner point of the icon.
      aY - the y position where the icon will be painted. y is the second coordinate of the top left corner point of the icon.
    • getIconWidth

      public int getIconWidth()
      Description copied from interface: ILcdIcon
      Returns the fixed width of the icon.
      Specified by:
      getIconWidth in interface ILcdIcon
      Returns:
      the fixed width of the icon.
    • getIconHeight

      public int getIconHeight()
      Description copied from interface: ILcdIcon
      Returns the fixed height of the icon.
      Specified by:
      getIconHeight in interface ILcdIcon
      Returns:
      the fixed height of the icon.
    • toString

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

      public boolean equals(Object aO)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class Object
      See Also:
    • setIconWidth

      public void setIconWidth(int aWidth)
      Specifies the width of the SVG icon to be displayed. Overwrites the width specified in the source file, if any.
      Specified by:
      setIconWidth in interface ILcdResizeableIcon
      Parameters:
      aWidth - the width of the icon to be displayed
      See Also:
    • setIconHeight

      public void setIconHeight(int aHeight)
      Specifies the height of the SVG icon to be displayed. Overwrites the height specified in the source file, if any.
      Specified by:
      setIconHeight in interface ILcdResizeableIcon
      Parameters:
      aHeight - the height of the icon to be displayed
      See Also:
    • setSize

      public void setSize(int aWidth, int aHeight)
      Specifies the width and height of the SVG icon to be displayed. Using this method is more efficient than using both the methods setIconWidth(int) and setIconHeight(int) one after another.
      Parameters:
      aWidth - the width of the icon to be displayed
      aHeight - the height of the icon to be displayed
    • getColor

      public Color getColor()
      Returns the color that will be used to paint the SVG icon. This color will be used to draw the outline and the fill.
      By default, the colors from the SVG icon are used, in which case this method returns null.
      Returns:
      the color used to paint the icon to be displayed
      See Also:
    • setColor

      public void setColor(Color aColor)
      Specifies a color to be used to paint the SVG icon. This color will be used as line and fill color.
      Parameters:
      aColor - the color used to paint the icon to be displayed, or null to use the colors as specified by the SVG file itself
      See Also:
    • isWorldSized

      public boolean isWorldSized()
      Determines whether this icon is assumed to be world-sized.
      Returns:
      whether the icon is world-sized.
    • getWorldWidth

      public double getWorldWidth()
      Get the world-width of the icon,
      Returns:
      The world-width of the icon in meters. The value is -1.0 when the world-size is undefined.
    • getWorldHeight

      public double getWorldHeight()
      Get the world-height of the icon,
      Returns:
      The world-height of the icon in meters. The value is -1.0 when the world-size is undefined.
    • getWorldScalingFactor

      public double getWorldScalingFactor()
      Get the ratio of the icon's world-width to the icon's width in pixels. This is equivalent to the scaling factor that you need to use with TLcdGXYIconPainter.setScale(double). When this is set correctly, the painter can correctly determine how it needs to scale the icon to correctly render it in world-size.
      Returns:
      the scaling factor to convert the icon's width from pixels to world-size.