7

Click here to load reader

Ingles proyecto traducido

Embed Size (px)

Citation preview

Page 1: Ingles proyecto traducido

UNIVERSIDAD TÉCNICA DE MANABÍ

FACULTAD DE CIENCIAS INFORMÁTICAS

CARRERA DE INGENIERÍA EN SISTEMAS

Alumno:

Vélez Sánchez José Manuel

Tema:

POLIMORFISMO – HERENCIA Y PROGRAMACIÓN

GRAFICA EN JAVA

Fecha:

22-01-2013

Curso:

3 “C”

Docente:

Ing. Danny Jarre

Periodo académico

Sept 2012 – enero 2013

Page 2: Ingles proyecto traducido

FACULTAD DE CIENCIAS INFORMÀTICAS

MISIÓN:

Ser una unidad con alto prestigio académico, con eficiencia, transparencia y calidad en la

educación, organizada en sus actividades, protagonistas del progreso regional y nacional.

VISIÓN:

Formar profesionales eficientes e innovadores en el campo de las ciencias informáticas, que

con honestidad, equidad y solidaridad, den respuestas a las necesidades de la sociedad

elevando su nivel de vida.

Page 3: Ingles proyecto traducido

INHERITANCE

Inheritance is a mechanism that allows the definition of a class from an existing definition.

Inheritance allows automatically share methods and data between classes, subclasses and

objects.

Inheritance is strongly related to code reuse in OOP. That is, the code of any class can be

used no more than create a class derived from it, or a subclass.

There are two types of single and multiple inheritance. Single means only inherit from a

base class, while we have several shows multiple base classes (eg inherits a seaplane and

boat tickets). Java only supports single inheritance.

STATEMENT

To indicate that a class derived from another, inheriting properties (attributes and

methods) extends the term is used, as in the following example:

public class SubClass extends SuperClass

{

/ / Class Content

}

For example, create a class MiPunto3D, daughter Mipunto class as shown:

Mipunto MiPunto3D class extends {

int z;

MiPunto3D () {

x = 0; / / Inherited from Mipunto

y = 0; / / Inherited from Mipunto

z = 0; / / New Attribute

}

}

Page 4: Ingles proyecto traducido

The extends keyword is used to say that we want to create a subclass of the class that is

named below, in our case is MiPunto3D Mipunto daughter.

POLYMORPHISM

Polymorphism is a concept of object-oriented programming that allows us to program in

general, rather than specifically. Overall we used to program objects with common

characteristics and that all these share the same superclass in a class hierarchy, as if they

were all objects of the superclass. This simplifies programming us.

Remember the example of the ecosystem, where all objects of different species inherited

from a superclass called Animal, which provided an overview of any animal, regardless of

species. However, each kind of particular use for each of the methods or operations

class is

{

CalcularPerimetro ();

}

Now we derive two classes of the class is, one is rectangle, and a pentagon.

Class :: rectangle shape

{

CalcularPerimetro ();

}

Class :: pentagon shape

{

CalcularPerimetro ()

}

Rectangle and Pentagon are ways, but each calculates its perimeter differently, so each

has its perimeter function.

Now imagine you have a variable of type form:

object form;

Page 5: Ingles proyecto traducido

Well, polymorphism says you can do this:

object = devolverForma ();

objeto.CalcularPerimetro ();

devolverForma () can return a rectangle, pentagon or an object, you do not know which of

the two things will return, and you do not care, you just call CalcularPerimetro, and

whether it is a pentagon or a rectangle, you use function correct (the Pentagon or the

rectangle).

That is polymorphism.

GRAPHIC PRORAMACION

INTRODUCTION

The user interface is the part of the program that allows it to interact with the user. User

interfaces can take many forms, ranging from simple command line to graphical user

interfaces (GUI-GUI) that provide the latest software. The user interface is one of the most

important aspects of any application. An application without a user-friendly interface, it

prevents users get the most from the program. Java provides the basic elements for

building user interfaces through the AWT class library, and options for improvement

through a new library called Swing. Because the Java programming language is

independent of the platform on which to run their applications, the AWT library is also

independent of the platform on which it runs. The AWT provides a toolkit for building

graphical interfaces that look and behave similarly on all platforms on which to run. The

interface elements provided by the AWT library are implemented using native toolkits

platforms, preserving an appearance similar to all applications that are created for that

platform. This is a strength of the AWT, but also has the disadvantage that a graphical

interface designed for one platform can not display properly in a different one. These

deficiencies are remedied AWT Swing in part, and in general by the JFC (JavaFoundation

Classes).

Page 6: Ingles proyecto traducido

AWT (Abstract Window Toolkit)

AWT is the acronym for Java Abstract Window Toolkit. This is a Java class library for

developing graphical user interfaces. The AWT version that Sun provides the JDK 1.0.x

developed in only two months and is the weakest part of everything that represents Java

as a language.

GUI INTERFACE

We call GUI GUI (Graphical User Interface) to the set of graphical components that allow

interaction between the user and the application. Ventnas ie, buttons, combos, lists,

dialog boxes, text fields, etc.

First we have to design the application, and finally programmed events that are

generated as the user interacts with the interface.

Components are objects of classes that inherit from the base class component like

Button, List, TextField, TextArea, Label, etc..

In a GUI components are contained in containers or containers. A containes is an object

whose class inherits from Container (class which in turn is subclass of Component) and has

the responsibility for containing components.

Usually a GUI is mounted on a frame. This will be the main Container containing the

components of the GUI, a Container can contain other containers.

Distribution of components (layouts)

The containers containing components and these are arranged in the visual space of the

container respetanto unaa some call distribution layout.

AWT and Swing

Java provides two API's with which we can work to develop GUIs, the most basic is AWT

(Abstrct Window Toolkit). The most developed are made with Swing, which are

identifiable because they all begin with "J", eg JButton, JTextField, JTextArea, JFrame and

JPanel are Swing classes.

All layouts and event handling is exactly the same for AWT and Swing.

Page 7: Ingles proyecto traducido

Relative distributions

The layouts determine the criterion by which to distribute vaan components within the

container

FlowLayout: distributes the components beside each other in the upper container. By

default provides a center alignment, but also can align to the left or right.

BorderLayout: Divide the space of the container in 5 regions: NORTH, SOUTH, EAST, WEST

and CENTER, supports a single component by region

GridLayout: Divide the space of the container into a grid of n rows by m columns, where

the cells are of equal size

GridBagLayout: Divide the space of the container into a grid where each component can

span multiple rows and columns. In addition to distribute the internal space of each cell.

To draw need an instance of the Graphics class. This class must be associated to the

component on which we draw to draw on it. For an instance of this class of a

componentel, simply ask the component in which we draw a Graphics. E.g.

Canvas canvas = new Canvas ();

Graphics g = lienzo.getGraphics ();

g.drawLine (...);

The Graphics class has methods of drawing style drawLine (), drawRectangle (), etc.. Since

that we have obtained the Graphics Canvas, what you draw with the Graphics will be

drawn on the Canvas. The problem is that this will not work well. When component (the

Canvas), need repainting, because it passes over another window, because we minimize it

and then we maximize or for whatever reason, do not redraw our drawing.