Mercoledi' 16 Ottobre 2002 : 13 31 4 - zito da 193.204.188.254

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class Ovale extends JApplet implements ActionListener {
Timer timer;
Display disegno;
double r,r1,spessore,rcavanti,rcdietro,xcavanti,xcdietro;
double rcravanti,rcrdietro,xcravanti,xcrdietro;
Image img;
double xmin,xmax,ymin,ymax;
double xim,xog;
public void init(){

xmin = -5.0;//mm
xmax = 42.0;ymin = -20.5;ymax = 27.5;
xim = 31.;xog=-1000.;
img=getImage(getCodeBase(),"eye.gif");

disegno = new Display(this);
setContentPane(disegno);
r=12.8 ;r1=11.8;spessore=.5;
xcavanti=-2.5;xcdietro=-2.1; rcavanti=7.25; rcdietro=5.68;
xcravanti=1.1;xcrdietro=-8.1; rcravanti=9.67; rcrdietro=6.32;
disegno.setBackground(Color.yellow);
}
public void start() {
if (timer == null) {
timer = new Timer(100,this);
timer.start();
}
}

public void stop() {
if (timer != null) {
timer.stop();
}
}

public void actionPerformed(ActionEvent e) {
xim = xim + 3./100.;if(xim > 34.) stop();
xog = xog + 980./100.;
disegno.repaint();
}

class Display extends JPanel {
int larghezza, altezza;
Ovale appl;
Display(Ovale appl1){appl=appl1;}
public void paintComponent(Graphics g){
larghezza = getSize().width;
altezza = getSize().height;
super.paintComponent(g);
//g.drawImage(img,5,152, this);
g.setColor(Color.black);
//g.drawLine(xconv(x),yconv(-.5),xconv(x),yconv(.5));
double xbar;
for( xbar=xmin;xbar g.drawLine(xconv(xbar),yconv(-.5),xconv(xbar),yconv(.5)); }
double ybar;
for( ybar=-20.;ybar g.drawLine(xconv(-.5),yconv(ybar),xconv(+.5),yconv(ybar)); }

g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(xim),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(xim),yconv(0.));
/*
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(34.),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(34.),yconv(0.));
*/

g.drawLine(xconv(xmin),yconv(0.),xconv(xmax),yconv(0.));
g.drawLine(xconv(0.),yconv(ymin),xconv(0.),yconv(ymax));
g.setColor(Color.black);
//System.out.println(xconv(0.)+" "+yconv(r)+" "+xconv(2*r)+" "+yconv(-r));
g.drawArc(xconv(-spessore/2.),yconv(r),xconv(2*r-spessore/2.)-xconv(-spessore/2.),yconv(-r)-yconv(r),210,300);
g.drawArc(xconv(spessore/2.),yconv(r1),xconv(2*r1+spessore/2.)-xconv(spessore/2.),yconv(-r1)-yconv(r1),210,300);
g.setColor(Color.red);
g.drawArc(xconv(xcavanti),yconv(rcavanti),xconv(2*rcavanti+xcavanti)-xconv(xcavanti),yconv(-rcavanti)-yconv(rcavanti),240,-120);
g.drawArc(xconv(xcdietro),yconv(rcdietro),xconv(2*rcdietro+xcdietro)-xconv(xcdietro),yconv(-rcdietro)-yconv(rcdietro),240,-120);

g.setColor(Color.green);
g.drawArc(xconv(xcravanti),yconv(rcravanti),xconv(2*rcravanti+xcravanti)-xconv(xcravanti),yconv(-rcravanti)-yconv(rcravanti),209,-60);
g.drawArc(xconv(xcrdietro),yconv(rcrdietro),xconv(2*rcrdietro+xcrdietro)-xconv(xcrdietro),yconv(-rcrdietro)-yconv(rcrdietro),50,-99);
}
int xconv(double x){
return((int)((x-xmin)/(xmax-xmin)*larghezza));
}
int yconv(double y){return(altezza-(int)((y-ymin)/(ymax-ymin)*altezza));
}
}

}
Mercoledi' 16 Ottobre 2002 : 13 33 2 - zito da 193.204.188.254
Idee su come completare l'applet
Mercoledi' 16 Ottobre 2002 : 13 33 5 - pc 9 da labmul8.fisica.uniba.it 193.204.188.65
aggiungere le ciglia
Mercoledi' 16 Ottobre 2002 : 13 36 4 - Anonimo da labmul12.fisica.uniba.it 193.204.188.69
mettiamoci l'ombretto
Mercoledi' 16 Ottobre 2002 : 13 36 5 - Anonimo da labmul6.fisica.uniba.it 193.204.188.63
inserire un pulsante che disabiliti/abiliti l'azione del cristallino
Mercoledi' 16 Ottobre 2002 : 13 39 - claudio da labmul1.fisica.uniba.it 193.204.188.58
inserire un campo in cui si puņ regolareil fuoco
Mercoledi' 16 Ottobre 2002 : 13 39 1 - Anonimo da labmul3.fisica.uniba.it 193.204.188.60
mostrare una barra che accomodi il cristallino
Mercoledi' 16 Ottobre 2002 : 14 9 1 - Anonimo da labmul5.fisica.uniba.it 193.204.188.62
CIAO A TUTTI!!! (punto java)
Mercoledi' 16 Ottobre 2002 : 14 9 3 - zito da 193.204.188.254

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class Ovale extends JApplet implements ActionListener {
Timer timer;
Display disegno;
JPanel p1;
JButton b1,b2;
double r,r1,spessore,rcavanti,rcdietro,xcavanti,xcdietro;
double rcravanti,rcrdietro,xcravanti,xcrdietro;
Image img;
double xmin,xmax,ymin,ymax;
double xim,xog;
public void init(){

xmin = -5.0;//mm
xmax = 42.0;ymin = -20.5;ymax = 27.5;
xim = 31.;xog=-1000.;
img=getImage(getCodeBase(),"eye.gif");

disegno = new Display(this);
getContentPane().setLayout(new
BorderLayout());
getContentPane().add(disegno,
BorderLayout.CENTER);
p1 = new JPanel();
getContentPane().add(p1,
BorderLayout.NORTH);
b1 = new JButton("Start animazione");
b2 = new JButton("Togli cristallino");
p1.add(b1);p1.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);

r=12.8 ;r1=11.8;spessore=.5;
xcavanti=-2.5;xcdietro=-2.1; rcavanti=7.25; rcdietro=5.68;
xcravanti=1.1;xcrdietro=-8.1; rcravanti=9.67; rcrdietro=6.32;
disegno.setBackground(Color.yellow);
}
public void start() {
if (timer == null) {
timer = new Timer(100,this);
timer.start();
}
}

