Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
morganjenks
morganjenks's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
an ArrayList of ArrayLists of a made up class?
[2 Replies]
26-Feb-2012 04:23 PM
Forum:
Programming Questions
First post on the forum. Howdy everybody, and thanks in advance.
this is the beginnings of a painting program which allows for animation/effecting of each discreet stroke made.
the way I'm trying to access the position of my Node class isn't working.
Can somebody point me to how the fields for the elements of an ArrayList inside an ArrayList are accessed?
/// seperate lines
// I want each line to be a new linked list of PVectors
ArrayList<ArrayList> strokes = new ArrayList<ArrayList>();
ArrayList<Node> writingList = new ArrayList<Node>();
PVector tMousePos;//catch our mouse position before we make nodes.
boolean writing = false;//switches when painting
void setup()
{
size(400, 400);
background(255);
smooth();
}
void draw()
{
tMousePos = new PVector(mouseX, mouseY);
if(writing)
{
Node nuNode = new Node(tMousePos);
writingList.add(nuNode);
}
if(strokes.size()>0)
{
display();
}
print(strokes.size() + " ");
}//////////////////////end draw;
///////////////////////////////////////////////////////////////////
void mouseReleased()
{
writing = false;
strokes.add(writingList);//add the written list to the ArrayList!
}
void mouseClicked()
{
writing = true;
//set the linkedList to be drawn
ArrayList<Node> writingList = new ArrayList<Node>();
}
////
//
//
////
/*
when you click, add a linked list to the end of strokes, and start adding to the end, the mouse position
*/
class Node{
//fields
PVector location;
// some other stuff for the kind of stuff that the different paints do...
/////////////////////////////////////////////constructors
Node(PVector loc)
{
location = loc;
}
/////////////////////////////////////////////accessors
PVector getLoc()
{
return location;
}
/////////////////////////////////////////////mutators
void setLoc(int x, int y)
{
location = new PVector(x, y);
}
}//////////end node;
void display()
{
for(int a = 0; a < strokes.size(); a++)
{
for(int b = 0; b < strokes.get(a).size(); b++)
{
stroke(0);
PVector loc_o_Node = strokes.get(a).get(b).getLoc();///////////////////////// PROCESSING
/////////////////////TELLS ME THAT getLoc() DOESN'T EXIST?
point(loc_o_Node.x, loc_o_Node.y);
}
}
}
«Prev
Next »
Moderate user : morganjenks
Forum