/** * @param aEvent * @param aStartPoint */ protected void handleZoomRegion(final MouseEvent aEvent, final Point aStartPoint) { // For now, disabled by default as it isn't 100% working yet... if (Boolean.FALSE.equals(Boolean.valueOf(System.getProperty("zoomregionenabled", "false")))) { return; } final JComponent source = (JComponent) aEvent.getComponent(); final boolean dragging = (aEvent.getID() == MouseEvent.MOUSE_DRAGGED); final GhostGlassPane glassPane = (GhostGlassPane) SwingUtilities.getRootPane(source).getGlassPane(); Rectangle viewRect; final JScrollPane scrollPane = SwingComponentUtils.getAncestorOfClass(JScrollPane.class, source); if (scrollPane != null) { final JViewport viewport = scrollPane.getViewport(); viewRect = SwingUtilities.convertRectangle(viewport, viewport.getVisibleRect(), glassPane); } else { viewRect = SwingUtilities.convertRectangle(source, source.getVisibleRect(), glassPane); } final Point start = SwingUtilities.convertPoint(source, aStartPoint, glassPane); final Point current = SwingUtilities.convertPoint(source, aEvent.getPoint(), glassPane); if (dragging) { if (!glassPane.isVisible()) { glassPane.setVisible(true); glassPane.setRenderer(new RubberBandRenderer(), start, current, viewRect); } else { glassPane.updateRenderer(start, current, viewRect); } glassPane.repaintPartially(); } else /* if ( !dragging ) */ { // Fire off a signal to the zoom controller to do its job... this.controller.getZoomController().zoomRegion(aStartPoint, aEvent.getPoint()); glassPane.setVisible(false); } }
/** * exports the data to a CSV file * * @param aFile File object */ private void storeToCsvFile(final File aFile, final UARTDataSet aDataSet) { try { final CsvExporter exporter = ExportUtils.createCsvExporter(aFile); exporter.setHeaders( "index", "start-time", "end-time", "event?", "event-type", "RxD event", "TxD event", "RxD data", "TxD data"); final List<UARTData> decodedData = aDataSet.getData(); for (int i = 0; i < decodedData.size(); i++) { final UARTData ds = decodedData.get(i); final String startTime = Unit.Time.format(aDataSet.getTime(ds.getStartSampleIndex())); final String endTime = Unit.Time.format(aDataSet.getTime(ds.getEndSampleIndex())); String eventType = null; String rxdEvent = null; String txdEvent = null; String rxdData = null; String txdData = null; switch (ds.getType()) { case UARTData.UART_TYPE_EVENT: eventType = ds.getEventName(); break; case UARTData.UART_TYPE_RXEVENT: rxdEvent = ds.getEventName(); break; case UARTData.UART_TYPE_TXEVENT: txdEvent = ds.getEventName(); break; case UARTData.UART_TYPE_RXDATA: rxdData = Integer.toString(ds.getData()); break; case UARTData.UART_TYPE_TXDATA: txdData = Integer.toString(ds.getData()); break; default: break; } exporter.addRow( Integer.valueOf(i), startTime, endTime, Boolean.valueOf(ds.isEvent()), eventType, rxdEvent, txdEvent, rxdData, txdData); } exporter.close(); } catch (final IOException exception) { // Make sure to handle IO-interrupted exceptions properly! if (!HostUtils.handleInterruptedException(exception)) { LOG.log(Level.WARNING, "CSV export failed!", exception); } } }