Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GeneralPath

 
paul wheaton
Trailboss
Posts: 22072
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the story with GeneralPath? When did it first show up in the java libraries? What's it for?
I'm looking at some code and the author was using it. But I can't seem to figure out what it's story is.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API spells everything out.
regds.
- satya
 
paul wheaton
Trailboss
Posts: 22072
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the API doesn't spell it out in this case (that was the first place I looked).
In rooting around Sun for an hour, I get the feeling that this is for making your own seriously goofy shapes. Would that be a correct statement? And it looks like it works like the old LOGO programming language. Is that right?
 
Anh Nguyen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GeneralPath story : a long time ago ..... in a far computer wolrd ... far far way ........
It first shoedw up : when an emperor create a java.awt.goem force to conquer all the geom object .
Its purpose : to create a general path between all the points . This general path then can be used as a Shape obj or pattern for reuse.
Ex code :
int xPoints[] = {50,100,150,100,50,0};//list of all the points
int yPoints[] = {0,0,50,100,100,50};//which will be drawn.
GeneralPath pol = new GeneralPath();
pol.moveTo(xPoints[0],yPoints[0]);//start from the first point
for (int i = 1; i<xPoints.length; i++){>
pol.lineTo(xPoints[i],yPoints[i]);//connect all the points
}
pol.closePath();//close the last gap between the first and the last point

------------------
... No one can escape .......
Heavenly Evil Knight
 
Anh Nguyen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm .... It mees up my ex code . Sorry
Ex code :
int xPoints[] = {50,100,150,100,50,0};//list of all the points
int yPoints[] = {0,0,50,100,100,50};//which will be drawn.
GeneralPath pol = new GeneralPath();
pol.moveTo(xPoints[0],yPoints[0]);//start from the first point
for (int i = 1; i<xPoints.length; i++)>
{
pol.lineTo(xPoints[i],yPoints[i]);//connect all the points
}
pol.closePath();//close the last gap between the first and the last point

------------------
... No one can escape .......
Heavenly Evil Knight
 
Anh Nguyen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm .... hmm ......... The for loop is mess up. Anyway, u loop from i = 1 to i less than xPoints.length

------------------
... No one can escape .......
Heavenly Evil Knight
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!