Modify

Opened 20 months ago

Last modified 14 months ago

#6955 new enhancement

(patch (unfinished)) Introducing JMapView SceneGraph

Reported by: jhuntley Owned by: jhuntley
Priority: normal Component: Core
Version: latest Keywords: scene graph objects labels
Cc: bastiK

Description (last modified by jhuntley)

I'm still working on this, but I wanted to go ahead and jump-start the topic as I'm sure others would like to contribute input.

I've placed together a working primitive scene graph for JMapView which allows you to draw objects in both world and local space. Moving and rotating parent objects will now result in child objects, markers, and labels being moved. In addition, you can also create scenes, which include groups of objects, specific to coordinates in view. Scenes are also capable of being animated if you choose to have moving objects on the map, which is useful for the application I'm using this in.

You can create objects in your scene by extending the MapObject abstract class and defining unimplemented methods. For example, the following code draws a basic rectangular structure with a label on top of the structure marking a specific location:

/**
 * @author Jason Huntley
 *
 */
public class MapFacility extends MapObject {
    final static BasicStroke stroke = new BasicStroke(2.0f);
    private FacilityModel facility = null;
    private Color color = Color.black;

    public MapFacility(FacilityModel model) {
        super();
        this.facility = model;
    }
    

    @Override
    public void initialize(MapViewInterface view) {
        this.setWorldCoordinate(facility.getLat(), facility.getLon());

        if (runway.getHeading()!=null)
            this.setRotateDegrees(facility.getHeading());

        MapLabel label=new MapLabel(facility.getLocation());

        label.setLocalCoordinates(0, -5);

        addMapObject(label);
    }

    /**
     * @return the color
     */
    public Color getColor() {
        return color;
    }

    /**
     * @param color the color to set
     */
    public void setColor(Color color) {
        this.color = color;
    }

    /*
     * Draw example object
     */
    @Override
    public void drawObject(Graphics2D g2, AffineTransform at) {
        Rectangle2D rect=new Rectangle2D.Double();

        rect.setRect(-(facility.getWidth()/2), 0, facility.getWidth(), facility.getLength());

        Shape shape2=at.createTransformedShape(rect);

        g2.draw(shape2);
    }
}

I'll try to get a working animated demo for you guys. I have to move the use-case out of our private source.

I'm attaching the code for reference.

Attachments (3)

MapScene.java (1.2 KB) - added by jhuntley 20 months ago.
MapObject.java (6.7 KB) - added by jhuntley 20 months ago.
MapLabel.java (1.3 KB) - added by jhuntley 20 months ago.

Download all attachments as: .zip

Change History (13)

Changed 20 months ago by jhuntley

Changed 20 months ago by jhuntley

Changed 20 months ago by jhuntley

comment:1 Changed 20 months ago by jhuntley

  • Description modified (diff)

comment:2 Changed 19 months ago by bastiK

I don't know of many developers that use the JMapViewer component (apart from JOSM). And those that do, probably don't follow the JOSM trac which has rather high traffic. So don't expect much feedback. :) I'm looking forward to your demo, please add a patch in a single file.

comment:3 Changed 19 months ago by bastiK

  • Summary changed from Introducing JMapView SceneGraph to [patch (beta)] Introducing JMapView SceneGraph

comment:4 Changed 18 months ago by bastiK

  • Summary changed from [patch (beta)] Introducing JMapView SceneGraph to (patch (beta)) Introducing JMapView SceneGraph

comment:5 follow-up: Changed 18 months ago by anonymous

Just wanted to provide a quick update on this as it's been a while, I'm still working on this. The scene graph work is actually complete. I've been working on the drag n drop part so you can interact with markers and objects. I'll let you know as soon as I have something demoable. More to come...

comment:6 Changed 18 months ago by bastiK

  • Summary changed from (patch (beta)) Introducing JMapView SceneGraph to [patch (unfinished)] Introducing JMapView SceneGraph

comment:7 in reply to: ↑ 5 Changed 18 months ago by jhuntley

Replying to anonymous:

Just wanted to provide a quick update on this as it's been a while, I'm still working on this. The scene graph work is actually complete. I've been working on the drag n drop part so you can interact with markers and objects. I'll let you know as soon as I have something demoable. More to come...

hmm, didn't remember login. FYI, update by me :)

Version 0, edited 18 months ago by jhuntley (next)

comment:8 Changed 18 months ago by jhuntley

Hey bastiK, do you have an email I can use to get in touch with you. Somebody recently committed a patch to the jmapviewer which broke the build. I've just updated and now some previous commits are missing.

comment:9 Changed 18 months ago by bastiK

Sure: phaaurlt at googlemail.com

comment:10 Changed 14 months ago by bastiK

  • Summary changed from [patch (unfinished)] Introducing JMapView SceneGraph to (patch (unfinished)) Introducing JMapView SceneGraph

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from jhuntley. Next status will be 'new'.
Next status will be 'needinfo'.The owner will change to jhuntley
as duplicate The resolution will be set to duplicate. Next status will be 'closed'.The specified ticket will be cross-referenced with this ticket
The owner will be changed from jhuntley to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.