Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit 7f428aea authored by BZoennchen's avatar BZoennchen

forgot the icon for the new action in the topographycreator.

parent 70017e7a
Pipeline #75621 canceled with stages
......@@ -296,6 +296,7 @@ TopographyCreator.btnCutTopography.tooltip=Cut Scenario
TopographyCreator.btnInsertPedestrian.tooltip=Pedestrian
TopographyCreator.btnTopographyBound.tooltip=Topography Bound
TopographyCreator.btnTranslation.tooltip=Translate topography
TopographyCreator.btnElementTranslation.tooltip=Translate topography elements
TopographyCreator.btnInsertObstacle.tooltip=Obstacle
TopographyCreator.btnInsertTarget.tooltip=Target
TopographyCreator.btnInsertSource.tooltip=Source
......
......@@ -292,6 +292,7 @@ TopographyCreator.btnInsertObstacle.tooltip=Hindernis
TopographyCreator.btnInsertTarget.tooltip=Ziel
TopographyCreator.btnTopographyBound.tooltip=Topographie Grenze
TopographyCreator.btnTranslation.tooltip=Topographie verschieben
TopographyCreator.btnElementTranslation.tooltip=Elemente der Topography verschieben
TopographyCreator.btnInsertSource.tooltip=Quelle
TopographyCreator.btnInsertStairs.tooltip=Treppen
TopographyCreator.btnErase.tooltip=Radierer
......
package org.vadere.gui.topographycreator.control;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.gui.topographycreator.view.ActionTranslateTopographyDialog;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.awt.event.ActionEvent;
import java.awt.geom.Rectangle2D;
import javax.swing.*;
import javax.swing.undo.UndoableEditSupport;
/**
* @author Benedikt Zoennchen
*/
public class ActionTranslateElements extends TopographyAction {
private TopographyAction action;
private final UndoableEditSupport undoableEditSupport;
public ActionTranslateElements(final String name,
final ImageIcon icon,
@NotNull final IDrawPanelModel<?> panelModel,
@NotNull final TopographyAction action,
@NotNull final UndoableEditSupport undoSupport) {
super(name, icon, panelModel);
this.action = action;
this.undoableEditSupport = undoSupport;
}
@Override
public void actionPerformed(ActionEvent e) {
action.actionPerformed(e);
TopographyCreatorModel model = (TopographyCreatorModel) getScenarioPanelModel();
ActionTranslateTopographyDialog dialog = new ActionTranslateTopographyDialog(0, 0);
if (dialog.getValue()){
double x = dialog.getX();
double y = dialog.getY();
TopographyCreatorModel topographyCreatorModel = (TopographyCreatorModel) getScenarioPanelModel();
topographyCreatorModel.translateElements(x, y);
undoableEditSupport.postEdit(new EditTranslateElements(topographyCreatorModel, x, y));
}
getScenarioPanelModel().notifyObservers();
}
}
package org.vadere.gui.topographycreator.control;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
/**
* @author Benedikt Zoennchen
*/
public class EditTranslateElements extends AbstractUndoableEdit {
private static final long serialVersionUID = 5176192525116057658L;
private final TopographyCreatorModel panelModel;
private final double dx;
private final double dy;
public EditTranslateElements(@NotNull final TopographyCreatorModel panelModel,
final double dx,
final double dy) {
this.panelModel = panelModel;
this.dx = dx;
this.dy = dy;
}
@Override
public void undo() throws CannotUndoException {
panelModel.translateElements(-dx, -dy);
}
@Override
public void redo() throws CannotRedoException {
panelModel.translateTopography(dx, dy);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public boolean canRedo() {
return true;
}
@Override
public String getPresentationName() {
return "translate elements";
}
}
......@@ -335,12 +335,16 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
public void translateTopography(final double x, final double y) {
double oldX = getTopographyBound().x;
double oldY = getTopographyBound().y;
topographyBuilder.translateElements(x - oldX, y - oldY);
translateElements(x - oldX, y - oldY);
setTopographyBound(new VRectangle(x, y, getTopographyBound().getWidth(), getTopographyBound().getHeight()));
setChanged();
}
public void translateElements(final double dx, final double dy) {
topographyBuilder.translateElements(dx, dy);
setChanged();
}
@Override
public VShape translate(final Point vector) {
VPoint worldVector = new VPoint(vector.x / getScaleFactor(), -vector.y / getScaleFactor());
......
......@@ -4,6 +4,7 @@ import org.vadere.gui.projectview.view.ProjectView;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.util.Locale;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
......@@ -22,7 +23,7 @@ public class ActionTranslateTopographyDialog {
public ActionTranslateTopographyDialog(final double x, double y){
this.textField = new JTextField(30);
this.textField.setText(String.format("%f, %f", x, y));
this.textField.setText(String.format(Locale.ENGLISH, "%f, %f", x, y));
this.textField.getDocument().addDocumentListener(new DialogListener());
this.valid = false;
this.x = x;
......
......@@ -31,6 +31,7 @@ import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import org.vadere.gui.topographycreator.control.ActionSwitchCategory;
import org.vadere.gui.topographycreator.control.ActionSwitchSelectionMode;
import org.vadere.gui.topographycreator.control.ActionTopographyMakroMenu;
import org.vadere.gui.topographycreator.control.ActionTranslateElements;
import org.vadere.gui.topographycreator.control.ActionTranslateTopography;
import org.vadere.gui.topographycreator.control.ActionUndo;
import org.vadere.gui.topographycreator.control.ActionZoomIn;
......@@ -308,10 +309,14 @@ public class TopographyWindow extends JPanel {
new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")),
panelModel, selectShape, undoSupport);
TopographyAction translateTopography =new ActionTranslateTopography("SetTopograpyBound",
TopographyAction translateTopography =new ActionTranslateTopography("TranslateTopography",
new ImageIcon(Resources.class.getResource("/icons/translation_icon.png")),
panelModel, selectShape, undoSupport);
TopographyAction translateElements =new ActionTranslateElements("TranslateElements",
new ImageIcon(Resources.class.getResource("/icons/translation_elements_icon.png")),
panelModel, selectShape, undoSupport);
/* Makros */
ActionTopographyMakroMenu actionTopographyMakroMenu =
new ActionTopographyMakroMenu("TopographyMakros",
......@@ -353,6 +358,7 @@ public class TopographyWindow extends JPanel {
addActionToToolbar(toolbar, maximizeAction, "TopographyCreator.btnMaximizeTopography.tooltip");
addActionToToolbar(toolbar, resizeTopographyBound, "TopographyCreator.btnTopographyBound.tooltip");
addActionToToolbar(toolbar, translateTopography, "TopographyCreator.btnTranslation.tooltip");
addActionToToolbar(toolbar, translateElements, "TopographyCreator.btnElementTranslation.tooltip");
toolbar.addSeparator(new Dimension(5, 50));
addActionToToolbar(toolbar, selectCutAction, "TopographyCreator.btnCutTopography.tooltip");
addActionToToolbar(toolbar, resetScenarioAction, "TopographyCreator.btnNewTopography.tooltip");
......
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