SlideShare a Scribd company logo
GLOBAL EARTHQUAKE MONITOR
A Report submitted in partial fulfilment of the requirement for the
award of degree of
Bachelor of Technology
In
Electronics and Communication Engineering
Submitted By
HIMANSHI (02215002817)
MAHARAJA SURAJMAL INSTITUTE OF TECHNOLOGY
C-4, Janakpuri, New Delhi-58
Affiliated to Guru Gobind Singh Indraprastha University, Delhi
June, 2020
2
3
CANDIDATE’S DECLARATION
I, Himanshi, Roll No. 02215002817, B.Tech (Semester- 7th)
of the Maharaja
Surajmal Institute of Technology, New Delhi hereby declare that the Training Report
entitled “Object-Oriented Programming in Java” is an original work and data provided in
the study is authentic to the best of my knowledge. This report has not been submitted to any
other Institute for the award of any other degree.
Name of Student:
Himanshi
(Roll No. 02215002817)
4
ACKNOWLEDGEMENT
A research work owes its success from commencement to completion, to the people
in love with researchers at various stages. Let me in this page express my gratitude to all those
who helped us in various stage of this study. First, I would like to express my sincere gratitude
indebtedness to Mr. Puneet Azad (HOD, Department of Information Technology, Maharaja
Surajmal Institute of Technology, New Delhi) for allowing me to undergo the summer training
of 6 weeks with Coursera.
I am grateful to my guide Ms. Mia Minnes, Ms. Christine Alvarado, and Mr. Leo
Porter, for the help provided in completion of the project, which was assigned to me. Without
his friendly help and guidance it was difficult to develop this project.
Last but not least, I pay my sincere thanks and gratitude to all the staff at courser for
their support and for making my training valuable and fruitful.
Submitted By:
HIMANSHI
5
Table of Contents
Acknowledgements 4
List of Figures 7
Chapter 1. About the Coursera …………………………………………. 8
Chapter 2. About the Course …………………………………………. 8
Chapter 3. Project Details ………………………………………… 9
3.1 Overview ……………………………………………………...…. 9
3.2 Software ....……………………………………………………… 9
3.3 Language ………………………………………………………… 9
3.4 Libraries ………………………………………………………… 9
3.5 Java ………………………………………………………………… 10
3.6 Unfolding Maps ………………………………………………… 10
3.7 Processing Library ………………………………………………… 11
3.8 Object Oriented Programming ………………………………… 12
3.9 Class PApplet ………………………………………………... 13
3.10 Class SimplePointMarker ………………………………………… 13
Chapter 4. Data Files ………………………………………………... 14
Chapter 5. Libraries ………………………………………………… 18
Chapter 6. SRC Files ………………………………………………… 22
Chapter 7. Code ………………………………………………………… 24
7.1 setUp() Method ………………………………………………… 24
7.2 draw() Method ………………………………………………… 27
7.3 sortAndPrint() Method ………………………………………… 27
7.4 mouseMoved() Method ………………………………………… 28
7.5 selectMarkerIfHover() Method ……………………………….. 28
7.6 mouseClicked() Method ………………………………………. 29
7.7 checkCitiesForClick() ………………………………………… 29
7.8 checkEarthquakesForClick() Method ……………………………. 30
6
7.9 unhideMarkers() Method ………………………………………… 30
7.10 isLand() method ………………………………………… 31
7.11 addKey() Method ………………………………………… 31
7.12 printQuakesMethod ………………………………………… 34
7.13 isInCountry() method ………………………………………… 36
Chapter 8. Output ………………………………………………………… 37
8.1 Offline Mode ………………………………………………… 37
8.2 Online Mode ………………………………………………… 42
8.3 Information Box ………………………………………………… 46
Chapter 9. Result ………………………………………………………… 47
Chapter 10. Conclusion ………………………………………………… 48
Chapter 11. References ………………………………………………… 49
7
List Of Figures
Figure 1 Coursera Logo ...………………………………….…………. 8
Figure 2 Live Earthquake data feed from http://earthquake.usgs.gov/ …… 14
Figure 3 city-data.json ………………………………………………. 15
Figure 4 blankLight-1-3.mbtiles ………………………………………. 16
Figure 5 countries.geo.json ………………………………………………. 16
Figure 6 2.5_week.atom ………………………………………………. 17
Figure 7 Libraries ………………………………………………………. 18
Figure 8 SRC Files ………………………………………………………. 22
Figure 9 Extends vs Implements ………………………………………. 23
Figure 10 EarthquakeCityMap.java run ……………………………….. 37
Figure 11 Zoom(2) in Offline Mode ……………………………………….. 38
Figure 12 Zoom(3) in Offline Mode ……………………………………….. 38
Figure 13 Cursor move on City Marker ……………………………….. 39
Figure 14 Cursor move on Land Earthquake ……………………………….. 39
Figure 15 Mouse clicked on Land Earthquake ……………………….. 40
Figure 16 Mouse clicked on Ocean Earthquake ……………………….. 40
Figure 17 Click on City Marker ……………………………………….. 41
Figure 18 Zoom(5) in Offline Mode ………………………………………... 41
Figure 19 EarthquakeCityMap.java file run ………………………………… 42
Figure 20 Cursor move on Ocean Earthquake ………………………... 43
Figure 21 Cursor move on CityMarker ………………………………… 44
Figure 22 Zoom in too much and Cursor move on ………………………… 45
Figure 23 Click on Ocean Earthquake ………………………………… 45
Figure 24 Information Box …………………………………………………. 46
8
ABOUT THE COURSERA
Coursera (/kərˈsɛrə/) is an American massive open online course (MOOC) provider
founded in 2012 by Stanford University's computer science professors Andrew
Ng and Daphne Koller that offers massive open online courses (MOOC), specializations,
degrees, professional and mastertrack courses.
Coursera works with universities and other organizations to offer online courses,
certifications, and degrees in a variety of subjects, such as engineering, data science, machine
learning, mathematics, business, financing, computer science, digital
marketing, humanities, medicine, biology, social sciences, 3000 plus variety of courses
giving students a very broad range of information & experience in different fields.
ABOUT THE COURSE
Object Oriented Programming in Java:
 Object design: constructors, instance variables, methods
 Memory models and Scope
 Creating GUIs using PApplet
 Unfolding Maps
 Inheritance and Polymorphism
 Event-Driven Programming
 Searching: Linear Search & Binary Search
 Sorting: Insertion Sort & Selection Sort
Fig.1 Coursera Logo
9
PROJECT DETAILS
OVERVIEW:
This project was a part of the Java Object-Oriented Design of Data Structures. An
interactive application with a Graphical User Interface (GUI).
Displays a world map with Earthquake data. This interactive map uses a live RSS feed
from the U.S. Geological Survey to show the location, magnitude, and potential impact of
earthquakes around the world. It contains:
 Object Oriented Programming principles like Encapsulation, Inheritance,
Polymorphism and Abstraction.
 Event Driven Programming
 Searching and Sorting techniques for data to be displayed.
SOFTWARE:
 ECLIPSE IDE
 JAVA PLATFORM (JDK) 8u60
LANGUAGE:
 Java
LIBRARIES:
 Unfolding Maps
 Processing Library
10
JAVA:
Java is a class-based, Object-Oriented Programming Language that is designed to
have as few implementation dependencies as possible. It is a general-purpose programming
language intended to let application developers Write Once, Run
Anywhere (WORA), meaning that compiled Java code can run on all platforms that support
Java without the need for recompilation. Java applications are typically compiled
to bytecode that can run on any Java Virtual Machine (JVM) regardless of the
underlying computer architecture.
UNFOLDING MAPS:
Unfolding is a library to create interactive maps and geo visualizations
in Processing and Java.
The main purpose of using unfolding is to create not only static maps but also interactive
maps in both java and processing. It can easily be installed on eclipse by downloading the
unfolding template from the official website. It is widely used due to the features provided by
unfolding like:
1. Interaction Events: In unfolding, we can easily create interactive maps. The basic
interactions like zoom and pan are included in this library.
2. Data Visualization: This library is very robust that it even lets users create geo-
positioned markers to display the data on a map. This visual style can be freely adapted.
This library also supports users to load and display user-defined shapes like points, lines
or polygons.
3. Styled Maps: This library is a title-based map library. This library allows map titles to
have various geographic features and styles.
4. Clean & Extendable Code: This library allows the beginners to easily create simple
maps. Advanced users can also sketch their prototypes or create their own sophisticated
visualizations.
11
PROCESSING LIBRARY:
Processing is an open-source low level animation and GUI library built on Java with
additional simplifications like additional classes, aliased mathematical functions and
operations. It also provides a GUI for simple compilation of the programs written in
processing.
Features of Processing: The following are the features of processing:
 It includes a sketchbook which is a minimalistic alternative to an IDE. This sketchbook
can be used as a normal IDE to organize projects.
 Every sketch drawn in processing is a subclass of the Java class (PApplet). This class
implements almost all the features of processing.
 Since processing inherits the properties of the class, all the additional classes defined in
the sketch will be treated as an inner class when the code is being converted into a pure
java code before compiling. Therefore, the use of static variables and methods is strictly
prohibited in processing.
 The processing language also gives the users an option to create own classes in the
PApplet sketch. Therefore, this gives the users a chance to use a more complex data
structures apart from the basic data types in java.
12
Object Oriented Programming:
Object-Oriented Programming or OOPs refers to languages that uses objects in
programming. Object-oriented programming aims to implement real-world entities like
inheritance, hiding, polymorphism etc. in programming. The main aim of OOP is to bind
together the data and the functions that operate on them so that no other part of the code can
access this data except that function.
Main OOPs Concepts:
 POLYMORPHISM: Polymorphism refers to the ability of OOPs programming
languages to differentiate between entities with the same name efficiently. This is done
by Java with the help of the signature and declaration of these entities.
 INHERITANCE: Inheritance is an important pillar of OOP (Object Oriented
Programming). It is the mechanism in java by which one class is allow to inherit the
features (fields and methods) of another class.
 ENCAPSULATION: Encapsulation is defined as the wrapping up of data under a
single unit. It is the mechanism that binds together code and the data it manipulates.
Another way to think about encapsulation is, it is a protective shield that prevents the
data from being accessed by the code outside this shield.
 ABSTRACTION: Data Abstraction is the property by virtue of which only the
essential details are displayed to the user. The trivial or the non-essentials units are not
displayed to the user. Ex: A car is viewed as a car rather than its individual
components.
Data Abstraction may also be defined as the process of identifying only the required
characteristics of an object ignoring the irrelevant details.
13
CLASS PApplet:
java.lang.Object
processing.core.PApplet
The processing library in Java has a class called PApplet which is used in
Making Graphical User Interface (GUI).
 The PApplet class must be the superclass of an applet that is to be embedded in a Web
page or viewed by the Java Applet Viewer.
 The PApplet class has two main methods namely the setup() and the draw() method.
 Using PApplet class we can create user-friendly GUI apps, which means the
