Example usage for org.jfree.chart ChartMouseListener ChartMouseListener

List of usage examples for org.jfree.chart ChartMouseListener ChartMouseListener

Introduction

In this page you can find the example usage for org.jfree.chart ChartMouseListener ChartMouseListener.

Prototype

ChartMouseListener

Source Link

Usage

From source file:net.sf.eclipsecs.ui.stats.views.GraphStatsView.java

/**
 * Creates the master view containing the chart.
 * //from   w w  w  .j av a  2  s  . c o m
 * @param parent
 *            the parent composite
 * @return the chart composite
 */
public Composite createMasterView(Composite parent) {

    // create the date set for the chart
    mPieDataset = new GraphPieDataset();
    mPieDataset.setShowAllCategories(mShowAllCategoriesAction.isChecked());
    mGraph = createChart(mPieDataset);

    // creates the chart component
    // Composite embeddedComposite = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    // embeddedComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    // experimental usage of JFreeChart SWT
    // the composite to harbor the Swing chart control
    ChartComposite embeddedComposite = new ChartComposite(parent, SWT.NONE, mGraph, true);
    embeddedComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    embeddedComposite.addChartMouseListener(new ChartMouseListener() {

        public void chartMouseClicked(final ChartMouseEvent event) {

            MouseEvent trigger = event.getTrigger();
            if (trigger.getButton() == MouseEvent.BUTTON1 && event.getEntity() instanceof PieSectionEntity) {

                // && trigger.getClickCount() == 2 //doubleclick not correctly detected with the SWT composite

                mMasterComposite.getDisplay().syncExec(new Runnable() {

                    public void run() {
                        mIsDrilledDown = true;
                        mCurrentDetailCategory = (String) ((PieSectionEntity) event.getEntity())
                                .getSectionKey();
                        mStackLayout.topControl = mDetailViewer.getTable();
                        mMainSection.layout();
                        mDetailViewer.setInput(mDetailViewer.getInput());

                        updateActions();
                        updateLabel();
                    }
                });
            } else {
                event.getTrigger().consume();
            }
        }

        public void chartMouseMoved(ChartMouseEvent event) {
            // NOOP
        }
    });

    return embeddedComposite;
}

From source file:au.gov.ansto.bragg.wombat.ui.views.WombatAnalysisControlViewOld.java

