Professional Documents
Culture Documents
Print Brush Java Project PDF
Print Brush Java Project PDF
Project Report
on
“Paint brush”
1
Paint brush
Table of Content
1. Introduction
3. Design Phase
4. Testing Phase
5. Maintenance Phase
7. Reference
2
Paint brush
Introduction
The name of the project is “Paint Brush”. This is a simple java applet implementation of a paint-
brush style program. This applet was taken directly from the Java Developers Kit. We use java
language for making this project. In this project we use java applet. Without the use of java
language and java applet we wouldn’t be able to complete this project. It is a small example of
what java can do. It has the basic drawing tools such as pen, line, eraser, clear, brush, filled and
non-filled rectangles and oval and color manipulation options, other than that its really boring,
but a good example of how to use java's graphics libraries. This project is simple so it is easy for
user to understand. We need Java NaviCoder IDE to run the program of this project. We need
java and java applet to complete this project.
In this project we make Pen, Line , Eraser, Clear , Rectangle, Oval, Filled Rectangle or Oval and
Brush. If we want to draw line then we can click on line option and we can click on color which
we want to take. After this drag the cursor then the operation will be performed. Like this we can
draw rectangle, oval etc. If we want to draw something free hand then we can use pen. We can
use brush to paint anything. If we want to erase something then we can use eraser by clicking on
eraser option. If we had made something wrong and we want to clear it then we can clear it by
using clear.
3
Paint brush
Requirement Analysis :-
Requirement analysis is meant for capturing the correct requirements. Requirement Analysis is
one of initial and very important step as success of project is largely depends on correct
requirement capturing. In this project we need java navicoder software to make and run the
program.We need Java language or java applet to complete the program.
Java applet :- Java applets can run in a Web browser using a Java Virtual Machine (JVM), or
in Sun's Applet Viewer, a stand-alone tool for testing applets. Java applets were introduced in the
first version of the Java language in 1995, and are written in programming languages that
compile to Java byte code, usually in Java, but also in other languages such
as Jython, JRuby, or Eiffel .Java applets run at very fast speeds comparable to, but generally
slower than, other compiled languages such as C++, but until approximately 2011 many times
faster than Java Script. In addition they can use 3D hardware acceleration that is available from
Java. This makes applets well suited for non-trivial, computation intensive visualizations. As
browsers have gained support for native hardware accelerated graphics in the form
of Canvas and WebGL, as well as Just in Time compiled JavaScript, the speed difference has
become less noticeable.
NaviCoder IDE:- NaviCoder is a Java IDE that runs on Windows which enables
programmers to create, navigate, modify, and debug code faster and more accurately. NaviCoder
can be used in conjunction with different Java Developer Kits by configurating JDK
profiles. NaviCoder features an intuitive interface and provides a wide range of features: fast
opening, rapid response times, customizable user interface, project management, wizards, class
viewer, package viewer, tabbed documents and remote debugging. In addition, NaviCoder
4
Paint brush
equips a comprehensive set of code editor tools enabling developers to rapidly create
sophisticated Java applications/applets, some of the capabilities, including syntax highlighting,
smart code completion, automatic indentation, formatting, and more.NaviCoder IDE for JAVA is
an Integrated Development Environment (IDE) for Java developers. It allows you to compile and
debug your Java program from the editor environment, as well as browse through your classes.
You will get all the tools you need to create professional programs: project management,
wizards, class viewer, package viewer, tabbed documents, JDK profiles (which allows you to
work with multiple Java Development Kits), a customizable user interface. It just simply meets
your exact needs.
5
Paint brush
Design Phase
In design phase we design how our project should look like.We design our code to make paint
brush project.In this project we make Oval, Rectangle, Pen, Line, Eraser, clear, Filled recatangle
or oval and brush.We make the coding of this project in Java NaviCoder IDE.This project is not
similar to simple paint which we have in our laptops or computers.
Pen:-Pen is a tool that is use to draw things free hand. If we want to draw free hand line of multi
colors then first we have to click on pen option then click on color tools and chose the colors
which we want.After this drag the cursor, the operation will be performed. The lines of the
selected colors will be shown.
Line:-A tool that is used to draw a straight line is known as line tool. If we want to draw line then
we have to click on line option and we have to click on color which we want to take.After
selecting color, drag a mouse then a operation will be perform.
Eraser: - The eraser is a tool that erase the things which be selected for erase. The Eraser tool is
simple to use. Just click on it to select it, then click on the part of the thing that we want to erase.
Clear :- A tool that is used to clear a screen is known as clear tool. The Clear tool is also simple
to use like eraser tool. Just click on it, then the screen will get clear.
Rectangle: - A rectangle is a four-sided flat shape where every angle is a right angle (90°). The
rectangle tool is used to draw a rectangle. Click on rectangle option. After that select color then
drag the cursor the operation will be performed. The rectangle of selected color will be display.
Oval: - An oval is a closed curve in a plane which "loosely" resembles the outline of an egg. The
oval tool is used to draw a oval. Click on Oval option. After this select color then drag the cursor
the operation will be performed. The oval of selected color will be display.
Filled rectangle or Oval :- The filled rectangle tool is used to draw the filled rectangle. Click on
filled rectangle option to make filled rectangle and chose the color. Then drag the cursor a filled
oval will display.
The filled oval tool is used to draw the filled oval. Click on filled oval option to make filled oval
and chose the color. Then drag the cursor a filled oval will display.
Brush: - The brush tool is used to paint anything. If we want to paint then click on it option.
Chose the color. Then drag the cursor the result will display.
6
Paint brush
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseEvent;
import java.lang.Math.*;
import java.lang.*;
import java.text.*;
import java.io.*;
import java.awt.Scrollbar.*;
public class paint extends Applet implements ActionListener, AdjustmentListener,
MouseListener, MouseMotionListener
{
private final int MAX_X = 800;
private final int MAX_Y = 600;
/* Operation Constants */
private final int NO_OP = 0;
private final int PEN_OP = 1;
private final int LINE_OP = 2;
private final int ERASER_OP = 3;
private final int CLEAR_OP = 4;
private final int RECT_OP = 5;
private final int OVAL_OP = 6;
private final int FRECT_OP = 7;
private final int FOVAL_OP = 8;
7
Paint brush
8
Paint brush
controlPanel.add(blackButton);
controlPanel.add(blueButton);
controlPanel.add(redButton);
controlPanel.add(greenButton);
9
Paint brush
controlPanel.add(purpleButton);
controlPanel.add(orangeButton);
controlPanel.add(pinkButton);
controlPanel.add(grayButton);
controlPanel.add(yellowButton);
controlPanel.add(userDefButton);
blueButton.setBackground(Color.blue);
redButton.setBackground(Color.red);
greenButton.setBackground(Color.green);
purpleButton.setBackground(Color.magenta);
orangeButton.setBackground(Color.orange);
pinkButton.setBackground(Color.pink);
grayButton.setBackground(Color.gray);
yellowButton.setBackground(Color.yellow);
userDefButton.setBackground(userDefinedColor);
controlPanel.add(penButton);
controlPanel.add(lineButton);
controlPanel.add(eraserButton);
controlPanel.add(clearButton);
controlPanel.add(rectButton);
controlPanel.add(ovalButton);
controlPanel.add(fillRectButton);
controlPanel.add(fillOvalButton);
controlPanel.add(BrushButton);
controlPanel.setBounds(0,0,100,300);
controlPanel.add(udefcolPanel);
controlPanel.add(udefdemcolPanel);
udefcolPanel.add(redValue);
udefcolPanel.add(redSlider);
udefcolPanel.add(greenValue);
udefcolPanel.add(greenSlider);
udefcolPanel.add(blueValue);
udefcolPanel.add(blueSlider);
10
Paint brush
statusPanel.add(colorLabel);
statusPanel.add(colorStatusBar);
statusPanel.add(operationLabel);
statusPanel.add(opStatusBar);
statusPanel.add(cursorLabel);
statusPanel.add(mouseStatusBar);
colorStatusBar.setEditable(false);
opStatusBar.setEditable(false);
mouseStatusBar.setEditable(false);
statusPanel.setBackground(statusBarColor);
controlPanel.setBackground(Color.white);
drawPanel.setBackground(Color.white);
add(statusPanel, "North");
add(controlPanel, "West");
add(drawPanel, "Center");
penButton.addActionListener(this);
lineButton.addActionListener(this);
eraserButton.addActionListener(this);
clearButton.addActionListener(this);
rectButton.addActionListener(this);
ovalButton.addActionListener(this);
fillRectButton.addActionListener(this);
fillOvalButton.addActionListener(this);
BrushButton.addActionListener(this);
blackButton.addActionListener(this);
blueButton.addActionListener(this);
redButton.addActionListener(this);
greenButton.addActionListener(this);
11
Paint brush
purpleButton.addActionListener(this);
orangeButton.addActionListener(this);
pinkButton.addActionListener(this);
grayButton.addActionListener(this);
yellowButton.addActionListener(this);
userDefButton.addActionListener(this);
redSlider.addAdjustmentListener(this);
blueSlider.addAdjustmentListener(this);
greenSlider.addAdjustmentListener(this);
drawPanel.addMouseMotionListener(this);
drawPanel.addMouseListener(this);
this.addMouseListener(this);
this.addMouseMotionListener(this);
updateRGBValues();
opStatusBar.setText("Pen");
colorStatusBar.setText("Black");
}
if (e.getActionCommand() == "Pen")
opStatus = PEN_OP;
if (e.getActionCommand() == "Line")
opStatus = LINE_OP;
if (e.getActionCommand() == "Eraser")
opStatus = ERASER_OP;
if (e.getActionCommand() == "Clear")
opStatus = CLEAR_OP;
12
Paint brush
if (e.getActionCommand() == "Rectangle")
opStatus = RECT_OP;
if (e.getActionCommand() == "Oval")
opStatus = OVAL_OP;
if (e.getActionCommand() == "Brush")
opStatus = POLY_OP;
if (e.getActionCommand() == "Black")
colorStatus = 1;
if (e.getActionCommand() == "Blue")
colorStatus = 2;
if (e.getActionCommand() == "Green")
colorStatus = 3;
if (e.getActionCommand() == "Red")
colorStatus = 4;
if (e.getActionCommand() == "Purple")
colorStatus = 5;
if (e.getActionCommand() == "Orange")
colorStatus = 6;
if (e.getActionCommand() == "Pink")
colorStatus = 7;
if (e.getActionCommand() == "Gray")
colorStatus = 8;
13
Paint brush
if (e.getActionCommand() == "Yellow")
colorStatus = 9;
if (e.getActionCommand() == "User-Def")
colorStatus = 10;
initialBrush = true;
initialSpline = true;
switch (opStatus)
{
case PEN_OP : opStatusBar.setText("Pen");
break;
14
Paint brush
switch (colorStatus)
{
case 1: colorStatusBar.setText("Black");
break;
case 2: colorStatusBar.setText("Blue");
break;
case 3: colorStatusBar.setText("Green");
break;
case 4: colorStatusBar.setText("Red");
break;
case 5: colorStatusBar.setText("Purple");
break;
case 6: colorStatusBar.setText("Orange");
break;
case 7: colorStatusBar.setText("Pink");
break;
case 8: colorStatusBar.setText("Gray");
break;
case 9: colorStatusBar.setText("Yellow");
break;
setMainColor();
updateRGBValues();
}
15
Paint brush
if (initialPen)
{
setGraphicalDefaults(e);
initialPen = false;
g.drawLine(prevx,prevy,mousex,mousey);
}
if (mouseHasMoved(e))
{
mousex = e.getX();
mousey = e.getY();
g.drawLine(prevx,prevy,mousex,mousey);
prevx = mousex;
prevy = mousey;
}
}
16
Paint brush
if (initialLine)
{
setGraphicalDefaults(e);
g.setXORMode(xorColor);
g.drawLine(Orx,Ory,mousex,mousey);
initialLine=false;
}
if (mouseHasMoved(e))
{
g.setXORMode(xorColor);
g.drawLine(Orx,Ory,mousex,mousey);
mousex = e.getX();
mousey = e.getY();
g.drawLine(Orx,Ory,mousex,mousey);
}
}
if (initialRect)
{
setGraphicalDefaults(e);
initialRect = false;
}
if (mouseHasMoved(e))
{
g.setXORMode(drawPanel.getBackground());
17
Paint brush
g.drawRect(drawX,drawY,OrWidth,OrHeight);
mousex = e.getX();
mousey = e.getY();
setActualBoundry();
g.drawRect(drawX,drawY,OrWidth,OrHeight);
if (initialOval)
{
setGraphicalDefaults(e);
initialOval=false;
}
if (mouseHasMoved(e))
{
g.setXORMode(xorColor);
g.drawOval(drawX,drawY,OrWidth,OrHeight);
mousex = e.getX();
mousey = e.getY();
setActualBoundry();
g.drawOval(drawX,drawY,OrWidth,OrHeight);
}
18
Paint brush
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
if (initialFRect)
{
setGraphicalDefaults(e);
initialFRect=false;
}
if (mouseHasMoved(e))
{
g.setXORMode(xorColor);
g.drawRect(drawX,drawY,OrWidth-1,OrHeight-1);
mousex = e.getX();
mousey = e.getY();
setActualBoundry();
g.drawRect(drawX,drawY,OrWidth-1,OrHeight-1);
if (initialFOval)
{
setGraphicalDefaults(e);
19
Paint brush
initialFOval = false;
}
if (mouseHasMoved(e))
{
g.setXORMode(xorColor);
g.drawOval(drawX,drawY,OrWidth,OrHeight);
mousex = e.getX();
mousey = e.getY();
setActualBoundry();
g.drawOval(drawX,drawY,OrWidth,OrHeight);
}
if (initialEraser)
{
setGraphicalDefaults(e);
initialEraser = false;
g.setColor(mainColor.white);
g.fillRect(mousex-eraserLength, mousey-eraserLength,eraserLength*2,eraserLength*2);
g.setColor(Color.black);
g.drawRect(mousex-eraserLength,mousey-eraserLength,eraserLength*2,eraserLength*2);
prevx = mousex;
prevy = mousey;
}
if (mouseHasMoved(e))
{
g.setColor(mainColor.white);
g.drawRect(prevx-eraserLength, prevy-eraserLength,eraserLength*2,eraserLength*2);
20
Paint brush
mousex = e.getX();
mousey = e.getY();
g.setColor(mainColor.white);
g.fillRect(mousex-eraserLength, mousey-eraserLength,eraserLength*2,eraserLength*2);
g.setColor(Color.black);
g.drawRect(mousex-eraserLength,mousey-eraserLength,eraserLength*2,eraserLength*2);
prevx = mousex;
prevy = mousey;
}
}
Thread.currentThread().sleep(80) ;
prevx = mousex;
prevy = mousey;
}
catch (InterruptedException ie)
{}
}
21
Paint brush
}
if (mousey < Ory)
{
OrHeight = Ory - mousey;
drawY = Ory - OrHeight;
}
else
{
drawY = Ory;
OrHeight = mousey - Ory;
}
}
else
{
drawX = Orx;
drawY = Ory;
22
Paint brush
switch (opStatus)
{
case PEN_OP : penOperation(e);
break;
23
Paint brush
updateMouseCoordinates(e);
switch (opStatus)
{
case PEN_OP : releasedPen();
break;
24
Paint brush
25
Paint brush
26
Paint brush
27
Paint brush
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
g.drawLine(prevx,prevy,mousex,mousey);
prevx = mousex;
prevy = mousey;
}
public void updateMouseCoordinates(MouseEvent e)
{
String xCoor ="";
String yCoor ="";
if (udefRedValue < 0 )
udefRedValue =0;
28
Paint brush
if (udefGreenValue < 0 )
udefGreenValue =0;
if (udefBlueValue < 0 )
udefBlueValue =0;
redValue.setText(String.valueOf(udefRedValue));
greenValue.setText(String.valueOf(udefGreenValue));
blueValue.setText(String.valueOf(udefBlueValue));
Graphics g = udefdemcolPanel.getGraphics();
g.setColor(userDefinedColor);
g.fillRect(0,0,800,800);
}
case 10 : BrushOperation(e);
break;
}
}
29
Paint brush
{
updateMouseCoordinates(e);
}
} // End of Scribble
Outputs of a tools :-
Output of pen :-
30
Paint brush
Output of Line :-
Output of Eraser :-
31
Paint brush
Output of Clear :
Output of rectangle :-
32
Paint brush
Output of oval :-
33
Paint brush
Output of brush :-
34
Paint brush
Testing phase
Java Testing includes testing of Java applications during development cycle. Locating and fixing
performance problems during source code development time is arguably the cheapest way to
resolve problems. As our project goes past the development phase, in to testing and deployment,
the cost of fixing problems grows exponentially. Java Testing ensures that the problems in
source code are addressed as and when you are developing. Java Testing also includes generating
test classes for your source code and executing it with different parameters ensuring that your
source works fine in all possible scenarios. Java Testing ensures fully functional, highly
intelligent test classes that understand your application and test your source files thoroughly.
Most of the applications today are designed and developed for simultaneous use by a large
number of users.
Types of testing :-
There are three main types of testing:
Assertion Testing—Testing at the API level, demonstrating that the code will perform as
specified: "For this API, and this input, the following output/error will be returned.
Stress Testing—Continually running features and methods randomly for as long as they
might be running in the real world. Stress testing is particularly effective at manifesting
memory leaks, garbage collection problems, and thread execution issues.
35
Paint brush
Maintenance
Maintenance is a set of organised activities that are carried out in order to keep an item in its best
operational condition with minimum cost acquired. the combination of all technical and
administrative actions, including supervision actions, intended to retain an item in, or restore it
to, a state in which it can perform a required function.
Types of Maintenance
The required repair, replacement, or restore action performed on a machine or a facility after the
occurrence of a failure in order to bring this machine or facility to at least its minimum
acceptable condition. It is the oldest type of maintenance.
Emergency maintenance: it is carried out as fast as possible in order to bring a failed machine or
facility to a safe and operationally efficient condition.
It is a set of activities that are performed on plant equipment, machinery, and systems before the
occurrence of a failure in order to protect them and to prevent or eliminate any degradation in
their operating conditions. The maintenance carried out at predetermined intervals or according
to prescribed criteria and intended to reduce the probability of failure or the degradation of the
functioning and the effects limited. It is good for those machines and facilities which their failure
would cause serious production losses. Its aim is to maintain machines and facilities in such a
condition that breakdowns and emergency repairs are minimised. Its activities include
replacements, adjustments, major overhauls, inspections and lubrications.
In this type, actions such as repair, replacement, or restore will be carried out after the
occurrence of a failure in order to eliminate the source of this failure or reduce the frequency of
36
Paint brush
its occurrence. The maintenance carried out after recognition and intended to put an item into a
state in which it can perform a required function.
Remedial maintenance, which is a set of activities that are performed to eliminate the
source of failure without interrupting the continuity of the production process.
Deferred maintenance, which is a set of corrective maintenance activities that are not
immediately initiated after the occurrence of a failure but are delayed in such a way that
will not affect the production process.
It aims at reducing or eliminating entirely the need for maintenance. This type of
maintenance is subdivided into three types as follows:
1. Design-out maintenance which is a set of activities that are used to eliminate the cause
of maintenance, simplify maintenance tasks, or raise machine performance from the
maintenance point of view by redesigning those machines and facilities which are
vulnerable to frequent occurrence of failure and their long term repair or replacement cost
is very expensive.
Predictive maintenance is a set of activities that detect changes in the physical condition
of equipment (signs of failure) in order to carry out the appropriate maintenance work for
maximising the service life of equipment without increasing the risk of failure.It is
classified into two kinds according to the methods of detecting the signs of failure:
37
Paint brush
38
Paint brush
In this project we made drawing tools like rectangle, oval, pen, eraser, clear, filled
rectangle or oval and brush. In our free time or boring time we can use it. This project is based
on java applet.
In future we can make this project totally differ from the window based paint or many
other kind of painting software. We will make it different because the low level and middle level
person can't purchase software. We will make this as a kind of application which can also run on
our mobile. We can use it as our professional work and for entertainment.
In future we can extend this project by making more tools. We can make polygon tool,
add text tool ,spline tool and many other tools. We can also add image tool for adding a image in
a project .Adding image in a project can change the shape of the project.
39
Paint brush
References :-
40