/** * DisplacementGUI.java * * --Copyright notice-- * * Copyright (c) School of Geography, University of Leeds. * http://www.geog.leeds.ac.uk/ * This software is licensed under 'The Artistic License' which can be found at * the Open Source Initiative website at... * http://www.opensource.org/licenses/artistic-license.php * Please note that the optional Clause 8 does not apply to this code. * * The Standard Version source code, and associated documentation can be found at... * [online] http://www.ccg.leeds.ac.uk/software/ * * --End of Copyright notice-- * **/ package uk.ac.leeds.ccg.boundarytypeanalyst; import java.awt.Label; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; import javax.swing.SpringLayout; /** * Non-modal dialog to get displacement distances for DisplayTypes tool. *
* ToDo: Needs internationalising with setup in DisplayTypes. * ToDo: Needs GridbagLayout. * ToDo: Needs modalising, if possible. * @author Andrew Evans * @version 0.1 */ public class DisplacementGUI extends JFrame { private JSpinner xSpinner = null; private JSpinner ySpinner = null; /** * Constructor just builds it. * @param parent */ public DisplacementGUI(DisplayTypes parent) { super("Displacement"); setSize(270,130); setLocation(300,300); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); JPanel panel = new JPanel(); SpinnerModel xModel = new SpinnerNumberModel(new Double(0.01), new Double(0.01), new Double(1000000.0), new Double(0.01)); SpinnerModel yModel = new SpinnerNumberModel(new Double(0.01), new Double(0.01), new Double(1000000.0), new Double(0.01)); JLabel xLabel = new JLabel("X Displacement (m)"); panel.add(xLabel); xSpinner = new JSpinner(xModel); xLabel.setLabelFor(xSpinner); panel.add(xSpinner); JLabel yLabel = new JLabel("Y Displacement (m)"); panel.add(yLabel); ySpinner = new JSpinner(yModel); yLabel.setLabelFor(ySpinner); panel.add(ySpinner); JButton ok = new JButton("Displace"); ok.addActionListener(parent); JButton cancel = new JButton("Finished"); cancel.addActionListener(parent); panel.add(ok); panel.add(cancel); add(panel); } /** * Gets the current x-value. * Note that non-int values go to == 1. * @return x value */ public double getXValue() { return ((Double) xSpinner.getValue()).doubleValue(); } /** * Gets the current y-value. * Note that non-int values go to == 1. * @return y value */ public double getYValue() { return ((Double) ySpinner.getValue()).doubleValue(); } }