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 )
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)
Change History (15)
by , 13 years ago
Attachment: | MapScene.java added |
---|
by , 13 years ago
Attachment: | MapObject.java added |
---|
by , 13 years ago
Attachment: | MapLabel.java added |
---|
comment:1 by , 13 years ago
Description: | modified (diff) |
---|
comment:2 by , 13 years ago
comment:3 by , 13 years ago
Summary: | Introducing JMapView SceneGraph → [patch (beta)] Introducing JMapView SceneGraph |
---|
comment:4 by , 13 years ago
Summary: | [patch (beta)] Introducing JMapView SceneGraph → (patch (beta)) Introducing JMapView SceneGraph |
---|
follow-up: 7 comment:5 by , 13 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 , 13 years ago
Summary: | (patch (beta)) Introducing JMapView SceneGraph → [patch (unfinished)] Introducing JMapView SceneGraph |
---|
comment:7 by , 13 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 :)
comment:8 by , 13 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:10 by , 13 years ago
Summary: | [patch (unfinished)] Introducing JMapView SceneGraph → (patch (unfinished)) Introducing JMapView SceneGraph |
---|
comment:11 by , 10 years ago
Description: | modified (diff) |
---|
comment:12 by , 10 years ago
Component: | Core → JMapViewer |
---|
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.