Points accumulating at the top
in
Programming Questions
•
7 months ago
I am using Processing core libraries for java to plot points given in a text file. The number of points usually range from 200-300. The issue is the points are plotted at the top of the sketch, instead of getting plotted at the top.
which looks like thisThe sketch is
private ArrayList<PointXY> pointsList;
//private File pointsFile; BoundingBox box;
TraceGroup tg;
public void setup(){ size(50, 50);
strokeWeight(3);
//noSmooth(); background(255);
if (frame != null) { frame.setResizable(true); }
selectInput("Select a file to Process", "fileSelected");
}
public void draw(){
if(tg != null)
{
for(Trace t : tg.getTraceList())
//loop iterates though all the points
for(PointXY p : t.getTracePoints())
{
System.out.println(p.getX() + " " + p.getY());
point(p.getX(), getY());
}
}
}
//callback- filechooser
public void fileSelected(File file)
{ pointsList = PenFileReader.readPointsFromFile(file);
System.out.print(pointsList.size());
//resizeFrameForCharDisplay() takes care of resizing the sketch window
//according to the points read. uses bounding bounding box of the points
//to resize the window.
tg = resizeFrameForCharDisplay(pointsList);
}
The println statement produces the following output:
552.0 221.0
552.0 209.0
552.0 199.0
552.0 187.0
552.0 171.0
552.0 162.0
555.0 156.0
555.0 146.0
555.0 143.0
555.0 137.0
555.0 134.0
555.0 134.0
558.0 134.0
558.0 131.0
561.0 131.0
564.0 131.0
570.0 137.0
573.0 146.0
579.0 168.0
582.0 190.0
582.0 215.0
582.0 249.0
582.0 287.0
582.0 330.0
582.0 371.0
582.0 414.0
582.0 452.0
582.0 489.0
585.0 517.0
588.0 542.0
588.0 561.0
588.0 576.0
588.0 586.0
588.0 595.0
What I know for sure is the resizing of the sketch window takes place correctly and the points are read correctly.
Note: I am using eclipse to write the sketch, not PDE
1