Contenuto della lavagna elettronica

Risultato dei test
Giovedi' 18 Ottobre 2001 : 14 14 5 - Anonimo da labmul2.fisica.uniba.it 193.204.188.59
sss
Giovedi' 18 Ottobre 2001 : 14 47 1 - zito da 193.204.188.61

import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.event.*;

public class Immagine3 extends Applet implements ActionListener, Runnable {
Thread animazione;
Image o;
Graphics og;
InverseColorFilter filter;
Image negative;
Button b1,b2,b3,b4,b5,b6;
TextField t1;
Scrollbar sc;
Image img,img2,img3;
Panel p,p1;
boolean im1,im2,im3,im4,im5;
int x,y,r;

public void init(){
o = createImage(size().width,size().height);
og = o.getGraphics();
filter = new InverseColorFilter ();
r = 100;
im1=false;
im2=false;
im3=false;
im4=false;
im5=false;
img = getImage( getCodeBase(), "fufis.jpg" );

filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));
img2 = getImage( getCodeBase(), "RIGHT1.gif" );
img3 = getImage( getCodeBase(), "MARE.gif" );
sc= new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,300);
b1 = new Button("gatto1");
b2 = new Button("gatto2");
b3 = new Button("mare");
b4 = new Button("animazione");
b5 = new Button("nuovo colore");
b6 = new Button("carica");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);

p = new Panel();
p1 = new Panel ();
t1 = new TextField();
p.setLayout(new GridLayou t());
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p.add(sc);
p1.add(b6);
p1.add(t1);
setLayout(new BorderLayout());
add("North",p);
add("South",p1);
}

public void start() {
if(im4==true)
if(animazione == null) {
animazione = new Thread(this);
animazione.start();
}
}

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

public void run() {
while(animazione != null) {
for (x = r; x <= size().width ; x=x+1) {
repaint();
try { Thread.sleep(100);}
catch (InterruptedException e) { } } } }

public void actionPerformed (ActionEvent evt){
if(evt.getSource()==b1){
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
stop();
}
if(evt.getSource()==b2){
im2=true;
im1=false;
im3=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b3){
im3=true;
im1=false;
im2=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b4){
im3=true;
im1=false;
im2=false;
im4=true;
im5=false;
start();
}
if(evt.getSource()==b5){
im5=true;
im1=false;
im2=false;
im3=false;
im4=false;
start();
}
if(evt.getSource()==b6){
Str ing nomefile = t1.getText();
if(nomefile !=null)
img = getImage( getCodeBase(), nomefile );

}

repaint();
}

public void paint(Graphics g){
og.setColor(Color.white);
og.fillRect(0,0,size().width,size().height);
if(im1==true)og.drawImage(img,0,100, this);
if(im2==true)og.drawImage(img2,0,100, this);
if(im3==true)og.drawImage(img3, 0,100,this);
if(im4==true){
og.drawImage(img3, 0,100,this);
og.drawImage(img2, x,200,this);
}
if(im5==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);
}

public void update(Graphics g) { paint(g); }
}

class InverseColorFilter extends RGBImageFilter
{
public InverseColorFilter () {
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;

red = 255-red; green = 255-green; blue = 255 - blue;

return (0xff000000 | (red << 16) | (green << 8) | blue); }
}
Giovedi' 18 Ottobre 2001 : 15 5 1 - zito da 193.204.188.61
int grigio = (int)((red+blue+green)/765.*255.);
red = green = blue = grigio;
Giovedi' 18 Ottobre 2001 : 15 12 3 - zito da 193.204.188.61

import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.event.*;

public class Immagine3 extends Applet implements ActionListener, Runnable {
Thread animazione;
Image o;
Graphics og;
InverseColorFilter filter;
Image negative;
Button b1,b2,b3,b4,b5,b6;
TextField t1;
Scrollbar sc;
Image img,img2,img3;
Panel p,p1;
boolean im1,im2,im3,im4,im5;
int x,y,r;

public void init(){
o = createImage(size().width,size().height);
og = o.getGraphics();
filter = new InverseColorFilter ();
r = 100;
im1=false;
im2=false;
im3=false;
im4=false;
im5=false;
img = getImage( getCodeBase(), "fufis.jpg" );

filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));
img2 = getImage( getCodeBase(), "RIGHT1.gif" );
img3 = getImage( getCodeBase(), "MARE.gif" );
sc= new Scrollbar(Scrollbar.HORIZONTAL,0,10,0,300);
b1 = new Button("gatto1");
b2 = new Button("gatto2");
b3 = new Button("mare");
b4 = new Button("animazione");
b5 = new Button("nuovo colore");
b6 = new Button("carica");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);