application is user interactive, they have icons, sliders, we can click, drag, drop and
play with the app window.
 The setup method is run once whereas the draw function will run repeatedly drawing
the image on the canvas.
Base class for all sketches that use processing.core.
import processing.core.PApplet;
CLASS SimplePointMarker:
java.lang.Object
de.fhpotsdam.unfolding.marker.AbstractMarker
de.fhpotsdam.unfolding.marker.SimplePointMarker
Marker representing a single location. Use directly to display as simple circle, or
extend it for custom styles.
14
DATA FILES:
 https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.atom
Fig.2 Live Earthquake data feed from http://earthquake.usgs.gov/
15
 city-data.json
Fig.3 city-data.json
16
 blankLight-1-3.mbtiles
 countries.geo.json
Fig.4 blankLight-1-3.mbtiles
Fig.5 countries.geo.json
17
 2.5_week.atom
Fig.6 2.5_week.atom
18
LIBRARIES
A Java library contains code which you can access and use in your Java project. The
deployment format of a Java library is a JAR file.
 java.util.ArrayList: Resizable-array implementation of the List interface.
Implements all optional list operations, and permits all elements, including null. In
addition to implementing the List interface, this class provides methods to manipulate
the size of the array that is used internally to store the list.
 java.util.Arrays: This class contains various methods for manipulating arrays (such
as sorting and searching). This class also contains a static factory that allows arrays to
be viewed as lists.
Fig.7 Libraries / Header Files
19
The methods in this class all throw a NullPointerException, if the specified array
reference is null, except where noted.
 java.util.Collections: This class consists exclusively of static methods that operate on
or return collections. It contains polymorphic algorithms that operate on collections,
"wrappers", which return a new collection backed by a specified collection, and a few
other odds and ends.
The methods of this class all throw a NullPointerException if the collections or class
objects provided to them are null.
 java.util.List: An ordered collection (also known as a sequence). The user of this
interface has precise control over where in the list each element is inserted. The user
can access elements by their integer index (position in the list), and search for elements
in the list.
Unlike sets, lists typically allow duplicate elements. More formally, lists typically
allow pairs of elements e1 and e2 such that e1.equals(e2).
 de.fhpotsdam.unfolding.UnfoldingMap: An interactive map. Uses the MapDisplay,
and handles hit test, active status, as well as all interactions such as panning, zooming,
and rotating (with or without tweening). Acts as facade for the map interactions, e.g.
using innerScale for zooming, and outerRotate for rotating.
 de.fhpotsdam.unfolding.data.Feature: A feature stores one or more locations, its
type, and additional data properties.
 de.fhpotsdam.unfolding.data.GeoJSONReader: Reads GeoJSON files and creates
Features.
 de.fhpotsdam.unfolding.data.PointFeature: Stores a single location.
20
 de.fhpotsdam.unfolding.geo.Location: The Location represents a geo location
defined by latitude and longitude.
 de.fhpotsdam.unfolding.marker.AbstractShapeMarker: Abstract marker
representing multiple locations and can be implemented as lines, polygons, or other
shapes. Handles multiple locations, and implements the main marker methods for
handling those properly.
 de.fhpotsdam.unfolding.marker.Marker: Displays visual representations of geo-
spatial locations using Marker and MarkerManager. Marker interface for all markers
to be drawn on to maps.
 de.fhpotsdam.unfolding.marker.MultiMarker: A MultiMarker enables handling of
multiple, logically grouped markers. Properties and display states are the same for all
its markers. A MultiMarker can consist of various sub-markers, even of different
types. For instance, a MultiMarker could have three polygon marker and one point
marker.
 de.fhpotsdam.unfolding.providers.MBTilesMapProvider: MapProvider for local
MBTiles.
de.fhpotsdam.unfolding.providers.AbstractMapProvider
de.fhpotsdam.unfolding.providers.AbstractMapTileProvider
de.fhpotsdam.unfolding.providers.MBTilesMapProvider
 de.fhpotsdam.unfolding.utils.MapUtils: Utility and convenience methods for
simplifying map usage.
 parsing.ParseFeed: This method is to parse a GeoRSS feed corresponding to
earthquakes around the globe.
21
 processing.core.PApplet: PApplet class must be the superclass of an applet that is to
be embedded in a Web page or viewed by the Java Applet Viewer. The PApplet class
has two main methods namely the setup() and the draw() method.
 processing.core.PConstants: Numbers shared throughout processing.core.
An attempt is made to keep the constants as short/non-verbose as possible. For
instance, the constant is TIFF instead of FILE_TYPE_TIFF. We'll do this as long as
we can get away with it.
 processing.core.PGraphics: Main graphics and rendering context, as well as the base
API implementation for processing "core". Use this class if you need to draw into an
off-screen graphics buffer. A PGraphics object can be constructed with
the createGraphics() function. The beginDraw() and endDraw() methods are
necessary to set up the buffer and to finalize it. The fields and methods for this class
are extensive.
22
SRC FILES
A Java source file is a plain
text file containing Java source code
and having . java extension. The
. java extension means that the file is
the Java source file. Java
source code file contains source code
for a class, interface, enumeration, or
annotation type.
 EarthquakeCityMap.java:
public class EarthquakeCityMap extends PApplet {
...
}
 EarthquakeMarker.java:
public abstract class EarthquakeMarker extends CommonMarker implements
Comparable<EarthquakeMarker>
{
...
}
 CommonMarker.java:
public abstract class CommonMarker extends SimplePointMarker {
...
}
 CityMarker.java:
public class CityMarker extends CommonMarker {
...
}
 LandQuakeMarker.java:
Fig.8 SRC Files
23
public class LandQuakeMarker extends EarthquakeMarker {
...
}
 OceanQuakeMarker.java:
public class OceanQuakeMarker extends EarthquakeMarker {
...
}
 Extends: In Java, the extends keyword is used to indicate that the class which is being
defined is derived from the base class using inheritance. So basically, extends keyword
is used to extend the functionality of the parent class to the subclass. In Java, multiple
inheritances are not allowed due to ambiguity. Therefore, a class can extend only one
class to avoid ambiguity.
 Implements: In Java, the implements keyword is used to implement an interface. An
interface is a special type of class which implements a complete abstraction and only
contains abstract methods. To access the interface methods, the interface must be
“implemented” by another class with the implements keyword and the methods need
to be implemented in the class which is inheriting the properties of the interface. Since
an interface is not having the implementation of the methods, a class can implement
any number of interfaces at a time.
Fig.9 Extends vs Implements
24
Code
setup() Method:
public void setup() {
size(900, 700, OPENGL);
if (offline) {
map = new UnfoldingMap(this, 300, 50, 750, 650, new
MBTilesMapProvider(mbTilesString));
earthquakesURL = "2.5_week.atom";
}
else {
map = new UnfoldingMap(this, 300, 50, 650, 600, new
Google.GoogleMapProvider());
}
MapUtils.createDefaultEventDispatcher(this, map);
List<Feature> countries = GeoJSONReader.loadData(this, countryFile);
countryMarkers = MapUtils.createSimpleMarkers(countries);
List<Feature> cities = GeoJSONReader.loadData(this, cityFile);
cityMarkers = new ArrayList<Marker>();
for(Feature city : cities) {
cityMarkers.add(new CityMarker(city));
}
List<PointFeature> earthquakes = ParseFeed.parseEarthquake(this,
earthquakesURL);
quakeMarkers = new ArrayList<Marker>();
for(PointFeature feature : earthquakes) {
if(isLand(feature)) {
quakeMarkers.add(new LandQuakeMarker(feature));
}
else {
quakeMarkers.add(new OceanQuakeMarker(feature));
}
}
printQuakes();
int t = quakeMarkers.size();
25
sortAndPrint(t);
map.addMarkers(quakeMarkers);
map.addMarkers(cityMarkers);
}
 size (width, height):
Syntax size(width, height)
size(width, height, renderer)
Parameters width int: height of the display window in units of pixels
height int: height of the display window in units of pixels
Defines the dimension of the display window width and height in units of
pixels. In a program that has the setup() function, the size() function must be the first
line of code inside setup(), and the setup() function must appear in the code tab with
the same name as your sketch folder.
The built-in variables width and height are set by the parameters passed to this
function. For example, running size(640, 480) will assign 640 to the width variable
and 480 to the height variable. If size() is not used, the window will be given a default
size of 100 x 100 pixels.
The renderer parameter selects which rendering engine to use. For example, if
you will be drawing 3D shapes, use P3D. In addition to the default renderer, other
renderers are:
 P2D (Processing 2D): 2D graphics renderer that makes use of OpenGL-
compatible graphics hardware.
 P3D (Processing 3D): 3D graphics renderer that makes use of OpenGL-
compatible graphics hardware.
 map = new UnfoldingMap(this, 300, 50, 750, 650, new
MBTilesMapProvider(mbTilesString)) :
Parameters:
this – The main applet
26
300 – The x position of this map.
50 – The y position of this map.
750 – The width of this map.
650 – The height of this map.
MBTilesMapProvider(mbTilesString)) or Google.GoogleMapProvider()) – we
needed to specify when we're building a new unfolding map object is where
that unfolding map object learns about the map features, in particular, the
boundaries of continents for example, or countries, or any road data that we
want to display in our map. And in order to do that, Unfolding Maps has this
infrastructure of map providers,
 MapUtils.createDefaultEventDispatcher(this, map) :
Initializes default events, i.e. all given maps handle mouse and keyboard
interactions. No cross-listening between maps.
Parameters:
this - The PApplet needed for mouse and key user interactions.
map- one map
 MapUtils.createSimpleMarkers(countries):
Creates Unfolding's simple markers from features. (without the need to create
a MarkerFactory)
Parameters:
features - The features to get markers for.
Returns:
The EventDispatcher to use for additional event handling.
 GeoJSONReader.loadData(this, countryFile):
Parses a GeoJSON String and creates features for them.
Parameters:
this - The PApplet.
27
countryFile - The name of the GeoJSON file.
Returns:
A list of features.
draw() Method:
public void draw() {
background(150,150,150);
map.draw();
addKey();
}
 background(150,150,150): The background() function sets the color used for the
