PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/src/net/aerith/misao/util/star/CatalogStar.java

https://github.com/jankotek/Pixy2
Java | 459 lines | 198 code | 49 blank | 212 comment | 51 complexity | 3f7c01898f6f909da709618b30c8ff84 MD5 | raw file
  1. /*
  2. * @(#)CatalogStar.java
  3. *
  4. * Copyright (C) 1997-2007 Seiichi Yoshida
  5. * All rights reserved.
  6. */
  7. package net.aerith.misao.util.star;
  8. import java.util.Vector;
  9. import net.aerith.misao.util.*;
  10. import net.aerith.misao.catalog.*;
  11. import net.aerith.misao.gui.PlotProperty;
  12. /**
  13. * The <code>CatalogStar</code> represents a star data in catalog.
  14. * This is the base class of subclasses in
  15. * <code>net.aerith.misao.catalog.star</code> package.
  16. *
  17. * @author Seiichi Yoshida (comet@aerith.net)
  18. * @version 2003 April 29
  19. */
  20. public abstract class CatalogStar extends Star {
  21. /**
  22. * True if this object contains all data required for detailed
  23. * format. If false, this can be output only in reduced format.
  24. */
  25. protected boolean detailed_output = true;
  26. /**
  27. * Sets the name of this star.
  28. * @param name the name to set.
  29. */
  30. public void setName ( String name ) {
  31. }
  32. /**
  33. * Gets the name of the catalog. It must be unique among all
  34. * subclasses.
  35. * @return the name of the catalog.
  36. */
  37. public String getCatalogName ( ) {
  38. return "";
  39. }
  40. /**
  41. * Gets the acronym of the catalog.
  42. * @return the acronym of the catalog.
  43. */
  44. public String getCatalogAcronym ( ) {
  45. return "";
  46. }
  47. /**
  48. * Gets the code of the catalog. It must be unique among all
  49. * subclasses.
  50. * @return the code of the catalog.
  51. */
  52. public String getCatalogCode ( ) {
  53. return getCatalogName();
  54. }
  55. /**
  56. * Gets the folder string of the catalog. It must be unique among
  57. * all subclasses.
  58. * @return the folder string of the catalog.
  59. */
  60. public String getCatalogFolderCode ( ) {
  61. return getCatalogCode();
  62. }
  63. /**
  64. * Gets the category of the catalog.
  65. * @return the category of the catalog.
  66. */
  67. public String getCatalogCategory ( ) {
  68. return "";
  69. }
  70. /**
  71. * Gets the list of the hierarchical folders.
  72. * @return the list of the hierarchical folders.
  73. */
  74. public Vector getHierarchicalFolders ( ) {
  75. return null;
  76. }
  77. /**
  78. * Gets the folder string of the star. It must be unique among all
  79. * subclasses.
  80. * @return the folder string of the star.
  81. */
  82. public String getStarFolder ( ) {
  83. return "";
  84. }
  85. /**
  86. * Sets the flag to output only in reduced format.
  87. */
  88. public void reduceOutput ( ) {
  89. detailed_output = false;
  90. }
  91. /**
  92. * Gets the mean error of position in arcsec.
  93. * @return the mean error of position in arcsec.
  94. */
  95. public double getPositionErrorInArcsec ( ) {
  96. return 1.0;
  97. }
  98. /**
  99. * Gets the maximum error of position in arcsec. It is the search
  100. * area size to identify with other stars.
  101. * @return the maximum error of position in arcsec.
  102. */
  103. public double getMaximumPositionErrorInArcsec ( ) {
  104. return 5.0;
  105. }
  106. /**
  107. * Gets the accuracy of R.A. and Decl.
  108. * @return the accuracy of R.A. and Decl.
  109. */
  110. public byte getCoorAccuracy ( ) {
  111. return Coor.ACCURACY_100M_ARCSEC;
  112. }
  113. /**
  114. * Sets the accuracy of R.A. and Decl. It must be overrided in the
  115. * subclasses if the accuracy can be different from the default.
  116. * @param accuracy the accuracy of R.A. and Decl.
  117. */
  118. public void setCoorAccuracy ( byte accuracy ) {
  119. }
  120. /**
  121. * Returns the date if the R.A. and Decl. is date dependent. For
  122. * example, in the case of astrometric observations in the MPC
  123. * format. In general, it returns null.
  124. * @return the date.
  125. */
  126. public JulianDay getDate ( ) {
  127. return null;
  128. }
  129. /**
  130. * Returns true if the catalog contains magnitude data.
  131. * @return true if the catalog contains magnitude data.
  132. */
  133. public boolean supportsMagnitude ( ) {
  134. return false;
  135. }
  136. /**
  137. * Returns true if the catalog contains magnitude data enough for
  138. * photometry.
  139. * @return true if the catalog contains magnitude data enough for
  140. * photometry.
  141. */
  142. public boolean supportsPhotometry ( ) {
  143. return false;
  144. }
  145. /**
  146. * Returns true if the catalog contains accurate R.A. and Decl.
  147. * enough for astrometry.
  148. * @return true if the catalog contains accurate R.A. and Decl.
  149. * enough for astrometry.
  150. */
  151. public boolean supportsAstrometry ( ) {
  152. return false;
  153. }
  154. /**
  155. * Returns true if the catalog description of astrometry and
  156. * photometry is edittable. If not, the description is the catalog
  157. * name.
  158. * @return true if the catalog description of astrometry and
  159. * photometry is edittable.
  160. */
  161. public boolean isDescriptionEdittable ( ) {
  162. return false;
  163. }
  164. /**
  165. * Gets the V magnitude.
  166. * @return the V magnitude.
  167. * @exception UnsupportedMagnitudeSystemException if no V mag data
  168. * is recorded in this catalog.
  169. */
  170. public double getVMagnitude ( )
  171. throws UnsupportedMagnitudeSystemException
  172. {
  173. throw new UnsupportedMagnitudeSystemException();
  174. }
  175. /**
  176. * Gets the U magnitude.
  177. * @return the U magnitude.
  178. * @exception UnsupportedMagnitudeSystemException if no U mag data
  179. * is recorded in this catalog.
  180. */
  181. public double getUMagnitude ( )
  182. throws UnsupportedMagnitudeSystemException
  183. {
  184. throw new UnsupportedMagnitudeSystemException();
  185. }
  186. /**
  187. * Gets the B magnitude.
  188. * @return the B magnitude.
  189. * @exception UnsupportedMagnitudeSystemException if no B mag data
  190. * is recorded in this catalog.
  191. */
  192. public double getBMagnitude ( )
  193. throws UnsupportedMagnitudeSystemException
  194. {
  195. throw new UnsupportedMagnitudeSystemException();
  196. }
  197. /**
  198. * Gets the Rc magnitude.
  199. * @return the Rc magnitude.
  200. * @exception UnsupportedMagnitudeSystemException if no Rc mag data
  201. * is recorded in this catalog.
  202. */
  203. public double getRcMagnitude ( )
  204. throws UnsupportedMagnitudeSystemException
  205. {
  206. throw new UnsupportedMagnitudeSystemException();
  207. }
  208. /**
  209. * Gets the Ic magnitude.
  210. * @return the Ic magnitude.
  211. * @exception UnsupportedMagnitudeSystemException if no Rc mag data
  212. * is recorded in this catalog.
  213. */
  214. public double getIcMagnitude ( )
  215. throws UnsupportedMagnitudeSystemException
  216. {
  217. throw new UnsupportedMagnitudeSystemException();
  218. }
  219. /**
  220. * Gets the difference between the V and B magnitude.
  221. * @return the difference between the V and B magnitude.
  222. * @exception UnsupportedMagnitudeSystemException if no V mag or
  223. * B mag data is recorded in this catalog.
  224. */
  225. public double getBVDifference ( )
  226. throws UnsupportedMagnitudeSystemException
  227. {
  228. throw new UnsupportedMagnitudeSystemException();
  229. }
  230. /**
  231. * Gets the list of magnitude systems supported by this catalog.
  232. * @return the list of magnitude systems supported by this catalog.
  233. */
  234. public String[] getAvailableMagnitudeSystems ( ) {
  235. return null;
  236. }
  237. /**
  238. * Gets the magnitude of the specified system.
  239. * @param system the magnitude system.
  240. * @return the magnitude of the specified system.
  241. * @exception UnsupportedMagnitudeSystemException if the specified
  242. * magnitude system is not supported.
  243. */
  244. public double getMagnitude ( String system )
  245. throws UnsupportedMagnitudeSystemException
  246. {
  247. throw new UnsupportedMagnitudeSystemException();
  248. }
  249. /**
  250. * Gets the magnitude of the specified magnitude system.
  251. * @param system the magnitude system.
  252. * @return the magnitude of the specified system.
  253. * @exception UnsupportedMagnitudeSystemException if the magnitude
  254. * system for the specified photometry setting is not supported.
  255. */
  256. public double getMagnitude ( MagnitudeSystem system )
  257. throws UnsupportedMagnitudeSystemException
  258. {
  259. if (system == null)
  260. return getMag();
  261. if (system.getMethod() == MagnitudeSystem.METHOD_DEFAULT) {
  262. return getMag();
  263. } else if (system.getMethod() == MagnitudeSystem.METHOD_STANDARD) {
  264. return getMagnitude(system.getSystemCode());
  265. } else if (system.getMethod() == MagnitudeSystem.METHOD_CATALOG) {
  266. return getMagnitude(system.getSystemCode());
  267. } else if (system.getMethod() == MagnitudeSystem.METHOD_INSTRUMENTAL) {
  268. double v_mag = getVMagnitude();
  269. double b_v = getBVDifference();
  270. return v_mag + system.getGradientBV() * b_v;
  271. }
  272. throw new UnsupportedMagnitudeSystemException();
  273. }
  274. /**
  275. * Gets the magnitude string of the specified system to output.
  276. * @param system the magnitude system.
  277. * @return the magnitude string of the specified system.
  278. * @exception UnsupportedMagnitudeSystemException if the specified
  279. * magnitude system is not supported.
  280. */
  281. public String getMagnitudeString ( String system )
  282. throws UnsupportedMagnitudeSystemException
  283. {
  284. throw new UnsupportedMagnitudeSystemException();
  285. }
  286. /**
  287. * Gets the catalog name with the specified magnitude system.
  288. * @param system the magnitude system.
  289. * @return the catalog name with the specified magnitude system.
  290. * @exception UnsupportedMagnitudeSystemException if the specified
  291. * magnitude system is not supported.
  292. */
  293. public String getCatalogNameWithMagnitudeSystem ( String system )
  294. throws UnsupportedMagnitudeSystemException
  295. {
  296. String[] catalog_names = getCatalogNamesWithMagnitudeSystem();
  297. if (catalog_names != null) {
  298. for (int i = 0 ; i < catalog_names.length ; i++) {
  299. if (getMagnitudeSystem(catalog_names[i]).equals(system))
  300. return catalog_names[i];
  301. }
  302. }
  303. throw new UnsupportedMagnitudeSystemException();
  304. }
  305. /**
  306. * Gets the list of catalog names with the supporting magnitude
  307. * system.
  308. * @return the list of catalog names with the supporting magnitude
  309. * system.
  310. */
  311. public String[] getCatalogNamesWithMagnitudeSystem ( ) {
  312. String[] systems = getAvailableMagnitudeSystems();
  313. if (systems == null)
  314. return null;
  315. String[] names = new String[systems.length];
  316. for (int i = 0 ; i < systems.length ; i++) {
  317. names[i] = getCatalogName();
  318. if (systems[i].length() > 0)
  319. names[i] += " (" + systems[i] + ")";
  320. }
  321. return names;
  322. }
  323. /**
  324. * Gets the magnitude system.
  325. * @param catalog_name the catalog name with magnitude system.
  326. * @return the magnitude system.
  327. */
  328. public String getMagnitudeSystem ( String catalog_name ) {
  329. if (catalog_name.indexOf(getCatalogName()) == 0) {
  330. String s = catalog_name.substring(getCatalogName().length()).trim();
  331. if (s.length() == 0)
  332. return "";
  333. int p = s.indexOf('(');
  334. int q = s.indexOf(')');
  335. if (p != 0 || q != s.length() - 1)
  336. return "";
  337. return s.substring(1, q);
  338. }
  339. return "";
  340. }
  341. /**
  342. * Gets the html help message for regular photometry.
  343. * @return the html help message for regular photometry.
  344. */
  345. public String getPhotometryHelpMessage ( ) {
  346. return null;
  347. }
  348. /**
  349. * Gets the html help message of the specified name with magnitude
  350. * system for simple magnitude comparison.
  351. * @param name the catalog name with magnitude system.
  352. * @return the html help message for simple magnitude comparison.
  353. */
  354. public String getHelpMessage ( String name ) {
  355. return null;
  356. }
  357. /**
  358. * Gets the default property to plot stars.
  359. * @return the default property to plot stars.
  360. */
  361. public PlotProperty getDefaultProperty ( ) {
  362. return new PlotProperty();
  363. }
  364. /**
  365. * Gets a string representing the R.A. and Decl. in a proper
  366. * format and accuracy.
  367. * @return the string representing R.A. and Decl.
  368. */
  369. public String getCoorString ( ) {
  370. if (getCoorAccuracy() == Coor.ACCURACY_1M_ARCSEC)
  371. return coor.getOutputStringTo1mArcsecWithUnit();
  372. if (getCoorAccuracy() == Coor.ACCURACY_10M_ARCSEC)
  373. return coor.getOutputStringTo10mArcsecWithUnit();
  374. if (getCoorAccuracy() == Coor.ACCURACY_ARCSEC)
  375. return coor.getOutputStringToArcsecWithUnit();
  376. if (getCoorAccuracy() == Coor.ACCURACY_ROUGH_ARCSEC)
  377. return coor.getOutputStringToRoughArcsecWithUnit();
  378. if (getCoorAccuracy() == Coor.ACCURACY_100M_ARCMIN)
  379. return coor.getOutputStringTo100mArcminWithUnit();
  380. if (getCoorAccuracy() == Coor.ACCURACY_100M_ARCMIN_HOURSEC)
  381. return coor.getOutputStringTo100mArcminHoursecWithUnit();
  382. if (getCoorAccuracy() == Coor.ACCURACY_ARCMIN)
  383. return coor.getOutputStringToArcminWithUnit();
  384. return coor.getOutputStringTo100mArcsecWithUnit();
  385. }
  386. /**
  387. * Gets a string representing the R.A. and Decl. in a proper
  388. * format and accuracy without unit.
  389. * @return the string representing R.A. and Decl.
  390. */
  391. public String getCoorStringWithoutUnit ( ) {
  392. if (getCoorAccuracy() == Coor.ACCURACY_10M_ARCSEC)
  393. return coor.getOutputStringTo10mArcsecWithoutUnit();
  394. if (getCoorAccuracy() == Coor.ACCURACY_ARCSEC)
  395. return coor.getOutputStringToArcsecWithoutUnit();
  396. if (getCoorAccuracy() == Coor.ACCURACY_100M_ARCMIN)
  397. return coor.getOutputStringTo100mArcminWithoutUnit();
  398. if (getCoorAccuracy() == Coor.ACCURACY_ARCMIN)
  399. return coor.getOutputStringToArcminWithoutUnit();
  400. return coor.getOutputStringTo100mArcsecWithoutUnit();
  401. }
  402. /**
  403. * Gets an array of keys and values related to the photometry. In
  404. * principle, this method must be overrided in subclasses.
  405. * @return an array of keys and values related to the photometry.
  406. */
  407. public KeyAndValue[] getKeyAndValuesForPhotometry ( ) {
  408. return new KeyAndValue[0];
  409. }
  410. }