/** * Handles mouse clicks in the chart panel. * * @param event the chart mouse event */ private void mouseClickedInChart(ChartMouseEvent event) { ArrayList<ChartEntity> entities = getEntitiesForPoint(event.getTrigger().getPoint().x, event.getTrigger().getPoint().y); if (entities.isEmpty()) { return; } boolean dataPointFound = false; String dataPointTooltip = ""; for (ChartEntity tempEntity : entities) { if (tempEntity instanceof XYAnnotationEntity) { if (((XYAnnotationEntity) tempEntity).getToolTipText() != null) { dataPointFound = true; dataPointTooltip = ((XYAnnotationEntity) tempEntity).getToolTipText(); } } } if (dataPointFound) { String dataset = tooltipToDatasetMap.get(dataPointTooltip); JOptionPane.showMessageDialog(this, dataPointTooltip + ":\n" + vennDiagramResults.get(dataset), "Selected Values", JOptionPane.INFORMATION_MESSAGE); } }
/** * Handles mouse movements in the chart panel. * * @param event the chart mouse event */ private void mouseMovedInChart(ChartMouseEvent event) { ArrayList<ChartEntity> entities = getEntitiesForPoint(event.getTrigger().getPoint().x, event.getTrigger().getPoint().y); boolean dataPointFound = false; for (ChartEntity tempEntity : entities) { if (tempEntity instanceof XYAnnotationEntity) { if (((XYAnnotationEntity) tempEntity).getToolTipText() != null) { dataPointFound = true; } } } if (dataPointFound) { chartPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); } else { chartPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); } }
@Override public void chartMouseClicked(ChartMouseEvent event) { if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1)) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { GraphColumn bgc = getGraphColumn(event); if (bgc == null) { return; } MQuery query = bgc.getMQuery(builder.getMGoal()); if (query != null) AEnv.zoom(query); else log.warn("Nothing to zoom to - " + bgc); } finally { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }
/** * Callback method for receiving notification of a mouse movement on a * chart. * * @param event information about the event. */ public void chartMouseMoved(ChartMouseEvent event) { if (!(event.getChart().getXYPlot().getRenderer() instanceof MotionBubbleRenderer)) { return; } MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer(); if (!(event.getEntity() instanceof XYItemEntity)) { renderer.setHighlightedItem(-1, -1); return; } XYItemEntity item = (XYItemEntity) event.getEntity(); renderer.setHighlightedItem(item.getSeriesIndex(), item.getItem()); }
@Override public void chartMouseMoved(ChartMouseEvent e) { disableToolTip(); if (isPointWithinChartArea(e.getTrigger().getX(), e.getTrigger().getY())) { chart.getXYPlot().setDomainCrosshairVisible(true); double vx = valueFromPosition(e); chart.getXYPlot().setDomainCrosshairValue(vx); scheduleTooltipDisplay(vx); } else { chart.getXYPlot().setDomainCrosshairVisible(false); synchronized(this) { if (tooltipTimerTask != null) { tooltipTimerTask.cancel(); } } } }
@Override public void chartMouseClicked( final ChartMouseEvent e ) { // left mouse click if ( e.getTrigger().getButton() == MouseEvent.BUTTON1 && enableReferenceTimePoint ) { referenceTimePoint = getChartXLocation( e.getTrigger().getPoint(), panel ); valueMarker.setValue( referenceTimePoint ); valueMarker.setLabel( " Reference\n Timepoint " + referenceTimePoint ); if ( !markerShown ) { ((XYPlot) e.getChart().getPlot()).addDomainMarker( valueMarker ); markerShown = true; } } }
@Override public void chartMouseClicked(ChartMouseEvent event) { if (event.getEntity().getClass() == CategoryItemEntity.class) { if ((getChart() != null) && (getChart().getClass() == HighlightableBarChart.class)) { HighlightableBarChart chart = (HighlightableBarChart) getChart(); CategoryItemEntity entity = (CategoryItemEntity) event.getEntity(); // toggle highlight if already selected if (chart.isHighlighted(entity)) { chart.clearHighlights(); firePropertyChange("highlightedBar", getRowAndColumn(entity), null); } else { chart.clearHighlights(); chart.highlightEntity(entity); firePropertyChange("highlightedBar", null, getRowAndColumn(entity)); } // assume whatever fired the event will repaint the chart } } }
public void chartMouseClicked(ChartMouseEvent e) { if(e.getEntity() != null){ for(Area shape : areas){ //if(shape.contains(e.getTrigger().getPoint())){ if(shape.equals(e.getEntity().getArea())){ if(!e.getTrigger().isControlDown()){ selected.clear(); } if(selected.contains(shape)){ selected.remove(shape); } else { selected.add(shape); } } } } else { selected.clear(); } setSelectedForList(true); }
/** * Receives notification of mouse clicks on the panel. These are translated and passed on to any * registered {@link ChartMouseListener}s. * * @param event * Information about the mouse event. */ @Override public void mouseClicked(MouseEvent event) { Insets insets = getInsets(); int x = (int) ((event.getX() - insets.left) / this.scaleX); int y = (int) ((event.getY() - insets.top) / this.scaleY); this.anchor = new Point2D.Double(x, y); if (this.chart == null) { return; } this.chart.setNotify(true); // force a redraw // new entity code... Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } }
/** * Implementation of the MouseMotionListener's method. * * @param e * the event. */ @Override public void mouseMoved(MouseEvent e) { Graphics2D g2 = (Graphics2D) getGraphics(); if (this.horizontalAxisTrace) { drawHorizontalAxisTrace(g2, e.getX()); } if (this.verticalAxisTrace) { drawVerticalAxisTrace(g2, e.getY()); } g2.dispose(); Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } Insets insets = getInsets(); int x = (int) ((e.getX() - insets.left) / this.scaleX); int y = (int) ((e.getY() - insets.top) / this.scaleY); ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } // we can only generate events if the panel's chart is not null // (see bug report 1556951) if (this.chart != null) { ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(event); } } }
@Override public void chartMouseClicked(final ChartMouseEvent cme) { if (cme.getTrigger().getClickCount() % 2 == 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (cache.isEmpty()) { return; } jNextChart.getXYPlot().setDomainCrosshairVisible(true); double xValue = jNextChart.getXYPlot().getDomainCrosshairValue(); double yValue = jNextChart.getXYPlot().getRangeCrosshairValue(); RectangleEdge xEdge = jNextChart.getXYPlot().getDomainAxisEdge(); RectangleEdge yEdge = jNextChart.getXYPlot().getRangeAxisEdge(); Rectangle2D dataArea = jChartPanel.getScreenDataArea(); // jChartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea(); int x = (int) jNextChart.getXYPlot().getDomainAxis().valueToJava2D(xValue, dataArea, xEdge); int y = (int) jNextChart.getXYPlot().getRangeAxis().valueToJava2D(yValue, dataArea, yEdge); Date date = new Date((long)xValue); jIskValue.setText(iskFormat.format(yValue)); jDateValue.setText(dateFormat.format(date)); TrackerNote trackerNote = Settings.get().getTrackerNotes().get(new TrackerDate(date)); if (trackerNote != null) { jAddNote.setVisible(false); jEditNote.setVisible(true); jNote.setVisible(true); jNote.setText(trackerNote.getNote()); } else { jAddNote.setVisible(true); jEditNote.setVisible(false); jNote.setVisible(false); } jPopupMenu.show((Component)cme.getTrigger().getSource(), x, y); } }); } }
/** * Get BarGraphColumn for ChartEntity * @param event * @return BarGraphColumn or null if not found */ private GraphColumn getGraphColumn(ChartMouseEvent event) { ChartEntity entity = event.getEntity(); String key = null; if (entity instanceof CategoryItemEntity) { Comparable<?> colKey = ((CategoryItemEntity)entity).getColumnKey(); if (colKey != null) { key = colKey.toString(); } } else if (entity instanceof PieSectionEntity) { Comparable<?> sectionKey = ((PieSectionEntity)entity).getSectionKey(); if (sectionKey != null) { key = sectionKey.toString(); } } if (key == null) { return null; } for (int i = 0; i < list.size(); i++) { final String label = list.get(i).getLabel(); if (key.equals(label)) { return list.get(i); } } // return null; }
public void chartMouseClicked(ChartMouseEvent event) { JFreeChart chart = event.getChart(); for(int x = 1; x < VisualFirewall.NUMVIEWS; ++x) { if( parent.views[x].chart != null && ( chart == parent.views[x].chart || chart.equals( parent.views[x].chart) ) ) { mouseClicked(new MouseEvent(parent.views[x].getCanvas(), 0,0,0,0,0,0, false)); break; } } // end for() }
@Override public void chartMouseClicked( final ChartMouseEvent e ) { // left mouse click if ( e.getTrigger().getButton() == MouseEvent.BUTTON1 ) { final double value = getChartXLocation( e.getTrigger().getPoint(), panel ); valueMarker.setValue( value ); valueMarker.setLabel( " Distance=" + value ); } }
@Override public void chartMouseClicked( final ChartMouseEvent e ) { // left mouse click if ( e.getTrigger().getButton() == MouseEvent.BUTTON1 && enableReferenceTimePoint ) { final int referenceTimePoint = getChartXLocation( e.getTrigger().getPoint(), panel ); if ( timepoints != null ) { if ( setReferenceTimepoint( timepoints, referenceTimePoint ) ) this.referenceTimePoint = referenceTimePoint; } else { this.referenceTimePoint = referenceTimePoint; } valueMarker.setValue( this.referenceTimePoint ); valueMarker.setLabel( " Reference\n Timepoint " + this.referenceTimePoint ); if ( !markerShown ) { ((XYPlot) e.getChart().getPlot()).addDomainMarker( valueMarker ); markerShown = true; } } }
/** * Receives notification of mouse clicks on the panel. These are translated and passed on to any registered * {@link ChartMouseListener}s. * * @param event * Information about the mouse event. */ @Override public void mouseClicked(MouseEvent event) { Insets insets = getInsets(); int x = (int) ((event.getX() - insets.left) / this.scaleX); int y = (int) ((event.getY() - insets.top) / this.scaleY); this.anchor = new Point2D.Double(x, y); if (this.chart == null) { return; } this.chart.setNotify(true); // force a redraw // new entity code... Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } }
public void chartMouseClicked(ChartMouseEvent event) { // ignore }
public void chartMouseMoved(ChartMouseEvent event) { // ignore }
@Override public void chartMouseClicked(ChartMouseEvent event) { try { int mouseX = event.getTrigger().getX(); int mouseY = event.getTrigger().getY(); Point mousePoint = new Point(mouseX, mouseY); CombinedDomainCategoryPlot combinedDomainCategoryPlot = (CombinedDomainCategoryPlot) event.getChart() .getPlot(); ChartRenderingInfo chartInfo = boxAndWiskerPanel.getChartRenderingInfo(); Point2D java2DPoint = boxAndWiskerPanel.translateScreenToJava2D(mousePoint); PlotRenderingInfo plotInfo = chartInfo.getPlotInfo(); int subplotIndex = plotInfo.getSubplotIndex(java2DPoint); if (subplotIndex >= 0) { Rectangle2D dataArea = plotInfo.getDataArea(); CategoryPlot categoryPlot = (CategoryPlot) combinedDomainCategoryPlot.getSubplots().get(subplotIndex); ValueAxis rangeAxis = categoryPlot.getRangeAxis(); long logEntryTimestamp = (long) rangeAxis.java2DToValue(java2DPoint.getY(), dataArea, categoryPlot.getRangeAxisEdge()); LOG.info("subplotIndex: " + subplotIndex + " logEntryTimestamp: " + logEntryTimestamp); // int rowNumber = ltm // .getClosestLogEntryRowIndex(logEntryTimestamp); // // if (rowNumber >= 0) { // logTable.setRowSelectionInterval(rowNumber, rowNumber); // logTable.scrollRowToVisible(rowNumber); // } } } catch (Exception e) { LOG.error("Error handling mouse click", e); } }
@Override public void chartMouseMoved(ChartMouseEvent cme) { }
@Override public void chartMouseMoved(ChartMouseEvent event) { }
protected JPanel getItemPanel(final JDialog dialog, XYItemEntity item, ChartMouseEvent event) { MotionDataSet dataset = (MotionDataSet) event.getChart().getXYPlot().getDataset(); MotionTableModel model = dataset.getTableModel(); DefaultTableModel tModel = new DefaultTableModel(2, 0); ArrayList<String> rowIds = new ArrayList<String>(); Integer row = model.getKeyMap().get(dataset.getSeriesKey(item.getSeriesIndex())).get(item.getItem()); rowIds.add(row + ":"); int columnCount = model.getColumnCount(); for (int c = 0; c < columnCount; c++) { tModel.addColumn(model.getColumnName(c)); tModel.setValueAt(model.getValueAt(row, c), 0, c); } rowIds.add("Mappings:"); Object category = dataset.getCategory(item.getSeriesIndex(), item.getItem()); if (category != null) { tModel.setValueAt(category, 1, model.getCategoryMapping()); } Object key = dataset.getSeriesKey(item.getSeriesIndex()); if (key != null) { tModel.setValueAt(key, 1, model.getKeyMapping()); } Object x = dataset.getX(item.getSeriesIndex(), item.getItem()); if (x != null) { tModel.setValueAt(x, 1, model.getXAxisMapping()); } Object y = dataset.getY(item.getSeriesIndex(), item.getItem()); if (y != null) { tModel.setValueAt(y, 1, model.getYAxisMapping()); } Object size = dataset.getSize(item.getSeriesIndex(), item.getItem()); if (size != null) { tModel.setValueAt(size, 1, model.getSizeMapping()); } Color color = dataset.getColor(item.getSeriesIndex(), item.getItem()); if (color != null) { //String colorText = "RGB(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")"; tModel.setValueAt(color, 1, model.getColorMapping()); } return getPanel(dialog, tModel, rowIds); }
protected JPanel getSeriesPanel(final JDialog dialog, ChartMouseEvent event) { MotionDataSet dataset = (MotionDataSet) event.getChart().getXYPlot().getDataset(); MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer(); MotionTableModel model = dataset.getTableModel(); DefaultTableModel tModel = new DefaultTableModel(); ArrayList<Integer> visibleSeries = renderer.getVisibleSeries(); ArrayList<String> rowIds = new ArrayList<String>(); int columnCount = model.getColumnCount(); int r = 0; for (int c = 0; c < columnCount; c++) { tModel.addColumn(model.getColumnName(c)); } Iterator<Integer> itr = visibleSeries.iterator(); while (itr.hasNext()) { ArrayList<Integer> rows = model.getKeyMap().get(dataset.getSeriesKey(itr.next())); Iterator<Integer> rItr = rows.iterator(); while (rItr.hasNext()) { int row = rItr.next(); tModel.addRow(new Object[0]); rowIds.add(new String(row + ":")); for (int c = 0; c < columnCount; c++) { tModel.setValueAt(model.getValueAt(row, c), r, c); } r++; } } return getPanel(dialog, tModel, rowIds); }
@Override public void chartMouseMoved(ChartMouseEvent mouseEvent) { }
@Override public void chartMouseClicked(ChartMouseEvent e) { if (isPointWithinChartArea(e.getTrigger().getX(), e.getTrigger().getY())) { enableTooltip(valueFromPosition(e)); } }
private double valueFromPosition(ChartMouseEvent e) { Rectangle2D chartArea = cp.getScreenDataArea(); XYPlot plot = chart.getXYPlot(); return plot.getDomainAxis().java2DToValue(e.getTrigger().getX(), chartArea, plot.getDomainAxisEdge()); }
@Override public void chartMouseMoved(ChartMouseEvent event) { updatePoint(event); }
private void updatePoint(ChartMouseEvent event) { if (xyDataset == null || xyDataset.getSeriesCount() == 0 // This situation appears, if the dataset has changed while the overlay is still visible || (seriesIndex < 0 || seriesIndex >= xyDataset.getSeriesCount())) { if (removeOverlay()) { // FIXME - exception here: // listener.pointDeselected(); /* Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at ProductSceneView.getRaster(ProductSceneView.java:511) at ProductSceneView.getProduct(ProductSceneView.java:468) at org.esa.snap.visat.toolviews.nav.CursorSynchronizer.removePPL(CursorSynchronizer.java:133) at org.esa.snap.visat.toolviews.nav.CursorSynchronizer.clearPsvOverlayMap(CursorSynchronizer.java:116) at org.esa.snap.visat.toolviews.nav.CursorSynchronizer.setEnabled(CursorSynchronizer.java:67) at org.esa.snap.visat.toolviews.stat.ProfilePlotPanel$3.pointDeselected(ProfilePlotPanel.java:211) */ } return; } addOverlay(); XYPlot plot = chartPanel.getChart().getXYPlot(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); double xView = event.getTrigger().getPoint().x; double xData = plot.getDomainAxis().java2DToValue(xView, dataArea, domainEdge); int itemCount = xyDataset.getItemCount(seriesIndex); for (int i = 0; i < itemCount - 1; i++) { double x1 = xyDataset.getXValue(seriesIndex, i); double x2 = xyDataset.getXValue(seriesIndex, i + 1); if (xData >= x1 && xData <= x2) { double y1 = xyDataset.getYValue(seriesIndex, i); double y2 = xyDataset.getYValue(seriesIndex, i + 1); double yData = y1 + (xData - x1) * (y2 - y1) / (x2 - x1); double yView = plot.getRangeAxis().valueToJava2D(yData, dataArea, rangeEdge); Point2D.Double viewPoint = new Point2D.Double(xView, yView); Point2D.Double dataPoint = new Point2D.Double(xData, yData); overlay.setPoint(viewPoint, dataPoint); listener.pointSelected(xyDataset, seriesIndex, dataPoint); break; } } }
@Override public void chartMouseMoved( final ChartMouseEvent e ) { }
@Override public final void chartMouseClicked(ChartMouseEvent event) { int series = -1; ChartEntity entity = event.getEntity(); if (entity == null) { return; } // users can click on either the line or the legend // regardless, figure out the series index if (entity.getClass() == XYItemEntity.class) { series = ((XYItemEntity) event.getEntity()).getSeriesIndex(); } else if (entity.getClass() == LegendItemEntity.class) { LegendItemEntity legendEntity = (LegendItemEntity) event.getEntity(); XYDataset dataset = (XYDataset) legendEntity.getDataset(); for (int i = 0; i < dataset.getSeriesCount(); i++) { if (dataset.getSeriesKey(i).equals(legendEntity.getSeriesKey())) { series = i; break; } } } if (series != -1) { XYItemRenderer renderer = getChart().getXYPlot().getRenderer(); Stroke oldHighlight = renderer.getSeriesStroke(series); // clear existing highlights ((AbstractRenderer) getChart().getXYPlot().getRenderer()).clearSeriesStrokes(false); // toggle series stroke if (oldHighlight != SELECTED_STROKE) { renderer.setSeriesStroke(series, SELECTED_STROKE); firePropertyChange("highlightedLine", null, series); } else { renderer.setSeriesStroke(series, null); firePropertyChange("highlightedLine", series, null); } // assume whatever fired the event will repaint the chart } }
@Override public final void chartMouseMoved(ChartMouseEvent event) {}
@Override public void chartMouseMoved(ChartMouseEvent event) {}