From: Stewart T. <wsr...@ho...> - 2005-03-07 10:43:56
|
Brett, I haven't investigated the feasibility of this, and its a few years since I last dabbled in Swing, but I recall that layout managers can be nested, and though complex, GridBagLayout is a *very* powerful layout manager. Given that the stock chart itself is basically just a collection of square, numeric fields, would it not be possible to use a JTextField for each "box" and control the layout with nested layout mangers. Switching on borders to get the grid effect is relatively simple. The tokens will still have to be drawn using Java 2D, but this approach might be a lot less work overall. I agree that the map and hex grid will have to be drawn with Java 2D. The tiles can be pre-drawn images - including all of the static elements of the map. This allows the "blank" map to be generic with size and coordinate systems the varying element. "Hex grid math" is a little different to "rectangular coordinate math", but it's all been worked out before for numerous computer wargame play aids, and will need an internal, consistent coordinate system to make it easy. cheers Stewart >From: "Brett Lentz" <wak...@ea...> >Reply-To: rai...@li... >To: rai...@li... >Subject: [Rails-devel] The UI >Date: Sun, 06 Mar 2005 19:29:08 -0800 > >As I'm mucking about attempting to acquaint myself with AWT and Swing, I'm >faced with the following unpleasantness: > >My options for implementing a stock market GUI seem to end up in two >categories: > >1. I can use the existing widgets, such as JTable, JButton, etc. to cobble >together something vaguely resembling a stockmarket. The downside being >that there are inherent limitations to these widgets because they are >generic widgets and weren't specially crafted just for me. > >2. I can use something like java.awt.Graphics2D to explicitly draw every >element in the stock chart. The advantage being, I've got full control over >_everything_. The downside being that I then get to explicitly define and >implement _everything_, which seems like a rather large and daunting task. > >Seeing as how I have the sneaking suspicion that when we get to working on >the hexmap we'll need to use option #2, I'm rather reluctant to use it for >the stockmarket as well (despite the seemingly obvious need for it). > >It didn't really help matters much that when I dug into the source of >Colossus for inspiration, I saw that they're making heavy use of Graphics2D >to draw damn near everything. On the up side, the Colossus source does use >one concept that will be important for the hexmap: entrances and exits from >a hex. I think we'll be able to use their ideas, if not their code, for >dealing with route calculation. However, I think that whole discussion >needs to wait until after the stockmarket is "done" and/or somebody starts >working on implementing the map. > >So, assuming that we take the long road and use Graphics2D for the stock >market GUI, here's how I'm thinking on doing it: > >1. Use a square ( or rectangle ) for each location on the stockmarket. >2. Make the whole stockmarket reside in (extend) a JPanel, possibly within >a JTable. >2. Use the drawString() methods to render the values of each location onto >the square itself. >3. Create a circle object (chit) for representing each company's position >on the stockmarket; extends a JPanel. >4. Draw the chit (JPanel) on top of the location object. Use the layout >manager to achieve overlaying a JPanel on top of another JPanel. >5. Moving the chit ought to be a matter of moving the x,y location of the >chit and calling repaint(). > > >Now, if only actually implementing it were so simple... :-) > > >---Brett. > > > >------------------------------------------------------- >SF email is sponsored by - The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://ads.osdn.com/?ad_ide95&alloc_id396&op=click >_______________________________________________ >Rails-devel mailing list >Rai...@li... >https://lists.sourceforge.net/lists/listinfo/rails-devel |