You are on page 1of 40

Paint brush

Project Report
on
Paint brush

1
Paint brush

Table of Content

S.NO. TOPIC PAGE NO.

1. Introduction

2. Requirement Analysis Phase

3. Design Phase

4. Testing Phase

5. Maintenance Phase

6. Future scope and applications

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 wouldnt 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 :- Java is a programming language originally developed by James Gosling at Sun


Microsystems which has since merged into Oracle Corporation and released in 1995 as a core
component of Sun Microsystems' Java platform. The language derives much of
its syntax from C and C++ but has a simpler object model and fewer low-level facilities.
Java applications are typically compiled to byte code (class file) that can run on any Java Virtual
Machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-
based, object-oriented language that is specifically designed to have as few implementation
dependencies as possible. It is intended to let application developers "write once, run anywhere"
(WORA), meaning that code that runs on one platform does not need to be recompiled to run on
another. Java is as of 2012 one of the most popular programming languages in use, particularly
for client-server web applications, with a reported 10 million users.

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.

Theory about all these tools:-

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

The coding of 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;

private final int POLY_OP = 9;

private int mousex = 0;


private int mousey = 0;

private int prevx = 0;


private int prevy = 0;

7
Paint brush

private boolean initialPen = true;


private boolean initialLine = true;
private boolean initialEraser = true;
private boolean initialRect = true;
private boolean initialOval = true;
private boolean initialFRect = true;
private boolean initialFOval = true;
private boolean initialBrush = true;

private int Orx = 0;


private int Ory = 0;
private int OrWidth = 0;
private int OrHeight = 0;
private int drawX = 0;
private int drawY = 0;
private int eraserLength = 5;
private int udefRedValue = 255;
private int udefGreenValue = 255;
private int udefBlueValue = 255;

private int opStatus = PEN_OP;


private int colorStatus = 1;
private Color mainColor = new Color(0,0,0);
private Color xorColor = new Color(255,255,255);
private Color statusBarColor = new Color(166,166,255);
private Color userDefinedColor = new Color(udefRedValue,udefGreenValue,udefBlueValue);

private Button penButton = new Button("Pen");


private Button lineButton = new Button("Line");
private Button eraserButton = new Button("Eraser");
private Button clearButton = new Button("Clear");
private Button rectButton = new Button("Rectangle");
private Button ovalButton = new Button("Oval");
private Button fillRectButton = new Button("Filled Rectangle");
private Button fillOvalButton = new Button("Filled Oval");

private Button BrushButton = new Button("Brush");

private Button blackButton = new Button("Black");

8
Paint brush

private Button blueButton = new Button("Blue");


private Button redButton = new Button("Red");
private Button greenButton = new Button("Green");
private Button purpleButton = new Button("Magenta");
private Button orangeButton = new Button("Orange");
private Button pinkButton = new Button("Pink");
private Button grayButton = new Button("Gray");
private Button yellowButton = new Button("Yellow");
private Button userDefButton = new Button("User-Def");

private Scrollbar redSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255);


private Scrollbar blueSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255);
private Scrollbar greenSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255);

private TextField colorStatusBar = new TextField(20);


private TextField opStatusBar = new TextField(20);
private TextField mouseStatusBar = new TextField(10);
private TextField redValue = new TextField(3);
private TextField greenValue = new TextField(3);
private TextField blueValue = new TextField(3);

private Label operationLabel = new Label(" Tool mode:");


private Label colorLabel = new Label(" Color mode:");
private Label cursorLabel = new Label(" Cursor:");

private Panel controlPanel = new Panel(new GridLayout(11,2,0,0));


private Panel drawPanel = new Panel();
private Panel statusPanel = new Panel();
private Panel udefcolPanel = new Panel(new GridLayout(3,2,0,0));
private Panel udefdemcolPanel = new Panel();

public void init()


{
setLayout(new BorderLayout());

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");
}

public void actionPerformed(ActionEvent e)


{

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() == "Filled Rectangle")


opStatus = FRECT_OP;

if (e.getActionCommand() == "Filled Oval")


opStatus = FOVAL_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;

case LINE_OP : opStatusBar.setText("Line");


break;

case ERASER_OP: opStatusBar.setText("Eraser");


break;

case CLEAR_OP : clearPanel(drawPanel);


break;

case RECT_OP : opStatusBar.setText("Rectangle");


break;

case OVAL_OP : opStatusBar.setText("Oval");


break;

case FRECT_OP : opStatusBar.setText("Fill-Rectangle");


break;

case FOVAL_OP : opStatusBar.setText("Fill-Oval");


break;

