Class ShapeIcon

  • All Implemented Interfaces:
    javax.swing.Icon
    Direct Known Subclasses:
    JsonEditor.HierarchyIcon

    public class ShapeIcon
    extends java.lang.Object
    implements javax.swing.Icon
    Handy class that lets you use a Shape as an icon. Will paint with anti-alias on.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.awt.Color color  
      protected int offX  
      protected int offY  
      protected java.awt.Shape shape  
    • Constructor Summary

      Constructors 
      Constructor Description
      ShapeIcon​(java.awt.Shape shape, java.awt.Color color, int width, int height)  
      ShapeIcon​(java.util.function.Supplier<java.awt.Shape> shapeGen, java.awt.Color color, int width, int height)  
    • Field Detail

      • shape

        protected final java.awt.Shape shape
      • color

        protected java.awt.Color color
      • offX

        protected int offX
      • offY

        protected int offY
    • Constructor Detail

      • ShapeIcon

        public ShapeIcon​(java.util.function.Supplier<java.awt.Shape> shapeGen,
                         java.awt.Color color,
                         int width,
                         int height)
      • ShapeIcon

        public ShapeIcon​(java.awt.Shape shape,
                         java.awt.Color color,
                         int width,
                         int height)
    • Method Detail

      • paintIcon

        public void paintIcon​(java.awt.Component c,
                              java.awt.Graphics graphics,
                              int x,
                              int y)
        Specified by:
        paintIcon in interface javax.swing.Icon
      • setColor

        public ShapeIcon setColor​(java.awt.Color color)
      • setOffset

        public ShapeIcon setOffset​(int x,
                                   int y)
      • getIconWidth

        public int getIconWidth()
        Specified by:
        getIconWidth in interface javax.swing.Icon
      • getIconHeight

        public int getIconHeight()
        Specified by:
        getIconHeight in interface javax.swing.Icon
      • createScaledInstance

        public ShapeIcon createScaledInstance​(double scale)
      • fromSvgPolygon

        public static java.awt.geom.Path2D.Double fromSvgPolygon​(java.lang.String polygonPoints)
        Creates a polygon path from a string which would be of the same format as an SVG polygon element's points attribute. https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/points