|
|
Re: Drawing a Tree
|
Posted: May 15, 2006 11:48 AM
|
|
public void drawTree(Graphics2D g){ for (int i=A_SIZE-1;i>=0;i--){//Loops through array that contains an object with the coordinates of each leave in the tree Rectangle r = new Rectangle(coordinates.getX()*50,coordinates.getY()*50,55,20); g.draw(r); g.drawString((String)coordinates.getPos().element(), r.x + 4, r.y + 15); g.drawLine( r.x-10, r.y+50, r.x + r.width/2 , r.y+20); g.drawLine( r.x+70, r.y+50, r.x + r.width/2, r.y+20); } }
Thank you for your help, this is is what I managed to do so far, I used rectangles for my nodes, but I find it difficult to connect the lines to the rectangles, cuz it seems that they have to get shorter when there is more nodes. Also I dont want lines coming from external nodes. I know this is basic stuff but I'm through thinking, have too much else on my mind. I appreciate your help (PS: The coordinates I use for the lines is just temporary, I'm still trying to figure out how I'd write it so that it adjust as the nodes get more)
--shiz
|
|