p = new Panel();
p1 = new Panel ();
t1 = new TextField(20);
p.setLayout(new GridLay out());
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p.add(sc);
p1.add(b6);
p1.add(t1);
setLayout(new BorderLayout());
add("North",p);
add("South",p1);
}

public void start() {
if(im4==true)
if(animazione == null) {
animazione = new Thread(this);
animazione.start();
}
}

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

public void run() {
while(animazione != null) {
for (x = r; x <= size().width ; x=x+1) {
repaint();
try { Thread.sleep(100);}
catch (InterruptedException e) { } } } }

public void actionPerformed (ActionEvent evt){
if(evt.getSource()==b1){
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
stop();
}
if(evt.getSource()==b2){
im2=true;
im1=false;
im3=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b3){
im3=true;
im1=false;
im2=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b4){
im3=true;
im1=false;
im2=false;
im4=true;
im5=false;
start();
}
if(evt.getSource()==b5){
filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));

im5=true;
im1=false;
im2=false;
im3=false;
im4=false;
start();
}
if(evt.getSource()==b6){
String nomefile = t1.getText();
if(nomefile !=null){
img = getImage( getCodeBase(), nomefile );
negative = createImage (new FilteredImageSource (img.getSource (), filter));
}
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
stop();

}

repaint();
}

public void paint(Graphics g){
og.setColor(Color.white);
og.fillRect(0,0,size().width,size().height);
if(im1==true)og.drawImage(img,0,100, this);
if(im2==true)og.drawImage(img2,0,100, this);
if(im3==true)og.drawImage(img3, 0,100,this);
if(im4==true){
og.drawImage(img3, 0,100,this);
og.drawImage(img2, x,200,this);
}
if(im5==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);
}

public void update(Graphics g) { paint(g); }
}

class InverseColorFilter extends RGBImageFilter
{
public InverseColorFilter () {
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*Math.random());
green = (int)(green*Math.random());
blue = (int)(blue*Math.random());
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}
Giovedi' 18 Ottobre 2001 : 16 1 3 - zito da 193.204.188.61

import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.event.*;

public class Immagine3 extends Applet implements ActionListener,
AdjustmentListener, Runnable {
Thread animazione;
Image o;
Graphics og;
InverseColorFilter filter;
Image negative;
Button b1,b2,b3,b4,b5,b6;
TextField t1;
Scrollbar verde,rosso,blu;
Image img,img2,img3;
Panel p,p1;
boolean im1,im2,im3,im4,im5;
int x,y,r;
double perc_rosso,perc_verde,perc_blu;

public void init(){
o = createImage(size().width,size().height);
og = o.getGraphics();
perc_rosso=perc_verde=perc_blu=1;
filter = new InverseColorFilter ();
r = 100;
im1=false;
im2=false;
im3=false;
im4=false;
im5=false;
img = getImage( getCodeBase(), "fufis.jpg" );

filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));
img2 = getImage( getCodeBase(), "RIGHT1.gif" );
img3 = getImage( getCodeBase(), "MARE.gif" );
rosso= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
verde= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
blu= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
rosso.addAdjustmentListener(this);
verde.addAdjustmentListener(this);
blu.addAdjustmentListener(this);

b1 = new Button("gatto1");
b2 = new Button("gatto2");
b3 = new Button("mare");
b4 = new Button("animazione");
b5 = new Button("nuovo colore");
b6 = new Button("carica");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);

p = new Panel();
p1 = new Panel ();
p1.setLayout(new GridLayout());
t1 = new TextField(20);
p.setLayout(new GridLayout());
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p1.add(verde);p1.add(rosso);p1.add(blu);
p1.add(b6);
p1.add(t1);
setLayout(new BorderLayout());
add("North",p);
add("South",p1);
}

public void start() {
if(im4==true)
if(animazione == null) {
animazione = new Thread(this);
animazione.start();
}
}

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

