# Project Features and Requirements
> Processing Team
### Team Members
* Sakshi Rathore
* Ahmed Zaheer Dadarkar
* Rakesh Kumar
* Himanshu Jain
* Shruti Umat
* Satchit Desai
* Devansh Singh Rathore
### Features
#### Menu bar
* shapes
* rotate objects
* insert text box
* coloured brushes - various sizes
* an eraser - various sizes
* import an image in the board
* a chat and video window
* disable the options in UI which are not accessible to user
#### File Options
* save, download, import and export a sheet
#### Edit options
* crop
* zoom
* redo-undo option which will be user specific
* clear my work (display warning)
#### Admin privileges
* clear full screen (display warning)
* select resolution
* give permissions to users
* enable/disable autosave
* select screen (portrait or landscape)
#### Managing multiple users
* status of each user - online/offline
* tag the cursor position of each user with username
* share sheet with multiple users - option to restrict
users to only view or edit modes
#### Other
* Autosave
#### Advancements
* Layers
* DIP techniques
* Multiple pages
### Project Requirements
```java
// Abstraction of different Id's used.
// These Id's are generated using a pseudo-Random generator from 'Java.util.Random'.
class SetUserId{
UserId setUserId();
};
class SetSheetId{
SheetId setSheetId();
};
class SetObjectId{
ObjectId setObjectId();
};
class SetTextBoxId{
TextBoxId setTextBoxId();
};
class SetShapeId{
ShapeId setShapeId();
};
```
#### Menu bar modules
```java
// pixel position
class Point {
int row, column;
};
// pixel intensity
class Intensity {
int red, green, blue;
};
// object is referred as group of pixels, and its meta data.
class Object_ {
Map<Point, Intensity> posnToAction;
time timestamp;
UserId userId;
ObjectId objectId;
};
// overload == operator for Object above
enum Status {ONLINE, OFFLINE};
enum Permission (VIEW,EDIT,EDIT_AND_SHARE);
// storing objects, text-boxes, users Id's and their permission in a sheet.
class GlobalState {
SheetId sheetId;
UserId admin;
WindowType screenOrientation;
Map<UserId, Permission> usersPermission;
Set<Object_> setOfObjects;
Set<TextBox> setOfTextBoxes;
};
```
* shapes
```java
// pre-defined shapes eg. circle, triangle, etc.
class Shape {
public ShapeId addShape();
public Object_ shapeToObject();
};
// addShape() and shapeToObject() of class Shape are overidden by concrete classes below
class Rectangle extends Shape {
@Override
public ShapeId addShape(Point topLeft, Point bottomRight);
public Object_ shapeToObject();
};
class Circle extends Shape {
@Override
public ShapeId addShape(Point center, float radius);
public Object_ shapeToObject();
};
class Triangle extends Shape {
@Override
public ShapeId addShape(Point p1, Point p2, Point p3);
public Object_ shapeToObject();
};
// UI first creates a shape, calls shapeToObject() to get an ObjectId and finally calls addObject()
// pixelsToObject() and imageToObject() will also use addObject to insert their objects into the Global state
public void addObject(Object_ o);
public void deleteObject(ObectId objectId, UserId userId);
public void resizeObject(ObjectId objectId, UserId userId, float scalingFactorX, float scalingFactorY);
// Only horizontal, vertical translation
public void moveObject(ObjectId objectId, UserId userId, int translationFactorX, int translationFactorY);
// Rotates object about its center by given angle (in radians) in CW direction
public void rotateObject(ObjectId objectId, UserId userId, float angleCW);
```
* Text Box
```java
// stores font information of each individual character in a text box.
class TextInfo {
char c;
String fontName;
int fontSize;
boolean bold, italics, underline;
};
// stores text and other meta information of a text box.
class TextBox {
UserId userId;
TextBoxId textBoxId;
Point topLeftCorner;
int width, height;
time timestamp;
Vector <TextInfo> text;
};
public TextBoxId insertTextBox(Point topLeftCorner, int width, int height, UserId userId);
public void deleteTextBox(TextBoxId textBoxId, UserId userId);
public void editTextBox(TextBoxId textBoxId, String text, String fontName, int fontSize, boolean bold, boolean italic, boolean underline, UserId userId, int lIndex, int rIndex);
public void resizeTextBox(TextBoxId textBoxId, UserId userId, Point topLeftCorner, int width, int height);
// move and rotate may be combined
public void moveTextBox(TextBoxId textBoxId, UserId userId, Point topLeftCorner);
public void rotateTextBox(TextBoxId textBoxId, UserId userId, Point topLeftCorner);
```
* Brushes
```java
public ObjectId pixelsToObject(Vector<Point> pixelPositions, Vector <Intensity> rgbValues, UserId userId);
```
* Erase
```java
public void erase(Vector<Point> pixelPositions, UserId userId);
```
* Import an image in the board
```java
public ObjectId imageToObject(Vector<Vector<Intensity>> imageMatrix, UserId userId);
```
#### File Options
```java
class Node {
Object_ obj;
Node prev, next;
};
// used for undo - redo operations
class ModifyOp {
UserId userId;
const int maxOp;
Node head, tail, curr;
}
// state of the whiteboard (2D matrix)
// there are two states -> current state of each user
// and common saved state
class UserState {
UserId userId;
Vector<Object_> objects;
Vector<TextBox> textBoxes;
};
```
* save: save current users objects into server objects
```java
void save(void);
```
* download: download saved global state into user's system in a
compressed file format with .kk extension
```java
// return codes: -
// 0: successful
// 1: permission error
// 2: invalid path
// 3: invalid extension (.kk)
int download(String filePath);
```
* import: import a .kk compressed global state file from user's
system to the whiteboard
```java
// return codes: -
// 0: successful
// 1: permission error
// 2: invalid path
// 3: invalid extension (.kk)
// 4: file invalid (no magic number)
int importState(String filePath)
```
* export: export the saved global state of the whiteboard to the
user's system in the requested file format
```java
enum Extension {PDF, JPG, JPEG, PNG, KK};
// return codes: -
// 0: successful
// 1: permission error
// 2: invalid path
int export(String path, Extension ext);
```
* crop: mask all objects with a part outside rectangle
with white (255)
```java
void crop(Point topLeft, Point bottomRight);
```
* undo: undo the last operation performed
```java
// true: operation successful
// false: operation unsuccessful (deque was empty)
Bool undo(void);
```
* redo: redo the last undone operation
```java
// true: operation successful
// false: operation unsuccessful (head == curr)
Bool redo(void);
```
* clear work: delete all objects of current user and clear operation
linked list -> this operation cannot be undone
Very Imp: Must give warning before
```java
// true: operation successful
// false: operation unsuccessful (permission denied)
Bool resetState(void);
```
#### Admin privileges
```java
// For listening of the events such as any feature selected or clicked which takes the event e as the argument which contains the information about the clicked button.
class EventListner {
void clickEvent(Event e);
}
```
```java
// if the admin clicks the clear screen button then this api will be called which will set the pixel value of all the pixels to 255(white).
void clrScreen();
```
```java
// In starting Admin can choose the orientation of the window and this api will set the global variable screenOrientation to the chosen orientation of the window.
enum WindowType {PORTRAIT,LANDSCAPE};
```
```java
enum Status {ONLINE, OFFLINE};
enum Permission {VIEW,EDIT,EDIT_AND_SHARE};
class User{
UserId userId;
Status status;
}
void setAutosaveOn(Duration duration); // Will set the autosave feature to on or off.
void setAutoSaveOff();
void setOrientation(windowType orientation);
void setPermission(UserId userId, Permission permission); // setPermission will grant user the Permission.
```
#### Managing Multiple users
```java
// setAllUserStatus can be called by UI, it takes the a map containing the status of each user for the given sheet.
void setAllUserStatus(Map<UserId, Permission> status, int sheet);
// updateUserStatus can be called by UI, to change the status of only one user in the sheet.
void updateUserStatus(UserId userId, Permission status, int sheet);
```
```java
// returns the coordinates of each user in the given sheet.
Map<UserId, Point> getAllUserPosition(SheetId sheetId);
// return the coordinates of one user in the given sheet
Point getUserPosition(UserId userId, SheetId sheetId);
```
version 0:
* draw using brush
* erase
* draw shapes
version 1:
* undo
* redo
* select and delete
version 2:
* display user name corresponding to each obj
* stitching the fragments