case POLY_OP : opStatusBar.setText("Brush");


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;

case 10: colorStatusBar.setText("User Defined Color");


break;
}

setMainColor();
updateRGBValues();
}

15
Paint brush

public void adjustmentValueChanged(AdjustmentEvent e)


{
updateRGBValues();
}

public void clearPanel(Panel p)


{
opStatusBar.setText("Clear");
Graphics g = p.getGraphics();
g.setColor(p.getBackground());
g.fillRect(0,0,p.getBounds().width,p.getBounds().height);
}

public void penOperation(MouseEvent e)


{
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);

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

public void lineOperation(MouseEvent e)


{
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);

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);
}
}

public void rectOperation(MouseEvent e)


{
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);

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);

public void ovalOperation(MouseEvent e)


{
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);

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

public void frectOperation(MouseEvent e)


{

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);

public void fovalOperation(MouseEvent e)


{
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);

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);
}

public void eraserOperation(MouseEvent e)


{
Graphics g = drawPanel.getGraphics();

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;
}
}

public void BrushOperation(MouseEvent e)


{
if (initialBrush)
{
prevx = e.getX();
prevy = e.getY();
initialBrush = false;
}
else
{
try
{
mousex = e.getX();
mousey = e.getY();
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
g.fillOval(prevx,prevy,6,6);

Thread.currentThread().sleep(80) ;
prevx = mousex;
prevy = mousey;
}
catch (InterruptedException ie)
{}
}

21
Paint brush

public boolean mouseHasMoved(MouseEvent e)


{
return (mousex != e.getX() || mousey != e.getY());
}

public void setActualBoundry()


{
if (mousex < Orx || mousey < Ory)
{

if (mousex < Orx)


{
OrWidth = Orx - mousex;
drawX = Orx - OrWidth;
}
else
{
drawX = Orx;
OrWidth = mousex - Orx;

}
if (mousey < Ory)
{
OrHeight = Ory - mousey;
drawY = Ory - OrHeight;
}
else
{
drawY = Ory;
OrHeight = mousey - Ory;
}
}
else
{
drawX = Orx;
drawY = Ory;

22
Paint brush

OrWidth = mousex - Orx;


OrHeight = mousey - Ory;
}
}

public void setGraphicalDefaults(MouseEvent e)


{
mousex = e.getX();
mousey = e.getY();
prevx = e.getX();
prevy = e.getY();
Orx = e.getX();
Ory = e.getY();
drawX = e.getX();
drawY = e.getY();
OrWidth = 0;
OrHeight = 0;
}

public void mouseDragged(MouseEvent e)


{
updateMouseCoordinates(e);

switch (opStatus)
{
case PEN_OP : penOperation(e);
break;

case LINE_OP : lineOperation(e);


break;

case RECT_OP : rectOperation(e);


break;

case OVAL_OP : ovalOperation(e);


break;

23
Paint brush

case FRECT_OP : frectOperation(e);


break;

case FOVAL_OP : fovalOperation(e);


break;

case ERASER_OP: eraserOperation(e);


break;
case POLY_OP: BrushOperation(e);
break;
}
}

public void mouseReleased(MouseEvent e)


{

updateMouseCoordinates(e);

switch (opStatus)
{
case PEN_OP : releasedPen();
break;

case LINE_OP : releasedLine();


break;

case RECT_OP : releasedRect();


break;

case OVAL_OP : releasedOval();


break;

case FRECT_OP : releasedFRect();


break;

24
Paint brush

case FOVAL_OP : releasedFOval();


break;

case ERASER_OP : releasedEraser();


break;
case POLY_OP: BrushOperation(e);
break;
}
}

public void mouseEntered(MouseEvent e)


{
updateMouseCoordinates(e);
}

public void setMainColor()


{
switch (colorStatus)
{
case 1 : mainColor = Color.black;
break;

case 2: mainColor = Color.blue;


break;

case 3: mainColor = Color.green;


break;

case 4: mainColor = Color.red;


break;

case 5: mainColor = Color.magenta;


break;

case 6: mainColor = Color.orange;


break;

25
Paint brush

case 7: mainColor = Color.pink;


break;

case 8: mainColor = Color.gray;


break;

case 9: mainColor = Color.yellow;


break;

case 10: mainColor = userDefinedColor;


break;
}
}

public void releasedPen()


{
initialPen = true;
}

public void releasedLine()


{
if ((Math.abs(Orx - mousex) + Math.abs(Ory - mousey)) != 0)
{
System.out.println("Line has been released....");
initialLine = true;
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
g.drawLine(Orx,Ory,mousex,mousey);
}
}

public void releasedEraser()


{
initialEraser = true;
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor.white);
g.drawRect(mousex-eraserLength,mousey-eraserLength,eraserLength*2,eraserLength*2);

26
Paint brush

public void releasedRect()


{
initialRect = true;
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
g.drawRect(drawX,drawY,OrWidth,OrHeight);
}

public void releasedOval()


{
initialOval = true;
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
g.drawOval(drawX,drawY,OrWidth,OrHeight);
}

public void releasedFRect()


{
initialFRect = true;
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
g.fillRect(drawX,drawY,OrWidth,OrHeight);
}

public void releasedFOval()


{
initialFOval = true;
Graphics g = drawPanel.getGraphics();
g.setColor(mainColor);
g.fillOval(drawX - 1,drawY - 1,OrWidth + 2,OrHeight + 2);
}
public void releasedBrush()
{
initialBrush = true;

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 (e.getX() < 0) xCoor = "0";


else
{
xCoor = String.valueOf(e.getX());
}

if (e.getY() < 0) xCoor = "0";


else
{
yCoor = String.valueOf(e.getY());
}
mouseStatusBar.setText("x:" + xCoor + " y:" + yCoor);
}

public void updateRGBValues()


{
udefRedValue = redSlider.getValue();
udefGreenValue = greenSlider.getValue();
udefBlueValue = blueSlider.getValue();
if (udefRedValue > 255)
udefRedValue = 255;

if (udefRedValue < 0 )
udefRedValue =0;

if (udefGreenValue > 255)


udefGreenValue = 255;

28
Paint brush

if (udefGreenValue < 0 )
udefGreenValue =0;

if (udefBlueValue > 255)


udefBlueValue = 255;

if (udefBlueValue < 0 )
udefBlueValue =0;

redValue.setText(String.valueOf(udefRedValue));
greenValue.setText(String.valueOf(udefGreenValue));
blueValue.setText(String.valueOf(udefBlueValue));

userDefinedColor = new Color(udefRedValue,udefGreenValue,udefBlueValue);


userDefButton.setBackground(userDefinedColor);

Graphics g = udefdemcolPanel.getGraphics();
g.setColor(userDefinedColor);
g.fillRect(0,0,800,800);
}

public void mouseClicked(MouseEvent e)


{
updateMouseCoordinates(e);
switch (opStatus)
{

case 10 : BrushOperation(e);
break;
}
}

public void mouseExited(MouseEvent e)


{
updateMouseCoordinates(e);
}

public void mouseMoved(MouseEvent e)

29
Paint brush

{
updateMouseCoordinates(e);
}

public void mousePressed(MouseEvent e)


{
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 :-

Output of Filled rectangle :-

Output of filled 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 TestingTesting 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.

Functional TestingTesting using a high-level, building-block approach. Taking features


that have been tested independently, assembling them into small applications, and
confirming that they work together.

Stress TestingContinually 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

Run to Failure Maintenance (RTF)


Preventive Maintenance (PM)
Corrective Maintenance (CM)
Improvement Maintenance (IM)
Predictive Maintenance (PDM)

Run to Failure Maintenance (RTF)

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.

It is subdivided into two types:

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.

Breakdown maintenance: it is performed after the occurrence of an advanced considered failure


for which advanced provision has been made in the form of repair method, spares, materials,
labour and equipment.

Preventive Maintenance (PM)

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.

Corrective Maintenance (CM)

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.

This type of maintenance is subdivided into three types:-

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.

Shutdown corrective maintenance, which is a set of corrective maintenance activities that


are performed when the production line is in total stoppage situation.

Improvement Maintenance (IM)

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.

2. Engineering services which includes construction and construction modification,


removal and installation, and rearrangement of facilities.

3. Shutdown improvement maintenance, which is a set of improvement maintenance


activities that are performed while the production line is in a complete stoppage situation.

Predictive Maintenance (PDM)

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:

Condition-based predictive maintenance

Statistical-based predictive maintenance

37
Paint brush

Condition-based predictive maintenance depends on continuous or periodic condition


monitoring equipment to detect the signs of failure.

Statistical-based predictive maintenance depends on statistical data from the meticulous


recording of the stoppages of the in-plant items and components in order to develop models for
predicting failures.

38
Paint brush

Future scope of the Project :-

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 :-

1) Sumita Arora,year of publication2006, Information Practise


2) Ebalagurusamy, year of publication 2010, Programming with Java (The MC Graw
Hill Companies.)
3) S.Chand, year of publication 20012, Programming in Java
4) Balagurusamy, year of publication 2009, Programming With java A Primer 4e

40