use of org.jfree.chart.plot.Crosshair in project Course_Generator by patrovite.
the class frmEditCurve method initComponents.
/**
* This method is called to initialize the form.
*/
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(bundle.getString("frmEditCurve.title"));
setPreferredSize(new Dimension(1200, 600));
setAlwaysOnTop(true);
setResizable(false);
setType(java.awt.Window.Type.UTILITY);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
// -- Layout
// ------------------------------------------------------------
Container paneGlobal = getContentPane();
paneGlobal.setLayout(new GridBagLayout());
// -- Curves list
ListCurves = new javax.swing.JList<>();
model = new ParamListModel();
ListCurves.setModel(model);
ListCurves.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
ListCurves.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
SelectCurve();
}
});
jScrollPaneCurves = new javax.swing.JScrollPane();
jScrollPaneCurves.setViewportView(ListCurves);
Utils.addComponent(paneGlobal, jScrollPaneCurves, 0, 0, 1, 4, 0.5, 1, 10, 10, 0, 0, GridBagConstraints.PAGE_START, GridBagConstraints.BOTH);
// -- Curve management toolbar
CreateCurvesToolbar();
Utils.addComponent(paneGlobal, ToolBarAction, 1, 0, 1, 4, 0, 0, 10, 0, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
lbSelectedCurve = new javax.swing.JLabel();
lbSelectedCurve.setBorder(javax.swing.BorderFactory.createEtchedBorder());
lbSelectedCurve.setText("Selected");
lbSelectedCurve.setHorizontalAlignment(JLabel.LEFT);
Utils.addComponent(paneGlobal, lbSelectedCurve, 2, 0, GridBagConstraints.REMAINDER, 1, 1, 0, 10, 0, 5, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
// -- Curve name
lbName = new javax.swing.JLabel();
lbName.setBorder(javax.swing.BorderFactory.createEtchedBorder());
lbName.setText(" " + bundle.getString("frmEditCurve.lbName.text") + " ");
Utils.addComponent(paneGlobal, lbName, 2, 1, 1, 1, 0, 0, 0, 0, 5, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
lbNameVal = new javax.swing.JLabel();
lbNameVal.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Utils.addComponent(paneGlobal, lbNameVal, 3, 1, GridBagConstraints.REMAINDER, 1, 1, 0, 0, 5, 5, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
// -- Curve comment
lbComment = new javax.swing.JLabel();
lbComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
lbComment.setText(" " + bundle.getString("frmEditCurve.lbComment.text") + " ");
Utils.addComponent(paneGlobal, lbComment, 2, 2, 1, 1, 0, 0, 0, 0, 5, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
tfComment = new JTextField();
tfComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Utils.addComponent(paneGlobal, tfComment, 3, 2, GridBagConstraints.REMAINDER, 1, 1, 0, 0, 5, 5, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
// -- Point list
TablePoints = new javax.swing.JTable();
// new ParamPointsModel(param));
TablePoints.setModel(tablemodel);
TablePoints.getTableHeader().setReorderingAllowed(false);
TablePoints.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
// TableMainMouseClicked(evt);
// TODO
}
});
TablePoints.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
// TableMainKeyReleased(evt);
// TODO
}
});
TablePoints.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent event) {
btEditLine.setEnabled(TablePoints.getSelectedRow() > 0);
}
});
jScrollPanePoint = new javax.swing.JScrollPane();
jScrollPanePoint.setViewportView(TablePoints);
Utils.addComponent(paneGlobal, jScrollPanePoint, 2, 3, 2, 1, 0.5, 0, 0, 0, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
// -- Edit toolbar
CreateEditToolbar();
Utils.addComponent(paneGlobal, ToolBarEdit, 4, 3, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
jPanelProfilChart = new ChartPanel(chart);
Utils.addComponent(paneGlobal, jPanelProfilChart, 5, 3, 1, 1, 1, 0, 0, 0, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
xCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
xCrosshair.setLabelVisible(true);
xCrosshair.setLabelBackgroundPaint(Color.WHITE);
yCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
yCrosshair.setLabelVisible(true);
yCrosshair.setLabelBackgroundPaint(Color.WHITE);
crosshairOverlay.addDomainCrosshair(xCrosshair);
crosshairOverlay.addRangeCrosshair(yCrosshair);
jPanelProfilChart.addOverlay(crosshairOverlay);
jPanelProfilChart.setBackground(new java.awt.Color(255, 0, 51));
jPanelProfilChart.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);
double y = d.getYValue(s, i);
xCrosshair.setValue(x);
yCrosshair.setValue(y);
}
}
@Override
public void chartMouseMoved(ChartMouseEvent event) {
}
});
// == Bottom button
// ===========================================================
btOk = new javax.swing.JButton();
btOk.setText(bundle.getString("Global.btOk.text"));
btOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/valid.png")));
btOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RequestToClose();
}
});
Utils.addComponent(paneGlobal, btOk, 0, 5, GridBagConstraints.REMAINDER, 1, 0, 0, 10, 0, 10, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE);
// --
pack();
// -- Refresh the curve list
RefreshCurveList();
// -- Center the windows
setLocationRelativeTo(null);
}
Aggregations