r1383 - trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial
Author: tchemit Date: 2013-11-25 00:19:42 +0100 (Mon, 25 Nov 2013) New Revision: 1383 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1383 Log: remove coordinate tests Removed: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateEditorTest.java trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateTest.java trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmsCoordinateEditorTest.java Deleted: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateEditorTest.java =================================================================== --- trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateEditorTest.java 2013-11-24 23:16:26 UTC (rev 1382) +++ trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateEditorTest.java 2013-11-24 23:19:42 UTC (rev 1383) @@ -1,216 +0,0 @@ -package fr.ifremer.tutti.ui.swing.spatial; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.beans.AbstractSerializableBean; - -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import javax.swing.border.TitledBorder; -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.text.ParseException; - -/** - * To test the {@link DmsCoordinateEditor}. - * <p/> - * Created on 10/17/13. - * - * @author Tony Chemit <chemit@codelutin.com> - * @since 2.8 - */ -public class DmdCoordinateEditorTest { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(DmdCoordinateEditorTest.class); - - public static class EditorBean extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_LONGITUDE_SIGN = "longitudeSign"; - - public static final String PROPERTY_LONGITUDE_DEGREE = "longitudeDegree"; - - public static final String PROPERTY_LONGITUDE_MINUTE = "longitudeMinute"; - - public static final String PROPERTY_LONGITUDE_DECIMAL = "longitudeDecimal"; - - public static final String PROPERTY_LATITUDE_SIGN = "latitudeSign"; - - public static final String PROPERTY_LATITUDE_DEGREE = "latitudeDegree"; - - public static final String PROPERTY_LATITUDE_MINUTE = "latitudeMinute"; - - public static final String PROPERTY_LATITUDE_DECIMAL = "latitudeDecimal"; - - protected final DmdCoordinate longitude = DmdCoordinate.empty(); - - protected final DmdCoordinate latitude = DmdCoordinate.empty(); - - public DmdCoordinate getLongitude() { - return longitude; - } - - public void setLongitudeDegree(Integer degre) { - Object oldValue = longitude.getDegree(); - longitude.setDegree(degre); - firePropertyChange(PROPERTY_LONGITUDE_DEGREE, oldValue, degre); - } - - public void setLongitudeMinute(Integer minute) { - Object oldValue = longitude.getMinute(); - longitude.setMinute(minute); - firePropertyChange(PROPERTY_LONGITUDE_MINUTE, oldValue, minute); - } - - public void setLongitudeDecimal(Integer decimal) { - Object oldValue = longitude.getDecimal(); - longitude.setDecimal(decimal); - firePropertyChange(PROPERTY_LONGITUDE_DECIMAL, oldValue, decimal); - } - - public void setLongitudeSign(boolean sign) { - Object oldValue = longitude.isSign(); - longitude.setSign(sign); - firePropertyChange(PROPERTY_LONGITUDE_SIGN, oldValue, sign); - } - - public DmdCoordinate getLatitude() { - return latitude; - } - - public void setLatitudeSign(boolean sign) { - Object oldValue = latitude.isSign(); - latitude.setSign(sign); - firePropertyChange(PROPERTY_LATITUDE_SIGN, oldValue, sign); - } - - public void setLatitudeDegree(Integer degre) { - Object oldValue = latitude.getDegree(); - latitude.setDegree(degre); - firePropertyChange(PROPERTY_LATITUDE_DEGREE, oldValue, degre); - } - - public void setLatitudeMinute(Integer minute) { - Object oldValue = latitude.getMinute(); - latitude.setMinute(minute); - firePropertyChange(PROPERTY_LATITUDE_MINUTE, oldValue, minute); - } - - public void setLatitudeDecimal(Integer decimal) { - Object oldValue = latitude.getDecimal(); - latitude.setDecimal(decimal); - firePropertyChange(PROPERTY_LATITUDE_DECIMAL, oldValue, decimal); - } - - @Override - public String toString() { - return "EditorBean{" + - "longitude=" + longitude + - ", latitude=" + latitude + - '}'; - } - } - - public static void main(String[] args) throws ParseException { - - - EditorBean bean = new EditorBean(); - - DmdCoordinateEditor longitudeEditor = new DmdCoordinateEditor(); - longitudeEditor.setBean(bean); - longitudeEditor.setPropertySign(EditorBean.PROPERTY_LONGITUDE_SIGN); - longitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LONGITUDE_DEGREE); - longitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LONGITUDE_MINUTE); - longitudeEditor.setPropertyDecimal(EditorBean.PROPERTY_LONGITUDE_DECIMAL); - longitudeEditor.setLongitudeEditor(true); - longitudeEditor.setShowReset(true); - longitudeEditor.init(); - - DmdCoordinateEditor latitudeEditor = new DmdCoordinateEditor(); - latitudeEditor.setBean(bean); - latitudeEditor.setPropertySign(EditorBean.PROPERTY_LATITUDE_SIGN); - latitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LATITUDE_DEGREE); - latitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LATITUDE_MINUTE); - latitudeEditor.setPropertyDecimal(EditorBean.PROPERTY_LATITUDE_DECIMAL); - latitudeEditor.setLongitudeEditor(false); - latitudeEditor.setShowReset(true); - latitudeEditor.init(); - - final JLabel latitudeResult = new JLabel(); - final JLabel longitudeResult = new JLabel(); - - bean.addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - EditorBean source = (EditorBean) evt.getSource(); - String propertyName = evt.getPropertyName(); - if (log.isInfoEnabled()) { - log.info("[" + propertyName + "] value changed: " + evt.getNewValue()); - } - if (propertyName.startsWith("longitude")) { - longitudeResult.setText(source.getLongitude().toString()); - } else { - - latitudeResult.setText(source.getLatitude().toString()); - } - } - }); - - JPanel longitudeEditorPanel = new JPanel(new GridLayout()); - longitudeEditorPanel.setBorder(new TitledBorder("Longitude")); - longitudeEditorPanel.add(BorderLayout.CENTER, longitudeEditor); - longitudeEditorPanel.add(BorderLayout.EAST, longitudeResult); - - JPanel latitudeEditorPanel = new JPanel(new GridLayout()); - latitudeEditorPanel.setBorder(new TitledBorder("Latitude")); - latitudeEditorPanel.add(BorderLayout.CENTER, latitudeEditor); - latitudeEditorPanel.add(BorderLayout.EAST, latitudeResult); - - JPanel panel = new JPanel(new GridLayout(0, 1)); - panel.add(longitudeEditorPanel); - panel.add(latitudeEditorPanel); - - final JDialog frame = new JDialog(); - - frame.setContentPane(panel); - - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - frame.setSize(800, 200); - frame.setVisible(true); - } - }); - } -} Deleted: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateTest.java =================================================================== --- trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateTest.java 2013-11-24 23:16:26 UTC (rev 1382) +++ trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmdCoordinateTest.java 2013-11-24 23:19:42 UTC (rev 1383) @@ -1,126 +0,0 @@ -package fr.ifremer.tutti.ui.swing.spatial; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Test; - -/** - * Created on 10/25/13. - * - * @author Tony Chemit <chemit@codelutin.com> - * @since 2.8 - */ -public class DmdCoordinateTest { - - @Test - public void testFromDecimal() throws Exception { - - { - DmdCoordinate actual = DmdCoordinate.empty(); - - actual.fromDecimal(42.7f); - - Integer expectedDegree = 42; - Integer expectedMinute = 42; - Integer expectedDecimal = null; - - Assert.assertEquals(expectedDegree, actual.getDegree()); - Assert.assertEquals(expectedMinute, actual.getMinute()); - Assert.assertEquals(expectedDecimal, actual.getDecimal()); - } - - { - DmdCoordinate actual = DmdCoordinate.empty(); - - float decimalExcepted = 42.707f; - actual.fromDecimal(decimalExcepted); - - Integer expectedDegree = 42; - Integer expectedMinute = 42; - Integer expectedDecimal = 42; - - Assert.assertEquals(expectedDegree, actual.getDegree()); - Assert.assertEquals(expectedMinute, actual.getMinute()); - Assert.assertEquals(expectedDecimal, actual.getDecimal()); - - Float decimal = actual.toDecimal(); - Assert.assertEquals(decimalExcepted, decimal, 0.001); - } - } - - @Test - public void testToDecimal() throws Exception { - - { - DmdCoordinate component = DmdCoordinate.empty(); - component.setDegree(42); - component.setMinute(42); - component.setDecimal(42); - Float actual = component.toDecimal(); - Float expected = 42.707f; - Assert.assertEquals(expected, actual, 0.001); - } - - { - DmdCoordinate component = DmdCoordinate.empty(); - component.setDegree(12); - component.setMinute(12); - Float actual = component.toDecimal(); - Float expected = 12.2f; - Assert.assertEquals(expected, actual, 0.0001); - - component.fromDecimal(expected); - - Integer expectedDegree = 12; - Integer expectedMinute = 12; - Integer expectedDecimal = null; - - Assert.assertEquals(expectedDegree, component.getDegree()); - Assert.assertEquals(expectedMinute, component.getMinute()); - Assert.assertEquals(expectedDecimal, component.getDecimal()); - } - - { - DmdCoordinate component = DmdCoordinate.empty(); - component.setDegree(12); - component.setMinute(12); - component.setDecimal(20); - Float actual = component.toDecimal(); - Float expected = 12.203333f; - Assert.assertEquals(expected, actual, 0.001); - - component.fromDecimal(expected); - - Integer expectedDegree = 12; - Integer expectedMinute = 12; - Integer expectedDecimal = 20; - - Assert.assertEquals(expectedDegree, component.getDegree()); - Assert.assertEquals(expectedMinute, component.getMinute()); - Assert.assertEquals(expectedDecimal, component.getDecimal()); - } - } -} Deleted: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmsCoordinateEditorTest.java =================================================================== --- trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmsCoordinateEditorTest.java 2013-11-24 23:16:26 UTC (rev 1382) +++ trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/spatial/DmsCoordinateEditorTest.java 2013-11-24 23:19:42 UTC (rev 1383) @@ -1,218 +0,0 @@ -package fr.ifremer.tutti.ui.swing.spatial; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.beans.AbstractSerializableBean; - -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import javax.swing.border.TitledBorder; -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.text.ParseException; - -/** - * To test the {@link DmsCoordinateEditor}. - * <p/> - * Created on 10/17/13. - * - * @author Tony Chemit <chemit@codelutin.com> - * @since 2.8 - */ -public class DmsCoordinateEditorTest { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(DmsCoordinateEditorTest.class); - - public static class EditorBean extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_LONGITUDE_SIGN = "longitudeSign"; - - public static final String PROPERTY_LONGITUDE_DEGREE = "longitudeDegree"; - - public static final String PROPERTY_LONGITUDE_MINUTE = "longitudeMinute"; - - public static final String PROPERTY_LONGITUDE_SECOND = "longitudeSecond"; - - public static final String PROPERTY_LATITUDE_SIGN = "latitudeSign"; - - public static final String PROPERTY_LATITUDE_DEGREE = "latitudeDegree"; - - public static final String PROPERTY_LATITUDE_MINUTE = "latitudeMinute"; - - public static final String PROPERTY_LATITUDE_SECOND = "latitudeSecond"; - - protected final DmsCoordinate longitude = DmsCoordinate.empty(); - - protected final DmsCoordinate latitude = DmsCoordinate.empty(); - - public DmsCoordinate getLongitude() { - return longitude; - } - - public void setLongitudeDegre(Integer degre) { - Object oldValue = longitude.getDegree(); - longitude.setDegree(degre); - firePropertyChange(PROPERTY_LONGITUDE_DEGREE, oldValue, degre); - } - - public void setLongitudeMinute(Integer minute) { - Object oldValue = longitude.getMinute(); - longitude.setMinute(minute); - firePropertyChange(PROPERTY_LONGITUDE_MINUTE, oldValue, minute); - } - - public void setLongitudeSecond(Integer seconde) { - Object oldValue = longitude.getSecond(); - - longitude.setSecond(seconde); - firePropertyChange(PROPERTY_LONGITUDE_SECOND, oldValue, seconde); - } - - public void setLongitudeSign(boolean sign) { - Object oldValue = longitude.isSign(); - longitude.setSign(sign); - firePropertyChange(PROPERTY_LONGITUDE_SIGN, oldValue, sign); - } - - public DmsCoordinate getLatitude() { - return latitude; - } - - public void setLatitudeDegre(Integer degre) { - Object oldValue = latitude.getDegree(); - latitude.setDegree(degre); - firePropertyChange(PROPERTY_LATITUDE_DEGREE, oldValue, degre); - } - - public void setLatitudeMinute(Integer minute) { - Object oldValue = latitude.getMinute(); - latitude.setMinute(minute); - firePropertyChange(PROPERTY_LATITUDE_MINUTE, oldValue, minute); - } - - - public void setLatitudeSecond(Integer seconde) { - Object oldValue = latitude.getSecond(); - latitude.setSecond(seconde); - firePropertyChange(PROPERTY_LATITUDE_SECOND, oldValue, seconde); - } - - public void setLatitudeSign(boolean sign) { - Object oldValue = latitude.isSign(); - latitude.setSign(sign); - firePropertyChange(PROPERTY_LATITUDE_SIGN, oldValue, sign); - } - - @Override - public String toString() { - return "EditorBean{" + - "longitude=" + longitude + - ", latitude=" + latitude + - '}'; - } - } - - public static void main(String[] args) throws ParseException { - - - EditorBean bean = new EditorBean(); - - DmsCoordinateEditor longitudeEditor = new DmsCoordinateEditor(); - longitudeEditor.setBean(bean); - longitudeEditor.setPropertySign(EditorBean.PROPERTY_LONGITUDE_SIGN); - longitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LONGITUDE_DEGREE); - longitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LONGITUDE_MINUTE); - longitudeEditor.setPropertySecond(EditorBean.PROPERTY_LONGITUDE_SECOND); - longitudeEditor.setLongitudeEditor(true); - longitudeEditor.setShowReset(true); - longitudeEditor.init(); - - DmsCoordinateEditor latitudeEditor = new DmsCoordinateEditor(); - latitudeEditor.setBean(bean); - latitudeEditor.setPropertySign(EditorBean.PROPERTY_LATITUDE_SIGN); - latitudeEditor.setPropertyDegree(EditorBean.PROPERTY_LATITUDE_DEGREE); - latitudeEditor.setPropertyMinute(EditorBean.PROPERTY_LATITUDE_MINUTE); - latitudeEditor.setPropertySecond(EditorBean.PROPERTY_LATITUDE_SECOND); - latitudeEditor.setLongitudeEditor(false); - latitudeEditor.setShowReset(true); - latitudeEditor.init(); - - final JLabel latitudeResult = new JLabel(); - final JLabel longitudeResult = new JLabel(); - - bean.addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - EditorBean source = (EditorBean) evt.getSource(); - String propertyName = evt.getPropertyName(); - if (log.isInfoEnabled()) { - log.info("[" + propertyName + "] value changed: " + evt.getNewValue()); - } - if (propertyName.startsWith("longitude")) { - longitudeResult.setText(source.getLongitude().toString()); - } else { - - latitudeResult.setText(source.getLatitude().toString()); - } - } - }); - - JPanel longitudeEditorPanel = new JPanel(new GridLayout()); - longitudeEditorPanel.setBorder(new TitledBorder("Longitude")); - longitudeEditorPanel.add(BorderLayout.CENTER, longitudeEditor); - longitudeEditorPanel.add(BorderLayout.EAST, longitudeResult); - - JPanel latitudeEditorPanel = new JPanel(new GridLayout()); - latitudeEditorPanel.setBorder(new TitledBorder("Latitude")); - latitudeEditorPanel.add(BorderLayout.CENTER, latitudeEditor); - latitudeEditorPanel.add(BorderLayout.EAST, latitudeResult); - - JPanel panel = new JPanel(new GridLayout(0, 1)); - panel.add(longitudeEditorPanel); - panel.add(latitudeEditorPanel); - - final JDialog frame = new JDialog(); - - frame.setContentPane(panel); - - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - frame.setSize(800, 200); - frame.setVisible(true); - } - }); - } -}
participants (1)
-
tchemit@users.forge.codelutin.com