Top Banner
Project Report On IMAGE EDITOR As Partial Fulfillment of Award of Bachelor of Engineering in Computer Engineering Prepared by: 100010107017 : Arpit Shroff 100010107055 : Ishan Desai Guided by: Ms. Soniya M. Hingu A. D. Patel Institute of Technology Vallabh Vidyanagar Gujarat Technological University (December - 2013)
82
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Project Report

Project Report

On

IMAGE EDITOR

As

Partial Fulfillment of Award of

Bachelor of Engineering in

Computer Engineering

Prepared by:

100010107017 : Arpit Shroff

100010107055 : Ishan Desai

Guided by:

Ms. Soniya M. Hingu

A. D. Patel Institute of Technology

Vallabh Vidyanagar

Gujarat Technological University

(December - 2013)

Page 2: Project Report

Image Editor Page ii

A. D. Patel Institute of Technology

Department of Electrical Engineering

CERTIFICATE

This is to that Arpit Shrof (100010107017) and Ishan Desai ((100010107055) of

final year Computer Engineering have satisfactory completed their project work

entitled “Image Editor” in the academic year 2013-14 for the partial fulfillment of

the award of the Bachelor of Engineering in Computer Engineering at Gujarat

Technological University, Gujarat, India.

Date:

Project Guide Head of the Department

Ms. Soniya M. Hingu Dr. Ramji M. Makwana

Page 3: Project Report

Image Editor Page iii

ACKNOWLEDGEMENT

It is indeed a great pleasure to express our sincere thanks and gratitude to all those who helped us

during the development of this project. The success we have got in the accomplishment of the

project work is not only due to our efforts. In fact, we stand on the shoulders of many people. So,

with a great pleasure we would like to take this opportunity to express our gratitude towards all

the individuals who have helped and inspired us in our project work.

Our project at A. D. Patel Institute of Technology – New VallabhVidhyanagar has been the

perfect stepping stone into the world of professionals. We acknowledge with deep sense of

gratitude, the guidance and support received from Prof. Soniya Hingu (Project Guide) and

Prof. Bhagirath Prajapati who approved our project, had faith in it and also for his critical

evaluation and suggestion regarding the project at every step. We are also thankful to all the

faculty of our department for helping us directly or indirectly in our project. We are also grateful

to have the valuable assistance of our lab assistants for constantly providing us all the tools and

software necessary for our project to be implemented whenever needed.

Although there may be many who remain unacknowledged in this humble note of gratitude,

there are none who remain unappreciated.

Arpit Shroff(100010107017)

Ishan Desai(100010107055)

Page 4: Project Report

Image Editor Page iv

TABLE OF CONTENTS

Chapter 1 2

1.1 Purpose 2

1.2 Objective 2

1.3 Resources at hand 3

1.4 Project Definition 3

1.5 Scope of the project 4

1.6 Technical Feasibility 5

1.7 Time and Operational Feasibility 6

1.8 Economic Feasibility 6

1.9 Some Preplanned Features 7

1.10 Project Plan 8

1.11 Build up to the project 9

Chapter 2 12

2.1. Introduction to Java 12

2.2. Features of Java: 13

2.3. Advantages of Java: 13

2.4. JAVA PROGRAM EXECUTION PROCESS 14

2.5. API(Application Programming Interface): 15

2.6. ACCESS Modifiers & Variables: 16

2.7. JFC(Java Foundation Class): 18

2.8. The AWT (Abstract Windows Toolkit): 21

2.9. The SWING: 21

2.10. NetBeans 24

Chapter 3 29

3.1 An Overview of UML: 29

3.2 Low level diagram of the Application 30

3.3 Class Diagram Of the Application 31

3.4 Use case Diagram for the Application 35

3.5 Activity Diagram 40

3.6 Screen Layouts 42

Page 5: Project Report

Image Editor Page v

Chapter 4 47

4.1 Classes Used. 47

4.2 Some General Algorithms and Their Implementation 51 4.2.1 Algorithm for Opening a Document:- 51

4.2.2. Algorithm for saving a document 54

4.2.3 Algorithm For General Annotations 57

4.2.4 Algorithm for Database Connection: 57

4.2.5 Algorithm for Adding the Records: 58

4.2.6 Algorithm for Viewing Records: 59

4.2.7 Algorithm for Brightness: 60

4.2.8 Algorithm for Grayscale: 61

4.2.9 Algorithm for Redeye View: 61

4.2.10 Algorithm for Invert: 62

4.2.11 Algorithm for Rotate 63

Chapter 5 66

5.1 Testing 66

5.2 Testing And Debugging 67

Chapter 6 71

6.1 USER MANUAL 71

Chapter 7 75

7.1 Future Enhancement 75

Conclusion 76

References and Bibliography

767

Page 6: Project Report

Image Editor Page 1

Chapter 1

INTRODUCTION

Page 7: Project Report

Image Editor Page 2

Chapter 1

INTRODUCTION

1.1 Purpose

This document describes the external behavior of the application. It also describes non-functional

requirements, design constraints and other factors necessary to provide a complete and comprehensive

description of the requirements for the software. The intended behavior of the system is clearly

explained so that the communication gaps do not lead to misinterpretations of actual requirements.

The requirements specified in this document are to be translated without any further assumptions from

the analysts or developers side to consequently lead to the system with desired functionalities.

1.2 Objective

In computer graphics, graphics software or image editing software is a program or collection of

programs that enable a person to open, save and edit an image. The basic editing features generally

Includes crop, effects, resizing, adding frames and many more.

The aim of this project is to create a software application which can be used for the processing of

various images (all generally used formats). The application should be able to support and open all

possible files which can possibly be supported, and also process the same. Viewing of this processed

and the original images should be facilitated.

Our application provides an editor to the user for viewing and performing simple manipulations on

images.

It also provides some basic manipulations like inverting the pixels in an image; transforming an

image; zooming in and out for detailed view; rotating and image; swapping the RGB components;

performing fast fourier transforms for a sharper and more accurate image and to fit the image to the

window size.

Page 8: Project Report

Image Editor Page 3

Our aim would be to create an application of the likes of Picasa or Instagram or Adobe Photoshop.

We’ll basically implement all the normal and simple functions available in such applications and

would try to merge the functions of all these well-established image editors into our application.

We will also establish a database most probably in MS ACCESS which will keep track of the images

being altered. The information that it would be holding includes the location of the image, Size of the

image, Type of the image, when the changes were made and stored i.e the Date and Time.

1.3 Resources at hand

A Laptop powered with Pentium-Core i5 processor was used for the development of the project.

The project had to be developed in either Java or C++, so after studying the requirements of the

project, a few discussions with the professionals and preliminary analysis it was concluded that it

should be developed in Java.

For this a Guide/Tutor was appointed who was to guide the team during the entire semester.

A mini-library for books and CD’s was made available so as to refer the contents whenever required.

Various online forums such as stackoverflow.com and many other were referred to develop the

project more efficiently.

1.4 Project Definition

The aim of this project is to create a software application which can be used for the processing of

various images (all generally used formats). The application should be able to support and open all

possible files which can possibly be supported, and also process the same. Viewing of this processed

and the original images should be facilitated.

Page 9: Project Report

Image Editor Page 4

Our application provides an editor to the user for viewing and performing simple manipulations on

images. It also provides some basic manipulations like inverting the pixels in an image; transforming

an image; zooming in and out for detailed view; rotating and image; swapping the RGB components;

performing fast fourier transforms for a sharper and more accurate image and to fit the image to the

window size.

The user interface is simple and appropriate. The GUI is simple and easy to understand. It has been

developed keeping in mind an average user.

The application developed is not an entirely new concept. It is inspired form different image editors

available in the market – an image viewer which supports various formats for viewing and editing

purposes.

This application is in a way better that it supports all the file formats that are supported by the jdk1.4.2

kit.

The application doesn’t modify the source document opened but it creates a new folder for each user

in which all the information of the image is stored and can be accessed using database with the help of

MS ACCESS.

As a part of look and feel, a few eye-soothing themes have also been added to the application.

1.5 Scope of the project

Scope of this project is to provide a basic image editor in a way which is able to perform annotations

on the images without modifying the original images in a layered form. The project has been dealt

with as a user-application so as to know each and every requirements of the user and trying to

complete each of those within the limited time span during the entire project. The DMS can be

developed on the basis of this application by attaching this application as a plug in module in the

system. The project can be extended to a variety of functionalities related to the document editing and

management.

Page 10: Project Report

Image Editor Page 5

This application can right now provide basic annotating facilities.

Goals: The sole aim of this project was to provide an application which is able to support images of

various formats available and annotate them as per the requirements and save them in a way so that

the original document opened can be modified/overwritten.

1.6 Technical Feasibility

The project is technically feasible in the sense that it uses Java as a tool to develop this project.

Taking the feasibility resource wise, actually the project was to be developed in either C++ or Java.

We know Java is a very powerful independent tool. To develop this application, which is basically

inspired form Kodak IMG Viewer Java was the choice because of a few factors. One of them is the

GUI (Graphical User Interface). Obviously the look and feel which is supported by Java was not

going to be the case with C++. Thus this was a major consideration.

Looking at the requirements another factor which highlights is the support for various electronic file

formats which Java does through its well-structured and well-defined sets of packages; and if C++ is

used, a code has to be written for each of the file formats to be supported thus making it a heavy task.

Thus Java had to be considered. Java APIs for various manipulations on images also add to the

flexibility to develop image-editing applications.

Another reason being the layer which is a stronghold of the project had to be implemented. And

adding to it, the different forms of annotations which were to be performed on this layer was to be

done. This could have been a mind-blowing job in C++, but Java makes it simpler as it has a set of

methods which can handle various events by just implementing them e.g. the mouse event handling

through co-ordinate manipulation which was a bit difficult in C++. Thus the ultimate choice was Java

seeing its vast use all over and its advanced image handling capabilities.

Page 11: Project Report

Image Editor Page 6

1.7 Time and Operational Feasibility

Time is one of the major considerations during the project development. The project loses its value

even if it is sound but not completed within its required time duration.

As far as this project is concerned, seeing the requirements the project definitely doesn’t seem to get

completed within the time duration allotted to us. But we have tried our best to implement what was

feasible within the time limit

The application operationally is very simple because it doesn’t have much complexity in its

menus/operations. All of the menus have simple and understandable functionality with most of the

functions available as a button on the toolbar. The application, as it is developed in Java, can be

considered platform independent and would require only runtime if the operating system platform

changes. And the design structure of the coding is very much tried to be made user-friendly so that if

the project is extended further it would be easy for a new comer. Various plug-in modules can also be

included e.g. for the support of a file format, by importing their corresponding packages from the

source.

1.8 Economic Feasibility

As the project is not live/ real-time, there is no need to mention this factor of concern but still we

would like to mention them. Economically also this project seems to be feasible in the sense that the

major requirement is Java which is available absolutely free of cost.

Adding further, if any further requirement arises for say format support APIs for a specific task they

are also made available on the net. Also third party APIs and plugging can contribute.

Company also sees this economically feasible because the project can be easily extended as the

primary platform, GUI is ready. Thus GUI designing and the basic facilities like that of paint are also

ready.

Page 12: Project Report

Image Editor Page 7

1.9 Some Preplanned Features

• File tab

This tab will generally consist of Opening, closing and saving the image. This tab may also consist

renaming and deleting the image from the program so that a new image can be opened along with

an Exit option.

• Edit tab

This tab will generally include the copy and paste functions along with undo and redo effects

options.

• Resize tab

This tab will generally deal with the resizing of image that is opened in the program. Such features

will include zooming the image to a particular percentage. Halving or doubling the image. It will

also include the option of fit to window. This resize tab will also include rotate left or right option.

• Simple Edits

Various features like crop, straighten, auto colour, contrast, text, auto brightness, saturation, hue.

• Slide Show Feature

We will also try to implement a slide show feature in our program. Our program will include a

previous and next option.

• Editing Themes

We can add various editing themes which are normally provided by various apps available such as

o Sharpen

o Sepia

o Black and white

o Exposure

o GreyScale

o Invert

Page 13: Project Report

Image Editor Page 8

• Pen tools

The Program will also consists of pen tools such that it will allow us to write what we desire and

erase what we desire. Such tools are mostly helpful for storing memories of a picture or signing a

picture.

We will also provide an Insert text dialog box so that we can add the desired text in a desired font.

1.10 Project Plan

List of major activities

The major activities during the entire project are as follows:

Study of Java and requirement analysis

GUI (Graphical User Interface) designing

Coding as per the requirements

Prototypes presented

Estimated time duration

The project as per the requirements was above the duration of the semester as the complete project

requires more than six month.

According to the requirements which were briefed to us, we had estimated that around 1-2 weeks

of studying the Development Tool would be sufficient.

Then the GUI designing was estimated around 1 or 1 ½ weeks for a complete user interface.

Page 14: Project Report

Image Editor Page 9

Then around 6 weeks of extensive coding was estimated to create a complete working model

which would provide annotations, and all basic image editing facilities and support for file formats

as many as possible.

The testing and debugging was estimated for 1 week. This part of project was estimated to be less

because the project was not to be used live but was to be developed / extended further as and when

possible.

The prototypes as and when became ready during the coding time were presented.

And of course documentation is not going to be a well estimated because it is going to be a

continuous work throughout the project, although a last 1 or 1½ weeks were dedicated to this part

of the project.

1.11 Build up to the project

Fact Finding

As the application is unique in itself, lot of exemplary documents and applications had to be studied.

A few of them will be described during this topic.

The study of the requirements of the application was done after a few meetings with the Head of our

project.

Meetings with the Faculties:

During the initial meetings with the head, the entire definition of the project was discussed at a stretch

in order to make the requirements’ study easier. Many references were pointed out by him whom had

to be studied which would sketch out a broad outline of the definition. Initially some of the Image

Viewer Soft wares were also used for reference as it was a probable feature of the project if the time

permitted. For this, it was necessary to know that what actually basically document management

means.

Page 15: Project Report

Image Editor Page 10

In order to get a taste of this a brief description of the Image Viewer and how it works will be

discussed below. The application was to be developed either in Java or C++. And ultimately seeing

the facilities provided Java it was decided to work in Java.

Discussion with the Project Guide:

The requirements were briefed before the guide and then we had some meetings for an elaborated

overview of the features which were must in the application. The first and the foremost task to be

carried out were to learn JAVA which has been used to develop this project.

The basic requirement was to implement the layered format of the annotated document. Each object to

be drawn was just like that of in Microsoft Paint but was not to be merged with the document and the

identification of each of them should be possible and that too according to the users.

Another important feature was the support of the electronic file formats. For this the guide gave a few

suggestions and a package in Java – image io which is widely used to support the commonly used

formats. Along with this the plugin packages are also available which can be imported to increase the

compatibility to support more file formats.

The requirements of the application were as follows:-

To provide flexible annotation support.

To implement the object drawing on the layer so as not to modify the source.

To provide identification of each object drawn.

To provide basic image editing facility such as zooming, blurring, sharpening, flipping the image

to left and right, etc...

To provide as many electronic file formats support as possible.

Page 16: Project Report

Image Editor Page 11

Chapter 2

INTRODUCTION TO

JAVA

Page 17: Project Report

Image Editor Page 12

Chapter 2

INTRODUCTION TO JAVA

2.1. Introduction to Java

Java has become a popular programming language today. As a part of introduction, some of its

important features will be highlighted in this section. As Java can be described completely here is an

overview of Java in relevance to the project.

Java is one of the first programming languages to consider security as a part of its design. Its compiler,

interpreter and runtime environment were developed in such a way so as to reduce the risk of loss of

data and program integrity and damage to system users.

The Java is designed in such a way so as to eliminate manual memory allocation and deallocation.

Memory in Java is automatically garbage collected. So never worry about the memory leaks!

Introduction of true array eliminated the pointer arithmetic. You never have to worry about

overwriting a key area of memory because of an off-by-one error when working with a pointer.

Elimination of multiple inheritances and replacing it with a new notion of Interface was another

distinguishing feature. Interfaces give what one wants from multiple inheritances, without the

complexities that come with managing multiple inheritance hierarchies.

It also offers same Application Programmer Interface (API) on all platforms.

The Java Language specification mandates several things that are normally left to the discretion of the

compiler writer. By requiring that operands which are evaluated strictly in a left to right order and

stipulating the size of all the primitive types ( int 32 bits, doubles 64 bits, etc…), Java offers not just

program portability but identical program behavior on different system. In other words, not only does

Page 18: Project Report

Image Editor Page 13

the program run everywhere, but it will get the same arithmetic results everywhere, despite of

different hardware models of arithmetic and overflow.

The class path is the path that the Java runtime environment searches for classes and other resource

files. Java uses the Unicode Character-set which is a 16-bit superset of ASCII. Unicode can represent

the symbols in most of the alphabets in the world.

2.2. Features of Java:

Java was designed to meet all the real world requirements with its key features as stated below,

Simple and Powerful

Object-oriented

Robust

Secure

Portable

Architecturally neutral

Interpreted and High Performance

Multithreaded

Dynamic and Distributed

2.3. Advantages of Java:

Platform independence:

One of the obvious advantage is a run-time library that hopes to provide platform independence;

same code can be used on windows 98, NT, Solaris, Unix, Macintosh etc…

Others include:

Object-orientation: Everything in Java except for a few basic types like numbers is an object thus

making it far easier to turn out bug-free code using Java than using C++.

Security, reliability, simplicity, standardization, rapid code generation, ease of documentation and

maintenance (when doc comments and the javadoc tool are used) has been the reason for its

increasing popularity.

Page 19: Project Report

Image Editor Page 14

2.4. JAVA PROGRAM EXECUTION PROCESS

Java source code compiles into portable byte-codes that require an interpreter to execute them. For

applets, this task is handled by the browser. For GUI and command-line applications, the Java

interpreter program is required to execute the application. A variety of applications can be built in Java

like applets, GUI applications, command-line applications, servlets, packages, embedded

applications,etc…

Component Diagram

Page 20: Project Report

Image Editor Page 15

The heart of Java is the Java Virtual Machine (JVM). It can be termed as a virtual computer residing

in the memory. The JVM enables the Java programs to be executed on a variety of platforms as

opposed to only the one platform for which the code is compiled. JVM is the very reason why Java is

portable. Java source code is compiled to the byte code level as compared to the bit code level. So

when the .java extension file is compiled using the compiler javac a new .class extension file is

generated which is actually byte code format of the corresponding java file. The size of an address in

the JVM is 32 bits so it can address up to 4G memory. There is a provision of a heap which is a

collection of memory from which the class instances are allocated.

The runtime environment keeps the track of references to each object on the heap and automatically

frees the memory occupied by objects which are no longer referenced.

The Java 2 SDK, Standard Edition, contains two implementations of the Java virtual machine (VM).

Java Hotspot Client VM

It is tuned for best performance when running applications in a client environment by reducing

application start-up time and memory footprint.

Java Hotspot Server VM

The Java Hotspot Server VM is designed for maximum program execution speed for applications

running in a server environment. The Java Hotspot Server VM is invoked by using the -server

command-line option when launching an application, as in java -server MyApp.

2.5. API(Application Programming Interface):

The Java Application Programming Interface API is a set of classes developed by Sun for use with the

Java language. It is designed to assist in developing one’s own classes, applications or the applets.

With these set of classes ready you can write an application in Java which is a few lines long and at

the same time easy to debug. The classes in API of Java are grouped into the Packages each of which

may have several classes and interfaces. Furthermore, each of these items may also have several

Page 21: Project Report

Image Editor Page 16

properties, such as fields and/or methods. Some of the major API’s include the Core API, which has

important packages like the applet, awt, data transfer, event, image, beans, math, net, sql, util, text and

the list goes on.

The other is the Standard Extension API (server API) which provides the capability of the server-side

programming.

Then is the Java 3D API which provides the capability to create three-dimensional graphics

applications as it consists of classes and interfaces that support the 3D objects and transformations.

Then are the Speech API, Telephony API, and Security API, Java Management API etc…

The Security API also provides application-level security by giving the cryptographic support which

can be obtained by having a separate add-on, the Java Cryptography Extension (JCE). And as we

know that as the technology advances more and more API’s and packages can be incorporated into it

to make Java feel richer in every way.

2.6. ACCESS Modifiers & Variables:

There are several keywords that control the visibility of a class and the members of a class. The table

below explains the access modifiers – private, protected, public and no modifier. There are plenty of

other keywords – static, final, abstract, native and so on; that affect other things about a member class.

Sometimes two keywords can also occur together, such as “static final”.

One can have only one access modifier though, if one leaves it off, then the default is “the field can be

accessed by anything in the same package”. In general, the fields should be given a more restricted

visibility that still makes it possible for them to work. Another important thing to be noted is that

making any fields public without any good reason destroys encapsulation.

Page 22: Project Report

Image Editor Page 17

Declaration Keyword

Private No

modifier

Protected Public

Same class Yes Yes Yes Yes

Same package subclass No Yes Yes Yes

Same package non-subclass No Yes Yes Yes

Different package subclass No No Yes Yes

Different package non-subclass No No No Yes

Private means that the members are not accessible outside the current class in which it is declared.

Making a constructor private prevents the class being instantiated. Making a method private means

that it can only be called from within the class.

No modifier means members are accessible in classes in the same package only. A class can be given

package access or public class.

Protected means members are accessible in the package and in subclasses of this class. Note that

protected is less protected than the default of package access.

Public means members are accessible anywhere the class is accessible. A class can be given package

access or public access. These keywords can also be used for the variables.

Variables are the locations in the memory that can hold values. Thus before assigning any value to a

variable, it must be declared.

Instance variables are used to define attributes or the state of a particular object. These are used to

store information needed by multiple methods in the objects.

Page 23: Project Report

Image Editor Page 18

Local variables are used inside blocks as counters or in methods as temporary variables. Once the

block or the method is executed, the variable ceases to exist. The local variables are used to store

information needed by a single method.

Class variables are global to a class and to all the instances of the class. They are used to communicate

between different objects.

Benefits of Java mainly include the rich set of packages that it provides and which come bundled with

the Java Development Kit (JDK) from Sun Microsystems. These prewritten objects make it easy to

run quickly because you do not need to develop the functionality they provide and the source code is

available for all.

2.7. JFC(Java Foundation Class):

It was very difficult to create a truly abstract system which would work on all the systems. So the

developers decided to build a different kind of system which would rely on fairly one common

component- a Container (a parent of Panel). Because a container is uniform for all systems, you can

paint and draw on one without encountering platform dependencies. So there came the JFC (Java

Foundation Classes). The JFC system is based on two primary things: first, the Container and Frame

components from AWT and second the JDK event model. JFC’s entire system is based on a design

concept called Model View Control, or MVC. The MVC system Separates the various portions of

each interface component into three separate components.

Each of these components has its own set of requirements and responsibilities.

Model: is responsible for knowing and maintaining the state of the component. eg.Buttons.

View: is responsible for all display aspects of the component. This primarily involves the paint ()

method, but also means that the view must know exactly what should be painted. eg. Rollover over

the icon.

Page 24: Project Report

Image Editor Page 19

Control: manages the actual events that are received by the component. These events can be either

from the user (mouse-click) or from the system (timer event). The control must figure out what to do

with this event and inform the model, view and other appropriate listeners.

Because the communication between the view and the control is very complicated, for the most part

JFC has combined them into a single component called a delegate resulting into a delegation-event

model as shown in fig. below.

The approach of handling the events is based on the following concept: a source generates an event

and sends it to one or more listeners. And the listener waits until it receives the event. Once received,

the listener processes the event and then returns.

The advantage of this design is that the application logic that processes events is clearly separated

form the user interface logic that generates those events. Thus a user interface is able to “delegate” the

processing of an event to a separate piece of code. Here the listeners must register with a source in

order to receive an event notification. This provides a benefit that the notifications are sent only to

listeners that want to receive them. Here are some important terms defined:

Events: It is an object that describes a state change in a source. It is generally generated as a result of

user interacting with any of the elements of the GUI (Graphical User Interface).

Page 25: Project Report

Image Editor Page 20

Source: It is an object that generates an event. This occurs when the internal state of that object

changes in some way.

Event Listeners: It is an object that is notified when an event occurs provided i) the event is registered

