Commit 81be0b1d authored by Riegel's avatar Riegel
Browse files

Merge branch 'dev_GUI' into 'dev'

Open source release of CityDoctorGUI and other extensions.

See merge request !6
parents 12d96d95 5a4d0a74
Pipeline #10056 passed with stage
in 1 minute and 6 seconds
package de.hft.stuttgart.citydoctor2.connect.edge;
import de.hft.stuttgart.citydoctor2.connect.edge.CppReferenceHandlingBase;
import de.hft.stuttgart.citydoctor2.connect.edge.NativePointerCastException;
public class AutoProSettingsMerge extends CppReferenceHandlingBase {
private native long createCppClass(
boolean useMerge,
boolean exportIntermediateStages,
boolean printMergeInfo,
double eps_PointEquality,
double eps_Parallelity
)
throws OutOfMemoryError;
private native void disposeCppClass(long ptrToCppAutoPro)
throws NativePointerCastException;
private boolean useMerge;
private boolean exportIntermediateStages;
private boolean printMergeInfo;
private double eps_PointEquality;
private double eps_Parallelity;
public AutoProSettingsMerge() {
setUseMerge(false);
setExportIntermediateStages(false);
setPrintMergeInfo(false);
setEps_PointEquality(0.01);
setEps_Parallelity(0.01);
}
/**
* Creates an C++ feature object
*
* @throws IllegalStateException
* Thrown if the encapsulated "long-Pointer" isn't 0
* @throws NativeOutOfMemoryException
* If there is no more memory on the native side
*
* @see {@link disposeCppObject}
* @see de.hft.stuttgart.citydoctor.connect.edGe.CppReferenceHandlingBase#createCppObject()
*/
public void createCppObject() throws IllegalStateException,
OutOfMemoryError {
if (0L != ptrToCppObject) {
throw new IllegalStateException(
"Can't create new C++ object, there is allready one!");
}
// Maybe an exception is thrown
long tmpPointer = createCppClass(
isUseMerge(),
isExportIntermediateStages(),
isPrintMergeInfo(),
getEps_PointEquality(),
getEps_Parallelity()
);
ptrToCppObject = tmpPointer;
}
@Override
public void disposeCppObject() throws NativePointerCastException {
if (0L != ptrToCppObject) {
disposeCppClass(ptrToCppObject);
ptrToCppObject = 0L;
}
}
public void setUseMerge(boolean useMerge) {
this.useMerge = useMerge;
}
public void setExportIntermediateStages(boolean exportIntermediateStages) {
this.exportIntermediateStages = exportIntermediateStages;
}
public void setPrintMergeInfo(boolean printMergeInfo) {
this.printMergeInfo = printMergeInfo;
}
public void setEps_PointEquality(double eps_PointEquality) {
this.eps_PointEquality = eps_PointEquality;
}
public void setEps_Parallelity(double eps_Parallelity) {
this.eps_Parallelity = eps_Parallelity;
}
public boolean isUseMerge() {
return useMerge;
}
public boolean isExportIntermediateStages() {
return exportIntermediateStages;
}
public boolean isPrintMergeInfo() {
return printMergeInfo;
}
public double getEps_PointEquality() {
return eps_PointEquality;
}
public double getEps_Parallelity() {
return eps_Parallelity;
}
}
/** --------------------------------------------------
* Hochschule fuer Technik Stuttgart
* Fachbereich Vermessung , Informatik und Mathematik
* Schellingstr . 24
* D - 70174 Stuttgart
*
* Projekt CityDoktor
*
* Copyright (c) 2011 HFT Stuttgart. All rights reserved.
* HFT Stuttgart and its licensors retain all intellectual property and
* proprietary rights in and to this software and related documentation.
* Any use, reproduction, disclosure, or distribution of this software
* and related documentation without an express license agreement from
* HFT Stuttgart is strictly prohibited.
*
* Please refer to the applicable HFT Stuttgart end user license agreement (EULA)
* associated with this source code for terms and conditions that govern
* your use of this HFT Stuttgart software.
*
* @author PiR
* @version 1.0
* created: 17.12.2017
*/
package de.hft.stuttgart.citydoctor2.gui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.filechooser.FileFilter;
import de.hft.stuttgart.citydoctor2.CppInitializer;
import de.hft.stuttgart.citydoctor2.connect.edge.AutoPro;
import de.hft.stuttgart.citydoctor2.connect.edge.AutoProSettingsAdvancedSweep;
import de.hft.stuttgart.citydoctor2.connect.edge.AutoProSettingsBool;
import de.hft.stuttgart.citydoctor2.connect.edge.AutoProSettingsExport;
import de.hft.stuttgart.citydoctor2.connect.edge.AutoProSettingsGeneral;
import de.hft.stuttgart.citydoctor2.connect.edge.AutoProSettingsMerge;
import de.hft.stuttgart.citydoctor2.connect.edge.CppFeature;
import de.hft.stuttgart.citydoctor2.connect.edge.CppHealResult;
import de.hft.stuttgart.citydoctor2.connect.edge.NativeException;
import de.hft.stuttgart.citydoctor2.connect.edge.NativePointerCastException;
//import de.hft.stuttgart.citydoctor2.CityDoctorDataStream;
//import de.hft.stuttgart.citydoctor2.CityDoctorValidationStreamLite;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingPart;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
class DoubleJSlider extends JSlider {
private static final long serialVersionUID = 1L;
final int scale;
public DoubleJSlider(int min, int max, int value, int scale) {
super(min, max, value);
this.scale = scale;
}
public double getScaledValue() {
return ((double)super.getValue()) / this.scale;
}
}
class FileInfo {
String filePath;
String fileName;
String fileType;
public FileInfo(String path, String name, String fileType) {
this.filePath = path;
this.fileName = name;
this.fileType = fileType;
}
public FileInfo() {
this.filePath = "";
this.fileName = "";
this.fileType = "";
}
public void setPath(String path) {
this.filePath = path;
}
public String getPath() {
return this.filePath;
}
public void setName(String name) {
this.fileName = name;
}
public String getName() {
return this.fileName;
}
public void setType(String fileType) {
this.fileType = fileType;
}
public String getType() {
return this.fileType;
}
public String getString() {
return this.filePath + this.fileName + this.fileType;
}
}
public class AutoProWindow extends JDialog implements ItemListener {
// Variable fuer Serialisierung
private static final long serialVersionUID = 2626132909887065227L;
JCheckBox MeshExportCheckBox;
private JTextField MeshExportTextField;
private JButton MeshExportJButton;
private FileInfo meshFileInfo = new FileInfo(".\\_meshFiles\\", "MeshObject", ".iv");
JCheckBox IVExportCheckBox;
private JTextField IVExportTextField;
private JButton IVExportJButton;
private FileInfo ivFileInfo = new FileInfo(".\\_ivFiles\\", "IVObject", ".iv");
JCheckBox STEPExportCheckBox;
private JTextField STEPExportTextField;
private JButton STEPExportJButton;
private FileInfo stepFileInfo = new FileInfo(".\\_stepFiles\\", "STEPObject", ".stp");
JCheckBox GMLExportCheckBox;
private JTextField GMLExportTextField;
private JButton GMLExportJButton;
private FileInfo gmlFileInfo = new FileInfo(".\\_gmlFiles\\", "CityGMLObject", ".gml");
JCheckBox exportValidBuildingsOnlyCheckBox;
JCheckBox moveBuildingBlockToOriginCheckBox;
JCheckBox exportIntermediateStagesCompleteCheckBox;
JCheckBox exportStepWithOneSolidPerBuilding;
double minDistToOrigin_X;
double minDistToOrigin_Y;
double minDistToOrigin_Z;
JCheckBox printBuildingInfoCheckBox;
JCheckBox printStatusCheckBox;
JCheckBox printAllCheckBox;
JCheckBox printSmallestAngleCheckBox;
JCheckBox printNumberOfSmallAnglesCheckBox;
JTextField smallAngleToleranceTextField;
double smallAngleTolerance;
JCheckBox printShortestEdgeCheckBox;
JCheckBox printNumberOfShortEdgesCheckBox;
JTextField shortEdgesToleranceTextField;
double shortEdgesTolerance;
JCheckBox printVolumeCheckBox;
JCheckBox printNumberOfFacesAndVerticesCheckBox;
JCheckBox boolCheckBox;
JCheckBox printBoolInfoCheckBox;
JCheckBox boolMinkowski_exportIntermediateStagesCheckBox;
JCheckBox minkowskiCheckBox;
JCheckBox printMinkowskiInfoCheckBox;
JLabel minkowskiCubeLabel;
DoubleJSlider minkowskiCubeSlider;
JTextField minkowskiCubeTextField;
JCheckBox rotateMinkowskiCube;
JCheckBox mergeCheckBox;
JCheckBox merge_exportIntermediateStagesCheckBox;
JCheckBox printMergeInfoCheckBox;
JLabel eps_PointEqualityLabel;
DoubleJSlider eps_PointEqualitySlider;
JTextField eps_PointEqualityTextField;
JLabel eps_ParallelityLabel;
DoubleJSlider eps_ParallelitySlider;
JTextField eps_ParallelityTextField;
JCheckBox advancedSweep_General_printInfoCheckBox;
JCheckBox advancedSweep_General_printFilterReasonInfoCheckBox;
JCheckBox advancedSweep_General_exportIntermediateStagesCheckBox;
JLabel advancedSweep_General_minEdgeLengthLabel;
DoubleJSlider advancedSweep_General_minEdgeLengthSlider;
JTextField advancedSweep_General_minEdgeLengthTextField;
JLabel advancedSweep_General_maxEdgeLengthLabel;
DoubleJSlider advancedSweep_General_maxEdgeLengthSlider;
JTextField advancedSweep_General_maxEdgeLengthTextField;
JLabel advancedSweep_General_minDistToSweepLabel;
DoubleJSlider advancedSweep_General_minDistToSweepSlider;
JTextField advancedSweep_General_minDistToSweepTextField;
JCheckBox advancedSweep_Planarity_Use_CheckBox;
JCheckBox advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox;
JLabel advancedSweep_Planarity_PlanarityTolerance_SweepLabel;
DoubleJSlider advancedSweep_Planarity_PlanarityTolerance_SweepSlider;
JTextField advancedSweep_Planarity_PlanarityTolerance_TextField;
JCheckBox advancedSweep_SweepPlane_Use_CheckBox;
JCheckBox advancedSweep_SweepPlane_PushOnly_CheckBox;
JCheckBox advancedSweep_SweepPlane_PullOnly_CheckBox;
JCheckBox advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox;
JCheckBox advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox;
JCheckBox advancedSweep_SweepPlane_SmallestDistFirst_CheckBox;
JCheckBox advancedSweep_SweepRotate_Use_CheckBox;
JLabel advancedSweep_SweepRotate_maxAngleLabel;
DoubleJSlider advancedSweep_SweepRotate_maxAngleSlider;
JTextField advancedSweep_SweepRotate_maxAngleTextField;
JCheckBox advancedSweep_SweepRotate_MinDistFirst_CheckBox;
JCheckBox advancedSweep_SweepRotate_MinAngleFirst_CheckBox;
JCheckBox advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox;
CityDoctorModel model;
private final int stdBtnHeight = 25;
private final int stdBtnWidth = 300;
// UV MinPoint als Attribut, da auch ausserhalb von setBuildigunstoOrigin darauf zugegriffen weden soll
Vertex minPoint;
private void doClicksLeft() // Method for preadjusting settings
{
IVExportCheckBox.doClick();
STEPExportCheckBox.doClick();
//exportValidBuildingsOnlyCheckBox.doClick();
moveBuildingBlockToOriginCheckBox.doClick();
//printBuildingInfoCheckBox.doClick();
printStatusCheckBox.doClick();
//printAllCheckBox.doClick();
//exportIntermediateStagesCompleteCheckBox.doClick();
}
private void doClicksRight() // Method for preadjusting settings
{
//boolCheckBox.doClick();
//minkowskiCheckBox.doClick();
mergeCheckBox.doClick();
//advancedSweep_Planarity_Use_CheckBox.doClick();
advancedSweep_SweepPlane_Use_CheckBox.doClick();
//advancedSweep_SweepRotate_Use_CheckBox.doClick();
//printBoolInfoCheckBox.doClick();
//printMinkowskiInfoCheckBox.doClick();
//printMergeInfoCheckBox.doClick();
//advancedSweep_General_printInfoCheckBox.doClick();
rotateMinkowskiCube.doClick();
//boolMinkowski_exportIntermediateStagesCheckBox.doClick();
//merge_exportIntermediateStagesCheckBox.doClick();
//advancedSweep_General_exportIntermediateStagesCheckBox.doClick();
//advancedSweep_General_printFilterReasonInfoCheckBox.doClick();
//advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox.doClick();
//advancedSweep_SweepPlane_PullOnly_CheckBox.doClick();
//advancedSweep_SweepPlane_PushOnly_CheckBox.doClick();
}
public AutoProWindow(CityDoctorModel model) {
CppInitializer.initCpp();
this.model = model;
// ##########################
// Einstellungen des Fensters
// ##########################
int width = 1000;
int height = 800;
this.setSize(width, height);
// das Fenster soll zentriert sein
int x = 0, y = 0;
// TODO : !!!
/*
if (mainWindow != null) {
x = ((mainWindow.getWidth() / 2) - (width / 2)) + mainWindow.getX();
y = ((mainWindow.getHeight() / 2) - (height / 2))
+ mainWindow.getY();
}
*/
this.setLocation(x, y);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setTitle(CDAutoProGuiMessages
.getString("AutoProWindow.PreferencesWindowTitle")); //$NON-NLS-1$
this.setModal(true);
// -------------------------------------------------------------------------
// Das Fenster aus Splitter und Buttons zusammenbauen
Container contentPane = this.getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel leftPanel = createLeftPanel();
contentPane.add(leftPanel, BorderLayout.WEST);
JPanel rightPanel = createRightPanel();
contentPane.add(rightPanel, BorderLayout.EAST);
JPanel bottomPanel = createBottomPanel();
contentPane.add(bottomPanel, BorderLayout.SOUTH);
}
/**
* Diese Methode schließt das Fenster.
*/
private void close() {
this.dispose();
}
/** @throws FileNotFoundException
*/
private void startCppAutoProMethods() throws FileNotFoundException {
List<Building> buildings = this.model.getBuildings();
List<Geometry> geometryList = getAllGeometriesOfSelectedBuildings(buildings);
setBuildingsToOrigin(geometryList);
AutoPro autopro = new AutoPro();
autopro.createCppObject();
// fill information for AutoProSettings
AutoProSettingsExport autoProSettingsExport = new AutoProSettingsExport();
autoProSettingsExport.setExportMesh(MeshExportCheckBox.isSelected());
autoProSettingsExport.setMeshFileName(meshFileInfo.getName());
autoProSettingsExport.setMeshFilePath(meshFileInfo.getPath());
autoProSettingsExport.setExportIV(IVExportCheckBox.isSelected());
autoProSettingsExport.setIVFileName(ivFileInfo.getName());
autoProSettingsExport.setIVFilePath(ivFileInfo.getPath());
autoProSettingsExport.setExportSTEP(STEPExportCheckBox.isSelected());
autoProSettingsExport.setSTEPFileName(stepFileInfo.getName());
autoProSettingsExport.setSTEPFilePath(stepFileInfo.getPath());
autoProSettingsExport.setExportCityGML(false/*GMLExportCheckBox.isSelected()*/);
autoProSettingsExport.setCityGMLFileName(gmlFileInfo.getName());
autoProSettingsExport.setCityGMLFilePath(gmlFileInfo.getPath());
autoProSettingsExport.setExportValidBuildingsOnly(exportValidBuildingsOnlyCheckBox.isSelected());
autoProSettingsExport.setMoveBuildingsToOrigin(moveBuildingBlockToOriginCheckBox.isSelected());
autoProSettingsExport.setExportIntermediateStagesComplete(exportIntermediateStagesCompleteCheckBox.isSelected());
autoProSettingsExport.setExportStepWithOneSolidPerBuilding(exportStepWithOneSolidPerBuilding.isSelected());
autoProSettingsExport.setMinDistToOrigin_X(minDistToOrigin_X);
autoProSettingsExport.setMinDistToOrigin_Y(minDistToOrigin_Y);
autoProSettingsExport.setMinDistToOrigin_Z(minDistToOrigin_Z);
autoProSettingsExport.createCppObject();
AutoProSettingsGeneral autoProSettingsGeneral = new AutoProSettingsGeneral();
autoProSettingsGeneral.setPrintBuildingInfo(printBuildingInfoCheckBox.isSelected());
autoProSettingsGeneral.setPrintStatus(printStatusCheckBox.isSelected());
autoProSettingsGeneral.setPrintSmallestAngle(printSmallestAngleCheckBox.isSelected());
autoProSettingsGeneral.setPrintNumberOfSmallAngles(printNumberOfSmallAnglesCheckBox.isSelected());
autoProSettingsGeneral.setSmallAngleTolerance(smallAngleTolerance);
autoProSettingsGeneral.setPrintShortestEdge(printShortestEdgeCheckBox.isSelected());
autoProSettingsGeneral.setPrintNumberOfShortEdges(printNumberOfShortEdgesCheckBox.isSelected());
autoProSettingsGeneral.setShortEdgesTolerance(shortEdgesTolerance);
autoProSettingsGeneral.setPrintVolume(printVolumeCheckBox.isSelected());
autoProSettingsGeneral.setPrintNumberOfFacesAndVertices(printNumberOfFacesAndVerticesCheckBox.isSelected());
autoProSettingsGeneral.createCppObject();
AutoProSettingsBool autoProSettingsBool = new AutoProSettingsBool();
autoProSettingsBool.setUseBool(boolCheckBox.isSelected());
autoProSettingsBool.setPrintBoolInfo(printBoolInfoCheckBox.isSelected());
autoProSettingsBool.setUseMinkowski(minkowskiCheckBox.isSelected());
autoProSettingsBool.setPrintMinkowskiInfo(printMinkowskiInfoCheckBox.isSelected());
autoProSettingsBool.setMinkowskiCubeSize(minkowskiCubeSlider.getScaledValue());
autoProSettingsBool.setExportIntermediateStages(boolMinkowski_exportIntermediateStagesCheckBox.isSelected());
autoProSettingsBool.setRotateMinkowskiCube(rotateMinkowskiCube.isSelected());
autoProSettingsBool.createCppObject();
AutoProSettingsMerge autoProSettingsMerge = new AutoProSettingsMerge();
autoProSettingsMerge.setUseMerge(mergeCheckBox.isSelected());
autoProSettingsMerge.setExportIntermediateStages(merge_exportIntermediateStagesCheckBox.isSelected());
autoProSettingsMerge.setPrintMergeInfo(printMergeInfoCheckBox.isSelected());
autoProSettingsMerge.setEps_PointEquality(eps_PointEqualitySlider.getScaledValue());
autoProSettingsMerge.setEps_Parallelity(eps_ParallelitySlider.getScaledValue());
autoProSettingsMerge.createCppObject();
AutoProSettingsAdvancedSweep autoProSettingsAdvancedSweep = new AutoProSettingsAdvancedSweep();
autoProSettingsAdvancedSweep.set_advancedSweep_General_printInfo( advancedSweep_General_printInfoCheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_General_printFilterReasonInfo( advancedSweep_General_printFilterReasonInfoCheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_General_exportIntermediateStages( advancedSweep_General_exportIntermediateStagesCheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_General_minEdgeLength( advancedSweep_General_minEdgeLengthSlider.getScaledValue());
autoProSettingsAdvancedSweep.set_advancedSweep_General_maxEdgeLength( advancedSweep_General_maxEdgeLengthSlider.getScaledValue());
autoProSettingsAdvancedSweep.set_advancedSweep_General_minDistToSweep( advancedSweep_General_minDistToSweepSlider.getScaledValue());
autoProSettingsAdvancedSweep.set_advancedSweep_Planarity_Use( advancedSweep_Planarity_Use_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_Planarity_IgnoreMultiplePoints( advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_Planarity_PlanarityTolerance( advancedSweep_Planarity_PlanarityTolerance_SweepSlider.getScaledValue());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepPlane_Use( advancedSweep_SweepPlane_Use_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepPlane_PushOnly( advancedSweep_SweepPlane_PushOnly_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepPlane_PullOnly( advancedSweep_SweepPlane_PullOnly_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepPlane_ShortestEdgeFirst( advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepPlane_SmallestFaceFirst( advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepPlane_SmallestDistFirst( advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepRotate_Use( advancedSweep_SweepRotate_Use_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepRotate_maxAngle( advancedSweep_SweepRotate_maxAngleSlider.getScaledValue());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepRotate_SmallestDistFirst( advancedSweep_SweepRotate_MinDistFirst_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepRotate_SmallestAngleFirst( advancedSweep_SweepRotate_MinAngleFirst_CheckBox.isSelected());
autoProSettingsAdvancedSweep.set_advancedSweep_SweepRotate_SmallestFaceFirst( advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.isSelected());
autoProSettingsAdvancedSweep.createCppObject();
// end fill information for AutoProSettings
System.out.println(" " + geometryList.size() + " geometry features counted");
List<CppFeature> features = new ArrayList<>();
for(Geometry geometry: geometryList)
{
try {
String gmlId_string = geometry.getGmlId().getGmlString();
CppFeature feature = new CppFeature( gmlId_string);
feature.setGeometry( geometry );
feature.setLoD(geometry.getLod());
features.add(feature);
autopro.ap_addFeature(feature);
} catch (IllegalStateException e) {
// Auto-generated catch block
e.printStackTrace();
} catch (NativePointerCastException e) {
// Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// Auto-generated catch block
e.printStackTrace();
} catch (NativeException e) {
// Auto-generated catch block
e.printStackTrace();
}
}
try {
autopro.ap_setSettingsExport(autoProSettingsExport);
autopro.ap_setSettingsGeneral(autoProSettingsGeneral);
autopro.ap_setSettingsBool(autoProSettingsBool);
autopro.ap_setSettingsMerge(autoProSettingsMerge);
autopro.ap_setSettingsAdvancedSweep(autoProSettingsAdvancedSweep);
//autopro.ap_setSettings(autoProSettings);
autopro.ap_applyAutoProMethods();
Map<String, Geometry> geometryMap = new HashMap<>();
for (Geometry geom : geometryList) {
geometryMap.put(geom.getGmlId().getGmlString(), geom);
}
for (CppFeature feature : features) {
long healResult = autopro.ap_getHealResult(feature);
//long healResult = feature.getHealResult();
if (healResult == 0) {
feature.disposeCppObject();
continue;
}
System.out.println("merge changes into geometry ");
CppHealResult res = new CppHealResult(healResult);
String gmlId = feature.getType();
Geometry geometry = geometryMap.get(gmlId);
res.mergeIntoGeometry(geometry);
if (geometry.getPolygons().isEmpty()) {
CityObject parent = geometry.getParent();
parent.getGeometries().remove(geometry);
if (parent instanceof BuildingPart && parent.getGeometries().isEmpty()) {
BuildingPart part = (BuildingPart) parent;
Building building = part.getParent();
building.getBuildingParts().remove(part);
if (building.getBuildingParts().isEmpty() && building.getGeometries().isEmpty()) {
model.getBuildings().remove(building);
}
} else if (parent instanceof Building && parent.getGeometries().isEmpty()) {
Building building = (Building) parent;
if (building.getBuildingParts().isEmpty()) {
model.getBuildings().remove(building);
}
}
}
feature.disposeCppObject();
}
autopro.disposeCppObject();
} catch (IllegalStateException e) {
// Auto-generated catch block
e.printStackTrace();
} catch (NativePointerCastException e) {
// Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// Auto-generated catch block
e.printStackTrace();
} catch (NativeException e) {
// Auto-generated catch block
e.printStackTrace();
}
// UV
// Hier ist der Step-Export abgeschlossen
// Translationsvektor an die Datei STEPObject_End.stp anhängen
//System.out.println("Translationsvektor " + minPoint.getX()+ " " + minPoint.getY() + " " +minPoint.getZ());
String text = "/*" + "Translationsvektor " + minPoint.getX()+ " " + minPoint.getY() + " " +minPoint.getZ() + "*/";
String destination = stepFileInfo.getPath() +"STEPObject_End.stp";
//System.out.println(destination);
try {
FileWriter fw = new FileWriter(destination, true); // true: öffnen zum Anhängen von weiteren Zeilen
BufferedWriter ausgabe = new BufferedWriter(fw);
ausgabe.write(text);
ausgabe.newLine();
ausgabe.close();
} catch (IOException e1) {
System.out.println("Couldn't open "+ destination);
}
}
private void setBuildingsToOrigin(List<Geometry> geometryList)
{
//UV
//Vertex minPoint = new Vertex(Double.MAX_VALUE ,Double.MAX_VALUE ,Double.MAX_VALUE , false);
// Jetzt als Attribut der Klasse
minPoint = new Vertex(Double.MAX_VALUE ,Double.MAX_VALUE ,Double.MAX_VALUE);
minDistToOrigin_X = Double.MAX_VALUE;
minDistToOrigin_Y = Double.MAX_VALUE;
minDistToOrigin_Z = Double.MAX_VALUE;
for(Geometry geometry: geometryList)
{
Collection<Vertex> vertexCollection = geometry.getVertices();
for (Vertex vertex : vertexCollection) {
if (minPoint.getX() > vertex.getX())
{
minPoint.setX(vertex.getX());
minDistToOrigin_X = vertex.getX();
}
if (minPoint.getY() > vertex.getY())
{
minPoint.setY(vertex.getY());
minDistToOrigin_Y = vertex.getY();
}
if (minPoint.getZ() > vertex.getZ())
{
minPoint.setZ(vertex.getZ());
minDistToOrigin_Z = vertex.getZ();
}
}
}
// UV 200609
// Ausgabe Translationsvektor
// System.out.println("Translationsvektor " + minPoint.getX()+ " " + minPoint.getY() + " " +minPoint.getZ());
//
for(Geometry geometry: geometryList)
{
Collection<Vertex> vertexCollection = geometry.getVertices();
for (Vertex vertex : vertexCollection) {
vertex.setX(vertex.getX()-minPoint.getX());
vertex.setY(vertex.getY()-minPoint.getY());
vertex.setZ(vertex.getZ()-minPoint.getZ());
}
}
}
private List<Geometry> getAllGeometriesOfSelectedBuildings(List<Building> buildings)
{
List<Geometry> geometryList = new ArrayList<Geometry>();
for (Building building : buildings)
{
if (0 != building.getGeometries().size() )
{
for(Geometry geometry : building.getGeometries())
{
Geometry geometryCopy = geometry;
geometryCopy.setGmlId(building.getGmlId());
geometryList.add(geometryCopy);
}
}
else if(0 != building.getBuildingParts().size())
{
for(BuildingPart buildingPart: building.getBuildingParts())
{
for(Geometry geometry : buildingPart.getGeometries())
{
Geometry geometryCopy = geometry;
geometryCopy.setGmlId(buildingPart.getGmlId());
geometryList.add(geometryCopy);
}
}
}
else if(0 != building.getBuildingInstallations().size())
{
for(Installation buildingInstallation: building.getBuildingInstallations())
{
for(Geometry geometry : buildingInstallation.getGeometries())
{
Geometry geometryCopy = geometry;
geometryCopy.setGmlId(buildingInstallation.getGmlId());
geometryList.add(geometryCopy);
}
}
}
else
{
System.out.println("WARNING : start : no GeometryList for this Building");
}
}
return geometryList;
}
private JPanel createLeftPanel() {
JPanel panel = new JPanel();
panel.setAlignmentX(TOP_ALIGNMENT);
// create panels
JPanel exportMeshPanel = createExportMeshPanel();
JPanel exportIVPanel = createExportIVPanel();
JPanel exportSTEPPanel = createExportSTEPPanel();
JPanel exportGMLPanel = createExportGMLPanel();
JPanel exportSettingsPanel = createExportSettingsPanel();
JPanel printInfoPanel = createPrintInfoPanel();
JPanel comparisonPanel = createComparisonPanel();
doClicksLeft();
// create layout
GridBagLayout gbl = new GridBagLayout();
panel.setLayout(gbl);
// anchor the panel in the top left corner
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.FIRST_LINE_START;
// create some distance to the panel above and below
c.insets = new Insets(10, 0, 10, 0);
c.gridx = 0;
c.gridy = 1;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(exportMeshPanel, c);
c.gridx = 0;
c.gridy = 2;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(exportIVPanel, c);
c.gridx = 0;
c.gridy = 3;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(exportSTEPPanel, c);
/*
c.gridx = 0;
c.gridy = 4;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(exportGMLPanel, c);
*/
c.gridx = 0;
c.gridy = 5;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(exportSettingsPanel, c);
c.gridx = 0;
c.gridy = 6;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(printInfoPanel, c);
c.gridx = 0;
c.gridy = 7;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(comparisonPanel, c);
return panel;
}
private JPanel createRightPanel() {
JPanel panel = new JPanel();
panel.setAlignmentX(TOP_ALIGNMENT);
panel.setAlignmentY(LEFT_ALIGNMENT);
// create panels
JPanel useBoolPanel = createBoolPanel();
JPanel useMergePanel = createMergePanel();
JPanel useAdvancedSweepPanel_General = createAdvancedSweepPanel_General();
JPanel useAdvancedSweepPanel_Planarity = createAdvancedSweepPanel_Planarity();
JPanel useAdvancedSweepPanel_SweepPlane = createAdvancedSweepPanel_SweepPlane();
JPanel useAdvancedSweepPanel_SweepRotate = createAdvancedSweepPanel_SweepRotate();
doClicksRight();
// create layout
GridBagLayout gbl = new GridBagLayout();
panel.setLayout(gbl);
// anchor the panel in the top left corner
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.FIRST_LINE_START;
// create some distance to the panel above and below
c.insets = new Insets(10, 0, 10, 0);
c.gridx = 0;
c.gridy = 1;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(useBoolPanel, c);
c.gridx = 0;
c.gridy = 2;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(useMergePanel, c);
/*
c.gridx = 0;
c.gridy = 3;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(useSweepPlanePanel, c);
*/
c.gridx = 0;
c.gridy = 5;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(useAdvancedSweepPanel_General, c);
c.gridx = 0;
c.gridy = 6;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(useAdvancedSweepPanel_Planarity, c);
c.gridx = 0;
c.gridy = 7;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(useAdvancedSweepPanel_SweepPlane, c);
c.gridx = 0;
c.gridy = 8;
// create some distance to the panel below
c.insets = new Insets(0, 0, 10, 0);
panel.add(useAdvancedSweepPanel_SweepRotate, c);
return panel;
}
private JPanel createBottomPanel() {
JPanel panel = new JPanel();
panel.setAlignmentX(TOP_ALIGNMENT);
panel.setAlignmentY(LEFT_ALIGNMENT);
// create panels
JPanel executeButtonPanel = createExecuteButtonPanel();
// create layout
GridBagLayout gbl = new GridBagLayout();
panel.setLayout(gbl);
// anchor the panel in the top left corner
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.FIRST_LINE_START;
// create some distance to the panel above and below
c.insets = new Insets(10, 0, 10, 0);
c.gridx = 0;
c.gridy = 1;
c.insets = new Insets(0, 0, 0, 0);
panel.add(executeButtonPanel, c);
return panel;
}
private JPanel createExportMeshPanel() {
// panel with surrounding border
JPanel exportMeshPanel = new JPanel();
exportMeshPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.exportMeshPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// Mesh Export Check Box
// --------------------------------------------------------------------
MeshExportCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.exportMeshButtonTitle"));
MeshExportCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.exportMeshButtonDescription"));
MeshExportCheckBox.setSelected(false);
MeshExportCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
MeshExportTextField.setEnabled(true);
MeshExportJButton.setEnabled(true);
} else {
MeshExportTextField.setEnabled(false);
MeshExportJButton.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// optional filename text field
// --------------------------------------------------------------------
MeshExportTextField = new JTextField();
MeshExportTextField
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.meshExportFileNameDescription"));
MeshExportTextField.setText(meshFileInfo.getString());
MeshExportTextField.setEnabled(false);
MeshExportTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
MeshExportTextField.setText(" Please Use The Button on the right ->");
}
}
});
// --------------------------------------------------------------------
// optional file search button
// --------------------------------------------------------------------
MeshExportJButton = new JButton("Set Path and Name");
MeshExportJButton
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.meshExportPathDescription"));
MeshExportJButton.setEnabled(false);
MeshExportJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
meshFileInfo = saveFileDialog(
".iv",
"IV (*.iv)",
"Speicher Mesh unter ...");
if (null != meshFileInfo.getPath()) {
MeshExportTextField.setText(meshFileInfo.getString());
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(exportMeshPanel);
exportMeshPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout
.createSequentialGroup()
.addGap(7)
// make the left side of the component align the buttons of the
// above check related panel
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(MeshExportCheckBox))
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(MeshExportTextField))
.addGap(10)
// pushes the file searchbuttons away
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(MeshExportJButton)).addGap(10));
panelLayout.setVerticalGroup(panelLayout
.createSequentialGroup()
.addGap(10)
// get some space between border and components
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(MeshExportCheckBox)
.addComponent(MeshExportTextField)
.addComponent(MeshExportJButton))
);
return exportMeshPanel;
}
private JPanel createExportIVPanel() {
// panel with surrounding border
JPanel exportIVPanel = new JPanel();
exportIVPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.exportIVPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// IV Export Check Box
// --------------------------------------------------------------------
IVExportCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.exportIVButtonTitle"));
IVExportCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.exportIVButtonDescription"));
IVExportCheckBox.setSelected(false);
IVExportCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
IVExportTextField.setEnabled(true);
IVExportJButton.setEnabled(true);
} else {
IVExportTextField.setEnabled(false);
IVExportJButton.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// optional filename text field
// --------------------------------------------------------------------
IVExportTextField = new JTextField();
IVExportTextField
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.ivExportFileNameDescription"));
IVExportTextField.setText(ivFileInfo.getString());
IVExportTextField.setEnabled(false);
IVExportTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
IVExportTextField.setText(" Please Use The Button on the right ->");
}
}
});
// --------------------------------------------------------------------
// optional file search button
// --------------------------------------------------------------------
IVExportJButton = new JButton("Set Path and Name");
IVExportJButton
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.ivExportPathDescription"));
IVExportJButton.setEnabled(false);
IVExportJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ivFileInfo = saveFileDialog(
".iv",
"IV (*.iv)",
"Speicher BRep Modell unter ...");
if (null != ivFileInfo.getPath()) {
IVExportTextField.setText(ivFileInfo.getString());
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(exportIVPanel);
exportIVPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout
.createSequentialGroup()
.addGap(7)
// make the left side of the component align the buttons of the
// above check related panel
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(IVExportCheckBox))
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(IVExportTextField))
.addGap(10)
// pushes the file searchbuttons away
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(IVExportJButton)).addGap(10));
panelLayout.setVerticalGroup(panelLayout
.createSequentialGroup()
.addGap(10)
// get some space between border and components
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(IVExportCheckBox)
.addComponent(IVExportTextField)
.addComponent(IVExportJButton))
);
return exportIVPanel;
}
private JPanel createExportSTEPPanel() {
// panel with surrounding border
JPanel exportSTEPPanel = new JPanel();
exportSTEPPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.exportSTEPPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// STEP Export Check Box
// --------------------------------------------------------------------
STEPExportCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.exportSTEPButtonTitle"));
STEPExportCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.exportSTEPButtonDescription"));
STEPExportCheckBox.setSelected(false);
STEPExportCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
STEPExportTextField.setEnabled(true);
STEPExportJButton.setEnabled(true);
} else {
STEPExportTextField.setEnabled(false);
STEPExportJButton.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// optional filename text field
// --------------------------------------------------------------------
STEPExportTextField = new JTextField();
STEPExportTextField
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.stepExportFileNameDescription"));
STEPExportTextField.setText(stepFileInfo.getString());
STEPExportTextField.setEnabled(false);
STEPExportTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
STEPExportTextField.setText(" Please Use The Button on the right ->");
}
}
});
// --------------------------------------------------------------------
// optional file search button
// --------------------------------------------------------------------
STEPExportJButton = new JButton("Set Path and Name");
STEPExportJButton
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.stepExportPathDescription"));
STEPExportJButton.setEnabled(false);
STEPExportJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stepFileInfo = saveFileDialog(
".stp",
"STEP (*.stp)",
"Speicher STEP Modell unter ...");
if (null != stepFileInfo.getPath()) {
STEPExportTextField.setText(stepFileInfo.getString());
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(exportSTEPPanel);
exportSTEPPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout
.createSequentialGroup()
.addGap(7)
// make the left side of the component align the buttons of the
// above check related panel
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(STEPExportCheckBox))
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(STEPExportTextField))
.addGap(10)
// pushes the file searchbuttons away
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(STEPExportJButton)).addGap(10));
panelLayout.setVerticalGroup(panelLayout
.createSequentialGroup()
.addGap(10)
// get some space between border and components
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(STEPExportCheckBox)
.addComponent(STEPExportTextField)
.addComponent(STEPExportJButton))
);
return exportSTEPPanel;
}
private JPanel createExportGMLPanel() {
// panel with surrounding border
JPanel exportGMLPanel = new JPanel();
exportGMLPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.exportGMLPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// cityGML Export Check Box
// --------------------------------------------------------------------
GMLExportCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.exportGMLButtonTitle"));
GMLExportCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.exportGMLButtonDescription"));
GMLExportCheckBox.setSelected(false);
GMLExportCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
GMLExportTextField.setEnabled(true);
GMLExportJButton.setEnabled(true);
} else {
GMLExportTextField.setEnabled(false);
GMLExportJButton.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// optional filename text field
// --------------------------------------------------------------------
GMLExportTextField = new JTextField();
GMLExportTextField
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.gmlExportFileNameDescription"));
GMLExportTextField.setText(gmlFileInfo.getString());
GMLExportTextField.setEnabled(false);
GMLExportTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
GMLExportTextField.setText(" Please Use The Button on the right ->");
}
}
});
// --------------------------------------------------------------------
// optional file search button
// --------------------------------------------------------------------
GMLExportJButton = new JButton("Set Path and Name");
GMLExportJButton
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.gmlExportPathDescription"));
GMLExportJButton.setEnabled(false);
GMLExportJButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gmlFileInfo = saveFileDialog(
".gml",
"GML (*.gml)",
"Speicher CityGML Modell unter ...");
if (null != gmlFileInfo.getPath()) {
GMLExportTextField.setText(gmlFileInfo.getString());
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(exportGMLPanel);
exportGMLPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout
.createSequentialGroup()
.addGap(7)
// make the left side of the component align the buttons of the
// above check related panel
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(GMLExportCheckBox))
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(GMLExportTextField))
.addGap(10)
// pushes the file searchbuttons away
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.LEADING)
.addComponent(GMLExportJButton)).addGap(10));
panelLayout.setVerticalGroup(panelLayout
.createSequentialGroup()
.addGap(10)
// get some space between border and components
.addGroup(
panelLayout
.createParallelGroup(
GroupLayout.Alignment.BASELINE)
.addComponent(GMLExportCheckBox)
.addComponent(GMLExportTextField)
.addComponent(GMLExportJButton))
);
return exportGMLPanel;
}
private JPanel createExportSettingsPanel() {
// panel with surrounding border
JPanel exportSettingsPanel = new JPanel();
exportSettingsPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.exportSettingsPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// create export only valid buildings Check Box
// --------------------------------------------------------------------
exportValidBuildingsOnlyCheckBox = new JCheckBox("valid only");
exportValidBuildingsOnlyCheckBox.setToolTipText("export only valid buildings");
exportValidBuildingsOnlyCheckBox.setEnabled(true);
// --------------------------------------------------------------------
// create move buildings to Origin Check Box
// --------------------------------------------------------------------
moveBuildingBlockToOriginCheckBox = new JCheckBox("move Building to Origin");
moveBuildingBlockToOriginCheckBox.setToolTipText("move Building to Origin");
moveBuildingBlockToOriginCheckBox.setEnabled(true);
// --------------------------------------------------------------------
// create export intermediate stages Check Box
// --------------------------------------------------------------------
exportIntermediateStagesCompleteCheckBox = new JCheckBox("export Intermediate Stages");
exportIntermediateStagesCompleteCheckBox.setToolTipText("export Intermediate Stages ");
exportIntermediateStagesCompleteCheckBox.setEnabled(true);
exportIntermediateStagesCompleteCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
} else {
advancedSweep_General_exportIntermediateStagesCheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create export intermediate stages Check Box
// --------------------------------------------------------------------
exportStepWithOneSolidPerBuilding = new JCheckBox("One Solid Per Building");
exportStepWithOneSolidPerBuilding.setToolTipText("export Step Files with one Solid per Building");
exportStepWithOneSolidPerBuilding.setEnabled(true);
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(exportSettingsPanel);
exportSettingsPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(exportValidBuildingsOnlyCheckBox)
.addComponent(moveBuildingBlockToOriginCheckBox)
.addComponent(exportIntermediateStagesCompleteCheckBox)
.addComponent(exportStepWithOneSolidPerBuilding)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(exportValidBuildingsOnlyCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(moveBuildingBlockToOriginCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(exportIntermediateStagesCompleteCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(exportStepWithOneSolidPerBuilding)
)
);
return exportSettingsPanel;
}
private JPanel createPrintInfoPanel() {
// panel with surrounding border
JPanel printInfoPanel = new JPanel();
printInfoPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.printInfoPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// create Check Box and TextFields
// --------------------------------------------------------------------
printBuildingInfoCheckBox = new JCheckBox("Print Building");
printBuildingInfoCheckBox.setToolTipText("Print Building");
printBuildingInfoCheckBox.setEnabled(true);
printStatusCheckBox = new JCheckBox("Print Status");
printStatusCheckBox.setToolTipText("Print Status");
printStatusCheckBox.setEnabled(true);
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(printInfoPanel);
printInfoPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printBuildingInfoCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printStatusCheckBox)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printBuildingInfoCheckBox)
.addComponent(printStatusCheckBox)
)
);
return printInfoPanel;
}
private JPanel createComparisonPanel() {
// panel with surrounding border
JPanel comparisonPanel = new JPanel();
comparisonPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.comparisonPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// create Check Box and TextFields
// --------------------------------------------------------------------
printAllCheckBox = new JCheckBox("Print all");
printAllCheckBox.setToolTipText("Print all");
printAllCheckBox.setEnabled(true);
printAllCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
printSmallestAngleCheckBox.setSelected(true);
printNumberOfSmallAnglesCheckBox.setSelected(true);
printShortestEdgeCheckBox.setSelected(true);
printNumberOfShortEdgesCheckBox.setSelected(true);
printVolumeCheckBox.setSelected(true);
printNumberOfFacesAndVerticesCheckBox.setSelected(true);
} else {
printSmallestAngleCheckBox.setSelected(false);
printNumberOfSmallAnglesCheckBox.setSelected(false);
printShortestEdgeCheckBox.setSelected(false);
printNumberOfShortEdgesCheckBox.setSelected(false);
printVolumeCheckBox.setSelected(false);
printNumberOfFacesAndVerticesCheckBox.setSelected(false);
}
}
});
printSmallestAngleCheckBox = new JCheckBox("Print smallest angle");
printSmallestAngleCheckBox.setToolTipText("Print smallest angle between two edges to JAVA console");
printSmallestAngleCheckBox.setEnabled(true);
printNumberOfSmallAnglesCheckBox = new JCheckBox("Print number of small angles");
printNumberOfSmallAnglesCheckBox.setToolTipText("Print number of small angles to JAVA console");
printNumberOfSmallAnglesCheckBox.setEnabled(true);
final DecimalFormat dfSmallAngleTol = new DecimalFormat("0.###");
smallAngleTolerance = 10;
smallAngleToleranceTextField = new JTextField();
smallAngleToleranceTextField.setToolTipText("angles between two edges smaller than this value (angle in degrees) are printed to JAVA console (DON'T FORGET TO PRESS ENTER)");
smallAngleToleranceTextField.setEnabled(true);
smallAngleToleranceTextField.setText(dfSmallAngleTol.format(smallAngleTolerance));
smallAngleToleranceTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = smallAngleToleranceTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed);
smallAngleTolerance = value;
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'));
smallAngleTolerance = value;
return;
}
else
{
return;
}
}
}
});
printShortestEdgeCheckBox = new JCheckBox("Print shortest edge");
printShortestEdgeCheckBox.setToolTipText("Print shortest edge to Java console");
printShortestEdgeCheckBox.setEnabled(true);
printNumberOfShortEdgesCheckBox = new JCheckBox("Print number of short edges");
printNumberOfShortEdgesCheckBox.setToolTipText("Print number of short edges to JAVA console");
printNumberOfShortEdgesCheckBox.setEnabled(true);
final DecimalFormat dfShortEdgeTol = new DecimalFormat("0.###");
shortEdgesTolerance = 2.0;
shortEdgesToleranceTextField = new JTextField();
shortEdgesToleranceTextField.setToolTipText("edges smaller than this value (size in meter) are printed to JAVA console (DON'T FORGET TO PRESS ENTER)");
shortEdgesToleranceTextField.setEnabled(true);
shortEdgesToleranceTextField.setText(dfShortEdgeTol.format(shortEdgesTolerance));
shortEdgesToleranceTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = shortEdgesToleranceTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed);
shortEdgesTolerance = value;
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'));
shortEdgesTolerance = value;
return;
}
else
{
return;
}
}
}
});
printVolumeCheckBox = new JCheckBox("Print volume");
printVolumeCheckBox.setToolTipText("Print volume of building(s) to JAVA console");
printVolumeCheckBox.setEnabled(true);
printNumberOfFacesAndVerticesCheckBox = new JCheckBox("Print number of faces and vertices ");
printNumberOfFacesAndVerticesCheckBox.setToolTipText("Print the number of faces and vertices for each building before and after the simplification");
printNumberOfFacesAndVerticesCheckBox.setEnabled(true);
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(comparisonPanel);
comparisonPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printAllCheckBox)
.addComponent(printSmallestAngleCheckBox)
.addComponent(printShortestEdgeCheckBox)
.addComponent(printVolumeCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//.addComponent(NULL)
.addComponent(printNumberOfSmallAnglesCheckBox)
.addComponent(printNumberOfShortEdgesCheckBox)
.addComponent(printNumberOfFacesAndVerticesCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//.addComponent(NULL)
.addComponent(smallAngleToleranceTextField)
.addComponent(shortEdgesToleranceTextField)
//.addComponent(NULL)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printAllCheckBox)
//.addComponent(NULL)
//.addComponent(NULL)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printSmallestAngleCheckBox)
.addComponent(printNumberOfSmallAnglesCheckBox)
.addComponent(smallAngleToleranceTextField)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printShortestEdgeCheckBox)
.addComponent(printNumberOfShortEdgesCheckBox)
.addComponent(shortEdgesToleranceTextField)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printVolumeCheckBox)
.addComponent(printNumberOfFacesAndVerticesCheckBox)
//.addComponent(NULL)
)
);
return comparisonPanel;
}
private JPanel createBoolPanel() {
// panel with surrounding border
JPanel boolPanel = new JPanel();
boolPanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.boolPanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// use bool Check Box
// --------------------------------------------------------------------
boolCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.boolButtonTitle"));
boolCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.boolButtonDescription"));
boolCheckBox.setSelected(false);
boolCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
printBoolInfoCheckBox.setEnabled(true);
} else {
printBoolInfoCheckBox.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// print bool info Check Box
// --------------------------------------------------------------------
printBoolInfoCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.boolInfoButtonTitle"));
printBoolInfoCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.boolInfoButtonDescription"));
printBoolInfoCheckBox.setSelected(false);
printBoolInfoCheckBox.setEnabled(false);
// --------------------------------------------------------------------
// use minkowski Check Box
// --------------------------------------------------------------------
minkowskiCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.minkowskiButtonTitle"));
minkowskiCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.minkowskiButtonDescription"));
minkowskiCheckBox.setSelected(false);
minkowskiCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
printMinkowskiInfoCheckBox.setEnabled(true);
minkowskiCubeLabel.setEnabled(true);
minkowskiCubeSlider.setEnabled(true);
minkowskiCubeTextField.setEnabled(true);
rotateMinkowskiCube.setEnabled(true);
} else {
printMinkowskiInfoCheckBox.setEnabled(false);
minkowskiCubeLabel.setEnabled(false);
minkowskiCubeSlider.setEnabled(false);
minkowskiCubeTextField.setEnabled(false);
rotateMinkowskiCube.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// print minkowski info Check Box
// --------------------------------------------------------------------
printMinkowskiInfoCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.minkowskiInfoButtonTitle"));
printMinkowskiInfoCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.minkowskiInfoButtonDescription"));
printMinkowskiInfoCheckBox.setSelected(false);
printMinkowskiInfoCheckBox.setEnabled(false);
// --------------------------------------------------------------------
// minkowskiCubeSize label, slider and text field
// --------------------------------------------------------------------
minkowskiCubeLabel = new JLabel("minkowskiCube Size");
minkowskiCubeLabel.setEnabled(false);
final DecimalFormat dfMinkowskiCube = new DecimalFormat("0.#");
minkowskiCubeSlider = new DoubleJSlider(1, 50, 20, 10);
minkowskiCubeSlider.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.minkowskiCubeSliderDescription"));
minkowskiCubeSlider.setMinorTickSpacing(10);
minkowskiCubeSlider.setPaintTicks(true);
minkowskiCubeSlider.setEnabled(false);
minkowskiCubeTextField = new JTextField();
minkowskiCubeTextField
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.minkowskiCubeDescription"));
minkowskiCubeTextField.setEnabled(false);
minkowskiCubeTextField.setText(dfMinkowskiCube.format(minkowskiCubeSlider.getScaledValue()));
minkowskiCubeSlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
minkowskiCubeTextField.setText(dfMinkowskiCube.format(minkowskiCubeSlider.getScaledValue()));
}
});
minkowskiCubeTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = minkowskiCubeTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*minkowskiCubeSlider.scale;
minkowskiCubeSlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*minkowskiCubeSlider.scale;
minkowskiCubeSlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// export intermediate stages Check Box
// --------------------------------------------------------------------
boolMinkowski_exportIntermediateStagesCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.boolMinkowski_exportIntermediateStagesCheckBoxButtonTitle"));
boolMinkowski_exportIntermediateStagesCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.boolMinkowski_exportIntermediateStagesCheckBoxButtonDescription"));
// --------------------------------------------------------------------
// rotate Minkowski Cube Check Box
// --------------------------------------------------------------------
rotateMinkowskiCube = new JCheckBox("rotateMinkowskiCube");
rotateMinkowskiCube.setToolTipText("rotates the Minkowski-Cube corresponding to the biggest wallface if selcted");
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(boolPanel);
boolPanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(boolCheckBox)
.addComponent(minkowskiCheckBox)
.addComponent(minkowskiCubeLabel)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(boolMinkowski_exportIntermediateStagesCheckBox)
.addComponent(rotateMinkowskiCube)
.addComponent(minkowskiCubeSlider)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printBoolInfoCheckBox)
.addComponent(printMinkowskiInfoCheckBox)
.addComponent(minkowskiCubeTextField)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(boolCheckBox)
.addComponent(boolMinkowski_exportIntermediateStagesCheckBox)
.addComponent(printBoolInfoCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(minkowskiCheckBox)
.addComponent(rotateMinkowskiCube)
.addComponent(printMinkowskiInfoCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(minkowskiCubeLabel)
.addComponent(minkowskiCubeSlider)
.addComponent(minkowskiCubeTextField)
)
);
return boolPanel;
}
private JPanel createMergePanel() {
// panel with surrounding border
JPanel mergePanel = new JPanel();
mergePanel.setBorder(createTitledBorder(CDAutoProGuiMessages
.getString("AutoProWindow.mergePanel")));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// use merge Check Box
// --------------------------------------------------------------------
mergeCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.mergeButtonTitle"));
mergeCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.mergeButtonDescription"));
mergeCheckBox.setSelected(false);
mergeCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
printMergeInfoCheckBox.setEnabled(true);
merge_exportIntermediateStagesCheckBox.setEnabled(true);
eps_PointEqualityLabel.setEnabled(true);
eps_PointEqualitySlider.setEnabled(true);
eps_PointEqualityTextField.setEnabled(true);
eps_ParallelityLabel.setEnabled(true);
eps_ParallelitySlider.setEnabled(true);
eps_ParallelityTextField.setEnabled(true);
} else {
printMergeInfoCheckBox.setEnabled(false);
merge_exportIntermediateStagesCheckBox.setEnabled(false);
eps_PointEqualityLabel.setEnabled(false);
eps_PointEqualitySlider.setEnabled(false);
eps_PointEqualityTextField.setEnabled(false);
eps_ParallelityLabel.setEnabled(false);
eps_ParallelitySlider.setEnabled(false);
eps_ParallelityTextField.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// export intermediate stages Check Box
// --------------------------------------------------------------------
merge_exportIntermediateStagesCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.merge_exportIntermediateStagesCheckBoxButtonTitle"));
merge_exportIntermediateStagesCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.merge_exportIntermediateStagesCheckBoxButtonDescription"));
merge_exportIntermediateStagesCheckBox.setEnabled(false);
// --------------------------------------------------------------------
// print merge info Check Box
// --------------------------------------------------------------------
printMergeInfoCheckBox = new JCheckBox(
CDAutoProGuiMessages.getString("AutoProWindow.mergeInfoButtonTitle"));
printMergeInfoCheckBox.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.mergeInfoButtonDescription"));
printMergeInfoCheckBox.setSelected(false);
// --------------------------------------------------------------------
// eps_PointEquality label, slider and text field
// --------------------------------------------------------------------
eps_PointEqualityLabel = new JLabel("Point Equality Tolerance");
eps_PointEqualityLabel.setEnabled(false);
final DecimalFormat dfAngleTol_PE = new DecimalFormat("0.###");
eps_PointEqualitySlider = new DoubleJSlider(0, 1000, 20, 1000);
eps_PointEqualitySlider.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.eps_PointEqualitySliderDescription"));
eps_PointEqualitySlider.setMinorTickSpacing(100);
eps_PointEqualitySlider.setPaintTicks(true);
eps_PointEqualitySlider.setEnabled(false);
eps_PointEqualityTextField = new JTextField();
eps_PointEqualityTextField
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.eps_PointEqualityDescription"));
eps_PointEqualityTextField.setEnabled(false);
eps_PointEqualityTextField.setText(dfAngleTol_PE.format(eps_PointEqualitySlider.getScaledValue()));
eps_PointEqualitySlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
eps_PointEqualityTextField.setText(dfAngleTol_PE.format(eps_PointEqualitySlider.getScaledValue()));
}
});
eps_PointEqualityTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = eps_PointEqualityTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*eps_PointEqualitySlider.scale;
eps_PointEqualitySlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*eps_PointEqualitySlider.scale;
eps_PointEqualitySlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// eps_Parallelity label, slider and text field
// --------------------------------------------------------------------
eps_ParallelityLabel = new JLabel("Parallelity Tolerance");
eps_ParallelityLabel.setEnabled(false);
final DecimalFormat dfAngleTol_P = new DecimalFormat("0.###");
eps_ParallelitySlider = new DoubleJSlider(0, 1000, 10, 1000);
eps_ParallelitySlider.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.eps_ParallelitySliderDescription"));
eps_ParallelitySlider.setMinorTickSpacing(100);
eps_ParallelitySlider.setPaintTicks(true);
eps_ParallelitySlider.setEnabled(false);
eps_ParallelityTextField = new JTextField();
eps_ParallelityTextField
.setToolTipText(CDAutoProGuiMessages
.getString("AutoProWindow.eps_ParallelityDescription"));
eps_ParallelityTextField.setEnabled(false);
eps_ParallelityTextField.setText(dfAngleTol_P.format(eps_ParallelitySlider.getScaledValue()));
eps_ParallelitySlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
eps_ParallelityTextField.setText(dfAngleTol_P.format(eps_ParallelitySlider.getScaledValue()));
}
});
eps_ParallelityTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = eps_ParallelityTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*eps_ParallelitySlider.scale;
eps_ParallelitySlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*eps_ParallelitySlider.scale;
eps_ParallelitySlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(mergePanel);
mergePanel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(mergeCheckBox)
.addComponent(eps_PointEqualityLabel)
.addComponent(eps_ParallelityLabel)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(merge_exportIntermediateStagesCheckBox)
.addComponent(eps_PointEqualitySlider)
.addComponent(eps_ParallelitySlider)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(printMergeInfoCheckBox)
.addComponent(eps_PointEqualityTextField)
.addComponent(eps_ParallelityTextField)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(mergeCheckBox)
.addComponent(merge_exportIntermediateStagesCheckBox)
.addComponent(printMergeInfoCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(eps_PointEqualityLabel)
.addComponent(eps_PointEqualitySlider)
.addComponent(eps_PointEqualityTextField)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(eps_ParallelityLabel)
.addComponent(eps_ParallelitySlider)
.addComponent(eps_ParallelityTextField)
)
);
return mergePanel;
}
private JPanel createAdvancedSweepPanel_General() {
// panel with surrounding border
JPanel advancedSweepPanel_General = new JPanel();
advancedSweepPanel_General.setBorder(createTitledBorder("Advanced Sweep - General Settings"));
// --------------------------------------------------------------------
// create print info Check Box
// --------------------------------------------------------------------
advancedSweep_General_printInfoCheckBox = new JCheckBox("Print Sweep info");
advancedSweep_General_printInfoCheckBox.setToolTipText("Print Sweep info into JAVA terminal");
advancedSweep_General_printInfoCheckBox.setEnabled(true);
advancedSweep_General_printInfoCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_General_printFilterReasonInfoCheckBox.setEnabled(true);
} else {
advancedSweep_General_printFilterReasonInfoCheckBox.setEnabled(false);
advancedSweep_General_printFilterReasonInfoCheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create print info Check Box
// --------------------------------------------------------------------
advancedSweep_General_printFilterReasonInfoCheckBox = new JCheckBox("Print Filter Reasons info");
advancedSweep_General_printFilterReasonInfoCheckBox.setToolTipText("prints the reason why faces cannot by sweep faces");
advancedSweep_General_printFilterReasonInfoCheckBox.setEnabled(false);
// --------------------------------------------------------------------
// create Label for export intermediate stages
// --------------------------------------------------------------------
advancedSweep_General_exportIntermediateStagesCheckBox = new JCheckBox("export stages");
advancedSweep_General_exportIntermediateStagesCheckBox.setToolTipText("exports the intermediate stages within the sweep algorithms");
advancedSweep_General_exportIntermediateStagesCheckBox.setEnabled(true);
advancedSweep_General_exportIntermediateStagesCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
exportIntermediateStagesCompleteCheckBox.setSelected(true);
}
}
});
// --------------------------------------------------------------------
// write minEdgeLength Slider
// --------------------------------------------------------------------
final DecimalFormat dfMinEdge = new DecimalFormat("0.###");
advancedSweep_General_minEdgeLengthLabel = new JLabel("Min Edge Length");
advancedSweep_General_minEdgeLengthSlider = new DoubleJSlider(0, 500, 200, 100);
advancedSweep_General_minEdgeLengthSlider.setToolTipText("after the sweep there shouldn't be no edge left smaller that this value (size in meter)");
advancedSweep_General_minEdgeLengthSlider.setMinorTickSpacing(100);
advancedSweep_General_minEdgeLengthSlider.setPaintTicks(true);
advancedSweep_General_minEdgeLengthSlider.setEnabled(true);
advancedSweep_General_minEdgeLengthTextField = new JTextField();
advancedSweep_General_minEdgeLengthTextField.setToolTipText("after the sweep there shouldn't be no edge left smaller that this value (size in meter)");
advancedSweep_General_minEdgeLengthTextField.setEnabled(true);
advancedSweep_General_minEdgeLengthTextField.setText(dfMinEdge.format(advancedSweep_General_minEdgeLengthSlider.getScaledValue()));
advancedSweep_General_minEdgeLengthSlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
advancedSweep_General_minEdgeLengthTextField.setText(dfMinEdge.format(advancedSweep_General_minEdgeLengthSlider.getScaledValue()));
}
});
advancedSweep_General_minEdgeLengthTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = advancedSweep_General_minEdgeLengthTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*advancedSweep_General_minEdgeLengthSlider.scale;
advancedSweep_General_minEdgeLengthSlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*advancedSweep_General_minEdgeLengthSlider.scale;
advancedSweep_General_minEdgeLengthSlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// write maxEdgeLength Slider
// --------------------------------------------------------------------
final DecimalFormat dfMaxEdge = new DecimalFormat("0.###");
advancedSweep_General_maxEdgeLengthLabel = new JLabel("Max Edge Length");
advancedSweep_General_maxEdgeLengthSlider = new DoubleJSlider(0, 2000, 500, 100);
advancedSweep_General_maxEdgeLengthSlider.setToolTipText("sweep is not allowed if an edge longer than this would completely dissapear (size in meter)");
advancedSweep_General_maxEdgeLengthSlider.setMinorTickSpacing(100);
advancedSweep_General_maxEdgeLengthSlider.setPaintTicks(true);
advancedSweep_General_maxEdgeLengthSlider.setEnabled(true);
advancedSweep_General_maxEdgeLengthTextField = new JTextField();
advancedSweep_General_maxEdgeLengthTextField.setToolTipText("sweep is not allowed if an edge longer than this would completely dissapear (size in meter)");
advancedSweep_General_maxEdgeLengthTextField.setEnabled(true);
advancedSweep_General_maxEdgeLengthTextField.setText(dfMaxEdge.format(advancedSweep_General_maxEdgeLengthSlider.getScaledValue()));
advancedSweep_General_maxEdgeLengthSlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
advancedSweep_General_maxEdgeLengthTextField.setText(dfMinEdge.format(advancedSweep_General_maxEdgeLengthSlider.getScaledValue()));
}
});
advancedSweep_General_maxEdgeLengthTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = advancedSweep_General_maxEdgeLengthTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*advancedSweep_General_maxEdgeLengthSlider.scale;
advancedSweep_General_maxEdgeLengthSlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*advancedSweep_General_maxEdgeLengthSlider.scale;
advancedSweep_General_maxEdgeLengthSlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// write minDistToSweep Slider
// --------------------------------------------------------------------
final DecimalFormat dfMinDist = new DecimalFormat("0.####");
advancedSweep_General_minDistToSweepLabel = new JLabel("Min Dist");
advancedSweep_General_minDistToSweepSlider = new DoubleJSlider(0, 10000, 1, 10000);
advancedSweep_General_minDistToSweepSlider.setToolTipText("No Sweep, if sweep would be less than this value (size in meter)");
advancedSweep_General_minDistToSweepSlider.setMinorTickSpacing(10000);
advancedSweep_General_minDistToSweepSlider.setPaintTicks(true);
advancedSweep_General_minDistToSweepSlider.setEnabled(true);
advancedSweep_General_minDistToSweepTextField = new JTextField();
advancedSweep_General_minDistToSweepTextField.setToolTipText("No Sweep, if sweep would be less than this value (size in meter)");
advancedSweep_General_minDistToSweepTextField.setEnabled(true);
advancedSweep_General_minDistToSweepTextField.setText(dfMinDist.format(advancedSweep_General_minDistToSweepSlider.getScaledValue()));
advancedSweep_General_minDistToSweepSlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
advancedSweep_General_minDistToSweepTextField.setText(dfMinDist.format(advancedSweep_General_minDistToSweepSlider.getScaledValue()));
}
});
advancedSweep_General_minDistToSweepTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = advancedSweep_General_minDistToSweepTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*advancedSweep_General_minDistToSweepSlider.scale;
advancedSweep_General_minDistToSweepSlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*advancedSweep_General_minDistToSweepSlider.scale;
advancedSweep_General_minDistToSweepSlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(advancedSweepPanel_General);
advancedSweepPanel_General.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_General_printInfoCheckBox)
.addComponent(advancedSweep_General_minEdgeLengthLabel)
.addComponent(advancedSweep_General_maxEdgeLengthLabel)
.addComponent(advancedSweep_General_minDistToSweepLabel)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_General_printFilterReasonInfoCheckBox)
.addComponent(advancedSweep_General_minEdgeLengthSlider)
.addComponent(advancedSweep_General_maxEdgeLengthSlider)
.addComponent(advancedSweep_General_minDistToSweepSlider)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_General_exportIntermediateStagesCheckBox)
.addComponent(advancedSweep_General_minEdgeLengthTextField)
.addComponent(advancedSweep_General_maxEdgeLengthTextField)
.addComponent(advancedSweep_General_minDistToSweepTextField)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_General_printInfoCheckBox)
.addComponent(advancedSweep_General_printFilterReasonInfoCheckBox)
.addComponent(advancedSweep_General_exportIntermediateStagesCheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_General_minEdgeLengthLabel)
.addComponent(advancedSweep_General_minEdgeLengthSlider)
.addComponent(advancedSweep_General_minEdgeLengthTextField)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_General_maxEdgeLengthLabel)
.addComponent(advancedSweep_General_maxEdgeLengthSlider)
.addComponent(advancedSweep_General_maxEdgeLengthTextField)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_General_minDistToSweepLabel)
.addComponent(advancedSweep_General_minDistToSweepSlider)
.addComponent(advancedSweep_General_minDistToSweepTextField)
)
);
return advancedSweepPanel_General;
}
private JPanel createAdvancedSweepPanel_Planarity() {
// panel with surrounding border
JPanel advancedSweepPanel_Planarity = new JPanel();
advancedSweepPanel_Planarity.setBorder(createTitledBorder("Advanced Sweep Settings - Planarity"));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// use Planarity Check Box
// --------------------------------------------------------------------
advancedSweep_Planarity_Use_CheckBox = new JCheckBox("Use Planarity");
advancedSweep_Planarity_Use_CheckBox.setToolTipText("Use planarity Algorithm");
advancedSweep_Planarity_Use_CheckBox.setSelected(false);
advancedSweep_Planarity_Use_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox.setEnabled(true);
advancedSweep_Planarity_PlanarityTolerance_SweepLabel.setEnabled(true);
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setEnabled(true);
advancedSweep_Planarity_PlanarityTolerance_TextField.setEnabled(true);
} else {
advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox.setEnabled(false);
advancedSweep_Planarity_PlanarityTolerance_SweepLabel.setEnabled(false);
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setEnabled(false);
advancedSweep_Planarity_PlanarityTolerance_TextField.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// create ignore multiple Points CheckBox
// --------------------------------------------------------------------
advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox = new JCheckBox("Ignore Mult Points");
advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox.setToolTipText("If unselected the target plane will be created through fixpoints");
advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox.setSelected(false);
advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox.setEnabled(false);
// --------------------------------------------------------------------
// write planarity Tolerance Slider
// --------------------------------------------------------------------
final DecimalFormat dfTolerance = new DecimalFormat("0.############");
advancedSweep_Planarity_PlanarityTolerance_SweepLabel = new JLabel("Planarity Tolerance");
advancedSweep_Planarity_PlanarityTolerance_SweepSlider = new DoubleJSlider(0, 1000000000, 1, 1000000000);
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setToolTipText("Planarity Tolerance (size in meter)");
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setMinorTickSpacing(1000000000);
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setPaintTicks(true);
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setEnabled(false);
advancedSweep_Planarity_PlanarityTolerance_TextField = new JTextField();
advancedSweep_Planarity_PlanarityTolerance_TextField.setToolTipText("Planarity Tolerance (size in meter)");
advancedSweep_Planarity_PlanarityTolerance_TextField.setEnabled(false);
advancedSweep_Planarity_PlanarityTolerance_TextField.setText(dfTolerance.format(advancedSweep_Planarity_PlanarityTolerance_SweepSlider.getScaledValue()));
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
advancedSweep_Planarity_PlanarityTolerance_TextField.setText(dfTolerance.format(advancedSweep_Planarity_PlanarityTolerance_SweepSlider.getScaledValue()));
}
});
advancedSweep_Planarity_PlanarityTolerance_TextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = advancedSweep_Planarity_PlanarityTolerance_TextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*advancedSweep_Planarity_PlanarityTolerance_SweepSlider.scale;
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*advancedSweep_Planarity_PlanarityTolerance_SweepSlider.scale;
advancedSweep_Planarity_PlanarityTolerance_SweepSlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(advancedSweepPanel_Planarity);
advancedSweepPanel_Planarity.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_Planarity_Use_CheckBox)
.addComponent(advancedSweep_Planarity_PlanarityTolerance_SweepLabel)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox)
.addComponent(advancedSweep_Planarity_PlanarityTolerance_SweepSlider)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//.addComponent(null)
.addComponent(advancedSweep_Planarity_PlanarityTolerance_TextField)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_Planarity_Use_CheckBox)
.addComponent(advancedSweep_Planarity_IgnoreMultiplePoints_CheckBox)
//.addComponent(null)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_Planarity_PlanarityTolerance_SweepLabel)
.addComponent(advancedSweep_Planarity_PlanarityTolerance_SweepSlider)
.addComponent(advancedSweep_Planarity_PlanarityTolerance_TextField)
)
);
return advancedSweepPanel_Planarity;
}
private JPanel createAdvancedSweepPanel_SweepPlane() {
// panel with surrounding border
JPanel advancedSweepPanel_SweepPlane = new JPanel();
advancedSweepPanel_SweepPlane.setBorder(createTitledBorder("Advanced Sweep Settings - SweepPlane"));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// use Planarity Check Box
// --------------------------------------------------------------------
advancedSweep_SweepPlane_Use_CheckBox = new JCheckBox("Use SweepPlane");
advancedSweep_SweepPlane_Use_CheckBox.setToolTipText("Use SweepPlane Algorithm");
advancedSweep_SweepPlane_Use_CheckBox.setSelected(false);
advancedSweep_SweepPlane_Use_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepPlane_PushOnly_CheckBox.setEnabled(true);
advancedSweep_SweepPlane_PullOnly_CheckBox.setEnabled(true);
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.setEnabled(true);
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.setEnabled(true);
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.setEnabled(true);
} else {
advancedSweep_SweepPlane_PushOnly_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_PullOnly_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// create push only CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepPlane_PushOnly_CheckBox = new JCheckBox("Push Only");
advancedSweep_SweepPlane_PushOnly_CheckBox.setToolTipText("faces will only be pushed into the geometry");
advancedSweep_SweepPlane_PushOnly_CheckBox.setSelected(false);
advancedSweep_SweepPlane_PushOnly_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_PushOnly_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepPlane_PullOnly_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create pull only CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepPlane_PullOnly_CheckBox = new JCheckBox("Pull Only");
advancedSweep_SweepPlane_PullOnly_CheckBox.setToolTipText("faces will only be pulled out of the geometry");
advancedSweep_SweepPlane_PullOnly_CheckBox.setSelected(false);
advancedSweep_SweepPlane_PullOnly_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_PullOnly_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepPlane_PushOnly_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create shortest edge first CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox = new JCheckBox("Shortest Edge First");
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.setToolTipText("Shortest Edge First");
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.setSelected(false);
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.setSelected(false);
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create smallest face first CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox = new JCheckBox("Smallest Face First");
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.setToolTipText("Smallest Face First");
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.setSelected(false);
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.setSelected(false);
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create smallest distance first CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox = new JCheckBox("Smallest Dist First");
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.setToolTipText("Smallest Dist First");
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.setSelected(false);
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.setEnabled(false);
advancedSweep_SweepPlane_SmallestDistFirst_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox.setSelected(false);
advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(advancedSweepPanel_SweepPlane);
advancedSweepPanel_SweepPlane.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepPlane_Use_CheckBox)
.addComponent(advancedSweep_SweepPlane_PushOnly_CheckBox)
.addComponent(advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//.addComponent(null)
.addComponent(advancedSweep_SweepPlane_PullOnly_CheckBox)
.addComponent(advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//.addComponent(null)
//.addComponent(null)
.addComponent(advancedSweep_SweepPlane_SmallestDistFirst_CheckBox)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepPlane_Use_CheckBox)
//.addComponent(null)
//.addComponent(null)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepPlane_PushOnly_CheckBox)
.addComponent(advancedSweep_SweepPlane_PullOnly_CheckBox)
//.addComponent(null)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepPlane_ShortestEdgeFirst_CheckBox)
.addComponent(advancedSweep_SweepPlane_SmallestFaceFirst_CheckBox)
.addComponent(advancedSweep_SweepPlane_SmallestDistFirst_CheckBox)
)
);
return advancedSweepPanel_SweepPlane;
}
private JPanel createAdvancedSweepPanel_SweepRotate() {
// panel with surrounding border
JPanel advancedSweepPanel_SweepRotate = new JPanel();
advancedSweepPanel_SweepRotate.setBorder(createTitledBorder("Advanced Sweep Settings - SweepRotate"));
// ----------------------------- CONTENT -----------------------------
// --------------------------------------------------------------------
// use Planarity Check Box
// --------------------------------------------------------------------
advancedSweep_SweepRotate_Use_CheckBox = new JCheckBox("Use SweepRotate");
advancedSweep_SweepRotate_Use_CheckBox.setToolTipText("Use SweepRotate Algorithm");
advancedSweep_SweepRotate_Use_CheckBox.setSelected(false);
advancedSweep_SweepRotate_Use_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepRotate_MinDistFirst_CheckBox.setEnabled(true);
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.setEnabled(true);
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.setEnabled(true);
} else {
advancedSweep_SweepRotate_MinDistFirst_CheckBox.setEnabled(false);
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.setEnabled(false);
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.setEnabled(false);
}
}
});
// --------------------------------------------------------------------
// write max Angle Slider
// --------------------------------------------------------------------
final DecimalFormat dfAngle = new DecimalFormat("0.####");
advancedSweep_SweepRotate_maxAngleLabel = new JLabel("Min Angle");
advancedSweep_SweepRotate_maxAngleSlider = new DoubleJSlider(0, 600, 100, 10);
advancedSweep_SweepRotate_maxAngleSlider.setToolTipText("Sweep rotate, if angle between two edges is lower than this value (angle in degrees)");
advancedSweep_SweepRotate_maxAngleSlider.setMinorTickSpacing(100);
advancedSweep_SweepRotate_maxAngleSlider.setPaintTicks(true);
advancedSweep_SweepRotate_maxAngleSlider.setEnabled(true);
advancedSweep_SweepRotate_maxAngleTextField = new JTextField();
advancedSweep_SweepRotate_maxAngleTextField.setToolTipText("Sweep rotate, if angle between two edges is lower than this value (angle in degrees)");
advancedSweep_SweepRotate_maxAngleTextField.setEnabled(true);
advancedSweep_SweepRotate_maxAngleTextField.setText(dfAngle.format(advancedSweep_SweepRotate_maxAngleSlider.getScaledValue()));
advancedSweep_SweepRotate_maxAngleSlider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
advancedSweep_SweepRotate_maxAngleTextField.setText(dfAngle.format(advancedSweep_SweepRotate_maxAngleSlider.getScaledValue()));
}
});
advancedSweep_SweepRotate_maxAngleTextField.addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_ENTER)
{
String typed = advancedSweep_SweepRotate_maxAngleTextField.getText();
if(typed.matches("\\d+(\\.\\d*)?")) {
double value = Double.parseDouble(typed)*advancedSweep_SweepRotate_maxAngleSlider.scale;
advancedSweep_SweepRotate_maxAngleSlider.setValue((int)value);
}
else if (typed.matches("\\d+(\\,\\d*)?")) {
double value = Double.parseDouble(typed.replace(',','.'))*advancedSweep_SweepRotate_maxAngleSlider.scale;
advancedSweep_SweepRotate_maxAngleSlider.setValue((int)value);
return;
}
else
{
return;
}
}
}
});
// --------------------------------------------------------------------
// create min dist first CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepRotate_MinDistFirst_CheckBox = new JCheckBox("Min. Distance First");
advancedSweep_SweepRotate_MinDistFirst_CheckBox.setToolTipText("Minimal Distance First");
advancedSweep_SweepRotate_MinDistFirst_CheckBox.setSelected(false);
advancedSweep_SweepRotate_MinDistFirst_CheckBox.setEnabled(false);
advancedSweep_SweepRotate_MinDistFirst_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.setSelected(false);
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create min angle first CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepRotate_MinAngleFirst_CheckBox = new JCheckBox("Min. Angle First");
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.setToolTipText("Minimal Angle First");
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.setSelected(false);
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.setEnabled(false);
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepRotate_MinDistFirst_CheckBox.setSelected(false);
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create smallest face first CheckBox
// --------------------------------------------------------------------
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox = new JCheckBox("Smallest Face First");
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.setToolTipText("Smallest Face First");
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.setSelected(false);
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.setEnabled(false);
advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) {
advancedSweep_SweepRotate_MinDistFirst_CheckBox.setSelected(false);
advancedSweep_SweepRotate_MinAngleFirst_CheckBox.setSelected(false);
}
}
});
// --------------------------------------------------------------------
// create layout
// --------------------------------------------------------------------
GroupLayout panelLayout = new GroupLayout(advancedSweepPanel_SweepRotate);
advancedSweepPanel_SweepRotate.setLayout(panelLayout);
panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepRotate_Use_CheckBox)
.addComponent(advancedSweep_SweepRotate_maxAngleLabel)
.addComponent(advancedSweep_SweepRotate_MinAngleFirst_CheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//.addComponent(NULL)
.addComponent(advancedSweep_SweepRotate_maxAngleSlider)
.addComponent(advancedSweep_SweepRotate_MinDistFirst_CheckBox)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//.addComponent(NULL)
.addComponent(advancedSweep_SweepRotate_maxAngleTextField)
.addComponent(advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox)
)
);
panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepRotate_Use_CheckBox)
//.addComponent(NULL)
//.addComponent(NULL)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepRotate_maxAngleLabel)
.addComponent(advancedSweep_SweepRotate_maxAngleSlider)
.addComponent(advancedSweep_SweepRotate_maxAngleTextField)
)
.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(advancedSweep_SweepRotate_MinAngleFirst_CheckBox)
.addComponent(advancedSweep_SweepRotate_MinDistFirst_CheckBox)
.addComponent(advancedSweep_SweepRotate_SmallestFaceFirst_CheckBox)
)
);
return advancedSweepPanel_SweepRotate;
}
private JPanel createExecuteButtonPanel() {
JPanel executePanel = new JPanel(new FlowLayout());
JButton execBtn = new JButton(
CDAutoProGuiMessages.getString("AutoProWindow.OkButtonLabel"));
execBtn.setMinimumSize(new Dimension(stdBtnWidth, stdBtnHeight));
execBtn.setMaximumSize(new Dimension(stdBtnWidth, stdBtnHeight));
execBtn.setPreferredSize(new Dimension(stdBtnWidth, stdBtnHeight));
execBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
startCppAutoProMethods();
} catch (FileNotFoundException e1) {
// Auto-generated catch block
e1.printStackTrace();
}
close();
}
});
executePanel.add(execBtn);
JButton cancelBtn = new JButton(
CDAutoProGuiMessages.getString("AutoProWindow.CancelButtonLabel"));
cancelBtn.setMinimumSize(new Dimension(stdBtnWidth, stdBtnHeight));
cancelBtn.setMaximumSize(new Dimension(stdBtnWidth, stdBtnHeight));
cancelBtn.setPreferredSize(new Dimension(stdBtnWidth, stdBtnHeight));
cancelBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
close();
}
});
executePanel.add(cancelBtn);
return executePanel;
}
// NOTE: this is a hack, to provide the file type and the description for
// the inner FileFilter class in the saveFileDialog method
private String currSaveTypeDescription;
private String currSaveFileType;
/**
* @param The target file type
* @param The description of the the file type
* @param The dialog title
* @return The FileInfo with absolute path, name and type for the selected file
*/
private FileInfo saveFileDialog(String fileType, String typeDescription,
String dialogTitle) {
if (!fileType.startsWith("."))
fileType = "." + fileType;
currSaveFileType = fileType;
currSaveTypeDescription = typeDescription;
JFileChooser fileChooser = new JFileChooser(new File("."));
fileChooser.setDialogTitle(dialogTitle);
fileChooser.setAcceptAllFileFilterUsed(false);
fileChooser.setFileFilter(new FileFilter() {
@Override
public String getDescription() {
return currSaveTypeDescription;
}
@Override
public boolean accept(File f) {
return f.isDirectory()
|| f.getName().toLowerCase().endsWith(currSaveFileType);
}
});
int userSelection = fileChooser.showSaveDialog(this);
if (userSelection == JFileChooser.APPROVE_OPTION) {
FileInfo fileInfo = new FileInfo();
fileInfo.setType(fileType);
String filename = fileChooser.getSelectedFile().getName();
if (filename.endsWith(fileType))
{
int pos = filename.lastIndexOf(".");
if (pos > 0) {
filename = filename.substring(0, pos);
}
}
fileInfo.setName(filename);
String absolutePath = fileChooser.getSelectedFile().getAbsolutePath();
fileInfo.setPath(absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)) + "\\");
return fileInfo;
} else
return null;
}
private TitledBorder createTitledBorder(String heading) {
Border baseBorder = new LineBorder(Color.GRAY); // to have a gray border
Font headingFont = new Font("Arial", Font.BOLD + Font.ITALIC, 13);
TitledBorder finalBorder = new TitledBorder(baseBorder, heading,
TitledBorder.DEFAULT_POSITION,
TitledBorder.DEFAULT_JUSTIFICATION, headingFont,
Color.DARK_GRAY);
return finalBorder;
}
/**
* test
*
* @param args
*/
public static void main(String[] args) {
AutoProWindow v = new AutoProWindow(null);
v.setVisible(true);
}
@Override
public void itemStateChanged(ItemEvent paramItemEvent) {
// Auto-generated method stub
}
}
/** --------------------------------------------------
* Hochschule fuer Technik Stuttgart
* Fachbereich Vermessung , Informatik und Mathematik
* Schellingstr . 24
* D - 70174 Stuttgart
*
* Projekt CityDoktor
*
* Copyright (c) 2011 HFT Stuttgart. All rights reserved.
* HFT Stuttgart and its licensors retain all intellectual property and
* proprietary rights in and to this software and related documentation.
* Any use, reproduction, disclosure, or distribution of this software
* and related documentation without an express license agreement from
* HFT Stuttgart is strictly prohibited.
*
* Please refer to the applicable HFT Stuttgart end user license agreement (EULA)
* associated with this source code for terms and conditions that govern
* your use of this HFT Stuttgart software.
*
* @author PiR
* @version 1.0
* created: 17.12.2017
*/
package de.hft.stuttgart.citydoctor2.gui;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Diese Klasse ermoeglicht den Zugriff auf das ResourceBundle mit den
* lokalisierten Strings.
*
*/
public class CDAutoProGuiMessages {
private static final String BUNDLE_NAME = "de.hft.stuttgart.citydoctor2.gui.cdautoproguimessages"; //$NON-NLS-1$
private CDAutoProGuiMessages() {
}
/**
* Diese Methode laedt einen String aus dem ResourceBundle.
*
* @param key der Schluessel des Strings
* @return der String
*/
public static String getString(String key) {
ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME, Locale.getDefault());
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}
CityDoctorAutoProFrame.WindowTitle=CityDoctor Automated Processing Tool
CityDoctorAutoProFrame.autoProActionTitle=Automated Processing
CityDoctorAutoProFrame.autoProActionText=Automated Processing
AutoProWindow.PreferencesWindowTitle = Automated Processing Window
// EXPORT
AutoProWindow.exportMeshPanel = export Mesh File via CPP (only original model can be printed)
AutoProWindow.exportMeshButtonTitle = export Mesh
AutoProWindow.exportMeshButtonDescription = export Mesh File via CPP
AutoProWindow.meshExportFileNameDescription = Hier kann optional der Name fuer die Mesh Datei angegeben werden
AutoProWindow.meshExportPathDescription = Hier kann optional der Speicherort fuer die Mesh Datei angegeben werden
AutoProWindow.exportMeshReportDialogTitle = Export Mesh File to...
AutoProWindow.exportIVPanel = export IV File via CPP
AutoProWindow.exportIVButtonTitle = export IV
AutoProWindow.exportIVButtonDescription = export IV File via CPP
AutoProWindow.ivExportFileNameDescription = Hier kann optional der Name fuer die IV Datei angegeben werden
AutoProWindow.ivExportPathDescription = Hier kann optional der Speicherort fuer die IV Datei angegeben werden
AutoProWindow.exportIVReportDialogTitle = Export IV File to...
AutoProWindow.exportSTEPPanel = export STEP File via CPP
AutoProWindow.exportSTEPButtonTitle = export STEP
AutoProWindow.exportSTEPButtonDescription = export STEP File via CPP
AutoProWindow.stepExportFileNameDescription = Hier kann optional der Name fuer die STEP Datei angegeben werden
AutoProWindow.stepExportPathDescription = Hier kann optional der Speicherort fuer die STEP Datei angegeben werden
AutoProWindow.exportSTEPReportDialogTitle = Export STEP File to...
AutoProWindow.exportGMLPanel = export CityGML File via CPP
AutoProWindow.exportGMLButtonTitle = export CityGML
AutoProWindow.exportGMLButtonDescription = export CityGML File via CPP
AutoProWindow.gmlExportFileNameDescription = Hier kann optional der Name fuer die CityGML Datei angegeben werden
AutoProWindow.gmlExportPathDescription = Hier kann optional der Speicherort fuer die CityGML Datei angegeben werden
AutoProWindow.exportGMLReportDialogTitle = Export CityGML File to...
AutoProWindow.exportSettingsPanel = General Setting for Export
//
AutoProWindow.printInfoPanel = General Print Info Settings
AutoProWindow.comparisonPanel = Print Settings for validation/comparison
// BOOL
AutoProWindow.boolPanel = Bool and Minkowski settings
AutoProWindow.boolButtonTitle = use Bool
AutoProWindow.boolButtonDescription = uses CGALs union operator to merge houses
AutoProWindow.boolInfoButtonTitle = Print Bool info
AutoProWindow.boolInfoButtonDescription = Print Bool info into JAVA terminal
AutoProWindow.minkowskiPanel = Minkowski settings
AutoProWindow.minkowskiButtonTitle = use Minkowski
AutoProWindow.minkowskiButtonDescription = uses CGALs minkowski operations
AutoProWindow.minkowskiInfoButtonTitle = Print Minkowski info
AutoProWindow.minkowskiInfoButtonDescription = Print Minkowski info into JAVA terminal
AutoProWindow.minkowskiCubeDescription = Sets the size of the minkowski cube (size in meter)
AutoProWindow.minkowskiCubeSliderDescription = Sets the size of the minkowski cube (size in meter)
AutoProWindow.boolMinkowski_exportIntermediateStagesCheckBoxButtonTitle = export intermediate stages
AutoProWindow.boolMinkowski_exportIntermediateStagesCheckBoxButtonDescription = if selected writes the intermediate stages of the algorithm to .iv and .step
// MERGE
AutoProWindow.mergePanel = Merge settings
AutoProWindow.mergeButtonTitle = use Merge
AutoProWindow.mergeButtonDescription = merges parallel, connected faces and edges and collapses degenerated faces and edges
AutoProWindow.merge_exportIntermediateStagesCheckBoxButtonTitle = export intermediate stages
AutoProWindow.merge_exportIntermediateStagesCheckBoxButtonDescription = if selected writes the intermediate stages of the algorithm to .iv and .step
AutoProWindow.mergeInfoButtonTitle = Print Merge info
AutoProWindow.mergeInfoButtonDescription = Print Merge info into JAVA terminal
AutoProWindow.eps_PointEqualitySliderDescription = Point Equality Tolerance (size in meter)
AutoProWindow.eps_PointEqualityDescription = if an edge is shorter than this tolerance the edge degenerates to a vertex
AutoProWindow.eps_ParallelitySliderDescription = Parallelity Tolerance (angle in degrees)
AutoProWindow.eps_ParallelityDescription = two vectors v1, v2 or planes (v are the planes' normal) are (anti-)parallel if |(v1 % v2) - (v1.length * v1.length)| < eps
// OK CANCEL
AutoProWindow.OkButtonLabel = DO IT
AutoProWindow.CancelButtonLabel = Cancel
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<ns prefix="gml" uri="http://www.opengis.net/gml"/>
<ns prefix="bldg" uri="http://www.opengis.net/citygml/building/2.0"/>
<pattern>
<rule context="//*:Building">
<assert test="count(descendant::*:lod1Solid) &gt; 0 or count(descendant::*:lod2Solid) &gt; 0 or count(descendant::*:lod3Solid) &gt; 0 or count(descendant::*:lod4Solid) &gt; 0"><value-of select="@gml:id | @id"/>||||SE_ATTRIBUTE_MISSING||any solid</assert>
</rule>
<rule context="//*:BuildingPart">
<assert test="count(*:lod1Solid) = 1 or count(*:lod2Solid) = 1 or count(*:lod3Solid) = 1 or count(*:lod4Solid) = 1"><value-of select="ancestor::*:Building/@*:id"/>||<value-of select="@gml:id | @id"/>||SE_ATTRIBUTE_MISSING||any solid</assert>
</rule>
</pattern>
</schema>
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.14.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>CityDoctorGUI</artifactId>
<name>CityDoctorGUI</name>
<description>Graphical User Interface for CityDoctor</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorModel</artifactId>
</dependency>
<dependency>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorValidation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
<id>create-binaries</id>
<properties>
<win-jre>jre-${jre-version-short}-full</win-jre>
<lin-jre>${win-jre}</lin-jre>
<mac-jre>${win-jre}.jre</mac-jre>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<id>downloadWindowsJre</id>
<phase>install</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<uri>https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-windows-amd64-full.zip</uri>
<unpack>false</unpack>
<outputDirectory>${project.build.directory}/jre/jre-win</outputDirectory>
<outputFileName>win-runtime.zip</outputFileName>
</configuration>
</execution>
<execution>
<id>downloadLinuxJre</id>
<phase>install</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<uri>https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-linux-amd64-full.tar.gz</uri>
<unpack>false</unpack>
<outputDirectory>${project.build.directory}/jre/jre-lin</outputDirectory>
<outputFileName>lin-runtime.tar.gz</outputFileName>
</configuration>
</execution>
<execution>
<id>downloadMacJre</id>
<phase>install</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<uri>https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-macos-amd64-full.zip</uri>
<unpack>false</unpack>
<outputDirectory>${project.build.directory}/jre/jre-mac</outputDirectory>
<outputFileName>mac-runtime.zip</outputFileName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>unpack</id>
<phase>install</phase>
<configuration>
<target name="unpack">
<untar src="${project.build.directory}/jre/jre-lin/lin-runtime.tar.gz" dest="${project.build.directory}/jre/jre-lin/runtime" compression="gzip"></untar>
<unzip src="${project.build.directory}/jre/jre-win/win-runtime.zip" dest="${project.build.directory}/jre/jre-win/runtime"></unzip>
<unzip src="${project.build.directory}/jre/jre-mac/mac-runtime.zip" dest="${project.build.directory}/jre/jre-mac/runtime"></unzip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>create-archive-no-runtime</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}-no-runtime</finalName>
<descriptors>
<descriptor>${project.basedir}/src/assembly/no_runtime/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>create-archive-win</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}-win</finalName>
<descriptors>
<descriptor>${project.basedir}/src/assembly/win/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>create-archive-lin</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}-lin</finalName>
<descriptors>
<descriptor>${project.basedir}/src/assembly/lin/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>create-archive-mac</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}-mac</finalName>
<descriptors>
<descriptor>${project.basedir}/src/assembly/mac/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<ns prefix="gml" uri="http://www.opengis.net/gml"/>
<ns prefix="bldg" uri="http://www.opengis.net/citygml/building/2.0"/>
<pattern>
<rule context="//*:Building">
<assert test="count(descendant::*:lod1Solid) &gt; 0 or count(descendant::*:lod2Solid) &gt; 0 or count(descendant::*:lod3Solid) &gt; 0 or count(descendant::*:lod4Solid) &gt; 0"><value-of select="@gml:id | @id"/>||||SE_ATTRIBUTE_MISSING||any solid</assert>
</rule>
<rule context="//*:BuildingPart">
<assert test="count(*:lod1Solid) = 1 or count(*:lod2Solid) = 1 or count(*:lod3Solid) = 1 or count(*:lod4Solid) = 1"><value-of select="ancestor::*:Building/@*:id"/>||<value-of select="@gml:id | @id"/>||SE_ATTRIBUTE_MISSING||any solid</assert>
</rule>
</pattern>
</schema>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>app</outputDirectory>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/assembly/lin</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>start.sh</include>
</includes>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/assembly/common</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>checkForSolid.xml</include>
</includes>
<filtered>false</filtered>
</fileSet>
<fileSet>
<directory>${project.build.directory}/jre/jre-lin/runtime/${lin-jre}/
</directory>
<outputDirectory>/runtime</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<filtered>false</filtered>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
#!/bin/sh
./runtime/bin/java -classpath app/*:plugin/* de.hft.stuttgart.citydoctor2.gui.CityDoctorGUIStarter
\ No newline at end of file
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>app</outputDirectory>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/assembly/lin</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>start.sh</include>
</includes>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/assembly/common</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>checkForSolid.xml</include>
</includes>
<filtered>false</filtered>
</fileSet>
<fileSet>
<directory>${project.build.directory}/jre/jre-mac/runtime/${mac-jre}/
</directory>
<outputDirectory>/runtime</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<filtered>false</filtered>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>app</outputDirectory>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/assembly/no_runtime</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>start.bat</include>
<include>start.sh</include>
</includes>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/assembly/common</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>checkForSolid.xml</include>
</includes>
<filtered>false</filtered>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
java -classpath app/*;plugins/* de.hft.stuttgart.citydoctor2.gui.CityDoctorGUIStarter
pause
\ No newline at end of file
#!/bin/sh
java -classpath app/*:plugin/* de.hft.stuttgart.citydoctor2.gui.CityDoctorGUIStarter
\ No newline at end of file
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>app</outputDirectory>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/assembly/win</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>start.bat</include>
</includes>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/assembly/common</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>checkForSolid.xml</include>
</includes>
<filtered>false</filtered>
</fileSet>
<fileSet>
<directory>${project.build.directory}/jre/jre-win/runtime/${win-jre}/
</directory>
<outputDirectory>/runtime</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<filtered>false</filtered>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
"runtime/bin/java.exe" -classpath app/*;plugins/* de.hft.stuttgart.citydoctor2.gui.CityDoctorGUIStarter
pause
\ No newline at end of file
package de.hft.stuttgart.citydoctor2.gui;
import java.io.IOException;
import java.io.InputStream;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
public class AboutDialog {
@FXML
private ImageView logoView;
@FXML
private ImageView beuthView;
@FXML
private ImageView minisView;
@FXML
private ImageView hftView;
@FXML
private Button closeBtn;
@FXML
private Label cdLabel;
private Stage stage;
public AboutDialog(Window parent) throws IOException {
FXMLLoader loader = new FXMLLoader(AboutDialog.class.getResource("AboutDialog.fxml"));
loader.setController(this);
VBox box = loader.load();
stage = new Stage(StageStyle.UTILITY);
stage.setTitle(Localization.getText("AboutDialog.title"));
stage.setResizable(false);
Scene scene = new Scene(box);
stage.setScene(scene);
stage.initOwner(parent);
stage.initModality(Modality.APPLICATION_MODAL);
}
public void initialize() {
String developedBy = Localization.getText("AboutDialog.developedBy");
String contact = Localization.getText("AboutDialog.contact");
closeBtn.setText(Localization.getText("AboutDialog.closeBtn"));
cdLabel.setText("CityDoctor Version " + Localization.getText(Localization.VERSION) + "\n\n" +
developedBy + ":\n" +
"Hochschule für Technik\n" +
"Beuth Hochschule Berlin\n\n" +
contact + ":\n" +
"Matthias Betz\n" +
"matthias.betz@hft-stuttgart.de");
closeBtn.setOnAction(ae -> hide());
try {
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/CityDoctor-Logo-rot_klein.png")) {
Image img = new Image(inStream);
logoView.setImage(img);
}
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/hft_logo.png")) {
Image img = new Image(inStream);
hftView.setImage(img);
}
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/Beuth-Logo_basis.png")) {
Image img = new Image(inStream);
beuthView.setImage(img);
}
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/BMBF_Logo.png")) {
Image img = new Image(inStream);
minisView.setImage(img);
}
} catch (IOException e) {
// ignore close exception
}
}
public void show() {
stage.show();
}
public void hide() {
stage.hide();
}
}
package de.hft.stuttgart.citydoctor2.gui;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.check.DefaultParameter;
import de.hft.stuttgart.citydoctor2.check.FilterConfiguration;
import de.hft.stuttgart.citydoctor2.check.GlobalParameters;
import de.hft.stuttgart.citydoctor2.check.Requirement;
import de.hft.stuttgart.citydoctor2.check.RequirementConfiguration;
import de.hft.stuttgart.citydoctor2.check.RequirementType;
import de.hft.stuttgart.citydoctor2.check.Unit;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.checks.Checks;
import de.hft.stuttgart.citydoctor2.gui.tree.TreeRequirement;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import javafx.application.Platform;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.cell.CheckBoxTreeTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.StringConverter;
import javafx.util.converter.DefaultStringConverter;
public class CheckDialog {
private static final String NUMBER_OF_ROUNDING_PLACES = "numberOfRoundingPlaces";
private static final Logger logger = LogManager.getLogger(CheckDialog.class);
private static final String CHECK_ENABLED = Localization.getText("CheckDialog.checkEnabled");
private static final String NAME = Localization.getText("CheckDialog.checkName");
private static final String VALUE = Localization.getText("CheckDialog.parameterValue");
private static final String UNIT = Localization.getText("CheckDialog.parameterUnit");
private Stage stage;
@FXML
private TreeTableView<TreeRequirement> geometricTable;
@FXML
private TreeTableView<TreeRequirement> semanticTable;
@FXML
private TableView<GlobalParameter> globalParametersTable;
@FXML
private ScrollPane scrollPane;
@FXML
private Button cancelBtn;
@FXML
private Button checkBtn;
@FXML
private ProgressBar progress;
@FXML
private Tab filterTab;
@FXML
private TabPane tabPane;
@FXML
private Button loadBtn;
@FXML
private ImageView loadView;
@FXML
private Button saveBtn;
@FXML
private ImageView saveView;
@FXML
private Button selectBtn;
@FXML
private TextField schematronField;
@FXML
private Tab checksTab;
@FXML
private Label globalParametersLabel;
@FXML
private Label availableChecksLabel;
@FXML
private Label geometricChecksLabel;
@FXML
private Label semanticChecksLabel;
@FXML
private Label schematronFileLabel;
private CityDoctorController controller;
private FilterPane filterPane;
private MainWindow window;
public CheckDialog(MainWindow window, Window parent, CityDoctorController controller) throws IOException {
this.window = window;
this.controller = controller;
FXMLLoader loader = new FXMLLoader(CheckDialog.class.getResource("CheckDialog.fxml"));
loader.setController(this);
VBox box = loader.load();
stage = new Stage();
stage.getIcons().add(new Image(MainWindow.class.getResourceAsStream("icons/CityDoctor-Logo-rot_klein.jpg")));
Scene scene = new Scene(box);
stage.setScene(scene);
stage.initOwner(parent);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle(Localization.getText("CheckDialog.title"));
}
public void initialize() {
createEnableColumn(geometricTable);
createNameColumn(geometricTable);
createValueColumn(geometricTable);
createUnitColumn(geometricTable);
createEnableColumn(semanticTable);
createNameColumn(semanticTable);
createValueColumn(semanticTable);
createUnitColumn(semanticTable);
checksTab.setText(Localization.getText("CheckDialog.checksTab"));
filterTab.setText(Localization.getText("CheckDialog.filterTab"));
globalParametersLabel.setText(Localization.getText("CheckDialog.globalParametersLabel"));
availableChecksLabel.setText(Localization.getText("CheckDialog.availableChecksLabel"));
geometricChecksLabel.setText(Localization.getText("CheckDialog.geometricChecksLabel"));
semanticChecksLabel.setText(Localization.getText("CheckDialog.semanticChecksLabel"));
schematronFileLabel.setText(Localization.getText("CheckDialog.schematronFileLabel"));
selectBtn.setText(Localization.getText("CheckDialog.selectBtn"));
checkBtn.setText(Localization.getText("CheckDialog.checkBtn"));
cancelBtn.setText(Localization.getText("CheckDialog.cancelBtn"));
List<TableColumn<GlobalParameter, ?>> columns = globalParametersTable.getColumns();
TableColumn<GlobalParameter, String> nameCol = new TableColumn<>(NAME);
columns.add(nameCol);
nameCol.setMinWidth(200);
nameCol.setPrefWidth(325);
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
setupValueColumns(columns);
TableColumn<GlobalParameter, Unit> unitCol = new TableColumn<>(UNIT);
columns.add(unitCol);
unitCol.setMinWidth(50);
unitCol.setPrefWidth(75);
unitCol.setMaxWidth(100);
unitCol.setEditable(false);
unitCol.setCellValueFactory(new PropertyValueFactory<>("unit"));
unitCol.setCellFactory(TextFieldTableCell.forTableColumn(new StringConverter<Unit>() {
@Override
public String toString(Unit object) {
return object.getRepresentation();
}
@Override
public Unit fromString(String string) {
return Unit.valueOf(string);
}
}));
loadImages();
setupSelectButton();
setupSaveButton();
setupLoadButton();
populateTreeWithChecks(geometricTable, RequirementType.GEOMETRY, true);
populateTreeWithChecks(semanticTable, RequirementType.SEMANTIC, false);
globalParametersTable.getItems().add(new GlobalParameter(NUMBER_OF_ROUNDING_PLACES, "8", Unit.NONE));
globalParametersTable.getItems().add(new GlobalParameter("minVertexDistance", "0.0001", Unit.METER));
cancelBtn.setOnAction(ea -> stage.close());
setupCheckButton();
tabPane.getSelectionModel().selectedIndexProperty().addListener((v, old, newV) -> {
if (newV.intValue() == 1 && filterPane == null) {
try {
getFilterPane();
} catch (IOException e) {
window.showExceptionDialog(e);
}
}
});
schematronField.setText(ValidationConfiguration.CHECK_FOR_SOLID_XML);
}
private void setupValueColumns(List<TableColumn<GlobalParameter, ?>> columns) {
TableColumn<GlobalParameter, String> valueCol = new TableColumn<>(VALUE);
columns.add(valueCol);
valueCol.setMinWidth(150);
valueCol.setPrefWidth(200);
valueCol.setEditable(true);
valueCol.setCellValueFactory(new PropertyValueFactory<>("value"));
valueCol.setCellFactory(column -> new TableEditCell<GlobalParameter, String>(new DefaultStringConverter()) {
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (!empty && item != null) {
GlobalParameter row = (GlobalParameter) getTableRow().getItem();
if (row == null) {
return;
}
row.setValue(item);
if (NUMBER_OF_ROUNDING_PLACES.equals(row.getName())) {
setEditable(false);
}
}
}
});
}
private void setupSelectButton() {
selectBtn.setOnAction(ae -> {
FileChooser chooser = new FileChooser();
List<String> extensions = new ArrayList<>();
extensions.add("*.xml");
String schematronFiles = Localization.getText("CheckDialog.schematronFiles");
chooser.getExtensionFilters().add(new ExtensionFilter(schematronFiles, extensions));
File dir = new File(Settings.get(Settings.LAST_OPEN_FOLDER, ""));
if (dir.exists() && dir.isDirectory()) {
chooser.setInitialDirectory(dir);
}
String schematronChooserTitle = Localization.getText("CheckDialog.schematronChooserTitle");
chooser.setTitle(schematronChooserTitle);
File file = chooser.showOpenDialog(stage);
if (file != null) {
schematronField.setText(file.getAbsolutePath());
}
});
}
private void setupLoadButton() {
loadBtn.setOnAction(ae -> {
FileChooser fc = new FileChooser();
String validationConfiguration = Localization.getText("CheckDialog.validationConfiguration");
fc.getExtensionFilters().add(new ExtensionFilter(validationConfiguration, "*.yml"));
File dir = new File(Settings.get(Settings.LAST_OPEN_FOLDER, ""));
if (dir.exists() && dir.isDirectory()) {
fc.setInitialDirectory(dir);
} else {
Settings.set(Settings.LAST_OPEN_FOLDER, "");
}
File f = fc.showOpenDialog(stage);
if (f != null) {
Settings.set(Settings.LAST_OPEN_FOLDER, f.getParent());
try {
ValidationConfiguration config = ValidationConfiguration.loadValidationConfig(f.getAbsolutePath());
applyConfig(config);
} catch (IOException e) {
window.showExceptionDialog(e);
}
}
});
}
private void setupSaveButton() {
saveBtn.setOnAction(ae -> {
ValidationConfiguration config = createConfig();
FileChooser fc = new FileChooser();
fc.getExtensionFilters()
.add(new ExtensionFilter(Localization.getText("CheckDialog.validationConfiguration"), "*.yml"));
File dir = new File(Settings.get(Settings.LAST_OPEN_FOLDER, ""));
if (dir.exists() && dir.isDirectory()) {
fc.setInitialDirectory(dir);
} else {
Settings.set(Settings.LAST_OPEN_FOLDER, "");
}
File f = fc.showSaveDialog(stage);
if (f != null) {
Settings.set(Settings.LAST_OPEN_FOLDER, f.getParent());
try {
config.saveAs(f);
} catch (IOException e) {
window.showExceptionDialog(e);
}
}
});
}
private void applyConfig(ValidationConfiguration config) throws IOException {
FilterConfiguration filter = config.getFilter();
if (filter != null) {
getFilterPane().applyFilterConfig(filter);
}
Map<String, RequirementConfiguration> checks = config.getRequirements();
for (Entry<String, RequirementConfiguration> e : checks.entrySet()) {
for (TreeItem<TreeRequirement> ti : geometricTable.getRoot().getChildren()) {
applyCheckConfig(e, ti);
}
}
globalParametersTable.getItems().clear();
globalParametersTable.getItems().add(new GlobalParameter(GlobalParameters.NUMBER_OF_ROUNDING_PLACES,
config.getNumberOfRoundingPlacesAsString(), Unit.NONE));
globalParametersTable.getItems().add(new GlobalParameter(GlobalParameters.MIN_VERTEX_DISTANCE,
config.getMinVertexDistanceAsString(), Unit.METER));
schematronField.setText(config.getSchematronFilePath());
}
private FilterPane getFilterPane() throws IOException {
if (filterPane == null) {
filterPane = new FilterPane();
Platform.runLater(() -> filterTab.setContent(filterPane.getPane()));
}
return filterPane;
}
private void applyCheckConfig(Entry<String, RequirementConfiguration> e, TreeItem<TreeRequirement> ti) {
Requirement r = ti.getValue().getRequirement();
RequirementConfiguration cConfig = e.getValue();
if (r.getId().equals(e.getKey())) {
ti.getValue().getEnabledProperty().set(cConfig.isEnabled());
for (Entry<String, String> paramEntry : cConfig.getParameters().entrySet()) {
String name = paramEntry.getKey();
String value = paramEntry.getValue();
for (TreeItem<TreeRequirement> configItem : ti.getChildren()) {
TreeRequirement parameterCheck = configItem.getValue();
if (name.equals(parameterCheck.getNameProperty().getValue())) {
parameterCheck.setValue(value);
}
}
}
}
}
private boolean collectCheckConfiguration(ValidationConfiguration config) {
collectCheckInformationFromTree(config, geometricTable);
collectCheckInformationFromTree(config, semanticTable);
config.setSchematronFilePathInGlobalParameters(schematronField.getText());
config.setMinVertexDistanceInGlobalParameters(
Double.parseDouble(globalParametersTable.getItems().get(1).getValue()));
// check if everything is okay with the configuration
config.validateConfiguration();
return true;
}
private void collectCheckInformationFromTree(ValidationConfiguration config, TreeTableView<TreeRequirement> table) {
for (TreeItem<TreeRequirement> ti : table.getRoot().getChildren()) {
Requirement r = ti.getValue().getRequirement();
if (ti.getValue().getEnabledProperty().getValue()) {
RequirementConfiguration cc = config.getRequirements().get(r.getId());
cc.setEnabled(ti.getValue().isEnabled());
// collect parameters
collectParameters(cc, ti);
} else {
config.getRequirements().get(r.getId()).setEnabled(false);
}
}
}
private void loadImages() {
try {
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/openFolderIcon.png")) {
Image img = new Image(inStream);
loadView.setImage(img);
}
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/save.png")) {
Image img = new Image(inStream);
saveView.setImage(img);
}
} catch (IOException e) {
// ignore close exception
}
}
private void setupCheckButton() {
checkBtn.setOnAction(ea -> {
ValidationConfiguration config = createConfig();
checkBtn.setDisable(true);
cancelBtn.setDisable(true);
stage.setOnCloseRequest(Event::consume);
Thread t = new Thread(() -> {
try {
if (logger.isInfoEnabled()) {
String startingChecks = Localization.getText("CheckDialog.startingChecks");
logger.info(startingChecks);
}
controller.startChecks(config, progress::setProgress);
if (logger.isInfoEnabled()) {
String checksDone = Localization.getText("CheckDialog.checksDone");
logger.info(checksDone);
}
} catch (Exception e) {
if (logger.isErrorEnabled()) {
String failedChecks = Localization.getText("CheckDialog.failedChecks");
logger.error(failedChecks, e);
}
Platform.runLater(() -> {
ExceptionDialog dialog = new ExceptionDialog();
dialog.show(e);
});
} finally {
Platform.runLater(() -> {
checkBtn.setDisable(false);
cancelBtn.setDisable(false);
stage.setOnCloseRequest(null);
stage.close();
});
}
});
t.start();
});
}
private ValidationConfiguration createConfig() {
ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig();
config.setMinVertexDistanceInGlobalParameters(
Double.parseDouble(globalParametersTable.getItems().get(1).getValue()));
if (filterPane != null) {
config.setFilter(filterPane.getConfiguration());
}
collectCheckConfiguration(config);
if (schematronField.getText().isEmpty()) {
return config;
}
File f = new File(schematronField.getText());
if (!f.exists() || f.isDirectory() && logger.isWarnEnabled()) {
String schematronFileNotExisting = Localization.getText("CheckDialog.schematronFileNotExisting");
logger.warn(schematronFileNotExisting);
} else {
config.setSchematronFilePathInGlobalParameters(schematronField.getText());
}
return config;
}
private void collectParameters(RequirementConfiguration cc, TreeItem<TreeRequirement> ti) {
Map<String, String> parameters = new HashMap<>();
for (TreeItem<TreeRequirement> paramTi : ti.getChildren()) {
String name = paramTi.getValue().getNameProperty().getValue();
String value = paramTi.getValue().getValueProperty().getValue();
parameters.put(name, value);
}
cc.setParameters(parameters);
}
private void createEnableColumn(TreeTableView<TreeRequirement> view) {
TreeTableColumn<TreeRequirement, Boolean> enableColumn = new TreeTableColumn<>(CHECK_ENABLED);
view.getColumns().add(enableColumn);
enableColumn.setCellValueFactory(param -> {
TreeRequirement check = param.getValue().getValue();
if (check != null) {
return check.getEnabledProperty();
}
return null;
});
StringConverter<Boolean> converter = new StringConverter<>() {
@Override
public String toString(Boolean object) {
return " ";
}
@Override
public Boolean fromString(String string) {
return Boolean.parseBoolean(string);
}
};
enableColumn.setCellFactory(list -> new CheckBoxTreeTableCell<TreeRequirement, Boolean>(null, converter) {
@Override
public void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setGraphic(null);
setText(null);
}
}
});
}
private void createNameColumn(TreeTableView<TreeRequirement> view) {
TreeTableColumn<TreeRequirement, String> nameColumn = new TreeTableColumn<>(NAME);
nameColumn.setEditable(false);
view.getColumns().add(nameColumn);
nameColumn.setCellValueFactory(param -> {
if (param.getValue().getValue() != null) {
return param.getValue().getValue().getNameProperty();
}
return null;
});
}
private void createValueColumn(TreeTableView<TreeRequirement> view) {
TreeTableColumn<TreeRequirement, String> valueColumn = new TreeTableColumn<>(VALUE);
view.getColumns().add(valueColumn);
valueColumn.setCellValueFactory(param -> {
if (param.getValue().getValue() != null) {
return param.getValue().getValue().getValueProperty();
}
return null;
});
valueColumn.setCellFactory(col -> new TreeEditCell<>(new DefaultStringConverter()));
valueColumn.setPrefWidth(100);
}
private void createUnitColumn(TreeTableView<TreeRequirement> view) {
TreeTableColumn<TreeRequirement, String> unitColumn = new TreeTableColumn<>(UNIT);
unitColumn.setEditable(false);
view.getColumns().add(unitColumn);
unitColumn.setCellValueFactory(param -> {
if (param.getValue().getValue() != null) {
return param.getValue().getValue().getUnitProperty();
}
return null;
});
}
private void populateTreeWithChecks(TreeTableView<TreeRequirement> view, RequirementType type, boolean enabled) {
view.setRoot(new TreeItem<>());
List<Requirement> requirements = new ArrayList<>(Checks.getAvailableRequirements().values());
Collections.sort(requirements, (r1, r2) -> r1.getId().compareTo(r2.getId()));
for (Requirement r : requirements) {
if (r.getType() != type) {
continue;
}
TreeRequirement treeCheck = new TreeRequirement(r);
treeCheck.setEnabled(enabled);
TreeItem<TreeRequirement> ti = new TreeItem<>(treeCheck);
view.getRoot().getChildren().add(ti);
for (DefaultParameter dp : r.getDefaultParameter()) {
TreeItem<TreeRequirement> dpTi = new TreeItem<>(new TreeRequirement(dp));
ti.getChildren().add(dpTi);
}
ti.setExpanded(true);
}
}
public void show() {
Platform.runLater(() -> {
if (controller.getCurrentConfig() != null) {
for (GlobalParameter parameter : globalParametersTable.getItems()) {
if (parameter.getName().equals(NUMBER_OF_ROUNDING_PLACES)) {
parameter.setValue("" + controller.getCurrentConfig().getNumberOfRoundingPlaces());
}
}
}
globalParametersTable.refresh();
progress.setProgress(0d);
stage.showAndWait();
});
}
}
package de.hft.stuttgart.citydoctor2.gui;
public enum CheckStatus {
ERROR, OK, NOT_CHECKED
}
package de.hft.stuttgart.citydoctor2.gui;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.StringJoiner;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.CityModel;
import org.xml.sax.SAXParseException;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.Checker;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.check.error.SchematronError;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.Installation;
import de.hft.stuttgart.citydoctor2.datastructure.BuildingPart;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.FeatureType;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.LandObject;
import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject;
import de.hft.stuttgart.citydoctor2.datastructure.TinObject;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.gui.table.ErrorStat;
import de.hft.stuttgart.citydoctor2.gui.tree.AllBoundarySurfacesNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllBridgeConstructiveElementsNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllBridgePartsNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllBridgesNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllInstallationsNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllBuildingPartsNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllBuildingsNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllOpeningsNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllTerrainNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllTinNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllTransportationNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllVegetationNode;
import de.hft.stuttgart.citydoctor2.gui.tree.AllWaterNode;
import de.hft.stuttgart.citydoctor2.gui.tree.BoundarySurfaceNode;
import de.hft.stuttgart.citydoctor2.gui.tree.BridgeConstructiveElementNode;
import de.hft.stuttgart.citydoctor2.gui.tree.BridgeNode;
import de.hft.stuttgart.citydoctor2.gui.tree.InstallationNode;
import de.hft.stuttgart.citydoctor2.gui.tree.BuildingNode;
import de.hft.stuttgart.citydoctor2.gui.tree.BuildingPartNode;
import de.hft.stuttgart.citydoctor2.gui.tree.ButtonRenderable;
import de.hft.stuttgart.citydoctor2.gui.tree.CityObjectNode;
import de.hft.stuttgart.citydoctor2.gui.tree.GeometryNode;
import de.hft.stuttgart.citydoctor2.gui.tree.LandUseNode;
import de.hft.stuttgart.citydoctor2.gui.tree.OpeningNode;
import de.hft.stuttgart.citydoctor2.gui.tree.ReliefNode;
import de.hft.stuttgart.citydoctor2.gui.tree.Renderable;
import de.hft.stuttgart.citydoctor2.gui.tree.TinNode;
import de.hft.stuttgart.citydoctor2.gui.tree.VegetationNode;
import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.parser.ProgressListener;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import javafx.application.Platform;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
public class CityDoctorController {
private static final int MAX_FEATURES_PER_CHUNK = 200;
private static final Logger logger = LogManager.getLogger(CityDoctorController.class);
private MainWindow mainWindow;
private CityDoctorModel model;
private ParserConfiguration currentConfig;
private String sourceFile;
private Checker currentChecker;
private HighlightController highlightController;
private Renderer renderer;
private AtomicInteger buildingChunkNr = new AtomicInteger(0);
private AtomicInteger vegetationChunkNr = new AtomicInteger(0);
private AtomicInteger transportationChunkNr = new AtomicInteger(0);
private AtomicInteger bridgeChunkNr = new AtomicInteger(0);
private AtomicInteger waterChunkNr = new AtomicInteger(0);
private AtomicInteger landChunkNr = new AtomicInteger(0);
public CityDoctorController(MainWindow mainWindow, HighlightController highlightController, Renderer renderer) {
this.mainWindow = mainWindow;
this.highlightController = highlightController;
this.renderer = renderer;
}
public void loadCityGml(String path, int numberOfRoundingPlaces, ProgressListener l, boolean useValidation)
throws CityGmlParseException, InvalidGmlFileException {
loadCityGml(path, numberOfRoundingPlaces, l, useValidation, false);
}
public void loadCityGml(String path, int numberOfRoundingPlaces, ProgressListener l, boolean useValidation,
boolean lowMemory) throws CityGmlParseException, InvalidGmlFileException {
try {
Platform.runLater(() -> {
mainWindow.getOpenBtn().setDisable(true);
mainWindow.getWriteReportButton().setDisable(true);
mainWindow.getMeshGroup().getChildren().clear();
clearTrees();
mainWindow.resetSearchBar();
mainWindow.resetFilterComboBox();
});
currentChecker = null;
currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory);
GMLValidationHandler handler = null;
List<String> validationIssues = new ArrayList<>();
if (useValidation) {
handler = new GMLValidationHandler() {
@Override
public void error(SAXParseException exception) {
if (exception.getLineNumber() >= 0) {
String s = "In line " + exception.getLineNumber() + ":";
validationIssues.add(s);
}
validationIssues.add(exception.getMessage());
}
@Override
public void warning(SAXParseException exception) {
error(exception);
}
@Override
public void fatalError(SAXParseException exception) {
error(exception);
}
};
}
model = CityGmlParser.parseCityGmlFile(path, currentConfig, l, handler);
if (!validationIssues.isEmpty()) {
StringJoiner sj = new StringJoiner("\n");
validationIssues.stream().forEach(sj::add);
throw new InvalidGmlFileException(sj.toString());
}
mainWindow.getClickHandler().setConfig(currentConfig);
sourceFile = path;
renderer.reset();
Platform.runLater(() -> {
mainWindow.addFileNameToTitle(path);
mainWindow.getCheckButton().setDisable(false);
mainWindow.getLod1Btn().setDisable(false);
mainWindow.getLod2Btn().setDisable(false);
mainWindow.getLod3Btn().setDisable(false);
mainWindow.getLod4Btn().setDisable(false);
mainWindow.getWorldBtn().setDisable(false);
mainWindow.getSaveBtn().setDisable(false);
buildTrees();
});
} finally {
Platform.runLater(() -> mainWindow.getOpenBtn().setDisable(false));
}
}
public void buildTrees() {
resetFeatureChunks();
buildBuildings(model);
buildVegetation(model.getVegetation());
buildTransportation(model.getTransportation());
buildBridges(model);
buildWater(model);
buildLand(model);
}
private void resetFeatureChunks() {
buildingChunkNr.set(0);
vegetationChunkNr.set(0);
transportationChunkNr.set(0);
bridgeChunkNr.set(0);
waterChunkNr.set(0);
landChunkNr.set(0);
}
private void buildLand(CityDoctorModel model) {
if (model.getLand().isEmpty()) {
return;
}
TreeView<Renderable> landView = mainWindow.getTerrainView();
TreeItem<Renderable> landRoot = new TreeItem<>(new AllTerrainNode(model.getLand()));
landRoot.setExpanded(true);
landView.setRoot(landRoot);
buildLandFromList(model.getLand(), landView.getRoot());
addMoreButtonIfNecessary(model.getLand(), landView, landRoot, landChunkNr);
}
private void buildLandFromList(List<CityObject> list, TreeItem<Renderable> root) {
int landChunk = landChunkNr.get();
for (int i = landChunk * MAX_FEATURES_PER_CHUNK; i < (landChunk + 1) * MAX_FEATURES_PER_CHUNK
&& i < list.size(); i++) {
CityObject land = list.get(i);
Renderable node;
if (land instanceof ReliefObject relief) {
node = new ReliefNode(relief);
} else if (land instanceof TinObject tin) {
node = new TinNode(tin);
} else {
node = new LandUseNode((LandObject) land);
}
TreeItem<Renderable> item = new TreeItem<>(node);
item.setExpanded(true);
root.getChildren().add(item);
createGeometryNodes(land, item);
if (land instanceof ReliefObject relief) {
createTinNodes(relief, item);
}
}
}
private void createTinNodes(ReliefObject relief, TreeItem<Renderable> item) {
if (relief.getComponents().isEmpty()) {
return;
}
AllTinNode allTinText = new AllTinNode(relief.getComponents());
TreeItem<Renderable> allBpsTextItem = new TreeItem<>(allTinText);
item.getChildren().add(allBpsTextItem);
for (TinObject tin : relief.getComponents()) {
TinNode tinNode = new TinNode(tin);
TreeItem<Renderable> tinNodeItem = new TreeItem<>(tinNode);
tinNodeItem.setExpanded(true);
allBpsTextItem.getChildren().add(tinNodeItem);
createGeometryNodes(tin, tinNodeItem);
}
}
private void buildWater(CityDoctorModel model) {
if (model.getWater().isEmpty()) {
return;
}
TreeView<Renderable> waterView = mainWindow.getWaterView();
TreeItem<Renderable> waterRoot = new TreeItem<>(new AllWaterNode(model.getWater()));
waterRoot.setExpanded(true);
waterView.setRoot(waterRoot);
buildTreeFromList(model.getWater(), waterView.getRoot(), waterChunkNr);
addMoreButtonIfNecessary(model.getWater(), waterView, waterRoot, waterChunkNr);
}
private void buildBridges(CityDoctorModel model) {
if (model.getBridges().isEmpty()) {
return;
}
TreeView<Renderable> bridgeView = mainWindow.getBridgeView();
TreeItem<Renderable> bridgeRoot = new TreeItem<>(new AllBridgesNode(model.getBridges()));
bridgeRoot.setExpanded(true);
bridgeView.setRoot(bridgeRoot);
buildBridgeTreeFromList(model.getBridges(), bridgeView.getRoot());
addMoreButtonIfNecessary(model.getBridges(), bridgeView, bridgeRoot, bridgeChunkNr);
}
private void buildTransportation(List<TransportationObject> trans) {
if (trans.isEmpty()) {
return;
}
TreeView<Renderable> transView = mainWindow.getTransportationView();
TreeItem<Renderable> transRoot = new TreeItem<>(new AllTransportationNode(model.getTransportation()));
transRoot.setExpanded(true);
transView.setRoot(transRoot);
buildTreeFromList(trans, transView.getRoot(), transportationChunkNr);
addMoreButtonIfNecessary(trans, transView, transRoot, transportationChunkNr);
}
private void buildVegetation(List<Vegetation> veg) {
if (veg.isEmpty()) {
return;
}
TreeView<Renderable> vegetationsView = mainWindow.getVegetationView();
TreeItem<Renderable> vegRoot = new TreeItem<>(new AllVegetationNode(model.getVegetation()));
vegRoot.setExpanded(true);
vegetationsView.setRoot(vegRoot);
buildTreeFromListWithProducer(veg, vegetationsView.getRoot(), vegetationChunkNr, VegetationNode::new);
addMoreButtonIfNecessary(veg, vegetationsView, vegRoot, vegetationChunkNr);
}
private void addMoreButtonIfNecessary(List<? extends CityObject> list, TreeView<Renderable> view,
TreeItem<Renderable> root, AtomicInteger chunkCounter) {
if ((chunkCounter.get() + 1) * MAX_FEATURES_PER_CHUNK < list.size()) {
Runnable run = new Runnable() {
public void run() {
// 29 is the height of one item
int numberOfDisplayedItems = (int) (view.getHeight() / 29);
int selectedIndex = view.getSelectionModel().getSelectedIndex();
// remove button node
root.getChildren().remove(root.getChildren().size() - 1);
chunkCounter.incrementAndGet();
int visibleFeatures = countVisibleNodes(view);
buildTreeFromList(list, root, chunkCounter);
updateTree(root);
if (selectedIndex >= 0) {
view.getSelectionModel().select(selectedIndex);
}
if ((chunkCounter.get() + 1) * MAX_FEATURES_PER_CHUNK < list.size()) {
root.getChildren().add(new TreeItem<>(new ButtonRenderable(this)));
}
view.scrollTo(visibleFeatures - numberOfDisplayedItems + 1);
}
};
// add button for expansion
root.getChildren().add(new TreeItem<>(new ButtonRenderable(run)));
}
}
private void buildBuildings(CityDoctorModel model) {
if (model.getBuildings().isEmpty()) {
return;
}
TreeView<Renderable> buildingsView = mainWindow.getBuildingsView();
TreeItem<Renderable> root = new TreeItem<>(new AllBuildingsNode(model.getBuildings()));
root.setExpanded(true);
buildBuildingTreeFromList(model.getBuildings(), root);
addMoreButtonToBuildingsIfNecessary(model.getBuildings(), buildingsView, root, buildingChunkNr);
buildingsView.setRoot(root);
}
private void addMoreButtonToBuildingsIfNecessary(List<Building> list, TreeView<Renderable> view,
TreeItem<Renderable> root, AtomicInteger chunkCounter) {
if ((chunkCounter.get() + 1) * MAX_FEATURES_PER_CHUNK < list.size()) {
Runnable run = new Runnable() {
public void run() {
// 29 is the height of one item
int numberOfDisplayedItems = (int) (view.getHeight() / 29);
int selectedIndex = view.getSelectionModel().getSelectedIndex();
// remove button node
root.getChildren().remove(root.getChildren().size() - 1);
chunkCounter.getAndIncrement();
int visibleFeatures = countVisibleNodes(view);
buildBuildingTreeFromList(list, root);
updateTree(root);
if (selectedIndex >= 0) {
view.getSelectionModel().select(selectedIndex);
}
if ((chunkCounter.get() + 1) * MAX_FEATURES_PER_CHUNK < list.size()) {
root.getChildren().add(new TreeItem<>(new ButtonRenderable(this)));
}
view.scrollTo(visibleFeatures - numberOfDisplayedItems + 1);
}
};
// add button for expansion
root.getChildren().add(new TreeItem<>(new ButtonRenderable(run)));
}
}
private static int countVisibleNodes(TreeView<Renderable> view) {
return countVisibleNodes(view.getRoot()) + 1;
}
private static int countVisibleNodes(TreeItem<Renderable> root) {
int visibleFeatures = root.getChildren().size();
for (TreeItem<Renderable> child : root.getChildren()) {
if (!child.getChildren().isEmpty() && child.isExpanded()) {
visibleFeatures += countVisibleNodes(child);
}
}
return visibleFeatures;
}
private void buildTreeFromList(List<? extends CityObject> cos, TreeItem<Renderable> root,
AtomicInteger chunkCounter) {
int chunk = chunkCounter.get();
for (int i = chunk * MAX_FEATURES_PER_CHUNK; i < (chunk + 1) * MAX_FEATURES_PER_CHUNK && i < cos.size(); i++) {
CityObject co = cos.get(i);
CityObjectNode node = new CityObjectNode(co);
TreeItem<Renderable> nodeItem = new TreeItem<>(node);
nodeItem.setExpanded(true);
root.getChildren().add(nodeItem);
createGeometryNodes(co, nodeItem);
}
}
private <T extends CityObject> void buildTreeFromListWithProducer(List<T> cos, TreeItem<Renderable> root,
AtomicInteger chunkCounter, Function<T, Renderable> nodeProducer) {
int chunk = chunkCounter.get();
for (int i = chunk * MAX_FEATURES_PER_CHUNK; i < (chunk + 1) * MAX_FEATURES_PER_CHUNK && i < cos.size(); i++) {
T co = cos.get(i);
Renderable node = nodeProducer.apply(co);
TreeItem<Renderable> nodeItem = new TreeItem<>(node);
nodeItem.setExpanded(true);
root.getChildren().add(nodeItem);
createGeometryNodes(co, nodeItem);
}
}
private void clearTrees() {
mainWindow.getBuildingsView().setRoot(null);
mainWindow.getVegetationView().setRoot(null);
mainWindow.getTransportationView().setRoot(null);
mainWindow.getBridgeView().setRoot(null);
mainWindow.getWaterView().setRoot(null);
mainWindow.getTerrainView().setRoot(null);
mainWindow.getErrorTree().getRoot().getChildren().clear();
mainWindow.getGlobalErrorsView().getItems().clear();
clearGeometryTrees();
}
private void clearGeometryTrees() {
highlightController.clearHighlights();
mainWindow.getPolygonsView().getRoot().getChildren().clear();
mainWindow.getEdgeView().getRoot().getChildren().clear();
mainWindow.getVertexView().getRoot().getChildren().clear();
}
private void buildBuildingTreeFromList(List<Building> list, TreeItem<Renderable> root) {
int buildingChunk = buildingChunkNr.get();
for (int i = buildingChunk * MAX_FEATURES_PER_CHUNK; i < (buildingChunk + 1) * MAX_FEATURES_PER_CHUNK
&& i < list.size(); i++) {
Building b = list.get(i);
BuildingNode node = new BuildingNode(b);
TreeItem<Renderable> item = new TreeItem<>(node);
item.setExpanded(true);
root.getChildren().add(item);
createGeometryNodes(b, item);
createBoundarySurfaceNodes(b.getBoundarySurfaces(), item);
createBuildingInstallationNodes(b, item);
createBuildingPartNodes(b, item);
}
}
private void buildBridgeTreeFromList(List<BridgeObject> list, TreeItem<Renderable> root) {
int bridgeChunk = bridgeChunkNr.get();
for (int i = bridgeChunk * MAX_FEATURES_PER_CHUNK; i < (bridgeChunk + 1) * MAX_FEATURES_PER_CHUNK
&& i < list.size(); i++) {
BridgeObject bridge = list.get(i);
BridgeNode node = new BridgeNode(bridge);
TreeItem<Renderable> item = new TreeItem<>(node);
item.setExpanded(true);
root.getChildren().add(item);
createGeometryNodes(bridge, item);
createBoundarySurfaceNodes(bridge.getBoundarySurfaces(), item);
createBridgeInstallationNodes(bridge, item);
createConstructiveElementsNodes(bridge, item);
createBridgePartNodes(bridge, item);
}
}
private void createBridgeInstallationNodes(BridgeObject bridge, TreeItem<Renderable> root) {
createInstallationNodes(bridge.getBridgeInstallations(), root);
}
private void createConstructiveElementsNodes(BridgeObject bridge, TreeItem<Renderable> item) {
if (bridge.getConstructiveElements().isEmpty()) {
return;
}
AllBridgeConstructiveElementsNode allBceNode = new AllBridgeConstructiveElementsNode(
bridge.getConstructiveElements());
TreeItem<Renderable> allBceNodeTextItem = new TreeItem<>(allBceNode);
item.getChildren().add(allBceNodeTextItem);
for (BridgeConstructiveElement bce : bridge.getConstructiveElements()) {
BridgeConstructiveElementNode bceNode = new BridgeConstructiveElementNode(bce);
TreeItem<Renderable> bpNodeItem = new TreeItem<>(bceNode);
bpNodeItem.setExpanded(true);
allBceNodeTextItem.getChildren().add(bpNodeItem);
createGeometryNodes(bce, bpNodeItem);
createBoundarySurfaceNodes(bce.getBoundarySurfaces(), bpNodeItem);
}
}
private void createBridgePartNodes(BridgeObject bridge, TreeItem<Renderable> item) {
if (bridge.getParts().isEmpty()) {
return;
}
AllBridgePartsNode allBpsText = new AllBridgePartsNode(bridge.getParts());
TreeItem<Renderable> allBpsTextItem = new TreeItem<>(allBpsText);
item.getChildren().add(allBpsTextItem);
for (BridgeObject bp : bridge.getParts()) {
BridgeNode bpNode = new BridgeNode(bp);
TreeItem<Renderable> bpNodeItem = new TreeItem<>(bpNode);
bpNodeItem.setExpanded(true);
allBpsTextItem.getChildren().add(bpNodeItem);
createGeometryNodes(bp, bpNodeItem);
createBoundarySurfaceNodes(bp.getBoundarySurfaces(), bpNodeItem);
}
}
private void createBuildingInstallationNodes(Building ab, TreeItem<Renderable> root) {
createInstallationNodes(ab.getBuildingInstallations(), root);
}
private void createInstallationNodes(List<Installation> installations, TreeItem<Renderable> root) {
if (installations.isEmpty()) {
return;
}
AllInstallationsNode allBiNode = new AllInstallationsNode(installations);
TreeItem<Renderable> allBpsTextItem = new TreeItem<>(allBiNode);
root.getChildren().add(allBpsTextItem);
for (Installation bi : installations) {
InstallationNode biNode = new InstallationNode(bi);
TreeItem<Renderable> biItem = new TreeItem<>(biNode);
biItem.setExpanded(true);
allBpsTextItem.getChildren().add(biItem);
createGeometryNodes(bi, biItem);
createBoundarySurfaceNodes(bi.getBoundarySurfaces(), biItem);
}
}
private void createBoundarySurfaceNodes(List<BoundarySurface> bsList, TreeItem<Renderable> root) {
if (bsList.isEmpty()) {
return;
}
AllBoundarySurfacesNode allBsText = new AllBoundarySurfacesNode(bsList);
TreeItem<Renderable> allBpsTextItem = new TreeItem<>(allBsText);
root.getChildren().add(allBpsTextItem);
allBpsTextItem.getChildren().add(new TreeItem<>());
allBpsTextItem.expandedProperty().addListener((obs, old, newV) -> {
if (Boolean.TRUE.equals(newV) && allBpsTextItem.getChildren().size() == 1) {
Platform.runLater(() -> {
allBpsTextItem.getChildren().clear();
for (BoundarySurface bs : bsList) {
BoundarySurfaceNode bsText = new BoundarySurfaceNode(bs);
TreeItem<Renderable> bsTextItem = new TreeItem<>(bsText);
bsTextItem.setExpanded(true);
allBpsTextItem.getChildren().add(bsTextItem);
createGeometryNodes(bs, bsTextItem);
createOpeningNodes(bs.getOpenings(), bsTextItem);
}
updateTree(allBpsTextItem);
});
}
});
}
private void createOpeningNodes(List<Opening> openings, TreeItem<Renderable> root) {
if (openings == null || openings.isEmpty()) {
return;
}
AllOpeningsNode allOpeningsNode = new AllOpeningsNode(openings);
TreeItem<Renderable> allOpeningsItem = new TreeItem<>(allOpeningsNode);
for (Opening o : openings) {
OpeningNode openingNode = new OpeningNode(o);
TreeItem<Renderable> openingsItem = new TreeItem<>(openingNode);
allOpeningsItem.getChildren().add(openingsItem);
}
root.getChildren().add(allOpeningsItem);
}
private void createBuildingPartNodes(Building ab, TreeItem<Renderable> item) {
if (ab.getBuildingParts().isEmpty()) {
return;
}
AllBuildingPartsNode allBpsText = new AllBuildingPartsNode(ab.getBuildingParts());
TreeItem<Renderable> allBpsTextItem = new TreeItem<>(allBpsText);
item.getChildren().add(allBpsTextItem);
for (BuildingPart bp : ab.getBuildingParts()) {
BuildingPartNode bpNode = new BuildingPartNode(bp);
TreeItem<Renderable> bpNodeItem = new TreeItem<>(bpNode);
bpNodeItem.setExpanded(true);
allBpsTextItem.getChildren().add(bpNodeItem);
createGeometryNodes(bp, bpNodeItem);
createBoundarySurfaceNodes(bp.getBoundarySurfaces(), bpNodeItem);
}
}
private void createGeometryNodes(CityObject co, TreeItem<Renderable> item) {
for (Geometry geom : co.getGeometries()) {
GeometryNode geomNode = new GeometryNode(geom);
TreeItem<Renderable> geomItem = new TreeItem<>(geomNode);
item.getChildren().add(geomItem);
}
}
public void startChecks(ValidationConfiguration config, ProgressListener l) {
if (model == null) {
logger.warn(Localization.getText("CityDoctorController.noDatamodel"));
return;
}
if (sourceFile == null) {
logger.warn(Localization.getText("CityDoctorController.noSourceFile"));
return;
}
try {
Platform.runLater(() -> {
mainWindow.getCheckButton().setDisable(true);
mainWindow.getErrorTree().getRoot().getChildren().clear();
mainWindow.getGlobalErrorsView().getItems().clear();
});
config.setNumberOfRoundingPlacesInGlobalParameters(currentConfig.getNumberOfRoundingPlaces());
config.setParserConfig(currentConfig);
currentChecker = new Checker(config, model);
currentChecker.runChecks(l);
Platform.runLater(() -> {
// apply check results to tree views
updateFeatureTrees();
updateTree(mainWindow.getPolygonsView().getRoot());
for (CheckError e : model.getGlobalErrors()) {
if (e instanceof SchematronError se) {
mainWindow.getGlobalErrorsView().getItems().add(se.getErrorIdString());
}
}
renderer.refresh();
mainWindow.getWriteReportButton().setDisable(false);
});
} finally {
Platform.runLater(() -> mainWindow.getCheckButton().setDisable(false));
}
}
void updateFeatureTrees() {
updateTree(mainWindow.getBuildingsView().getRoot());
updateTree(mainWindow.getVegetationView().getRoot());
updateTree(mainWindow.getBridgeView().getRoot());
updateTree(mainWindow.getTerrainView().getRoot());
updateTree(mainWindow.getTransportationView().getRoot());
updateTree(mainWindow.getWaterView().getRoot());
renderer.updateErrors();
}
private void updateTree(TreeItem<Renderable> root) {
if (root == null) {
return;
}
for (TreeItem<Renderable> item : root.getChildren()) {
updateItem(item);
}
}
private void updateItem(TreeItem<Renderable> item) {
if (item.getValue() == null) {
return;
}
item.getValue().refreshTextColor();
for (TreeItem<Renderable> child : item.getChildren()) {
updateItem(child);
}
}
public void writePdfReport(File pdfFile) {
if (currentChecker == null) {
return;
}
currentChecker.writePdfReport(pdfFile.getAbsolutePath());
}
public void writeXmlReport(File xmlFile) {
if (currentChecker == null) {
return;
}
currentChecker.writeXmlReport(xmlFile.getAbsolutePath());
}
private Map<ErrorId, ErrorStat> getErrorStats() {
Map<ErrorId, ErrorStat> stats = new HashMap<>();
addErrorStats(stats, model.getBridges());
addErrorStats(stats, model.getBuildings());
addErrorStats(stats, model.getLand());
addErrorStats(stats, model.getTransportation());
addErrorStats(stats, model.getVegetation());
addErrorStats(stats, model.getWater());
return stats;
}
private void addErrorStats(Map<ErrorId, ErrorStat> stats, List<? extends CityObject> cos) {
List<CheckError> errors = new ArrayList<>();
for (CityObject co : cos) {
co.collectContainedErrors(errors);
}
Set<CheckError> filteredErrors = new HashSet<>(errors);
for (CheckError error : filteredErrors) {
ErrorStat stat = stats.computeIfAbsent(error.getErrorId(), ErrorStat::new);
stat.incrementCount();
}
}
public void export(Building b) {
if (model == null) {
return;
}
CityDoctorModel newModel = new CityDoctorModel(model.getParserConfig(), model.getFile());
newModel.setCityModel(new CityModel());
newModel.addBuilding(b);
FileChooser fc = new FileChooser();
fc.getExtensionFilters().add(new ExtensionFilter("CityGML", "*.gml"));
fc.getExtensionFilters().add(new ExtensionFilter("OFF - Object File Format", "*.off"));
File dir = new File(Settings.get(Settings.LAST_OPEN_FOLDER, ""));
if (dir.exists() && dir.isDirectory()) {
fc.setInitialDirectory(dir);
} else {
Settings.set(Settings.LAST_OPEN_FOLDER, "");
}
File f = fc.showSaveDialog(mainWindow.getMainStage());
if (f != null) {
Settings.set(Settings.LAST_OPEN_FOLDER, f.getParent());
try {
newModel.saveAs(f.getAbsolutePath(), true);
} catch (CityDoctorWriteException e) {
logger.error(e);
}
}
}
public void showWorld() {
if (model != null) {
renderer.render(model);
}
}
public void storeModel(File f, boolean saveQualityAde) throws CityDoctorWriteException {
if (model == null) {
return;
}
model.saveAs(f.getAbsolutePath(), saveQualityAde);
}
public void searchFeature(String searchString, FeatureType selectedTab) {
if (model == null || searchString == null || searchString.trim().isEmpty()) {
return;
}
mainWindow.unselectEverything();
resetFeatureChunks();
if (selectedTab == FeatureType.BUILDING) {
List<Building> foundBuildings = filterFeatures(searchString, model.getBuildings());
TreeView<Renderable> buildingsView = mainWindow.getBuildingsView();
TreeItem<Renderable> root = buildingsView.getRoot();
root.getChildren().clear();
buildBuildingTreeFromList(foundBuildings, root);
updateTree(root);
addMoreButtonToBuildingsIfNecessary(foundBuildings, buildingsView, root, buildingChunkNr);
} else {
TreeView<Renderable> view;
List<? extends CityObject> cos;
AtomicInteger chunkCounter;
switch (selectedTab) {
case VEGETATION:
view = mainWindow.getVegetationView();
cos = filterFeatures(searchString, model.getVegetation());
chunkCounter = vegetationChunkNr;
break;
case BRIDGE:
view = mainWindow.getBridgeView();
cos = filterFeatures(searchString, model.getBridges());
chunkCounter = bridgeChunkNr;
break;
case TRANSPORTATION:
view = mainWindow.getTransportationView();
cos = filterFeatures(searchString, model.getTransportation());
chunkCounter = transportationChunkNr;
break;
case WATER:
view = mainWindow.getWaterView();
cos = filterFeatures(searchString, model.getWater());
chunkCounter = waterChunkNr;
break;
case LAND:
view = mainWindow.getTerrainView();
cos = filterFeatures(searchString, model.getLand());
chunkCounter = landChunkNr;
break;
default:
throw new IllegalStateException("Unknown selected feature tab");
}
TreeItem<Renderable> root = view.getRoot();
root.getChildren().clear();
buildTreeFromList(cos, root, chunkCounter);
updateTree(root);
addMoreButtonIfNecessary(cos, view, root, chunkCounter);
}
}
private <T extends CityObject> List<T> filterFeatures(String searchString, List<T> features) {
List<T> foundFeatures = new ArrayList<>();
for (T t : features) {
if (t.getGmlId().getGmlString().contains(searchString)) {
foundFeatures.add(t);
}
}
return foundFeatures;
}
public void resetSearch(FeatureType selectedTab) {
if (model == null) {
return;
}
resetFeatureChunks();
if (selectedTab == FeatureType.BUILDING) {
// buildings are handled differently, because of surface and building
// installations
TreeItem<Renderable> root = mainWindow.getBuildingsView().getRoot();
if (root != null) {
root.getChildren().clear();
buildBuildingTreeFromList(model.getBuildings(), root);
updateTree(root);
addMoreButtonToBuildingsIfNecessary(model.getBuildings(), mainWindow.getBuildingsView(), root,
buildingChunkNr);
}
} else {
TreeView<Renderable> view;
List<? extends CityObject> cos;
AtomicInteger chunkCounter;
switch (selectedTab) {
case VEGETATION:
view = mainWindow.getVegetationView();
cos = model.getVegetation();
chunkCounter = vegetationChunkNr;
break;
case BRIDGE:
view = mainWindow.getBridgeView();
cos = model.getBridges();
chunkCounter = bridgeChunkNr;
break;
case TRANSPORTATION:
view = mainWindow.getTransportationView();
cos = model.getTransportation();
chunkCounter = transportationChunkNr;
break;
case WATER:
view = mainWindow.getWaterView();
cos = model.getWater();
chunkCounter = waterChunkNr;
break;
case LAND:
view = mainWindow.getTerrainView();
cos = model.getLand();
chunkCounter = landChunkNr;
break;
default:
throw new IllegalStateException("Unknown selected feature tab");
}
TreeItem<Renderable> root = view.getRoot();
root.getChildren().clear();
buildTreeFromList(cos, root, chunkCounter);
updateTree(root);
addMoreButtonIfNecessary(cos, view, root, chunkCounter);
}
}
public Series<String, Number> createErrorSeries() {
Series<String, Number> series = new Series<>();
if (model == null) {
return series;
}
Map<ErrorId, ErrorStat> errorStats = getErrorStats();
for (ErrorStat es : errorStats.values()) {
series.getData().add(new Data<>(es.getErrorId().toString(), es.getCount()));
}
return series;
}
public String getFileName() {
return model.getFileName();
}
public void fillTreeViewWithErrorBuildings() {
TreeView<Renderable> buildingsView = mainWindow.getBuildingsView();
TreeItem<Renderable> root = buildingsView.getRoot();
if (model == null) {
return;
}
if (root == null) {
return;
}
mainWindow.resetSearchBar();
root.getChildren().clear();
List<Building> errorBuildings = new ArrayList<>();
for (Building b : model.getBuildings()) {
if (b.containsAnyError()) {
errorBuildings.add(b);
}
}
resetFeatureChunks();
buildBuildingTreeFromList(errorBuildings, root);
updateTree(root);
addMoreButtonToBuildingsIfNecessary(errorBuildings, buildingsView, root, buildingChunkNr);
}
public void fillTreeViewWithErrorVegetation() {
if (model == null) {
return;
}
fillTreeViewWithErrorCityObjects(mainWindow.getVegetationView(), model.getVegetation(), vegetationChunkNr);
}
public void fillTreeViewWithErrorBridges() {
if (model == null) {
return;
}
fillTreeViewWithErrorCityObjects(mainWindow.getBridgeView(), model.getBridges(), bridgeChunkNr);
}
public void fillTreeViewWithErrorLand() {
if (model == null) {
return;
}
fillTreeViewWithErrorCityObjects(mainWindow.getTerrainView(), model.getLand(), landChunkNr);
}
public void fillTreeViewWithErrorTransportation() {
if (model == null) {
return;
}
fillTreeViewWithErrorCityObjects(mainWindow.getTransportationView(), model.getTransportation(),
transportationChunkNr);
}
public void fillTreeViewWithErrorWater() {
if (model == null) {
return;
}
fillTreeViewWithErrorCityObjects(mainWindow.getWaterView(), model.getWater(), waterChunkNr);
}
private void fillTreeViewWithErrorCityObjects(TreeView<Renderable> treeView, List<? extends CityObject> objects,
AtomicInteger chunkCounter) {
TreeItem<Renderable> root = treeView.getRoot();
if (root == null) {
return;
}
mainWindow.resetSearchBar();
root.getChildren().clear();
List<CityObject> errorObjects = new ArrayList<>();
for (CityObject co : objects) {
if (co.containsAnyError()) {
errorObjects.add(co);
}
}
buildTreeFromList(errorObjects, root, chunkCounter);
updateTree(root);
addMoreButtonIfNecessary(errorObjects, treeView, root, chunkCounter);
}
public void fillTreeViewFromFeatures(FeatureType selectedTab) {
if (model == null) {
return;
}
mainWindow.resetSearchBar();
switch (selectedTab) {
case BUILDING:
buildBuildings(model);
updateTree(mainWindow.getBuildingsView().getRoot());
break;
case VEGETATION:
buildVegetation(model.getVegetation());
updateTree(mainWindow.getVegetationView().getRoot());
break;
case BRIDGE:
buildBridges(model);
updateTree(mainWindow.getBridgeView().getRoot());
break;
case LAND:
buildLand(model);
updateTree(mainWindow.getTerrainView().getRoot());
break;
case TRANSPORTATION:
buildTransportation(model.getTransportation());
updateTree(mainWindow.getTransportationView().getRoot());
break;
case WATER:
buildWater(model);
updateTree(mainWindow.getWaterView().getRoot());
break;
default:
throw new IllegalStateException();
}
}
public CityDoctorModel getModel() {
return model;
}
public void showView(View v) {
v.fireOnShowEvent(model, currentChecker, mainWindow);
}
public void askAndSave() {
boolean saveWithQualityAde = true;
if (model.isValidated()) {
ButtonType yesBtn = ButtonType.YES;
ButtonType noBtn = ButtonType.NO;
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setTitle("Save with QualityADE?");
dialog.setContentText("Save with QualityADE information?");
dialog.getDialogPane().getButtonTypes().add(yesBtn);
dialog.getDialogPane().getButtonTypes().add(noBtn);
Optional<ButtonType> result = dialog.showAndWait();
if (result.isPresent() && result.get() == ButtonType.NO) {
saveWithQualityAde = false;
}
}
FileChooser fc = new FileChooser();
fc.getExtensionFilters().add(new ExtensionFilter("CityGML", "*.gml"));
fc.getExtensionFilters().add(new ExtensionFilter("OFF - Object File Format", "*.off"));
File dir = new File(Settings.get(Settings.LAST_OPEN_FOLDER, ""));
if (dir.exists() && dir.isDirectory()) {
fc.setInitialDirectory(dir);
} else {
Settings.set(Settings.LAST_OPEN_FOLDER, "");
}
File f = fc.showSaveDialog(mainWindow.getMainStage());
if (f != null) {
Settings.set(Settings.LAST_OPEN_FOLDER, f.getParent());
try {
storeModel(f, saveWithQualityAde);
} catch (CityDoctorWriteException e) {
mainWindow.showExceptionDialog(e);
}
}
}
public void delete(TreeItem<Renderable> selectedItem) {
if (model == null) {
return;
}
Renderable render = selectedItem.getValue();
if (render instanceof BuildingNode node) {
model.getBuildings().remove(node.getBuilding());
mainWindow.getBuildingsView().getRoot().getChildren().remove(selectedItem);
}
}
public void errorFilterIndexChanged(Number newV) {
mainWindow.getMeshGroup().getChildren().clear();
mainWindow.unselectEverything();
if (newV.intValue() == 0) {
fillTreeViewFromFeatures(mainWindow.getSelectedTab());
} else if (newV.intValue() == 1) {
switch (mainWindow.getSelectedTab()) {
case BUILDING:
fillTreeViewWithErrorBuildings();
break;
case VEGETATION:
fillTreeViewWithErrorVegetation();
break;
case BRIDGE:
fillTreeViewWithErrorBridges();
break;
case LAND:
fillTreeViewWithErrorLand();
break;
case TRANSPORTATION:
fillTreeViewWithErrorTransportation();
break;
case WATER:
fillTreeViewWithErrorWater();
break;
default:
throw new IllegalStateException("Unknown selected feature tab: " + mainWindow.getSelectedTab());
}
} else {
throw new IllegalStateException("Unknown filter index selected: " + newV);
}
}
public ParserConfiguration getCurrentConfig() {
return currentConfig;
}
}
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