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

Add padding in statement panel

parent 90747dd6
......@@ -4,10 +4,14 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
class StatementPanel extends JPanel {
......@@ -26,6 +30,7 @@ class StatementPanel extends JPanel {
propertyLabel.setFont(propertyLabel.getFont().deriveFont(Font.BOLD));
propertyLabel.setForeground(Color.BLACK);
propertyLabel.setBackground(new Color(0xeaecf0));
propertyLabel.setHorizontalAlignment(JLabel.CENTER);
propertyLabel.setOpaque(true);
propertyLabel.setHorizontalAlignment(JLabel.TRAILING);
setBackground(new Color(0xeaecf0));
......@@ -34,8 +39,7 @@ class StatementPanel extends JPanel {
constraints.weightx = 0;
constraints.anchor = GridBagConstraints.CENTER;
constraints.fill = GridBagConstraints.BOTH;
constraints.ipadx = 20;
constraints.ipady = constraints.ipadx / 2;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.gridx = 0;
constraints.gridy = 0;
add(propertyLabel, constraints);
......@@ -46,6 +50,8 @@ class StatementPanel extends JPanel {
}
private synchronized void setValueNames(final String[] valueNames) {
final Border padding = BorderFactory.createEmptyBorder(5, 5, 5, 5);
constraints.insets = new Insets(0, 0, 0, 0);
constraints.gridx = 1;
constraints.weightx = 1;
for (int i = 0; i < Math.max(valueNames.length, valueLabels.size()); i++) {
......@@ -59,6 +65,7 @@ class StatementPanel extends JPanel {
currentLabel.setBackground(Color.WHITE);
currentLabel.setForeground(Color.BLACK);
currentLabel.setOpaque(true);
currentLabel.setBorder(padding);
valueLabels.add(currentLabel);
constraints.gridy = i;
add(currentLabel, constraints);
......
......@@ -73,7 +73,11 @@ public class WikiLayer extends Layer implements ListDataListener {
@Override
public Object getInfoComponent() {
return MessageFormat.format("{0} elements with coordinates, {1} elements with missing coordinates are not displayed", wikiDialog.model.getSize(), Collections.list(wikiDialog.model.elements()).stream().filter(it -> it.coordinate == null).count());
return MessageFormat.format(
"{0} elements with coordinates, {1} elements with missing coordinates are not displayed",
wikiDialog.model.getSize(),
Collections.list(wikiDialog.model.elements()).stream().filter(it -> it.coordinate == null).count()
);
}
@Override
......@@ -83,7 +87,10 @@ public class WikiLayer extends Layer implements ListDataListener {
@Override
public void mergeFrom(Layer from) {
throw new UnsupportedOperationException(MessageFormat.format("Layer of type {0} is not mergable!", WikiLayer.class.getSimpleName()));
throw new UnsupportedOperationException(MessageFormat.format(
"Layer of type {0} is not mergable!",
WikiLayer.class.getSimpleName()
));
}
@Override
......@@ -117,7 +124,9 @@ public class WikiLayer extends Layer implements ListDataListener {
.map(it -> mv.getPoint(it.coordinate))
.collect(new WikiLayerClusteringCollector(getMarkerWidth(), getMarkerHeight()));
paintWikiMarkers(g, entriesInBbox, false);
paintWikiMarkers(g, selectedEntries.stream().map(it -> Collections.singleton(mv.getPoint(it.coordinate))).collect(Collectors.toList()), true);
paintWikiMarkers(g, selectedEntries.stream()
.map(it -> Collections.singleton(mv.getPoint(it.coordinate)))
.collect(Collectors.toList()), true);
}
private static void paintWikiMarkers(final Graphics2D g, final Collection<Collection<Point>> clusters, final boolean selected) {
......@@ -129,7 +138,15 @@ public class WikiLayer extends Layer implements ListDataListener {
final Point point = cluster.iterator().next();
final Path2D path = new Path2D.Double();
path.moveTo(point.getX(), point.getY());
path.append(new Arc2D.Double(point.getX() - markerHeight / 3, point.getY() - markerHeight, markerHeight / 3 * 2, markerHeight / 3 * 2, -30, 240.0, Arc2D.OPEN), true);
path.append(new Arc2D.Double(
point.getX() - markerHeight / 3,
point.getY() - markerHeight,
markerHeight / 3 * 2,
markerHeight / 3 * 2,
-30,
240.0,
Arc2D.OPEN
), true);
path.closePath();
g.setColor(selected ? MARKER_FILL_SELECTED_COLOR : MARKER_FILL_COLOR);
......@@ -141,7 +158,12 @@ public class WikiLayer extends Layer implements ListDataListener {
OptionalDouble avgY = cluster.stream().mapToDouble(Point::getY).average();
avgX.ifPresent(x -> avgY.ifPresent(y -> {
g.setColor(selected ? MARKER_STROKE_SELECTED_COLOR : MARKER_STROKE_COLOR);
final Ellipse2D ellipse = new Ellipse2D.Double(x - getMarkerHeight() / 2, y - getMarkerHeight() / 2, getMarkerHeight(), getMarkerHeight());
final Ellipse2D ellipse = new Ellipse2D.Double(
x - getMarkerHeight() / 2,
y - getMarkerHeight() / 2,
getMarkerHeight(),
getMarkerHeight()
);
g.fill(ellipse);
g.setColor(selected ? MARKER_FILL_SELECTED_COLOR : MARKER_FILL_COLOR);
g.draw(ellipse);
......
......@@ -4,7 +4,6 @@ import java.awt.BorderLayout;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
......@@ -18,7 +17,6 @@ import javax.swing.table.AbstractTableModel;
import org.openstreetmap.josm.gui.Notification;
import org.openstreetmap.josm.tools.I18n;
import org.openstreetmap.josm.tools.Logging;
import org.openstreetmap.josm.tools.Pair;
import org.wikipedia.WikipediaPlugin;
import org.wikipedia.api.ApiQueryClient;
import org.wikipedia.api.wikidata_action.WikidataActionApiQuery;
......
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