with one or more sources to receive notifications about specific types of events ii) it must implement

methods to receive and process these notifications. The methods that receive and process events are

defined in a set of interfaces found in java.awt.event.

Event Classes: These represent the events that are at the core of Java’s event handling mechanism.

The main event classes in the package for event handling are Action Event, Adjustment Event,

Component Event, Container Event, Focus Event, Input Event, and Item Event.

In the age where individuals around the world are globally connected via internet, programs are often

required to be tailorable to the language and customs of the locales in which they execute. So when

you execute the code in a different country or so, you need to maintain multiple copies of the program

according to the locale. On the other hand, if you carefully isolate the local-specific resources and

maintain them separately from locale-independent code, global programs can be developed with a

minimum effort. Java supports this very concept known as the Internationalization. It is the process of

designing and developing global programs in such a way that locale-specific information is separately

and efficiently maintained. The JDK supports it by using a multi-language character set (Unicode 2.0).

JAR Features: Jar stands for Java ARchive. It's a file format based on the popular ZIP file format and

is used for aggregating many files into one. Although Jar can be used as a general archiving tool, the

primary motivation for its development was so that Java applets and their requisite components (.class

files, images and sounds) can be downloaded to a browser in a single HTTP transaction, rather than

opening a new connection for each piece. This greatly improves the speed with which an applet can be

