SlideShare a Scribd company logo
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 Write a .java file Compile it with the  javac  command Now you have a .class file Run it with the  java  command Voilá!
Running a Java Application Write 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(&quot;Evolutionary Design&quot;); jMenuFile.setText(&quot;File&quot;);… 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(&quot;minMean&quot;)) {   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 (20)

Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
Raghuveer Guthikonda
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Veerabadra Badra
 
QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
Qspiders - Software Testing Training Institute
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
CPD INDIA
 
JDBC
JDBCJDBC
JDBC
People Strategists
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
Core Java
Core JavaCore Java
Core Java
Priyanka Pradhan
 
History Of JAVA
History Of JAVAHistory Of JAVA
History Of JAVA
ARSLANAHMED107
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
Java PPT
Java PPTJava PPT
Java PPT
Dilip Kr. Jangir
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
Eduonix Learning Solutions
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Professional Guru
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
Arun Prasad
 
Core java
Core java Core java
Core java
Shubham singh
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
CPD INDIA
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
Arun Prasad
 

Viewers also liked (20)

Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2
Raghu nath
 
Programming with Java: the Basics
Programming with Java: the BasicsProgramming with Java: the Basics
Programming with Java: the Basics
Jussi Pohjolainen
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: Basics
Anton Keks
 
Java Basics
Java BasicsJava Basics
Java Basics
Brandon Black
 
Java Basics
Java BasicsJava Basics
Java Basics
Rajkattamuri
 
PALASH SL GUPTA
PALASH SL GUPTAPALASH SL GUPTA
PALASH SL GUPTA
PALASH GUPTA
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
poonguzhali1826
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of java
vinay arora
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
Anton Keks
 
Java basics
Java basicsJava basics
Java basics
Jitender Jain
 
2. Basics of Java
2. Basics of Java2. Basics of Java
2. Basics of Java
Nilesh Dalvi
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
pinkpreet_kaur
 
Java basics
Java basicsJava basics
Java basics
Hoang Nguyen
 
Core java Basics
Core java BasicsCore java Basics
Core java Basics
RAMU KOLLI
 
Java Basics
Java BasicsJava Basics
Java Basics
sunilsahu07
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
mhtspvtltd
 
OOPs in Java
OOPs in JavaOOPs in Java
OOPs in Java
Ranjith Sekar
 
Java basics part 1
Java basics part 1Java basics part 1
Java basics part 1
Kevin Rowan
 
Java Basics
Java BasicsJava Basics
Java Basics
Rkrishna Mishra
 
Ppt on java basics
Ppt on java basicsPpt on java basics
Ppt on java basics
Mavoori Soshmitha
 
Ad

Similar to Java Programming for Designers (20)

ITFT - Java Coding
ITFT - Java CodingITFT - Java Coding
ITFT - Java Coding
Blossom Sood
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
Zeeshan MIrza
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
mrinalbhutani
 
Curso de Programación Java Básico
Curso de Programación Java BásicoCurso de Programación Java Básico
Curso de Programación Java Básico
Universidad de Occidente
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
sotlsoc
 
JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).ppt
AliyaJav
 
Javanotes
JavanotesJavanotes
Javanotes
John Cutajar
 
Unit 2 Java
Unit 2 JavaUnit 2 Java
Unit 2 Java
arnold 7490
 
Java Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece departmentJava Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece department
om2348023vats
 
Java ppts unit1
Java ppts unit1Java ppts unit1
Java ppts unit1
Priya11Tcs
 
1- java
1- java1- java
1- java
Krishna Sujeer
 
Java review00
Java review00Java review00
Java review00
saryu2011
 
basic_java.ppt
basic_java.pptbasic_java.ppt
basic_java.ppt
sujatha629799
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
juliasceasor
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
Fundamentals of oop lecture 2
Fundamentals of oop lecture 2Fundamentals of oop lecture 2
Fundamentals of oop lecture 2
miiro30
 
Java platform
Java platformJava platform
Java platform
BG Java EE Course
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
Narcisa Velez
 
