1 /* 2 * Copyright (c) 2003-2008 by Cosylab d. d. 3 * 4 * This file is part of CosyBeans-Common. 5 * 6 * CosyBeans-Common is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * CosyBeans-Common is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with CosyBeans-Common. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package com.cosylab.gui.components.numberfield; 21 22 /** 23 * Visualize double value in radians by converting it to degrees and displays 24 * it in format XX\u00B0XX'XX\". 25 * 26 * @author <a href="mailto:igor.kriznar@cosylab.com">Igor Kriznar</a> 27 */ 28 public class Rad2DegNumberDescriptor extends AngleNumberDescriptor 29 { 30 /** 31 * @see NumberDescriptor 32 */ 33 public final static String NAME = "Radians as Degrees Visualization"; 34 35 /** 36 * @see NumberDescriptor 37 */ 38 public final static String DESCRIPTION = "Converts double value from radians to degrees and diplays in degree format: XX\u00B0XX'XX\"."; 39 /** 40 * 41 */ 42 public Rad2DegNumberDescriptor() 43 { 44 super(); 45 } 46 47 /** 48 * Constructs a new Rad2DegNumberDescriptor. 49 * 50 * @param full should full format be used 51 * @see #setUseFullFormat(boolean) 52 */ 53 public Rad2DegNumberDescriptor(boolean full) 54 { 55 super(full); 56 } 57 58 /** 59 * Constructs a new Rad2DegNumberDescriptor. 60 * 61 * @param degreeSeparator 62 * @param minuteSeparator 63 * @param secondSeparator 64 */ 65 public Rad2DegNumberDescriptor(char degreeSeparator, char minuteSeparator, 66 char secondSeparator) 67 { 68 super(degreeSeparator, minuteSeparator, secondSeparator); 69 } 70 71 /** 72 * Constructs a new Rad2DegNumberDescriptor. 73 * 74 * @param degreeSeparator 75 * @param minuteSeparator 76 * @param secondSeparator 77 * @param full should full format be used 78 * @see #setUseFullFormat(boolean) 79 */ 80 public Rad2DegNumberDescriptor(char degreeSeparator, char minuteSeparator, 81 char secondSeparator, boolean full) 82 { 83 super(degreeSeparator, minuteSeparator, secondSeparator, full); 84 } 85 86 /* (non-Javadoc) 87 * @see com.cosylab.gui.components.numberfield.AngleNumberDescriptor#printString(java.lang.Number) 88 */ 89 public String printString(Number number) 90 { 91 return super.printString(new Double(Math.toDegrees(number.doubleValue()))); 92 } 93 94 /* (non-Javadoc) 95 * @see com.cosylab.gui.components.numberfield.AngleNumberDescriptor#parseNumber(java.lang.String) 96 */ 97 public Number parseNumber(String number) 98 { 99 Number n = super.parseNumber(number); 100 101 if (n == null) { 102 return n; 103 } 104 105 return new Double(Math.toRadians(n.doubleValue())); 106 } 107 } 108 109 /* __oOo__ */