a. FinalFrame.java - Bilkent University

braintreesmileSoftware and s/w Development

Aug 15, 2012 (4 years and 10 months ago)

270 views

0


CS
-
422 / EEE
-
436

Wireless Networking

Technologies and Applications

Spring 2010


Group # 9

SIMULTANEOUS GRAPHIC MANAGER

MULTIBRUSH


Final Report

20
.05.2010


Fehmi Berkay Aksoy

Mehmet Doğaç Gülnerman

Şahin Höke

Umut Gültepe

Umut Cemal Yetgin

1


Table of Conten
ts

Table of Contents

................................
................................
................................
................................
..........

1

Introduction

................................
................................
................................
................................
..................

2

System Architecture

................................
................................
................................
................................
......

3

a.

The Environment

................................
................................
................................
...............................

3

b.

The Principles

................................
................................
................................
................................
....

3

c.

The Components and their tasks

................................
................................
................................
......

3

d.

The Process

................................
................................
................................
................................
.......

4

The Main Components

................................
................................
................................
................................
..

5

a.

FinalFrame.java

................................
................................
................................
................................
.

5

b.

Opener.java

................................
................................
................................
................................
.......

5

c.

Sample_Server.java

................................
................................
................................
...........................

5

d.

DrawingPanel.java

................................
................................
................................
............................

5

Other Components

................................
................................
................................
................................
.......

6

a.

AirBrush.java

................................
................................
................................
................................
.....

6

b.

About.java

................................
................................
................................
................................
.........

6

c.

AskIp.Java

................................
................................
................................
................................
..........

6

d.

Bright.java

................................
................................
................................
................................
.........

6

e.

Blocker.Java
................................
................................
................................
................................
.......

6

f.

Colorbar.java

................................
................................
................................
................................
.....

6

g.

FillOval.java

................................
................................
................................
................................
.......

7

h.

FillRect.java

................................
................................
................................
................................
.......

7

i.

Help.Java

................................
................................
................................
................................
...........

7

j.

Line.java

................................
................................
................................
................................
............

7

k.

MultiBrush.Java

................................
................................
................................
................................
.

7

l.

Oval.java

................................
................................
................................
................................
............

7

m.

Shape.java

................................
................................
................................
................................
.....

7

n.

Text.Java

................................
................................
................................
................................
............

7

o.

Rect.Java

................................
................................
................................
................................
...........

7

p.

Toolbar.java

................................
................................
................................
................................
......

8

Conclusion

................................
................................
................................
................................
.....................

8


2



Introduction


MultiBrush

is a graphics manage
ment program. Containing the basic aspects of MS Paint, it
takes it to a whole new level by introducing multi
-
user support from different bases. Theoretically, it
supports unlimited number of users, with unnoticeable delay between stations, allows simultan
eous
working on the same project. Although the current version of our project contains very simple drawing
tools, it is easy to implement new previously defined drawing tools, making it easy for previous more
advanced single
-
user graphic management program
s to escalade to the multi
-
user system.


The defined operating system is Windows XP, with the coding language of JAVA. Using JAVA
makes it possible to implement the system for other work stations and operating systems as well, since
it is a universal code
. We used the NetBeans Java development platform due to its user
-
friendly
interface and its simplicity to create GUI projects.
We implemented exception handling in various classes
in order to avoid bugs and crashes.


The application can be used with ad
-
hoc

networks, and it can be configured o be run from a
dedicated host with a router; however the performance with ad
-
hoc network was sufficient with such
primitive tools. With more advanced drawing platforms, a dedicated host can be used.


We have met most of

our initial goals; they will be examined in the following chapters.

3


System Architecture

a.

The Environment


MultiBrush is coded with Java language, and it is designed to work with Windows XP and higher
operating systems. It is developed in NetBeans platfor
m.
It can be operated from laptops or desktops
with wireless adapters.

b.

The Principles

The principles which are designated in the initial project meeting are listed below, and they are
either checked or crossed with respect to their achievements.



4 user sup
port



Limited Area Locking



