JAVA CBP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

A Course Based Project Report on Submitted to the

DRAWING APPLICATION IN JAVA


Department of CSE- (CYS, DS) AND AI&DS

in partial fulfilment of the requirements for the completion of course


OBJECT ORIENTED PROGRAMMING THROUGH JAVA
LABORATORY(22PC2IT201)

BACHELOR OF TECHNOLOGY

IN

COMPUTER SCIENCE AND ENGINEERING DATA SCIENCE

Submitted by

PENJARLA HASINI (22071A6743)


PUVVALA BHANU SATISH (22071A6749)
SABAVATH SRI RAM (22071A6751)
VADLURI SANJANA (22071A6760)
VOORE SIRI (22071A6764)

Under the guidance of


MRS. G. ASHA LATHA
(Course Instructor)
Assistant professor Dept. of CSE- (CYS, DS) AND AI&DS

Department of CSE- (CYS, DS) AND AI&DS

VALLURUPALLI NAGESWARA RAO VIGNANA


JYOTHI INSTITUTE OF ENGINEERING &
TECHNOLOGY
An Autonomous Institute, NAAC Accredited with ‘A++’ Grade, NBA
Vignana Jyothi Nagar, Pragathi Nagar, Nizampet (S.O), Hyderabad – 500 090, TS,
India
JANUARY 2024
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous Institute, NAAC Accredited with ‘A++’ Grade, NBA Accredited for CE, EEE, ME,
ECE, CSE, EIE, IT B. Tech Courses, Approved by AICTE, New Delhi, Affiliated to JNTUH,
Recognized as “College with Potential for Excellence” by UGC, ISO 9001:2015 Certified, QS I
GUAGE Diamond Rated
Vignana Jyothi Nagar, Pragathi Nagar, Nizampet(SO), Hyderabad-500090, TS, India

Department of CSE- (CYS, DS) AND AI&DS

CERTIFICATE

This is to certify that the project report entitled “DRAWING APPLICATION IN


JAVA” is a bonafide work done under our supervision and is being submitted by
P.Hasini (22071A6743) , P.Bhanu Satish(22071A6749), S.Sri Ram
(22071A6751),V.Sanjana(22071A6760),V.Siri(22071A6764) in partial fulfilment
for the award of the degree of Bachelor of Technology in COMPUTER SCIENCE
AND ENGINEERING DATA SCIENCE, of the VNRVJIET, Hyderabad during the
academic year 2023-2024.

Course Instructor Name Head of the Department


Mrs. Ashalatha.G Dr. M. Raja Sekhar
Assistant professor Professor & HOD
Department of CSE-CYS, DS, AI&DS Department of CSE-CYS, DS,AI&DS

VNR VJIET VNR VJIET

Course based Projects Reviewer

VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI


INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous Institute, NAAC Accredited with ‘A++’ Grade,
Vignana Jyothi Nagar, Pragathi Nagar, Nizampet(SO), Hyderabad-500090, TS, India
Department of CSE- (CYS, DS) AND AI&DS

DECLARATION

We declare that the course based project work entitled “Supermarket Mnagement
System” submitted in the Department of Information Technology, Vallurupalli
Nageswara Rao Vignana Jyothi Institute of Engineering and Technology, Hyderabad,
in partial fulfilment of the requirement for the award of the degree of Bachelor of
Technology in COMPUTER SCIENCE AND ENGINEERING DATA SCIENCE is a bonafide
record of our own work carried out under the supervision of MRS. Ashalatha.G,
Assistant Professor, Dept. of CSE- (CYS, DS) AND AI&DS, VNRVJIET. Also,
we declare that the matter embodied in this thesis has not been submitted by us in full
or in any part thereof for the award of any degree/diploma of any other institution or
university previously.
Place: Hyderabad.

P.Hasini Reddy P.Bhanu Satish S.Sri Ram

(22071A6743) (22071A6749) (22071A6751)

V.Sanjana V.Siri

(22071A6760) (22071A6764)
ACKNOWLEDGEMENT

We express our deep sense of gratitude to our beloved President, Sri. D. Suresh Babu,
VNR Vignana Jyothi Institute of Engineering & Technology for the valuable guidance
and for permitting us to carry out this project.

With immense pleasure, we record our deep sense of gratitude to our beloved Principal,
Dr. C.D Naidu, for permitting us to carry out this project.

We express our deep sense of gratitude to our beloved Professor Dr. M. RAJA
SEKHAR, Associate Professor and Head, Dept. of CSE- (CYS, DS) AND AI&DS,
VNR Vignana Jyothi Institute of Engineering & Technology, Hyderabad-500090 for
the valuable guidance and suggestions, keen interest and through encouragement
extended throughout the period of project work.

We take immense pleasure to express our deep sense of gratitude to our beloved Guide,
MRS. Ashalatha.G, Assistant Professor, Dept. of CSE- (CYS, DS) AND AI&DS,
VNRVJIET her valuable suggestions and rare insights, for constant source of
encouragement and inspiration throughout my project work.