public void stop() {
if (timer != null) {
timer.stop();
}
}

public void actionPerformed(ActionEvent e) {
if(e.getSource()==timer){
xim = xim + 3./100.;if(xim > 34.) stop();
xog = xog + 980./100.;
disegno.repaint();}
if(e.getSource()==b1){}
if(e.getSource()==b2){}
}

class Display extends JPanel {
int larghezza, altezza;
Ovale appl;
Display(Ovale appl1){appl=appl1;}
public void paintComponent(Graphics g){
larghezza = getSize().width;
altezza = getSize().height;
super.paintComponent(g);
//g.drawImage(img,5,152, this);
g.setColor(Color.black);
//g.drawLine(xconv(x),yconv(-.5),xconv(x),yconv(.5));
double xbar;
for( xbar=xmin;xbar g.drawLine(xconv(xbar),yconv(-.5),xconv(xbar),yconv(.5)); }
double ybar;
for( ybar=-20.;ybar g.drawLine(xconv(-.5),yconv(ybar),xconv(+.5),yconv(ybar)); }

g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(xim),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(xim),yconv(0.));
/*
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(34.),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(34.),yconv(0.));
*/

g.drawLine(xconv(xmin),yconv(0.),xconv(xmax),yconv(0.));
g.drawLine(xconv(0.),yconv(ymin),xconv(0.),yconv(ymax));
g.setColor(Color.black);
//System.out.println(xconv(0.)+" "+yconv(r)+" "+xconv(2*r)+" "+yconv(-r));
g.drawArc(xconv(-spessore/2.),yconv(r),xconv(2*r-spessore/2.)-xconv(-spessore/2.),yconv(-r)-yconv(r),210,300);
g.drawArc(xconv(spessore/2.),yconv(r1),xconv(2*r1+spessore/2.)-xconv(spessore/2.),yconv(-r1)-yconv(r1),210,300);
g.setColor(Color.red);
g.drawArc(xconv(xcavanti),yconv(rcavanti),xconv(2*rcavanti+xcavanti)-xconv(xcavanti),yconv(-rcavanti)-yconv(rcavanti),240,-120);
g.drawArc(xconv(xcdietro),yconv(rcdietro),xconv(2*rcdietro+xcdietro)-xconv(xcdietro),yconv(-rcdietro)-yconv(rcdietro),240,-120);

g.setColor(Color.green);
g.drawArc(xconv(xcravanti),yconv(rcravanti),xconv(2*rcravanti+xcravanti)-xconv(xcravanti),yconv(-rcravanti)-yconv(rcravanti),209,-60);
g.drawArc(xconv(xcrdietro),yconv(rcrdietro),xconv(2*rcrdietro+xcrdietro)-xconv(xcrdietro),yconv(-rcrdietro)-yconv(rcrdietro),50,-99);
}
int xconv(double x){
return((int)((x-xmin)/(xmax-xmin)*larghezza));
}
int yconv(double y){return(altezza-(int)((y-ymin)/(ymax-ymin)*altezza));
}
}

}
Mercoledi' 16 Ottobre 2002 : 14 31 4 - Anonimo da labmul5.fisica.uniba.it 193.204.188.62
CON AFFETTO

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class Ovale extends JApplet implements ActionListener {
Timer timer;
Display disegno;
JPanel p1;
JButton b1,b2;
double r,r1,spessore,rcavanti,rcdietro,xcavanti,xcdietro;
double rcravanti,rcrdietro,xcravanti,xcrdietro;
Image img;
double xmin,xmax,ymin,ymax;
double xim,xog;
public void init(){
xmin = -5.0;//mm
xmax = 42.0;ymin = -20.5;ymax = 27.5;
xim = 31.;xog=-1000.;
img=getImage(getCodeBase(),"eye.gif");

disegno = new Display(this);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(disegno, BorderLayout.CENTER);
p1 = new JPanel();
b1 = new JButton("Start animazione");
b2 = new JButton("Togli il cristallino");
p1.add(b1);p1.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);

getContentPane().add(p1, BorderLayout.NORTH);




r=12.8 ;r1=11.8;spessore=.5;
xcavanti=-2.5;xcdietro=-2.1; rcavanti=7.25; rcdietro=5.68;
xcravanti=1.1;xcrdietro=-8.1; rcravanti=9.67; rcrdietro=6.32;
disegno.setBackground(Color.pink);
}
public void startanim() {
if (timer == null) {
timer = new Timer(100,this);
timer.start();
}
}

