use of org.jfree.chart.ChartMouseEvent in project cubrid-manager by CUBRID.
the class WhiteChart method loadChart.
public void loadChart() {
ChartComposite frame;
if (groupName != null) {
final Group chartGroup = new Group(composite, SWT.RESIZE);
chartGroup.setText(groupName);
GridLayout chartGroupLayout = new GridLayout();
chartGroupLayout.marginHeight = 6;
chartGroupLayout.marginWidth = 6;
chartGroup.setLayout(chartGroupLayout);
chartGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
frame = new ChartComposite(chartGroup, SWT.NONE, createChart(), false, false, false, false, false);
} else {
frame = new ChartComposite(composite, SWT.NONE, createChart(), false, false, false, false, false);
}
GridData gdFrame = new GridData(SWT.FILL, SWT.FILL, true, true);
frame.setLayoutData(gdFrame);
frame.setLayout(new FillLayout());
frame.setDomainZoomable(false);
frame.setRangeZoomable(false);
frame.addChartMouseListener(new ChartMouseListener() {
public void chartMouseMoved(ChartMouseEvent event) {
}
public void chartMouseClicked(ChartMouseEvent event) {
if (event.getTrigger().getButton() == 1) {
editor.openEditStatisticItemDialog();
}
}
});
}
use of org.jfree.chart.ChartMouseEvent in project tdq-studio-se by Talend.
the class TOPChartService method addListenerToChartComp.
@Override
public void addListenerToChartComp(Object chartComposite, final String referenceLink, final String menuText) {
final ChartComposite chartComp = (ChartComposite) chartComposite;
final ChartMouseListener listener = new ChartMouseListener() {
@Override
public void chartMouseClicked(ChartMouseEvent event) {
if (event.getTrigger().getButton() == 1 && referenceLink != null) {
Menu menu = new Menu(chartComp.getShell(), SWT.POP_UP);
chartComp.setMenu(menu);
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(menuText);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ChartUtils.openReferenceLink(referenceLink);
}
});
menu.setVisible(true);
}
}
@Override
public void chartMouseMoved(ChartMouseEvent event) {
// no need to implement
}
};
chartComp.addChartMouseListener(listener);
chartComp.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
chartComp.removeChartMouseListener(listener);
chartComp.dispose();
}
});
}
use of org.jfree.chart.ChartMouseEvent 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.chart.ChartMouseEvent 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.chart.ChartMouseEvent in project Course_Generator by patrovite.
the class JPanelAnalysisSpeed method initComponents.
private void initComponents() {
setLayout(new java.awt.BorderLayout());
// //-- Left - Toolbar
// Create_Toolbar();
// add(toolBar, java.awt.BorderLayout.WEST);
//
// -- Bottom - Info
jPanelSpeedInfo = new javax.swing.JPanel();
jPanelSpeedInfo.setOpaque(true);
jPanelSpeedInfo.setBackground(Color.WHITE);
jPanelSpeedInfo.setLayout(new GridBagLayout());
add(jPanelSpeedInfo, java.awt.BorderLayout.SOUTH);
// -- Start speed/End speed/Speed/Distance
// -- Start speed
lbSpeedInfoStartSpeed = new javax.swing.JLabel();
lbSpeedInfoStartSpeed.setOpaque(true);
lbSpeedInfoStartSpeed.setBackground(Color.WHITE);
lbSpeedInfoStartSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoStartSpeed.text") + "=0km/h ");
lbSpeedInfoStartSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Utils.addComponent(jPanelSpeedInfo, lbSpeedInfoStartSpeed, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
// -- End speed
lbSpeedInfoEndSpeed = new javax.swing.JLabel();
lbSpeedInfoEndSpeed.setOpaque(true);
lbSpeedInfoEndSpeed.setBackground(Color.WHITE);
lbSpeedInfoEndSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoEndSpeed.text") + "=0km/h ");
lbSpeedInfoEndSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Utils.addComponent(jPanelSpeedInfo, lbSpeedInfoEndSpeed, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
// -- Speed
lbSpeedInfoSpeed = new javax.swing.JLabel();
lbSpeedInfoSpeed.setOpaque(true);
lbSpeedInfoSpeed.setBackground(Color.WHITE);
lbSpeedInfoSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoSpeed.text") + "=0km/h ");
lbSpeedInfoSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Utils.addComponent(jPanelSpeedInfo, lbSpeedInfoSpeed, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
// -- Distance
lbSpeedInfoDistance = new javax.swing.JLabel();
lbSpeedInfoDistance.setOpaque(true);
lbSpeedInfoDistance.setBackground(Color.WHITE);
lbSpeedInfoDistance.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoDistance.text") + "=0.000km ");
lbSpeedInfoDistance.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Utils.addComponent(jPanelSpeedInfo, lbSpeedInfoDistance, 3, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL);
// -- Chart Speed/Dist & Time/Dist
ChartPanelSpeed = new ChartPanel(chart, true, /* Properties */
true, /* save */
true, /* print */
false, /* zoom */
true);
ChartPanelSpeed.setDomainZoomable(false);
ChartPanelSpeed.setRangeZoomable(false);
CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
xCrosshair = new Crosshair(Double.NaN, Color.RED, new BasicStroke(0f));
xCrosshair.setLabelBackgroundPaint(Color.WHITE);
crosshairOverlay.addDomainCrosshair(xCrosshair);
ChartPanelSpeed.addOverlay(crosshairOverlay);
ChartPanelSpeed.setBackground(new java.awt.Color(255, 0, 51));
ChartPanelSpeed.addChartMouseListener(new ChartMouseListener() {
@Override
public void chartMouseClicked(ChartMouseEvent event) {
ChartEntity chartentity = event.getEntity();
if (chartentity instanceof XYItemEntity) {
XYItemEntity e = (XYItemEntity) chartentity;
XYDataset d = e.getDataset();
int s = e.getSeriesIndex();
int i = e.getItem();
double x = d.getXValue(s, i);
xCrosshair.setValue(x);
RefreshInfo(i);
}
}
@Override
public void chartMouseMoved(ChartMouseEvent event) {
}
});
add(ChartPanelSpeed, java.awt.BorderLayout.CENTER);
}
Aggregations