diff --git a/src/PamView/component/DataBlockTableView.java b/src/PamView/component/DataBlockTableView.java index af5918cf..3b9b87e7 100644 --- a/src/PamView/component/DataBlockTableView.java +++ b/src/PamView/component/DataBlockTableView.java @@ -249,6 +249,18 @@ public abstract class DataBlockTableView { } } + /** + * Get the data unit for the selected data row + * @return + */ + public T getSelectedDataUnit() { + int row = testTable.getSelectedRow(); + if (row < 0) { + return null; + } + return getDataUnit(row); + } + /** * Get the number of rows in the table - default behaviour is the * number of rows in the datablock, but this may be overridden if @@ -344,7 +356,7 @@ public abstract class DataBlockTableView { } public void popupMenuAction(MouseEvent e, T dataUnit, String colName) { - +// System.out.println("Pop"); } private void showPopupMenu(MouseEvent e) { diff --git a/src/detectiongrouplocaliser/dialogs/DetectionGroupTable.java b/src/detectiongrouplocaliser/dialogs/DetectionGroupTable.java index 3dd7ecb8..fc48befa 100644 --- a/src/detectiongrouplocaliser/dialogs/DetectionGroupTable.java +++ b/src/detectiongrouplocaliser/dialogs/DetectionGroupTable.java @@ -338,7 +338,7 @@ public class DetectionGroupTable extends UserDisplayComponentAdapter implements * * @return which data row is selected, or null. */ - private DetectionGroupDataUnit getSelectedDataRow() { + public DetectionGroupDataUnit getSelectedDataRow() { int row = table.getSelectedRow(); if (row < 0 || dataCopy == null || row >= dataCopy.size()) { return null; diff --git a/src/pamScrollSystem/AbstractScrollManager.java b/src/pamScrollSystem/AbstractScrollManager.java index e1485a4d..60de4983 100644 --- a/src/pamScrollSystem/AbstractScrollManager.java +++ b/src/pamScrollSystem/AbstractScrollManager.java @@ -104,6 +104,13 @@ public abstract class AbstractScrollManager { */ abstract public void centreDataAt(PamDataBlock dataBlock, long menuMouseTime); + /** + * Move scroll to given time. Don't move the outer scroller unless necessary. + * @param dataBlock + * @param menuMouseTime + */ + abstract public void scrollToTime(PamDataBlock dataBlock, long menuMouseTime); + /** * Start all data in all data blocks at the given time * @param dataBlock diff --git a/src/pamScrollSystem/PamScrollSlider.java b/src/pamScrollSystem/PamScrollSlider.java index bb1062ad..8b908b12 100644 --- a/src/pamScrollSystem/PamScrollSlider.java +++ b/src/pamScrollSystem/PamScrollSlider.java @@ -93,11 +93,12 @@ public class PamScrollSlider extends AbstractPamScrollerAWT { } @Override - void doMouseWheelAction(MouseWheelEvent mouseWheelEvent) { + public void doMouseWheelAction(MouseWheelEvent mouseWheelEvent) { int n = mouseWheelEvent.getWheelRotation(); slider.setValue(slider.getValue() - n); scrollMoved(); } + public void scrollMoved() { AbstractScrollManager.getScrollManager().moveInnerScroller(this, getValueMillis()); notifyValueChange(); @@ -146,6 +147,7 @@ public class PamScrollSlider extends AbstractPamScrollerAWT { public long getVisibleAmount() { return 0; } + /* (non-Javadoc) * @see pamScrollSystem.AbstractPamScroller#setRangeMillis(long, long, boolean) */ diff --git a/src/pamScrollSystem/RealTimeScrollManager.java b/src/pamScrollSystem/RealTimeScrollManager.java index 662cfdf3..ecb9ef7c 100644 --- a/src/pamScrollSystem/RealTimeScrollManager.java +++ b/src/pamScrollSystem/RealTimeScrollManager.java @@ -59,4 +59,10 @@ public class RealTimeScrollManager extends AbstractScrollManager { return newMin; } + @Override + public void scrollToTime(PamDataBlock dataBlock, long menuMouseTime) { + // TODO Auto-generated method stub + + } + } diff --git a/src/pamScrollSystem/ViewerScrollerManager.java b/src/pamScrollSystem/ViewerScrollerManager.java index 82159a4d..dba01fae 100644 --- a/src/pamScrollSystem/ViewerScrollerManager.java +++ b/src/pamScrollSystem/ViewerScrollerManager.java @@ -17,6 +17,7 @@ import PamController.PamControllerInterface; import PamController.PamGUIManager; import PamController.PamSettingManager; import PamController.PamSettings; +import PamUtils.PamCalendar; import PamguardMVC.PamDataBlock; import PamguardMVC.dataOffline.OfflineDataLoadInfo; import PamguardMVC.superdet.SuperDetDataBlock; @@ -624,20 +625,52 @@ public class ViewerScrollerManager extends AbstractScrollManager implements PamS public void centreDataAt(PamDataBlock dataBlock, long menuMouseTime) { // centre all scroll bars as close to the above as is possible. AbstractPamScroller aScroller; - long scrollRange, newMax, newMin; for (int i = 0; i < pamScrollers.size(); i++) { aScroller = pamScrollers.get(i); - scrollRange = aScroller.getMaximumMillis() - aScroller.getMinimumMillis(); - newMin = checkMinimumTime(menuMouseTime - scrollRange / 2); - newMax = checkMaximumTime(newMin + scrollRange); - newMin = newMax-scrollRange; - newMin = checkGapPos(dataBlock, newMin, newMax); - newMax = newMin + scrollRange; - aScroller.setRangeMillis(newMin, newMax, false); - // aScroller.setValueMillis(menuMouseTime - scrollRange/2); + centreScrollerAt(aScroller, dataBlock, menuMouseTime); } loadData(false); } + + /** + * Moves outer scroller to centre at given time. + * @param aScroller + * @param dataBlock + * @param menuMouseTime + */ + private void centreScrollerAt(AbstractPamScroller aScroller, PamDataBlock dataBlock, long menuMouseTime) { + long scrollRange, newMax, newMin; + scrollRange = aScroller.getMaximumMillis() - aScroller.getMinimumMillis(); + newMin = checkMinimumTime(menuMouseTime - scrollRange / 2); + newMax = checkMaximumTime(newMin + scrollRange); + newMin = menuMouseTime - scrollRange/2; + newMin = checkGapPos(dataBlock, newMin, newMax); + newMax = newMin + scrollRange; + System.out.printf("Centering scoller at %s, range %s to %s\n", PamCalendar.formatDBDateTime(menuMouseTime), + PamCalendar.formatDBDateTime(newMin), PamCalendar.formatDBDateTime(newMax)); + aScroller.setRangeMillis(newMin, newMax, false); + aScroller.setValueMillis(menuMouseTime); + } + + @Override + public void scrollToTime(PamDataBlock dataBlock, long menuMouseTime) { + // centre all scroll bars as close to the above as is possible. + AbstractPamScroller aScroller; + boolean moved = false; + for (int i = 0; i < pamScrollers.size(); i++) { + aScroller = pamScrollers.get(i); + long scrollerMin = aScroller.getMinimumMillis(); + long scrollerMax = aScroller.getMaximumMillis(); + if (menuMouseTime < scrollerMin || menuMouseTime > scrollerMax) { + centreScrollerAt(aScroller, dataBlock, menuMouseTime); + moved = true; + } + aScroller.setValueMillis(menuMouseTime); + } + if (moved) { + loadData(false); + } + } @Override public void startDataAt(PamDataBlock dataBlock, long menuMouseTime, boolean immediateLoad) {