Modify

Opened 13 years ago

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

Download all attachments as: .zip

Change History (15)

by jhuntley, 13 years ago

Attachment: MapScene.java added

by jhuntley, 13 years ago

Attachment: MapObject.java added

by jhuntley, 13 years ago

Attachment: MapLabel.java added

comment:1 by jhuntley, 13 years ago

Description: modified (diff)

comment:2 by bastiK, 13 years ago

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 by bastiK, 13 years ago

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

comment:4 by bastiK, 12 years ago

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

comment:5 by anonymous, 12 years ago

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 by bastiK, 12 years ago

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

in reply to:  5 comment:7 by jhuntley, 12 years ago

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 12 years ago by jhuntley (previous) (diff)

comment:8 by jhuntley, 12 years ago

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 by bastiK, 12 years ago

Sure: phaaurlt at googlemail.com

comment:10 by bastiK, 12 years ago

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

comment:11 by Don-vip, 10 years ago

Description: modified (diff)

comment:12 by Don-vip, 10 years ago

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. Next status will be 'closed'.
to The owner will be changed from jhuntley to the specified user.
Next status will be 'needinfo'. The owner will be changed from jhuntley 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'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.