Package gui.tool

Class ShapeTool

java.lang.Object
gui.tool.ShapeTool
All Implemented Interfaces:
PageEventHandler, Tool

public class ShapeTool extends Object implements Tool
An implementation of Tool that allows the user to create various shapes
  • Nested Class Summary

    Nested classes/interfaces inherited from interface gui.page.PageEventHandler

    PageEventHandler.HandlerMethod<T extends javafx.event.Event>
  • Constructor Summary

    Constructors
    Constructor
    Description
    ShapeTool(javafx.beans.property.ObjectProperty<javafx.scene.paint.Color> colour)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called when the handler is no longer set to receive events for the given page.
    void
    Called when the handler is set to receive events from the given page.
    void
    Updates the page with the currently drawn shape
     
    javafx.scene.Node
    Return the "graphic" to show in the toolbar for this tool.
    Get the handler methods to be added to a page through which events will be received.
    Return the name of this tool.
    javafx.scene.layout.FlowPane
    Return the GUI element which configures the settings for this tool.
    void
    startShape(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.scene.paint.Color c1, ShapeType type)
    Initializes a shape given two positions, its color and its type.
    void
    updateShape(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, boolean sameSides)
    Modifies and updates a shape to fit within the bounding box defined by two points.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ShapeTool

      public ShapeTool(javafx.beans.property.ObjectProperty<javafx.scene.paint.Color> colour)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Tool
      Return the name of this tool.
      Specified by:
      getName in interface Tool
    • getGraphic

      public javafx.scene.Node getGraphic()
      Description copied from interface: Tool
      Return the "graphic" to show in the toolbar for this tool.
      Specified by:
      getGraphic in interface Tool
    • getHandlerMethods

      public PageEventHandler.HandlerMethod<?>[] getHandlerMethods()
      Description copied from interface: PageEventHandler
      Get the handler methods to be added to a page through which events will be received.
      Specified by:
      getHandlerMethods in interface PageEventHandler
    • enabledFor

      public void enabledFor(Page page)
      Description copied from interface: PageEventHandler
      Called when the handler is set to receive events from the given page.
      Specified by:
      enabledFor in interface PageEventHandler
    • disabledFor

      public void disabledFor(Page page)
      Description copied from interface: PageEventHandler
      Called when the handler is no longer set to receive events for the given page.

      Implementors should get rid of any references to the given page when this method is called.

      Specified by:
      disabledFor in interface PageEventHandler
    • getSettingsGUI

      public javafx.scene.layout.FlowPane getSettingsGUI()
      Description copied from interface: Tool
      Return the GUI element which configures the settings for this tool.

      The returned Node will be shown in the tool pane when this tool is selected.

      Specified by:
      getSettingsGUI in interface Tool
    • getCurrentShape

      public GUIShape getCurrentShape()
    • startShape

      public void startShape(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.scene.paint.Color c1, ShapeType type)
      Initializes a shape given two positions, its color and its type.
      Parameters:
      p1 - The point to create the shape
      p2 - The first point that defines the shape
      c1 - The second point that defines the shape
      type - The enum representing the shape's type
    • updateShape

      public void updateShape(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, boolean sameSides)
      Modifies and updates a shape to fit within the bounding box defined by two points.
      Parameters:
      p1 - The first point that defines the shape
      p2 - The second point that defines the shape
      sameSides - Whether the shape should have the same width and height (e.x. making a square)
    • endShape

      public void endShape()
      Updates the page with the currently drawn shape