List of usage examples for java.awt.geom Line2D.Float Line2D.Float
public Float(float x1, float y1, float x2, float y2)
From source file:graticules2wld.Main.java
/** * Abstracts the source CSV file format, and exposes the data as two ArrayList<Graticule> for the rest of the program. * @param csvReader// ww w. j a v a 2 s . c o m * @param lonGrats * @param latGrats * @throws Exception */ private static void readCSV(BufferedReader csvReader, ArrayList<Graticule> lonGrats, ArrayList<Graticule> latGrats) throws Exception { // chew the header line and check it is what we expect String line = csvReader.readLine(); if (!line.equals("lonlat,dir,value,x1,y1,x2,y2")) System.exit(1); // read each line of the CSV file and build our internal data structures for (line = csvReader.readLine(); line != null; line = csvReader.readLine()) { String[] l = line.split(","); if (l.length != 7) throw new Exception( "Source file has bad format. Each line should have 7 columns, but we found a line with " + l.length + "columns."); LATLON latlon; if (l[0].equals("lon")) latlon = LATLON.LON; else if (l[0].equals("lat")) latlon = LATLON.LAT; else throw new Exception("Either 'lat' or 'lon' expected, found " + l[0]); DIR dir; if (l[1].equals("w")) dir = DIR.W; else if (l[1].equals("e")) dir = DIR.E; else if (l[1].equals("n")) dir = DIR.N; else if (l[1].equals("s")) dir = DIR.S; else if (l[1].equals("v")) dir = DIR.E; else if (l[1].equals("h")) dir = DIR.N; else throw new Exception("Either n,s,e,w,h,v expected, found " + l[1]); Graticule graticule = new Graticule(latlon, dir, Integer.parseInt(l[2]), new Line2D.Float(Float.parseFloat(l[3]), Float.parseFloat(l[4]), Float.parseFloat(l[5]), Float.parseFloat(l[6]))); if (latlon.equals(LATLON.LAT)) latGrats.add(graticule); else lonGrats.add(graticule); } }