アットウィキロゴ

999;;;;

package pic;
 
import java.awt.*; 
import java.awt.Color;   
import java.awt.image.*;   
import java.awt.image.BufferedImage;   
import java.io.*;   
import javax.imageio.ImageIO;   
import java.awt.Polygon;
import java.util.HashMap;
 
class graph{
 
 
       int number_adm;
    int h=500;
    int w=500;
 int s,datanumber;
  double[] lon=new double[300000];
double[] lat=new double[300000];
 
String maxg;  
 
 
 
 
 double z;
 
 
 
void makedata(String file){
 
    int w1,h1,mx,nx;
 
 
w1=500;
h1=500;    
BufferedImage off = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_BGR);   
Graphics offsc = off.getGraphics();  
 
offsc.setColor(Color.BLUE);
offsc.fillRect(0,0,500,500);
 
double miny=999;
double maxy=0;        
double minx=999;
double maxx=0;  
for(s=1;s<datanumber;s++){
if(lon[s]>maxy)maxy=lon[s];
if(lon[s]<miny)miny=lon[s];
if(lat[s]>maxx)maxx=lat[s];
if(lat[s]<minx)minx=lat[s];
}
offsc.setColor(Color.RED);
for(s=1;s<datanumber;s++){
int y1=500-(int)((500*(lon[s]-miny))/(maxy-miny));    
int x1=(int)((500*(lat[s]-minx))/(maxx-minx));  
offsc.fillRect(x1,y1,1,1);
}
 
 
 
offsc.dispose(); 
 
try { 
ImageIO.write(off, "jpeg", new File(file)); 
} catch (IOException exception) { exception.printStackTrace(); }     
}   
 
}
 
 
package pic;
 
 
import java.io.*;
 
public class pro {
 String[] data=new String[300000];
    int s,datanumber;
double[] lon=new double[300000];
double[] lat=new double[300000];
 
int number;
 
    public static void main(String[] args) {
        pro r=new pro();
    }
    pro(){
 
 
 
        readx("geo.csv");
 
 
        for(s=1;s<datanumber;s++){
        String str=data[s+1];
 
        String[] x=str.split(",");
     x[6]=x[6].replace("\"","");
     x[7]=x[7].replace("\"","");
     lon[s]=num_double(x[6]);
     lat[s]=num_double(x[7]);
        }
 
        System.out.println(datanumber);
 
 
 
 
 
        graph sub=new graph();
        sub.datanumber=datanumber;
        sub.lon=lon;
        sub.lat=lat;
        sub.makedata("r.jpg");
 
 
 
 
    }
 
    double num_double(String str){
 
    double nx;
 
    nx=0;
 
 try{
 
    nx=Double.parseDouble(str);
 
 }catch (Exception e) {}
 
 return nx;
 
 
 
}
 
 
    void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<number+1;s++){   
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
 
 
 
 
 
 
      void readx(String file){
 
String str;
BufferedReader br;  
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));  
while((str = br.readLine()) != null) {  
s=s+1;
data[s]=str;  
}
br.close();
} catch (IOException e) {System.out.println(e);}  
 
datanumber=s;
 
} 
 
 
}
最終更新:2018年02月05日 06:28