public void stopanim() {
if (timer != null) {
timer.stop();
}
}

public void actionPerformed(ActionEvent e) {
if(e.getSource()== timer){
xim = xim + 3./100.;if(xim > 34.) stopanim();
xog = xog + 980./100.;
disegno.repaint();}
if(e.getSource()== b1){
if(e.getActionCommand().equals ("Start animazione")){
b1.setText("Stop animazione");startanim();}
if(e.getActionCommand().equals ("Stop animazione")){
b1.setText("Start animazione");stopanim();
xim = 31.;xog=-1000.;
}

}
if(e.getSource()== b2){}
}

class Display extends JPanel {
int larghezza, altezza;
Ovale appl;
Display(Ovale appl1){appl=appl1;}
public void paintComponent(Graphics g){
larghezza = getSize().width;
altezza = getSize().height;
super.paintComponent(g);
//g.drawImage(img,5,152, this);
g.setColor(Color.black);
//g.drawLine(xconv(x),yconv(-.5),xconv(x),yconv(.5));
double xbar;
for( xbar=xmin;xbarg.drawLine(xconv(xbar),yconv(-.5),xconv(xbar),yconv(.5)); }
double ybar;
for( ybar=-20.;ybarg.drawLine(xconv(-.5),yconv(ybar),xconv(+.5),yconv(ybar)); }

g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(xim),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(xim),yconv(0.));
/*
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(34.),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(34.),yconv(0.));
*/

g.drawLine(xconv(xmin),yconv(0.),xconv(xmax),yconv(0.));
g.drawLine(xconv(0.),yconv(ymin),xconv(0.),yconv(ymax));
g.setColor(Color.white);
//System.out.println(xconv(0.)+" "+yconv(r)+" "+xconv(2*r)+" "+yconv(-r));
g.drawArc(xconv(-spessore/2.),yconv(r),xconv(2*r-spessore/2.)-xconv(-spessore/2.),yconv(-r)-yconv(r),210,300);
g.drawArc(xconv(spessore/2.),yconv(r1),xconv(2*r1+spessore/2.)-xconv(spessore/2.),yconv(-r1)-yconv(r1),210,300);
g.setColor(Color.yellow);
g.drawArc(xconv(xcavanti),yconv(rcavanti),xconv(2*rcavanti+xcavanti)-xconv(xcavanti),yconv(-rcavanti)-yconv(rcavanti),240,-120);
g.drawArc(xconv(xcdietro),yconv(rcdietro),xconv(2*rcdietro+xcdietro)-xconv(xcdietro),yconv(-rcdietro)-yconv(rcdietro),240,-120);

g.setColor(Color.green);
g.drawArc(xconv(xcravanti),yconv(rcravanti),xconv(2*rcravanti+xcravanti)-xconv(xcravanti),yconv(-rcravanti)-yconv(rcravanti),209,-60);
g.drawArc(xconv(xcrdietro),yconv(rcrdietro),xconv(2*rcrdietro+xcrdietro)-xconv(xcrdietro),yconv(-rcrdietro)-yconv(rcrdietro),50,-99);
}
int xconv(double x){
return((int)((x-xmin)/(xmax-xmin)*larghezza));
}
int yconv(double y){return(altezza-(int)((y-ymin)/(ymax-ymin)*altezza));
}
}

}

Mercoledi' 16 Ottobre 2002 : 14 33 2 - mascalzone latino da labmul14.fisica.uniba.it 193.204.188.72

AIUTO!!!

Mercoledi' 16 Ottobre 2002 : 14 41 - Anonimo da labmul2.fisica.uniba.it 193.204.188.59

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class Ovale extends JApplet implements ActionListener {
Timer timer;
Display disegno;
JPanel p1;
JButton b1;
JButton b2;
double r,r1,spessore,rcavanti,rcdietro,xcavanti,xcdietro;
double rcravanti,rcrdietro,xcravanti,xcrdietro;
Image img;
double xmin,xmax,ymin,ymax;
double xim,xog;
public void init(){

xmin = -5.0;//mm
xmax = 42.0;ymin = -20.5;ymax = 27.5;
xim = 31.;xog=-1000.;
img=getImage(getCodeBase(),"eye.gif");

disegno = new Display(this);
getContentPane().setLayout(new
BorderLayout());
getContentPane().add(disegno,BorderLayout.CENTER);

/* getContentPane().setLayout(new BorderLayout()); // create a layout mgr

_textField=new JTextField(); // input fld
_textField.setText("12 24 15 76 54 15");// sample data for starters
getContentPane().add("North", _textField);

_barChart=new BarChart(_set, _width, 150);
getContentPane().add("Center", _barChart);

setContentPane(disegno); */

p1 = new JPanel();
getContentPane().add(p1,BorderLayout.NORTH);

b1 = new JButton("Start animazione");
b2 = new JButton("Togli cristallino");
p1.add(b1); p1.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);


r=12.8 ;r1=11.8;spessore=.5;
xcavanti=-2.5;xcdietro=-2.1; rcavanti=7.25; rcdietro=5.68;
xcravanti=1.1;xcrdietro=-8.1; rcravanti=9.67; rcrdietro=6.32;
disegno.setBackground(Color.yellow);
}
public void startanim() {
if (timer == null) {
timer = new Timer(100,this);
timer.start();
}
else { timer.restart();}
}

public void stopanim() {
if (timer != null) {
timer.stop();
}
}

public void actionPerformed(ActionEvent e) {
if(e.getSource()==timer){

xim = xim + 3./100.;if(xim > 34.) stopanim();
xog = xog + 980./100.;
disegno.repaint();}
if(e.getSource()==b1){
if(e.getActionCommand().equals("Start animazione")){b1.setText("Stop animazione"); startanim();}
if(e.getActionCommand().equals("Stop animazione")){b1.setText("Start animazione"); stopanim();
xim = 31.;xog=-1000.;
}


}
if(e.getSource()==b2){}



}

