mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 14:42:27 +00:00
click selection in BT display
Cleaned up code. Hopefully fixed issue with clicks not selecting correctly on large displays.
This commit is contained in:
parent
2540fd0d32
commit
2d207a15c3
@ -400,11 +400,24 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
* @param newFile
|
||||
*/
|
||||
public void setNewFile (String newFile) {
|
||||
fileInputParameters.recentFiles.remove(newFile);
|
||||
fileInputParameters.recentFiles.add(0, newFile);
|
||||
fillFileList();
|
||||
if (newFile == null) {
|
||||
return;
|
||||
}
|
||||
String currentFirst = getFirstFile();
|
||||
if (newFile.equals(currentFirst) == false) {
|
||||
fileInputParameters.recentFiles.remove(newFile);
|
||||
fileInputParameters.recentFiles.add(0, newFile);
|
||||
fillFileList();
|
||||
}
|
||||
interpretNewFile(newFile);
|
||||
}
|
||||
|
||||
public String getFirstFile() {
|
||||
if (fileInputParameters.recentFiles.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return fileInputParameters.recentFiles.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a new file or folder is selected.
|
||||
@ -434,7 +447,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe
|
||||
if (file.isFile() && !file.isHidden() && acquisitionDialog != null) {
|
||||
try {
|
||||
|
||||
System.out.println("FileInputSystem - interpretNewFile");
|
||||
// System.out.println("FileInputSystem - interpretNewFile");
|
||||
AudioInputStream audioStream = PamAudioFileManager.getInstance().getAudioInputStream(file);
|
||||
|
||||
// // Get additional information from the header if it's a wav file.
|
||||
|
@ -3131,7 +3131,8 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
zoomer.paintShape(g, this, true);
|
||||
}
|
||||
|
||||
ArrayList<ClickDetection> clickCopy = clickData.getDataCopy(displayStartMillis, displayStartMillis+displayLengthMillis, true, getDataSelector());
|
||||
// ArrayList<ClickDetection> clickCopy = clickData.getDataCopy(displayStartMillis, displayStartMillis+displayLengthMillis, true, getDataSelector());
|
||||
ArrayList<ClickDetection> clickCopy = getPlottableClicks();
|
||||
if (clickCopy.size() == 0) {
|
||||
return;
|
||||
}
|
||||
@ -3484,23 +3485,20 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
*/
|
||||
ClickDetection findClick(int x, int y, int maxdist) {
|
||||
ClickDetection closestClick = null;
|
||||
PamDataBlock<ClickDetection> clickData = clickControl.getClickDataBlock();
|
||||
ClickDetection unit;
|
||||
Point pt;
|
||||
int dist;
|
||||
int closest = maxdist * maxdist;
|
||||
synchronized (clickData.getSynchLock()) {
|
||||
ListIterator<ClickDetection> clickIterator = clickData.getListIterator(PamDataBlock.ITERATOR_END);
|
||||
while (clickIterator.hasPrevious()) {
|
||||
unit = clickIterator.previous();
|
||||
// if (unit.getTimeMilliseconds() < displayStartMillis - 1000)
|
||||
// break;
|
||||
if (!shouldPlot(unit)) continue;
|
||||
pt = clickXYPos(unit);
|
||||
if ((dist = ((pt.x - x) * (pt.x - x) + (pt.y - y) * (pt.y - y))) <= closest) {
|
||||
closest = dist;
|
||||
closestClick = unit;
|
||||
}
|
||||
ListIterator<ClickDetection> clickIterator = getPlottableClicksIterator(0);
|
||||
while (clickIterator.hasNext()) {
|
||||
unit = clickIterator.next();
|
||||
// if (unit.getTimeMilliseconds() < displayStartMillis - 1000)
|
||||
// break;
|
||||
if (!shouldPlot(unit)) continue;
|
||||
pt = clickXYPos(unit);
|
||||
if ((dist = ((pt.x - x) * (pt.x - x) + (pt.y - y) * (pt.y - y))) <= closest) {
|
||||
closest = dist;
|
||||
closestClick = unit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3763,7 +3761,8 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
}
|
||||
// first find the current click
|
||||
ClickDetection click;
|
||||
ListIterator<ClickDetection> clickIterator = cdb.getListIterator(PamDataBlock.ITERATOR_END);
|
||||
// ListIterator<ClickDetection> clickIterator = cdb.getListIterator(PamDataBlock.ITERATOR_END);
|
||||
ListIterator<ClickDetection> clickIterator = getPlottableClicksIterator(PamDataBlock.ITERATOR_END);
|
||||
while (clickIterator.hasPrevious()) {
|
||||
click = clickIterator.previous();
|
||||
if (click == selectedClick) {
|
||||
@ -3797,16 +3796,47 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
// TODO Auto-generated method stub
|
||||
super.clickedOnClick(click);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plottable clicks, i.e ones within time range and ones which
|
||||
* pass data selection.
|
||||
* @return Array list of clicks.
|
||||
*/
|
||||
private ArrayList<ClickDetection> getPlottableClicks() {
|
||||
/**
|
||||
* In viewer mode, it may be possible to not bother calling this by simply keeping
|
||||
* this list if the parameters haven't changed.
|
||||
*/
|
||||
PamDataBlock<ClickDetection> clickData = clickControl.getClickDataBlock();
|
||||
return clickData.getDataCopy(displayStartMillis, displayStartMillis+displayLengthMillis, true, getClickDataSelector());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator to plottable clicks, based around a COPY of underlying
|
||||
* data, so no need to synchronize, but not to modify.
|
||||
* @return iterator from start of plottable clicks array list.
|
||||
*/
|
||||
private ListIterator<ClickDetection> getPlottableClicksIterator(int whereFrom) {
|
||||
ArrayList<ClickDetection> clicks = getPlottableClicks();
|
||||
if (whereFrom == PamDataBlock.ITERATOR_END) {
|
||||
whereFrom = Math.max(0, clicks.size()-1);
|
||||
}
|
||||
return clicks.listIterator(whereFrom);
|
||||
}
|
||||
|
||||
private ClickDetection getFirstSelectableClick() {
|
||||
PamDataBlock<ClickDetection> cdb = clickControl.getClickDataBlock();
|
||||
ListIterator<ClickDetection> clickIterator = cdb.getListIterator(0);
|
||||
ClickDetection click;
|
||||
ClickDataSelector dataSelector = getClickDataSelector();
|
||||
while (clickIterator.hasNext()) {
|
||||
click = clickIterator.next();
|
||||
if (!shouldPlot(click) || !clickInMarkedArea(click)) {
|
||||
continue;
|
||||
}
|
||||
if (dataSelector != null && dataSelector.scoreData(click) == 0) {
|
||||
continue;
|
||||
}
|
||||
return click;
|
||||
}
|
||||
return null;
|
||||
@ -3816,11 +3846,15 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
PamDataBlock<ClickDetection> cdb = clickControl.getClickDataBlock();
|
||||
ListIterator<ClickDetection> clickIterator = cdb.getListIterator(PamDataBlock.ITERATOR_END);
|
||||
ClickDetection click;
|
||||
ClickDataSelector dataSelector = getClickDataSelector();
|
||||
while (clickIterator.hasPrevious()) {
|
||||
click = clickIterator.previous();
|
||||
if (!shouldPlot(click) || !clickInMarkedArea(click)) {
|
||||
continue;
|
||||
}
|
||||
if (dataSelector != null && dataSelector.scoreData(click) == 0) {
|
||||
continue;
|
||||
}
|
||||
return click;
|
||||
}
|
||||
return null;
|
||||
@ -3860,7 +3894,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
return;
|
||||
}
|
||||
PamDataBlock<ClickDetection> cdb = clickControl.getClickDataBlock();
|
||||
ListIterator<ClickDetection> clickIterator = cdb.getListIterator(0);
|
||||
ListIterator<ClickDetection> clickIterator = getPlottableClicksIterator(0);
|
||||
ClickDetection click;
|
||||
while (clickIterator.hasNext()) {
|
||||
click = clickIterator.next();
|
||||
@ -4027,7 +4061,7 @@ public class ClickBTDisplay extends ClickDisplay implements PamObserver, PamSett
|
||||
double[][] clickWave = null;
|
||||
int clickLen = 0;
|
||||
try {
|
||||
clickIterator = clickData.getListIterator(0);
|
||||
clickIterator = getPlottableClicksIterator(0);
|
||||
|
||||
click = getFirstClick(startMillis);
|
||||
if (click != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user