This is an archived, read-only instance of the JaCaVi Trac. This site is no longer actively maintained. Registration and login have been disabled. Content is preserved for reference only.

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#5 closed feature (fixed)

Implement the track view

Reported by: Henrik Heimbuerger Owned by: Henrik Heimbuerger
Priority: major Milestone: MS1: First release (1.0.0)
Component: track Version: pre-1.0
Keywords: track view Cc:

Description (last modified by Henrik Heimbuerger)

Implement the view that shows a track rendered with the SWT GC.

The first version would probably use a static image as background (later to be replaced with individual images of track parts that have been rotated and placed as described by the track file) and draw simple 'cars' (dots or rectangles) on top of that.

Change History (34)

comment:1 Changed 18 years ago by Henrik Heimbuerger

Owner: changed from somebody to Stefanos Papadopoulos

comment:2 Changed 18 years ago by Henrik Heimbuerger

Status: newassigned

comment:4 Changed 18 years ago by Henrik Heimbuerger

Owner: changed from Stefanos Papadopoulos to Henrik Heimbuerger

comment:5 Changed 18 years ago by Henrik Heimbuerger

Status: assignedaccepted

comment:6 Changed 18 years ago by Henrik Heimbuerger

Milestone: MS1: First usable version

comment:7 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [67]):
[In preparation of #18 and #5] Improved in-memory data structures for storing the slot car track.

The Track class has been extended by some methods (most of which aren't implemented yet) and a new class TrackSection? has been created that is supposed to represent one section of the whole track.

Also added three section bitmaps for testing, taken from the track bitmap Fabi found somewhere. These are of course not the final images, only placeholders.

comment:8 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [68]):
[Partial fix for #5] Added early version of a real track view.

An early version of the track view has been created. While this is in fact already using seperate images for the sections and does take its track data from the in-memory data structure, how it is using the data structure has to be overhauled majorly in the future. Also, the track is currently defined inside the track view for testing purposes.

It's already possible to pan the view by holding the right mouse button and the display is also double-buffered.

comment:9 Changed 18 years ago by Henrik Heimbuerger

http://forums.sun.com/thread.jspa?messageID=10307518 might be helpful when rotation by arbitrary angles is needed.

comment:10 Changed 18 years ago by Henrik Heimbuerger

Description: modified (diff)
Summary: Create a proof-of-concept for a track view in SWTImplement the track view

comment:11 Changed 18 years ago by Henrik Heimbuerger

Keywords: swt graphics context proof-of-concept removed

comment:12 Changed 18 years ago by Henrik Heimbuerger

Rotation by arbitrary angles has been implemented (uncommitted) and does work properly. The next steps will be to read available tiles and track definitions from XML files (partly done) and to construct the track (halfway done).

comment:13 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [71]):
[Partial fix for #5] Implemented first working version of the dynamic track view.

This is the first working version of a track view that creates a track dynamically from a set of tiles.

So far, it has only been tested with 90-degree turns and there's still an abundance of unused code, hacky workarounds and undocumented sections. This will change soon.

A new bean has been introduced, the TilesetRepository? (name probably going to change). It's used to store the set of available tiles of various tilesets. The class TrackSection? might go away as well.

comment:14 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [72]):
[Partial fix for #5] Added experimental non-rectangular track.

Added a new tile, a 30-degree turn and created an experimental track using it. It's not pretty (that's mostly due to the tile images however), but it works.

comment:15 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [73]):
[Partial fix for #5] Implemented configuration file-based tile repository.

The tile repository is now completely driven by an XML-based configuration file that can be accessed as a bean.

The tile images have been moved to /tiles/<TILESET>/... and the configuration file is by default /tiles/tiles.xml (this is specified in the Spring configuration).

comment:16 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [74]):
[Partial fix for #5] Implemented reading tracks from XML files.

Tracks can now be read from XML-files. Writing them back to a back has not yet been implemented.

Track objects can now no longer be created with the default constructor and have therefore been removed from the Spring configuration.

comment:17 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [76]):
[Related to #5] Moved track-related classes into separate package.

The track and tile-related classes have been moved into the package de.jacavi.track, because 'valueobjects' didn't really fit anymore.

comment:18 Changed 18 years ago by Henrik Heimbuerger

Pending subissues for this ticket:

  • Implement TrackView as editor, not view.
  • Implement scroll bars.
  • Implement drawing cars on top of the track.
  • Consider using Java 2D directly for drawing the TrackWidget.
  • Implement zooming and rotating.
  • Allow using tiles wrong-way.

comment:19 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [77]):
[Partial fix for #5] Cleaned up Java2D integration and added simple zooming and rotation functionality.

The Java2D integration has been cleaned up by using the helper class !Graphics2DRenderer suggested by the article Java 2D imaging for the Standard Widget Toolkit. Java2D rendering now takes place in every frame, instead of just creating an SWT Image from the Java2D rendered one once and then putting it on the screen depending on the current panning position.
This has the advantage that dynamic Java2D operations are possible (which will probably be needed later anyway) and hence rotation and zooming is easily possible. At first glance, the framerate seems to have dropped noticeably. More research whether this can be improved is necessary.

This allowed a very simple proof-of-concept implementation of rotation and zooming by pressing the middle mouse button. Both do not take place at the current mouse position yet, as the user would intuitively expect it.

Additionally, a new demonstration track has been added that contains crossings.

comment:20 Changed 18 years ago by Henrik Heimbuerger

Drawing the cars has been split into a separate ticket: #25.

comment:21 in reply to:  18 Changed 18 years ago by Henrik Heimbuerger

Updated list of subissues for this ticket:

  • Implement scroll bars, proper positioning and intuitive rolling/zooming.
  • Allow using tiles wrong-way.
  • #28?

comment:22 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [94]):
[Related to ticket #5] Added a setter for the track name to the Track class and improved documentation.

A setter has been added for the track name of the Track class (so it can be changed while running in designer mode) and the used tile set is now stored and can be retrieved.

The javadoc documentation has been improved.

NOTE: The class is no longer Serializable, as the loading and saving is done manually via member methods anyway.

comment:23 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [102]):
[Partial fix for ticket #5, related to ticket #6] The current Track of the TrackWidget can now be changed and the TrackWidget is notified about modifications of the track.

The TrackWidget now expects a Track object in the constructor that will be used to initialize the Widget with. The current track can also be changed using the setTrack() method.

Additionally, the TrackWidget now automatically registers itself as a listener on the track (both when the track is assigned via the constructor as well as when it is changed using setTrack()) and will update itself when the track changes.

comment:24 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [103]):
[Partial fix for ticket #5] Replaced Graphics2DRenderer with the 'Java2D for SWT' library.

Added the Java2D for SWT library to the repository and included it in the build path.

Adjusted the TrackWidget to use the library for rendering the track. This improves performance greatly if a native acceleration library is available. (Windows and Linux (GTK/Motif) libraries are included in the repository now.)

The Graphics2DRenderer is no longer required and has been removed.

NOTE: "-Djava.library.path=${workspace_loc:JACAVI}/libs" has to be added to the "VM arguments" of the launch configuration to make use of the native acceleration libraries.

comment:25 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [128]):
[Partial fix for ticket #5] Proof-of-concept for track rendering engine reimplementation.

The rendering engine has been almost completely rewritten, making heavy use of the Java2D affine transforms. No custom calculation is necessary anymore. This is an intermediate commit that is not yet cleaned up or refactored.

Among other things, this made it possible to do hit detection. A track section is now selected when it is double-clicked.

comment:26 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [129]):
[Partial fix for ticket #5] Proof-of-concept for track rendering engine reimplementation.

(Missing part of last commit.)

The rendering engine has been almost completely rewritten, making heavy use of the Java2D affine transforms. No custom calculation is necessary anymore. This is an intermediate commit that is not yet cleaned up or refactored.

Among other things, this made it possible to do hit detection. A track section is now selected when it is double-clicked.

comment:27 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [137]):
[Partial fix for ticket #5] Refactored and cleaned up the TrackWidget.

The TrackWidget has been cleaned up, refactored from ground up and javadoc'ed.

The selection algorithm has been fixed and is more intuitive now. Selections are attempted to be preserved, modified if possible and only removed if necessary.

Selection is now done using a single click of the left mouse button and the selection can be removed by clicking anywhere outside the tiles.

The TrackDesigner had to be modified because the TrackWidget constructor no longer throws an exception (previously couldn't either, but the throws clause was still there).

comment:28 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [138]):
[Partial fix for ticket #5, related to ticket #6] Improved code for removing sections in the designer and prevented the initial tile from being removed.

The code for removing tiles in the TrackDesigner has been moved into the Track's removeSection() method.

The initial tile is now properly determined from the tiles.xml and used to initialize a new thread. It can no longer be removed (removeSection() throws an exception) and it's no longer part of the list returned by TilesetRepository.getAvailableTiles().

Additionally, a bug has been fixed that prevented the TrackWidget from rerendering after a section insertion if no selection was active.

comment:29 Changed 18 years ago by Henrik Heimbuerger

Type: enhancementnew feature

comment:30 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [144]):
[Final fix for ticket #5] Implemented an inner control system for the track view widget and added panning, rotation and zooming controls.

When hovering over the track view widget, it now shows a set of controls for controlling the viewport of the track view (scrollers for panning, buttons for rotation and zooming).

Icons have been included from the famfamfam silk set.

A new util class, GrayscalableImage, has been added for images that need to be shown coloured and in greyscale. This is necessary because converting an image to greyscale takes some time and caching this improves performance a lot.

comment:31 Changed 18 years ago by Henrik Heimbuerger

Resolution: fixed
Status: acceptedclosed

comment:32 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [163]):
[Partial fix for ticket #5] Fixed a bug that caused a NullReferenceException?.

During the mouse move handler, the timer for detecting held buttons was cancelled in some situations, even if this time had never been created because no mouse click had occured. This has now been fixed by adding a check for this special case.

comment:33 Changed 18 years ago by SVN

New commit by hheimbuerger (revision [166]):
[Partial fix for ticket #5] Fixed a bug that caused a NullReferenceException?.

Similar to [163], but this time in the mouse up handler.

comment:34 Changed 18 years ago by Henrik Heimbuerger

Component: unspecifiedtrack
Note: See TracTickets for help on using tickets.