Download Semiotic Oriented Autonomous Intelligent Systems - DCA

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Implementation using JAVA
DCA-FEEC-UNICAMP
Ricardo Gudwin
From Design to Implementation
 Design Phase
development of a logical solution to the problem
 Implementation Phase
start the process of program construction
 Main Implementation Steps
Constructive Design
Coding
Testing
Documenting
 Main Results
Constructive Design Documentation
Program Code
Program Manual
From Design to Implementation
 Constructive Design
Object reuse
from older projects
from development tools API’s and frameworks
Based on the selected encoding language and development tool
Follows the same basic principles from design phase
 Constructive Design Documentation
Based on design documentation
Interaction Diagrams
Software Class Diagrams
Details the parts of diagrams including reused objects and
classes
Contracts are substituted by Method code
Constructive Design
 Some care with the Constructive Design Diagrams
Software Class Diagram
Set of Navigability in associations
Set of Role Names in associations
Set of Multiplicity in associations
Extraction of unnecessary associations
Interaction Diagram
Use of extended message notation, when required
Decomposition to avoid bloated diagrams
 Condition to start Constructive Design
understanding the objects/classes available from the
development tool/language API’s and frameworks
mixing reused objects and new objects in a consistent way
Java API’s and Frameworks
 Java Frameworks
Java Applet Framework - basics for Java applets
Java Commerce Framework - secure monetary transactions
Java Enterprise Framework - object and database-access
services for distributed systems (includes CORBA)
Java Server Framework - development of servers
Java Media Framework - graphics, video, audio and animation
Java Security Framework - authentication, digital signatures,
encryption
Java Beans Framework - Java native component model
 Objects are distributed within “packages”
imported to source code using the “import” instruction
Java Platform Packages
java.applet
java.awt
java.beans
java.io
java.lang
java.math
java.net
java.rmi
java.security
Provides the classes necessary to create an applet and the classes an applet uses to
communicate with its applet context.
Contains all of the classes for creating user interfaces and for painting graphics and
images.
Contains classes related to Java Beans development.
Provides for system input and output through data streams, serialization and the file
system.
Provides classes that are fundamental to the design of the Java programming
language.
Provides classes for performing arbitrary-precision integer arithmetic (BigInteger)
and arbitrary-precision decimal arithmetic (BigDecimal).
Provides the classes for implementing networking applications.
Provides the RMI package.
Provides the classes and interfaces for the security framework.
Java Platform Packages
java.sql
java.text
java.util
javax.accessibility
javax.swing
org.omg.CORBA
Provides the JDBC package.
Provides classes and interfaces for handling text, dates, numbers, and messages in a
manner independent of natural languages.
Contains the collections framework, legacy collection classes, event model, date and
time facilities, internationalization, and miscellaneous utility classes (a string
tokenizer, a random-number generator, and a bit array).
Defines a contract between user-interface components and an assistive technology
that provides access to those components.
Provides a set of "lightweight" (all-Java language) components that, to the maximum
degree possible, work the same on all platforms.
Provides the mapping of the OMG CORBA APIs to the JavaTM programming
language, including the class ORB, which is implemented so that a programmer can
use it as a fully-functional Object Request Broker (ORB).
Java Foundation Classes
 Java Foundation Classes (JFC)
AWT
Abstract Window Toolkit
Java™ 2D
Java 2D is a graphics API based on technology licensed from
IBM/Taligent
Accessibility
provides assistive technologies, like screen magnifiers, for use with
the various pieces of JFC
Drag and Drop
part of the next JavaBean™ generation, "Glasgow," also available
with the Java® 2 platform.
Swing
set of well-groomed widgets and a framework to specify how
GUIs are visually presented, independent of platform.
Swing
 Swing widgets
simply extend AWT by adding a new set of components, the
JComponents, and a group of related support classes.
are all JavaBeans and participate in the JavaBeans event model.
 Subset of Swing widgets
