diff --git a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityObject.java b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityObject.java index ffd42e34740288826c0db0507f508ea5b6c95ee3..7e3b52573dec699ae071bda0cc7a3a22fbe88d5d 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityObject.java +++ b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/CityObject.java @@ -45,7 +45,7 @@ public abstract class CityObject extends GmlElement { private static final long serialVersionUID = 651712070755024188L; private final List<Geometry> geometryList = new ArrayList<>(); - + private final List<GenericAttribute> genericAttributeList = new ArrayList<>(); /** * Recreates the CityGML4j geometry in this object. The CityGML4j geometry is * deleted from the data structure as was mapped to the city doctor data @@ -77,6 +77,7 @@ public abstract class CityObject extends GmlElement { geom.setParent(this); } + public List<Geometry> getGeometries() { return geometryList; } @@ -101,6 +102,14 @@ public abstract class CityObject extends GmlElement { return highestLodGeometry; } + public void addGenericAttribute(GenericAttribute genericAttribute) { + genericAttributeList.add(genericAttribute); + } + + public List<GenericAttribute> getGenericAttributes() { + return genericAttributeList; + } + public abstract FeatureType getFeatureType(); @Override diff --git a/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/GenericAttribute.java b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/GenericAttribute.java new file mode 100644 index 0000000000000000000000000000000000000000..6262123228db8e5638098f9fe380fe576d80f4a6 --- /dev/null +++ b/CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/GenericAttribute.java @@ -0,0 +1,72 @@ +package de.hft.stuttgart.citydoctor2.datastructure; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.citygml4j.core.model.core.AbstractGenericAttributeProperty; +import org.citygml4j.core.model.generics.*; + + +public class GenericAttribute { + + private static final Logger logger = LogManager.getLogger(GenericAttribute.class); + + private final AbstractGenericAttributeProperty original; + + private String type; + private String name; + private String value; + + public GenericAttribute(AbstractGenericAttributeProperty attributeProperty) { + original = attributeProperty; + if (attributeProperty.getObject() == null) { + logger.warn("GenericAttribute {} is null", attributeProperty); + return; + } + name = attributeProperty.getObject().getName(); + + if (attributeProperty.getObject() instanceof StringAttribute sa) { + type = "StringAttribute"; + value = sa.getValue(); + } else if (attributeProperty.getObject() instanceof IntAttribute ia) { + type = "IntAttribute"; + value = ia.getValue().toString(); + } else if (attributeProperty.getObject() instanceof DoubleAttribute da) { + type = "DoubleAttribute"; + value = da.getValue().toString(); + } else if (attributeProperty.getObject() instanceof DateAttribute date) { + type = "DateAttribute"; + value = date.getValue().toString(); + } else if (attributeProperty.getObject() instanceof UriAttribute ua) { + type = "UriAttribute"; + value = ua.getValue(); + } else if (attributeProperty.getObject() instanceof MeasureAttribute ma) { + type = "MeasureAttribute"; + value = ma.getValue().toString(); + } else if (attributeProperty.getObject() instanceof CodeAttribute ca) { + type = "CodeAttribute"; + value = ca.getValue().toString(); + } else { + logger.warn("GenericAttribute {} is of unknown type {}", attributeProperty, attributeProperty.getObject()); + value = attributeProperty.getObject().getValue().toString(); + type = "Unknown type"; + } + + } + + public AbstractGenericAttributeProperty getOriginal() { + return original; + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.format("%s: [ %s = %s ]", type, name, value); + } +} diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/tree/GenericAttributeNode.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/tree/GenericAttributeNode.java new file mode 100644 index 0000000000000000000000000000000000000000..9f71ead88b5fadec34f32762b4a4926209e023b7 --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/tree/GenericAttributeNode.java @@ -0,0 +1,27 @@ +package de.hft.stuttgart.citydoctor2.gui.tree; + +import de.hft.stuttgart.citydoctor2.datastructure.GenericAttribute; +import de.hft.stuttgart.citydoctor2.gui.Renderer; + +public class GenericAttributeNode extends Renderable { + + private final GenericAttribute gen; + + + public GenericAttributeNode(GenericAttribute gen) { + this.gen = gen; + } + + @Override + public void refreshTextColor() { + } + + @Override + public String getText() { + return gen.toString(); + } + + @Override + public void visit(Renderer renderer) { + } +}