introduction to java-final with Unit Nexus
introduction to java-final with Unit Nexus introduction to java-final with Unit Nexus
introduction to java-final with Unit Nexus
Unit Nexus Pvt. Ltd.
 
1 java fundamental KSHRD
1   java fundamental KSHRD1   java fundamental KSHRD
1 java fundamental KSHRD
Tola Meng
 
ITFT - Java Coding
ITFT - Java CodingITFT - Java Coding
ITFT - Java Coding
Blossom Sood
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
Zeeshan MIrza
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
sotlsoc
 
JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).ppt
AliyaJav
 
Java Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece departmentJava Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece department
om2348023vats
 
Java ppts unit1
Java ppts unit1Java ppts unit1
Java ppts unit1
Priya11Tcs
 
Java review00
Java review00Java review00
Java review00
saryu2011
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
juliasceasor
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
Fundamentals of oop lecture 2
Fundamentals of oop lecture 2Fundamentals of oop lecture 2
Fundamentals of oop lecture 2
miiro30
 
introduction to java-final with Unit Nexus
introduction to java-final with Unit Nexus introduction to java-final with Unit Nexus
introduction to java-final with Unit Nexus
Unit Nexus Pvt. Ltd.
 
1 java fundamental KSHRD
1   java fundamental KSHRD1   java fundamental KSHRD
1 java fundamental KSHRD
Tola Meng
 
Ad

More from R. Sosa (20)

All Lectures DECO1006 and DECO2016 in 2025.pdf
All Lectures DECO1006 and DECO2016 in 2025.pdfAll Lectures DECO1006 and DECO2016 in 2025.pdf
All Lectures DECO1006 and DECO2016 in 2025.pdf
R. Sosa
 
Zomia Barbarians by Design. Autonomy and Resistance
Zomia Barbarians by Design. Autonomy and ResistanceZomia Barbarians by Design. Autonomy and Resistance
Zomia Barbarians by Design. Autonomy and Resistance
R. Sosa
 
Design Lab guest lecture in Engineering 2025
Design Lab guest lecture in Engineering 2025Design Lab guest lecture in Engineering 2025
Design Lab guest lecture in Engineering 2025
R. Sosa
 
El Buen Vivir, notas del libro Sumak Kawsay 2009
El Buen Vivir, notas del libro Sumak Kawsay 2009El Buen Vivir, notas del libro Sumak Kawsay 2009
El Buen Vivir, notas del libro Sumak Kawsay 2009
R. Sosa
 
Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...
Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...
Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...
R. Sosa
 
bell hooks all about love quotes from her book
bell hooks all about love quotes from her bookbell hooks all about love quotes from her book
bell hooks all about love quotes from her book
R. Sosa
 
Design Jam Embark University of Sydney 2024
Design Jam Embark University of Sydney 2024Design Jam Embark University of Sydney 2024
Design Jam Embark University of Sydney 2024
R. Sosa
 
Arte, Diseño y Tecnología como Obstáculos para el Humanismo Mexicano
Arte, Diseño y Tecnología como Obstáculos para el Humanismo MexicanoArte, Diseño y Tecnología como Obstáculos para el Humanismo Mexicano
Arte, Diseño y Tecnología como Obstáculos para el Humanismo Mexicano
R. Sosa
 
Luis Porter Imaginacion y Educacion del Disenño.pptx
Luis Porter Imaginacion y Educacion del Disenño.pptxLuis Porter Imaginacion y Educacion del Disenño.pptx
Luis Porter Imaginacion y Educacion del Disenño.pptx
R. Sosa
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
R. Sosa
 
Week 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo SosaWeek 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo Sosa
R. Sosa
 
Causation
CausationCausation
Causation
R. Sosa
 
100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN
R. Sosa
 
Edgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideasEdgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideas
R. Sosa
 
USYD Virtual Design lecture
USYD Virtual Design lectureUSYD Virtual Design lecture
USYD Virtual Design lecture
R. Sosa
 
Design School Confidential Class Projects
Design School Confidential Class ProjectsDesign School Confidential Class Projects
Design School Confidential Class Projects
R. Sosa
 
La Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio RamonetLa Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio Ramonet
R. Sosa
 
Apocalípticos e Integrados
Apocalípticos e IntegradosApocalípticos e Integrados
Apocalípticos e Integrados
R. Sosa
 
Understanding Computers and Cognition
Understanding Computers and CognitionUnderstanding Computers and Cognition
Understanding Computers and Cognition
R. Sosa
 
Convivial Toolbox
Convivial ToolboxConvivial Toolbox
Convivial Toolbox
R. Sosa
 
All Lectures DECO1006 and DECO2016 in 2025.pdf
All Lectures DECO1006 and DECO2016 in 2025.pdfAll Lectures DECO1006 and DECO2016 in 2025.pdf
All Lectures DECO1006 and DECO2016 in 2025.pdf
R. Sosa
 
Zomia Barbarians by Design. Autonomy and Resistance
Zomia Barbarians by Design. Autonomy and ResistanceZomia Barbarians by Design. Autonomy and Resistance
Zomia Barbarians by Design. Autonomy and Resistance
R. Sosa
 
Design Lab guest lecture in Engineering 2025
Design Lab guest lecture in Engineering 2025Design Lab guest lecture in Engineering 2025
Design Lab guest lecture in Engineering 2025
R. Sosa
 
El Buen Vivir, notas del libro Sumak Kawsay 2009
El Buen Vivir, notas del libro Sumak Kawsay 2009El Buen Vivir, notas del libro Sumak Kawsay 2009
El Buen Vivir, notas del libro Sumak Kawsay 2009
R. Sosa
 
Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...
Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...
Health Futures Participatory Design for Creative Youth Agency and Disaster Pr...
R. Sosa
 
bell hooks all about love quotes from her book
bell hooks all about love quotes from her bookbell hooks all about love quotes from her book
bell hooks all about love quotes from her book
R. Sosa
 
Design Jam Embark University of Sydney 2024
Design Jam Embark University of Sydney 2024Design Jam Embark University of Sydney 2024
Design Jam Embark University of Sydney 2024
R. Sosa
 
Arte, Diseño y Tecnología como Obstáculos para el Humanismo Mexicano
Arte, Diseño y Tecnología como Obstáculos para el Humanismo MexicanoArte, Diseño y Tecnología como Obstáculos para el Humanismo Mexicano
Arte, Diseño y Tecnología como Obstáculos para el Humanismo Mexicano
R. Sosa
 
Luis Porter Imaginacion y Educacion del Disenño.pptx
Luis Porter Imaginacion y Educacion del Disenño.pptxLuis Porter Imaginacion y Educacion del Disenño.pptx
Luis Porter Imaginacion y Educacion del Disenño.pptx
R. Sosa
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
R. Sosa
 
Week 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo SosaWeek 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo Sosa
R. Sosa
 
100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN
R. Sosa
 
Edgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideasEdgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideas
R. Sosa
 
USYD Virtual Design lecture
USYD Virtual Design lectureUSYD Virtual Design lecture
USYD Virtual Design lecture
R. Sosa
 
Design School Confidential Class Projects
Design School Confidential Class ProjectsDesign School Confidential Class Projects
Design School Confidential Class Projects
R. Sosa
 
La Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio RamonetLa Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio Ramonet
R. Sosa
 
Apocalípticos e Integrados
Apocalípticos e IntegradosApocalípticos e Integrados
Apocalípticos e Integrados
R. Sosa
 
Understanding Computers and Cognition
Understanding Computers and CognitionUnderstanding Computers and Cognition
Understanding Computers and Cognition
R. Sosa
 
Convivial Toolbox
Convivial ToolboxConvivial Toolbox
Convivial Toolbox
R. Sosa
 

Recently uploaded (20)

AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 

Java Programming for Designers

  • 1. Java Programming (for designers)
  • 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 &quot;1.&quot; 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 Write a .java file Compile it with the javac command Now you have a .class file Run it with the java command Voilá!
  • 17. Running a Java Application Write 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(&quot;Hello World!&quot;, 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).
  • 30. Example An Evolutionary Design System
  • 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(&quot;Evolutionary Design&quot;); jMenuFile.setText(&quot;File&quot;);… 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(&quot;minMean&quot;)) { 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