Commit c30de7dc authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

issue #43. Add button and dialog to resize topography bound from editor

New toolbar button with modal dialog to change width and size of
topography from the topography creator window.
Todo: new icon for resize action
Todo: Scenario Pane is not marked as changed (asterisk on scenario name)
Todo: Message Dialog for wrong syntax
Todo: allow comma an decimal point
parent 16279b58
......@@ -207,6 +207,8 @@ PostVis.menuCloseFloorFieldFile.title=Remove Floor Field File
OnlineVis.btnShowPotentialfield.tooltip=Show the Target Potential Field for the selected Agent
TopographyBoundDialog.title = Set Topography Bounds
InformationDialogError.title=Internal Error
InformationDialogFileError=Could not load file!
LoadingDialog.title=Loading...
......@@ -252,6 +254,7 @@ TopographyCreator.btnUndo.tooltip=Undo
TopographyCreator.btnRedo.tooltip=Redo
TopographyCreator.btnCutTopography.tooltip=Cut Scenario
TopographyCreator.btnInsertPedestrian.tooltip=Pedestrian
TopographyCreator.btnTopographyBound.tooltip=Topography Bound
TopographyCreator.btnInsertObstacle.tooltip=Obstacle
TopographyCreator.btnInsertTarget.tooltip=Target
TopographyCreator.btnInsertSource.tooltip=Source
......
......@@ -206,6 +206,8 @@ PostVis.menuCloseFloorFieldFile.title=Floor Field-Datei l\u00F6schen
OnlineVis.btnShowPotentialfield.tooltip=Zeigt das Zielpotenzialfeld des ausgew\u00E4hlten Agenten
TopographyBoundDialog.title = Setze Topographie Grenzen
InformationDialogError.title=Interner Fehelr
InformationDialogFileError=Datei konnte nicht geladen werden!
LoadingDialog.title=Lade...
......@@ -253,6 +255,7 @@ TopographyCreator.btnCutTopography.tooltip=Szenario ausschneiden
TopographyCreator.btnInsertPedestrian.tooltip=Fu\u00dfg\u00e4nger
TopographyCreator.btnInsertObstacle.tooltip=Hindernis
TopographyCreator.btnInsertTarget.tooltip=Ziel
TopographyCreator.btnTopographyBound.tooltip=Topographie Grenze
TopographyCreator.btnInsertSource.tooltip=Quelle
TopographyCreator.btnInsertStairs.tooltip=Treppen
TopographyCreator.btnErase.tooltip=Radierer
......
package org.vadere.gui.topographycreator.control;
import org.vadere.gui.postvisualization.view.DialogFactory;
import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VRectangle;
import java.awt.event.ActionEvent;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.*;
public class ActionResizeTopographyBound extends TopographyAction {
private TopographyAction action;
public ActionResizeTopographyBound(String name, ImageIcon icon, IDrawPanelModel<?> panelModel,
TopographyAction action) {
super(name, icon, panelModel);
this.action = action;
}
public ActionResizeTopographyBound(final String name, final IDrawPanelModel<?> panelModel,
TopographyAction action) {
super(name, panelModel);
this.action = action;
}
@Override
public void actionPerformed(ActionEvent e) {
//set to Selection to to be sure no accidental changes are introduced
action.actionPerformed(e);
TopographyCreatorModel model = (TopographyCreatorModel) getScenarioPanelModel();
JTextField textField = new JTextField();
textField.setText(String.format("%.3f x %.3f",
model.getTopography().getBounds().width,
model.getTopography().getBounds().height));
if (JOptionPane.showConfirmDialog(ProjectView.getMainWindow(), textField,
"Set width x height", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION){
String input = textField.getText().trim().replace(" ", "");
String[] in = input.split("x");
double width;
double height;
VRectangle bound = null;
try{
width = Double.valueOf(in[0]);
height = Double.valueOf(in[1]);
bound = new VRectangle(0.0,0.0,width, height);
}catch (NumberFormatException exp){
System.out.println("wrong format");
}
if (bound != null){
model.setTopographyBound(bound);
}
}
getScenarioPanelModel().notifyObservers();
}
}
......@@ -23,6 +23,7 @@ import org.vadere.gui.topographycreator.control.ActionOpenDrawOptionMenu;
import org.vadere.gui.topographycreator.control.ActionQuickSaveTopography;
import org.vadere.gui.topographycreator.control.ActionRedo;
import org.vadere.gui.topographycreator.control.ActionResetTopography;
import org.vadere.gui.topographycreator.control.ActionResizeTopographyBound;
import org.vadere.gui.topographycreator.control.ActionSelectCut;
import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import org.vadere.gui.topographycreator.control.ActionSwitchCategory;
......@@ -65,7 +66,7 @@ public class TopographyWindow extends JPanel {
private UndoableEditSupport undoSupport;
private UndoManager undoManager;
public TopographyWindow(final Scenario currentScenario) throws IOException, IntrospectionException {
public TopographyWindow(final Scenario currentScenario) {
toolbar = new ScenarioToolBar("Toolbar");
int toolbarSize = Integer.parseInt(resources.getProperty("Toolbar.size"));
......@@ -247,8 +248,8 @@ public class TopographyWindow extends JPanel {
undoSupport),
basicAction);
List<Action> obstacleAndTargetDrawModes = new ArrayList<Action>();
List<Action> sourceDrawModes = new ArrayList<Action>();
List<Action> obstacleAndTargetDrawModes = new ArrayList<>();
List<Action> sourceDrawModes = new ArrayList<>();
obstacleAndTargetDrawModes.add(rectangle);
obstacleAndTargetDrawModes.add(pen);
......@@ -294,6 +295,11 @@ public class TopographyWindow extends JPanel {
ActionSelectSelectShape selectShape = new ActionSelectSelectShape("select shape mode", new ImageIcon(
Resources.class.getResource("/icons/select_shapes_icon.png")), panelModel, undoSupport);
/* resize Topography */
TopographyAction resizeTopographyBound =new ActionResizeTopographyBound("SetTopograpyBound",
new ImageIcon(Resources.class.getResource("/icons/paint_method_rectangle_icon.png")),
panelModel, selectShape);
addActionToToolbar(toolbar, selectShape, "select_shape_tooltip");
addActionToToolbar(
toolbar,
......@@ -311,6 +317,7 @@ public class TopographyWindow extends JPanel {
addActionToToolbar(toolbar, openObstacleDialog, "TopographyCreator.btnInsertObstacle.tooltip",
obsButton);
addActionToToolbar(toolbar, closeDialogAction, "TopographyCreator.btnInsertPedestrian.tooltip");
addActionToToolbar(toolbar, resizeTopographyBound, "TopographyCreator.btnTopographyBound.tooltip");
addActionToToolbar(toolbar, openStairsDialog, "TopographyCreator.btnInsertStairs.tooltip",
stairsButton);
toolbar.addSeparator(new Dimension(5, 50));
......
Markdown is supported
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