public void run() {
while(animazione != null) {
for (x = r; x <= size().width ; x=x+1) {
repaint();
try { Thread.sleep(100);}
catch (InterruptedException e) { } } } }
public void adjustmentValueChanged
(AdjustmentEvent evt){
if(evt.getSource()==rosso){
}
if(evt.getSource()==verde){
}
if(evt.getSource()==blu){
}

}
public void actionPerformed (ActionEvent evt){
if(evt.getSource()==b1){
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
stop();
}
if(evt.getSource()==b2){
im2=true;
im1=false;
im3=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b3){
im3=true;
im1=false;
im2=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b4){
im3=true;
im1=false;
im2=false;
im4=true;
im5=false;
start();
}
if(evt.getSource()==b5){
filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));

im5=true;
im1=false;
im2=false;
im3=false;
im4=false;
start();
}
if(evt.getSource()==b6){
String nomefile = t1.getText();
if(nomefile !=null){
img = getImage( getCodeBase(), nomefile );
negative = createImage (new FilteredImageSource (img.getSource (), filter));
}
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
stop();

}

repaint();
}

public void paint(Graphics g){
og.setColor(Color.white);
og.fillRect(0,0,size().width,size().height);
if(im1==true)og.drawImage(img,0,100, this);
if(im2==true)og.drawImage(img2,0,100, this);
if(im3==true)og.drawImage(img3, 0,100,this);
if(im4==true){
og.drawImage(img3, 0,100,this);
og.drawImage(img2, x,200,this);
}
if(im5==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);
}

public void update(Graphics g) { paint(g); }
}

class InverseColorFilter extends RGBImageFilter< BR> {
public InverseColorFilter () {
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*Math.random());
green = (int)(green*Math.random());
blue = (int)(blue*Math.random());
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}

Giovedi' 18 Ottobre 2001 : 16 1 3 - zito da 193.204.188.61

import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.event.*;

public class Immagine3 extends Applet implements ActionListener,
AdjustmentListener, Runnable {
Thread animazione;
Image o;
Graphics og;
InverseColorFilter filter;
Image negative;
Button b1,b2,b3,b4,b5,b6;
TextField t1;
Scrollbar verde,rosso,blu;
Image img,img2,img3;
Panel p,p1;
boolean im1,im2,im3,im4,im5;
int x,y,r;
double perc_rosso,perc_verde,perc_blu;

public void init(){
o = createImage(size().width,size().height);
og = o.getGraphics();
perc_rosso=perc_verde=perc_blu=1;
filter = new InverseColorFilter ();
r = 100;
im1=false;
im2=false;
im3=false;
im4=false;
im5=false;
img = getImage( getCodeBase(), "fufis.jpg" );

filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));
img2 = getImage( getCodeBase(), "RIGHT1.gif" );
img3 = getImage( getCodeBase(), "MARE.gif" );
rosso= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
verde= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
blu= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
rosso.addAdjustmentListener(this);
verde.addAdjustmentListener(this);
blu.addAdjustmentListener(this);

b1 = new Button("gatto1");
b2 = new Button("gatto2");
b3 = new Button("mare");
b4 = new Button("animazione");
b5 = new Button("nuovo colore");
b6 = new Button("carica");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);

p = new Panel();
p1 = new Panel ();
p1.setLayout(new GridLayout());
t1 = new TextField(20);
p.setLayout(new GridLayout());
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p1.add(verde);p1.add(rosso);p1.add(blu);
p1.add(b6);
p1.add(t1);
setLayout(new BorderLayout());
add("North",p);
add("South",p1);
}

public void start() {
if(im4==true)
if(animazione == null) {
animazione = new Thread(this);
animazione.start();
}
}

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

public void run() {
while(animazione != null) {
for (x = r; x <= size().width ; x=x+1) {
repaint();
try { Thread.sleep(100);}
catch (InterruptedException e) { } } } }
public void adjustmentValueChanged
(AdjustmentEvent evt){
if(evt.getSource()==rosso){
}
if(evt.getSource()==verde){
}
if(evt.getSource()==blu){
}

}
public void actionPerformed (ActionEvent evt){
if(evt.getSource()==b1){
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
stop();
}
if(evt.getSource()==b2){
im2=true;
im1=false;
im3=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b3){
im3=true;
im1=false;
im2=false;
im4=false;
im5=false;
stop();
}

if(evt.getSource()==b4){
im3=true;
im1=false;
im2=false;
im4=true;
im5=false;
start();
}
if(evt.getSource()==b5){
filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));

im5=true;
im1=false;
im2=false;
im3=false;
im4=false;
start();
}
if(evt.getSource()==b6){
String nomefile = t1.getText();
if(nomefile !=null){
img = getImage( getCodeBase(), nomefile );
negative = createImage (new FilteredImageSource (img.getSource (), filter));
}
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
stop();

}

repaint();
}

public void paint(Graphics g){
og.setColor(Color.white);
og.fillRect(0,0,size().width,size().height);
if(im1==true)og.drawImage(img,0,100, this);
if(im2==true)og.drawImage(img2,0,100, this);
if(im3==true)og.drawImage(img3, 0,100,this);
if(im4==true){
og.drawImage(img3, 0,100,this);
og.drawImage(img2, x,200,this);
}
if(im5==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);
}

public void update(Graphics g) { paint(g); }
}

class InverseColorFilter extends RGBImageFilter< BR> {
public InverseColorFilter () {
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*Math.random());
green = (int)(green*Math.random());
blue = (int)(blue*Math.random());
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}

Venerdi' 19 Ottobre 2001 : 13 49 - ........... da labmul5.fisica.uniba.it 193.204.188.62
import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.event.*;

public class Animazionecompleta extends Applet implements ActionListener,
AdjustmentListener, Runnable {
Thread animazione;
Image o;
Graphics og;
InverseColorFilter filter;
MioColorFilter filter1;

Image negative;
Button b1,b2,b3,b4,b5,b6,b7;
TextField t1;
Scrollbar verde,rosso,blu;
Image img,img2,img3;
Panel p,p1;
boolean im1,im2,im3,im4,im5,im7;
int x,y,r;
double perc_rosso,perc_verde,perc_blu;

public void init(){
o = createImage(size().width,size().height);
og = o.getGraphics();
perc_rosso=perc_verde=perc_blu=1;
filter = new InverseColorFilter ();
r = 100;
im1=false;
im2=false;
im3=false;
im4=false;
im5=false;
im7=false;
img = getImage( getCodeBase(), "fufis.jpg" );

filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));
img2 = getImage( getCodeBase(), "RIGHT1.gif" );
img3 = getImage( getCodeBase(), "MARE.gif" );
rosso= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
verde= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
blu= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
rosso.addAdjustmentListener(this);
verde.addAdjustmentListener(this);
blu.addAdjustmentListener(this);

b1 = new Button("gatto1");
b2 = new Button("gatto2");
b3 = new Button("mare");
b4 = new Button("animazione");
b5 = new Button("nuovo colore");
b6 = new Button("carica");
b7 = new Button("mostra");

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);

p = new Panel();
p1 = ne w Panel ();
p1.setLayout(new GridLayout());
t1 = new TextField(20);
p.setLayout(new GridLayout());
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p1.add(b7);

p1.add(rosso);p1.add(verde);p1.add(blu);
p1.add(b6);
p1.add(t1);
setLayout(new BorderLayout());
add("North",p);
add("South",p1);
}

public void start() {
if(im4==true)
if(animazione == null) {
animazione = new Thread(this);
animazione.start();
}
}

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

public void run() {
while(animazione != null) {
for (x = r; x <= size().width ; x=x+1) {
repaint();
try { Thread.sleep(100);}
catch (InterruptedException e) { } } } }
public void adjustmentValueChanged
(AdjustmentEvent evt){
if(evt.getSource()==rosso){
perc_rosso=rosso.getValue()/100.;
System.out.println("perc_rosso="+perc_rosso);
}
if(evt.getSource()==verde){
perc_verde=verde.getValue()/100.;
System.out.println("perc_verde="+perc_verde);
}
if(evt.getSource()==blu){
perc_blu=blu.getValue()/100.;
System.out.println("perc_blu="+perc_blu);
}

}
public void actionPerformed (ActionEvent evt){
if(evt.getSource()==b1){
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
im7=false;

stop();
}
if(evt.getSource()==b2){
im2=true;
im1=false;
im3=false;
im4=false;
im5=false;
im7=false;

stop();
}

if(evt.getSource()==b3){
im3=true;
im1=false;
im2=false;
im4=false;
im5=false;
im7=false;

stop();
}

if(evt.getSource()==b4){
im3=true;
im1=false;
im2=false;
im4=true;
im5=false;
im7=false;
start();
}
if(evt.getSource()==b5){
filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));