Line, Rectangle, Circle, Pencil, Brush and Eraser



AD
-
HOC compatible



10 Colors



Help Menus



Offline Operating Option



Text Support

The following principles are either omitted or replaced by other features.



Mirroring and rotating suppo
rt



Cut, copy and paste features

c.

The
C
omponents and their
tasks

Since MultiBrush is a relatively complex application, it contains various pre
-
defined classes and
components. While making the GUI functional and user
-
friendly, we used the following Java class
es:



AirBrush
.java


: Brushing Tool



bright.java


: Used to set brightness



Colorbar.java


: Holds the available colors



FillOval.java


: Filled oval(circle) tool



FillRect.java


: Filled rectangle tool



Line.java


: Line tool



Oval.java


: Oval tool



Shape.java


: General shape class, all tools are extended from this class



Text.java


: Text inserting tool



Rect.java


:

Rectangle tool



Toolbar.java


:
Holds the available tools

The following components are defined and implemented by us:



About.java


:

Used for displayi
ng information about the project



AskIp.java


:

Used for
inputting the

IP of host



Blocker.java


: Used to block a portion of the drawing area



DrawingPanel.java

: Holds the information about the drawing area

4




Help.java


: Used to display help about the projec
t



FinalFrame.java


: Used to initialize the program



Opener.java


: Used to

listen to the mouse

and perform connections



S
ample_server.java

:
The

server model used in the program



MultiBrush.java


: The main component of the program

d.

The Process



The server is
created by running the sample_server.java. Other computers can connect to the
server with the opener class.



When the project is run, the main method in MultiBrush.java is executed, which creates a new
FinalFrame object, holding everything for the program i
n the JFrame
, the toolbar, color bar….



With every click on a shape or a color, the current selection is recorded by the mouse listener,
and used in the clicks on the drawing area.



When a drawing is performed, the information is sent with the methods implem
ented in the
sample_server.java.



Sample_server.java also contains a method to update the drawing area after listening to the
incoming data from other computers.



The travelling packets contain information about the colour, tool and the location of the
opera
tion.



The predefined IP of the host is 127.0.01. The number of the used port is 80.

5


The Main Components

The main components of MultiBrush can be listed as below:



FinalFrame.java



Opener.java



Sample_server.java

The details of these components will be given

in this section, whereas the other components
will be briefly explained in the next section.

a.

FinalFrame.java

Final frame is the object created with the opening of the program. When it is executed, it performs the
following tasks:



Sets the layout of the fr
ame as a border layout, adds the drawing area in the center, the menu
bar at its place, the tool buttons above the drawing area and the color buttons below the
drawing area.

o

The menu bar contains file, edit, view, colors and help menus. The contents of the
se
menus are standard, without any complex functions.

o

The toolbar and the colorbar are defined at their respective classes.
They are not
classified as main components since they are pre
-
defined.



Adds a WindowListener to exit when it is clicked.



After creat
ing the menus,
the menu listener is implemented, by adding each function to menu
buttons, and assigning the functions associated with them.

b.

Opener.java

Opener is a class executed after the initiation of the program. It is the main class that is handling th
e
networking features of the application. It contains the ip of the server, and several methods to update
the drawing panel.

However with the latest developments, the server’s ip is acquired with the askIp
class. The opener.java is executed after the IP is

acquired from the askIp, or it is dismissed, in order to
create the mouse listener.

c.

Sample_Server.java

This class handles all the transfers between the stations. It uses Java.net libraries in order to perform
networking tasks, and uses their streaming ob
jects in order to transmit and receive data packets.

d.

DrawingPanel.java

DrawingPanel.java is the cornerstone of the whole program. It holds the information about the drawing,
invokes the sending method in sample_server with every new action. It contains mo
use listener and
mouse motion listeners, in order to acquire information. Most of the program is the same with the
traditional drawing panel used in other painting programs, however, every new change is packed, and
sent with output streaming. It also recei
ves data from other clients, and performs the drawing by others
itself.

6


Other

Components

