Commit 0122c59c authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

issue #146 fix view if the viewport=topographyBound.

parent e38b3d59
......@@ -115,7 +115,7 @@ public abstract class DefaultRenderer {
Rectangle2D.Double viewportBound = defaultModel.getViewportBound();
double dy = topographyBound.getHeight() - viewportBound.getHeight();
graphics2D.translate(-viewportBound.getX(), Math.max((dy - viewportBound.getY()), 0));
graphics2D.translate(-viewportBound.getX(), Math.max((dy - viewportBound.getY()), - viewportBound.getY()));
// graphics2D.translate(+viewportBound.getX(), -Math.max((dy - viewportBound.getY()), 0));
}
......
......@@ -2,25 +2,23 @@ package org.vadere.gui.topographycreator.control;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.util.geometry.shapes.VRectangle;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.undo.UndoableEditSupport;
public class ActionResizeTopographyBound extends TopographyAction {
private TopographyAction action;
private final UndoableEditSupport undoableEditSupport;
public ActionResizeTopographyBound(String name, ImageIcon icon, IDrawPanelModel<?> panelModel,
TopographyAction action) {
TopographyAction action, final UndoableEditSupport undoSupport) {
super(name, icon, panelModel);
this.action = action;
}
public ActionResizeTopographyBound(final String name, final IDrawPanelModel<?> panelModel,
TopographyAction action) {
super(name, panelModel);
this.action = action;
this.undoableEditSupport = undoSupport;
}
@Override
......@@ -29,13 +27,13 @@ public class ActionResizeTopographyBound extends TopographyAction {
action.actionPerformed(e);
TopographyCreatorModel model = (TopographyCreatorModel) getScenarioPanelModel();
ActionResizeTopographyBoundDialog dialog = new ActionResizeTopographyBoundDialog(
model.getTopography().getBounds().width,
model.getTopography().getBounds().height
);
ActionResizeTopographyBoundDialog dialog = new ActionResizeTopographyBoundDialog(model.getTopographyBound());
if (dialog.getValue()){
model.setTopographyBound(dialog.getBound());
VRectangle oldBound = new VRectangle(model.getTopographyBound());
VRectangle newBound = new VRectangle(dialog.getBound());
model.setTopographyBound(newBound);
undoableEditSupport.postEdit(new EditResizeTopographyBound(getScenarioPanelModel(), oldBound, newBound));
}
getScenarioPanelModel().notifyObservers();
}
......
......@@ -4,6 +4,7 @@ import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.util.geometry.shapes.VRectangle;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
......@@ -12,25 +13,23 @@ import javax.swing.event.DocumentListener;
public class ActionResizeTopographyBoundDialog {
JTextField textField;
VRectangle bound;
VRectangle boundOld;
boolean valid;
private JTextField textField;
private Rectangle2D.Double bound;
private Rectangle2D.Double boundOld;
private boolean valid;
public ActionResizeTopographyBoundDialog(double width, double height){
public ActionResizeTopographyBoundDialog(final Rectangle2D.Double topographyBound){
textField = new JTextField();
textField.setText(String.format("%.3f x %.3f", width, height));
textField.setText(String.format("%.3f x %.3f", topographyBound.getWidth(), topographyBound.getHeight()));
textField.getDocument().addDocumentListener(new DialogListener());
bound = new VRectangle(0.0,0.0, width, height);
boundOld = new VRectangle(0.0,0.0, width, height);
bound = topographyBound;
boundOld = topographyBound;
valid = false;
}
public VRectangle getBound() {
public Rectangle2D.Double getBound() {
return valid ? bound : boundOld;
}
......@@ -44,8 +43,8 @@ public class ActionResizeTopographyBoundDialog {
private class DialogListener implements DocumentListener{
JTextField textField;
String text;
private JTextField textField;
private String text;
DialogListener(){
textField = ActionResizeTopographyBoundDialog.this.textField;
......@@ -75,8 +74,10 @@ public class ActionResizeTopographyBoundDialog {
try {
width = Double.valueOf(tmp[0]);
height = Double.valueOf(tmp[1]);
ActionResizeTopographyBoundDialog.this.bound =
new VRectangle(0.0,0.0, width, height);
new Rectangle2D.Double(ActionResizeTopographyBoundDialog.this.boundOld.getMinX(),
ActionResizeTopographyBoundDialog.this.boundOld.getMinY(), width, height);
ActionResizeTopographyBoundDialog.this.valid = true;
textField.setForeground(Color.BLACK);
}catch (Exception ex){
......
package org.vadere.gui.topographycreator.control;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
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 EditResizeTopographyBound extends AbstractUndoableEdit {
private static final long serialVersionUID = 5176192525116057658L;
private final IDrawPanelModel panelModel;
private final VRectangle oldBound;
private final VRectangle newBound;
public EditResizeTopographyBound(final IDrawPanelModel panelModel, final VRectangle oldBound, final VRectangle newBound) {
this.panelModel = panelModel;
this.oldBound = oldBound;
this.newBound = newBound;
}
@Override
public void undo() throws CannotUndoException {
panelModel.setTopographyBound(oldBound);
}
@Override
public void redo() throws CannotRedoException {
panelModel.setTopographyBound(newBound);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public boolean canRedo() {
return true;
}
@Override
public String getPresentationName() {
return "resize topography bound";
}
}
......@@ -300,7 +300,11 @@ public class TopographyWindow extends JPanel {
/* resize Topography */
TopographyAction resizeTopographyBound =new ActionResizeTopographyBound("SetTopograpyBound",
new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")),
panelModel, selectShape);
panelModel, selectShape, undoSupport);
/*TopographyAction translateTopographyBound =new ActionResizeTopographyBound("SetTopograpyBound",
new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")),
panelModel, selectShape, undoSupport);*/
/* Makros */
ActionTopographyMakroMenu actionTopographyMakroMenu =
......
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