background of the Processing window. The default background is light gray. This
function is typically used within draw() to clear the display window at the beginning
of each frame, but it can be used inside setup() to set the background on the first frame
of animation or if the backgound need only be set once.
sortAndPrint() Method:
This method call from setup in EarthquakeCityMap. This method is used to sort the
earthquake magnitude in descending order and then print it.
private void sortAndPrint(int numToPrint) {
EarthquakeMarker[] markers=new
EarthquakeMarker[quakeMarkers.size()];
markers=quakeMarkers.toArray(markers);
List<Float> quakeMarkerList = new ArrayList<Float>();
Arrays.sort(markers);
for(int num=0;num<numToPrint;num++)
{
quakeMarkerList.add(markers[num].getMagnitude());
}
Collections.sort(quakeMarkerList);
Collections.reverse(quakeMarkerList);
System.out.println(quakeMarkerList.toString());
}
28
OUTPUT:
[5.9, 5.8, 5.7, 5.7, 5.6, 5.5, 5.4, 5.4, 5.3, 5.3, 5.3, 5.3, 5.3, 5.3, 5.3, 5.2,
5.2, 5.2, 5.2, 5.2, 5.2, 5.2, 5.2, 5.1, 5.1, 5.1, 5.1, 5.1, 5.0, 5.0, 5.0, 5.0,
5.0, 5.0, 4.9, 4.9, 4.9, 4.9, 4.9, 4.9, 4.9, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8,
4.8, 4.8, 4.8, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7,
4.6, 4.6, 4.6, 4.6, 4.6, 4.6, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5,
4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.3, 4.3, 4.3, 4.3, 4.3, 4.3, 4.3, 4.2,
4.2, 4.2, 4.2, 4.1, 4.1, 4.1, 4.1, 4.1, 4.1, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0,
3.9, 3.9, 3.9, 3.9, 3.8, 3.8, 3.8, 3.7, 3.7, 3.6, 3.6, 3.6, 3.5, 3.5, 3.5, 3.5,
3.5, 3.5, 3.5, 3.5, 3.5, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4,
3.4, 3.4, 3.4, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3,
3.3, 3.3, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2,
3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1,
3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1,
3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0,
3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9,
2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9,
2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.7, 2.7, 2.7,
2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7,
2.7, 2.7, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6,
2.6, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
2.5, 2.5, 2.5, 2.5, 2.5]
mouseMoved() Method: This method is use for clear the last selection.
public void mouseMoved()
{
if (lastSelected != null) {
lastSelected.setSelected(false);
lastSelected = null;
}
selectMarkerIfHover(quakeMarkers);
selectMarkerIfHover(cityMarkers);
}
selectMarkerIfHover() Method: This method is used when there is marker selected.
private void selectMarkerIfHover(List<Marker> markers)
{
if (lastSelected != null) {
return;
}
for (Marker m : markers)
{
CommonMarker marker = (CommonMarker)m;
if (marker.isInside(map, mouseX, mouseY)) {
29
lastSelected = marker;
marker.setSelected(true);
return;
}
}
}
mouseClicked() Method: The event handler for mouse clicks. It will display an
earthquake and its threat circle of cities or if a city is clicked, it will display all the earthquakes
where the city is in the threat circle.
public void mouseClicked()
{
if (lastClicked != null) {
unhideMarkers();
lastClicked = null;
}
else if (lastClicked == null)
{
checkEarthquakesForClick();
if (lastClicked == null) {
checkCitiesForClick();
}
}
}
checkCitiesForClick(): This is a helper method that will check if a city marker was
clicked on and respond appropriately. The city markers to see if one of them is selected and
hide all the other earthquakes.
private void checkCitiesForClick()
{
if (lastClicked != null) return;
for (Marker marker : cityMarkers) {
if (!marker.isHidden() && marker.isInside(map, mouseX,
mouseY)) {
lastClicked = (CommonMarker)marker;
for (Marker mhide : cityMarkers) {
if (mhide != lastClicked) {
mhide.setHidden(true);
}
}
for (Marker mhide : quakeMarkers) {
EarthquakeMarker quakeMarker =
(EarthquakeMarker)mhide;
30
if
(quakeMarker.getDistanceTo(marker.getLocation())
> quakeMarker.threatCircle()) {
quakeMarker.setHidden(true);
}
}
return;
}
}
}
checkEarthquakesForClick() Method: This is a helper method that will check if a
earthquake was clicked on and respond appropriately. The earthquake markers to see if one
of them is selected and hide all the other earthquakes.
private void checkEarthquakesForClick()
{
if (lastClicked != null) return;
for (Marker m : quakeMarkers) {
EarthquakeMarker marker = (EarthquakeMarker)m;
if (!marker.isHidden() && marker.isInside(map, mouseX,
mouseY)) {
lastClicked = marker;
for (Marker mhide : quakeMarkers) {
if (mhide != lastClicked) {
mhide.setHidden(true);
}
}
for (Marker mhide : cityMarkers) {
if (mhide.getDistanceTo(marker.getLocation())
> marker.threatCircle()) {
mhide.setHidden(true);
}
}
return;
}
}
}
unhideMarkers() Method: This is used to unhide all markers.
private void unhideMarkers() {
for(Marker marker : quakeMarkers) {
marker.setHidden(false);
}
31
for(Marker marker : cityMarkers) {
marker.setHidden(false);
}
}
isLand() Method: Checks whether this quake occurred on land. If it did, it sets the
"country" property of its PointFeature to the country where it occurred and returns true.
Otherwise it returns false.
private boolean isLand(PointFeature earthquake) {
for (Marker country : countryMarkers) {
if (isInCountry(earthquake, country)) {
return true;
}
}
return false;
}
addKey() Method: This is a helper method to draw key in GUI.
private void addKey() {
fill(255, 250, 240);
int xbase = 25;
int ybase = 50;
stroke(0,0,0);
rect(xbase, ybase, 250, 410);
stroke(250,235,215);
fill(245,255,250);
rect(xbase-10, ybase-10, 260, 420);
fill(0);
textAlign(LEFT, CENTER);
textSize(12);
text("Earthquake Key", xbase+25, ybase+25);
fill(255,0,255);
int tri_xbase = xbase + 35;
int tri_ybase = ybase + 50;
stroke(0,0,0);
triangle(tri_xbase, tri_ybase-5, tri_xbase-5, tri_ybase+5,
tri_xbase+5, tri_ybase+5);
fill(0, 0, 0);
textAlign(LEFT, CENTER);
text("City Marker", tri_xbase + 15, tri_ybase);
32
text("Land Quake", xbase+50, ybase+70);
text("Ocean Quake", xbase+50, ybase+90);
text("Size ~ Magnitude", xbase+25, ybase+130);
fill(255, 255, 255);
stroke(0,0,0);
ellipse(xbase+35, ybase+70, 10, 10);
stroke(0,0,0);
rect(xbase+35-5, ybase+90-5, 10, 10);
stroke(0,0,0);
fill(color(255, 255, 0));
ellipse(xbase+35, ybase+160, 12, 12);
stroke(0,0,0);
fill(color(0, 0, 255));
ellipse(xbase+35, ybase+180, 12, 12);
stroke(0,0,0);
fill(color(255, 0, 0));
ellipse(xbase+35, ybase+200, 12, 12);
textAlign(LEFT, CENTER);
fill(0, 0, 0);
text("Shallow", xbase+50, ybase+160);
text("Intermediate", xbase+50, ybase+180);
text("Deep", xbase+50, ybase+200);
text("Past hour", xbase+50, ybase+220);
fill(255, 255, 255);
int centerx = xbase+35;
int centery = ybase+220;
stroke(0,0,0);
ellipse(centerx, centery, 12, 12);
strokeWeight(2);
line(centerx-8, centery-8, centerx+8, centery+8);
line(centerx-8, centery+8, centerx+8, centery-8);
int t_xbase=xbase+35;
int t_ybase=ybase+260;
fill(250,0,250);
stroke(0,0,0);
triangle(t_xbase, t_ybase-5, t_xbase-5, t_ybase+5, t_xbase+5,
t_ybase+5);
fill(255,0,0);
stroke(255,0,0);
triangle(t_xbase, t_ybase-7, t_xbase-7, t_ybase+7, t_xbase+7,
t_ybase+7);
textAlign(LEFT, CENTER);
fill(0, 0, 0);
text("+20.0 Population (Million)", xbase+50, ybase+260);
text("+10.0 Population (Million)", xbase+50, ybase+280);
text("Below 10.0", xbase+50, ybase+300);
int t_xbas=xbase+35;
33
int t_ybas=ybase+280;
fill(250,0,250);
stroke(0,0,0);
triangle(t_xbas, t_ybas-5, t_xbas-5, t_ybas+5, t_xbas+5, t_ybas+5);
fill(0,255,255);
stroke(0,255,255);
triangle(t_xbas, t_ybas-7, t_xbas-7, t_ybas+7, t_xbas+7, t_ybas+7);
int t_xba=xbase+35;
int t_yba=ybase+300;
fill(250,0,250);
stroke(0,0,0);
triangle(t_xba, t_yba-5, t_xba-5, t_yba+5, t_xba+5, t_yba+5);
fill(0,255,0);
stroke(0,255,0);
triangle(t_xba, t_yba-7, t_xba-7, t_yba+7, t_xba+7, t_yba+7);
fill(255,255,255);
stroke(255,0,0);
ellipse(xbase+35, ybase+340, 12, 12);
stroke(34,139,34);
ellipse(xbase+35, ybase+360, 12, 12);
stroke(139,0,139);
ellipse(xbase+35, ybase+380, 12, 12);
textAlign(LEFT, CENTER);
fill(0, 0, 0);
text("+5.0 Magnitude", xbase+50, ybase+340);
text("+4.0 Magnitude", xbase+50, ybase+360);
text("Below 4.0", xbase+50, ybase+380);
stroke(255,250,240);
noFill();
rect(300, 50, 750, 650);
}
 fill(): Sets the color used to fill shapes.
 noFill(): Disables filling geometry. If both noStroke() and noFill() are called,
nothing will be drawn to the screen.
 triangle(): A triangle is a plane created by connecting three points. The first two
arguments specify the first point, the middle two arguments specify the second point,
and the last two arguments specify the third point.
 ellipse(): Draws an ellipse (oval) to the screen. An ellipse with equal width and
height is a circle. By default, the first two parameters set the location, and the third
34
and fourth parameters set the shape's width and height. The origin may be changed
with the ellipseMode() function.
 rect(): Draws a rectangle to the screen. A rectangle is a four-sided shape with every
angle at ninety degrees. By default, the first two parameters set the location of the
upper-left corner, the third sets the width, and the fourth sets the height. The way
these parameters are interpreted, however, may be changed with
the rectMode() function.
 stroke(): Sets the color used to draw lines and borders around shapes. This color is
either specified in terms of the RGB or HSB color depending on the
current colorMode(). The default color space is RGB, with each value in the range
from 0 to 255.
 color(): Creates colors for storing in variables of the color datatype. The parameters
are interpreted as RGB or HSB values depending on the current colorMode().
 textAlign(): Sets the current alignment for drawing text. The parameters LEFT,
CENTER, and RIGHT set the display characteristics of the letters in relation to the
values for the x and y parameters of the text() function.
 text(): Draws text to the screen. Displays the information specified in the first
parameter on the screen in the position specified by the additional parameters. A
default font will be used unless a font is set with the textFont() function and a default
size will be used unless a font is set with textSize(). Change the color of the text with
the fill() function. The text displays in relation to the textAlign() function, which
gives the option to draw to the left, right, and center of the coordinates.
 textSize(): Sets the current font size. This size will be used in all subsequent calls to
the text() function. Font size is measured in units of pixels.
printQuakes() Method: Prints countries with number of earthquakes through loop the
country markers or country features (either will work) and then for each country, loop through
35
the quakes to count how many occurred in that country. Recall that the country markers have
a "name" property, and LandQuakeMarkers have a "country" property set.
private void printQuakes() {
int totalWaterQuakes = quakeMarkers.size();
for (Marker country : countryMarkers) {
String countryName = country.getStringProperty("name");
int numQuakes = 0;
for (Marker marker : quakeMarkers)
{
EarthquakeMarker eqMarker = (EarthquakeMarker)marker;
if (eqMarker.isOnLand()) {
if
(countryName.equals(eqMarker.getStringProperty("country"))) {
numQuakes++;
}
}
}
if (numQuakes > 0) {
totalWaterQuakes -= numQuakes;
System.out.println(countryName + ": " + numQuakes);
}
}
System.out.println("OCEAN QUAKES: " + totalWaterQuakes);
}
OUTPUT:
36
isInCountry() Method: This is a helper method to test whether a given earthquake is in
a given country This will also add the country property to the properties of the earthquake
feature if it's in one of the countries.
private boolean isInCountry(PointFeature earthquake, Marker country) {
Location checkLoc = earthquake.getLocation();
if(country.getClass() == MultiMarker.class) {
for(Marker marker : ((MultiMarker)country).getMarkers()) {
if(((AbstractShapeMarker)marker).isInsideByLocation(checkLoc)) {
earthquake.addProperty("country",
country.getProperty("name"));
return true;
}
}
}
else if(((AbstractShapeMarker)country).isInsideByLocation(checkLoc))
{
earthquake.addProperty("country",
country.getProperty("name"));
return true;
}
return false;
}
37
OUTPUT
OFFLINE Mode:
If we are working offline, then set the value of this variable to true.
private static final boolean offline = true;
 When EarthquakeCityMap.java file run:
Fig.10 EarthquakeCityMap.java run
38
 When Zoom(2) then it look’s like:
 When zoom(3) then it look like :
Fig.11 Zoom(2) in Offline Mode
Fig.12 Zoom(3) in Offline Mode
39
 When cursor move on City Marker:
 When cursor move on Land Earthquake:
Fig.13 Cursor move on City Marker
Fig.14 Cursor move on Land Earthquake
40
 When mouse clicked on Land Earthquake then the city affected by that earthquake is
also shown:
 When mouse clicked on Ocean Earthquake then the city affected by that earthquake
is also shown:
Fig.15 Mouse clicked on Land Earthquake
Fig.16 Mouse clicked on Ocean Earthquake
41
 When we Click on City Marker then all Earthquake is shown which affected that
city:
 When zoom(5) then it shows clearly above Earthquake’s:
Fig.17 Click on City Marker
Fig.18 Zoom(5) in Offline Mode
42
ONLINE MODE:
When we working online then set the value of this variable to false.
private static final boolean offline = false;
 When EarthquakeCityMap.java file run:
Fig.19 EarthquakeCityMap.java file run
43
 When cursor move on Ocean Earthquake:
Fig.20 Cursor move on Ocean Earthquake
44
 When cursor move on CityMarker:
Fig.21 Cursor move on CityMarker
45
 When we Zoom in too much and Cursor move on CityMarker:
 When we Click on Ocean Earthquake:
Fig.22 Zoom in too much and Cursor move on
CityMarker
Fig.23 Click on Ocean Earthquake
46
Information Box:
Fig.24 Information Box
47
RESULT
This project was a part of the Java Object-Oriented Design of Data Structures
Specialization by UCSD on Coursera. This Specialization covers intermediate topics in
software development, including implementation of data structures and algorithms for
organizing large amounts of data in a way that is both efficient and easy to work with. The
project that was assigned was completed successfully.
User Stories:-
1. Users can obtain a graphical representation of how each earthquake compares to other
earthquakes along a certain parameter.
2. If the user clicks an earthquake marker, all cities that may be affected by this
earthquake are displayed; when the user clicks a city marker, all earthquakes that may
affect that city are displayed.
3. Popup information boxes about the earthquakes and cities are always drawn on top of
all other graphical information. Information boxes are contained within the map
content area.
48
CONCLUSION
It gives me immense pleasure to write that my summer training has completed
successfully online from Coursera. This report presented a complete overview of Basics of
Java Programming. I got this opportunity to create a Global Earthquake Monitor using Java.
I also understood and got the knowledge more about java language and its applications.
After completing this course from Coursera, I can say I have learnt about the basics of
OOPs. I learned using the different libraries of Java like, Unfolding Maps, Processing Library.
These Libraries were an essential part of my project on Global Earthquake Monitor as they
helped me Analyze and Visualize the data easily.
I have gained lots of knowledge and experience needed to be successful in great engineering
challenges.
49
REFERENCES
 https://www.coursera.org/specializations/object-oriented-programming
 https://www.coursera.org/learn/object-oriented-java/home/welcome
 https://processing.org/
 http://unfoldingmaps.org/javadoc/
 https://docs.oracle.com/javase/8/docs/api/java/util/
 https://processing.github.io/processing-
javadocs/core/index.html?processing/core/PApplet.html
 http://unfoldingmaps.org/javadoc/overview-summary.html
 https://en.wikipedia.org/wiki/Coursera
 https://www.coursera.org/
 https://www.coursera.org/learn/object-oriented-java/supplement/eZIfJ/a-note-about-
the-main-method
 https://www.oracle.com/java/technologies/javase-downloads.html
 https://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-
windows.html
 https://wiki.eclipse.org/Eclipse/Installation#Download_Eclipse
 https://www.eclipse.org/downloads/

More Related Content

What's hot

Autonomous drone project part 1
Autonomous drone project part 1Autonomous drone project part 1
Autonomous drone project part 1
ABIN VARGHESE
 
Quadcopter 140410021020-phpapp02
Quadcopter 140410021020-phpapp02Quadcopter 140410021020-phpapp02
Quadcopter 140410021020-phpapp02
Prasanth Reddy
 
8 sem final report print copy (1)
8 sem final report print copy (1)8 sem final report print copy (1)
8 sem final report print copy (1)
Jha Bhargav
 
Density based traffic light control
Density based traffic light controlDensity based traffic light control
Density based traffic light control
Rohit Nair
 
Density Based Traffic signal system using microcontroller
Density Based Traffic signal system using microcontrollerDensity Based Traffic signal system using microcontroller
Density Based Traffic signal system using microcontroller
krity kumari
 
Advanced vehicle security system 2016 upload
Advanced vehicle security system 2016 uploadAdvanced vehicle security system 2016 upload
Advanced vehicle security system 2016 upload
Nishanth C
 
Android Based Application Project Report.
Android Based Application Project Report. Android Based Application Project Report.
Android Based Application Project Report.
Abu Kaisar
 
Halstead's software science - ananalytical technique
Halstead's software science - ananalytical techniqueHalstead's software science - ananalytical technique
Halstead's software science - ananalytical technique
Vishnupriya T H
 
Function Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. MohiteFunction Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. Mohite
Zeal Education Society, Pune
 
Tic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max AlgorithmTic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max Algorithm
Ujjawal Poudel
 
Bitcoin Price Prediction Using LSTM
Bitcoin Price Prediction Using LSTMBitcoin Price Prediction Using LSTM
Bitcoin Price Prediction Using LSTM
IRJET Journal
 
Android Sos app development report
Android Sos app development reportAndroid Sos app development report
Android Sos app development report
Sudhanshu kumar Sah
 
A Cloud-Based Smart-Parking System Based on Internet-of-Things Technologies
A Cloud-Based Smart-Parking System Based on Internet-of-Things TechnologiesA Cloud-Based Smart-Parking System Based on Internet-of-Things Technologies
A Cloud-Based Smart-Parking System Based on Internet-of-Things Technologies
Kamal Spring
 
Software engineering process
Software engineering processSoftware engineering process
Software engineering process
KanchanPatil34
 
Defect removal effectiveness
Defect removal effectivenessDefect removal effectiveness
Defect removal effectiveness
Roy Antony Arnold G
 
IRJET- Road Accident Prediction using Machine Learning Algorithm
IRJET- Road Accident Prediction using Machine Learning AlgorithmIRJET- Road Accident Prediction using Machine Learning Algorithm
IRJET- Road Accident Prediction using Machine Learning Algorithm
IRJET Journal
 
Driverless car
Driverless carDriverless car
Driverless car
zahoor shah
 
software failures
 software failures software failures
software failures
Respa Peter
 
Smart car parking system
Smart car parking systemSmart car parking system
Smart car parking system
JHALAKNIHALANI
 

What's hot (20)

Autonomous drone project part 1
Autonomous drone project part 1Autonomous drone project part 1
Autonomous drone project part 1
 
Quadcopter 140410021020-phpapp02
Quadcopter 140410021020-phpapp02Quadcopter 140410021020-phpapp02
Quadcopter 140410021020-phpapp02
 
8 sem final report print copy (1)
8 sem final report print copy (1)8 sem final report print copy (1)
8 sem final report print copy (1)
 
Density based traffic light control
Density based traffic light controlDensity based traffic light control
Density based traffic light control
 
Density Based Traffic signal system using microcontroller
Density Based Traffic signal system using microcontrollerDensity Based Traffic signal system using microcontroller
Density Based Traffic signal system using microcontroller
 
Advanced vehicle security system 2016 upload
Advanced vehicle security system 2016 uploadAdvanced vehicle security system 2016 upload
Advanced vehicle security system 2016 upload
 
Android Based Application Project Report.
Android Based Application Project Report. Android Based Application Project Report.
Android Based Application Project Report.
 
Halstead's software science - ananalytical technique
Halstead's software science - ananalytical techniqueHalstead's software science - ananalytical technique
Halstead's software science - ananalytical technique
 
Function Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. MohiteFunction Point Analysis (FPA) by Dr. B. J. Mohite
Function Point Analysis (FPA) by Dr. B. J. Mohite
 
Tic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max AlgorithmTic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max Algorithm
 
Bitcoin Price Prediction Using LSTM
Bitcoin Price Prediction Using LSTMBitcoin Price Prediction Using LSTM
Bitcoin Price Prediction Using LSTM
 
Android Sos app development report
Android Sos app development reportAndroid Sos app development report
Android Sos app development report
 
A Cloud-Based Smart-Parking System Based on Internet-of-Things Technologies
A Cloud-Based Smart-Parking System Based on Internet-of-Things TechnologiesA Cloud-Based Smart-Parking System Based on Internet-of-Things Technologies
A Cloud-Based Smart-Parking System Based on Internet-of-Things Technologies
 
Software engineering process
Software engineering processSoftware engineering process
Software engineering process
 
Defect removal effectiveness
Defect removal effectivenessDefect removal effectiveness
Defect removal effectiveness
 
IRJET- Road Accident Prediction using Machine Learning Algorithm
IRJET- Road Accident Prediction using Machine Learning AlgorithmIRJET- Road Accident Prediction using Machine Learning Algorithm
IRJET- Road Accident Prediction using Machine Learning Algorithm
 
Driverless car
Driverless carDriverless car
Driverless car
 
Incremental model
Incremental modelIncremental model
Incremental model
 
software failures
 software failures software failures
software failures
 
Smart car parking system
Smart car parking systemSmart car parking system
Smart car parking system
 

Similar to Global Earthquake Monitor (Real Time)

NEW BACKEND.pdf
NEW BACKEND.pdfNEW BACKEND.pdf
NEW BACKEND.pdf
Shreejit Jadhav
 
F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)
F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)
F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)Tomáš Milata
 
Java Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage EssayJava Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage Essay
Liz Sims
 
_OOP with JAVA Solution Manual (1).pdf
_OOP with JAVA Solution Manual (1).pdf_OOP with JAVA Solution Manual (1).pdf
_OOP with JAVA Solution Manual (1).pdf
vanithagp1
 
Vikeshp
VikeshpVikeshp
Vikeshp
MdAsu1
 
City search documentation
City search documentationCity search documentation
City search documentationRajesh Varanasi
 
City search documentation
City search documentationCity search documentation
City search documentationRajesh Varanasi
 
A Java-Based System For Building Animated Presentations Over The Web
A Java-Based System For Building Animated Presentations Over The WebA Java-Based System For Building Animated Presentations Over The Web
A Java-Based System For Building Animated Presentations Over The Web
Scott Faria
 
hem.pdf
hem.pdfhem.pdf
hem.pdf
GeethMayaa
 
Library Managemnet System
Library Managemnet SystemLibrary Managemnet System
Library Managemnet System
Abhishek Shakya
 
Minor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure VisualizerMinor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure Visualizer
RonitShrivastava057
 
Java presentation
Java presentationJava presentation
Java presentation
Karan Sareen
 
Ball Collecting game report
Ball Collecting game report Ball Collecting game report
Ball Collecting game report
Dileep Maurya
 
Industrial training report on core java
Industrial training report on core java Industrial training report on core java
Industrial training report on core java
Nitesh Dubey
 
6-wall CAVE Immersive 3D Visualization Laboratory Demonstrator
6-wall CAVE Immersive 3D Visualization Laboratory Demonstrator6-wall CAVE Immersive 3D Visualization Laboratory Demonstrator
6-wall CAVE Immersive 3D Visualization Laboratory DemonstratorJan Klimczak
 
java
javajava
Java report by ravi raja
Java report by ravi rajaJava report by ravi raja
Java report by ravi raja
RaviRaja55
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Pratima Parida
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Pratima Parida
 

Similar to Global Earthquake Monitor (Real Time) (20)

NEW BACKEND.pdf
NEW BACKEND.pdfNEW BACKEND.pdf
NEW BACKEND.pdf
 
F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)
F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)
F3-DP-2015-Milata-Tomas-java-ee-batch-editor (1)
 
Java Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage EssayJava Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage Essay
 
_OOP with JAVA Solution Manual (1).pdf
_OOP with JAVA Solution Manual (1).pdf_OOP with JAVA Solution Manual (1).pdf
_OOP with JAVA Solution Manual (1).pdf
 
Vikeshp
VikeshpVikeshp
Vikeshp
 
City search documentation
City search documentationCity search documentation
City search documentation
 
City search documentation
City search documentationCity search documentation
City search documentation
 
A Java-Based System For Building Animated Presentations Over The Web
A Java-Based System For Building Animated Presentations Over The WebA Java-Based System For Building Animated Presentations Over The Web
A Java-Based System For Building Animated Presentations Over The Web
 
hem.pdf
hem.pdfhem.pdf
hem.pdf
 
Library Managemnet System
Library Managemnet SystemLibrary Managemnet System
Library Managemnet System
 
gopal hp
gopal hpgopal hp
gopal hp
 
Minor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure VisualizerMinor Project Synopsis on Data Structure Visualizer
Minor Project Synopsis on Data Structure Visualizer
 
Java presentation
Java presentationJava presentation
Java presentation
 
Ball Collecting game report
Ball Collecting game report Ball Collecting game report
Ball Collecting game report
 
Industrial training report on core java
Industrial training report on core java Industrial training report on core java
Industrial training report on core java
 
6-wall CAVE Immersive 3D Visualization Laboratory Demonstrator
6-wall CAVE Immersive 3D Visualization Laboratory Demonstrator6-wall CAVE Immersive 3D Visualization Laboratory Demonstrator
6-wall CAVE Immersive 3D Visualization Laboratory Demonstrator
 
java
javajava
java
 
Java report by ravi raja
Java report by ravi rajaJava report by ravi raja
Java report by ravi raja
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 

More from HimanshiSingh71

RFID Technology - Electronics and Communication Seminar Topic
RFID Technology - Electronics and Communication Seminar TopicRFID Technology - Electronics and Communication Seminar Topic
RFID Technology - Electronics and Communication Seminar Topic
HimanshiSingh71
 
Automatic Car Number Plate Detection and Recognition using MATLAB
Automatic Car Number Plate Detection and Recognition using MATLABAutomatic Car Number Plate Detection and Recognition using MATLAB
Automatic Car Number Plate Detection and Recognition using MATLAB
HimanshiSingh71
 
Object Oriented Programming in Java
Object Oriented Programming in JavaObject Oriented Programming in Java
Object Oriented Programming in Java
HimanshiSingh71
 
E1 LINK IS EUROPEAN FORMAT
E1 LINK IS EUROPEAN FORMAT E1 LINK IS EUROPEAN FORMAT
E1 LINK IS EUROPEAN FORMAT
HimanshiSingh71
 
Training Report BHARAT ELECTRONICS LIMITED
Training Report BHARAT ELECTRONICS LIMITEDTraining Report BHARAT ELECTRONICS LIMITED
Training Report BHARAT ELECTRONICS LIMITED
HimanshiSingh71
 
Java Based Case Study program Solved Question
Java Based Case Study program Solved QuestionJava Based Case Study program Solved Question
Java Based Case Study program Solved Question
HimanshiSingh71
 
JAVA Program in NetBeans
JAVA Program in NetBeansJAVA Program in NetBeans
JAVA Program in NetBeans
HimanshiSingh71
 
One table MySQL queries
One table MySQL queriesOne table MySQL queries
One table MySQL queries
HimanshiSingh71
 
Mysql two table queries
Mysql two table queriesMysql two table queries
Mysql two table queries
HimanshiSingh71
 
JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)
HimanshiSingh71
 
Child Labour in India
Child Labour in India Child Labour in India
Child Labour in India
HimanshiSingh71
 
Airline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEAirline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDE
HimanshiSingh71
 
Automatic street light using LDR and Transistor
Automatic street light using LDR  and TransistorAutomatic street light using LDR  and Transistor
Automatic street light using LDR and Transistor
HimanshiSingh71
 

More from HimanshiSingh71 (13)

RFID Technology - Electronics and Communication Seminar Topic
RFID Technology - Electronics and Communication Seminar TopicRFID Technology - Electronics and Communication Seminar Topic
RFID Technology - Electronics and Communication Seminar Topic
 
Automatic Car Number Plate Detection and Recognition using MATLAB
Automatic Car Number Plate Detection and Recognition using MATLABAutomatic Car Number Plate Detection and Recognition using MATLAB
Automatic Car Number Plate Detection and Recognition using MATLAB
 
Object Oriented Programming in Java
Object Oriented Programming in JavaObject Oriented Programming in Java
Object Oriented Programming in Java
 
E1 LINK IS EUROPEAN FORMAT
E1 LINK IS EUROPEAN FORMAT E1 LINK IS EUROPEAN FORMAT
E1 LINK IS EUROPEAN FORMAT
 
Training Report BHARAT ELECTRONICS LIMITED
Training Report BHARAT ELECTRONICS LIMITEDTraining Report BHARAT ELECTRONICS LIMITED
Training Report BHARAT ELECTRONICS LIMITED
 
Java Based Case Study program Solved Question
Java Based Case Study program Solved QuestionJava Based Case Study program Solved Question
Java Based Case Study program Solved Question
 
JAVA Program in NetBeans
JAVA Program in NetBeansJAVA Program in NetBeans
JAVA Program in NetBeans
 
One table MySQL queries
One table MySQL queriesOne table MySQL queries
One table MySQL queries
 
Mysql two table queries
Mysql two table queriesMysql two table queries
Mysql two table queries
 
JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)
 
Child Labour in India
Child Labour in India Child Labour in India
Child Labour in India
 
Airline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDEAirline reservation project using JAVA in NetBeans IDE
Airline reservation project using JAVA in NetBeans IDE
 
Automatic street light using LDR and Transistor
Automatic street light using LDR  and TransistorAutomatic street light using LDR  and Transistor
Automatic street light using LDR and Transistor
 

Recently uploaded

DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 

Recently uploaded (20)

DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 