@Override
public void createPartControl(Composite composite) {
    super.createPartControl(composite);

    AlgorithmTask task = getAlgorithmTask();
    final Operation operation = task.getOperationManager(0).getOperation(NAVIGATION_PROCESSOR_NAME);
    final OperationParameter valueOnAxisParameter = operation.getOperationParameter(SCAN_VARIABLE_NAME);
    final Operation plotOperation = task.getOperationManager(0).getOperation(ONEDPLOT_PROCESSOR_NAME);
    final Operation geometryOperation = task.getOperationManager(0)
            .getOperation(CORRECTED_HISTOGRAM_PROCESSOR_NAME);
    final Operation integrationOperation = task.getOperationManager(0).getOperation(INTEGRATION_PROCESSOR_NAME);
    final OperationParameter applyToAllParameter = operation.getOperationParameter(APPLYTOALL_VARIABLE_NAME);
    final OperationParameter resetHistoryParameter = operation
            .getOperationParameter(RESET_HISTORY_VARIABLE_NAME);
    //      final IPointLocatorListener mouseListener = new IPointLocatorListener(){
    ///* w  w  w.j  a v  a  2s .  co m*/
    //         public void locationUpdated(double x, double y, double val) {
    //            List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName());
    //            for (OperationParameterEditor editor : editors){
    //               if (editor.getOperationParameter() == parameter){
    ////                  parameter.setValue(new Double(x));
    ////                  editor.loadData();
    //                  if (editor instanceof OptionOperationParameterEditor)
    //                     ((OptionOperationParameterEditor) editor).setSelection(new Double(x));
    //               }
    //            }
    //            
    //            applyParameters();
    //         }
    //      };

    final OperationParameterListener applyToAllListener = new OperationParameterListener() {

        public void serverDataUpdated(OperationParameter operationParameter, Object newData) {
            if (newData instanceof Boolean) {
                geometryOperation.setOperationDataListenerEnabled(!(Boolean) newData);
                integrationOperation.setOperationDataListenerEnabled(!(Boolean) newData);
                plotOperation.setOperationDataListenerEnabled(!(Boolean) newData);
            }
        }

    };

    applyToAllParameter.addOperationParameterListener(applyToAllListener);

    //      final KurandaMouseListener doubleClickListener = new KurandaMouseListener(){
    //
    //         public void mouseDoubleClick(EventData eventData) {
    //            List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName());
    //            for (OperationParameterEditor editor : editors){
    //               if (editor.getOperationParameter() == valueOnAxisParameter){
    ////                  parameter.setValue(new Double(x));
    ////                  editor.loadData();
    //                  if (editor instanceof OptionOperationParameterEditor)
    //                     ((OptionOperationParameterEditor) editor).setSelection(
    ////                           new Position(String.valueOf(eventData.getX())));
    //                           Double.valueOf(eventData.getX()));
    //               }
    //            }
    //            
    //            applyParameters();            
    //         }
    //
    //         public void mouseDown(EventData eventData) {
    //            
    //         }
    //
    //         public void mouseUp(EventData eventData) {
    //            
    //         }
    //         
    //      };
    //
    //      PlotManager.addOpenNewPlotListener(new PlotManager.OpenNewPlotListener(){
    //
    //         public void newPlotOpened(Plot plot) {
    //            if (plot.getOperaton() == plotOperation)
    ////               plot.getCurrentPlotWidget().addPointLocatorListener(mouseListener);
    //               plot.getCurrentPlotWidget().addMouseEventListener(doubleClickListener);
    //         }});

    final ChartMouseListener chartMouseListener = new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            // TODO Auto-generated method stub
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            if (event instanceof XYChartMouseEvent) {
                List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName());
                for (OperationParameterEditor editor : editors) {
                    if (editor.getOperationParameter() == valueOnAxisParameter) {
                        if (editor instanceof OptionOperationParameterEditor)
                            ((OptionOperationParameterEditor) editor).setSelection(
                                    new Position(String.valueOf(((XYChartMouseEvent) event).getX())));
                    }
                }
            }
        }
    };

    PlotManager.addOpenNewPlotListener(new PlotManager.OpenNewPlotListener() {

        public void newPlotOpened(au.gov.ansto.bragg.kakadu.ui.plot.Plot plot) {
            if (plot.getOperaton() == plotOperation)
                //               plot.getCurrentPlotWidget().addPointLocatorListener(mouseListener);
                plot.getCurrentPlotWidget().addChartMouseListener(chartMouseListener);
        }
    });

    configurationButton.removeSelectionListener(configurationSelectionListener);
    configurationButton.setText("Reset");
    configurationButton.setToolTipText("clear all history data");
    configurationButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent arg0) {

        }

        public void widgetSelected(SelectionEvent arg0) {
            if (MessageDialog.openConfirm(getSite().getShell(), "Confirm of Clearing History Data",
                    "Do you want to clear all the history data?")) {
                try {
                    algorithmTask.applyParameterChangesForAllDataItems(RESET_HISTORY_VARIABLE_NAME, true);
                    algorithmTask.markOperationsActual(NAVIGATION_PROCESSOR_NAME, false);
                } catch (SetTunerException e) {
                    Util.handleException(getSite().getShell(), e);
                }
                applyParameters();
            }
        }
    });

}

From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java

/**
 * /*from   w w w . j  a va  2s  . c om*/
 * @return
 */
