Class GradientEditor

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, HasMembersChangedHandlers, HasGradientChangedHandlers

public class GradientEditor extends VLayout implements HasGradientChangedHandlers
A widget for visually editing CSS gradients.

Note: this feature requires Smart GWT Enterprise.

  • Constructor Details

    • GradientEditor

      public GradientEditor()
    • GradientEditor

      public GradientEditor(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static GradientEditor 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:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class VLayout
    • setDragSnapAngle

      public GradientEditor setDragSnapAngle(int dragSnapAngle)
      The angle by which drag-rotating a linear-gradient in the preview should snap. The default of 1 means a linear-gradient can be positioned to any exact degree of a circle.
      Parameters:
      dragSnapAngle - New dragSnapAngle value. Default value is 1
      Returns:
      GradientEditor instance, for chaining setter calls
    • getDragSnapAngle

      public int getDragSnapAngle()
      The angle by which drag-rotating a linear-gradient in the preview should snap. The default of 1 means a linear-gradient can be positioned to any exact degree of a circle.
      Returns:
      Current dragSnapAngle value. Default value is 1
    • setGradient

      public GradientEditor setGradient(String gradient)
      The CSS gradient-statement to work with.

      If this method is called after the component has been drawn/initialized: Parses the passed gradient and applies it to the UI for editing.
      Parameters:
      gradient - CSS gradient string. Default value is null
      Returns:
      GradientEditor instance, for chaining setter calls
    • getGradient

      public String getGradient()
      The CSS gradient-statement to work with.
      Returns:
      Returns the current state of the widget as a CSS gradient. Default value is null
    • getOutputForm

      public DynamicForm getOutputForm() throws IllegalStateException
      A DynamicForm that shows the gradient-string produced by this editor.

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

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

      public Canvas getPreviewCanvas() throws IllegalStateException
      An com.smartgwt.client.types.AutoChild of type Canvas, used to display the gradient according to the defined color-stops. The canvas supports drag and click mouse interactions to update a gradient's rotation and origin.

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

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

      public GradientEditor setShowPreviewCanvas(Boolean showPreviewCanvas)
      Whether to show the preview canvas, used to display the gradient.
      Parameters:
      showPreviewCanvas - New showPreviewCanvas value. Default value is true
      Returns:
      GradientEditor instance, for chaining setter calls
    • getShowPreviewCanvas

      public Boolean getShowPreviewCanvas()
      Whether to show the preview canvas, used to display the gradient.
      Returns:
      Current showPreviewCanvas value. Default value is true
    • addGradientChangedHandler

      public HandlerRegistration addGradientChangedHandler(GradientChangedHandler handler)
      Add a gradientChanged handler.

      Notification fired whenever a user updates the gradient.

      Specified by:
      addGradientChangedHandler in interface HasGradientChangedHandlers
      Parameters:
      handler - the gradientChanged handler
      Returns:
      HandlerRegistration used to remove this handler
    • setDefaultProperties

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

      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 VLayout