The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit d609f8c4 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

Merge branch 'dev/bugfix' into 'develop'

Dev/bugfix

Following Issue's have been fixed with this patch:
- issue #34 JComboCheckBox NullPointerException on dropdown (OS: Windows)
- issue #30 Predefined Attributes for outputprocessors
- issue #26 Quicksave feature ist komisch
- issue #23 Undo/Redo Funktionalität unzuverlässig
- issue #16 Topography creator: esc sollte einen Zeichenvorgang abbrechen
- issue #9 Postvis: Photo und Video Export

See merge request !21
parents 7e27a232 a6475449
VadereGui/resources/icons/stop_record.png

5.84 KB | W: | H:

VadereGui/resources/icons/stop_record.png

884 Bytes | W: | H:

VadereGui/resources/icons/stop_record.png
VadereGui/resources/icons/stop_record.png
VadereGui/resources/icons/stop_record.png
VadereGui/resources/icons/stop_record.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -11,8 +11,6 @@ import org.vadere.gui.postvisualization.PostVisualisation;
import org.vadere.gui.postvisualization.utils.ImageGenerator;
import org.vadere.gui.postvisualization.view.ImageSizeDialog;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.File;
......@@ -21,6 +19,9 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.swing.*;
public class ActionGeneratePNG extends AbstractAction implements IRendererChangeListener {
private static Logger logger = LogManager.getLogger(ActionGeneratePNG.class);
private static Resources resources = Resources.getInstance("postvisualization");
......@@ -40,21 +41,32 @@ public class ActionGeneratePNG extends AbstractAction implements IRendererChange
ImageSizeDialog imageSizeDialog = new ImageSizeDialog(model);
if (imageSizeDialog.getState() == ImageSizeDialog.State.Ok) {
BufferedImage bi = generator.generateImage(imageSizeDialog.getImageBound());
JFileChooser fileChooser = new JFileChooser(Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", "."));
Date todaysDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat(resources.getProperty("View.dataFormat"));
String formattedDate = formatter.format(todaysDate);
File outputfile = new File(
Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", ".")
+ System.getProperty("file.separator") + "pv_snapshot_" + formattedDate + ".png");
try {
ImageIO.write(bi, "png", outputfile);
logger.info("generate new png: " + outputfile.getAbsolutePath());
} catch (IOException e1) {
logger.error(e1.getMessage());
e1.printStackTrace();
File outputFile = new File("pv_snapshot_" + formattedDate + ".png");
fileChooser.setSelectedFile(outputFile);
int returnVal = fileChooser.showDialog(null, "Save");
if (returnVal == JFileChooser.APPROVE_OPTION) {
outputFile = fileChooser.getSelectedFile().toString().endsWith(".png") ? fileChooser.getSelectedFile()
: new File(fileChooser.getSelectedFile().toString() + ".png");
BufferedImage bi = generator.generateImage(imageSizeDialog.getImageBound());
try {
ImageIO.write(bi, "png", outputFile);
logger.info("generate new png: " + outputFile.getAbsolutePath());
} catch (IOException e1) {
logger.error(e1.getMessage());
e1.printStackTrace();
}
}
}
}
......
......@@ -8,17 +8,16 @@ import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.components.view.SimulationRenderer;
import org.vadere.gui.onlinevisualization.view.IRendererChangeListener;
import org.vadere.gui.postvisualization.PostVisualisation;
import org.vadere.gui.postvisualization.utils.ImageGenerator;
import org.vadere.gui.postvisualization.utils.SVGGenerator;
import org.vadere.gui.postvisualization.view.PostvisualizationRenderer;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.prefs.Preferences;
import javax.swing.*;
public class ActionGenerateSVG extends AbstractAction implements IRendererChangeListener {
private static Logger logger = LogManager.getLogger(ActionGenerateSVG.class);
private static Resources resources = Resources.getInstance("postvisualization");
......@@ -37,10 +36,21 @@ public class ActionGenerateSVG extends AbstractAction implements IRendererChange
Date todaysDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat(resources.getProperty("View.dataFormat"));
String formattedDate = formatter.format(todaysDate);
File outputfile = new File(
Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", ".")
+ System.getProperty("file.separator") + "pv_snapshot_" + formattedDate + ".svg");
svgGenerator.generateSVG(outputfile);
JFileChooser fileChooser = new JFileChooser(Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", "."));
File outputFile = new File("pv_snapshot_" + formattedDate + ".svg");
fileChooser.setSelectedFile(outputFile);
int returnVal = fileChooser.showDialog(null, "Save");
if (returnVal == JFileChooser.APPROVE_OPTION) {
outputFile = fileChooser.getSelectedFile().toString().endsWith(".svg") ? fileChooser.getSelectedFile()
: new File(fileChooser.getSelectedFile().toString() + ".svg");
svgGenerator.generateSVG(outputFile);
}
}
@Override
......
package org.vadere.gui.postvisualization.control;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.postvisualization.PostVisualisation;
import org.vadere.gui.postvisualization.utils.ImageGenerator;
import org.vadere.gui.postvisualization.view.ImageSizeDialog;
import org.vadere.gui.postvisualization.view.PostvisualizationRenderer;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.File;
......@@ -11,14 +19,6 @@ import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.swing.*;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.postvisualization.PostVisualisation;
import org.vadere.gui.postvisualization.utils.ImageGenerator;
import org.vadere.gui.postvisualization.view.ImageSizeDialog;
import org.vadere.gui.postvisualization.view.PostvisualizationRenderer;
public class ActionGeneratePNG extends ActionVisualization {
private static Logger logger = LogManager.getLogger(ActionGeneratePNG.class);
private static Resources resources = Resources.getInstance("postvisualization");
......@@ -35,21 +35,32 @@ public class ActionGeneratePNG extends ActionVisualization {
ImageSizeDialog imageSizeDialog = new ImageSizeDialog(model);
if (imageSizeDialog.getState() == ImageSizeDialog.State.Ok) {
BufferedImage bi = generator.generateImage(imageSizeDialog.getImageBound());
JFileChooser fileChooser = new JFileChooser(Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", "."));
Date todaysDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat(resources.getProperty("View.dataFormat"));
String formattedDate = formatter.format(todaysDate);
File outputfile = new File(
Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", ".")
+ System.getProperty("file.separator") + "pv_snapshot_" + formattedDate + ".png");
try {
ImageIO.write(bi, "png", outputfile);
logger.info("generate new png: " + outputfile.getAbsolutePath());
} catch (IOException e1) {
logger.error(e1.getMessage());
e1.printStackTrace();
File outputFile = new File("pv_snapshot_" + formattedDate + ".png");
fileChooser.setSelectedFile(outputFile);
int returnVal = fileChooser.showDialog(null, "Save");
if (returnVal == JFileChooser.APPROVE_OPTION) {
outputFile = fileChooser.getSelectedFile().toString().endsWith(".png") ? fileChooser.getSelectedFile()
: new File(fileChooser.getSelectedFile().toString() + ".png");
BufferedImage bi = generator.generateImage(imageSizeDialog.getImageBound());
try {
ImageIO.write(bi, "png", outputFile);
logger.info("generate new png: " + outputFile.getAbsolutePath());
} catch (IOException e1) {
logger.error(e1.getMessage());
e1.printStackTrace();
}
}
}
}
......
package org.vadere.gui.postvisualization.control;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.prefs.Preferences;
import javax.swing.Icon;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.gui.components.utils.Resources;
......@@ -15,6 +7,14 @@ import org.vadere.gui.postvisualization.PostVisualisation;
import org.vadere.gui.postvisualization.utils.SVGGenerator;
import org.vadere.gui.postvisualization.view.PostvisualizationRenderer;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.prefs.Preferences;
import javax.swing.*;
public class ActionGenerateSVG extends ActionVisualization {
private static Logger logger = LogManager.getLogger(ActionGenerateSVG.class);
private static Resources resources = Resources.getInstance("postvisualization");
......@@ -30,9 +30,19 @@ public class ActionGenerateSVG extends ActionVisualization {
Date todaysDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat(resources.getProperty("View.dataFormat"));
String formattedDate = formatter.format(todaysDate);
File outputfile = new File(
Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", ".")
+ System.getProperty("file.separator") + "pv_snapshot_" + formattedDate + ".svg");
svgGenerator.generateSVG(outputfile);
JFileChooser fileChooser = new JFileChooser(Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", "."));
File outputFile = new File("pv_snapshot_" + formattedDate + ".svg");
fileChooser.setSelectedFile(outputFile);
int returnVal = fileChooser.showDialog(null, "Save");
if (returnVal == JFileChooser.APPROVE_OPTION) {
outputFile = fileChooser.getSelectedFile().toString().endsWith(".svg") ? fileChooser.getSelectedFile()
: new File(fileChooser.getSelectedFile().toString() + ".svg");
svgGenerator.generateSVG(outputFile);
}
}
}
......@@ -2,6 +2,8 @@ package org.vadere.gui.postvisualization.utils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.apache.log4j.lf5.LogLevel;
import org.jcodec.api.awt.SequenceEncoder;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.postvisualization.PostVisualisation;
......@@ -17,6 +19,8 @@ import java.util.Date;
import java.util.Observable;
import java.util.prefs.Preferences;
import javax.swing.*;
public class MovRecorder implements IRecorder {
private static Logger logger = LogManager.getLogger(MovRecorder.class);
private static Resources resources = Resources.getInstance("postvisualization");
......@@ -61,7 +65,11 @@ public class MovRecorder implements IRecorder {
@Override
public synchronized void stopRecording() throws IOException {
enc.finish();
try {
enc.finish();
} catch (IndexOutOfBoundsException error) {
logger.log(Priority.DEBUG, "Nothing recorded! " + error.getMessage());
}
logger.info(this + " stop recording");
}
......@@ -77,15 +85,25 @@ public class MovRecorder implements IRecorder {
Date todaysDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat(resources.getProperty("View.dataFormat"));
String formattedDate = formatter.format(todaysDate);
try {
this.enc = new SequenceEncoder(new File(
Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", ".")
+ System.getProperty("file.separator") + "pv_snapshot_" + formattedDate + ".mov"));
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
JFileChooser fileChooser = new JFileChooser(Preferences.userNodeForPackage(PostVisualisation.class).get("PostVis.snapshotDirectory.path", "."));
File outputFile = new File("pv_snapshot_" + formattedDate + ".mov");
fileChooser.setSelectedFile(outputFile);
int returnVal = fileChooser.showDialog(null, "Save");
if (returnVal == JFileChooser.APPROVE_OPTION) {
outputFile = fileChooser.getSelectedFile().toString().endsWith(".mov") ? fileChooser.getSelectedFile()
: new File(fileChooser.getSelectedFile().toString() + ".mov");
try {
this.enc = new SequenceEncoder(outputFile);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
}
logger.info(this + " start recording");
}
logger.info(this + " start recording");
}
@Override
......
......@@ -3,8 +3,6 @@ package org.vadere.gui.postvisualization.view;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import javax.swing.*;
import org.vadere.gui.components.control.IViewportChangeListener;
import org.vadere.gui.components.control.JViewportChangeListener;
import org.vadere.gui.components.control.PanelResizeListener;
......@@ -14,7 +12,18 @@ import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.components.utils.SwingUtils;
import org.vadere.gui.components.view.ScenarioElementView;
import org.vadere.gui.postvisualization.PostVisualisation;
import org.vadere.gui.postvisualization.control.*;
import org.vadere.gui.postvisualization.control.ActionGeneratePNG;
import org.vadere.gui.postvisualization.control.ActionGenerateSVG;
import org.vadere.gui.postvisualization.control.ActionOpenFile;
import org.vadere.gui.postvisualization.control.ActionPause;
import org.vadere.gui.postvisualization.control.ActionPlay;
import org.vadere.gui.postvisualization.control.ActionRecording;
import org.vadere.gui.postvisualization.control.ActionRemoveFloorFieldFile;
import org.vadere.gui.postvisualization.control.ActionShowPotentialField;
import org.vadere.gui.postvisualization.control.ActionStop;
import org.vadere.gui.postvisualization.control.ActionSwapSelectionMode;
import org.vadere.gui.postvisualization.control.ActionVisualization;
import org.vadere.gui.postvisualization.control.Player;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.gui.projectview.control.ActionDeselect;
import org.vadere.simulator.projects.Scenario;
......@@ -31,6 +40,8 @@ import java.text.MessageFormat;
import java.util.Observer;
import java.util.prefs.Preferences;
import javax.swing.*;
/**
* Main Window of the new post visualization.
*
......@@ -319,7 +330,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
// deselect selected element on esc
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "deselect");
getActionMap().put("deselect", new ActionDeselect(model, this));
getActionMap().put("deselect", new ActionDeselect(model, this, null));
}
public JMenuBar getMenu() {
......
package org.vadere.gui.projectview.control;
import javax.swing.*;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class ActionDeselect extends AbstractAction {
private static final long serialVersionUID = 1L;
private final IDefaultModel panelModel;
private JPanel jpanel;
private ActionSelectSelectShape selectSelectShape;
public ActionDeselect(final IDefaultModel panelModel, JPanel jpanel) {
public ActionDeselect(final IDefaultModel panelModel, JPanel jpanel, ActionSelectSelectShape selectSelectShape) {
this.panelModel = panelModel;
this.jpanel = jpanel;
this.selectSelectShape = selectSelectShape;
}
@Override
public void actionPerformed(ActionEvent e) {
panelModel.deselectSelectedElement();
//Reset to select mode
if (selectSelectShape != null) {
selectSelectShape.actionPerformed(e);
}
jpanel.repaint();
}
}
package org.vadere.gui.topographycreator.control;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.*;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.UndoManager;
/**
......@@ -15,6 +20,7 @@ public class ActionRedo extends AbstractAction {
private static final long serialVersionUID = 4975524648404524891L;
private final UndoManager undoManager;
private final TopographyAction action;
private static Logger logger = LogManager.getLogger(ActionRedo.class);
public ActionRedo(final String name, final ImageIcon icon, final UndoManager undoManager,
final TopographyAction action) {
......@@ -25,7 +31,12 @@ public class ActionRedo extends AbstractAction {
@Override
public void actionPerformed(ActionEvent arg0) {
undoManager.redo();
try {
undoManager.redo();
} catch (CannotRedoException e) {
logger.log(Priority.DEBUG, "Cannot redo! List of edits is empty!");
Toolkit.getDefaultToolkit().beep();
}
action.actionPerformed(arg0);
}
}
package org.vadere.gui.topographycreator.control;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.*;
import javax.swing.undo.CannotUndoException;
import javax.swing.undo.UndoManager;
/**
......@@ -16,6 +21,7 @@ public class ActionUndo extends AbstractAction {
private static final long serialVersionUID = 6022031098257929748L;
private final UndoManager undoManager;
private final TopographyAction action;
private static Logger logger = LogManager.getLogger(ActionUndo.class);
public ActionUndo(final String name, final ImageIcon icon, UndoManager undoManager, final TopographyAction action) {
super(name, icon);
......@@ -25,7 +31,13 @@ public class ActionUndo extends AbstractAction {
@Override
public void actionPerformed(ActionEvent arg0) {
undoManager.undo();
try {
undoManager.undo();
} catch (CannotUndoException e) {
logger.log(Priority.DEBUG, "Cannot undo! List of edits is empty!");
Toolkit.getDefaultToolkit().beep();
}
action.actionPerformed(arg0);
}
......
package org.vadere.gui.topographycreator.view;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.beans.IntrospectionException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.undo.UndoManager;
import javax.swing.undo.UndoableEditSupport;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import org.vadere.gui.components.control.IViewportChangeListener;
import org.vadere.gui.components.control.JViewportChangeListener;
......@@ -64,8 +42,16 @@ import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.simulator.projects.Scenario;
import org.vadere.state.types.ScenarioElementType;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.beans.IntrospectionException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.undo.UndoManager;
import javax.swing.undo.UndoableEditSupport;
public class TopographyWindow extends JPanel {
private static Resources resources = Resources.getInstance("topographycreator");
......@@ -295,7 +281,7 @@ public class TopographyWindow extends JPanel {
/* pedestrians */
TopographyAction switchToPedestrianAction = new ActionSwitchCategory("switch to pedestrian", panelModel,
ScenarioElementType.PEDESTRIAN, selectDotModeAction);
TopographyAction closeDialogAction = new ActionCloseDrawOptionPanel("Pedestrain", new ImageIcon(
TopographyAction closeDialogAction = new ActionCloseDrawOptionPanel("Pedestrian", new ImageIcon(
Resources.class.getResource("/icons/pedestrians_icon.png")), panelModel,
switchToPedestrianAction);
......@@ -309,9 +295,10 @@ public class TopographyWindow extends JPanel {
.getResource("/icons/source_icon.png")), panelModel, switchToSourceAction, sourceButton,
sourceDrawModes);
addActionToToolbar(toolbar, new ActionSelectSelectShape("select shape mode", new ImageIcon(
Resources.class.getResource("/icons/select_shapes_icon.png")), panelModel, undoSupport),
"select_shape_tooltip");
ActionSelectSelectShape selectShape = new ActionSelectSelectShape("select shape mode", new ImageIcon(
Resources.class.getResource("/icons/select_shapes_icon.png")), panelModel, undoSupport);
addActionToToolbar(toolbar, selectShape,"select_shape_tooltip");
addActionToToolbar(
toolbar,
new ActionSwitchSelectionMode("erase mode", new ImageIcon(Resources.class
......@@ -386,7 +373,7 @@ public class TopographyWindow extends JPanel {
// deselect selected element on esc
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "deselect");
getActionMap().put("deselect", new ActionDeselect(panelModel, thisPanel));
getActionMap().put("deselect", new ActionDeselect(panelModel, thisPanel, selectShape));
}
});
}
......
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