mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
2.02.07b
Fix ICI display bug in click detector
This commit is contained in:
parent
a89279ef81
commit
269398890e
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.pamguard</groupId>
|
||||
<artifactId>Pamguard</artifactId>
|
||||
<version>2.02.07a</version>
|
||||
<version>2.02.07b</version>
|
||||
<name>Pamguard Java12+</name>
|
||||
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
|
||||
<url>www.pamguard.org</url>
|
||||
|
@ -31,12 +31,12 @@ public class PamguardVersionInfo {
|
||||
* Version number, major version.minorversion.sub-release.
|
||||
* Note: can't go higher than sub-release 'f'
|
||||
*/
|
||||
static public final String version = "2.02.07a";
|
||||
static public final String version = "2.02.07b";
|
||||
|
||||
/**
|
||||
* Release date
|
||||
*/
|
||||
static public final String date = "10 January 2023";
|
||||
static public final String date = "19 January 2023";
|
||||
|
||||
// /**
|
||||
// * Release type - Beta or Core
|
||||
|
@ -1697,14 +1697,13 @@ abstract public class PamDataUnit<T extends PamDataUnit, U extends PamDataUnit>
|
||||
*/
|
||||
public int getColourIndex() {
|
||||
/*
|
||||
* This can go wrong when UID > 2^31 since the colour choser takes
|
||||
* This can go wrong when UID > 2^31 since the colour chooser takes
|
||||
* a mod WRT number of whale colours and it doesn't like negative numbers.
|
||||
* So need to keep the value going in positive.
|
||||
*/
|
||||
long uid = getUID();
|
||||
uid -= uid/2^31;
|
||||
uid &= 0x7FFFFFFF; // avoid anything in top bit of an int32 or higher
|
||||
return (int) uid;
|
||||
// return (int) getUID();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,6 +47,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
@ -134,7 +136,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
|
||||
private PamScroller hScrollBar;
|
||||
|
||||
// private PamDataBlock<ClickDetection> trackedClicks;
|
||||
// private PamDataBlock<ClickDetection> trackedClicks;
|
||||
|
||||
protected BTPlot btPlot;
|
||||
|
||||
@ -219,7 +221,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
/**
|
||||
* The symbol chooser for the BT display
|
||||
*/
|
||||
// private ClickDetSymbolChooser symbolChooser;
|
||||
// private ClickDetSymbolChooser symbolChooser;
|
||||
|
||||
public ClickBTDisplay(ClickControl clickControl, ClickDisplayManager clickDisplayManager, ClickDisplayManager.ClickDisplayInfo clickDisplayInfo) {
|
||||
|
||||
@ -265,7 +267,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
topControls = new TopControls();
|
||||
setNorthPanel(topControls);
|
||||
|
||||
// trackedClicks = clickControl.getClickDetector().getTrackedClicks();
|
||||
// trackedClicks = clickControl.getClickDetector().getTrackedClicks();
|
||||
|
||||
highlightSymbol.setLineThickness(3);
|
||||
|
||||
@ -369,13 +371,49 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
@Override
|
||||
public void updateData(PamObservable observable, PamDataUnit pamDataUnit) {
|
||||
|
||||
if (pamDataUnit instanceof ClickDetection) {
|
||||
updateClick((ClickDetection) pamDataUnit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateClick(ClickDetection clickDetection) {
|
||||
// ICI may have been set when the click was added to an event
|
||||
// so work it out there rather than rebuilding the entire list.
|
||||
SuperDetection superDet = clickDetection.getSuperDetection(0);
|
||||
if (superDet == null) {
|
||||
// sortTempICIs();
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Work only within the superdetection to find the previous
|
||||
* click within that for this clicks channel combination and update
|
||||
* the ICI accordingly. For the first click an event, it won't find
|
||||
* a preceeding click, but that's OK.
|
||||
*/
|
||||
synchronized (superDet.getSubDetectionSyncronisation()) {
|
||||
int subDetInd = superDet.findSubdetectionInfo(clickDetection);
|
||||
for (int i = subDetInd-1; i >= 0; i--) {
|
||||
PamDataUnit subDet = superDet.getSubDetection(i);
|
||||
if (subDet.getChannelBitmap() == clickDetection.getChannelBitmap()) {
|
||||
double ici = (double) (clickDetection.getTimeMilliseconds() - subDet.getTimeMilliseconds())/1000.;
|
||||
clickDetection.setTempICI(ici);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void changedEvent(OfflineEventDataUnit event) {
|
||||
sortTempICIs();
|
||||
btPlot.repaint(10);
|
||||
}
|
||||
|
||||
public void newClick(ClickDetection clickDataUnit) {
|
||||
|
||||
sortTempICI(clickDataUnit);
|
||||
|
||||
if (shouldPlot(clickDataUnit)){
|
||||
// btPlot.drawClick(btPlot.getImageGraphics(), clickDataUnit, null);
|
||||
// btPlot.repaint(minPaintTime);
|
||||
@ -386,6 +424,71 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
|
||||
}
|
||||
|
||||
private HashMap<Long, ClickDetection> lastClicks = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Sort out all ICI's for all clicks.
|
||||
*/
|
||||
private void sortTempICIs() {
|
||||
// long t1 = System.nanoTime();
|
||||
PamDataBlock<ClickDetection> clickData = clickControl.getClickDataBlock();
|
||||
ArrayList<ClickDetection> allClicks = clickData.getDataCopy();
|
||||
sortTempICIs(allClicks);
|
||||
// long t2 = System.nanoTime();
|
||||
// System.out.printf("time to sort %d ICI measures is %3.1fms\n", allClicks.size(), (double) (t2-t1)/1.e6);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear ICI history, e.g. when new data are loaded or processing starts.
|
||||
*/
|
||||
private void clearICIHistory() {
|
||||
synchronized(lastClicks) {
|
||||
lastClicks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts ICI's for a list of clicks.
|
||||
* @param clicks
|
||||
*/
|
||||
private void sortTempICIs(List<ClickDetection> clicks) {
|
||||
clearICIHistory();
|
||||
|
||||
for (ClickDetection aClick : clicks) {
|
||||
sortTempICI(aClick);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts ICI information for a new click.
|
||||
* @param aClick
|
||||
*/
|
||||
private void sortTempICI(ClickDetection aClick) {
|
||||
long chans = aClick.getChannelBitmap(); // int32 channel group.
|
||||
long superId = 0;
|
||||
SuperDetection superDet = aClick.getSuperDetection(0);
|
||||
if (superDet != null) {
|
||||
superId = superDet.getUID();
|
||||
}
|
||||
/*
|
||||
* make an overall id for the click in a long. This could in theory wrap
|
||||
* a superdet, but that is very unlikely and we probably don't care anyway
|
||||
* since it's unlikely a uid that different would be in memory at the same time.
|
||||
*/
|
||||
long totalId = superId<<32 | chans;
|
||||
synchronized(lastClicks) {
|
||||
ClickDetection prevClick = lastClicks.get(totalId);
|
||||
if (prevClick == null) {
|
||||
aClick.setTempICI(0);
|
||||
}
|
||||
else {
|
||||
double ici = (double) (aClick.getTimeMilliseconds() - prevClick.getTimeMilliseconds()) / 1000.;
|
||||
aClick.setTempICI(ici);
|
||||
}
|
||||
lastClicks.put(totalId, aClick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -467,6 +570,8 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
hScrollManager.reset();
|
||||
}
|
||||
|
||||
clearICIHistory();
|
||||
|
||||
// hScrollManager.setupScrollBar(0);
|
||||
// setupTimeBar();
|
||||
repaintBoth();
|
||||
@ -1193,6 +1298,8 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
hScrollBar.setUnitIncrement(getUnitIncrement(getTimeRangeMillis()));
|
||||
hScrollBar.setBlockIncrement(getTimeRangeMillis() * 7 / 8);
|
||||
|
||||
sortTempICIs();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1265,7 +1372,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
// System.out.println("New max time = " + PamCalendar.formatTime(displayMaxMillis));
|
||||
// System.out.println(String.format("Set up scroll bar at %s", PamCalendar.formatDateTime(displayMaxMillis)));
|
||||
long displayLength = getTimeRangeMillis();
|
||||
// long currentStart = hScrollBar.getMinimumMillis();
|
||||
// long currentStart = hScrollBar.getMinimumMillis();
|
||||
long scrollRange = hScrollBar.getRangeMillis(); // total scrollable range
|
||||
long currentValue = hScrollBar.getValueMillis();
|
||||
long displayMinMillis = displayMaxMillis-scrollRange; // start of scrollable region.
|
||||
@ -1444,6 +1551,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
|
||||
@Override
|
||||
public void offlineDataChanged() {
|
||||
sortTempICIs();
|
||||
repaintBoth();
|
||||
}
|
||||
|
||||
@ -1572,9 +1680,9 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
}
|
||||
private double clickAngleToY(ClickDetection click) {
|
||||
AbstractLocalisation loc = click.getLocalisation();
|
||||
// if (click.getUID() == 110006089) {
|
||||
// System.out.println("Click 110006089 angle " + click.getAngle());
|
||||
// }
|
||||
// if (click.getUID() == 110006089) {
|
||||
// System.out.println("Click 110006089 angle " + click.getAngle());
|
||||
// }
|
||||
if (loc == null) return 0;
|
||||
double angle = 0;
|
||||
GpsData oll;
|
||||
@ -1590,20 +1698,20 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
case ArrayManager.ARRAY_TYPE_VOLUME:
|
||||
PamVector v = getDisplayVector(click);
|
||||
angle = Math.toDegrees(PamVector.vectorToSurfaceBearing(v));
|
||||
// PamVector[] vecs = null;
|
||||
// angle = click.getAngle();
|
||||
// if (btDisplayParameters.bearingType == BTDisplayParameters.BEARING_FROMVESSEL) {
|
||||
// PamVector[] vecs = null;
|
||||
// angle = click.getAngle();
|
||||
// if (btDisplayParameters.bearingType == BTDisplayParameters.BEARING_FROMVESSEL) {
|
||||
// have to use real world vectors to get the array rotation vector
|
||||
// then subtract back off the heading
|
||||
// vecs = loc.getPlanarAngles()();
|
||||
// if (vecs == null || vecs.length < 1) {
|
||||
// return 0;
|
||||
// }
|
||||
// angle = Math.toDegrees(PamVector.vectorToSurfaceBearing(vecs[0]));
|
||||
// oll = click.getOriginLatLong(false);
|
||||
// if (oll != null) {
|
||||
// angle -= oll.getHeading();
|
||||
// }
|
||||
// vecs = loc.getPlanarAngles()();
|
||||
// if (vecs == null || vecs.length < 1) {
|
||||
// return 0;
|
||||
// }
|
||||
// angle = Math.toDegrees(PamVector.vectorToSurfaceBearing(vecs[0]));
|
||||
// oll = click.getOriginLatLong(false);
|
||||
// if (oll != null) {
|
||||
// angle -= oll.getHeading();
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -1648,7 +1756,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
if (vr != null && vr.length > 0) {
|
||||
return vr[0];
|
||||
}
|
||||
// rotAngles[0] = Math.toRadians(oll.getHeading());
|
||||
// rotAngles[0] = Math.toRadians(oll.getHeading());
|
||||
}
|
||||
else if (rType == BTDisplayParameters.ROTATE_TONORTH) {
|
||||
PamVector[] vr = loc.getRealWorldVectors();
|
||||
@ -1656,11 +1764,11 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
return vr[0];
|
||||
}
|
||||
}
|
||||
// if (rotAngles[0] == 0 && rotAngles[1] == 0 && rotAngles[2] == 0) {
|
||||
// return v;
|
||||
// }
|
||||
// PamQuaternion pq = new PamQuaternion(rotAngles[0], rotAngles[1], rotAngles[2]);
|
||||
// PamVector v2 = PamVector.rotateVector(v, pq);
|
||||
// if (rotAngles[0] == 0 && rotAngles[1] == 0 && rotAngles[2] == 0) {
|
||||
// return v;
|
||||
// }
|
||||
// PamQuaternion pq = new PamQuaternion(rotAngles[0], rotAngles[1], rotAngles[2]);
|
||||
// PamVector v2 = PamVector.rotateVector(v, pq);
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -1677,16 +1785,16 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
return yStart + (yMax-yPos)/yScale;
|
||||
}
|
||||
|
||||
private ClickDetection lastICIClick;
|
||||
// private ClickDetection lastICIClick;
|
||||
private double clickICIToY(ClickDetection click) {
|
||||
if (click.getICI() > 0) {
|
||||
return btPlot.getHeight() - yAxis.getPosition(click.getICI());
|
||||
// return click.getICI() * yScale;
|
||||
}
|
||||
else {
|
||||
// if (click.getTempICI() > 0) {
|
||||
return btPlot.getHeight() - yAxis.getPosition(click.getTempICI());
|
||||
// return click.getTempICI() * yScale;
|
||||
}
|
||||
// return click.getICI() * yScale;
|
||||
// }
|
||||
// else {
|
||||
// return btPlot.getHeight() - yAxis.getPosition(click.getTempICI());
|
||||
// // return click.getTempICI() * yScale;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -1783,7 +1891,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
|
||||
}
|
||||
|
||||
// private JPopupMenu clickPopupMenu = null;
|
||||
// private JPopupMenu clickPopupMenu = null;
|
||||
|
||||
public RangeSpinner rangeSpinner;
|
||||
|
||||
@ -1792,20 +1900,20 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
public ClickDetSymbolChooser symbolChooser;
|
||||
|
||||
private JPopupMenu getClickPUMenu(ClickDetection click) {
|
||||
// if (clickPopupMenu == null){
|
||||
// clickPopupMenu = new JPopupMenu();
|
||||
// JMenuItem menuItem;
|
||||
// PamSymbol pamSymbol;
|
||||
// Color symbolColour;
|
||||
// for (int i = 0; i < PamColors.getInstance().getNWhaleColours(); i++) {
|
||||
// menuItem = new JMenuItem(" Whale Train " + i);
|
||||
// symbolColour = PamColors.getInstance().getWhaleColor(i);
|
||||
// pamSymbol = new PamSymbol(PamSymbol.SYMBOL_CIRCLE, 12, 12, true, symbolColour, symbolColour);
|
||||
// menuItem.setIcon(pamSymbol);
|
||||
// menuItem.addActionListener(new clickPUListener(i));
|
||||
// clickPopupMenu.add(menuItem);
|
||||
// }
|
||||
// }
|
||||
// if (clickPopupMenu == null){
|
||||
// clickPopupMenu = new JPopupMenu();
|
||||
// JMenuItem menuItem;
|
||||
// PamSymbol pamSymbol;
|
||||
// Color symbolColour;
|
||||
// for (int i = 0; i < PamColors.getInstance().getNWhaleColours(); i++) {
|
||||
// menuItem = new JMenuItem(" Whale Train " + i);
|
||||
// symbolColour = PamColors.getInstance().getWhaleColor(i);
|
||||
// pamSymbol = new PamSymbol(PamSymbol.SYMBOL_CIRCLE, 12, 12, true, symbolColour, symbolColour);
|
||||
// menuItem.setIcon(pamSymbol);
|
||||
// menuItem.addActionListener(new clickPUListener(i));
|
||||
// clickPopupMenu.add(menuItem);
|
||||
// }
|
||||
// }
|
||||
/*
|
||||
* Make a menu based on which whales are currently alive and active and also
|
||||
* a "new" category at the end ...
|
||||
@ -1830,7 +1938,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
OfflineEventDataUnit clickGroup = it.next();
|
||||
whaleId = clickGroup.getEventId();
|
||||
if (click.getSuperDetection(0) == clickGroup) continue;
|
||||
// if (whaleId == click.getEventId()) continue;
|
||||
// if (whaleId == click.getEventId()) continue;
|
||||
biggestId = Math.max(biggestId, whaleId);
|
||||
menuItem = new JMenuItem("Click Train " + whaleId);
|
||||
symbolColour = PamColors.getInstance().getWhaleColor(clickGroup.getColourIndex());
|
||||
@ -1841,9 +1949,9 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
}
|
||||
whaleId = biggestId + 1;
|
||||
menuItem = new JMenuItem("New Click Train");
|
||||
// symbolColour = PamColors.getInstance().getWhaleColor(whaleId);
|
||||
// pamSymbol = new PamSymbol(PamSymbol.SYMBOL_CIRCLE, 12, 12, true, symbolColour, symbolColour);
|
||||
// menuItem.setIcon(pamSymbol);
|
||||
// symbolColour = PamColors.getInstance().getWhaleColor(whaleId);
|
||||
// pamSymbol = new PamSymbol(PamSymbol.SYMBOL_CIRCLE, 12, 12, true, symbolColour, symbolColour);
|
||||
// menuItem.setIcon(pamSymbol);
|
||||
menuItem.addActionListener(new clickPUListener(whaleId));
|
||||
clickPopupMenu.add(menuItem, 0);
|
||||
|
||||
@ -1921,7 +2029,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
|
||||
if (popupClick == null) return;
|
||||
|
||||
// popupClick.setEventId(whaleId);
|
||||
// popupClick.setEventId(whaleId);
|
||||
|
||||
trackClick(popupClick, whaleId);
|
||||
|
||||
@ -1962,7 +2070,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
private void trackClick(ClickDetection click, int whaleId) {
|
||||
|
||||
click.setTracked(true);
|
||||
// clickControl.clickDetector.reWriteClick(click, false);
|
||||
// clickControl.clickDetector.reWriteClick(click, false);
|
||||
|
||||
// ClickDetection newDataUnit = new ClickDetection(click.getChannelBitmap(), click.getStartSample(),
|
||||
// click.getDuration(), click.clickDetector, click.triggerList);
|
||||
@ -2000,35 +2108,35 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
if (scaleManager == null) {
|
||||
return;
|
||||
}
|
||||
// scaleManager
|
||||
// System.out.println(String.format("set y range from %s %3.4f to %3.4fs", scaleManager.getTitle(),
|
||||
// scaleManager.getCurrentStart(), scaleManager.getCurrentEnd()));
|
||||
// scaleManager
|
||||
// System.out.println(String.format("set y range from %s %3.4f to %3.4fs", scaleManager.getTitle(),
|
||||
// scaleManager.getCurrentStart(), scaleManager.getCurrentEnd()));
|
||||
yAxis.setRange(scaleManager.getCurrentStart(), scaleManager.getCurrentEnd());
|
||||
yAxis.setLogScale(btDisplayParameters.logICIScale && btDisplayParameters.VScale == BTDisplayParameters.DISPLAY_ICI);
|
||||
yAxis.setInterval(scaleManager.getYAxisInterval());
|
||||
yAxis.setLabel(scaleManager.getTitle());
|
||||
yAxis.setAutoFormat(false);
|
||||
// String format = getYAxisFormat()
|
||||
// double range = Math.abs(scaleManager.currentRange);
|
||||
// if (range > 30) {
|
||||
// yAxis.setFormat("%d");
|
||||
// }
|
||||
// else if (range > 8) {
|
||||
// yAxis.setFormat("%3.1f");
|
||||
// }
|
||||
// else if (range > 1) {
|
||||
// yAxis.setFormat("%3.1f");
|
||||
// }
|
||||
// else if (range > .1) {
|
||||
// yAxis.setFormat("%3.2f");
|
||||
// }
|
||||
// else if (range <= 0) {
|
||||
// yAxis.setFormat("%3.2f");
|
||||
// }
|
||||
// else {
|
||||
// int nDP = (int)Math.ceil(Math.abs(Math.log10(range)));
|
||||
// yAxis.setFormat(String.format("%%%d.%df", nDP+2, nDP));
|
||||
// }
|
||||
// String format = getYAxisFormat()
|
||||
// double range = Math.abs(scaleManager.currentRange);
|
||||
// if (range > 30) {
|
||||
// yAxis.setFormat("%d");
|
||||
// }
|
||||
// else if (range > 8) {
|
||||
// yAxis.setFormat("%3.1f");
|
||||
// }
|
||||
// else if (range > 1) {
|
||||
// yAxis.setFormat("%3.1f");
|
||||
// }
|
||||
// else if (range > .1) {
|
||||
// yAxis.setFormat("%3.2f");
|
||||
// }
|
||||
// else if (range <= 0) {
|
||||
// yAxis.setFormat("%3.2f");
|
||||
// }
|
||||
// else {
|
||||
// int nDP = (int)Math.ceil(Math.abs(Math.log10(range)));
|
||||
// yAxis.setFormat(String.format("%%%d.%df", nDP+2, nDP));
|
||||
// }
|
||||
|
||||
// switch (btDisplayParameters.VScale) {
|
||||
//
|
||||
@ -2227,7 +2335,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
* @return
|
||||
*/
|
||||
private JPopupMenu getPopupMenu(ClickDetection clickedClick) {
|
||||
// System.out.println("Create click right click menu.....");
|
||||
// System.out.println("Create click right click menu.....");
|
||||
boolean isView = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW;
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
JMenuItem menuItem;
|
||||
@ -2289,23 +2397,23 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by species id",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_SPECIES);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_SPECIES));
|
||||
// menu.add(menuItem);
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by click train",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_TRAIN);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_TRAIN));
|
||||
// menu.add(menuItem);
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by train, then species",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_TRAINANDSPECIES);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_TRAINANDSPECIES));
|
||||
// menu.add(menuItem);
|
||||
// // if (isNetReceiver) {
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by hydrophone",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_HYDROPHONE);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_HYDROPHONE));
|
||||
// menu.add(menuItem);
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by species id",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_SPECIES);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_SPECIES));
|
||||
// menu.add(menuItem);
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by click train",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_TRAIN);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_TRAIN));
|
||||
// menu.add(menuItem);
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by train, then species",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_TRAINANDSPECIES);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_TRAINANDSPECIES));
|
||||
// menu.add(menuItem);
|
||||
// // if (isNetReceiver) {
|
||||
// menuItem = new JCheckBoxMenuItem("Colour by hydrophone",
|
||||
// btDisplayParameters.colourScheme == BTDisplayParameters.COLOUR_BY_HYDROPHONE);
|
||||
// menuItem.addActionListener(new ColourByAction(BTDisplayParameters.COLOUR_BY_HYDROPHONE));
|
||||
// menu.add(menuItem);
|
||||
// }
|
||||
menuItem = new JCheckBoxMenuItem("Bearing / Time");
|
||||
menuItem.addActionListener(new AxesMenuAction(BTDisplayParameters.DISPLAY_BEARING));
|
||||
@ -2639,23 +2747,23 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
}
|
||||
}
|
||||
|
||||
// class ColourByAction implements ActionListener {
|
||||
//
|
||||
// private int colourChoice;
|
||||
//
|
||||
// public ColourByAction(int colourChoice) {
|
||||
// super();
|
||||
// this.colourChoice = colourChoice;
|
||||
// }
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// btDisplayParameters.colourScheme = colourChoice;
|
||||
// symbolChooser.setSymbolType(colourChoice);
|
||||
//
|
||||
// btPlot.setTotalRepaint();
|
||||
// btPlot.repaint(minPaintTime);
|
||||
// btPlot.createKey();
|
||||
// }
|
||||
// }
|
||||
// class ColourByAction implements ActionListener {
|
||||
//
|
||||
// private int colourChoice;
|
||||
//
|
||||
// public ColourByAction(int colourChoice) {
|
||||
// super();
|
||||
// this.colourChoice = colourChoice;
|
||||
// }
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// btDisplayParameters.colourScheme = colourChoice;
|
||||
// symbolChooser.setSymbolType(colourChoice);
|
||||
//
|
||||
// btPlot.setTotalRepaint();
|
||||
// btPlot.repaint(minPaintTime);
|
||||
// btPlot.createKey();
|
||||
// }
|
||||
// }
|
||||
|
||||
class SettingsMenuAction implements ActionListener {
|
||||
|
||||
@ -2670,7 +2778,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
getVScaleManager().setSelected();
|
||||
}
|
||||
btAxis.makeAxis();
|
||||
// System.out.println("360: "+btDisplayParameters.view360);
|
||||
// System.out.println("360: "+btDisplayParameters.view360);
|
||||
repaintBoth();
|
||||
btPlot.createKey();
|
||||
if (clickControl.getOfflineToolbar() != null) {
|
||||
@ -2694,16 +2802,16 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
Rectangle b = null ;
|
||||
if (btAmplitudeSelector != null) {
|
||||
b= btAmplitudeSelector.getFrame().getBounds();
|
||||
// btAmplitudeSelector.getFrame().setVisible(true);
|
||||
// // btAmplitudeSelector.getFrame().
|
||||
// btAmplitudeSelector.getFrame().setVisible(true);
|
||||
// // btAmplitudeSelector.getFrame().
|
||||
}
|
||||
// else {
|
||||
// else {
|
||||
btAmplitudeSelector = BTAmplitudeSelector.showAmplitudeFrame(clickControl, this);
|
||||
if(b!=null){
|
||||
|
||||
btAmplitudeSelector.getFrame().setBounds(b);
|
||||
}
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private void checkBTAmplitudeSelectHisto() {
|
||||
@ -2895,7 +3003,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
|
||||
|
||||
public boolean redrawAllClicks(){
|
||||
// System.out.println("redrawAllClicks " + hScrollBar.getValueMillis()+ " "+vScrollBar.getValue()+" "+ hScrollBar.getMaximumMillis()+" "+hScrollBar.getStepSizeMillis());
|
||||
// System.out.println("redrawAllClicks " + hScrollBar.getValueMillis()+ " "+vScrollBar.getValue()+" "+ hScrollBar.getMaximumMillis()+" "+hScrollBar.getStepSizeMillis());
|
||||
if (totalRepaint) {
|
||||
return true;
|
||||
}
|
||||
@ -2914,7 +3022,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
}
|
||||
}
|
||||
|
||||
// double lastPaintTime;
|
||||
// double lastPaintTime;
|
||||
public void paintClicks(Graphics g, Rectangle clipRectangle) {
|
||||
|
||||
long t0 = System.nanoTime();
|
||||
@ -2928,18 +3036,21 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
zoomer.paintShape(g, this, true);
|
||||
}
|
||||
|
||||
// long t1 = System.nanoTime();
|
||||
// long t1 = System.nanoTime();
|
||||
synchronized (clickData.getSynchLock()) {
|
||||
// long t2 = System.nanoTime();
|
||||
// double ms = ((double) (t2-t1)) / 1000000.;
|
||||
// long t2 = System.nanoTime();
|
||||
// double ms = ((double) (t2-t1)) / 1000000.;
|
||||
// if (btDisplayParameters.VScale == BTDisplayParameters.DISPLAY_ICI) {
|
||||
// sortTempICIs();
|
||||
// }
|
||||
|
||||
ListIterator<ClickDetection> clickIterator = clickData.getListIterator(PamDataBlock.ITERATOR_END);
|
||||
while (clickIterator.hasPrevious()) {
|
||||
click = clickIterator.previous();
|
||||
if (shouldPlot(prevPlottedClick)){
|
||||
if (btDisplayParameters.VScale == BTDisplayParameters.DISPLAY_ICI) {
|
||||
prevPlottedClick.setTempICI((double) (prevPlottedClick.getStartSample()-click.getStartSample()) / sampleRate);
|
||||
}
|
||||
// if (btDisplayParameters.VScale == BTDisplayParameters.DISPLAY_ICI) {
|
||||
// prevPlottedClick.setTempICI((double) (prevPlottedClick.getStartSample()-click.getStartSample()) / sampleRate);
|
||||
// }
|
||||
if (drawClick(g, prevPlottedClick, clipRectangle) < -0){
|
||||
break;
|
||||
}
|
||||
@ -2949,16 +3060,16 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
if (shouldPlot(prevPlottedClick)){ // and draw the last one !
|
||||
drawClick(g, prevPlottedClick, clipRectangle);
|
||||
}
|
||||
// g.drawString(String.format("Wait synch %3.3fms", ms), 0, 20);
|
||||
// g.drawString(String.format("Wait synch %3.3fms", ms), 0, 20);
|
||||
}
|
||||
// long t3 = System.nanoTime();
|
||||
// g.drawString(String.format("Last draw %3.3fms", lastPaintTime), 0, 20);
|
||||
// lastPaintTime = ((double) (t3-t0)) / 1000000.;
|
||||
// long t3 = System.nanoTime();
|
||||
// g.drawString(String.format("Last draw %3.3fms", lastPaintTime), 0, 20);
|
||||
// lastPaintTime = ((double) (t3-t0)) / 1000000.;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintPanel(Graphics g, Rectangle clipRectangle) {
|
||||
// long tNow = System.currentTimeMillis();
|
||||
// long tNow = System.currentTimeMillis();
|
||||
redrawClicks=redrawAllClicks();
|
||||
/**
|
||||
* Need to call this every time since the original symbol chooser will get deleted after
|
||||
@ -3090,11 +3201,11 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
if (pt.x - width > clipRegion.x + clipRegion.width) return +1;
|
||||
}
|
||||
if (click.tracked) {
|
||||
// System.out.println("Drawing tracked click");
|
||||
// System.out.println("Drawing tracked click");
|
||||
}
|
||||
|
||||
//set the colour scheme.
|
||||
// symbolChooser.setSymbolType(btDisplayParameters.colourScheme);
|
||||
// symbolChooser.setSymbolType(btDisplayParameters.colourScheme);
|
||||
PamSymbol symbol = symbolChooser.getPamSymbol(btProjector, click);
|
||||
|
||||
//.getClickSymbol(clickControl.getClickIdentifier(), click, btDisplayParameters.colourScheme);
|
||||
@ -3156,8 +3267,8 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
return null;
|
||||
}
|
||||
String tip = click.getSummaryString();
|
||||
// String tip = String.format("<html>UID. %d; Click No. %d; Channels %s", click.getUID(),
|
||||
// click.clickNumber, PamUtils.getChannelList(click.getChannelBitmap()));
|
||||
// String tip = String.format("<html>UID. %d; Click No. %d; Channels %s", click.getUID(),
|
||||
// click.clickNumber, PamUtils.getChannelList(click.getChannelBitmap()));
|
||||
byte type = click.getClickType();
|
||||
if (clickControl.getClickIdentifier() != null) {
|
||||
String typeStr = clickControl.getClickIdentifier().getSpeciesName(type);
|
||||
@ -3262,7 +3373,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
setKeyPosition(CornerLayoutContraint.LAST_LINE_START);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
// e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3342,7 +3453,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
return false;
|
||||
}
|
||||
if (btDisplayParameters.VScale == BTDisplayParameters.DISPLAY_ICI) {
|
||||
// if (btDisplayParameters.showUnassignedICI == false && click.getICI() < 0) return false;
|
||||
// if (btDisplayParameters.showUnassignedICI == false && click.getICI() < 0) return false;
|
||||
if (btDisplayParameters.showUnassignedICI == false && click.getSuperDetectionsCount() <= 0) return false;
|
||||
// otherwise may be ok, since will estimate all ici's on teh fly.
|
||||
}
|
||||
@ -3436,7 +3547,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
* to zero. However DO call these functions which were previously in
|
||||
* reset();
|
||||
*/
|
||||
// reset();
|
||||
// reset();
|
||||
int channels = clickControl.clickParameters.getChannelBitmap();
|
||||
int[] channelGroups = clickControl.clickParameters.getChannelGroups();
|
||||
int nChannelGroups = GroupedSourcePanel.countChannelGroups(channels, channelGroups);
|
||||
@ -3502,8 +3613,8 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
this.btDisplayParameters = ((BTDisplayParameters) pamControlledUnitSettings
|
||||
.getSettings()).clone();
|
||||
// rangeScrollBar.setValue(btDisplayParameters.vScrollValue);
|
||||
// rangeSpinner.setSpinnerValue(btDisplayParameters.getTimeRange());
|
||||
// btPlot.createKey();
|
||||
// rangeSpinner.setSpinnerValue(btDisplayParameters.getTimeRange());
|
||||
// btPlot.createKey();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1511,7 +1511,7 @@ public class ClickDetection extends PamDataUnit<PamDataUnit, PamDataUnit> implem
|
||||
* @param iCI the iCI to set
|
||||
*/
|
||||
public void setICI(double iCI) {
|
||||
ICI = iCI;
|
||||
this.ICI = iCI;
|
||||
}
|
||||
|
||||
protected void setChannelGroupDetector(ChannelGroupDetector channelGroupDetector) {
|
||||
|
@ -140,6 +140,7 @@ public class PamScrollSlider extends AbstractPamScrollerAWT {
|
||||
valueMillis = Math.max(scrollerData.minimumMillis, Math.min(scrollerData.maximumMillis, valueMillis));
|
||||
int val = (int) ((valueMillis - scrollerData.minimumMillis) / scrollerData.getStepSizeMillis());
|
||||
if (val >= slider.getMinimum() && val <= slider.getMaximum()) {
|
||||
// System.out.printf("Set slider val %d in range %d to %d\n", val, slider.getMinimum(), slider.getMaximum());
|
||||
slider.setValue(val);
|
||||
}
|
||||
}
|
||||
|
@ -699,6 +699,23 @@ public class ViewerScrollerManager extends AbstractScrollManager implements PamS
|
||||
if (aScroller == pamScroller) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Can end up with some horrible feedback here if two
|
||||
* coupled scrollers bring in rounding errors and start
|
||||
* to oscillate each other.
|
||||
*/
|
||||
long currentVal = aScroller.getValueMillis();
|
||||
long change = Math.abs(value-currentVal);
|
||||
long range = aScroller.getMaximumMillis() - aScroller.getMinimumMillis();
|
||||
if (range == 0) {
|
||||
aScroller.setValueMillis(aScroller.getMinimumMillis());
|
||||
continue;
|
||||
}
|
||||
double fracChange = (double) change / (double) range;
|
||||
if (fracChange <= .0001) {
|
||||
continue;
|
||||
}
|
||||
|
||||
aScroller.setValueMillis(value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user