Class DrawRect

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClickHandlers, HasDragMoveHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDrawEndHandlers, HasDrawStartHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMovedHandlers, HasResizedHandlers, HasShowContextMenuHandlers

public class DrawRect extends DrawItem
DrawItem subclass to render rectangle shapes, optionally with rounded corners.
  • Constructor Details

    • DrawRect

      public DrawRect()
    • DrawRect

      public DrawRect(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static DrawRect getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, DrawItem defaults)
      Changes the defaults for DrawItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - DrawItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class DrawItem
    • setHeight

      public DrawRect setHeight(int height)
      Height in pixels relative to the local coordinate system.

      If this method is called after the component has been drawn/initialized: Set the height of the drawRect
      Parameters:
      height - new height. Default value is 100
      Returns:
      DrawRect instance, for chaining setter calls
    • getHeight

      public int getHeight()
      Height in pixels relative to the local coordinate system.
      Returns:
      Current height value. Default value is 100
    • getHeightAsDouble

      public double getHeightAsDouble()
      Height in pixels relative to the local coordinate system.
      Returns:
      Current height value. Default value is 100
    • setLeft

      public DrawRect setLeft(int left)
      Left coordinate in pixels relative to the local coordinate system.

      If this method is called after the component has been drawn/initialized: Set the left coordinate of the drawRect
      Parameters:
      left - new left coordinate. Default value is 0
      Returns:
      DrawRect instance, for chaining setter calls
    • getLeft

      public int getLeft()
      Left coordinate in pixels relative to the local coordinate system.
      Returns:
      Current left value. Default value is 0
    • getLeftAsDouble

      public double getLeftAsDouble()
      Left coordinate in pixels relative to the local coordinate system.
      Returns:
      Current left value. Default value is 0
    • setLineCap

      public DrawRect setLineCap(LineCap lineCap)
      Style of drawing the endpoints of a line.

      Note that for dashed and dotted lines, the lineCap style affects each dash or dot.

      Overrides:
      setLineCap in class DrawItem
      Parameters:
      lineCap - New lineCap value. Default value is "butt"
      Returns:
      DrawRect instance, for chaining setter calls
    • getLineCap

      public LineCap getLineCap()
      Style of drawing the endpoints of a line.

      Note that for dashed and dotted lines, the lineCap style affects each dash or dot.

      Overrides:
      getLineCap in class DrawItem
      Returns:
      Current lineCap value. Default value is "butt"
    • setRounding

      public DrawRect setRounding(float rounding) throws IllegalStateException
      Rounding of corners, from 0 (square corners) to 1.0 (shorter edge is a semicircle).

      If this method is called after the component has been drawn/initialized: Setter method for rounding
      Parameters:
      rounding - new rounding value. Should be between zero (a rectangle) and 1 (shorter edge is a semicircle). Default value is 0
      Returns:
      DrawRect instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getRounding

      public float getRounding()
      Rounding of corners, from 0 (square corners) to 1.0 (shorter edge is a semicircle).
      Returns:
      Current rounding value. Default value is 0
    • setTitleRotationMode

      public DrawRect setTitleRotationMode(TitleRotationMode titleRotationMode) throws IllegalStateException
      The mode in which the titleLabel (if shown) is rotated with this draw item.

      Note : This is an advanced setting

      Overrides:
      setTitleRotationMode in class DrawItem
      Parameters:
      titleRotationMode - New titleRotationMode value. Default value is "withItemAlwaysUp"
      Returns:
      DrawRect instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getTitleRotationMode

      public TitleRotationMode getTitleRotationMode()
      The mode in which the titleLabel (if shown) is rotated with this draw item.
      Overrides:
      getTitleRotationMode in class DrawItem
      Returns:
      Current titleRotationMode value. Default value is "withItemAlwaysUp"
      See Also:
    • setTop

      public DrawRect setTop(int top)
      Top coordinate in pixels relative to the local coordinate system.

      If this method is called after the component has been drawn/initialized: Set the top coordinate of the drawRect
      Parameters:
      top - new top coordinate. Default value is 0
      Returns:
      DrawRect instance, for chaining setter calls
    • getTop

      public int getTop()
      Top coordinate in pixels relative to the local coordinate system.
      Returns:
      Current top value. Default value is 0
    • getTopAsDouble

      public double getTopAsDouble()
      Top coordinate in pixels relative to the local coordinate system.
      Returns:
      Current top value. Default value is 0
    • setWidth

      public DrawRect setWidth(int width)
      Width in pixels relative to the local coordinate system.

      If this method is called after the component has been drawn/initialized: Set the width of the drawRect
      Parameters:
      width - new width. Default value is 100
      Returns:
      DrawRect instance, for chaining setter calls
    • getWidth

      public int getWidth()
      Width in pixels relative to the local coordinate system.
      Returns:
      Current width value. Default value is 100
    • getWidthAsDouble

      public double getWidthAsDouble()
      Width in pixels relative to the local coordinate system.
      Returns:
      Current width value. Default value is 100
    • getCenter

      public Point getCenter()
      Get the center point of the rectangle.
      Overrides:
      getCenter in class DrawItem
      Returns:
      the center point
    • isPointInPath

      public boolean isPointInPath(int x, int y)
      Returns true if the given point in the drawing coordinate system is within this DrawItem's shape, taking into account local transforms.
      Overrides:
      isPointInPath in class DrawItem
      Parameters:
      x - X coordinate of the test point.
      y - Y coordinate of the test point.
      Returns:
    • moveBy

      public void moveBy(int dX, int dY)
      Move the drawRect by the specified delta
      Overrides:
      moveBy in class DrawItem
      Parameters:
      dX - number of pixels to move horizontally
      dY - number of pixels to move vertically
    • moveTo

      public void moveTo(Integer left, Integer top)
      Move the drawRect to the specified position
      Overrides:
      moveTo in class DrawItem
      Parameters:
      left - new left coordinate
      top - new top coordinate
    • resizeBy

      public void resizeBy(int dX, int dY)
      Resize by the specified delta
      Overrides:
      resizeBy in class DrawItem
      Parameters:
      dX - number of pixels to resize by horizontally
      dY - number of pixels to resize by vertically
    • resizeTo

      public void resizeTo(Integer width, Integer height)
      Resize to the specified size
      Overrides:
      resizeTo in class DrawItem
      Parameters:
      width - new width
      height - new height
    • setCenter

      public void setCenter(int left, int top)
      Move the drawRect such that it is centered over the specified coordinates.
      Parameters:
      left - left coordinate for new center position
      top - top coordinate for new center postiion
    • setRect

      public void setRect(Integer left, Integer top, Integer width, Integer height)
      Move and resize the drawRect to match the specified coordinates and size.
      Parameters:
      left - new left coordinate
      top - new top coordinate
      width - new width
      height - new height
    • setDefaultProperties

      public static void setDefaultProperties(DrawRect drawRectProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      drawRectProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(DrawRectLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class DrawItem