User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 20 May 2007, 22:01   #1
Appocomaster
PA Team
 
Appocomaster's Avatar
 
Join Date: Oct 2003
Posts: 7,449
Appocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus would
Java 2D GUI Drawing

I'm going to be spending some part of the summer implementing a user inteface for my project.
I basically want some way of coding a user interface that allows for lots of dots, and lines of varing curvature (and colour) to join them together.

Has anyone got any suggestions for the best class(es) to use to do this? Java's java.awt.geom supports various curves but requires 1 or more "control points" it seems, which I'd prefer not to have.
__________________
r8-10 RaH r10.5-12 MISTU
Appocomaster is offline   Reply With Quote
Unread 20 May 2007, 22:34   #2
Phil^
Insomniac
 
Phil^'s Avatar
 
Join Date: May 2003
Posts: 3,583
Phil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

what do you mean by lots of dots and lines? Graphs or just randomly placed dots on a canvas type thing where the interface is constructed from them?
__________________
Phil^
Phil^ is offline   Reply With Quote
Unread 20 May 2007, 22:39   #3
Appocomaster
PA Team
 
Appocomaster's Avatar
 
Join Date: Oct 2003
Posts: 7,449
Appocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

the latter.
It's meant to be a game with lots of dots connected by different coloured lines, where each player takes a turn to remove a line. Often, the lines are positioned to make pretty patterns, and I thought it might be a bit more exciting to be able to make different shapes than to force the lines to be straight.
Also, there's no constraint on the number of lines between any 2 points, so...
__________________
r8-10 RaH r10.5-12 MISTU
Appocomaster is offline   Reply With Quote
Unread 20 May 2007, 22:45   #4
Phil^
Insomniac
 
Phil^'s Avatar
 
Join Date: May 2003
Posts: 3,583
Phil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

the java2d libraries are probably your best bet then ( ie the ones you already know about )
Aint going to be easy to manipulate them though, it'll require some fancy computation to determine which line is being clicked on.
I'd use a GeneralPath for each line between two dots, it sounds like it would do what you want - ie allowing multiple shapes to be appended on it as a path between points
__________________
Phil^
Phil^ is offline   Reply With Quote
Unread 20 May 2007, 22:49   #5
Appocomaster
PA Team
 
Appocomaster's Avatar
 
Join Date: Oct 2003
Posts: 7,449
Appocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

that's what I was worried of (the clicking stuff) as much as the drawing stuff.
__________________
r8-10 RaH r10.5-12 MISTU

Last edited by Appocomaster; 20 May 2007 at 23:07.
Appocomaster is offline   Reply With Quote
Unread 21 May 2007, 09:41   #6
djbass
mmm.. pills
 
djbass's Avatar
 
Join Date: Apr 2000
Location: Australia
Posts: 2,152
djbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond repute
Re: Java 2D GUI Drawing

couldn't you impose an artificial z-plane on each coloured line when boundary checking to determine the top-most line being clicked on?
__________________
CSS : the result of letting artists design something only an engineer should touch.
djbass is offline   Reply With Quote
Unread 21 May 2007, 10:03   #7
Appocomaster
PA Team
 
Appocomaster's Avatar
 
Join Date: Oct 2003
Posts: 7,449
Appocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

what? :/
__________________
r8-10 RaH r10.5-12 MISTU
Appocomaster is offline   Reply With Quote
Unread 21 May 2007, 11:52   #8
djbass
mmm.. pills
 
djbass's Avatar
 
Join Date: Apr 2000
Location: Australia
Posts: 2,152
djbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond repute
Re: Java 2D GUI Drawing

well.. assuming you would be using some form of crude collision detection (ie when point a - the mouse cursor, touches point b - any place on a line), if the mouse collides with multiple points (or lines) then assigning each line a number from say 1-20, 1 being the highest or topmost line, 20 being the lowest or bottom most line, you could then check to see which line had the smallest number to determine which should respond to being clicked on.
__________________
CSS : the result of letting artists design something only an engineer should touch.
djbass is offline   Reply With Quote
Unread 21 May 2007, 13:37   #9
Shyne
Flash in the PAN
 
