Sample Report
Sample Report
Projects are made within ten weeks, just enough to complete it. However, due to much
new knowledge as well as the time we do through each week is not optimal, the
project will have many errors, which is inevitable. We are looking forward to
receiving all the comments of our teachers to help our limited knowledge better.
Sincerely thanks.
3
Preface
The purpose and objective of this training and mainly the content is time-being, and
with this training, we have gained some confidence regarding introducing the
application. We also believe that way we gained some sorts of IT knowledge, and if
we practice much and having some expertise in the field, then we will be able to
survive smartly in today’s competitive environment.
The effort to write the report is a partial fulfilment to complete the course. In the
report, I try my best to represent all the content that we learned in a great deal in the
program in a systematic and presentable order. I divided each of the topics as an
individual chapter to reflect the entire topic more prominently and clearly. In
reference, I have used the citation method in the entire report. Finally, I am very
hopeful that the structure and topic of the report will be a useful material for all the
reader, especially to the user.
4
CONTENT
Acknowledgment ........................................................................................................ 3
Preface ........................................................................................................................ 4
1. Objectives...................................................................................................... 8
V. Conclusion ........................................................................................................ 36
2. Difficulties .................................................................................................. 37
3. Advantages .................................................................................................. 37
4. Disadvantages ............................................................................................. 37
5
5. Development ideas ...................................................................................... 37
References ................................................................................................................ 38
6
List of images
Image 1 – Use Case Diagram ................................................................................... 10
List of tables
Table 1 – Use case Draw Shape description ............................................................ 11
7
Table 19 – List of methods of ReadThread class ..................................................... 31
I. Project description
1. Objectives
The drawing board provides users abilities to customise their drawings; we could find
some applications such as Windows Paint, Artweaver, GIMP, etc. However, these
programs only available for one user at a time. Remote Draw can allow multiple
users to draw on board simultaneously through the network, which helps users spread
their idea to other people more comfortable.
2. User benefits
Similarly to other drawing application programs, the Remote Draw provides users
with the abilities to draw, move, and modify graphics objects. Essential drawing
functions are:
• Select: Select any shape and stroke on the artboard and move them to another
position.
• Undo: Return to the previous action.
• Change colour: User can change colour with HSB, RGB and Web format.
• Change the thickness of a stroke or border width of a shape.
8
• Erase: Clear everything when an eraser goes through, and the user can change
the size of an eraser.
• Pen: Draw strokes to canvas.
• Shape: Draw rectangle and ellipse.
• Export: Export the artboard into the PNG format.
With the ability to connect to the Internet, Remote Draw application also allows users
to invite one or more friends to draw together. Furthermore, after connecting, users
and their friends can chat with each other to spread their ideas before drawing
something.
9
Image 1 – Use Case Diagram
10
4. Use case description tables
Table 1 – Use case Draw Shape description
Use case name Draw Shape
Description Allows user to draw a rectangle or an ellipse on the board
Actor User
Preconditions Click the Shape button and choose a specific shape
Conditions affecting
termination outcome
Table 2 – Use case Pen description
Use case name Pen
Description Allows user to draw any stroke on the board
Actor User
Preconditions Click Pen button
Conditions affecting
termination outcome
Table 3 – Use case Invite description
Use case name Invite
Description Allows user to invite other people to draw together
Actor User
Business event No. Agent System
1 Click Invite button
2 A connection is established
between user and server
3 The server sends a code to the
user
4 The system displays the code
to the chatbox
Preconditions Server is running
Conditions affecting The server is running, the connection is established successfully
termination outcome The server is terminated, connection failed
Table 4 – Use case Join description
Use case name Join
Description Allows user to join to a remote board
Actor User
Business event No. Agent System
1 Click Join button
2 A connection is established
between user and server
3 The server sends all information of
the remote board to the user
11
4 Render the drawing information to
the board
Preconditions Server is running
Conditions affecting The server is running, the connection is established successfully
termination outcome The server is terminated, connection failed
Table 5 – Use case Leave description
Use case name Leave
Description Disconnect to server
Actor User
Business event No. Agent System
1 Click Leave button
2 Disconnect to the server
Preconditions User is connected to the server
Conditions affecting
termination outcome
Table 6 – Use case Export description
Use case name Export
Description Exports the current state of the board to a png file
Actor User
Business event No. Agent System
1 Click the export
button
2 Show a dialogue for the user to
choose the directory to store the
image
3 Choose a specific
folder
4 Export the image
Preconditions
Conditions affecting
termination outcome
Table 7 – Use case Chat description
Use case name Chat
Description Allow users to communicate with each other
Actor User
Business event No. Agent System
1 Enter the message
to a text box
2 Click Send button
3 Send the message to the server to
broadcast to other people that are
connected to the same artboard
4 Display the message to the chatbox
12
Preconditions User is connected to the server
Conditions affecting
termination outcome
13
Table 9 – Work Assignment
14/10/2019
21/10/2019
28/10/2019
04/11/2019
11/11/2019
18/11/2019
25/11/2019
02/12/2019
09/12/2019
Day
Week 1 2 3 4 5 6 7 8 9 10
o – Begin
Note o – Complete 50%
o – Complete 100%
III. Design
1. Process description
Everything drawn on the application is objects; these objects have attributes that
define them, such as position, colour, etc. The role of application is rendering all those
14
objects to a canvas. In java programming language, it provides us with a library called
GraphicsContext. This library takes inputs which are the information of an object and
draw it to a canvas. Canvas is also a library, its role is a UI element, and it works with
GraphicsContext to display graphic elements.
1.1. Rendering
GraphicsContext and Canvas libraries help the application to draw every object to
canvas, such as a line, a rectangle, an ellipse, a triangle, a circle, a polygon, etc.
Remote Draw application focuses on three objects only that is a line, a rectangle, and
an ellipse.
To perform all drawing actions easier, we created a class called Drawing. Then we
need to import the necessary libraries to that class. This class receive information
about canvas from User Interface.
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
Create a new GraphicsContext instance.
After having the tool is GraphicsContext and Canvas library, we need objects. For
example, we have a Rectangle class which is inherited from Shape abstract class.
This class defines all the information of a rectangle.
15
//region Private Attributes
private double x1;
private double y1;
private double x2;
private double y2;
boolean fill;
private String color;
private int thickness;
//endregion
//region Constructor
public Shape(double x1, double y1, double x2, double y2, boolean fill, String
color, int thickness) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.fill = fill;
this.color = color;
this.thickness = thickness;
}
}
public class Rectangle extends Shape {
//region Constructor
public Rectangle(double x1, double y1, double x2, double y2, boolean fill, String
color, int thickness, String type) {
super(x1, y1, x2, y2, fill, color, thickness);
16
this.type = type;
}
}
Now we can draw rectangles to a canvas using below command
Similarly we can draw a list of graphics elements such as a ellipse and a stroke, note
that a stroke is a set of lines. Everytime we draw an new object to the canvas, we add
it to the list called graphicsElements, so that the Drawing class just need to render
that list.
19
Image 3 – Draw a list of graphics objects
To allow users to draw together, we need a server to be a middle man between users.
Server receives graphics elements from a user and broadcast it to other users who are
connecting to the same artboard.
In this project, we use the low-level API to establish a connection between client and
server. Java.net.socket library helps us to communicate with a server by an IP address
and a port.
20
In the client-side, which is the Remote Draw application, we create two thread for
reading data from the server and sending data to the server called ReadThread and
WriteThread.
So users want to draw with their friends, what information do they need to send to
the server? Every time a user (host) wants to invite someone (guest) to draw with
him, he needs to send all his current graphics elements to the server. The server stores
that information plus a code, this code is unique for each host. The server will send
this code back to the host and tell him that you need to share this code to your friends
to start drawing together. Guest will send this code to the server and receive all
drawing information of the host from the server. From now on, every modification of
any graphics elements server will know and broadcast that changes to other users.
After successfully allowing users to draw remotely, we also allow users to send
messages like a chat application to make their work more comfortable.
2. Class Design
In other to handling all features from drawing and communication, object-oriented
programming is the best technique helping us to implement those features. Below is
the detail of all classes that are defined by us in this project, including the methods
and the purpose of them.
21
We divided all classes in this application into two groups. The first group contains all
classes of the client (Remote Draw), and the second one consists of all classes of the
server.
2.1. Client
22
Table 11 – List of methods in DrawingObject class
No. Method Purpose File name, Responsible
Line
1 equals(Object obj) Compare DrawingObjects DrawingO Le Duc
Input: obj. bject.java Thinh
Output: boolean. (8)
Pseudocode: none.
2 toString() Print out the default DrawingO Le Duc
Input: none information of an instance bject.java Thinh
Output: String of DrawingObject to the (13)
PseudoCode: none console
List of methods in Shape class
23
8 getY2() Get the Y position of the Shape.java Nguyen
Input: none. lower right corner of a (56) Hoang
Output: double. shape Danh
Pseudocode: none.
9 isFill() Check whether the state Shape.java Nguyen
Input: none. of a shape is filled or (64) Hoang
Output: boolean. unfilled Danh
Pseudocode: none.
10 setFill(boolean fill) Set the fill value Shape.java Nguyen
Input: fill. (68) Hoang
Output: none. Danh
Pseudocode: none.
11 getColor() Get the color of border Shape.java Nguyen
Input: none. and fill color of a shape (72) Hoang
Output: String. Danh
Pseudocode: none.
12 setColor(String color) Set the color of border Shape.java Nguyen
Input: color. and fill color of a shape (76) Hoang
Output: String. Danh
Pseudocode: none.
13 getThickness() Get the border width of a Shape.java Nguyen
Input: none. shape (80) Hoang
Output: int. Danh
Pseudocode: none
14 setThickness(int Set the border width of a Shape.java Nguyen
thickness) shape (84) Hoang
Input: thickness Danh
Output: none.
Pseudocode: none.
List of methods of Rectangle class
24
Output: boolean
Pseudocode: none
4 isOnRectangle(double Check whether a specific Rectangle.j Nguyen
x, double y) position on the canvas is ava Hoang
Input: x, y. on a rectangle (50) Danh
Output: boolean
Pseudocode: none
List of methods of Ellipse class
27
Output: none. (95)
Pseudocode: none
17 getName() Get the name of the user Infrastructu Le Duc
Input: none. re.java Thinh
Output: String (99)
Pseudocode: none
18 setName(String name) Set the name of the user Infrastructu Le Duc
Input: name. re.java Thinh
Output: none. (103)
Pseudocode: none
19 getResult() Get the result from the Infrastructu Le Duc
Input: none. server re.java Thinh
Output: String (107)
Pseudocode: none
20 setResult(String result) Set the result value Infrastructu Le Duc
Input: result. re.java Thinh
Output: none. (111)
Pseudocode: none
21 setNotification(String Set notification for the Infrastructu Le Duc
notification) application re.java Thinh
Input: notification. (119)
Output: none.
Pseudocode: none
22 getNotification() Get notification from the Infrastructu Le Duc
Input: none. server re.java Thinh
Output: String. (115)
Pseudocode: none
23 setIncomingMessage(St Set incoming message for Infrastructu Le Duc
ring incomingMessage) the application re.java Thinh
Input: incomingMessage. (127)
Output: none.
Pseudocode: none
24 getIncomingMessage() Get the incoming Infrastructu Le Duc
Input: none. message from the server re.java Thinh
Output: String. (123)
Pseudocode: none
25 setOutgoingMessage(St Set outgoing message for Infrastructu Le Duc
ring outgoingMessage) the application re.java Thinh
Input: outgoingMessage. (135)
Output: none.
Pseudocode: none
26 getOutgoingMessage() Get the outgoing message Infrastructu Le Duc
Input: none. from the server re.java Thinh
Output: String. (131)
Pseudocode: none
List of methods of Drawing class
28
Table 18 – List of methods of Drawing class
No. Method Purpose File name, Responsible
Line
1 Render() Draw all Drawing.ja Nguyen
Input: none. graphic va Hoang
Output: none. elements (41) Danh
Pseudo ode: which are in
for(object in graphicsElements) the graphics
elements lít
draw the object to the canvas
2 Undo() Remove the Drawing.ja Nguyen
Input: none last element in va Hoang
Output: String graphicElemen (97) Danh
Pseudocode: ts list
if the graphics elements list is not
empty
remove the last element
3 Clear() Clear canvas Drawing.ja Nguyen
Input: none. va Hoang
Output: none. (107) Danh
Pseudocode:
Clear graphicsElements list
Render()
4 getSelectionGraphicElements() Get all Drawing.ja Nguyen
Input: none. graphics va Hoang
Output: List<DrawingObject> elements that (115) Danh
Pseudocode: none. are selected
5 getGraphicElements() Get all Drawing.ja Nguyen
Input: none. graphics va Hoang
Output: List<DrawingObject> elements (123) Danh
Pseudocode: none.
6 setGraphicElements() Set graphics Drawing.ja Nguyen
Input: List<DrawingObject>. elements va Hoang
Output: none. (127) Danh
Pseudocode: none.
7 initDrawRect(double x, double y, Add a new Drawing.ja Nguyen
boolean fill, String color, int rectangle to va Hoang
thickness) object list (172) Danh
Input: x, y, fill, color, thickness when the
Output: none. mouse is
Pseudocode: none. pressed
8 onDrawRect(double x, double y) Draw the latest Drawing.ja Nguyen
Input: x,y. rectangle in va Hoang
Output: none the object list (182) Danh
29
Pseudocode: none corresponding
to the position
of the mouse
when it is
being dragged
9 initDrawEllipse(double x, double Add a new Drawing.ja Nguyen
y, boolean fill, String color, int ellipse to va Hoang
thickness) object list (222) Danh
Input: x, y, fill, color, thickness when the
Output: none. mouse is
Pseudocode: none. pressed
10 onDrawEllipse(double x, double y) Draw the latest Drawing.ja Nguyen
Input: x,y. ellipse in the va Hoang
Output: none object list (232) Danh
Pseudocode: none corresponding
to the position
of mouse
when it is
being dragged
11 initDrawStroke(double x, double Add a new Drawing.ja Nguyen
y, String color, int penSize) stroke to va Hoang
Input: x, y, fill, color, penSize object list (272) Danh
Output: none. when the
Pseudocode: none. mouse is
pressed
12 onDrawStroke(double x, double y) Draw the latest Drawing.ja Nguyen
Input: x,y. stroke in the va Hoang
Output: none object list (285) Danh
Pseudocode: none corresponding
to the position
of mouse
when it is
being dragged
13 initDrawEraser(double x, double Add a new Drawing.ja Nguyen
y, double eraserSize) eraser to va Hoang
Input: x, y, eraserSize object list (296) Danh
Output: none.
Pseudocode: none.
14 onDrawEraser(double x, double y) Clear every Drawing.ja Nguyen
Input: x,y. stroke va Hoang
Output: none corresponding (309) Danh
Pseudocode: none to the position
of mouse
when it is
being dragged
List of methods of ReadThread class
30
Table 19 – List of methods of ReadThread class
No. Method Purpose File name, Responsible
Line
1 run() Listen to data sent from ReadThrea Le Duc
Input: none. the server d.java Thinh
Output: none. (26)
Pseudocode: none.
2 getSocket() Get current socket ReadThrea Le Duc
Input: none. d.java Thinh
Output: Socket. (82)
Pseudocode: none
3 setSocket() Update socket ReadThrea Le Duc
Input: none. d.java Thinh
Output: Socket. (86)
Pseudo code: none
List of methods of WriteThread class
31
2 Client Le Duc Store information of a client
Thinh who is connecting to the
server
3 Datasource Le Duc An instance provides the
Thinh server with the ability to share
resources between threads
4 UserThread Le Duc Handle every request come
Thinh from clients
List of methods of Artboard class
32
Output: none.
Pseudocode: none.
3 getClientThread() Get the UserThread of a Client.java Le Duc
Input: none. client (15) Thinh
Output: UserThread.
Pseudocode: none
4 setClientThread() Get the UserThread of a Client.java Le Duc
Input: UserThread. client (19) Thinh
Output: none.
Pseudocode: none
List of methods of Datasource class
33
4 leaveAction(Artboard Close the connection UserThrea Le Duc
artboard, Client client) between client and server d.java Thinh
Input: artboard, client. (184)
Output: none.
Pseudocode: none.
5 updateAction(Artboard Tell the client that it UserThrea Le Duc
artboard, Client client) needs to update graphics d.java Thinh
Input: artboard, client. elements. (204)
Output: none.
Pseudocode: none.
6 broadcastMessage(Artb Broadcast message to UserThrea Le Duc
oard artboard, Client other clients d.java Thinh
client, String data) (211)
Input: artboard, client,
data.
Output: none.
Pseudocode: none.
34
3. Graphic User Interface
Table 26 – GUI explanation
No. GUI Purpose Brief Explanation
1 Main window The main Le Duc Thinh
window of On the left side is
the the menu for
application drawing functions
such as Select,
Undo, etc.
On the top is the
menu for export
the artboard to png
file, three buttons
which help connect
to other users.
After choosing one
of the drawing
function like Pen,
the user can click
and hold on the
blue grid to start
drawing.
2 Chat box Allows user Le Duc Thinh
to User can type
communicat anything to the text
e with field and then click
others send button. A
message will be
displayed in the
text area above the
text field and send
button
V.Conclusion
1. Student evaluation
• Almost requirements are met.
• Design the application with Object-Oriented programming paradigm.
36
• Simple design GUI for easy using.
• The code is quite clean and reusable
• Our application allows many people to draw together.
• Our application cannot allow the user to type in the canvas and import an
image to the canvas.
2. Difficulties
• Learning new technology is a problem for us because it slows down the
project progress
• Multi-threading programming is also a problem because we do not have
enough knowledge and practice.
3. Advantages
4. Disadvantages
• Multiple threads in this application are working but not in the perfect way.
Therefore, user experience (UX) may be a problem.
• The application cannot allow users to type text on the canvas.
• The application cannot import images to canvas.
5. Development ideas
• Instead of allowing a user with the basic drawing functions, we can upgrade
the drawing functions to become more technical and professional like
Photoshop or Corel Draw.
37
References
Examples about chat application using java socket:
https://cs.lmu.edu/~ray/notes/javanetexamples/
https://www.geeksforgeeks.org/multi-threaded-chat-application-set-1/
https://openjfx.io/openjfx-docs/#install-javafx
https://examples.javacodegeeks.com/desktop-java/javafx/javafx-canvas-example/
Multi-threading programming:
https://dzone.com/articles/java-thread-tutorial-creating-threads-and-multithr
Socket in java:
https://www.geeksforgeeks.org/socket-programming-in-java/
38