📄 compassdemo.java
字号:
}); this.spinWind.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (DEBUG) { System.out.println("compassDemo:spinWindPropertyChange"); } final Spinner spinner = (Spinner) evt.getSource(); if (spinner.isEnabled()) { compassData.setValue(new Double(spinner.getValue())); } } }); this.jPanel12.setLayout(this.gridLayout2); this.jPanel2.setBorder(this.titledBorder1); this.jPanel2.setLayout(this.gridBagLayout2); this.jPanel1.setBorder(this.titledBorder2); this.jPanel1.setLayout(this.gridBagLayout1); this.titledBorder1.setTitle("Second Pointer"); this.titledBorder2.setTitle("First Pointer"); this.titledBorder3.setTitle("Plot Options"); this.pick2Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick2PointerActionPerformed(e); } }); this.pick1Pointer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final ActionEvent e) { pick1PointerActionPerformed(e); } }); add(this.panelCompassHolder, null); this.panelCompassHolder.add(this.jPanel12, BorderLayout.SOUTH); this.jPanel12.add(this.jPanel1, null); this.jPanel1.add(this.pick1Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.windNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel1.add(this.spinWind, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel12.add(this.jPanel2, null); this.jPanel2.add(this.pick2Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.shipNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); this.jPanel2.add(this.spinShip, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.panelCompassHolder.add(this.panelCompass, BorderLayout.CENTER); } /** * Entry point for the demo application. * * @param args ignored. */ public static void main(final String[] args) { final CompassDemo panel = new CompassDemo(); final JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout(5, 5)); frame.setDefaultCloseOperation(3); frame.setTitle("Compass Demo"); frame.getContentPane().add(panel, BorderLayout.CENTER); frame.setSize(700, 400); final Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); frame.setVisible(true); } // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** /** * Updates the data. * * @param value the value. */ public void adjustData(final double value) { final Number val = this.compassData.getValue(); double newVal = value; if (val != null) { newVal += val.doubleValue(); } if (newVal > 360) { newVal = 0; } if (newVal < 0) { newVal = 360; } this.compassData.setValue(new Double(newVal)); } /** * Handles an action event. * * @param e the event. */ void checkWindNullActionPerformed(final ActionEvent e) { if (CompassDemo.DEBUG) { System.out.println("CompassDemo:checkWindNull: " + this.windNullCheckBox.isSelected()); } if (this.windNullCheckBox.isSelected()) { this.compassData.setValue(null); this.spinWind.setEnabled(false); } else { // compassData.setValue((new Double(((Integer)spinWind.getValue()).intValue()))); this.compassData.setValue(new Double(this.spinWind.getValue())); this.spinWind.setEnabled(true); } if (CompassDemo.DEBUG) { System.out.println("CompassDemo:checkWindNull: " + this.compassData.getValue()); } } /** * Handles an action event. * * @param e the event. */ void checkShipNullActionPerformed(final ActionEvent e) { if (CompassDemo.DEBUG) { System.out.println("CompassDemo:checkShipNull: " + this.shipNullCheckBox.isSelected()); } if (this.shipNullCheckBox.isSelected()) { this.shipData.setValue(null); this.spinShip.setEnabled(false); } else { // shipData.setValue((new Double(((Integer)spinShip.getValue()).intValue()))); this.shipData.setValue(new Double(this.spinShip.getValue())); this.spinShip.setEnabled(true); } } /** * Handles an action event. * * @param e the event. */ void pick2PointerActionPerformed(final ActionEvent e) { if (CompassDemo.DEBUG) { System.out.println("compassDemo:pick2PointActionPerformed " + e.getActionCommand() + ","); } this.compassPlot.setSeriesNeedle(1, this.pick2Pointer.getSelectedIndex()); this.compassPlot.setSeriesPaint(1, Color.red); this.compassPlot.setSeriesOutlinePaint(1, Color.red); } /** * Handles an action event. * * @param e the event. */ void pick1PointerActionPerformed(final ActionEvent e) { if (CompassDemo.DEBUG) { System.out.println("compassDemo:pick1PointActionPerformed " + e.getActionCommand() + ","); } this.compassPlot.setSeriesNeedle(0, this.pick1Pointer.getSelectedIndex()); this.compassPlot.setSeriesPaint(0, Color.blue); this.compassPlot.setSeriesOutlinePaint(0, Color.blue); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -