 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
lastninja Guest
|
Posted: Fri Jan 21, 2005 6:25 pm Post subject: newbie question |
|
|
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
|
Posted: Sat Jan 22, 2005 9:46 am Post subject: Re: newbie question |
|
|
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
|
Posted: Sun Jan 23, 2005 12:27 am Post subject: Re: newbie question |
|
|
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
|
Posted: Sun Jan 23, 2005 1:33 am Post subject: Re: newbie question |
|
|
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 |
|
 |
|
|
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
|
|