Commit fb534a86 authored by Florian Schäfer's avatar Florian Schäfer

Highlight selected Wiki elements in the wiki layer

parent 18f24149
......@@ -44,6 +44,7 @@ public class WikiLayer extends Layer implements ListDataListener {
super("WikiLayer");
this.wikiDialog = wikiDialog;
wikiDialog.model.addListDataListener(this);
wikiDialog.list.addListSelectionListener(it -> invalidate());
}
@Override
......@@ -91,17 +92,19 @@ public class WikiLayer extends Layer implements ListDataListener {
final Point minPoint = mv.getPoint(bbox.getMin());
bbox.extend(mv.getLatLon(minPoint.getX() - 10, minPoint.getY() + 30));
final Collection<WikipediaEntry> selectedEntries = wikiDialog.list.getSelectedValuesList();
final Collection<Point> entriesInBbox = Collections.list(wikiDialog.model.elements()).parallelStream()
.filter(it -> it.coordinate != null && bbox.contains(it.coordinate))
.filter(it -> it.coordinate != null && bbox.contains(it.coordinate) && !selectedEntries.contains(it))
.map(it -> mv.getPoint(it.coordinate))
.collect(Collectors.toList());
paintWikiMarkers(g, entriesInBbox);
paintWikiMarkers(g, entriesInBbox, false);
paintWikiMarkers(g, selectedEntries.stream().map(it -> mv.getPoint(it.coordinate)).collect(Collectors.toList()), true);
}
private static void paintWikiMarkers(final Graphics2D g, final Collection<Point> points) {
private void paintWikiMarkers(final Graphics2D g, final Collection<Point> points, final boolean selected) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g.setStroke(new BasicStroke(2));
g.setStroke(new BasicStroke(selected ? 3 : 2));
for (final Point point: points) {
final Path2D path = new Path2D.Double();
path.moveTo(point.getX(), point.getY());
......@@ -110,7 +113,7 @@ public class WikiLayer extends Layer implements ListDataListener {
g.setColor(MARKER_FILL_COLOR);
g.fill(path);
g.setColor(MARKER_STROKE_COLOR);
g.setColor(selected ? Color.YELLOW : MARKER_STROKE_COLOR);
g.draw(path);
}
}
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" viewBox="0 0 810 500" width="810px" height="500px">
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.2" viewBox="0 0 810 500">
<path d="M 0,0 h 30 v 500 h -30 z M 60,0 h 90 v 500 h -90 z M 180,0 h 90 v 500 h -90 z" style="fill:#900"/>
<path d="M 300,0 h 30 v 500 h -30 z M 360,0 h 30 v 500 h -30 z M 720,0 h 30 v 500 h -30 z M 780,0 h 30 v 500 h -30 z" style="fill:#396"/>
<path d="M 420,0 h 90 v 500 h -90 z M 540,0 h 30 v 500 h -30 z M 600,0 h 90 v 500 h -90 z" style="fill:#069"/>
</svg>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="24px" height="24px" viewBox="0 0 24 24">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24px" height="24px" viewBox="0 0 24 24">
<path d="m1.5,16.5h17l4,-10h-17z" fill="#ddd" stroke="#000"/>
<g transform="translate(7, 8) skewX(-22) scale(.4)">
<path d="M10.76 3.62l-.5-1C9.44.98 9.46.9 8.62.78 8.37.74 8.25.71 8.25.6V.07l.07-.05h4.91l.13.04v.52c0 .12-.08.18-.26.18l-.35.06c-.9.07-.76.43-.16 1.62l5.68 11.62.2.05L23.5 2.15c.18-.48.15-.82-.07-1.02-.23-.2-.39-.32-.97-.34l-.48-.02a.27.27 0 0 1-.16-.06.17.17 0 0 1-.08-.15v-.5l.07-.05h5.7l.05.05v.5c0 .14-.07.2-.23.2-.74.04-1.3.2-1.65.49-.36.29-.64.69-.84 1.21 0 0-4.64 10.6-6.22 14.14-.61 1.15-1.2 1.05-1.73-.04-1.11-2.28-4.24-9.21-4.24-9.21z"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="24px" height="24px" viewBox="0 0 24 24">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24px" height="24px" viewBox="0 0 24 24">
<path d="m1.5,16.5h17l4,-10h-17z" fill="#ddd" stroke="#000"/>
<g transform="translate(7, 8) skewX(-22) scale(.4)">
<path d="M10.76 3.62l-.5-1C9.44.98 9.46.9 8.62.78 8.37.74 8.25.71 8.25.6V.07l.07-.05h4.91l.13.04v.52c0 .12-.08.18-.26.18l-.35.06c-.9.07-.76.43-.16 1.62l5.68 11.62.2.05L23.5 2.15c.18-.48.15-.82-.07-1.02-.23-.2-.39-.32-.97-.34l-.48-.02a.27.27 0 0 1-.16-.06.17.17 0 0 1-.08-.15v-.5l.07-.05h5.7l.05.05v.5c0 .14-.07.2-.23.2-.74.04-1.3.2-1.65.49-.36.29-.64.69-.84 1.21 0 0-4.64 10.6-6.22 14.14-.61 1.15-1.2 1.05-1.73-.04-1.11-2.28-4.24-9.21-4.24-9.21z"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment