SlideShare a Scribd company logo
1 of 44
Download to read offline
Java
Programming(for designers)
What is a Program?
A list of detailed instructions that the computer
carries out
To make a cup of coffee the
following would not be sufficient:
The instructions would have
to be much more detailed:
You have to say exactly what to do in the right order with no ambiguity
1. Boil water
2. Put coffee in cup
3. Pour in hot water
4. Add milk
1.1. Go to kettle
1.2. Check kettle has water in it
1.3. If not
1.3.1 Take kettle to cold tap
1.3.2 Remove lid of kettle
1.3.3 Put kettle under cold tap
1.3.4 Turn on tap
1.3.5 When kettle full turn off tap
1.3.6 Return kettle to worktop
1.4. Plug kettle into mains
1.5.Switch on electricity
ā€¦ā€¦.
Java isā€¦
ā€¢ Platform-independent
ā€¢ Apps for mobile phones and other consumer
devices
ā€¢ Secure, portable, multithreaded
ā€¢ Online, server-side applications
ā€¢ Simple, Object oriented
ā€¢ GPL libraries
X
X
X?
ā˜ŗ
X
ā˜ŗ
Get started
ā€¢ Two components:
ā€¢ Java Virtual Machine (VM)
ā€¢ Base for the Java platform, install Win version
ā€¢ Java Application Programming Interface (API)
ā€¢ Prewritten code, organized into packages of similar
topics. Each package or library contains classes and
interfaces that you can call and extend. Example:
ā€¢ Rectangle2D = new Rectangle2D(loc, width, height)
ā€¢ http://java.sun.com/learning/new2java
Acronyms
ā€¢ JDK or J2SE, Development Kit
ā€¢ Set of Java development tools, consisting of the
API classes, a Java compiler, and the Java virtual
machine (VM) interpreter
ā€¢ The JDK is used to compile Java applications and
applets. The most current version is the J2SE 5
ā€¢ J2SE, Runtime Environment 5.0
Set up: Download the JDK
ā€¢ And set the classpath in Windows
Include the directories
where you will run
Java apps
Set Up a Development
Environment
ā€¢ NetBeans IDE, JEdit, Eclipse, JCreator
ā€¢ Or use a simple text editor, and compile and
run from the command line
Set Up
ā€¢ Download J2SE 5.0 Documentation
ā€¢ Look for useful libraries
Some Useful Libraries
ā€¢ Colt: or High Performance Scientific and Technical Computing
ā€¢ Weka 3: Data Mining Software in Java
ā€¢ JHotDraw is a two-dimensional graphics framework for structured
drawing editors
ā€¢ JGAP is a genetic algorithms component written in the form of a
Java package
ā€¢ OpenAI: a full suite of Artificial Intelligence components: Agents,
Neural Nets, GAsā€¦
ā€¢ JUNG:Java Universal Network/Graph Framework
ā€¢ JOONE: JGAP's genetic algorithms to evolve neural nets
ā€¢ HyperGraph: to work with hyperbolic geometry and especially with
hyperbolic trees
ā€¢ Repast: an agent modeling toolkit (like Swarm)
ā€¢ JExcel or JXL provides the ability to read, write, and modify
Microsoft Excel spreadsheets
Standard Java Libraries
ā€¢ Language
ā€¢ Maths
ā€¢ Graphics
ā€¢ 2D
ā€¢ 3D
ā€¢ File I/O
ā€¢JAI: Advanced
Networking
ā€¢Imaging
ā€¢XML
ā€¢Print
Swing
ā€¢ GUI-control (widget) library in Java 2
ā€¢ Built-in controls, flexible and customizable
ā€¢ Features aimed at interface design
ā€¢ Buttons, tabbed panes,
dockable toolbars,
scroll panes, tooltips,
tables, etc.
ā€¢ Look & feel can be changed
Java 2D
ā€¢ Standard drawing library in Java 2
ā€¢ Drawing attributes
ā€¢ Fill patterns and images
ā€¢ Fonts
ā€¢ Line thicknesses and dashing patterns
ā€¢ Colour mixing rules and transparency
ā€¢ Transformations
ā€¢ Floating-point coordinate system
ā€¢ Mapping from memory coords to
screen or printer coords
ā€¢ Affine transforms: translate, scale,
rotate, and shear
Java 3D
ā€¢ Extension to Java
ā€¢ Not part of ā€œcoreā€ Java language like Java 2D
ā€¢ Built on Direct3D or OpenGL, depending on
platform
ā€¢ Scene-graph based model, not primarily
immediate-mode rendering
Java Versions
ā€¢ Java 1.0, 1.1ā€¦ ā€œJava 2ā€ refers to 1.2 onwards
ā€¢ Popular: 1.4.2
ā€¢ New: 1.5. The leading "1." is dropped, now it
is Java Platform Standard Edition 5.0
ā€¢ Butā€¦ version 5.0 also keeps the version
number 1.5.0 in some places visible only to
developers
ā€¢ This release is also known as ā€œTigerā€ (not the latest Mac OS X!)
Jargon
ā€¢ Application is a stand-alone Java program
ā€¢ Applet is a browser-based Java program
Basic Procedure
1. Write a .java file
2. Compile it with the javac command
3. Now you have a .class file
4. Run it with the java command
5. VoilĆ”!
Running a Java
ApplicationWrite
Java
code
javac MyProg.java
java MyProg
Java code:
MyProg.java
Bytecode:
MyProg.class
IDE or
Text
Editor
Output
Save the file
with a .java
extension
Run the
Java
compiler
'javac'
Execute the
bytecode with the
command 'java'
This creates
a file of
bytecode with
a .class
extension User to interact
with the system
Program to
execute and
produce a data
set, graphs, etc.
Java program layout
ā€¢ A typical Java file looks like:
import java.awt.*;
import java.util.*;
public class SomethingOrOther {
// field and method definitions
. . .
}
This must be in a file named
SomethingOrOther.java !
What does it mean?
import java.awt.*;
import java.applet.Applet;
public class Greetings extends Applet {
public void paint(Graphics g) {
g.drawString("Hello World!", 50, 50);
}
}
These 2 lines tell the computer to include
(import) two standard libraries awt (Abstract
Window Toolkit) and applet.
This line tells the
computer to display
some text (a string) on
the screen.
This line announces that the
program (class) can be run by
anyone (public), is called
Greetings and is an Applet.
This line
declares what
follows in the {
} as a method
called paint.
This is where it is displayed in
pixels across and down from the
top left hand corner
This is what is displayed
A Java Class
ā€¢ Java programs are collections of classes
ā€¢ OOP:
ā€¢ A class that represents a rectangle would contain
variables for its location, its width, and its height
ā€¢ The class can also contain a method that
calculates the area of the rectangle
ā€¢ An instance of the rectangle class could contain
the information for a specific rectangle, such as
the dimensions of a room
An Applet is a Panel is a
Containerā€¦ is an Object
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.applet.Applet
ā€¦so you can do things with it that youā€™d do with
applets, panels, containers, components, and objects.
Object Oriented (OO)
Programming
A key aspect is Inheritance.
You donā€™t have to describe similar objects completely. You
can define a superclass (sometimes called base class) that
has the common attributes and methods and inherit these
adding only the ones that are different.
Vehicle
Bus Lorry
Attributes: Speed, Colour
Methods: Start, Stop
Attributes:
Max Load
Methods:
Pick up Load
Attributes: Max
Passengers
Methods: Pick up
Passengers
These are inherited
What classes, why?
ā€¢ A file can contain multiple classes, but only
one can be declared public, and that oneā€™s
name must match the filename
ā€¢ Usually 1 class = 1 file
ā€¢ Most difficult part is to plan the program: the
classes, the methods, the variables, the
procedure
ā€¢ If you can define it in paper & pencil, the rest is
easy
Methods
ā€¢ Define a group of statements that perform a
particular operation
ā€¢ With or without arguments
calculateArea(shape) {
// here geom operations
}
createShape() {
// new square...
// calculateArea(square)
}
Primitives and Objects
ā€¢ Java distinguishes two kinds of entities
ā€¢ Primitive types
ā€¢ Objects
ā€¢ Primitive types: integers, doubles, booleans,
stringsā€¦
ā€¢ Objects are associated with reference
variables which store an objectā€™s address
Expressions
ā€¢ Assignment statements: =, +=, *= etc.
ā€¢ Arithmetic uses the familiar + - * / %
ā€¢ Java uses ++ and --
ā€¢ Java has boolean operators && || !
ā€¢ Java has comparisons < <= == != >= >
Control statements
if (x < y) smaller = x;
if (x < y){ smaller=x; sum += x;}
else { smaller = y; sum += y; }
while (x < y) { y = y - x; }
do { y = y - x; } while (x < y)
for (int i = 0; i < max; i++)
sum += i;
The main method
ā€¢ Every Java application must contain a main
method:
ā€¢ public static void main(String[] args)
ā€¢ An application executes the main method
first. The array of Strings can be empty or it
can receive arguments to customise how the
program runs (number of iterations, number
of agents, etc).
Example
An Evolutionary Design System
public static void main(String[] args) {
new Model();
}
public Model() {
EvoDesign frame = new EvoDesign();
frame.setVisible(true);
}
public EvoDesign() {
jbInit();
}
private void jbInit() throws Exception {
setSize(new Dimension(860,680));
setTitle("Evolutionary Design");
jMenuFile.setText("File");ā€¦
setJMenuBar(jMenuBar);
JComboBox jGensā€¦
JList jListFnsā€¦
JButton jRunā€¦
jTabs.addTabsā€¦
contentPane.add(ā€¦);
}
void jTabs_clicked(ChangeEvent e) { ā€¦ }
void jLists_mouseClicked(MouseEvent e) {
ā€¦ }
Image makeFitnessLines(Image im) {
LineGraph bg = new LineGraph();
bg.setDefaultLineThickness(0.1);
ā€¦
try {
new ImageOutput(im);
out.render(bg); im = out.getImage();
}
}
void jMenuExit_actionPerformed(ActionEvent e) {
System.exit(0);
}
class drawPanel extends JPanel {
public void paint(Graphics g) {
g.setFont(EvoDesign.myFont);
g2.drawImage(new BufferedImage(0, 50, 2);
}
}
public void setupGA() throws Exception {
fitnessHistory = new DoubleArrayList();
topFitness.clear();
Configuration conf = new DefaultConfiguration();
conf.addGeneticOperator( new MutationOperator(mut) );
conf.addGeneticOperator( new CustomCrossover(cross) );
FitnessFunction myFunc = new FitnessFn(chrom);
conf.setFitnessFunction(myFunc);
Gene[] g = new Gene[chrom];
g[0] = new BooleanGene();
g[i] = new IntegerGene(1, alle);
Chromosome sampleChromosome = new Chromosome(g);
conf.setSampleChromosome(sampleChromosome);
conf.setPopulationSize(EvoDesign.pop);
genPopulation = Genotype.randomInitialGenotype(conf);
Chromosome best = genPopulation.getFittestChromosome();
}
public FitnessFn(int a) {
}
public int evaluate(Chromosome a) {
int fitness = 0;
Gene[] gs = a.getGenes();
if (EvoDesign.fnCrit.equals("minMean")) {
fitness += ( EvoDesign.alle -
Descriptive.mean(sd) );
}
return Math.max(1, fitness);
}
public Colours01() {
setColorPalettes();
}
public static BufferedImage
makeOutputImage() {
for (int i = 0; i < topSolutions.size(); i++) {
Chromosome s = topSolutions.get(i);
for (int j = 0; j < s.size(); j++) {
Gene si = s.getGene(j);
g2.setColor( getAllele() .intValue());
g2.fillRect(boxX, boxY, stepX, 25);
}
}
return bf;
}
Code
ā€¢ Get these slides and the source code for the
example at:
http://www.arch.usyd.edu.au/~rsos7705/programming.html

More Related Content

What's hot

PROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IIPROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IISivaSankari36
Ā 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)DevelopIntelligence
Ā 
PROGRAMMING IN JAVA
PROGRAMMING IN JAVAPROGRAMMING IN JAVA
PROGRAMMING IN JAVASivaSankari36
Ā 
Java Tutorial
Java TutorialJava Tutorial
Java TutorialVijay A Raj
Ā 
Core java Basics
Core java BasicsCore java Basics
Core java BasicsRAMU KOLLI
Ā 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on javashashi shekhar
Ā 
Java user group 2015 02-09-java8
Java user group 2015 02-09-java8Java user group 2015 02-09-java8
Java user group 2015 02-09-java8marctritschler
Ā 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
Ā 
Core java
Core java Core java
Core java Ravi varma
Ā 
PROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part IPROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part ISivaSankari36
Ā 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in javaagorolabs
Ā 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT studentsPartnered Health
Ā 
Basic java for Android Developer
Basic java for Android DeveloperBasic java for Android Developer
Basic java for Android DeveloperNattapong Tonprasert
Ā 
PROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part IPROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part ISivaSankari36
Ā 

What's hot (20)

Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
Ā 
PROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IIPROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part II
Ā 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Ā 
PROGRAMMING IN JAVA
PROGRAMMING IN JAVAPROGRAMMING IN JAVA
PROGRAMMING IN JAVA
Ā 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
Ā 
55 New Features in Java 7
55 New Features in Java 755 New Features in Java 7
55 New Features in Java 7
Ā 
Core java Basics
Core java BasicsCore java Basics
Core java Basics
Ā 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
Ā 
Java user group 2015 02-09-java8
Java user group 2015 02-09-java8Java user group 2015 02-09-java8
Java user group 2015 02-09-java8
Ā 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
Ā 
Core java
Core java Core java
Core java
Ā 
PROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part IPROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part I
Ā 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
Ā 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
Ā 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Ā 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
Ā 
Basic java for Android Developer
Basic java for Android DeveloperBasic java for Android Developer
Basic java for Android Developer
Ā 
PROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part IPROGRAMMING IN JAVA -unit 5 -part I
PROGRAMMING IN JAVA -unit 5 -part I
Ā 
Java basic
Java basicJava basic
Java basic
Ā 
Java basics notes
Java basics notesJava basics notes
Java basics notes
Ā 

Viewers also liked

76829060 java-coding-conventions
76829060 java-coding-conventions76829060 java-coding-conventions
76829060 java-coding-conventionsslavicp
Ā 
Coding Standards & Conventions for Java and Rails projects
Coding Standards & Conventions for Java and Rails projectsCoding Standards & Conventions for Java and Rails projects
Coding Standards & Conventions for Java and Rails projectsDavid Francisco
Ā 
Php Coding Convention
Php Coding ConventionPhp Coding Convention
Php Coding ConventionPhuong Vy
Ā 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java CodingRahul Bhutkar
Ā 
Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseRayhan Chowdhury
Ā 
Why coding convention ?
Why coding convention ?Why coding convention ?
Why coding convention ?Panji Gautama
Ā 
Secure Coding for Java - An introduction
Secure Coding for Java - An introductionSecure Coding for Java - An introduction
Secure Coding for Java - An introductionSebastien Gioria
Ā 
Standard java coding convention
Standard java coding conventionStandard java coding convention
Standard java coding conventionTam Thanh
Ā 
Coding Best practices (PHP)
Coding Best practices (PHP)Coding Best practices (PHP)
Coding Best practices (PHP)Christian Baune
Ā 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for javamaheshm1206
Ā 
Coding convention
Coding conventionCoding convention
Coding conventionKhoa Nguyen
Ā 
Lan acceptance for carriage
Lan   acceptance for carriageLan   acceptance for carriage
Lan acceptance for carriagecomercio01
Ā 

Viewers also liked (12)

76829060 java-coding-conventions
76829060 java-coding-conventions76829060 java-coding-conventions
76829060 java-coding-conventions
Ā 
Coding Standards & Conventions for Java and Rails projects
Coding Standards & Conventions for Java and Rails projectsCoding Standards & Conventions for Java and Rails projects
Coding Standards & Conventions for Java and Rails projects
Ā 
Php Coding Convention
Php Coding ConventionPhp Coding Convention
Php Coding Convention
Ā 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java Coding
Ā 
Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code Reuse
Ā 
Why coding convention ?
Why coding convention ?Why coding convention ?
Why coding convention ?
Ā 
Secure Coding for Java - An introduction
Secure Coding for Java - An introductionSecure Coding for Java - An introduction
Secure Coding for Java - An introduction
Ā 
Standard java coding convention
Standard java coding conventionStandard java coding convention
Standard java coding convention
Ā 
Coding Best practices (PHP)
Coding Best practices (PHP)Coding Best practices (PHP)
Coding Best practices (PHP)
Ā 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
Ā 
Coding convention
Coding conventionCoding convention
Coding convention
Ā 
Lan acceptance for carriage
Lan   acceptance for carriageLan   acceptance for carriage
Lan acceptance for carriage
Ā 

Similar to ITFT - Java Coding

Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for DesignersR. Sosa
Ā 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
Ā 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentationjuliasceasor
Ā 
Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdprat0ham
Ā 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept Prakash Poudel
Ā 
Java Programming and J2ME: The Basics
Java Programming and J2ME: The BasicsJava Programming and J2ME: The Basics
Java Programming and J2ME: The Basicstosine
Ā 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operatorkamal kotecha
Ā 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbaivibrantuser
Ā 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCFAKHRUN NISHA
Ā 
Java review00
Java review00Java review00
Java review00saryu2011
Ā 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.pptSmitaBorkar9
Ā 

Similar to ITFT - Java Coding (20)

Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
Ā 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
Ā 
java slides
java slidesjava slides
java slides
Ā 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
Ā 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
Ā 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
Ā 
Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rd
Ā 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
Ā 
Introduction to java programming part 1
Introduction to java programming   part 1Introduction to java programming   part 1
Introduction to java programming part 1
Ā 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
Ā 
Letest
LetestLetest
Letest
Ā 
Java Programming and J2ME: The Basics
Java Programming and J2ME: The BasicsJava Programming and J2ME: The Basics
Java Programming and J2ME: The Basics
Ā 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
Ā 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbai
Ā 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
Ā 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
Ā 
Java review00
Java review00Java review00
Java review00
Ā 
Java1
Java1Java1
Java1
Ā 
Java1
Java1Java1
Java1
Ā 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.ppt
Ā 

More from Blossom Sood

ITFT - Web security
ITFT - Web securityITFT - Web security
ITFT - Web securityBlossom Sood
Ā 
ITFT - Trends in it
ITFT - Trends in itITFT - Trends in it
ITFT - Trends in itBlossom Sood
Ā 
ITFT - Search engine
ITFT - Search engineITFT - Search engine
ITFT - Search engineBlossom Sood
Ā 
ITFT - Number system
ITFT - Number systemITFT - Number system
ITFT - Number systemBlossom Sood
Ā 
ITFT - DOS - Disk Operating System
ITFT - DOS - Disk Operating SystemITFT - DOS - Disk Operating System
ITFT - DOS - Disk Operating SystemBlossom Sood
Ā 
ITFT - Window explorer
ITFT - Window explorerITFT - Window explorer
ITFT - Window explorerBlossom Sood
Ā 

More from Blossom Sood (9)

ITFT- Dbms
ITFT- DbmsITFT- Dbms
ITFT- Dbms
Ā 
ITFT - Web security
ITFT - Web securityITFT - Web security
ITFT - Web security
Ā 
ITFT - Trends in it
ITFT - Trends in itITFT - Trends in it
ITFT - Trends in it
Ā 
ITFT - Search engine
ITFT - Search engineITFT - Search engine
ITFT - Search engine
Ā 
ITFT - Oops
ITFT - OopsITFT - Oops
ITFT - Oops
Ā 
ITFT - Number system
ITFT - Number systemITFT - Number system
ITFT - Number system
Ā 
ITFT - Java
ITFT - JavaITFT - Java
ITFT - Java
Ā 
ITFT - DOS - Disk Operating System
ITFT - DOS - Disk Operating SystemITFT - DOS - Disk Operating System
ITFT - DOS - Disk Operating System
Ā 
ITFT - Window explorer
ITFT - Window explorerITFT - Window explorer
ITFT - Window explorer
Ā 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
Ā 
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
Ā 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
Ā 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
Ā 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
Ā 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
Ā 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
Ā 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
Ā 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
Ā 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
Ā 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
Ā 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)Dr. Mazin Mohamed alkathiri
Ā 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
Ā 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
Ā 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
Ā 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
Ā 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Ā 
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
Ā 
Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”
Ā 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
Ā 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
Ā 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
Ā 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
Ā 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
Ā 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
Ā 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
Ā 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
Ā 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
Ā 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
Ā 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
Ā 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Ā 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Ā 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
Ā 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
Ā 

ITFT - Java Coding

  • 2. What is a Program? A list of detailed instructions that the computer carries out To make a cup of coffee the following would not be sufficient: The instructions would have to be much more detailed: You have to say exactly what to do in the right order with no ambiguity 1. Boil water 2. Put coffee in cup 3. Pour in hot water 4. Add milk 1.1. Go to kettle 1.2. Check kettle has water in it 1.3. If not 1.3.1 Take kettle to cold tap 1.3.2 Remove lid of kettle 1.3.3 Put kettle under cold tap 1.3.4 Turn on tap 1.3.5 When kettle full turn off tap 1.3.6 Return kettle to worktop 1.4. Plug kettle into mains 1.5.Switch on electricity ā€¦ā€¦.
  • 3. Java isā€¦ ā€¢ Platform-independent ā€¢ Apps for mobile phones and other consumer devices ā€¢ Secure, portable, multithreaded ā€¢ Online, server-side applications ā€¢ Simple, Object oriented ā€¢ GPL libraries X X X? ā˜ŗ X ā˜ŗ
  • 4. Get started ā€¢ Two components: ā€¢ Java Virtual Machine (VM) ā€¢ Base for the Java platform, install Win version ā€¢ Java Application Programming Interface (API) ā€¢ Prewritten code, organized into packages of similar topics. Each package or library contains classes and interfaces that you can call and extend. Example: ā€¢ Rectangle2D = new Rectangle2D(loc, width, height) ā€¢ http://java.sun.com/learning/new2java
  • 5. Acronyms ā€¢ JDK or J2SE, Development Kit ā€¢ Set of Java development tools, consisting of the API classes, a Java compiler, and the Java virtual machine (VM) interpreter ā€¢ The JDK is used to compile Java applications and applets. The most current version is the J2SE 5 ā€¢ J2SE, Runtime Environment 5.0
  • 6. Set up: Download the JDK ā€¢ And set the classpath in Windows Include the directories where you will run Java apps
  • 7. Set Up a Development Environment ā€¢ NetBeans IDE, JEdit, Eclipse, JCreator ā€¢ Or use a simple text editor, and compile and run from the command line
  • 8. Set Up ā€¢ Download J2SE 5.0 Documentation ā€¢ Look for useful libraries
  • 9. Some Useful Libraries ā€¢ Colt: or High Performance Scientific and Technical Computing ā€¢ Weka 3: Data Mining Software in Java ā€¢ JHotDraw is a two-dimensional graphics framework for structured drawing editors ā€¢ JGAP is a genetic algorithms component written in the form of a Java package ā€¢ OpenAI: a full suite of Artificial Intelligence components: Agents, Neural Nets, GAsā€¦ ā€¢ JUNG:Java Universal Network/Graph Framework ā€¢ JOONE: JGAP's genetic algorithms to evolve neural nets ā€¢ HyperGraph: to work with hyperbolic geometry and especially with hyperbolic trees ā€¢ Repast: an agent modeling toolkit (like Swarm) ā€¢ JExcel or JXL provides the ability to read, write, and modify Microsoft Excel spreadsheets
  • 10. Standard Java Libraries ā€¢ Language ā€¢ Maths ā€¢ Graphics ā€¢ 2D ā€¢ 3D ā€¢ File I/O ā€¢JAI: Advanced Networking ā€¢Imaging ā€¢XML ā€¢Print
  • 11. Swing ā€¢ GUI-control (widget) library in Java 2 ā€¢ Built-in controls, flexible and customizable ā€¢ Features aimed at interface design ā€¢ Buttons, tabbed panes, dockable toolbars, scroll panes, tooltips, tables, etc. ā€¢ Look & feel can be changed
  • 12. Java 2D ā€¢ Standard drawing library in Java 2 ā€¢ Drawing attributes ā€¢ Fill patterns and images ā€¢ Fonts ā€¢ Line thicknesses and dashing patterns ā€¢ Colour mixing rules and transparency ā€¢ Transformations ā€¢ Floating-point coordinate system ā€¢ Mapping from memory coords to screen or printer coords ā€¢ Affine transforms: translate, scale, rotate, and shear
  • 13. Java 3D ā€¢ Extension to Java ā€¢ Not part of ā€œcoreā€ Java language like Java 2D ā€¢ Built on Direct3D or OpenGL, depending on platform ā€¢ Scene-graph based model, not primarily immediate-mode rendering
  • 14. Java Versions ā€¢ Java 1.0, 1.1ā€¦ ā€œJava 2ā€ refers to 1.2 onwards ā€¢ Popular: 1.4.2 ā€¢ New: 1.5. The leading "1." is dropped, now it is Java Platform Standard Edition 5.0 ā€¢ Butā€¦ version 5.0 also keeps the version number 1.5.0 in some places visible only to developers ā€¢ This release is also known as ā€œTigerā€ (not the latest Mac OS X!)
  • 15. Jargon ā€¢ Application is a stand-alone Java program ā€¢ Applet is a browser-based Java program
  • 16. Basic Procedure 1. Write a .java file 2. Compile it with the javac command 3. Now you have a .class file 4. Run it with the java command 5. VoilĆ”!
  • 17. Running a Java ApplicationWrite Java code javac MyProg.java java MyProg Java code: MyProg.java Bytecode: MyProg.class IDE or Text Editor Output Save the file with a .java extension Run the Java compiler 'javac' Execute the bytecode with the command 'java' This creates a file of bytecode with a .class extension User to interact with the system Program to execute and produce a data set, graphs, etc.
  • 18. Java program layout ā€¢ A typical Java file looks like: import java.awt.*; import java.util.*; public class SomethingOrOther { // field and method definitions . . . } This must be in a file named SomethingOrOther.java !
  • 19. What does it mean? import java.awt.*; import java.applet.Applet; public class Greetings extends Applet { public void paint(Graphics g) { g.drawString("Hello World!", 50, 50); } } These 2 lines tell the computer to include (import) two standard libraries awt (Abstract Window Toolkit) and applet. This line tells the computer to display some text (a string) on the screen. This line announces that the program (class) can be run by anyone (public), is called Greetings and is an Applet. This line declares what follows in the { } as a method called paint. This is where it is displayed in pixels across and down from the top left hand corner This is what is displayed
  • 20. A Java Class ā€¢ Java programs are collections of classes ā€¢ OOP: ā€¢ A class that represents a rectangle would contain variables for its location, its width, and its height ā€¢ The class can also contain a method that calculates the area of the rectangle ā€¢ An instance of the rectangle class could contain the information for a specific rectangle, such as the dimensions of a room
  • 21.
  • 22. An Applet is a Panel is a Containerā€¦ is an Object java.lang.Object | +----java.awt.Component | +----java.awt.Container | +----java.awt.Panel | +----java.applet.Applet ā€¦so you can do things with it that youā€™d do with applets, panels, containers, components, and objects.
  • 23. Object Oriented (OO) Programming A key aspect is Inheritance. You donā€™t have to describe similar objects completely. You can define a superclass (sometimes called base class) that has the common attributes and methods and inherit these adding only the ones that are different. Vehicle Bus Lorry Attributes: Speed, Colour Methods: Start, Stop Attributes: Max Load Methods: Pick up Load Attributes: Max Passengers Methods: Pick up Passengers These are inherited
  • 24. What classes, why? ā€¢ A file can contain multiple classes, but only one can be declared public, and that oneā€™s name must match the filename ā€¢ Usually 1 class = 1 file ā€¢ Most difficult part is to plan the program: the classes, the methods, the variables, the procedure ā€¢ If you can define it in paper & pencil, the rest is easy
  • 25. Methods ā€¢ Define a group of statements that perform a particular operation ā€¢ With or without arguments calculateArea(shape) { // here geom operations } createShape() { // new square... // calculateArea(square) }
  • 26. Primitives and Objects ā€¢ Java distinguishes two kinds of entities ā€¢ Primitive types ā€¢ Objects ā€¢ Primitive types: integers, doubles, booleans, stringsā€¦ ā€¢ Objects are associated with reference variables which store an objectā€™s address
  • 27. Expressions ā€¢ Assignment statements: =, +=, *= etc. ā€¢ Arithmetic uses the familiar + - * / % ā€¢ Java uses ++ and -- ā€¢ Java has boolean operators && || ! ā€¢ Java has comparisons < <= == != >= >
  • 28. Control statements if (x < y) smaller = x; if (x < y){ smaller=x; sum += x;} else { smaller = y; sum += y; } while (x < y) { y = y - x; } do { y = y - x; } while (x < y) for (int i = 0; i < max; i++) sum += i;
  • 29. The main method ā€¢ Every Java application must contain a main method: ā€¢ public static void main(String[] args) ā€¢ An application executes the main method first. The array of Strings can be empty or it can receive arguments to customise how the program runs (number of iterations, number of agents, etc).
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. public static void main(String[] args) { new Model(); } public Model() { EvoDesign frame = new EvoDesign(); frame.setVisible(true); }
  • 39. public EvoDesign() { jbInit(); } private void jbInit() throws Exception { setSize(new Dimension(860,680)); setTitle("Evolutionary Design"); jMenuFile.setText("File");ā€¦ setJMenuBar(jMenuBar); JComboBox jGensā€¦ JList jListFnsā€¦ JButton jRunā€¦ jTabs.addTabsā€¦ contentPane.add(ā€¦); } void jTabs_clicked(ChangeEvent e) { ā€¦ } void jLists_mouseClicked(MouseEvent e) { ā€¦ }
  • 40. Image makeFitnessLines(Image im) { LineGraph bg = new LineGraph(); bg.setDefaultLineThickness(0.1); ā€¦ try { new ImageOutput(im); out.render(bg); im = out.getImage(); } } void jMenuExit_actionPerformed(ActionEvent e) { System.exit(0); } class drawPanel extends JPanel { public void paint(Graphics g) { g.setFont(EvoDesign.myFont); g2.drawImage(new BufferedImage(0, 50, 2); } }
  • 41. public void setupGA() throws Exception { fitnessHistory = new DoubleArrayList(); topFitness.clear(); Configuration conf = new DefaultConfiguration(); conf.addGeneticOperator( new MutationOperator(mut) ); conf.addGeneticOperator( new CustomCrossover(cross) ); FitnessFunction myFunc = new FitnessFn(chrom); conf.setFitnessFunction(myFunc); Gene[] g = new Gene[chrom]; g[0] = new BooleanGene(); g[i] = new IntegerGene(1, alle); Chromosome sampleChromosome = new Chromosome(g); conf.setSampleChromosome(sampleChromosome); conf.setPopulationSize(EvoDesign.pop); genPopulation = Genotype.randomInitialGenotype(conf); Chromosome best = genPopulation.getFittestChromosome(); }
  • 42. public FitnessFn(int a) { } public int evaluate(Chromosome a) { int fitness = 0; Gene[] gs = a.getGenes(); if (EvoDesign.fnCrit.equals("minMean")) { fitness += ( EvoDesign.alle - Descriptive.mean(sd) ); } return Math.max(1, fitness); }
  • 43. public Colours01() { setColorPalettes(); } public static BufferedImage makeOutputImage() { for (int i = 0; i < topSolutions.size(); i++) { Chromosome s = topSolutions.get(i); for (int j = 0; j < s.size(); j++) { Gene si = s.getGene(j); g2.setColor( getAllele() .intValue()); g2.fillRect(boxX, boxY, stepX, 25); } } return bf; }
  • 44. Code ā€¢ Get these slides and the source code for the example at: http://www.arch.usyd.edu.au/~rsos7705/programming.html