We express our thanks to all those who contributed for the successful completion of
our project work.

P.HASINI (22071A6743)
P.BHANU SATISH (22071A6749)
S.SRI RAM (22071A6751)
V.SANJANA (22071A6760)
V.SIRI (22071A6764)
ABSTRACT

The Java Drawing Application is an innovative software solution designed to empower

users with a robust and user-friendly platform for digital art creation. Leveraging the

flexibility and versatility of the Java programming language, this application provides a

dynamic canvas equipped with an array of drawing tools, including pencils, brushes, shapes,

and text. The intuitive user interface incorporates features like customizable brush settings,

layer management, and undo/redo functionality, ensuring a seamless and enjoyable drawing

experience. With support for various file formats and project files, users can save and revisit

their creations, preserving both the final composition and the individual elements for future

modifications. The application's cross-platform compatibility makes it accessible to a broad

audience, allowing artists and designers to unleash their creativity on different operating

systems.

This drawing application stands out for its emphasis on a layered approach to drawing,

enabling users to organize and manipulate elements within their artwork efficiently. The

color palette, zoom and pan features, and the ability to create custom swatches further

enhance the user's control and expression. Whether used by professionals for intricate

illustrations or by hobbyists for casual sketching, the Java Drawing Application provides a

comprehensive suite of tools that caters to a wide range of digital art creation needs.

1
TABLE OF CONTENTS

1.Introduction 3

2.Source Code 4-21

3.Outputs 22-23

4.Conclusion 24

2
INTRODUCTION

1.PROBLEM STATEMENT

Java-based drawing application enabling users to draw shapes, lines, text, and modify them
with different colors and brush sizes. Include features for saving, loading, and exporting
drawings in multiple formats. Incorporate basic editing options like undo, redo, copy, paste,
and resizing elements. Consider advanced features such as layers for better organization and
cater to users of varying skill levels.

2.OBJECTIVE

The primary objectives of developing a drawing application in a Java project encompass


providing a user-friendly and intuitive interface for creative expression while incorporating
essential features for a seamless drawing experience. The application should enable users
to easily create, edit, and save drawings through a variety of tools such as pencils, brushes,
shapes, and colors. The user interface should be designed to facilitate smooth navigation
and efficient utilization of drawing tools, catering to both novice and advanced users.

Additionally, the application should implement robust functionalities, including undo and
redo options, layer management, and the ability to import/export images. Integration of
advanced features like pressure sensitivity for digital drawing tablets, customizable
brushes, and real-time collaboration could enhance the application's appeal. Moreover, the
project should prioritize scalability, ensuring that the application can accommodate future
updates and additional features.

Furthermore, the development process should adhere to best practices in software


engineering, emphasizing modularity, maintainability, and code efficiency. Testing should
be comprehensive to identify and address any potential bugs or issues, ensuring a stable
and reliable drawing application. Overall, the project aims to deliver a feature-rich, user-
centric drawing application that combines creativity with functionality, providing an
enjoyable and productive experience for users of varying skill levels.

3
SOURCE CODE

Main.java

public class Main {


public static void main(String[] args) {
Canvas canvas = new Canvas();
canvas.CanvasView();
}
}

Canvas.java

package sanjana;

import java.awt.AWTException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Canvas implements MouseMotionListener{


JFrame frame = new JFrame();
JPanel canvasPanel, toolBar;
JButton btn;
JTextField col, sz;
String prev, back;

Canvas() {
canvasPanel = new JPanel();
canvasPanel.addMouseMotionListener(this);
}

4
public void CanvasView() {

//-----------CANVAS-------------
canvasPanel.setBounds(320, 30, 850, 600);
canvasPanel.setBackground(Color.white);
canvasPanel.setLayout(null);
frame.add(canvasPanel);
canvasPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
String cl = col.getText();
int rad = Integer.parseInt(sz.getText());
Graphics grap = canvasPanel.getGraphics();
grap.setColor(Color.decode(cl));
grap.fillRect(e.getX(), e.getY(), rad, rad);
}
});
//-----------------------------

//-----------TOOLBAR-------------
toolBar = new JPanel();
toolBar.setBounds(30, 30, 250, 600);
toolBar.setBackground(Color.white);
toolBar.setLayout(null);
frame.add(toolBar);
addButton(32, 30, "#000000");
addButton(105, 30, "#FFFFFF");
addButton(177, 30, "#808080");
addButton(32, 90, "#FF0000");
addButton(105, 90, "#00FF00");
addButton(177, 90, "#0000FF");
addButton(32, 150, "#FFFF00");
addButton(105, 150, "#FFA500");
addButton(177, 150, "#A020F0");
addButton(32, 210, "#FFC0CB");
addButton(105, 210, "#964B00");
addButton(177, 210, "#C32148");
//-----------------------------

//---------CUSTOM---------------
JLabel cllabel = new JLabel("Custom Colors : ");
cllabel.setBounds(30, 260, 100, 50);
toolBar.add(cllabel);
col = new JTextField();
col.setBounds(30, 310, 190, 30);
col.setText("#000000");
toolBar.add(col);
//------------------------------