loaded onto a web page and begin functioning. The Jar format also supports compression, which

reduces the size of the file and improves download time still further. Additionally, individual entries in

a Jar file may be digitally signed by the applet author to authenticate their origin.

Page 26: Project Report

Image Editor Page 21

2.8. The AWT (Abstract Windows Toolkit):

Next is a very important package of java, the AWT (Abstract Windows Toolkit). It contains numerous

classes and methods that allow you to create and manage windows. Although the main purpose of the

AWT is to support applet windows, it can also be used to create stand-alone windows that run in a

GUI environment, such as Windows.

With relevance to the project an important class which deals with the images needs a bit of

description. The Image class of java.awt.image package provides the support for imaging. Images are

objects of the IMAGE class, which is a part of the above mentioned package which supports the

commonly used formats of images like the GIF, BMP, JPEG, PNG.

The Java Image I/O API, provides a pluggable architecture for working with images stored in files and

accessed across the network. It offers substantially more flexibility and power than the current APIs

for loading and saving images.

The API provides a framework for the addition of format-specific plug-ins. Plug-ins for several

common formats are included with Java Image I/O, but third parties can use this API to create their

own plug-in to handle special formats.

2.9. The SWING:

Same as the AWT is the SWING. It is one of the key APIs of the Java Foundation Classes (JFC).

