Class PamSVGIcon

java.lang.Object
pamViewFX.fxGlyphs.PamSVGIcon

public class PamSVGIcon extends Object
Load SVG icons. These are preferable to images because they scale nicely between different resolution displays. code adapted from https://github.com/DeskChan/DeskChan

Note on speed: This can be very slow loading icons. It seems that this is due to the metadata at the start of the SVG file. Tried with more SVG focused builders but this leads to dependency issues with org.w3c.dom which is very hard to sort out. The fix is simply to replace the metadata at the start of the SVG file with generic metadata that loads fast. Example which works:

invalid input: '<'svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">

This is a hack rather than a fix but works for now.

Author:
JamieMacaulauy
  • Field Details Link icon

  • Constructor Details Link icon

    • PamSVGIcon Link icon

      public PamSVGIcon(javafx.scene.shape.SVGPath[] shapes, String contentStyle, javafx.geometry.Insets margin, URL path)
    • PamSVGIcon Link icon

      public PamSVGIcon()
  • Method Details Link icon

    • canRead Link icon

      public static boolean canRead(File path)
    • getInstance Link icon

      public static PamSVGIcon getInstance()
    • create Link icon

      @Deprecated public PamSVGIcon create(URL path, javafx.scene.paint.Color color, double lineWidth) throws Exception
      Deprecated.
      Throws:
      Exception
    • create Link icon

      public PamSVGIcon create(URL path) throws Exception
      Throws:
      Exception
    • getOriginWidth Link icon

      public double getOriginWidth()
    • getOriginHeight Link icon

      public double getOriginHeight()
    • setFitWidth Link icon

      public void setFitWidth(double width)
    • setFitHeight Link icon

      public void setFitHeight(double height)
    • getTextStyle Link icon

      public static String getTextStyle(Document document)
    • getSpritePath Link icon

      public String getSpritePath()
    • getSpriteNode Link icon

      public javafx.scene.Node getSpriteNode()
    • getFitWidth Link icon

      public double getFitWidth()
    • getFitHeight Link icon

      public double getFitHeight()