Commit 18e09ac6 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

Display current FloorFieldHash in InfoPanel. ToolTip for full hash

By clicking on the short hash value the full hash is copied into the
clipboard for future use.
parent c79a6b76
Pipeline #173566 passed with stages
in 140 minutes and 21 seconds
......@@ -368,6 +368,7 @@ InfoPanel.ScenarioSize.label=Scenario Size
InfoPanel.GridResolution.label=Grid Resolution
InfoPanel.CursorPosition.label=Cursor Position
InfoPanel.ScaleFactor.label=Scale Factor
InfoPanel.ScenarioHash.label=Scenario Hash
Messages.changeLanguagePopup.title=Reload required
Messages.changeLanguagePopup.text=Reload Vadere GUI to switch language.
......
......@@ -362,6 +362,7 @@ InfoPanel.ScenarioSize.label=Szenariogr\u00f6\u00dfe
InfoPanel.GridResolution.label=Gitteraufl\u00f6sung
InfoPanel.CursorPosition.label=Cursor-Position
InfoPanel.ScaleFactor.label=Skalierungsfaktor
InfoPanel.ScenarioHash.label=Scenario Hash
Messages.changeLanguagePopup.title=Neu laden n\u00f6tig
Messages.changeLanguagePopup.text=Laden Sie die Vadere GUI neu um die Sprache zu wechseln.
......
package org.vadere.gui.components.view;
import java.awt.FlowLayout;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.state.attributes.models.AttributesFloorField;
import org.vadere.state.util.StateJsonConverter;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.components.utils.Messages;
import javax.swing.*;
/**
* The About-Dialog of the topographycreator.
......@@ -23,11 +29,15 @@ public class InfoPanel extends JPanel implements Observer {
private JLabel lblGridResulutionLabel;
private JLabel lblCursorPositionLabel;
private JLabel lblScaleFactorLabel;
private JLabel lblScenarioHashLabel;
private JLabel lblScenarioSizeValue;
private JLabel lblGridResulutionValue;
private JLabel lblCursorPositionValue;
private JLabel lblScaleFactorValue;
private JLabel lblScenarioHashValue;
private String hash;
public InfoPanel(final IDefaultModel defaultModel) {
this.defaultModel = defaultModel;
......@@ -36,11 +46,13 @@ public class InfoPanel extends JPanel implements Observer {
lblGridResulutionLabel = new JLabel(Messages.getString("InfoPanel.GridResolution.label") + ":");
lblCursorPositionLabel = new JLabel(Messages.getString("InfoPanel.CursorPosition.label") + ":");
lblScaleFactorLabel = new JLabel(Messages.getString("InfoPanel.ScaleFactor.label") + ":");
lblScenarioHashLabel = new JLabel(Messages.getString("InfoPanel.ScenarioHash.label") + ":");
lblScaleFactorValue = new JLabel();
lblScenarioSizeValue = new JLabel();
lblGridResulutionValue = new JLabel();
lblCursorPositionValue = new JLabel();
lblScenarioHashValue = new JLabel();
add(lblGridResulutionLabel);
add(lblGridResulutionValue);
......@@ -53,6 +65,19 @@ public class InfoPanel extends JPanel implements Observer {
add(lblScaleFactorLabel);
add(lblScaleFactorValue);
add(lblScenarioHashLabel);
add(lblScenarioHashValue);
// copy full FloorFieldHash to clipboard after clicking on the short version of the hash
lblScenarioHashValue.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
StringSelection stringSelection = new StringSelection(hash);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
});
}
@Override
......@@ -66,7 +91,25 @@ public class InfoPanel extends JPanel implements Observer {
lblCursorPositionValue
.setText(String.format("%3.2f %3.2f | ", (float) defaultModel.getMousePosition().getX(),
(float) defaultModel.getMousePosition().getY()));
lblScaleFactorValue.setText(String.format("%3.2f ", (float) defaultModel.getScaleFactor()));
lblScaleFactorValue.setText(String.format("%3.2f | ", (float) defaultModel.getScaleFactor()));
// show short version of FloorFieldHash in label and full hash as tooltip.
if (defaultModel instanceof TopographyCreatorModel){
TopographyCreatorModel m = (TopographyCreatorModel)defaultModel;
AttributesFloorField attFF = m.getScenario().getModelAttributes()
.stream()
.filter(a -> a instanceof AttributesFloorField)
.map(a ->(AttributesFloorField)a)
.findFirst().orElse(null);
if (attFF != null){
hash = StateJsonConverter.getFloorFieldHash(m.getTopography(), attFF);
}
} else {
hash = "--------";
}
lblScenarioHashValue.setText(hash.substring(0, 8) + " | ");
lblScenarioHashValue.setToolTipText(hash);
}
}
}
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