Join Date: Aug 2005
Location: Birmingham, Romania
Posts: 554
Shyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud of
Re: Java 2D GUI Drawing

You need to use Java 2D Graphics.

I think then there are some methods you can use to see if a shape contains a coordinate (e.g. has been clicked on).

PM me on IRC and I'll find some java code where I have done what you want to do.
Shyne is offline   Reply With Quote
Unread 21 May 2007, 14:59   #10
Phil^
Insomniac
 
Phil^'s Avatar
 
Join Date: May 2003
Posts: 3,583
Phil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

the z-depth method is what i would use for determining which line is on top and clicked, but the problem comes in determining if a given point is part of a line - since they can be varying shapes that are not easy to apply mathematical formulae to. There is the .contains method of general path but im not sure if that triggers when you are over the line precisely, or if you are within a general rectangualar bounding box that contains the path
if its the former, it just got a whole lot easier
__________________
Phil^
Phil^ is offline   Reply With Quote
Unread 21 May 2007, 19:36   #11
Shyne
Flash in the PAN
 
Join Date: Aug 2005
Location: Birmingham, Romania
Posts: 554
Shyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud ofShyne has much to be proud of
Re: Java 2D GUI Drawing

If I remember rightly you cant use .contains for a line (because it is 1dimensional)
Shyne is offline   Reply With Quote
Unread 21 May 2007, 19:46   #12
Phil^
Insomniac
 
Phil^'s Avatar
 
Join Date: May 2003
Posts: 3,583
Phil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

The function is there for general path ( a series of lines ) so presumably it works for it. A similar function exists for Line2D
http://java.sun.com/j2se/1.3/docs/ap...e-summary.html
http://java.sun.com/j2se/1.3/docs/ap...neralPath.html
http://java.sun.com/j2se/1.3/docs/api/java/awt/geom/GeneralPath.html#contains(double,%20double)
__________________
Phil^

Last edited by Phil^; 21 May 2007 at 19:58.
Phil^ is offline   Reply With Quote
Unread 28 May 2007, 16:40   #13
Appocomaster
PA Team
 
Appocomaster's Avatar
 
Join Date: Oct 2003
Posts: 7,449
Appocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus wouldAppocomaster spreads love and joy to the forum in the same way Jesus would
Re: Java 2D GUI Drawing

Thanks for the replies. I know i've not really responded and I apoligise - I've been a bit busy and I've sort of jumped the gun, as I was just panicing about this in preliminary research. I probably won't actually start trying to implement it until a week or two after a general presentation I have to give on the 20th to classmates and lecturers on my project. I'll probably bump the thread then when I find I don't understand any of what you just said
Thanks though!
__________________
r8-10 RaH r10.5-12 MISTU
Appocomaster is offline   Reply With Quote
Unread 14 Jun 2007, 11:40   #14
[DW]Entropy
Ent|lunch
 
[DW]Entropy's Avatar
 
Join Date: Oct 2006
Location: Liverpool
Posts: 539
[DW]Entropy is a splendid one to behold[DW]Entropy is a splendid one to behold[DW]Entropy is a splendid one to behold[DW]Entropy is a splendid one to behold[DW]Entropy is a splendid one to behold[DW]Entropy is a splendid one to behold[DW]Entropy is a splendid one to behold[DW]Entropy is a splendid one to behold
Re: Java 2D GUI Drawing

If you ever decide to go 3D i used an octree structure a while back for volume rendering which implemented cartesian coordinates to map points in a cube. though this isnt what you mentioned if you ever consider it give me a holler.
__________________
[F-Crew] - You know when you've been [FC]uked

"Don't tell people how to do things, tell them what to do and let them surprise you with their results."

"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile"
[DW]Entropy is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 16:23.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018