class Display extends JPanel {
int larghezza, altezza;
Ovale appl;
Display(Ovale appl1){appl=appl1;}
public void paintComponent(Graphics g){
larghezza = getSize().width;
altezza = getSize().height;
super.paintComponent(g);
//g.drawImage(img,5,152, this);
g.setColor(Color.black);
//g.drawLine(xconv(x),yconv(-.5),xconv(x),yconv(.5));
double xbar;
for( xbar=xmin;xbarg.drawLine(xconv(xbar),yconv(-.5),xconv(xbar),yconv(.5)); }
double ybar;
for( ybar=-20.;ybarg.drawLine(xconv(-.5),yconv(ybar),xconv(+.5),yconv(ybar)); }

g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(xim),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(xim),yconv(0.));
/*
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(34.),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(34.),yconv(0.));
*/

g.drawLine(xconv(xmin),yconv(0.),xconv(xmax),yconv(0.));
g.drawLine(xconv(0.),yconv(ymin),xconv(0.),yconv(ymax));
g.setColor(Color.black);
//System.out.println(xconv(0.)+" "+yconv(r)+" "+xconv(2*r)+" "+yconv(-r));
g.drawArc(xconv(-spessore/2.),yconv(r),xconv(2*r-spessore/2.)-xconv(-spessore/2.),yconv(-r)-yconv(r),210,300);
g.drawArc(xconv(spessore/2.),yconv(r1),xconv(2*r1+spessore/2.)-xconv(spessore/2.),yconv(-r1)-yconv(r1),210,300);
g.setColor(Color.red);
g.drawArc(xconv(xcavanti),yconv(rcavanti),xconv(2*rcavanti+xcavanti)-xconv(xcavanti),yconv(-rcavanti)-yconv(rcavanti),240,-120);
g.drawArc(xconv(xcdietro),yconv(rcdietro),xconv(2*rcdietro+xcdietro)-xconv(xcdietro),yconv(-rcdietro)-yconv(rcdietro),240,-120);
if(true){}
g.setColor(Color.green);
g.drawArc(xconv(xcravanti),yconv(rcravanti),xconv(2*rcravanti+xcravanti)-xconv(xcravanti),yconv(-rcravanti)-yconv(rcravanti),209,-60);
g.drawArc(xconv(xcrdietro),yconv(rcrdietro),xconv(2*rcrdietro+xcrdietro)-xconv(xcrdietro),yconv(-rcrdietro)-yconv(rcrdietro),50,-99);
}
int xconv(double x){
return((int)((x-xmin)/(xmax-xmin)*larghezza));
}
int yconv(double y){return(altezza-(int)((y-ymin)/(ymax-ymin)*altezza));
}
}

}

Mercoledi' 16 Ottobre 2002 : 14 53 - zito da 193.204.188.254

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class Ovale extends JApplet implements ActionListener {
Timer timer;
boolean cristallino;
Display disegno;
JPanel p1;
JButton b1,b2;
double r,r1,spessore,rcavanti,rcdietro,xcavanti,xcdietro;
double rcravanti,rcrdietro,xcravanti,xcrdietro;
Image img;
double xmin,xmax,ymin,ymax;
double xim,xog;
public void init(){

cristallino=true;
xmin = -5.0;//mm
xmax = 42.0;ymin = -20.5;ymax = 27.5;
xim = 31.;xog=-1000.;
img=getImage(getCodeBase(),"eye.gif");

disegno = new Display(this);
getContentPane().setLayout(new
BorderLayout());
getContentPane().add(disegno,
BorderLayout.CENTER);
p1 = new JPanel();
getContentPane().add(p1,
BorderLayout.NORTH);
b1 = new JButton("Start animazione");
b2 = new JButton("Togli cristallino");
p1.add(b1);p1.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);

r=12.8 ;r1=11.8;spessore=.5;
xcavanti=-2.5;xcdietro=-2.1; rcavanti=7.25; rcdietro=5.68;
xcravanti=1.1;xcrdietro=-8.1; rcravanti=9.67; rcrdietro=6.32;
disegno.setBackground(Color.yellow);
}
public void startanim() {
if (timer == null) {
timer = new Timer(100,this);
timer.start();
}else { timer.restart();}
}

public void stopanim() {
if (timer != null) {
timer.stop();
}
}

public void actionPerformed(ActionEvent e) {
if(e.getSource()==timer){
xim = xim + 3./100.;if(xim > 34.) stopanim();
xog = xog + 980./100.;
disegno.repaint();}
if(e.getSource()==b1){
if(e.getActionCommand().equals("Start animazione")){
b1.setText("Stop animazione"); startanim();}
if(e.getActionCommand().equals("Stop animazione")){
b1.setText("Start animazione");stopanim();
xim = 31.;xog=-1000.;
}}
if(e.getSource()==b2){
if(e.getActionCommand().equals("Togli cristallino")){
b2.setText("Aggiungi cristallino");
cristallino=false; disegno.repaint();}
if(e.getActionCommand().equals("Aggiungi cristallino")){
b2.setText("Togli cristallino");
cristallino=true; disegno.repaint();}

}
}

class Display extends JPanel {
int larghezza, altezza;
Ovale appl;
Display(Ovale appl1){appl=appl1;}
public void paintComponent(Graphics g){
larghezza = getSize().width;
altezza = getSize().height;
super.paintComponent(g);
//g.drawImage(img,5,152, this);
g.setColor(Color.black);
//g.drawLine(xconv(x),yconv(-.5),xconv(x),yconv(.5));
double xbar;
for( xbar=xmin;xbar g.drawLine(xconv(xbar),yconv(-.5),xconv(xbar),yconv(.5)); }
double ybar;
for( ybar=-20.;ybar g.drawLine(xconv(-.5),yconv(ybar),xconv(+.5),yconv(ybar)); }

g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(xim),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(xim),yconv(0.));
/*
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(34.),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(34.),yconv(0.));
*/

g.drawLine(xconv(xmin),yconv(0.),xconv(xmax),yconv(0.));
g.drawLine(xconv(0.),yconv(ymin),xconv(0.),yconv(ymax));
g.setColor(Color.black);
//System.out.println(xconv(0.)+" "+yconv(r)+" "+xconv(2*r)+" "+yconv(-r));
g.drawArc(xconv(-spessore/2.),yconv(r),xconv(2*r-spessore/2.)-xconv(-spessore/2.),yconv(-r)-yconv(r),210,300);
g.drawArc(xconv(spessore/2.),yconv(r1),xconv(2*r1+spessore/2.)-xconv(spessore/2.),yconv(-r1)-yconv(r1),210,300);
g.setColor(Color.red);
g.drawArc(xconv(xcavanti),yconv(rcavanti),xconv(2*rcavanti+xcavanti)-xconv(xcavanti),yconv(-rcavanti)-yconv(rcavanti),240,-120);
g.drawArc(xconv(xcdietro),yconv(rcdietro),xconv(2*rcdietro+xcdietro)-xconv(xcdietro),yconv(-rcdietro)-yconv(rcdietro),240,-120);
if(cristallino){
g.setColor(Color.green);
g.drawArc(xconv(xcravanti),yconv(rcravanti),xconv(2*rcravanti+xcravanti)-xconv(xcravanti),yconv(-rcravanti)-yconv(rcravanti),209,-60);
g.drawArc(xconv(xcrdietro),yconv(rcrdietro),xconv(2*rcrdietro+xcrdietro)-xconv(xcrdietro),yconv(-rcrdietro)-yconv(rcrdietro),50,-99);
}
}
int xconv(double x){
return((int)((x-xmin)/(xmax-xmin)*larghezza));
}
int yconv(double y){return(altezza-(int)((y-ymin)/(ymax-ymin)*altezza));
}
}

}
Mercoledi' 16 Ottobre 2002 : 15 4 1 - zito da 193.204.188.254

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class Ovale extends JApplet implements ActionListener {
Timer timer;
boolean cristallino;
Display disegno;
JPanel p1;
JButton b1,b2;
double r,r1,spessore,rcavanti,rcdietro,xcavanti,xcdietro;
double rcravanti,rcrdietro,xcravanti,xcrdietro;
Image img;
double xmin,xmax,ymin,ymax;
double xim,xog;
public void init(){

cristallino=true;
xmin = -5.0;//mm
xmax = 42.0;ymin = -20.5;ymax = 27.5;
xim = 31.;xog=-1000.;
img=getImage(getCodeBase(),"eye.gif");

disegno = new Display(this);
getContentPane().setLayout(new
BorderLayout());
getContentPane().add(disegno,
BorderLayout.CENTER);
p1 = new JPanel();
getContentPane().add(p1,
BorderLayout.NORTH);
b1 = new JButton("Start animazione");
b2 = new JButton("Togli cristallino");
p1.add(b1);p1.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);

r=12.8 ;r1=11.8;spessore=.5;
xcavanti=-2.5;xcdietro=-2.1; rcavanti=7.25; rcdietro=5.68;
xcravanti=1.1;xcrdietro=-8.1; rcravanti=9.67; rcrdietro=6.32;
disegno.setBackground(Color.yellow);
}
public void startanim() {
if (timer == null) {
timer = new Timer(100,this);
timer.start();
}else { timer.restart();}
}

public void stopanim() {
if (timer != null) {
timer.stop();
}
}