im5=false;
im1=false;
im2=false;
im3=false;
im4=false;
im7=false;< BR>start();
}
if(evt.getSource()==b7){
filter1 = new MioColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter1));

im5=true;
im1=false;
im2=false;
im3=false;
im4=false;
im7=true;
start();
}

if(evt.getSource()==b6){
String nomefile = t1.getText();
if(nomefile !=null){
img = getImage( getCodeBase(), nomefile );
negative = createImage (new FilteredImageSource (img.getSource (), filter));
}
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
im7=false;
stop();

}

repaint();
}

public void paint(Graphics g){
og.setColor(Color.white);
og.fillRect(0,0,size().width,size().height);
if(im1==true)og.drawImage(img,0,100, this);
if(im2==true)og.drawImage(img2,0,100, this);
if(im3==true)og.drawImage(img3, 0,100,this);
if(im4==true){
og.drawImage(img3, 0,100,this);
og.drawImage(img2, x,200,this);
}
if(im5==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);
if(im7==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);
}

public void update(Graphics g) { paint(g); }
}

class InverseColorFilter extends RGBImageFilter
{
public InverseColorFilter () {
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*Math.random());
green = (int)(green*Math.random());
blue = (int)(blue*Math.random());
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}

class MioColorFilter extends RGBImageFilter
{
public MioColorFilter () {
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*Math.random());
green = (int)(green*Math.random());
blue = (int)(blue*Ma th.random());
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}

Venerdi' 19 Ottobre 2001 : 13 59 2 - zito da labmul4.fisica.uniba.it 193.204.188.61

import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.event.*;

public class Immagine3 extends Applet implements ActionListener,
AdjustmentListener, Runnable {
Thread animazione;
Image o;
Graphics og;
InverseColorFilter filter;
MioColorFilter filter1;

Image negative;
Button b1,b2,b3,b4,b5,b6,b7;
TextField t1;
Scrollbar verde,rosso,blu;
Image img,img2,img3;
Panel p,p1;
boolean im1,im2,im3,im4,im5,im7;
int x,y,r;
double perc_rosso,perc_verde,perc_blu;

public void init(){
o = createImage(size().width,size().height);
og = o.getGraphics();
perc_rosso=perc_verde=perc_blu=1;
filter = new InverseColorFilter ();
r = 100;
im1=false;
im2=false;
im3=false;
im4=false;
im5=false;
im7 = false;
img = getImage( getCodeBase(), "fufis.jpg" );

filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));
img2 = getImage( getCodeBase(), "RIGHT1.gif" );
img3 = getImage( getCodeBase(), "MARE.gif" );
rosso= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
verde= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
blu= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
rosso.addAdjustmentListener(this);
verde.addAdjustmentListener(this);
blu.addAdjustmentListener(this);

b1 = new Button("gatto1");
b2 = new Button("gatto2");
b3 = new Button("mare");
b4 = new Button("animazione");
b5 = new Button("nuovo colore");
b6 = new Button("carica");
b7 = new Button("mostra");

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);


p = new Panel();
p1 = new Panel ();
p1.setLayout(new GridLayout());
t1 = new TextField(20);
p.setLayout(new GridLayout());
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p1.add(b7);
p1.add(rosso);p1.add(verde);p1.add(blu);
p1.add(b6);
p1.add(t1);
setLayout(new BorderLayout());
add("North",p);
add("South",p1);
}

public void start() {
if(im4==true)
if(animazione == null) {
animazione = new Thread(this);
animazione.start();
}
}

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

public void run() {
while(animazione != null) {
for (x = r; x <= size().width ; x=x+1) {
repaint();
try { Thread.sleep(100);}
catch (InterruptedException e) { } } } }
public void adjustmentValueChanged
(AdjustmentEvent evt){
if(evt.getSource()==rosso){
perc_rosso = rosso.getValue()/100.;
System.out.println("perc_rosso="+perc_rosso);
}
if(evt.getSource()==verde){
perc_verde = verde.getValue()/100.;
System.out.println("perc_verde="+perc_verde);

}
if(evt.getSource()==blu){
perc_blu = blu.getValue()/100.;
System.out.println("perc_blu="+perc_blu);
}

}
public void actionPerformed (ActionEvent evt){
if(evt.getSource()==b1){
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
im7 = false;
stop();
}
if(evt.getSource()==b2){
im2=true;
im1=false;
im3=false;
im4=false;
im5=false;
im7 = false;
stop();
}

if(evt.getSource()==b3){
im3=true;
im1=false;
im2=false;
im4=false;
im5=false;
im7 = false;
stop();
}

if(evt.getSource()==b4){
im3=true;
im1=false;
im2=false;
im4=true;
im5=false;
im7 = false;
start();
}
if(evt.getSource()==b5){
filter = new InverseColorFilter ();
negative = createImage (new FilteredImageSource (img.getSource (), filter));

im5=true;
im1=false;
im2=false;
im3=false;
im4=false;
im7 = false;
start();
}
if(evt.getSource()==b7){
filter1 = new MioColorFilter (this);
negative = createImage (new FilteredImageSource (img.getSource (), filter1));
im7 = true;
im5=false;
im1=false;
im2=false;
im3=false;
im4=false;
start(); }

if(evt.getSource()==b6){
String nomefile = t1.getText();
if(nomefile !=null){
img = getImage( getCodeBase(), nomefile );
negative = createImage (new FilteredImageSource (img.getSource (), filter));
}
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
im7 = false;
stop();

}

repaint();
}

public void paint(Graphics g){
og.setColor(Color.white);
og.fillRect(0,0,size().width,size().height);
if(im1==true)og.drawImage(img,0,100, this);
if(im2==true)og.drawImage(img2,0,100, this);
if(im3==true)og.drawImage(img3, 0,100,this);
if(im4==true){
og.drawImage(img3, 0,100,this);
og.drawImage(img2, x,200,this);
}
if(im5==true)og.drawImage(negative,0,100, this);

if(im7==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);


}

public void update(Graphics g) { paint(g); }
}

class InverseColorFilter extends RGBImageFilter
{
public InverseColorFilter () {
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*Math.random());
green = (int)(green*Math.random());
blue = (int)(blue*Math.random());
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}
class MioColorFilter extends RGBImageFilter
{
Immagine3 app;
public MioColorFilter (Immagine3 app) {
this.app = app;
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*app.perc_rosso);
green = (int)(green*app.perc_verde);
blue = (int)(blue*app.perc_blu);
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}

Venerdi' 19 Ottobre 2001 : 14 31 4 - zito da labmul4.fisica.uniba.it 193.204.188.61

import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.image.*;
import java.awt.event.*;

public class Immagine3 extends Applet implements ActionListener,
AdjustmentListener, Runnable {
Thread animazione;
Image o;
Graphics og;
InverseColorFilter filter;
MioColorFilter filter1;

Image negative;
Button b1,b2,b3,b4,b5,b6,b7;
TextField t1;
Scrollbar verde,rosso,blu;
Image img,img2,img3;
Panel p,p1;
boolean im1,im2,im3,im4,im5,im7;
int x,y,r;
double perc_rosso,perc_verde,perc_blu;
double perc_rosso1,perc_verde1,perc_blu1;

public void init(){
o = createImage(size().width,size().height);
og = o.getGraphics();
perc_rosso=perc_verde=perc_blu=1;
perc_rosso1=perc_verde1=perc_blu1=1;

filter = new InverseColorFilter (this);
r = 100;
im1=false;
im2=false;
im3=false;
im4=false;
im5=false;
im7 = false;
img = getImage( getCodeBase(), "fufis.jpg" );

filter = new InverseColorFilter (this);
negative = createImage (new FilteredImageSource (img.getSource (), filter));
img2 = getImage( getCodeBase(), "RIGHT1.gif" );
img3 = getImage( getCodeBase(), "MARE.gif" );
rosso= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
verde= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
blu= new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,100);
rosso.addAdjustmentListener(this);
verde.addAdjustmentListener(this);
blu.addAdjustmentListener(this);

b1 = new Button("gatto1");
b2 = new Button("gatto2");
b3 = new Button("mare");
b4 = new Button("animazione");
b5 = new Button("nuovo colore");
b6 = new Button("carica");
b7 = new Button("mostra");

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);


p = new Panel();
p1 = new Panel ();
p1.setLayout(new GridLayout());
t1 = new TextField(20);
p.setLayout(new GridLayout());
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p1.add(b7);
p1.add(rosso);p1.add(verde);p1.add(blu);
p1.add(b6);
p1.add(t1);
setLayout(new BorderLayout());
add("North",p);
add("South",p1);
}

