ArrayList scope - getting "not visible" error
in
Programming Questions
•
1 year ago
I'm getting scope errors but my declaration of the ArrayList should be public and visible throughout my sketch, so I must be missing something. I've been struggling with ArrayLists as all the examples I have found refer to adding array objects to the ArrayList while I simply want to stuff it with float values as my program loops through a set of points. I'd like to store the numbers in pairs in a two element arraylist (for x and y points) but couldn't get that to work. I did get it to store single points and I can read out the list of individual values into pairs later, so I'm not too concerned with that.
So my question is why do I get the error ""The Field ArrayList<Float>.size is not visible"?
Here's my code:
- import controlP5.*;
- ControlP5 joyButton, rotButton, scaleButton;
- Textlabel jogLabel, rotLabel, scaleLabel;
- PrintWriter output;
- import geomerative.*;
- int g = 0;
- int allPointsLength;
- RFont font;
- String myText = "TEST TEXT";
- ArrayList<Float> allPoints = new ArrayList<Float>();
- void setup() {
- float OldX, OldY;
- size(800, 300);
- background(255);
- smooth();
- RG.init(this);
- font = new RFont("times.ttf", 75, CENTER); //change number to font size
- fill(255, 0, 0);
- stroke(0,0,0);
- translate(width/2, height/2);
- RCommand.setSegmentLength(1);//Distance between points in pixels. Determines "resolution" of font
- RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
- //GROUP TOGETHER MY FONT & TEXT.
- RGroup myGroup = font.toGroup(myText);
- myGroup = myGroup.toPolygonGroup();
- //ACCESS POINTS ON MY FONT/SHAPE OUTLINE
- RPoint[] myPoints = myGroup.getPoints();
- OldX = myPoints[0].x;
- OldY = myPoints[0].y;
- beginShape();
- for (int i=0; i<myPoints.length; i++) {
- if (OldX != myPoints[i].x) {
- if (OldY != myPoints[i].y){
- i=i+1;
- }
- }
- allPoints.add(myPoints[i].x);
- allPoints.add(myPoints[i].y);
- line(OldX, OldY, myPoints[i].x, myPoints[i].y);
- OldX = myPoints[i].x;
- OldY = myPoints[i].y;
- }
- allPointsLength = allPoints.size; //THIS IS THE OFFENDING LINE
- endShape();
- }
- void draw() {
- }
1