Technical Documentation (API — Backend) - Software-Engineering-Spring-2020/PollyPaint GitHub Wiki
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. (The API for Window is in a separate page, so that it can be easily accessed).
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.
protected abstract class ColorfulObject extends PollyObject implements Serializable
An PollyObject that has border and/or fill color
Description: A constructor that creates a new ColorfulObject
Parameters: sketch, float x (x position), float y (y position), int[] fillColor, int[] boarderColor | Sets the sketch, x position, and y position in Superclass
Returns: A ColorfulObject
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Sets the color of the object's border
Parameters: int r (red value), int g (green value), int b (blue value)
Returns: void
Description: Sets the inner color of the object, not including the border
Parameters: int r (red value), int g (green value), int b (blue value)
Returns: void
Description: Returns an int array with values that make up the border color. Position 0 is the red value, position 1 is the green value, and position 3 is the blue value.
Parameters: None
Returns: int[]
Description: Returns an int array with values that make up the fill color. Position 0 is the red value, position 1 is the green value, and position 3 is the blue value.
Parameters: None
Returns: int[]
Description: Displays ColorfulObjects. | Calls display in the superclass, then calls methods for the fill, stroke, and strokeweight
protected class DrawSpace extends ColorfulObject
The DrawSpace represents the section of the canvas that the user draws on. It also includes all the objects the user draws.
Description: A constructor that creates a new DrawSpace object
Parameters: sketch, float x, float y, float w, float h
Returns: A DrawSpace object
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Gets a list of all objects in the DrawSpace.
Parameters: None
Returns: ArrayList
Description: Returns the object at the same location as the mouse.
Parameters: float mouseX, float mouseY, float zoom
Returns: Void
Description: Determines if an x and y position is within the DrawSpace
Parameters: float x, float y
Returns: Boolean
Description: Returns number of objects in the drawSpace.
Parameters: None
Returns: int
Description: Translates from relational fractions (used on the backend) to coordinates (used on the frontend)
Parameters: float x, float y, float zoom
Returns: float[] | The first float is the x position, the second the y position
Description: Pans taking in account zoom factor
Parameters: float xo, float yo, float zoom
Returns: float[]
Description: Pans working off window coordinates
Parameters: float x, float y
Returns: void
Description: Sets position of the DrawSpace
Parameters: float x, float y
Returns: void
Description: Displays the DrawSpace and all the objects present on it. It calls the individual display function of each object in the DrawSpace.
Parameters: float zoom, boolean showGrid, float gridSpacing
Returns: Void
Description: Add an object to the DrawSpace. Returns boolean of if action was successful.
Parameters: PollyObject shape
Returns: boolean
Description: Removes an object from the DrawSpace. Returns boolean of if action was successful.
Parameters: PollyObject shape
Returns: boolean
Description: Returns the index of a PollyObject from the list of objects in the DrawSpace
Parameters: PollyObject shape
Returns: int
Description: Returns a shape of a certain index from the list of objects in the DrawSpace
Parameters: int i
Returns: PollyObject
Description: Adds a comment to list of objects in the DrawSpace. Returns boolean of if action was successful.
Parameters: PollyObject Shape
Returns: boolean
Description: Removes a comment to list of objects in the DrawSpace. Returns boolean of if action was successful.
Parameters: PollyObject Shape
Returns: boolean
Description: Returns a comment of a certain index from the list of comments in the DrawSpace
Parameters: int i
Returns: PollyObject
Description: Displays grid over the DrawSpace
Parameters: float spacing
Returns: void
protected class group extends PollyObject implements Serializable
Description: A constructor that creates a new Group object.
Parameters: sketch, float x (x position), float y (y position) | Sets the x and y positions in Superclass
Returns: A Group object
Description: Shows bounding box for objects in the group.
Parameters: none
Returns: void
Description: Determines if objects in the group are within the scope of the DrawSpace
Parameters: float x, float y
Returns: void
Description: Pans all the objects in the group
Parameters: float xo, float yo
Returns: void
Description: Resizes all the objects in the group
Parameters: float factor
Returns: void
Description: Sets relative rotate for objects in the group
Parameters: None
Returns: void
public abstract class NonShape extends ColorfulObject
Description: A constructor that creates a new NonShape object
Parameters: sketch, float x, float y, float strokeWeight, int[] fillColor, int[] boarderColor | All set in superclass
Returns: NonShape
Description: Sets the settings of NonShape
Parameters: None
Returns: void
Description: Sets the stroke weight of the NonShape
Parameters: float wgt
Returns: void
Description: Sets border color of NonShape
Parameters: int r, int g, int b
Returns: void
Description: Sets fill color of NonShape
Parameters: int r, int g, int b
Returns: void
Description: Displays NonShape
Parameters: None
Returns: void
Description: Pans NonShape
Parameters: float xo, float yo
Returns: void
Description: Rotates NonShape
Parameters: float ro
Returns: void
protected abstract class PollyObject implements Serializable
A PollyObject applies to most objects in PollyPaint that can be displayed, such as shapes, lines, and the DrawSpace
Description: A constructor that creates a new PollyObject object
Parameters: sketch, float x (x position), float y (y position)
Returns: A PollyObject object
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Returns x and y coordinates of the PollyObject, in that order
Parameters: None
Returns: float[]
Description: Sets the PollyObject's x and y coordinates
Parameters: float x (x position), float y (y position)
Returns: void
Description: Sets how many degrees to increase or decrease PollyObject's rotate | You might enter 90 in this function. Then rotate will increase by 90 % 360
Parameters: float r
Returns: void
Description: Increases/decreases PollyObject's rotate. Subtract r from previous rotate, and use this value to increase or decrease the rotation of the shape.
Parameters: float r
Returns: void
Description: Returns x position, y position, pixelWidth, and pixelHeight of PollyObject
Parameters: none
*Returns: float[]
Description: Checks to see if coordinates are within bounding box of PollyObject
Parameters: float x, float y
Returns: boolean
Description: Shows the bounding box of PollyObject
Parameters: none
Returns: void
Description: Generates four bounding box points around PollyObject. It uses the PollyObject's width and height, as well as the centerpoint, which has to be passed in. Points are not rotated if the PollyObject is rotated.
Parameters: float xcenter, float ycenter
Returns: PVector[] | Array is four points long
Description: Generates four bounding box points around PollyObject. It uses the PollyObject's width and height, as well as the centerpoint, which has to be passed in. Corresponds with a rotated PollyObject.
Parameters: float xcenter, float ycenter
Returns: PVector[] | Array is four points long
Description: Rotates PollyObject around a point
Parameters: PVector rotatePoint, PVector anchor, float degree
Returns: Pvector
Description: displays PollyObject, adjusting for location, rotation, and scaling
Parameters: None
Returns: void
Description: Changes PollyObject's position by an x and y value
Parameters: float xo, float yo
Returns: void
Description: Resizes PollyObject by a certain factor
Parameters: float factor
Returns: void
public abstract class Shape extends ColorfulObject implements Serializable
Description: A constructor to create a new Shape object
Parameters: sketch, float x, float y, float strokeWeight, int[] fillColor, int[] boardercolor
Returns: Shape
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Sets the settings of Shape
Parameters: None
Returns: void
Description: Sets the stroke weight of Shape
Parameters: float wgt
Returns: void
Description: Sets border color of Shape
Parameters: int r, int g, int b
Returns: void
Description: Sets fill color of Shape
Parameters: int r, int g, int b, int a
Returns: void
Description: Sets relative rotate | calls superclass
Parameters: float ro
Returns: void
public class SerialManager
Description: Returns a deep clone of the provided PollyObject | throws IOException, ClassNotFoundException
Parameters: PApplet sketch, PollyObject obj
Returns: PollyObject
Description: Saves the draw space to a file that can be opened and restored later | throws IOException
Parameters: DrawSpace ds, String filename
Returns: void
Description: Returns a draw space opened from file that can be made the current draw space | throws IOException, ClassNotFoundException
Parameters: PApplet sketch, String filename
Returns: DrawSpace
class *Comment extends TextBox implements Serializable
Description: A constructor that creates a new Comment
Parameters: sketch, float x, float y, int[] fillColor, int[] boarderColor, String str, String font, float textSize | Sets values in superclass
Returns: Comment
Description: Sets source for Comment
Parameters: PollyObject source
Returns: void
Description: Displays Comment | calls method in superclass
Parameters: None
Returns: void
class Curve extends ColorfulObject implements Serializable
Description: A constructor that creates a new Curve object
Parameters: PApplet sketch, float x, float y, ArrayList<float[]> points, float strokeWeight, int[] fillColor, int[] boarderColor | Sketch, x, y, strokeWeight, fillColor, and borderColor are set in Superclass
Returns: Curve
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Set the points of the curve
Parameters: ArrayList<float[]> points
Returns: void
Description: Displays Curve
Parameters: none
Returns: void
class Ellipse extends ColorfulObject implements Serializable
Description: A constructor that creates a new Ellipse object
Parameters: sketch, float x, float y, float w, float h, int[] fillColor, int[] borderColor | Sketch, x, y, fillColor, and borderColor are set in Superclass
Returns: Ellipse
Description: A constructor that creates a new Ellipse object
Parameters: sketch, float x, float y, float d, int[] fillColor, int[] borderColor
Returns: Ellipse
Description: A constructor that creates a new Ellipse object
Parameters: sketch, float x, float y, int[] fillColor, int[] borderColor
Returns: Ellipse
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Displays Ellipse
Parameters: None
Returns: void
class FreeForm extends Shape implements Serializable
Description: A constructor that creates a new FreeForm object
Parameters: sketch, float x, float y, ArrayList<float[]> points, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: FreeForm
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Creates a FreeForm shape from an ArrayList of point arrays
Parameters: ArrayList<float[]> points
Returns: void
Description: Determines if a position is within scope of the FreeForm shape
Parameters: float x, float y
*Returns: boolean
Description: Displays FreeForm shape | calls superclass
Parameters: None
Returns: void
class Image extends PollyObject implements Serializable
Description: A constructor that creates a new Image object
Parameters: sketch, float x, float y, String filename, String extension | sets sketch, x, y in superclass
Returns: Image
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Displays image
Parameters: None
Returns: Void
Description Resize image by a certain factor | calls superclass
Parameters: float factor
Returns: void
class NonCurve extends Shape
Description: A constructor to create a new NoNCurve object
Parameters: PApplet sketch, float x, float y, ArrayList<float[]> points, float strokeWeight, int[] fillColor, int[] boarderColor | sketch, x, y, strokeWeight, fillColor, boarderColor are set in superclass
Returns: NonCurve
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Set fill color, border color, and stroke weight
Parameters: None
Returns: void
Description: Creates a shape from an ArrayList of float[] points
Parameters: ArrayList<float[]> points
Returns: void
class PollyGon extends Shape implements Serializable
Description: A constructor to create a new PollyGon object
Parameters: sketch, float x, float y, ArrayList<float[]> points, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: PollyGon
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Creates a PollyGon from an ArrayList of float[] points passed to constructor
Parameters: None
Returns: void
Description: Displays PollyGon | calls superclass and then translates
Parameters: None
Returns: void
class Rectangle extends Shape implements Serializable
Description: A constructor that creates a new Rectangle object
Parameters: sketch, float x, float y, float w, float h, int[] fillColor, int[] borderColor
Returns: Rectangle
Description: A constructor that creates a new Rectangle object
Parameters: sketch, float x, float y, float d, int[] fillColor, int[] borderColor
Returns: Rectangle
Description: A constructor that creates a new Rectangle object
Parameters: sketch, float x, float y, int[] fillColor, int[] borderColor
Returns: Rectangle
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
protected class TextBox extends ColorfulObject implements Serializable
Description: A constructor that creates a new TextBox object
Parameters: sketch, float x, float y, int[] fillColor, int[] boarderColor, String str, String font, float textSize | sketch, x, y, fillcolor, boarderColor set in superclass
Returns: TextBox
Description: Initiates the Processing Sketch
Parameters: PApplet sketch
Returns: void
Description: Displays TextBox | calls superclass and then translates
Parameters: none
Returns: void
public class ObjectFactory
Description: Creates an image from a file
Parameters: float x, float y, String filename, String extension
Returns: Image
Description: Creates a TextBox
Parameters: float x, float y, int[] fillColor, int[] boarderColor, String str, String font, float textSize
Returns: TextBox
Description: Creates a Comment
Parameters: float x, float y, int[] fillColor, int[] boarderColor, String str, String font, float textSize
Returns: TextBox
Description: Creates a shape based on the user-input char. 'e' corresponds to Circle, 'r' corresponds to Rectangle.
Parameters: float x, float y, char shape, int[] fillColor, int[] borderColor
Returns: null
Description: Creates an Ellipse object
Parameters: float x, float y, float w, float h, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Ellipse
Description: Creates an Ellipse object
Parameters: float x, float y, float d, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Ellipse
Description: Creates an Ellipse object
Parameters: float x, float y, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Ellipse
Description: Creates a Rectangle object
Parameters: (float x, float y, float w, float h, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Rectangle
Description: Creates a Rectangle object
Parameters: float x, float y, float d, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Rectangle
Description: Creates a Rectangle object
Parameters: float x, float y, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Rectangle
Description: Creates a FreeForm object
Parameters: float x, float y, ArrayList<float[]> points, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: FreeForm
Description: Creates a Line
Parameters: float x, float y, ArrayList<float[]> points, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Line
Description: Creates a PollyGon
Parameters: float x, float y, ArrayList<float[] points points, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: PollyGon
Description: Creates a Curve
Parameters: ArrayList<float[]> points, float strokeWeight, int[] fillColor, int[] boarderColor
Returns: Curve