public void actionPerformed(ActionEvent e) {
if(e.getSource()==timer){
xim = xim + 3./100.;if(xim > 34.) stopanim();
xog = xog + 980./100.;
disegno.repaint();}
if(e.getSource()==b1){
if(e.getActionCommand().equals("Start animazione")){
b1.setText("Stop animazione"); startanim();}
if(e.getActionCommand().equals("Stop animazione")){
b1.setText("Start animazione");stopanim();
xim = 31.;xog=-1000.;
}}
if(e.getSource()==b2){
if(e.getActionCommand().equals("Togli cristallino")){
b2.setText("Aggiungi cristallino");
cristallino=false; disegno.repaint();}
if(e.getActionCommand().equals("Aggiungi cristallino")){
b2.setText("Togli cristallino");
cristallino=true; disegno.repaint();}

}
}

class Display extends JPanel {
int larghezza, altezza;
Ovale appl;
Display(Ovale appl1){appl=appl1;}
public void paintComponent(Graphics g){
larghezza = getSize().width;
altezza = getSize().height;
super.paintComponent(g);
//g.drawImage(img,5,152, this);
g.setColor(Color.black);
//g.drawLine(xconv(x),yconv(-.5),xconv(x),yconv(.5));
double xbar;
for( xbar=xmin;xbar g.drawLine(xconv(xbar),yconv(-.5),xconv(xbar),yconv(.5)); }
double ybar;
for( ybar=-20.;ybar g.drawLine(xconv(-.5),yconv(ybar),xconv(+.5),yconv(ybar)); }
/*
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(xim),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(xim),yconv(0.));
*/
/*
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(34.),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(34.),yconv(0.));
*/

g.drawLine(xconv(xmin),yconv(0.),xconv(xmax),yconv(0.));
g.drawLine(xconv(0.),yconv(ymin),xconv(0.),yconv(ymax));
g.setColor(Color.black);
//System.out.println(xconv(0.)+" "+yconv(r)+" "+xconv(2*r)+" "+yconv(-r));
g.drawArc(xconv(-spessore/2.),yconv(r),xconv(2*r-spessore/2.)-xconv(-spessore/2.),yconv(-r)-yconv(r),210,300);
g.drawArc(xconv(spessore/2.),yconv(r1),xconv(2*r1+spessore/2.)-xconv(spessore/2.),yconv(-r1)-yconv(r1),210,300);
g.setColor(Color.red);
g.drawArc(xconv(xcavanti),yconv(rcavanti),xconv(2*rcavanti+xcavanti)-xconv(xcavanti),yconv(-rcavanti)-yconv(rcavanti),240,-120);
g.drawArc(xconv(xcdietro),yconv(rcdietro),xconv(2*rcdietro+xcdietro)-xconv(xcdietro),yconv(-rcdietro)-yconv(rcdietro),240,-120);
if(cristallino){
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(24),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(24),yconv(0.));
}else{
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(31),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(31),yconv(0.));
}
if(cristallino){
g.setColor(Color.green);
g.drawArc(xconv(xcravanti),yconv(rcravanti),xconv(2*rcravanti+xcravanti)-xconv(xcravanti),yconv(-rcravanti)-yconv(rcravanti),209,-60);
g.drawArc(xconv(xcrdietro),yconv(rcrdietro),xconv(2*rcrdietro+xcrdietro)-xconv(xcrdietro),yconv(-rcrdietro)-yconv(rcrdietro),50,-99);
}
}
int xconv(double x){
return((int)((x-xmin)/(xmax-xmin)*larghezza));
}
int yconv(double y){return(altezza-(int)((y-ymin)/(ymax-ymin)*altezza));
}
}

}
Mercoledi' 16 Ottobre 2002 : 15 10 5 - zito da 193.204.188.254

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class Ovale extends JApplet implements ActionListener {
Timer timer;
boolean cristallino,animazione;
Display disegno;
JPanel p1;
JButton b1,b2;
double r,r1,spessore,rcavanti,rcdietro,xcavanti,xcdietro;
double rcravanti,rcrdietro,xcravanti,xcrdietro;
Image img;
double xmin,xmax,ymin,ymax;
double xim,xog;
public void init(){

cristallino=true;
animazione=false;
xmin = -5.0;//mm
xmax = 42.0;ymin = -20.5;ymax = 27.5;
xim = 31.;xog=-1000.;
img=getImage(getCodeBase(),"eye.gif");

disegno = new Display(this);
getContentPane().setLayout(new
BorderLayout());
getContentPane().add(disegno,
BorderLayout.CENTER);
p1 = new JPanel();
getContentPane().add(p1,
BorderLayout.NORTH);
b1 = new JButton("Start animazione");
b2 = new JButton("Togli cristallino");
p1.add(b1);p1.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);

r=12.8 ;r1=11.8;spessore=.5;
xcavanti=-2.5;xcdietro=-2.1; rcavanti=7.25; rcdietro=5.68;
xcravanti=1.1;xcrdietro=-8.1; rcravanti=9.67; rcrdietro=6.32;
disegno.setBackground(Color.yellow);
}
public void startanim() {
if (timer == null) {
timer = new Timer(100,this);
timer.start();
}else { timer.restart();}
}

