Opened 14 years ago
Last modified 11 years ago
#6955 new enhancement
Introducing JMapView SceneGraph — at Version 1
| 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.
Change History (4)
by , 14 years ago
| Attachment: | MapScene.java added |
|---|
by , 14 years ago
| Attachment: | MapObject.java added |
|---|
by , 14 years ago
| Attachment: | MapLabel.java added |
|---|
comment:1 by , 14 years ago
| Description: | modified (diff) |
|---|