Global Earthquake Monitor (Real Time)

  • 1. GLOBAL EARTHQUAKE MONITOR A Report submitted in partial fulfilment of the requirement for the award of degree of Bachelor of Technology In Electronics and Communication Engineering Submitted By HIMANSHI (02215002817) MAHARAJA SURAJMAL INSTITUTE OF TECHNOLOGY C-4, Janakpuri, New Delhi-58 Affiliated to Guru Gobind Singh Indraprastha University, Delhi June, 2020
  • 2. 2
  • 3. 3 CANDIDATE’S DECLARATION I, Himanshi, Roll No. 02215002817, B.Tech (Semester- 7th) of the Maharaja Surajmal Institute of Technology, New Delhi hereby declare that the Training Report entitled “Object-Oriented Programming in Java” is an original work and data provided in the study is authentic to the best of my knowledge. This report has not been submitted to any other Institute for the award of any other degree. Name of Student: Himanshi (Roll No. 02215002817)
  • 4. 4 ACKNOWLEDGEMENT A research work owes its success from commencement to completion, to the people in love with researchers at various stages. Let me in this page express my gratitude to all those who helped us in various stage of this study. First, I would like to express my sincere gratitude indebtedness to Mr. Puneet Azad (HOD, Department of Information Technology, Maharaja Surajmal Institute of Technology, New Delhi) for allowing me to undergo the summer training of 6 weeks with Coursera. I am grateful to my guide Ms. Mia Minnes, Ms. Christine Alvarado, and Mr. Leo Porter, for the help provided in completion of the project, which was assigned to me. Without his friendly help and guidance it was difficult to develop this project. Last but not least, I pay my sincere thanks and gratitude to all the staff at courser for their support and for making my training valuable and fruitful. Submitted By: HIMANSHI
  • 5. 5 Table of Contents Acknowledgements 4 List of Figures 7 Chapter 1. About the Coursera …………………………………………. 8 Chapter 2. About the Course …………………………………………. 8 Chapter 3. Project Details ………………………………………… 9 3.1 Overview ……………………………………………………...…. 9 3.2 Software ....……………………………………………………… 9 3.3 Language ………………………………………………………… 9 3.4 Libraries ………………………………………………………… 9 3.5 Java ………………………………………………………………… 10 3.6 Unfolding Maps ………………………………………………… 10 3.7 Processing Library ………………………………………………… 11 3.8 Object Oriented Programming ………………………………… 12 3.9 Class PApplet ………………………………………………... 13 3.10 Class SimplePointMarker ………………………………………… 13 Chapter 4. Data Files ………………………………………………... 14 Chapter 5. Libraries ………………………………………………… 18 Chapter 6. SRC Files ………………………………………………… 22 Chapter 7. Code ………………………………………………………… 24 7.1 setUp() Method ………………………………………………… 24 7.2 draw() Method ………………………………………………… 27 7.3 sortAndPrint() Method ………………………………………… 27 7.4 mouseMoved() Method ………………………………………… 28 7.5 selectMarkerIfHover() Method ……………………………….. 28 7.6 mouseClicked() Method ………………………………………. 29 7.7 checkCitiesForClick() ………………………………………… 29 7.8 checkEarthquakesForClick() Method ……………………………. 30
  • 6. 6 7.9 unhideMarkers() Method ………………………………………… 30 7.10 isLand() method ………………………………………… 31 7.11 addKey() Method ………………………………………… 31 7.12 printQuakesMethod ………………………………………… 34 7.13 isInCountry() method ………………………………………… 36 Chapter 8. Output ………………………………………………………… 37 8.1 Offline Mode ………………………………………………… 37 8.2 Online Mode ………………………………………………… 42 8.3 Information Box ………………………………………………… 46 Chapter 9. Result ………………………………………………………… 47 Chapter 10. Conclusion ………………………………………………… 48 Chapter 11. References ………………………………………………… 49
  • 7. 7 List Of Figures Figure 1 Coursera Logo ...………………………………….…………. 8 Figure 2 Live Earthquake data feed from http://earthquake.usgs.gov/ …… 14 Figure 3 city-data.json ………………………………………………. 15 Figure 4 blankLight-1-3.mbtiles ………………………………………. 16 Figure 5 countries.geo.json ………………………………………………. 16 Figure 6 2.5_week.atom ………………………………………………. 17 Figure 7 Libraries ………………………………………………………. 18 Figure 8 SRC Files ………………………………………………………. 22 Figure 9 Extends vs Implements ………………………………………. 23 Figure 10 EarthquakeCityMap.java run ……………………………….. 37 Figure 11 Zoom(2) in Offline Mode ……………………………………….. 38 Figure 12 Zoom(3) in Offline Mode ……………………………………….. 38 Figure 13 Cursor move on City Marker ……………………………….. 39 Figure 14 Cursor move on Land Earthquake ……………………………….. 39 Figure 15 Mouse clicked on Land Earthquake ……………………….. 40 Figure 16 Mouse clicked on Ocean Earthquake ……………………….. 40 Figure 17 Click on City Marker ……………………………………….. 41 Figure 18 Zoom(5) in Offline Mode ………………………………………... 41 Figure 19 EarthquakeCityMap.java file run ………………………………… 42 Figure 20 Cursor move on Ocean Earthquake ………………………... 43 Figure 21 Cursor move on CityMarker ………………………………… 44 Figure 22 Zoom in too much and Cursor move on ………………………… 45 Figure 23 Click on Ocean Earthquake ………………………………… 45 Figure 24 Information Box …………………………………………………. 46
  • 8. 8 ABOUT THE COURSERA Coursera (/kərˈsɛrə/) is an American massive open online course (MOOC) provider founded in 2012 by Stanford University's computer science professors Andrew Ng and Daphne Koller that offers massive open online courses (MOOC), specializations, degrees, professional and mastertrack courses. Coursera works with universities and other organizations to offer online courses, certifications, and degrees in a variety of subjects, such as engineering, data science, machine learning, mathematics, business, financing, computer science, digital marketing, humanities, medicine, biology, social sciences, 3000 plus variety of courses giving students a very broad range of information & experience in different fields. ABOUT THE COURSE Object Oriented Programming in Java:  Object design: constructors, instance variables, methods  Memory models and Scope  Creating GUIs using PApplet  Unfolding Maps  Inheritance and Polymorphism  Event-Driven Programming  Searching: Linear Search & Binary Search  Sorting: Insertion Sort & Selection Sort Fig.1 Coursera Logo
  • 9. 9 PROJECT DETAILS OVERVIEW: This project was a part of the Java Object-Oriented Design of Data Structures. An interactive application with a Graphical User Interface (GUI). Displays a world map with Earthquake data. This interactive map uses a live RSS feed from the U.S. Geological Survey to show the location, magnitude, and potential impact of earthquakes around the world. It contains:  Object Oriented Programming principles like Encapsulation, Inheritance, Polymorphism and Abstraction.  Event Driven Programming  Searching and Sorting techniques for data to be displayed. SOFTWARE:  ECLIPSE IDE  JAVA PLATFORM (JDK) 8u60 LANGUAGE:  Java LIBRARIES:  Unfolding Maps  Processing Library
  • 10. 10 JAVA: Java is a class-based, Object-Oriented Programming Language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let application developers Write Once, Run Anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java Virtual Machine (JVM) regardless of the underlying computer architecture. UNFOLDING MAPS: Unfolding is a library to create interactive maps and geo visualizations in Processing and Java. The main purpose of using unfolding is to create not only static maps but also interactive maps in both java and processing. It can easily be installed on eclipse by downloading the unfolding template from the official website. It is widely used due to the features provided by unfolding like: 1. Interaction Events: In unfolding, we can easily create interactive maps. The basic interactions like zoom and pan are included in this library. 2. Data Visualization: This library is very robust that it even lets users create geo- positioned markers to display the data on a map. This visual style can be freely adapted. This library also supports users to load and display user-defined shapes like points, lines or polygons. 3. Styled Maps: This library is a title-based map library. This library allows map titles to have various geographic features and styles. 4. Clean & Extendable Code: This library allows the beginners to easily create simple maps. Advanced users can also sketch their prototypes or create their own sophisticated visualizations.
  • 11. 11 PROCESSING LIBRARY: Processing is an open-source low level animation and GUI library built on Java with additional simplifications like additional classes, aliased mathematical functions and operations. It also provides a GUI for simple compilation of the programs written in processing. Features of Processing: The following are the features of processing:  It includes a sketchbook which is a minimalistic alternative to an IDE. This sketchbook can be used as a normal IDE to organize projects.  Every sketch drawn in processing is a subclass of the Java class (PApplet). This class implements almost all the features of processing.  Since processing inherits the properties of the class, all the additional classes defined in the sketch will be treated as an inner class when the code is being converted into a pure java code before compiling. Therefore, the use of static variables and methods is strictly prohibited in processing.  The processing language also gives the users an option to create own classes in the PApplet sketch. Therefore, this gives the users a chance to use a more complex data structures apart from the basic data types in java.
  • 12. 12 Object Oriented Programming: Object-Oriented Programming or OOPs refers to languages that uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc. in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function. Main OOPs Concepts:  POLYMORPHISM: Polymorphism refers to the ability of OOPs programming languages to differentiate between entities with the same name efficiently. This is done by Java with the help of the signature and declaration of these entities.  INHERITANCE: Inheritance is an important pillar of OOP (Object Oriented Programming). It is the mechanism in java by which one class is allow to inherit the features (fields and methods) of another class.  ENCAPSULATION: Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. Another way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield.  ABSTRACTION: Data Abstraction is the property by virtue of which only the essential details are displayed to the user. The trivial or the non-essentials units are not displayed to the user. Ex: A car is viewed as a car rather than its individual components. Data Abstraction may also be defined as the process of identifying only the required characteristics of an object ignoring the irrelevant details.
  • 13. 13 CLASS PApplet: java.lang.Object processing.core.PApplet The processing library in Java has a class called PApplet which is used in Making Graphical User Interface (GUI).  The PApplet class must be the superclass of an applet that is to be embedded in a Web page or viewed by the Java Applet Viewer.  The PApplet class has two main methods namely the setup() and the draw() method.  Using PApplet class we can create user-friendly GUI apps, which means the application is user interactive, they have icons, sliders, we can click, drag, drop and play with the app window.  The setup method is run once whereas the draw function will run repeatedly drawing the image on the canvas. Base class for all sketches that use processing.core. import processing.core.PApplet; CLASS SimplePointMarker: java.lang.Object de.fhpotsdam.unfolding.marker.AbstractMarker de.fhpotsdam.unfolding.marker.SimplePointMarker Marker representing a single location. Use directly to display as simple circle, or extend it for custom styles.
  • 16. 16  blankLight-1-3.mbtiles  countries.geo.json Fig.4 blankLight-1-3.mbtiles Fig.5 countries.geo.json
  • 18. 18 LIBRARIES A Java library contains code which you can access and use in your Java project. The deployment format of a Java library is a JAR file.  java.util.ArrayList: Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is used internally to store the list.  java.util.Arrays: This class contains various methods for manipulating arrays (such as sorting and searching). This class also contains a static factory that allows arrays to be viewed as lists. Fig.7 Libraries / Header Files
  • 19. 19 The methods in this class all throw a NullPointerException, if the specified array reference is null, except where noted.  java.util.Collections: This class consists exclusively of static methods that operate on or return collections. It contains polymorphic algorithms that operate on collections, "wrappers", which return a new collection backed by a specified collection, and a few other odds and ends. The methods of this class all throw a NullPointerException if the collections or class objects provided to them are null.  java.util.List: An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list. Unlike sets, lists typically allow duplicate elements. More formally, lists typically allow pairs of elements e1 and e2 such that e1.equals(e2).  de.fhpotsdam.unfolding.UnfoldingMap: An interactive map. Uses the MapDisplay, and handles hit test, active status, as well as all interactions such as panning, zooming, and rotating (with or without tweening). Acts as facade for the map interactions, e.g. using innerScale for zooming, and outerRotate for rotating.  de.fhpotsdam.unfolding.data.Feature: A feature stores one or more locations, its type, and additional data properties.  de.fhpotsdam.unfolding.data.GeoJSONReader: Reads GeoJSON files and creates Features.  de.fhpotsdam.unfolding.data.PointFeature: Stores a single location.
  • 20. 20  de.fhpotsdam.unfolding.geo.Location: The Location represents a geo location defined by latitude and longitude.  de.fhpotsdam.unfolding.marker.AbstractShapeMarker: Abstract marker representing multiple locations and can be implemented as lines, polygons, or other shapes. Handles multiple locations, and implements the main marker methods for handling those properly.  de.fhpotsdam.unfolding.marker.Marker: Displays visual representations of geo- spatial locations using Marker and MarkerManager. Marker interface for all markers to be drawn on to maps.  de.fhpotsdam.unfolding.marker.MultiMarker: A MultiMarker enables handling of multiple, logically grouped markers. Properties and display states are the same for all its markers. A MultiMarker can consist of various sub-markers, even of different types. For instance, a MultiMarker could have three polygon marker and one point marker.  de.fhpotsdam.unfolding.providers.MBTilesMapProvider: MapProvider for local MBTiles. de.fhpotsdam.unfolding.providers.AbstractMapProvider de.fhpotsdam.unfolding.providers.AbstractMapTileProvider de.fhpotsdam.unfolding.providers.MBTilesMapProvider  de.fhpotsdam.unfolding.utils.MapUtils: Utility and convenience methods for simplifying map usage.  parsing.ParseFeed: This method is to parse a GeoRSS feed corresponding to earthquakes around the globe.
  • 21. 21  processing.core.PApplet: PApplet class must be the superclass of an applet that is to be embedded in a Web page or viewed by the Java Applet Viewer. The PApplet class has two main methods namely the setup() and the draw() method.  processing.core.PConstants: Numbers shared throughout processing.core. An attempt is made to keep the constants as short/non-verbose as possible. For instance, the constant is TIFF instead of FILE_TYPE_TIFF. We'll do this as long as we can get away with it.  processing.core.PGraphics: Main graphics and rendering context, as well as the base API implementation for processing "core". Use this class if you need to draw into an off-screen graphics buffer. A PGraphics object can be constructed with the createGraphics() function. The beginDraw() and endDraw() methods are necessary to set up the buffer and to finalize it. The fields and methods for this class are extensive.
  • 22. 22 SRC FILES A Java source file is a plain text file containing Java source code and having . java extension. The . java extension means that the file is the Java source file. Java source code file contains source code for a class, interface, enumeration, or annotation type.  EarthquakeCityMap.java: public class EarthquakeCityMap extends PApplet { ... }  EarthquakeMarker.java: public abstract class EarthquakeMarker extends CommonMarker implements Comparable<EarthquakeMarker> { ... }  CommonMarker.java: public abstract class CommonMarker extends SimplePointMarker { ... }  CityMarker.java: public class CityMarker extends CommonMarker { ... }  LandQuakeMarker.java: Fig.8 SRC Files
  • 23. 23 public class LandQuakeMarker extends EarthquakeMarker { ... }  OceanQuakeMarker.java: public class OceanQuakeMarker extends EarthquakeMarker { ... }  Extends: In Java, the extends keyword is used to indicate that the class which is being defined is derived from the base class using inheritance. So basically, extends keyword is used to extend the functionality of the parent class to the subclass. In Java, multiple inheritances are not allowed due to ambiguity. Therefore, a class can extend only one class to avoid ambiguity.  Implements: In Java, the implements keyword is used to implement an interface. An interface is a special type of class which implements a complete abstraction and only contains abstract methods. To access the interface methods, the interface must be “implemented” by another class with the implements keyword and the methods need to be implemented in the class which is inheriting the properties of the interface. Since an interface is not having the implementation of the methods, a class can implement any number of interfaces at a time. Fig.9 Extends vs Implements
  • 24. 24 Code setup() Method: public void setup() { size(900, 700, OPENGL); if (offline) { map = new UnfoldingMap(this, 300, 50, 750, 650, new MBTilesMapProvider(mbTilesString)); earthquakesURL = "2.5_week.atom"; } else { map = new UnfoldingMap(this, 300, 50, 650, 600, new Google.GoogleMapProvider()); } MapUtils.createDefaultEventDispatcher(this, map); List<Feature> countries = GeoJSONReader.loadData(this, countryFile); countryMarkers = MapUtils.createSimpleMarkers(countries); List<Feature> cities = GeoJSONReader.loadData(this, cityFile); cityMarkers = new ArrayList<Marker>(); for(Feature city : cities) { cityMarkers.add(new CityMarker(city)); } List<PointFeature> earthquakes = ParseFeed.parseEarthquake(this, earthquakesURL); quakeMarkers = new ArrayList<Marker>(); for(PointFeature feature : earthquakes) { if(isLand(feature)) { quakeMarkers.add(new LandQuakeMarker(feature)); } else { quakeMarkers.add(new OceanQuakeMarker(feature)); } } printQuakes(); int t = quakeMarkers.size();
  • 25. 25 sortAndPrint(t); map.addMarkers(quakeMarkers); map.addMarkers(cityMarkers); }  size (width, height): Syntax size(width, height) size(width, height, renderer) Parameters width int: height of the display window in units of pixels height int: height of the display window in units of pixels Defines the dimension of the display window width and height in units of pixels. In a program that has the setup() function, the size() function must be the first line of code inside setup(), and the setup() function must appear in the code tab with the same name as your sketch folder. The built-in variables width and height are set by the parameters passed to this function. For example, running size(640, 480) will assign 640 to the width variable and 480 to the height variable. If size() is not used, the window will be given a default size of 100 x 100 pixels. The renderer parameter selects which rendering engine to use. For example, if you will be drawing 3D shapes, use P3D. In addition to the default renderer, other renderers are:  P2D (Processing 2D): 2D graphics renderer that makes use of OpenGL- compatible graphics hardware.  P3D (Processing 3D): 3D graphics renderer that makes use of OpenGL- compatible graphics hardware.  map = new UnfoldingMap(this, 300, 50, 750, 650, new MBTilesMapProvider(mbTilesString)) : Parameters: this – The main applet
  • 26. 26 300 – The x position of this map. 50 – The y position of this map. 750 – The width of this map. 650 – The height of this map. MBTilesMapProvider(mbTilesString)) or Google.GoogleMapProvider()) – we needed to specify when we're building a new unfolding map object is where that unfolding map object learns about the map features, in particular, the boundaries of continents for example, or countries, or any road data that we want to display in our map. And in order to do that, Unfolding Maps has this infrastructure of map providers,  MapUtils.createDefaultEventDispatcher(this, map) : Initializes default events, i.e. all given maps handle mouse and keyboard interactions. No cross-listening between maps. Parameters: this - The PApplet needed for mouse and key user interactions. map- one map  MapUtils.createSimpleMarkers(countries): Creates Unfolding's simple markers from features. (without the need to create a MarkerFactory) Parameters: features - The features to get markers for. Returns: The EventDispatcher to use for additional event handling.  GeoJSONReader.loadData(this, countryFile): Parses a GeoJSON String and creates features for them. Parameters: this - The PApplet.
  • 27. 27 countryFile - The name of the GeoJSON file. Returns: A list of features. draw() Method: public void draw() { background(150,150,150); map.draw(); addKey(); }  background(150,150,150): The background() function sets the color used for the background of the Processing window. The default background is light gray. This function is typically used within draw() to clear the display window at the beginning of each frame, but it can be used inside setup() to set the background on the first frame of animation or if the backgound need only be set once. sortAndPrint() Method: This method call from setup in EarthquakeCityMap. This method is used to sort the earthquake magnitude in descending order and then print it. private void sortAndPrint(int numToPrint) { EarthquakeMarker[] markers=new EarthquakeMarker[quakeMarkers.size()]; markers=quakeMarkers.toArray(markers); List<Float> quakeMarkerList = new ArrayList<Float>(); Arrays.sort(markers); for(int num=0;num<numToPrint;num++) { quakeMarkerList.add(markers[num].getMagnitude()); } Collections.sort(quakeMarkerList); Collections.reverse(quakeMarkerList); System.out.println(quakeMarkerList.toString()); }
  • 28. 28 OUTPUT: [5.9, 5.8, 5.7, 5.7, 5.6, 5.5, 5.4, 5.4, 5.3, 5.3, 5.3, 5.3, 5.3, 5.3, 5.3, 5.2, 5.2, 5.2, 5.2, 5.2, 5.2, 5.2, 5.2, 5.1, 5.1, 5.1, 5.1, 5.1, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 4.9, 4.9, 4.9, 4.9, 4.9, 4.9, 4.9, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 4.6, 4.6, 4.6, 4.6, 4.6, 4.6, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.3, 4.3, 4.3, 4.3, 4.3, 4.3, 4.3, 4.2, 4.2, 4.2, 4.2, 4.1, 4.1, 4.1, 4.1, 4.1, 4.1, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 3.9, 3.9, 3.9, 3.9, 3.8, 3.8, 3.8, 3.7, 3.7, 3.6, 3.6, 3.6, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.2, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.1, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.9, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.6, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5] mouseMoved() Method: This method is use for clear the last selection. public void mouseMoved() { if (lastSelected != null) { lastSelected.setSelected(false); lastSelected = null; } selectMarkerIfHover(quakeMarkers); selectMarkerIfHover(cityMarkers); } selectMarkerIfHover() Method: This method is used when there is marker selected. private void selectMarkerIfHover(List<Marker> markers) { if (lastSelected != null) { return; } for (Marker m : markers) { CommonMarker marker = (CommonMarker)m; if (marker.isInside(map, mouseX, mouseY)) {
  • 29. 29 lastSelected = marker; marker.setSelected(true); return; } } } mouseClicked() Method: The event handler for mouse clicks. It will display an earthquake and its threat circle of cities or if a city is clicked, it will display all the earthquakes where the city is in the threat circle. public void mouseClicked() { if (lastClicked != null) { unhideMarkers(); lastClicked = null; } else if (lastClicked == null) { checkEarthquakesForClick(); if (lastClicked == null) { checkCitiesForClick(); } } } checkCitiesForClick(): This is a helper method that will check if a city marker was clicked on and respond appropriately. The city markers to see if one of them is selected and hide all the other earthquakes. private void checkCitiesForClick() { if (lastClicked != null) return; for (Marker marker : cityMarkers) { if (!marker.isHidden() && marker.isInside(map, mouseX, mouseY)) { lastClicked = (CommonMarker)marker; for (Marker mhide : cityMarkers) { if (mhide != lastClicked) { mhide.setHidden(true); } } for (Marker mhide : quakeMarkers) { EarthquakeMarker quakeMarker = (EarthquakeMarker)mhide;
  • 30. 30 if (quakeMarker.getDistanceTo(marker.getLocation()) > quakeMarker.threatCircle()) { quakeMarker.setHidden(true); } } return; } } } checkEarthquakesForClick() Method: This is a helper method that will check if a earthquake was clicked on and respond appropriately. The earthquake markers to see if one of them is selected and hide all the other earthquakes. private void checkEarthquakesForClick() { if (lastClicked != null) return; for (Marker m : quakeMarkers) { EarthquakeMarker marker = (EarthquakeMarker)m; if (!marker.isHidden() && marker.isInside(map, mouseX, mouseY)) { lastClicked = marker; for (Marker mhide : quakeMarkers) { if (mhide != lastClicked) { mhide.setHidden(true); } } for (Marker mhide : cityMarkers) { if (mhide.getDistanceTo(marker.getLocation()) > marker.threatCircle()) { mhide.setHidden(true); } } return; } } } unhideMarkers() Method: This is used to unhide all markers. private void unhideMarkers() { for(Marker marker : quakeMarkers) { marker.setHidden(false); }
  • 31. 31 for(Marker marker : cityMarkers) { marker.setHidden(false); } } isLand() Method: Checks whether this quake occurred on land. If it did, it sets the "country" property of its PointFeature to the country where it occurred and returns true. Otherwise it returns false. private boolean isLand(PointFeature earthquake) { for (Marker country : countryMarkers) { if (isInCountry(earthquake, country)) { return true; } } return false; } addKey() Method: This is a helper method to draw key in GUI. private void addKey() { fill(255, 250, 240); int xbase = 25; int ybase = 50; stroke(0,0,0); rect(xbase, ybase, 250, 410); stroke(250,235,215); fill(245,255,250); rect(xbase-10, ybase-10, 260, 420); fill(0); textAlign(LEFT, CENTER); textSize(12); text("Earthquake Key", xbase+25, ybase+25); fill(255,0,255); int tri_xbase = xbase + 35; int tri_ybase = ybase + 50; stroke(0,0,0); triangle(tri_xbase, tri_ybase-5, tri_xbase-5, tri_ybase+5, tri_xbase+5, tri_ybase+5); fill(0, 0, 0); textAlign(LEFT, CENTER); text("City Marker", tri_xbase + 15, tri_ybase);
  • 32. 32 text("Land Quake", xbase+50, ybase+70); text("Ocean Quake", xbase+50, ybase+90); text("Size ~ Magnitude", xbase+25, ybase+130); fill(255, 255, 255); stroke(0,0,0); ellipse(xbase+35, ybase+70, 10, 10); stroke(0,0,0); rect(xbase+35-5, ybase+90-5, 10, 10); stroke(0,0,0); fill(color(255, 255, 0)); ellipse(xbase+35, ybase+160, 12, 12); stroke(0,0,0); fill(color(0, 0, 255)); ellipse(xbase+35, ybase+180, 12, 12); stroke(0,0,0); fill(color(255, 0, 0)); ellipse(xbase+35, ybase+200, 12, 12); textAlign(LEFT, CENTER); fill(0, 0, 0); text("Shallow", xbase+50, ybase+160); text("Intermediate", xbase+50, ybase+180); text("Deep", xbase+50, ybase+200); text("Past hour", xbase+50, ybase+220); fill(255, 255, 255); int centerx = xbase+35; int centery = ybase+220; stroke(0,0,0); ellipse(centerx, centery, 12, 12); strokeWeight(2); line(centerx-8, centery-8, centerx+8, centery+8); line(centerx-8, centery+8, centerx+8, centery-8); int t_xbase=xbase+35; int t_ybase=ybase+260; fill(250,0,250); stroke(0,0,0); triangle(t_xbase, t_ybase-5, t_xbase-5, t_ybase+5, t_xbase+5, t_ybase+5); fill(255,0,0); stroke(255,0,0); triangle(t_xbase, t_ybase-7, t_xbase-7, t_ybase+7, t_xbase+7, t_ybase+7); textAlign(LEFT, CENTER); fill(0, 0, 0); text("+20.0 Population (Million)", xbase+50, ybase+260); text("+10.0 Population (Million)", xbase+50, ybase+280); text("Below 10.0", xbase+50, ybase+300); int t_xbas=xbase+35;
  • 33. 33 int t_ybas=ybase+280; fill(250,0,250); stroke(0,0,0); triangle(t_xbas, t_ybas-5, t_xbas-5, t_ybas+5, t_xbas+5, t_ybas+5); fill(0,255,255); stroke(0,255,255); triangle(t_xbas, t_ybas-7, t_xbas-7, t_ybas+7, t_xbas+7, t_ybas+7); int t_xba=xbase+35; int t_yba=ybase+300; fill(250,0,250); stroke(0,0,0); triangle(t_xba, t_yba-5, t_xba-5, t_yba+5, t_xba+5, t_yba+5); fill(0,255,0); stroke(0,255,0); triangle(t_xba, t_yba-7, t_xba-7, t_yba+7, t_xba+7, t_yba+7); fill(255,255,255); stroke(255,0,0); ellipse(xbase+35, ybase+340, 12, 12); stroke(34,139,34); ellipse(xbase+35, ybase+360, 12, 12); stroke(139,0,139); ellipse(xbase+35, ybase+380, 12, 12); textAlign(LEFT, CENTER); fill(0, 0, 0); text("+5.0 Magnitude", xbase+50, ybase+340); text("+4.0 Magnitude", xbase+50, ybase+360); text("Below 4.0", xbase+50, ybase+380); stroke(255,250,240); noFill(); rect(300, 50, 750, 650); }  fill(): Sets the color used to fill shapes.  noFill(): Disables filling geometry. If both noStroke() and noFill() are called, nothing will be drawn to the screen.  triangle(): A triangle is a plane created by connecting three points. The first two arguments specify the first point, the middle two arguments specify the second point, and the last two arguments specify the third point.  ellipse(): Draws an ellipse (oval) to the screen. An ellipse with equal width and height is a circle. By default, the first two parameters set the location, and the third
  • 34. 34 and fourth parameters set the shape's width and height. The origin may be changed with the ellipseMode() function.  rect(): Draws a rectangle to the screen. A rectangle is a four-sided shape with every angle at ninety degrees. By default, the first two parameters set the location of the upper-left corner, the third sets the width, and the fourth sets the height. The way these parameters are interpreted, however, may be changed with the rectMode() function.  stroke(): Sets the color used to draw lines and borders around shapes. This color is either specified in terms of the RGB or HSB color depending on the current colorMode(). The default color space is RGB, with each value in the range from 0 to 255.  color(): Creates colors for storing in variables of the color datatype. The parameters are interpreted as RGB or HSB values depending on the current colorMode().  textAlign(): Sets the current alignment for drawing text. The parameters LEFT, CENTER, and RIGHT set the display characteristics of the letters in relation to the values for the x and y parameters of the text() function.  text(): Draws text to the screen. Displays the information specified in the first parameter on the screen in the position specified by the additional parameters. A default font will be used unless a font is set with the textFont() function and a default size will be used unless a font is set with textSize(). Change the color of the text with the fill() function. The text displays in relation to the textAlign() function, which gives the option to draw to the left, right, and center of the coordinates.  textSize(): Sets the current font size. This size will be used in all subsequent calls to the text() function. Font size is measured in units of pixels. printQuakes() Method: Prints countries with number of earthquakes through loop the country markers or country features (either will work) and then for each country, loop through
  • 35. 35 the quakes to count how many occurred in that country. Recall that the country markers have a "name" property, and LandQuakeMarkers have a "country" property set. private void printQuakes() { int totalWaterQuakes = quakeMarkers.size(); for (Marker country : countryMarkers) { String countryName = country.getStringProperty("name"); int numQuakes = 0; for (Marker marker : quakeMarkers) { EarthquakeMarker eqMarker = (EarthquakeMarker)marker; if (eqMarker.isOnLand()) { if (countryName.equals(eqMarker.getStringProperty("country"))) { numQuakes++; } } } if (numQuakes > 0) { totalWaterQuakes -= numQuakes; System.out.println(countryName + ": " + numQuakes); } } System.out.println("OCEAN QUAKES: " + totalWaterQuakes); } OUTPUT:
  • 36. 36 isInCountry() Method: This is a helper method to test whether a given earthquake is in a given country This will also add the country property to the properties of the earthquake feature if it's in one of the countries. private boolean isInCountry(PointFeature earthquake, Marker country) { Location checkLoc = earthquake.getLocation(); if(country.getClass() == MultiMarker.class) { for(Marker marker : ((MultiMarker)country).getMarkers()) { if(((AbstractShapeMarker)marker).isInsideByLocation(checkLoc)) { earthquake.addProperty("country", country.getProperty("name")); return true; } } } else if(((AbstractShapeMarker)country).isInsideByLocation(checkLoc)) { earthquake.addProperty("country", country.getProperty("name")); return true; } return false; }
  • 37. 37 OUTPUT OFFLINE Mode: If we are working offline, then set the value of this variable to true. private static final boolean offline = true;  When EarthquakeCityMap.java file run: Fig.10 EarthquakeCityMap.java run
  • 38. 38  When Zoom(2) then it look’s like:  When zoom(3) then it look like : Fig.11 Zoom(2) in Offline Mode Fig.12 Zoom(3) in Offline Mode
  • 39. 39  When cursor move on City Marker:  When cursor move on Land Earthquake: Fig.13 Cursor move on City Marker Fig.14 Cursor move on Land Earthquake
  • 40. 40  When mouse clicked on Land Earthquake then the city affected by that earthquake is also shown:  When mouse clicked on Ocean Earthquake then the city affected by that earthquake is also shown: Fig.15 Mouse clicked on Land Earthquake Fig.16 Mouse clicked on Ocean Earthquake
  • 41. 41  When we Click on City Marker then all Earthquake is shown which affected that city:  When zoom(5) then it shows clearly above Earthquake’s: Fig.17 Click on City Marker Fig.18 Zoom(5) in Offline Mode
  • 42. 42 ONLINE MODE: When we working online then set the value of this variable to false. private static final boolean offline = false;  When EarthquakeCityMap.java file run: Fig.19 EarthquakeCityMap.java file run
  • 43. 43  When cursor move on Ocean Earthquake: Fig.20 Cursor move on Ocean Earthquake
  • 44. 44  When cursor move on CityMarker: Fig.21 Cursor move on CityMarker
  • 45. 45  When we Zoom in too much and Cursor move on CityMarker:  When we Click on Ocean Earthquake: Fig.22 Zoom in too much and Cursor move on CityMarker Fig.23 Click on Ocean Earthquake
  • 47. 47 RESULT This project was a part of the Java Object-Oriented Design of Data Structures Specialization by UCSD on Coursera. This Specialization covers intermediate topics in software development, including implementation of data structures and algorithms for organizing large amounts of data in a way that is both efficient and easy to work with. The project that was assigned was completed successfully. User Stories:- 1. Users can obtain a graphical representation of how each earthquake compares to other earthquakes along a certain parameter. 2. If the user clicks an earthquake marker, all cities that may be affected by this earthquake are displayed; when the user clicks a city marker, all earthquakes that may affect that city are displayed. 3. Popup information boxes about the earthquakes and cities are always drawn on top of all other graphical information. Information boxes are contained within the map content area.
  • 48. 48 CONCLUSION It gives me immense pleasure to write that my summer training has completed successfully online from Coursera. This report presented a complete overview of Basics of Java Programming. I got this opportunity to create a Global Earthquake Monitor using Java. I also understood and got the knowledge more about java language and its applications. After completing this course from Coursera, I can say I have learnt about the basics of OOPs. I learned using the different libraries of Java like, Unfolding Maps, Processing Library. These Libraries were an essential part of my project on Global Earthquake Monitor as they helped me Analyze and Visualize the data easily. I have gained lots of knowledge and experience needed to be successful in great engineering challenges.
  • 49. 49 REFERENCES  https://www.coursera.org/specializations/object-oriented-programming  https://www.coursera.org/learn/object-oriented-java/home/welcome  https://processing.org/  http://unfoldingmaps.org/javadoc/  https://docs.oracle.com/javase/8/docs/api/java/util/  https://processing.github.io/processing- javadocs/core/index.html?processing/core/PApplet.html  http://unfoldingmaps.org/javadoc/overview-summary.html  https://en.wikipedia.org/wiki/Coursera  https://www.coursera.org/  https://www.coursera.org/learn/object-oriented-java/supplement/eZIfJ/a-note-about- the-main-method  https://www.oracle.com/java/technologies/javase-downloads.html  https://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation- windows.html  https://wiki.eclipse.org/Eclipse/Installation#Download_Eclipse  https://www.eclipse.org/downloads/