public void stopanim() {
if (timer != null) {
timer.stop();
}
}

public void actionPerformed(ActionEvent e) {
if(e.getSource()==timer){
xim = xim + 3./100.;if(xim > 34.) stopanim();
xog = xog + 980./100.;
disegno.repaint();}
if(e.getSource()==b1){
if(e.getActionCommand().equals("Start animazione")){
b1.setText("Stop animazione");animazione=true; startanim();}
if(e.getActionCommand().equals("Stop animazione")){
b1.setText("Start animazione");animazione=false;stopanim();

xim = 31.;xog=-1000.;
disegno.repaint();
}}
if(e.getSource()==b2){
if(e.getActionCommand().equals("Togli cristallino")){
b2.setText("Aggiungi cristallino");
cristallino=false; disegno.repaint();}
if(e.getActionCommand().equals("Aggiungi cristallino")){
b2.setText("Togli cristallino");
cristallino=true; disegno.repaint();}

}
}

class Display extends JPanel {
int larghezza, altezza;
Ovale appl;
Display(Ovale appl1){appl=appl1;}
public void paintComponent(Graphics g){
larghezza = getSize().width;
altezza = getSize().height;
super.paintComponent(g);
//g.drawImage(img,5,152, this);
g.setColor(Color.black);
//g.drawLine(xconv(x),yconv(-.5),xconv(x),yconv(.5));
double xbar;
for( xbar=xmin;xbar g.drawLine(xconv(xbar),yconv(-.5),xconv(xbar),yconv(.5)); }
double ybar;
for( ybar=-20.;ybar g.drawLine(xconv(-.5),yconv(ybar),xconv(+.5),yconv(ybar)); }
if(animazione){
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(xog),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(xim),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(xim),yconv(0.));
}
/*
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-20.),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(34.),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(34.),yconv(0.));
*/

g.drawLine(xconv(xmin),yconv(0.),xconv(xmax),yconv(0.));
g.drawLine(xconv(0.),yconv(ymin),xconv(0.),yconv(ymax));
g.setColor(Color.black);
//System.out.println(xconv(0.)+" "+yconv(r)+" "+xconv(2*r)+" "+yconv(-r));
g.drawArc(xconv(-spessore/2.),yconv(r),xconv(2*r-spessore/2.)-xconv(-spessore/2.),yconv(-r)-yconv(r),210,300);
g.drawArc(xconv(spessore/2.),yconv(r1),xconv(2*r1+spessore/2.)-xconv(spessore/2.),yconv(-r1)-yconv(r1),210,300);
g.setColor(Color.red);
g.drawArc(xconv(xcavanti),yconv(rcavanti),xconv(2*rcavanti+xcavanti)-xconv(xcavanti),yconv(-rcavanti)-yconv(rcavanti),240,-120);
g.drawArc(xconv(xcdietro),yconv(rcdietro),xconv(2*rcdietro+xcdietro)-xconv(xcdietro),yconv(-rcdietro)-yconv(rcdietro),240,-120);
if(cristallino){
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(24),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(24),yconv(0.));
}else{
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(4.5));
g.drawLine(xconv(-1000),yconv(0.),xconv(-1.5),yconv(-4.5));
g.drawLine(xconv(-1.5),yconv(4.5),xconv(31),yconv(0.));
g.drawLine(xconv(-1.5),yconv(-4.5),xconv(31),yconv(0.));
}
if(cristallino){
g.setColor(Color.green);
g.drawArc(xconv(xcravanti),yconv(rcravanti),xconv(2*rcravanti+xcravanti)-xconv(xcravanti),yconv(-rcravanti)-yconv(rcravanti),209,-60);
g.drawArc(xconv(xcrdietro),yconv(rcrdietro),xconv(2*rcrdietro+xcrdietro)-xconv(xcrdietro),yconv(-rcrdietro)-yconv(rcrdietro),50,-99);
}
}
int xconv(double x){
return((int)((x-xmin)/(xmax-xmin)*larghezza));
}
int yconv(double y){return(altezza-(int)((y-ymin)/(ymax-ymin)*altezza));
}
}

}