Commit bb8385f5 authored by Matthias Betz's avatar Matthias Betz
Browse files

added parameters for color configuration files

parent 282708a8
...@@ -23,6 +23,9 @@ import java.io.IOException; ...@@ -23,6 +23,9 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.DoubleBuffer; import java.nio.DoubleBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
...@@ -71,9 +74,11 @@ import de.hft.stuttgart.citygml.viewer.datastructure.BoundingBox; ...@@ -71,9 +74,11 @@ import de.hft.stuttgart.citygml.viewer.datastructure.BoundingBox;
import de.hft.stuttgart.citygml.viewer.datastructure.Polygon; import de.hft.stuttgart.citygml.viewer.datastructure.Polygon;
import de.hft.stuttgart.citygml.viewer.math.Vector3d; import de.hft.stuttgart.citygml.viewer.math.Vector3d;
import de.hft.stuttgart.citygml.viewer.parser.CityGMLParser; import de.hft.stuttgart.citygml.viewer.parser.CityGMLParser;
import de.hft.stuttgart.citygml.viewer.parser.ColorHandler;
import de.hft.stuttgart.citygml.viewer.parser.FeatureMapper; import de.hft.stuttgart.citygml.viewer.parser.FeatureMapper;
import de.hft.stuttgart.citygml.viewer.parser.ObservedInputStream; import de.hft.stuttgart.citygml.viewer.parser.ObservedInputStream;
import de.hft.stuttgart.citygml.viewer.parser.ParserConfiguration; import de.hft.stuttgart.citygml.viewer.parser.ParserConfiguration;
import de.hft.stuttgart.citygml.viewer.parser.PolygonColorMapper;
public class CityGMLViewer { public class CityGMLViewer {
...@@ -100,6 +105,10 @@ public class CityGMLViewer { ...@@ -100,6 +105,10 @@ public class CityGMLViewer {
private static final String CITY_OBJECT_MEMBER = "cityObjectMember"; private static final String CITY_OBJECT_MEMBER = "cityObjectMember";
private static List<QName> chunkProperties = new ArrayList<>(); private static List<QName> chunkProperties = new ArrayList<>();
private static PolygonColorMapper colorMapper = null;
private static ColorHandler colorHandler = null;
private static boolean useDebug = false;
static { static {
chunkProperties.add(new QName(CityGMLConstants.CITYGML_1_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER)); chunkProperties.add(new QName(CityGMLConstants.CITYGML_1_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
chunkProperties.add(new QName(CityGMLConstants.CITYGML_2_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER)); chunkProperties.add(new QName(CityGMLConstants.CITYGML_2_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
...@@ -107,23 +116,9 @@ public class CityGMLViewer { ...@@ -107,23 +116,9 @@ public class CityGMLViewer {
} }
public static void main(String[] args) { public static void main(String[] args) {
boolean useDebug = false;
for (String arg : args) {
if (arg.equals("-debug")) {
useDebug = true;
}
}
File f = null; File f = null;
if (args != null && args.length == 1) { f = parseArguments(args, f);
f = new File(args[0]);
if (!f.exists() || f.isDirectory()) {
// no file given
f = null;
}
}
if (f == null) {
f = showFileChooserDialog();
}
try { try {
setupWindow(f, useDebug); setupWindow(f, useDebug);
} catch (Exception e) { } catch (Exception e) {
...@@ -131,7 +126,7 @@ public class CityGMLViewer { ...@@ -131,7 +126,7 @@ public class CityGMLViewer {
if (e.getCause() != null) { if (e.getCause() != null) {
message += "\nCause: " + e.getCause().getClass().getSimpleName() + ": " + e.getCause().getMessage(); message += "\nCause: " + e.getCause().getClass().getSimpleName() + ": " + e.getCause().getMessage();
} }
JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); showErrorDialog(message);
} finally { } finally {
for (PolygonViewInformation view : viewing) { for (PolygonViewInformation view : viewing) {
view.destroy(); view.destroy();
...@@ -139,6 +134,68 @@ public class CityGMLViewer { ...@@ -139,6 +134,68 @@ public class CityGMLViewer {
} }
} }
private static File parseArguments(String[] args, File f) {
Path colorsPath = null;
Path mappingPath = null;
boolean nextColorsFile = false;
boolean nextMappingsFile = false;
for (String arg : args) {
if (nextColorsFile) {
nextColorsFile = false;
String file = arg;
Path path = Paths.get(file);
if (!Files.exists(path) || !Files.isRegularFile(path)) {
showErrorDialog("Name specified for colors is not a file");
System.exit(1);
}
colorsPath = path;
} else if (nextMappingsFile) {
nextMappingsFile = false;
String file = arg;
Path path = Paths.get(file);
if (!Files.exists(path) || !Files.isRegularFile(path)) {
showErrorDialog("Name specified for mapping is not a file");
System.exit(2);
}
mappingPath = path;
} else if (arg.equals("-debug")) {
useDebug = true;
} else if (arg.equals("-colors")) {
// next argument must be a file for the color properties
nextColorsFile = true;
} else if (arg.equals("-mapping")) {
nextMappingsFile = true;
} else {
// this must be the citygml file
String file = arg;
Path path = Paths.get(file);
if (!Files.exists(path) || !Files.isRegularFile(path)) {
showErrorDialog("CityGML file specified does is not a file or does not exist");
System.exit(3);
}
}
}
// default values for missing parameters
if (colorsPath == null) {
colorsPath = Paths.get("color.properties");
}
if (mappingPath == null) {
mappingPath = Paths.get("colorMappings.csv");
}
if (f == null) {
f = showFileChooserDialog();
}
colorMapper = new PolygonColorMapper(mappingPath);
colorHandler = new ColorHandler(colorsPath);
return f;
}
public static void showErrorDialog(String msg) {
JOptionPane.showMessageDialog(null, msg, "Error", JOptionPane.ERROR_MESSAGE);
}
private static File showFileChooserDialog() { private static File showFileChooserDialog() {
File f = null; File f = null;
try (MemoryStack stack = MemoryStack.stackPush()) { try (MemoryStack stack = MemoryStack.stackPush()) {
...@@ -160,7 +217,7 @@ public class CityGMLViewer { ...@@ -160,7 +217,7 @@ public class CityGMLViewer {
int[] pixels = new int[width * height]; int[] pixels = new int[width * height];
int bindex; int bindex;
// allocate space for RBG pixels // allocate space for RBG pixels
ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3); ByteBuffer fb = MemoryUtil.memAlloc(width * height * 3);
// grab a copy of the current frame contents as RGB // grab a copy of the current frame contents as RGB
GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb);
...@@ -171,6 +228,7 @@ public class CityGMLViewer { ...@@ -171,6 +228,7 @@ public class CityGMLViewer {
bindex = i * 3; bindex = i * 3;
pixels[i] = (fb.get(bindex) << 16) + (fb.get(bindex + 1) << 8) + (fb.get(bindex + 2)); pixels[i] = (fb.get(bindex) << 16) + (fb.get(bindex + 1) << 8) + (fb.get(bindex + 2));
} }
MemoryUtil.memFree(fb);
// Allocate colored pixel to buffered Image // Allocate colored pixel to buffered Image
imageIn.setRGB(0, 0, width, height, pixels, 0, width); imageIn.setRGB(0, 0, width, height, pixels, 0, width);
...@@ -405,7 +463,7 @@ public class CityGMLViewer { ...@@ -405,7 +463,7 @@ public class CityGMLViewer {
while (reader.hasNext()) { while (reader.hasNext()) {
CityGMLChunk nextChunk = reader.nextChunk(); CityGMLChunk nextChunk = reader.nextChunk();
mappers.add(service.submit(() -> { mappers.add(service.submit(() -> {
FeatureMapper mapper = new FeatureMapper(config); FeatureMapper mapper = new FeatureMapper(config, colorMapper, colorHandler);
AbstractFeature feature = nextChunk.build(); AbstractFeature feature = nextChunk.build();
feature.accept(mapper); feature.accept(mapper);
return mapper; return mapper;
......
...@@ -2,6 +2,7 @@ package de.hft.stuttgart.citygml.viewer.parser; ...@@ -2,6 +2,7 @@ package de.hft.stuttgart.citygml.viewer.parser;
import java.awt.Color; import java.awt.Color;
import java.io.FileReader; import java.io.FileReader;
import java.nio.file.Path;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -9,19 +10,19 @@ public class ColorHandler { ...@@ -9,19 +10,19 @@ public class ColorHandler {
private static final Logger logger = Logger.getLogger(ColorHandler.class.getName()); private static final Logger logger = Logger.getLogger(ColorHandler.class.getName());
private static Color groundColor = new Color(0.9411765f, 0.9019608f, 0.54901963f); private Color groundColor = new Color(0.9411765f, 0.9019608f, 0.54901963f);
private static Color roofColor = Color.RED; private Color roofColor = Color.RED;
private static Color doorColor = Color.ORANGE; private Color doorColor = Color.ORANGE;
private static Color windowColor = new Color(0.0f, 0.5019608f, 0.5019608f); private Color windowColor = new Color(0.0f, 0.5019608f, 0.5019608f);
private static Color wallColor = Color.WHITE; private Color wallColor = Color.WHITE;
private static Color bridgeColor = new Color(1.0f, 0.49803922f, 0.3137255f); private Color bridgeColor = new Color(1.0f, 0.49803922f, 0.3137255f);
private static Color landColor = new Color(0.64705884f, 0.16470589f, 0.16470589f); private Color landColor = new Color(0.64705884f, 0.16470589f, 0.16470589f);
private static Color transportationColor = new Color(1.0f, 1.0f, 0.0f); private Color transportationColor = new Color(1.0f, 1.0f, 0.0f);
private static Color vegetationColor = new Color(0.5647059f, 0.93333334f, 0.5647059f); private Color vegetationColor = new Color(0.5647059f, 0.93333334f, 0.5647059f);
private static Color waterColor = new Color(0.5294118f, 0.80784315f, 0.98039216f); private Color waterColor = new Color(0.5294118f, 0.80784315f, 0.98039216f);
static { public ColorHandler(Path path) {
try (FileReader reader = new FileReader("color.properties")) { try (FileReader reader = new FileReader(path.toFile())) {
Properties props = new Properties(); Properties props = new Properties();
props.load(reader); props.load(reader);
Color parsedGroundColor = parseColor(props.getProperty("groundColor")); Color parsedGroundColor = parseColor(props.getProperty("groundColor"));
...@@ -69,10 +70,7 @@ public class ColorHandler { ...@@ -69,10 +70,7 @@ public class ColorHandler {
} }
} }
private ColorHandler() { private Color parseColor(String colorString) {
}
private static Color parseColor(String colorString) {
if (colorString == null) { if (colorString == null) {
return null; return null;
} }
...@@ -88,43 +86,43 @@ public class ColorHandler { ...@@ -88,43 +86,43 @@ public class ColorHandler {
} }
} }
public static Color getGroundColor() { public Color getGroundColor() {
return groundColor; return groundColor;
} }
public static Color getRoofColor() { public Color getRoofColor() {
return roofColor; return roofColor;
} }
public static Color getDoorColor() { public Color getDoorColor() {
return doorColor; return doorColor;
} }
public static Color getWindowColor() { public Color getWindowColor() {
return windowColor; return windowColor;
} }
public static Color getWallColor() { public Color getWallColor() {
return wallColor; return wallColor;
} }
public static Color getBridgeColor() { public Color getBridgeColor() {
return bridgeColor; return bridgeColor;
} }
public static Color getLandColor() { public Color getLandColor() {
return landColor; return landColor;
} }
public static Color getTransportationColor() { public Color getTransportationColor() {
return transportationColor; return transportationColor;
} }
public static Color getVegetationColor() { public Color getVegetationColor() {
return vegetationColor; return vegetationColor;
} }
public static Color getWaterColor() { public Color getWaterColor() {
return waterColor; return waterColor;
} }
......
...@@ -79,9 +79,14 @@ public class FeatureMapper extends ObjectWalker { ...@@ -79,9 +79,14 @@ public class FeatureMapper extends ObjectWalker {
private ProjCoordinate p1 = new ProjCoordinate(); private ProjCoordinate p1 = new ProjCoordinate();
private ProjCoordinate p2 = new ProjCoordinate(); private ProjCoordinate p2 = new ProjCoordinate();
public FeatureMapper(ParserConfiguration config) { private PolygonColorMapper colorMapper;
currentColor = ColorHandler.getWallColor(); private ColorHandler colorHandler;
public FeatureMapper(ParserConfiguration config, PolygonColorMapper colorMapper, ColorHandler colorHandler) {
this.colorMapper = colorMapper;
this.colorHandler = colorHandler;
this.config = config; this.config = config;
currentColor = colorHandler.getWallColor();
lod1Polygons = new ArrayList<>(); lod1Polygons = new ArrayList<>();
lod2Polygons = new ArrayList<>(); lod2Polygons = new ArrayList<>();
lod3Polygons = new ArrayList<>(); lod3Polygons = new ArrayList<>();
...@@ -95,7 +100,7 @@ public class FeatureMapper extends ObjectWalker { ...@@ -95,7 +100,7 @@ public class FeatureMapper extends ObjectWalker {
} }
Color setColor = currentColor; Color setColor = currentColor;
if (gmlPoly.getId() != null) { if (gmlPoly.getId() != null) {
Color mappedColor = PolygonColorMapper.getColorForPolygon(gmlPoly.getId()); Color mappedColor = colorMapper.getColorForPolygon(gmlPoly.getId());
if (mappedColor != null) { if (mappedColor != null) {
setColor = mappedColor; setColor = mappedColor;
} }
...@@ -140,46 +145,46 @@ public class FeatureMapper extends ObjectWalker { ...@@ -140,46 +145,46 @@ public class FeatureMapper extends ObjectWalker {
} }
currentPolygons.add(viewerPoly); currentPolygons.add(viewerPoly);
} }
@Override @Override
public void visit(OtherConstruction otherConstruction) { public void visit(OtherConstruction otherConstruction) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(otherConstruction); super.visit(otherConstruction);
} }
@Override @Override
public void visit(CityFurniture cityFurniture) { public void visit(CityFurniture cityFurniture) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(cityFurniture); super.visit(cityFurniture);
} }
@Override @Override
public void visit(CityObjectGroup cityObjectGroup) { public void visit(CityObjectGroup cityObjectGroup) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(cityObjectGroup); super.visit(cityObjectGroup);
} }
@Override @Override
public void visit(GenericLogicalSpace genericLogicalSpace) { public void visit(GenericLogicalSpace genericLogicalSpace) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(genericLogicalSpace); super.visit(genericLogicalSpace);
} }
@Override @Override
public void visit(GenericOccupiedSpace genericOccupiedSpace) { public void visit(GenericOccupiedSpace genericOccupiedSpace) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(genericOccupiedSpace); super.visit(genericOccupiedSpace);
} }
@Override @Override
public void visit(GenericThematicSurface genericThematicSurface) { public void visit(GenericThematicSurface genericThematicSurface) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(genericThematicSurface); super.visit(genericThematicSurface);
} }
@Override @Override
public void visit(GenericUnoccupiedSpace genericUnoccupiedSpace) { public void visit(GenericUnoccupiedSpace genericUnoccupiedSpace) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(genericUnoccupiedSpace); super.visit(genericUnoccupiedSpace);
} }
...@@ -270,10 +275,10 @@ public class FeatureMapper extends ObjectWalker { ...@@ -270,10 +275,10 @@ public class FeatureMapper extends ObjectWalker {
parseAbstractGeometry(ab.getLod2Solid(), lod2Polygons); parseAbstractGeometry(ab.getLod2Solid(), lod2Polygons);
parseAbstractGeometry(ab.getLod3Solid(), lod3Polygons); parseAbstractGeometry(ab.getLod3Solid(), lod3Polygons);
} }
@Override @Override
public void visit(AbstractBuilding ab) { public void visit(AbstractBuilding ab) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(ab); super.visit(ab);
DeprecatedPropertiesOfAbstractBuilding deprecatedProperties = ab.getDeprecatedProperties(); DeprecatedPropertiesOfAbstractBuilding deprecatedProperties = ab.getDeprecatedProperties();
parseAbstractGeometry(deprecatedProperties.getLod1MultiSurface(), lod1Polygons); parseAbstractGeometry(deprecatedProperties.getLod1MultiSurface(), lod1Polygons);
...@@ -303,13 +308,13 @@ public class FeatureMapper extends ObjectWalker { ...@@ -303,13 +308,13 @@ public class FeatureMapper extends ObjectWalker {
currentPolygons = lod1Polygons; currentPolygons = lod1Polygons;
break; break;
} }
currentColor = ColorHandler.getLandColor(); currentColor = colorHandler.getLandColor();
super.visit(tinRelief); super.visit(tinRelief);
} }
@Override @Override
public void visit(WaterBody wb) { public void visit(WaterBody wb) {
currentColor = ColorHandler.getWaterColor(); currentColor = colorHandler.getWaterColor();
super.visit(wb); super.visit(wb);
parseAbstractGeometry(wb.getDeprecatedProperties().getLod1MultiSurface(), lod1Polygons); parseAbstractGeometry(wb.getDeprecatedProperties().getLod1MultiSurface(), lod1Polygons);
parseAbstractGeometry(wb.getDeprecatedProperties().getLod4Solid(), lod4Polygons); parseAbstractGeometry(wb.getDeprecatedProperties().getLod4Solid(), lod4Polygons);
...@@ -317,7 +322,7 @@ public class FeatureMapper extends ObjectWalker { ...@@ -317,7 +322,7 @@ public class FeatureMapper extends ObjectWalker {
@Override @Override
public void visit(PlantCover pc) { public void visit(PlantCover pc) {
currentColor = ColorHandler.getVegetationColor(); currentColor = colorHandler.getVegetationColor();
super.visit(pc); super.visit(pc);
parseAbstractGeometry(pc.getDeprecatedProperties().getLod1MultiSurface(), lod1Polygons); parseAbstractGeometry(pc.getDeprecatedProperties().getLod1MultiSurface(), lod1Polygons);
parseMultiSolid(pc.getDeprecatedProperties().getLod1MultiSolid(), lod1Polygons); parseMultiSolid(pc.getDeprecatedProperties().getLod1MultiSolid(), lod1Polygons);
...@@ -325,7 +330,6 @@ public class FeatureMapper extends ObjectWalker { ...@@ -325,7 +330,6 @@ public class FeatureMapper extends ObjectWalker {
parseMultiSolid(pc.getDeprecatedProperties().getLod3MultiSolid(), lod3Polygons); parseMultiSolid(pc.getDeprecatedProperties().getLod3MultiSolid(), lod3Polygons);
parseMultiSolid(pc.getDeprecatedProperties().getLod4MultiSolid(), lod4Polygons); parseMultiSolid(pc.getDeprecatedProperties().getLod4MultiSolid(), lod4Polygons);
} }
private void parseMultiSolid(MultiSolidProperty ms, List<Polygon> polygons) { private void parseMultiSolid(MultiSolidProperty ms, List<Polygon> polygons) {
if (ms == null || ms.getObject() == null) { if (ms == null || ms.getObject() == null) {
...@@ -338,27 +342,27 @@ public class FeatureMapper extends ObjectWalker { ...@@ -338,27 +342,27 @@ public class FeatureMapper extends ObjectWalker {
@Override @Override
public void visit(SolitaryVegetationObject svo) { public void visit(SolitaryVegetationObject svo) {
currentColor = ColorHandler.getVegetationColor(); currentColor = colorHandler.getVegetationColor();
super.visit(svo); super.visit(svo);
parseAbstractGeometry(svo.getDeprecatedProperties().getLod1Geometry(), lod1Polygons); parseAbstractGeometry(svo.getDeprecatedProperties().getLod1Geometry(), lod1Polygons);
parseAbstractGeometry(svo.getDeprecatedProperties().getLod2Geometry(), lod2Polygons); parseAbstractGeometry(svo.getDeprecatedProperties().getLod2Geometry(), lod2Polygons);
parseAbstractGeometry(svo.getDeprecatedProperties().getLod3Geometry(), lod3Polygons); parseAbstractGeometry(svo.getDeprecatedProperties().getLod3Geometry(), lod3Polygons);
parseAbstractGeometry(svo.getDeprecatedProperties().getLod4Geometry(), lod4Polygons); parseAbstractGeometry(svo.getDeprecatedProperties().getLod4Geometry(), lod4Polygons);
} }
@Override @Override
public void visit(GroundSurface groundSurface) { public void visit(GroundSurface groundSurface) {
Color oldColor = currentColor; Color oldColor = currentColor;
currentColor = ColorHandler.getGroundColor(); currentColor = colorHandler.getGroundColor();
// process window // process window
super.visit(groundSurface); super.visit(groundSurface);
currentColor = oldColor; currentColor = oldColor;
} }
@Override @Override
public void visit(RoofSurface roofSurface) { public void visit(RoofSurface roofSurface) {
Color oldColor = currentColor; Color oldColor = currentColor;
currentColor = ColorHandler.getRoofColor(); currentColor = colorHandler.getRoofColor();
// process window // process window
super.visit(roofSurface); super.visit(roofSurface);
currentColor = oldColor; currentColor = oldColor;
...@@ -377,13 +381,13 @@ public class FeatureMapper extends ObjectWalker { ...@@ -377,13 +381,13 @@ public class FeatureMapper extends ObjectWalker {
@Override @Override
public void visit(LandUse landUse) { public void visit(LandUse landUse) {
currentColor = ColorHandler.getLandColor(); currentColor = colorHandler.getLandColor();
super.visit(landUse); super.visit(landUse);
} }
@Override @Override
public void visit(AbstractTransportationSpace ats) { public void visit(AbstractTransportationSpace ats) {
currentColor = ColorHandler.getTransportationColor(); currentColor = colorHandler.getTransportationColor();
DeprecatedPropertiesOfAbstractTransportationSpace deprecatedProperties = ats.getDeprecatedProperties(); DeprecatedPropertiesOfAbstractTransportationSpace deprecatedProperties = ats.getDeprecatedProperties();
parseAbstractGeometry(ats.getLod1Solid(), lod1Polygons); parseAbstractGeometry(ats.getLod1Solid(), lod1Polygons);
parseAbstractGeometry(ats.getLod2Solid(), lod1Polygons); parseAbstractGeometry(ats.getLod2Solid(), lod1Polygons);
...@@ -394,25 +398,24 @@ public class FeatureMapper extends ObjectWalker { ...@@ -394,25 +398,24 @@ public class FeatureMapper extends ObjectWalker {
parseAbstractGeometry(ats.getLod3MultiSurface(), lod3Polygons); parseAbstractGeometry(ats.getLod3MultiSurface(), lod3Polygons);
parseAbstractGeometry(deprecatedProperties.getLod4MultiSurface(), lod4Polygons); parseAbstractGeometry(deprecatedProperties.getLod4MultiSurface(), lod4Polygons);
} }
@Override @Override
public void visit(Window window) { public void visit(Window window) {
Color oldColor = currentColor; Color oldColor = currentColor;
currentColor = ColorHandler.getWindowColor(); currentColor = colorHandler.getWindowColor();
// process window // process window
super.visit(window); super.visit(window);
currentColor = oldColor; currentColor = oldColor;
} }
@Override @Override
public void visit(Door door) { public void visit(Door door) {
Color oldColor = currentColor; Color oldColor = currentColor;
currentColor = ColorHandler.getDoorColor(); currentColor = colorHandler.getDoorColor();
super.visit(door); super.visit(door);
currentColor = oldColor; currentColor = oldColor;
} }
@Override @Override
public void visit(AbstractFillingElement ao) { public void visit(AbstractFillingElement ao) {
super.visit(ao); super.visit(ao);
...@@ -428,7 +431,7 @@ public class FeatureMapper extends ObjectWalker { ...@@ -428,7 +431,7 @@ public class FeatureMapper extends ObjectWalker {
@Override @Override
public void visit(AbstractBridge ab) { public void visit(AbstractBridge ab) {
currentColor = ColorHandler.getBridgeColor(); currentColor = colorHandler.getBridgeColor();
super.visit(ab); super.visit(ab);
parseAbstractGeometry(ab.getDeprecatedProperties().getLod1MultiSurface(), lod1Polygons); parseAbstractGeometry(ab.getDeprecatedProperties().getLod1MultiSurface(), lod1Polygons);
parseAbstractGeometry(ab.getDeprecatedProperties().getLod4MultiSurface(), lod4Polygons); parseAbstractGeometry(ab.getDeprecatedProperties().getLod4MultiSurface(), lod4Polygons);
...@@ -437,7 +440,7 @@ public class FeatureMapper extends ObjectWalker { ...@@ -437,7 +440,7 @@ public class FeatureMapper extends ObjectWalker {
@Override @Override
public void visit(BuildingInstallation bi) { public void visit(BuildingInstallation bi) {
currentColor = ColorHandler.getWallColor(); currentColor = colorHandler.getWallColor();
super.visit(bi); super.visit(bi);
} }
......
...@@ -14,15 +14,11 @@ import javax.swing.JOptionPane; ...@@ -14,15 +14,11 @@ import javax.swing.JOptionPane;
public class PolygonColorMapper { public class PolygonColorMapper {
private static final String IGNORING_ALL_POLYGON_COLOR_MAPPINGS = "\nIgnoring all polygon color mappings"; private static final String IGNORING_ALL_POLYGON_COLOR_MAPPINGS = "\nIgnoring all polygon color mappings";
private static Function<String, Color> producer; private Function<String, Color> producer;
private static Map<String, Color> colorMap; private Map<String, Color> colorMap;
static {
loadColorMap();
}
private static void loadColorMap() { private void loadColorMap(Path path) {
Path colorMappingPath = Path.of("colorMappings.csv"); Path colorMappingPath = Path.of("colorMappings.csv");
if (!Files.exists(colorMappingPath)) { if (!Files.exists(colorMappingPath)) {
producer = s -> null; producer = s -> null;
...@@ -73,11 +69,12 @@ public class PolygonColorMapper { ...@@ -73,11 +69,12 @@ public class PolygonColorMapper {
} }
public static Color getColorForPolygon(String polygonId) { public Color getColorForPolygon(String polygonId) {
return producer.apply(polygonId); return producer.apply(polygonId);
} }
private PolygonColorMapper() { public PolygonColorMapper(Path path) {
loadColorMap(path);
} }
} }
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