analogous to the basic AWT widgets.
lightweight components
 Lightweight component architecture
introduced in AWT 1.1.
allows components to exist without native operating system
widgets
participate in the Model/View/Controller (MVC) architecture
 New widgets
trees, tabbed panes, and splitter panes
Swing Widgets
Creating and Managing
Windows
 Panels
JPanel - The basic container
 Layout Manager
Organizes widgets within a container
BorderLayout, GridLayout, FlowLayout, etc…
 The Main Window
JFrame - a window with decorations
has content panel - JPanel
 Events and Listeners
Application listeners implement standard listener interfaces,
based on the desired events
are further added to the desired component
Creating and Managing
Windows
b1=JButton
4: new
7: addActionListener(mb)
JFrame
ActionListener
MainWindowClass
MyButtonListener
5: new
8: addActionListener(mb)
2: panel = getContentPane()
b2=JButton
1: new
6: new
Kernel
MainWindow:MainWindowClass
mb=MyButtonListener
3: setLayout(new BorderLayout)
9: add(b1)
10: add(b2)
panel:JPanel
Drawing on a Window
 All JComponent (including JPanels) can be drawn over
overriding the method “paint”
public void paint(Graphics g)
 The “Graphics object”
provide a full set of methods for drawing, filling, etc.
 Graphics2D
extends the Graphics class to provide more sophisticated control
over geometry,coordinate transformations, color management,
and text layout
fundamental class for rendering 2-dimensional shapes, text and
images
public void paint(Graphics g)
{Graphics2D g2 = (Graphics2D) g;
…
}
Basics on Java
 The starting object
implements the method “main”
public static void main(String[] args)
callable from the o.s. environment
 Exceptions
the try-catch/throws mechanism
 Special objects
super and this
 Inner Classes
used to derive specialized listeners and adapters
 Interfaces, Classes and Abstract Classes
Basics on Java
 Listeners and Adapters
Listener - interface (need to be implemented)
Adapter - basic class implementing a listener (need to be
extended)
 Class Modifiers
public, abstract, final
 Field Modifiers
static, final, transient, volatile
 Method Modifiers
public, protected, private, abstract, static, final, synchronized,
native
 Special statements
throw, synchronized
Basics on Java
 Thread Programming
The Java Virtual Machine allows an application to have multiple
threads of execution running concurrently
 Priorities
 Daemons and Non-Daemons Threads
 Two ways to create a new thread of execution
declare a class to be a subclass of Thread
override the “run” method of class Thread
instance of the subclass can then be allocated and started by
calling its method “start”
declare a class that implements the Runnable interface
implements the “run” method
instance of the class can then be allocated and passed as an
argument when creating a Thread object that is further started
Converting Diagrams to Code
public class Class3 {
int i = 0;
float method (float i, float j)
{ ...
}
}
Class3
i : int = 0
method (i : float, j : float) : float
Class5
wop : int
rCl5
init () : void
rCl1
public class Class2 {
int i = 0;
void opera(int k)
{ ...
}
}
Class1
a : int = 5
b : float = 3.4
func (c : int) : double
rCl4
public class Class1 extends Class3 {
int a = 5;
float b = 3.4;
Class2 rCl2;
Class4 rCl4;
Class5 rCl5;
}
rCl2
Class4
att : int
Class2
i : int = 0
foo () : void
opera (k : t) : void
public class Class4 {
int att;
void foo()
{ ...
}
}
public class Class5 {
int wop;
Class1 rCl1;
void init()
{ ...
}
}
Converting Diagrams to Code
1: create
2: create
a : Class1
b : Class2
3: create
4: create
c : Class4
i : Class5
public class Class1 extends Class3 {
int a = 5;
float b = 3.4;
Class2 rCl2;
Class4 rCl4;
Class5 rCl5;
void Class1()
{rCl2 = new Class2();
rCl4 = new Class4();
rCl5 = new Class5();
}
}