import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.io.*;
public class pro extends JFrame{
double c[][]=new double[6][6];
double y1[][]=new double[6][6];
double y2[][]=new double[6][6];
int s1,s2;
public static void main(String[] args){
pro test = new pro();
test.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}
});
test.setBounds( 0, 0, 700, 700);
test.setVisible(true);
}
pro(){
try{
BufferedReader br =
new BufferedReader(new FileReader("tax.txt"));
String str;
String x[]=new String[5];
for(int i=0; i<25; i++){
str = br.readLine();
x=str.split(",");
s1=Integer.valueOf(x[0]);
s2=Integer.valueOf(x[1]);
c[s1][s2]=Double.valueOf(x[2]);
y1[s1][s2]=Double.valueOf(x[3]);
y2[s1][s2]=Double.valueOf(x[4]);
}
br.close();
}
catch(IOException e){System.out.println("入出力エラーです。");}
}
public void paint(Graphics g){
double x,y,z;
int px,py;
int px1,px2,py1,py2;
Graphics2D g2 = (Graphics2D)g;
BufferedImage readImage = null;
if (readImage == null){
readImage = new BufferedImage(getWidth(), getHeight(),
BufferedImage.TYPE_INT_BGR);
}
Graphics2D off = readImage.createGraphics();
off.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
BasicStroke wideStroke = new BasicStroke(2.0f);
off.setStroke(wideStroke);
off.setPaint(Color.red);
x=0;
y=0;
z=500;
px=pointx(x,y,z);
py=pointy(x,y,z);
off.drawLine(100,600,100+px,600-py);
x=500;
y=0;
z=0;
px=pointx(x,y,z);
py=pointy(x,y,z);
off.drawLine(100,600,100+px,600-py);
x=0;
y=500;
z=0;
px=pointx(x,y,z);
py=pointy(x,y,z);
off.drawLine(100,600,100+px,600-py);
g.setColor(Color.blue);
for (s2=1;s2<6;s2++){
for (s1=1;s1<5;s1++){
x=1000*y1[s1][s2];
y=1000*y2[s1][s2];
z=1000*c[s1][s2];
px1=pointx(x,y,z);
py1=pointy(x,y,z);
x=1000*y1[s1+1][s2];
y=1000*y2[s1+1][s2];
z=1000*c[s1+1][s2];
px2=pointx(x,y,z);
py2=pointy(x,y,z);
off.drawLine(100+px1,600-py1,100+px2,600-py2);
}
}
if (readImage != null){g2.drawImage(readImage,0,0, this);}
try {
boolean result =
ImageIO.write(readImage, "jpg", new File("sam.jpg"));
} catch (Exception e) {
e.printStackTrace();
}
}
public static int pointy(double x,double y,double z){
int p2;
double theta,phi;
theta=-0.222222*Math.PI;
phi=0.333333*Math.PI;
p2=(int)(-Math.cos(theta)*Math.cos(phi)*x-Math.sin(theta)*Math.cos(phi)*y+Math.sin(phi)*z);
return p2;
}
public static int pointx(double x,double y,double z){
int p1;
double theta;
theta=-0.222222*Math.PI;
p1=(int)(-Math.sin(theta)*x+Math.cos(theta)*y);
return p1;
}
}
最終更新:2010年11月05日 13:38