public void start() {
if(im4==true)
if(animazione == null) {
animazione = new Thread(this);
animazione.start();
}
}

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

public void run() {
while(animazione != null) {
for (x = r; x <= size().width ; x=x+1) {
repaint();
try { Thread.sleep(100);}
catch (InterruptedException e) { } } } }
public void adjustmentValueChanged
(AdjustmentEvent evt){
if(evt.getSource()==rosso){
perc_rosso = rosso.getValue()/100.;
System.out.println("perc_rosso="+perc_rosso);
}
if(evt.getSource()==verde){
perc_v erde = verde.getValue()/100.;
System.out.println("perc_verde="+perc_verde);

}
if(evt.getSource()==blu){
perc_blu = blu.getValue()/100.;
System.out.println("perc_blu="+perc_blu);
}

}
public void actionPerformed (ActionEvent evt){
if(evt.getSource()==b1){
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
im7 = false;
stop();
}
if(evt.getSource()==b2){
im2=true;
im1=false;
im3=false;
im4=false;
im5=false;
im7 = false;
stop();
}

if(evt.getSource()==b3){
im3=true;
im1=false;
im2=false;
im4=false;
im5=false;
im7 = false;
stop();
}

if(evt.getSource()==b4){
im3=true;
im1=false;
im2=false;
im4=true;
im5=false;
im7 = false;
start();
}
if(evt.getSource()==b5){
perc_verde1 = Math.random();
perc_rosso1 = Math.random();
perc_blu1 = Math.random();
filter = new InverseColorFilter (this);
negative = createImage (new FilteredImageSource (img.getSource (), filter));

im5=true;
im1=false;
im2=false;
im3=false;
im4=false;
im7 = false;
start();
}
if(evt.getSource()==b7){
filter1 = new MioColorFilter (this);
negative = createImage (new FilteredImageSource (img.getSource (), filter1));
im7 = true;
im5=false;
im1=false;
im2=false;
im3=false;
im4=false;
start(); }

if(evt.getSource()==b6){
String nomefile = t1.getText();
if(nomefile !=null){
img = getImage( getCodeBase(), nomefile );
negative = createImage (new FilteredImageSource (img.getSource (), filter));
}
im1=true;
im2=false;
im3=false;
im4=false;
im5=false;
im7 = false;
stop();

}

repaint();
}

public void paint(Graphics g){
og.setColor(Color.white);
og.fillRect(0,0,size().width,size().height);
if(im1==true)og.drawImage(img,0,100, this);
if(im2==true)og.drawImage(img2,0,100, this);
if(im3==true)og.drawImage(img3, 0,100,this);
if(im4==true){
og.drawImage(img3, 0,100,this);
og.drawImage(img2, x,200,this);
}
if(im5==true)og.drawImage(negative,0,100, this);

if(im7==true)og.drawImage(negative,0,100, this);
g.drawImage(o, 0, 0 ,this);


}

public void update(Graphics g) { paint(g); }
}

class MioColorFilter extends RGBImageFilter
{
Immagine3 app;
public MioColorFilter (Immagine3 app) {
this.app = app;
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*app.perc_rosso);
green = (int)(green*app.perc_verde);
blue = (int)(blue*app.perc_blu);
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}
class InverseColorFilter extends RGBImageFilter
{
Immagine3 app;
public InverseColorFilter (Immagine3 app) {
this.app = app;
canFilterIndexColorModel = true; }

public int filterRGB (int x, int y, int rgb) {
int red = (rgb & 0xff0000) >>16;
int green = (rgb & 0xff00) >> 8;
int blue = rgb & 0xff;
red = (int)(red*app.perc_rosso1);
green = (int)(green*app.perc_verde1);
blue = (int)(blue*app.perc_blu1);
return (0xff000000 | (red << 16) | (green << 8) | blue); }
}




Venerdi' 19 Ottobre 2001 : 14 34 - zito da labmul4.fisica.uniba.it 193.204.188.61
test
Venerdi' 19 Ottobre 2001 : 15 7 3 - Anonimo da labmul4.fisica.uniba.it 193.204.188.61
Fortran Assembler PL/1 Basic Algol Pascal

C# .NET
Java JVM