Modify

Opened 9 years ago

Last modified 6 years ago

#6955 new enhancement

(patch (unfinished)) Introducing JMapView SceneGraph

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

Description (last modified by Don-vip)

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 9 years ago.
MapObject.java (6.7 KB) - added by jhuntley 9 years ago.
MapLabel.java (1.3 KB) - added by jhuntley 9 years ago.

Download all attachments as: .zip

Change History (15)

Changed 9 years ago by jhuntley

Attachment: MapScene.java added

Changed 9 years ago by jhuntley

Attachment: MapObject.java added

Changed 9 years ago by jhuntley

Attachment: MapLabel.java added

comment:1 Changed 9 years ago by jhuntley

Description: modified (diff)

comment:2 Changed 9 years 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 9 years ago by bastiK

Summary: Introducing JMapView SceneGraph[patch (beta)] Introducing JMapView SceneGraph

comment:4 Changed 9 years ago by bastiK

Summary: [patch (beta)] Introducing JMapView SceneGraph(patch (beta)) Introducing JMapView SceneGraph

comment:5 Changed 9 years 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 9 years ago by bastiK

Summary: (patch (beta)) Introducing JMapView SceneGraph[patch (unfinished)] Introducing JMapView SceneGraph

comment:7 in reply to:  5 Changed 9 years 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, browser didn't remember login. FYI, update by me :)

Last edited 9 years ago by jhuntley (previous) (diff)

comment:8 Changed 9 years 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 9 years ago by bastiK

Sure: phaaurlt at googlemail.com

comment:10 Changed 9 years ago by bastiK

Summary: [patch (unfinished)] Introducing JMapView SceneGraph(patch (unfinished)) Introducing JMapView SceneGraph

comment:11 Changed 6 years ago by Don-vip

Description: modified (diff)

comment:12 Changed 6 years ago by Don-vip

Component: CoreJMapViewer

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain jhuntley.
as The resolution will be set.
to The owner will be changed from jhuntley to the specified user.
The owner will change to jhuntley
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from jhuntley to anonymous.

Add Comment


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

 
Note: See TracTickets for help on using tickets.