Immagine(elimino dei dati perché di troppo):
codice:
public class Immagine {
//private...
public Immagine(String filename){
try...
this.firstImage = ImageIO.read(new File(filename));
this.image = firstImage;
}
void initPolygon(){
A = new Point[4];
A[0] = new Point(222,250);
A[1] = new Point(272,274);
A[2] = new Point(222,300);
A[3] = new Point(172,275);
P = new Point[4];
}
Image getImage(){
returnimage;
}
BufferedImage getFirstImage(){
returnfirstImage;
}
void setImage(BufferedImage image) {
this.image = image;
}
void flush(){
image.flush();
}
public Polygon getPolygon() {
return p;
}
publicvoid setPolygonXYZ(doubleX, doubleY, doubleZ) {
P[0] = new Point((int)(A[0].x-LX*X+Y*LX), (int)(A[0].y+X*LY/2+LY/2*Y-Z*LZ));
P[1] = new Point((int)(A[1].x-LX*X+Y*LX), (int)(A[1].y+X*LY/2+LY/2*Y-Z*LZ));
P[2] = new Point((int)(A[2].x-LX*X+Y*LX), (int)(A[2].y+X*LY/2+LY/2*Y-Z*LZ));
P[3] = new Point((int)(A[3].x-LX*X+Y*LX), (int)(A[3].y+X*LY/2+LY/2*Y-Z*LZ));
p = new Polygon();
p.addPoint(P[0].x,P[0].y);
p.addPoint(P[1].x,P[1].y);
p.addPoint(P[2].x,P[2].y);
p.addPoint(P[3].x,P[3].y);
}
void disegna(Color colore){
g = image.getGraphics();
g.setColor(colore);
g.fillPolygon(p);
}
public void saveImage(String filename) throws IOException {
ImageIO.write(image, "png", new File(filename));
}
}