//-----------BACKGROUNDCOLOUR-------------
back = "#FFFFFF";
JButton bc = new JButton("SET BACKGROUND");
5
bc.setBounds(30, 350, 190, 30);
toolBar.add(bc);
bc.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
back = col.getText();
canvasPanel.setBackground(Color.decode(back));
}
});
//---------------------------------

//---------SIZE------------------
JLabel szlabel = new JLabel("Size : ");
szlabel.setBounds(30, 380, 100, 50);
toolBar.add(szlabel);
JButton sub = new JButton("-");
sub.setBounds(30, 415, 50, 30);
toolBar.add(sub);
sz = new JTextField();
sz.setBounds(100, 415, 50, 30);
sz.setText("5");
toolBar.add(sz);
JButton add = new JButton("+");
add.setBounds(170, 415, 50, 30);
toolBar.add(add);
sub.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
sz.setText(Integer.parseInt(sz.getText())-1+"");
}
});
add.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
sz.setText(Integer.parseInt(sz.getText())+1+"");
}
});
//-------------------------------

//---------PAINT&ERASE-----------------
JButton brush = new JButton("BRUSH");
brush.setBounds(30, 465, 80, 30);
toolBar.add(brush);
JButton erase = new JButton("ERASE");
erase.setBounds(140, 465, 80, 30);
toolBar.add(erase);
prev = "#000000";
brush.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
col.setText(prev);
}
6
});
erase.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(!col.getText().equals(back))
prev = col.getText();
col.setText(back);
}
});
//--------------------------------

//-----------CLEAN--------------
JButton clean = new JButton("CLEAN");
clean.setBounds(30, 515, 190, 30);
toolBar.add(clean);
clean.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
canvasPanel.removeAll();
canvasPanel.repaint();
}
});
//-------------------------------

//-----------SAVE---------------
JButton save = new JButton("SAVE");
save.setBounds(30, 555, 190, 30);
toolBar.add(save);
save.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String tm = java.time.LocalTime.now()+"";
tm = tm.substring(0, 2) + tm.substring(3, 5) + tm.substring(6,
8) + tm.substring(9, 12) + ".png";
try {
BufferedImage image = getImg(canvasPanel);
ImageIO.write(image, "png", new File(tm));
}
catch(Exception ex) {

}
}
});
//-------------------------------

//------FRAME------------------
frame.setSize(1250, 700);
frame.setLocationRelativeTo(null);
frame.setLayout(null);
frame.getContentPane().setBackground(Color.decode("#001122"));
frame.setVisible(true);
frame.setResizable(false);
7
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//---------------------------------
}
//---------MOUSE FUNCTIONS---------------------
@Override
public void mouseDragged(MouseEvent e) {
String cl = col.getText();
int rad = Integer.parseInt(sz.getText());
Graphics grap = canvasPanel.getGraphics();
grap.setColor(Color.decode(cl));
grap.fillRect(e.getX(), e.getY(), rad, rad);
}

@Override
public void mouseMoved(MouseEvent e) {

}
//-------------------------------------------------

//---------FUNCTIONS TO CREATE SIMILAR BUTTONS---------


public void addButton(int x, int y, String clr) {
this.btn = new JButton();
btn.setBounds(x, y, 40, 40);
btn.setBackground(Color.decode(clr));
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
col.setText(clr);
}
});
toolBar.add(btn);
}
//-------------------------------------------------------

//----------FUNCTION TO CREATE IMAGE TO SAVE-----------------------------


public BufferedImage getImg(Component comp) throws AWTException {
Point p = comp.getLocationOnScreen();
Dimension dim = comp.getSize();
BufferedImage capture = new Robot().createScreenCapture(new Rectangle(p,
dim));
return capture;
}
//--------------------------------------------------------------------------
}

8
Proposed System Outputs

9
CONCLUSION

In conclusion, the Java-based drawing application project embodies a robust and user-

friendly platform that seamlessly integrates creative expression with technological

innovation. The project's success lies in its adept utilization of Java's versatile

features, providing a responsive and intuitive environment for users to unleash their

artistic potential. The implementation of object-oriented programming principles has

facilitated the creation of a modular and scalable system, allowing for easy addition of

new features and enhancements in the future.

Furthermore, the project's emphasis on user experience is evident through its well-

designed graphical interface, offering a wide array of drawing tools, color palettes,

and customization options. The utilization of Java's Swing framework ensures

platform independence, allowing users to enjoy the drawing application on various

operating systems seamlessly. The incorporation of event-driven programming

enhances the responsiveness of the application, ensuring a smooth and interactive

drawing experience.

In essence, the Java drawing application project not only showcases the technical

prowess of Java but also demonstrates the fusion of creativity and technology. It

stands as a testament to the potential of Java in crafting sophisticated and engaging

applications, making it a valuable tool for both developers and users alike.

10

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy