We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Extending traer.physics library
Page Index Toggle Pages: 1
Extending traer.physics library (Read 3091 times)
Extending traer.physics library
Nov 26th, 2008, 11:17am
 
Currently i'm trying to extend the physics library for a social network visualisation:

class Network extends ParticleSystem
{
 addPerson(..)
}
class Person extends Particle

The Function addPerson() adds the person to the ArrayList particle of the ParticleSystem. If i try:

particles.add((Particle) p);

i get the Error: "The field ParticleSystem.particles is not visible."

if i add "ArrayList particles = new ArrayList();" to the Network-Class, i suppose a second particles-ArrayList will be created.

How is it possible to access the particles-ArrayList of the superclass?

Unfortunately i have no source files of the library - so i can't declare it public.
Re: Extending traer.physics library
Reply #1 - Dec 3rd, 2008, 11:19pm
 
jewe wrote on Nov 26th, 2008, 11:17am:
Currently i'm trying to extend the physics library for a social network visualisation:

class Network extends ParticleSystem
{
 addPerson(..)
}
class Person extends Particle

The Function addPerson() adds the person to the ArrayList particle of the ParticleSystem. If i try:

particles.add((Particle) p);

i get the Error: "The field ParticleSystem.particles is not visible."

if i add "ArrayList particles = new ArrayList();" to the Network-Class, i suppose a second particles-ArrayList will be created.

How is it possible to access the particles-ArrayList of the superclass

Unfortunately i have no source files of the library - so i can't declare it public.



Not quite sure what you're shooting for here -- but it sounds like you're trying to encapsulate your subclassed entity inside the particle system which (I believe) is the wrong way to go about it unless I'm missing something strategic about your effort.

Why not just create a Person class that upon instantiation has a particle created for it That way the particle system knows about it and you don't have to fiddle with any of the under the hood mechanics.

I've got a pretty ugly example of force-directed tree graphing at http://www.remix.net/static/MassiveForce/ that crudely implements what I mean. Nodes get assigned particles, particlesystem is basically left to do it's thing.

Also, if you want the source you might be interested in JAD. It works like a charm. http://www.kpdus.com/jad.html
Re: Extending traer.physics library
Reply #2 - Dec 4th, 2008, 12:05am
 
Thanks a lot for your reply! I thought it would be more flexible and clean to extend the particle-class especially because of the general forces between all particles.
But i suppose you are right - your example of the force-directed tree shows a functional implementation.
I will give it a try... Thanks a lot!
Re: Extending traer.physics library
Reply #3 - Jan 2nd, 2009, 8:07am
 
synthesizer_patel wrote on Dec 3rd, 2008, 11:19pm:
I've got a pretty ugly example of force-directed tree graphing at http://www.remix.net/static/MassiveForce/ that crudely implements what I mean. Nodes get assigned particles, particlesystem is basically left to do it's thing.


I like your "ugly" example - just curious what is gained by making the original example by banksean use the traer physiscs engine I am kind of new to processing but had been working with banksean's example but recently have been considering a physics engine...i wanted to use this library for its ready built system to create attractive and repellent forces, spawn particles and kill them etc etc...the force directed layout had alot of things going on that I didn't want to, nor did I know how to, ammend. so, are there any performance gained in this switch do you even need the bank sean version If Nodes are particles, and Springs are edges, why do you need those classes

thanks!
Project finished
Reply #4 - Jun 18th, 2009, 2:08am
 
Thanks for your help. I finished the software.
See these links for the results:


...
Page Index Toggle Pages: 1