Trying to create getter/setter methods with a class that creates shapes
in
Programming Questions
•
3 months ago
Hi all,
Is it possible to create get() and set() methods within a class created in Processing. Not that XML stuff for Processing that comes up on a Google search but actual getters and setters created with Processing as with Java proper or an equivalent OOP mid-level language.
As in: "float getFloat(float numX) {
return (xNum);
}"
That kind of thing.
I'm trying to create hotspots on a map which are represented by rectangles which will be made invisible but when the mouse hovers over them (so, in other words, when the map uses paths via an SVG file, which of course have classes and ids in them for reference) which makes this a harder task so I'm racking my brain trying to come up with a solution which creates the hotspots and then displays data using text superimposed on a rectangle. I'm also trying another solution of creating another map underneath the main one in which each state (the map is of the US) is its own hotspot instead of using rectangles to represent them.
A getter and setter seems like the most efficient solution at the moment but I can't try it out because Processing doesn't seem to like it (for the rectangle hotspot solution, I am trying to get the x and y positions and use those to calculate where the mouse is from there which would simulate a mousehover -- which also isn't already built into the code).
Does anyone know or can point to a tutorial/working example of how do to this. If you need code I'm using, I can provide that. I have been up since last night doing this so if anyone can help me out that would be so appreciated -- and full apologies if I've come off bad in tone here in this question.
Is it possible to create get() and set() methods within a class created in Processing. Not that XML stuff for Processing that comes up on a Google search but actual getters and setters created with Processing as with Java proper or an equivalent OOP mid-level language.
As in: "float getFloat(float numX) {
return (xNum);
}"
That kind of thing.
I'm trying to create hotspots on a map which are represented by rectangles which will be made invisible but when the mouse hovers over them (so, in other words, when the map uses paths via an SVG file, which of course have classes and ids in them for reference) which makes this a harder task so I'm racking my brain trying to come up with a solution which creates the hotspots and then displays data using text superimposed on a rectangle. I'm also trying another solution of creating another map underneath the main one in which each state (the map is of the US) is its own hotspot instead of using rectangles to represent them.
A getter and setter seems like the most efficient solution at the moment but I can't try it out because Processing doesn't seem to like it (for the rectangle hotspot solution, I am trying to get the x and y positions and use those to calculate where the mouse is from there which would simulate a mousehover -- which also isn't already built into the code).
Does anyone know or can point to a tutorial/working example of how do to this. If you need code I'm using, I can provide that. I have been up since last night doing this so if anyone can help me out that would be so appreciated -- and full apologies if I've come off bad in tone here in this question.
2