mirror of https://github.com/FreeCol/freecol.git
Shows all the areas in the map editor when there are overlapping areas.
This commit is contained in:
parent
06dcf01df9
commit
7870bc7bb8
|
@ -32,6 +32,7 @@ import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.Shape;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.font.TextLayout;
|
import java.awt.font.TextLayout;
|
||||||
|
@ -49,6 +50,7 @@ import java.util.EnumMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
@ -770,15 +772,45 @@ public final class MapViewer extends FreeColClientHolder {
|
||||||
|
|
||||||
final Color oldColor = nonAnimationG2d.getColor();
|
final Color oldColor = nonAnimationG2d.getColor();
|
||||||
|
|
||||||
|
final GeneralPath baseTileOutline = mapViewerScaledUtils.getBaseTileOutline();
|
||||||
paintEachTile(nonAnimationG2d, tcb, (tileG2d, tile) -> {
|
paintEachTile(nonAnimationG2d, tcb, (tileG2d, tile) -> {
|
||||||
// This can easily be optimized if slow on some systems.
|
// This can easily be optimized if slow on some systems.
|
||||||
final List<Area> areas = getGame().getAreas();
|
final List<Area> areas = getGame().getAreas().stream()
|
||||||
// TODO: Support showing multiple areas by drawing in a checkered/blinds pattern.
|
.filter(a -> a.containsTile(tile))
|
||||||
final Area area = areas.stream().filter(a -> a.containsTile(tile)).findAny().orElse(null);
|
.collect(Collectors.toList());
|
||||||
if (area != null) {
|
if (areas.isEmpty()) {
|
||||||
tileG2d.setColor(area.getColor());
|
return;
|
||||||
tileG2d.fill(mapViewerScaledUtils.getFog());
|
|
||||||
}
|
}
|
||||||
|
if (areas.size() == 1) {
|
||||||
|
final Area area = areas.get(0);
|
||||||
|
tileG2d.setColor(area.getColor());
|
||||||
|
tileG2d.fill(baseTileOutline);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Shape oldClip = tileG2d.getClip();
|
||||||
|
final Stroke oldStroke = tileG2d.getStroke();
|
||||||
|
tileG2d.setClip(baseTileOutline);
|
||||||
|
|
||||||
|
final int stepSize = lib.scaleInt(4);
|
||||||
|
tileG2d.setStroke(new BasicStroke(stepSize));
|
||||||
|
|
||||||
|
int step = 0;
|
||||||
|
int index = 0;
|
||||||
|
while (step * stepSize < tileBounds.getHeight()) {
|
||||||
|
final Area area = areas.get(index);
|
||||||
|
tileG2d.setColor(area.getColor());
|
||||||
|
tileG2d.drawLine(0, step*stepSize, tileBounds.getWidth(), step*stepSize);
|
||||||
|
|
||||||
|
step++;
|
||||||
|
index++;
|
||||||
|
if (index == areas.size()) {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tileG2d.setClip(oldClip);
|
||||||
|
tileG2d.setStroke(oldStroke);
|
||||||
});
|
});
|
||||||
nonAnimationG2d.setColor(oldColor);
|
nonAnimationG2d.setColor(oldColor);
|
||||||
nonAnimationG2d.setComposite(oldComposite);
|
nonAnimationG2d.setComposite(oldComposite);
|
||||||
|
|
|
@ -115,6 +115,10 @@ final class MapViewerScaledUtils {
|
||||||
return fog;
|
return fog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeneralPath getBaseTileOutline() {
|
||||||
|
return fog;
|
||||||
|
}
|
||||||
|
|
||||||
Stroke getGridStroke() {
|
Stroke getGridStroke() {
|
||||||
return gridStroke;
|
return gridStroke;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue