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

  • Constructor Details

    • PamSVGIcon

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

      public PamSVGIcon()
  • Method Details

    • canRead

      public static boolean canRead(File path)
    • getInstance

      public static PamSVGIcon getInstance()
    • create

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

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

      public double getOriginWidth()
    • getOriginHeight

      public double getOriginHeight()
    • setFitWidth

      public void setFitWidth(double width)
    • setFitHeight

      public void setFitHeight(double height)
    • getTextStyle

      public static String getTextStyle(Document document)
    • getSpritePath

      public String getSpritePath()
    • getSpriteNode

      public javafx.scene.Node getSpriteNode()
    • getFitWidth

      public double getFitWidth()
    • getFitHeight

      public double getFitHeight()