Commit d58e0286 authored by Riegel's avatar Riegel
Browse files

Docs: Add JavaDoc

parent f4d3cb7f
...@@ -93,7 +93,7 @@ public abstract class Checkable implements Serializable { ...@@ -93,7 +93,7 @@ public abstract class Checkable implements Serializable {
/** /**
* This should be called before executing a check if low memory consumption * This should be called before executing a check if low memory consumption
* method has been enabled. This should create edges and additional meta * method has been enabled. Creates edges and additional meta
* information necessary to perform checks. * information necessary to perform checks.
*/ */
public void prepareForChecking() { public void prepareForChecking() {
...@@ -101,20 +101,19 @@ public abstract class Checkable implements Serializable { ...@@ -101,20 +101,19 @@ public abstract class Checkable implements Serializable {
} }
/** /**
* This should be called after checking has been done. This should remove any * This should be called after checking has been done. Removes any
* created meta information like edges to free up additional memory space * created meta information like edges to free up memory.
*/ */
public void clearMetaInformation() { public void clearMetaInformation() {
this.accept(new ClearMetaInformationVisitor()); this.accept(new ClearMetaInformationVisitor());
} }
/** /**
* This method checks if the object or any object contained within this * Checks if the object, or any object in its datastructure, has a specific error or is not fulfilling the dependencies
* checkable has an error. It counts as an error if the result status if the * of it.
* given check is <code>DEPENDENCIES_NOT_MET<code>.
* *
* @param checkIdentifier the name of the check for which an error is searched * @param checkIdentifier the associated CheckID of this error
* @return true if an error has been found with the given check * @return true if the error was found, false otherwise
*/ */
public boolean containsError(CheckId checkIdentifier) { public boolean containsError(CheckId checkIdentifier) {
try { try {
...@@ -125,6 +124,12 @@ public abstract class Checkable implements Serializable { ...@@ -125,6 +124,12 @@ public abstract class Checkable implements Serializable {
return false; return false;
} }
/**
* Checks if this checkable has an error or is not meeting the dependencies for it.
*
* @param checkIdentifier the associated CheckID of this error
* @return true if the error was found, false otherwise
*/
public boolean hasError(CheckId checkIdentifier) { public boolean hasError(CheckId checkIdentifier) {
CheckResult cs = getCheckResult(checkIdentifier); CheckResult cs = getCheckResult(checkIdentifier);
if (cs == null) { if (cs == null) {
...@@ -156,7 +161,7 @@ public abstract class Checkable implements Serializable { ...@@ -156,7 +161,7 @@ public abstract class Checkable implements Serializable {
/** /**
* *
* @return all check results for this checkable. * @return all check results of this checkable.
*/ */
public Map<CheckId, CheckResult> getAllCheckResults() { public Map<CheckId, CheckResult> getAllCheckResults() {
return checkResults; return checkResults;
...@@ -179,9 +184,7 @@ public abstract class Checkable implements Serializable { ...@@ -179,9 +184,7 @@ public abstract class Checkable implements Serializable {
} }
/** /**
* Checks whether this checkable has an error. Dependency errors are not * Checks whether this checkable has any error, barring dependency errors.
* considered for this function. This will only check this checkable and not
* traverse any checkables contained in this instance.
* *
* @return true if it has an error, otherwise false * @return true if it has an error, otherwise false
*/ */
...@@ -218,7 +221,7 @@ public abstract class Checkable implements Serializable { ...@@ -218,7 +221,7 @@ public abstract class Checkable implements Serializable {
} }
/** /**
* Clears all errors from this checkable * Clears the checkResults list of this checkable.
*/ */
public void clearCheckResults() { public void clearCheckResults() {
setValidated(false); setValidated(false);
...@@ -226,16 +229,16 @@ public abstract class Checkable implements Serializable { ...@@ -226,16 +229,16 @@ public abstract class Checkable implements Serializable {
} }
/** /**
* Removes all errors from this instance and all contained checkables. * Clears the checkResults list of this checkable and all child objects in its datastructure.
*/ */
public final void clearAllContainedCheckResults() { public final void clearAllContainedCheckResults() {
this.accept(new ClearCheckResultsVisitor()); this.accept(new ClearCheckResultsVisitor());
} }
/** /**
* Checks if this checkable contains any error within its datastructure.
* *
* @return false if the checkable or all checkables contained in this one don't * @return true if any checkable of this datastructure contains an error, false otherwise
* have any error.
*/ */
public final boolean containsAnyError() { public final boolean containsAnyError() {
try { try {
...@@ -246,6 +249,10 @@ public abstract class Checkable implements Serializable { ...@@ -246,6 +249,10 @@ public abstract class Checkable implements Serializable {
return false; return false;
} }
/**
* Checks if this checkable has any error
* @return true if this checkable has any error, false otherwise
*/
public boolean hasAnyError() { public boolean hasAnyError() {
for (CheckResult cr : checkResults.values()) { for (CheckResult cr : checkResults.values()) {
if (cr.getResultStatus() == ResultStatus.ERROR if (cr.getResultStatus() == ResultStatus.ERROR
......
...@@ -48,20 +48,24 @@ public abstract class CityObject extends GmlElement { ...@@ -48,20 +48,24 @@ public abstract class CityObject extends GmlElement {
private final List<GenericAttribute> genericAttributeList = new ArrayList<>(); private final List<GenericAttribute> genericAttributeList = new ArrayList<>();
/** /**
* Recreates the CityGML4j geometry in this object. The CityGML4j geometry is * Recreates the CityGML4j geometry in this object's datastructure using the CityDoctor geometries.
* deleted from the data structure as was mapped to the city doctor data * The original CityGML4j geometry is deleted after parsing to reduce the memory overhead of {@link CityObject CityObjects}.
* structure. For writing CityGML files the geometry has to be restored. Also * <p/>
* maps changes to geometry back to CityGML4j * Recreation of the geometries is needed for writing validation results to the QualityADE, as well as for the export
* * of repaired geometries from CityDoctor's internal datastructure.
* @param factory needed to create CityGML4j data structures * @param factory the GeometryFactory used for creation of CityGml4j geometry objects
* @param config contains information whether a city doctor point was * @param config the configuration settings of the parser
* transformed to a different coordinate system. It would need to
* be transformed to the original coordinate system
*/ */
public final void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public final void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
this.accept(new GmlGeometryRebuilder(factory, config)); this.accept(new GmlGeometryRebuilder(factory, config));
} }
/**
* Rebuilds the CityGML4j geometries of this object.
*
* @param factory the GeometryFactory used for creation of CityGml4j geometry objects
* @param config the configuration settings of the parser
*/
public abstract void rebuildGeometries(GeometryFactory factory, ParserConfiguration config); public abstract void rebuildGeometries(GeometryFactory factory, ParserConfiguration config);
/** /**
...@@ -72,36 +76,58 @@ public abstract class CityObject extends GmlElement { ...@@ -72,36 +76,58 @@ public abstract class CityObject extends GmlElement {
public abstract AbstractCityObject getGmlObject(); public abstract AbstractCityObject getGmlObject();
/** /**
* Remove the CityGML4j geometries from this CityObject to save memory. * Remove the CityGML4j geometries from this CityObject to reduce memory overhead.
*/ */
public abstract void unsetGmlGeometries(); public abstract void unsetGmlGeometries();
/** /**
* Removes all CityGML4J geometries from this CityObject and all children in its datastructure. * Removes all CityGML4J geometries from this CityObject and child objects of its datastructure to reduce
* the memory overhead.
*/ */
public final void clearGmlGeometries() { public final void clearGmlGeometries() {
this.accept(new UnsetGeometriesVisitor()); this.accept(new UnsetGeometriesVisitor());
} }
/**
* Adds a Geometry to this object.
* @param geom the Geometry to add.
*/
public void addGeometry(Geometry geom) { public void addGeometry(Geometry geom) {
Objects.requireNonNull(geom); Objects.requireNonNull(geom);
geometryList.add(geom); geometryList.add(geom);
geom.setParent(this); geom.setParent(this);
} }
/**
* Returns all Geometries of this object.
* @return a list of the Geometries.
*/
public List<Geometry> getGeometries() { public List<Geometry> getGeometries() {
return geometryList; return geometryList;
} }
/**
* Removes a Geometry from this object.
* @param lod the {@link Lod} of the Geometry.
*/
public void removeGeometry(Lod lod) { public void removeGeometry(Lod lod) {
geometryList.removeIf(geom -> geom.getLod() == lod); geometryList.removeIf(geom -> geom.getLod() == lod);
} }
/**
* Removes a Geometry from this object.
* @param lod the {@link Lod} of the Geometry.
* @param type the {@link GeometryType} of the Geometry.
*/
public void removeGeometry(Lod lod, GeometryType type) { public void removeGeometry(Lod lod, GeometryType type) {
geometryList.removeIf(geom -> geom.getLod() == lod && geom.getType() == type); geometryList.removeIf(geom -> geom.getLod() == lod && geom.getType() == type);
} }
/**
* Returns the Geometry with the highest LOD of this object. If multiple Geometries share the highest LOD, the one
* that was added first will be returned.
* @return the Geometry with the highest LOD
*/
public Geometry getHighestLodGeometry() { public Geometry getHighestLodGeometry() {
Geometry highestLodGeometry = null; Geometry highestLodGeometry = null;
Lod highestLod = null; Lod highestLod = null;
...@@ -115,29 +141,47 @@ public abstract class CityObject extends GmlElement { ...@@ -115,29 +141,47 @@ public abstract class CityObject extends GmlElement {
} }
/** /**
* Returns the top-level CityObject (like Building or Tunnel) belonging to this object. * Returns the top-level CityObject (e.g. Building, Tunnel, Vegetation etc.) belonging to this object.
*/ */
public abstract CityObject getTopLevelCityObject(); public abstract CityObject getTopLevelCityObject();
/** /**
* Returns the display text for this object * Returns a String representation of this object for display in the featuretab TreeViews in the format of
* "[FeatureType] Gml-ID"
* @return the String representation.
*/ */
public String getDisplayText() { public String getDisplayText() {
return String.format("[%s] %s", this.getClass().getSimpleName(), this.getGmlId().toString()); return String.format("[%s] %s", this.getClass().getSimpleName(), this.getGmlId().toString());
} }
/**
* Returns the color for rendering of this object's polygons.
* @return color for this object
*/
public Color getRenderColor() { public Color getRenderColor() {
return Color.WHITE; return Color.WHITE;
} }
/**
* Adds a GenericAttribute to this object.
* @param genericAttribute the attribute to add.
*/
public void addGenericAttribute(GenericAttribute genericAttribute) { public void addGenericAttribute(GenericAttribute genericAttribute) {
genericAttributeList.add(genericAttribute); genericAttributeList.add(genericAttribute);
} }
/**
* Returns all GenericAttributes of this object.
* @return a list of the GenericAttributes.
*/
public List<GenericAttribute> getGenericAttributes() { public List<GenericAttribute> getGenericAttributes() {
return genericAttributeList; return genericAttributeList;
} }
/**
* Returns the CityGML FeatureType of this object.
* @return this object's FeatureType.
*/
public abstract FeatureType getFeatureType(); public abstract FeatureType getFeatureType();
@Override @Override
......
...@@ -28,7 +28,6 @@ import de.hft.stuttgart.citydoctor2.utils.SerializablePair; ...@@ -28,7 +28,6 @@ import de.hft.stuttgart.citydoctor2.utils.SerializablePair;
import java.io.Serial; import java.io.Serial;
import java.util.*; import java.util.*;
import java.util.Map.Entry;
/** /**
* Representation of a geometry containing the polygons and edges * Representation of a geometry containing the polygons and edges
......
package de.hft.stuttgart.citydoctor2.utils; package de.hft.stuttgart.citydoctor2.utils;
/**
* This Throwable signals that a requested CheckError was found.
*/
public class CheckErrorFound extends Throwable { public class CheckErrorFound extends Throwable {
......
...@@ -6,10 +6,18 @@ import de.hft.stuttgart.citydoctor2.check.Checkable; ...@@ -6,10 +6,18 @@ import de.hft.stuttgart.citydoctor2.check.Checkable;
import java.util.List; import java.util.List;
/**
* This Visitor collects all CheckErrors in the datastructure of a checkable.
*/
public class CheckableErrorCollector extends AbstractCheck { public class CheckableErrorCollector extends AbstractCheck {
List<CheckError> errors; List<CheckError> errors;
/**
* Collects all CheckErrors into a list
*
* @param errors the list
*/
public CheckableErrorCollector(List<CheckError> errors) { public CheckableErrorCollector(List<CheckError> errors) {
this.errors = errors; this.errors = errors;
} }
......
...@@ -7,12 +7,17 @@ import java.util.HashSet; ...@@ -7,12 +7,17 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** /**
* This AbstractCheck collects all CityObjects in the substructure of a Feature. * This Visitor collects all sub-CityObjects that are in the datastructure of a CityObject (including itself) in a Set.
*/ */
public class CityObjectCollector extends AbstractCheck { public class CityObjectCollector extends AbstractCheck {
private final Set<CityObject> objects = new HashSet<>(); private final Set<CityObject> objects = new HashSet<>();
/**
* Returns the collected CityObjects.
*
* @return A set of CityObjects
*/
public Set<CityObject> getCityObjects() { public Set<CityObject> getCityObjects() {
return objects; return objects;
} }
......
...@@ -3,6 +3,9 @@ package de.hft.stuttgart.citydoctor2.utils.visitors; ...@@ -3,6 +3,9 @@ package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck; import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.check.Checkable; import de.hft.stuttgart.citydoctor2.check.Checkable;
/**
* This Visitor removes the check results from a CityObject and the objects in its datastructure.
*/
public class ClearCheckResultsVisitor extends AbstractCheck { public class ClearCheckResultsVisitor extends AbstractCheck {
@Override @Override
......
...@@ -3,6 +3,9 @@ package de.hft.stuttgart.citydoctor2.utils.visitors; ...@@ -3,6 +3,9 @@ package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck; import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry; import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
/**
* This Visitor removes the metadata created by the {@link PrepareForCheckingVisitor} for the low-memory consumption mode.
*/
public class ClearMetaInformationVisitor extends AbstractCheck { public class ClearMetaInformationVisitor extends AbstractCheck {
@Override @Override
......
...@@ -5,8 +5,22 @@ import de.hft.stuttgart.citydoctor2.check.Checkable; ...@@ -5,8 +5,22 @@ import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.utils.CheckErrorFound; import de.hft.stuttgart.citydoctor2.utils.CheckErrorFound;
import de.hft.stuttgart.citydoctor2.utils.ThrowUtils; import de.hft.stuttgart.citydoctor2.utils.ThrowUtils;
/**
* This visitor checks if a checkable contains any error in its datastructure.
* <p><p/>
* This visitor's check method terminates early by throwing an unchecked {@link CheckErrorFound},
* use {@link #checkObject(Checkable) ContainsAnyErrorVisitor.checkObject(Checkable)} to handle the Throwable.
*/
public class ContainsAnyErrorVisitor extends AbstractCheck { public class ContainsAnyErrorVisitor extends AbstractCheck {
/**
* Checks if a Checkable, or any Object in its datastructure, contains any error.
* <p>
* Terminates early upon finding an error by throwing {@link CheckErrorFound}
*
* @param checkable The object to check
* @throws CheckErrorFound when any Error is found
*/
public static void checkObject(Checkable checkable) throws CheckErrorFound { public static void checkObject(Checkable checkable) throws CheckErrorFound {
checkable.accept(new ContainsAnyErrorVisitor()); checkable.accept(new ContainsAnyErrorVisitor());
} }
......
...@@ -6,10 +6,25 @@ import de.hft.stuttgart.citydoctor2.check.Checkable; ...@@ -6,10 +6,25 @@ import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.utils.CheckErrorFound; import de.hft.stuttgart.citydoctor2.utils.CheckErrorFound;
import de.hft.stuttgart.citydoctor2.utils.ThrowUtils; import de.hft.stuttgart.citydoctor2.utils.ThrowUtils;
/**
* This visitor checks if a checkable contains a specific error in its datastructure.
* <p><p/>
* This visitor's check method terminates early by throwing an unchecked {@link CheckErrorFound},
* use {@link #checkObject(Checkable, CheckId) ContainsAnyErrorVisitor.checkObject(Checkable, CheckId)} to handle the Throwable.
*/
public class ContainsErrorVisitor extends AbstractCheck { public class ContainsErrorVisitor extends AbstractCheck {
private CheckId checkId; private CheckId checkId;
/**
* Checks if a Checkable, or any Object in its datastructure, contains a specific error.
* <p>
* Terminates early upon finding the error by throwing {@link CheckErrorFound}
*
* @param checkable The object to check
* @param checkIdentifier The specific error's associated ID
* @throws CheckErrorFound when the error is found
*/
public static void checkObject(Checkable checkable, CheckId checkIdentifier) throws CheckErrorFound { public static void checkObject(Checkable checkable, CheckId checkIdentifier) throws CheckErrorFound {
checkable.accept(new ContainsErrorVisitor(checkIdentifier)); checkable.accept(new ContainsErrorVisitor(checkIdentifier));
} }
......
...@@ -5,12 +5,26 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject; ...@@ -5,12 +5,26 @@ import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import org.citygml4j.core.util.geometry.GeometryFactory; import org.citygml4j.core.util.geometry.GeometryFactory;
import java.util.Objects;
/**
* This Visitor recreates the Geometries of the original CityGml object from the associated Geometries in CityDoctor's
* internal model.
*/
public class GmlGeometryRebuilder extends AbstractCheck { public class GmlGeometryRebuilder extends AbstractCheck {
private final GeometryFactory factory; private final GeometryFactory factory;
private final ParserConfiguration config; private final ParserConfiguration config;
/**
* Creates a new Rebuilder for reconstruction of CityGml geometries.
*
* @param factory the GeometryFactory used for creation of CityGml geometry objects.
* @param configuration the configuration settings of the parser
*/
public GmlGeometryRebuilder(GeometryFactory factory, ParserConfiguration configuration) { public GmlGeometryRebuilder(GeometryFactory factory, ParserConfiguration configuration) {
Objects.requireNonNull(factory);
Objects.requireNonNull(configuration);
this.factory = factory; this.factory = factory;
this.config = configuration; this.config = configuration;
} }
......
...@@ -3,6 +3,9 @@ package de.hft.stuttgart.citydoctor2.utils.visitors; ...@@ -3,6 +3,9 @@ package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck; import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry; import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
/**
* This Visitor prepares the {@link Geometry Geometries} in a Checkable for low-memory consumption mode.
*/
public class PrepareForCheckingVisitor extends AbstractCheck { public class PrepareForCheckingVisitor extends AbstractCheck {
@Override @Override
......
...@@ -3,6 +3,10 @@ package de.hft.stuttgart.citydoctor2.utils.visitors; ...@@ -3,6 +3,10 @@ package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.AbstractCheck; import de.hft.stuttgart.citydoctor2.check.AbstractCheck;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject; import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
/**
* This Visitor removes the GmlGeometries from the linked original GmlObjects in a CityObject's datastructure to reduce
* memory bloat.
*/
public class UnsetGeometriesVisitor extends AbstractCheck { public class UnsetGeometriesVisitor extends AbstractCheck {
......
Supports Markdown
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