Class WBrush

public class WBrush extends WJavaScriptExposableObject
A value class that defines the style for filling a path.

A brush defines the properties of how areas (the interior of shapes) are filled. A brush is defined either as a solid color or a gradient.

JavaScript exposability

A WBrush is JavaScript exposable. If a WBrush is JavaScript bound, it can be accessed in your custom JavaScript code through its handle's jsRef(). At the moment, only the getColor() property is exposed, e.g. a brush with the color WColor(10,20,30,255) will be represented in JavaScript as:

 color: [10,20,30,255]


Warning: A WBrush that is JavaScript exposed should be modified only through its handle. Any attempt at modifying it will cause an exception to be thrown.

See Also:
  • Constructor Details

    • WBrush

      public WBrush()
      Creates a brush.

      Creates a brush with a BrushStyle::None fill style.

    • WBrush

      public WBrush(BrushStyle style)
      Creates a brush with the given style.
    • WBrush

      public WBrush(WColor color)
      Creates a solid brush of a given color.

      Creates a solid brush with the indicated color.

    • WBrush

      public WBrush(StandardColor color)
      Creates a solid brush with a standard color.

      Creates a solid brush with the indicated color.

    • WBrush

      public WBrush(WGradient gradient)
      Creates a gradient brush.
  • Method Details

    • clone

      public WBrush clone()
      Clone method.

      Clones this brush.

      Specified by:
      clone in class WJavaScriptExposableObject
    • equals

      public boolean equals(WBrush other)
      Indicates whether some other object is "equal to" this one.

      Returns true if the brushes are exactly the same.

    • setStyle

      public void setStyle(BrushStyle style)
      Sets the brush style.

      See Also:
    • getStyle

      public BrushStyle getStyle()
      Returns the fill style.

      See Also:
    • setColor

      public void setColor(WColor color)
      Sets the brush color.

      If the current style is a gradient style, then it is reset to BrushStyle::Solid.

      See Also:
    • getColor

      public WColor getColor()
      Returns the brush color.

      See Also:
    • setGradient

      public void setGradient(WGradient gradient)
      Sets the brush gradient.

      This also sets the style to BrushStyle::Gradient.

    • getGradient

      public WGradient getGradient()
      Returns the brush gradient.
    • getJsValue

      public String getJsValue()
      Description copied from class: WJavaScriptExposableObject
      Returns a JavaScript representation of the value of this object.

      Note: The value returned will reflect the current server side value of the object. If this object is JavaScript bound, this value may not reflect the actual client side value. If you need access to the client side value, use getJsRef() intead.

      Specified by:
      getJsValue in class WJavaScriptExposableObject
    • assignFromJSON

      protected void assignFromJSON( value)
      Specified by:
      assignFromJSON in class WJavaScriptExposableObject