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;
}
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
}
});
}
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();
}
});
}
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;
}
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();
}
}
Aggregations