Appendice B – Codici sorgenti dell’applicazione

BMP.java

import java.awt.*;

import java.awt.image.*;

import java.io.*;

public class BMP {

private static ImageProducer getBMPImage(InputStream stream,int newx,int newy, int mode)

throws IOException {

DataInputStream in = new DataInputStream(stream);

if (in.read() != 'B') throw new IOException("Not a .BMP file");

if (in.read() != 'M') throw new IOException("Not a .BMP file");

int fileSize = sistemaInt(in.readInt());

in.readUnsignedShort();in.readUnsignedShort();

int bitmapOffset = sistemaInt(in.readInt());

int bitmapInfoSize = sistemaInt(in.readInt());

int width = sistemaInt(in.readInt());

int height = sistemaInt(in.readInt());

in.readUnsignedShort();

int bitCount = sistemaShort(in.readUnsignedShort());

int compressionType = sistemaInt(in.readInt());

int imageSize = sistemaInt(in.readInt());

in.readInt();in.readInt();

int colorsUsed = sistemaInt(in.readInt());

int colorsImportant = sistemaInt(in.readInt());

if (colorsUsed == 0) colorsUsed = 1 << bitCount;

int colorTable[] = new int[colorsUsed];

if (mode==0) {

for (int i=0; i < colorsUsed; i++)

colorTable[i] = (sistemaInt(in.readInt()) & 0xffffff) + 0xff000000;

int pixels[] = new int[width * height];

leggiRGB(width, height, colorTable, bitCount,pixels, in);

return new MemoryImageSource(width, height, pixels, 0, width);

}

else {

for (int i=0; i < colorsUsed; i++)

colorTable[i] = sistemaInt(in.readInt());

int pixels[] = new int[width * height];

leggiRGB(width, height, colorTable, bitCount,pixels, in);

int newpixels[] = new int[newx*newy];

newpixels = resize(pixels,width,height,newx,newy);

return new MemoryImageSource(newx, newy, newpixels, 0, newx);

}

}

private static void leggiRGB(int width, int height, int colorTable[],

int bitCount, int pixels[], DataInputStream in) throws IOException{

int pixelsPerByte = 8 / bitCount;

int bitMask = (1 << bitCount) - 1;

int bitShifts[] = new int[pixelsPerByte];

for (int i=0; i < pixelsPerByte; i++) bitShifts[i] = 8 - ((i+1) * bitCount);

int whichBit = 0;

int currByte,byteInt;

for (int h=height-1; h >= 0; h--) {

int pos = h * width;

currByte = in.read();

whichBit=0;

byteInt = 0;

for (int w=0; w < width; w++) {

if (whichBit >= pixelsPerByte) {

whichBit = 0;

currByte = in.read();

byteInt++;

if (byteInt == 4) byteInt=0;

}

pixels[pos] = colorTable[(currByte >> bitShifts[whichBit]) & bitMask];

pos++;

whichBit++;

}

if (byteInt != 3)

for (int i=byteInt; i<3;i++)

in.read();

}

}

private static int sistemaShort(int i) {

return ((i >> 8) & 0xff) + ((i << 8) & 0xff00);

}

private static int sistemaInt(int i) {

return ((i & 0xff) << 24) +

((i& 0xff00) << 8) +

((i & 0xff0000) >> 8) +

((i >>24) & 0xff);

}

public static Image getBMP(String nomefile){

return getBMP(nomefile,0,0,0);

}

public static Image getBMPResized(String nomefile,int x,int y){

return getBMP(nomefile,x,y,1);

}

private static Image getBMP(String nomefile,int x,int y,int mode){

FileInputStream miobmp;

ImageProducer mioprod;

Image miaimg;

try {

miobmp = new FileInputStream(nomefile);

mioprod = getBMPImage(miobmp,x,y,mode);

miaimg = Toolkit.getDefaultToolkit().createImage(mioprod);

}

catch(Exception e){

miaimg = null;

}

return miaimg;

}

public static void putBMP(String nomefile,Contorno cont,

Rettangolo _Rett,int _mode) throws IOException {

FileOutputStream fos = new FileOutputStream(nomefile);

DataOutputStream out = new DataOutputStream(fos);

int width = _Rett.Est - _Rett.Ovest+1;

int height = _Rett.Sud - _Rett.Nord+1;

int bitCount = 1;

int intPerRow = (width/32); // numero di blocchi

if ((width%32) != 0) intPerRow++; //numero di blocchi

int bytePerRow = intPerRow * 4; // numero di byte per riga

int imageSize = intPerRow * height*4;//numero di byte totali

out.write(66);out.write(77);

out.writeInt(sistemaInt(62+imageSize));

out.writeShort(0);out.writeShort(0);

out.writeInt(sistemaInt(62));//offset 54 + 8

out.writeInt(sistemaInt(40));

out.writeInt(sistemaInt(width));

out.writeInt(sistemaInt(height));

out.writeShort(256);

out.writeShort(sistemaShort(bitCount));

out.writeInt(sistemaInt(0));

out.writeInt(sistemaInt(imageSize));//imageSize

out.writeInt(sistemaInt(0));

out.writeInt(sistemaInt(0));

out.writeInt(sistemaInt(2));//coloriUsati

out.writeInt(sistemaInt(2));//coloriImportanti

out.writeInt(sistemaInt(0x00ffffff));//Bianco trasparente

if (_mode==0) out.writeInt(sistemaInt(0xff000000));//Nero

else out.writeInt(sistemaInt(0xffff0000));//Rosso

int pixels[] = new int[imageSize];

for (int i=0; i<imageSize; i++) pixels[i]=0;

int temp1=0;

int mask;

Contorno temp=cont;

do {

int X=temp.x - _Rett.Ovest;

int Y=temp.y - _Rett.Nord;

temp1=((height-Y-1)*bytePerRow)+((int)(X/8));

mask = 128 >> (X%8);

pixels[temp1] = (pixels[temp1] | mask);

temp = temp.next;

} while(temp != cont);

for (int i=0; i<imageSize; i++) out.write(pixels[i]);

fos.close();

}

private static int[] resize(int oldpix[],int oldx, int oldy, int newx, int newy){

int newpix[] = new int[newx*newy];

double shiftx=(double)newx / (double)oldx;

double shifty=(double)newy / (double)oldy;

int x,y;

for (int i=0; i<newx; i++){

x = (int)(i/shiftx);

for (int j=0; j<newy; j++){

y = (int)(j/shifty);

newpix[(j*newx)+i]=oldpix[(y*oldx)+x];

}

}

return newpix;

}

}

ButtonImage.java

import java.awt.*;

import java.awt.event.*;

public class ButtonImage extends Canvas implements MouseListener {

public int SizeX;

public int SizeY;

Image im;

boolean isPressed;

public ButtonImage(String filename,int _SizeX,int _SizeY){

setSize(55,55);

SizeX = _SizeX;

SizeY = _SizeY;

if (SizeX > 53) SizeX=53;

if (SizeY > 53) SizeY=53;

im = BMP.getBMPResized(filename,SizeX,SizeY);

isPressed = false;

addMouseListener(this);

}

public void paint(Graphics g){

if (! isPressed){

g.setColor(Color.white);

g.drawLine(0,0,54,0);

g.drawLine(0,0,0,54);

g.setColor(Color.black);

g.drawLine(54,0,54,54);

g.drawLine(0,54,54,54);

}

else{

g.setColor(Color.black);

g.drawLine(0,0,54,0);

g.drawLine(0,0,0,54);

g.setColor(Color.white);

g.drawLine(54,0,54,54);

g.drawLine(0,54,54,54);

}

if (im != null) g.drawImage(im,27-(SizeX/2),27-(SizeY/2),this);

}

public void mousePressed(MouseEvent e){

isPressed = true;

repaint();

}

public void mouseReleased(MouseEvent e){

isPressed = false;

repaint();

}

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}

public void mouseClicked(MouseEvent e){}

}

Colori.java

import java.awt.Color;

public class Colori {

public int ColorCount;

public Color Pal[] = new Color[30];

public Colori() {

ColorCount = 0;

Pal[0]=new Color(252,102,0);

Pal[1]=new Color(252,206,9);

Pal[2]=new Color(204,0,0);

Pal[3]=new Color(51,102,51);

Pal[4]=new Color(153,153,51);

Pal[5]=new Color(153,51,0);

Pal[6]=new Color(252,143,102);

Pal[7]=new Color(0,153,153);

Pal[8]=new Color(106,83,0);

Pal[9]=new Color(213,128,0);

Pal[10]=new Color(128,255,0);

Pal[11]=new Color(252,84,84);

Pal[12]=new Color(0,252,84);

Pal[13]=new Color(32,159,7);

Pal[14]=new Color(78,156,156);

Pal[15]=new Color(170,85,0);

Pal[16]=new Color(124,0,252);

Pal[17]=new Color(252,84,252);

Pal[18]=new Color(188,0,252);

Pal[19]=new Color(252,0,252);

Pal[20]=new Color(252,0,188);

Pal[21]=new Color(252,0,124);

Pal[22]=new Color(102,153,153);

Pal[23]=new Color(252,0,64);

Pal[24]=new Color(252,0,0);

Pal[25]=new Color(252,64,0);

Pal[26]=new Color(252,124,0);

Pal[27]=new Color(252,188,0);

Pal[28]=new Color(252,252,0);

Pal[29]=new Color(188,252,0);

}

}

Contorno.java

import java.awt.*;

import java.awt.image.*;

public class Contorno {

public int x;

public int y;

public Contorno next;

public Contorno(int _x, int _y){

x=_x;

y=_y;

next = null;

}

private void move(int dir){

switch (dir){

case 0: y--; break;

case 1: y--; x++; break;

case 2: x++; break;

case 3: y++; x++; break;

case 4: y++; break;

case 5: y++; x--; break;

case 6: x--; break;

case 7: y--; x--; break;

}

}

public void primoPunto(Pix img){

int col=img.pix[this.y*Costanti.DIM+this.x];

while (col == img.pix[this.y*Costanti.DIM+this.x] && this.y>=0){this.move(Costanti.NORD);}

this.move(Costanti.SUD);

}

private static int sceltaDir(Contorno a, Contorno b){

int i=0;

if (a.x == b.x && a.y == b.y-1) i = Costanti.NORD;

else if (a.x == b.x+1 && a.y == b.y-1) i = Costanti.NORDEST;

else if (a.x == b.x+1 && a.y == b.y) i = Costanti.EST;

else if (a.x == b.x+1 && a.y == b.y+1) i = Costanti.SUDEST;

else if (a.x == b.x && a.y == b.y+1) i = Costanti.SUD;

else if (a.x == b.x-1 && a.y == b.y+1) i = Costanti.SUDOVEST;

else if (a.x == b.x-1 && a.y == b.y) i = Costanti.OVEST;

else if (a.x == b.x-1 && a.y == b.y-1) i = Costanti.NORDOVEST;

return i;

}

private Contorno check8Conn(int dir, Pix pixels, int col){

int colore = pixels.pix[(this.y+Costanti.DIRY[dir])*Costanti.DIM+(this.x+Costanti.DIRX[dir])];

while (colore != col || this.x<0 || this.x>255 || this.y<0 || this.y>255){

dir++;

if (dir==8) dir=0;

colore = pixels.pix[(this.y+Costanti.DIRY[dir])*Costanti.DIM+(this.x+Costanti.DIRX[dir])];

}

Contorno ret = new Contorno(this.x+Costanti.DIRX[dir], this.y+Costanti.DIRY[dir]);

return ret;

}

public void estrazione(Pix img){

Contorno partenza = this;

int _col = img.pix[this.y*Costanti.DIM + this.x];

Contorno N, pred, curr, prossimoPunto;

curr = new Contorno(this.x,this.y);

pred = new Contorno(this.x,this.y);

pred.move(Costanti.NORD);

prossimoPunto = cercaProssimo(curr, pred, img);

this.next = prossimoPunto;

while (!(prossimoPunto.x == partenza.x && prossimoPunto.y == partenza.y)){

curr.next = prossimoPunto;

pred = curr;

curr = prossimoPunto;

prossimoPunto = cercaProssimo(curr, pred, img);

}

curr.next = prossimoPunto;

prossimoPunto.next = partenza; // chiusura della catena

}

private static Contorno cercaProssimo(Contorno curr, Contorno pred, Pix img){

Contorno next = new Contorno(0,0);

int i,j;

Contorno temp;

int colcurr = img.pix[curr.y*Costanti.DIM+curr.x];

i = sceltaDir(pred, curr);

j=i+1;

if (j==8) j=0;

temp = curr.check8Conn(j, img, colcurr);

return temp;

}

public Contorno ordinaMinX(){

Contorno temp;

int min=256;

Contorno first = this;

Contorno newFirst;

temp = first;

newFirst = null;

do {

if (temp.x < min){

newFirst = temp;

min = temp.x;

}

temp = temp.next;

}while (temp != first);

return newFirst;

}

public int numNodi(){

Contorno temp = this;

int ret = 0;

do {

ret++;

temp = temp.next;

} while(temp != this);

return ret;

}

public double sceltaErrore(int _num){

int _err=0;

if (_num<50) _err=0;

else if (_num>=50 && _num <170) _err=1;

else if (_num>=170 && _num <250) _err=2;

else if (_num>=250 && _num <550) _err=3;

else if (_num>=550 && _num <750) _err=4;

else _err = 5;

return Costanti.APPROXERR[_err];

}

public Contorno approssimazionePoligonale(double err){

Contorno i,t,k,mind,Approx,ret;

double a,b,c,max,distanza;

Approx = new Contorno(this.x,this.y);

ret = Approx;

mind = this;

i=mind;

t=mind.next.next;

while (t!=this && t!=this.next){

max=0;

k=i.next;

while (k!=t){

a = t.y - i.y;

b = t.x - i.x;

c = i.y * t.x - i.x * t.y;

distanza=Math.abs(((double)(a*k.x-b*k.y+c))/

Math.sqrt((double)(Math.pow(a,2)+Math.pow(b,2))));

if (distanza > max) {

max=distanza;

mind=k;

}

k=k.next;

}

if (max>err){

i=mind;

Approx.next = new Contorno(mind.x, mind.y);

Approx = Approx.next;

t = mind.next.next;

}

else

t = t.next;

}

Approx.next = ret; // chiusura della catena

return ret;

}

public Pix creaPix(){

Pix nuovoPix = new Pix();

Contorno temp = this;

do {

nuovoPix.pix[temp.y*Costanti.DIM+temp.x]=0xff000000;

temp = temp.next;

} while(temp!=this);

return nuovoPix;

}

}

Costanti.java

public class Costanti {

public static final int DIM = 256;

public static final int DIMTOT = 256*256;

public static final int BIANCO = 0xffffffff;

public static final int GRIGI = 256;

public static final int MAXLIV = 7;

public static final int MAXPERC = 8;

public static final int LASTLIV = 7;

public static final int MINWHITE = 3000;

public static final double MAXPIX = 85.0;

public static final int DIRX[] = {0,1,1,1,0,-1,-1,-1};

public static final int DIRY[] = {-1,-1,0,1,1,1,0,-1};

public static final int NORD = 0;

public static final int NORDEST = 1;

public static final int EST = 2;

public static final int SUDEST = 3;

public static final int SUD = 4;

public static final int SUDOVEST = 5;

public static final int OVEST = 6;

public static final int NORDOVEST = 7;

public static final int INIMAGEX = 20;

public static final int INIMAGEY = 40;

public static final double APPROXERR[] = {1.0, 2.0, 4.1, 6.5, 9.5,14.5};

public static final int NUMPICCHI = 6;

public static final int SIGMA = 5;

}

DatiQuery.java

import java.sql.*;

public class DatiQuery {

static final double rangear=50000;

static final double rangede=10000;

static final double rangeas=40;//da -20 a 20

static final double rangeor=2;

static final double rangesp=200;

static final double rangeun=150;

static final double war=2;

static final double wde=10;

static final double wun=3;

static final double wor=3;

static final double was=3;

static final double wsp=3;

public double Area,infar,supar;

public double Densità,infde,supde;

public double Asimmetria,infas,supas;

public double Orientazione,infor,supor;

public double Spreadness,infsp,supsp;

public double Uniformità,infun,supun;

public double Convessità,infco,supco;

public int viid[] = new int[6];

public int relX[] = new int[6];

public int relY[] = new int[6];

public String desc[] = new String[6];

public int mode;

public double t0,t1;// t0=Trel; t1=Tgeo

SQL Rset;

public DatiQuery(){

Rset=null;

Area=0;infar=0;supar=1;

Densità=0;infde=0;supde=1;

Asimmetria=0;infas=0;supas=1;

Orientazione=0;infor=0;supor=1;

Spreadness=0;infsp=0;supsp=1;

Uniformità=0;infun=0;supun=1;

Convessità=0;infco=0;supco=1;

for (int i=0; i<6; i++){

viid[i]=-1;

relX[i]=-1;

relY[i]=-1;

desc[i]="";

}

mode=2;t0=0;t1=0;

}

public int F(){

int i=0;

for (int j=1;j<6;j++){

if (viid[i]>0) i++;

}

return i;

}

public void ordina(){

for (int i=2; i<6; i++){

if (viid[i]>0) ordina(i);

}

}

public void calcola(){

SQL.Query38(Rset.conn);

if ((mode==0 || mode==2) && viid[1]!= -1) calcolaVI();

if (mode==1) { riempiGM(); filtraGM(); }

if (mode==2) filtraGM();

}

private void calcolaVI(){

SQL R1=new SQL(Rset.conn);

SQL R2=new SQL(Rset.conn);

double sx=0;

double sy=0;

R1.Query39(viid[1]);

while (R1.next()){

if ( Sim(R1.getInt("relX"),relX[1]) >= t0 &&

Sim(R1.getInt("relY"),relY[1]) >= t0){

SQL.Query40(Rset.conn,R1.getInt("viid"),

Sim(R1.getInt("relX"),relX[1]),

Sim(R1.getInt("relY"),relY[1]));

}

}

R1.close();

SQL.statoRis(Rset.conn);

int i=2;

while(viid[i]>0){

R1.newSession();

R1.Query41();

while(R1.next()){

R2.Query42(R1.getInt("viid"),viid[i]);

if (R2.isEmpty()) {

SQL.Query43(Rset.conn,R1.getInt("viid"));

}

else {

sx=R1.getDouble("sx");

sy=R1.getDouble("sy");

sx+=Sim(R2.getInt("relx"),relX[i]);

sy+=Sim(R2.getInt("rely"),relY[i]);

SQL.Query44(Rset.conn,R2.getInt("viid"),sx,sy);

}

}

i++;

}

R1.close();

R2.close();

SQL.statoRis(Rset.conn);

}

private void riempiGM(){

SQL R1 = new SQL(Rset.conn);

R1.Query37();

while (R1.next()){

SQL.Query45(Rset.conn,R1.getInt("viid"));

}

R1.close();

SQL.statoRis(Rset.conn);

}

private void filtraGM(){

SQL R1=new SQL(Rset.conn);

SQL R2=new SQL(Rset.conn);

R1.Query41();

while (R1.next()){

R2.Query46(R1.getInt("viid"));

R2.next();

if (Between(R2)){

double dist=distanza(R2);

SQL.Query47(Rset.conn,R1.getInt("viid"),dist);

}

else {

SQL.Query48(Rset.conn,R1.getInt("viid"));

}

}

R1.close();

R2.close();

SQL.statoRis(Rset.conn);

}

private boolean Between(SQL R2){

double temp;

temp = R2.getDouble("convessita");

if (temp < infco) return false;

if (temp > supco) return false;

temp = normar(R2.getDouble("area"));

if (temp < infar) return false;

if (temp > supar) return false;

temp = normde(R2.getDouble("densita"));

if (temp < infde) return false;

if (temp > supde) return false;

temp = normas(R2.getDouble("asimmetria"));

if (temp < infas) return false;

if (temp > supas) return false;

temp = normsp(R2.getDouble("spreadness"));

if (temp < infsp) return false;

if (temp > supsp) return false;

temp = normor(R2.getDouble("orientazione"));

if (temp < infor) return false;

if (temp > supor) return false;

temp = normun(R2.getDouble("uniformita"));

if (temp < infun) return false;

if (temp > supun) return false;

return true;

}

private double distanza(SQL R2){

double dist=0;

double temp=0;

temp = R2.getDouble("densita");

dist+= (wde*Math.pow((Densità-temp)/rangede,2));

temp = R2.getDouble("uniformita");

dist+= (wun*Math.pow((Uniformità-temp)/rangeun,2));

temp = R2.getDouble("orientazione");

dist+= (wor*Math.pow((Orientazione-temp)/rangeor,2));

temp = R2.getDouble("asimmetria");

dist+= (was*Math.pow((Asimmetria-temp)/rangeas,2));

temp = R2.getDouble("area");

dist+= (war*Math.pow((Area-temp)/rangear,2));

temp = R2.getDouble("spreadness");

dist+= (wsp*Math.pow((Spreadness-temp)/rangesp,2));

return dist;

}

private double normar(double _area){

double _ret=_area/rangear;

if (_ret<0) return 0;

else if (_ret>1) return 1;

else return _ret;

}

private double normde(double _densità){

double _ret=_densità/rangede;

if (_ret<0) return 0;

else if (_ret>1) return 1;

else return _ret;

}

private double normas(double _asimmetria){

double _ret = (_asimmetria+20)/rangeas;

if (_ret<0) return 0;

else if (_ret>1) return 1;

else return _ret;

}

private double normun(double _uniformità){

double _ret=_uniformità/rangeun;

if (_ret<0) return 0;

else if (_ret>1) return 1;

else return _ret;

}

private double normor(double _orientazione){

double _ret=_orientazione/rangeor;

if (_ret<0) return 0;

else if (_ret>1) return 1;

else return _ret;

}

private double normsp(double _spreadness){

double _ret =_spreadness/rangesp;

if (_ret<0) return 0;

else if (_ret>1) return 1;

else return _ret;

}

private double norminf(double _val){

if (_val<0 || _val>1) return 0;

return _val;

}

private double normsup(double _val){

if (_val>1 || _val<0) return 1;

return _val;

}

public void setDefault(double val){

double temp;

temp = normar(Area);

infar=norminf(temp-val);

supar=normsup(temp+val);

temp = normde(Densità);

infde=norminf(temp-val);

supde=normsup(temp+val);

temp = normas(Asimmetria);

infas=norminf(temp-val);

supas=normsup(temp+val);

temp = normor(Orientazione);

infor=norminf(temp-val);

supor=normsup(temp+val);

temp = normsp(Spreadness);

infsp=norminf(temp-val);

supsp=normsup(temp+val);

temp = normun(Uniformità);

infun=norminf(temp-val);

supun=normsup(temp+val);

temp = Convessità;

infco=norminf(temp-val);

supco=normsup(temp+val);

}

private void ordina(int pos){

if (viid[pos]==-1) return;

else if (viid[pos-1]==-1 || viid[pos]<viid[pos-1]) {

bubbleUp(pos);

if (pos>2) ordina(pos-1);

}

}

private void bubbleUp(int pos){

int tempviid = viid[pos-1];

int temprelX = relX[pos-1];

int temprelY = relY[pos-1];

String tempdesc=desc[pos-1];

viid[pos-1]=viid[pos];

relX[pos-1]=relX[pos];

relY[pos-1]=relY[pos];

desc[pos-1]=desc[pos];

viid[pos]=tempviid;

relX[pos]=temprelX;

relY[pos]=temprelY;

desc[pos]=tempdesc;

}

private double Sim(int i,int j){

i=Math.abs(i);

j=Math.abs(j);

switch (i){

case 1:

switch (j){

case 1:return 1;

case 2:return .25;

case 3:return .75;

case 4:return 0;

case 5:return .25;

case 6:return 0;

case 7:return .5;

}

case 2:

switch(j){

case 1:return .25;

case 2:return 1;

case 3:return .5;

case 4:return .75;

case 5:return .75;

case 6:return .75;

case 7:return .75;

}

case 3:

switch(j){

case 1:return .75;

case 2:return .5;

case 3:return 1;

case 4:return .25;

case 5:return .5;

case 6:return .25;

case 7:return .75;

}

case 4:

switch(j){

case 1:return 0;

case 2:return .75;

case 3:return .25;

case 4:return 1;

case 5:return .75;

case 6:return .75;

case 7:return .75;

}

case 5:

switch(j){

case 1:return .25;

case 2:return .75;

case 3:return .5;

case 4:return .75;

case 5:return 1;

case 6:return .5;

case 7:return .5;

}

case 6:

switch(j){

case 1:return 0;

case 2:return .75;

case 3:return .25;

case 4:return .75;

case 5:return .5;

case 6:return 1;

case 7:return .75;

}

case 7:

switch(j){

case 1:return .5;

case 2:return .75;

case 3:return .75;

case 4:return .5;

case 5:return .75;

case 6:return .5;

case 7:return 1;

}

}

return 0;

}

}

