Commit 97a65114 authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev' into 'master'

Version 3.15.0

See merge request !8
parents 99c8f6a8 5950ea5f
Pipeline #10106 passed with stage
in 3 minutes and 15 seconds
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class CityObjectNode extends Renderable {
private final CityObject co;
public CityObjectNode(CityObject co) {
this.co = co;
}
@Override
public void refreshTextColor() {
if (!co.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (co.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
return co.getGmlId().getGmlString();
}
@Override
public void visit(Renderer renderer) {
renderer.render(co);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.gui.CityDoctorController;
public interface Displayable {
public void visitForDisplaying(CityDoctorController controller);
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class EdgeNode extends Renderable {
private static final DecimalFormat nf;
static {
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance();
dfs.setDecimalSeparator('.');
nf = new DecimalFormat("#.####", dfs);
}
private static final String SEPERATOR = ", ";
private final Edge e;
private String text;
public EdgeNode(Edge e) {
this.e = e;
}
@Override
public void refreshTextColor() {
// not used
}
@Override
public String getText() {
if (text == null) {
StringBuilder sb = new StringBuilder();
sb.append("Edge from [");
Vertex from = e.getFrom();
sb.append(nf.format(from.getX()));
sb.append(SEPERATOR);
sb.append(nf.format(from.getY()));
sb.append(SEPERATOR);
sb.append(nf.format(from.getZ()));
sb.append("] to [");
Vertex to = e.getTo();
sb.append(nf.format(to.getX()));
sb.append(SEPERATOR);
sb.append(nf.format(to.getY()));
sb.append(SEPERATOR);
sb.append(nf.format(to.getZ()));
sb.append("]");
text = sb.toString();
}
return text;
}
@Override
public void visit(Renderer renderer) {
renderer.highlight(e);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import javafx.scene.control.cell.TextFieldTreeCell;
public class ErrorCell extends TextFieldTreeCell<CheckError> {
@Override
public void updateItem(CheckError item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
setText(item.getErrorId().toString());
}
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.util.List;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ErrorVisitor;
import de.hft.stuttgart.citydoctor2.check.error.AllPolygonsWrongOrientationError;
import de.hft.stuttgart.citydoctor2.check.error.AttributeInvalidError;
import de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError;
import de.hft.stuttgart.citydoctor2.check.error.AttributeValueWrongError;
import de.hft.stuttgart.citydoctor2.check.error.ConsecutivePointSameError;
import de.hft.stuttgart.citydoctor2.check.error.DependenciesNotMetError;
import de.hft.stuttgart.citydoctor2.check.error.MultipleConnectedComponentsError;
import de.hft.stuttgart.citydoctor2.check.error.NestedRingError;
import de.hft.stuttgart.citydoctor2.check.error.NonManifoldEdgeError;
import de.hft.stuttgart.citydoctor2.check.error.NonManifoldVertexError;
import de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonDistancePlaneError;
import de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonNormalsDeviation;
import de.hft.stuttgart.citydoctor2.check.error.NotCeilingError;
import de.hft.stuttgart.citydoctor2.check.error.NotFloorError;
import de.hft.stuttgart.citydoctor2.check.error.NotGroundError;
import de.hft.stuttgart.citydoctor2.check.error.NotWallError;
import de.hft.stuttgart.citydoctor2.check.error.NullAreaError;
import de.hft.stuttgart.citydoctor2.check.error.PointTouchesEdgeError;
import de.hft.stuttgart.citydoctor2.check.error.PolygonHoleOutsideError;
import de.hft.stuttgart.citydoctor2.check.error.PolygonInteriorDisconnectedError;
import de.hft.stuttgart.citydoctor2.check.error.PolygonIntersectingRingsError;
import de.hft.stuttgart.citydoctor2.check.error.PolygonSameOrientationError;
import de.hft.stuttgart.citydoctor2.check.error.PolygonWithoutSurfaceError;
import de.hft.stuttgart.citydoctor2.check.error.PolygonWrongOrientationError;
import de.hft.stuttgart.citydoctor2.check.error.RingDuplicatePointError;
import de.hft.stuttgart.citydoctor2.check.error.RingEdgeIntersectionError;
import de.hft.stuttgart.citydoctor2.check.error.RingNotClosedError;
import de.hft.stuttgart.citydoctor2.check.error.RingTooFewPointsError;
import de.hft.stuttgart.citydoctor2.check.error.SchematronError;
import de.hft.stuttgart.citydoctor2.check.error.SolidNotClosedError;
import de.hft.stuttgart.citydoctor2.check.error.SolidSelfIntError;
import de.hft.stuttgart.citydoctor2.check.error.SurfaceUnfragmentedError;
import de.hft.stuttgart.citydoctor2.check.error.DegeneratedRingError;
import de.hft.stuttgart.citydoctor2.check.error.TooFewPolygonsError;
import de.hft.stuttgart.citydoctor2.check.error.UnknownCheckError;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import javafx.scene.control.TreeItem;
public class ErrorItemVisitor implements ErrorVisitor {
private static final String NAME_OF_ATTRIBUTE = "Name of Attribute: ";
private static final String CHILD_ID = "ChildId: ";
private final TreeItem<Renderable> root;
public ErrorItemVisitor(TreeItem<Renderable> root) {
this.root = root;
}
@Override
public void visit(PolygonHoleOutsideError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(NonManifoldEdgeError err) {
for (Edge e : err.getEdges()) {
EdgeNode edgeNode = new EdgeNode(e);
TreeItem<Renderable> edgeItem = new TreeItem<>(edgeNode);
root.getChildren().add(edgeItem);
}
}
@Override
public void visit(MultipleConnectedComponentsError err) {
for (int i = 0; i < err.getComponents().size(); i++) {
TextNode textNode = new TextNode("Component " + i);
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
List<Polygon> component = err.getComponents().get(i);
for (Polygon p : component) {
PolygonNode polyNode = new PolygonNode(p, CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
textItem.getChildren().add(polyItem);
}
}
}
@Override
public void visit(NestedRingError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(NonManifoldVertexError err) {
VertexNode vertexNode = new VertexNode(err.getVertex());
TreeItem<Renderable> vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
for (int i = 0; i < err.getComponents().size(); i++) {
TextNode textNode = new TextNode("Component " + i);
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
List<Polygon> component = err.getComponents().get(i);
for (Polygon p : component) {
PolygonNode polyNode = new PolygonNode(p, CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
textItem.getChildren().add(polyItem);
}
}
}
@Override
public void visit(PolygonWrongOrientationError err) {
for (Edge e : err.getEdges()) {
EdgeNode edgeNode = new EdgeNode(e);
TreeItem<Renderable> edgeItem = new TreeItem<>(edgeNode);
root.getChildren().add(edgeItem);
}
}
@Override
public void visit(PolygonSameOrientationError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(SolidNotClosedError err) {
for (Edge e : err.getErrorEdges()) {
EdgeNode edgeNode = new EdgeNode(e);
TreeItem<Renderable> edgeItem = new TreeItem<>(edgeNode);
root.getChildren().add(edgeItem);
}
}
@Override
public void visit(DependenciesNotMetError err) {
// not displayed
}
@Override
public void visit(UnknownCheckError err) {
// not displayed
}
@Override
public void visit(RingNotClosedError err) {
LinearRingNode ringNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> ringItem = new TreeItem<>(ringNode);
root.getChildren().add(ringItem);
}
@Override
public void visit(ConsecutivePointSameError err) {
LinearRingNode ringNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> ringItem = new TreeItem<>(ringNode);
root.getChildren().add(ringItem);
VertexNode vertexNode = new VertexNode(err.getVertex1());
TreeItem<Renderable> vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
vertexNode = new VertexNode(err.getVertex2());
vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
}
@Override
public void visit(AllPolygonsWrongOrientationError err) {
// not displayed
}
@Override
public void visit(PolygonInteriorDisconnectedError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(NullAreaError err) {
LinearRingNode ringNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> ringItem = new TreeItem<>(ringNode);
root.getChildren().add(ringItem);
}
@Override
public void visit(RingTooFewPointsError err) {
LinearRingNode ringNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> ringItem = new TreeItem<>(ringNode);
root.getChildren().add(ringItem);
if (err.getRing().getGmlId().isGenerated()) {
PolygonNode polyNode = new PolygonNode(err.getRing().getParent(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
ringItem.getChildren().add(polyItem);
}
}
@Override
public void visit(NonPlanarPolygonNormalsDeviation err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
TextNode textNode = new TextNode("Deviation: " + err.getDeviation());
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
}
@Override
public void visit(NonPlanarPolygonDistancePlaneError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
VertexNode vertexNode = new VertexNode(err.getVertex());
TreeItem<Renderable> vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
TextNode textNode = new TextNode("Distance: " + err.getDistance() + "m");
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
}
@Override
public void visit(PolygonIntersectingRingsError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(SolidSelfIntError err) {
PolygonNode polyNode1 = new PolygonNode(err.getIntersections().get(0).getP1(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem1 = new TreeItem<>(polyNode1);
root.getChildren().add(polyItem1);
PolygonNode polyNode2 = new PolygonNode(err.getIntersections().get(0).getP2(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem2 = new TreeItem<>(polyNode2);
root.getChildren().add(polyItem2);
}
@Override
public void visit(TooFewPolygonsError err) {
// not displayed
}
@Override
public void visit(RingDuplicatePointError err) {
LinearRingNode ringNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> ringItem = new TreeItem<>(ringNode);
root.getChildren().add(ringItem);
VertexNode vertexNode = new VertexNode(err.getVertex1());
TreeItem<Renderable> vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
vertexNode = new VertexNode(err.getVertex2());
vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
}
@Override
public void visit(RingEdgeIntersectionError err) {
LinearRingNode ringNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> ringItem = new TreeItem<>(ringNode);
root.getChildren().add(ringItem);
EdgeNode edgeNode = new EdgeNode(err.getEdge1());
TreeItem<Renderable> edgeItem = new TreeItem<>(edgeNode);
root.getChildren().add(edgeItem);
EdgeNode edge2Node = new EdgeNode(err.getEdge2());
TreeItem<Renderable> edge2Item = new TreeItem<>(edge2Node);
root.getChildren().add(edge2Item);
VertexNode vertexNode = new VertexNode(new Vertex(err.getIntersection()));
TreeItem<Renderable> vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
}
@Override
public void visit(PointTouchesEdgeError err) {
TextNode textNode = new TextNode("Point touches edge");
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
VertexNode vertexNode = new VertexNode(err.getVertex());
TreeItem<Renderable> vertexItem = new TreeItem<>(vertexNode);
root.getChildren().add(vertexItem);
EdgeNode edgeNode = new EdgeNode(err.getEdge());
TreeItem<Renderable> edgeItem = new TreeItem<>(edgeNode);
root.getChildren().add(edgeItem);
LinearRingNode ringNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> ringItem = new TreeItem<>(ringNode);
root.getChildren().add(ringItem);
}
@Override
public void visit(NotCeilingError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(NotFloorError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(NotWallError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(NotGroundError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(CheckError err) {
// not used
}
@Override
public void visit(SchematronError err) {
TextNode textNode = new TextNode(err.getErrorIdString());
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
}
@Override
public void visit(SurfaceUnfragmentedError err) {
TextNode textNode = new TextNode("Deviation: " + err.getAngleDeviation());
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
}
@Override
public void visit(DegeneratedRingError err) {
TextNode textNode = new TextNode("Type: degenerated ring");
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
LinearRingNode polyNode = new LinearRingNode(err.getRing(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
@Override
public void visit(AttributeMissingError err) {
if (!err.getChildId().isEmpty()) {
TextNode textNode = new TextNode(CHILD_ID + err.getChildId());
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
}
TextNode nameNode = new TextNode(NAME_OF_ATTRIBUTE + err.getNameOfAttribute());
TreeItem<Renderable> nameItem = new TreeItem<>(nameNode);
root.getChildren().add(nameItem);
}
@Override
public void visit(AttributeValueWrongError err) {
if (!err.getChildId().isEmpty()) {
TextNode textNode = new TextNode(CHILD_ID + err.getChildId());
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
}
TextNode nameNode = new TextNode(NAME_OF_ATTRIBUTE + err.getNameOfAttribute());
TreeItem<Renderable> nameItem = new TreeItem<>(nameNode);
root.getChildren().add(nameItem);
}
@Override
public void visit(AttributeInvalidError err) {
if (!err.getChildId().isEmpty()) {
TextNode textNode = new TextNode(CHILD_ID + err.getChildId());
TreeItem<Renderable> textItem = new TreeItem<>(textNode);
root.getChildren().add(textItem);
}
TextNode nameNode = new TextNode(NAME_OF_ATTRIBUTE + err.getNameOfAttribute());
TreeItem<Renderable> nameItem = new TreeItem<>(nameNode);
root.getChildren().add(nameItem);
}
@Override
public void visit(PolygonWithoutSurfaceError err) {
PolygonNode polyNode = new PolygonNode(err.getPolygon(), CheckStatus.NOT_CHECKED);
TreeItem<Renderable> polyItem = new TreeItem<>(polyNode);
root.getChildren().add(polyItem);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class ErrorNode extends Renderable {
private final CheckError err;
public ErrorNode(CheckError e) {
this.err = e;
}
@Override
public void refreshTextColor() {
// not used
}
@Override
public String getText() {
return err.getErrorId().toString();
}
@Override
public void visit(Renderer renderer) {
renderer.highlight(err);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class GeometryNode extends Renderable {
private final Geometry geom;
private final String text;
public GeometryNode(Geometry geom) {
this.geom = geom;
StringBuilder sb = new StringBuilder();
sb.append("Geometry [");
sb.append(geom.getType());
sb.append(", ");
sb.append(geom.getLod());
if (geom.getGmlId().isGenerated()) {
sb.append("]");
} else {
sb.append("] ");
sb.append(geom.getGmlId());
}
text = sb.toString();
}
@Override
public void refreshTextColor() {
if (!geom.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (geom.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
return text;
}
@Override
public void visit(Renderer renderer) {
renderer.render(geom);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class InstallationNode extends Renderable {
private final Installation bi;
public InstallationNode(Installation bi) {
this.bi = bi;
}
@Override
public String getText() {
return bi.getGmlId().getGmlString();
}
@Override
public void visit(Renderer renderer) {
renderer.render(bi);
}
@Override
public void refreshTextColor() {
if (!bi.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (bi.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
}
\ No newline at end of file
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class LandUseNode extends Renderable {
private final LandObject landUse;
public LandUseNode(LandObject landUse) {
this.landUse = landUse;
}
@Override
public void refreshTextColor() {
if (!landUse.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (landUse.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
return "[LandUse] " + landUse.getGmlId().getGmlString();
}
@Override
public void visit(Renderer renderer) {
renderer.render(landUse);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class LinearRingNode extends Renderable {
private final LinearRing lr;
private String text;
public LinearRingNode(LinearRing lr, CheckStatus cs) {
this.lr = lr;
setStatus(cs);
}
@Override
public void refreshTextColor() {
if (!lr.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (lr.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
if (text == null) {
text = "Linear Ring (" + lr.getType().toString() + ") " + lr.getGmlId().getGmlString();
}
return text;
}
@Override
public void visit(Renderer renderer) {
renderer.highlight(lr);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class OpeningNode extends Renderable {
private final Opening opening;
public OpeningNode(Opening o) {
opening = o;
}
@Override
public void refreshTextColor() {
if (!opening.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (opening.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
return "Opening [" + opening.getGmlId() + ", " + opening.getType() + "]";
}
@Override
public void visit(Renderer renderer) {
renderer.render(opening);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class PolygonNode extends Renderable {
private final Polygon p;
private String text;
public PolygonNode(Polygon p, CheckStatus cs) {
this.p = p;
setStatus(cs);
}
@Override
public void refreshTextColor() {
if (!p.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (p.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
if (text == null) {
text = "Polygon " + p.getGmlId().getGmlString();
}
return text;
}
@Override
public void visit(Renderer renderer) {
renderer.highlight(p);
}
}
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class ReliefNode extends Renderable {
private final ReliefObject relief;
public ReliefNode(ReliefObject relief) {
this.relief = relief;
}
@Override
public void refreshTextColor() {
if (!relief.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (relief.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
return "[ReliefFeature] " + relief.getGmlId().getGmlString();
}
@Override
public void visit(Renderer renderer) {
renderer.render(relief);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
public abstract class Renderable {
private final ObjectProperty<CheckStatus> statusProperty = new SimpleObjectProperty<>();
/**
* @return the status
*/
public CheckStatus getStatus() {
return statusProperty.getValue();
}
/**
* @param status the status to set
*/
public void setStatus(CheckStatus status) {
statusProperty.set(status);
}
public ObjectProperty<CheckStatus> getStatusProperty() {
return statusProperty;
}
public abstract void refreshTextColor();
public abstract String getText();
public abstract void visit(Renderer renderer);
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.scene.control.Button;
import javafx.scene.control.TreeCell;
import javafx.scene.paint.Color;
public class RenderableTreeCell extends TreeCell<Renderable> {
private Renderable currentCheckable = null;
private ChangeListener<CheckStatus> listener;
@Override
protected void updateItem(Renderable item, boolean empty) {
super.updateItem(item, empty);
if (!empty && item != null) {
if (item instanceof ButtonRenderable renderable) {
Button b = new Button("More ...");
b.setMaxWidth(Double.MAX_VALUE);
setText(null);
setGraphic(b);
b.setOnAction(ae -> renderable.run());
return;
}
updateColor(item.getStatus());
setText(item.getText());
setGraphic(null);
if (currentCheckable != item) {
if (listener != null) {
// remove old Listener
item.getStatusProperty().removeListener(listener);
}
// only add listener to the status property once
listener = (obs, oldV, newV) -> Platform.runLater(() -> updateColor(newV));
item.getStatusProperty().addListener(listener);
currentCheckable = item;
}
} else {
setTextFill(Color.BLACK);
setText(null);
setGraphic(null);
}
}
private void updateColor(CheckStatus status) {
if (status == CheckStatus.OK) {
setTextFill(Color.GREEN);
} else if (status == CheckStatus.ERROR) {
setTextFill(Color.RED);
} else {
setTextFill(Color.BLACK);
}
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class TextNode extends Renderable {
private final String text;
public TextNode(String text) {
this.text = text;
}
@Override
public void refreshTextColor() {
// don't refresh anything
}
@Override
public String getText() {
return text;
}
@Override
public void visit(Renderer renderer) {
// not used
}
}
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.TinObject;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class TinNode extends Renderable {
private final TinObject tin;
public TinNode(TinObject tin) {
this.tin = tin;
}
@Override
public void refreshTextColor() {
if (!tin.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (tin.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
return "[TINRelief] " + tin.getGmlId().getGmlString();
}
@Override
public void visit(Renderer renderer) {
renderer.render(tin);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.check.DefaultParameter;
import de.hft.stuttgart.citydoctor2.check.Requirement;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
public class TreeRequirement {
private BooleanProperty enabled;
private final ObservableValue<String> name;
private SimpleStringProperty value;
private final ObservableValue<String> unit;
private Requirement r;
public TreeRequirement(Requirement r) {
this.r = r;
enabled = new SimpleBooleanProperty(true);
name = new SimpleStringProperty(r.getId());
unit = new SimpleStringProperty();
}
public TreeRequirement(DefaultParameter dp) {
name = new SimpleStringProperty(dp.getName());
value = new SimpleStringProperty(dp.getValue());
unit = new SimpleStringProperty(dp.getUnitType().getRepresentation());
}
public void setEnabled(boolean enabled) {
this.enabled.set(enabled);
}
public ObservableValue<String> getUnitProperty() {
return unit;
}
/**
* @return the enabled
*/
public BooleanProperty getEnabledProperty() {
return enabled;
}
public ObservableValue<String> getNameProperty() {
return name;
}
public ObservableValue<String> getValueProperty() {
return value;
}
public void setValue(String value) {
this.value.setValue(value);
}
public Requirement getRequirement() {
return r;
}
public boolean isEnabled() {
return enabled.get();
}
}
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.gui.tree;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.gui.CheckStatus;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class VegetationNode extends Renderable {
private final Vegetation veg;
private final String text;
public VegetationNode(Vegetation veg) {
this.veg = veg;
text = "[" + veg.getVegetationType() + "] " + veg.getGmlId().getGmlString();
}
@Override
public void refreshTextColor() {
if (!veg.isValidated()) {
setStatus(CheckStatus.NOT_CHECKED);
} else if (veg.containsAnyError()) {
setStatus(CheckStatus.ERROR);
} else {
setStatus(CheckStatus.OK);
}
}
@Override
public String getText() {
return text;
}
@Override
public void visit(Renderer renderer) {
renderer.render(veg);
}
}
package de.hft.stuttgart.citydoctor2.gui.tree;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.gui.Renderer;
public class VertexNode extends Renderable {
private static final DecimalFormat nf;
static {
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance();
dfs.setDecimalSeparator('.');
nf = new DecimalFormat("#.########", dfs);
}
private static final String SEPERATOR = ", ";
private final Vertex v;
private String text;
public VertexNode(Vertex v) {
this.v = v;
}
@Override
public void refreshTextColor() {
// not used
}
@Override
public String getText() {
if (text == null) {
text = "Vertex [" + nf.format(v.getX()) + SEPERATOR +
nf.format(v.getY()) + SEPERATOR + nf.format(v.getZ()) + "]";
}
return text;
}
@Override
public void visit(Renderer renderer) {
renderer.highlight(v);
}
}
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