Swing is basically used to develop the GUIs for applications and applets. Swing also provides the

capability to quickly change the look &feel of a single component or a group of components which is

also known as the pluggable look & feel. Although Swing is separate from the AWT, it is

implemented in terms of basic AWT classes.

The AWT provides the interface between the underlying native windowing system and the Java GUI

components. Swing uses this interface, but does not rely on AWT components that make use of the

basic windowing objects because the Swing components are written in pure Java.

Page 27: Project Report

Image Editor Page 22

This provides significant advantages. It allows Swing components to be independent of the native

windowing system, and allows them to be independent of any limitations of the native windowing

system. This independence allows Swing to control and tailor its look and feel- hence the emergence

of PL&F. Swing has its development on the MVC (model, view, and controller) architecture.

MVC based structure allows swing components to be replaced with different data models and views.

The PL&F is a result of that.

Swing also provides a pure Java implementation of many traditional AWT components which have

the same functionality as the AWT components and all of the advantages of Swing. Swing is

compatible with the AWT, and Swing components can be interchangeably used with AWT

components.

Because Swing provides GUI components that are analogous to AWT components, it is easy to

convert applications and applets to Swing. Applications are converted to Swing by replacing the

Frame class with JFrame class and using getContentPane () to access the frame’s container. In fact,

most of the AWT components can be converted to Swing GUI components by simply preceding the

AWT class name by ‘J’.

Swing consists of 9 main packages, and hundreds of classes and interfaces. Here is a view of a

complete Swing Components hierarchy.

JComponent

AbstractButton

JButton

JMenuItem

JCheckBoxMenuItem

JMenu

JRadioButtonMenuItem

JToggleButton

JCheckBox

JRadioButton

JComboBox

Page 28: Project Report

Image Editor Page 23

JInternalFrame

JLabel

DefaultTableCellRenderer (java.awt.swing.table)

JLayeredPane

JDesktopPane

JList

JMenuBar

JOptionPane

JPanel

ColorChooserPanel

JPopupMenu

JProgressBar

JRootPane

JScrollBar

JScrollPane

JSeperator

JSlider

JSplitPane

JTabbedPane

JTable

JTextComponent

JEditorPane

JTextPane

JTextArea

JTextField

JPasswordField

JToolBar

JToolTip

This project is basically a GUI based application which uses all the necessary components of Java

Swing.

Page 29: Project Report

Image Editor Page 24

By default, the appearance of Swing programs is set to the Java Metal look, a cross-platform that Sun

has designed. But it can be changed using the UIManager class which is available in the

javax.swing.UIManager package.

2.10. NetBeans

NetBeans is an integrated development environment (IDE) for developing primarily with Java, but

also with other languages, in particular PHP, C/C++, and HTML5. It is also an application

platform framework for Java desktop applications and others.

The NetBeans IDE is written in Java and can run on Windows, OS X, Linux, Solaris and other

platforms supporting a compatible JVM.

The NetBeans Platform allows applications to be developed from a set of modular software

components called modules. Applications based on the NetBeans Platform (including the NetBeans

IDE itself) can be extended by third party developers.

The NetBeans Team actively support the product and seek feature suggestions from the wider

community. Every release is preceded by a time for Community testing and feedback.

Page 30: Project Report

Image Editor Page 25

Netbeans Platform

Framework for simplifying the development of Java Swing desktop applications. The NetBeans

IDE bundle for Java SE contains what is needed to start developing NetBeans plugins and

NetBeans Platform based applications; no additional SDK is required.

Applications can install modules dynamically. Any application can include the Update Center

module to allow users of the application to download digitally signed upgrades and new features

directly into the running application. Reinstalling an upgrade or a new release does not force

users to download the entire application again.

NetBeans IDE is a free, open-source, cross-platform IDE with built-in-support for Java

Programming Language.

The platform offers reusable services common to desktop applications, allowing developers to

focus on the logic specific to their application. Among the features of the platform are:

User interface management (e.g. menus and toolbars)

User settings management

Storage management (saving and loading any kind of data)

Window management

Wizard framework (supports step-by-step dialogs)

NetBeans Visual Library

Integrated development tools

Netbeans Integrated Modules

The Following modules are part of the NetBeans IDE.

NetBeans Profiler

The NetBeans Profiler is a tool for the monitoring of Java applications: It helps developers

find memory leaks and optimize speed. Formerly downloaded separately, it is integrated into the

core IDE since version 6.0.

Page 31: Project Report

Image Editor Page 26

The Profiler is based on a Sun Laboratories research project that was named JFluid. That

research uncovered specific techniques that can be used to lower the overhead of profiling a Java

application. One of those techniques is dynamic bytecode instrumentation, which is particularly

useful for profiling large Java applications. Using dynamic bytecode instrumentation and

additional algorithms, the NetBeans Profiler is able to obtain runtime information on applications

that are too large or complex for other profilers. NetBeans also support Profiling Points that let

you profile precise points of execution and measure execution time.

GUI design tool

Formerly known as project Matisse, the GUI design-tool enables developers to prototype and

design Swing GUIs by dragging and positioning GUI components.

The GUI builder has built-in support for JSR 295 (Beans Binding technology), but the support

for JSR 296 (Swing Application Framework) was removed in 7.1.

Page 32: Project Report

Image Editor Page 27

NetBeans JavaScript editor

The NetBeans JavaScript editor provides extended support for JavaScript, Ajax, and CSS.

JavaScript editor features comprise syntax highlighting, refactoring, code completion for native

objects and functions, generation of JavaScript class skeletons, generation

of Ajax callbacks from a template; and automatic browser compatibility checks.

CSS editor features comprise code completion for styles names, quick navigation through the

navigator panel, displaying the CSS rule declaration in a List View and file structure in a Tree

View, sorting the outline view by name, type or declaration order (List & Tree), creating rule

declarations (Tree only), refactoring a part of a rule name (Tree only).

Page 33: Project Report

Image Editor Page 28

Chapter 3

SYSTEM DESIGN

Page 34: Project Report

Image Editor Page 29

Chapter 3

SYSTEM DESIGN

3.1 An Overview of UML:

The UML is a language for,

• Visualizing

• Specifying

• Constructing

• Documenting

These are the artifacts of a software-intensive system.

The embedded real-time software systems encountered in applications such as telecommunications,

school systems, aerospace, and defense typically tends to be large and extremely complex. It is crucial

in such systems that the software is designed with a sound architecture. A good architecture not only

simplifies construction of the initial system, but also, readily accommodates changes forced by a

steady stream of new requirements

Visual modeling is a way of thinking about problems using models organized around real world ideas.

Models are useful for understanding problems, communication with everyone involved with the

project, modeling enterprises, preparing documentation and designing programs and database.

Modeling promotes better understanding of requirements, cleaner designs and more maintainable

systems.

Models are abstractions that portraits the essentials of complex problem or structure by filtering out

nonessential details, thus making the problem easier to understand.

Page 35: Project Report

Image Editor Page 30

3.2 Low level diagram of the Application

Input

Application

Java Compatible

Image Formats

(gif, bmp, jpg, png)

Annotations

Adjust

Resize

Layer Info

Themes etc.

Output

Annotated

document

with layer info

and unmodified

source

Annotations - line,oval,rectangle,filled rect,stamp,freehand,highlight etc.

Adjust - Undo, blur, sharpen, grayscale etc.

Resize - double, halve, customize

Layer Info - userwise layer information(main user)

The diagram shows the 0-level diagram for the application. The inputs are mentioned which are the

Java compatible image formats

Page 36: Project Report

Image Editor Page 31

3.3 Class Diagram Of the Application

Classes Description

Image Editor Class

This is the main class of our application. This is an abstract class that represents the entire system as a

whole. The main function of this class is to show how the actual program must work.

This class has a direct association with the ImageEditorframe Class and ImageManager Class.

ImageEditorFrame Class

The main function of ImageEditorFrame class is to implement the application’s main frame. It

provides the user the UI for the main features of the application through a tool bar and a menu.

Page 37: Project Report

Image Editor Page 32

This is a main class and it generalizes various classes as follows:

1. ScaleDialogBox Class

The ScaleDialog class implements the user interface for getting the values for the scale

operation the user wants to perform. The user can enter the value for the scale in the X axis

and the Y axis separately or to check the ‘Maintain aspect ratio’ option for the same scale

percentage on both axis.

The ScaleDialog class extends the JDialog class.

The main methods of the ScaleDialog class are:

GetXScaleValue() – This method returns the value for the scale operation on X axis.

GetYScaleValue() – This method returns the value for the scale operation on Y axis.

2. RotateDialogBox Class

The RotateDialog class implements the user interface for getting the rotation angle for the

rotate operation.

The RotateDialog class extends the JDialog class.

The main methods of the RotateDialog class are:

getValue() – This method returns the rotation angle the user entered.

rotateLeft() – This method returns the rotation direction the user entered.

rotateRight() – This method returns the rotation direction the user entered.

Page 38: Project Report

Image Editor Page 33

3. TextDialogBox Class

The TextDialog class implements the user interface for getting the text, the font, the font size

and color for the add text operation.

The TextDialog class extends the JDialog class.

The main methods of the TextDialog class are:

getStr() – This method returns the text the user entered.

getTextFont() – This method returns the font the user selected.

getcolor() – This method returns the text color the user selected.

4. SaveImageDialogBox Class

The SaveImageDialog class implements the user interface for saving an image file. The user

can select the file name and path, the image file format, and can define the properties for the

saving for some of the file formats.

The SaveImageDialog class extends the JFileChooser class for adding it the ability to define

the save properties by the ‘Advanced’ button.

The main methods of the SaveImageDialog class are:

ShowDialog() – Shows or opens up a SaveImageDialog box.

5. HelpBox Class

The HelpFrame class implements the HTML help pages viewer. It first displays the help

content page, and allow the user to view the other pages by using hyperlinks. It allows the user

to go backward and forward on the viewed pages, and to return to the content page.

Page 39: Project Report

Image Editor Page 34

The HelpFrame class extends the JFrame class.

The HelpFrame class implements the hyperlinkUpdate event for the ability to go backward

and forward on the viewed pages.

This class provides an extensive help for each of the functions mentioned in the

ImageManager class.

ImageManager Class

The ImageManger class represents an image. This image is on a frame.

This class implements the displaying of an image on a frame, the handling of the events associated

with the frame and the mouse, the opening and saving of an image file, and the image manipulation

operations (such as rotating an image, scaling an image, drawing on an image etc.)

The main methods of this class are described below:

Open() – This method opens an image file.

Save() – This methods save an image in its original file format and file name.

SaveAs() – This method save an image with a new file name and/or new image file format.

Close() – This method closes an image file, and saves it if the user wants.

RotateImage() – This method rotates the image.

ScaleImage() – This method scales up/down the image at the specified factor for X and Y axis.

SharpenImage() – This method sharpen the image using a convolution operation.

Undo() – This method return the image to the last state before the current change.

Redo() - This method return the image to the previous state before the current change.

ZoomImage() – this method displays a zoom in/out image of the image.

EdgeDetect() – This method performs an edge detection operation on the image using a convolution

operation.

FlipImage() –This method perform a flip/mirror operation on the image.

Page 40: Project Report

Image Editor Page 35

Brightness() – This method performs various brightness operation on the image.

Contrast() – This method adjusts the contrast levels of the image.

Saturation() – This method adjusts the saturation levels of the image.

Hue() – This method adjusts the hue levels of the image.

3.4 Use case Diagram for the Application

Page 41: Project Report

Image Editor Page 36

Use Case Diagram

Actor

The System only has a single actor. This actor generally comprises of the User. The user is the only

person which will guide the system and perform all the functions related to it.

The End User will perform all the Use Cases associated with the system. These are described below.

The normal activities that are performed by the actor in our system are Opening and Closing of an

Image. It also includes all the manipulations and general transformation performed on the image.

These activities will be performed by the user by interacting with the GUI of our system.

Use Cases

The various activities i.e. use cases which are performed by the actor are as follows:

Open

Exit

Save

Help

Print

Transform Image

Swap Colors

Scale And Zoom

Invert Image

Some of the Use Cases are explained in detail as below:

Open Use Case

End User

Open

Page 42: Project Report

Image Editor Page 37

Brief Description: The End User accesses the System and click the open tab for opening in an image.

Initial Step by Step Description:

1. The End User accesses the System.

2. Next, he clicks the File menu.

3. He then selects the Open tab.

4. Thus, the Image is loaded in the frame.

Exit Use Case

Brief Description: The End User accesses the System and click the exit tab for closing the system.

Initial Step by Step Description:

1. The End User accesses the System.

2. Next, he clicks the File menu.

3. He then selects the Exit tab.

4. Thus, the Image is saved and application exits.

Save Use Case

Brief Description: The End User accesses the System and click the Save tab for saving the work done

in the system.

End User

Exit

End User

Save

Page 43: Project Report

Image Editor Page 38

Initial Step by Step Description:

1. The End User accesses the System.

2. Next, he clicks the File menu.

3. He then selects the Save tab.

4. Thus, the Image is saved and user in prompt with an SaveDialog Box.

Print Use Case

Brief Description: The End User accesses the System and click the Print tab for printing the image

from the system.

Initial Step by Step Description:

1. The End User accesses the System.

2. Next, he clicks the File menu.

3. He then selects the Print tab.

4. Thus, the Image is saved and user in prompt with an PrintDialog Box.

Scale And Zoom Use Case

Brief Description: The End User accesses the System and click the Zoom tab for zooming the image

from the system.

End User

Print

End User

Scale and Zoom

Page 44: Project Report

Image Editor Page 39

Initial Step by Step Description:

1. The End User accesses the System.

2. Next, he clicks the Effects menu.

3. He then selects the Zoom tab.

4. Thus, the user is prompt with an ZoomDialog Box.

Help Use Case

Brief Description: The End User accesses the System and click the Help tab to recieve various related

information to edit an image in the system.

Initial Step by Step Description:

1. The End User accesses the System.

2. Next, he clicks the Help menu.

3. He then selects the Various tabs designated for the same.

4. Thus, the user is prompt with a HelpDialog Box.

Transform Image Use Case

Brief Description: The End User accesses the System and click the Print tab for printing the image

from the system.

End User

Help

End User

Transform Image

Page 45: Project Report

Image Editor Page 40

Initial Step by Step Description:

1. The End User accesses the System.

2. Next, he clicks the File menu.

3. He then selects the Print tab.

4. Thus, the Image is saved and user in prompt with an PrintDialog Box.

3.5 Activity Diagram

The first Diagram depicts the general flow of the process which are normally followed by the user

while editing or manipulating an image.

And the second Diagram show the flow structure of saving a file. This includes the Save and Save As

functionality.

General Flow Diagram

Page 46: Project Report

Image Editor Page 41

Save Process

Page 47: Project Report

Image Editor Page 42

3.6 Screen Layouts

1) The Application on first run and how the selected image shall be displayed on window frame.

And after an image is selected to be open in the respective frame.

Page 48: Project Report

Image Editor Page 43

2) View of the menus which are activated.

The file menu activates which has the option of opening the file through file dialog. It has the

copy, paste, save as, save, close, exit etc.. options. The complete toolbar appears after login.

Page 49: Project Report

Image Editor Page 44

3) The OPEN file dialog.

o This open filedialog is used to select a file in the application.

o The dialog shows all the file formats which are Java compatible.

o Also preview of some of the image file are available on the right portion.

o There is also a facility to move up, create a new folder, change the views

Page 50: Project Report

Image Editor Page 45

4) Annotations Demonstration.

o Annotation tools circle and line are demonstrated with different colors.

o The text input dialog box is also shown, which takes user input and puts it on the

image wherever user clicks.

o The object tagging is also shown. ( Which is sequential irrespective of the object

drawn).

Page 51: Project Report

Image Editor Page 46

Chapter 4

IMPLEMENTATION

Page 52: Project Report

Image Editor Page 47

Chapter 4

IMPLEMENTATION

4.1 Classes Used.

The following is the description of some of the classes used by us in our application

JPanel Class

In the simplest case, you use a JPanel exactly the same way as you would a Panel. Allocate it, drop

components in it, then add the JPanel to some Container. However, JPanel also acts as a replacement

for Canvas (there is no JCanvas). When using JPanel as a drawing area in lieu of a Canvas, there are

two additional steps you usually need to follow. First, you should set the preferred size via

setPreferredSize (recall that a Canvas' preferred size is just its current size, while a Panel and JPanel

determine their preferred size from the components they contain). Secondly, you should use

paintComponent for drawing, not paint. And since double-buffering is turned on by default, the first

thing you normally do in paintComponent is clear the off-screen bitmap via super.paintComponent.

JButton Class

The class JButton is an implementation of a push button. This component has a label and generates an

