mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-26 00:52:29 +00:00
Merge branch 'main' of https://github.com/PAMGuard/PAMGuard
This commit is contained in:
commit
1739bd66b2
@ -76,6 +76,9 @@ public class MarkOverlayDraw extends PanelOverlayDraw {
|
||||
hoverData.setTransformShape(t);
|
||||
generalProjector.addHoverData(t, pamDataUnit);
|
||||
}
|
||||
if (drawnShape == null) {
|
||||
return null;
|
||||
}
|
||||
return drawnShape.getBounds();
|
||||
}
|
||||
|
||||
@ -143,10 +146,14 @@ public class MarkOverlayDraw extends PanelOverlayDraw {
|
||||
* To allow for things like the rotated map which no longer show rectangles as
|
||||
* rectangles, we now need to draw rectangles are irregular polygons too !
|
||||
*/
|
||||
try {
|
||||
int[] x = new int[4];
|
||||
int[] y = new int[4];
|
||||
PamCoordinate m0 = mark.getCoordinate(0);
|
||||
PamCoordinate m1 = mark.getCoordinate(1);
|
||||
if (m0 == null || m1 == null) {
|
||||
return null;
|
||||
}
|
||||
Point p;
|
||||
p = generalProjector.getCoord3d(m0.getCoordinate(0), m0.getCoordinate(1), 0).getXYPoint();
|
||||
x[0] = p.x;
|
||||
@ -167,28 +174,32 @@ public class MarkOverlayDraw extends PanelOverlayDraw {
|
||||
g2d.fillPolygon(pgon);
|
||||
}
|
||||
return pgon;
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// Point p0 = generalProjector.getCoord3d(m0).getXYPoint();
|
||||
// Point p1 = generalProjector.getCoord3d(m1).getXYPoint();
|
||||
// g2d.setColor(getLineCol());
|
||||
// g2d.setStroke(getLineStroke());
|
||||
// g2d.drawLine(p0.x, p0.y, p1.x, p0.y);
|
||||
// g2d.drawLine(p1.x, p0.y, p1.x, p1.y);
|
||||
// g2d.drawLine(p1.x, p1.y, p0.x, p1.y);
|
||||
// g2d.drawLine(p0.x, p1.y, p0.x, p0.y);
|
||||
// int x = Math.min(p0.x, p1.x);
|
||||
// int y = Math.min(p0.y, p1.y);
|
||||
// int w = Math.abs(p0.x - p1.x);
|
||||
// int h = Math.abs(p0.y - p1.y);
|
||||
//
|
||||
// Color fillCol = getFillCol();
|
||||
// if (fillCol != null) {
|
||||
// g2d.setColor(getFillCol());
|
||||
// g2d.fillRect(x, y, w, h);
|
||||
// }
|
||||
// Rectangle r = new Rectangle(x, y, w, h);
|
||||
// return r;
|
||||
//
|
||||
// Point p0 = generalProjector.getCoord3d(m0).getXYPoint();
|
||||
// Point p1 = generalProjector.getCoord3d(m1).getXYPoint();
|
||||
// g2d.setColor(getLineCol());
|
||||
// g2d.setStroke(getLineStroke());
|
||||
// g2d.drawLine(p0.x, p0.y, p1.x, p0.y);
|
||||
// g2d.drawLine(p1.x, p0.y, p1.x, p1.y);
|
||||
// g2d.drawLine(p1.x, p1.y, p0.x, p1.y);
|
||||
// g2d.drawLine(p0.x, p1.y, p0.x, p0.y);
|
||||
// int x = Math.min(p0.x, p1.x);
|
||||
// int y = Math.min(p0.y, p1.y);
|
||||
// int w = Math.abs(p0.x - p1.x);
|
||||
// int h = Math.abs(p0.y - p1.y);
|
||||
//
|
||||
// Color fillCol = getFillCol();
|
||||
// if (fillCol != null) {
|
||||
// g2d.setColor(getFillCol());
|
||||
// g2d.fillRect(x, y, w, h);
|
||||
// }
|
||||
// Rectangle r = new Rectangle(x, y, w, h);
|
||||
// return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -232,6 +232,9 @@ public class OverlayMark {
|
||||
}
|
||||
PamCoordinate c0 = projector.getCoord3d(coordinates.get(0));
|
||||
PamCoordinate c1 = projector.getCoord3d(coordinates.get(1));
|
||||
if (c0 == null || c1 == null) {
|
||||
return null;
|
||||
}
|
||||
double x = Math.min(c0.getCoordinate(0), c1.getCoordinate(0));
|
||||
double y = Math.min(c0.getCoordinate(1), c1.getCoordinate(1));
|
||||
double w = Math.abs(c0.getCoordinate(0) - c1.getCoordinate(0));
|
||||
|
@ -289,11 +289,11 @@ public class CTDataSelectPanel implements PamDialogPanel {
|
||||
|
||||
// System.out.println("No. count: " + count);
|
||||
currentParams.classifier = new int[count];
|
||||
ArrayList<CTClassifier> classifiers = ctDataSelector.getClickControl().getClassifierManager().getCurrentClassifiers();
|
||||
int used = 0;
|
||||
ArrayList<CTClassifier> currentClassifiers = ctDataSelector.getClickControl().getClassifierManager().getCurrentClassifiers();
|
||||
for (int i=0; i<classifierCheckBoxes.length; i++) {
|
||||
if (classifierCheckBoxes[i].isSelected()) {
|
||||
currentParams.classifier[used++] = currentClassifiers.get(i).getSpeciesID();
|
||||
currentParams.classifier[used++] = classifiers.get(i).getSpeciesID();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
@ -18,14 +19,18 @@ import PamController.PamController;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamUtils.PamCalendar;
|
||||
import PamView.PamSidePanel;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamProcess;
|
||||
import PamguardMVC.debug.Debug;
|
||||
import effortmonitor.swing.EffortDataMapGraph;
|
||||
import effortmonitor.swing.EffortDialog;
|
||||
import effortmonitor.swing.EffortDisplayProvider;
|
||||
import effortmonitor.swing.EffortSidePanel;
|
||||
import pamScrollSystem.AbstractPamScroller;
|
||||
import pamScrollSystem.AbstractScrollManager;
|
||||
import pamScrollSystem.PamScroller;
|
||||
import pamScrollSystem.PamScrollerData;
|
||||
import userDisplay.UserDisplayControl;
|
||||
|
||||
public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
@ -42,6 +47,10 @@ public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
|
||||
private EffortDataMapGraph dataMapGraph;
|
||||
|
||||
private HashMap<AbstractPamScroller, PamScrollerData> lastOuterStarts = new HashMap<>();
|
||||
|
||||
private EffortSidePanel effortSidePanel;
|
||||
|
||||
public EffortControl(String unitName) {
|
||||
super("unitType", unitName);
|
||||
EffortProcess effortProc = new EffortProcess();
|
||||
@ -51,11 +60,21 @@ public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
effortDataBlock.SetLogging(new EffortLogging(this, effortDataBlock));
|
||||
dataMapGraph = new EffortDataMapGraph(this);
|
||||
|
||||
// PamScroller
|
||||
|
||||
UserDisplayControl.addUserDisplayProvider(new EffortDisplayProvider(this));
|
||||
|
||||
PamSettingManager.getInstance().registerSettings(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PamSidePanel getSidePanel() {
|
||||
if (effortSidePanel == null) {
|
||||
effortSidePanel = new EffortSidePanel(this);
|
||||
}
|
||||
return effortSidePanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyModelChanged(int changeType) {
|
||||
super.notifyModelChanged(changeType);
|
||||
@ -65,6 +84,10 @@ public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
break;
|
||||
case PamController.NEW_SCROLL_TIME:
|
||||
updateScrollerInfo();
|
||||
break;
|
||||
case PamController.DATA_LOAD_COMPLETE:
|
||||
updateScrollerInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +126,24 @@ public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean newOuter = isNewOuter(scroller);
|
||||
if (effortParams.outserScrollOnly) {
|
||||
if (newOuter) {
|
||||
logOuterScroll(scroller);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logInnerScroll(scroller);
|
||||
}
|
||||
}
|
||||
|
||||
private void logOuterScroll(AbstractPamScroller scroller) {
|
||||
EffortDataUnit effortData = new EffortDataUnit(scroller, effortParams.getObserver(), effortParams.getObjective());
|
||||
effortData.setOuterLimits();
|
||||
effortDataBlock.addPamData(effortData);
|
||||
}
|
||||
|
||||
private void logInnerScroll(AbstractPamScroller scroller) {
|
||||
// checkObserverName();
|
||||
|
||||
EffortDataUnit effortData = effortDataBlock.findActiveUnit(scroller);
|
||||
@ -129,6 +170,38 @@ public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the outer scroll moved.
|
||||
* @param scroller
|
||||
* @return true if the outer has moved.
|
||||
*/
|
||||
private boolean isNewOuter(AbstractPamScroller scroller) {
|
||||
PamScrollerData lastData = lastOuterStarts.get(scroller);
|
||||
PamScrollerData nowVal = scroller.getScrollerData();
|
||||
if (nowVal == null) {
|
||||
return false; // shouldn't happen !
|
||||
}
|
||||
boolean changed = isChanged(lastData, nowVal);
|
||||
if (changed) {
|
||||
lastOuterStarts.put(scroller, nowVal.clone());
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean isChanged(PamScrollerData lastData, PamScrollerData nowVal) {
|
||||
if (lastData == null || nowVal == null) {
|
||||
return true;
|
||||
}
|
||||
if (lastData.getMinimumMillis() != nowVal.getMinimumMillis()) {
|
||||
return true;
|
||||
}
|
||||
if (lastData.getMaximumMillis() != nowVal.getMaximumMillis()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick and dirty to get observer name.
|
||||
*/
|
||||
@ -203,9 +276,11 @@ public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
existingUnit.setObserver(newParams.getObserver());
|
||||
existingUnit.setObjective(newParams.getObjective());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (effortSidePanel != null) {
|
||||
effortSidePanel.updateSettings();
|
||||
}
|
||||
return newParams!=null;
|
||||
}
|
||||
|
||||
public void goToTime(AbstractPamScroller scroller, long timeInMilliseconds) {
|
||||
@ -235,6 +310,9 @@ public class EffortControl extends PamControlledUnit implements PamSettings{
|
||||
@Override
|
||||
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
|
||||
effortParams = ((EffortParams) pamControlledUnitSettings.getSettings());
|
||||
if (effortSidePanel != null) {
|
||||
effortSidePanel.updateSettings();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ public class EffortDataUnit extends PamDataUnit {
|
||||
getBasicData().setEndTime(scroller.getValueMillis()+scroller.getVisibleAmount());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor to use when reloading from database.
|
||||
* @param databaseIndex
|
||||
@ -210,4 +211,13 @@ public class EffortDataUnit extends PamDataUnit {
|
||||
return runMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the limits as the outer limits of the scroller.
|
||||
*/
|
||||
public void setOuterLimits() {
|
||||
setTimeMilliseconds(scroller.getMinimumMillis());
|
||||
getBasicData().setEndTime(scroller.getMaximumMillis());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,11 @@ public class EffortParams implements Cloneable, Serializable, ManagedParameters
|
||||
|
||||
public transient boolean isSet;
|
||||
|
||||
/**
|
||||
* Only log outer scroll events when paging forwards, not every little movement.
|
||||
*/
|
||||
public boolean outserScrollOnly = false;
|
||||
|
||||
private static final int MAX_OBSERVERS = 10;
|
||||
private static final int MAX_OBJECTIVES = 10;
|
||||
|
||||
|
@ -8,9 +8,11 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import PamView.DBTextArea;
|
||||
@ -29,6 +31,7 @@ public class EffortDialog extends PamDialog {
|
||||
private JComboBox<String> observer;
|
||||
private JComboBox<String> oldObjectives;
|
||||
private DBTextArea objective;
|
||||
private JRadioButton outerOnly, allActions;
|
||||
|
||||
private EffortDialog(Window parentFrame, EffortControl effortControl) {
|
||||
super(parentFrame, effortControl.getUnitName(), false);
|
||||
@ -40,6 +43,18 @@ public class EffortDialog extends PamDialog {
|
||||
mainPanel.add(new JLabel("Observer name or initials"), c);
|
||||
c.gridx++;
|
||||
mainPanel.add(observer = new JComboBox<String>(), c);
|
||||
outerOnly = new JRadioButton("Log uter scroll only");
|
||||
allActions = new JRadioButton("Log all scroll actions");
|
||||
ButtonGroup bg = new ButtonGroup();
|
||||
bg.add(allActions);
|
||||
bg.add(outerOnly);
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
c.gridwidth = 1;
|
||||
mainPanel.add(allActions, c);
|
||||
c.gridx+=c.gridwidth;
|
||||
mainPanel.add(outerOnly, c);
|
||||
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
c.gridwidth = 2;
|
||||
@ -80,6 +95,8 @@ public class EffortDialog extends PamDialog {
|
||||
for (String obs : oldObs) {
|
||||
observer.addItem(obs);
|
||||
}
|
||||
allActions.setSelected(effortParams.outserScrollOnly == false);
|
||||
outerOnly.setSelected(effortParams.outserScrollOnly);
|
||||
oldObjectives.removeAllItems();
|
||||
oldObjectives.addItem("");
|
||||
for (String obj : effortParams.getRecentObjectives()) {
|
||||
@ -100,6 +117,7 @@ public class EffortDialog extends PamDialog {
|
||||
if (obs == null || obs.length() == 0) {
|
||||
return showWarning("You must give your name or initials to contine");
|
||||
}
|
||||
effortParams.outserScrollOnly = outerOnly.isSelected();
|
||||
effortParams.setObserver(obs);
|
||||
effortParams.setObjective(objective.getText());
|
||||
return true;
|
||||
|
99
src/effortmonitor/swing/EffortSidePanel.java
Normal file
99
src/effortmonitor/swing/EffortSidePanel.java
Normal file
@ -0,0 +1,99 @@
|
||||
package effortmonitor.swing;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import PamView.PamSidePanel;
|
||||
import PamView.component.PamSettingsIconButton;
|
||||
import PamView.dialog.PamCheckBox;
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
import PamView.dialog.PamLabel;
|
||||
import PamView.dialog.PamTextField;
|
||||
import PamView.panel.PamPanel;
|
||||
import effortmonitor.EffortControl;
|
||||
import effortmonitor.EffortObserver;
|
||||
import effortmonitor.EffortParams;
|
||||
|
||||
public class EffortSidePanel implements PamSidePanel, EffortObserver {
|
||||
|
||||
private PamPanel mainPanel;
|
||||
|
||||
private PamTextField person;
|
||||
|
||||
private PamCheckBox logging;
|
||||
|
||||
private PamSettingsIconButton settingsButton;
|
||||
|
||||
private EffortControl effortControl;
|
||||
|
||||
public EffortSidePanel(EffortControl effortControl) {
|
||||
this.effortControl = effortControl;
|
||||
|
||||
mainPanel = new PamPanel(new GridBagLayout());
|
||||
mainPanel.setBorder(new TitledBorder(effortControl.getUnitName()));
|
||||
GridBagConstraints c = new PamGridBagContraints();
|
||||
mainPanel.add(new PamLabel("Person ", JLabel.RIGHT), c);
|
||||
c.gridx++;
|
||||
mainPanel.add(person = new PamTextField(6), c);
|
||||
person.setEditable(false);
|
||||
c.gridx = 0;
|
||||
c.gridy++;
|
||||
c.gridwidth = 1;
|
||||
mainPanel.add(logging = new PamCheckBox("Log effort"), c);
|
||||
c.gridx += c.gridwidth;
|
||||
mainPanel.add(settingsButton = new PamSettingsIconButton(), c);
|
||||
settingsButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
settings();
|
||||
}
|
||||
});
|
||||
effortControl.addObserver(this);
|
||||
logging.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
loggingButton();
|
||||
}
|
||||
});
|
||||
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
protected void loggingButton() {
|
||||
effortControl.setOnEffort(logging.isSelected());
|
||||
}
|
||||
|
||||
protected void settings() {
|
||||
effortControl.showSettingsDialog(effortControl.getGuiFrame(), null);
|
||||
}
|
||||
|
||||
public void updateSettings() {
|
||||
EffortParams params = effortControl.getEffortParams();
|
||||
person.setText(params.getObserver());
|
||||
logging.setSelected(params.isSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPanel() {
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String newName) {
|
||||
mainPanel.setBorder(new TitledBorder(newName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void statusChange() {
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
}
|
@ -58,7 +58,7 @@ public class PamScrollerData implements Serializable, Cloneable {
|
||||
|
||||
|
||||
@Override
|
||||
protected PamScrollerData clone() {
|
||||
public PamScrollerData clone() {
|
||||
try {
|
||||
return (PamScrollerData) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user