use of eu.esdihumboldt.hale.ui.views.styledmap.painter.InstanceWaypoint in project hale by halestudio.
the class StyledMapUtil method zoomToSelection.
/**
* Zoom to the selected instances. Does nothing if the selection is empty or
* contains no {@link Instance}s or {@link InstanceReference}s.
*
* @param mapKit the map kit
* @param selection the selection
*/
public static void zoomToSelection(BasicMapKit mapKit, IStructuredSelection selection) {
BoundingBox bb = null;
// determine bounding box for each reference and accumulate it
for (AbstractInstancePainter painter : mapKit.getTilePainters(AbstractInstancePainter.class)) {
for (Object element : selection.toList()) {
InstanceReference ref = getReference(element);
if (ref != null) {
InstanceWaypoint wp = painter.findWaypoint(ref);
if (wp != null) {
BoundingBox wpBB = wp.getBoundingBox();
if (wpBB.checkIntegrity() && !wpBB.isEmpty()) {
if (bb == null) {
bb = new BoundingBox(wpBB);
} else {
bb.add(wpBB);
}
}
}
}
}
}
if (bb != null) {
Set<GeoPosition> positions = new HashSet<GeoPosition>();
positions.add(new GeoPosition(bb.getMinX(), bb.getMinY(), SelectableWaypoint.COMMON_EPSG));
positions.add(new GeoPosition(bb.getMaxX(), bb.getMaxY(), SelectableWaypoint.COMMON_EPSG));
mapKit.zoomToPositions(positions);
}
}
use of eu.esdihumboldt.hale.ui.views.styledmap.painter.InstanceWaypoint in project hale by halestudio.
the class InstanceMapTip method getTipText.
/**
* @see de.fhg.igd.mapviewer.tip.HoverMapTip#getTipText(int, int,
* org.jdesktop.swingx.mapviewer.PixelConverter, int)
*/
@Override
protected String getTipText(int x, int y, PixelConverter converter, int zoom) {
Point point = new Point(x, y);
String sourceName = null;
List<SourceInstancePainter> sourcePainters = mapKit.getTilePainters(SourceInstancePainter.class);
if (!sourcePainters.isEmpty()) {
InstanceWaypoint wp = sourcePainters.get(0).findWaypoint(point);
if (wp != null) {
sourceName = wp.getName();
}
}
String transformedName = null;
List<TransformedInstancePainter> transformedPainters = mapKit.getTilePainters(TransformedInstancePainter.class);
if (!transformedPainters.isEmpty()) {
InstanceWaypoint wp = transformedPainters.get(0).findWaypoint(point);
if (wp != null) {
transformedName = wp.getName();
}
}
if (sourceName != null && sourceName.equals(transformedName)) {
// if both are equal, return one name only
return sourceName;
}
if (sourceName != null) {
sourceName += " (source)";
}
if (transformedName != null) {
transformedName += " (transformed)";
}
if (sourceName != null && transformedName != null) {
return sourceName + "; " + transformedName;
} else if (sourceName != null) {
return sourceName;
} else if (transformedName != null) {
return transformedName;
}
return null;
}
Aggregations