Search in sources :

Example 1 with SourceInstancePainter

use of eu.esdihumboldt.hale.ui.views.styledmap.painter.SourceInstancePainter 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;
}
Also used : InstanceWaypoint(eu.esdihumboldt.hale.ui.views.styledmap.painter.InstanceWaypoint) Point(java.awt.Point) SourceInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.SourceInstancePainter) TransformedInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.TransformedInstancePainter)

Aggregations

InstanceWaypoint (eu.esdihumboldt.hale.ui.views.styledmap.painter.InstanceWaypoint)1 SourceInstancePainter (eu.esdihumboldt.hale.ui.views.styledmap.painter.SourceInstancePainter)1 TransformedInstancePainter (eu.esdihumboldt.hale.ui.views.styledmap.painter.TransformedInstancePainter)1 Point (java.awt.Point)1