16.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 17ea3e8c authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

Merge branch 'dev/MeshPlotting' into 'master'

Dev/mesh plotting

See merge request !133
parents d77a1a8d 290ae70a
Pipeline #266819 passed with stages
in 145 minutes and 18 seconds
...@@ -136,6 +136,7 @@ ProjectView.chooseFile=Chose file ...@@ -136,6 +136,7 @@ ProjectView.chooseFile=Chose file
ProjectView.ScenarioChecker.title=Scenario Checker ProjectView.ScenarioChecker.title=Scenario Checker
ProjectView.ScenarioChecker.deactive.text=ScenarioChecker deactivated. Project > Activate ScenarioChecker ProjectView.ScenarioChecker.deactive.text=ScenarioChecker deactivated. Project > Activate ScenarioChecker
ProjectView.ScenarioChecker.active.text=The following problems where found ProjectView.ScenarioChecker.active.text=The following problems where found
ProjectView.btnGenerateMesh.tooltip=Generate background mesh
SaveBeforeClosing.text=Do you want to save the current project before closing? SaveBeforeClosing.text=Do you want to save the current project before closing?
...@@ -364,6 +365,7 @@ TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.requested.text=Req ...@@ -364,6 +365,7 @@ TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.requested.text=Req
TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.placed.text=Placed pedestrians TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.placed.text=Placed pedestrians
TopographyCreator.btnChecker.tooltip=Show Topography Checker Messages TopographyCreator.btnChecker.tooltip=Show Topography Checker Messages
TopographyCreator.btnGenerateIds.tooltip=Generate missing Ids for sources, targets, ... TopographyCreator.btnGenerateIds.tooltip=Generate missing Ids for sources, targets, ...
TopographyCreator.btnGenerateMesh.tooltip=Generate background mesh
select_shape_tooltip=Select Shape select_shape_tooltip=Select Shape
......
...@@ -137,6 +137,7 @@ ProjectView.label.simResults=Simulationsergebniss ...@@ -137,6 +137,7 @@ ProjectView.label.simResults=Simulationsergebniss
ProjectView.ScenarioChecker.title=Scenario Checker ProjectView.ScenarioChecker.title=Scenario Checker
ProjectView.ScenarioChecker.deactive.text=ScenarioChecker deaktiviert. Projekt > ScenarioChecker aktivieren ProjectView.ScenarioChecker.deactive.text=ScenarioChecker deaktiviert. Projekt > ScenarioChecker aktivieren
ProjectView.ScenarioChecker.active.text=Probleme gefunden ProjectView.ScenarioChecker.active.text=Probleme gefunden
ProjectView.btnGenerateMesh.tooltip=Generiere Hintergrundgitter
SaveBeforeClosing.text=Aktuelles Projekt vor dem Beenden speichern? SaveBeforeClosing.text=Aktuelles Projekt vor dem Beenden speichern?
...@@ -356,7 +357,7 @@ TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.requested.text=Ang ...@@ -356,7 +357,7 @@ TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.requested.text=Ang
TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.placed.text=Platzierte Fu\u00dfg\u00e4nger TopographyCreator.PlaceRandomPedestrians.couldNotPlaceAllPeds.placed.text=Platzierte Fu\u00dfg\u00e4nger
TopographyCreator.btnChecker.tooltip=Topography Linter Nachrichten TopographyCreator.btnChecker.tooltip=Topography Linter Nachrichten
TopographyCreator.btnGenerateIds.tooltip=Erzeuge fehlende Ids f\u00fcr Quellen, Ziele, ... TopographyCreator.btnGenerateIds.tooltip=Erzeuge fehlende Ids f\u00fcr Quellen, Ziele, ...
TopographyCreator.btnGenerateMesh.tooltip=Generiere Hintergrundgitter
# tab titles Topography creator / postvis # tab titles Topography creator / postvis
Tab.Simulation.title=Simulation Tab.Simulation.title=Simulation
......
package org.vadere.gui.components.control;
import org.apache.commons.configuration2.Configuration;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.control.simulation.ActionGeneratePNG;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.topographycreator.view.ActionTranslateTopographyDialog;
import org.vadere.meshing.mesh.gen.PFace;
import org.vadere.meshing.mesh.gen.PHalfEdge;
import org.vadere.meshing.mesh.gen.PVertex;
import org.vadere.meshing.mesh.impl.PSLG;
import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.meshing.utils.MeshConstructor;
import org.vadere.meshing.utils.io.poly.MeshPolyWriter;
import org.vadere.simulator.utils.pslg.PSLGConverter;
import org.vadere.util.config.VadereConfig;
import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import javax.swing.*;
public class ActionGenerateMesh extends AbstractAction {
private static Logger logger = Logger.getLogger(ActionGeneratePNG.class);
private static final Configuration CONFIG = VadereConfig.getConfig();
private final ProjectViewModel model;
public ActionGenerateMesh(final String name, Icon icon, final ProjectViewModel model) {
super(name, icon);
this.model = model;
}
@Override
public void actionPerformed(final ActionEvent e) {
/*JFileChooser fileChooser = new JFileChooser(CONFIG.getString("SettingsDialog.snapshotDirectory.path"));
Date todaysDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat(CONFIG.getString("SettingsDialog.dataFormat"));
String formattedDate = formatter.format(todaysDate);*/
ActionTranslateTopographyDialog dialog = new ActionTranslateTopographyDialog(0.5, 5.0, "hmin, hmax");
if (dialog.getValue()){
double hmin = dialog.getX();
double hmax = dialog.getY();
PSLGConverter pslgConverter = new PSLGConverter();
PSLG pslg = pslgConverter.toPSLG(model.getCurrentScenario().getTopography());
logger.info("generate poly");
MeshConstructor constructor = new MeshConstructor();
CompletableFuture.supplyAsync(() -> constructor.pslgToAdaptivePMesh(pslg, hmin, hmax, true)).thenAccept(mesh -> saveFloorFieldMesh(mesh,""));
CompletableFuture.supplyAsync(() -> constructor.pslgToCoarsePMesh(pslg, true)).thenAccept(mesh -> saveFloorFieldMesh(mesh,IOUtils.BACKGROUND_MESH_ENDING));
}
}
private void saveFloorFieldMesh(@NotNull final IMesh<PVertex, PHalfEdge, PFace> mesh, final String ending) {
logger.info("generate mesh");
File meshDir = new File(model.getCurrentProjectPath().concat("/" + IOUtils.SCENARIO_DIR + "/" + IOUtils.MESH_DIR));
File outputFile = new File(meshDir.getAbsoluteFile() + "/" + model.getCurrentScenario().getName() + ending + ".poly");
MeshPolyWriter<PVertex, PHalfEdge, PFace> meshPolyWriter = new MeshPolyWriter<>();
String meshString = meshPolyWriter.to2DPoly(mesh);
if(meshDir.exists()) {
meshDir.mkdir();
}
if(!outputFile.exists()) {
try {
outputFile.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
}
}
try(FileWriter fileWriter = new FileWriter(outputFile)) {
fileWriter.write(meshString);
logger.info("generate new mesh file: " + outputFile.getAbsolutePath());
} catch (IOException ex) {
logger.error(ex.getMessage());
ex.printStackTrace();
}
}
}
...@@ -51,7 +51,7 @@ public abstract class SimulationModel<T extends DefaultSimulationConfig> extends ...@@ -51,7 +51,7 @@ public abstract class SimulationModel<T extends DefaultSimulationConfig> extends
return config; return config;
} }
public IMesh<?, ?, ?> getDiscretization() { public IMesh<?, ?, ?> getFloorFieldMesh() {
return new PMesh(); return new PMesh();
} }
......
...@@ -673,7 +673,10 @@ public abstract class DefaultRenderer { ...@@ -673,7 +673,10 @@ public abstract class DefaultRenderer {
@NotNull final Graphics2D g, @NotNull final Graphics2D g,
@NotNull final IMesh<?, ?, ?> mesh, @NotNull final IMesh<?, ?, ?> mesh,
@NotNull final VRectangle bound) { @NotNull final VRectangle bound) {
MeshRenderer<?, ?, ?> meshRenderer = new MeshRenderer<>(mesh);
MeshRenderer<?, ?, ?> meshRenderer = new MeshRenderer<>(mesh, false);
meshRenderer.renderPostTransform(g, bound);
//meshRenderer.renderGraphics(g, bound); //meshRenderer.renderGraphics(g, bound);
} }
......
...@@ -108,7 +108,7 @@ public abstract class SimulationRenderer extends DefaultRenderer { ...@@ -108,7 +108,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
} }
if(model.config.isShowTargetPotentielFieldMesh()) { if(model.config.isShowTargetPotentielFieldMesh()) {
renderMesh(graphics, model.getDiscretization(), new VRectangle(model.getTopographyBound())); renderMesh(graphics, model.getFloorFieldMesh(), new VRectangle(model.getTopographyBound()));
} }
renderSimulationContent(graphics); renderSimulationContent(graphics);
......
...@@ -9,6 +9,7 @@ import org.vadere.meshing.mesh.inter.IMesh; ...@@ -9,6 +9,7 @@ import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.simulator.control.simulation.PassiveCallback; import org.vadere.simulator.control.simulation.PassiveCallback;
import org.vadere.simulator.models.potential.fields.IPotentialField; import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget; import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.simulator.projects.Domain;
import org.vadere.state.scenario.Agent; import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VRectangle; import org.vadere.util.geometry.shapes.VRectangle;
...@@ -25,7 +26,7 @@ public class OnlineVisualization implements PassiveCallback { ...@@ -25,7 +26,7 @@ public class OnlineVisualization implements PassiveCallback {
*/ */
public class ObservationAreaSnapshotData { public class ObservationAreaSnapshotData {
public final double simTimeInSec; public final double simTimeInSec;
public final Topography scenario; public final Domain domain;
public final IPotentialField potentialFieldTarget; public final IPotentialField potentialFieldTarget;
public final Agent selectedAgent; public final Agent selectedAgent;
public final IPotentialField potentialField; public final IPotentialField potentialField;
...@@ -33,13 +34,13 @@ public class OnlineVisualization implements PassiveCallback { ...@@ -33,13 +34,13 @@ public class OnlineVisualization implements PassiveCallback {
public ObservationAreaSnapshotData( public ObservationAreaSnapshotData(
final double simTimeInSec, final double simTimeInSec,
@NotNull final Topography scenario, @NotNull final Domain scenario,
@Nullable final IPotentialField potentialFieldTarget, @Nullable final IPotentialField potentialFieldTarget,
@Nullable final IPotentialField potentialField, @Nullable final IPotentialField potentialField,
@Nullable final Agent selectedAgent, @Nullable final Agent selectedAgent,
@Nullable final Function<Agent, IMesh<?, ?, ?>> discretizations) { @Nullable final Function<Agent, IMesh<?, ?, ?>> discretizations) {
this.simTimeInSec = simTimeInSec; this.simTimeInSec = simTimeInSec;
this.scenario = scenario; this.domain = scenario;
this.potentialFieldTarget = potentialFieldTarget; this.potentialFieldTarget = potentialFieldTarget;
this.potentialField = potentialField; this.potentialField = potentialField;
this.selectedAgent = selectedAgent; this.selectedAgent = selectedAgent;
...@@ -50,7 +51,7 @@ public class OnlineVisualization implements PassiveCallback { ...@@ -50,7 +51,7 @@ public class OnlineVisualization implements PassiveCallback {
private MainPanel window; private MainPanel window;
private OnlineVisualisationWindow onlineVisualisationPanel; private OnlineVisualisationWindow onlineVisualisationPanel;
private OnlineVisualizationModel model; private OnlineVisualizationModel model;
private Topography scenario; private Domain domain;
/** /**
* Target potential. * Target potential.
...@@ -75,8 +76,8 @@ public class OnlineVisualization implements PassiveCallback { ...@@ -75,8 +76,8 @@ public class OnlineVisualization implements PassiveCallback {
} }
@Override @Override
public void setTopography(final Topography scenario) { public void setDomain(final Domain domain) {
this.scenario = scenario; this.domain = domain;
} }
@Override @Override
...@@ -146,7 +147,7 @@ public class OnlineVisualization implements PassiveCallback { ...@@ -146,7 +147,7 @@ public class OnlineVisualization implements PassiveCallback {
pedPotentialField = IPotentialField.copyAgentField(potentialField, selectedAgent, new VRectangle(model.getTopographyBound()), 0.1); pedPotentialField = IPotentialField.copyAgentField(potentialField, selectedAgent, new VRectangle(model.getTopographyBound()), 0.1);
} }
ObservationAreaSnapshotData data = new ObservationAreaSnapshotData(simTimeInSec, scenario.clone(), pft, pedPotentialField, selectedAgent, discretizations); ObservationAreaSnapshotData data = new ObservationAreaSnapshotData(simTimeInSec, domain.clone(), pft, pedPotentialField, selectedAgent, discretizations);
model.pushObservationAreaSnapshot(data); model.pushObservationAreaSnapshot(data);
} }
} }
......
...@@ -14,9 +14,11 @@ import org.vadere.gui.components.model.AgentColoring; ...@@ -14,9 +14,11 @@ import org.vadere.gui.components.model.AgentColoring;
import org.vadere.gui.components.model.DefaultSimulationConfig; import org.vadere.gui.components.model.DefaultSimulationConfig;
import org.vadere.gui.components.model.SimulationModel; import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.onlinevisualization.OnlineVisualization; import org.vadere.gui.onlinevisualization.OnlineVisualization;
import org.vadere.meshing.mesh.gen.AMesh;
import org.vadere.meshing.mesh.gen.PMesh; import org.vadere.meshing.mesh.gen.PMesh;
import org.vadere.meshing.mesh.inter.IMesh; import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.simulator.models.potential.fields.IPotentialField; import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.projects.Domain;
import org.vadere.state.scenario.*; import org.vadere.state.scenario.*;
import org.vadere.util.geometry.shapes.IPoint; import org.vadere.util.geometry.shapes.IPoint;
import org.vadere.util.voronoi.VoronoiDiagram; import org.vadere.util.voronoi.VoronoiDiagram;
...@@ -38,8 +40,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -38,8 +40,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
private IPotentialField potentialField = null; private IPotentialField potentialField = null;
private Function<Agent, IMesh<?, ?, ?>> discretizations = null;
private Agent agent = null; private Agent agent = null;
/** /**
...@@ -63,7 +63,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -63,7 +63,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
* The observation area to display. Updated by popDrawData() with the latest * The observation area to display. Updated by popDrawData() with the latest
* observation area snapshot. * observation area snapshot.
*/ */
private Topography topography; private Domain domain;
public OnlineVisualizationModel() { public OnlineVisualizationModel() {
super(new DefaultSimulationConfig()); super(new DefaultSimulationConfig());
...@@ -75,21 +75,21 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -75,21 +75,21 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
@Override @Override
public Collection<Agent> getAgents() { public Collection<Agent> getAgents() {
if (topography == null) { if (domain == null || domain.getTopography() == null) {
return new ArrayList<>(); return new ArrayList<>();
} }
Collection<Agent> result = new LinkedList<>(); Collection<Agent> result = new LinkedList<>();
result.addAll(topography.getElements(Agent.class)); result.addAll(domain.getTopography().getElements(Agent.class));
return result; return result;
} }
@Override @Override
public Collection<Pedestrian> getPedestrians() { public Collection<Pedestrian> getPedestrians() {
if (topography == null) { if (domain == null) {
return new ArrayList<>(); return new ArrayList<>();
} }
Collection<Pedestrian> result = new LinkedList<>(); Collection<Pedestrian> result = new LinkedList<>();
result.addAll(topography.getElements(Pedestrian.class)); result.addAll(domain.getTopography().getElements(Pedestrian.class));
return result; return result;
} }
...@@ -100,15 +100,18 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -100,15 +100,18 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
@Override @Override
public Topography getTopography() { public Topography getTopography() {
return topography; if(domain == null) {
return null;
}
return domain.getTopography();
} }
@Override @Override
public Iterator<ScenarioElement> iterator() { public Iterator<ScenarioElement> iterator() {
if (topography == null) { if (domain == null) {
return new ArrayList<ScenarioElement>().iterator(); return new ArrayList<ScenarioElement>().iterator();
} }
return new TopographyIterator(topography); return new TopographyIterator(domain.getTopography());
} }
/** /**
...@@ -130,7 +133,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -130,7 +133,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
potentialFieldTarget = observationAreaSnapshot.potentialFieldTarget; potentialFieldTarget = observationAreaSnapshot.potentialFieldTarget;
potentialField = observationAreaSnapshot.potentialField; potentialField = observationAreaSnapshot.potentialField;
agent = observationAreaSnapshot.selectedAgent; agent = observationAreaSnapshot.selectedAgent;
discretizations = observationAreaSnapshot.discretizations;
/* /*
* if(topography == null || * if(topography == null ||
...@@ -139,30 +141,30 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -139,30 +141,30 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
* } * }
*/ */
if (topography == null) { if (domain == null) {
topography = observationAreaSnapshot.scenario; domain = observationAreaSnapshot.domain;
// recalculate GUI (fireChangeViewportEvent will synchronize on model which is also // recalculate GUI (fireChangeViewportEvent will synchronize on model which is also
// needed by some awt event. Therefore do this in EDT (Event Dispatching Thread) // needed by some awt event. Therefore do this in EDT (Event Dispatching Thread)
EventQueue.invokeLater(() -> { EventQueue.invokeLater(() -> {
fireChangeViewportEvent(new Rectangle2D.Double(topography.getBounds().x, topography.getBounds().y, fireChangeViewportEvent(new Rectangle2D.Double(getTopography().getBounds().x, getTopography().getBounds().y,
topography.getBounds().width, topography.getBounds().height)); getTopography().getBounds().width, getTopography().getBounds().height));
}); });
} else { } else {
topography = observationAreaSnapshot.scenario; domain = observationAreaSnapshot.domain;
} }
if (getSelectedElement() instanceof Car) { if (getSelectedElement() instanceof Car) {
int carId = getSelectedElement().getId(); int carId = getSelectedElement().getId();
Car car = topography.getElement(Car.class, carId); Car car = domain.getTopography().getElement(Car.class, carId);
setSelectedElement(car); setSelectedElement(car);
} else if (getSelectedElement() instanceof Pedestrian) { } else if (getSelectedElement() instanceof Pedestrian) {
int pedId = getSelectedElement().getId(); int pedId = getSelectedElement().getId();
Pedestrian ped = topography.getElement(Pedestrian.class, pedId); Pedestrian ped = domain.getTopography().getElement(Pedestrian.class, pedId);
setSelectedElement(ped); setSelectedElement(ped);
} }
if (isVoronoiDiagramAvailable() && isVoronoiDiagramVisible()) { if (isVoronoiDiagramAvailable() && isVoronoiDiagramVisible()) {
getVoronoiDiagram().computeVoronoiDiagram(topography.getPedestrianDynamicElements().getElements() getVoronoiDiagram().computeVoronoiDiagram(domain.getTopography().getPedestrianDynamicElements().getElements()
.stream() .stream()
.map(ped -> ped.getPosition()) .map(ped -> ped.getPosition())
.collect(Collectors.toList())); .collect(Collectors.toList()));
...@@ -186,7 +188,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -186,7 +188,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
selectedElement = null; selectedElement = null;
voronoiDiagram = null; voronoiDiagram = null;
topography = null; domain = null;
simTimeInSec = 0.0; simTimeInSec = 0.0;
} }
...@@ -225,12 +227,12 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -225,12 +227,12 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
} }
@Override @Override
public IMesh<?, ?, ?> getDiscretization() { public IMesh<?, ?, ?> getFloorFieldMesh() {
if(agent != null && discretizations != null && config.isShowTargetPotentielFieldMesh() && agent.equals(getSelectedElement())) { if(domain.getFloorFieldMesh() != null) {
return discretizations.apply(agent); return domain.getFloorFieldMesh();
} else {
return new AMesh();
} }
return new PMesh();
} }
@Override @Override
...@@ -263,6 +265,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC ...@@ -263,6 +265,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
@Override @Override
public boolean isAlive(int pedId) { public boolean isAlive(int pedId) {
return topography.getPedestrianDynamicElements().idExists(pedId); return domain.getTopography().getPedestrianDynamicElements().idExists(pedId);
} }
} }
...@@ -256,7 +256,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro ...@@ -256,7 +256,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
tabbedPane.removeTabAt(tabbedPane.indexOfComponent(topographyCreatorView)); tabbedPane.removeTabAt(tabbedPane.indexOfComponent(topographyCreatorView));
} }
topographyCreatorView = new TopographyWindow(scenario); topographyCreatorView = new TopographyWindow(scenario, model);
tabbedPane.addTab(Messages.getString("Tab.TopographyCreator.title"), topographyCreatorView); tabbedPane.addTab(Messages.getString("Tab.TopographyCreator.title"), topographyCreatorView);
tabbedPane.validate(); tabbedPane.validate();
tabbedPane.repaint(); tabbedPane.repaint();
......
...@@ -19,8 +19,13 @@ public class ActionTranslateTopographyDialog { ...@@ -19,8 +19,13 @@ public class ActionTranslateTopographyDialog {
private final double xOld; private final double xOld;
private final double yOld; private final double yOld;
private boolean valid; private boolean valid;
private final String label;
public ActionTranslateTopographyDialog(final double x, double y){ public ActionTranslateTopographyDialog(final double x, double y){
this(x, y, "x, y");
}
public ActionTranslateTopographyDialog(final double x, double y, final String label){
this.textField = new JTextField(30); this.textField = new JTextField(30);
this.textField.setText(String.format(Locale.ENGLISH, "%f, %f", x, y)); this.textField.setText(String.format(Locale.ENGLISH, "%f, %f", x, y));
...@@ -30,6 +35,7 @@ public class ActionTranslateTopographyDialog { ...@@ -30,6 +35,7 @@ public class ActionTranslateTopographyDialog {
this.y = y; this.y = y;
this.xOld = x; this.xOld = x;
this.yOld = y; this.yOld = y;
this.label = label;
} }
public double getX() { public double getX() {
...@@ -44,7 +50,7 @@ public class ActionTranslateTopographyDialog { ...@@ -44,7 +50,7 @@ public class ActionTranslateTopographyDialog {
return JOptionPane.showConfirmDialog( return JOptionPane.showConfirmDialog(
ProjectView.getMainWindow(), ProjectView.getMainWindow(),
textField, textField,
"x, y", label,