Features.java

import java.awt.*;

import java.awt.image.*;

public class Features {

public double Convessità;

public double Densità;

public double Area;

public double Orientazione;

public double Spreadness;

public double Elongazione;

public double Uniformità;

public double Asimmetria;

public Contorno Cont;

public double Perimetro;

public Contorno Centroide;

public int Punti;

Pix origImage;

Pix segImage;

public Features(Contorno _C, Pix _origImage, Pix _segImage){

Cont=_C;

origImage = _origImage;

segImage = _segImage;

punti();

centroide();

simmetry();

features();

density();

if (convex()) Convessità=1;

else Convessità=0;

}

public void punti(){

Contorno temp = Cont;

Punti=0;

do{

Punti++;

temp=temp.next;

}while(temp!=Cont);

}

public void centroide(){

Contorno temp = Cont;

int X=0;

int Y=0;

for (int i=0; i<Punti; i++){

X+=temp.x;

Y+=temp.y;

temp = temp.next;

}

Centroide = new Contorno((int)X/Punti, (int)Y/Punti);

}

public void simmetry(){

int k;

Contorno temp;

float dist[] = new float[Punti];

double vmedioq=0,vmedio=0,mediana=0,X2=0,Y2=0;

double uff1=0,uff2=0,Som=0,Som2=0,Som3=0;

temp = this.Cont;

for (k=0; k<Punti;k++){

X2=Math.pow((temp.x - this.Centroide.x),2);

Y2=Math.pow((temp.y - this.Centroide.y),2);

dist[k]=(float)Math.sqrt(X2+Y2);

vmedio+=(dist[k]/Punti);

vmedioq+=(Math.pow(dist[k],2)/Punti);

temp = temp.next;

}

Orientazione=(float)((vmedioq)-Math.pow(vmedio,2));

float min=0,aiuto=0;

k=0;

int j=0,minind=0;

while(k < (Punti-1)){

min=dist[k];

j=k+1;

while(j<Punti){

if (min>dist[j]){

min=dist[j];

minind=j;

}

j++;

}

aiuto=dist[k];

dist[k]=dist[minind];

dist[minind]=aiuto;

k++;

}

if (Punti%2!=0) mediana=dist[Punti/2+1];

else {

double med1=dist[Punti/2],med2=dist[Punti/2+1];

mediana=(med1+med2)/2;

}

double s=Math.sqrt(Orientazione);

Asimmetria=3*(vmedio-mediana)/s;

}

public void features(){

double m00=0, alfa=0, m10=0, m01=0, p=0, peri=0;

double mi11=0, mi20=0, mi02=0;

Contorno pi,pj;

pi = Cont;

pj = Cont.next;

do {

peri += Math.sqrt(Math.pow(((double)(pi.x-pj.x)),2)+Math.pow(((double)(pi.y-pj.y)),2));

alfa = ((pj.y*pi.x)-(pi.y*pj.x))/2;

m00 += alfa;

m10 += (alfa*(pi.x+pj.x));

m01 += (alfa*(pi.y+pj.y));

pi = pi.next;

pj = pj.next;

}while(pi!=Cont);

m10 /= 3;

m01 /= 3;

mi11 = (m10*m01)/m00;

mi20 = Math.pow(m10,2)/m00;

mi02 = Math.pow(m01,2)/m00;

double Imin=0,Imax=0;

Area = (long)m00;

Imin = (mi20+mi02-Math.sqrt(4*Math.pow(mi11,2)+Math.pow(mi20-mi02,2)))/2;

Imax = (mi20+mi02+Math.sqrt(4*Math.pow(mi11,2)+Math.pow(mi20-mi02,2)))/2;

Spreadness = (Imin+Imax)/Math.pow(m00,2);

Elongazione=(Imax-Imin)/(Imax+Imin);

Orientazione=0.5*Math.atan2(2*mi11,mi20-mi02);

Perimetro=(int)peri;

if(Perimetro>0) Uniformità=((float)Math.pow(Perimetro,2)/(float)Area);

}

public boolean convex(){

Contorno temp = this.Cont;

int prodinc=0, verso=0;

Contorno pi,pj,pk;

boolean Concav = false;

if (this.Punti == 0) return false;

pi = temp;

pj = temp.next;

pk = temp.next.next;

prodinc = ((pk.x-pi.x)*(pj.y-pi.y)-(pj.x-pi.x)*(pk.y-pi.y));

if (prodinc>0) verso=1;

else verso = -1;

temp = temp.next;

while (temp != this.Cont && !Concav){

pi = temp;

pj = temp.next;

pk = temp.next.next;

prodinc = ((pk.x-pi.x)*(pj.y-pi.y)-(pj.x-pi.x)*(pk.y-pi.y));

switch(verso){

case 1 :if (prodinc < 0) Concav=true; break;

case -1:if (prodinc > 0) Concav=true; break;

}

temp = temp.next;

}

return (!Concav);

}

public void density(){

double d,dq,col;

d=0;

dq=0;

int n_punti=0;

Rettangolo CRet=new Rettangolo(Cont);

int colore = segImage.pix[Cont.y*Costanti.DIM+Cont.x];

for (int i=CRet.Ovest; i<=CRet.Est; i++){

for (int j=CRet.Nord; j<=CRet.Sud; j++){

if (segImage.inShape(i,j,colore)){

n_punti++;

}

}

}

for (int i=CRet.Ovest; i<=CRet.Est; i++){

for (int j=CRet.Nord; j<=CRet.Sud; j++){

if (segImage.inShape(i,j,colore)){

col = ((origImage.pix[j*Costanti.DIM+i] >> 16) & 0xff);

d += (col/n_punti);

dq += ((Math.pow(col,2))/n_punti);

}

}

}

Densità=(dq-Math.pow(d,2));

}

}

FrameAccettazione.java

import java.awt.*;import java.awt.event.*;

import java.sql.*;

public class FrameAccettazione extends Frame implements MouseListener,KeyListener {

TextField Cog,Nom,Num,Anno,Mod,Dia,Data,Med;

Button Esame,Anamnesi,Diario,MNext,New,Save,Exit;

Image Title;

SQL Rset,RsetFA;

boolean isNew;

String nprat,anno;

public FrameAccettazione(SQL _Rset){

setLocation(100,100);

setSize(600,360);

setTitle("Moduli di accettazione");

setResizable(false);

setVisible(true);

Title = Toolkit.getDefaultToolkit().getImage("image3.gif");

Cog = new TextField();

Nom = new TextField();

Num = new TextField();

Anno = new TextField();

Mod = new TextField();

Data = new TextField();

Med = new TextField();

Dia = new TextField();

Rset = _Rset;

RsetFA = new SQL(Rset.conn);

nprat = Rset.getInt2String("nprat");

anno = Rset.getInt2String("anno");

RsetFA.Query8(nprat,anno);

Esame = new Button("Esame obiettivo");

Anamnesi = new Button("Anamnesi");

Diario = new Button("Diario clinico");

MNext = new Button("Moduli successivi");

New = new Button("Nuovo Modulo");

Save = new Button("Salva");

Exit = new Button("Esci");

riempiCampi1();

if (RsetFA.isEmpty()){

azzeraCampi();

enableTasti(false,true);

isNew = true;

}

else {

riempiCampi();

isNew = false;

}

add(Esame);

add(Anamnesi);

add(Diario);

add(MNext);

add(New);

add(Save);

add(Exit);

add(Cog);

add(Nom);

add(Num);

add(Anno);

add(Mod);

add(Dia);

add(Data);

add(Med);

Exit.addMouseListener(this);

Save.addMouseListener(this);

New.addMouseListener(this);

MNext.addMouseListener(this);

Diario.addMouseListener(this);

Anamnesi.addMouseListener(this);

Esame.addMouseListener(this);

Mod.addKeyListener(this);

Dia.addKeyListener(this);

Data.addKeyListener(this);

Med.addKeyListener(this);

Cog.setEditable(false);

Nom.setEditable(false);

Num.setEditable(false);

Anno.setEditable(false);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Paziente",10,120);

g.drawString("Cartella clinica n.",350,120);

g.drawString("Archiviata nel",350,150);

g.drawString("Modulo n.",20,200);

g.drawString("Diagnosi di accettazione",20,230);

g.drawString("Data acc.",20,260);

g.drawString("Medico accettante",175,260);

Esame.setSize(100,20);Esame.setLocation(470,185);

Anamnesi.setSize(100,20);Anamnesi.setLocation(470,215);

Diario.setSize(100,20);Diario.setLocation(470,245);

Cog.setSize(120,20);Cog.setLocation(70,105);

Nom.setSize(120,20);Nom.setLocation(200,105);

Num.setSize(60,20);Num.setLocation(450,105);

Anno.setSize(60,20);Anno.setLocation(430,135);

Mod.setSize(60,20);Mod.setLocation(80,185);

Dia.setSize(300,20);Dia.setLocation(160,215);

Data.setSize(90,20);Data.setLocation(80,245);

Med.setSize(180,20);Med.setLocation(280,245);

MNext.setSize(110,20);MNext.setLocation(35,290);

New.setSize(110,20);New.setLocation(35,320);

Save.setSize(100,30);Save.setLocation(180,300);

Exit.setSize(100,30);Exit.setLocation(300,300);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit){

RsetFA.close();

this.setVisible(false);

FrameFacciata FF = new FrameFacciata(false,Rset);

}

if (e.getComponent()==Save){

if (isNew){

int oldmod = SQL.retInt(Mod.getText());

if (SQL.Query9(Rset.conn,Num.getText(), Anno.getText(), Mod.getText(),

Data.getText(), Med.getText(), Dia.getText())) {

RsetFA.newSession();

RsetFA.Query8(nprat,anno);

RsetFA.next();

while (RsetFA.getInt("nmodulo") != oldmod) RsetFA.next();

riempiCampi();

enableTasti(true,true);

}

else new MsgBox(this,"Dati non validi");

}

else {

int oldmod = SQL.retInt(Mod.getText());

if (SQL.Query10(Rset.conn, Num.getText(), Anno.getText(), Mod.getText(),

Data.getText(), Med.getText(), Dia.getText())) {

RsetFA.Query8(nprat,anno);

RsetFA.next();

while (RsetFA.getInt("nmodulo") != oldmod) RsetFA.next();

riempiCampi();

}

else new MsgBox(this,"Dati non validi");

}

}

if (e.getComponent() == New){

isNew=true;

azzeraCampi();

enableTasti(false,true);

}

if (e.getComponent() == MNext){

if (RsetFA.next()) riempiCampi();

else {

RsetFA.newSession();

RsetFA.Query8(nprat,anno);

RsetFA.next();

riempiCampi();

}

}

if (e.getComponent()==Anamnesi){

RsetFA.close();

setVisible(false);

FrameAnamnesi FAn = new FrameAnamnesi(Rset,RsetFA);

}

if (e.getComponent()==Esame){

RsetFA.close();

setVisible(false);

FrameEsameObiettivo FAn = new FrameEsameObiettivo(Rset,RsetFA);

}

if (e.getComponent()==Diario){

RsetFA.close();

setVisible(false);

FrameDiarioClinico FDC = new FrameDiarioClinico(Rset,RsetFA.getInt("nmodulo"),true);

}

}

public void enableTasti(boolean value,boolean savevalue){

New.setEnabled(value);

MNext.setEnabled(value);

Diario.setEnabled(value);

Anamnesi.setEnabled(value);

Esame.setEnabled(value);

Save.setEnabled(savevalue);

}

public void azzeraCampi(){

Mod.setText("");

Data.setText("");

Med.setText("");

Dia.setText("");

}

public void riempiCampi(){

Mod.setText(RsetFA.getInt2String("nmodulo"));

Dia.setText(RsetFA.getString("diagnosi"));

Data.setText(RsetFA.getDate2String("data"));

Med.setText(RsetFA.getString("medico"));

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void riempiCampi1(){

Cog.setText(Rset.getString("cognome"));

Nom.setText(Rset.getString("nome"));

Num.setText(nprat);

Anno.setText(anno);

}

}

FrameAnamnesi.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameAnamnesi extends Frame implements MouseListener,KeyListener {

Button Save,Exit;

TextField Cog,Nom,Num,Anno;

TextArea Testo;

Image Title;

SQL Rset,RsetFA,RsetFAn;

String nprat,anno,nmodulo;

public FrameAnamnesi(SQL _Rset,SQL _RsetFA){

setLocation(100,100);

setSize(600,400);

setTitle("Anamnesi");

setResizable(false);

setVisible(true);

Rset = _Rset;

RsetFA = _RsetFA;

RsetFAn = new SQL(Rset.conn);

Title = Toolkit.getDefaultToolkit().getImage("image5.gif");

Save = new Button("Salva");

Exit = new Button("Esci");

Testo = new TextArea();

Cog = new TextField();

Nom = new TextField();

Num = new TextField();

Anno = new TextField();

Cog.setEditable(false);

Nom.setEditable(false);

Num.setEditable(false);

Anno.setEditable(false);

add(Save);

add(Exit);

add(Cog);

add(Nom);

add(Num);

add(Anno);

add(Testo);

riempiCampi1();

nprat = RsetFA.getInt2String("nprat");

anno = RsetFA.getInt2String("anno");

nmodulo = RsetFA.getInt2String("nmodulo");

RsetFAn.Query11(nprat,anno,nmodulo);

RsetFAn.next();

Testo.setText(RsetFAn.getString("anamnesi"));

Save.addMouseListener(this);

Exit.addMouseListener(this);

Testo.addKeyListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Paziente",10,120);

g.drawString("Cartella clinica n.",350,120);

g.drawString("Archiviata nel",350,150);

Cog.setSize(120,20);Cog.setLocation(70,105);

Nom.setSize(120,20);Nom.setLocation(200,105);

Num.setSize(60,20);Num.setLocation(450,105);

Anno.setSize(60,20);Anno.setLocation(430,135);

Testo.setSize(500,170);Testo.setLocation(50,160);

Save.setSize(100,30);Save.setLocation(180,340);

Exit.setSize(100,30);Exit.setLocation(300,340);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit){

RsetFA.close();

RsetFAn.close();

this.setVisible(false);

FrameAccettazione FA = new FrameAccettazione(Rset);

}

if (e.getComponent()==Save){

if (! SQL.Query12(Rset.conn,nprat,anno,nmodulo,Testo.getText()))

new MsgBox(this, "Dati non validi");

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void riempiCampi1(){

Cog.setText(Rset.getString("cognome"));

Nom.setText(Rset.getString("nome"));

Num.setText(Rset.getInt2String("nprat"));

Anno.setText(Rset.getInt2String("anno"));

}

}

FrameContorno.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameContorno extends Frame implements MouseListener{

Button Approx,TBCa,Save,Exit,Query,Anomalia;

TextField Dati[] = new TextField[7];

TextField Desc[] = new TextField[5];

TextField RelX[] = new TextField[5];

TextField RelY[] = new TextField[5];

TextField ApproxVal;

int selected,nmod,viid;

double Errore;

QueryCanvas QC;

ToolBar TBC;

SQL Rset;

Image ContImage;

Pix PixOrig,PixSeg;

Contorno Cont,App;

Features Feat;

boolean Saved;

public FrameContorno(Pix _origImage,Pix _segImage, int x, int y,

SQL _Rset,int _nmod, int _viid){

setSize(600,540);

setLocation(100,50);

setResizable(false);

setTitle("Estrazione del contorno e creazione virtual image");

Rset = _Rset;

nmod = _nmod;

viid = _viid;

Cont = new Contorno(x,y);

Cont.primoPunto(_segImage);

Cont.estrazione(_segImage);

Pix PixCont = Cont.creaPix();

ContImage = PixCont.getImage();

PixOrig = _origImage;

PixSeg = _segImage;

Errore = Cont.sceltaErrore(Cont.numNodi());

App = Cont.approssimazionePoligonale(Errore);

Feat = new Features(App, PixOrig, PixSeg);

Rettangolo R=new Rettangolo(App);

for (int i=0; i<7; i++) Dati[i]=new TextField();

for (int i=0; i<5; i++) {

Desc[i]=new TextField();

RelX[i]=new TextField();

RelY[i]=new TextField();

}

ApproxVal = new TextField();

Approx = new Button("Approssima");

Save = new Button("Salva");

Exit = new Button("Esci");

Query = new Button("Query");

TBCa = new Button("ToolBar");

Anomalia = new Button("Salva anomalia");

selected = -1;

Saved=true;

caricaDatiFeat();

ApproxVal.setText(String.valueOf(Errore));

TBC = new ToolBar(this,Rset.conn,1);

QC = new QueryCanvas();

setVisible(true);

add(ApproxVal);

add(Approx);

add(Save);

add(Exit);

add(Query);

add(Anomalia);

add(TBCa);

add(QC);

QC.caricaContorno(App,"anomalia"+String.valueOf(viid),viid);

for (int i=0; i<7; i++) add(Dati[i]);

for (int i=0; i<5; i++) {

add(Desc[i]);

add(RelX[i]);

add(RelY[i]);

}

Approx.addMouseListener(this);

Save.addMouseListener(this);

Exit.addMouseListener(this);

Query.addMouseListener(this);

TBCa.addMouseListener(this);

Anomalia.addMouseListener(this);

for (int i=0; i<TBC.numImage; i++)

TBC.BI[i].addMouseListener(this);

QC.addMouseListener(this);

}

public void paint(Graphics g){

g.drawImage(ContImage,10,25,this);

g.drawRect(279,24,258,258);

QC.setSize(256,256);

QC.setLocation(280,25);

QC.repaint();

g.drawString("Area",10,305);

g.drawString("Densità",10,335);

g.drawString("Asimmetria",10,365);

g.drawString("Orientazione",10,395);

g.drawString("Spreadness",10,425);

g.drawString("Uniformità",10,455);

g.drawString("Convessità",10,485);

for (int i=0; i<7; i++){

Dati[i].setSize(120,20);

Dati[i].setLocation(100,290+(30*i));

}

ApproxVal.setSize(80,20);

ApproxVal.setLocation(230,290);

Approx.setSize(100,20);

Approx.setLocation(320,290);

TBCa.setSize(100,20);

TBCa.setLocation(430,290);

Save.setSize(85,30);

Save.setLocation(230,470);

Exit.setSize(85,30);

Exit.setLocation(320,470);

Query.setSize(85,30);

Query.setLocation(410,470);

Anomalia.setSize(85,30);

Anomalia.setLocation(500,470);

for(int i=0; i<5; i++){

Desc[i].setSize(160,20);

Desc[i].setLocation(230,320+(30*i));

RelX[i].setSize(60,20);

RelX[i].setLocation(400,320+(30*i));

RelY[i].setSize(60,20);

RelY[i].setLocation(470,320+(30*i));

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {

if (e.getComponent()==QC) riempiDati2();

}

public void mousePressed(MouseEvent e){}

public void mouseClicked(MouseEvent e){

if (e.getComponent()==Query) {

if (Saved){

DatiQuery QD=new DatiQuery();

riempiDatiQuery(QD);

QD.ordina();

setVisible(false);

FrameEsecuzioneQuery FEQ=new FrameEsecuzioneQuery(Rset,QD);

}

else new MsgBox(this,"Bisogna prima salvare i dati");

return;

}

if (e.getComponent()==Exit) {

setVisible(false);

FrameReferto FR=new FrameReferto(Rset,nmod,viid);

return;

}

if (e.getComponent()==Anomalia){

Rettangolo A=new Rettangolo(Cont);

try{

BMP.putBMP("ToolBar/anomalia"+String.valueOf(viid)+".bmp",Cont,A,0);

BMP.putBMP("ToolBar/Ranomalia"+String.valueOf(viid)+".bmp",Cont,A,1);

}

catch(Exception ex){}

SQL.Query33(Rset.conn,"anomalia"+String.valueOf(viid)+".bmp",A.Est-A.Ovest+1,A.Sud-A.Nord+1,viid);

return;

}

if (e.getComponent()==Save){

DatiQuery QD = new DatiQuery();

riempiDatiQuery(QD);

QD.ordina();

SQL.Query32(Rset.conn,QD);

Saved=true;

}

if (e.getComponent()==TBCa) {

TBC.setVisible(true);

return;

}

if (e.getComponent()==QC){

Saved=false;

riempiDati2();

return;

}

if (e.getComponent()==Approx){

Saved=false;

Errore = new Double(ApproxVal.getText()).doubleValue();

if (Errore > 0){

App = Cont.approssimazionePoligonale(Errore);

Feat = new Features(App, PixOrig, PixSeg);

Rettangolo R=new Rettangolo(App);

caricaDatiFeat();

QC.caricaContorno(App,"anomalia "+String.valueOf(viid),viid);

riempiDati2();

}

else new MsgBox(this,"Errore di approssimazione non valido");

return;

}

int sel=-1;

for (int i=0; i<TBC.numImage; i++)

if (e.getComponent()==TBC.BI[i])

sel=i;

if (sel != -1){

SQL R1=new SQL(Rset.conn);

R1.Query30(sel+1);

R1.next();

QC.caricaCanonico(R1.getString("FileBMP"),R1.getString("descrizione"),

R1.getInt("SizeX"),R1.getInt("SizeY"),sel+1);

riempiDati2();

return;

}

}

public void riempiDati2(){

for (int i=0; i<5; i++){

Desc[i].setText(QC.desc[i+1]);

RelX[i].setText(Rettangolo.val2String(QC.relX[i+1]));

RelY[i].setText(Rettangolo.val2String(QC.relY[i+1]));

}

}

public void caricaDatiFeat(){

Dati[0].setText(String.valueOf(Feat.Area));

Dati[1].setText(String.valueOf(Feat.Densità));

Dati[2].setText(String.valueOf(Feat.Asimmetria));

Dati[3].setText(String.valueOf(Feat.Orientazione));

Dati[4].setText(String.valueOf(Feat.Spreadness));

Dati[5].setText(String.valueOf(Feat.Uniformità));

if (Feat.Convessità == 1) Dati[6].setText("Convesso");

else Dati[6].setText("Concavo");

}

public void riempiDatiQuery(DatiQuery DQ){

DQ.Rset=Rset;

DQ.Area = Feat.Area;

DQ.Densità = Feat.Densità;

DQ.Asimmetria = Feat.Asimmetria;

DQ.Orientazione = Feat.Orientazione;

DQ.Spreadness = Feat.Spreadness;

DQ.Uniformità = Feat.Uniformità;

DQ.Convessità = Feat.Convessità;

for (int i=0; i<6; i++){

DQ.desc[i]=QC.desc[i];

DQ.viid[i]=QC.viid[i];

DQ.relX[i]=QC.relX[i];

DQ.relY[i]=QC.relY[i];

}

DQ.viid[0]=viid;

DQ.ordina();

}

}

FrameDatiAnagrafici.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

 

public class FrameDatiAnagrafici extends Frame implements MouseListener,KeyListener {

Button Save,Exit;

TextField Cog,Nom,Pat,Cod,Sex,Natoa,NatPr,Natoil,Res,Prv,Reg,Ind,Tel,Civ,Prof,Cog2,Nom2,Nato2,Il2;

Image Title;

Connection Conn;

ResultSet Rset,RsetDA;

FrameDatiAnagrafici(Connection _Conn, ResultSet _Rset){

setSize(600,450);

setLocation(100,100);

setVisible(true);

setResizable(false);

setTitle("Dati anagrafici");

Title = Toolkit.getDefaultToolkit().getImage("image2.gif");

Conn = _Conn;

Rset = _Rset;

RsetDA = null;

try{

RsetDA = SQLlibrary.Query6(Conn,Rset.getString("codfisc"));

RsetDA.next();

}

catch(Exception e){ }

Save = new Button("Salva");

Exit = new Button("Esci");

try {Cog = new TextField(Rset.getString("cognome"));}

catch(Exception e){Cog = new TextField();}

try {Nom = new TextField(Rset.getString("nome"));}

catch(Exception e){Nom = new TextField();}

try {Pat = new TextField(RsetDA.getString("padre"));}

catch(Exception e){Pat = new TextField();}

try {Cod = new TextField(RsetDA.getString("codfisc"));}

catch(Exception e){Cod = new TextField();}

try {Sex = new TextField(RsetDA.getString("sesso"));}

catch(Exception e){Sex = new TextField();}

try {Natoa = new TextField(RsetDA.getString("luogo_nasc"));}

catch(Exception e){Natoa = new TextField();}

try {NatPr = new TextField(RsetDA.getString("prov_nasc"));}

catch(Exception e){NatPr = new TextField();}

try {Natoil = new TextField(SQLlibrary.retDate(Rset.getDate("data_nasc")));}

catch(Exception e){Natoil = new TextField();}

try {Res = new TextField(RsetDA.getString("luogo_res"));}

catch(Exception e){Res = new TextField();}

try {Prv = new TextField(RsetDA.getString("prov_res"));}

catch(Exception e){Prv = new TextField();}

try {Reg = new TextField(RsetDA.getString("regione"));}

catch(Exception e){Reg = new TextField();}

try {Ind = new TextField(RsetDA.getString("indirizzo"));}

catch(Exception e){Ind = new TextField();}

try {Tel = new TextField(RsetDA.getString("tel"));}

catch(Exception e){Tel = new TextField();}

try {Civ = new TextField(RsetDA.getString("stato_civ"));}

catch(Exception e){Civ = new TextField();}

try {Prof = new TextField(RsetDA.getString("profess"));}

catch(Exception e){Prof = new TextField();}

try {Cog2 = new TextField(RsetDA.getString("cognome_cf"));}

catch(Exception e){Cog2 = new TextField();}

try {Nom2 = new TextField(RsetDA.getString("nome_cf"));}

catch(Exception e){Nom2 = new TextField();}

try {Nato2 = new TextField(RsetDA.getString("luogo_nasc_cf"));}

catch(Exception e){Nato2 = new TextField();}

try {Il2 = new TextField(SQLlibrary.retDate(RsetDA.getDate("data_nasc_cf")));}

catch(Exception e){Il2 = new TextField();}

add(Save);

add(Exit);

add(Cog);

add(Nom);

add(Pat);

add(Cod);

add(Sex);

add(Natoa);

add(NatPr);

add(Natoil);

add(Res);

add(Prv);

add(Reg);

add(Ind);

add(Tel);

add(Civ);

add(Prof);

add(Cog2);

add(Nom2);

add(Nato2);

add(Il2);

Pat.addKeyListener(this);

Sex.addKeyListener(this);

Natoa.addKeyListener(this);

NatPr.addKeyListener(this);

Res.addKeyListener(this);

Prv.addKeyListener(this);

Reg.addKeyListener(this);

Ind.addKeyListener(this);

Tel.addKeyListener(this);

Civ.addKeyListener(this);

Prof.addKeyListener(this);

Cog2.addKeyListener(this);

Nom2.addKeyListener(this);

Nato2.addKeyListener(this);

Il2.addKeyListener(this);

Save.addMouseListener(this);

Exit.addMouseListener(this);

Cog.setEditable(false);

Nom.setEditable(false);

Natoil.setEditable(false);

Cod.setEditable(false);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Cognome",10,115);

g.drawString("Nome",220,115);

g.drawString("Paternità",410,115);

g.drawString("Codice Fiscale",10,145);

g.drawString("Sesso",280,145);

g.drawString("Nato a",10,175);

g.drawString("Prov.",240,175);

g.drawString("il",340,175);

g.drawString("Residente a",10,205);

g.drawString("Prov.",260,205);

g.drawString("Regione",360,205);

g.drawString("Indirizzo",10,235);

g.drawString("Telefono",250,235);

g.drawString("Stato civile",10,265);

g.drawString("Professione",210,265);

g.drawString("Generalità del coniuge o esercente patria podetà",150,310);

g.drawString("Cognome",110,335);

g.drawString("Nome",310,335);

g.drawString("Nato a",170,365);

g.drawString("il",310,365);

g.drawLine(100,290,490,290);

g.drawLine(490,290,490,380);

g.drawLine(490,380,100,380);

g.drawLine(100,380,100,290);

Cog.setSize(120,20);

Cog.setLocation(80,100);

Nom.setSize(120,20);Nom.setLocation(270,100);

Pat.setSize(120,20);Pat.setLocation(470,100);

Cod.setSize(150,20);Cod.setLocation(110,130);

Sex.setSize(40,20);Sex.setLocation(330,130);

Natoa.setSize(160,20);Natoa.setLocation(70,160);

NatPr.setSize(40,20);NatPr.setLocation(280,160);

Natoil.setSize(110,20);Natoil.setLocation(360,160);

Res.setSize(160,20);Res.setLocation(85,190);

Prv.setSize(40,20);Prv.setLocation(300,190);

Reg.setSize(80,20);Reg.setLocation(420,190);

Ind.setSize(170,20);Ind.setLocation(70,220);

Tel.setSize(100,20);Tel.setLocation(310,220);

Civ.setSize(115,20);Civ.setLocation(80,250);

Prof.setSize(120,20);Prof.setLocation(290,250);

Cog2.setSize(120,20);Cog2.setLocation(175,320);

Nom2.setSize(120,20);Nom2.setLocation(355,320);

Nato2.setSize(80,20);Nato2.setLocation(220,350);

Il2.setSize(110,20);Il2.setLocation(325,350);

Save.setSize(100,30);Save.setLocation(180,400);

Exit.setSize(100,30);Exit.setLocation(300,400);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit){

this.setVisible(false);

FrameFacciata FF = new FrameFacciata(false,Conn,Rset);

}

if (e.getComponent()==Save){

String h="";

try{h=Rset.getString("codfisc");}

catch(Exception ex){}

if (SQLlibrary.Query7(Conn,h,Natoa.getText(),Sex.getText(),Res.getText(),

Ind.getText(),Prv.getText(),Reg.getText(),Tel.getText(),

NatPr.getText(),Pat.getText(),Prof.getText(),Civ.getText(),

Nom2.getText(),Cog2.getText(),Il2.getText(),Nato2.getText())){

}

else new MsgBox(this,"Dati errati");

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

}

FrameDenunce.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameDenunce extends Frame implements MouseListener,KeyListener{

TextField Cog,Nom,Num,Anno,Mal,Data;

Button Next,New,Save,Exit;

Image Title;

SQL Rset,RsetFD;

boolean isNew;

String nprat,anno;

public FrameDenunce(SQL _Rset){

setLocation(100,100);

setSize(600,360);

setTitle("Denunce");

setResizable(false);

setVisible(true);

Title = Toolkit.getDefaultToolkit().getImage("image10.gif");

Rset = _Rset;

RsetFD = new SQL(Rset.conn);

nprat = Rset.getInt2String("nprat");

anno = Rset.getInt2String("anno");

RsetFD.Query18(nprat,anno);

creaOggetti();

impostaCampi1();

isNew=false;

if (RsetFD.isEmpty()){

azzeraCampi();

Next.setEnabled(false);

New.setEnabled(true);

Save.setEnabled(false);

}

else riempiCampi();

add(Next);

add(New);

add(Save);

add(Exit);

add(Cog);

add(Nom);

add(Num);

add(Anno);

add(Mal);

add(Data);

Exit.addMouseListener(this);

Save.addMouseListener(this);

New.addMouseListener(this);

Next.addMouseListener(this);

Mal.addKeyListener(this);

Data.addKeyListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Paziente",10,120);

g.drawString("Cartella clinica n.",350,120);

g.drawString("Archiviata nel",350,150);

g.drawString("Malattia",20,200);

g.drawString("Data",20,230);

Cog.setSize(120,20);Cog.setLocation(70,105);

Nom.setSize(120,20);Nom.setLocation(200,105);

Num.setSize(60,20);Num.setLocation(450,105);

Anno.setSize(60,20);Anno.setLocation(430,135);

Mal.setSize(260,20);Mal.setLocation(80,185);

Data.setSize(100,20);Data.setLocation(80,215);

Next.setSize(110,20);Next.setLocation(35,290);

New.setSize(110,20);New.setLocation(35,320);

Save.setSize(100,30);Save.setLocation(180,300);

Exit.setSize(100,30);Exit.setLocation(300,300);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit){

RsetFD.close();

this.setVisible(false);

FrameFacciata FF = new FrameFacciata(false,Rset);

}

if (e.getComponent()==Save){

if (isNew){

if (SQL.Query19(Rset.conn,Num.getText(), Anno.getText(), Mal.getText(),Data.getText())) {

RsetFD.newSession();

RsetFD.Query18(nprat,anno);

RsetFD.next();

riempiCampi();

isNew=false;

Next.setEnabled(true);

New.setEnabled(true);

Save.setEnabled(true);

}

else new MsgBox(this,"Dati non validi");

}

else {

if (SQL.Query20(Rset.conn,Num.getText(), Anno.getText(),RsetFD.getString("malattia"),

Mal.getText(),Data.getText())) {

RsetFD.close();

RsetFD.Query18(nprat,anno);

RsetFD.next();

riempiCampi();

}

else new MsgBox(this,"Dati non validi");

}

}

if (e.getComponent() == New){

isNew=true;

azzeraCampi();

New.setEnabled(false);

Save.setEnabled(true);

Next.setEnabled(false);

}

if (e.getComponent() == Next){

if (RsetFD.next()) riempiCampi();

else {

RsetFD.newSession();

RsetFD.Query18(nprat,anno);

RsetFD.next();

riempiCampi();

}

}

}

public void azzeraCampi(){

Mal.setText("");

Data.setText("");

}

public void riempiCampi(){

Mal.setText(RsetFD.getString("malattia"));

Data.setText(RsetFD.getDate2String("data"));

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void creaOggetti(){

Mal = new TextField();

Data = new TextField();

Next = new Button("Successiva");

New = new Button("Nuova");

Save = new Button("Salva");

Exit = new Button("Esci");

Cog = new TextField();

Nom = new TextField();

Num = new TextField();

Anno = new TextField();

}

public void impostaCampi1(){

Cog.setText(Rset.getString("cognome"));

Nom.setText(Rset.getString("nome"));

Num.setText(Rset.getInt2String("nprat"));

Anno.setText(Rset.getInt2String("anno"));

Cog.setEditable(false);

Nom.setEditable(false);

Num.setEditable(false);

Anno.setEditable(false);

}

}

FrameDiarioClinico.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameDiarioClinico extends Frame implements MouseListener,KeyListener,ItemListener {

Button Save,Exit,New,Next,Referto,Esami;

TextField Cog,Nom,Num,Anno,NomeEsame,Data,Nmod;

Choice Codice;

Image Title;

SQL Rset,RsetFDC,RsetC;

String nprat,anno,nmodulo;

boolean isNew,fromAcc;

int nmod,codref;

public FrameDiarioClinico(SQL _Rset,int _nmod,boolean _fromAcc){

setLocation(100,100);

setSize(600,400);

setTitle("Diario Clinico");

setResizable(false);

setVisible(true);

Title = Toolkit.getDefaultToolkit().getImage("image6.gif");

Rset = _Rset;

fromAcc = _fromAcc;

nmod = _nmod;

RsetFDC = new SQL(Rset.conn);

RsetC = new SQL(Rset.conn);

Save = new Button("Salva");

Exit = new Button("Esci");

New = new Button("Nuovo");

Next = new Button("Prossimo");

Cog = new TextField();

Nom = new TextField();

Num = new TextField();

Anno = new TextField();

Referto = new Button("Referto");

Esami = new Button("Esami");

Codice = new Choice();

NomeEsame = new TextField();

Data = new TextField();

Nmod = new TextField();

NomeEsame.setEditable(false);

Nmod.setEditable(false);

RsetC.Query25();

while (RsetC.next()) Codice.add(RsetC.getString("codice"));

add(Save);

add(Exit);

add(Next);

add(New);

add(Cog);

add(Nom);

add(Num);

add(Anno);

add(Referto);

add(Esami);

add(Codice);

add(NomeEsame);

add(Data);

add(Nmod);

Save.addMouseListener(this);

Exit.addMouseListener(this);

Next.addMouseListener(this);

New.addMouseListener(this);

Esami.addMouseListener(this);

Referto.addMouseListener(this);

Codice.addItemListener(this);

Data.addKeyListener(this);

impostaCampi1();

if (fromAcc){

RsetFDC.Query21(nprat,anno,String.valueOf(nmod));

if (RsetFDC.isEmpty()){

Next.setEnabled(false);

azzeraCampi();

isNew=true;

}

else {

riempiCampi();

}

}

else {

RsetFDC.Query22(nprat,anno);

Save.setEnabled(false);

New.setEnabled(false);

if (RsetFDC.isEmpty()){

Next.setEnabled(false);

azzeraCampi();

}

else {

riempiCampi();

}

}

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Paziente",10,120);

g.drawString("Cartella clinica n.",350,120);

g.drawString("Archiviata nel",350,150);

Cog.setSize(120,20);Cog.setLocation(70,105);

Nom.setSize(120,20);Nom.setLocation(200,105);

Num.setSize(60,20);Num.setLocation(450,105);

Anno.setSize(60,20);Anno.setLocation(430,135);

Save.setSize(100,30);Save.setLocation(180,340);

Exit.setSize(100,30);Exit.setLocation(300,340);

New.setSize(100,20);New.setLocation(20,310);

Next.setSize(100,20);Next.setLocation(20,280);

g.drawString("N. Modulo",10,170);

g.drawString("Codice",10,205);

g.drawString("Nome Esame",10,235);

g.drawString("Data",10,265);

Nmod.setSize(80,20);Nmod.setLocation(100,160);

Codice.setSize(100,20);Codice.setLocation(100,190);

NomeEsame.setSize(250,20);NomeEsame.setLocation(100,220);

Data.setSize(120,20);Data.setLocation(100,250);

Referto.setSize(100,20);Referto.setLocation(400,205);

Esami.setSize(100,20);Esami.setLocation(400,235);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit){

RsetFDC.close();

RsetC.close();

this.setVisible(false);

if (fromAcc) {

FrameAccettazione FA = new FrameAccettazione(Rset);

}

else {

FrameFacciata FF = new FrameFacciata(false,Rset);

}

}

if (e.getComponent()==Next){

if (! RsetFDC.isEmpty()) riempiCampi();

else {

if (fromAcc){

RsetFDC.newSession();

RsetFDC.Query21(nprat,anno,String.valueOf(nmod));

if (RsetFDC.isEmpty()){

Next.setEnabled(false);

azzeraCampi();

}

else {

riempiCampi();

}

}

else {

RsetFDC.newSession();

RsetFDC.Query22(nprat,anno);

if (RsetFDC.isEmpty()){

Next.setEnabled(false);

azzeraCampi();

}

else {

riempiCampi();

}

}

}

}

if (e.getComponent()==New){

azzeraCampi();

isNew=true;

Next.setEnabled(false);

New.setEnabled(false);

Referto.setEnabled(false);

Esami.setEnabled(false);

}

if (e.getComponent()==Save){

if (isNew){

if (SQL.Query23(Rset.conn,nprat,anno,String.valueOf(nmod),Codice.getSelectedItem(),Data.getText())){

RsetFDC.newSession();

RsetFDC.Query21(nprat,anno,String.valueOf(nmod));

RsetFDC.next();

riempiCampi();

New.setEnabled(true);

Next.setEnabled(true);

Referto.setEnabled(true);

Esami.setEnabled(true);

}

else new MsgBox(this,"Dati non validi");

}

else {

int codref=0;

codref = RsetFDC.getInt("codref");

if (SQL.Query24(Rset.conn,String.valueOf(codref),Codice.getSelectedItem(),Data.getText())){

RsetFDC.newSession();

RsetFDC.Query21(nprat,anno,String.valueOf(nmod));

RsetFDC.next();

riempiCampi();

New.setEnabled(true);

Next.setEnabled(true);

}

else new MsgBox(this,"Dati non validi");

}

}

if (e.getComponent()==Esami){

RsetFDC.close();

RsetC.close();

this.setVisible(false);

FrameEsami FE= new FrameEsami(Rset,nmod);

}

if (e.getComponent()==Referto){

RsetFDC.close();

RsetC.close();

this.setVisible(false);

FrameReferto FR = new FrameReferto(Rset,nmod,codref);

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void impostaCampi1() {

Cog.setText(Rset.getString("cognome"));

Nom.setText(Rset.getString("nome"));

Anno.setText(Rset.getInt2String("anno"));

Num.setText(Rset.getInt2String("nprat"));

nprat = Num.getText();

anno = Anno.getText();

Cog.setEditable(false);

Nom.setEditable(false);

Anno.setEditable(false);

Num.setEditable(false);

}

public void azzeraCampi(){

NomeEsame.setText("");

Data.setText("");

codref = 0;

Nmod.setText(String.valueOf(nmod));

}

public void riempiCampi(){

Codice.select(RsetFDC.getString("cod_esame"));

NomeEsame.setText(RsetFDC.getString("nome_esame"));

Data.setText(RsetFDC.getDate2String("data_esame"));

codref = RsetFDC.getInt("codref");

Nmod.setText(RsetFDC.getInt2String("nmodulo"));

}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void itemStateChanged(ItemEvent i){

RsetC.newSession();

RsetC.Query25b(Codice.getSelectedItem());

RsetC.next();

NomeEsame.setText(RsetC.getString("nome_esame"));

}

}

FrameEsameObiettivo.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameEsameObiettivo extends Frame implements MouseListener,KeyListener {

Button Save,Exit;

TextField Cog,Nom,Num,Anno;

TextArea Testo;

Image Title;

SQL Rset,RsetFA,RsetFAn;

String nprat,anno,nmodulo;

public FrameEsameObiettivo(SQL _Rset, SQL _RsetFA){

setLocation(100,100);

setSize(600,400);

setTitle("Esame Obiettivo");

setResizable(false);

setVisible(true);

Rset = _Rset;

RsetFA = _RsetFA;

RsetFAn = new SQL(Rset.conn);

Title = Toolkit.getDefaultToolkit().getImage("image4.gif");

Save = new Button("Salva");

Exit = new Button("Esci");

Testo = new TextArea();

Cog = new TextField();

Nom = new TextField();

Num = new TextField();

Anno = new TextField();

Cog.setEditable(false);

Nom.setEditable(false);

Num.setEditable(false);

Anno.setEditable(false);

add(Save);

add(Exit);

add(Cog);

add(Nom);

add(Num);

add(Anno);

add(Testo);

riempiCampi1();

nprat = RsetFA.getInt2String("nprat");

anno = RsetFA.getInt2String("anno");

nmodulo = RsetFA.getInt2String("nmodulo");

RsetFAn.Query13(nprat,anno,nmodulo);

RsetFAn.next();

Testo.setText(RsetFAn.getString("esame_ob"));

Save.addMouseListener(this);

Exit.addMouseListener(this);

Testo.addKeyListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Paziente",10,120);

g.drawString("Cartella clinica n.",350,120);

g.drawString("Archiviata nel",350,150);

Cog.setSize(120,20);Cog.setLocation(70,105);

Nom.setSize(120,20);Nom.setLocation(200,105);

Num.setSize(60,20);Num.setLocation(450,105);

Anno.setSize(60,20);Anno.setLocation(430,135);

Testo.setSize(500,170);Testo.setLocation(50,160);

Save.setSize(100,30);Save.setLocation(180,340);

Exit.setSize(100,30);Exit.setLocation(300,340);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit){

RsetFA.close();

RsetFAn.close();

this.setVisible(false);

FrameAccettazione FA = new FrameAccettazione(Rset);

}

if (e.getComponent()==Save){

if (! SQL.Query14(Rset.conn,nprat,anno,nmodulo,Testo.getText()))

new MsgBox(this, "Dati non validi");

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void riempiCampi1(){

Cog.setText(Rset.getString("cognome"));

Nom.setText(Rset.getString("nome"));

Num.setText(Rset.getInt2String("nprat"));

Anno.setText(Rset.getInt2String("anno"));

}

}

FrameEsami.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameEsami extends Frame implements MouseListener,KeyListener{

Image Title;

SQL Rset,RsetFE;

TextField Cod, Nom, Tar;

Choice Nota;

TextArea Des;

Button Save, Exit, Next, New;

boolean isNew;

int nmod;

public FrameEsami(SQL _Rset,int _nmod){

setLocation(100,100);

setSize(600,400);

setTitle("Prestazioni di assistenza ambulatoriale");

setResizable(false);

setVisible(true);

Rset = _Rset;

RsetFE = new SQL(Rset.conn);

nmod = _nmod;

Title = Toolkit.getDefaultToolkit().getImage("image9.gif");

Save = new Button("Salva");

Exit = new Button("Esci");

Next = new Button("Prossimo");

New = new Button("Nuovo");

Cod = new TextField();

Nom = new TextField();

Des = new TextArea();

Tar = new TextField();

Nota = new Choice();

Nota.add("R");

Nota.add("H");

Nota.add("*");

add(Save);

add(Exit);

add(Next);

add(New);

add(Cod);

add(Nom);

add(Des);

add(Nota);

add(Tar);

RsetFE.Query15();

if (RsetFE.isEmpty()) isNew = true;

else isNew=false;

if (isNew) azzeraCampi();

else riempiCampi();

Save.addMouseListener(this);

Exit.addMouseListener(this);

Next.addMouseListener(this);

New.addMouseListener(this);

Cod.addKeyListener(this);

Nom.addKeyListener(this);

Des.addKeyListener(this);

Tar.addKeyListener(this);

}

public void azzeraCampi(){

Cod.setText("");

Nom.setText("");

Des.setText("");

Tar.setText("");

}

public void riempiCampi(){

Cod.setText(RsetFE.getString("codice"));

Nom.setText(RsetFE.getString("nome_esame"));

Des.setText(RsetFE.getString("descrizione"));

Nota.select(RsetFE.getString("nota"));

Tar.setText(RsetFE.getInt2String("tariffa"));

}

public void enableTasti(boolean value){

Next.setEnabled(value);

New.setEnabled(value);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Codice",10,120);

g.drawString("Nome", 160,120);

g.drawString("Descrizione",10,150);

g.drawString("Tariffa",130,240);

g.drawString("Nota",10,240);

Cod.setSize(80,20);Cod.setLocation(60,105);

Nom.setSize(210,20);Nom.setLocation(220,105);

Des.setSize(400,80);Des.setLocation(100,135);

Nota.setSize(60,20);Nota.setLocation(50,225);

Tar.setSize(120,20);Tar.setLocation(180,225);

Save.setSize(100,30);Save.setLocation(200,300);

Exit.setSize(100,30);Exit.setLocation(320,300);

Next.setSize(100,20);Next.setLocation(20,290);

New.setSize(100,20);New.setLocation(20,320);

}

public void mouseClicked(MouseEvent e){

if (e.getComponent()==Exit){

RsetFE.close();

this.setVisible(false);

FrameDiarioClinico FDC = new FrameDiarioClinico(Rset,nmod,true);

}

if (e.getComponent()==New){

isNew = true;

azzeraCampi();

enableTasti(false);

}

if (e.getComponent()== Next){

if (RsetFE.next()) riempiCampi();

else {

RsetFE.newSession();

RsetFE.Query15();

RsetFE.next();

riempiCampi();

}

}

if (e.getComponent()==Save){

if (isNew){

if (! SQL.Query16(Rset.conn,Cod.getText(),Nom.getText(),Des.getText(),Nota.getSelectedItem(),Tar.getText())) new MsgBox(this,"Dati non validi");

else {

isNew=false;

enableTasti(true);

}

}

else if (! SQL.Query17(Rset.conn,Cod.getText(),Nom.getText(),Des.getText(),Nota.getSelectedItem(),Tar.getText())) new MsgBox(this,"Dati non validi");

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

}

FrameEsecuzioneQuery.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameEsecuzioneQuery extends Frame implements MouseListener,FocusListener,ItemListener{

TextField Dati[] = new TextField[7];

TextField Inf[] = new TextField[7];

TextField Sup[] = new TextField[7];

TextField Desc[] = new TextField[5];

TextField RelX[] = new TextField[5];

TextField RelY[] = new TextField[5];

TextField Err[] = new TextField[2];

CheckboxGroup TipoQuery;

Checkbox Scelta1,Scelta2,Scelta3;

Button Exit,Start;

Image Title;

SQL Rset;

DatiQuery D;

public FrameEsecuzioneQuery(SQL _Rset,DatiQuery _D){

setSize(680,550);

setLocation(50,25);

setVisible(true);

setResizable(false);

setTitle("Esecuzione Query");

Title = Toolkit.getDefaultToolkit().getImage("image13.gif");

Rset = _Rset;

D=_D;

for (int i=0; i<7; i++) {

Dati[i] = new TextField();

Inf[i] = new TextField();

Sup[i] = new TextField();

}

for (int i=0; i<5; i++) {

Desc[i]=new TextField();

RelX[i]=new TextField();

RelY[i]=new TextField();

}

for (int i=0; i<2; i++) Err[i]=new TextField();

TipoQuery = new CheckboxGroup();

Scelta1 = new Checkbox("per relazioni spaziali",TipoQuery,false);

Scelta2 = new Checkbox("per caratteristiche morfologiche",TipoQuery,false);

Scelta3 = new Checkbox("entrambe",TipoQuery,true);

Exit = new Button("Esci");

Start = new Button("Esegui query");

for (int i=0; i<7; i++) {

add(Dati[i]);

add(Inf[i]);

add(Sup[i]);

}

for (int i=0; i<5; i++) {

add(Desc[i]);

add(RelX[i]);

add(RelY[i]);

}

add(Scelta1);

add(Scelta2);

add(Scelta3);

add(Start);

add(Exit);

add(Err[0]);

add(Err[1]);

riempiCampi();

Exit.addMouseListener(this);

Start.addMouseListener(this);

for (int i=0; i<7;i++){

Inf[i].addFocusListener(this);

Sup[i].addFocusListener(this);

}

Err[0].addFocusListener(this);

Err[1].addFocusListener(this);

Scelta1.addItemListener(this);

Scelta2.addItemListener(this);

Scelta3.addItemListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Caratteristiche geo-morfologiche",10,115);

g.drawString("inf.",230,115);

g.drawString("sup.",280,115);

g.drawString("Area",10,145);

g.drawString("Densità",10,175);

g.drawString("Asimmetria",10,205);

g.drawString("Orientazione",10,235);

g.drawString("Spreadness",10,265);

g.drawString("Uniformità",10,295);

g.drawString("Convessità",10,325);

g.drawString("RELAZIONI SPAZIALI",40,355);

for (int i=0; i<7; i++){

Dati[i].setSize(120,20);

Dati[i].setLocation(100,130+(i*30));

Inf[i].setSize(40,20);

Inf[i].setLocation(230,130+(i*30));

Sup[i].setSize(40,20);

Sup[i].setLocation(280,130+(i*30));

}

g.drawString("Oggetti canonici",10,385);

g.drawString("Rel. asse X",420,385);

g.drawString("Rel. asse Y",500,385);

for (int i=0; i<5; i++){

Desc[i].setSize(400,20);

Desc[i].setLocation(10,400+(i*30));

RelX[i].setSize(60,20);

RelX[i].setLocation(420,400+(i*30));

RelY[i].setSize(60,20);

RelY[i].setLocation(500,400+(i*30));

}

Scelta1.setSize(200,20);Scelta1.setLocation(340,200);

Scelta2.setSize(200,20);Scelta2.setLocation(340,230);

Scelta3.setSize(200,20);Scelta3.setLocation(340,260);

Start.setSize(100,30);Start.setLocation(340,290);

Exit.setSize(100,30);Exit.setLocation(460,290);

g.drawString("Errore",540,185);

for (int i=0; i<2; i++){

Err[i].setSize(60,20);

Err[i].setLocation(540,200+(i*30));

}

}

public void mousePressed(MouseEvent e){}

public void mouseReleased(MouseEvent e){}

public void mouseClicked(MouseEvent e){

if (e.getComponent()==Exit){

setVisible(false);

Rset.close();

FrameOpen FO=new FrameOpen(Rset.conn);

}

if (e.getComponent()==Start){

SQL.statoRel(Rset.conn);

D.calcola();

setVisible(false);

FrameRisultati FR=new FrameRisultati(Rset,D.F());

}

}

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}

public void itemStateChanged(ItemEvent i){

if (Scelta1.getState()) D.mode=0;

else if (Scelta2.getState()) D.mode=1;

else if (Scelta3.getState()) D.mode=2;

}

public void focusGained(FocusEvent f){}

public void focusLost(FocusEvent f){

for (int i=0;i<7;i++){

if (f.getComponent()==Inf[i]){

switch(i){

case 0:D.infar=String2inf(Inf[0].getText());Inf[0].setText(String.valueOf(D.infar));break;

case 1:D.infde=String2inf(Inf[1].getText());Inf[1].setText(String.valueOf(D.infde));break;

case 2:D.infas=String2inf(Inf[2].getText());Inf[2].setText(String.valueOf(D.infas));break;

case 3:D.infor=String2inf(Inf[3].getText());Inf[3].setText(String.valueOf(D.infor));break;

case 4:D.infsp=String2inf(Inf[4].getText());Inf[4].setText(String.valueOf(D.infsp));break;

case 5:D.infun=String2inf(Inf[5].getText());Inf[5].setText(String.valueOf(D.infun));break;

case 6:D.infco=String2inf(Inf[6].getText());Inf[6].setText(String.valueOf(D.infco));break;

}

}

}

for (int i=0;i<7;i++){

if (f.getComponent()==Sup[i]){

switch(i){

case 0:D.supar=String2sup(Sup[0].getText());Sup[0].setText(String.valueOf(D.supar));break;

case 1:D.supde=String2sup(Sup[1].getText());Sup[1].setText(String.valueOf(D.supde));break;

case 2:D.supas=String2sup(Sup[2].getText());Sup[2].setText(String.valueOf(D.supas));break;

case 3:D.supor=String2sup(Sup[3].getText());Sup[3].setText(String.valueOf(D.supor));break;

case 4:D.supsp=String2sup(Sup[4].getText());Sup[4].setText(String.valueOf(D.supsp));break;

case 5:D.supun=String2sup(Sup[5].getText());Sup[5].setText(String.valueOf(D.supun));break;

case 6:D.supco=String2sup(Sup[6].getText());Sup[6].setText(String.valueOf(D.supco));break;

}

}

}

if (f.getComponent()==Err[0]) {

D.t0 = String2Err(Err[0].getText());

Err[0].setText(String.valueOf(D.t0));

}

if (f.getComponent()==Err[1]) {

D.t1 = String2Err(Err[1].getText());

Err[1].setText(String.valueOf(D.t1));

D.setDefault(D.t1);

riempiCampi2();

}

}

public void riempiCampi(){

Dati[0].setText(String.valueOf(D.Area));

Dati[1].setText(String.valueOf(D.Densità));

Dati[2].setText(String.valueOf(D.Asimmetria));

Dati[3].setText(String.valueOf(D.Orientazione));

Dati[4].setText(String.valueOf(D.Spreadness));

Dati[5].setText(String.valueOf(D.Uniformità));

if (D.Convessità==1) Dati[6].setText("Convesso");

else Dati[6].setText("Concavo");

for (int i=1; i<6; i++){

if (D.viid[i]>0){

Desc[i-1].setText(D.desc[i]);

RelX[i-1].setText(String.valueOf(Rettangolo.val2String(D.relX[i])));

RelY[i-1].setText(String.valueOf(Rettangolo.val2String(D.relY[i])));

}

}

D.t0=0.20;

D.t1=0.20;

D.setDefault(D.t1);

riempiCampi2();

}

private void riempiCampi2(){

Err[0].setText(String.valueOf(D.t0));

Err[1].setText(String.valueOf(D.t1));

Inf[0].setText(String.valueOf(D.infar));

Sup[0].setText(String.valueOf(D.supar));

Inf[1].setText(String.valueOf(D.infde));

Sup[1].setText(String.valueOf(D.supde));

Inf[2].setText(String.valueOf(D.infas));

Sup[2].setText(String.valueOf(D.supas));

Inf[3].setText(String.valueOf(D.infor));

Sup[3].setText(String.valueOf(D.supor));

Inf[4].setText(String.valueOf(D.infsp));

Sup[4].setText(String.valueOf(D.supsp));

Inf[5].setText(String.valueOf(D.infun));

Sup[5].setText(String.valueOf(D.supun));

Inf[6].setText(String.valueOf(D.infco));

Sup[6].setText(String.valueOf(D.supco));

}

private double String2inf(String str){

Double d;

try {

d=new Double(str);

}

catch (Exception e){

d=new Double(0);

}

double d1=d.doubleValue();

if (d1>=0 && d1<=1) return d1;

else return 0;

}

private double String2sup(String str){

Double d;

try {

d=new Double(str);

}

catch (Exception e){

d=new Double(1);

}

double d1=d.doubleValue();

if (d1>=0 && d1<=1) return d1;

else return 1;

}

private double String2Err(String str){

Double d;

try {

d=new Double(str);

}

catch (Exception e){

d=new Double(0.2);

}

double d1=d.doubleValue();

if (d1>=0 && d1<=1) return d1;

else return 0.2;

}

}

FrameFacciata.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameFacciata extends Frame implements MouseListener,KeyListener {

Button Dati,Acc,Diario,Den,Save,Exit;

TextField Num,Anno,Cog,Nom,Data,Codfis;

Image Title;

SQL Rset;

boolean isNew;

public FrameFacciata(boolean _isNew, SQL _Rset){

isNew = _isNew;

setLocation(100,100);

setSize(600,350);

setResizable(false);

setVisible(true);

setTitle("Quadro generale del paziente");

Title = Toolkit.getDefaultToolkit().getImage("image8.gif");

Rset = _Rset;

Dati = new Button("Dati Anagrafici");

Acc = new Button("Accettazione");

Diario = new Button("Diario Clinico");

Den = new Button("Denunce");

Exit = new Button("Esci");

Save = new Button("Salva");

Num = new TextField();

Anno = new TextField();

Cog = new TextField();

Nom = new TextField();

Data = new TextField();

Codfis = new TextField();

if (isNew){

azzeraCampi();

}

else {

riempiCampi();

disabilitaCampi();

}

if (! isNew) Save.setVisible(false);

add(Dati);

add(Acc);

add(Diario);

add(Den);

if (isNew) add(Save);

add(Exit);

add(Num);

add(Anno);

add(Cog);

add(Nom);

add(Data);

add(Codfis);

Exit.addMouseListener(this);

Save.addMouseListener(this);

Dati.addMouseListener(this);

Acc.addMouseListener(this);

Diario.addMouseListener(this);

Den.addMouseListener(this);

Cog.addKeyListener(this);

Nom.addKeyListener(this);

Codfis.addKeyListener(this);

Data.addKeyListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,40,30,this);

g.drawString("Cartella clinica n.",125,115);

g.drawString("Archiviata nel",280,115);

g.drawString("del paziente",65,155);

g.drawString("nato il",390,155);

g.drawString("codice fiscale",160,195);

Num.setSize(50,20);

Num.setLocation(220,100);

Anno.setSize(50,20);

Anno.setLocation(360,100);

Cog.setSize(120,20);

Cog.setLocation(140,140);

Nom.setSize(120,20);

Nom.setLocation(265,140);

Data.setSize(110,20);

Data.setLocation(430,140);

Codfis.setSize(160,20);

Codfis.setLocation(245,180);

Dati.setSize(100,30);

Acc.setSize(100,30);

Diario.setSize(100,30);

Den.setSize(100,30);

Save.setSize(100,30);

Exit.setSize(100,30);

Dati.setLocation(60,250);

Acc.setLocation(180,250);

Diario.setLocation(300,250);

Den.setLocation(420,250);

if (isNew){

Save.setLocation(180,300);

Exit.setLocation(300,300);

Dati.setEnabled(false);

Acc.setEnabled(false);

Diario.setEnabled(false);

Den.setEnabled(false);

}

else Exit.setLocation(240,300);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit) {

this.setVisible(false);

Rset.close();

FrameOpen FO=new FrameOpen(Rset.conn);

}

if (e.getComponent()==Save) {

if (SQL.Query4(Rset.conn,Num.getText(),Anno.getText(),Codfis.getText(),Cog.getText(),Nom.getText(),Data.getText())){

isNew = false;

Save.setEnabled(false);

Dati.setEnabled(true);

Acc.setEnabled(true);

Diario.setEnabled(true);

Den.setEnabled(true);

SQL.Query5(Rset.conn,Codfis.getText());

Rset.Query2(Codfis.getText());

Rset.next();

}

else new MsgBox(this,"Dati non validi");

}

if (e.getComponent()==Dati) {

this.setVisible(false);

FrameDatiAnagrafici FDA=new FrameDatiAnagrafici(Rset);

}

if (e.getComponent()==Acc){

this.setVisible(false);

FrameAccettazione FA=new FrameAccettazione(Rset);

}

if (e.getComponent()==Den){

this.setVisible(false);

FrameDenunce FD=new FrameDenunce(Rset);

}

if (e.getComponent()==Diario){

this.setVisible(false);

FrameDiarioClinico FDC = new FrameDiarioClinico(Rset,0,false);

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void azzeraCampi(){

Num.setText("");

Anno.setText("");

Cog.setText("");

Nom.setText("");

Data.setText("");

Codfis.setText("");

}

public void riempiCampi(){

Num.setText(Rset.getInt2String("nprat"));

Anno.setText(Rset.getInt2String("anno"));

Nom.setText(Rset.getString("nome"));

Cog.setText(Rset.getString("cognome"));

Data.setText(Rset.getDate2String("data_nasc"));

Codfis.setText(Rset.getString("codfisc"));

}

public void disabilitaCampi(){

Num.setEditable(false);

Anno.setEditable(false);

Cog.setEditable(false);

Nom.setEditable(false);

Data.setEditable(false);

Codfis.setEditable(false);

}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

}

FrameOpen.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameOpen extends Frame implements MouseListener,KeyListener,WindowListener {

Image Title;

Button Ric1,Ric2,Ric3,New,Exit,Query;

TextField Prat,Arch,Codfis,Cog,Nom;

Connection Conn;

SQL Rset;

public FrameOpen(Connection _Conn) {

setLocation(100,100);

setSize(600,300);

setTitle("Gestione Cartelle Cliniche");

setResizable(false);

Title = Toolkit.getDefaultToolkit().getImage("image1.gif");

setVisible(true);

Conn = _Conn;

Rset = new SQL(Conn);

Ric1 = new Button("OK");

Ric2 = new Button("OK");

Ric3 = new Button("OK");

New = new Button("Nuovo Paziente");

Exit = new Button("Esci");

Query = new Button("Query");

Prat = new TextField();

Arch = new TextField();

Codfis = new TextField();

Cog = new TextField();

Nom = new TextField();

add(Ric1);

add(Ric2);

add(Ric3);

add(New);

add(Exit);

add(Query);

add(Prat);

add(Arch);

add(Codfis);

add(Cog);

add(Nom);

Ric1.addMouseListener(this);

Ric2.addMouseListener(this);

Ric3.addMouseListener(this);

New.addMouseListener(this);

Exit.addMouseListener(this);

Query.addMouseListener(this);

Codfis.addKeyListener(this);

Cog.addKeyListener(this);

Nom.addKeyListener(this);

addWindowListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,40,30,this);

g.drawString("Ricerca per numero di pratica",10,115);

g.drawString("e anno di archiviazione",240,115);

g.drawString("Ricerca per Codice Fiscale",10,165);

g.drawString("Ricerca per cognome",10,215);

g.drawString("e nome",270,215);

Ric1.setSize(100,20);Ric1.setLocation(450,100);

Ric2.setSize(100,20);Ric2.setLocation(450,150);

Ric3.setSize(100,20);Ric3.setLocation(450,200);

New.setSize(100,30);New.setLocation(445,250);

Exit.setSize(100,30);Exit.setLocation(220,250);

Query.setSize(100,30);Query.setLocation(100,250);

Prat.setSize(50,20);Prat.setLocation(180,100);

Arch.setSize(50,20);Arch.setLocation(370,100);

Codfis.setSize(180,20);Codfis.setLocation(190,150);

Cog.setSize(120,20);Cog.setLocation(140,200);

Nom.setSize(120,20);Nom.setLocation(315,200);

}

public static void main(String[] args) throws SQLException{

Frame temp=new Frame();

MsgWin MW=new MsgWin(temp);

MW.mostra("Collegamento ad Oracle in corso...");

try {

FrameOpen FO=new FrameOpen(SQL.Connessione());

MW.nascondi();

}

catch (Exception e){

MW.nascondi();

MsgBox MB = new MsgBox(temp,"Impossibile collegarsi ad Oracle");

}

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Ric1) {

Rset.newSession();

Rset.Query1(Prat.getText(),Arch.getText());

if (! Rset.isEmpty()){

this.setVisible(false);

FrameFacciata FF=new FrameFacciata(false,Rset);

}

else new MsgBox(this,"Valori non validi o record non trovato");

}

else if (e.getComponent()==Ric2) {

Rset.newSession();

Rset.Query2(Codfis.getText());

if (! Rset.isEmpty()){

this.setVisible(false);

FrameFacciata FF=new FrameFacciata(false,Rset);

}

else new MsgBox(this,"Valori non validi o record non trovato");

}

else if (e.getComponent()==Ric3) {

Rset.newSession();

Rset.Query3(Cog.getText(),Nom.getText());

if (! Rset.isEmpty()){

this.setVisible(false);

FrameFacciata FF=new FrameFacciata(false,Rset);

}

else new MsgBox(this,"Valori non validi o record non trovato");

}

else if (e.getComponent()==New){

this.setVisible(false);

FrameFacciata FF=new FrameFacciata(true,Rset);

}

else if (e.getComponent()==Exit)exitButton();

else if (e.getComponent()==Query){

setVisible(false);

FramePreparazioneQuery FPQ = new FramePreparazioneQuery(Rset);

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void windowClosed(WindowEvent w){}

public void windowClosing(WindowEvent w) {exitButton();}

public void windowOpened(WindowEvent w){}

public void windowIconified(WindowEvent w){}

public void windowDeiconified(WindowEvent w){}

public void windowActivated(WindowEvent w){}

public void windowDeactivated(WindowEvent w){}

public void saveButton(){

}

public void exitButton() {

try { Conn.close(); System.exit(0);}

catch(Exception ex){}

}

}

FramePreparazioneQuery.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FramePreparazioneQuery extends Frame implements MouseListener{

Image Canonico,Anomalia,Title;

Button Start,Exit,TBAn,TBCa;

QueryCanvas QC;

TextField Dati[] = new TextField[7];

TextField Desc[] = new TextField[6];

TextField RelX[] = new TextField[6];

TextField RelY[] = new TextField[6];

int AnomaliaX,AnomaliaY;

ToolBar TBC,TBA;

SQL Rset;

int selected;

int viid[] = new int[5];

public FramePreparazioneQuery(SQL _Rset){

setSize(600,545);

setLocation(50,10);

setVisible(true);

setTitle("Preparazione Query");

Title = Toolkit.getDefaultToolkit().getImage("image12.gif");

Rset = _Rset;

Canonico = null;

Anomalia = null;

AnomaliaX=0;

AnomaliaY=0;

for(int i=0; i<5; i++) viid[i]=-1;

Start = new Button("Esecuzione Query");

Exit = new Button("Esci");

TBAn = new Button("ToolBar anomalie");

TBCa = new Button("ToolBar oggetti canonici");

QC = new QueryCanvas();

for (int i=0; i<6; i++){

Dati[i]=new TextField();

Desc[i]=new TextField();

RelX[i]=new TextField();

RelY[i]=new TextField();

}

Dati[6]=new TextField();

TBA = new ToolBar(this,Rset.conn,0);

TBC = new ToolBar(this,Rset.conn,1);

add(Start);

add(Exit);

add(TBAn);

add(TBCa);

add(QC);

for (int i=0; i<6; i++){

add(Dati[i]);

add(Desc[i]);

add(RelX[i]);

add(RelY[i]);

}

add(Dati[6]);

for (int i=0; i<TBA.numImage; i++)

TBA.BI[i].addMouseListener(this);

for (int i=0; i<TBC.numImage; i++)

TBC.BI[i].addMouseListener(this);

QC.addMouseListener(this);

TBAn.addMouseListener(this);

TBCa.addMouseListener(this);

Exit.addMouseListener(this);

Start.addMouseListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,30,25,this);

g.drawString("Area",10,115);

g.drawString("Densità",10,145);

g.drawString("Asimmetria",10,175);

g.drawString("Orientazione",10,205);

g.drawString("Spreadness",10,235);

g.drawString("Uniformità",10,265);

g.drawString("Convessità",10,295);

for (int i=0; i<7; i++){

Dati[i].setSize(100,20);

Dati[i].setLocation(100,100+(i*30));

}

for (int i=0; i<6; i++){

Desc[i].setSize(220,20);

Desc[i].setLocation(180,365+(i*30));

RelX[i].setSize(60,20);

RelX[i].setLocation(410,365+(i*30));

RelY[i].setSize(60,20);

RelY[i].setLocation(480,365+(i*30));

}

QC.setSize(256,256);

QC.setLocation(260,90);

g.drawRect(259,89,258,258);

TBAn.setSize(140,30);

TBAn.setLocation(10,380);

TBCa.setSize(140,30);

TBCa.setLocation(10,420);

Start.setSize(140,30);

Start.setLocation(10,460);

Exit.setSize(140,30);

Exit.setLocation(10,500);

}

public void mousePressed(MouseEvent e){}

public void mouseReleased(MouseEvent e){

if (e.getComponent()==QC) riempiDati2();

}

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}

public void mouseClicked(MouseEvent e){

if (e.getComponent()==Exit){

TBC.setVisible(false);

TBA.setVisible(false);

setVisible(false);

Rset.close();

FrameOpen FO= new FrameOpen(Rset.conn);

return;

}

if (e.getComponent()==TBCa) {

TBC.setVisible(true);

return;

}

if (e.getComponent()==TBAn){

TBA.setVisible(true);

return;

}

if (e.getComponent()==Start){

if (QC.viid[0]>0 && QC.viid[1]>0){

DatiQuery DQ=new DatiQuery();

riempiDatiQuery(DQ);

DQ.ordina();

TBC.setVisible(false);

TBA.setVisible(false);

setVisible(false);

FrameEsecuzioneQuery FEQ=new FrameEsecuzioneQuery(Rset,DQ);

}

else new MsgBox(this,"Oggetti non sufficienti per una");

}

int sel=-1;

for (int i=0; i<TBC.numImage; i++)

if (e.getComponent()==TBC.BI[i]) sel=i;

if (sel != -1){

SQL R1 = new SQL(Rset.conn);

R1.Query30(sel+1);

R1.next();

QC.caricaCanonico(R1.getString("FileBMP"),R1.getString("descrizione"),

R1.getInt("SizeX"),R1.getInt("SizeY"),sel+1);

riempiDati2();

R1.close();

return;

}

int selA = -1;

for (int i=0; i<TBA.numImage; i++)

if (e.getComponent()==TBA.BI[i]) selA=i;

if (selA!=-1){

SQL RA=new SQL(Rset.conn);

RA.Query31(TBA.viid[selA]);

RA.next();

QC.caricaAnomalia(RA.getString("FileBMP"),"anomalia"+RA.getInt2String("Viid"),

RA.getInt("SizeX"),RA.getInt("SizeY"),TBA.viid[selA]);

riempiDati(RA);

riempiDati2();

RA.close();

}

}

public void riempiDati(SQL RA){

Dati[0].setText(RA.getDouble2String("area"));

Dati[1].setText(RA.getDouble2String("densita"));

Dati[2].setText(RA.getDouble2String("asimmetria"));

Dati[3].setText(RA.getDouble2String("orientazione"));

Dati[4].setText(RA.getDouble2String("spreadness"));

Dati[5].setText(RA.getDouble2String("uniformita"));

int conv = RA.getInt("convessita");

if (conv==1) Dati[6].setText("Convesso");

else Dati[6].setText("Concavo");

}

public void riempiDati2(){

for (int i=0; i<6; i++){

Desc[i].setText(QC.desc[i]);

RelX[i].setText(Rettangolo.val2String(QC.relX[i]));

RelY[i].setText(Rettangolo.val2String(QC.relY[i]));

}

}

public void riempiDatiQuery(DatiQuery DQ){

DQ.Rset=Rset;

DQ.Area = new Double(Dati[0].getText()).doubleValue();

DQ.Densità = new Double(Dati[1].getText()).doubleValue();

DQ.Asimmetria = new Double(Dati[2].getText()).doubleValue();

DQ.Orientazione = new Double(Dati[3].getText()).doubleValue();

DQ.Spreadness = new Double(Dati[4].getText()).doubleValue();

DQ.Uniformità = new Double(Dati[5].getText()).doubleValue();

if (Dati[6].getText().equals("Convesso")) DQ.Convessità=1;

else DQ.Convessità=0;

for (int i=0; i<6; i++){

DQ.desc[i]=QC.desc[i];

DQ.viid[i]=QC.viid[i];

DQ.relX[i]=QC.relX[i];

DQ.relY[i]=QC.relY[i];

}

}

}

FrameReferto.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameReferto extends Frame implements MouseListener,FocusListener,KeyListener{

TextField Cog,Nom,Num,Anno,File,Nmod;

TextArea Note;

Image Title,Immagine;

String tempFile;

SQL Rset,RsetR;

int nmod,codref;

Button Save,Exit,Seg,Dati;

boolean notSaved;

DatiQuery D;

public FrameReferto(SQL _Rset, int _nmod, int _codref){

setLocation(100,80);

setSize(600,500);

setTitle("Referto");

setResizable(false);

setVisible(true);

Title = Toolkit.getDefaultToolkit().getImage("image7.gif");

Rset = _Rset;

RsetR = new SQL(Rset.conn);

nmod = _nmod;

codref = _codref;

Cog = new TextField();

Nom = new TextField();

Num = new TextField();

Anno = new TextField();

Note = new TextArea();

File = new TextField();

Nmod = new TextField();

Save = new Button("Salva");

Exit = new Button("Esci");

Seg = new Button("Segmentazione");

Dati = new Button("Dati anomalia");

add(Cog);

add(Nom);

add(Num);

add(Anno);

add(Nmod);

add(File);

add(Note);

add(Save);

add(Exit);

add(Seg);

add(Dati);

riempiCampi1();

RsetR.Query26(String.valueOf(codref));

if (RsetR.isEmpty()) Immagine = null;

else riempiCampi();

Nmod.setEditable(false);

Save.addMouseListener(this);

Exit.addMouseListener(this);

Seg.addMouseListener(this);

Dati.addMouseListener(this);

File.addFocusListener(this);

File.addKeyListener(this);

Note.addKeyListener(this);

notSaved = false;

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Paziente",10,120);

g.drawString("Cartella clinica n.",350,120);

g.drawString("Archiviata nel",350,150);

g.drawString("Modulo di accettazione",10,150);

Cog.setSize(120,20);Cog.setLocation(70,105);

Nom.setSize(120,20);Nom.setLocation(200,105);

Num.setSize(60,20);Num.setLocation(450,105);

Anno.setSize(60,20);Anno.setLocation(430,135);

Nmod.setSize(60,20);Nmod.setLocation(170,135);

Note.setSize(256,150);Note.setLocation(300,170);

g.drawString("File sorgente",300,345);

File.setSize(180,20);File.setLocation(380,330);

Seg.setSize(100,20);Seg.setLocation(300,360);

Dati.setSize(100,20);Dati.setLocation(300,390);

Save.setSize(100,30);Save.setLocation(180,440);

Exit.setSize(100,30);Exit.setLocation(300,440);

if (Immagine != null) g.drawImage(Immagine,30,170,this);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Save){

if (! SQL.Query27(Rset.conn,String.valueOf(codref),File.getText(),Note.getText()))

new MsgBox(this,"Dati Errati");

else notSaved = false;

}

if (e.getComponent()==Exit){

RsetR.close();

setVisible(false);

FrameDiarioClinico FDC = new FrameDiarioClinico(Rset,nmod,true);

}

if (e.getComponent()==Dati){

SQL R1 = new SQL(Rset.conn);

SQL R2 = new SQL(Rset.conn);

R1.Query34(codref);

R2.Query35(codref);

DatiQuery D = riempiDatiQuery(R1,R2);

D.ordina();

setVisible(false);

R1.close();

R2.close();

RsetR.close();

FrameEsecuzioneQuery FEQ=new FrameEsecuzioneQuery(Rset,D);

}

if (e.getComponent()==Seg){

if (! notSaved) {

RsetR.close();

setVisible(false);

FrameSegmentazione FS = new FrameSegmentazione(Rset,codref,nmod,File.getText());

}

else new MsgBox(this,"Bisogna prima salvare l'immagine");

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void focusGained(FocusEvent e){

if (e.getComponent()==File) {

tempFile=File.getText();

}

}

public void focusLost(FocusEvent e){

if (e.getComponent()==File && !File.getText().equals(tempFile)){

notSaved=true;

caricaImmagine(File.getText());

repaint();

}

}

public void riempiCampi1(){

Cog.setText(Rset.getString("cognome"));

Nom.setText(Rset.getString("nome"));

Num.setText(Rset.getInt2String("nprat"));

Anno.setText(Rset.getString("anno"));

Cog.setEditable(false);

Nom.setEditable(false);

Num.setEditable(false);

Anno.setEditable(false);

}

public void riempiCampi(){

String im="";

Note.setText(RsetR.getString("note"));

im=RsetR.getString("immagine");

File.setText(im);

Nmod.setText(RsetR.getInt2String("nmodulo"));

nmod = RsetR.getInt("nmodulo");

if (im==null) Immagine = null;

else caricaImmagine(im);

}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void caricaImmagine(String _im){

MsgWin MW=new MsgWin(this);

MW.mostra("caricamento immagine...");

Immagine = BMP.getBMP("images/"+_im);

MW.nascondi();

if (Immagine==null) new MsgBox(this,"File non trovato o immagine non valida");

}

public DatiQuery riempiDatiQuery(SQL R1,SQL R2){

SQL R3=new SQL(Rset.conn);

DatiQuery d=new DatiQuery();

d.Rset=Rset;

d.viid[0] = codref;

R2.next();

d.Area = R2.getDouble("area");

d.Densità = R2.getDouble("densita");

d.Asimmetria = R2.getDouble("asimmetria");

d.Orientazione = R2.getDouble("orientazione");

d.Spreadness = R2.getDouble("spreadness");

d.Uniformità = R2.getDouble("uniformita");

d.Convessità = R2.getDouble("convessita");

int i=1;

while (R1.next()){

R3.newSession();

R3.Query36(R1.getInt("oggetto"));

R3.next();

d.desc[i]=R3.getString("descrizione");

d.viid[i]=R1.getInt("oggetto");

d.relX[i]=R1.getInt("relx");

d.relY[i]=R1.getInt("rely");

i++;

}

R3.close();

return d;

}

}

FrameRisultati.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class FrameRisultati extends Frame implements MouseListener,KeyListener{

TextField Cog,Nom,Num,Anno,File,Nmod,Esame,Data,SimDeg,Dist;

TextArea Note;

Image Title,Immagine;

String tempFile;

SQL Rset,RsetR,RsetD;

Button Exit,Next,Ref,OrdS,OrdD;

int F,numRec,currRec,ordine;

public FrameRisultati(SQL _Rset,int _F){

Rset = _Rset;

RsetR = new SQL(Rset.conn);

RsetD = new SQL(Rset.conn);

F=_F;

ordine=0;

RsetR.Query41();

if (RsetR.isEmpty()) {

new MsgBox(this,"Nessun referto trovato");

Rset.close();

RsetR.close();

RsetD.close();

FrameOpen FO = new FrameOpen(Rset.conn);

return;

}

numRec = SQL.Query52(Rset.conn);

currRec = 1;

setLocation(100,80);

setSize(600,520);

setTitle("Referto");

setResizable(false);

setVisible(true);

reTitle();

Title = Toolkit.getDefaultToolkit().getImage("image14.gif");

Cog = new TextField();

Nom = new TextField();

Num = new TextField();

Anno = new TextField();

Nmod = new TextField();

Note = new TextArea();

File = new TextField();

Esame = new TextField();

Data = new TextField();

SimDeg = new TextField();

Dist = new TextField();

Nmod.setEditable(false);

Cog.setEditable(false);

Nom.setEditable(false);

Num.setEditable(false);

Anno.setEditable(false);

Note.setEditable(false);

File.setEditable(false);

Esame.setEditable(false);

Data.setEditable(false);

SimDeg.setEditable(false);

Dist.setEditable(false);

Exit = new Button("Esci");

Next = new Button("Prossimo");

Ref = new Button("Referto");

OrdS = new Button("Similitudine");

OrdD = new Button("Distanza");

add(Cog);

add(Nom);

add(Num);

add(Anno);

add(Nmod);

add(File);

add(Note);

add(Esame);

add(Data);

add(SimDeg);

add(Dist);

add(Exit);

add(Next);

add(Ref);

add(OrdS);

add(OrdD);

riempiCampi();

Exit.addMouseListener(this);

Next.addMouseListener(this);

Ref.addMouseListener(this);

Dist.addMouseListener(this);

OrdS.addMouseListener(this);

OrdD.addMouseListener(this);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Paziente",10,120);

g.drawString("Cartella clinica n.",350,120);

g.drawString("Archiviata nel",350,150);

g.drawString("Modulo di accettazione",10,150);

Cog.setSize(120,20);Cog.setLocation(70,105);

Nom.setSize(120,20);Nom.setLocation(200,105);

Num.setSize(60,20);Num.setLocation(450,105);

Anno.setSize(60,20);Anno.setLocation(430,135);

Nmod.setSize(60,20);Nmod.setLocation(170,135);

Note.setSize(256,100);Note.setLocation(300,170);

g.drawString("File sorgente",300,295);

g.drawString("Nome esame",300,325);

g.drawString("Data esame",300,355);

g.drawString("Grado di somiglianza (VI)",300,385);

g.drawString("Distanza (geo-morfologica)",300,415);

g.drawString("Ordina per ",10,455);

File.setSize(180,20);File.setLocation(380,280);

Esame.setSize(180,20);Esame.setLocation(380,310);

Data.setSize(120,20);Data.setLocation(380,340);

SimDeg.setSize(100,20);SimDeg.setLocation(450,370);

Dist.setSize(100,20);Dist.setLocation(450,400);

Next.setSize(100,30);Next.setLocation(140,470);

Ref.setSize(100,30);Ref.setLocation(260,470);

Exit.setSize(100,30);Exit.setLocation(380,470);

OrdS.setSize(100,20);OrdS.setLocation(90,440);

OrdD.setSize(100,20);OrdD.setLocation(200,440);

if (Immagine != null) g.drawImage(Immagine,30,170,this);

}

public void mouseClicked(MouseEvent e) {

if (e.getComponent()==Exit){

Rset.close();

RsetR.close();

RsetD.close();

setVisible(false);

FrameOpen FO = new FrameOpen(Rset.conn);

}

if (e.getComponent()==Next){

if (RsetR.next()){

currRec++;

reTitle();

riempiCampi();

}

else {

RsetR.newSession();

if (ordine==0) RsetR.Query41();

if (ordine==1) RsetR.Query49(F);

if (ordine==2) RsetR.Query50();

RsetR.next();

currRec=1;

reTitle();

riempiCampi();

}

}

if (e.getComponent()==Exit){

Rset.close();

RsetR.close();

RsetD.close();

FrameOpen FO = new FrameOpen(Rset.conn);

}

if (e.getComponent()==OrdS){

RsetR.newSession();

ordine=1;

RsetR.Query49(F);

RsetR.next();

currRec=1;

reTitle();

riempiCampi();

}

if (e.getComponent()==OrdD){

RsetR.newSession();

ordine=2;

RsetR.Query50();

RsetR.next();

currRec=1;

reTitle();

riempiCampi();

}

if (e.getComponent()==Ref){

Rset.newSession();

Rset.Query1(RsetD.getInt2String("nprat"),RsetD.getInt2String("anno"));

Rset.next();

int nmod=RsetD.getInt("nmodulo");

int codref=RsetR.getInt("viid");

RsetR.close();

RsetD.close();

setVisible(false);

FrameReferto FR = new FrameReferto(Rset,nmod,codref);

}

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void mousePressed(MouseEvent e){}

public void riempiCampi(){

RsetD.newSession();

RsetD.Query51(RsetR.getInt("viid"));

RsetD.next();

Cog.setText(RsetD.getString("cognome"));

Nom.setText(RsetD.getString("nome"));

Num.setText(RsetD.getInt2String("nprat"));

Anno.setText(RsetD.getString("anno"));

Nmod.setText(RsetD.getInt2String("nmodulo"));

File.setText(RsetD.getString("immagine"));

Note.setText(RsetD.getString("note"));

Esame.setText(RsetD.getString("nome_esame"));

Data.setText(RsetD.getDate2String("data_esame"));

caricaImmagine(RsetD.getString("immagine"));

double sx=RsetR.getDouble("sx");

double sy=RsetR.getDouble("sy");

double sim_deg = (sx+sy)/F;

SimDeg.setText(String.valueOf(sim_deg));

Dist.setText(RsetR.getDouble2String("distanza"));

}

public void keyTyped(KeyEvent k){

char c = k.getKeyChar();

k.setKeyChar(new Character(c).toUpperCase(c));

}

public void keyPressed(KeyEvent k){}

public void keyReleased(KeyEvent k){}

public void caricaImmagine(String _im){

MsgWin MW=new MsgWin(this);

MW.mostra("caricamento immagine...");

Immagine = BMP.getBMP("images/"+_im);

MW.nascondi();

if (Immagine==null) new MsgBox(this,"File non trovato o immagine non valida");

}

public void reTitle(){

setTitle("Risultati Query -> "+currRec+" di "+numRec);

}

}

FrameSegmentazione.java

import java.awt.*;

import java.awt.image.*;

import java.awt.event.*;

import java.sql.*;

public class FrameSegmentazione extends Frame implements MouseListener {

Segmentazione S;

Button BottoneCreaCont, BottoneBMP, BottoneAvvia, BottoneEsci;

TextField TextX,TextY,TextLiv,TextErrore,TextFile;

Checkbox CheckNonConnessi,CheckSegCompleta,CheckSceltaPunto;

Label LabX, LabY, LabLiv, LabErr;

MsgWin MW = new MsgWin(this);

Image im;

Connection Conn;

SQL Rset;

int codref,nmod;

public FrameSegmentazione (SQL _Rset, int _codref,int _nmod, String _nomefile){

setTitle("Segmentazione");

setSize(630,460);

setLocation(100,100);

setResizable(false);

Rset = _Rset;

codref = _codref;

nmod = _nmod;

BottoneCreaCont = new Button("Crea Contorno");

BottoneEsci = new Button("Annulla");

BottoneBMP = new Button("Nuova segmentazione");

BottoneAvvia = new Button("Avvia Segmentazione");

TextX = new TextField();

TextY = new TextField();

TextErrore = new TextField("0.01");

TextLiv = new TextField("7");

TextFile = new TextField(_nomefile);

CheckNonConnessi = new Checkbox("Nodi non connessi",false);

CheckSceltaPunto = new Checkbox("Scelta del punto",false);

CheckSegCompleta = new Checkbox("Segmentazione Completa",true);

LabX = new Label("X");

LabY = new Label("Y");

LabLiv = new Label("Livello");

LabErr = new Label("Errore");

setVisible(true);

add(BottoneCreaCont);

add(BottoneEsci);

add(BottoneBMP);

add(BottoneAvvia);

add(TextX);

add(TextY);

add(TextErrore);

add(TextLiv);

add(TextFile);

add(CheckNonConnessi);

add(CheckSegCompleta);

add(CheckSceltaPunto);

add(LabX);

add(LabY);

add(LabLiv);

add(LabErr);

TextFile.setEditable(false);

actionCaricaBMP(TextFile.getText());

addMouseListener(this);

BottoneCreaCont.addMouseListener(this);

BottoneEsci.addMouseListener(this);

BottoneBMP.addMouseListener(this);

BottoneAvvia.addMouseListener(this);

}

public void mousePressed(MouseEvent e) {}

public void mouseClicked(MouseEvent e) {

if (e.getComponent() == BottoneEsci){

setVisible(false);

FrameReferto FR=new FrameReferto(Rset,nmod,codref);

}

else if (e.getComponent()==BottoneBMP)actionCaricaBMP(TextFile.getText());

else if (e.getComponent() == this) actionSceltaPunto(e);

else if (e.getComponent() == BottoneAvvia) {

if (S != null){

if (CheckSegCompleta.getState()) {

MW.mostra("Segmentazione completa in corso...");

S.segmentazione();

MW.nascondi();

new MsgBox(this, "Segmentazione Completata");

}

else {

if (CheckSceltaPunto.getState()) actionSingoloPassoSC(CheckNonConnessi.getState());

else {

MW.mostra("Singolo passo di segmentazione in corso...");

S.singoloPasso();

MW.nascondi();

new MsgBox(this,"Passo di Segmentazione completato");

}

}

repaint();

}

else new MsgBox(this, "Nessuna immagine da Segmentare");

}

else if (e.getComponent() == BottoneCreaCont) actionCreaContorno();

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mouseReleased(MouseEvent e) {}

public void paint(Graphics g){

if (S != null){

g.drawImage(S.outImage,320,45,this);

g.drawImage(S.inImage, 30,45,this);

}

BottoneCreaCont.setSize(140,30);

BottoneEsci.setSize(100,30);

BottoneBMP.setSize(140,30);

BottoneAvvia.setSize(140,30);

TextX.setSize(49,20);

TextY.setSize(49,20);

TextErrore.setSize(84,20);

TextLiv.setSize(49,20);

TextFile.setSize(133,22);

CheckNonConnessi.setSize(182,21);

CheckSceltaPunto.setSize(182,21);

CheckSegCompleta.setSize(182,21);

LabX.setSize(15,15);

LabY.setSize(15,15);

LabLiv.setSize(50,15);

LabErr.setSize(50,15);

BottoneCreaCont.setLocation(400,305);

BottoneEsci.setLocation(420,355);

BottoneBMP.setLocation(21,305);

BottoneAvvia.setLocation(240,355);

TextX.setLocation(56,408);

TextY.setLocation(56,430);

TextErrore.setLocation(196,430);

TextLiv.setLocation(196,408);

TextFile.setLocation(168,313);

CheckNonConnessi.setLocation(308,428);

CheckSceltaPunto.setLocation(308,398);

CheckSegCompleta.setLocation(25,358);

LabX.setLocation(34,408);

LabY.setLocation(34,432);

LabLiv.setLocation(140,408);

LabErr.setLocation(140,432);

}

public void actionCaricaBMP(String s){

MW.mostra("Caricamento immagine in corso...");

im = BMP.getBMP("images/"+s);

MW.nascondi();

if (im != null){

S = new Segmentazione(im);

repaint();

}

else new MsgBox(this,"File non valido");

}

public void actionAutomatico(){

MW.mostra("Singolo passo di segmentazione in corso...");

S.singoloPasso();

MW.nascondi();

}

public void actionSceltaPunto(MouseEvent e){

if (e.getX() >= 30 && e.getX() < 30+256 &&

e.getY() >= 45 && e.getY() < 45+256){

TextX.setText(String.valueOf(e.getX()-30));

TextY.setText(String.valueOf(e.getY()-45));

}

if (e.getX() >= 320 && e.getX() < 320+256 &&

e.getY() >= 45 && e.getY() < 45+256){

TextX.setText(String.valueOf(e.getX()-320));

TextY.setText(String.valueOf(e.getY()-45));

}

}

public void actionSingoloPassoSC(boolean _conn){

int x,y,liv;

float err;

QTnode nodoCampione;

try{x=new Integer(TextX.getText()).intValue();}

catch(Exception exc) {

new MsgBox(this,"Valori del punto scelto non validi");

return;}

try{y=new Integer(TextY.getText()).intValue();}

catch(Exception exc){

new MsgBox(this,"Valori del punto scelto non validi");

return;}

try{liv = new Integer(TextLiv.getText()).intValue();}

catch(Exception exc){

new MsgBox(this,"Valore del livello non valido");

return;}

try{err=new Float(TextErrore.getText()).floatValue();}

catch(Exception exc){

new MsgBox(this,"Valori dell'errore non valido");

return;}

nodoCampione = S.QT.cerca(x, y,(int)Math.pow(2,8-liv));

MW.mostra("Singolo passo di segmentazione in atto...");

S.singoloPasso(nodoCampione,err,_conn);

MW.nascondi();

new MsgBox(this, "Passo di Segmentazione completato");

}

public void actionCreaContorno(){

try {

if (S != null){

int x,y;

try{x=new Integer(TextX.getText()).intValue();}

catch(Exception exc) {

new MsgBox(this,"Valori del punto scelto non validi");

return;

}

try{y=new Integer(TextY.getText()).intValue();}

catch(Exception exc){

new MsgBox(this,"Valori del punto scelto non validi");

return;

}

setVisible(false);

FrameContorno C=new FrameContorno(S.inPix,S.outPix,

new Integer(TextX.getText()).intValue(),

new Integer(TextY.getText()).intValue(),

Rset,nmod,codref);

}

else new MsgBox(this,"Nessuna immagine segmentata");

}

catch(Exception k){

setVisible(true);

new MsgBox(this,"Errore durante l'estrazione del contorno");

return;

}

}

}

Istogramma.java

import java.awt.*;

import java.awt.image.*;

public class Istogramma{

public float isto[] = new float[Costanti.GRIGI];

public float picchiVal[] = new float[Costanti.NUMPICCHI];

public int picchiPos[] = new int[Costanti.NUMPICCHI];

public Istogramma() {

for (int i=0; i<Costanti.GRIGI; i++) isto[i] = 0;

for (int i=0; i<Costanti.NUMPICCHI; i++) {

picchiVal[i]=0;

picchiPos[i]=0;

}

}

public Istogramma(Pix _p, int _x, int _y, int _dim,boolean isCol[]){

for (int i=0; i<Costanti.GRIGI; i++) isto[i] = 0;

for (int i=0; i<Costanti.NUMPICCHI; i++) {

picchiVal[i]=0;

picchiPos[i]=0;

}

creaIstogramma(_p, _x, _y, _dim,isCol);

occ2perc();

picchi();

}

public void creaIstogramma(Pix _p, int _x, int _y, int _dim,boolean isCol[]){

int red;

for (int j=_x; j<_x+_dim;j++){

for (int i=_y; i<_y+_dim; i++) {

if (_p.pix[i*Costanti.DIM +j] < 0){

red = (_p.pix[i*Costanti.DIM + j] >> 16) & 0xff;

if (isCol[i*Costanti.DIM + j]) isto[red]++;

}

}

}

}

private void occ2perc(){

float area=0;

for(int i=0; i<Costanti.DIM; i++) area += isto[i];

for(int i=0; i<Costanti.DIM; i++) isto[i] /= (float)area;

}

private void picchi(){

int stationary=0;

boolean crescente=true;

int j=0;

float currentValue=0;

for (int i=0; i<Costanti.DIM; i++){

if (isto[i] > currentValue) {

stationary=0;

crescente=true;

currentValue=isto[i];

}

else if (isto[i] == currentValue){

stationary++;

crescente=true;

}

else {

if (crescente) {

if (stationary==0){ inserisciPicco(isto[i-1],i-1);}

else{

inserisciPicco(isto[(i-1)-(stationary/2)], (i-1)-(stationary/2));

}

crescente = false;

currentValue=isto[i];

stationary=0;

}

}

}

if (crescente){

if (stationary==0) inserisciPicco(isto[255],255);

else inserisciPicco(isto[255-(stationary/2)], 255-(stationary/2));

}

}

private void inserisciPicco(float _val, int _pos){

float temp=_val;

for (int i=1; i<6; i++){

if (_pos-i >= 0) temp+= isto[_pos-i];

if (_pos+i < 256) temp+= isto[_pos+i];

}

_val = temp;

for (int i=0; i<Costanti.NUMPICCHI; i++){

if (picchiVal[i] != 0){

if (intersezionePiena(_pos, picchiPos[i]) && picchiVal[i]>=_val) return;

}

}

for (int i=0; i<Costanti.NUMPICCHI; i++){

if (picchiVal[i] != 0){

if (intersezionePiena(_pos, picchiPos[i]) && picchiVal[i]<_val){

picchiPos[i]=0;

picchiVal[i]=0;

}

}

}

riassestaPicchi();

if (_val > picchiVal[Costanti.NUMPICCHI-1]){

picchiVal[Costanti.NUMPICCHI-1]=_val;

picchiPos[Costanti.NUMPICCHI-1]=_pos;

}

int j=Costanti.NUMPICCHI-2;

while(j>=0){

if (_val > picchiVal[j]){

picchiVal[j+1]=picchiVal[j];

picchiPos[j+1]=picchiPos[j];

picchiVal[j]=_val;

picchiPos[j]=_pos;

j--;

}

else return;

}

return;

}

private static boolean intersezione(int _pos1, int _pos2){

boolean ret=false;

if (_pos1 < _pos2){

if (_pos1+Costanti.SIGMA >= _pos2-Costanti.SIGMA) ret=true;

}

else if (_pos1 > _pos2){

if (_pos2+Costanti.SIGMA >= _pos1-Costanti.SIGMA) ret=true;

}

else ret=true;

return ret;

}

private static boolean intersezionePiena(int _pos1, int _pos2){

if ((_pos1 >= _pos2 - Costanti.SIGMA) &&

(_pos1 <= _pos2 + Costanti.SIGMA))

return true;

else

return false;

}

private void riassestaPicchi(){

for (int i=0; i < Costanti.NUMPICCHI-1; i++){

if (picchiVal[i]==0){

for (int j=i; j < Costanti.NUMPICCHI-1; j++){

picchiVal[j]=picchiVal[j+1];

picchiPos[j]=picchiPos[j+1];

}

picchiVal[Costanti.NUMPICCHI-1]=0;

picchiPos[Costanti.NUMPICCHI-1]=0;

}

}

}

public static float calcola_fv(Istogramma i1, Istogramma i2){

float fv=0;

for (int i=0; i<Costanti.NUMPICCHI; i++){

for (int j=0; j<Costanti.NUMPICCHI; j++){

if (i1.picchiVal[i]!=0 && i2.picchiVal[j]!=0){

if (intersezione(i1.picchiPos[i], i2.picchiPos[j])){

fv += i1.picchiVal[i]*i2.picchiVal[j];

}

}

}

}

return fv;

}

}

MsgBox.java

import java.awt.*;

import java.awt.event.*;

public class MsgBox extends Dialog implements MouseListener,FocusListener{

Button B;

Label L;

Frame Father;

public MsgBox(Frame F, String _s){

super(F, "Messaggio di errore");

setSize(250,120);

setLocation(300,300);

setVisible(true);

Father = F;

Father.setEnabled(false);

B = new Button("OK");

B.setSize(100,30);

B.setLocation(75,70);

L = new Label(_s);

L.setSize(230,20);

L.setLocation(10,30);

L.setAlignment(Label.CENTER);

add(B);

add(L);

B.setVisible(true);

L.setVisible(true);

B.addMouseListener(this);

addFocusListener(this);

}

public void mouseReleased(MouseEvent e){}

public void mousePressed(MouseEvent e) {}

public void mouseClicked(MouseEvent e) {

Father.setEnabled(true);

setVisible(false);

}

public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void focusLost(FocusEvent f){

}

public void focusGained(FocusEvent f){}

}

FrameEsecuzioneQuery.java

import java.awt.*;

import java.awt.event.*;

public class FrameEsecuzioneQuery extends Frame {

TextField Dati[] = new TextField[8];

TextField Oggetti[] = new TextField[5];

TextField RelX[] = new TextField[5];

TextField RelY[] = new TextField[5];

TextField Err[] = new TextField[2];

CheckboxGroup TipoQuery;

Checkbox Scelta1,Scelta2,Scelta3;

Button Exit,Start;

Image Title;

public FrameEsecuzioneQuery(){

setSize(600,550);

setLocation(50,25);

setVisible(true);

setResizable(false);

Title = Toolkit.getDefaultToolkit().getImage("image11.gif");

for (int i=0; i<8; i++) Dati[i] = new TextField();

for (int i=0; i<5; i++) {

Oggetti[i]=new TextField();

RelX[i]=new TextField();

RelY[i]=new TextField();

}

for (int i=0; i<2; i++) Err[i]=new TextField();

TipoQuery = new CheckboxGroup();

Scelta1 = new Checkbox("per relazioni spaziali",TipoQuery,false);

Scelta2 = new Checkbox("per caratteristiche morfologiche",TipoQuery,false);

Scelta3 = new Checkbox("entrambe",TipoQuery,true);

Exit = new Button("Esci");

Start = new Button("Esegui query");

for (int i=0; i<8; i++) add(Dati[i]);

for (int i=0; i<5; i++) {

add(Oggetti[i]);

add(RelX[i]);

add(RelY[i]);

}

add(Scelta1);

add(Scelta2);

add(Scelta3);

add(Start);

add(Exit);

add(Err[0]);

add(Err[1]);

}

public void paint(Graphics g){

g.drawImage(Title,50,30,this);

g.drawString("Convessità",10,115);

g.drawString("Densità",10,145);

g.drawString("Asimmetria",10,175);

g.drawString("Spreadness",10,205);

g.drawString("Orientazione",10,235);

g.drawString("Elongazione",10,265);

g.drawString("Area",10,295);

g.drawString("Uniformità",10,325);

g.drawString("RELAZIONI SPAZIALI",40,355);

for (int i=0; i<8; i++){

Dati[i].setSize(120,20);

Dati[i].setLocation(100,100+(i*30));

}

g.drawString("Oggetti canonici",10,385);

g.drawString("Rel. asse X",420,385);

g.drawString("Rel. asse Y",500,385);

for (int i=0; i<5; i++){

Oggetti[i].setSize(400,20);

Oggetti[i].setLocation(10,400+(i*30));

RelX[i].setSize(60,20);

RelX[i].setLocation(420,400+(i*30));

RelY[i].setSize(60,20);

RelY[i].setLocation(500,400+(i*30));

}

Scelta1.setSize(200,20);Scelta1.setLocation(300,200);

Scelta2.setSize(200,20);Scelta2.setLocation(300,230);

Scelta3.setSize(200,20);Scelta3.setLocation(300,260);

Start.setSize(100,30);Start.setLocation(300,290);

Exit.setSize(100,30);Exit.setLocation(420,290);

g.drawString("Errore",500,185);

for (int i=0; i<2; i++){

Err[i].setSize(60,20);

Err[i].setLocation(500,200+(i*30));

}

}

public static void main(String[] args){

FrameDati FD = new FrameDati();

}

}

MsgWin.java

import java.awt.*;

public class MsgWin extends Dialog{

Label L;

public MsgWin(Frame F){

super(F, "Messaggio di runtime");

setSize(250,120);

setLocation(300,300);

L = new Label();

L.setSize(230,20);

L.setLocation(10,30);

L.setAlignment(Label.CENTER);

add(L);

L.setVisible(true);

}

public void mostra(String _s){

L.setText(_s);

this.setVisible(true);

}

public void nascondi(){

this.setVisible(false);

}

}

PercorsoOttimo.java

import java.awt.*;

public class PercorsoOttimo {

public int num[] = new int[Costanti.MAXPERC];

public float fv[] = new float[Costanti.MAXPERC];

public PercorsoOttimo(){

for (int i=0; i<Costanti.MAXPERC; i++){

num[i] = 0;

fv[i] = 0;

}

}

public QTnode nodoCampione(Pix _inp,QTnode _rad,boolean isCol[]){

int ret;

this.creaPercorsoOttimo(_inp, _rad, isCol);

ret = this.cercaNodoCampione();

return _rad.cerca(ret);

}

private int cercaNodoCampione(){

int bestInt=0;

float bestFloat = 0;

bestInt = this.num[6];

bestFloat = this.fv[6];

for (int i=6; i<Costanti.MAXPERC; i++){

if (this.fv[i] > bestFloat) {

bestInt = this.num[i];

bestFloat = this.fv[i];

}

}

return bestInt;

}

private void creaPercorsoOttimo(Pix _inp, QTnode _rad, boolean isCol[]){

int i;

QTnode best;

best = _rad;

for (i=1; i<Costanti.MAXPERC; i++){

best = this.bestChild(_inp, best, isCol);

this.num[i]=best.num;

this.fv[i]=best.fv;

}

}

private QTnode bestChild(Pix _inp,QTnode temp,boolean isCol[]){

float bestfv;

QTnode node2,bestNode;

Istogramma i1,i2;

i1 = new Istogramma(_inp, temp.r, temp.c, temp.dim,isCol);

if (!temp.child1.BClosed){

node2 = temp.child1;

i2 = new Istogramma(_inp, node2.r, node2.c, node2.dim,isCol);

temp.child1.fv = Istogramma.calcola_fv(i1, i2);

}

if (!temp.child2.BClosed){

node2 = temp.child2;

i2 = new Istogramma(_inp, node2.r, node2.c, node2.dim,isCol);

temp.child2.fv = Istogramma.calcola_fv(i1, i2);

}

if (!temp.child3.BClosed){

node2 = temp.child3;

i2 = new Istogramma(_inp, node2.r, node2.c, node2.dim,isCol);

temp.child3.fv = Istogramma.calcola_fv(i1, i2);

}

if (!temp.child4.BClosed){

node2 = temp.child4;

i2 = new Istogramma(_inp, node2.r, node2.c, node2.dim,isCol);

temp.child4.fv = Istogramma.calcola_fv(i1, i2);

}

bestNode = null;

bestfv = -1;

if (!temp.child1.BClosed && temp.child1.fv>bestfv){

bestNode = temp.child1;

bestfv = temp.child1.fv;

}

if (!temp.child2.BClosed && temp.child2.fv>bestfv){

bestNode = temp.child2;

bestfv = temp.child2.fv;

}

if (!temp.child3.BClosed && temp.child3.fv>bestfv){

bestNode = temp.child3;

bestfv = temp.child3.fv;

}

if (!temp.child4.BClosed && temp.child4.fv>bestfv){

bestNode = temp.child4;

}

return bestNode;

}

}

Pix.java

import java.awt.image.*;

import java.awt.*;

public class Pix {

public int whitePix;

public int pix[] = new int[Costanti.DIMTOT];

public Pix(){

for (int i=0; i<(Costanti.DIMTOT); i++) pix[i]=Costanti.BIANCO;

whitePix = Costanti.DIMTOT;

}

public void detArray(Image _img, int _x, int _y, int _dim){

int pixels[] = new int[_dim*_dim];

int red;

PixelGrabber pg = new PixelGrabber(_img,_x,_y,_dim,_dim,pixels,0,_dim);

try {

pg.grabPixels();

}

catch (InterruptedException e) {

System.err.println("errore");

return;

}

if ((pg.getStatus() & ImageObserver.ABORT) != 0){

System.err.println("errore");

return;

}

this.pix = pixels;

}

public void detArray(Image _img){

int pixels[] = new int[Costanti.DIMTOT];

int red;

PixelGrabber pg = new PixelGrabber(_img,0,0,Costanti.DIM,Costanti.DIM,pixels,0,Costanti.DIM);

try {

pg.grabPixels();

}

catch (InterruptedException e) {

System.err.println("errore");

return;

}

if ((pg.getStatus() & ImageObserver.ABORT) != 0){

System.err.println("errore");

return;

}

this.pix = pixels;

}

public void copia(Pix _p){

for (int i=0; i<Costanti.DIMTOT; i++) pix[i]=_p.pix[i];

}

public Image getImage(){

return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(Costanti.DIM, Costanti.DIM, pix, 0, Costanti.DIM));

}

public boolean inShape(int _x,int _y, int _col){

if (_col == pix[_y*Costanti.DIM + _x]) return true;

else return false;

}

}

Qtnode.java

import java.awt.image.*;

import java.awt.*;

public class QTnode{

public int num;

public int r;

public int c;

public int dim;

public int pix_col;

public float fv;

public boolean BClosed;

public QTnode father;

public QTnode child1;

public QTnode child2;

public QTnode child3;

public QTnode child4;

public QTnode(int _num, int _r, int _c, int _dim,float _fv, boolean _bc,

QTnode _f,QTnode _c1, QTnode _c2, QTnode _c3, QTnode _c4){

num = _num;

r = _r;

c = _c;

dim = _dim;

fv = _fv;

BClosed = _bc;

father = _f;

child1 = _c1;

child2 = _c2;

child3 = _c3;

child4 = _c4;

pix_col=0;

}

public void creaQT(int liv){

if (liv > Costanti.MAXLIV) return;

else {

QTnode ch1 = new QTnode(num*10+1,r,c,dim/2,-1,false,this,null,null,null,null);

child1 = ch1;

ch1.creaQT(liv+1);

QTnode ch2 = new QTnode(num*10+2,r+dim/2,c,dim/2,-1,false,this,null,null,null,null);

child2 = ch2;

ch2.creaQT(liv+1);

QTnode ch3 = new QTnode(num*10+3,r,c+dim/2,dim/2,-1,false,this,null,null,null,null);

child3 = ch3;

ch3.creaQT(liv+1);

QTnode ch4 = new QTnode(num*10+4,r+dim/2,c+dim/2,dim/2,-1,false,this,null,null,null,null);

child4 = ch4;

ch4.creaQT(liv+1);

}

}

public static int livello(int _num){

int liv=0;

while (_num > 0) {

liv++;

_num /= 10;

}

return liv;

}

public QTnode cerca(int _num) {

QTnode temp = this;

int liv = livello( _num);

for (int i=liv-1; i >= 0; i--){

switch (_num / ((int)Math.pow(10,i))) {

case 1 : temp = temp.child1; break;

case 2 : temp = temp.child2; break;

case 3 : temp = temp.child3; break;

case 4 : temp = temp.child4; break;

default : return null;

}

_num = _num % ((int) Math.pow(10,i));

}

return temp;

}

public QTnode cerca(int _x, int _y, int _dim){

int _num = 0;

int _livello = 0;

while (_dim < Costanti.DIM){

if ((_x & _dim)>0 && (_y & _dim)>0) _num += (Math.pow(10,_livello))*4;

if ((_x & _dim)>0 && (_y & _dim)==0) _num += (Math.pow(10,_livello))*2;

if ((_x & _dim)==0 && (_y & _dim)>0) _num += (Math.pow(10,_livello))*3;

if ((_x & _dim)==0 && (_y & _dim)==0) _num += (Math.pow(10,_livello))*1;

_dim *=2;

_livello++;

}

QTnode temp = this.cerca(_num);

return temp;

}

public boolean etichettato(int _num){

QTnode temp = cerca(_num);

return temp.BClosed;

}

public void etichetta(int _num){

QTnode temp=cerca(_num);

temp.BClosed = true;

temp.etichettaAlbero();

temp.etichettaPadre();

}

private void etichettaAlbero(){

BClosed = true;

if (child1 != null){

child1.etichettaAlbero();

child2.etichettaAlbero();

child3.etichettaAlbero();

child4.etichettaAlbero();

}

}

private void etichettaPadre(){

if (father != null) {

QTnode temp = father;

if (temp.child1.BClosed && temp.child2.BClosed && temp.child3.BClosed && temp.child4.BClosed){

temp.BClosed = true;

temp.etichettaPadre();

}

}

}

public void colora(Pix _pix, Colori _col, QTnode _node){

int colore = _col.Pal[_col.ColorCount].getRGB();

int i=0;

for (int x = _node.r; x < _node.r + _node.dim; x++){

for (int y = _node.c; y < _node.c + _node.dim; y++){

if (_pix.pix[y*Costanti.DIM+x] == Costanti.BIANCO) {

_pix.pix[y*Costanti.DIM+x]=colore;

_pix.whitePix--;

i++;

}

}

}

etichetta(_node.num);

}

}

QueryCanvas.java

import java.awt.*;

import java.awt.event.*;

public class QueryCanvas extends Canvas implements MouseListener,MouseMotionListener{

Image Oggetto[] = new Image[6];

Image OggettoRed[] = new Image[6];

String desc[] = new String[6];

int locX[] = new int[6];

int locY[] = new int[6];

int sizeX[] = new int[6];

int sizeY[] = new int[6];

int relX[] = new int[6];

int relY[] = new int[6];

int viid[] = new int[6];

boolean pressed[] = new boolean[6];

int selected;

boolean isPressed;

int lastImage;

Contorno Cont;

public QueryCanvas(){

for (int i=0; i<6; i++){

Oggetto[i]=null;

OggettoRed[i]=null;

desc[i]="";

locX[i]=0;

locY[i]=0;

sizeX[i]=0;

sizeY[i]=0;

relX[i]=0;

relY[i]=0;

viid[i]=0;

}

selected=-1;

isPressed=false;

lastImage=0;

Cont = null;

setSize(256,256);

addMouseListener(this);

addMouseMotionListener(this);

}

public void paint(Graphics g){

if (Cont!=null){

Contorno temp = Cont;

if (selected==0) g.setColor(Color.red);

else g.setColor(Color.black);

do{

g.drawLine(temp.x,temp.y,temp.next.x,temp.next.y);

temp = temp.next;

}while (temp != Cont);

}

else if(Oggetto[0]!=null) {

if (pressed[0])

g.drawImage(OggettoRed[0],locX[0],locY[0],this);

else

g.drawImage(Oggetto[0],locX[0],locY[0],this);

}

for (int i=1; i<6; i++){

if (Oggetto[i]!=null) {

if (pressed[i]) g.drawImage(OggettoRed[i],locX[i],locY[i],this);

else g.drawImage(Oggetto[i],locX[i],locY[i],this);

}

}

}

public void caricaAnomalia(String nomefile,String _desc,int _sizex,int _sizey, int _viid){

Oggetto[0]=BMP.getBMPResized("ToolBar/"+nomefile,_sizex,_sizey);

OggettoRed[0]=BMP.getBMPResized("ToolBar/R"+nomefile,_sizex,_sizey);

desc[0]=_desc;

viid[0]=_viid;

locX[0]=0;

locY[0]=0;

sizeX[0]=_sizex;

sizeY[0]=_sizey;

calcolaRel();

repaint();

}

public void caricaCanonico(String nomefile,String _desc,int _sizex,int _sizey, int _viid){

if (lastImage<5 && assente(_viid)) lastImage++;

else return;

Oggetto[lastImage]=BMP.getBMPResized("ToolBar/"+nomefile,_sizex,_sizey);

OggettoRed[lastImage]=BMP.getBMPResized("ToolBar/R"+nomefile,_sizex,_sizey);

desc[lastImage]=_desc;

viid[lastImage]=_viid;

locX[lastImage]=0;

locY[lastImage]=0;

sizeX[lastImage]=_sizex;

sizeY[lastImage]=_sizey;

calcolaRel();

repaint();

}

private boolean assente(int _viid){

for (int i=1; i<6;i++) if (viid[i]==_viid) return false;

return true;

}

public void remove(int i){

Oggetto[i]=null;

OggettoRed[i]=null;

viid[i]=0;

relX[i]=0;

relY[i]=0;

locX[i]=0;

locY[i]=0;

sizeX[i]=0;

sizeY[i]=0;

desc[i]="";

lastImage--;

bubbleUp();

repaint();

}

public void bubbleUp(int i){

if (Oggetto[i-1]==null){

Oggetto[i-1]=Oggetto[i];

OggettoRed[i-1]=OggettoRed[i];

locX[i-1]=locX[i];

locY[i-1]=locY[i];

desc[i-1]=desc[i];

sizeX[i-1]=sizeX[i];

sizeY[i-1]=sizeY[i];

relX[i-1]=relX[i];

relY[i-1]=relY[i];

viid[i-1]=viid[i];

pressed[i-1]=false;

Oggetto[i]=null;

if (i>2) bubbleUp(i-1);

}

}

public void bubbleUp(){

for (int i=2; i<6; i++) bubbleUp(i);

}

public void caricaContorno(Contorno _Cont,String _desc, int _viid){

Cont=_Cont;

Rettangolo R = new Rettangolo(Cont);

locX[0]=R.Ovest;

locY[0]=R.Nord;

sizeX[0]=R.Est-R.Ovest;

sizeY[0]=R.Sud-R.Nord;

pressed[0]=false;

desc[0]=_desc;

viid[0]=_viid;

calcolaRel();

repaint();

}

public void calcolaRel(){

if (Oggetto[0]!=null || Cont!=null){

for (int i=1;i<6;i++){

if (Oggetto[i]!=null){

relX[i]=Rettangolo.relX(locX[0],locX[0]+sizeX[0],locX[i],locX[i]+sizeX[i]);

relY[i]=Rettangolo.relY(locY[0],locY[0]+sizeY[0],locY[i],locY[i]+sizeY[i]);

}

}

}

}

public void mousePressed(MouseEvent e){

selected = -1;

int i=0;

while (selected<0 && i<6){

if (e.getX()>=locX[i] && e.getY()>=locY[i] && e.getX()<=locX[i]+sizeX[i]

&& e.getY()<=locY[i]+sizeY[i] && Oggetto[i]!=null)

selected = i;

i++;

}

if (selected >=0 && Oggetto[selected]!=null){

pressed[selected]=true;

repaint();

}

else selected=-1;

}

public void mouseReleased(MouseEvent e){

if ((e.getX()>256 || e.getY()>256 || e.getX()<0 || e.getY()<0) && selected>0){

remove(selected);

}

for (int i=0; i<6; i++) pressed[i]=false;

selected = -1;

calcolaRel();

repaint();

}

public void mouseEntered(MouseEvent e){}

public void mouseExited(MouseEvent e){}

public void mouseClicked(MouseEvent e){}

public void mouseMoved(MouseEvent e){}

public void mouseDragged(MouseEvent e){

if (selected >=0){

locX[selected]=e.getX();

locY[selected]=e.getY();

repaint();

}

}

}

Rettangolo.java

public class Rettangolo {

public int Nord;

public int Sud;

public int Est;

public int Ovest;

public Rettangolo(Contorno cont){

Nord = Sud = cont.y;

Est = Ovest = cont.x;

Contorno temp = cont.next;

do{

if (temp.x < Ovest) Ovest = temp.x;

if (temp.x > Est) Est = temp.x;

if (temp.y < Nord) Nord = temp.y;

if (temp.y > Sud) Sud = temp.y;

temp = temp.next;

} while (temp != cont);

}

public Rettangolo(int _Nord,int _Sud, int _Ovest,int _Est){

Nord = _Nord;

Sud = _Sud;

Ovest = _Ovest;

Est = _Est;

}

public static int relX(int ovest1,int est1,

int ovest2,int est2){

if (est1 < ovest2) return 1;

else if (est2 < ovest1) return -1;

else if (ovest1==ovest2 && est1==est2) return 2;

else if (est1==ovest2) return 3;

else if (est2==ovest1) return -3;

else if (ovest1 < ovest2 && est1 > est2) return 4;

else if (ovest2 < ovest1 && est2 > est1) return -4;

else if (ovest1==ovest2 && est1 > est2) return 5;

else if (ovest1==ovest2 && est2 > est1) return -5;

else if (est1==est2 && ovest1<ovest2) return 6;

else if (est1==est2 && ovest2<ovest1) return -6;

else if (ovest1 < ovest2 && ovest2<est1 && est1<est2) return 7;

else return -7;

}

public static int relY(int nord1,int sud1,

int nord2, int sud2){

nord1=-nord1;

nord2=-nord2;

sud1=-sud1;

sud2=-sud2;

if (nord1 < sud2) return 1;

else if (nord2 < sud1) return -1;

else if (sud1==sud2 && nord1==nord2) return 2;

else if (nord1==sud2) return 3;

else if (nord2==sud1) return -3;

else if (sud1 < sud2 && nord1 > nord2) return 4;

else if (sud2 < sud1 && nord2 > nord1) return -4;

else if (sud1==sud2 && nord1 > nord2) return 5;

else if (sud1==sud2 && nord2 > nord1) return -5;

else if (nord1==nord2 && sud1<sud2) return 6;

else if (nord1==nord2 && sud2<sud1) return -6;

else if (sud1 < sud2 && sud2<nord1 && nord1<nord2) return 7;

else return -7;

}

public static String val2String(int i){

if (i==1) return "<";

else if (i==-1) return "<";

else if (i==2) return "=";

else if (i==3) return "|";

else if (i==-3) return "|";

else if (i==4) return "%";

else if (i==-4) return "%";

else if (i==5) return "[";

else if (i==-5) return "[";

else if (i==6) return "]";

else if (i==-6) return "]";

else if (i==7) return "/";

else if (i==-7) return "/";

else return "";

}

}

Segmentazione.java

import java.awt.*;

import java.awt.image.*;

public class Segmentazione {

public Image inImage, outImage;

public QTnode QT;

public Pix inPix,outPix;

public PercorsoOttimo PO;

public Colori Col;

public boolean isCol[]= new boolean[256*256];

public Segmentazione(Image _inImage){

inImage = _inImage;

QT = new QTnode(0,0,0,Costanti.DIM,-1,false,null,null,null,null,null);

QT.creaQT(1);

Col = new Colori();

outPix = new Pix();

inPix = new Pix();

inPix.detArray(inImage);

outImage = outPix.getImage();

PO = new PercorsoOttimo();

Col = new Colori();

for (int i=0; i<256*256; i++) isCol[i]=true;

}

public void singoloPasso(QTnode _node, float _err, boolean _nonConnessi){

Istogramma i1=new Istogramma(inPix, _node.r, _node.c, _node.dim,isCol);

QT.colora(outPix, Col, _node);

if (_nonConnessi) nodiNonConnessi(_node, i1, _err);

else nodiConnessi(_node, i1, _err);

Col.ColorCount++;

outImage = outPix.getImage();

}

public void singoloPasso(){

QTnode temp = PO.nodoCampione(inPix, QT, isCol);

singoloPasso(temp, temp.fv, true);

outImage = outPix.getImage();

}

public void segmentazione(){

int oldwhitepix;

while (outPix.whitePix > Costanti.MINWHITE){

singoloPasso();

}

}

private void nodiConnessi(QTnode _nc, Istogramma _i1, float _err){

QTnode temp;

_nc.BClosed=true;

Istogramma i2;

for (int i=0; i<8; i++){

temp = QT.cerca(_nc.r+(Costanti.DIRX[i]*_nc.dim),

_nc.c+(Costanti.DIRY[i]*_nc.dim),

_nc.dim);

if (!temp.BClosed){

i2 = new Istogramma(inPix, temp.r, temp.c, temp.dim,isCol);

if (Istogramma.calcola_fv(_i1,i2) >= (_err/3)){

QT.colora(outPix, Col, temp);

for (int x=temp.r; x<temp.r+temp.dim; x++)

for (int y=temp.c; y<temp.c+temp.dim; y++)

isCol[y*256+x]=false;

nodiConnessi(temp, _i1, _err);

}

}

}

return;

}

private void nodiNonConnessi(QTnode _nc, Istogramma _i1, float _err){

QTnode temp;

Istogramma i2;

for (int i=0; i<Costanti.DIM; i+=_nc.dim){

for (int j=0; j<Costanti.DIM; j+=_nc.dim){

temp = QT.cerca(i,j,_nc.dim);

if (!temp.BClosed){

i2 = new Istogramma(inPix, temp.r, temp.c, temp.dim,isCol);

if (Istogramma.calcola_fv(_i1,i2) >= (_err/3)){

for (int x=temp.r; x<temp.r+temp.dim; x++)

for (int y=temp.c; y<temp.c+temp.dim; y++)

isCol[y*256+x]=false;

QT.colora(outPix, Col, temp);

}

}

}

}

return;

}

}

SQL.java

import java.util.Date;import java.util.Calendar;import java.util.GregorianCalendar;import java.sql.*;

public class SQL{ static int connessioni = 0; Connection conn; Statement stmt; ResultSet rset;

public SQL(Connection _conn) {

conn = _conn;

try{

stmt = conn.createStatement();

connessioni++;

}

catch(Exception e) {stmt=null;}

rset = null;

}

public void close(){

try {

stmt.close();

connessioni--;

}

catch (Exception e){}

}

public boolean next() {

try{return rset.next();}

catch(Exception e){

e.printStackTrace();

return false;

}

}

public static boolean executeUpdate(Connection _conn, String arg){

SQL R=new SQL(_conn);

try {

R.close();

return true;

}

catch(Exception e){

R.close();

return false;

}

}

public void executeQuery(String arg) {

try {

rset = stmt.executeQuery(arg);

}

catch (Exception e){close(); }

}

public void createStatement() {

try {stmt = conn.createStatement(); }

catch (Exception e){stmt=null;}

}

public void newSession(){

try{

stmt.close();

stmt=conn.createStatement();

}

catch(Exception e){ stmt=null; }

}

public static Connection Connessione() throws SQLException, ClassNotFoundException {

Class.forName ("oracle.jdbc.driver.OracleDriver");

Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@", "utente", "password");

return conn;

}

public void Query1(String prat, String anno){

executeQuery("Select * from Associazione where nprat="+prat+" and anno="+anno);

}

public void Query2(String codfis){

executeQuery("Select * from Associazione where codfisc='"+codfis+"'");

}

public void Query3(String cog, String nom){

executeQuery("Select * from Associazione where cognome='"+cog+"' and nome='"+nom+"'");

}

public static boolean Query4(Connection _conn,String nprat,String anno,String codfisc,

String cog, String nom, String data){

return executeUpdate(_conn,"insert into associazione values ("+nprat+","+anno+",'"+codfisc+"','"+cog+"','"+nom+"','"+data+"')");

}

public static boolean Query5(Connection _conn,String codfis){

return executeUpdate(_conn,"insert into pazienti(codfisc) values ('"+codfis+"')");

}

public void Query6(String codfis){

executeQuery("select * from associazione,pazienti where pazienti.codfisc='"+codfis+"' and associazione.codfisc='"+codfis+"'");

}

public static boolean Query7(Connection _conn,String codfisc,String luogo_nas,String sesso,String luogo_res,String indirizzo,String prov_res,String regione,

String tel,String prov_nasc,String padre,String profess,String stato_civ,String nome_cf,String cognome_cf,

String data_nasc_cf,String luogo_nasc_cf){

String U="update pazienti set luogo_nasc='"+luogo_nas;

U+="',sesso='"+sesso+"',luogo_res='"+luogo_res;

U+="',indirizzo='"+indirizzo+"',prov_res='"+prov_res;

U+="',regione='"+regione+"',tel='"+tel;

U+="',prov_nasc='"+prov_nasc+"',padre='"+padre;

U+="',profess='"+profess+"',stato_civ='"+stato_civ;

U+="',nome_cf='"+nome_cf+"',cognome_cf='"+cognome_cf;

U+="',data_nasc_cf='"+data_nasc_cf+"',luogo_nasc_cf='"+luogo_nasc_cf;

U+="' where codfisc='"+codfisc+"'";

return executeUpdate(_conn,U);

}

public void Query8(String nprat,String anno){

executeQuery("Select * from accettazioni where nprat="+nprat+" and anno="+anno+" order by nmodulo");

}

public static boolean Query9(Connection _conn,String nprat,String anno,String nmodulo,

String data,String medico, String diagnosi){

return executeUpdate(_conn,"insert into accettazioni values("+nprat+","+anno+","+nmodulo+",'"+data+"','"+medico+"','"+diagnosi+"',null,null)");

}

public static boolean Query10(Connection _conn,String nprat, String anno, String nmodulo,

String data,String medico, String diagnosi){

return executeUpdate(_conn,"update accettazioni set data='"+data+"',medico='"+medico+"',diagnosi='"+diagnosi+"' where nprat="+nprat+" and anno="+anno+" and nmodulo="+nmodulo);

}

public void Query11(String nprat, String anno, String nmodulo){

executeQuery("select anamnesi from accettazioni where nprat="+nprat+" and anno="+anno+" and nmodulo="+nmodulo);

}

public static boolean Query12(Connection _conn,String nprat, String anno, String nmodulo, String anamnesi){

return executeUpdate(_conn,"update accettazioni set anamnesi='"+anamnesi+"' where nprat="+nprat+" and anno="+anno+" and nmodulo="+nmodulo);

}

public void Query13(String nprat, String anno, String nmodulo){

executeQuery("select esame_ob from accettazioni where nprat="+nprat+" and anno="+anno+" and nmodulo="+nmodulo);

}

public static boolean Query14(Connection _conn,String nprat, String anno, String nmodulo, String esame_ob){

return executeUpdate(_conn,"update accettazioni set esame_ob='"+esame_ob+"' where nprat="+nprat+" and anno="+anno+" and nmodulo="+nmodulo);

}

public void Query15(){

executeQuery("select * from esami order by codice");

}

public static boolean Query16(Connection _conn,String codice, String nome_esame, String descrizione, String nota, String tariffa){

return executeUpdate(_conn,"insert into esami values('"+codice+"','"+nome_esame+"','"+descrizione+"',"+tariffa+",'"+nota+"')");

}

public static boolean Query17(Connection _conn,String codice, String nome_esame, String descrizione, String nota, String tariffa){

return executeUpdate(_conn,"update esami set nome_esame='"+nome_esame+"',descrizione='"+descrizione+"',nota='"+nota+"',tariffa="+tariffa+" where codice='"+codice+"'");

}

public void Query18(String nprat, String anno){

executeQuery("Select * from denunce where nprat="+nprat+" and anno="+anno+" order by data");

}

public static boolean Query19(Connection _conn,String nprat,String anno,String malattia,String data){

return executeUpdate(_conn,"insert into denunce values("+nprat+","+anno+",'"+malattia+"','"+data+"')");

}

public static boolean Query20(Connection _conn,String nprat,String anno,String oldMal,String malattia,String data){

return executeUpdate(_conn,"update denunce set malattia='"+malattia+"',data='"+data+"' where nprat="+nprat+" and anno="+anno+" and malattia='"+oldMal+"'");

}

public void Query21(String nprat, String anno,String nmodulo){

executeQuery("select nome_esame,data_esame,cod_esame,codref,nmodulo from diario_clinico,esami where nprat="+nprat+" and anno="+anno+" and nmodulo="+nmodulo+" and cod_esame=codice");

}

public void Query22(String nprat, String anno){

executeQuery("select nome_esame,data_esame,cod_esame,codref,nmodulo from diario_clinico,esami where nprat="+nprat+" and anno="+anno+" and cod_esame=codice");

}

public static boolean Query23(Connection _conn,String nprat,String anno,String nmodulo,

String cod_esame,String data_esame){

int max;

SQL R1=new SQL(_conn);

R1.executeQuery("select max(codref) from diario_clinico");

if (R1.next()) max = R1.getInt("max(codref)")+1;

else max=1;

R1.close();

executeUpdate(_conn,"insert into geomorph(viid) values("+max+")");

return executeUpdate(_conn,"insert into diario_clinico values("+nprat+","+anno+","+nmodulo+",'"+cod_esame+"','"+data_esame+"',null,null,"+String.valueOf(max)+")");

}

public static boolean Query24(Connection _conn,String codref,String cod_esame, String data_esame){

return executeUpdate(_conn,"update diario_clinico set cod_esame='"+cod_esame+"',data_esame='"+data_esame+"' where codref="+codref);

}

public void Query25(){executeQuery("select codice,nome_esame from esami"); }

public void Query25b(String codice){

executeQuery("select nome_esame from esami where codice='"+codice+"'");

}

public void Query26(String codref){

executeQuery("select immagine,note,nmodulo from diario_clinico where codref="+codref);

}

public static boolean Query27(Connection _conn,String codref,String immagine,String note){

return executeUpdate(_conn,"update diario_clinico set immagine='"+immagine+"',note='"+note+"' where codref="+codref);

}

public static int Query28(Connection _conn,int tipo){

SQL R=new SQL(_conn);

if (tipo==0) R.executeQuery("select count(*) from Geomorph where FileBMP like 'anomalia%'");

else R.executeQuery("select count(*) from Canonici");

R.next();

int _ret=R.getInt("Count(*)");

R.close();

return _ret;

}

public void Query29(int tipo){

if (tipo==0)

executeQuery("select * from Geomorph where FileBMP like 'anomalia%'");

else executeQuery("Select * from Canonici");

}

public void Query30(int viid){ executeQuery("select * from canonici where viid="+viid); }

public void Query31(int viid){ executeQuery("select * from geomorph where viid="+viid); }

public static boolean Query32(Connection _conn,DatiQuery D){

SQL R=new SQL(_conn);

R.Query35(D.viid[0]);

if (R.isEmpty()) Query32b(_conn,D.viid[0]);

R.close();

String r="update geomorph set Area="+String.valueOf(D.Area);

r+=",Densita="+String.valueOf(D.Densità);

r+=",Asimmetria="+String.valueOf(D.Asimmetria);

r+=",Orientazione="+String.valueOf(D.Orientazione);

r+=",Spreadness="+String.valueOf(D.Spreadness);

r+=",Uniformita="+String.valueOf(D.Uniformità);

r+=",Convessita="+String.valueOf(D.Convessità);

r+=" where viid="+String.valueOf(D.viid[0]);

executeUpdate(_conn,r);

executeUpdate(_conn,"delete from spatial_rel where viid="+String.valueOf(D.viid[0]));

for (int i=1; i<6; i++){

if (D.viid[i]>0){

r="insert into spatial_rel values(";

r+=String.valueOf(D.viid[0])+",";

r+=String.valueOf(D.viid[i])+",";

r+=String.valueOf(D.relX[i])+",";

r+=String.valueOf(D.relY[i])+")";

executeUpdate(_conn,r);

}

}

return true;

}

public static boolean Query32b(Connection _conn,int viid){

return executeUpdate(_conn,"insert into geomorph (viid) values("+viid+")");

}

public static boolean Query33(Connection _conn,String nomefile,int x,int y,int viid){

String r="update geomorph set fileBMP='"+nomefile+"',";

r+="sizeX="+String.valueOf(x)+",sizeY="+String.valueOf(y);

r+=" where viid="+String.valueOf(viid);

return executeUpdate(_conn,r);

}

public void Query34(int viid){ executeQuery("select * from spatial_rel where viid="+viid); }

public void Query35(int viid){ executeQuery("select * from geomorph where viid="+viid); }

public void Query36(int viid){ executeQuery("select descrizione from canonici where viid="+viid);}

public void Query37(){executeQuery("select * from geomorph");}

public static boolean Query38(Connection _conn){

return executeUpdate(_conn,"delete from risultati");

}

public void Query39(int viid){ executeQuery("select * from spatial_rel where oggetto="+viid);}

public static boolean Query40(Connection _conn,int viid,double relx,double rely){

return executeUpdate(_conn,"insert into risultati values("+viid+","+relx+","+rely+",0)");

}

public void Query41(){executeQuery("select * from risultati");}

public void Query42(int viid,int oggetto){

executeQuery("select * from spatial_rel where viid="+viid+" and oggetto="+oggetto);

}

public static boolean Query43(Connection _conn,int viid){

return executeUpdate(_conn,"delete from risultati where viid="+viid);

}

public static boolean Query44(Connection _conn,int viid,double sx,double sy){

return executeUpdate(_conn,"update risultati set sx="+sx+",sy="+sy+" where viid="+viid);

}

public static boolean Query45(Connection _conn,int viid){

return executeUpdate(_conn,"insert into risultati values("+viid+",0,0,0)");

}

public void Query46(int viid){ executeQuery("select * from geomorph where viid="+viid); }

public static boolean Query47(Connection _conn,int viid,double dist){

return executeUpdate(_conn,"update risultati set distanza="+dist+" where viid="+viid);

}

public static boolean Query48(Connection _conn,int viid){

return executeUpdate(_conn,"delete from risultati where viid="+viid);

}

public void Query49(int F){executeQuery("select * from risultati order by (sx+sy)/"+F+" desc"); }

public void Query50(){executeQuery("select * from risultati order by distanza");}

public void Query51(int viid){

String Q="select diario_clinico.nprat,diario_clinico.anno,nmodulo,cognome,nome,immagine,data_Esame,nome_Esame ";

Q +="from associazione,diario_clinico,esami where esami.codice=diario_clinico.cod_esame and diario_clinico.anno=associazione.anno ";

Q +="and diario_clinico.nprat=associazione.nprat and diario_clinico.codref="+String.valueOf(viid);

executeQuery(Q);

}

public static int Query52(Connection _conn){

SQL R=new SQL(_conn);

R.executeQuery("select count(*) from risultati");

R.next();

int _ret=R.getInt("count(*)");

R.close();

return _ret;

}

public boolean isEmpty(){return (! next());}

public String getString(String campo){

try { return rset.getString(campo); }

catch (Exception e) {return "";}

}

public int getInt(String campo){

try { return rset.getInt(campo);}

catch (Exception e) {return 0;}

}

public double getDouble(String campo){

try { return rset.getDouble(campo);}

catch (Exception e) {return 0;}

}

public Date getDate(String campo){

try {return rset.getDate(campo);}

catch(Exception e) {return null;}

}

public String getInt2String(String campo){

try {return String.valueOf(getInt(campo));}

catch(Exception e){return "";}

}

public String getDouble2String(String campo){

try {return String.valueOf(getDouble(campo));}

catch(Exception e){return "";}

}

public String getDate2String(String campo){

try {return retDate(rset.getDate(campo));}

catch(Exception e){return null;}

}

public static int retInt(String _int){

try {

Integer _ret = new Integer(_int.trim());

return _ret.intValue();

}

catch(Exception e){

return 0;

}

}

public static String retDate(Date _data){

if (_data==null) return "";

else {

GregorianCalendar cal = new GregorianCalendar();

cal.setTime(_data);

int anno=cal.get(Calendar.YEAR);

int mese=cal.get(Calendar.MONTH);

int giorno=cal.get(Calendar.DATE);

String month="";

switch(mese){

case 0:month="GEN";break;

case 1:month="FEB";break;

case 2:month="MAR";break;

case 3:month="APR";break;

case 4:month="MAG";break;

case 5:month="GIU";break;

case 6:month="LUG";break;

case 7:month="AGO";break;

case 8:month="SET";break;

case 9:month="OTT";break;

case 10:month="NOV";break;

case 11:month="DIC";break;

default : break;

}

return String.valueOf(giorno)+"-"+month+"-"+String.valueOf(anno);

}

}

public static void statoRis(Connection _conn){

SQL R1=new SQL(_conn);

R1.executeQuery("Select * from risultati order by distanza");

}

}

ToolBar.java

import java.awt.*;

import java.awt.event.*;

import java.sql.*;

public class ToolBar extends Dialog implements MouseListener,AdjustmentListener,WindowListener {

ButtonImage BI[];

int viid[];

String name[];

int numImage;

Scrollbar Slider;

Connection Conn;

int firstImage;

int selected;

int tipo;

public ToolBar(Frame F, Connection _Conn, int _tipo){

super(F);

tipo=_tipo;

if (tipo==0) setTitle("ToolBar anomalie");

else setTitle("ToolBar oggetti canonici");

setSize(55*6+10,110);

setLocation(100,300+tipo*110);

setResizable(false);

setVisible(true);

Conn = _Conn;

numImage = SQL.Query28(Conn,tipo);

BI = new ButtonImage[numImage];

viid = new int[numImage];

if (tipo==1) name = new String[numImage];

SQL R1 = new SQL(Conn);

R1.Query29(tipo);

R1.next();

selected = -1;

int sizex, sizey;

for (int i=0; i<numImage; i++){

sizex = R1.getInt("SizeX");

sizey = R1.getInt("SizeY");

if (sizex < 52 && sizey < 52)

BI[i] = new ButtonImage("ToolBar/"+R1.getString("FileBMP"),sizex,sizey);

else

BI[i] = new ButtonImage("ToolBar/"+R1.getString("FileBMP"),52,52);

viid[i] = R1.getInt("Viid");

if (tipo==1) name[i]=R1.getString("descrizione");

R1.next();

}

R1.close();

Slider = new Scrollbar(Scrollbar.HORIZONTAL);

Slider.setMinimum(0);

Slider.setMaximum(numImage);

Slider.setVisibleAmount(6);

Slider.setBlockIncrement(6);

firstImage=0;

add(Slider);

for (int i=0; i<numImage; i++) add(BI[i]);

Slider.addAdjustmentListener(this);

for (int i=0; i<numImage; i++)

BI[i].addMouseListener(this);

addWindowListener(this);

}

public void paint(Graphics g){

for (int i=0; i<numImage; i++) {

if (i<firstImage || i>firstImage+5) {

BI[i].setVisible(false);

}

else BI[i].setVisible(true);

}

for (int i=0; i<6; i++){

if (i+firstImage <= numImage-1){

BI[i+firstImage].setSize(55,55);

BI[i+firstImage].setLocation(i*55+5,25);

BI[i+firstImage].repaint();

}

}

Slider.setSize(55*6,18);

Slider.setLocation(5,85);

}

public void adjustmentValueChanged(AdjustmentEvent e){

firstImage=Slider.getValue();

repaint();

}

public void mousePressed(MouseEvent e){}

public void mouseReleased(MouseEvent e){}

public void mouseEntered(MouseEvent e){

if (tipo==1)

for (int i=0; i<numImage; i++)

if (e.getComponent()==BI[i]) setTitle("ToolBar oggetti canonici - "+name[i]);

}

public void mouseExited(MouseEvent e){

if (tipo==1) setTitle("ToolBar oggetti canonici");

}

public void mouseClicked(MouseEvent e){

for(int i=0; i<numImage; i++)

if (e.getComponent()==BI[i]) selected = i;

}

public void windowClosed(WindowEvent w){}

public void windowClosing(WindowEvent w) {setVisible(false);}

public void windowOpened(WindowEvent w){}

public void windowIconified(WindowEvent w){}

public void windowDeiconified(WindowEvent w){}

public void windowActivated(WindowEvent w){}

public void windowDeactivated(WindowEvent w){}

}

Home