private ChartPanel getChartPanel() {

    if (chartPanel == null) {

        renderer = new StackedBarRenderer();
        renderer.setMaximumBarWidth(0.05);
        renderer.setShadowVisible(false);

        renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
            @Override
            public String generateToolTip(CategoryDataset dataset, int row, int column) {

                WaterfallCategory wfCategory = (WaterfallCategory) dataset.getColumnKey(column);
                return wfCategory.getTooltip();
            }
        });
        renderer.setBaseItemLabelsVisible(true);
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.INSIDE9, TextAnchor.CENTER_LEFT));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.INSIDE9, TextAnchor.CENTER_LEFT));

        // Set up plot
        CategoryPlot plot = new CategoryPlot(new DefaultCategoryDataset(), getCategoryAxis(), getTimeAxis(),
                renderer);
        plot.setOrientation(PlotOrientation.HORIZONTAL);
        plot.setDomainGridlinesVisible(true);
        plot.setDomainGridlinePosition(CategoryAnchor.END);

        JFreeChart chart = new JFreeChart(plot);
        chartPanel = new ChartPanel(chart, 400, 200, 200, 200, 2000, 5000, true, false, false, false, false,
                true);
        chartPanel.setMouseZoomable(false);
        chartPanel.setRangeZoomable(false);
        chartPanel.setDomainZoomable(false);
        chartPanel.addChartMouseListener(new ChartMouseListener() {

            @Override
            public void chartMouseMoved(ChartMouseEvent arg0) {
                // Do Nothing
            }

            @Override
            public void chartMouseClicked(ChartMouseEvent event) {

                //TODO Add listner info or separate the listener.
                if (event.getEntity() instanceof CategoryItemEntity) {
                    CategoryItemEntity xyitem = (CategoryItemEntity) event.getEntity();
                    WaterfallCategory wfCategory = (WaterfallCategory) xyitem.getColumnKey();
                    if (wfCategory != null && wfCategory.getReqResp() != null) {
                        int count = event.getTrigger().getClickCount();
                        if (count > 1) {
                            waterfallTab.updateMainFrame(wfCategory.getSession());
                        } else {
                            popup.refresh(wfCategory.getReqResp(), wfCategory.getIndex());
                            if (!popup.getPopupDialog().isVisible()) {
                                popup.getPopupDialog().setVisible(true);
                            }
                        }
                    }
                }

            }
        });
    }

    return chartPanel;
}

From source file:org.gumtree.vis.plot1d.Plot1D.java

private void createStatusBar() {
    Composite statusComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(6, false);
    layout.marginLeft = 6;//  w w w.j  a va  2s  . c  o m
    layout.marginRight = 6;
    layout.marginTop = 1;
    layout.marginBottom = 1;
    layout.horizontalSpacing = 3;
    layout.verticalSpacing = 1;
    statusComposite.setLayout(layout);

    GridData gridData = new GridData(SWT.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    statusComposite.setLayoutData(gridData);

    final Label xLabel = new Label(statusComposite, SWT.NONE);
    xLabel.setText("X:");
    gridData = new GridData(SWT.DEFAULT);
    xLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(xLabel);
    final Text xText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    xText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(xText);
    xText.setEditable(false);

    final Label yLabel = new Label(statusComposite, SWT.NONE);
    yLabel.setText("Y:");
    gridData = new GridData(SWT.DEFAULT);
    yLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(yLabel);
    final Text yText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    yText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(yText);
    yText.setEditable(false);

    final Composite composite = this;
    panel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            if (event instanceof XYChartMouseEvent) {
                final String xString = String.format("%.2f", ((XYChartMouseEvent) event).getX());
                final String yString = String.format("%.2f", ((XYChartMouseEvent) event).getY());
                //                  panel.requestFocus();

                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        xText.setText(xString);
                        yText.setText(yString);
                        if (!composite.isFocusControl()) {
                            composite.setFocus();
                        }
                    }
                });
            }
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    if (!composite.isFocusControl()) {
                        composite.setFocus();
                    }
                }
            });
        }
    });
}

From source file:org.gumtree.vis.hist2d.Hist2D.java

private void createStatusBar() {
    Composite statusComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(6, false);
    layout.marginLeft = 6;/*from   w  ww  . j a v a2s  .  com*/
    layout.marginRight = 6;
    layout.marginTop = 1;
    layout.marginBottom = 1;
    layout.horizontalSpacing = 3;
    layout.verticalSpacing = 1;
    statusComposite.setLayout(layout);

    GridData gridData = new GridData(SWT.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    statusComposite.setLayoutData(gridData);

    final Label xLabel = new Label(statusComposite, SWT.NONE);
    xLabel.setText("X:");
    gridData = new GridData(SWT.DEFAULT);
    xLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(xLabel);
    final Text xText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    xText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(xText);
    xText.setEditable(false);

    final Label yLabel = new Label(statusComposite, SWT.NONE);
    yLabel.setText("Y:");
    gridData = new GridData(SWT.DEFAULT);
    yLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(yLabel);
    final Text yText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    yText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(yText);
    yText.setEditable(false);

    final Label zLabel = new Label(statusComposite, SWT.NONE);
    zLabel.setText("Z:");
    gridData = new GridData(SWT.DEFAULT);
    zLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(zLabel);
    final Text zText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    zText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(zText);
    zText.setEditable(false);

    final Composite composite = this;
    panel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            if (event instanceof XYZChartMouseEvent) {
                final String xString = String.format("%.2f", ((XYZChartMouseEvent) event).getX());
                final String yString = String.format("%.2f", ((XYZChartMouseEvent) event).getY());
                final String zString = String.format("%.2f", ((XYZChartMouseEvent) event).getZ());
                panel.requestFocus();

                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        xText.setText(xString);
                        yText.setText(yString);
                        zText.setText(zString);
                        if (!composite.isFocusControl()) {
                            composite.setFocus();
                        }
                    }
                });
            }
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            // TODO Auto-generated method stub

        }
    });
}

From source file:org.talend.dataprofiler.chart.TOPChartService.java

@Override
public void addMouseListenerForChart(Object chartComposite, final Map<String, Object> menuMap,
        final boolean useRowFirst) {
    final ChartComposite chartComp = (ChartComposite) chartComposite;
    final ChartMouseListener listener = new ChartMouseListener() {

        @Override//ww w.  ja va 2s . c om
        public void chartMouseClicked(ChartMouseEvent event) {
            boolean flag = event.getTrigger().getButton() != MouseEvent.BUTTON3;
            chartComp.setDomainZoomable(flag);
            chartComp.setRangeZoomable(flag);
            if (flag) {
                return;
            }

            ChartEntity chartEntity = event.getEntity();
            if (chartEntity != null && chartEntity instanceof CategoryItemEntity) {
                CategoryItemEntity cateEntity = (CategoryItemEntity) chartEntity;

                Menu menu = getCurrentMenu(cateEntity);
                if (menu != null) {
                    chartComp.setMenu(menu);
                    menu.setVisible(true);
                }
            }
        }

        private Menu getCurrentMenu(CategoryItemEntity cateEntity) {
            if (useRowFirst) {
                return findCurrentMenu(cateEntity.getRowKey(), cateEntity.getColumnKey());
            } else {
                return findCurrentMenu(cateEntity.getColumnKey(), cateEntity.getRowKey());
            }
        }

        /**
         * DOC yyin Comment method "findCurrentMenu".
         * 
         * @param firstKey
         * @param secondKey
         * @return
         */
        private Menu findCurrentMenu(final Object firstKey, Object secondKey) {
            Object menu = menuMap.get(firstKey);
            if (menu != null) {
                return (Menu) menu;
            }
            menu = menuMap.get(secondKey);
            if (menu != null) {
                return (Menu) menu;
            }
            return null;
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            // no action here

        }

    };
    chartComp.addChartMouseListener(listener);
    chartComp.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            chartComp.removeChartMouseListener(listener);
            chartComp.dispose();
        }

    });
}

From source file:au.gov.ansto.bragg.kowari.ui.views.AnalysisControlView.java

@Override
public void createPartControl(Composite composite) {
    super.createPartControl(composite);
    defaultParametersButton.dispose();/* w  w w.jav a 2s  .  c  om*/
    revertParametersButton.dispose();
    configurationButton.dispose();
    applyParametersButton.setText("Apply");
    GridData data = new GridData();
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    applyParametersButton.setLayoutData(data);
    generateReportButton = new Button(parameterGroupButtonsComposite, SWT.PUSH);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    generateReportButton.setLayoutData(data);
    generateReportButton.setText("Report");
    generateReportButton.setToolTipText("Generate the analysis report");
    generateReportButton.setImage(
            Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/report16x16.png").createImage());
    parametersComposite.layout(parameterGroupButtonsComposite.getChildren());

    initReportListener();
    //      parameterGroupButtonsComposite.layout();
    //      parameterGroupButtonsComposite.update();
    //      parameterGroupButtonsComposite.redraw();
    //      parameterGroupButtonsComposite.getParent().update();
    //      parameterGroupButtonsComposite.getParent().redraw();
    AlgorithmTask task = getAlgorithmTask();
    final Operation operation = task.getOperationManager(0).getOperation(NAVIGATION_PROCESSOR_NAME);
    final Tuner isInLoopTuner = ((ProcessorAgent) operation.getAgent()).getTuner(IS_IN_LOOP_TUNER_NAME);
    final OperationParameter parameter = operation.getOperationParameter(SCAN_VARIABLE_NAME);
    final Operation plotOperation = task.getOperationManager(0).getOperation(ONEDPLOT_PROCESSOR_NAME);
    final Operation geometryOperation = task.getOperationManager(0)
            .getOperation(CORRECTED_HISTOGRAM_PROCESSOR_NAME);
    final Operation integrationOperation = task.getOperationManager(0).getOperation(INTEGRATION_PROCESSOR_NAME);

    generateReportButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }

        public void widgetSelected(SelectionEvent arg0) {
            IGroup result = plotOperation.getOutputData();
            if (result == null) {
                MessageDialog.openError(getSite().getShell(), "Report Error",
                        "There is no result data available");
            }
            Plot algorithmResult = (Plot) result;
            String filename = Util.selectDirectoryFromShell(getSite().getShell());
            if (filename == null || filename.trim().length() == 0)
                return;
            URI targetFolderURI = null;
            try {
                targetFolderURI = ConverterLib.path2URI(filename);
            } catch (FileAccessException e) {
                Util.handleException(getSite().getShell(), new FileAccessException("Illegal folder path"));
            }
            exportReport(targetFolderURI, algorithmResult);
        }
    });
    //      final IPointLocatorListener mouseListener = new IPointLocatorListener(){
    //
    //         public void locationUpdated(double x, double y, double val) {
    //            List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName());
    //            for (OperationParameterEditor editor : editors){
    //               if (editor.getOperationParameter() == parameter){
    ////                  parameter.setValue(new Double(x));
    ////                  editor.loadData();
    //                  if (editor instanceof OptionOperationParameterEditor)
    //                     ((OptionOperationParameterEditor) editor).setSelection(new Double(x));
    //               }
    //            }
    //            
    //            applyParameters();
    //         }
    //      };

    //      final KurandaMouseListener doubleClickListener = new KurandaMouseListener(){
    //
    //         public void mouseDoubleClick(EventData eventData) {
    //            List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName());
    //            for (OperationParameterEditor editor : editors){
    //               if (editor.getOperationParameter() == parameter){
    ////                  parameter.setValue(new Double(x));
    ////                  editor.loadData();
    //                  if (editor instanceof OptionOperationParameterEditor)
    //                     ((OptionOperationParameterEditor) editor).setSelection(
    //                           new Position(String.valueOf(eventData.getX())));
    //               }
    //            }
    //            
    //            applyParameters();            
    //         }
    //
    //         public void mouseDown(EventData eventData) {
    //            
    //         }
    //
    //         public void mouseUp(EventData eventData) {
    //            
    //         }
    //         
    //      };

    final ChartMouseListener chartMouseListener = new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            // TODO Auto-generated method stub
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            if (event instanceof XYChartMouseEvent) {
                List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName());
                for (OperationParameterEditor editor : editors) {
                    if (editor.getOperationParameter() == parameter) {
                        if (editor instanceof OptionOperationParameterEditor) {
                            ((OptionOperationParameterEditor) editor).setSelection(
                                    new Position(String.valueOf(((XYChartMouseEvent) event).getX())));
                            applyParameters();
                        }
                    }
                }
            }
        }
    };

    PlotManager.addOpenNewPlotListener(new PlotManager.OpenNewPlotListener() {

        public void newPlotOpened(au.gov.ansto.bragg.kakadu.ui.plot.Plot plot) {
            if (plot.getOperaton() == plotOperation)
                //               plot.getCurrentPlotWidget().addPointLocatorListener(mouseListener);
                plot.getCurrentPlotWidget().addChartMouseListener(chartMouseListener);
        }
    });

    final IMaskEventListener maskEventListener = new IMaskEventListener() {

        @Override
        public void maskAdded(AbstractMask mask) {
            runDelayedTask();
        }

        @Override
        public void maskRemoved(AbstractMask mask) {
            runDelayedTask();
        }

        @Override
        public void maskUpdated(AbstractMask mask) {
            runDelayedTask();
        }

    };

    PlotManager.addOpenNewPlotListener(new PlotManager.OpenNewPlotListener() {

        public void newPlotOpened(au.gov.ansto.bragg.kakadu.ui.plot.Plot plot) {
            if (plot.getOperaton() == geometryOperation)
                plot.getCurrentPlotWidget().addMaskEventListener(maskEventListener);
        }
    });

    final TunerPortListener applyToAllListener = new TunerPortListener(isInLoopTuner) {

        @Override
        public void updateUIMax(Object max) {
        }

        @Override
        public void updateUIMin(Object min) {
        }

        @Override
        public void updateUIOptions(List<?> options) {
        }

        @Override
        public void updateUIValue(Object newData) {
            if (newData instanceof Boolean) {
                DisplayManager.getDefault().setEnable(!(Boolean) newData);
                System.err.println("Display manager " + (!(Boolean) newData ? "enabled" : "disabled"));
                //               geometryOperation.setOperationDataListenerEnabled(!(Boolean) newData);
                //               integrationOperation.setOperationDataListenerEnabled(!(Boolean) newData);
                //               plotOperation.setOperationDataListenerEnabled(!(Boolean) newData);
            }
        }

    };
    isInLoopTuner.addVarPortListener(applyToAllListener);
}

From source file:com.epiq.bitshark.ui.FrequencyDomainPanel.java

/**
 * Initialize the graph/* www  .jav a  2 s  .c  o  m*/
 */
private void initGraph() {

    this.series = new BasicSeries("FFT");
    XYSeriesCollection dataset = new XYSeriesCollection(series);

    JFreeChart graph = ChartFactory.createXYLineChart(null, // title
            "", // no x-axis label
            "", // no y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // no legend
            false, // no tooltips
            false // no URLs
    );

    graph.setBorderVisible(false);
    graph.setPadding(new RectangleInsets(-5, 0, 0, 0));
    graph.setBackgroundPaint(null);
    graph.setBackgroundImageAlpha(0.0f);
    graph.setAntiAlias(true);

    plot = (XYPlot) graph.getPlot();

    powerAxis = new PowerAxis();
    plot.setRangeAxis(powerAxis);

    frequencyAxis = new FrequencyAxis();
    frequencyAxis.setTickLabelInsets(new RectangleInsets(10, 0, 0, 0));
    plot.setDomainAxis(frequencyAxis);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setBaseShapesFilled(true);
        renderer.setSeriesPaint(0, Common.EPIQ_GREEN);
        renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    }

    plot.setBackgroundAlpha(0.0f);
    plot.setBackgroundPaint(null);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));

    // X-axis setup
    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setVisible(true);
    plot.getDomainAxis().setRange(0, FMCUartClient.BLOCK_SIZE - 1);
    plot.setDomainCrosshairVisible(false);
    plot.setDomainCrosshairPaint(new Color(46, 46, 46));

    // Y-axis setup
    plot.getRangeAxis().setAutoRange(false);
    plot.getRangeAxis().setVisible(true);
    plot.getRangeAxis().setRange(-50, 70);
    plot.setRangeCrosshairVisible(false);

    markerAnnotation.setVisible(false);
    plot.addAnnotation(markerAnnotation);
    plot.addAnnotation(markerTextAnnotation);

    this.markerTitle.setFont(new Font("Tahoma", Font.BOLD, 12));
    this.markerTitle.setFrame(new BlockBorder(new Color(46, 46, 46)));
    this.markerTitle.setBackgroundPaint(new Color(200, 200, 255, 100));
    this.markerTitle.setText("");
    this.markerTitle.setPadding(5, 15, 5, 15);
    this.markerTitle.setExpandToFitSpace(false);
    this.markerTitle.setBounds(new Rectangle2D.Double(0, 0, 100, 30));

    chartPanel = new ChartPanel(graph, false);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMouseZoomable(true);
    chartPanel.setOpaque(false);

    chartPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            markerLocked = !markerLocked;
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            updateMouseMarker(event);
        }

    });

    chartPanel.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
            if (!markerLocked) {
                markerAnnotation.setVisible(false);
                plot.setDomainCrosshairVisible(false);
                markerTitle.setVisible(false);
                markerTitle.setText("");
            }
        }

    });

    chartPanel.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            int clicks = e.getWheelRotation();
            plot.getRangeAxis().setUpperBound(plot.getRangeAxis().getUpperBound() + clicks);
            plot.getRangeAxis().setLowerBound(plot.getRangeAxis().getLowerBound() + clicks);
        }
    });

}

