Package snap.gfx

Class ShadowEffect

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable

public class ShadowEffect extends Effect
An Effect subclass to represent a drop shadow.
  • Field Details

  • Constructor Details

    • ShadowEffect

      public ShadowEffect()
      Constructor.
    • ShadowEffect

      public ShadowEffect(double aRadius, Color aColor, double aDX, double aDY)
      Constructor for given radius, color and offset.
  • Method Details

    • getRadius

      public double getRadius()
      Returns the radius of the blur.
    • getDX

      public double getDX()
      Returns the X offset of the shadow.
    • getDY

      public double getDY()
      Returns the Y offset of the shadow.
    • getColor

      public Color getColor()
      Returns the color associated with this fill.
    • isSimple

      public boolean isSimple()
      Returns whether this shadow should just be rect.
    • getBounds

      public Rect getBounds(Rect aRect)
      Override to account for blur radius and shadow offset.
      Overrides:
      getBounds in class Effect
    • applyEffect

      public void applyEffect(PainterDVR aPDVR, Painter aPntr, Rect aRect)
      Performs the ShadowEffect with given PainterDVR.
      Overrides:
      applyEffect in class Effect
    • applyEffectShadowOnly

      public void applyEffectShadowOnly(PainterDVR aPDVR, Painter aPntr, Rect aRect)
      Performs the ShadowEffect with given PainterDVR.
    • getShadowImage

      public Image getShadowImage(PainterDVR aPDVR, Rect aRect)
      Returns the effect image.
    • copyForRadius

      public ShadowEffect copyForRadius(double aRad)
      Returns a copy of this shadow with given radius.
    • copyForOffset

      public ShadowEffect copyForOffset(double aDX, double aDY)
      Returns a copy of this shadow with given offset.
    • copyForColor

      public ShadowEffect copyForColor(Color aColor)
      Returns a copy of this shadow with given color.
    • copySimple

      public ShadowEffect copySimple()
      Returns a copy of this shadow with given color.
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • initProps

      protected void initProps(PropSet aPropSet)
      Override to configure props for this class.
      Overrides:
      initProps in class PropObject
    • getPropValue

      public Object getPropValue(String aPropName)
      Override to support props for this class.
      Overrides:
      getPropValue in class PropObject
    • setPropValue

      public void setPropValue(String aPropName, Object aValue)
      Override to support props for this class.
      Overrides:
      setPropValue in class PropObject
    • toXML

      public XMLElement toXML(XMLArchiver anArchiver)
      XML archival.
      Specified by:
      toXML in interface XMLArchiver.Archivable
      Overrides:
      toXML in class Effect
    • fromXML

      public Object fromXML(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Specified by:
      fromXML in interface XMLArchiver.Archivable
      Overrides:
      fromXML in class Effect
    • getShadowImage

      public static Image getShadowImage(Rect aRect, double aRad, Color aColor)
      Returns the effect image for an opaque rect by making a small shadow and blitting over the 8 pieces.