use of com.ramussoft.chart.core.ChartBounds in project ramus by Vitaliy-Yakovchuk.
the class ChartSetView method createComponent.
@Override
public JComponent createComponent() {
final JLabel label = new JLabel(ChartResourceManager.getString("Message.MoveChartToChartSet"));
desktop = new JDesktopPane();
desktop.setTransferHandler(new TransferHandler("") {
/**
*/
private static final long serialVersionUID = 4967256166603971141L;
@Override
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
for (DataFlavor flavor : transferFlavors) {
if (flavor.equals(RowTreeTable.rowsListFlavor)) {
return true;
}
}
return false;
}
@Override
public boolean importData(JComponent comp, Transferable t) {
try {
Rows rows = (Rows) t.getTransferData(RowTreeTable.rowsListFlavor);
if (rows.size() > 0) {
((Journaled) engine).startUserTransaction();
for (Row row : rows) {
Point position = comp.getMousePosition();
if (position == null)
position = new Point(10, 10);
ChartPlugin.addChartLink(engine, element, row.getElement(), position.getX(), position.getY(), 340, 300);
}
}
((Journaled) engine).commitUserTransaction();
return rows.size() > 0;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
});
label.setBackground(desktop.getBackground());
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
List<ChartBounds> bounds = ChartPlugin.getChartBounds(engine, element);
for (ChartBounds cb : bounds) {
final JInternalFrame frame = new JInternalFrame(cb.getChart().getName(), true, true, true, true);
final ChartView chartView = new ChartView(framework, cb.getChart()) {
protected void titleChanged(String newTitle) {
frame.setTitle(newTitle);
reload();
}
};
final ChartBounds b = cb;
frame.setSize((int) cb.getWidth(), (int) cb.getHeight());
frame.setLocation((int) cb.getX(), (int) cb.getY());
frame.setContentPane(chartView.createComponent());
desktop.add(frame);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ChartHolder holder = new ChartHolder(chartView, frame, b.getLink());
holders.add(holder);
}
});
}
return desktop;
}
Aggregations