event when pressed. It can have Image also.

It is an implementation of a "push" button.

Buttons can be configured, and to some degree controlled, by Actions. Using an Action with a button

has many benefits beyond directly configuring a button.

JLabel Class

A display area for a short text string or an image, or both. A label does not react to input events. As a

result, it cannot get the keyboard focus. A label can, however, display a keyboard alternative as a

convenience for a nearby component that has a keyboard alternative but can't display it.

Page 53: Project Report

Image Editor Page 48

A JLabel object can display either text, an image, or both. You can specify where in the label's display

area the label's contents are aligned by setting the vertical and horizontal alignment. By default, labels

are vertically centered in their display area. Text-only labels are leading edge aligned, by default;

image-only labels are horizontally centered, by default.

You can also specify the position of the text relative to the image. By default, text is on the trailing

edge of the image, with the text and image vertically aligned.

A label's leading and trailing edge are determined from the value of its ComponentOrientation

property. At present, the default ComponentOrientation setting maps the leading edge to left and the

trailing edge to right.

Finally, you can use the setIconTextGap method to specify how many pixels should appear between

the text and the image. The default is 4 pixels.

JMenu Class and JMenuItem Class

An implementation of a menu -- a popup window containing JMenuItems that is displayed when the

user selects an item on the JMenuBar. In addition to JMenuItems, a JMenu can also contain

JSeparators.

In essence, a menu is a button with an associated JPopupMenu. When the "button" is pressed, the

JPopupMenu appears. If the "button" is on the JMenuBar, the menu is a top-level window. If the

"button" is another menu item, then the JPopupMenu is "pull-right" menu.

Menus can be configured, and to some degree controlled, by Actions. Using an Action with a menu

has many benefits beyond directly configuring a menu.

An implementation of an item in a menu. A menu item is essentially a button sitting in a list. When

the user selects the "button", the action associated with the menu item is performed. A JMenuItem

Page 54: Project Report

Image Editor Page 49

contained in a JPopupMenu performs exactly that function.

Menu items can be configured, and to some degree controlled, by Actions. Using an Action with a

menu item has many benefits beyond directly configuring a menu item.

JSlider Class

A component that lets the user graphically select a value by sliding a knob within a bounded interval.

The knob is always positioned at the points that match integer values within the specified interval.

The slider can show both major tick marks, and minor tick marks between the major ones. The

number of values between the tick marks is controlled with setMajorTickSpacing and

setMinorTickSpacing. Painting of tick marks is controlled by setPaintTicks.

Sliders can also print text labels at regular intervals (or at arbitrary locations) along the slider track.

Painting of labels is controlled by setLabelTable and setPaintLabels.

JTextField Class

JTextField is a lightweight component that allows the editing of a single line of text. For information

on and examples of using text fields, see How to Use Text Fields in The Java Tutorial.

JTextField is intended to be source-compatible with java.awt.TextField where it is reasonable to do so.

This component has capabilities not found in the java.awt.TextField class. The superclass should be

consulted for additional capabilities.

JTextField has a method to establish the string used as the command string for the action event that

gets fired. The java.awt.TextField used the text of the field as the command string for the

ActionEvent. JTextField will use the command string set with the setActionCommand method if not

null, otherwise it will use the text of the field as a compatibility with java.awt.TextField.

The method setEchoChar and getEchoChar are not provided directly to avoid a new implementation

of a pluggable look-and-feel inadvertently exposing password characters. To provide password-like

Page 55: Project Report

Image Editor Page 50

services a separate class JPasswordField extends JTextField to provide this service with an

independently pluggable look-and-feel.

The java.awt.TextField could be monitored for changes by adding a TextListener for TextEvent's.

BuffereImage Class

The BufferedImage subclass describes an Image with an accessible buffer of image data. A

BufferedImage is comprised of a ColorModel and a Raster of image data. The number and types of

bands in the SampleModel of the Raster must match the number and types required by the

ColorModel to represent its color and alpha components. All BufferedImage objects have an upper

left corner coordinate of (0, 0). Any Raster used to construct a BufferedImage must therefore have

minX=0 and minY=0.

This class relies on the data fetching and setting methods of Raster, and on the color characterization

methods of ColorModel.

FileDialog Class

The FileDialog class displays a dialog window from which the user can select a file.

Since it is a modal dialog, when the application calls its show method to display the dialog, it blocks

the rest of the application until the user has chosen a file.

JFileChooser Class

The JFileChooser Swing component let's users explore files on their system. It provides a GUI similar

to Windows Explorer found in Windows or Nautilus in Ubuntu.

It allows users to navigate through their file system and choose the desired file/directory.

Page 56: Project Report

Image Editor Page 51

You can use a JFileChooser to open or save files from/to a location which is chosen by the user.

Here's a complete guide explaining the use of JFileChooser and it's important properties.

Connection Class

A connection (session) with a specific database. SQL statements are executed and results are returned

within the context of a connection.

A Connection object's database is able to provide information describing its tables, its supported SQL

grammar, its stored procedures, the capabilities of this connection, and so on. This information is

obtained with the getMetaData method.

4.2 Some General Algorithms and Their Implementation

4.2.1 Algorithm for Opening a Document:-

Step1:- Show the open File dialog (JFileCchooser) for choosing the file which is to be opened.

Page 57: Project Report

Image Editor Page 52

Step2:- Get the name of the file or the image name which user selects in string format by appropriate

method and store it in the array.

Step3:- Get the image name from the filename i.e. the portion before the extension (.) and display the

name without extension at the title of the application to show that which file is open.

Step4:- Now get height and width of the image which we have read. Use the drawimage image

function (image, startx, starty, height, width, container). For drawing the image on the scrollpane. The

scrollpane is used for drawing the image on it so that if image is larger than screen then also complete

image is seen as the scrollbar is present.

Step5:- After drawing the image, check if image related files “imagename.txt” and “imagename1.txt”

present or not.

Step6:- If present get the data from that file using appropriate fileReader methods and load them to

initialize the array to draw different objects saved in the file using the different draw functions of

graphics method.

Implementation

private void jMenuOpenActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

JFileChooser jfcOpen = new JFileChooser();

jfcOpen.setDialogTitle("Select Image");

jfcOpen.setFileFilter(readfilt);

jfcOpen.setVisible(true);

jfcOpen.setAccessory(new ImagePreview(jfcOpen));

if(ffilload != null)

jfcOpen.setSelectedFile(ffilload);

try

{

int i = jfcOpen.showOpenDialog(this);

}

catch(HeadlessException headlessexception) {

System.out.println("Err" + headlessexception.getMessage());

}

File input = jfcOpen.getSelectedFile();

Page 58: Project Report

Image Editor Page 53

try

{

this.setTitle(jfcOpen.getSelectedFile().toString());

// im=ImageIO.read(input);

image=ImageIO.read(input);

image1=ImageIO.read(input);

image2=ImageIO.read(input);

}

catch(IOException e1)

{

e1.printStackTrace();

}

// JPanel pb = new JPanel(new FlowLayout(FlowLayout.LEFT));

jLabel1.setIcon(new ImageIcon(image.getScaledInstance( -1, -1,

BufferedImage.SCALE_DEFAULT)));

jLabel1.setVerticalAlignment(SwingConstants.TOP);

repaint();

jScrollPane1.getViewport().add(jLabel1);

repaint();

path=new File(jfcOpen.getSelectedFile().toString());

folderpath=path.getParent().toString();

String NewPath = path.getName().toString();

int i = NewPath.lastIndexOf('.');

if (i > 0)

{

extension = NewPath.substring(i+1);

}

im=image;

sethistogram();

System.out.println("Name of file="+NewPath+"\tExtension="+extension+"Path :::"+folderpath);

try

{

DBConnection DB = new DBConnection();

DB.CreateConnect();

String FilePath = folderpath.toString()+"\\"+ path.toString();

java.util.Date D = new java.util.Date();

Page 59: Project Report

Image Editor Page 54

String FileAccessDate = D.getDate() +"-"+(D.getMonth()+1) + "-"+(1900+D.getYear());

String FileAccessTime = D.getHours() +":"+D.getMinutes()+ ":"+D.getSeconds();

String IP = InetAddress.getLocalHost().toString();

String OS = System.getProperty("os.name");

if(DB.addFileRecord(NewPath, FileAccessDate, FileAccessTime, IP, OS))

{

System.out.println("Record is Saved....");

}

else

{

System.out.println("Missing ....");

}

}

catch(Exception e)

{

e.printStackTrace();

}

}

4.2.2. Algorithm for saving a document

Two saving options are provided in the file menu for saving a document

(1) Save as

(2) Save

Page 60: Project Report

Image Editor Page 55

Save as:-

Using this option the user is able to change the original image in a way that when image is saved, its

work is merged on the original image and can save it elsewhere. Thus the source is modified in this

case.