From source file:org.talend.dataprofiler.chart.TOPChartService.java

@Override
public void addMouseListenerForConceptChart(Object chartComposite, final Map<String, Object> actionMap) {
    final ChartComposite chartComp = (ChartComposite) chartComposite;
    final ChartMouseListener listener = new ChartMouseListener() {

        @Override/*from w  ww  .j  a v  a 2s .  c  o  m*/
        public void chartMouseClicked(ChartMouseEvent event) {
            boolean flag = event.getTrigger().getButton() == MouseEvent.BUTTON1;
            chartComp.setDomainZoomable(flag);
            chartComp.setRangeZoomable(flag);
            if (!flag) {
                return;
            }

            ChartEntity chartEntity = event.getEntity();
            if (chartEntity != null && chartEntity instanceof CategoryItemEntity) {
                CategoryItemEntity cateEntity = (CategoryItemEntity) chartEntity;
                // highlight current selected bar
                Plot plot = event.getChart().getPlot();
                if (plot != null) {
                    // ((CategoryPlot) plot).getRenderer().setSeriesPaint(cateEntity.getSeries(), Green);
                    CustomConceptRenderer render = new CustomConceptRenderer(cateEntity.getCategoryIndex());
                    render.setShadowVisible(false);
                    render.setDrawBarOutline(false);
                    ((CategoryPlot) plot).setRenderer(render);
                    // ChartDecorator.decorateConceptChart(event.getChart(), PlotOrientation.HORIZONTAL);

                }
                Object action = getCurrentAction(cateEntity);
                Class<? extends Object> actionClass = action.getClass();
                try {
                    Method actionRunMethod = actionClass.getDeclaredMethod("run"); //$NON-NLS-1$
                    actionRunMethod.invoke(action);

                } catch (NoSuchMethodException e) {
                    log.error(e, e);
                } catch (SecurityException e) {
                    log.error(e, e);
                } catch (IllegalAccessException e) {
                    log.error(e, e);
                } catch (IllegalArgumentException e) {
                    log.error(e, e);
                } catch (InvocationTargetException e) {
                    log.error(e, e);
                }

            }
        }

        private Object getCurrentAction(CategoryItemEntity cateEntity) {
            return findCurrentAction(cateEntity.getColumnKey(), cateEntity.getRowKey());
        }

        /**
         * Find current action
         * 
         * @param firstKey
         * @param secondKey
         * @return
         */
        private Object findCurrentAction(final Object firstKey, Object secondKey) {
            Object action = actionMap.get(firstKey);
            if (action != null) {
                return action;
            }
            action = actionMap.get(secondKey);
            if (action != null) {
                return action;
            }
            return null;
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            // no action here

        }

    };
    chartComp.addChartMouseListener(listener);
    chartComp.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            chartComp.removeChartMouseListener(listener);
            chartComp.dispose();
        }

    });
}

From source file:com.bwc.ora.views.LrpDisplayFrame.java

private ChartMouseListener getMovementChartMouseListener(HighlightXYRenderer renderer) {
    return new ChartMouseListener() {

        @Override/*from   w w w .  j  ava 2s.  co m*/
        public void chartMouseClicked(ChartMouseEvent cme) {
            //do nothing
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            ChartEntity entity = cme.getEntity();
            if (!(entity instanceof XYItemEntity)) {
                renderer.setHighlightedItem(-1, -1);
                octDrawnPointsCollection.clear();
            } else {
                XYItemEntity xyent = (XYItemEntity) entity;
                renderer.setHighlightedItem(xyent.getSeriesIndex(), xyent.getItem());
                int x = lrps.getSelectedValue().getLrpCenterXPosition();
                //get the Y value of the item on the LRP (in the case of
                // the graph this is the X value since the orientation of the plot is flipped)
                int y = (int) Math.round(xyent.getDataset().getXValue(xyent.getSeriesIndex(), xyent.getItem()));
                octDrawnPointsCollection.add(new OctDrawnPoint("Peak", new Point(x, y)));
            }
        }

    };
}