Search in sources :

Example 21 with ChartComposite

use of org.jfree.experimental.chart.swt.ChartComposite in project tdq-studio-se by Talend.

the class TOPChartService method createChartCompositeWithSpecialSize.

@Override
public Object createChartCompositeWithSpecialSize(Object composite, int style, Object chart, boolean useBuffer, int height, int width) {
    ChartComposite cc = new ChartComposite((Composite) composite, style, (JFreeChart) chart, useBuffer);
    GridData gd = new GridData();
    gd.widthHint = width;
    gd.heightHint = height;
    cc.setLayoutData(gd);
    return cc;
}
Also used : TalendChartComposite(org.talend.dataprofiler.chart.util.TalendChartComposite) ChartComposite(org.jfree.experimental.chart.swt.ChartComposite) GridData(org.eclipse.swt.layout.GridData)

Example 22 with ChartComposite

use of org.jfree.experimental.chart.swt.ChartComposite in project tdq-studio-se by Talend.

the class TOPChartService method addSpecifiedListenersForCorrelationChart.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.service.ITOPChartService#addSpecifiedListenersForCorrelationChart(boolean, boolean,
     * java.lang.Object, java.util.List)
     */
@Override
public void addSpecifiedListenersForCorrelationChart(Object chartcomp, final Object chart, final boolean isAvg, final boolean isDate, final Map<Integer, Object> keyWithAdapter) {
    final ChartComposite chartComp = (ChartComposite) chartcomp;
    chartComp.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            chartComp.setRangeZoomable(event.getTrigger().getButton() == 1);
            chartComp.setDomainZoomable(event.getTrigger().getButton() == 1);
            if (event.getTrigger().getButton() != 3) {
                return;
            }
            final Menu menu = new Menu(chartComp.getShell(), SWT.POP_UP);
            MenuItem itemShowInFullScreen = new MenuItem(menu, SWT.PUSH);
            // $NON-NLS-1$
            itemShowInFullScreen.setText(Messages.getString("HideSeriesChartComposite.ShowInFullScreen"));
            itemShowInFullScreen.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    Display.getDefault().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            showChartInFillScreen(chart, isAvg, isDate);
                        }
                    });
                }
            });
            chartComp.setMenu(menu);
            ChartEntity chartEntity = event.getEntity();
            if (chartEntity != null) {
                if (isAvg) {
                    addMenuOnBubbleChart(menu, chartEntity);
                } else if (isDate) {
                    addMenuOnGantChart(menu, chartEntity);
                }
            }
            menu.setVisible(true);
        }

        private void addMenuOnBubbleChart(Menu menu, ChartEntity chartEntity) {
            if (chartEntity instanceof XYItemEntity) {
                XYItemEntity xyItemEntity = (XYItemEntity) chartEntity;
                createMenuItem(menu, xyItemEntity.getItem());
            }
        }

        private void addMenuOnGantChart(Menu menu, ChartEntity chartEntity) {
            if (chartEntity instanceof CategoryItemEntity) {
                CategoryItemEntity itemEntity = (CategoryItemEntity) chartEntity;
                createMenuItem(menu, itemEntity.getCategoryIndex());
            }
        }

        private void createMenuItem(Menu menu, final int seriesK) {
            final SelectionAdapter selectionAdapter = (SelectionAdapter) keyWithAdapter.get(seriesK);
            MenuItem item;
            item = new MenuItem(menu, SWT.PUSH);
            // $NON-NLS-1$
            item.setText(Messages.getString("HideSeriesChartComposite.ViewRow"));
            item.addSelectionListener(selectionAdapter);
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        // no need to implement
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) ChartMouseListener(org.jfree.chart.ChartMouseListener) XYItemEntity(org.jfree.chart.entity.XYItemEntity) TalendChartComposite(org.talend.dataprofiler.chart.util.TalendChartComposite) ChartComposite(org.jfree.experimental.chart.swt.ChartComposite) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) ChartEntity(org.jfree.chart.entity.ChartEntity) CategoryItemEntity(org.jfree.chart.entity.CategoryItemEntity)

Example 23 with ChartComposite

use of org.jfree.experimental.chart.swt.ChartComposite in project tdq-studio-se by Talend.

the class TOPChartService method addMouseListenerForConceptChart.

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

        @Override
        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 {
                    // $NON-NLS-1$
                    Method actionRunMethod = actionClass.getDeclaredMethod("run");
                    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();
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) XYPlot(org.jfree.chart.plot.XYPlot) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Plot(org.jfree.chart.plot.Plot) Method(java.lang.reflect.Method) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) CategoryPlot(org.jfree.chart.plot.CategoryPlot) InvocationTargetException(java.lang.reflect.InvocationTargetException) ChartMouseListener(org.jfree.chart.ChartMouseListener) TalendChartComposite(org.talend.dataprofiler.chart.util.TalendChartComposite) ChartComposite(org.jfree.experimental.chart.swt.ChartComposite) ChartEntity(org.jfree.chart.entity.ChartEntity) CategoryItemEntity(org.jfree.chart.entity.CategoryItemEntity)

Example 24 with ChartComposite

use of org.jfree.experimental.chart.swt.ChartComposite in project tdq-studio-se by Talend.

the class TOPChartService method createChartCompositeWithFull.

@Override
public Object createChartCompositeWithFull(Object composite, Object chart) {
    ChartComposite chartComp = new ChartComposite((Composite) composite, SWT.NONE, (JFreeChart) chart, true);
    chartComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    return chartComp;
}
Also used : TalendChartComposite(org.talend.dataprofiler.chart.util.TalendChartComposite) ChartComposite(org.jfree.experimental.chart.swt.ChartComposite) GridData(org.eclipse.swt.layout.GridData)

Example 25 with ChartComposite

use of org.jfree.experimental.chart.swt.ChartComposite in project SIMVA-SoS by SESoS.

the class SWTTimeSeriesDemo method main.

/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.
 */
public static void main(String[] args) {
    final JFreeChart chart = createChart(createDataset());
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 300);
    shell.setLayout(new FillLayout());
    shell.setText("Time series demo for jfreechart running with SWT");
    ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    frame.setDisplayToolTips(true);
    frame.setHorizontalAxisTrace(false);
    frame.setVerticalAxisTrace(false);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
Also used : ChartComposite(org.jfree.experimental.chart.swt.ChartComposite) Shell(org.eclipse.swt.widgets.Shell) FillLayout(org.eclipse.swt.layout.FillLayout) JFreeChart(org.jfree.chart.JFreeChart) Display(org.eclipse.swt.widgets.Display)

Aggregations

ChartComposite (org.jfree.experimental.chart.swt.ChartComposite)25 GridData (org.eclipse.swt.layout.GridData)17 FillLayout (org.eclipse.swt.layout.FillLayout)11 JFreeChart (org.jfree.chart.JFreeChart)9 TalendChartComposite (org.talend.dataprofiler.chart.util.TalendChartComposite)8 ChartMouseEvent (org.jfree.chart.ChartMouseEvent)7 ChartMouseListener (org.jfree.chart.ChartMouseListener)7 Display (org.eclipse.swt.widgets.Display)4 Group (org.eclipse.swt.widgets.Group)4 Shell (org.eclipse.swt.widgets.Shell)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)3 DisposeListener (org.eclipse.swt.events.DisposeListener)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Menu (org.eclipse.swt.widgets.Menu)3 CategoryItemEntity (org.jfree.chart.entity.CategoryItemEntity)3 ChartEntity (org.jfree.chart.entity.ChartEntity)3 Color (java.awt.Color)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2