Step1: Open the save dialogbox (using the default save filechooser dialog).

Step 2: After giving the filename from user get that filename.

Step 3: For that first draw all the work of user on the image by getting the graphics of image using the

image.getgraphics().

Step 4: Use the Imageio’s write method to store the image.

Save:

In this option user can save the file and various useful information of the image. The manipulated or

edited image is stored on the storage memory which is easily accessible for future use.

Step1: For saving the text file first all the arrays of objects stored on the file using the FileWriter

methods and the object identification symbol is also stored in the file to identify it later. So total 7/8

strings for each object are stored. Sequence of this strings are stored on file.

Step 2 :For the name of this file use the same name as that of image and extension for that is (.txt).

Step 3: Get the elements from the string array in which date and time information stored.

Step 4: For the name of this file use the image name and concate 1 at the end and extension is .txt.

Step 5:Check if any adjustment/modification or resizing is done on the image.

If done then using the imageio.write(File f) function write that image in the users folder, and name of

that file is same as that of image but the extension is (.png).

Page 61: Project Report

Image Editor Page 56

Implementation(Save)

private void jMenuSaveActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

try

{

System.out.println("Path=" + path + "extension=" + extension);

ImageIO.write(imageToBufferedImage(image), extension, path);

}

catch (IOException e) {

}

}

Implementation(SaveAS)

private void jMenuSaveAsActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

FileFilter filter = new FileNameExtensionFilter("JPEG", "jpg", "jpeg");

FileFilter filter1 = new FileNameExtensionFilter("GIF", "gif", "GIF");

FileFilter filter2 = new FileNameExtensionFilter("PNG", "png", "PNG");

JFileChooser fileChooser = new JFileChooser();

fileChooser.addChoosableFileFilter(filter);

fileChooser.addChoosableFileFilter(filter1);

fileChooser.addChoosableFileFilter(filter2);

fileChooser.showSaveDialog(this);

System.out.println("FIle Exet" + fileChooser.getFileFilter().getDescription() + "\t" +

fileChooser.getSelectedFile().getPath() );

String ext= fileChooser.getFileFilter().getDescription();

File file = new File(fileChooser.getSelectedFile().getPath() + "." + ext);

try

{

ImageIO.write(imageToBufferedImage(image), ext, file);

}

catch (IOException e) {

}

}

Page 62: Project Report

Image Editor Page 57

4.2.3 Algorithm For General Annotations

Step 1: Identify which annotation tool user has selected by implementing the MouseListener interface

and set the flag for that tool.

Step 2: Get the starting point at where user clicked using the getX (), getY () methods.

Step 3: Get the end point where the user released after dragging the mouse.

Step 4: If drawing the object requires height and width parameters to be calculated,

width = end.x - start.x;

height = end.y - start.y;

Step 5: Invoke the paint() method for drawing that object.

Step 6: In the paint () check which flag was set to true and draw that object on the image.

4.2.4 Algorithm for Database Connection:

This helps an application to have a connectivity to a small database. The database can be helpful in

retrieving various useful information regarding the MachineIP, File Access Date and Time,

user/author name, image/file name, Operating system name and even the location.

package pkgfinal.ivp;

import java.sql.*;

public class DBConnection {

public ResultSet Rs = null;

public Statement Stmt = null;

public Connection Conn = null;

public void CreateConnect( )

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Conn = DriverManager.getConnection("jdbc:odbc:FileHand","","");

Stmt = Conn.createStatement();

}

catch(Exception e)

{

e.printStackTrace();

}

}

Page 63: Project Report

Image Editor Page 58

4.2.5 Algorithm for Adding the Records:

public boolean addFileRecord(String Path, String FileDate, String FileTime, String IP, String Os)

{

boolean flag=false;

try

{

String Qry="Insert Into History

(FilePath,FileAccessDate,FileAccessTime,MachineIp,OSName) values ('"+Path

+"','"+FileDate+"','"+FileTime+"','"+IP+"','" + Os +"')";

int I = Stmt.executeUpdate(Qry);

if(I>=1)

flag=true;

else

flag=false;

}

catch(Exception e)

{

flag=false;

}

return flag;

}

Page 64: Project Report

Image Editor Page 59

4.2.6 Algorithm for Viewing Records:

public ResultSet ViewAll()

{

try

{

Rs = Stmt.executeQuery("Select * From History");

}

catch(Exception e)

{

Rs = null;

}

return Rs;

}

public ResultSet ViewFive()

{

try

{

Rs = Stmt.executeQuery("select Count(*) from history");

Rs.next();

int C = Rs.getInt(1);

if(C>5)

{

Rs = Stmt.executeQuery("Select * From History where ID>=(select Max(Id)-5 from

History)");

}

else

{

Rs = Stmt.executeQuery("Select * From History");

Page 65: Project Report

Image Editor Page 60

}

}

catch(Exception e)

{

Rs = null;

}

return Rs;

}

}

4.2.7 Algorithm for Brightness:

public BufferedImage brightenImage(BufferedImage img)

{

for (int x = 0; x < img.getWidth(); x++) //width

{

for (int y = 0; y < img.getHeight(); y++) //height

{

Color color = new Color(img.getRGB(x, y));

Color brighter = color.brighter();

img.setRGB(x, y, brighter.getRGB());

}

}

return img;

}

Page 66: Project Report

Image Editor Page 61

4.2.8 Algorithm for Grayscale:

public BufferedImage grayImage(BufferedImage img)

{ img=im;

ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);

ColorConvertOp op = new ColorConvertOp(cs, null);

img = op.filter(img, null);

return img;

}

4.2.9 Algorithm for Redeye View:

Page 67: Project Report

Image Editor Page 62

private void jMenuRedEyeViewActionPerformed(java.awt.event.ActionEvent evt)

{

BufferedImage img = im;

Color col;

for (int x = 0; x < img.getWidth(); x++) //width

{

for (int y = 0; y < img.getHeight(); y++) //height

{

int RGBA = img.getRGB(x, y); //gets RGBA data for the specific pixel

col = new Color(RGBA, true); //get the color data of the specific pixel

col = new Color(Math.abs(col.getRed() - 255),1,1); //Swaps values

img.setRGB(x, y, col.getRGB()); //set the pixel to the altered colors

}

}

Graphics2D gg = img.createGraphics();

gg.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);

jLabel1.setIcon(new ImageIcon(img.getScaledInstance( -1, -1,

BufferedImage.SCALE_DEFAULT)));

image=img;

4.2.10 Algorithm for Invert:

private void jMenuInvertActionPerformed(java.awt.event.ActionEvent evt) {

BufferedImage img = im;

Color col;

for (int x = 0; x < img.getWidth(); x++) //width

{

for (int y = 0; y < img.getHeight(); y++) {//height

int RGBA = img.getRGB(x, y); //gets RGBA data for the specific pixel

col = new Color(RGBA, true); //get the color data of the specific pixel

col = new Color(Math.abs(col.getRed() - 255),

Math.abs(col.getGreen() - 255), Math.abs(col.getBlue() - 255)); //Swaps values

img.setRGB(x, y, col.getRGB()); //set the pixel to the altered colors

}

}

Graphics2D gg = img.createGraphics();

gg.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);

Page 68: Project Report

Image Editor Page 63

jLabel1.setIcon(new ImageIcon(img.getScaledInstance( -1, -1,

BufferedImage.SCALE_DEFAULT)));

image=img;

4.2.11 Algorithm for Rotate

private void jMenuRotateLeftActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

BufferedImage im5;

im5= rotate90(image,"left");

jLabel1.setIcon(new ImageIcon(im5.getScaledInstance( -1, -1,

BufferedImage.SCALE_DEFAULT)));

repaint();

jScrollPane1.getViewport().add(jLabel1);

repaint();

image=im5;

Page 69: Project Report

Image Editor Page 64

}

private void jMenuRotateRightActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

BufferedImage im6;

im6= rotate90(image,"right");

jLabel1.setIcon(new ImageIcon(im6.getScaledInstance( -1, -1,

BufferedImage.SCALE_DEFAULT)));

repaint();

jScrollPane1.getViewport().add(jLabel1);

repaint();

image=im6;

}

Page 70: Project Report

Image Editor Page 65

Chapter 5

TESTING

Page 71: Project Report

Image Editor Page 66

Chapter 5

TESTING

5.1 Testing

Software testing is the process used to assess the quality of computer software. Software testing is an

empirical technical investigation conducted to provide stakeholders with information about the quality

of the product or service under test , with respect to the context in which it is intended to operate. This

includes, but is not limited to, the process of executing a program or application with the intent of

finding software bugs. Quality is not an absolute; it is value to some person. With that in mind, testing

can never completely establish the correctness of arbitrary computer software; testing furnishes a

criticism or comparison that compares the state and behavior of the product against a specification.

The software faults occur through the following process. A programmer makes an error (mistake),

