Class DrawSector

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 DrawSector extends DrawItem
DrawItem subclass to render Pie Slices.
  • Constructor Details

    • DrawSector

      public DrawSector()
    • DrawSector

      public DrawSector(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static DrawSector 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
    • setCenterPoint

      public DrawSector setCenterPoint(Point centerPoint)
      Center point of the sector

      If this method is called after the component has been drawn/initialized: Change the center point for this sector.
      Parameters:
      centerPoint - X coordinate of the center point (in the global coordinate system). Default value is [0,0]
      Returns:
      DrawSector instance, for chaining setter calls
    • getCenterPoint

      public Point getCenterPoint()
      Center point of the sector
      Returns:
      Current centerPoint value. Default value is [0,0]
    • setEndAngle

      public DrawSector setEndAngle(float endAngle) throws IllegalStateException
      Deprecated.
      End angle of the sector in degrees. See startAngle for further details.
      Parameters:
      endAngle - New endAngle value. Default value is 20.0
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getEndAngle

      public float getEndAngle()
      Deprecated.
      End angle of the sector in degrees. See startAngle for further details.
      Returns:
      Current endAngle value. Default value is 20.0
    • setEndAngle

      public DrawSector setEndAngle(double endAngle) throws IllegalStateException
      End angle of the sector in degrees. See startAngle for further details.
      Parameters:
      endAngle - New endAngle value. Default value is 20.0
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getEndAngleAsDouble

      public double getEndAngleAsDouble()
      End angle of the sector in degrees. See startAngle for further details.
      Returns:
      Current endAngle value. Default value is 20.0
    • setKnobs

      public DrawSector setKnobs(KnobType... knobs) throws IllegalStateException
      DrawSector only supports the KnobType.MOVE knob type.
      Overrides:
      setKnobs in class DrawItem
      Parameters:
      knobs - New knobs value. Default value is null
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getKnobs

      public KnobType[] getKnobs()
      DrawSector only supports the KnobType.MOVE knob type.
      Overrides:
      getKnobs in class DrawItem
      Returns:
      Current knobs value. Default value is null
      See Also:
    • setRadius

      public DrawSector setRadius(int radius) throws IllegalStateException
      Radius of the sector.
      Parameters:
      radius - New radius value. Default value is 100
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getRadius

      public int getRadius()
      Radius of the sector.
      Returns:
      Current radius value. Default value is 100
    • getRadiusAsDouble

      public double getRadiusAsDouble()
      Radius of the sector.
      Returns:
      Current radius value. Default value is 100
    • setRotation

      public DrawSector setRotation(float rotation) throws IllegalStateException
      Deprecated.
      Rotation in degrees about the centerPoint of the DrawSector. The positive direction is clockwise.
      Overrides:
      setRotation in class DrawItem
      Parameters:
      rotation - New rotation value. Default value is 0.0
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getRotation

      public float getRotation()
      Deprecated.
      Rotation in degrees about the centerPoint of the DrawSector. The positive direction is clockwise.
      Overrides:
      getRotation in class DrawItem
      Returns:
      Current rotation value. Default value is 0.0
    • setRotation

      public DrawSector setRotation(double rotation) throws IllegalStateException
      Rotation in degrees about the centerPoint of the DrawSector. The positive direction is clockwise.
      Overrides:
      setRotation in class DrawItem
      Parameters:
      rotation - New rotation value. Default value is 0.0
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getRotationAsDouble

      public double getRotationAsDouble()
      Rotation in degrees about the centerPoint of the DrawSector. The positive direction is clockwise.
      Overrides:
      getRotationAsDouble in class DrawItem
      Returns:
      Current rotation value. Default value is 0.0
    • setShowTitleLabelBackground

      public DrawSector setShowTitleLabelBackground(boolean showTitleLabelBackground) throws IllegalStateException
      If the titleLabel is showing, should the titleLabelBackground be created and placed behind the titleLabel?

      This defaults to true for DrawSectors and shapes that are not commonly filled (e.g. DrawLines).

      Note : This is an advanced setting

      Overrides:
      setShowTitleLabelBackground in class DrawItem
      Parameters:
      showTitleLabelBackground - New showTitleLabelBackground value. Default value is true
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getShowTitleLabelBackground

      public boolean getShowTitleLabelBackground()
      If the titleLabel is showing, should the titleLabelBackground be created and placed behind the titleLabel?

      This defaults to true for DrawSectors and shapes that are not commonly filled (e.g. DrawLines).

      Overrides:
      getShowTitleLabelBackground in class DrawItem
      Returns:
      Current showTitleLabelBackground value. Default value is true
    • setStartAngle

      public DrawSector setStartAngle(float startAngle) throws IllegalStateException
      Deprecated.
      Start angle of the sector in degrees. Default of 0.0 will create a sector that starts with a line from the centerPoint and extends horizontally to the right for the indicated radius, then sweeps clockwise toward the endAngle.

      Note that the startAngle may validly be a greater numeric value than the endAngle. The sector will always be drawn clockwise from startAngle to endAngle, so a sector with startAngle of 350 and endAngle of 10 would draw a 20-degree segment sticking out to the right of the centerPoint.

      Drawing a full circle: A developer may have a drawSector transcribe a full circle by using values of 360 or greater as the end point. For example a drawSector with startAngle set to 350 and endAngle set to 710 would transcribe a full circle which starts and ends on the same line (10 degrees above the horizontal, to the right of the centerPoint).

      Parameters:
      startAngle - New startAngle value. Default value is 0.0
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getStartAngle

      public float getStartAngle()
      Deprecated.
      Start angle of the sector in degrees. Default of 0.0 will create a sector that starts with a line from the centerPoint and extends horizontally to the right for the indicated radius, then sweeps clockwise toward the endAngle.

      Note that the startAngle may validly be a greater numeric value than the endAngle. The sector will always be drawn clockwise from startAngle to endAngle, so a sector with startAngle of 350 and endAngle of 10 would draw a 20-degree segment sticking out to the right of the centerPoint.

      Drawing a full circle: A developer may have a drawSector transcribe a full circle by using values of 360 or greater as the end point. For example a drawSector with startAngle set to 350 and endAngle set to 710 would transcribe a full circle which starts and ends on the same line (10 degrees above the horizontal, to the right of the centerPoint).

      Returns:
      Current startAngle value. Default value is 0.0
    • setStartAngle

      public DrawSector setStartAngle(double startAngle) throws IllegalStateException
      Start angle of the sector in degrees. Default of 0.0 will create a sector that starts with a line from the centerPoint and extends horizontally to the right for the indicated radius, then sweeps clockwise toward the endAngle.

      Note that the startAngle may validly be a greater numeric value than the endAngle. The sector will always be drawn clockwise from startAngle to endAngle, so a sector with startAngle of 350 and endAngle of 10 would draw a 20-degree segment sticking out to the right of the centerPoint.

      Drawing a full circle: A developer may have a drawSector transcribe a full circle by using values of 360 or greater as the end point. For example a drawSector with startAngle set to 350 and endAngle set to 710 would transcribe a full circle which starts and ends on the same line (10 degrees above the horizontal, to the right of the centerPoint).

      Parameters:
      startAngle - New startAngle value. Default value is 0.0
      Returns:
      DrawSector instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getStartAngleAsDouble

      public double getStartAngleAsDouble()
      Start angle of the sector in degrees. Default of 0.0 will create a sector that starts with a line from the centerPoint and extends horizontally to the right for the indicated radius, then sweeps clockwise toward the endAngle.

      Note that the startAngle may validly be a greater numeric value than the endAngle. The sector will always be drawn clockwise from startAngle to endAngle, so a sector with startAngle of 350 and endAngle of 10 would draw a 20-degree segment sticking out to the right of the centerPoint.

      Drawing a full circle: A developer may have a drawSector transcribe a full circle by using values of 360 or greater as the end point. For example a drawSector with startAngle set to 350 and endAngle set to 710 would transcribe a full circle which starts and ends on the same line (10 degrees above the horizontal, to the right of the centerPoint).

      Returns:
      Current startAngle value. Default value is 0.0
    • getArcMidpoint

      public Point getArcMidpoint()
      Calculates the coordinates of the midpoint of this DrawSector's circular arc. The formula for this point is:
      var averageAngle = (startAngle + endAngle) / 2; // in degrees
       [centerX + radius * cosdeg(averageAngle), centerY + radius * sindeg(averageAngle)]
      Returns:
      the coordinates of the midpoint of the arc.
    • getCenter

      public Point getCenter()
      Returns the sector's centerPoint.
      Overrides:
      getCenter in class DrawItem
      Returns:
      the current centerPoint
    • moveBy

      public void moveBy(int x, int y)
      Move the DrawSector by the specified amounts.
      Overrides:
      moveBy in class DrawItem
      Parameters:
      x - number of pixels to move by horizontally
      y - number of pixels to move by vertically
    • getArcMidpoint

      public static Point getArcMidpoint(double centerX, double centerY, double startAngle, double endAngle, double radius)
      Calculates the midpoint coordinates of the circular arc of the sector defined by the given centerPoint, startAngle, endAngle, and radius. The formula for this point is:
      var averageAngle = (startAngle + endAngle) / 2; // in degrees
       [centerX + radius * cosdeg(averageAngle), centerY + radius * sindeg(averageAngle)]
      Parameters:
      centerX - X coordinate of the center point of the sector.
      centerY - Y coordinate of the center point of the sector.
      startAngle - start angle of the sector in degrees.
      endAngle - end angle of the sector in degrees.
      radius - radius of the sector.
      Returns:
      the coordinates of the midpoint of the arc.
    • setDefaultProperties

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

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