Class DrawKnob

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers

public class DrawKnob extends Canvas
Canvas that renders a DrawItem into a DrawPane and provides interactivity for that drawItem, including drag and drop.

A DrawKnob can either be initialized with a DrawItem knobShape or created via the com.smartgwt.client.types.AutoChild pattern.

DrawKnobs are used by the drawItem control knobs subsystem.

  • Constructor Details

    • DrawKnob

      public DrawKnob()
    • DrawKnob

      public DrawKnob(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static DrawKnob 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 Canvas
    • setDrawPane

      public DrawKnob setDrawPane(DrawPane drawPane) throws IllegalStateException
      DrawPane into which this DrawKnob's knobShape will be rendered.
      Parameters:
      drawPane - New drawPane value. Default value is null
      Returns:
      DrawKnob instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getDrawPane

      public DrawPane getDrawPane()
      DrawPane into which this DrawKnob's knobShape will be rendered.
      Returns:
      Current drawPane value. Default value is null
    • getKnobShape

      public DrawItem getKnobShape() throws IllegalStateException
      The DrawItem instance rendered into this DrawKnob's drawPane

      This component is an AutoChild named "knobShape". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current knobShape value. Default value is null
      Throws:
      IllegalStateException - if this widget has not yet been rendered.
    • setKnobShapeDefaults

      public DrawKnob setKnobShapeDefaults(DrawItem knobShapeDefaults) throws IllegalStateException
      Default properties for this component's knobShape. Has the following properties by default:
         radius : 5,
         lineWidth:2,
         fillColor:"#FF0000",
         fillOpacity:0.5,
        

      Note : This is an advanced setting

      Parameters:
      knobShapeDefaults - New knobShapeDefaults value. Default value is {...}
      Returns:
      DrawKnob instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getKnobShapeDefaults

      public DrawItem getKnobShapeDefaults()
      Default properties for this component's knobShape. Has the following properties by default:
         radius : 5,
         lineWidth:2,
         fillColor:"#FF0000",
         fillOpacity:0.5,
        
      Returns:
      Current knobShapeDefaults value. Default value is {...}
    • setX

      public DrawKnob setX(Integer x) throws IllegalStateException
      X-Coordinate for this DrawKnob. DrawKnob will initially be drawn centered over this coordinate
      Parameters:
      x - New x value. Default value is null
      Returns:
      DrawKnob instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getX

      public Integer getX()
      X-Coordinate for this DrawKnob. DrawKnob will initially be drawn centered over this coordinate
      Returns:
      Current x value. Default value is null
    • setY

      public DrawKnob setY(Integer y) throws IllegalStateException
      Y-Coordinate for this DrawKnob. DrawKnob will initially be drawn centered over this coordinate
      Parameters:
      y - New y value. Default value is null
      Returns:
      DrawKnob instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getY

      public Integer getY()
      Y-Coordinate for this DrawKnob. DrawKnob will initially be drawn centered over this coordinate
      Returns:
      Current y value. Default value is null
    • setCenterPoint

      public void setCenterPoint(Integer x, Integer y)
      Sets the center point of the drawKnob. If the optional viewboxCoords argument is passed, coordinates are expected to be adjusted for drawPane pan and zoom. Otherwise coordinates are expected to be absolute pixel coordinates within the drawPane.
      Parameters:
      x - new x coordinate for this drawKnob
      y - new y coordinate for this drawKnob
    • setCenterPoint

      public void setCenterPoint(Integer x, Integer y, boolean viewboxCoords)
      Sets the center point of the drawKnob. If the optional viewboxCoords argument is passed, coordinates are expected to be adjusted for drawPane pan and zoom. Otherwise coordinates are expected to be absolute pixel coordinates within the drawPane.
      Parameters:
      x - new x coordinate for this drawKnob
      y - new y coordinate for this drawKnob
      viewboxCoords - If true, the x and y values are expected to be in the viewbox coordinate system (described here) - already adjusted for any zoom or pan applied to the drawPane.
    • updatePoints

      public void updatePoints(Integer x, Integer y, Integer dX, Integer dY, String state)
      Method called in response to the user dragging this DrawKnob.

      Note that the default implementation does nothing. When working with draw knobs directly this is typically where you would both update the shape being controlled by the draw knob, and ensure the drawKnob gets repositioned. You may also need to update the drawKnob position in response to the drawItem being repositioned, resized, etc.

      Parameters:
      x - new x-coordinate of the drawKnob
      y - new y-coordinate of the drawKnob
      dX - horizontal distance moved
      dY - vertical distance moved
      state - either "start", "move", or "stop", to indicate the current phase of dragging of the DrawKnob for which the points need to be updated
    • setDefaultProperties

      public static void setDefaultProperties(DrawKnob drawKnobProperties)
      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:
      drawKnobProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setAutoChildProperties

      public void setAutoChildProperties(String autoChildName, DrawItem properties) throws IllegalStateException
      Sets the properties for creating a DrawItem AutoChild named autoChildName.

      properties must not have already been created (properties.isCreated() must be false).

      NOTE: Overrides at override points are not applied to the AutoChild created from properties; that is, if the Java Class of properties overrides a Smart GWT override point, the custom method implementation will not be called.

      Throws:
      IllegalStateException - if properties has been created.
      See Also:
    • getDrawItemAutoChild

      public final DrawItem getDrawItemAutoChild(String autoChildName)
      Returns the DrawItem AutoChild named autoChildName if already created.
      Parameters:
      autoChildName - name of an AutoChild to return.
      Throws:
      RuntimeException - if the AutoChild is not a SmartClient DrawItem object.
      See Also:
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(DrawKnobLogicalStructure 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 Canvas