which results in a defect (fault, bug) in the software source code. If this defect is executed, in certain

situations the system will produce wrong results, causing a failure. Not all defects will necessarily

result in failures. For example, defects in a dead code will never result in failures. A defect can turn

into a failure when the environment is changed.

There are many approaches to software testing. Reviews, walkthroughs or inspections are considered

as static testing, whereas actually running the program with a given set of test cases in a given

development stage is referred to as dynamic testing.

Software testing is used in association with verification and validation: Verification: Have we built the

software right (i.e., does it match the specification)? Validation: Have we built the right software (i.e.,

is this what the customer wants)?

Software testing methods are traditionally divided into black box testing and white box testing. These

two approaches are used to describe the point of view that a test engineer takes when designing test

cases.

Page 72: Project Report

Image Editor Page 67

Black box testing treats the software as a black-box without any understanding of internal behavior. It

aims to test the functionality according to the requirements. Thus, the tester inputs data and only sees

the output from the test object. This level of testing usually requires thorough test cases to be provided

to the tester who then can simply verify that for a given input, the output value (or behavior), is the

same as the expected value specified in the test case. Black box testing methods include: equivalence

partitioning, boundary value analysis, all-pairs testing, fuzz testing, model-based testing, traceability

matrix etc.

White box testing, however, is when the tester has access to the internal data structures, code, and

algorithms. White box testing methods include creating tests to satisfy some code coverage criteria.

For example, the test designer can create tests to cause all statements in the program to be executed at

least once. Other examples of white box testing are mutation testing and fault injection methods.

White box testing includes all static testing.

5.2 Testing And Debugging

The testing and debugging is also one of the important stages in the development life-cycle of a

project. The project within its limitations has to be tested for various kinds of inputs and for

various bugs which may hinder the features/utility of the project and they should be resolved if

possible.

These are some of the inputs and bugs for which the project was tested and debugged for an

optimized application.

Test Case No. 1.

Module Opening Image

Problem/ Error The application had some problems while opening the BMP

image format.

Solution Problem was resolved after using the ImageIO package.

Page 73: Project Report

Image Editor Page 68

Test Case No. 2.

Module Opening the image

Problem/ Error Image loaded into the application at the first time was limited

only to the size of the frame resulting into a cut image if the size

of the image was greater than that of frame. The problem of

image size occurred because the image was opened in the Panel

Solution This was solved by loading the image on the scroll pane.

Test Case No. 3.

Module Freehand(Annotation)

Problem/ Error Whenever mouse was released , and on new mouse click the

freehand line started from where the mouse had been released.

Solution At the new mouse click the start point was initialized to last

mouse release.

Test Case No. 4.

Module Close file

Problem/ Error In the file menu close option when clicked, it displayed a

message to save the document the buttons (yes / no) but no

option to cancel that dialog. Later on clicking on that cancel

button of the option pane, the document used to get closed.

Solution This problem was solved by taking care of return value of the

JOptionPane.

Page 74: Project Report

Image Editor Page 69

Test Case No. 5.

Module Zoom

Problem/ Error In the view menu tab Zoom Image option when clicked, it

displayed the image in a very unsophisticated way. Since the

zoom option enlarges the image, the frame chosen wasn’t able to

accommodate the enlarged image, thus the cause of problem.

Solution This was solved by loading the image on the scroll pane.

Test Case No. 6.

Module Rotate

Problem/ Error In the view menu tab Rotate Image option when clicked, it

displayed the image such that the desired result wasn’t obtained.

Since the width and height of an image are different in many

cases,the rotation caused the image to be adjusted in a space

where it can’t be accomodated, the frame chosen wasn’t able to

accommodate the different sizes, thus the cause of problem.

Solution This was solved by loading the image on the scroll pane.

Test Case No. 7.

Module Restore

Problem/ Error It was found that the algorithm for blur used , modified the

object of the source image, Hence, even after multiple

alterations of image, when restores the blur effect was still

prevalent.

Solution This was solved by loading the image in a new object .

Page 75: Project Report

Image Editor Page 70

Chapter 6

USER MANUAL

Page 76: Project Report

Image Editor Page 71

Chapter 6

USER MANUAL

6.1 USER MANUAL

The manual gives a brief general sequence of the options to be followed in order to use the

application. The application manual has been described user wise and as per the menus available on

the application so that each of their uses and options can be explained well.

General user

When the application runs, firstly only some of the menus on the menubar will be activated. The user

can select any of the various options available in the various menu.

FILE menu:

The File menu contains all the options like open, save, next, close, reopen, save as, reset ,exit etc.

Open will open any of the image like bmp, gif, jpg, etc. which is compatible with the application. .

Close is used to close the image; it asks whether to save if any work done before closing.

Reopen reloads the image again. For saving a document there are two options: save and save as.

Save as option saves the current document with its work done in such a way that all the work is

merged on the original document and the source is modified with no layer.

While if Save option is used, the source file gets modified , no new file is created.

Exit is used to close the application.

Page 77: Project Report

Image Editor Page 72

ADJUST menu:

Next is the Adjust menu which has the following options:

Blur- this option blurs the opened document.

Sharpen- sharpens the quality of the document and

Grayscale- puts the document in grayed shade with only black and white color.

Invert- This option is used to invert the pixels of an image.

Brightness- This option is used to factor the brightness element in our application.

EdgeDetect-This option is used to detect all the leading edges.

RedEyeView- This option is used to implement RedEye view in a picture

EDIT menu:

The menu has the options like:

Double- this option doubles the original size of the document along with the annotations performed on

it.

Halve- this option halves the original size of the document along with the annotations on it.

Custom- This option is used to resize the image with the size inserted by the user. Thus the image gets

resized according to the input.

Reset- This option undoes the last object drawn on the document. i.e. the most recently drawn object

can be removed through this option.

Rotate Left/Right- This option is used to flip the opened document either to the left or right.

ANNOTATIONS menu:

The Annotations menu includes all the annotation tools which are on the toolbar too like rectangle,

oval, fillrectangle, straight line, text, stamp which is customizable(user input can be stamped),

freehand line drawing, and the highlight option which highlights the selected portion of the document

through mouse. There is a select color option at the end of the menu which opens the color palette for

the selection of color for drawing the tools. The color palette button on the toolbar is also available.

Page 78: Project Report

Image Editor Page 73

Also after the color is selected, the user needs to select the annotation tool again to work on the

document.

Meanings of standard keys and mouse buttons:

The application has all the keys which have the standard functionalities. The mnemonics of the

hotkeys can be put. The mouse has also the standard functionalities as in the Windows.

Page 79: Project Report

Image Editor Page 74

Chapter 7

FUTURE

ENHANCEMENT

Page 80: Project Report

Image Editor Page 75

Chapter 7

FUTURE ENHANCEMENT

7.1 Future Enhancement

An ideal project should have smart plug ability and good interpretable structure so that if

under any circumstances the project is extended, would be easy to understand and implement

new features/enhancements easily.

Some of the possible future extensions for this application are listed as below.

A complete document scanning support can be implemented as a module in the application so

that the documents directly scanned form the external device can be used by the application.

Different rights and rules can be defined for users. E.g. suppose a user works and saves it to

give it to his high-level user, after saving the work he should not be able to modify it unless

the high level user grants him the access.

Implementation of secure notes on the work item so that browsing them by notes is possible,

can also be there.

The JDBC can be used for a database that contains the username and all relevant information

stored, and thus access rights defining for the user and other facilities become easy to

implement.

The GUI can be provided with better look and feel.

Copy, paste and selective cropping features can be added.

Support for fax-in, emails etc. can be included.

The information provided in the output window for the history and tracking option can be

displayed in the running window itself.

The annotation toolkit range could be increased. Number of times of Undo operation can be

increased too.

Layering feature i.e. overlapping of image, formation of collage, textures are the few features

that can be thought of implementing.

Page 81: Project Report

Image Editor Page 76

Conclusion

The application has been tested and found to be free of bugs.

Further enhancements to the code are always appreciated.

As of now, the editor is limited to displaying a single picture at a time. We would like to implement

thumbnail view for this application, enabling users to view and manipulate multiple pictures at once.

Another limitation that we would like to overcome is to integrate the editor with a web browser for

additional features.

We would also like to add a tree view of all the available files and folders for easy accessing .

Page 82: Project Report

Image Editor Page 77

References and Bibliography

Books referred:

The Complete Reference JAVA2, Herbert Schildt, Patrick Naughton

Java2 Special Edition, By - John P Weber

Pure JFC Swing, By – Dr. Satyaraj Pantham

Java2 programming ‘Black Book’

Online References:

Java

www.java.sun.com

www.javaboutique.com

www.javaworld.com

DMS

www.ereviewonline.com

www.worldox.com

www.newgensoft.com

Offline references:

JavaTM

2 SDK, Standard Edition Documentation