AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

newbie question

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
lastninja
Guest





PostPosted: Fri Jan 21, 2005 6:25 pm    Post subject: newbie question Reply with quote



Hi
Im a beginner with Java. In few words, I need to build a GUI with 2D
graphics. The user must create one or more rectangules just inserting 4
points for each figure. Aften then, info about these figures should be
written in a XML file. Can someone suggest me something useful to do
this (hints, tools, urls, documents, guides etc)?

thanks

GG




Back to top
Roland
Guest





PostPosted: Sat Jan 22, 2005 9:46 am    Post subject: Re: newbie question Reply with quote



On 21-1-2005 19:25, lastninja wrote:

Quote:
Hi
Im a beginner with Java. In few words, I need to build a GUI with 2D
graphics. The user must create one or more rectangules just inserting 4
points for each figure. Aften then, info about these figures should be
written in a XML file. Can someone suggest me something useful to do
this (hints, tools, urls, documents, guides etc)?

thanks

GG


Java tutorial:
<http://java.sun.com/docs/books/tutorial/>

In particlar the 2D trail:
<http://java.sun.com/docs/books/tutorial/2d/index.html>

The Java 2D guide:
<http://java.sun.com/j2se/1.5.0/docs/guide/2d/index.html>

--
Regards,

Roland de Ruiter
___ ___
/__/ w_/ /__/
/ /_/ /

Back to top
Fahd Shariff
Guest





PostPosted: Sun Jan 23, 2005 12:27 am    Post subject: Re: newbie question Reply with quote



I wrote something similar to this. Well, simply put all you need to do
is listen for mouse clicks on the panel and connect them using Graphics
methods after the fourth click. Then repaint the panel.

(But obviously the four clicks might not form a rectangle. They might
form any old polygon. If you strictly want a rectangle you might have
to check the validity of the points.)

You will need to have a data model to store everything. So you need a
rectangle class and a Collection in which you can add/remove
rectangles. After the fourth click, create a rectangle object and
store it in the collection. Then when you want to save the diagram you
can loop through the collection and generate the appropriate XML for
each rectangle.

Your XML for a diagram with rectangles might look like:

<diagram>
<rectangle x="10" y="10" width="100" height="50" />
<rectangle x="10" y="100" width="50" height="100" />
</diagram>

Hope this helps,

--
Fahd Shariff
http://www.fahdshariff.cjb.net
"Let the code do the talking... "

Back to top
Andrew Thompson
Guest





PostPosted: Sun Jan 23, 2005 1:33 am    Post subject: Re: newbie question Reply with quote

On 22 Jan 2005 16:27:19 -0800, Fahd Shariff wrote:

Quote:
(But obviously the four clicks might not form a rectangle. They might
form any old polygon. If you strictly want a rectangle you might have
to check the validity of the points.)

A common strategy is to lock down either the X, or Y as needed.
If you offer 'resize' bars afterwards, it is very easy and
intuitive for the end user. They simply 'click' the box
approximately where it is used, then resize/drag to need.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.