アットウィキロゴ

練習 hh

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.white);
off.fillRect(0,0,700,700);    

off.setPaint(Color.red);

off.drawLine(100,600,100,100);    
off.drawLine(100,600,600,600);

off.setPaint(Color.blue);

s2=1;
for (s1=1;s1<5;s1++){
px1=100*s1;
px2=100*(s1+1);
py1=(int)(1000*y1[s1][s2]);
py2=(int)(1000*y1[s1+1][s2]);
off.drawLine(100+px1,600-py1,100+px2,600-py2);  
}

off.setPaint(Color.red);

s2=5;
for (s1=1;s1<5;s1++){
px1=100*s1;
px2=100*(s1+1);
py1=(int)(1000*y1[s1][s2]);
py2=(int)(1000*y1[s1+1][s2]);
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();
    }
  }






}
最終更新:2010年11月09日 17:30