The components explained here are either previously created classes for public use, or small classes
written by us in order to perform specific tasks. They are most
ly about the GUI of the program. The
pictures for
buttons are included with the project.

All the tools extended from shape classes override the

abstract

draw method in order to perform their
individual drawing operations. Contour
-
like shapes also
have a

se
tShape method in order to achieve
their designed shapes.

a.

AirBrush
.java

AirBrush.Java contains the class to implement a paint brush on the panel.
It paints not only the point
clicked, but also creates a random amount of splatter around the point clicked.

Th
e color is chosen from
the colorbar at the bottom of the frame.


b.

About.java

About.java only pops up a dialog box containing information about the project. It is merely an
information class, and has no other functionality.


c.

AskIp.Java

When the program is in
itiated, AskIp.java pops up a dialog box, in order to acquire the IP of the server. It
contains two buttons and a text box. One of the buttons is to notify the computer after typing in the IP
address in the text box, to get it processed. Other button is us
ed to ignore the networking features of
the program, and MultiBrush becomes merely a simple drawing application.


d.

Bright.java

This class is used to change the brightness of the colors used, with a slider. It adds a variety of colors to
the program. It uses

the java Slider to acquire information, and its listener.


e.

Blocker.Java

This class contains one of the key features of MultiBrush. It has the methods to allow one of the users to
lock a certain portion of the drawing panel in order to keep other users fro
m interfering with its work.
When the user blocks a portion of the area, a Boolean variable is set, and the incoming data from other
users are completely ignored as packets.
The blocking information is used in drawing panel.


f.

Colorbar.java

Colorbar.java co
ntains 11 JRadioButtons, and sets the color variable in the program according to the one
pressed last.
It creates its layout by adding its buttons one by one next to each other. It acquires its
input with the listener of the radio buttons.


7


g.

FillOval.java



This method is for drawing ovals with fill. The color is chosen from the colorbar at the bottom of the
frame. Unlike MS Paint, the circle is not drawn by draggin the mouse, but rather by clicking at the first
and second points defining the oval.


h.

FillRect
.java



Exactly like FillOval.java, but with rectangles. The color is chosen from the colorbar at the bottom of the
frame. Unlike MS Paint, the circle is not drawn by draggin the mouse, but rather by clicking at the first
and second points defining the ova
l.

i.

Help.Java

Like about.java, this class creates an object which pops up a dialog box containing information about
operating the program. It has no function that has anything to do with the GUI or networking
whatsoever.

j.

Line.java



This method is simply us
ed to draw lines between two consequently clicked points on the drawing
panel. Its color is chosen from the colorbar.

k.

MultiBrush.Java

The project’s main component, merely creates a new FinalFrame object when executed. Acting only as
an initiator, MultiBrus
h.Java is the simplest component in all the project.

l.

Oval.java



Oval.Java is the unfilled version of FillOval class. Everything else about it is exactly the same as
FillOval.Java.

m.

Shape.java


The draft for all shaping tools, shape.java only contains the m
ethod to acquire the color specified at the
colorbar. It has only one variable color, every other specification about any shape is defined within its
own class. It also contains two abstract methods to force implementation on other shapes: draw and
isBlock
er.


n.

Text.Java

Text.Java creates a new shape object based on the input text. It uses the pre
-
defined drawString method
of Java libraries.

o.

Rect.Java

Rect.Java is the unfilled version of FillRect class. Everything else about it is exactly the same as
FillRe
ct.Java.


8


p.

Toolbar.java


Toolbar
.java contains 11 JRadioButtons, and sets the color variable in the program according to the one
pressed last. It creates its layout by adding its buttons one by one next to each other. It acquires its
input with the listener

of the radio buttons.


Conclusion

The crucial goals we set out in the beginning are met, and we came up with a functional wireless
supporting graphics management program.

Although there are several shortcomings such as the
simplicity, and the failure of u
pdating the drawing area after a certain amount of users, the primary
functions of the program are complete and useful. Below is a final screenshot of the program, ready to
be worked on by a number of different users sumiltaneously.