Technical Documentation (API — Window) - Software-Engineering-Spring-2020/PollyPaint GitHub Wiki
This is the main class that interfaces with the front end.
The only class accessible from the frontend is Window. All needed DrawSpace functionality is in this class. Other classes are protected and only accessible within the backend package.
Note that the x and y positions in the backend are different from the frontend. The backend uses relational fractions, and the frontend uses coordinates. See "translateCoordinates()" in the DrawSpace class for information on how positions are translated from the frontend to backend.
xo, yo, and basically any letter +o is represents translation or distance of change. Oftentimes, a function needing to be passed xo will require this.mousex-this.pmousex
public class Window
Description: A constructor that creates a new Window object
Parameters: sketch, float x (x position), float y (y position), float w (width), float h (height)
Returns: A Window object
Description: Displays drawSpace
Parameters: none
Returns: void
Description: Translates frontend coordinates to the back-end DrawSpace coordinates
Parameters: float x, float y
Returns: float[]
Description: Clears PollyGon points, curve points, and freeform points when the user clicks on a new tool.
Paramenters: None
Returns: Void
DRAWSPACE RELATED FUNCTIONALITY
Description: Creates a new DrawSpace object
Parameters: sketch, float x (x position), float y (y position), float w (width), float h (height)
Returns: A DrawSpace object
Description: Draws the DrawSpace off-center once zoomed
Parameters: float factor
Returns: void
Description: Determines if an x and y position is within the DrawSpace
Parameters: float x, float y
Returns: boolean
Description: Pans the DrawSpace
Parameters: float xo, float yo
Returns: void
Description: Re-centers the DrawSpace to its initial position
Parameters: None
Returns: Void
Description: Toggles grid from "on" to "off" and "off" to "on" Parameters: none Returns: void
Description: Set the size of spacing on the grid
Parameters: float spacing
Returns: void
Description: Toggles comments from "on" to "off" and "off" to "on"
Parameters: None
Returns: void
OBJECT CREATION RELATED FUNCTIONALITY
Description: Creates an Ellipse object. Returns boolean of if action was successful.
Parameters: float x, float y, float w, float h
Returns: boolean
Description: Creates an Ellipse object. Returns boolean of if action was successful.
Parameters: float x, float y, float d
Returns: boolean
Description: Creates an Ellipse object. Returns boolean of if action was successful.
Parameters: float x, float y | Defaults to 20 and 20 with and height
Returns: boolean
Note: Commented out
Description: Creates a Rectangle object. Returns boolean of if action was successful.
Parameters: float x, float y, float w, float h
Returns: boolean
Description: Creates a Rectangle object. Returns boolean of if action was successful.
Parameters: float x, float y, float d
Returns: boolean
Description: Creates a Rectangle object. Returns boolean of if action was successful.
Parameters: float x, float y | defaults to 100 width, 50 height
Returns: boolean
Description: Creates a text box. Returns boolean of if action was successful.
Parameters: float x, float y, String str, String font, float textSize
Returns: boolean
Description: Creates a comment. They should only be shown or not shown based on the comment toggle status. Returns boolean of if action was successful.
Parameters: float x, float y, String str, String font, float textSize
Returns: boolean
###importImage()
Description: Imports an image into the DrawSpace. Returns boolean of if action was successful.
Parameters: float x, float y, String filename, String extension
Returns: boolean
TOOLBAR RELATED FUNCTIONALITY
Description: Resizes objects that are selected by a certain factor
Parameters: float factor
Returns: void
##toggleGroup()
Description: Toggles whether selected objects are or aren't in a group
Paramters: None
Returns: Void
Description: Creates a group from objects that are selected
Parameters: None
Returns: Void
Description: Removes selected objects from their groups
Parameters: None
Returns: Void
Description: Shifts all selected objects. Can also be used for the DrawSpace
Parameters: float mouseX, float mouseY, float pmouseX, float pmouseY
Returns: void
Description: Sets the inner color of new objects to be created, not including the border
Parameters: int r (red value), int g (green value), int b (blue value), int a (alpha)
Returns: Void
Description: Sets the color of the border, of new objects to be created
Parameters: int r (red value), int g (green value), int b (blue value)
Returns: Void
Description: Sets the inner color of selected objects, not including the border
Parameters: int r (red value), int g (green value), int b (blue value), int a (alpha)
Returns: Void
Description: Sets the color of the border, of new objects to be created
Parameters: int r (red value), int g (green value), int b (blue value)
Returns: Void
Description: Returns an ArrayList of int[] representing fill colors of selected objects
Parameters: None
Returns: ArrayList<int[]>
Description: Returns an ArrayList of int[] representing border colors of selected objects
Parameters: None
Returns: ArrayList<int[]>
Description: Rotates a selected shape by a certain number of degrees
Parameters: float ao
Returns: Void
Description: Selects an object at the position of the user's mouse. Only one object can be selected.
Parameters: float x, float y
Returns: Void
Description: Selects an object at the position of the user's mouse. Multiple objects can be selected.
Parameters: float x, float y
Returns: Void
Description: Used instead of single- or multi- select. It selects objects that are clicked. If the canvas is clicked, it de-selects objects.
Parameters: float x, float y
Returns: void
Description: Deletes objects selected. Returns boolean of if action was successful.
Parameters: None
Returns: boolean
Description: Deletes objects selected. Returns boolean of if action was successful.
Parameters: None
Returns: boolean
Note: Exact copy of delete() function
Description: Duplicates objects that are selected.
Parameters: None
Returns: void
Description: Duplicates objects that are selected.
Parameters: None
Returns: void
Note: Exact copy of duplicateSelected() function
Description: Deletes the last object created
Parameters: None
Returns: void
Description: Restores the last object trashed
Parameters: None
Returns: void
Description: Deletes all objects on the DrawSpace
Parameters: None
Returns: Void
Description: Copies a shape that is selected. Returns boolean of if action was successful.
Parameters: None
Returns: boolean
Description: Copies a shape that is successful and then deletes it. Returns boolean of if action was successful.
Parmeters: None
Returns: boolean
Description: Pastes a shape that has been copied.
Parameters: None
Returns: Void
DRAWING RELATED FUNCTIONALITY
Description: Sets the thickness of shape borders for newly-drawn shapes
Parameters: int size
Returns: void
Description: Allows the user to free-draw a shape. It takes in the users' mouse coordinates as they drag the mouse along the screen. You must call createFreeForm() on mouseRelease() for freeDraw object to be created correctly.
Parameters: float pmousex, floatpmousey
Returns: void
Description: Creates a PollyGon object based on points the user clicks on the canvas.
Parameters: float pmousex, float pmousey, int numberVertex
Returns: void
Description: Creates a curve out of points the user clicks. A curve has four total points.
Parameters: float pmousex, float pmousey
Returns: void
Description: Creates a line based on two points the user clicks.
Parameters: float pmousex, float pmousey
Returns: void
Description: Creates a freeForm object based on points gathered by the freeDraw() function. This function must be called on mouseReleased()
Parameters: None
*Returns: void
SAVE/LOAD/EXPORT RELATED FUNCTIONALITY
Description: Export an image of the DrawSpace
Parameters: String saveName, String extension | make sure to include the dot in the extension
Returns: void
Description: Saves DrawSpace so it can be re-loaded later
Parameters: String filename
Returns: void | Throws IOException
Description: Opens a file containing a DrawSpace()
Parameters: String filename
Returns: void | Throws IOException, ClassNotFoundException