diff --git a/AUTHORS b/AUTHORS index 2cae2e43..57c7fb44 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,14 +1,15 @@ -Uwe Filges (CVS/ChangeLog username: uf) -Przemek Klosowski (CVS/ChangeLog username: pk) -Mark Koennecke (CVS/ChangeLog username: mk) -Nick Maliszewskyj (CVS/ChangeLog username: ncm) -Chris Moreton-Smith (CVS/ChangeLog username: cmm) -Ray Osborn (CVS/ChangeLog username: rio) -Jon Tischler (CVS/ChangeLog username: jzt) -Freddie Akeroyd (CVS/ChangeLog username: faa59) -Jens Krueger (CVS/ChangeLog username: jk) -Joern Beckmann (CVS/ChangeLog username: jb) -Peter Peterson (CVS/ChangeLog username: pfp) -Hartmut Gilde (CVS/ChangeLog username: hg) +Uwe Filges +Przemek Klosowski +Mark Koennecke +Nick Maliszewskyj +Chris Moreton-Smith +Ray Osborn +Jon Tischler +Freddie Akeroyd +Jens Krueger +Joern Beckmann +Peter Peterson +Hartmut Gilde +Tobias Richter $Id$ diff --git a/InstallerBits/Licences/AUTHORS.txt b/InstallerBits/Licences/AUTHORS.txt deleted file mode 100644 index c4de0e01..00000000 --- a/InstallerBits/Licences/AUTHORS.txt +++ /dev/null @@ -1,14 +0,0 @@ -The following people have been involved with the development of the NeXus source code - -Uwe Filges (CVS/ChangeLog username: uf) -Przemek Klosowski (CVS/ChangeLog username: pk) -Mark Koennecke (CVS/ChangeLog username: mk) -Nick Maliszewskyj (CVS/ChangeLog username: ncm) -Chris Moreton-Smith (CVS/ChangeLog username: cmm) -Ray Osborn (CVS/ChangeLog username: rio) -Jon Tischler (CVS/ChangeLog username: jzt) -Freddie Akeroyd (CVS/ChangeLog username: faa59) -Jens Krueger (CVS/ChangeLog username: jk) -Joern Beckmann (CVS/ChangeLog username: jb) -Peter Peterson (CVS/ChangeLog username: pfp) -Hartmut Gilde (CVS/ChangeLog username: hg) diff --git a/InstallerBits/Licences/COPYING.txt b/InstallerBits/Licences/COPYING.txt deleted file mode 100644 index 16adb434..00000000 --- a/InstallerBits/Licences/COPYING.txt +++ /dev/null @@ -1,34 +0,0 @@ -License Information - -The NeXus library and utilities are distributed under the terms on the GNU Lesser General Public License (LGPL) – -see the enclosed COPYING_NeXus.txt file or http://www.opensource.org/licenses/lgpl-license.php for further details. -The NeXus library is linked statically against Michael Sweet’s Mini-XML parsing library (http://www.easysw.com/~mike/mxml/) -which is also governed by the LGPL. - -In addition to the NeXus libraries, this kit will also install DLLs from other packages that have been linked into -the NeXus library. These packages and their licenses are as follows: - -libxml2.dll is from the XML C Parser for GNOME (http://xmlsoft.org/). Its distribution is covered by the MIT License -which is detailed in the enclosed COPYING_libxml2.txt file and also at http://www.opensource.org/licenses/mit-license.html - -hd*.dll and hm*.dll files are the HDF4 libraries developed at the -National Center for Supercomputing Applications (NCSA) at the -University of Illinois at Urbana-Champaign (http://hdf.ncsa.uiuc.edu/). Their distribution is covered by the license detailed -in the enclosed COPYING_hdf4.txt file and at ftp://ftp.ncsa.uiuc.edu/HDF/HDF/HDF_Current/src/unpacked/COPYING - -hdf5dll.dll is the HDF5 library developed at the -National Center for Supercomputing Applications (NCSA) at the -University of Illinois at Urbana-Champaign (http://hdf.ncsa.uiuc.edu/). Distribution is covered by the license detailed in -the enclosed COPYING_hdf5.txt file and at ftp://ftp.ncsa.uiuc.edu/HDF/HDF5/current/src/unpacked/COPYING - -szlibdll.dll is the decoder-only version of the SZIP compression library – it is licensed for use only in conjunction with -the enclosed HDF software. For further information see http://hdf.ncsa.uiuc.edu/doc_resource/SZIP/ and -http://hdf.ncsa.uiuc.edu/doc_resource/SZIP/Commercial_szip.html - -zlib1.dll is from the the ZLIB compression library http://www.gzip.org/zlib/ . Its distribution is covered by the -license detailed in the enclosed COPYING_zlib.txt and also at http://www.zlib.net/zlib_license.html - -iconv.dll is from the GNU ICONV library (http://www.gnu.org/software/libiconv/). It is distributed under the terms -of the GNU Lesser General Public License (LGPL) as detailed in the enclosed COPYING_iconv.txt and at . -http://www.opensource.org/licenses/lgpl-license.php - diff --git a/InstallerBits/Licences/COPYING_nexus.txt b/InstallerBits/Licences/COPYING_nexus.txt deleted file mode 100644 index 4bc8bf8e..00000000 --- a/InstallerBits/Licences/COPYING_nexus.txt +++ /dev/null @@ -1,515 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - - diff --git a/README.cmake b/README.cmake deleted file mode 100644 index e69de29b..00000000 diff --git a/applications/NXdir/.cvsignore b/applications/NXdir/.cvsignore deleted file mode 100644 index 96d238e1..00000000 --- a/applications/NXdir/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -nxdir diff --git a/bindings/java/bin/README b/bindings/java/bin/README deleted file mode 100644 index 8e77dbbd..00000000 --- a/bindings/java/bin/README +++ /dev/null @@ -1,5 +0,0 @@ - - Binary Distributions - - - du40 shared jnexus library for DigitalUnix4.0D - - rh62 shared jnexus library for Redhat 6.2 on Intel diff --git a/bindings/java/bin/win32/hd413m.def b/bindings/java/bin/win32/hd413m.def deleted file mode 100644 index 96aa9f73..00000000 --- a/bindings/java/bin/win32/hd413m.def +++ /dev/null @@ -1,870 +0,0 @@ -LIBRARY HD413M.DLL - -EXPORTS - _AFANNLEN = AFANNLEN ; AFANNLEN - _AFANNLIST = AFANNLIST ; AFANNLIST - _AFATYPETAG = AFATYPETAG ; AFATYPETAG - _AFCREATE = AFCREATE ; AFCREATE - _AFEND = AFEND ; AFEND - _AFENDACCESS = AFENDACCESS ; AFENDACCESS - _AFFCREATE = AFFCREATE ; AFFCREATE - _AFFILEINFO = AFFILEINFO ; AFFILEINFO - _AFGETTAGREF = AFGETTAGREF ; AFGETTAGREF - _AFIDTAGREF = AFIDTAGREF ; AFIDTAGREF - _AFNUMANN = AFNUMANN ; AFNUMANN - _AFREADANN = AFREADANN ; AFREADANN - _AFSELECT = AFSELECT ; AFSELECT - _AFSTART = AFSTART ; AFSTART - _AFTAGATYPE = AFTAGATYPE ; AFTAGATYPE - _AFTAGREFID = AFTAGREFID ; AFTAGREFID - _AFWRITEANN = AFWRITEANN ; AFWRITEANN - _ANannlen = ANannlen ; ANannlen - _ANannlist = ANannlist ; ANannlist - _ANatype2tag = ANatype2tag ; ANatype2tag - _ANcreate = ANcreate ; ANcreate - _ANcreatef = ANcreatef ; ANcreatef - _ANdestroy = ANdestroy ; ANdestroy - _ANend = ANend ; ANend - _ANendaccess = ANendaccess ; ANendaccess - _ANfileinfo = ANfileinfo ; ANfileinfo - _ANget_tagref = ANget_tagref ; ANget_tagref - _ANid2tagref = ANid2tagref ; ANid2tagref - _ANnumann = ANnumann ; ANnumann - _ANreadann = ANreadann ; ANreadann - _ANselect = ANselect ; ANselect - _ANstart = ANstart ; ANstart - _ANtag2atype = ANtag2atype ; ANtag2atype - _ANtagref2id = ANtagref2id ; ANtagref2id - _ANwriteann = ANwriteann ; ANwriteann - _DF24addimage = DF24addimage ; DF24addimage - _DF24getdims = DF24getdims ; DF24getdims - _DF24getimage = DF24getimage ; DF24getimage - _DF24lastref = DF24lastref ; DF24lastref - _DF24nimages = DF24nimages ; DF24nimages - _DF24putimage = DF24putimage ; DF24putimage - _DF24readref = DF24readref ; DF24readref - _DF24reqil = DF24reqil ; DF24reqil - _DF24restart = DF24restart ; DF24restart - _DF24setcompress = DF24setcompress ; DF24setcompress - _DF24setdims = DF24setdims ; DF24setdims - _DF24setil = DF24setil ; DF24setil - _DFANIaddentry = DFANIaddentry ; DFANIaddentry - _DFANIaddfann = DFANIaddfann ; DFANIaddfann - _DFANIclear = DFANIclear ; DFANIclear - _DFANIgetann = DFANIgetann ; DFANIgetann - _DFANIgetannlen = DFANIgetannlen ; DFANIgetannlen - _DFANIgetfann = DFANIgetfann ; DFANIgetfann - _DFANIgetfannlen = DFANIgetfannlen ; DFANIgetfannlen - _DFANIlablist = DFANIlablist ; DFANIlablist - _DFANIlocate = DFANIlocate ; DFANIlocate - _DFANIputann = DFANIputann ; DFANIputann - _DFANPshutdown = DFANPshutdown ; DFANPshutdown - _DFANaddfds = DFANaddfds ; DFANaddfds - _DFANaddfid = DFANaddfid ; DFANaddfid - _DFANclear = DFANclear ; DFANclear - _DFANgetdesc = DFANgetdesc ; DFANgetdesc - _DFANgetdesclen = DFANgetdesclen ; DFANgetdesclen - _DFANgetfds = DFANgetfds ; DFANgetfds - _DFANgetfdslen = DFANgetfdslen ; DFANgetfdslen - _DFANgetfid = DFANgetfid ; DFANgetfid - _DFANgetfidlen = DFANgetfidlen ; DFANgetfidlen - _DFANgetlabel = DFANgetlabel ; DFANgetlabel - _DFANgetlablen = DFANgetlablen ; DFANgetlablen - _DFANlablist = DFANlablist ; DFANlablist - _DFANlastref = DFANlastref ; DFANlastref - _DFANputdesc = DFANputdesc ; DFANputdesc - _DFANputlabel = DFANputlabel ; DFANputlabel - _DFCIimcomp = DFCIimcomp ; DFCIimcomp - _DFCIjpeg = DFCIjpeg ; DFCIjpeg - _DFCIrle = DFCIrle ; DFCIrle - _DFCIunimcomp = DFCIunimcomp ; DFCIunimcomp - _DFCIunjpeg = DFCIunjpeg ; DFCIunjpeg - _DFCIunrle = DFCIunrle ; DFCIunrle - _DFGRIaddimlut = DFGRIaddimlut ; DFGRIaddimlut - _DFGRIgetdims = DFGRIgetdims ; DFGRIgetdims - _DFGRIgetimlut = DFGRIgetimlut ; DFGRIgetimlut - _DFGRIlastref = DFGRIlastref ; DFGRIlastref - _DFGRIreqil = DFGRIreqil ; DFGRIreqil - _DFGRIrestart = DFGRIrestart ; DFGRIrestart - _DFGRIsetdims = DFGRIsetdims ; DFGRIsetdims - _DFGRIsetil = DFGRIsetil ; DFGRIsetil - _DFGRPshutdown = DFGRPshutdown ; DFGRPshutdown - _DFGRaddimage = DFGRaddimage ; DFGRaddimage - _DFGRaddlut = DFGRaddlut ; DFGRaddlut - _DFGRgetimage = DFGRgetimage ; DFGRgetimage - _DFGRgetimdims = DFGRgetimdims ; DFGRgetimdims - _DFGRgetlut = DFGRgetlut ; DFGRgetlut - _DFGRgetlutdims = DFGRgetlutdims ; DFGRgetlutdims - _DFGRputimage = DFGRputimage ; DFGRputimage - _DFGRreadref = DFGRreadref ; DFGRreadref - _DFGRreqimil = DFGRreqimil ; DFGRreqimil - _DFGRreqlutil = DFGRreqlutil ; DFGRreqlutil - _DFGRsetcompress = DFGRsetcompress ; DFGRsetcompress - _DFGRsetimdims = DFGRsetimdims ; DFGRsetimdims - _DFGRsetlut = DFGRsetlut ; DFGRsetlut - _DFGRsetlutdims = DFGRsetlutdims ; DFGRsetlutdims - _DFIVOPN = DFIVOPN ; DFIVOPN - _DFKNTsize = DFKNTsize ; DFKNTsize - _DFKconvert = DFKconvert ; DFKconvert - _DFKgetPNSC = DFKgetPNSC ; DFKgetPNSC - _DFKislitendNT = DFKislitendNT ; DFKislitendNT - _DFKisnativeNT = DFKisnativeNT ; DFKisnativeNT - _DFKnb1b = DFKnb1b ; DFKnb1b - _DFKnb2b = DFKnb2b ; DFKnb2b - _DFKnb4b = DFKnb4b ; DFKnb4b - _DFKnb8b = DFKnb8b ; DFKnb8b - _DFKsb2b = DFKsb2b ; DFKsb2b - _DFKsb4b = DFKsb4b ; DFKsb4b - _DFKsb8b = DFKsb8b ; DFKsb8b - _DFKsetNT = DFKsetNT ; DFKsetNT - _DFPaddpal = DFPaddpal ; DFPaddpal - _DFPgetpal = DFPgetpal ; DFPgetpal - _DFPlastref = DFPlastref ; DFPlastref - _DFPnpals = DFPnpals ; DFPnpals - _DFPputpal = DFPputpal ; DFPputpal - _DFPreadref = DFPreadref ; DFPreadref - _DFPrestart = DFPrestart ; DFPrestart - _DFPwriteref = DFPwriteref ; DFPwriteref - _DFR8Pshutdown = DFR8Pshutdown ; DFR8Pshutdown - _DFR8addimage = DFR8addimage ; DFR8addimage - _DFR8getdims = DFR8getdims ; DFR8getdims - _DFR8getimage = DFR8getimage ; DFR8getimage - _DFR8getpalref = DFR8getpalref ; DFR8getpalref - _DFR8lastref = DFR8lastref ; DFR8lastref - _DFR8nimages = DFR8nimages ; DFR8nimages - _DFR8putimage = DFR8putimage ; DFR8putimage - _DFR8readref = DFR8readref ; DFR8readref - _DFR8restart = DFR8restart ; DFR8restart - _DFR8setcompress = DFR8setcompress ; DFR8setcompress - _DFR8setpalette = DFR8setpalette ; DFR8setpalette - _DFR8writeref = DFR8writeref ; DFR8writeref - _DFSDPshutdown = DFSDPshutdown ; DFSDPshutdown - _DFSDadddata = DFSDadddata ; DFSDadddata - _DFSDclear = DFSDclear ; DFSDclear - _DFSDendslab = DFSDendslab ; DFSDendslab - _DFSDendslice = DFSDendslice ; DFSDendslice - _DFSDgetNT = DFSDgetNT ; DFSDgetNT - _DFSDgetcal = DFSDgetcal ; DFSDgetcal - _DFSDgetdata = DFSDgetdata ; DFSDgetdata - _DFSDgetdatalen = DFSDgetdatalen ; DFSDgetdatalen - _DFSDgetdatastrs = DFSDgetdatastrs ; DFSDgetdatastrs - _DFSDgetdimlen = DFSDgetdimlen ; DFSDgetdimlen - _DFSDgetdims = DFSDgetdims ; DFSDgetdims - _DFSDgetdimscale = DFSDgetdimscale ; DFSDgetdimscale - _DFSDgetdimstrs = DFSDgetdimstrs ; DFSDgetdimstrs - _DFSDgetfillvalue = DFSDgetfillvalue ; DFSDgetfillvalue - _DFSDgetrange = DFSDgetrange ; DFSDgetrange - _DFSDgetslice = DFSDgetslice ; DFSDgetslice - _DFSDlastref = DFSDlastref ; DFSDlastref - _DFSDndatasets = DFSDndatasets ; DFSDndatasets - _DFSDpre32sdg = DFSDpre32sdg ; DFSDpre32sdg - _DFSDputdata = DFSDputdata ; DFSDputdata - _DFSDputslice = DFSDputslice ; DFSDputslice - _DFSDreadref = DFSDreadref ; DFSDreadref - _DFSDreadslab = DFSDreadslab ; DFSDreadslab - _DFSDrestart = DFSDrestart ; DFSDrestart - _DFSDsetNT = DFSDsetNT ; DFSDsetNT - _DFSDsetcal = DFSDsetcal ; DFSDsetcal - _DFSDsetdatastrs = DFSDsetdatastrs ; DFSDsetdatastrs - _DFSDsetdims = DFSDsetdims ; DFSDsetdims - _DFSDsetdimscale = DFSDsetdimscale ; DFSDsetdimscale - _DFSDsetdimstrs = DFSDsetdimstrs ; DFSDsetdimstrs - _DFSDsetfillvalue = DFSDsetfillvalue ; DFSDsetfillvalue - _DFSDsetlengths = DFSDsetlengths ; DFSDsetlengths - _DFSDsetrange = DFSDsetrange ; DFSDsetrange - _DFSDstartslab = DFSDstartslab ; DFSDstartslab - _DFSDstartslice = DFSDstartslice ; DFSDstartslice - _DFSDwriteref = DFSDwriteref ; DFSDwriteref - _DFSDwriteslab = DFSDwriteslab ; DFSDwriteslab - _DFVCLOS = DFVCLOS ; DFVCLOS - _DFdifree = DFdifree ; DFdifree - _DFdiget = DFdiget ; DFdiget - _DFdinobj = DFdinobj ; DFdinobj - _DFdiput = DFdiput ; DFdiput - _DFdiread = DFdiread ; DFdiread - _DFdisetup = DFdisetup ; DFdisetup - _DFdiwrite = DFdiwrite ; DFdiwrite - _DFfindnextref = DFfindnextref ; DFfindnextref - _DFgetcomp = DFgetcomp ; DFgetcomp - _DFputcomp = DFputcomp ; DFputcomp - _GRIil_convert = GRIil_convert ; GRIil_convert - _GRPshutdown = GRPshutdown ; GRPshutdown - _GRattrinfo = GRattrinfo ; GRattrinfo - _GRcreate = GRcreate ; GRcreate - _GRend = GRend ; GRend - _GRendaccess = GRendaccess ; GRendaccess - _GRfileinfo = GRfileinfo ; GRfileinfo - _GRfindattr = GRfindattr ; GRfindattr - _GRgetattr = GRgetattr ; GRgetattr - _GRgetchunkinfo = GRgetchunkinfo ; GRgetchunkinfo - _GRgetiminfo = GRgetiminfo ; GRgetiminfo - _GRgetlutid = GRgetlutid ; GRgetlutid - _GRgetlutinfo = GRgetlutinfo ; GRgetlutinfo - _GRidtoref = GRidtoref ; GRidtoref - _GRluttoref = GRluttoref ; GRluttoref - _GRnametoindex = GRnametoindex ; GRnametoindex - _GRreadchunk = GRreadchunk ; GRreadchunk - _GRreadimage = GRreadimage ; GRreadimage - _GRreadlut = GRreadlut ; GRreadlut - _GRreftoindex = GRreftoindex ; GRreftoindex - _GRreqimageil = GRreqimageil ; GRreqimageil - _GRreqlutil = GRreqlutil ; GRreqlutil - _GRselect = GRselect ; GRselect - _GRsetaccesstype = GRsetaccesstype ; GRsetaccesstype - _GRsetattr = GRsetattr ; GRsetattr - _GRsetchunk = GRsetchunk ; GRsetchunk - _GRsetchunkcache = GRsetchunkcache ; GRsetchunkcache - _GRsetcompress = GRsetcompress ; GRsetcompress - _GRsetexternalfile = GRsetexternalfile ; GRsetexternalfile - _GRstart = GRstart ; GRstart - _GRwritechunk = GRwritechunk ; GRwritechunk - _GRwriteimage = GRwriteimage ; GRwriteimage - _GRwritelut = GRwritelut ; GRwritelut - _HBPcloseAID = HBPcloseAID ; HBPcloseAID - _HBPendaccess = HBPendaccess ; HBPendaccess - _HBPinfo = HBPinfo ; HBPinfo - _HBPinquire = HBPinquire ; HBPinquire - _HBPread = HBPread ; HBPread - _HBPseek = HBPseek ; HBPseek - _HBPstread = HBPstread ; HBPstread - _HBPstwrite = HBPstwrite ; HBPstwrite - _HBPwrite = HBPwrite ; HBPwrite - _HBconvert = HBconvert ; HBconvert - _HCPcloseAID = HCPcloseAID ; HCPcloseAID - _HCPdecode_header = HCPdecode_header ; HCPdecode_header - _HCPencode_header = HCPencode_header ; HCPencode_header - _HCPendaccess = HCPendaccess ; HCPendaccess - _HCPinfo = HCPinfo ; HCPinfo - _HCPinquire = HCPinquire ; HCPinquire - _HCPquery_encode_header = HCPquery_encode_header ; HCPquery_encode_header - _HCPread = HCPread ; HCPread - _HCPseek = HCPseek ; HCPseek - _HCPstread = HCPstread ; HCPstread - _HCPstwrite = HCPstwrite ; HCPstwrite - _HCPwrite = HCPwrite ; HCPwrite - _HCcreate = HCcreate ; HCcreate - _HDDONTATEXIT = HDDONTATEXIT ; HDDONTATEXIT - _HDc2fstr = HDc2fstr ; HDc2fstr - _HDcalloc = HDcalloc ; HDcalloc - _HDcheck_tagref = HDcheck_tagref ; HDcheck_tagref - _HDdont_atexit = HDdont_atexit ; HDdont_atexit - _HDerr = HDerr ; HDerr - _HDf2cstring = HDf2cstring ; HDf2cstring - _HDfidtoname = HDfidtoname ; HDfidtoname - _HDflush = HDflush ; HDflush - _HDfree = HDfree ; HDfree - _HDgetNTdesc = HDgetNTdesc ; HDgetNTdesc - _HDget_special_info = HDget_special_info ; HDget_special_info - _HDgetc = HDgetc ; HDgetc - _HDgettagdesc = HDgettagdesc ; HDgettagdesc - _HDgettagnum = HDgettagnum ; HDgettagnum - _HDgettagsname = HDgettagsname ; HDgettagsname - _HDinqblockinfo = HDinqblockinfo ; HDinqblockinfo - _HDmalloc = HDmalloc ; HDmalloc - _HDmemfill = HDmemfill ; HDmemfill - _HDpackFstring = HDpackFstring ; HDpackFstring - _HDputc = HDputc ; HDputc - _HDrealloc = HDrealloc ; HDrealloc - _HDreuse_tagref = HDreuse_tagref ; HDreuse_tagref - _HDset_special_info = HDset_special_info ; HDset_special_info - _HDstrdup = HDstrdup ; HDstrdup - _HDvalidfid = HDvalidfid ; HDvalidfid - _HEPRNT = HEPRNT ; HEPRNT - _HEPclear = HEPclear ; HEPclear - _HESTRING = HESTRING ; HESTRING - _HESTRINGC = HESTRINGC ; HESTRINGC - _HEprint = HEprint ; HEprint - _HEpush = HEpush ; HEpush - _HEreport = HEreport ; HEreport - _HEshutdown = HEshutdown ; HEshutdown - _HEstring = HEstring ; HEstring - _HEvalue = HEvalue ; HEvalue - _HGFILVER = HGFILVER ; HGFILVER - _HGFILVERC = HGFILVERC ; HGFILVERC - _HGLIBVER = HGLIBVER ; HGLIBVER - _HGLIBVERC = HGLIBVERC ; HGLIBVERC - _HIISHDF = HIISHDF ; HIISHDF - _HIOPEN = HIOPEN ; HIOPEN - _HISHDF = HISHDF ; HISHDF - _HIget_access_rec = HIget_access_rec ; HIget_access_rec - _HIgetspinfo = HIgetspinfo ; HIgetspinfo - _HIrelease_accrec_node = HIrelease_accrec_node ; HIrelease_accrec_node - _HIstrncpy = HIstrncpy ; HIstrncpy - _HLPcloseAID = HLPcloseAID ; HLPcloseAID - _HLPendaccess = HLPendaccess ; HLPendaccess - _HLPinfo = HLPinfo ; HLPinfo - _HLPinquire = HLPinquire ; HLPinquire - _HLPread = HLPread ; HLPread - _HLPseek = HLPseek ; HLPseek - _HLPstread = HLPstread ; HLPstread - _HLPstwrite = HLPstwrite ; HLPstwrite - _HLPwrite = HLPwrite ; HLPwrite - _HLconvert = HLconvert ; HLconvert - _HLcreate = HLcreate ; HLcreate - _HMCPcloseAID = HMCPcloseAID ; HMCPcloseAID - _HMCcreate = HMCcreate ; HMCcreate - _HMCreadChunk = HMCreadChunk ; HMCreadChunk - _HMCsetMaxcache = HMCsetMaxcache ; HMCsetMaxcache - _HMCwriteChunk = HMCwriteChunk ; HMCwriteChunk - _HNUMBER = HNUMBER ; HNUMBER - _HP_read = HP_read ; HP_read - _HP_write = HP_write ; HP_write - _HPbitshutdown = HPbitshutdown ; HPbitshutdown - _HPcompare_accrec_tagref = HPcompare_accrec_tagref ; HPcompare_accrec_tagref - _HPcompare_filerec_path = HPcompare_filerec_path ; HPcompare_filerec_path - _HPend = HPend ; HPend - _HPfreediskblock = HPfreediskblock ; HPfreediskblock - _HPgetdiskblock = HPgetdiskblock ; HPgetdiskblock - _HPisappendable = HPisappendable ; HPisappendable - _HPregister_term_func = HPregister_term_func ; HPregister_term_func - _HPseek = HPseek ; HPseek - _HRPcloseAID = HRPcloseAID ; HRPcloseAID - _HRPconvert = HRPconvert ; HRPconvert - _HRPendaccess = HRPendaccess ; HRPendaccess - _HRPinfo = HRPinfo ; HRPinfo - _HRPinquire = HRPinquire ; HRPinquire - _HRPread = HRPread ; HRPread - _HRPseek = HRPseek ; HRPseek - _HRPstread = HRPstread ; HRPstread - _HRPstwrite = HRPstwrite ; HRPstwrite - _HRPwrite = HRPwrite ; HRPwrite - _HXISCDIR = HXISCDIR ; HXISCDIR - _HXISDIR = HXISDIR ; HXISDIR - _HXPcloseAID = HXPcloseAID ; HXPcloseAID - _HXPendaccess = HXPendaccess ; HXPendaccess - _HXPinfo = HXPinfo ; HXPinfo - _HXPinquire = HXPinquire ; HXPinquire - _HXPread = HXPread ; HXPread - _HXPreset = HXPreset ; HXPreset - _HXPseek = HXPseek ; HXPseek - _HXPsetaccesstype = HXPsetaccesstype ; HXPsetaccesstype - _HXPshutdown = HXPshutdown ; HXPshutdown - _HXPstread = HXPstread ; HXPstread - _HXPstwrite = HXPstwrite ; HXPstwrite - _HXPwrite = HXPwrite ; HXPwrite - _HXSCDIR = HXSCDIR ; HXSCDIR - _HXSDIR = HXSDIR ; HXSDIR - _HXcreate = HXcreate ; HXcreate - _HXsetcreatedir = HXsetcreatedir ; HXsetcreatedir - _HXsetdir = HXsetdir ; HXsetdir - _Happendable = Happendable ; Happendable - _Hbitappendable = Hbitappendable ; Hbitappendable - _Hbitread = Hbitread ; Hbitread - _Hbitseek = Hbitseek ; Hbitseek - _Hbitwrite = Hbitwrite ; Hbitwrite - _Hcache = Hcache ; Hcache - _Hclose = Hclose ; Hclose - _Hdeldd = Hdeldd ; Hdeldd - _Hdupdd = Hdupdd ; Hdupdd - _Hendaccess = Hendaccess ; Hendaccess - _Hendbitaccess = Hendbitaccess ; Hendbitaccess - _Hexist = Hexist ; Hexist - _Hfidinquire = Hfidinquire ; Hfidinquire - _Hfind = Hfind ; Hfind - _Hgetbit = Hgetbit ; Hgetbit - _Hgetelement = Hgetelement ; Hgetelement - _Hgetfileversion = Hgetfileversion ; Hgetfileversion - _Hgetlibversion = Hgetlibversion ; Hgetlibversion - _Hinquire = Hinquire ; Hinquire - _Hishdf = Hishdf ; Hishdf - _Hlength = Hlength ; Hlength - _Hnewref = Hnewref ; Hnewref - _Hnextread = Hnextread ; Hnextread - _Hnumber = Hnumber ; Hnumber - _Hoffset = Hoffset ; Hoffset - _Hopen = Hopen ; Hopen - _Hputelement = Hputelement ; Hputelement - _Hread = Hread ; Hread - _Hseek = Hseek ; Hseek - _Hsetaccesstype = Hsetaccesstype ; Hsetaccesstype - _Hsetlength = Hsetlength ; Hsetlength - _Hshutdown = Hshutdown ; Hshutdown - _Hstartaccess = Hstartaccess ; Hstartaccess - _Hstartbitread = Hstartbitread ; Hstartbitread - _Hstartbitwrite = Hstartbitwrite ; Hstartbitwrite - _Hstartread = Hstartread ; Hstartread - _Hstartwrite = Hstartwrite ; Hstartwrite - _Hsync = Hsync ; Hsync - _Htagnewref = Htagnewref ; Htagnewref - _Htell = Htell ; Htell - _Htrunc = Htrunc ; Htrunc - _Hwrite = Hwrite ; Hwrite - _MGATINF = MGATINF ; MGATINF - _MGCGICHNK = MGCGICHNK ; MGCGICHNK - _MGCRCCHNK = MGCRCCHNK ; MGCRCCHNK - _MGCRCHNK = MGCRCHNK ; MGCRCHNK - _MGCREAT = MGCREAT ; MGCREAT - _MGCSCCHNK = MGCSCCHNK ; MGCSCCHNK - _MGCSCHNK = MGCSCHNK ; MGCSCHNK - _MGCSCOMPRESS = MGCSCOMPRESS ; MGCSCOMPRESS - _MGCWCCHNK = MGCWCCHNK ; MGCWCCHNK - _MGCWCHNK = MGCWCHNK ; MGCWCHNK - _MGEND = MGEND ; MGEND - _MGENDAC = MGENDAC ; MGENDAC - _MGFINFO = MGFINFO ; MGFINFO - _MGFNDAT = MGFNDAT ; MGFNDAT - _MGGATTR = MGGATTR ; MGGATTR - _MGGCATT = MGGCATT ; MGGCATT - _MGGICHNK = MGGICHNK ; MGGICHNK - _MGGIINF = MGGIINF ; MGGIINF - _MGGLINF = MGGLINF ; MGGLINF - _MGGLTID = MGGLTID ; MGGLTID - _MGGNATT = MGGNATT ; MGGNATT - _MGICREAT = MGICREAT ; MGICREAT - _MGID2RF = MGID2RF ; MGID2RF - _MGIFNDAT = MGIFNDAT ; MGIFNDAT - _MGIGNAT = MGIGNAT ; MGIGNAT - _MGIN2NDX = MGIN2NDX ; MGIN2NDX - _MGIRIMG = MGIRIMG ; MGIRIMG - _MGISATTR = MGISATTR ; MGISATTR - _MGISCATT = MGISCATT ; MGISCATT - _MGISXFIL = MGISXFIL ; MGISXFIL - _MGIWIMG = MGIWIMG ; MGIWIMG - _MGN2NDX = MGN2NDX ; MGN2NDX - _MGR2IDX = MGR2IDX ; MGR2IDX - _MGRCCHNK = MGRCCHNK ; MGRCCHNK - _MGRCHNK = MGRCHNK ; MGRCHNK - _MGRCIMG = MGRCIMG ; MGRCIMG - _MGRCLUT = MGRCLUT ; MGRCLUT - _MGRDIMG = MGRDIMG ; MGRDIMG - _MGRDLUT = MGRDLUT ; MGRDLUT - _MGRIMIL = MGRIMIL ; MGRIMIL - _MGRLTIL = MGRLTIL ; MGRLTIL - _MGSACTP = MGSACTP ; MGSACTP - _MGSCATT = MGSCATT ; MGSCATT - _MGSCCHNK = MGSCCHNK ; MGSCCHNK - _MGSCHNK = MGSCHNK ; MGSCHNK - _MGSCOMPRESS = MGSCOMPRESS ; MGSCOMPRESS - _MGSELCT = MGSELCT ; MGSELCT - _MGSNATT = MGSNATT ; MGSNATT - _MGSTART = MGSTART ; MGSTART - _MGSXFIL = MGSXFIL ; MGSXFIL - _MGWCCHNK = MGWCCHNK ; MGWCCHNK - _MGWCHNK = MGWCHNK ; MGWCHNK - _MGWCIMG = MGWCIMG ; MGWCIMG - _MGWCLUT = MGWCLUT ; MGWCLUT - _MGWRIMG = MGWRIMG ; MGWRIMG - _MGWRLUT = MGWRLUT ; MGWRLUT - _VADTRC = VADTRC ; VADTRC - _VATCHC = VATCHC ; VATCHC - _VDELETE = VDELETE ; VDELETE - _VDELETEC = VDELETEC ; VDELETEC - _VDTCHC = VDTCHC ; VDTCHC - _VDTRC = VDTRC ; VDTRC - _VENTSC = VENTSC ; VENTSC - _VFADTR = VFADTR ; VFADTR - _VFAINFO = VFAINFO ; VFAINFO - _VFATCH = VFATCH ; VFATCH - _VFCFDAT = VFCFDAT ; VFCFDAT - _VFCSATT = VFCSATT ; VFCSATT - _VFCSCAT = VFCSCAT ; VFCSCAT - _VFDTCH = VFDTCH ; VFDTCH - _VFDTR = VFDTR ; VFDTR - _VFEND = VFEND ; VFEND - _VFENTS = VFENTS ; VFENTS - _VFFDATT = VFFDATT ; VFFDATT - _VFFESIZ = VFFESIZ ; VFFESIZ - _VFFISIZ = VFFISIZ ; VFFISIZ - _VFFLOC = VFFLOC ; VFFLOC - _VFFNAME = VFFNAME ; VFFNAME - _VFFORDR = VFFORDR ; VFFORDR - _VFFTYPE = VFFTYPE ; VFFTYPE - _VFGCATT = VFGCATT ; VFGCATT - _VFGCLS = VFGCLS ; VFGCLS - _VFGID = VFGID ; VFGID - _VFGNAM = VFGNAM ; VFGNAM - _VFGNATT = VFGNATT ; VFGNATT - _VFGNXT = VFGNXT ; VFGNXT - _VFGTTR = VFGTTR ; VFGTTR - _VFGTTRS = VFGTTRS ; VFGTTRS - _VFGVER = VFGVER ; VFGVER - _VFIND = VFIND ; VFIND - _VFINDC = VFINDC ; VFINDC - _VFINQ = VFINQ ; VFINQ - _VFINQTR = VFINQTR ; VFINQTR - _VFINSRT = VFINSRT ; VFINSRT - _VFISVG = VFISVG ; VFISVG - _VFISVS = VFISVS ; VFISVS - _VFLOCC = VFLOCC ; VFLOCC - _VFLONE = VFLONE ; VFLONE - _VFNATTS = VFNATTS ; VFNATTS - _VFNDCLS = VFNDCLS ; VFNDCLS - _VFNDCLSC = VFNDCLSC ; VFNDCLSC - _VFNFLDS = VFNFLDS ; VFNFLDS - _VFNTR = VFNTR ; VFNTR - _VFSCATT = VFSCATT ; VFSCATT - _VFSCLS = VFSCLS ; VFSCLS - _VFSNAM = VFSNAM ; VFSNAM - _VFSNATT = VFSNATT ; VFSNATT - _VFSTART = VFSTART ; VFSTART - _VFfieldesize = VFfieldesize ; VFfieldesize - _VFfieldisize = VFfieldisize ; VFfieldisize - _VFfieldname = VFfieldname ; VFfieldname - _VFfieldorder = VFfieldorder ; VFfieldorder - _VFfieldtype = VFfieldtype ; VFfieldtype - _VFnfields = VFnfields ; VFnfields - _VGCLSC = VGCLSC ; VGCLSC - _VGIDC = VGIDC ; VGIDC - _VGNAMC = VGNAMC ; VGNAMC - _VGNXTC = VGNXTC ; VGNXTC - _VGTTRC = VGTTRC ; VGTTRC - _VGTTRSC = VGTTRSC ; VGTTRSC - _VHFMKGP = VHFMKGP ; VHFMKGP - _VHFSCD = VHFSCD ; VHFSCD - _VHFSCDM = VHFSCDM ; VHFSCDM - _VHFSD = VHFSD ; VHFSD - _VHFSDM = VHFSDM ; VHFSDM - _VHMKGPC = VHMKGPC ; VHMKGPC - _VHSCDC = VHSCDC ; VHSCDC - _VHSCDMC = VHSCDMC ; VHSCDMC - _VHSDC = VHSDC ; VHSDC - _VHSDMC = VHSDMC ; VHSDMC - _VHmakegroup = VHmakegroup ; VHmakegroup - _VHstoredata = VHstoredata ; VHstoredata - _VHstoredatam = VHstoredatam ; VHstoredatam - _VINQC = VINQC ; VINQC - _VINQTRC = VINQTRC ; VINQTRC - _VINSRTC = VINSRTC ; VINSRTC - _VISVGC = VISVGC ; VISVGC - _VISVSC = VISVSC ; VISVSC - _VLONEC = VLONEC ; VLONEC - _VNREFS = VNREFS ; VNREFS - _VNTRC = VNTRC ; VNTRC - _VPshutdown = VPshutdown ; VPshutdown - _VQREF = VQREF ; VQREF - _VQTAG = VQTAG ; VQTAG - _VQueryref = VQueryref ; VQueryref - _VQuerytag = VQuerytag ; VQuerytag - _VSAPP = VSAPP ; VSAPP - _VSATCHC = VSATCHC ; VSATCHC - _VSCLSC = VSCLSC ; VSCLSC - _VSDLTC = VSDLTC ; VSDLTC - _VSDTCHC = VSDTCHC ; VSDTCHC - _VSELTSC = VSELTSC ; VSELTSC - _VSFAINF = VSFAINF ; VSFAINF - _VSFATCH = VSFATCH ; VSFATCH - _VSFCCPK = VSFCCPK ; VSFCCPK - _VSFCFDA = VSFCFDA ; VSFCFDA - _VSFCFDX = VSFCFDX ; VSFCFDX - _VSFCPAK = VSFCPAK ; VSFCPAK - _VSFCSAT = VSFCSAT ; VSFCSAT - _VSFCSCA = VSFCSCA ; VSFCSCA - _VSFDEFC = VSFDEFC ; VSFDEFC - _VSFDLTE = VSFDLTE ; VSFDLTE - _VSFDTCH = VSFDTCH ; VSFDTCH - _VSFELTS = VSFELTS ; VSFELTS - _VSFEX = VSFEX ; VSFEX - _VSFEXC = VSFEXC ; VSFEXC - _VSFFCLS = VSFFCLS ; VSFFCLS - _VSFFDAT = VSFFDAT ; VSFFDAT - _VSFFDEF = VSFFDEF ; VSFFDEF - _VSFFIDX = VSFFIDX ; VSFFIDX - _VSFFNAS = VSFFNAS ; VSFFNAS - _VSFFND = VSFFND ; VSFFND - _VSFGCAT = VSFGCAT ; VSFGCAT - _VSFGCLS = VSFGCLS ; VSFGCLS - _VSFGFLD = VSFGFLD ; VSFGFLD - _VSFGID = VSFGID ; VSFGID - _VSFGINT = VSFGINT ; VSFGINT - _VSFGNAM = VSFGNAM ; VSFGNAM - _VSFGNAT = VSFGNAT ; VSFGNAT - _VSFINQ = VSFINQ ; VSFINQ - _VSFISAT = VSFISAT ; VSFISAT - _VSFLONE = VSFLONE ; VSFLONE - _VSFNATS = VSFNATS ; VSFNATS - _VSFNCPK = VSFNCPK ; VSFNCPK - _VSFNDC = VSFNDC ; VSFNDC - _VSFNPAK = VSFNPAK ; VSFNPAK - _VSFRD = VSFRD ; VSFRD - _VSFRDC = VSFRDC ; VSFRDC - _VSFREAD = VSFREAD ; VSFREAD - _VSFSCAT = VSFSCAT ; VSFSCAT - _VSFSCLS = VSFSCLS ; VSFSCLS - _VSFSEEK = VSFSEEK ; VSFSEEK - _VSFSEXTF = VSFSEXTF ; VSFSEXTF - _VSFSFLD = VSFSFLD ; VSFSFLD - _VSFSINT = VSFSINT ; VSFSINT - _VSFSIZ = VSFSIZ ; VSFSIZ - _VSFSNAM = VSFSNAM ; VSFSNAM - _VSFSNAT = VSFSNAT ; VSFSNAT - _VSFWRIT = VSFWRIT ; VSFWRIT - _VSFWRT = VSFWRT ; VSFWRT - _VSFWRTC = VSFWRTC ; VSFWRTC - _VSGCLSC = VSGCLSC ; VSGCLSC - _VSGFLDC = VSGFLDC ; VSGFLDC - _VSGIDC = VSGIDC ; VSGIDC - _VSGINTC = VSGINTC ; VSGINTC - _VSGNAMC = VSGNAMC ; VSGNAMC - _VSGVER = VSGVER ; VSGVER - _VSINQC = VSINQC ; VSINQC - _VSLONEC = VSLONEC ; VSLONEC - _VSNAMC = VSNAMC ; VSNAMC - _VSPhshutdown = VSPhshutdown ; VSPhshutdown - _VSPshutdown = VSPshutdown ; VSPshutdown - _VSQFFLDS = VSQFFLDS ; VSQFFLDS - _VSQFINTR = VSQFINTR ; VSQFINTR - _VSQFLDSC = VSQFLDSC ; VSQFLDSC - _VSQFNAME = VSQFNAME ; VSQFNAME - _VSQFNELT = VSQFNELT ; VSQFNELT - _VSQFVSIZ = VSQFVSIZ ; VSQFVSIZ - _VSQNAMEC = VSQNAMEC ; VSQNAMEC - _VSQREF = VSQREF ; VSQREF - _VSQTAG = VSQTAG ; VSQTAG - _VSQueryref = VSQueryref ; VSQueryref - _VSQuerytag = VSQuerytag ; VSQuerytag - _VSREADC = VSREADC ; VSREADC - _VSSCLSC = VSSCLSC ; VSSCLSC - _VSSEEKC = VSSEEKC ; VSSEEKC - _VSSEXTFC = VSSEXTFC ; VSSEXTFC - _VSSFLDC = VSSFLDC ; VSSFLDC - _VSSINTC = VSSINTC ; VSSINTC - _VSSIZC = VSSIZC ; VSSIZC - _VSSNAMC = VSSNAMC ; VSSNAMC - _VSWRITC = VSWRITC ; VSWRITC - _VSappendable = VSappendable ; VSappendable - _VSattach = VSattach ; VSattach - _VSattrinfo = VSattrinfo ; VSattrinfo - _VSdelete = VSdelete ; VSdelete - _VSdetach = VSdetach ; VSdetach - _VSdump = VSdump ; VSdump - _VSelts = VSelts ; VSelts - _VSfdefine = VSfdefine ; VSfdefine - _VSfexist = VSfexist ; VSfexist - _VSfind = VSfind ; VSfind - _VSfindattr = VSfindattr ; VSfindattr - _VSfindclass = VSfindclass ; VSfindclass - _VSfindex = VSfindex ; VSfindex - _VSfnattrs = VSfnattrs ; VSfnattrs - _VSfpack = VSfpack ; VSfpack - _VSgetattr = VSgetattr ; VSgetattr - _VSgetclass = VSgetclass ; VSgetclass - _VSgetfields = VSgetfields ; VSgetfields - _VSgetid = VSgetid ; VSgetid - _VSgetinterlace = VSgetinterlace ; VSgetinterlace - _VSgetname = VSgetname ; VSgetname - _VSgetversion = VSgetversion ; VSgetversion - _VSinquire = VSinquire ; VSinquire - _VSisattr = VSisattr ; VSisattr - _VSlone = VSlone ; VSlone - _VSnattrs = VSnattrs ; VSnattrs - _VSread = VSread ; VSread - _VSseek = VSseek ; VSseek - _VSsetattr = VSsetattr ; VSsetattr - _VSsetclass = VSsetclass ; VSsetclass - _VSsetexternalfile = VSsetexternalfile ; VSsetexternalfile - _VSsetfields = VSsetfields ; VSsetfields - _VSsetinterlace = VSsetinterlace ; VSsetinterlace - _VSsetname = VSsetname ; VSsetname - _VSsizeof = VSsizeof ; VSsizeof - _VSwrite = VSwrite ; VSwrite - _Vaddtagref = Vaddtagref ; Vaddtagref - _Vattach = Vattach ; Vattach - _Vattrinfo = Vattrinfo ; Vattrinfo - _Vclose = Vclose ; Vclose - _Vdelete = Vdelete ; Vdelete - _Vdeletetagref = Vdeletetagref ; Vdeletetagref - _Vdetach = Vdetach ; Vdetach - _Ventries = Ventries ; Ventries - _Vfind = Vfind ; Vfind - _Vfindattr = Vfindattr ; Vfindattr - _Vfindclass = Vfindclass ; Vfindclass - _Vfinish = Vfinish ; Vfinish - _Vflocate = Vflocate ; Vflocate - _Vgetattr = Vgetattr ; Vgetattr - _Vgetclass = Vgetclass ; Vgetclass - _Vgetid = Vgetid ; Vgetid - _Vgetname = Vgetname ; Vgetname - _Vgetnext = Vgetnext ; Vgetnext - _Vgettagref = Vgettagref ; Vgettagref - _Vgettagrefs = Vgettagrefs ; Vgettagrefs - _Vgetversion = Vgetversion ; Vgetversion - _Vinitialize = Vinitialize ; Vinitialize - _Vinqtagref = Vinqtagref ; Vinqtagref - _Vinquire = Vinquire ; Vinquire - _Vinsert = Vinsert ; Vinsert - _Visvg = Visvg ; Visvg - _Visvs = Visvs ; Visvs - _Vlone = Vlone ; Vlone - _Vnattrs = Vnattrs ; Vnattrs - _Vnrefs = Vnrefs ; Vnrefs - _Vntagrefs = Vntagrefs ; Vntagrefs - _Vopen = Vopen ; Vopen - _Vsetattr = Vsetattr ; Vsetattr - _Vsetclass = Vsetclass ; Vsetclass - _Vsetname = Vsetname ; Vsetname - _Vsetzap = Vsetzap ; Vsetzap - AFANNLEN = _AFANNLEN@4 - AFANNLIST = _AFANNLIST@20 - AFATYPETAG = _AFATYPETAG@4 - AFCREATE = _AFCREATE@16 - AFEND = _AFEND@4 - AFENDACCESS = _AFENDACCESS@4 - AFFCREATE = _AFFCREATE@8 - AFFILEINFO = _AFFILEINFO@20 - AFGETTAGREF = _AFGETTAGREF@20 - AFIDTAGREF = _AFIDTAGREF@12 - AFNUMANN = _AFNUMANN@16 - AFREADANN = _AFREADANN@16 - AFSELECT = _AFSELECT@12 - AFSTART = _AFSTART@4 - AFTAGATYPE = _AFTAGATYPE@4 - AFTAGREFID = _AFTAGREFID@12 - AFWRITEANN = _AFWRITEANN@16 - HCLOSE = _HCLOSE@4 - HESTRING = _HESTRING@12 - HGFILVER = _HGFILVER@24 - HGLIBVER = _HGLIBVER@20 - HISHDF = _HISHDF@8 - HNUMBER = _HNUMBER@8 - HOPEN = _HOPEN@16 - HXSCDIR = _HXSCDIR@8 - HXSDIR = _HXSDIR@8 - MGATINF = _MGATINF@24 - MGCREAT = _MGCREAT@28 - MGEND = _MGEND@4 - MGENDAC = _MGENDAC@4 - MGFINFO = _MGFINFO@12 - MGFNDAT = _MGFNDAT@12 - MGGATTR = _MGGATTR@12 - MGGCATT = _MGGCATT@16 - MGGICHNK = _MGGICHNK@12 - MGGIINF = _MGGIINF@32 - MGGLINF = _MGGLINF@20 - MGGLTID = _MGGLTID@8 - MGGNATT = _MGGNATT@12 - MGID2RF = _MGID2RF@4 - MGN2NDX = _MGN2NDX@12 - MGR2IDX = _MGR2IDX@8 - MGRCCHNK = _MGRCCHNK@16 - MGRCHNK = _MGRCHNK@12 - MGRCIMG = _MGRCIMG@24 - MGRCLUT = _MGRCLUT@12 - MGRDIMG = _MGRDIMG@20 - MGRDLUT = _MGRDLUT@8 - MGRIMIL = _MGRIMIL@8 - MGRLTIL = _MGRLTIL@8 - MGSACTP = _MGSACTP@8 - MGSCATT = _MGSCATT@28 - MGSCCHNK = _MGSCCHNK@12 - MGSCHNK = _MGSCHNK@16 - MGSCOMPRESS = _MGSCOMPRESS@12 - MGSELCT = _MGSELCT@8 - MGSNATT = _MGSNATT@24 - MGSTART = _MGSTART@4 - MGSXFIL = _MGSXFIL@16 - MGWCCHNK = _MGWCCHNK@16 - MGWCHNK = _MGWCHNK@12 - MGWCIMG = _MGWCIMG@24 - MGWCLUT = _MGWCLUT@28 - MGWRIMG = _MGWRIMG@20 - MGWRLUT = _MGWRLUT@24 - VDELETE = _VDELETE@8 - VFADTR = _VFADTR@12 - VFAINFO = _VFAINFO@28 - VFATCH = _VFATCH@16 - VFDTCH = _VFDTCH@4 - VFDTR = _VFDTR@12 - VFEND = _VFEND@4 - VFENTS = _VFENTS@8 - VFFDATT = _VFFDATT@12 - VFFESIZ = _VFFESIZ@8 - VFFISIZ = _VFFISIZ@8 - VFFLOC = _VFFLOC@12 - VFFNAME = _VFFNAME@16 - VFFORDR = _VFFORDR@8 - VFFTYPE = _VFFTYPE@8 - VFGCATT = _VFGCATT@16 - VFGCLS = _VFGCLS@12 - VFGID = _VFGID@8 - VFGNAM = _VFGNAM@12 - VFGNATT = _VFGNATT@12 - VFGNXT = _VFGNXT@8 - VFGTTR = _VFGTTR@16 - VFGTTRS = _VFGTTRS@16 - VFGVER = _VFGVER@4 - VFIND = _VFIND@12 - VFINQ = _VFINQ@16 - VFINQTR = _VFINQTR@12 - VFINSRT = _VFINSRT@8 - VFISVG = _VFISVG@8 - VFISVS = _VFISVS@8 - VFLONE = _VFLONE@12 - VFNATTS = _VFNATTS@4 - VFNDCLS = _VFNDCLS@12 - VFNFLDS = _VFNFLDS@4 - VFNTR = _VFNTR@4 - VFSCATT = _VFSCATT@28 - VFSCLS = _VFSCLS@12 - VFSNAM = _VFSNAM@12 - VFSNATT = _VFSNATT@24 - VFSTART = _VFSTART@4 - VHFMKGP = _VHFMKGP@32 - VHFSCD = _VHFSCD@44 - VHFSCDM = _VHFSCDM@48 - VHFSD = _VHFSD@40 - VHFSDM = _VHFSDM@44 - VNREFS = _VNREFS@8 - VQREF = _VQREF@4 - VQTAG = _VQTAG@4 - VSFAINF = _VSFAINF@32 - VSFATCH = _VSFATCH@16 - VSFCPAK = _VSFCPAK@44 - VSFDLTE = _VSFDLTE@8 - VSFDTCH = _VSFDTCH@4 - VSFELTS = _VSFELTS@4 - VSFEX = _VSFEX@12 - VSFFCLS = _VSFFCLS@12 - VSFFDAT = _VSFFDAT@16 - VSFFDEF = _VSFFDEF@20 - VSFFIDX = _VSFFIDX@16 - VSFFNAS = _VSFFNAS@8 - VSFFND = _VSFFND@12 - VSFGCAT = _VSFGCAT@20 - VSFGCLS = _VSFGCLS@12 - VSFGFLD = _VSFGFLD@12 - VSFGID = _VSFGID@8 - VSFGINT = _VSFGINT@4 - VSFGNAM = _VSFGNAM@12 - VSFGNAT = _VSFGNAT@16 - VSFINQ = _VSFINQ@32 - VSFISAT = _VSFISAT@4 - VSFLONE = _VSFLONE@12 - VSFNATS = _VSFNATS@4 - VSFNPAK = _VSFNPAK@40 - VSFRD = _VSFRD@16 - VSFRDC = _VSFRDC@20 - VSFREAD = _VSFREAD@20 - VSFSCAT = _VSFSCAT@32 - VSFSCLS = _VSFSCLS@12 - VSFSEEK = _VSFSEEK@8 - VSFSEXTF = _VSFSEXTF@16 - VSFSFLD = _VSFSFLD@12 - VSFSINT = _VSFSINT@8 - VSFSIZ = _VSFSIZ@12 - VSFSNAM = _VSFSNAM@12 - VSFSNAT = _VSFSNAT@28 - VSFWRIT = _VSFWRIT@20 - VSFWRT = _VSFWRT@16 - VSFWRTC = _VSFWRTC@20 - VSGVER = _VSGVER@4 - VSQFFLDS = _VSQFFLDS@12 - VSQFINTR = _VSQFINTR@8 - VSQFNAME = _VSQFNAME@12 - VSQFNELT = _VSQFNELT@8 - VSQFVSIZ = _VSQFVSIZ@8 - VSQREF = _VSQREF@4 - VSQTAG = _VSQTAG@4 - _rigcompare = rigcompare ; rigcompare - _scanattrs = scanattrs ; scanattrs - _tagcompare = tagcompare ; tagcompare - _tagdestroynode = tagdestroynode ; tagdestroynode - _vcheckcompat = vcheckcompat ; vcheckcompat - _vcompare = vcompare ; vcompare - _vdestroynode = vdestroynode ; vdestroynode - _vexistvg = vexistvg ; vexistvg - _vexistvs = vexistvs ; vexistvs - _vfdestroynode = vfdestroynode ; vfdestroynode - _vicheckcompat = vicheckcompat ; vicheckcompat - _vimakecompat = vimakecompat ; vimakecompat - _vmakecompat = vmakecompat ; vmakecompat - _vsdestroynode = vsdestroynode ; vsdestroynode diff --git a/bindings/java/bin/win32/hd413m.dll b/bindings/java/bin/win32/hd413m.dll deleted file mode 100644 index 07fc807a..00000000 Binary files a/bindings/java/bin/win32/hd413m.dll and /dev/null differ diff --git a/bindings/java/bin/win32/hd413m.lib b/bindings/java/bin/win32/hd413m.lib deleted file mode 100644 index bf9a4108..00000000 Binary files a/bindings/java/bin/win32/hd413m.lib and /dev/null differ diff --git a/bindings/java/bin/win32/hd415m.dll b/bindings/java/bin/win32/hd415m.dll deleted file mode 100755 index bc116f0f..00000000 Binary files a/bindings/java/bin/win32/hd415m.dll and /dev/null differ diff --git a/bindings/java/bin/win32/hdf5dll.dll b/bindings/java/bin/win32/hdf5dll.dll deleted file mode 100755 index ec0e172e..00000000 Binary files a/bindings/java/bin/win32/hdf5dll.dll and /dev/null differ diff --git a/bindings/java/bin/win32/hm413m.def b/bindings/java/bin/win32/hm413m.def deleted file mode 100644 index 6fbdacd1..00000000 --- a/bindings/java/bin/win32/hm413m.def +++ /dev/null @@ -1,201 +0,0 @@ -LIBRARY HM413M.DLL - -EXPORTS - _SDattrinfo = SDattrinfo ; SDattrinfo - _SDcheckempty = SDcheckempty ; SDcheckempty - _SDcreate = SDcreate ; SDcreate - _SDdiminfo = SDdiminfo ; SDdiminfo - _SDend = SDend ; SDend - _SDendaccess = SDendaccess ; SDendaccess - _SDfileinfo = SDfileinfo ; SDfileinfo - _SDfindattr = SDfindattr ; SDfindattr - _SDgetcal = SDgetcal ; SDgetcal - _SDgetchunkinfo = SDgetchunkinfo ; SDgetchunkinfo - _SDgetdatastrs = SDgetdatastrs ; SDgetdatastrs - _SDgetdimid = SDgetdimid ; SDgetdimid - _SDgetdimscale = SDgetdimscale ; SDgetdimscale - _SDgetdimstrs = SDgetdimstrs ; SDgetdimstrs - _SDgetfillvalue = SDgetfillvalue ; SDgetfillvalue - _SDgetinfo = SDgetinfo ; SDgetinfo - _SDgetrange = SDgetrange ; SDgetrange - _SDidtoref = SDidtoref ; SDidtoref - _SDiscoordvar = SDiscoordvar ; SDiscoordvar - _SDisdimval_bwcomp = SDisdimval_bwcomp ; SDisdimval_bwcomp - _SDisrecord = SDisrecord ; SDisrecord - _SDnametoindex = SDnametoindex ; SDnametoindex - _SDreadattr = SDreadattr ; SDreadattr - _SDreadchunk = SDreadchunk ; SDreadchunk - _SDreaddata = SDreaddata ; SDreaddata - _SDreftoindex = SDreftoindex ; SDreftoindex - _SDselect = SDselect ; SDselect - _SDsetaccesstype = SDsetaccesstype ; SDsetaccesstype - _SDsetattr = SDsetattr ; SDsetattr - _SDsetblocksize = SDsetblocksize ; SDsetblocksize - _SDsetcal = SDsetcal ; SDsetcal - _SDsetchunk = SDsetchunk ; SDsetchunk - _SDsetchunkcache = SDsetchunkcache ; SDsetchunkcache - _SDsetcompress = SDsetcompress ; SDsetcompress - _SDsetdatastrs = SDsetdatastrs ; SDsetdatastrs - _SDsetdimname = SDsetdimname ; SDsetdimname - _SDsetdimscale = SDsetdimscale ; SDsetdimscale - _SDsetdimstrs = SDsetdimstrs ; SDsetdimstrs - _SDsetdimval_comp = SDsetdimval_comp ; SDsetdimval_comp - _SDsetexternalfile = SDsetexternalfile ; SDsetexternalfile - _SDsetfillmode = SDsetfillmode ; SDsetfillmode - _SDsetfillvalue = SDsetfillvalue ; SDsetfillvalue - _SDsetnbitdataset = SDsetnbitdataset ; SDsetnbitdataset - _SDsetrange = SDsetrange ; SDsetrange - _SDstart = SDstart ; SDstart - _SDwritechunk = SDwritechunk ; SDwritechunk - _SDwritedata = SDwritedata ; SDwritedata - _SFCHEMPTY = SFCHEMPTY ; SFCHEMPTY - _SFCREATE = SFCREATE ; SFCREATE - _SFDIMID = SFDIMID ; SFDIMID - _SFEND = SFEND ; SFEND - _SFENDACC = SFENDACC ; SFENDACC - _SFFATTR = SFFATTR ; SFFATTR - _SFFINFO = SFFINFO ; SFFINFO - _SFGAINFO = SFGAINFO ; SFGAINFO - _SFGCAL = SFGCAL ; SFGCAL - _SFGCFILL = SFGCFILL ; SFGCFILL - _SFGDINFO = SFGDINFO ; SFGDINFO - _SFGDMSTR = SFGDMSTR ; SFGDMSTR - _SFGDSCALE = SFGDSCALE ; SFGDSCALE - _SFGDTSTR = SFGDTSTR ; SFGDTSTR - _SFGFILL = SFGFILL ; SFGFILL - _SFGICHNK = SFGICHNK ; SFGICHNK - _SFGINFO = SFGINFO ; SFGINFO - _SFGRANGE = SFGRANGE ; SFGRANGE - _SFID2REF = SFID2REF ; SFID2REF - _SFISCVAR = SFISCVAR ; SFISCVAR - _SFISDMVC = SFISDMVC ; SFISDMVC - _SFISRCRD = SFISRCRD ; SFISRCRD - _SFN2INDEX = SFN2INDEX ; SFN2INDEX - _SFRATTR = SFRATTR ; SFRATTR - _SFRCATT = SFRCATT ; SFRCATT - _SFRCCHNK = SFRCCHNK ; SFRCCHNK - _SFRCDATA = SFRCDATA ; SFRCDATA - _SFRCHNK = SFRCHNK ; SFRCHNK - _SFRDATA = SFRDATA ; SFRDATA - _SFREF2INDEX = SFREF2INDEX ; SFREF2INDEX - _SFRNATT = SFRNATT ; SFRNATT - _SFSACCT = SFSACCT ; SFSACCT - _SFSATTR = SFSATTR ; SFSATTR - _SFSBLSZ = SFSBLSZ ; SFSBLSZ - _SFSCAL = SFSCAL ; SFSCAL - _SFSCATT = SFSCATT ; SFSCATT - _SFSCCHNK = SFSCCHNK ; SFSCCHNK - _SFSCFILL = SFSCFILL ; SFSCFILL - _SFSCHNK = SFSCHNK ; SFSCHNK - _SFSCOMPRESS = SFSCOMPRESS ; SFSCOMPRESS - _SFSDMNAME = SFSDMNAME ; SFSDMNAME - _SFSDMSTR = SFSDMSTR ; SFSDMSTR - _SFSDMVC = SFSDMVC ; SFSDMVC - _SFSDSCALE = SFSDSCALE ; SFSDSCALE - _SFSDTSTR = SFSDTSTR ; SFSDTSTR - _SFSELECT = SFSELECT ; SFSELECT - _SFSEXTF = SFSEXTF ; SFSEXTF - _SFSFILL = SFSFILL ; SFSFILL - _SFSFLMD = SFSFLMD ; SFSFLMD - _SFSNATT = SFSNATT ; SFSNATT - _SFSNBIT = SFSNBIT ; SFSNBIT - _SFSRANGE = SFSRANGE ; SFSRANGE - _SFSTART = SFSTART ; SFSTART - _SFWCCHNK = SFWCCHNK ; SFWCCHNK - _SFWCDATA = SFWCDATA ; SFWCDATA - _SFWCHNK = SFWCHNK ; SFWCHNK - _SFWDATA = SFWDATA ; SFWDATA - SFCHEMPTY = _SFCHEMPTY@8 - SFCREATE = _SFCREATE@24 - SFDIMID = _SFDIMID@8 - SFEND = _SFEND@4 - SFENDACC = _SFENDACC@4 - SFFATTR = _SFFATTR@12 - SFFINFO = _SFFINFO@12 - SFGAINFO = _SFGAINFO@24 - SFGCAL = _SFGCAL@24 - SFGCFILL = _SFGCFILL@12 - SFGDINFO = _SFGDINFO@24 - SFGDMSTR = _SFGDMSTR@32 - SFGDSCALE = _SFGDSCALE@8 - SFGDTSTR = _SFGDTSTR@40 - SFGFILL = _SFGFILL@8 - SFGICHNK = _SFGICHNK@12 - SFGINFO = _SFGINFO@28 - SFGRANGE = _SFGRANGE@12 - SFID2REF = _SFID2REF@4 - SFISCVAR = _SFISCVAR@4 - SFISDMVC = _SFISDMVC@4 - SFISRCRD = _SFISRCRD@4 - SFN2INDEX = _SFN2INDEX@12 - SFRATTR = _SFRATTR@16 - SFRCATT = _SFRCATT@16 - SFRCCHNK = _SFRCCHNK@16 - SFRCDATA = _SFRCDATA@24 - SFRCHNK = _SFRCHNK@12 - SFRDATA = _SFRDATA@20 - SFREF2INDEX = _SFREF2INDEX@8 - SFRNATT = _SFRNATT@12 - SFSACCT = _SFSACCT@8 - SFSATTR = _SFSATTR@28 - SFSBLSZ = _SFSBLSZ@8 - SFSCAL = _SFSCAL@24 - SFSCATT = _SFSCATT@28 - SFSCCHNK = _SFSCCHNK@12 - SFSCFILL = _SFSCFILL@12 - SFSCHNK = _SFSCHNK@16 - SFSCOMPRESS = _SFSCOMPRESS@12 - SFSDMNAME = _SFSDMNAME@12 - SFSDMSTR = _SFSDMSTR@28 - SFSDMVC = _SFSDMVC@8 - SFSDSCALE = _SFSDSCALE@16 - SFSDTSTR = _SFSDTSTR@36 - SFSELECT = _SFSELECT@8 - SFSEXTF = _SFSEXTF@16 - SFSFILL = _SFSFILL@8 - SFSFLMD = _SFSFLMD@8 - SFSNATT = _SFSNATT@24 - SFSNBIT = _SFSNBIT@20 - SFSRANGE = _SFSRANGE@12 - SFSTART = _SFSTART@12 - SFWCCHNK = _SFWCCHNK@16 - SFWCDATA = _SFWCDATA@24 - SFWCHNK = _SFWCHNK@12 - SFWDATA = _SFWDATA@20 - _ncabort = ncabort ; ncabort - _ncattcopy = ncattcopy ; ncattcopy - _ncattdel = ncattdel ; ncattdel - _ncattget = ncattget ; ncattget - _ncattinq = ncattinq ; ncattinq - _ncattname = ncattname ; ncattname - _ncattput = ncattput ; ncattput - _ncattrename = ncattrename ; ncattrename - _ncclose = ncclose ; ncclose - _nccreate = nccreate ; nccreate - _ncdimdef = ncdimdef ; ncdimdef - _ncdimid = ncdimid ; ncdimid - _ncdiminq = ncdiminq ; ncdiminq - _ncdimrename = ncdimrename ; ncdimrename - _ncendef = ncendef ; ncendef - _ncinquire = ncinquire ; ncinquire - _ncopen = ncopen ; ncopen - _ncopts = ncopts ; ncopts - _ncrecget = ncrecget ; ncrecget - _ncrecinq = ncrecinq ; ncrecinq - _ncrecput = ncrecput ; ncrecput - _ncredef = ncredef ; ncredef - _ncsetfill = ncsetfill ; ncsetfill - _ncsync = ncsync ; ncsync - _nctypelen = nctypelen ; nctypelen - _ncvardef = ncvardef ; ncvardef - _ncvarget = ncvarget ; ncvarget - _ncvarget1 = ncvarget1 ; ncvarget1 - _ncvargetg = ncvargetg ; ncvargetg - _ncvargets = ncvargets ; ncvargets - _ncvarid = ncvarid ; ncvarid - _ncvarinq = ncvarinq ; ncvarinq - _ncvarput = ncvarput ; ncvarput - _ncvarput1 = ncvarput1 ; ncvarput1 - _ncvarputg = ncvarputg ; ncvarputg - _ncvarputs = ncvarputs ; ncvarputs - _ncvarrename = ncvarrename ; ncvarrename diff --git a/bindings/java/bin/win32/hm413m.dll b/bindings/java/bin/win32/hm413m.dll deleted file mode 100644 index 174d739f..00000000 Binary files a/bindings/java/bin/win32/hm413m.dll and /dev/null differ diff --git a/bindings/java/bin/win32/hm413m.lib b/bindings/java/bin/win32/hm413m.lib deleted file mode 100644 index 9344f8a0..00000000 Binary files a/bindings/java/bin/win32/hm413m.lib and /dev/null differ diff --git a/bindings/java/bin/win32/hm415m.dll b/bindings/java/bin/win32/hm415m.dll deleted file mode 100755 index 0445bf77..00000000 Binary files a/bindings/java/bin/win32/hm415m.dll and /dev/null differ diff --git a/bindings/java/bin/win32/szlibdll.dll b/bindings/java/bin/win32/szlibdll.dll deleted file mode 100755 index ebb39ff4..00000000 Binary files a/bindings/java/bin/win32/szlibdll.dll and /dev/null differ diff --git a/bindings/java/bin/win32/zlib.dll b/bindings/java/bin/win32/zlib.dll deleted file mode 100755 index b27eaf4c..00000000 Binary files a/bindings/java/bin/win32/zlib.dll and /dev/null differ diff --git a/contrib/.cvsignore b/contrib/.cvsignore deleted file mode 100644 index 282522db..00000000 --- a/contrib/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/contrib/README b/contrib/README index d2ca46d4..71133667 100644 --- a/contrib/README +++ b/contrib/README @@ -1,6 +1,6 @@ -This directory contains software contributed by the neutron community that -is not (yet) part of the official NeXus distribution. Its structure should -mirror that of the top directory i.e. have bindings, test and applications +This directory contains software contributed by the community that is not +(yet) part of the official NeXus distribution. Its structure should mirror +that of the top directory i.e. have bindings, test and applications sub-directories. $Id$ diff --git a/contrib/applications/.cvsignore b/contrib/applications/.cvsignore deleted file mode 100644 index 282522db..00000000 --- a/contrib/applications/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/contrib/applications/CMakeLists.txt b/contrib/applications/CMakeLists.txt index c5f105d2..139d116a 100644 --- a/contrib/applications/CMakeLists.txt +++ b/contrib/applications/CMakeLists.txt @@ -28,5 +28,3 @@ add_subdirectory (CBFLib) add_subdirectory (NXextract) - - diff --git a/contrib/applications/Makefile.am b/contrib/applications/Makefile.am index b2b9b08d..17a685d2 100644 --- a/contrib/applications/Makefile.am +++ b/contrib/applications/Makefile.am @@ -6,10 +6,6 @@ # @configure_input@ # #==================================================================== -#if HAVE_LIBXML2 -#NXTRANSLATE=NXtranslate -#endif -#SUBDIRS = NXdir $(NXTRANSLATE) if HAVE_CBFLIB CBFLIB=CBFLib endif diff --git a/contrib/applications/NXformat_dfn/NXconvert.py b/contrib/applications/NXformat_dfn/NXconvert.py deleted file mode 100755 index 5292e445..00000000 --- a/contrib/applications/NXformat_dfn/NXconvert.py +++ /dev/null @@ -1,191 +0,0 @@ -#!env python - -""" -Form to convert NeXus XML definition files into formatted HTML -R. Osborn 2002/4/6 -""" - -import cgitb; cgitb.enable() -import cgi, os, re -from StringIO import * -from urllib import * -from xml.dom.minidom import * - -rootURL = "http://127.0.0.1/nexus/" -XMLdir = rootURL+"xml" -homeLink = 'NeXus Home Page' -glossaryLink = 'NeXus Glossary' -instrumentLink = 'NeXus Instruments' -metaLink = 'NeXus Meta-DTD Format' -reComment = re.compile(r"\<\!--([\s\S]*)--\>") - -def FormatStartTag(node): - "Write element name and attributes as a start tag" - buffer = StringIO() - try: - node.tagName.index("NX") - class_ = "group" - except ValueError: - class_ = "data" - buffer.write('' % class_) - buffer.write(cgi.escape('<')) - try: - node.tagName.index("NX") - buffer.write('') - buffer.write(node.tagName) - buffer.write('') - except ValueError: - buffer.write(node.tagName) - if node.hasAttributes(): - buffer.write('') - buffer.write(FormatAttributes(node)) - buffer.write('' % class_) - buffer.write(cgi.escape('>')) - buffer.write('\n') - return buffer.getvalue() - -def FormatEndTag(node): - "Write element name as an end tag" - buffer = StringIO() - try: - node.tagName.index("NX") - class_ = "group" - except ValueError: - class_ = "data" - buffer.write('' % class_) - buffer.write(cgi.escape('')) - buffer.write('\n') - return buffer.getvalue() - -def FormatAttributes(node): - "Write element attributes" - buffer = StringIO() - buffer.write('') - keys = node.attributes.keys() - for key in keys: - buffer.write(' '+key+'="') - buffer.write(node.attributes[key].value) - buffer.write('"') - buffer.write('') - return buffer.getvalue() - -def FormatXMLTag(): - "Write XML definition tag" - buffer = StringIO() - buffer.write('') - buffer.write(cgi.escape('')) - buffer.write('\n') - return buffer.getvalue() - -def HTMLelement(node, indent="", - addindent="        "): - "Write HTML formatting for each type of node" - buffer = StringIO() - if node.nodeType == node.DOCUMENT_NODE: - for childNode in node.childNodes: - buffer.write(HTMLelement(childNode,indent,addindent)) - elif node.nodeType == node.ELEMENT_NODE: - buffer.write('
'+indent+FormatStartTag(node)) - for childNode in node.childNodes: - buffer.write(HTMLelement(childNode,indent+addindent,addindent)) - if len(node.childNodes)>1: buffer.write('
'+indent) - buffer.write(FormatEndTag(node)) - elif node.nodeType == node.TEXT_NODE: - text = node.data.strip() - if len(text)>0: - buffer.write('') - buffer.write(text) - buffer.write('\n') - return buffer.getvalue() - -def HTMLhead(title): - "Return string for head of HTML page" - buffer = StringIO() - buffer.write('\n') - buffer.write('\n') - buffer.write('\n') - buffer.write(''+title+'\n') - buffer.write('\n') - buffer.write('\n') - buffer.write('\n') - buffer.write('

') - buffer.write('\n') - buffer.write('

\n') - buffer.write('

'+title+'

\n') - buffer.write('
\n') - buffer.write(FormatXMLTag()) - return buffer.getvalue() - -def HTMLcomments(text): - "Return string for foot of HTML page" - buffer = StringIO() - commentSearch = reComment.search(text) - if commentSearch: - comment = cgi.escape(commentSearch.group()) - buffer.write('') - buffer.write('
'+comment.replace('\n','
')) - buffer.write('
\n') - return buffer.getvalue() - else: - pass - -def HTMLfile(file_name): - "Return string for foot of HTML page" - buffer = StringIO() - buffer.write('
\n') - buffer.write('

\n') - buffer.write('[') - buffer.write('Download '+file_name+']\n') - buffer.write('

\n') - return buffer.getvalue() - -def HTMLfoot(links): - "Return string for foot of HTML page" - buffer = StringIO() - buffer.write('
\n') - buffer.write('

\n') - buffer.write('['+' | '.join(links)+']\n') - buffer.write('

\n') - buffer.write('\n') - buffer.write('\n') - return buffer.getvalue() - -def ConvertToHTML(text): - "Convert XML text into formatted HTML" - doc = parseString(text) - return HTMLelement(doc) - -def main(): - "Output XML file as formatted HTML" - try: - form = cgi.FieldStorage() - print 'Content-type: text/html' - print - if form.has_key("file"): - file_name = form["file"].value - file = urlopen(os.path.join(XMLdir,file_name)) - text = file.read() - file.close() - print HTMLhead(file_name) - print HTMLcomments(text) - doc = parseString(text) - doc.normalize() - print HTMLelement(doc) - print HTMLfile(file_name) - print HTMLfoot([homeLink,glossaryLink,instrumentLink,metaLink]) - except: - cgi.print_exception() - -main() - diff --git a/contrib/applications/NXformat_dfn/NXformat_dfn.py b/contrib/applications/NXformat_dfn/NXformat_dfn.py deleted file mode 100755 index e6788105..00000000 --- a/contrib/applications/NXformat_dfn/NXformat_dfn.py +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env python - -import format_docbook -import format_xml -import StringIO -from xml.dom.minidom import parse - -def copy_dictionary(orig): - copy={} - for key in orig.keys(): - copy[key]=orig[key] - return copy - -def get_path(file): - """Determine the directory name that a file exists in (if specified)""" - - # default value for end - end=0 - - # try linux path separator - try: - end=file.rindex("/") - except ValueError: - pass # let it drop on the floor - if(end): return file[:end]+"/" - - # try windows path separator - try: - end=file.rindex("\\") - except ValueError: - pass # let it drop on the floor - if(end): return file[:end]+"\\" - - # the path must not have been specified - return "" - -def get_root_name(file): - """Determine the root of the filename assuming that it either ends - with '.xml' or is already a root""" - - # determine the path and strip it off - begin=get_path(file).__len__() - - # determine where the result ends - ext=".xml" - end=file.__len__() - try: - end=file.rindex(ext) - except ValueError: - pass # let it drop on the floor - - # return the result - return file[begin:end] - -def print_usage(command,level=0): - print "USAGE:",command,"[options] " - print " where is the name of file to format" - if(level<1): # done after simple usage statement - return - print "" - print "This will format the file using the \"XML\" formatter unless specified." - - print "" - print "GENERAL:" - print " -d|--debug Increase debug level." - print " --docbook Use the docbook formatter." - print " --format Specify the formatter to use. The options are \"xml\"" - print " and \"docbook\". \"xml\" is the default." - print " -h|--help Print this help information." - print " -o Name of output file. If not specified uses STDOUT." - print " --root Specify the name of the definition." - print " --xml Use the xml formatter." - - print "" - print "For XML formatter: (default extension is \"%s\")" \ - % format_xml.get_def_ext() - print format_xml.get_command_line_doc() - - print "" - print "For DOCBOOK formatter: (default extension is \"%s\")" \ - % format_docbook.get_def_ext() - print format_docbook.get_command_line_doc() - -def process_file(infile, outfile, options, DEBUG=1, append=False): - # parse the xml file - if DEBUG: print "Processing \"%s\"" % infile - try: - doc=parse(infile) - except Exception, error: - print "ERROR:",error.__str__() - raise error - if DEBUG: print " ... done" - - # determine the path - path=get_path(infile) - - # determine the input name - try: - root_name=options.pop("--root") - except KeyError: - root_name=get_root_name(infile) - - # determine the proper formatter - try: - format_option=options.pop("--format") - except KeyError: - format_option="xml" - format_option=format_option.upper() - - # if output file name not supplied create the default one - if not outfile: - ext="" - if(format_option=="XML"): - ext=format_xml.get_def_ext() - elif(format_option=="DOCBOOK"): - ext=format_docbook.get_def_ext() - outfile="%s%s.%s" % (path,root_name,ext) - - # open the output file or create the buffer to write to - if DEBUG: print "Writing result to \"%s\"" % outfile - if DEBUG<=0: - if(append): - buffer=open(outfile,"a") - else: - buffer=open(outfile,"w") - else: - buffer=StringIO.StringIO() - - # if appending then add a newline to the end of the file - if(append): buffer.write("\n") - - # get the appropriate formatter - if DEBUG: print "Creating %s formatter" % format_option - if format_option=="XML": - formatter=format_xml.format_xml(root_name,options) - elif format_option=="DOCBOOK": - formatter=format_docbook.format_docbook(root_name,options) - else: - raise KeyError("no formatter named \"%s\"" % format_option) - if DEBUG: print " ... done" - - # format the DOM directly to the file buffer - if DEBUG: print "Formatting information" - formatter.format(doc,buffer) - if DEBUG: print " ... done" - - # if we are actually writting to STDOUT then print there now - if DEBUG: - string=buffer.getvalue() - if(string): - print string, - else: - print "EMPTY RESULT" - -def main(infile, outfile, options, DEBUG=1): - # deal with processing a single file - if not infile.__class__==[].__class__: - process_file(infile,outfile,options,DEBUG) - return - - # confirm that we are working without an output file name - append=False - first=True - if outfile: - append=True - else: - outfile="" - - # deal with no output file specified - for file in infile: - options_copy=copy_dictionary(options) - if first: - process_file(file,outfile,options_copy,DEBUG) - first=False - else: - process_file(file,outfile,options_copy,DEBUG,append) - - -if __name__ == "__main__": - # sys module only needed for command line operation - import sys - - # remove the program name from the command line arguments - progname=sys.argv[0] - sys.argv.remove(progname) - - # confirm that there are enough arguments to even bother - if sys.argv.__len__()<1: - print_usage(progname) - sys.exit(-1) - - # parse the command line options - options={} - debug=0 - infile=[] - outfile="" - while sys.argv.__len__()>0: - key=sys.argv[0] - sys.argv=sys.argv[1:] - if key.startswith("-"): - if key=="--help" or key=="-h": # print help - print_usage(progname,100) - sys.exit(0) - elif key=="--debug" or key=="-d": # increase debug level - debug=debug+1 - elif key=="--docbook": # use the docbook formatter - options["--format"]="docbook" - elif key=="--xml": # use the xml formatter - options["--format"]="xml" - else: - # get key and value - try: - index=key.index("=") - value=key[index+1:] - key=key[:index] - except ValueError: - value=sys.argv[0] - sys.argv=sys.argv[1:] - # check for special keys - if key=="-o": # output file selected - outfile=value - else: # everything else goes into the options slop bucket - options[key]=value - else: - infile.append(key) - - if infile.__len__()==1: - infile=infile[0] - - # pass the command line options to main - try: - main(infile,outfile,options,debug) - except Exception: - sys.exit(-1) diff --git a/contrib/applications/NXformat_dfn/NXprettyprint.py b/contrib/applications/NXformat_dfn/NXprettyprint.py deleted file mode 100755 index b2c97819..00000000 --- a/contrib/applications/NXformat_dfn/NXprettyprint.py +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/env python - -""" -Form to convert NeXus XML definition files into a formatted HTML table -R. Osborn 2004/02/12 -""" - -import sys, os, re, cgi -from urllib import * -from xml.dom.minidom import * -import HTML - -rootURL = "http://www.nexus.anl.gov/" -XMLurl = "http://www.nexus.anl.gov/classes/xml" -XMLdir = "/Users/osborn/Sites/nexus/classes/xml" -HTMLdir = "/Users/osborn/Sites/nexus/classes" -reComment = re.compile(r"\<\!--([\s\S]*?)--\>", re.DOTALL) -reValue = re.compile(r"([\s\S]*)[\?\*\+]") -reShort = re.compile(r"([\s\S]*){([\s\S]*)}", re.DOTALL) -reLong = re.compile(r"([\s\S]*){([\s\S]*)}.*{([\s\S]*)}", re.DOTALL) -reAttribute = re.compile(r"([\s\S]*){([\s\S]*)}", re.DOTALL) - -def XMLhead(NXclass): - "Return string for head of HTML page" - file = open("NXheader.txt","r") - header = file.read() - file.close() - title = NXclass+" Class" - output = HTML.headblock(title, header, stylesheet="%s/nexus.css" % rootURL) - return "%s\n%s" % (output, str(HTML.Header(title))) - -def XMLcomments(text): - "Return description of XML file contained in the initial comments" - comment = cgi.escape(reComment.search(text).groups()[0]) - return str(HTML.Para(comment.replace('\n', '
', 5))) - -def XMLtags(doc): - "Start table" - table = HTML.Table(["15%", "15%", "50%", "20%"], width="90%", - cellspacing="0") - row = HTML.Row() - row.Add(HTML.HeaderCell("Name")) - row.Add(HTML.HeaderCell("Type")) - row.Add(HTML.HeaderCell("Description")) - row.Add(HTML.HeaderCell("Attributes")) - table.Add(row) - for node in doc.childNodes[1].childNodes: - if node.nodeType == node.ELEMENT_NODE: - table.Add(XMLtag(node)) - return str(table) - -def XMLtag(node): - "Write HTML formatting for each type of node" - row = HTML.Row() - try: - node.tagName.index("NX") - row.Add(HTML.Cell(" ")) - url = node.tagName + ".html" - row.Add(HTML.Cell(HTML.anchor(url, node.tagName))) - except ValueError: - row.Add(HTML.Cell(node.tagName)) - NXtype = "NX_CHAR" - if node.hasAttributes(): - if "type" in node.attributes.keys(): - NXtype = node.attributes["type"].value - row.Add(HTML.Cell(NXtype)) - if len(node.childNodes) > 0: - cell = HTML.Cell() - longSearch = reLong.search(node.childNodes[0].data) - shortSearch = reShort.search(node.childNodes[0].data) - valueSearch = reValue.search(node.childNodes[0].data) - if longSearch: - value, shortDescription, longDescription = longSearch.groups() - value = value.strip() - if value: - cell.Add(cgi.escape(value)) - if shortDescription: - cell.Add(HTML.br()) - cell.Add(cgi.escape(shortDescription.strip())) - if shortDescription.strip() and longDescription.strip(): - cell.Add(HTML.br()) - cell.Add(HTML.Span(cgi.escape(longDescription.strip()), - class_="small")) - elif shortSearch: - value, shortDescription = shortSearch.groups() - value = value.strip() - if value: - cell.Add(cgi.escape(value)) - if shortDescription: - cell.Add(HTML.br()) - cell.Add(cgi.escape(shortDescription.strip())) - elif valueSearch: - value, = valueSearch.groups() - cell.Add(value.strip()) - row.Add(cell) - else: - row.Add(HTML.Cell(" ")) - cell = HTML.Cell() - try: - node.tagName.index("NX") - cell.Add(" ") - except ValueError: - text = "" - for key in node.attributes.keys(): - value = node.attributes[key].value - attributeSearch = reAttribute.search(value) - if key <> "type": - if text: text += HTML.br() - text += key - if attributeSearch: - value, shortDescription = attributeSearch.groups() - if value: - text += '="%s"' % value - text += "%s\n%s" % \ - (HTML.br(), - HTML.Span(cgi.escape(shortDescription), class_="small")) - else: - text +='="%s"' % node.attributes[key].value - if text: - cell.Add(text) - else: - cell.Add(" ") - row.Add(cell) - return row - -def XMLfile(fileName): - "Return link to the original XML file" - url = os.path.join(XMLurl, fileName) - return str(HTML.Para("%s%s%s" - % ("[", HTML.anchor(url, "Download "+fileName), "]"), - class_="center")) - -def XMLfoot(): - "Return string for foot of HTML page" - file = open("NXfooter.txt","r") - footer = file.read() - file.close() - return HTML.foot(footer=footer) - -def main(): - "Output XML file as formatted HTML" - NXclass = sys.argv[1] - fileName = sys.argv[1] + ".xml" - file = open(os.path.join(XMLdir, fileName)) - text = file.read() - file.close() - file = open(os.path.join(HTMLdir, NXclass+".html"), "w") - file.write(XMLhead(NXclass)) - file.write(XMLcomments(text)) - doc = parseString(text) - doc.normalize() - file.write(XMLtags(doc)) - file.write(XMLfile(fileName)) - file.write(XMLfoot()) - file.close() - -if __name__ == "__main__": - main() - diff --git a/contrib/applications/NXformat_dfn/format_docbook.py b/contrib/applications/NXformat_dfn/format_docbook.py deleted file mode 100644 index 6c38dfe3..00000000 --- a/contrib/applications/NXformat_dfn/format_docbook.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -from format_xml import * - -def get_def_ext(): - return "docbook" - -class format_docbook(format_xml): - """Formatting object that goes through a DOM tree and puts it out - as a space formatted XML document surrounded by docbook tagsfor - easier reading in a simple text editor.""" - - def format_head(self): - """Put a header on the resulting document""" - result="" % self.main_name - result=result+"<filename>%s.xml</filename>\n" % self.main_name - result=result+"\n" - result=result+"\n"+"\n"+"\n" diff --git a/contrib/applications/NXformat_dfn/format_xml.py b/contrib/applications/NXformat_dfn/format_xml.py deleted file mode 100644 index a267159d..00000000 --- a/contrib/applications/NXformat_dfn/format_xml.py +++ /dev/null @@ -1,263 +0,0 @@ -#!/usr/bin/env python - -# default value for options -default_width=80 -default_indent=2 - -def trim(string): - """Trim leading and trailing whitespace off of the supplied string""" - - # exit early if supplied an empty string - if not string: return "" - - # default value for trimming - begin=0 - end=string.__len__()-1 # index of last char is one less - # than string size - - # determine amount of leading whitespace - while string[begin].isspace() and beginbegin: - end=end-1 - # return shortened result - if begin+1>=end: - return "" - else: - return string[begin:end+1] - -def remove_extra_spaces(string): - """Condense all whitespace into ' '""" - # first remove leading and trailing space - temp_string=trim(string) - - # set up for loop - is_space=False - result="" - - # go through entire string, condensing all spaces into " " - for letter in temp_string: - if letter.isspace(): # look for a space - if not is_space: # turn multiple spaces into one - is_space=True - result=result+" " - else: # just copy the result - is_space=False - result=result+letter - - # remove the shortened result - return result - -def wrap_text(string,width,continue_additional_indent=""): - """This will perform \"word wrapping\" of text based on - spaces. The default indentation level is determined from the - number of spaces at the start of the string""" - - # confirm that there is something to wrap - if string.__len__()<=width: - return string - - # determine the current indentation level - indent="" - for char in string: - if char.isspace(): - indent=indent+char - else: - break - - # add the continuation indentation - indent=indent+continue_additional_indent - - # generate an array of strings of the correct with for formatting - result=string - str_array=[] - while result.__len__()>width: - line=result[0:width] - while not line[-1].isspace(): - line=line[0:-1] - str_array.append(line+"\n") - result=indent+trim(result[line.__len__():]) - str_array.append(result+"\n") - - # convert the string array into a single string - result="" - for str in str_array: - result=result+str - - # return the wrapped string - return result - -def get_def_ext(): - return "xml" - -def get_command_line_doc(): - result = " --width Specify the width the the document for wrapping. This does not \n"+ \ - " apply to open or close tags. The default is %d.\n" %default_width + \ - " --indent Specify the number of spaces for each indentation level. The \n" + \ - " default is %d." % default_indent - return result - -class format_xml(object): - """Formatting object that goes through a DOM tree and puts it out - as a space formatted XML document for easier reading in a simple - text editor.""" - def __init__(self,main_name,options={},indent=2): - # variable for tracking indent level - self.__cur_indent=0 - - # option for how wide text can go before wrapping - try: - self.__width=int(options.pop("--width")) - except KeyError: - self.__width=default_width - - # option for how many spaces to use for each indentation level - try: - self.__indent=int(options.pop("--indent")) - except KeyError: - self.__indent=default_indent - - # name of definition being formatted - self.main_name=main_name - - def __setattr__(self,name,value): - """This does not allow the user to set the value of the - attributes. This is an immutable object""" - if name=="width": - raise AttributeError("Cannot set value of immutable \"width\"") - if name=="indent": - raise AttributeError("Cannot set value of immutable \"indent\"") - if name=="cur_indent": - raise AttributeError("Cannot set value of immutable \"cur_indent\"") - self.__dict__[name]=value - - # allow access to the attribute values - def __getattr__(self,name): - if name=="width": - return int(self.__width) - if name=="indent": - return int(self.__indent) - if name=="cur_indent": - return int(self.__cur_indent) - return self.__dict__[name] - - def format_head(self): - """Put a header on the resulting document""" - return "\n" - - def format_foot(self): - """Put a footer on the resulting document""" - return "" - - def format_data(self,data): - """Format the data for the output file""" - # determine the indentation - indent=self.__cur_indent*" " - - # create the idiot version - result="%s%s\n" % (indent,data) - - return wrap_text(result,self.__width) -# -# # return the idiot version if it works -# if(result.__len__()<=self.__width): -# return result -# -# # generate an array of strings of the correct with for formatting -# str_array=[] -# while result.__len__()>self.__width: -# line=result[0:self.__width] -# while not line[-1].isspace(): -# line=line[0:-1] -# str_array.append(line+"\n") -# result=indent+trim(result[line.__len__():]) -# str_array.append(result+"\n") -# -# # convert the string array into a single string -# result="" -# for str in str_array: -# result=result+str -# -# return result - - def format_attributes(self,node): - """Format the node attributes for the output file""" - # return empty string if nothing found - if not node.hasAttributes(): - return "" - - # put together a string of the formatted attributes - string="" - for key in node.attributes.keys(): - value=node.attributes[key].value - string=string+(" %s=\"%s\"" % (key,value)) - - return string - - def format_node(self,file,tag,node): - """Format a node for the output file""" - # format the attributes - attr_string=self.format_attributes(node) - # create the open tag - file.write(wrap_text("%s<%s%s>\n" % ((" "*self.__cur_indent),tag,attr_string),self.__width,(" "*(self.__indent+2)))) - # increase the indent level - self.__cur_indent=self.__cur_indent+self.__indent - # recurse down into the tree - for child in node.childNodes: - try: - child_tag=child.tagName - self.format_node(file,child_tag,child) - except AttributeError: - data=remove_extra_spaces(child.data) - if(data.__len__()): - file.write(self.format_data(data)) - # decrease the indent level - self.__cur_indent=self.__cur_indent-self.__indent - # create the close tag - file.write("%s\n" % ((" "*self.__cur_indent),tag)) - - def format_comment_section(self,file,node): - # get the data, if there is a problem, just return - full_comment="" - try: - full_comment=trim(node.data) - except AttributeError: - return - if not full_comment: return - - # divide the data into lines - lines=full_comment.splitlines() - - # compress the lines into header and overview - header="" - overview="" - is_header=True - for line in lines: - if is_header: - header=header+line+"\n" - if line.startswith("$Id"): - is_header=False - else: - overview=overview+line+" " - - # remove leading and trailing whitespace - header=trim(header) - overview=wrap_text(trim(overview),self.__width) - - # format the result into the file - file.write("\n" % (header,overview)) - - def format(self,doc,file): # take from NXconvert.HTMLelement - """The public method for formating a DOM""" - # put in the header - file.write(self.format_head()) - # format the body - for childNode in doc.childNodes: - try: - tag=childNode.tagName - self.format_node(file,tag,childNode) - except AttributeError: - self.format_comment_section(file,childNode) - # put in the footer - file.write(self.format_foot()) diff --git a/contrib/applications/nxplot/NXplot/.classpath b/contrib/applications/nxplot/NXplot/.classpath deleted file mode 100755 index ad32c83a..00000000 --- a/contrib/applications/nxplot/NXplot/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/contrib/applications/nxplot/NXplot/.project b/contrib/applications/nxplot/NXplot/.project deleted file mode 100755 index b0e18cc0..00000000 --- a/contrib/applications/nxplot/NXplot/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - NXplot - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/NXplot/.settings/org.eclipse.jdt.core.prefs b/contrib/applications/nxplot/NXplot/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index a67c8081..00000000 --- a/contrib/applications/nxplot/NXplot/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Oct 21 11:46:43 CEST 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/contrib/applications/nxplot/NXplot/META-INF/MANIFEST.MF b/contrib/applications/nxplot/NXplot/META-INF/MANIFEST.MF deleted file mode 100755 index 2c1ecb15..00000000 --- a/contrib/applications/nxplot/NXplot/META-INF/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: NXplot -Bundle-SymbolicName: NXplot; singleton:=true -Bundle-Version: 1.0.0 -Bundle-Vendor: NeXus International Advisory Comittee -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.ui, - mountaingumsys;bundle-version="0.1.0", - mountaingumuibase;bundle-version="1.0.0", - mountaingumnexus;bundle-version="1.0.0", - org.eclipse.nebula.compositetable;bundle-version="1.0.0", - jnexus;bundle-version="4.2.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/contrib/applications/nxplot/NXplot/build.properties b/contrib/applications/nxplot/NXplot/build.properties deleted file mode 100755 index 8923d230..00000000 --- a/contrib/applications/nxplot/NXplot/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = plugin.xml,\ - META-INF/,\ - .,\ - icons/,\ - splash.bmp diff --git a/contrib/applications/nxplot/NXplot/icons/alt_window_16.gif b/contrib/applications/nxplot/NXplot/icons/alt_window_16.gif deleted file mode 100755 index 05626b17..00000000 Binary files a/contrib/applications/nxplot/NXplot/icons/alt_window_16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/NXplot/icons/alt_window_32.gif b/contrib/applications/nxplot/NXplot/icons/alt_window_32.gif deleted file mode 100755 index b432f883..00000000 Binary files a/contrib/applications/nxplot/NXplot/icons/alt_window_32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/NXplot/icons/nexusw.png b/contrib/applications/nxplot/NXplot/icons/nexusw.png deleted file mode 100644 index abd1b3cb..00000000 Binary files a/contrib/applications/nxplot/NXplot/icons/nexusw.png and /dev/null differ diff --git a/contrib/applications/nxplot/NXplot/icons/nexusw32.png b/contrib/applications/nxplot/NXplot/icons/nexusw32.png deleted file mode 100644 index ee54e06c..00000000 Binary files a/contrib/applications/nxplot/NXplot/icons/nexusw32.png and /dev/null differ diff --git a/contrib/applications/nxplot/NXplot/nxplot.product b/contrib/applications/nxplot/NXplot/nxplot.product deleted file mode 100644 index 4fc3042b..00000000 --- a/contrib/applications/nxplot/NXplot/nxplot.product +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - NXplot - -An extendable utility for plotting any NeXus file. - -NeXus International Advisory Committee (2009 - ????) - -Problems to be reported to: nexus-developers@nexusformat.org - - - - - - - - -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/NXplot/plugin.xml b/contrib/applications/nxplot/NXplot/plugin.xml deleted file mode 100755 index a031d434..00000000 --- a/contrib/applications/nxplot/NXplot/plugin.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/NXplot/splash.bmp b/contrib/applications/nxplot/NXplot/splash.bmp deleted file mode 100755 index 6d9e8aeb..00000000 Binary files a/contrib/applications/nxplot/NXplot/splash.bmp and /dev/null differ diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ActionDelegateProxy.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ActionDelegateProxy.java deleted file mode 100755 index 26f1525b..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ActionDelegateProxy.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * The NeXus actions are IWorkbenchWindowActionDelegates. These - * have to mogrified to actions to be included in a menu of NXplot. - * This is the point of this class. This should probably go into - * some util package in the long run. - * - * copyright: GPL - * - * Mark Koennecke, October 2009 - */ -package org.nexusformat.nxplot; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.PlatformUI; - -public class ActionDelegateProxy extends Action { - private IWorkbenchWindowActionDelegate deli; - private String title; - - ActionDelegateProxy(String title, IWorkbenchWindowActionDelegate deli){ - super(title); - this.deli = deli; - this.title = title; - } - - public String getId() { - return "actiondelgateproxy." + title; - } - - public void run() { - deli.init(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); - deli.run(this); - } -} diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationActionBarAdvisor.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationActionBarAdvisor.java deleted file mode 100755 index c1e65926..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationActionBarAdvisor.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This class defines the menu bar for the NXplot application - * - * copyright:GPL - * - * Mark Koennecke, October 2009 - */ -package org.nexusformat.nxplot; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; - -import ch.psi.num.mountaingum.nexus.actions.*; -/** - * An action bar advisor is responsible for creating, adding, and disposing of - * the actions added to a workbench window. Each window will be populated with - * new actions. - */ -public class ApplicationActionBarAdvisor extends ActionBarAdvisor { - - // Actions - important to allocate these only in makeActions, and then use - // them - // in the fill methods. This ensures that the actions aren't recreated - // when fillActionBars is called with FILL_PROXY. - private IWorkbenchAction exitAction, about; - private IAction open, save, png, print; - - public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { - super(configurer); - } - - protected void makeActions(final IWorkbenchWindow window) { - // Creates the actions and registers them. - // Registering is needed to ensure that key bindings work. - // The corresponding commands key bindings are defined in the plugin.xml - // file. - // Registering also provides automatic disposal of the actions when - // the window is closed. - - exitAction = ActionFactory.QUIT.create(window); - register(exitAction); - - about = ActionFactory.ABOUT.create(window); - - open = new ActionDelegateProxy("Open" ,new OpenNexus()); - register(open); - save = new ActionDelegateProxy("Save" ,new SaveNexus()); - register(save); - png = new ActionDelegateProxy("Export PNG" ,new PNGNexusGraph()); - register(save); - print = new ActionDelegateProxy("Print" ,new PrintNexusGraph()); - register(save); - - } - - protected void fillMenuBar(IMenuManager menuBar) { - MenuManager fileMenu = new MenuManager("&File", - IWorkbenchActionConstants.M_FILE); - menuBar.add(fileMenu); - fileMenu.add(open); - fileMenu.add(save); - fileMenu.add(png); - fileMenu.add(print); - fileMenu.add(exitAction); - - MenuManager helpMenu = new MenuManager("&Help", - IWorkbenchActionConstants.HELP_END); - menuBar.add(helpMenu); - helpMenu.add(about); - - } -} diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationWorkbenchAdvisor.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationWorkbenchAdvisor.java deleted file mode 100755 index b454d553..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationWorkbenchAdvisor.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.nexusformat.nxplot; - -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.application.WorkbenchAdvisor; -import org.eclipse.ui.application.WorkbenchWindowAdvisor; - -public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { - - private static final String PERSPECTIVE_ID = "NXplot.perspective"; - - public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor( - IWorkbenchWindowConfigurer configurer) { - return new ApplicationWorkbenchWindowAdvisor(configurer); - } - - public String getInitialWindowPerspectiveId() { - return PERSPECTIVE_ID; - } - -} diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationWorkbenchWindowAdvisor.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationWorkbenchWindowAdvisor.java deleted file mode 100755 index fbf8a68e..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/ApplicationWorkbenchWindowAdvisor.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.nexusformat.nxplot; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.application.WorkbenchWindowAdvisor; - -public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { - - public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - super(configurer); - } - - public ActionBarAdvisor createActionBarAdvisor( - IActionBarConfigurer configurer) { - return new ApplicationActionBarAdvisor(configurer); - } - - public void preWindowOpen() { - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - configurer.setInitialSize(new Point(640, 480)); - configurer.setShowCoolBar(false); - configurer.setShowStatusLine(false); - } -} diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/BlankSysAdapter.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/BlankSysAdapter.java deleted file mode 100755 index 8dfa9848..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/BlankSysAdapter.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This is a dummy system adapter to make NXplot tick - * - * copyright: GPL - * - * Mark Koennecke, October 2009 - */ -package org.nexusformat.nxplot; - -import ch.psi.num.mountaingum.sys.IDisconnectListener; -import ch.psi.num.mountaingum.sys.ISystemAdapter; -import ch.psi.num.mountaingum.sys.TerminalInterface; -import ch.psi.num.mountaingum.tree.TreeNode; - -public class BlankSysAdapter implements ISystemAdapter { - - public void addDisconnectListener(IDisconnectListener l) { - } - - public boolean canAsync() { - return false; - } - - public void closeTerminalInterface(TerminalInterface ti) { - } - - public void configureTree(TreeNode root) { - } - - public void interrupt() { - } - - public TerminalInterface makeTerminalInterface() { - return null; - } - - public void removeDisconnectListener(IDisconnectListener l) { - } - -} diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/NXplot.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/NXplot.java deleted file mode 100755 index de03a44f..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/NXplot.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Eclipse-rcp main class for NXplot - * - * copyright: GPL - * - * Mark Koennecke, October 2009 - */ -package org.nexusformat.nxplot; - -import org.eclipse.equinox.app.IApplication; -import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; - -import ch.psi.num.mountaingum.sys.SysRegistry; - -/** - * This class controls all aspects of the application's execution - */ -public class NXplot implements IApplication { - - /* (non-Javadoc) - * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) - */ - public Object start(IApplicationContext context) { - SysRegistry.setSystemAdapter(new BlankSysAdapter()); - Display display = PlatformUI.createDisplay(); - try { - int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); - if (returnCode == PlatformUI.RETURN_RESTART) { - return IApplication.EXIT_RESTART; - } - return IApplication.EXIT_OK; - } finally { - display.dispose(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.equinox.app.IApplication#stop() - */ - public void stop() { - final IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench == null) - return; - final Display display = workbench.getDisplay(); - display.syncExec(new Runnable() { - public void run() { - if (!display.isDisposed()) - workbench.close(); - } - }); - } -} diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/Perspective.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/Perspective.java deleted file mode 100755 index f0631bb2..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/Perspective.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * The NeXus Perspective to load - * - * copyright: GPL - * - * Mark Koennecke, October 2009 - */ -package org.nexusformat.nxplot; - -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -import ch.psi.num.mountaingum.nexus.Perspective.NameView; -import ch.psi.num.mountaingum.nexus.Perspective.NexusTree; -import ch.psi.num.mountaingum.ui.EditorView.TreeEditorView; - -public class Perspective implements IPerspectiveFactory { - - public void createInitialLayout(IPageLayout layout) { - String editorArea = layout.getEditorArea(); - layout.setEditorAreaVisible(false); - layout.setFixed(true); - - layout.addStandaloneView(NameView.ID, false, IPageLayout.TOP, 0.05f, editorArea); - layout.addStandaloneView(NexusTree.ID, false, IPageLayout.LEFT, 0.33f, editorArea); - layout.addStandaloneView(TreeEditorView.ID +":1", false, - IPageLayout.RIGHT, 0.66f, editorArea); - - } - -} diff --git a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/View.java b/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/View.java deleted file mode 100755 index 89f6c999..00000000 --- a/contrib/applications/nxplot/NXplot/src/org/nexusformat/nxplot/View.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.nexusformat.nxplot; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.ViewPart; - -public class View extends ViewPart { - public static final String ID = "NXplot.view"; - - private TableViewer viewer; - - /** - * The content provider class is responsible for providing objects to the - * view. It can wrap existing objects in adapters or simply return objects - * as-is. These objects may be sensitive to the current input of the view, - * or ignore it and always show the same content (like Task List, for - * example). - */ - class ViewContentProvider implements IStructuredContentProvider { - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - } - - public void dispose() { - } - - public Object[] getElements(Object parent) { - return new String[] { "One", "Two", "Three" }; - } - } - - class ViewLabelProvider extends LabelProvider implements - ITableLabelProvider { - public String getColumnText(Object obj, int index) { - return getText(obj); - } - - public Image getColumnImage(Object obj, int index) { - return getImage(obj); - } - - public Image getImage(Object obj) { - return PlatformUI.getWorkbench().getSharedImages().getImage( - ISharedImages.IMG_OBJ_ELEMENT); - } - } - - /** - * This is a callback that will allow us to create the viewer and initialize - * it. - */ - public void createPartControl(Composite parent) { - viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL - | SWT.V_SCROLL); - viewer.setContentProvider(new ViewContentProvider()); - viewer.setLabelProvider(new ViewLabelProvider()); - viewer.setInput(getViewSite()); - } - - /** - * Passing the focus request to the viewer's control. - */ - public void setFocus() { - viewer.getControl().setFocus(); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/README.build b/contrib/applications/nxplot/README.build deleted file mode 100644 index c1e768f0..00000000 --- a/contrib/applications/nxplot/README.build +++ /dev/null @@ -1,61 +0,0 @@ - - Building NXplot - - Prerequisites - - At a minimum you need the eclipse IDE with the plugin development - kit installed. Eclipse version 3.5 is required. This can be - downloaded from www.eclipse.org. Choose the classic option. - - If you just want to have a look, a copy of eclipse is all you need. - However, if you wish to create stand alone copies of NXplot, you - need a platform kit. A platform kit is the set of basic eclipse - plugins you need to build an eclipse-RCP application. In order to - arrive at a suitable platform kit for NXplot you need to merge - plugins from three different sources: - - The eclipse-RCP platform kit. To be downloaded from the eclipse - site - - The diff-kit belonging to your platform kit. This kit contains - system specific shared libraries and such for the various platforms - eclipse runs on. - - A selection of eclipse-IDE plugins which you copy from your - eclipse-IDE installation. Of course: same version as the eclipse-RCP - platform. - Again at least version 3.5 is required. Older then that: you are in - trouble on the Macintosh. A full list of platform plugins is provided - in a separate text file. Please note that version strings may vary - over time. - - The easy way to get a suitable kit is to ask someone who already - develops for NXplot to send you a tarball. - - - Setting up Eclipse - - 1) Fire up eclipse and select a workspace - 2) Add and activate the eclipse-RCP platform you installed in - Window/Preference/Plugin Development/Target Platform. Omit this step - if you did not setup a platform. - 3) Import all the plugins in this directory to your workspace: - File/Import/Existing projects into workspace - Unckeck the copy sources option, otherwise all files will be copied - and svn will be thrown off. - 4) Find and double click the nxplot.product file in the NXplot - plugin - 5) In its dependencies tab, use Add required plugins - 6) Do the same in Run/Run configurations. If you have no run - configuration for NXplot, try to run it from the nxplot.product - Overview tab - 7) Setting up eclipse run configurations and dependencies can be painful! - - - - Running NXplot - - The key to everything is the nxplot.nxproduct/Overview tab. It has - buttons to start NXplot in normal and debug mode and to export - NXplot as a standalone application. - - jnexus requires shared libraries. There is yet another readme in the - jnexus root directory how to set this up for different platforms. - \ No newline at end of file diff --git a/contrib/applications/nxplot/jnexus/.classpath b/contrib/applications/nxplot/jnexus/.classpath deleted file mode 100755 index ad32c83a..00000000 --- a/contrib/applications/nxplot/jnexus/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/contrib/applications/nxplot/jnexus/.project b/contrib/applications/nxplot/jnexus/.project deleted file mode 100755 index 759a85a9..00000000 --- a/contrib/applications/nxplot/jnexus/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - jnexus - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/jnexus/.settings/org.eclipse.jdt.core.prefs b/contrib/applications/nxplot/jnexus/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index a67c8081..00000000 --- a/contrib/applications/nxplot/jnexus/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Oct 21 11:46:43 CEST 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/contrib/applications/nxplot/jnexus/Linuxi386.lib b/contrib/applications/nxplot/jnexus/Linuxi386.lib deleted file mode 100644 index 764d195d..00000000 --- a/contrib/applications/nxplot/jnexus/Linuxi386.lib +++ /dev/null @@ -1,8 +0,0 @@ -z -mxml -jpeg -hdf5 -df -mfhdf -NeXus -jnexus diff --git a/contrib/applications/nxplot/jnexus/META-INF/MANIFEST.MF b/contrib/applications/nxplot/jnexus/META-INF/MANIFEST.MF deleted file mode 100755 index 70469319..00000000 --- a/contrib/applications/nxplot/jnexus/META-INF/MANIFEST.MF +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Jnexus Plug-in -Bundle-SymbolicName: jnexus -Bundle-Version: 4.2.0 -Bundle-Vendor: The NeXus Group -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: ncsa.hdf.hdflib, - org.nexusformat -Eclipse-LazyStart: true -Bundle-Activator: NexusActivator -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.3.100" diff --git a/contrib/applications/nxplot/jnexus/build.properties b/contrib/applications/nxplot/jnexus/build.properties deleted file mode 100755 index 588a95d1..00000000 --- a/contrib/applications/nxplot/jnexus/build.properties +++ /dev/null @@ -1,34 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - libNeXus.so,\ - libjnexus.so,\ - hd421m.dll,\ - hdf5dll.dll,\ - hm421m.dll,\ - iconv.dll,\ - jnexus.dll,\ - libNeXus-0.dll,\ - libjnexus-0.dll,\ - libxml2.dll,\ - szlibdll.dll,\ - zlib1.dll,\ - libjpeg.so.62,\ - libmfhdf.so.4,\ - libmxml.so.1,\ - libhdf5-1.6.5.so.0,\ - libdf.so.4,\ - libz.so.1,\ - libdf.so,\ - libhdf5.so,\ - libjpeg.so,\ - libmfhdf.so,\ - libmxml.so,\ - libz.so,\ - Linuxi386.lib,\ - windoofx86.lib,\ - build.properties,\ - sharedlib.readme,\ - libjnexus.jnilib,\ - macosx.lib diff --git a/contrib/applications/nxplot/jnexus/hd421m.dll b/contrib/applications/nxplot/jnexus/hd421m.dll deleted file mode 100755 index 28d236a2..00000000 Binary files a/contrib/applications/nxplot/jnexus/hd421m.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/hdf5dll.dll b/contrib/applications/nxplot/jnexus/hdf5dll.dll deleted file mode 100755 index 9045f3b9..00000000 Binary files a/contrib/applications/nxplot/jnexus/hdf5dll.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/hm421m.dll b/contrib/applications/nxplot/jnexus/hm421m.dll deleted file mode 100755 index b052206e..00000000 Binary files a/contrib/applications/nxplot/jnexus/hm421m.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/iconv.dll b/contrib/applications/nxplot/jnexus/iconv.dll deleted file mode 100755 index b448e7de..00000000 Binary files a/contrib/applications/nxplot/jnexus/iconv.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/jnexus.dll b/contrib/applications/nxplot/jnexus/jnexus.dll deleted file mode 100755 index 2b8465cc..00000000 Binary files a/contrib/applications/nxplot/jnexus/jnexus.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libNeXus-0.dll b/contrib/applications/nxplot/jnexus/libNeXus-0.dll deleted file mode 100755 index 4f6a4e90..00000000 Binary files a/contrib/applications/nxplot/jnexus/libNeXus-0.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libNeXus.so b/contrib/applications/nxplot/jnexus/libNeXus.so deleted file mode 100755 index 36205248..00000000 Binary files a/contrib/applications/nxplot/jnexus/libNeXus.so and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libNeXus.so.0 b/contrib/applications/nxplot/jnexus/libNeXus.so.0 deleted file mode 100755 index 36205248..00000000 Binary files a/contrib/applications/nxplot/jnexus/libNeXus.so.0 and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libdf.so.4 b/contrib/applications/nxplot/jnexus/libdf.so.4 deleted file mode 100644 index 74f4fe1f..00000000 Binary files a/contrib/applications/nxplot/jnexus/libdf.so.4 and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libhdf5-1.6.5.so.0 b/contrib/applications/nxplot/jnexus/libhdf5-1.6.5.so.0 deleted file mode 100644 index 4b3ef6a9..00000000 Binary files a/contrib/applications/nxplot/jnexus/libhdf5-1.6.5.so.0 and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libhdf5.so b/contrib/applications/nxplot/jnexus/libhdf5.so deleted file mode 100755 index 4b3ef6a9..00000000 Binary files a/contrib/applications/nxplot/jnexus/libhdf5.so and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libjnexus-0.dll b/contrib/applications/nxplot/jnexus/libjnexus-0.dll deleted file mode 100755 index d5ccb391..00000000 Binary files a/contrib/applications/nxplot/jnexus/libjnexus-0.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libjnexus.jnilib b/contrib/applications/nxplot/jnexus/libjnexus.jnilib deleted file mode 100644 index 97e5e7c8..00000000 Binary files a/contrib/applications/nxplot/jnexus/libjnexus.jnilib and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libjnexus.so b/contrib/applications/nxplot/jnexus/libjnexus.so deleted file mode 100755 index b3329251..00000000 Binary files a/contrib/applications/nxplot/jnexus/libjnexus.so and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libjpeg.so b/contrib/applications/nxplot/jnexus/libjpeg.so deleted file mode 100755 index b95fa573..00000000 Binary files a/contrib/applications/nxplot/jnexus/libjpeg.so and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libjpeg.so.62 b/contrib/applications/nxplot/jnexus/libjpeg.so.62 deleted file mode 100644 index b95fa573..00000000 Binary files a/contrib/applications/nxplot/jnexus/libjpeg.so.62 and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libmfhdf.so b/contrib/applications/nxplot/jnexus/libmfhdf.so deleted file mode 100755 index 0226558e..00000000 Binary files a/contrib/applications/nxplot/jnexus/libmfhdf.so and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libmfhdf.so.4 b/contrib/applications/nxplot/jnexus/libmfhdf.so.4 deleted file mode 100644 index 0226558e..00000000 Binary files a/contrib/applications/nxplot/jnexus/libmfhdf.so.4 and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libmxml.so b/contrib/applications/nxplot/jnexus/libmxml.so deleted file mode 100755 index a55fe73e..00000000 Binary files a/contrib/applications/nxplot/jnexus/libmxml.so and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libmxml.so.1 b/contrib/applications/nxplot/jnexus/libmxml.so.1 deleted file mode 100644 index a55fe73e..00000000 Binary files a/contrib/applications/nxplot/jnexus/libmxml.so.1 and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libxml2.dll b/contrib/applications/nxplot/jnexus/libxml2.dll deleted file mode 100755 index cecdc43b..00000000 Binary files a/contrib/applications/nxplot/jnexus/libxml2.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/libz.so.1 b/contrib/applications/nxplot/jnexus/libz.so.1 deleted file mode 100644 index 1711f991..00000000 Binary files a/contrib/applications/nxplot/jnexus/libz.so.1 and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/macosx.lib b/contrib/applications/nxplot/jnexus/macosx.lib deleted file mode 100644 index fdf6b1e0..00000000 --- a/contrib/applications/nxplot/jnexus/macosx.lib +++ /dev/null @@ -1 +0,0 @@ -jnexus diff --git a/contrib/applications/nxplot/jnexus/sharedlib.readme b/contrib/applications/nxplot/jnexus/sharedlib.readme deleted file mode 100644 index c3de7320..00000000 --- a/contrib/applications/nxplot/jnexus/sharedlib.readme +++ /dev/null @@ -1,38 +0,0 @@ - - Shared Library Instructions - - Both NXplot and GTSE use jnexus and jnexus in turn requires the shared libraries - for NeXus and HDF. This is a pain in the ass. Contrary to the eclipse documentation - (2009) loading shared libraries from some directory in the jnexus hierarchy does - not work. The only thing what does work is to load a named shared library from - the root directory of the plugin. However, shared libraries the loaded library - dependent upon are not automatically found. Thus the only way is to load the - shared libraries and their dependents from Java code in the right order. To this - purpose an activator class was defined which implements the following algorithm: - - A system specific filename is constructed from Java properties. The name of this - file is printed. For further reference I call this file the library file. - - The library file is supposed to hold the names of the libraries to load in - the right order, a library per line. - - The Activator reads this file, line by line, prints the name of the library Java - thinks it should have and loads the library. - - Thus exchanging the libraries or adding libraries for an unsupported architecture - requires the following steps: - 1) copy the jnexus libraries and its dependents into this directory. - 2) Run NXplot in order to find out about the library filename - 3) Write a new library file with the required libraries - 4) Try it out, I am sure there will be errors - Java tries to be clever and builds library names from the strings provided. - These names may not be the ones expected, for instance under unix it tries to find - for jnexus libjnexus.so but not the libjnexus.so.12 or so which usually is present. - Thus some shared library renaming may be in order too. - - If NXplot does not print onto the console, please start it with: - - nxplot -debug -console -consolelog - - NXplot also works if the shared libraries are somewhere in the system shared - library path. - - Mark.Koennecke@psi.ch - \ No newline at end of file diff --git a/contrib/applications/nxplot/jnexus/src/NexusActivator.java b/contrib/applications/nxplot/jnexus/src/NexusActivator.java deleted file mode 100644 index 58154c70..00000000 --- a/contrib/applications/nxplot/jnexus/src/NexusActivator.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * This is the activator class for the jnexus plugin. Its purpose is to - * load all the shared libraries required for jnexus, depending on the OS. - * - * copyright: GPL - * - * Mark Koennecke, October 2000 - */ -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.URL; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - - -public class NexusActivator extends Plugin { - - public void start(BundleContext context) throws Exception { - String line, os, libfile; - super.start(context); - - os = System.getProperty("os.name"); - if(os.indexOf("Windows") >= 0){ - libfile = "windoof" + System.getProperty("os.arch") + ".lib"; - } else if(os.indexOf("Mac OS X") >= 0){ - libfile = "macosx.lib"; - } else { - libfile = os + System.getProperty("os.arch") + ".lib"; - libfile = libfile.replace(" ", "_"); - } - System.out.println("Trying to load libraries from " + libfile); - URL ulli = Platform.getBundle("jnexus").getEntry(libfile); - if(ulli == null){ - System.out.println(libfile + " library information file not found"); - return; - } - BufferedReader in = new BufferedReader(new InputStreamReader(ulli.openStream())); - while((line = in.readLine()) != null){ - System.out.println(System.mapLibraryName(line)); - try{ - System.loadLibrary(line); - }catch(Exception e){ - System.out.println("Failed to load library: " + line); - } - } - in.close(); - } - -} diff --git a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFArray.java b/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFArray.java deleted file mode 100755 index 25f92fd7..00000000 --- a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFArray.java +++ /dev/null @@ -1,850 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * National Comptational Science Alliance * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -package ncsa.hdf.hdflib; - -/** - * This is a class for handling multidimensional arrays for - * HDF. - *

- * The purpose is to allow the storage and retrieval of - * arbitrary array types containing scientific data. - *

- * The methods support the conversion of an array to and - * from Java to a one-dimensional array of bytes suitable - * for I/O by the C library. - *

- * This class heavily uses the HDFNativeData - * class to convert between Java and C representations. - */ - -public class HDFArray { - -private Object _theArray = null; -private ArrayDescriptor _desc = null; -private byte [] _barray = null; - -public HDFArray(Object anArray) throws HDFException { - - if (anArray == null) { - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: array is null?: "); -ex.printStackTrace(); - } - Class tc = anArray.getClass(); - if (tc.isArray() == false) { - /* exception: not an array */ - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: not an array?: "); -ex.printStackTrace(); - throw(ex); - } - _theArray = anArray; - _desc = new ArrayDescriptor( _theArray ); - - /* extra error checking -- probably not needed */ - if (_desc == null ) { - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: internal error: array description failed?: "); - throw(ex); - } -} - -/** - * allocate a one-dimensional array of bytes sufficient to store - * the array. - * @exception HDFException . - */ - -public byte[] emptyBytes() -throws HDFException -{ - byte[] b = null; - if (_desc.dims == 1 && _desc.NT == 'B') { - b = (byte [])_theArray; - } else { - b = new byte[_desc.totalSize]; - } - if (b == null) { - System.out.println("Error: HDFArray can't allocate bytes for array"); - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: emptyBytes: allocation failed"); - throw(ex); - } - return (b); - //return (new byte[_desc.totalSize]); -} - -/** - * Given a Java array of numbers, convert it to a one-dimensional - * array of bytes in correct native order. - * - * @exception ncsa.hdf.hdflib.HDFException - * thrown for errors: - * object is not array: HDFJavaException - */ -public byte[] byteify() throws HDFException{ - - if (_barray != null) return _barray; - if (_theArray == null) { - /* exception: not an array */ - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: byteify not an array?: "); - throw(ex); - } - - if (_desc.dims == 1) { - /* special case */ - if (_desc.NT == 'B') { - /* really special case! */ - _barray = (byte [])_theArray; - return _barray; - } else { - try { - _barray = new byte[_desc.totalSize]; - - byte [] therow; - if (_desc.NT == 'I') { - therow = ncsa.hdf.hdflib.HDFNativeData.intToByte(0,_desc.dimlen[1],(int [])_theArray); - } else if (_desc.NT == 'S') { - therow = ncsa.hdf.hdflib.HDFNativeData.shortToByte(0,_desc.dimlen[1],(short [])_theArray); - } else if (_desc.NT == 'F') { - therow = ncsa.hdf.hdflib.HDFNativeData.floatToByte(0,_desc.dimlen[1],(float [])_theArray); - } else if (_desc.NT == 'J') { - therow = ncsa.hdf.hdflib.HDFNativeData.longToByte(0,_desc.dimlen[1],(long [])_theArray); - } else if (_desc.NT == 'D') { - therow = ncsa.hdf.hdflib.HDFNativeData.doubleToByte(0,_desc.dimlen[1],(double [])_theArray); - } else if (_desc.NT == 'L') { - if (_desc.className.equals("java.lang.Byte")) { - therow = ByteObjToByte((Byte[])_theArray); - } else if (_desc.className.equals("java.lang.Integer")) { - therow = IntegerToByte((Integer[])_theArray); - } else if (_desc.className.equals("java.lang.Short")) { - therow = ShortToByte((Short[])_theArray); - } else if (_desc.className.equals("java.lang.Float")) { - therow = FloatObjToByte((Float[])_theArray); - } else if (_desc.className.equals("java.lang.Double")) { - therow = DoubleObjToByte((Double[])_theArray); - } else if (_desc.className.equals("java.lang.Long")) { - therow = LongObjToByte((Long[])_theArray); - } else { - HDFJavaException ex = - new HDFJavaException("HDFArray: unknown type of Object?"); - throw(ex); - } - } else { - HDFJavaException ex = - new HDFJavaException("HDFArray: unknown type of Object?"); - throw(ex); - } - System.arraycopy(therow,0,_barray,0,(_desc.dimlen[1] * _desc.NTsize)); - return _barray; - } catch (OutOfMemoryError err) { - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: byteify array too big?"); - ex.printStackTrace(); - throw(ex); - } - } - } - - try { - _barray = new byte[_desc.totalSize]; - } catch (OutOfMemoryError err) { - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: byteify array too big?"); - ex.printStackTrace(); - throw(ex); - } - - - Object oo = _theArray; - int n = 0; /* the current byte */ - int index = 0; - int i; - while ( n < _desc.totalSize ) { - oo = _desc.objs[0]; - index = n / _desc.bytetoindex[0]; - index %= _desc.dimlen[0]; - for (i = 0 ; i < (_desc.dims); i++) { - index = n / _desc.bytetoindex[i]; - index %= _desc.dimlen[i]; - - if (index == _desc.currentindex[i]) { - /* then use cached copy */ - oo = _desc.objs[i]; - } else { - /* check range of index */ - if (index > (_desc.dimlen[i] - 1)) { - System.out.println("out of bounds?"); - return null; - } - oo = java.lang.reflect.Array.get((Object) oo,index); - _desc.currentindex[i] = index; - _desc.objs[i] = oo; - } - } - - /* byte-ify */ - byte arow[]; - try { - if (_desc.NT == 'J') { - arow = ncsa.hdf.hdflib.HDFNativeData.longToByte(0,_desc.dimlen[_desc.dims],(long [])_desc.objs[_desc.dims - 1]); - arow = ncsa.hdf.hdflib.HDFNativeData.longToByte(0,_desc.dimlen[_desc.dims],(long [])_desc.objs[_desc.dims - 1]); - } else if (_desc.NT == 'I') { - arow = ncsa.hdf.hdflib.HDFNativeData.intToByte(0,_desc.dimlen[_desc.dims],(int [])_desc.objs[_desc.dims - 1]); - } else if (_desc.NT == 'S') { - arow = ncsa.hdf.hdflib.HDFNativeData.shortToByte(0,_desc.dimlen[_desc.dims],(short [])_desc.objs[_desc.dims - 1]); - } else if (_desc.NT == 'B') { - arow = (byte [])_desc.objs[_desc.dims - 1]; - } else if (_desc.NT == 'F') { - /* 32 bit float */ - arow = ncsa.hdf.hdflib.HDFNativeData.floatToByte(0,_desc.dimlen[_desc.dims],(float [])_desc.objs[_desc.dims - 1]); - } else if (_desc.NT == 'D') { - /* 64 bit float */ - arow = ncsa.hdf.hdflib.HDFNativeData.doubleToByte(0,_desc.dimlen[_desc.dims],(double [])_desc.objs[_desc.dims - 1]); - } else if (_desc.NT == 'L') { - if (_desc.className.equals("java.lang.Byte")) { - arow = ByteObjToByte((Byte[])_desc.objs[_desc.dims - 1]); - } else if (_desc.className.equals("java.lang.Integer")) { - arow = IntegerToByte((Integer[])_desc.objs[_desc.dims - 1]); - } else if (_desc.className.equals("java.lang.Short")) { - arow = ShortToByte((Short[])_desc.objs[_desc.dims - 1]); - } else if (_desc.className.equals("java.lang.Float")) { - arow = FloatObjToByte((Float[])_desc.objs[_desc.dims - 1]); - } else if (_desc.className.equals("java.lang.Double")) { - arow = DoubleObjToByte((Double[])_desc.objs[_desc.dims - 1]); - } else if (_desc.className.equals("java.lang.Long")) { - arow = LongObjToByte((Long[])_desc.objs[_desc.dims - 1]); - } else { - HDFJavaException ex = - new HDFJavaException("HDFArray: byteify Object type not implemented?"); - throw(ex); - } - } else { - HDFJavaException ex = - new HDFJavaException("HDFArray: byteify Object type not implemented?"); - throw(ex); - } - System.arraycopy(arow,0,_barray,n,(_desc.dimlen[_desc.dims] * _desc.NTsize)); - n += _desc.bytetoindex[_desc.dims - 1]; - } catch (OutOfMemoryError err) { - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: byteify array too big?"); - ex.printStackTrace(); - throw(ex); - } - } -/* assert: the whole array is completed--currentindex should == len - 1 */ - - /* error checks */ - - if (n < _desc.totalSize) { - throw new java.lang.InternalError( - new String("HDFArray:::byteify: Panic didn't complete all input data: n= "+n+" size = "+_desc.totalSize)); - } - for (i = 0;i < _desc.dims; i++) { - if (_desc.currentindex[i] != _desc.dimlen[i] - 1) { - throw new java.lang.InternalError( - new String("Panic didn't complete all data: currentindex["+i+"] = "+_desc.currentindex[i]+" (should be "+(_desc.dimlen[i] - 1)+" ?)")); - } - } - return _barray; -} - -/** - * Given a one-dimensional array of numbers, convert it to a java - * array of the shape and size passed to the constructor. - * - * @exception ncsa.hdf.hdflib.HDFException - * thrown for errors: - * object not an array: HDFJavaException - */ -public Object arrayify(byte[] bytes) throws HDFException { - - if (_theArray == null) { - /* exception: not an array */ - HDFException ex = - (HDFException)new HDFJavaException("arrayify: not an array?: "); - throw(ex); - } - - if (java.lang.reflect.Array.getLength((Object) bytes) != _desc.totalSize) { - /* exception: array not right size */ - HDFException ex = - (HDFException)new HDFJavaException("arrayify: array is wrong size?: "); - } - _barray = bytes; /* hope that the bytes are correct.... */ - if (_desc.dims == 1) { - /* special case */ - /* 2 data copies here! */ - try { - if (_desc.NT == 'I') { - int [] x = (int [])ncsa.hdf.hdflib.HDFNativeData.byteToInt(_barray); - System.arraycopy(x,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.NT == 'S') { - short [] x = ncsa.hdf.hdflib.HDFNativeData.byteToShort(_barray); - System.arraycopy(x,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.NT == 'F') { - float x[] = ncsa.hdf.hdflib.HDFNativeData.byteToFloat(_barray); - System.arraycopy(x,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.NT == 'J') { - long x[] = ncsa.hdf.hdflib.HDFNativeData.byteToLong(_barray); - System.arraycopy(x,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.NT == 'D') { - double x[] = ncsa.hdf.hdflib.HDFNativeData.byteToDouble(_barray); - System.arraycopy(x,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.NT == 'B') { - System.arraycopy(_barray,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.NT == 'L') { - if (_desc.className.equals("java.lang.Byte")) { - Byte I[] = ByteToByteObj(_barray); - System.arraycopy(I,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.className.equals("java.lang.Integer")) { - Integer I[] = ByteToInteger(_barray); - System.arraycopy(I,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.className.equals("java.lang.Short")) { - Short I[] = ByteToShort(_barray); - System.arraycopy(I,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.className.equals("java.lang.Float")) { - Float I[] = ByteToFloatObj(_barray); - System.arraycopy(I,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.className.equals("java.lang.Double")) { - Double I[] = ByteToDoubleObj(_barray); - System.arraycopy(I,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else if (_desc.className.equals("java.lang.Long")) { - Long I[] = ByteToLongObj(_barray); - System.arraycopy(I,0,_theArray,0,_desc.dimlen[1]); - return _theArray; - } else { - HDFJavaException ex = - new HDFJavaException("arrayify: Object type not implemented yet..."); - throw(ex); - } - } else { - HDFJavaException ex = - new HDFJavaException("arrayify: Object type not implemented yet..."); - throw(ex); - } - } catch (OutOfMemoryError err) { - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: arrayify array too big?"); - ex.printStackTrace(); - throw(ex); - } - } - /* Assert dims >= 2 */ - - Object oo = _theArray; - int n = 0; /* the current byte */ - int index = 0; - int i; - while ( n < _desc.totalSize ) { - oo = _desc.objs[0]; - index = n / _desc.bytetoindex[0]; - index %= _desc.dimlen[0]; - for (i = 0 ; i < (_desc.dims); i++) { - index = n / _desc.bytetoindex[i]; - index %= _desc.dimlen[i]; - - if (index == _desc.currentindex[i]) { - /* then use cached copy */ - oo = _desc.objs[i]; - } else { - /* check range of index */ - if (index > (_desc.dimlen[i] - 1)) { - System.out.println("out of bounds?"); - return null; - } - oo = java.lang.reflect.Array.get((Object) oo,index); - _desc.currentindex[i] = index; - _desc.objs[i] = oo; - } - } - - /* array-ify */ - try { - if (_desc.NT == 'J') { - long [] arow = ncsa.hdf.hdflib.HDFNativeData.byteToLong(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), (Object)arow); - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.NT == 'I') { - int [] arow = ncsa.hdf.hdflib.HDFNativeData.byteToInt(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), (Object)arow); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.NT == 'S') { - short [] arow = ncsa.hdf.hdflib.HDFNativeData.byteToShort(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), (Object)arow); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.NT == 'B') { - System.arraycopy( _barray, n, _desc.objs[_desc.dims - 1], 0, _desc.dimlen[_desc.dims]); - n += _desc.bytetoindex[_desc.dims - 1]; - } else if (_desc.NT == 'F') { - float arow[] = ncsa.hdf.hdflib.HDFNativeData.byteToFloat(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), (Object)arow); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.NT == 'D') { - double [] arow = ncsa.hdf.hdflib.HDFNativeData.byteToDouble(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), (Object)arow); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.NT == 'L') { - if (_desc.className.equals("java.lang.Byte")) { - Byte I[] = ByteToByteObj(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), - (Object)I); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.className.equals("java.lang.Integer")) { - Integer I[] = ByteToInteger(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), - (Object)I); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.className.equals("java.lang.Short")) { - Short I[] = ByteToShort(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), - (Object)I); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.className.equals("java.lang.Float")) { - Float I[] = ByteToFloatObj(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), - (Object)I); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.className.equals("java.lang.Double")) { - Double I[] = ByteToDoubleObj(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), - (Object)I); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else if (_desc.className.equals("java.lang.Long")) { - Long I[] = ByteToLongObj(n,_desc.dimlen[_desc.dims],_barray); - java.lang.reflect.Array.set(_desc.objs[_desc.dims - 2] , - (_desc.currentindex[_desc.dims - 1]), - (Object)I); - - n += _desc.bytetoindex[_desc.dims - 1]; - _desc.currentindex[_desc.dims - 1]++; - } else { - HDFJavaException ex = - new HDFJavaException("HDFArray: unsupported Object type: "+_desc.NT); - throw(ex); - } - } else { - HDFJavaException ex = - new HDFJavaException("HDFArray: unsupported Object type: "+_desc.NT); - throw(ex); - } - } catch (OutOfMemoryError err) { - HDFException ex = - (HDFException)new HDFJavaException("HDFArray: arrayify array too big?"); - ex.printStackTrace(); - throw(ex); - } - - } - -/* assert: the whole array is completed--currentindex should == len - 1 */ - - /* error checks */ - - if (n < _desc.totalSize) { - throw new java.lang.InternalError( - new String("HDFArray::arrayify Panic didn't complete all input data: n= "+n+" size = "+_desc.totalSize)); - } - for (i = 0;i <= _desc.dims-2; i++) { - if (_desc.currentindex[i] != _desc.dimlen[i] - 1) { - throw new java.lang.InternalError( - new String("HDFArray::arrayify Panic didn't complete all data: currentindex["+i+"] = "+_desc.currentindex[i]+" (should be "+(_desc.dimlen[i] - 1)+"?")); - } - } - if (_desc.NT != 'B') { - if (_desc.currentindex[_desc.dims - 1] != _desc.dimlen[_desc.dims - 1]) { - throw new java.lang.InternalError( - new String("HDFArray::arrayify Panic didn't complete all data: currentindex["+i+"] = "+_desc.currentindex[i]+" (should be "+(_desc.dimlen[i])+"?")); - } - } else { - if (_desc.currentindex[_desc.dims - 1] != (_desc.dimlen[_desc.dims - 1] - 1)) { - throw new java.lang.InternalError( - new String("HDFArray::arrayify Panic didn't complete all data: currentindex["+i+"] = "+_desc.currentindex[i]+" (should be "+(_desc.dimlen[i] - 1)+"?")); - } - } - - return _theArray; -} - -private byte[] IntegerToByte( Integer in[] ) { - int nelems = java.lang.reflect.Array.getLength((Object)in); - int[] out = new int[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = in[i].intValue(); - } - return HDFNativeData.intToByte(0,nelems,out); -} - -private Integer[] ByteToInteger( byte[] bin ) { - int in[] = (int [])HDFNativeData.byteToInt(bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Integer[] out = new Integer[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Integer(in[i]); - } - return out; -} -private Integer[] ByteToInteger( int start, int len, byte[] bin ) { - int in[] = (int [])HDFNativeData.byteToInt(start,len,bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Integer[] out = new Integer[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Integer(in[i]); - } - return out; -} - - -private byte[] ShortToByte( Short in[] ) { - int nelems = java.lang.reflect.Array.getLength((Object)in); - short[] out = new short[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = in[i].shortValue(); - } - return HDFNativeData.shortToByte(0,nelems,out); -} - -private Short[] ByteToShort( byte[] bin ) { - short in[] = (short [])HDFNativeData.byteToShort(bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Short[] out = new Short[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Short(in[i]); - } - return out; -} - -private Short[] ByteToShort( int start, int len, byte[] bin ) { - short in[] = (short [])HDFNativeData.byteToShort(start,len,bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Short[] out = new Short[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Short(in[i]); - } - return out; -} - -private byte[] ByteObjToByte( Byte in[] ) { - int nelems = java.lang.reflect.Array.getLength((Object)in); - byte[] out = new byte[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = in[i].byteValue(); - } - return out; -} - -private Byte[] ByteToByteObj( byte[] bin ) { - int nelems = java.lang.reflect.Array.getLength((Object)bin); - Byte[] out = new Byte[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Byte(bin[i]); - } - return out; -} - -private Byte[] ByteToByteObj( int start, int len, byte[] bin ) { - Byte[] out = new Byte[len]; - - for (int i = 0; i < len; i++) { - out[i] = new Byte(bin[i]); - } - return out; -} - -private byte[] FloatObjToByte( Float in[] ) { - int nelems = java.lang.reflect.Array.getLength((Object)in); - float[] out = new float[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = in[i].floatValue(); - } - return HDFNativeData.floatToByte(0,nelems,out); -} - -private Float[] ByteToFloatObj( byte[] bin ) { - float in[] = (float [])HDFNativeData.byteToFloat(bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Float[] out = new Float[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Float(in[i]); - } - return out; -} - -private Float[] ByteToFloatObj( int start, int len, byte[] bin ) { - float in[] = (float [])HDFNativeData.byteToFloat(start,len,bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Float[] out = new Float[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Float(in[i]); - } - return out; -} - -private byte[] DoubleObjToByte( Double in[] ) { - int nelems = java.lang.reflect.Array.getLength((Object)in); - double[] out = new double[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = in[i].doubleValue(); - } - return HDFNativeData.doubleToByte(0,nelems,out); -} - -private Double[] ByteToDoubleObj( byte[] bin ) { - double in[] = (double [])HDFNativeData.byteToDouble(bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Double[] out = new Double[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Double(in[i]); - } - return out; -} - -private Double[] ByteToDoubleObj( int start, int len, byte[] bin ) { - double in[] = (double [])HDFNativeData.byteToDouble(start,len,bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Double[] out = new Double[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Double(in[i]); - } - return out; -} - -private byte[] LongObjToByte( Long in[] ) { - int nelems = java.lang.reflect.Array.getLength((Object)in); - long[] out = new long[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = in[i].longValue(); - } - return HDFNativeData.longToByte(0,nelems,out); -} - -private Long[] ByteToLongObj( byte[] bin ) { - long in[] = (long [])HDFNativeData.byteToLong(bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Long[] out = new Long[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Long(in[i]); - } - return out; -} - -private Long[] ByteToLongObj( int start, int len, byte[] bin ) { - long in[] = (long [])HDFNativeData.byteToLong(start,len,bin); - int nelems = java.lang.reflect.Array.getLength((Object)in); - Long[] out = new Long[nelems]; - - for (int i = 0; i < nelems; i++) { - out[i] = new Long(in[i]); - } - return out; -} - -} - - -/** - * This class is used by HDFArray to discover the shape and type of an - * arbitrary array. - */ - -class ArrayDescriptor { - - static String theType = ""; - static Class theClass = null; - static int [] dimlen = null; - static int [] dimstart = null; - static int [] currentindex = null; - static int [] bytetoindex = null; - static int totalSize = 0; - static Object [] objs = null; - static char NT = ' '; /* must be B,S,I,L,F,D, else error */ - static int NTsize = 0; - static int dims = 0; - static String className; - - public ArrayDescriptor ( Object anArray ) throws HDFException { - - Class tc = anArray.getClass(); - if (tc.isArray() == false) { - /* exception: not an array */ - HDFException ex = - (HDFException)new HDFJavaException("ArrayDescriptor: not an array?: "); - throw(ex); - } - - theClass = tc; - - /* parse the type descriptor to discover the - shape of the array */ - String ss = tc.toString(); - theType = ss; - int n = 6; - dims = 0; - char c = ' '; - while (n < ss.length()) { - c = ss.charAt(n); - n++; - if (c == '[') { - dims++; - } - } - - String css = ss.substring(ss.lastIndexOf('[')+1); - Class compC = tc.getComponentType(); - String cs = compC.toString(); - NT = c; - if (NT == 'B') { - NTsize = 1; - } else if (NT == 'S') { - NTsize = 2; - } else if ((NT == 'I') || (NT == 'F')) { - NTsize = 4; - } else if ((NT == 'J') || (NT == 'D')){ - NTsize = 8; - } else if (css.startsWith("Ljava.lang.Byte")) { - NT='L'; - className = "java.lang.Byte"; - NTsize = 1; - } else if (css.startsWith("Ljava.lang.Short")) { - NT='L'; - className = "java.lang.Short"; - NTsize = 2; - } else if (css.startsWith("Ljava.lang.Integer")) { - NT='L'; - className = "java.lang.Integer"; - NTsize = 4; - } else if (css.startsWith("Ljava.lang.Float")) { - NT='L'; - className = "java.lang.Float"; - NTsize = 4; - } else if (css.startsWith("Ljava.lang.Double")) { - NT='L'; - className = "java.lang.Double"; - NTsize = 8; - } else if (css.startsWith("Ljava.lang.Long")) { - NT='L'; - className = "java.lang.Long"; - NTsize = 8; - } else if (css.startsWith("Ljava.lang.String")) { -throw new HDFJavaException(new String("ArrayDesciptor: Error: String array not supported yet")); - } else { - /* exception: not a numeric type */ -throw new HDFJavaException(new String("Error: array is not numeric? (type is "+css+")")); - } - - /* fill in the table */ - dimlen = new int [dims+1]; - dimstart = new int [dims+1]; - currentindex = new int [dims+1]; - bytetoindex = new int [dims+1]; - objs = new Object [dims+1]; - - Object o = anArray; - objs[0] = o; - dimlen[0]= 1; - dimstart[0] = 0; - currentindex[0] = 0; - int i; - for ( i = 1; i <= dims; i++) { - dimlen[i]= java.lang.reflect.Array.getLength((Object) o); - o = java.lang.reflect.Array.get((Object) o,0); - objs [i] = o; - dimstart[i] = 0; - currentindex[i] = 0; - } - - int j; - int dd; - bytetoindex[dims] = NTsize; - for ( i = dims; i >= 0; i--) { - dd = NTsize; - for (j = i; j < dims; j++) { - dd *= dimlen[j + 1]; - } - bytetoindex[i] = dd; - } - - totalSize = bytetoindex[0]; - } - - public void dumpInfo() - { - System.out.println("Type: "+theType); - System.out.println("Class: "+theClass); - System.out.println("NT: "+NT+" NTsize: "+NTsize); - System.out.println("Array has "+dims+" dimensions ("+totalSize+" bytes)"); - int i; - for (i = 0; i <= dims; i++) { - Class tc = objs[i].getClass(); - String ss = tc.toString(); - System.out.println(i+": start "+dimstart[i]+": len "+dimlen[i]+" current "+currentindex[i]+" bytetoindex "+bytetoindex[i]+" object "+objs[i]+" otype "+ss); - } - } -} diff --git a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFConstants.java b/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFConstants.java deleted file mode 100755 index 5209fb61..00000000 --- a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFConstants.java +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * National Comptational Science Alliance * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -package ncsa.hdf.hdflib; - -/** - *

- * This interface defines the values of constants defined - * by the HDF 4.1 API. - *

- * For details of the HDF libraries, see the HDF Documentation at: - * http://hdf.ncsa.uiuc.edu - */ -public class HDFConstants -{ - /** FAIL */ - public static final int FAIL = -1; - - // file access code definitions - public static final int DFACC_READ = 1; - public static final int DFACC_WRITE= 2; - public static final int DFACC_RDWR = 3; - public static final int DFACC_CREATE=4; - public static final int DFACC_RDONLY=DFACC_READ; - public static final int DFACC_DEFAULT=000; - public static final int DFACC_SERIAL=001; - public static final int DFACC_PARALLEL=011; - - // annotation type in HDF - public static final int AN_DATA_LABEL = 0; - public static final int AN_DATA_DESC = AN_DATA_LABEL + 1; - public static final int AN_FILE_LABEL = AN_DATA_LABEL + 2; - public static final int AN_FILE_DESC = AN_DATA_LABEL + 3; - - // HDF Tag Definations - - // HDF WILDCARD - public static final int DFTAG_WILDCARD = 0; - public static final int DFREF_WILDCARD = 0; - - // File identifier - public static final int DFTAG_FID = 100; - - // File Description - public static final int DFTAG_FD = 101; - - // Data Identifier Label - public static final int DFTAG_DIL = 104; - - // Data Identifier Annotation - public static final int DFTAG_DIA = 105; - - // 8-bits Raster image - public static final int DFTAG_RI8 = 202; - public static final int DFTAG_CI8 = 203; - public static final int DFTAG_II8 = 204; - - // 24-bits Raster image - public static final int DFTAG_RI = 302; - public static final int DFTAG_CI = 303; - public static final int DFTAG_RIG = 306; - - // SDS - public static final int DFTAG_SD = 702; - public static final int DFTAG_SDG = 700; - public static final int DFTAG_NDG = 720; - - // Vgroup or Vdata - public static final int DFTAG_VH = 1962; - public static final int DFTAG_VS = 1963; - public static final int DFTAG_VG = 1965; - - /** pixel interlacing scheme */ - public static final int MFGR_INTERLACE_PIXEL = 0; - - /** line interlacing scheme */ - public static final int MFGR_INTERLACE_LINE = MFGR_INTERLACE_PIXEL +1; - - /** component interlacing scheme */ - public static final int MFGR_INTERLACE_COMPONENT = MFGR_INTERLACE_PIXEL +2; - - /** interlacing supported by the vset.*/ - public static final int FULL_INTERLACE = 0; - public static final int NO_INTERLACE = 1; - - /** unsigned char */ - public static final int DFNT_UCHAR8 = 3; - public static final int DFNT_UCHAR = 3; - - /** char */ - public static final int DFNT_CHAR8 = 4; - public static final int DFNT_CHAR = 4; - - /** No supported by HDF */ - public static final int DFNT_CHAR16 = 42; - public static final int DFNT_UCHAR16= 43; - - - /** float */ - public static final int DFNT_FLOAT32 = 5; - public static final int DFNT_FLOAT = 5 ; - - //** double */ - public static final int DFNT_FLOAT64 = 6; - public static final int DFNT_FLOAT128 = 7 ; - public static final int DFNT_DOUBLE = 6 ; - - /** 8-bit integer */ - public static final int DFNT_INT8 = 20; - - /** unsigned 8-bit interger */ - public static final int DFNT_UINT8 = 21; - - /** short */ - public static final int DFNT_INT16 = 22; - - /** unsigned interger */ - public static final int DFNT_UINT16 = 23; - - /** interger */ - public static final int DFNT_INT32 = 24; - - /** unsigned interger */ - public static final int DFNT_UINT32 = 25; - - /** No supported */ - public static final int DFNT_INT64 = 26; - public static final int DFNT_UINT64 = 27; - public static final int DFNT_INT128 = 28; - public static final int DFNT_UINT128 = 30; - public static final int DFNT_LITEND = 0x00004000; - - public static final int DF_FORWARD = 1; - public static final int DFS_MAXLEN = 255; - - public static final int COMP_NONE = 0; - public static final int COMP_JPEG = 2; - public static final int COMP_RLE = 11; - public static final int COMP_IMCOMP = 12; - public static final int COMP_CODE_NONE = 0; - public static final int COMP_CODE_RLE = 1; - public static final int COMP_CODE_NBIT = 2; - public static final int COMP_CODE_SKPHUFF = 3; - public static final int COMP_CODE_DEFLATE = 4; - public static final int COMP_CODE_INVALID = 5; - public static final int COMP_MODEL_STDIO = 0; - - // Interlace schemes - public static final int DFIL_PIXEL = 0; /* Pixel Interlacing */ - public static final int DFIL_LINE = 1; /* Scan Line Interlacing */ - public static final int DFIL_PLANE = 2; /* Scan Plane Interlacing */ - - public static final int SD_FILL = 0; - public static final int SD_NOFILL = 0x100; - public static final int SD_DIMVAL_BW_COMP = 1; - public static final int SD_DIMVAL_BW_INCOMP = 0; - - public static final int HDF_NONE = 0x0; - public static final int HDF_CHUNK = 0x1; - public static final int HDF_COMP = 0x3; - public static final int HDF_NBIT = 0x5; - public static final int MAX_VAR_DIMS =32; - - //the names of the Vgroups created by the GR interface - public static final String GR_NAME = "RIG0.0"; - public static final String RI_NAME = "RI0.0"; - public static final String RIGATTRNAME = "RIATTR0.0N"; - public static final String RIGATTRCLASS = "RIATTR0.0C"; - - // names of classes of the Vdatas/Vgroups created by the SD interface - public static final String HDF_ATTRIBUTE = "Attr0.0"; - public static final String HDF_VARIABLE = "Var0.0"; - public static final String HDF_DIMENSION = "Dim0.0"; - public static final String HDF_UDIMENSION = "UDim0.0"; - public static final String DIM_VALS = "DimVal0.0"; - public static final String DIM_VALS01 = "DimVal0.1"; - public static final String HDF_CHK_TBL = "_HDF_CHK_TBL_"; - public static final String HDF_CDF = "CDF0.0"; - - // names of data object types - public static final String ANNOTATION = "HDF_ANNOTATION"; - public static final String RI8 = "HDF_RI8"; - public static final String RI24 = "HDF_RI24"; - public static final String GR = "HDF_GR"; - public static final String SDS = "HDF_SDS"; - public static final String VDATA = "HDF_VDATA"; - public static final String VGROUP = "HDF_GROUP"; - - // data types represented by Strings - public static final String UCHAR8 = "UCHAR8"; - public static final String CHAR8 = "CHAR8"; - public static final String UCHAR16 = "UCHAR16"; - public static final String CHAR16 = "CHAR16"; - public static final String FLOAT32 = "FLOAT32"; - public static final String FLOAT64 = "FLOAT64"; - public static final String FLOAT128 = "FLOAT128"; - public static final String INT8 = "INT8"; - public static final String UINT8 = "UINT8"; - public static final String INT16 = "INT16"; - public static final String UINT16 = "UINT16"; - public static final String INT32 = "INT32"; - public static final String UINT32 = "UINT32"; - public static final String INT64 = "INT64"; - public static final String UINT64 = "UINT64"; - public static final String INT128 = "INT128"; - public static final String UINT128 = "UINT128"; - - - /** - * convert number type to string type - * params type the number representing the data type - * return the string representing the data type - */ - public static String getType(int type) - { - if (type == HDFConstants.DFNT_UCHAR8) return HDFConstants.UCHAR8; - else if (type == HDFConstants.DFNT_CHAR8) return HDFConstants.CHAR8; - else if (type == HDFConstants.DFNT_UCHAR16) return HDFConstants.UCHAR16; - else if (type == HDFConstants.DFNT_CHAR16) return HDFConstants.CHAR16; - else if (type == HDFConstants.DFNT_FLOAT32) return HDFConstants.FLOAT32; - else if (type == HDFConstants.DFNT_FLOAT64) return HDFConstants.FLOAT64; - else if (type == HDFConstants.DFNT_FLOAT128) return HDFConstants.FLOAT128; - else if (type == HDFConstants.DFNT_INT8) return HDFConstants.INT8; - else if (type == HDFConstants. DFNT_UINT8) return HDFConstants.UINT8; - else if (type == HDFConstants.DFNT_INT16) return HDFConstants.INT16; - else if (type == HDFConstants.DFNT_UINT16) return HDFConstants.UINT16; - else if (type == HDFConstants.DFNT_INT32) return HDFConstants.INT32; - else if (type == HDFConstants.DFNT_UINT32) return HDFConstants.UINT32; - else if (type == HDFConstants.DFNT_INT64) return HDFConstants.INT64; - else if (type == HDFConstants.DFNT_UINT64) return HDFConstants.UINT64; - else if (type == HDFConstants.DFNT_INT128) return HDFConstants.INT128; - else if (type == HDFConstants.DFNT_UINT128) return HDFConstants.UINT128; - else return "Undefined Data Type"; - } - - /** - * convert string type to number type - * params type the string representing the data type - * return the integer representing the data type - */ - public static int getType(String type) - { - if (type.equalsIgnoreCase(HDFConstants.UCHAR8)) return HDFConstants.DFNT_UCHAR8; - else if (type.equalsIgnoreCase(HDFConstants.CHAR8)) return HDFConstants.DFNT_CHAR8; - else if (type.equalsIgnoreCase(HDFConstants.UCHAR16)) return HDFConstants.DFNT_UCHAR16; - else if (type.equalsIgnoreCase(HDFConstants.CHAR16)) return HDFConstants.DFNT_CHAR16; - else if (type.equalsIgnoreCase(HDFConstants.FLOAT32)) return HDFConstants.DFNT_FLOAT32; - else if (type.equalsIgnoreCase(HDFConstants.FLOAT64)) return HDFConstants.DFNT_FLOAT64; - else if (type.equalsIgnoreCase(HDFConstants.FLOAT128)) return HDFConstants.DFNT_FLOAT128; - else if (type.equalsIgnoreCase(HDFConstants.INT8)) return HDFConstants.DFNT_INT8; - else if (type.equalsIgnoreCase(HDFConstants. UINT8)) return HDFConstants.DFNT_UINT8; - else if (type.equalsIgnoreCase(HDFConstants.INT16)) return HDFConstants.DFNT_INT16; - else if (type.equalsIgnoreCase(HDFConstants.UINT16)) return HDFConstants.DFNT_UINT16; - else if (type.equalsIgnoreCase(HDFConstants.INT32)) return HDFConstants.DFNT_INT32; - else if (type.equalsIgnoreCase(HDFConstants.UINT32)) return HDFConstants.DFNT_UINT32; - else if (type.equalsIgnoreCase(HDFConstants.INT64)) return HDFConstants.DFNT_INT64; - else if (type.equalsIgnoreCase(HDFConstants.UINT64)) return HDFConstants.DFNT_UINT64; - else if (type.equalsIgnoreCase(HDFConstants.INT128)) return HDFConstants.DFNT_INT128; - else if (type.equalsIgnoreCase(HDFConstants.UINT128)) return HDFConstants.DFNT_UINT128; - else return -1; - } - - /** - * gets the size of the data type in bytes, - * e.g size of DFNT_FLOAT32 = 4 - * - * the size of the data type - */ - public static int getTypeSize(int type) - { - int size = 0; - - switch(type) - { - case HDFConstants.DFNT_UCHAR16: - case HDFConstants.DFNT_CHAR16: - case HDFConstants.DFNT_INT16: - case HDFConstants.DFNT_UINT16: - size = 2; - break; - case HDFConstants.DFNT_FLOAT32: - case HDFConstants.DFNT_INT32: - case HDFConstants.DFNT_UINT32: - size = 4; - break; - case HDFConstants.DFNT_FLOAT64: - case HDFConstants.DFNT_INT64: - case HDFConstants.DFNT_UINT64: - size = 8; - break; - case HDFConstants.DFNT_FLOAT128: - case HDFConstants.DFNT_INT128: - case HDFConstants.DFNT_UINT128: - size = 16; - break; - default: - size = 1; - break; - } - - return size; - } - -} diff --git a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFException.java b/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFException.java deleted file mode 100755 index 45904cd3..00000000 --- a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFException.java +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * National Comptational Science Alliance * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -package ncsa.hdf.hdflib; - -/** - *

- * The class HDFException returns errors from the HDF - * library. - *

- * Two sub-classes of HDFException are defined: - *

- *

    - *
  1. - * HDFLibraryException -- errors raised the HDF library code - *
  2. - * HDFJavaException -- errors raised the HDF Java wrapper code - *
- *

- * These exceptions will be sub-classed to represent specific - * error conditions, as needed. - *

- * The only specific exception currently defined is - * HDFNotImplementedException, indicating a function that is part - * of the HDF API, but which cannot or will not be implemented - * for Java. - */ -public class HDFException extends Exception { - - - static public final String OutOfMemoryMessage="ERROR: HDF Library: Out of memory"; - static public final String HDFExceptionMessage="ERROR: HDF Library Error"; - static public final String HDFMessage="ERROR: Unknown HDF Error"; - - int HDFerror; - String msg; - - public HDFException() { - HDFerror = 0; - } - - public HDFException(String s) { - msg = s; - } - - public HDFException(int err) { - HDFerror = err; - } - - public String getMessage() { - return msg; - } -} diff --git a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFJavaException.java b/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFJavaException.java deleted file mode 100755 index 1afafec7..00000000 --- a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFJavaException.java +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * National Comptational Science Alliance * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -package ncsa.hdf.hdflib; - -/** - *

- * The class HDFJavaException returns errors from the Java - * wrapper of theHDF library. - *

- * These errors include Java configuration errors, security - * violations, and resource exhaustion. - */ -public class HDFJavaException extends HDFException { - - String msg; - - public HDFJavaException() { - HDFerror = 0; - } - - public HDFJavaException(String s) { - msg = "HDFLibraryException: "+s; - } - - public String getMessage() { - return msg; - } -} diff --git a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFNativeData.java b/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFNativeData.java deleted file mode 100755 index 1f0b11b3..00000000 --- a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFNativeData.java +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * National Comptational Science Alliance * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -package ncsa.hdf.hdflib; - -public class HDFNativeData -{ - public HDFNativeData() {} - public static native int[] byteToInt( byte[] data ); - public static native float[] byteToFloat( byte[] data ); - public static native short[] byteToShort( byte[] data ); - public static native long[] byteToLong( byte[] data ); - public static native double[] byteToDouble( byte[] data ); - - public static native int[] byteToInt( int start, int len, byte[] data ); - public static int byteToInt( byte[] data, int start) - { - int []ival = new int[1]; - ival = byteToInt(start,1,data); - return(ival[0]); - } - - public static native short[] byteToShort( int start, int len, byte[] data ); - public static short byteToShort( byte[] data, int start) - { - short []sval = new short[1]; - sval = byteToShort(start,1,data); - return(sval[0]); - } - - public static native float[] byteToFloat( int start, int len, byte[] data ); - public static float byteToFloat( byte[] data, int start) - { - float []fval = new float[1]; - fval = byteToFloat(start,1,data); - return(fval[0]); - } - - public static native long[] byteToLong( int start, int len, byte[] data ); - public static long byteToLong( byte[] data, int start) - { - long []lval = new long[1]; - lval = byteToLong(start,1,data); - return(lval[0]); - } - - public static native double[] byteToDouble( int start, int len, byte[] data ); - public static double byteToDouble( byte[] data, int start) - { - double []dval = new double[1]; - dval = byteToDouble(start,1,data); - return(dval[0]); - } - - public static native byte[] intToByte( int start, int len, int[] data); - public static native byte[] shortToByte( int start, int len, short[] data); - public static native byte[] floatToByte( int start, int len, float[] data); - public static native byte[] longToByte( int start, int len, long[] data); - public static native byte[] doubleToByte( int start, int len, double[] data); - - public static native byte[] byteToByte( byte data); - static byte[] byteToByte( Byte data){return byteToByte(data.byteValue());} - public static native byte[] intToByte( int data); - static byte[] intToByte( Integer data){return intToByte(data.intValue());} - public static native byte[] shortToByte(short data); - static byte[] shortToByte( Short data){return shortToByte(data.shortValue());} - public static native byte[] floatToByte( float data); - static byte[] floatToByte( Float data){return floatToByte(data.floatValue());}; - public static native byte[] longToByte( long data); - static byte[] longToByte(Long data){ return longToByte(data.longValue());} - public static native byte[] doubleToByte( double data); - static byte[] doubleToByte( Double data){return doubleToByte(data.doubleValue());} - - public Object byteToNumber( byte[] barray, Object obj) - throws HDFException - { - Class theClass = obj.getClass(); - String type = theClass.getName(); - Object retobj = null; - - if (type.equals("java.lang.Integer")) { - int[] i = ncsa.hdf.hdflib.HDFNativeData.byteToInt(0,1,barray); - retobj = new Integer(i[0]); - } else if (type.equals("java.lang.Byte")) { - retobj = new Byte(barray[0]); - } else if (type.equals("java.lang.Short")) { - short[] f = ncsa.hdf.hdflib.HDFNativeData.byteToShort(0,1,barray); - retobj = new Short(f[0]) ; - } else if (type.equals("java.lang.Float")) { - float[] f = ncsa.hdf.hdflib.HDFNativeData.byteToFloat(0,1,barray); - retobj = new Float(f[0]) ; - } else if (type.equals("java.lang.Long")) { - long[] f = ncsa.hdf.hdflib.HDFNativeData.byteToLong(0,1,barray); - retobj = new Long(f[0]) ; - } else if (type.equals("java.lang.Double")) { - double[] f = ncsa.hdf.hdflib.HDFNativeData.byteToDouble(0,1,barray); - retobj = new Double(f[0] ); - } else { - /* exception: unsupprted type */ - HDFException ex = - (HDFException)new HDFJavaException("byteToNumber: setfield bad type: "+obj+" "+type); - throw(ex); - } - return(retobj); - } - - /** - * Allocate a 1D array large enough to hold a multidimensional - * array of 'datasize' elements of 'dataType' numbers. - * This is called from ncsa.hdf.hdfobject.HDFGR and - * ncsa.hdf.hdfobject.HDFSDS, and hdf.ncsa.io.ASCII2HDF - * - * @param dataType the type of the iamge data - * @param datasize the size of the image data array - * @returns an array of 'datasize' numbers of 'dataType - * - * @see ncsa.hdf.hdfobject.HDFGR - * @see ncsa.hdf.hdfobject.HDFSDS - */ -public static Object defineDataObject(int dataType, int datasize) - { - Object data = null; - - if ((dataType & HDFConstants.DFNT_LITEND) != 0) { - dataType -= HDFConstants.DFNT_LITEND; - } - - switch(dataType) - { - case HDFConstants.DFNT_INT16: - case HDFConstants.DFNT_UINT16: - data = new short[datasize]; - break; - case HDFConstants.DFNT_INT32: - case HDFConstants.DFNT_UINT32: - data = new int[datasize]; - break; - case HDFConstants.DFNT_INT64: - case HDFConstants.DFNT_UINT64: - data = new long[datasize]; - break; - case HDFConstants.DFNT_FLOAT32: - data = new float[datasize]; - break; - case HDFConstants.DFNT_FLOAT64: - data = new double[datasize]; - break; - default: - case HDFConstants.DFNT_CHAR: - case HDFConstants.DFNT_UCHAR8: - case HDFConstants.DFNT_UINT8: - case HDFConstants.DFNT_INT8: - data = new byte[datasize]; - break; - - } - return data; - } -} diff --git a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFNotImplementedException.java b/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFNotImplementedException.java deleted file mode 100755 index 73cf3226..00000000 --- a/contrib/applications/nxplot/jnexus/src/ncsa/hdf/hdflib/HDFNotImplementedException.java +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * National Comptational Science Alliance * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -package ncsa.hdf.hdflib; - -/** - *

- * HDFNotImplementedException indicates a function that is part - * of the HDF API, but which cannot or will not be implemented - * for Java. - *

- * For instance, C routines which take Unix FILE objects - * as parameters are not appropriate for the Java interface - * and will not be implemented. These routines will raise - * an HDFNotImplementedException. - */ - -public class HDFNotImplementedException extends HDFJavaException { - - String msg; - - public HDFNotImplementedException() { - HDFerror = 0; - } - - public HDFNotImplementedException(String s) { - msg = "HDFJavaException: HDF function not implmented (yet): "+s; - } - - public String getMessage() { - return msg; - } -} diff --git a/contrib/applications/nxplot/jnexus/src/org/nexusformat/AttributeEntry.java b/contrib/applications/nxplot/jnexus/src/org/nexusformat/AttributeEntry.java deleted file mode 100755 index e4bb0d60..00000000 --- a/contrib/applications/nxplot/jnexus/src/org/nexusformat/AttributeEntry.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This is a little helper class which holds additional information about - * a dataset or global attribute. - * - * @author Mark Koennecke, October 2000 - * - * @see NeXusFileInterface. - * - * copyright: see acompanying COPYRIGHT file. - */ -package org.nexusformat; - -public class AttributeEntry { - /** - * length is the length of the attribute. - * type is the number type of the attribute. - */ - public int length, type; -} diff --git a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NXlink.java b/contrib/applications/nxplot/jnexus/src/org/nexusformat/NXlink.java deleted file mode 100755 index 3dd12d7b..00000000 --- a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NXlink.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * NXlink is a replacement for the structure holding the data necessary - * for doing a link in the NeXus-API. Consequently it is primitive. - * - * Mark Koennecke, October 2000 - * - * updated for Napi-2.0 with HDF-5 - * Mark Koennecke, August 2001 - * - * updated for NAPI-3.0 with XML - * Mark Koennecke, October 2004 - * - * copyright: see accompanying COPYRIGHT file - */ -package org.nexusformat; - -public class NXlink { - public int tag, ref, linkType; - public String targetPath; - - public NXlink(){ - targetPath = new String(""); - } -} diff --git a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NeXusFileInterface.java b/contrib/applications/nxplot/jnexus/src/org/nexusformat/NeXusFileInterface.java deleted file mode 100755 index 0bb3553f..00000000 --- a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NeXusFileInterface.java +++ /dev/null @@ -1,346 +0,0 @@ -/** - * - * The NeXus-API for Java. NeXus is an attempt to define a common data - * format for org and x-ray diffraction. NeXus is built on top of the - * Hierarchical Data Format from NCSA. There exist already API's to - * NeXus files for F77, F90, C and C++. This is the interface definition - * for a Java API to NeXus files. - * - * Some changes to the API have been necessary however, due to the - * different calling standards between C and Java. - * - * - * @author Mark Koennecke, October 2000 - * - * updated for NAPI-2.0, including HDF-5 support - * @author Mark Koennecke, August 2001 - * - * updated for NXopengrouppath, NXopensourcepath, XML - * @author Mark Koennecke, December 2004 - * - * copyright: see accompanying COPYRIGHT file - */ -package org.nexusformat; - -import java.util.Hashtable; - -public interface NeXusFileInterface { - - // general functions - /** - * flush writes all previously unsaved data to disk. All directory - * searches are invalidated. Any open SDS is closed. - * @exception NexusException if an HDF error occurs. - */ - public void flush() throws NexusException; - /** - * finalize closes the file. It is supposed to be called by the - * garbage collector when the object is collected. As this happens - * at discretion of the garbage collector it is safer to call finalize - * yourself, when a NeXus file needs to be closed. Multiple calls to - * finalize do no harm. - * @exception Throwable because it is required by the definition of - * finalize. - */ - public void finalize() throws Throwable; - /** - * close the NeXus file. To make javalint and diamond happy - * @throws NexusException - */ - public void close() throws NexusException; - // group functions - /** - * makegroup creates a new group below the current group within - * the NeXus file hierarchy. - * @param name The name of the group to create. - * @param nxclass The classname of the group. - * @exception NexusException if an error occurs during this operation. - */ - public void makegroup(String name, String nxclass) throws - NexusException; - /** - * opengroup opens the group name with class nxclass. - * The group must exist, otherwise an exception is thrown. opengroup is - * similar to a cd name in a filesystem. - * @param name the name of the group to open. - * @param nxclass the classname of the group to open. - * @exception NexusException when something goes wrong. - */ - public void opengroup(String name, String nxclass) throws - NexusException; - /** - * openpath opens groups and datsets accroding to the path string - * given. The path syntax follows unix conventions. Both absolute - * and relative paths are possible. All objects of the path must - * exist. - * @param path The path string - * @exception NexusException when something goes wrong. - */ - public void openpath(String path) throws - NexusException; - /** - * opengrouppath opens groups and datsets accroding to the path string - * given. The path syntax follows unix conventions. Both absolute - * and relative paths are possible. All objects of the path must - * exist. This function stops int the last group. - * @param path The path string - * @exception NexusException when something goes wrong. - */ - public void opengrouppath(String path) throws - NexusException; - /** - * closegroup closes access to the current group and steps down one - * step in group hierarchy. - * @exception NexusException when an HDF error occurs during this - * operation. - */ - public void closegroup() throws - NexusException; - - // data set handling - /** - * makedata creates a new dataset with the specified characteristics - * in the current group. - * @param name The name of the dataset. - * @param type The number type of the dataset. Usually a constant from - * a selection of values. - * @param rank The rank or number of dimensions of the dataset. - * @param dim An array containing the length of each dimension. dim must - * have at least rank entries. The first dimension can be -1 which - * means it is an unlimited dimension. - * @exception NexusException when the dataset could not be created. - */ - public void makedata(String name, int type, int rank, int dim[]) - throws NexusException; - /** - * compmakedata creates a new dataset with the specified characteristics - * in the current group. This data set will be compressed. - * @param name The name of the dataset. - * @param type The number type of the dataset. Usually a constant from - * a selection of values. - * @param rank The rank or number of dimensions of the dataset. - * @param dim An array containing the length of each dimension. dim must - * have at least rank entries. The first dimension can be -1 which - * means it is an unlimited dimension. - * @param compression_type determines the compression type. - * @param iChunk With HDF-5, slabs can be written to compressed data - * sets. The size of these slabs is specified through the chunk array. - * This must have the rank values for the size of the chunk to - * be written in each dimension. - * @exception NexusException when the dataset could not be created. - */ - public void compmakedata(String name, int type, int rank, int dim[], - int compression_type, int iChunk[]) throws - NexusException; - /** - * opendata opens an existing dataset for access. For instance for - * reading or writing. - * @param name The name of the dataset to open. - * @exception NexusException when the dataset does not exist or - * something else is wrong. - */ - public void opendata(String name)throws - NexusException; - /** - * closedata closes an opened dataset. Then no further access is - * possible without a call to opendata. - * @exception NexusException when an HDF error occurrs. - */ - public void closedata() throws - NexusException; - /** - * causes the currently open dataset to be compressed on file. - * This must be called after makedata and before writing to the - * dataset. - * @param compression_type determines the type of compression - * to use. - * @exception NexusException when no dataset is open or an HDF error - * occurs. - */ - public void compress(int compression_type) throws - NexusException; - - // data set reading - /** - * getdata reads the data from an previously openend dataset into - * array. - * @param array An n-dimensional array of the appropriate number - * type for the dataset. Make sure to have the right type and size - * here. - * @exception NexusException when either an HDF error occurs or - * no dataset is open or array is not of the right type to hold - * the data. - */ - public void getdata(Object arrary)throws - NexusException; - /** - * getslab reads a subset of a large dataset into array. - * @param start An array of dimension rank which contains the start - * position in the dataset from where to start reading. - * @param size An array of dimension rank which contains the size - * in each dimension of the data subset to read. - * @param array An array for holding the returned data values. - * @exception NexusException when either an HDF error occurs or - * no dataset is open or array is not of the right type to hold - * the data. - */ - public void getslab(int start[], int size[],Object array)throws - NexusException; - /** - * getattr retrieves the data associated with the attribute - * name. - * @param name The name of the attribute. - * @param data an array with sufficient space for holding the attribute - * data. - * @param args An integer array holding the number of data elements - * in data as args[0], and the type as args[1]. Both values will be - * updated while reading. - * @exception NexusException when either an HDF error occurs or - * the attribute could not be found. - */ - public void getattr(String name,Object data, int args[])throws - NexusException; - - // data set writing - /** - * putdata writes the data from array into a previously opened - * dataset. - * @param array The data to write. - * @exception NexusException when an HDF error occurs. - */ - public void putdata(Object array) throws - NexusException; - /** - * putslab writes a subset of a larger dataset to a previously opened - * dataset. - * @param array The data to write. - * @param start An integer array of dimension rank which holds the - * startcoordinates of the data subset in the larger dataset. - * @param size An integer array of dimension rank whidh holds the - * size in each dimension of the data subset to write. - * @exception NexusException when an HDF error occurs. - */ - public void putslab(Object array, int start[], int size[]) throws - NexusException; - /** - * putattr adds a named attribute to a previously opened dataset or - * a global attribute if no dataset is open. - * @param name The name of the attribute. - * @param array The data of the attribute. - * @param iType The number type of the attribute. - * @exception NexusException if an HDF error occurs. - */ - public void putattr(String name, Object array, int iType) throws - NexusException; - - // inquiry - /** - * getinfo retrieves information about a previously opened dataset. - * @param iDim An array which will be filled with the size of - * the dataset in each dimension. - * @param args An integer array which will hold more information about - * the dataset after return. The fields: args[0] is the rank, args[1] is - * the number type. - * @exception NexusException when an HDF error occurs. - */ - public void getinfo(int iDim[], int args[]) throws - NexusException; - /** - * setnumberformat sets the number format for printing number when - * using the XML-NeXus format. For HDF4 and HDF5 this is ignored. - * If a dataset is open, the format for the dataset is set, if none - * is open the default setting for the number type is changed. - * The format must be a ANSII-C language format string. - * @param type The NeXus type to set the format for. - * @param format The new format to use. - */ - public void setnumberformat(int type, String format) - throws NexusException; - /** - * groupdir will retrieve the content of the currently open vGroup. - * groupdir is similar to an ls in unix. - * @return A Hashtable which will hold the names of the items in - * the group as keys and the NeXus classname for vGroups or the - * string 'SDS' for datasets as values. - * @exception NexusException if an HDF error occurs - */ - public Hashtable groupdir()throws - NexusException; - /** - * attrdir returns the attributes of the currently open dataset or - * the file global attributes if no dataset is open. - * @return A Hashtable which will hold the names of the attributes - * as keys. For each key there is an AttributeEntry class as value. - * @exception NexusException when an HDF error occurs. - */ - public Hashtable attrdir()throws - NexusException; - - // linking - /** - * getgroupID gets the data necessary for linking the current vGroup - * somewhere else. - * @return A NXlink object holding the link data. - * @exception NexusException if an HDF error occurs. - */ - public NXlink getgroupID() throws - NexusException; - /** - * getdataID gets the data necessary for linking the current dataset - * somewhere else. - * @return A NXlink object holding the link data. - * @exception NexusException if an HDF error occurs. - */ - public NXlink getdataID()throws - NexusException; - /** - * makelink links the object described by target into the current - * vGroup. - * @param target The Object to link into the current group. - * @exception NexusException if an error occurs. - */ - public void makelink(NXlink target)throws - NexusException; - /** - * makenamedlink links the object described by target into the current - * vGroup. The object will have a new name in the group into which it is - * linked - * @param target The Object to link into the current group. - * @param name The name of this object in the current group - * @exception NexusException if an error occurs. - */ - public void makenamedlink(String name, NXlink target)throws - NexusException; - /** - * opensourcepath opens the group from which the current item was linked - * Returns an error if the current item is not linked. - * @exception NexusException if an error occurs. - */ - public void opensourcepath()throws - NexusException; - /** - * inquirefile inquires which file we are currently in. This is - * a support function for external linking - * @return The current file - * @throws NexusException when things are wrong - */ - public String inquirefile() throws NexusException; - /** - * linkexternal links group name, nxclass to the URL nxurl - * @param name The name of the vgroup to link to - * @apram nxcall The class name of the linked vgroup - * @param nxurl The URL to the linked external file - * @throws NexusException if things are wrong - */ - public void linkexternal(String name, String nxclass, String nxurl) throws NexusException; - /** - * nxisexternalgroup test the group name, nxclass if it is linked externally. - * @param name of the group to test - * @param nxclass class of the group to test - * @return null when the group is not linked, else a string giving the URL of the - * linked file. - * @throws NexusException if things are wrong - */ - public String isexternalgroup(String name, String nxclass) throws NexusException; -} - diff --git a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NexusException.java b/contrib/applications/nxplot/jnexus/src/org/nexusformat/NexusException.java deleted file mode 100755 index ce6fec8d..00000000 --- a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NexusException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * NexusException is thrown whenever an error occurs in the NeXus Java API - * - * Mark Koennecke, October 2000 - * - * copyright: see accompanying COPYRIGHT file. - */ -package org.nexusformat; - -public class NexusException extends Exception { - - - static public final String OutOfMemoryMessage= - "ERROR: NeXus-API: Out of memory"; - static public final String NexusExceptionMessage= - "ERROR: NeXus-API Error"; - static public final String NeXusMessage= - "ERROR: Unknown NeXus-API Error"; - - int HDFerror; - String msg; - - public NexusException() { - HDFerror = 0; - } - - public NexusException(String s) { - msg = s; - } - - public NexusException(int err) { - HDFerror = err; - } - - public String getMessage() { - return msg; - } -} - diff --git a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NexusFile.java b/contrib/applications/nxplot/jnexus/src/org/nexusformat/NexusFile.java deleted file mode 100755 index 70e9d89e..00000000 --- a/contrib/applications/nxplot/jnexus/src/org/nexusformat/NexusFile.java +++ /dev/null @@ -1,780 +0,0 @@ -/** - * - * The NeXus-API for Java. NeXus is an attempt to define a common data - * format for org and x-ray diffraction. NeXus is built on top of the - * Hierarchical Data Format from NCSA. There exist already API's to - * NeXus files for F77, F90, C and C++. This is an implementation of - * a Java NeXus API using native methods. - * - * Some changes to the API have been necessary however, due to the - * different calling standards between C and Java. - * - * - * @author Mark Koennecke, October 2000 - * - * Updated: Mark Koennecke, April 2006 - * - * copyright: see accompanying COPYRIGHT file - */ -package org.nexusformat; - -import java.util.Hashtable; -import java.io.File; -import ncsa.hdf.hdflib.HDFArray; -import ncsa.hdf.hdflib.HDFException; -import ncsa.hdf.hdflib.HDFConstants; - -public class NexusFile implements NeXusFileInterface { - - // constants - /** - * possible access codes, @see #NexusFile. - */ - public final static int NXACC_READ = 1; - public final static int NXACC_RDWR = 2; - public final static int NXACC_CREATE = 3; - public final static int NXACC_CREATE4 = 4; - public final static int NXACC_CREATE5 = 5; - public final static int NXACC_CREATEXML = 6; - public final static int NXACC_NOSTRIP = 128; - - /** - * constant denoting an unlimited dimension. - */ - public final static int NX_UNLIMITED = -1; - - /** - * constants for number types. @see #makedata, @see #putattr - * and others. - */ - public final static int NX_FLOAT32 = 5; - public final static int NX_FLOAT64 = 6; - public final static int NX_INT8 = 20; - public final static int NX_BINARY = 20; - public final static int NX_UINT8 = 21; - public final static int NX_BOOLEAN = 21; - public final static int NX_INT16 = 22; - public final static int NX_UINT16 = 23; - public final static int NX_INT32 = 24; - public final static int NX_UINT32 = 25; - public final static int NX_INT64 = 26; - public final static int NX_UINT64 = 27; - public final static int NX_CHAR = 4; - - /** - * constants for compression schemes @see #compress - */ - public final static int NX_COMP_NONE = 100; - public final static int NX_COMP_LZW = 200; - public final static int NX_COMP_RLE = 300; - public final static int NX_COMP_HUF = 400; - - /** - * Maximum name length, must be VGNAMELENMAX in hlimits.h - */ - protected final static int MAXNAMELEN = 64; - - /* - This code takes care of loading the static library required for - this class to work properly. The algorithm first looks for a - property org.nexusformat.JNEXUSLIB and loads that file if available, - else it tries to locate the library in the system shared library - path. - */ - static - { - String filename = null; - filename = System.getProperty("org.nexusformat.JNEXUSLIB",null); - if ((filename != null) && (filename.length() > 0)) - { - File hdfdll = new File(filename); - if (hdfdll.exists() && hdfdll.canRead() && hdfdll.isFile()) - { - System.load(filename); - } else { - throw (new UnsatisfiedLinkError("Invalid JNEXUS library")); - } - } - else { - System.loadLibrary("jnexus"); - } - } - - /** - * This is the handle to the NeXus file handle. - */ - protected int handle; - - // Construction - // native methods for this section - protected native int init(String filename, int access); - protected native void close(int handle); - protected native int nxflush(int handle); - - /** - * constructs a new NexusFile Object. - * @param filename The name of the NeXus file to access. - * @param access. The access mode for the file. Can only be one - * of the predefined NeXus access code NXACC.... These are: - *

- *
NXACC_CREATE - *
or creating a new file. - *
NXACC_RDWR - *
For opening an existing file for modification or appending - * data. - *
NXACC_READ - *
For opening a file for reading. - *
- *
NXACC_NOSTRIP - *
To keep leading and trailing whitespace on strings - * - * @exception NexusException when the file could not be found or - * an HDF error occurred. - */ - public NexusFile(String filename, int access) throws NexusException - { - handle = init(filename,access); - if(handle < 0){ - throw new NexusException("Failed to open " + filename); - } - } - /** - * flushes all pending data to disk. Closes any open SDS's. - */ - public void flush() throws NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - handle = nxflush(handle); - } - /** - * close the NeXus file. To make javalint and diamond happy - * @throws NexusException - */ - public void close() throws NexusException{ - if(handle >= 0) - { - close(handle); - handle = -1; - } - } - - /** - * removes all NeXus file data structures and closes the file. This - * function should automatically be called by the Java garbage - * collector whenever the NexusFile object falls into disuse. However - * the time when this is done is left to the garbage collector. My - * personal experience is that finalize might never be called. I - * suggest, to call finalize yourself when you are done with the - * NeXus file. finalize makes sure that multiple invocations will not - * do any harm. - */ - public void finalize() throws Throwable - { - close(); - } - - - // group functions - //native methods for this section - protected native void nxmakegroup(int handle, String name, String nxclass); - protected native void nxopengroup(int handle, String name, String nxclass); - protected native void nxopenpath(int handle, String path); - protected native void nxopengrouppath(int handle, String path); - protected native void nxclosegroup(int handle); - - /** - * makegroup creates a new group below the current group within - * the NeXus file hierarchy. - * @param name The name of the group to create. - * @param nxclass The classname of the group. - * @exception NexusException if an error occurs during this operation. - */ - public void makegroup(String name, String nxclass) throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxmakegroup(handle, name, nxclass); - } - /** - * opengroup opens the group name with class nxclass. - * The group must exist, otherwise an exception is thrown. opengroup is - * similar to a cd name in a filesystem. - * @param name the name of the group to open. - * @param nxclass the classname of the group to open. - * @exception NexusException when something goes wrong. - */ - public void opengroup(String name, String nxclass) throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxopengroup(handle, name, nxclass); - } - /** - * openpath opens groups and datsets accroding to the path string - * given. The path syntax follows unix conventions. Both absolute - * and relative paths are possible. All objects of the path must - * exist. - * @param path The path string - * @exception NexusException when something goes wrong. - */ - public void openpath(String path) throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxopenpath(handle,path); - } - /** - * opengrouppath opens groups and datsets accroding to the path string - * given. The path syntax follows unix conventions. Both absolute - * and relative paths are possible. All objects of the path must - * exist. This opens only until the last group. - * @param path The path string - * @exception NexusException when something goes wrong. - */ - public void opengrouppath(String path) throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxopengrouppath(handle,path); - } - - /** - * closegroup closes access to the current group and steps down one - * step in group hierarchy. - * @exception NexusException when an HDF error occurs during this - * operation. - */ - public void closegroup() throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxclosegroup(handle); - } - - // data set handling - // native methods for this section - protected native void nxmakedata(int handle, String name, int type, - int rank, int dim[]); - protected native void nxmakecompdata(int handle, String name, int type, - int rank, int dim[], int iCompress, - int iChunk[]); - protected native void nxopendata(int handle, String name); - protected native void nxclosedata(int handle); - protected native void nxcompress(int handle, int compression_type); - /** - * compmakedata creates a new dataset with the specified characteristics - * in the current group. This data set will be compressed. - * @param name The name of the dataset. - * @param type The number type of the dataset. Usually a constant from - * a selection of values. - * @param rank The rank or number of dimensions of the dataset. - * @param dim An array containing the length of each dimension. dim must - * have at least rank entries. The first dimension can be -1 which - * means it is an unlimited dimension. - * @param compression_type determines the compression type. - * @param iChunk With HDF-5, slabs can be written to compressed data - * sets. The size of these slabs is specified through the chunk array. - * This must have the rank values for the size of the chunk to - * be written in each dimension. - * @exception NexusException when the dataset could not be created. - */ - public void compmakedata(String name, int type, int rank, int dim[], - int compression_type, int iChunk[]) throws - NexusException { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - checkType(type); - switch(compression_type) { - case NexusFile.NX_COMP_NONE: - case NexusFile.NX_COMP_LZW: - break; - default: - throw new NexusException("Invalid compression code requested"); - - } - nxmakecompdata(handle,name,type,rank,dim,compression_type, iChunk); - } - - /** - * makedata creates a new dataset with the specified characteristics - * in the current group. - * @param name The name of the dataset. - * @param type The number type of the dataset. Usually a constant from - * a selection of values. - * @param rank The rank or number of dimensions of the dataset. - * @param dim An array containing the length of each dimension. dim must - * have at least rank entries. The first dimension can be -1 which - * means it is an unlimited dimension. - * @exception NexusException when the dataset could not be created. - */ - public void makedata(String name, int type, int rank, int dim[]) throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - checkType(type); - nxmakedata(handle,name,type,rank,dim); - } - /** - * opendata opens an existing dataset for access. For instance for - * reading or writing. - * @param name The name of the dataset to open. - * @exception NexusException when the dataset does not exist or - * something else is wrong. - */ - public void opendata(String name)throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxopendata(handle,name); - } - /** - * closedata closes an opened dataset. Then no further access is - * possible without a call to opendata. - * @exception NexusException when an HDF error occurrs. - */ - public void closedata() throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxclosedata(handle); - } - /** - * causes the currently open dataset to be compressed on file. - * This must be called after makedata and before writing to the - * dataset. - * @param compression_type determines the type of compression - * to use. - * @exception NexusException when no dataset is open or an HDF error - * occurs. - */ - public void compress(int compression_type) throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - switch(compression_type) { - case NexusFile.NX_COMP_NONE: - case NexusFile.NX_COMP_LZW: - case NexusFile.NX_COMP_RLE: - case NexusFile.NX_COMP_HUF: - break; - default: - throw new NexusException("Invalid compression code requested"); - - } - nxcompress(handle,compression_type); - } - - // data set reading - // native methods in this section - protected native void nxgetdata(int handle, byte bdata[]); - protected native void nxgetslab(int handle, int Start[], int size[], - byte bdata[]); - protected native void nxgetattr(int handle, String name, byte bdata[], - int args[]); - /** - * getdata reads the data from an previously openend dataset into - * array. - * @param array An n-dimensional array of the appropriate number - * type for the dataset. Make sure to have the right type and size - * here. - * @exception NexusException when either an HDF error occurs or - * no dataset is open or array is not of the right type to hold - * the data. - */ - public void getdata(Object array)throws - NexusException - { - byte bdata[]; - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - try{ - HDFArray ha = new HDFArray(array); - bdata = ha.emptyBytes(); - nxgetdata(handle,bdata); - array = ha.arrayify(bdata); - }catch(HDFException he) { - throw new NexusException(he.getMessage()); - } - } - /** - * getslab reads a subset of a large dataset into array. - * @param start An array of dimension rank which contains the start - * position in the dataset from where to start reading. - * @param size An array of dimension rank which contains the size - * of the dataset subset in each dimension to read. - * @param array An array for holding the returned data values. - * @exception NexusException when either an HDF error occurs or - * no dataset is open or array is not of the right type to hold - * the data. - */ - public void getslab(int start[], int size[],Object array)throws - NexusException - { - byte bdata[]; - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - try{ - HDFArray ha = new HDFArray(array); - bdata = ha.emptyBytes(); - nxgetslab(handle,start,size,bdata); - array = ha.arrayify(bdata); - }catch(HDFException he) { - throw new NexusException(he.getMessage()); - } - } - /** - * getattr retrieves the data associated with the attribute - * name. - * @param name The name of the attribute. - * @param array an array with sufficient space for holding the attribute - * data. - * @param args An integer array of dimension rank which holds the - * length of the array as first value and the type as the last - * value. Both values will be updated during reading. - * @exception NexusException when either an HDF error occurs or - * the attribute could not be found. - */ - public void getattr(String name,Object array, int args[])throws - NexusException - { - byte bdata[]; - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - checkType(args[1]); - try{ - HDFArray ha = new HDFArray(array); - bdata = ha.emptyBytes(); - nxgetattr(handle, name, bdata,args); - array = ha.arrayify(bdata); - }catch(HDFException he) { - throw new NexusException(he.getMessage()); - } - } - - // data set writing - // native methods for this section - protected native void nxputdata(int handle, byte array[]); - protected native void nxputslab(int handle, byte array[], - int start[],int size[]); - protected native void nxputattr(int handle, String name, - byte array[], int type); - - /** - * putdata writes the data from array into a previously opened - * dataset. - * @param array The data to write. - * @exception NexusException when an HDF error occurs. - */ - public void putdata(Object array) throws - NexusException - { - byte data[]; - - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - try{ - HDFArray ha = new HDFArray(array); - data = ha.byteify(); - ha = null; - }catch(HDFException he) { - throw new NexusException(he.getMessage()); - } - nxputdata(handle,data); - data = null; - } - /** - * putslab writes a subset of a larger dataset to a previously opened - * dataset. - * @param array The data to write. - * @param start An integer array of dimension rank which holds the - * startcoordinates of the data subset in the larger dataset. - * @param size An integer array of dimension rank which holds the - * size in each dimension of the data subset to write. - * @exception NexusException when an HDF error occurs. - */ - public void putslab(Object array, int start[], int size[]) throws - NexusException - { - byte data[]; - - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - try{ - HDFArray ha = new HDFArray(array); - data = ha.byteify(); - ha = null; - }catch(HDFException he) { - throw new NexusException(he.getMessage()); - } - nxputslab(handle,data,start,size); - data = null; - } - /** - * putattr adds a named attribute to a previously opened dataset or - * a global attribute if no dataset is open. - * @param name The name of the attribute. - * @param array The data of the attribute. - * @param iType The number type of the attribute. - * @exception NexusException if an HDF error occurs. - */ - public void putattr(String name, Object array, int iType) throws - NexusException - { - byte data[]; - - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - checkType(iType); - try{ - HDFArray ha = new HDFArray(array); - data = ha.byteify(); - ha = null; - }catch(HDFException he) { - throw new NexusException(he.getMessage()); - } - nxputattr(handle,name,data,iType); - data = null; - } - - // inquiry - //native methods for this section - protected native void nxgetinfo(int handle, int iDim[], int args[]); - protected native void nxsetnumberformat(int handle, int type, - String format); - protected native int nextentry(int handle, String names[]); - protected native int nextattr(int handle, String names[], int args[]); - /** - * setnumberformat sets the number format for printing number when - * using the XML-NeXus format. For HDF4 and HDF5 this is ignored. - * If a dataset is open, the format for the dataset is set, if none - * is open the default setting for the number type is changed. - * The format must be a ANSII-C language format string. - * @param type The NeXus type to set the format for. - * @param format The new format to use. - */ - public void setnumberformat(int type, String format) - throws NexusException{ - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxsetnumberformat(handle,type,format); - } - /** - * getinfo retrieves information about a previously opened dataset. - * @param iDim An array which will be filled with the size of - * the dataset in each dimension. - * @param args An integer array which will hold more information about - * the dataset after return. The fields: args[0] is the rank, args[1] is - * the number type. - * @exception NexusException when an HDF error occurs. - */ - public void getinfo(int iDim[], int args[]) throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxgetinfo(handle,iDim,args); - } - /** - * groupdir will retrieve the content of the currently open vGroup. - * groupdir is similar to an ls in unix. - * @return A Hashtable which will hold the names of the items in - * the group as keys and the NeXus classname for vGroups or the - * string 'SDS' for datasets as values. - * @exception NexusException if an HDF error occurs - */ - public Hashtable groupdir()throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - Hashtable h = new Hashtable(); - String names[] = new String[2]; - int i; - while(nextentry(handle,names) != -1) - { - h.put(names[0],names[1]); - } - return h; - } - /** - * attrdir returns the attributes of the currently open dataset or - * the file global attributes if no dataset is open. - * @return A Hashtable which will hold the names of the attributes - * as keys. For each key there is an AttributeEntry class as value. - * @exception NexusException when an HDF error occurs. - */ - public Hashtable attrdir()throws - NexusException - { - int args[] = new int[2]; - AttributeEntry at; - String names[] = new String[1]; - - Hashtable h = new Hashtable(); - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - while(nextattr(handle,names,args) != -1) - { - at = new AttributeEntry(); - at.length = args[0]; - at.type = args[1]; - h.put(names[0], at); - } - return h; - } - - // linking - // native methods for this section - protected native void nxgetgroupid(int handle, NXlink link); - protected native void nxgetdataid(int handle, NXlink link); - protected native void nxmakelink(int handle, NXlink target); - protected native void nxmakenamedlink(int handle, String name, NXlink target); - protected native void nxopensourcepath(int handle); - /** - * getgroupID gets the data necessary for linking the current vGroup - * somewhere else. - * @return A NXlink class holding the link data. - * @exception NexusException if an HDF error occurs. - */ - public NXlink getgroupID() throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - NXlink l = new NXlink(); - nxgetgroupid(handle,l); - return l; - } - /** - * getdataID gets the data necessary for linking the current dataset - * somewhere else. - * @return A NXlink class holding the link data. - * @exception NexusException if an HDF error occurs. - */ - public NXlink getdataID()throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - NXlink l = new NXlink(); - nxgetdataid(handle,l); - return l; - } - /** - * makelink links the object described by target into the current - * vGroup. - * @param target The Object to link into the current group. - * @exception NexusException if an error occurs. - */ - public void makelink(NXlink target)throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxmakelink(handle,target); - } - /** - * makenamedlink links the object described by target into the current - * vGroup. The object will have a new name in the group into which it is - * linked - * @param target The Object to link into the current group. - * @param name The name of this object in the current group - * @exception NexusException if an error occurs. - */ - public void makenamedlink(String name, NXlink target)throws - NexusException { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxmakenamedlink(handle,name, target); - } - - /** - * opensourcepath opens the group from which the current item was linked - * Returns an error if the current item is not linked. - * @exception NexusException if an error occurs. - */ - public void opensourcepath()throws - NexusException - { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxopensourcepath(handle); - } - - - /** - * checkType verifies if a parameter is a valid NeXus type code. - * If not an exception is thrown. - * @param type The type value to check. - * @exception NexusException if the the type is no known type value - */ - private void checkType(int type) throws NexusException - { - switch(type) { - case NexusFile.NX_INT8: - case NexusFile.NX_UINT8: - case NexusFile.NX_CHAR: - case NexusFile.NX_INT16: - case NexusFile.NX_UINT16: - case NexusFile.NX_INT32: - case NexusFile.NX_UINT32: - case NexusFile.NX_FLOAT32: - case NexusFile.NX_FLOAT64: - break; - default: - throw new NexusException("Illegal number type requested"); - } - } - - // external file interface - // native methods for this section - protected native void nxinquirefile(int handle, String names[]); - protected native void nxlinkexternal(int handle, String name, String nxclass, String nxurl); - protected native int nxisexternalgroup(int handle, String name, String nxclass, String nxurl[]); - /** - * inquirefile inquires which file we are currently in. This is - * a support function for external linking - * @return The current file - * @throws NexusException when things are wrong - */ - public String inquirefile() throws NexusException { - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - String names[] = new String[1]; - nxinquirefile(handle,names); - return names[0]; - } - /** - * linkexternal links group name, nxclass to the URL nxurl - * @param name The name of the vgroup to link to - * @apram nxcall The class name of the linked vgroup - * @param nxurl The URL to the linked external file - * @throws NexusException if things are wrong - */ - public void linkexternal(String name, String nxclass, String nxurl) throws NexusException{ - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - nxlinkexternal(handle,name,nxclass,nxurl); - } - /** - * nxisexternalgroup test the group name, nxclass if it is linked externally. - * @param name of the group to test - * @param nxclass class of the group to test - * @return null when the group is not linked, else a string giving the URL of the - * linked file. - * @throws NexusException if things are wrong - */ - public String isexternalgroup(String name, String nxclass) throws NexusException{ - if(handle < 0) throw new NexusException("NAPI-ERROR: File not open"); - String nxurl[] = new String[1]; - - int status = nxisexternalgroup(handle,name,nxclass,nxurl); - if(status == 1){ - return nxurl[0]; - } else { - return null; - } - } - - /** - * debugstop is a debugging helper function which goes into an - * endless loop in the dynamic link library. Then a unix debugger - * may attach to the running java process using the pid, interrupt, - * set the loop variable to leave the loop, set a new breakpoint and - * continue debugging. This works with ladebug on DU40D. This is an - * developer support routine and should NEVER be called in normal - * code. - */ - public native void debugstop(); -} - - - - - - - - - diff --git a/contrib/applications/nxplot/jnexus/szlibdll.dll b/contrib/applications/nxplot/jnexus/szlibdll.dll deleted file mode 100755 index 01baf717..00000000 Binary files a/contrib/applications/nxplot/jnexus/szlibdll.dll and /dev/null differ diff --git a/contrib/applications/nxplot/jnexus/windoofx86.lib b/contrib/applications/nxplot/jnexus/windoofx86.lib deleted file mode 100755 index 52fa8f3c..00000000 --- a/contrib/applications/nxplot/jnexus/windoofx86.lib +++ /dev/null @@ -1,9 +0,0 @@ -zlib1 -szlibdll -iconv -libxml2 -hdf5dll -hd421m -hm421m -libNeXus-0 -libjnexus-0 diff --git a/contrib/applications/nxplot/jnexus/zlib1.dll b/contrib/applications/nxplot/jnexus/zlib1.dll deleted file mode 100755 index 7912482a..00000000 Binary files a/contrib/applications/nxplot/jnexus/zlib1.dll and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/.classpath b/contrib/applications/nxplot/mountaingumnexus/.classpath deleted file mode 100755 index 9fa5ee51..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/contrib/applications/nxplot/mountaingumnexus/.project b/contrib/applications/nxplot/mountaingumnexus/.project deleted file mode 100755 index 3a40948a..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - mountaingumnexus - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/mountaingumnexus/.settings/org.eclipse.jdt.core.prefs b/contrib/applications/nxplot/mountaingumnexus/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index a67c8081..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Oct 21 11:46:43 CEST 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/contrib/applications/nxplot/mountaingumnexus/META-INF/MANIFEST.MF b/contrib/applications/nxplot/mountaingumnexus/META-INF/MANIFEST.MF deleted file mode 100755 index d5cf1b2e..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Mountaingumnexus Plug-in -Bundle-SymbolicName: mountaingumnexus;singleton:=true -Bundle-Version: 1.0.0 -Bundle-Vendor: Mark Koennecke -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: mountaingumsys;bundle-version="0.1.0", - org.eclipse.core.runtime;bundle-version="3.3.100", - org.eclipse.ui;bundle-version="3.3.1", - jnexus;bundle-version="4.2.0", - mountaingumuibase;bundle-version="1.0.0" -Export-Package: ch.psi.num.mountaingum.nexus.Perspective, - ch.psi.num.mountaingum.nexus.actions, - ch.psi.num.mountaingum.nexus.loader diff --git a/contrib/applications/nxplot/mountaingumnexus/build.properties b/contrib/applications/nxplot/mountaingumnexus/build.properties deleted file mode 100755 index 1f0bd9d9..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - icons/nexusw.png,\ - icons/nexusw32.png diff --git a/contrib/applications/nxplot/mountaingumnexus/icons/nexusw.png b/contrib/applications/nxplot/mountaingumnexus/icons/nexusw.png deleted file mode 100755 index abd1b3cb..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/icons/nexusw.png and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/icons/nexusw32.png b/contrib/applications/nxplot/mountaingumnexus/icons/nexusw32.png deleted file mode 100644 index 37f9e505..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/icons/nexusw32.png and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/plugin.xml b/contrib/applications/nxplot/mountaingumnexus/plugin.xml deleted file mode 100755 index f0840e16..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/plugin.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/mountaingumnexus/schema/NexusMapper.ID.exsd b/contrib/applications/nxplot/mountaingumnexus/schema/NexusMapper.ID.exsd deleted file mode 100755 index e4616b8f..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/schema/NexusMapper.ID.exsd +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - This extension point alllows to influence how a NeXus file hierarchy is -translated into a hierarchy for use with GTSE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NameView.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NameView.java deleted file mode 100755 index 5124fb60..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NameView.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * This is a tiny little view which will be used to display the - * filename of the loaded file. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.Perspective; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.part.ViewPart; - -public class NameView extends ViewPart { - public final static String ID = "mountaingumnexus.NameView"; - - private Label l; - - public NameView() { - } - - public void createPartControl(Composite parent) { - l = new Label(parent, SWT.CENTER); - l.setText("Unknown"); - l.setBackground(l.getDisplay().getSystemColor(SWT.COLOR_WHITE)); - } - - public void setName(String val){ - l.setText(val); - } - public void setFocus() { - // Nothing to do - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NexusPerspective.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NexusPerspective.java deleted file mode 100755 index 72cf2bbf..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NexusPerspective.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This is the perspective for looking at NeXus files. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.Perspective; - -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -import ch.psi.num.mountaingum.ui.EditorView.TreeEditorView; - -public class NexusPerspective implements IPerspectiveFactory { - public static final String ID = "mountaingum.NexusPerspective"; - public void createInitialLayout(IPageLayout layout) { - String editorArea = layout.getEditorArea(); - layout.setEditorAreaVisible(false); - layout.setFixed(true); - - layout.addStandaloneView(NameView.ID, false, IPageLayout.TOP, 0.05f, editorArea); - layout.addStandaloneView(NexusTree.ID, false, IPageLayout.LEFT, 0.33f, editorArea); - layout.addStandaloneView(TreeEditorView.ID +":1", false, - IPageLayout.RIGHT, 0.66f, editorArea); - layout.addActionSet("mountaingumnexus.ActionSet"); - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NexusTree.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NexusTree.java deleted file mode 100755 index 9db38bc0..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/Perspective/NexusTree.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This is derived class of BaseTreeView which locates - * a TreeEditorView instead of a EditroView. All in an ongoing - * effort not do display interrupt buttons in the NeXus perspective - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.Perspective; - -import java.util.Comparator; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.widgets.Composite; - -import ch.psi.num.mountaingum.nexus.labelprovider.IconTreeLabelProvider; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.ui.EditorView.EditorView; -import ch.psi.num.mountaingum.ui.EditorView.TreeEditorView; -import ch.psi.num.mountaingum.ui.TreeViewer.BaseTreeView; -import ch.psi.num.mountaingum.ui.eclipse.RCPUtil; - -public class NexusTree extends BaseTreeView { - public static final String ID = "mountaingumnexus.NexusTree"; - - protected EditorView getEditorView() { - if(eva == null){ - eva = (EditorView)RCPUtil.findView(TreeEditorView.ID,"1"); - } - return eva; - } - - public TreeNode getTree(){ - return root; - } - - public void createPartControl(Composite parent) { - super.createPartControl(parent); - treeViewer.setLabelProvider(new IconTreeLabelProvider()); - ViewerComparator comparator = new ViewerComparator(new Comparator() { - public int compare(Object o1, Object o2) { - TreeNode node1; - TreeNode node2; - if (o1 instanceof TreeNode) { - node1 = (TreeNode) o1; - } else return -1; - if (o2 instanceof TreeNode) { - node2 = (TreeNode) o2; - } else return 1; - - String type1 = node1.getProperty("type"); - String type2 = node2.getProperty("type"); - String name1 = node1.getProperty("name"); - String name2 = node2.getProperty("name"); - if (type1 == null && type2 == null) return 0; - if (type1 == null) return 1; - if (type2 == null) return -1; - if (type1.equals(type2)) - return name1.compareTo(name2); - if (type1.startsWith("graph")) return -1; - if (type2.startsWith("graph")) return 1; - return name1.compareTo(name2); - } - }) { - public int compare(Viewer viewer, Object e1, Object e2) { - return getComparator().compare(e1, e2); - } - }; - treeViewer.setComparator(comparator); - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/OpenNexus.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/OpenNexus.java deleted file mode 100755 index 50f4d93f..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/OpenNexus.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * This is the action for loading a NeXus file from the - * file system. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.actions; - - - -import java.io.IOException; - -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import ch.psi.num.mountaingum.nexus.loader.NexusLoader; -import ch.psi.num.mountaingum.nexus.loader.sinqascii.ASCIILoader; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.ui.UIRegistry; - -public class OpenNexus implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow win; - private static String dirpref = "opendir"; - - public void init(IWorkbenchWindow window) { - win = window; - } - - public void run(IAction action) { - NexusLoader loadi = new NexusLoader(); - FileDialog fd = new FileDialog(win.getShell(),SWT.OPEN); - TreeNode root = null; - - fd.setFilterExtensions(new String[] {"*.hdf","*.dat", "*.*"}); - fd.setFilterNames(new String[] {"HDF-files","ASCII-Scan-files", "All Files"}); - IEclipsePreferences pref = new InstanceScope().getNode("mountaingumnexus"); - String path = pref.get(dirpref, null); - if(path != null){ - fd.setFileName(path); - } - String filename = fd.open(); - if(filename != null){ - try{ - if(filename.endsWith(".dat")){ - ASCIILoader al = new ASCIILoader(); - root = al.loadASCIIFile(filename); - } else { - root = loadi.loadNexusIntoTree(filename); - } - loadi.viewNode(root); - pref.put(dirpref, filename); - try{ - pref.flush(); - }catch(Exception edith){ - edith.printStackTrace(); - } - }catch(Exception eva){ - eva.printStackTrace(); - } - } - } - - public void selectionChanged(IAction action, ISelection selection) { - // Nothing to do - } - public void dispose() { - // Nothing to do - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/PNGNexusGraph.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/PNGNexusGraph.java deleted file mode 100644 index 17f7db85..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/PNGNexusGraph.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This is an action for printing a NeXus graph into a PNG file - * - * copyright: GPL - * - * Mark Koennecke, October 2009 - */ -package ch.psi.num.mountaingum.nexus.actions; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; - -import javax.imageio.ImageIO; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import ch.psi.num.mountaingum.nexus.Perspective.NexusTree; -import ch.psi.num.mountaingum.sys.SysRegistry; -import ch.psi.num.mountaingum.ui.UIRegistry; -import ch.psi.num.mountaingum.ui.EditorView.TreeEditorView; -import ch.psi.num.mountaingum.ui.GraphicsView.GraphicsView; -import ch.psi.num.mountaingum.ui.eclipse.NodeViewer; -import ch.psi.num.mountaingum.ui.eclipse.RCPUtil; - -public class PNGNexusGraph implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow win; - - public void init(IWorkbenchWindow window) { - win = window; - } - - - - public void run(IAction action) { - TreeEditorView gv = (TreeEditorView)RCPUtil.findView("mountaingumui.TreeEditorView","1"); - if(gv == null){ - SysRegistry.getLogger().error("No NexusTree found in PNGNexusGraph"); - return; - } - NodeViewer nv = gv.getPlot(); - if(nv == null){ - UIRegistry.getAdapter().displayError("No graph to print selected"); - return; - } - - FileDialog fd = new FileDialog(win.getShell(),SWT.OPEN); - fd.setText("Open"); - String[] ext = {"*.png"}; - fd.setFilterExtensions(ext); - String file = fd.open(); - if(file != null){ - BufferedImage bi = nv.makeImage(1280, 1024); - try{ - ImageIO.write(bi, "png", new File(file)); - }catch(IOException eva){ - SysRegistry.getLogger().exception(eva); - }finally { - bi.flush(); - } - } - } - - public void selectionChanged(IAction action, ISelection selection) { - } - public void dispose() { - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/PrintNexusGraph.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/PrintNexusGraph.java deleted file mode 100644 index ee5fdd19..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/PrintNexusGraph.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * This is an action for printing a NeXus graph as displayed - * in the neXus viewer - * - * copyright: GPL - * - * Mark Koennecke, October 2009 - */ -package ch.psi.num.mountaingum.nexus.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.printing.PrintDialog; -import org.eclipse.swt.printing.Printer; -import org.eclipse.swt.printing.PrinterData; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import ch.psi.num.mountaingum.sys.SysRegistry; -import ch.psi.num.mountaingum.ui.UIRegistry; -import ch.psi.num.mountaingum.ui.EditorView.TreeEditorView; -import ch.psi.num.mountaingum.ui.GraphicsView.GraphicsView; -import ch.psi.num.mountaingum.ui.eclipse.NodeViewer; -import ch.psi.num.mountaingum.ui.eclipse.RCPUtil; - -public class PrintNexusGraph implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow win; - - public void init(IWorkbenchWindow window) { - win = window; - } - - public void run(IAction action) { - TreeEditorView gv = (TreeEditorView)RCPUtil.findView("mountaingumui.TreeEditorView","1"); - if(gv == null){ - SysRegistry.getLogger().error("No GraphicsView found in PrintAction"); - return; - } - NodeViewer nv = gv.getPlot(); - if(nv == null){ - UIRegistry.getAdapter().displayError("No graph to print selected"); - return; - } - - PrintDialog dia = new PrintDialog(win.getShell(),SWT.NONE); - PrinterData pd = dia.open(); - if(pd != null){ - Printer p = new Printer(pd); - nv.print(p); - p.dispose(); - } - } - - public void selectionChanged(IAction action, ISelection selection) { - } - public void dispose() { - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SaveNexus.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SaveNexus.java deleted file mode 100755 index d9be0d70..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SaveNexus.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This is a plain old save of the modified NeXus file when - * possible. - * - * copyright: GPL - * - * Mark Koennecke - */ -package ch.psi.num.mountaingum.nexus.actions; - -import java.io.IOException; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import ch.psi.num.mountaingum.nexus.loader.NexusLoader; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.ui.UIRegistry; - -public class SaveNexus implements IWorkbenchWindowActionDelegate { - - public void dispose() { - // Nothing to do - } - - public void init(IWorkbenchWindow window) { - // Nothing to do - } - - public void run(IAction action) { - NexusLoader nl = new NexusLoader(); - TreeNode root = nl.getTree(); - try{ - nl.saveTree(root, root.getProperty("filename")); - }catch(IOException eva){ - UIRegistry.getAdapter().displayError(eva.getMessage()); - } - } - - public void selectionChanged(IAction action, ISelection selection) { - // Nothing to do - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFile.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFile.java deleted file mode 100755 index f6319be5..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFile.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This is a tiny utility class for finding the filename of a SINQ data - * file. It first tries to locate the file in the local data area and - * if this fails, at sinqdata. May be this gets extended to download the file - * via http in a later stage. As this may be used elsewhere, this goes into - * a little utility class. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.actions; - -import java.io.File; -import java.text.NumberFormat; - -public class SinqFile { - public static String getSinqFile(String instrument, int year, int numor, String extension){ - StringBuffer file, path; - String yy, numString, hundred; - File f; - - /** - * build bits and pieces - */ - NumberFormat nf = NumberFormat.getInstance(); - nf.setGroupingUsed(false); - nf.setMinimumIntegerDigits(4); - yy = nf.format(year); - nf.setMinimumIntegerDigits(6); - numString = nf.format(numor); - nf.setMinimumIntegerDigits(3); - hundred = nf.format(numor/1000); - - - /** - * build file name - */ - file = new StringBuffer(instrument.toLowerCase()); - file.append(yy); - file.append('n'); - file.append(numString); - file.append(extension); - //System.out.println(file.toString()); - - /** - * test local - */ - path = new StringBuffer("/home/"); - path.append(instrument); - path.append("/data/"); - path.append(yy); - path.append('/'); - path.append(hundred); - path.append('/'); - path.append(file.toString()); - //System.out.println(path.toString()); - - f = new File(path.toString()); - if(f.canRead()){ - return path.toString(); - } - - /** - * test sinqdata - */ - path = new StringBuffer("/afs/psi.ch/project/sinqdata/"); - path.append(yy); - path.append('/'); - path.append(instrument); - path.append('/'); - path.append(hundred); - path.append('/'); - path.append(file.toString()); - //System.out.println(path.toString()); - - f = new File(path.toString()); - if(f.canRead()){ - return path.toString(); - } - return null; - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFileAction.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFileAction.java deleted file mode 100755 index 52968ba3..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFileAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This is the action driving the dialog to load a SINQ data file - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.actions; - -import java.io.IOException; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import ch.psi.num.mountaingum.nexus.loader.NexusLoader; -import ch.psi.num.mountaingum.nexus.loader.sinqascii.ASCIILoader; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.ui.UIRegistry; - -public class SinqFileAction implements IWorkbenchWindowActionDelegate { - - private IWorkbenchWindow win; - - public void run(IAction action) { - TreeNode root; - - SinqFileDialog sfd = new SinqFileDialog(win.getShell()); - int status = sfd.open(); - if(status == Window.OK){ - String filename = sfd.getFilename(); - if(filename == null){ - UIRegistry.getAdapter().displayError("This file does not exist"); - } else { - NexusLoader nl = new NexusLoader(); - try{ - if(filename.endsWith(".dat")){ - ASCIILoader al = new ASCIILoader(); - root = al.loadASCIIFile(filename); - } else { - root = nl.loadNexusIntoTree(filename); - } - nl.viewNode(root); - }catch(IOException eva){ - UIRegistry.getAdapter().displayError(eva.getMessage()); - } - } - } - } - public void init(IWorkbenchWindow window) { - win = window; - } - - public void selectionChanged(IAction action, ISelection selection) { - // Nothing to do - } - public void dispose() { - // Nothing to do - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFileDialog.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFileDialog.java deleted file mode 100755 index 7d3904db..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/actions/SinqFileDialog.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * This is the dialog for loading SINQ files. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.actions; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.Calendar; -import java.util.HashSet; -import java.util.Properties; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import ch.psi.num.mountaingum.sys.SysRegistry; - -public class SinqFileDialog extends Dialog { - private String filename; - private Combo instrument; - private Combo year; - private Text numor; - private HashSet killSet; - - private static String savedInst = "savedInst"; - private static String savedYear = "savedYear"; - private static String savedNumor = "savedNumor"; - - protected SinqFileDialog(Shell parentShell) { - super(parentShell); - killSet = new HashSet(); - killSet.add("local"); - killSet.add("test"); - killSet.add("sansli"); - killSet.add("tasp"); - } - - protected Control createDialogArea(Composite parent) { - Composite root = (Composite)super.createDialogArea(parent); - root.setLayout(new GridLayout()); - - Group instGroup = new Group(root,SWT.NONE); - instGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - instGroup.setText("Select Instrument"); - instGroup.setLayout(new GridLayout()); - instrument = new Combo(instGroup,SWT.SINGLE); - instrument.setLayoutData(new GridData(GridData.FILL_BOTH)); - URL ulli = Platform.getBundle("MountainGumApplication").getEntry("sics.config"); - Properties config = new Properties(); - try{ - config.load(ulli.openStream()); - }catch(IOException e){ - SysRegistry.getLogger().error("Failed to load SICS properties"); - return root; - } - String prop = config.getProperty("instrumentlist"); - if(prop == null){ - SysRegistry.getLogger().error("Failed to load SICS Properties"); - return root; - } - StringTokenizer st = new StringTokenizer(prop.trim(),",",false); - String inst; - while(st.hasMoreTokens()){ - inst = st.nextToken(); - if(inst.indexOf("sim") < 0 && !killSet.contains(inst)){ - if(inst.indexOf("rita") >= 0){ - instrument.add("rita2"); - } else { - instrument.add(inst); - } - } - } - instrument.select(0); - - Group yearGroup = new Group(root,SWT.NONE); - yearGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - yearGroup.setText("Select Year"); - yearGroup.setLayout(new GridLayout()); - year = new Combo(yearGroup, SWT.SINGLE); - year.setLayoutData(new GridData(GridData.FILL_BOTH)); - Calendar cal = Calendar.getInstance(); - int yy = cal.get(Calendar.YEAR); - for(int y = yy; y > 1996; y--){ - year.add(Integer.toString(y)); - } - year.select(0); - - Group numGroup = new Group(root,SWT.NONE); - numGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - numGroup.setText("Data File Number"); - numGroup.setLayout(new GridLayout()); - numor = new Text(numGroup, SWT.SINGLE); - numor.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - numor.setEditable(true); - numor.setText("0"); - - IEclipsePreferences pref = new InstanceScope().getNode("mountaingumnexus"); - String val = pref.get(savedInst, null); - if(val != null){ - instrument.setText(val); - } - val = pref.get("savedYear", null); - if(val != null){ - year.setText(val); - } - val = pref.get("savedNumor", null); - if(val != null){ - numor.setText(val); - } - - - return root; - } - - public String getFilename() { - return filename; - } - - protected void okPressed() { - filename = SinqFile.getSinqFile(instrument.getText(), - Integer.parseInt(year.getText()), - Integer.parseInt(numor.getText()), ".hdf"); - - if(filename == null){ - filename = SinqFile.getSinqFile(instrument.getText(), - Integer.parseInt(year.getText()), - Integer.parseInt(numor.getText()), ".dat"); - } - IEclipsePreferences pref = new InstanceScope().getNode("mountaingumnexus"); - pref.put(savedInst, instrument.getText()); - pref.put(savedYear, year.getText()); - pref.put(savedNumor, numor.getText()); - try{ - pref.flush(); - }catch(Exception e){} - - super.okPressed(); - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/IconTreeLabelProvider.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/IconTreeLabelProvider.java deleted file mode 100644 index d429f9be..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/IconTreeLabelProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -package ch.psi.num.mountaingum.nexus.labelprovider; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; - -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.ui.TreeViewer.TreeLabelProvider; - -public class IconTreeLabelProvider extends TreeLabelProvider { - - Map classToIcon = new HashMap(); - - Image defaultIcon; - - public IconTreeLabelProvider() { - super(); - URL iconUrl = getClass().getResource("icons/unknown.gif"); - ImageDescriptor iconDes = ImageDescriptor.createFromURL(iconUrl); - this.defaultIcon = iconDes.createImage(true); - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - - if (columnIndex != 0) return null; - - if (element instanceof TreeNode) { - TreeNode node = (TreeNode) element; - String type = node.getProperty("type"); - if (type != null) { - if (classToIcon.containsKey(type)) - return classToIcon.get(type); - else { - URL iconUrl = getClass().getResource("icons/" + type + ".gif"); - ImageDescriptor iconDes = ImageDescriptor.createFromURL(iconUrl); - Image icon = iconDes.createImage(false); - if (icon == null) { -// System.out.println("dishing out default icon for " + type); - icon = defaultIcon; - } - classToIcon.put(type, icon); - return icon; - } - } else { -// System.out.println("IconTreeLabelProvider.getColumnImage() type null"); - } - } - -// System.out.println("dishing out default icon for " + element); - - Image columnImage = super.getColumnImage(element, columnIndex); - return columnImage; - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/CHAR.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/CHAR.gif deleted file mode 100755 index 3154a648..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/CHAR.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/CHAR_array.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/CHAR_array.gif deleted file mode 100755 index d47c8f83..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/CHAR_array.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DOUBLE.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DOUBLE.gif deleted file mode 100755 index 2ab8b20b..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DOUBLE.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DOUBLE_array.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DOUBLE_array.gif deleted file mode 100755 index 5318a493..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DOUBLE_array.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DfnTree.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DfnTree.gif deleted file mode 100755 index 969ee117..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/DfnTree.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/FLOAT.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/FLOAT.gif deleted file mode 100755 index 65ff4523..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/FLOAT.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/FLOAT_array.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/FLOAT_array.gif deleted file mode 100755 index 471b4edb..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/FLOAT_array.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/INT.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/INT.gif deleted file mode 100755 index c2a55200..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/INT.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/INT_array.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/INT_array.gif deleted file mode 100755 index 4703b48c..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/INT_array.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/ISO8601.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/ISO8601.gif deleted file mode 100755 index d0543823..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/ISO8601.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXaperture.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXaperture.gif deleted file mode 100755 index b03ef993..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXaperture.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXattenuator.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXattenuator.gif deleted file mode 100755 index a88b6506..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXattenuator.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXchopper.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXchopper.gif deleted file mode 100755 index 4bd6b1ed..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXchopper.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXcollimator.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXcollimator.gif deleted file mode 100755 index d644444c..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXcollimator.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXcrystal.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXcrystal.gif deleted file mode 100755 index cc6130cd..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXcrystal.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXdata.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXdata.gif deleted file mode 100755 index 05e7a3b9..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXdata.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXdetector.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXdetector.gif deleted file mode 100755 index 1b6f8b28..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXdetector.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXentry.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXentry.gif deleted file mode 100755 index 7ce9477f..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXentry.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXfilter.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXfilter.gif deleted file mode 100755 index 3ac79699..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXfilter.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXinstrument.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXinstrument.gif deleted file mode 100755 index cf1bf814..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXinstrument.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXlog.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXlog.gif deleted file mode 100755 index 8c9e3ac3..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXlog.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXmonitor.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXmonitor.gif deleted file mode 100755 index 0f59fe7d..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXmonitor.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXmonochromator.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXmonochromator.gif deleted file mode 100755 index e4cef857..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXmonochromator.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXnote.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXnote.gif deleted file mode 100755 index 6aa9bd2b..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXnote.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXroot.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXroot.gif deleted file mode 100755 index 5721420b..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXroot.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXsample.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXsample.gif deleted file mode 100755 index e0ac6e2c..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXsample.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXslit.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXslit.gif deleted file mode 100755 index 72e2270a..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXslit.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXsource.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXsource.gif deleted file mode 100755 index 5b253317..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXsource.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXuser.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXuser.gif deleted file mode 100755 index 10a77976..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/NXuser.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/UINT.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/UINT.gif deleted file mode 100755 index 7c2a957c..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/UINT.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/UINT_array.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/UINT_array.gif deleted file mode 100755 index 65a581e7..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/UINT_array.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/graphdata.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/graphdata.gif deleted file mode 100755 index 05e7a3b9..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/graphdata.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/graphset.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/graphset.gif deleted file mode 100755 index e0b531c3..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/graphset.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrCol.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrCol.gif deleted file mode 100755 index b9d546df..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrCol.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrLay.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrLay.gif deleted file mode 100755 index a770668c..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrLay.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrRow.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrRow.gif deleted file mode 100755 index 7189ad12..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/incrRow.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transCL.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transCL.gif deleted file mode 100755 index 52cdba8a..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transCL.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transRC.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transRC.gif deleted file mode 100755 index 4b462216..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transRC.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transRL.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transRL.gif deleted file mode 100755 index 07c7b40e..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/transRL.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/unknown.gif b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/unknown.gif deleted file mode 100755 index e0b531c3..00000000 Binary files a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/labelprovider/icons/unknown.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/FlatNexusFile.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/FlatNexusFile.java deleted file mode 100755 index bc7e0ac9..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/FlatNexusFile.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * This is a derived class of NexusFile which uses the protected - * native getdata function and HDFnative methods to get plain - * 1D array data of various data types. this is what I need for - * GTSE. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.loader; - -import ncsa.hdf.hdflib.HDFNativeData; - -import org.nexusformat.NexusException; -import org.nexusformat.NexusFile; - -public class FlatNexusFile extends NexusFile { - - public FlatNexusFile(String arg0, int arg1) throws NexusException { - super(arg0, arg1); - } - - protected int getTotalLength(){ - int dim[], info[], length = 1; - dim = new int[32]; - info = new int[2]; - - try{ - getinfo(dim,info); - }catch(NexusException ne){ - return 0; - } - - for(int i = 0; i < info[0]; i++){ - length *= dim[i]; - } - - return length; - } - public int[] getintdata(){ - int length = getTotalLength(); - byte bdata[] = new byte[length*4]; - nxgetdata(handle,bdata); - return HDFNativeData.byteToInt(bdata); - } - public short[] getshortdata(){ - int length = getTotalLength(); - byte bdata[] = new byte[length*2]; - nxgetdata(handle,bdata); - return HDFNativeData.byteToShort(bdata); - } - public long[] getlongdata(){ - int length = getTotalLength(); - byte bdata[] = new byte[length*8]; - nxgetdata(handle,bdata); - return HDFNativeData.byteToLong(bdata); - } - public float[] getfloatdata(){ - int length = getTotalLength(); - byte bdata[] = new byte[length*4]; - nxgetdata(handle,bdata); - return HDFNativeData.byteToFloat(bdata); - } - public double[] getdoubledata(){ - int length = getTotalLength(); - byte bdata[] = new byte[length*8]; - nxgetdata(handle,bdata); - return HDFNativeData.byteToDouble(bdata); - } - public String gettextdata(){ - int length = getTotalLength(); - byte bdata[] = new byte[length]; - nxgetdata(handle,bdata); - return new String(bdata); - } - - public byte[] getrawslab(int start[], int size[], int type){ - int i, length = 1; - for(i = 0; i < size.length; i++){ - length *= size[i]; - } - switch(type){ - case NexusFile.NX_CHAR: - case NexusFile.NX_INT8: - case NexusFile.NX_UINT8: - break; - case NexusFile.NX_INT16: - case NexusFile.NX_UINT16: - length *= 2; - break; - case NexusFile.NX_INT32: - case NexusFile.NX_UINT32: - case NexusFile.NX_FLOAT32: - length *= 4; - break; - case NexusFile.NX_INT64: - case NexusFile.NX_UINT64: - case NexusFile.NX_FLOAT64: - length *= 8; - } - byte result[] = new byte[length]; - nxgetslab(handle,start,size,result); - return result; - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NeXusMapper.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NeXusMapper.java deleted file mode 100755 index e80d72dc..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NeXusMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This is a the interface to be implemented by any NeXus data file - * mapper. The mappers task is to edit the raw hierarchy as created - * by the NexusLoader in order to adapt it to different needs. - * - * - * copyright GPL - * - * Mark Koennecke, July 2009 - */ -package ch.psi.num.mountaingum.nexus.loader; - -import ch.psi.num.mountaingum.tree.TreeNode; - -public interface NeXusMapper { - - /** - * This method allows the mapper to modify the tree at will. - * Usually the mapper may want to check if it can be sensibly applied and just - * return otherwise. - * - * @param root the populated tree - * @param nf a handle to the file if needed - * @param nl The NexusLoader for support functions - */ - public void transform(TreeNode root, FlatNexusFile nf, NexusLoader nl); - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusLoader.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusLoader.java deleted file mode 100755 index da2d21ef..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusLoader.java +++ /dev/null @@ -1,971 +0,0 @@ -/** - * This is the main driver class for loading NeXus file data into - * a tree. I first build a list of all paths to consider, then - * iterate through this list. The idea is that the mapper may choose - * to step through the tree at its own pleasure in order to find axis - * data or whatever. - * - * This also supports saving of NeXus trees. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.loader; - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.lang.reflect.Array; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.nexusformat.AttributeEntry; -import org.nexusformat.NexusException; -import org.nexusformat.NexusFile; - -import ch.psi.num.mountaingum.func.FuncUtil; -import ch.psi.num.mountaingum.func.IFunc; -import ch.psi.num.mountaingum.nexus.Perspective.NameView; -import ch.psi.num.mountaingum.nexus.Perspective.NexusTree; -import ch.psi.num.mountaingum.sys.SysRegistry; -import ch.psi.num.mountaingum.tree.ChildStream; -import ch.psi.num.mountaingum.tree.CommandNode; -import ch.psi.num.mountaingum.tree.DoubleValue; -import ch.psi.num.mountaingum.tree.GraphicsNode; -import ch.psi.num.mountaingum.tree.IntValue; -import ch.psi.num.mountaingum.tree.InternalParameter; -import ch.psi.num.mountaingum.tree.LongValue; -import ch.psi.num.mountaingum.tree.NodeValue; -import ch.psi.num.mountaingum.tree.ParameterNode; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.tree.TreeUtil; -import ch.psi.num.mountaingum.ui.EditorView.EditorView; -import ch.psi.num.mountaingum.ui.EditorView.TreeEditorView; -import ch.psi.num.mountaingum.ui.eclipse.RCPUtil; - -public class NexusLoader { - - private HashSet checkedPaths = new HashSet(); - private TreeNode root; - private FlatNexusFile nf; - - public static final Charset nexusCharset = Charset.forName("UTF-8"); - - public NexusLoader() { - } - - public TreeNode loadNexusIntoTree(String filename) throws IOException { - root = null; - - nf = null; - boolean canWrite = false; - - File f = new File(filename); - if (!f.canRead()) { - throw new IOException("File not readable"); - } - canWrite = f.canWrite(); - - try { - if (canWrite) { - nf = new FlatNexusFile(filename, NexusFile.NXACC_RDWR); - } else { - nf = new FlatNexusFile(filename, NexusFile.NXACC_READ); - } - } catch (NexusException ne) { - throw new IOException(ne.getMessage()); - } - - buildTree(filename); - - setPrivilege(root, canWrite); - - try { - nf.close(); - } catch (NexusException ne) { - throw new IOException(ne.getMessage()); - } - - return root; - } - - private void recurseFile(TreeNode parent, String path) throws NexusException { - String name, type, newPath; - StringBuffer stb; - - Hashtable dir = nf.groupdir(); - Enumeration d = dir.keys(); - while (d.hasMoreElements()) { - name = (String) d.nextElement(); - type = (String) dir.get(name); - if (type.equalsIgnoreCase("CDF0.0")) { - continue; - } - stb = new StringBuffer(); - stb.append(path); - stb.append('/'); - stb.append(name); - newPath = stb.toString(); - TreeNode nextLevel = makeNode(parent, type, newPath); - if (!type.equalsIgnoreCase("SDS") && nextLevel != null) { - nf.opengroup(name, type); - recurseFile(nextLevel, newPath); - nf.closegroup(); - } - } - } - - private class PrivFunc implements IFunc { - private boolean canWrite; - - PrivFunc(boolean canWrite) { - this.canWrite = canWrite; - } - - public Object apply(Object o) { - if (o instanceof ParameterNode) { - ParameterNode pn = (ParameterNode) o; - pn.setReadOnly(!canWrite); - } - return null; - } - } - - private void setPrivilege(TreeNode root, boolean canWrite) { - FuncUtil.map(root.getTreeStream(), new PrivFunc(canWrite)); - } - - private void buildTree(String filename) throws IOException { - - root = new TreeNode(null, ""); - root.setProperty("filename", filename); - locateGraphics(); - checkedPaths.clear(); - - try { - recurseFile(root, ""); - } catch (NexusException e) { - throw new IOException(e); - } - - engageMappers(); - } - - private void engageMappers() { - - NeXusMapper mapper; - IConfigurationElement[] decl = Platform.getExtensionRegistry().getConfigurationElementsFor( - "ch.psi.num.mountaingum.nexus.loader.NexusMapper"); - for (int i = 0; i < decl.length; i++) { - IConfigurationElement e = decl[i]; - try { - mapper = (NeXusMapper) e.createExecutableExtension("className"); - mapper.transform(root, nf, this); - } catch (Exception eva) { - eva.printStackTrace(); - } - } - } - - public TreeNode getTree() { - NexusTree btv = (NexusTree) RCPUtil.findView(NexusTree.ID); - if (btv == null) { - // This means that the Nexus perspective has not yet been opened - return null; - } - return btv.getTree(); - } - - private class SaveNXPar implements IFunc { - private FlatNexusFile nf; - - SaveNXPar(FlatNexusFile nf) { - this.nf = nf; - } - - public Object apply(Object o) { - NexusParameter nxpar; - String path; - int dim[], info[], i; - - if (o instanceof NexusParameter) { - nxpar = (NexusParameter) o; - if (nxpar.getProperty("mogrified") != null) { - path = nxpar.getProperty("nxpath"); - try { - nf.openpath(path); - dim = new int[32]; - info = new int[2]; - nf.getinfo(dim, info); - switch (info[1]) { - case NexusFile.NX_CHAR: - case NexusFile.NX_INT8: - case NexusFile.NX_UINT8: - String data = nxpar.getValue().toString(); - nf.putdata(data.getBytes()); - break; - case NexusFile.NX_INT16: - case NexusFile.NX_UINT16: - IntValue iv = (IntValue) nxpar.getValue(); - short sdata[] = new short[iv.getLength()]; - int idata[] = iv.getData(); - for (i = 0; i < sdata.length; i++) { - sdata[i] = (short) idata[i]; - } - nf.putdata(sdata); - sdata = null; - idata = null; - break; - case NexusFile.NX_INT32: - case NexusFile.NX_UINT32: - IntValue iiv = (IntValue) nxpar.getValue(); - nf.putdata(iiv.getData()); - break; - case NexusFile.NX_INT64: - case NexusFile.NX_UINT64: - LongValue lv = (LongValue) nxpar.getValue(); - nf.putdata(lv.getData()); - break; - case NexusFile.NX_FLOAT32: - DoubleValue dv = (DoubleValue) nxpar.getValue(); - double ddata[] = dv.getData(); - float fdata[] = new float[ddata.length]; - for (i = 0; i < ddata.length; i++) { - fdata[i] = (float) ddata[i]; - } - nf.putdata(fdata); - fdata = null; - ddata = null; - break; - case NexusFile.NX_FLOAT64: - DoubleValue ddv = (DoubleValue) nxpar.getValue(); - nf.putdata(ddv.getData()); - break; - } - } catch (NexusException ne) { - SysRegistry.getLogger().error("Failed to write " + path); - } - } - } - return null; - } - } - - /** - * the main mapping function, entry to all the work - */ - public TreeNode makeNode(TreeNode parent, String nxclass, String nxpath) { - - if (alreadySeen(nxpath)) { - return null; - } - - TreeNode node; - - if (nxclass.equalsIgnoreCase("SDS")) { - node = makeParameterNode(parent, nxpath, nxclass); - addPath(nxpath); - } else { - node = makeGroupNode(parent, nxpath, nxclass); - } - - return node; - } - - protected void addPath(String nxpath) { - checkedPaths.add(nxpath); - //System.out.println("Added " + nxpath); - - // TODO - try { - nf.openpath(nxpath); - /** - * This section is a workaround for a problem with attribute reading - * through the Java-API. This can be removed once nxinitattrdir() - * has been included and is used by nf.attrdir() - */ - String pathel[] = nxpath.substring(1).split("/"); - String name = pathel[pathel.length - 1]; - nf.closedata(); - nf.opendata(name); - String link = getAttr("target"); - if (link != null) { - checkedPaths.add(link); - //System.out.println("Added target" + link); - } - } catch (NexusException ne) { - } - } - - /* - * This creates all the group hierarchy components till nxpath. - */ - protected TreeNode makeGroupNode(TreeNode parent, String nxpath, String type) { - String pathElement[] = nxpath.substring(1).split("/"); - String name = pathElement[pathElement.length - 1]; - TreeNode current; - - current = new TreeNode(parent, name); - if (type == null) { - System.out.println("could not get type for " + nxpath + " you may guess this shouldn't happen"); - type = "NXwidget"; - } - current.setProperty("type", type); - parent.insertNode(TreeNode.APPEND, current); - - return current; - } - - /** - * make any parameter node - * - * @param root - * @param nf - * @param parent - * @param nxpath - * @param nxclass - * @return - */ - protected TreeNode makeParameterNode(TreeNode parent, String nxpath, String nxclass) { - int dim[], info[], totalLength = 1; - TreeNode node = null; - - dim = new int[32]; - info = new int[2]; - String pathel[] = nxpath.substring(1).split("/"); - String name = pathel[pathel.length - 1]; - - try { - - nf.opendata(name); - - nf.getinfo(dim, info); - totalLength = calcTotalLength(dim,info); - - Hashtable attr = nf.attrdir(); - if (attr.get("axis") != null) { - // ignore: will be picked up when building graph data - } else if (attr.get("signal") != null || totalLength > 100) { - // System.out.println("Making graphnode for " + nxpath); - node = makeGraphNode(parent, nxpath); - } else { - node = makeSimpleParNode(parent, nxpath, dim, info); - } - } catch (NexusException ne) { - ne.printStackTrace(); - } - return node; - } - - /** - * make a simple parameter node - * - * @param root - * @param nf - * @param nxpath - * @param dim - * @param info - */ - protected TreeNode makeSimpleParNode(TreeNode parent, String nxpath, int[] dim, int[] info) { - String name, pathel[]; - NexusParameter par; - - pathel = nxpath.substring(1).split("/"); - name = pathel[pathel.length - 1]; - - par = new NexusParameter(parent, name); - parent.insertNode(TreeNode.APPEND, par); - par.setProperty("nxpath", nxpath); - - if(calcTotalLength(dim,info) < 1000){ - NodeValue v = makeValue(nf,dim, info); - par.updateValue(v); - } else { - // use deferred loading - par.setProperty("visible", "false"); - } - return par; - } - - /** - * convert the current SDS to a GTSE NodeValue - * - * @param nf - * @param dim - * @param info - * @return - */ - public static NodeValue makeValue(FlatNexusFile nf, int[] dim, int[] info) { - NodeValue v; - IntValue iv; - DoubleValue dv; - LongValue lv; - int i; - - switch (info[1]) { - case NexusFile.NX_CHAR: - case NexusFile.NX_INT8: - case NexusFile.NX_UINT8: - v = new NodeValue(); - v.setFromString(nf.gettextdata()); - return v; - case NexusFile.NX_INT16: - case NexusFile.NX_UINT16: - short sdata[] = nf.getshortdata(); - iv = new IntValue(info[0], dim); - for (i = 0; i < sdata.length; i++) { - iv.append(sdata[i]); - } - return iv; - case NexusFile.NX_INT32: - case NexusFile.NX_UINT32: - int idata[] = nf.getintdata(); - iv = new IntValue(info[0], dim); - iv.setData(idata); - return iv; - case NexusFile.NX_INT64: - case NexusFile.NX_UINT64: - long ldata[] = nf.getlongdata(); - lv = new LongValue(info[0], dim); - lv.setData(ldata); - return lv; - case NexusFile.NX_FLOAT32: - float fdata[] = nf.getfloatdata(); - dv = new DoubleValue(info[0], dim); - for (i = 0; i < fdata.length; i++) { - dv.append(fdata[i]); - } - return dv; - case NexusFile.NX_FLOAT64: - double ddata[] = nf.getdoubledata(); - dv = new DoubleValue(info[0], dim); - dv.setData(ddata); - return dv; - } - return null; - } - - /** - * make a graphics node - * - * @param root - * @param nf - * @param parent - * @param nxpath - * @return - */ - public TreeNode makeGraphNode(TreeNode parent, String nxpath) { - TreeNode graphics, mygraph = null; - InternalParameter tmp; - int dim[], info[], helpdim[], i; - IntValue iv; - - // ensure graphics node - graphics = locateGraphics(); - - // get data info - dim = new int[32]; - info = new int[2]; - try { - nf.getinfo(dim, info); - } catch (NexusException ne) { - return null; - } - - // create graph data node and the rank and dim nodes - String pathel[] = nxpath.substring(1).split("/"); - mygraph = new GraphicsNode(graphics, pathel[pathel.length - 2]); - mygraph.setProperty("type", "graphdata"); - testNameAndInsert(graphics, mygraph); - - tmp = new InternalParameter(mygraph, "rank"); - mygraph.insertNode(TreeNode.APPEND, tmp); - helpdim = new int[1]; - helpdim[0] = 1; - iv = new IntValue(1, helpdim); - iv.append(info[0]); - tmp.updateValue(iv); - - tmp = new InternalParameter(mygraph, "dim"); - mygraph.insertNode(TreeNode.APPEND, tmp); - helpdim[0] = info[0]; - iv = new IntValue(1, helpdim); - for (i = 0; i < info[0]; i++) { - iv.append(dim[i]); - } - tmp.updateValue(iv); - - // add our data - if (info[0] == 3) { - makeFrameSeriesViewer(mygraph, nxpath, info, dim); - return mygraph; - } else { - tmp = new NexusParameter(mygraph, "counts"); - mygraph.insertNode(TreeNode.APPEND, tmp); - tmp.setProperty("type", "data"); - tmp.setProperty("nxpath", nxpath); - if(calcTotalLength(dim,info) < 1000){ - tmp.updateValue(makeValue(nf,dim, info)); - } else { - // use deferred loading - tmp.setProperty("visible", "false"); - } - } - - try { - nf.closedata(); - } catch (NexusException ne) { - } - - findAxis(nxpath, mygraph); - - checkAndDefaultAxis(mygraph, info[0], dim); - - return mygraph; - } - - - public TreeNode locateGraphics() { - TreeNode graphics = TreeUtil.findChild(root, "graphics"); - if (graphics == null) { - graphics = new TreeNode(root, "graphics"); - root.insertNode(TreeNode.APPEND, graphics); - graphics.setProperty("type", "graphset"); - } - return graphics; - } - - /** - * this test if the name for mygraph is already a child of graphics If so a - * new name is invented. - * - * @param graphics - * The node to insert mygraph to - * @param mygraph - * The node to insert. - */ - protected void testNameAndInsert(TreeNode graphics, TreeNode mygraph) { - int i = 1, idx; - StringBuffer name; - String oldName; - - while (TreeUtil.findChild(graphics, mygraph.getName()) != null) { - oldName = mygraph.getName(); - if ((idx = oldName.indexOf('_')) > 0) { - oldName = oldName.substring(0, idx); - } - name = new StringBuffer(oldName); - name.append('_'); - name.append(Integer.toString(i)); - mygraph.setProperty("name", name.toString()); - i++; - } - graphics.insertNode(TreeNode.APPEND, mygraph); - } - - protected void makeFrameSeriesViewer(TreeNode mygraph, String nxpath, int info[], int dim[]) { - int helpdim[] = new int[1], i, idim; - IntValue iv; - InternalParameter work; - String axis; - TreeNode node; - - mygraph.setProperty("viewer", "mountaingumui.frameseries"); - - work = (InternalParameter) TreeUtil.findChild(mygraph, "dim"); - work.setValue(Integer.toString(dim[1]) + " " + Integer.toString(dim[2])); - - work = (InternalParameter) TreeUtil.findChild(mygraph, "rank"); - work.setValue("2"); - - work = new InternalParameter(mygraph, "currentFrame"); - helpdim[0] = dim[0]; - iv = new IntValue(1, helpdim); - iv.append(dim[0] - 1); - work.updateValue(iv); - mygraph.insertNode(TreeNode.APPEND, work); - - work = new InternalParameter(mygraph, "counts"); - helpdim[0] = dim[1] * dim[2]; - iv = new IntValue(1, helpdim); - work.updateValue(iv); - work.setProperty("type", "data"); - mygraph.insertNode(TreeNode.APPEND, work); - String countpath = TreeUtil.pathForNode(work); - - InternalParameter cur = new InternalParameter(mygraph, "currentData"); - iv = new IntValue(1, helpdim); - cur.updateValue(iv); - mygraph.insertNode(TreeNode.APPEND, cur); - - CommandNode oldframe = new OldFrameCommand(mygraph, "getoldframe"); - oldframe.setProperty("countpath", countpath); - oldframe.setProperty("nxpath", nxpath); - oldframe.setProperty("type", "command"); - mygraph.insertNode(TreeNode.APPEND, oldframe); - InternalParameter num = (InternalParameter) TreeUtil.findChild(oldframe, "framenumber"); - num.setValue(Integer.toString(dim[0] - 1)); - oldframe.start(); - - cur.updateValue(work.getValue()); - - try { - nf.closedata(); - } catch (NexusException ne) { - } - - findAxis(nxpath, mygraph); - - /** - * Axis numbers in the NeXus file refer to a 3D array. This has to be - * fixed up here. - */ - for (i = 0; i < mygraph.countChildren(); i++) { - node = mygraph.getChild(i); - if (node instanceof InternalParameter) { - work = (InternalParameter) node; - } else { - continue; - } - axis = work.getProperty("type"); - if (axis != null && axis.equalsIgnoreCase("axis")) { - axis = work.getProperty("dim"); - idim = Integer.parseInt(axis); - idim--; - work.setProperty("dim", Integer.toString(idim)); - } - } - - checkAndDefaultAxis(mygraph, info[0], dim); - } - - /** - * check if each axis has been found; if not add a suitable default axis. - * - * @param mygraph - * The graphics node to check - * @param rank - * the rank of the data - * @param dim - * The dimensions of the data - */ - protected void checkAndDefaultAxis(TreeNode mygraph, int rank, int[] dim) { - int i; - - for (i = 0; i < rank; i++) { - ParameterNode ax = (ParameterNode)locateAxis(mygraph, i); - if (ax == null) { - addDefaultAxis(mygraph, i, dim[i]); - } else { - if(ax.getValue().getLength() != dim[i]){ - /* - System.out.println("Dimension mismatch on axis " + ax.getName() + - ", is " + ax.getValue().getLength() +", should " + dim[i]); - */ - mygraph.deleteChild(ax); - addDefaultAxis(mygraph, i, dim[i]); - } - } - } - } - - public void addDefaultAxis(TreeNode mygraph, int dim, int size) { - String name = "axis" + dim; - InternalParameter ax = new InternalParameter(mygraph, name); - ax.setProperty("type", "axis"); - ax.setProperty("dim", Integer.toString(dim)); - int tmp[] = new int[1]; - tmp[0] = size; - DoubleValue dv = new DoubleValue(1, tmp); - for (int i = 0; i < size; i++) { - dv.append(i); - } - ax.updateValue(dv); - mygraph.insertNode(TreeNode.APPEND, ax); - } - - /** - * try to find a suitable axis for dimension i - * - * @param mygraph - * The node to search - * @param i - * The dim to check - * @return A suitable TreeNode or null - */ - protected TreeNode locateAxis(TreeNode mygraph, int i) { - ChildStream cs = new ChildStream(mygraph); - TreeNode ax; - String dim; - - while ((ax = (TreeNode) cs.next()) != null) { - dim = ax.getProperty("dim"); - if (dim != null) { - if (Integer.parseInt(dim) == i) { - return ax; - } - } - } - return null; - } - - /** - * Try to locate axis nodes - * - * @param nf - * @param nxpath - * @param mygraph - */ - protected void findAxis(String nxpath, TreeNode mygraph) { - String name, type, axAttr; - try { - Hashtable dir = nf.groupdir(); - Enumeration it = dir.keys(); - while (it.hasMoreElements()) { - name = (String) it.nextElement(); - type = (String) dir.get(name); - if (type.equalsIgnoreCase("SDS")) { - nf.opendata(name); - axAttr = getAttr("axis"); - if (axAttr != null) { - makeAxis(name, axAttr, mygraph); - } - nf.closedata(); - } - } - } catch (NexusException ne) { - - } - } - - /** - * create an axis node - * - * @param nf - * @param name - * @param axAttr - * @param mygraph - * @throws NexusException - */ - protected void makeAxis(String name, String axAttr, TreeNode mygraph) throws NexusException { - InternalParameter ax = new InternalParameter(mygraph, name); - mygraph.insertNode(TreeNode.APPEND, ax); - ax.setProperty("type", "axis"); - int axno = Integer.parseInt(axAttr); - ax.setProperty("dim", Integer.toString(axno - 1)); - int dim[] = new int[32]; - int info[] = new int[2]; - nf.getinfo(dim, info); - ax.updateValue(makeValue(nf,dim, info)); - } - - /** - * test if this node has already been seen. - * - * @param nf - * @param nxpath - * @return - */ - protected boolean alreadySeen(String nxpath) { - if (checkedPaths.contains(nxpath)) { - return true; - } - String link = getAttr("target"); - if (link != null) { - if (checkedPaths.contains(link)) { - return true; - } - } - return false; - } - - /** - * helper function to get an attribute - * - * @param nf - * @param name - * @return - */ - public String getAttr(String name) { - try { - Hashtable h = nf.attrdir(); - AttributeEntry e = (AttributeEntry) h.get(name); - if (e == null) { - return null; - } - Serializable value = getAttrInSuitableJavaType(name, e.type, e.length); - return value.toString(); - } catch (NexusException ne) { - return null; - } - } - - private Serializable getAttrInSuitableJavaType(String name, int type, int length) throws NexusException { - /* - * add on 1 extra byte for the null in the attribute string hdfdump - * shows that we simply put the attribute using the code: - * file.putattr(name, (String)value.getBytes(), NexusFile.NX_CHAR); but - * the attribute length does not account the byte for the null - */ - - if (type == NexusFile.NX_CHAR) { - length += 1; - } - - int args[] = new int[] { length, type }; - - Serializable data = createObjectFromTypeAndLength(type, length); - - nf.getattr(name, data, args); - - // string - if (type == NexusFile.NX_CHAR) { - // remove the 1 extra bytes added on for the null in the attribute - length -= 1; - // remove training zero, if any - while (length > 0 && ((Number) Array.get(data, length - 1)).intValue() == 0) - length -= 1; - if (length == 0) - return ""; - data = Arrays.copyOf((byte[]) data, length); - return new String((byte[]) data, nexusCharset); - } - - return (Serializable) Array.get(data, 0); - } - - private Object getDataInSuitableJavaType(int[] infoDims, int[] infoArgs) throws NexusException { - int rank = infoArgs[0]; - int[] dimensions = new int[rank]; - for (int i = 0; i < rank; i++) { - dimensions[i] = infoDims[i]; - } - int type = infoArgs[1]; - int totalLength = calcTotalLength(dimensions,infoArgs); - - Serializable data = null; - if (totalLength > 0) { - data = createObjectFromTypeAndLength(type, totalLength); - if (data == null) { - throw new NexusException("Nexus type " + Integer.toString(type) + " is not supported"); - } - nf.getdata(data); - } - return data; - } - - private Serializable createObjectFromTypeAndLength(int type, int length) { - Serializable data = null; - switch (type) { - case NexusFile.NX_CHAR: - case NexusFile.NX_INT8: - case NexusFile.NX_UINT8: - data = new byte[length]; - break; - case NexusFile.NX_INT16: - case NexusFile.NX_UINT16: - data = new short[length]; - break; - case NexusFile.NX_INT32: - case NexusFile.NX_UINT32: - data = new int[length]; - break; - case NexusFile.NX_INT64: - case NexusFile.NX_UINT64: - data = new long[length]; - break; - case NexusFile.NX_FLOAT32: - data = new float[length]; - break; - case NexusFile.NX_FLOAT64: - data = new double[length]; - break; - } - return data; - } - - /** - * @param dimensions - * @return the size of a buffer needed to hold the data in an SDS block - */ - static public int calcTotalLength(int[] dimensions, int[] info) { - int totalLength = 1; - for (int i = 0; i < info[0]; i++) { - totalLength *= dimensions[i]; - } - return totalLength; - } - - /** - * reset ourselves... - */ - public void reset() { - checkedPaths.clear(); - } - - public void saveTree(TreeNode root, String filename) throws IOException { - - String oldfile = root.getProperty("filename"); - if (!oldfile.equals(filename)) { - /** - * To fix this I need to copy the old file on the new file and then - * apply the changes. For this I would need the apache commons-io - * library, or include it into the source or whatever. As of now - * (08/2009) I cannot yet bring myself to add the additional - * dependency. - */ - throw new IOException("Filename mismatch"); - } - - try { - FlatNexusFile nf = new FlatNexusFile(filename, NexusFile.NXACC_RDWR); - FuncUtil.map(root.getTreeStream(), new SaveNXPar(nf)); - nf.close(); - } catch (NexusException ne) { - throw new IOException(ne.getMessage()); - } - } - - public void viewNode(TreeNode root) { - if (root == null) { - return; - } - - NexusTree btv = (NexusTree) RCPUtil.findView(NexusTree.ID); - if (btv == null) { - // This means that the Nexus perspective has not yet been opened - return; - } - - btv.setTree(root); - EditorView ed = (EditorView) RCPUtil.findView(TreeEditorView.ID, "1"); - if (ed != null) { - ed.disconnect(); - } - - NameView nv = (NameView) RCPUtil.findView(NameView.ID); - if (nv != null) { - nv.setName(root.getProperty("filename")); - } - } - - public void removeUnwanted(TreeNode root, String[] toRemove) { - int i; - TreeNode n; - - for(i = 0; i < toRemove.length; i++){ - n = TreeUtil.searchNode(root, toRemove[i]); - if(n != null){ - n.getParent().deleteChild(n); - }else { - System.out.println("Failed to remove: " + toRemove[i]); - } - } - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusMapperDemo.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusMapperDemo.java deleted file mode 100755 index 12b85226..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusMapperDemo.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This is a demonstration mapper Is useless - * copyright: GPL - * - * Tobias Richter, October 2009 - */ -package ch.psi.num.mountaingum.nexus.loader; - -import ch.psi.num.mountaingum.tree.TreeNode; - -public class NexusMapperDemo implements NeXusMapper { - public void transform(TreeNode root, FlatNexusFile nf, NexusLoader nl) { - if (false) - root.insertNode(TreeNode.APPEND, new TreeNode(root, "DemoMapperNode")); - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusParameter.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusParameter.java deleted file mode 100755 index 80f6ae63..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/NexusParameter.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This is a very simple derived class of InternalParameter which makes a - * property by setting the property mogified if it has been changed. - * The intent is that, when saving files, this property will be examined and - * only those fields changed on file which have this property. The other - * operation implemented by this class is deferred loading, i.e. data is - * only read from file when it is actually required for the calculation of a - * plot. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.loader; - -import org.nexusformat.NexusException; - -import ch.psi.num.mountaingum.tree.NodeValue; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.tree.TreeUtil; -import ch.psi.num.mountaingum.ui.UIRegistry; - - -public class NexusParameter extends ch.psi.num.mountaingum.tree.InternalParameter { - private boolean loaded; - - public NexusParameter(TreeNode p, String name) { - super(p, name); - loaded = false; - } - - public void setValue(String val) { - super.setValue(val); - setProperty("mogrified", "true"); - loaded = true; - } - public NodeValue getValue() { - if(!loaded){ - loadData(); - } - return v; - } - - private void loadData() { - int dim[], info[]; - TreeNode root = TreeUtil.findRoot(this); - - String filename = root.getProperty("filename"); - String nxpath = getProperty("nxpath"); - - //System.out.println("Doing deferred load of " + nxpath); - - try{ - FlatNexusFile nf = new FlatNexusFile(filename,FlatNexusFile.NXACC_READ); - nf.openpath(nxpath); - dim = new int[32]; - info = new int[2]; - nf.getinfo(dim,info); - NodeValue v = NexusLoader.makeValue(nf, dim, info); - updateValue(v); - nf.close(); - }catch(NexusException ne){ - UIRegistry.getAdapter().displayError("Exception " + ne.getMessage() + " while loading " + nxpath); - } - } - - public void updateValue(NodeValue v) { - loaded = true; - super.updateValue(v); - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/OldFrameCommand.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/OldFrameCommand.java deleted file mode 100755 index 92b0995d..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/OldFrameCommand.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * This is a node which can load old frames from a NeXus data file. - * - * copyright: GPL - * - * Mark Koennecke, August 2009 - */ -package ch.psi.num.mountaingum.nexus.loader; - -import ncsa.hdf.hdflib.HDFNativeData; - -import org.nexusformat.NexusException; -import org.nexusformat.NexusFile; - -import ch.psi.num.mountaingum.tree.CommandNode; -import ch.psi.num.mountaingum.tree.IntValue; -import ch.psi.num.mountaingum.tree.InternalParameter; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.tree.TreeUtil; -import ch.psi.num.mountaingum.ui.UIRegistry; -import ch.psi.num.mountaingum.util.Array2DUtil; - -public class OldFrameCommand extends CommandNode { - - public OldFrameCommand(TreeNode parent, String name) { - super(parent, name); - InternalParameter no = new InternalParameter(this,"framenumber"); - int helpdim[] = new int[1]; - helpdim[0] = 1; - IntValue iv = new IntValue(1,helpdim); - iv.append(0); - no.updateValue(iv); - insertNode(TreeNode.APPEND,no); - } - - public void start() { - int start[], size[]; - int dim[], info[]; - TreeNode root = TreeUtil.findRoot(this); - - String filename = root.getProperty("filename"); - String nxpath = getProperty("nxpath"); - int frameNo = getFrameNo(); - start = new int[3]; - size = new int[3]; - - InternalParameter dn = (InternalParameter) TreeUtil.searchNode(root, getProperty("countpath")); - - if(getProperty("buenzel") != null){ - loadThorough(filename, frameNo, dn); - return; - } - try{ - FlatNexusFile nx = new FlatNexusFile(filename, NexusFile.NXACC_READ); - nx.openpath(nxpath); - dim = new int[32]; - info = new int[2]; - nx.getinfo(dim,info); - start[0] = Math.max(0,frameNo-1); - if(start[0] >= dim[0]){ - start[0] = dim[0] -1; - } - start[1] = 0; - start[2] = 0; - size[0] = 1; - size[1] = dim[1]; - size[2] = dim[2]; - byte raw[] = nx.getrawslab(start, size, info[1]); - if(info[1] != NexusFile.NX_INT32 && info[1] != NexusFile.NX_UINT32){ - /** - * TODO: fix this to handle all types of data? - */ - throw new NexusException("Unsupported data conversion"); - } - int data[] = HDFNativeData.byteToInt(raw); - if(getProperty("swap") != null){ - int targetdata[] = new int[data.length]; - Array2DUtil au = new Array2DUtil(); - au.rotate90(data, targetdata, dim[2], dim[1]); - data = targetdata; - } - IntValue iv = (IntValue) dn.getValue(); - iv.setData(data); - dn.notifyUpdate(); - raw = null; - data = null; - nx.close(); - }catch(Exception noemi){ - UIRegistry.getAdapter().displayError(noemi.getMessage()); - } - } - - private void loadThorough(String filename, int frameNo, InternalParameter dn) { - int data[], rawdata[][][], dim[], info[], i, j; - - try{ - FlatNexusFile nx = new FlatNexusFile(filename, NexusFile.NXACC_READ); - nx.openpath(getProperty("nxpath")); - dim = new int[32]; - info = new int[2]; - nx.getinfo(dim,info); - rawdata = new int[dim[0]][dim[1]][dim[2]]; - data = new int[dim[1]*dim[2]]; - nx.getdata(rawdata); - for(j = 0; j < dim[2]; j++ ){ - for(i = 0; i < dim[1]; i++){ - data[i + j*dim[1]] = rawdata[frameNo][j][i]; - } - } - nx.close(); - IntValue iv = (IntValue)dn.getValue(); - iv.setData(data); - dn.notifyUpdate(); - rawdata = null; - data = null; - }catch(Exception eva){ - UIRegistry.getAdapter().displayError(eva.getMessage()); - } - } - - private int getFrameNo() { - InternalParameter no = (InternalParameter) TreeUtil.findChild(this, "framenumber"); - IntValue iv = (IntValue) no.getValue(); - return iv.getValue(0); - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/PruneEmptyGroup.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/PruneEmptyGroup.java deleted file mode 100644 index 3ef598a4..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/PruneEmptyGroup.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This is a NeXusMapper which removes empty groups - * - * copyright: GPL - * - * Mark Koennecke, October 2009 - */ -package ch.psi.num.mountaingum.nexus.loader; - -import ch.psi.num.mountaingum.func.FuncUtil; -import ch.psi.num.mountaingum.func.IFunc; -import ch.psi.num.mountaingum.func.IStream; -import ch.psi.num.mountaingum.tree.ParameterNode; -import ch.psi.num.mountaingum.tree.TreeNode; - -public class PruneEmptyGroup implements NeXusMapper { - - private class TestFunc implements IFunc { - public Object apply(Object o) { - TreeNode n = (TreeNode)o; - if( ! (o instanceof ParameterNode) && n.countChildren() < 1){ - n.getParent().deleteChild(n); - } - return null; - } - - } - public void transform(TreeNode root, FlatNexusFile nf, NexusLoader nl) { - IStream s = root.getTreeStream(); - FuncUtil.map(s, new TestFunc()); - } - -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/sinqascii/ASCIILoader.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/sinqascii/ASCIILoader.java deleted file mode 100755 index a10207b2..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/sinqascii/ASCIILoader.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This class is responsible for loading a SINQ ASCII file into a - * GTSE NeXus viewer tree for viewing. - * - * copyright: GPL - * - * Mark Koennecke, September 2009 - */ -package ch.psi.num.mountaingum.nexus.loader.sinqascii; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Enumeration; -import java.util.HashSet; - -import ch.psi.num.mountaingum.sys.SysRegistry; -import ch.psi.num.mountaingum.tree.DoubleValue; -import ch.psi.num.mountaingum.tree.GraphicsNode; -import ch.psi.num.mountaingum.tree.IntValue; -import ch.psi.num.mountaingum.tree.InternalParameter; -import ch.psi.num.mountaingum.tree.TreeNode; - -public class ASCIILoader { - private HashSet exclude; - - public ASCIILoader(){ - exclude = new HashSet(); - exclude.add("ScanVariables"); - } - public TreeNode loadASCIIFile(String filename){ - TreeNode root = null, par; - GraphicsNode graph; - InternalParameter tmp; - ASCIIReader ar; - int i; - String parname, parvalue; - - try{ - File f = new File(filename); - FileInputStream fin = new FileInputStream(f); - ar = new ASCIIReader(fin); - ar.read(); - fin.close(); - }catch(IOException eva){ - SysRegistry.getLogger().error(eva.getMessage()); - return null; - } - - root = new TreeNode(null,""); - par = new TreeNode(root,"parameter"); - root.insertNode(TreeNode.APPEND, par); - graph = new GraphicsNode(root,"scan"); - root.insertNode(TreeNode.APPEND, graph); - - /** - * exclude arrays of scan vars - */ - String scanvars = (String)ar.getValue("names"); - String scanp[] = scanvars.split(","); - for(i = 0; i < scanp.length; i++){ - exclude.add(scanp[i]); - } - - - /** - * add parameters - */ - Enumeration e = ar.getKeys(); - while(e.hasMoreElements()){ - parname = (String)e.nextElement(); - if(! exclude.contains(parname)){ - parvalue = (String)ar.getValue(parname); - tmp = new InternalParameter(par,parname); - par.insertNode(TreeNode.APPEND, tmp); - tmp.setValue(parvalue); - } - } - - makeGraph(graph, ar); - root.setProperty("filename", filename); - - return root; - } - private void makeGraph(GraphicsNode graph, ASCIIReader ar) { - int helpdim[], i, j; - InternalParameter tmp; - IntValue iv; - DoubleValue dv; - float counts[], par[]; - - graph.setProperty("type", "graphset"); - counts = (float[])ar.getValue("Counts"); - - helpdim = new int[1]; - tmp = new InternalParameter(graph,"rank"); - graph.insertNode(TreeNode.APPEND, tmp); - helpdim = new int[1]; - helpdim[0] = 1; - iv = new IntValue(1,helpdim); - iv.append(1); - tmp.updateValue(iv); - - - tmp = new InternalParameter(graph,"dim"); - graph.insertNode(TreeNode.APPEND, tmp); - helpdim[0] = 1; - iv = new IntValue(1,helpdim); - iv.append(counts.length); - tmp.updateValue(iv); - - - tmp = new InternalParameter(graph,"counts"); - tmp.setProperty("type", "data"); - graph.insertNode(TreeNode.APPEND, tmp); - helpdim[0] = counts.length; - iv = new IntValue(1,helpdim); - for(i = 0; i < counts.length; i++){ - iv.append(counts[i]); - } - tmp.updateValue(iv); - - String scanvars = (String)ar.getValue("ScanVariables"); - String scanp[] = scanvars.split(","); - for(i = 0; i < scanp.length; i++){ - par = (float[])ar.getValue(scanp[i].trim()); - if(par != null && par.length > 1 && Math.abs(par[1] - par[0]) > 0.0001) { - tmp = new InternalParameter(graph,scanp[i]); - graph.insertNode(TreeNode.APPEND, tmp); - helpdim[0] = par.length; - dv = new DoubleValue(1,helpdim); - for(j = 0; j < par.length; j++){ - dv.append(par[j]); - } - tmp.updateValue(dv); - tmp.setProperty("type", "axis"); - tmp.setProperty("dim", "0"); - return; - } - } - } -} diff --git a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/sinqascii/ASCIIReader.java b/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/sinqascii/ASCIIReader.java deleted file mode 100755 index e8bffae9..00000000 --- a/contrib/applications/nxplot/mountaingumnexus/src/ch/psi/num/mountaingum/nexus/loader/sinqascii/ASCIIReader.java +++ /dev/null @@ -1,266 +0,0 @@ - /** - * A S C I I R e a d e r - * - * A class for reading SinQ ASCII data files. Data is entered in a - * dictionary on reading. From this dictionary data can be retrieved - * using its keyword. There are a few system special dictionary entries: - * NP is the number of points, Preset the preset and Mode the scan mode. - * ScanVariables has as value a comma separated list of scan variables. - * names is a comma separated list of all the variables recorded at each - * scan point. - * - * Mark Koennecke, August 1998 - * - * Added getKeys() method - * - * Mark Koennecke, September 2009 - */ -package ch.psi.num.mountaingum.nexus.loader.sinqascii; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; -import java.util.StringTokenizer; -import java.io.InputStreamReader; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.IOException; - - public class ASCIIReader { - - /** - * Variables - */ - protected BufferedReader bin; - protected Hashtable datadict; - private final static int debug = 0; - - /** - * A Constructor - */ - public ASCIIReader(InputStream in) - { - bin = new BufferedReader(new InputStreamReader(in)); - datadict = new Hashtable(); - } - - /** - * The Read method coordinates the work. It calls readHeader and - * readData - */ - public void read() throws IOException - { - readHeader(); - readData(); - } - - /** - * readHader reads lines until it finds a string with ** DATA **. - * If the line contains a = sign, the line is split there and - * the two components added to the datadict as key value pair. - */ - protected void readHeader() throws IOException - { - String line; - StringTokenizer st; - int iIndex; - String key,value; - - line = bin.readLine(); - while(line.indexOf("*** DATA ***") < 0) - { - /* older TOPSI files do not have the = in all cases */ - line = fixTopsi(line); - iIndex = line.indexOf('='); - if(iIndex > 0) - { - key = line.substring(0,iIndex); - key = key.trim(); - value = line.substring(iIndex+1,line.length()); - value = value.trim(); - if(debug > 0) - { - System.out.println("Entering: " + - key + ", " + - value ); - } - datadict.put(key,value); - } - line = bin.readLine(); - } - } - /** - * - */ - private String fixTopsi(String line) - { - int iIndex; - String result; - - if(line.indexOf("Stardate:") > 0) - { - iIndex = line.indexOf(':'); - result = line.substring(0,iIndex) + "=" + - line.substring(iIndex+1, line.length()) ; - return result; - } - return line; - } - - /** - * readData reads the data header info, then the data and stores - * them in the dictionary as Vectors. - */ - protected void readData() throws IOException - { - int iIndex, i, i2; - int iNP = 0, nData, iCount; - String line, temp, snames; - String names[]; - float data[][], f2[]; - Float f; - - /* get scan variables */ - line = bin.readLine(); - iIndex = line.indexOf("WARNING"); - if(iIndex >=0 ) - { - line = bin.readLine(); - } - iIndex = line.indexOf(':'); - datadict.put("ScanVariables", - line.substring(iIndex+1,line.length())); - - /* get np, mode & preset */ - line = bin.readLine(); - StringTokenizer st = new StringTokenizer(line,",",false); - if(st.countTokens() < 3) - { - throw new IOException("Invalid data file format"); - } - temp = st.nextToken(); - iIndex = temp.indexOf(' '); - Integer ig = new Integer(0); - try { - ig = new Integer(temp.substring(0,iIndex)); - iNP = ig.intValue(); - } catch(Exception egolf) { - throw new IOException("Invalid data file format"); - } - if(debug > 0) - { - System.out.println("Found NP as: " + iNP); - } - datadict.put("NP",ig.toString()); - temp = st.nextToken(); - iIndex = temp.indexOf(':'); - datadict.put("ScanMode", - temp.substring(iIndex+1,temp.length())); - temp = st.nextToken(); - iIndex = temp.indexOf(' '); - datadict.put("Preset", - temp.substring(iIndex+1,temp.length())); - - /* get data item names */ - line = bin.readLine(); - st = new StringTokenizer(line," ",false); - nData = st.countTokens(); - names = new String[nData-1]; /* do not get NP */ - st.nextToken(); /* skip NP */ - for(i = 0; i < nData-1; i++) - { - names[i] = st.nextToken(); - } - data = new float[nData][iNP]; - - /* after having set up, read the actual data */ - if(debug > 0) - { - System.out.println("Starting to read Scan data"); - } - for(i = 0; i < iNP; i++) - { - line = bin.readLine(); - /* handle it gracefully, if the user aborted the scan */ - if(line.equals("END-OF-DATA")) - { - iNP = i-1; - datadict.remove("NP"); - ig = new Integer(iNP); - datadict.put("NP",ig.toString()); - break; - } - st = new StringTokenizer(line," ",false); - /* skip NP as first column */ - st.nextToken(); - for(i2 = 0; i2 < nData -1; i2++) - { - temp = st.nextToken(); - try { - f = new Float(temp); - data[i2][i] = f.floatValue(); - if(debug > 3) - { - System.out.println("assigning: " + f.floatValue() + - "to " + i2 + "," +i); - } - }catch(Exception rudolf) { - if(debug > 0) - { - System.out.println("Failure to convert number from " - +temp); - System.out.println(rudolf.getMessage()); - } - data[i2][i] = (float)0.0; - } - } - } - if(debug > 0) - { - System.out.println("Read all scan points"); - } - - /* done reading, stow away */ - snames = new String(); - for(i = 0; i < nData-1; i++) - { - snames = snames.concat(names[i]); - snames = snames.concat(","); - f2 = new float[iNP]; - for(i2 = 0; i2 < iNP; i2++) - { - f2[i2] = data[i][i2]; - } - datadict.put(names[i],f2); - } - /* remove last komma in snames */ - iIndex = snames.lastIndexOf(','); - snames = snames.substring(0,iIndex); - - datadict.put("names",snames); - } - - /** - * getValue gets the object requested as key from the dictionary. - */ - public Object getValue(String key) - { - return datadict.get(key); - } - - public Enumeration getKeys(){ - return datadict.keys(); - } - /** - * a finalizer - */ - protected void finalize() throws Throwable - { - if(bin != null) - { - bin.close(); - bin = null; - } - datadict = null; - } - } /* end of class definition */ diff --git a/contrib/applications/nxplot/mountaingumsys/.classpath b/contrib/applications/nxplot/mountaingumsys/.classpath deleted file mode 100755 index 1fa3e680..00000000 --- a/contrib/applications/nxplot/mountaingumsys/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/contrib/applications/nxplot/mountaingumsys/.project b/contrib/applications/nxplot/mountaingumsys/.project deleted file mode 100755 index fd13e059..00000000 --- a/contrib/applications/nxplot/mountaingumsys/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - mountaingumsys - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/mountaingumsys/META-INF/MANIFEST.MF b/contrib/applications/nxplot/mountaingumsys/META-INF/MANIFEST.MF deleted file mode 100755 index 9b6bc713..00000000 --- a/contrib/applications/nxplot/mountaingumsys/META-INF/MANIFEST.MF +++ /dev/null @@ -1,13 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Mountaingumsys Plug-in -Bundle-SymbolicName: mountaingumsys;singleton:=true -Bundle-Version: 0.1 -Bundle-Vendor: Mark.Koennecke@psi.ch -Bundle-Localization: plugin -Export-Package: ch.psi.num.mountaingum.batch, - ch.psi.num.mountaingum.func, - ch.psi.num.mountaingum.sys, - ch.psi.num.mountaingum.tree, - ch.psi.num.mountaingum.ui, - ch.psi.num.mountaingum.util diff --git a/contrib/applications/nxplot/mountaingumsys/build.properties b/contrib/applications/nxplot/mountaingumsys/build.properties deleted file mode 100755 index e9863e28..00000000 --- a/contrib/applications/nxplot/mountaingumsys/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml diff --git a/contrib/applications/nxplot/mountaingumsys/plugin.xml b/contrib/applications/nxplot/mountaingumsys/plugin.xml deleted file mode 100755 index 9483051f..00000000 --- a/contrib/applications/nxplot/mountaingumsys/plugin.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/contrib/applications/nxplot/mountaingumsys/schema/ch.num.psi.mountaingum.tree.DataFilter.exsd b/contrib/applications/nxplot/mountaingumsys/schema/ch.num.psi.mountaingum.tree.DataFilter.exsd deleted file mode 100755 index 2b52c233..00000000 --- a/contrib/applications/nxplot/mountaingumsys/schema/ch.num.psi.mountaingum.tree.DataFilter.exsd +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - A filter for node data - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - See interface ch.psi.num.mountaingum.tree.DataFilter - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchAdapter.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchAdapter.java deleted file mode 100755 index a381be8c..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchAdapter.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * This is an abstract class for interfacing with the batch system. The general idea - * is that Parameter- or CommandNodes are cloned into a batch queue which can be - * edited, both the sequence and the nodes. Implementations are then responsible - * for serializing, deserializing and running such queues against the underlying - * system - * - * Classes implementing this interface are also responsible for holding the current - * Queue of edited or active batch nodes. - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.batch; - -import java.util.List; -import java.util.Vector; - -import ch.psi.num.mountaingum.func.FuncUtil; -import ch.psi.num.mountaingum.func.IFunc; -import ch.psi.num.mountaingum.func.IteratorStream; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.util.ListSequence; -import ch.psi.num.mountaingum.util.Sequence; - -public abstract class BatchAdapter { - protected Sequence buffer; - protected Vector batchListeners; - - public BatchAdapter(){ - batchListeners = new Vector(); - buffer = new ListSequence(); - } - /** - * Clone a tree node in a suitable way that it can be used in the - * batch editor. - * @param source The node to clone - * @return A TreeNode implementing the BatchNode interface - */ - abstract public TreeNode cloneBatchNode(TreeNode source); - /** - * get the sequence we are currently editing. - * @return An editing Sequence - */ - public Sequence getSequence(){ - return buffer; - } - /** - * Get a list of urls for available batch files held in the underlying - * system. - * @return A List holding url strings. - */ - abstract public List getAvailableBatchBuffers(); - - /** - * Load a batch sequence from somewhere into the editing sequence - * @param url A system specific identifier for the buffer to laod. - */ - abstract public void load(String url); - /** - * save the current sequence to a file - * @param url The identifier for the file to save the sequence too - */ - abstract public void save(String url); - /** - * Start executing the current Sequence - */ - abstract public void start(String url); - /** - * Interrupt processing of the current sequence. - */ - abstract public void Interrupt(); - /** - * loadRaw loads a batch file for script style editing - * @param url The URL of the batch file to load - * @return the content of the batch file or an error message - */ - abstract public String loadRaw(String url); - /** - * save a raw script edited file to the DAQ system - * @param url The URL of the file to save - * @param txt The content of the file - */ - abstract public void saveRaw(String url, String txt); - /** - * execute a batch file - * @param url The name of the batch file - * @param data The batch data - * @param l A BatchScriptListener which is informed about the progress of the - * script. - */ - abstract public void exeScript(String url, String data, BatchScriptListener l); - /** - * add a BatchListener - * @param l The BatchListener to add - */ - public void addBatchListener(BatchListener l){ - batchListeners.add(l); - } - /** - * remove a BatchListener - * @param l The BatchListener to remove. - */ - public void removeBatchListener(BatchListener l){ - batchListeners.remove(l); - } - /** - * Utility function for appending a node to the sequence. - * @param n The node to append - */ - public void append(TreeNode n){ - buffer.insert(buffer.length(), n); - sequenceChanged(); - nodeEnqueued(n); - } - private class NewIndex implements IFunc { - private int id; - - NewIndex(int id){ - this.id = id; - } - public Object apply(Object o) { - BatchListener l = (BatchListener)o; - l.startingEntry(id); - return null; - } - } - private class NewLog implements IFunc { - private String log; - - NewLog(String txt){ - this.log = txt; - } - public Object apply(Object o) { - BatchListener l = (BatchListener)o; - l.logMessage(log); - return null; - } - } - private class SeqChange implements IFunc { - private Sequence s; - - SeqChange(Sequence s){ - this.s = s; - } - public Object apply(Object o) { - BatchListener l = (BatchListener)o; - l.sequenceChanged(s); - return null; - } - } - private class NodeEnqueue implements IFunc { - private BatchNode n; - - NodeEnqueue(BatchNode n){ - this.n = n; - } - public Object apply(Object o) { - BatchListener l = (BatchListener)o; - l.nodeEnqueued(n); - return null; - } - } - /** - * send a notification to all BatchListeners that we are now executing a - * new entry. - * @param id The entry which starts executing. - */ - protected void newIndex (int id){ - FuncUtil.map(new IteratorStream(batchListeners), new NewIndex(id)); - } - /** - * send a new log message to all BatchListeners. - * @param txt The message to send. - */ - protected void newLogData(String txt){ - FuncUtil.map(new IteratorStream(batchListeners), new NewLog(txt)); - } - public void sequenceChanged(){ - FuncUtil.map(new IteratorStream(batchListeners), new SeqChange(buffer)); - } - protected void nodeEnqueued(TreeNode n){ - FuncUtil.map(new IteratorStream(batchListeners), new NodeEnqueue((BatchNode)n)); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchListener.java deleted file mode 100755 index 0db10d15..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchListener.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * This is a listener interface for all things coming from the execution of - * a batch sequence. - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.batch; - -import ch.psi.num.mountaingum.util.Sequence; - -public interface BatchListener { - /** - * This is the information that the entry with the index id - * has started executing. - * @param id The index of the queue entry executing - */ - public void startingEntry(int id); - /** - * A log message has arrived. - * @param txt The text being logged. - */ - public void logMessage(String txt); - /** - * This shall be called whenever the sequence has changed. The client ought to - * react to this with a redraw. - * @param s The sequence changed. - */ - public void sequenceChanged(Sequence s); - /** - * This is called whenever a node has been queued to the batch queue. - * @param n The node which has been enqueued. - */ - public void nodeEnqueued(BatchNode n); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchNode.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchNode.java deleted file mode 100755 index b3160a40..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchNode.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * This is the interface to be implemented by tree nodes in the batch queue. I - * separated this into an interface in order to allow batch tree nodes to - * inherit from real nodes as they might and will share the command formatting - * code in the SICS implementation. - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.batch; - -public interface BatchNode { - /** - * Is this node capable to handle textual edits of command strings? - * If yes, parse() must do sensible things. - * @return true or false - */ - public boolean canEdit(); - /** - * getDescription returns a textual description of the batch node entry - * @return A string for displaying info about this entry. - */ - public String getDescription(); - /** - * After text editing, parse the resulting string into the - * node. - * @param txt The text to parse. - */ - public void parse(String txt)throws BatchParseException; -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchParseException.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchParseException.java deleted file mode 100755 index 8cdeaf28..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchParseException.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * An exception top be thrown when parsing a node from edited data fails. Currently - * this jusst identifies the type. More things may be added later on. - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.batch; - -public class BatchParseException extends Exception { - public BatchParseException(String txt){ - super(txt); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchReceiver.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchReceiver.java deleted file mode 100755 index ba501c27..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchReceiver.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This is a little class with default implementations for the BatchListener interface. - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.batch; - -import ch.psi.num.mountaingum.util.Sequence; - -public class BatchReceiver implements BatchListener { - - public void logMessage(String txt) { - // Nothing to do - } - - public void nodeEnqueued(BatchNode n) { - // Nothing to do - } - - public void sequenceChanged(Sequence s) { - // Nothing to do - } - - public void startingEntry(int id) { - // Nothing to do - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchScriptListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchScriptListener.java deleted file mode 100755 index 4e66d5c0..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/batch/BatchScriptListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This is a listener for events from processing scripted batch - * files. - * - * copyright: GPL - * - * Mark Koennecke, September 2009 - */ -package ch.psi.num.mountaingum.batch; - -public interface BatchScriptListener { - /** - * some log data - * @param txt The log data; - */ - public void log(String txt); - /** - * change the text range which is currently executing - * @param start of the range - * @param end of the range - */ - public void range(int start, int end); - /** - * inidication that the script terminated - */ - public void terminated(); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/ArrayStream.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/ArrayStream.java deleted file mode 100755 index 6d3e9af2..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/ArrayStream.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This is an aray of objects based stream - * - * copyright: GPL - * - * Mark Koennecke, July 2007 - */ -package ch.psi.num.mountaingum.func; - -public class ArrayStream implements IStream { - - private Object obj[]; - private int count; - public ArrayStream(Object o[]){ - obj = o; - count = 0; - } - public Object next() { - Object o; - if(count < obj.length ){ - o = obj[count]; - count++; - return o; - } - return null; - } - -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/EnumerationStream.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/EnumerationStream.java deleted file mode 100755 index 346ef920..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/EnumerationStream.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This is a stream to iterate over a Java Enumeration - * - * copyright: GPL - * - * Mark Koennecke, December 2007 - */ -package ch.psi.num.mountaingum.func; -import java.util.Enumeration; - -public class EnumerationStream implements IStream { - private Enumeration eno; - - public EnumerationStream(Enumeration eno){ - this.eno = eno; - } - public Object next() { - if(eno.hasMoreElements()){ - return eno.nextElement(); - } else { - return null; - } - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/FuncUtil.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/FuncUtil.java deleted file mode 100755 index c6425719..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/FuncUtil.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * a utility class which implements various functional strategies - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.func; -import java.util.LinkedList; -import java.util.List; - -public class FuncUtil { - - public static List map(IStream in, IFunc func){ - Object arg, out; - List l = new LinkedList(); - - while((arg = in.next()) != null){ - out = func.apply(arg); - if(out != null){ - l.add(out); - } - } - return l; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IFunc.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IFunc.java deleted file mode 100755 index 7345485e..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IFunc.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Interface for a function acting upon an object - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.func; - -public interface IFunc { - /** - * apply the function to - * @param o The argument object - * @return null or a result object - */ - public Object apply(Object o); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IStream.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IStream.java deleted file mode 100755 index 53e55345..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IStream.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This is an interface for streams of objects. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.func; - -public interface IStream { - /** - * return next object or null when exhausted - * @return an object or null when exhausted. - */ - public Object next(); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IteratorStream.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IteratorStream.java deleted file mode 100755 index e119c204..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/func/IteratorStream.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This packages any of the standard Java collection iterators into a - * stream interface - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.func; -import java.util.Collection; -import java.util.Iterator; - -public class IteratorStream implements IStream { - - protected Iterator it; - - public IteratorStream(Collection c){ - it = c.iterator(); - } - public Object next() { - if(it.hasNext()){ - return it.next(); - } - return null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/DefaultLogger.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/DefaultLogger.java deleted file mode 100755 index c7f4baa1..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/DefaultLogger.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * This is a default logger which does: NOTHING! - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.sys; - -public class DefaultLogger implements LoggerInterface { - - public void debug(String txt) { - } - - public void error(String txt) { - } - - public void info(String txt) { - } - - public void received(String txt) { - } - - public void sent(String txt) { - } - - public void trace(String txt) { - } - - public void warn(String txt) { - } - - public void exception(Exception eva) { - } -} - diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/IDisconnectListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/IDisconnectListener.java deleted file mode 100755 index 578fb3cc..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/IDisconnectListener.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * listeneing for disconnects? - * - * copyright: GPL - * - * Mark Koennecke, July 2007 - */ -package ch.psi.num.mountaingum.sys; - -public interface IDisconnectListener { - public void disconnect(); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/ISystemAdapter.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/ISystemAdapter.java deleted file mode 100755 index d3cd2862..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/ISystemAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This is the interface any adapter to an underlying system has to implement - * - * copyright: GPL - * - * Mark Koennecke, July 2007 - */ -package ch.psi.num.mountaingum.sys; -import ch.psi.num.mountaingum.tree.TreeNode; - -public interface ISystemAdapter { - /* - * can do asynchronous processing - */ - public boolean canAsync(); - /** - * configure the tree according to the demands of the underlying system. - * Please note that this may also be called to reconfigure parts of the - * tree after the underlying system modifies the tree. - * @param root The root of the tree. Children have to be added to this - */ - public void configureTree(TreeNode root); - /** - * interrupt the current operation - */ - public void interrupt(); - /** - * create a suitable TerminalInterface implementation. - * @return A TerminalInterface - */ - public TerminalInterface makeTerminalInterface(); - /** - * return a terminal interface to the factory for destruction. - * @param ti The TerminalInterface to destroy. - */ - public void closeTerminalInterface(TerminalInterface ti); - /** - * add a listener for disconnects to the control system - * @param l The listener to add - */ - public void addDisconnectListener(IDisconnectListener l); - /** - * remove a listener for disconnects to the control system - * @param l The listener to remove - */ - public void removeDisconnectListener(IDisconnectListener l); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/LoggerInterface.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/LoggerInterface.java deleted file mode 100755 index 9a3eefd6..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/LoggerInterface.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * This is an interface describing a logger. Clients can implement - * different implementations in order to realize different logging - * strategies. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.sys; - -public interface LoggerInterface { - public void trace(String txt); - public void debug(String txt); - public void info(String txt); - public void warn(String txt); - public void error(String txt); - public void sent(String txt); - public void received(String txt); - public void exception(Exception eva); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/NullTerminal.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/NullTerminal.java deleted file mode 100755 index 7080d47a..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/NullTerminal.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * This is the default implementation of a terminal interface - * - * copyright: GPL - * - * Mark Koennecke, December 2007 - */ -package ch.psi.num.mountaingum.sys; - -import java.util.ArrayList; -import java.util.List; - -public class NullTerminal implements TerminalInterface { - - public NullTerminal(){ - l = null; - } - protected TerminalListener l; - public TerminalListener getTerminalListener() { - return l; - } - - public void interrupt() { - reply("ERROR: Not connected, interrupt annihilated"); - } - - public void sendCommand(String command) { - reply("ERROR: not connected, command " + command + " annihilated"); - } - - public void setTerminalListener(TerminalListener l) { - this.l = l; - } - private void reply(String txt){ - if(l != null){ - List ll = new ArrayList(); - ll.add(txt); - l.handleOutput(ll); - } - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/QueueListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/QueueListener.java deleted file mode 100755 index ad517174..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/QueueListener.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * This is the interface anyone has to implement who wishes to be informed of - * a batch queues progress. - * - * copyright: GPL - * - * Mark Koennecke, August 2007 - */ -package ch.psi.num.mountaingum.sys; - -public interface QueueListener { - public void nodeExecuting(int idx); - public void batchError(String descr); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/StdoutLogger.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/StdoutLogger.java deleted file mode 100755 index 3499cd0e..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/StdoutLogger.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This is another logger which outputs to stdout. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.sys; - -public class StdoutLogger implements LoggerInterface { - - public final static int IO = 0; - public final static int TRACE = 1; - public final static int INFO = 2; - public final static int DEBUG = 3; - public final static int WARN = 4; - public final static int ERROR = 5; - public final static int OFF = 6; - - protected int logLevel; - - public void debug(String txt) { - log(DEBUG,txt); - } - - public void error(String txt) { - log(ERROR,txt); - } - - public void info(String txt) { - log(INFO,txt); - } - - public void received(String txt) { - log(IO,txt); - } - - public void sent(String txt) { - log(IO,txt); - } - - public void trace(String txt) { - log(TRACE,txt); - } - - public void warn(String txt) { - log(WARN,txt); - } - protected void log(int level, String txt){ - if(level >= logLevel){ - System.out.println(txt); - } - } - - protected String levelToString(int level) { - switch(level){ - case IO: - return "IO"; - case TRACE: - return "TRACE"; - case INFO: - return "INFO"; - case DEBUG: - return "DEBUG"; - case WARN: - return "WARNING"; - case ERROR: - return "ERROR"; - } - return "BADLEVEL"; - } - public int getLogLevel() { - return logLevel; - } - - public void setLogLevel(int logLevel) { - this.logLevel = logLevel; - } - - public void exception(Exception eva) { - if(logLevel > ERROR){ - return; - } - /* - * This keeps popping up as excessive - * object allocations in hprof-files. So we stop - * it with the code above. - */ - log(ERROR,"Exception " + eva.getMessage()); - StackTraceElement stack[] = eva.getStackTrace(); - for(int i = 0; i < stack.length; i++){ - log(ERROR,stack[i].toString()); - } - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/SysRegistry.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/SysRegistry.java deleted file mode 100755 index d5057557..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/SysRegistry.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This is the central access point for all system services. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - * - * added TerminalInterface support - * - * Mark Koennecke, December 2007 - */ -package ch.psi.num.mountaingum.sys; - -import ch.psi.num.mountaingum.batch.BatchAdapter; - -public class SysRegistry { - /** - * logging stuff - */ - private static LoggerInterface logger = null; - - /** - * an adapter which can do tree creation - */ - private static ISystemAdapter sys = null; - - /** - * and adpater for managing batch processing - */ - private static BatchAdapter batch = null; - - static public LoggerInterface getLogger(){ - if(logger == null){ - logger = new DefaultLogger(); - } - return logger; - } - static synchronized public void setLogger(LoggerInterface li){ - logger = li; - } - public static BatchAdapter getBatchAdapter() { - return batch; - } - public static void setBatchAdapter(BatchAdapter batch) { - SysRegistry.batch = batch; - } - public static ISystemAdapter getSystemAdapter() { - return sys; - } - public static void setSystemAdapter(ISystemAdapter sys) { - SysRegistry.sys = sys; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/TerminalInterface.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/TerminalInterface.java deleted file mode 100755 index 283f0607..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/TerminalInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This is an interface to an underlying text based command system - * - * copyright: GPL - * - * Mark Koennecke, December 2007 - */ -package ch.psi.num.mountaingum.sys; - -public interface TerminalInterface { - /** - * send a command to the CLI system - * @param command The command to send - */ - public void sendCommand(String command); - /** - * interrupt what is going on in the CLI - */ - public void interrupt(); - /** - * set a listener for output from the CLI - * @param l The listener to set. - */ - public void setTerminalListener(TerminalListener l); - /** - * get the current terminal listener - * @return The current TerminalListener - */ - public TerminalListener getTerminalListener(); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/TerminalListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/TerminalListener.java deleted file mode 100755 index 48fdc5dd..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/sys/TerminalListener.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This is an interface for an object to listen for output from - * a command line application. - * - * copyright: GPL - * - * Mark Koennecke, December 2007 - */ -package ch.psi.num.mountaingum.sys; - -import java.util.List; - -public interface TerminalListener { - /** - * handle output from the CLI - * @param lines is a list of lines. - */ - public void handleOutput(List lines); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/test/TestInt.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/test/TestInt.java deleted file mode 100755 index 2b3e8678..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/test/TestInt.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Testing the IntValue class..... - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.test; -import ch.psi.num.mountaingum.tree.IntValue; -public class TestInt { - public static void main(String argv[]){ - int dim[] = new int[1]; - dim[0] = 3; - IntValue iv = new IntValue(1,dim); - iv.setFromString("1 2 3"); - int d[] = iv.getData(); - d[0] = 5; - d[1] = 6; - d[2] = 7; - iv.setData(d); - System.out.println(iv.toString()); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ChildStream.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ChildStream.java deleted file mode 100755 index e645e804..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ChildStream.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * A stream of child nodes of the parent node given in the constructor. - * This stream does not recurse - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -import ch.psi.num.mountaingum.func.IStream; - -public class ChildStream implements IStream { - - private TreeNode parent; - private int current; - private int count; - public ChildStream(TreeNode parent){ - current = 0; - this.parent = parent; - count = parent.countChildren(); - } - public Object next() { - Object o = null; - if(current < count){ - o = parent.getChild(current); - current++; - } - return o; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/CommandNode.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/CommandNode.java deleted file mode 100755 index 4b25242e..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/CommandNode.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This is a node representing a command. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -import ch.psi.num.mountaingum.batch.BatchAdapter; -import ch.psi.num.mountaingum.sys.SysRegistry; - -public abstract class CommandNode extends ExecutableNode { - public CommandNode(TreeNode parent, String name){ - super(parent,name); - } - abstract public void start(); - public void enqueue(){ - BatchAdapter ba = SysRegistry.getBatchAdapter(); - TreeNode tn = ba.cloneBatchNode(this); - ba.append(tn); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/DataFilter.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/DataFilter.java deleted file mode 100755 index 92bdba40..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/DataFilter.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This is an interface for all data filters. A data filter transforms - * the data read into something else. - * - * Mark Koennecke, May 2008 - */ -package ch.psi.num.mountaingum.tree; - - -public interface DataFilter { - public void process(TreeNode n) throws Exception; -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/DoubleValue.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/DoubleValue.java deleted file mode 100755 index 9ac5c0a4..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/DoubleValue.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * This is a node representing double data. We do some lazy evaluation - * here: i.e. data gets converted from text to array or from array to text - * only when requested. Please note that client code is responsible for - * adapting dimensions for the case of variable length arrays. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; -import ch.psi.num.mountaingum.util.DynamicDoubleArray; - -public class DoubleValue extends NodeValue { - protected DynamicDoubleArray data; - protected boolean arrayDirty; - protected boolean textDirty; - - public DoubleValue(int rank, int dim[]){ - this.type = FLOAT; - this.rank = rank; - this.dim = dim; - textData = new String("0"); - data = new DynamicDoubleArray(); - textDirty = false; - } - - public void setFromString(String data){ - super.setFromString(data); - arrayDirty = true; - textDirty = false; - } - public String toString(){ - if(textDirty){ - textData = data.toString(); - textDirty = false; - } - return textData; - } - public void setDim(int dim[]){ - super.setDim(dim); - arrayDirty = true; - textDirty = true; - } - public int getLength(){ - return data.getLength(); - } - public double[] getData(){ - if(arrayDirty){ - data.setFromText(textData.trim()); - arrayDirty = false; - } - return data.getData(); - } - public double getValue(int idx){ - if(arrayDirty){ - data.setFromText(textData.trim()); - arrayDirty = false; - } - return data.getValue(idx); - } - public void setData(double data[]){ - this.data.reset(); - this.data.append(data); - textDirty = true; - } - public void append(double d){ - data.append(d); - textDirty = true; - } - public void append(int i){ - data.append((double)i); - textDirty = true; - } - public double[] getRawData(){ - return data.getRawArray(); - } - public void reset() { - super.reset(); - data.reset(); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ExecutableNode.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ExecutableNode.java deleted file mode 100755 index 8cf94521..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ExecutableNode.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * This is a base class for all node which are executable. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; -import java.util.LinkedList; -import ch.psi.num.mountaingum.func.*; - -public abstract class ExecutableNode extends TreeNode { - public final static int OK = 0; - public final static int RUN = 1; - public final static int ERROR = 2; - - protected LinkedList logListeners, updateListeners; - protected boolean readOnly; - protected StringBuffer logBuffer; - protected int state; - - public ExecutableNode(TreeNode mama, String name){ - super(mama,name); - logListeners = new LinkedList(); - updateListeners = new LinkedList(); - readOnly = false; - logBuffer = new StringBuffer(); - state = OK; - } - /** - * add a log listener - * @param l The listener to add - */ - public void addLogListener(LogListener l){ - logListeners.add(l); - } - /** - * remove a LogListener - * @param l The LogListener to remove - */ - public void removeLogListener(LogListener l){ - if(logListeners.contains(l)){ - logListeners.remove(l); - } - } - private class StartNotify implements IFunc { - private TreeNode me; - StartNotify(TreeNode m){ - me = m; - } - public Object apply(Object o){ - LogListener ll = (LogListener)o; - ll.deviceStarted(me); - return null; - } - } - protected void startDevice(){ - logBuffer = null; - logBuffer = new StringBuffer(); - FuncUtil.map(new IteratorStream(logListeners), new StartNotify(this)); - state = RUN; - } - private class LogNotify implements IFunc{ - private TreeNode me; - private String message; - private boolean success; - LogNotify(TreeNode n, String mes, boolean s){ - me = n; - message = mes; - success = s; - } - public Object apply(Object o){ - LogListener ll = (LogListener)o; - ll.addLogData(me, message, success); - return null; - } - } - protected void log(String message, boolean success){ - FuncUtil.map(new IteratorStream(logListeners), - new LogNotify(this, message, success)); - logBuffer.append(message); - logBuffer.append('\n'); - if(!success){ - state = ERROR; - } - } - private class StopNotify implements IFunc { - private TreeNode me; - boolean success; - StopNotify(TreeNode n, boolean success){ - me = n; - this.success = success; - } - public Object apply(Object o){ - LogListener ll = (LogListener)o; - ll.deviceFinished(me, success); - return null; - } - } - protected void finish(boolean success){ - if(!success){ - state = ERROR; - } - if(state != ERROR){ - state = OK; - } - FuncUtil.map(new IteratorStream(logListeners), - new StopNotify(this,success)); - } - private class CommandNotify implements IFunc { - private TreeNode me; - private String com; - CommandNotify(TreeNode n, String command){ - me = n; - com = command; - } - public Object apply(Object o){ - LogListener ll = (LogListener)o; - ll.commandSent(me, com); - return null; - } - } - protected void commandNotify(String command){ - /* - FuncUtil.map(new IteratorStream(logListeners), - new CommandNotify(this,command)); - */ - int i; - LogListener ll; - for(i = 0; i < logListeners.size(); i++){ - ll = (LogListener)logListeners.get(i); - ll.commandSent(this,command); - } - } - public boolean isReadOnly() { - return readOnly; - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - notifyState(); - } - class StateNotify implements IFunc { - private TreeNode me; - StateNotify(TreeNode m){ - me = m; - } - public Object apply(Object o){ - UpdateListener ll = (UpdateListener)o; - ll.nodeStatusChanged(me); - return null; - } - } - public void addUpdateListener(UpdateListener l) { - updateListeners.add(l); - } - - public void removeUpdateListener(UpdateListener l) { - updateListeners.remove(l); - } - - protected void notifyState() { - FuncUtil.map(new IteratorStream(updateListeners), new StateNotify(this)); - } - public String getLogBuffer(){ - return logBuffer.toString(); - } - public int getState(){ - return state; - } - public void dispose() { - super.dispose(); - logListeners = null; - updateListeners = null; - logBuffer = null; - } - -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/GraphicsNode.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/GraphicsNode.java deleted file mode 100755 index 05f798f5..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/GraphicsNode.java +++ /dev/null @@ -1,14 +0,0 @@ -package ch.psi.num.mountaingum.tree; - -public class GraphicsNode extends TreeNode { - public GraphicsNode(TreeNode p, String name){ - super(p,name); - p.setProperty("viewer","default"); - } - public void setDisplayKey(String editor){ - p.setProperty("viewer", editor); - } - public String getDisplayKey(){ - return p.getProperty("viewer"); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/IntValue.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/IntValue.java deleted file mode 100755 index 63ebfb38..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/IntValue.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * This is a node representing integer data. We do some lazy evaluation - * here: i.e. data gets converted from text to array or from array to text - * only when requested. Please note that client code is responsible for - * adapting dimensions for the case of variable length arrays. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; -import ch.psi.num.mountaingum.util.DynamicIntArray; - -public class IntValue extends NodeValue { - protected DynamicIntArray data; - protected boolean arrayDirty; - protected boolean textDirty; - - public IntValue(int rank, int dim[]){ - this.type = INT; - this.rank = rank; - this.dim = dim; - textData = new String("0"); - data = new DynamicIntArray(); - textDirty = false; - } - - public void setFromString(String data){ - super.setFromString(data); - arrayDirty = true; - textDirty = false; - } - public String toString(){ - if(textDirty){ - textData = data.toString(); - textDirty = false; - } - return textData; - } - public void setDim(int dim[]){ - super.setDim(dim); - arrayDirty = true; - textDirty = true; - } - public int getLength(){ - return data.getLength(); - } - public int[] getData(){ - if(arrayDirty){ - data.setFromText(textData.trim()); - arrayDirty = false; - } - return data.getData(); - } - public int getValue(int idx){ - if(arrayDirty){ - data.setFromText(textData.trim()); - arrayDirty = false; - } - return data.getValue(idx); - } - public void setData(int data[]){ - this.data.reset(); - this.data.append(data); - textDirty = true; - } - public void append(int i){ - data.append(i); - textDirty = true; - } - public void append(double d){ - data.append((int)Math.abs(d)); - textDirty = true; - } - public void append(long i){ - data.append((int)i); - textDirty = true; - } - - public void reset() { - super.reset(); - data.reset(); - } - public int[] getRawData(){ - return data.getRawArray(); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/InternalParameter.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/InternalParameter.java deleted file mode 100755 index e71fd39f..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/InternalParameter.java +++ /dev/null @@ -1,25 +0,0 @@ -package ch.psi.num.mountaingum.tree; - -public class InternalParameter extends ParameterNode { - - public InternalParameter(TreeNode p, String name){ - super(p,name); - } - public void setValue(String val) { - v.setFromString(val); - notifyUpdate(); - } - public void updateValue(NodeValue v) { - this.v = v; - notifyUpdate(); - } - public void enqueueValue(String v) { - // Nothing to do.... - } - public void queryValue() { - /* - * As this is an internal parameter, we cannot ask - * any underlying system to do something for us. - */ - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/LogListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/LogListener.java deleted file mode 100755 index d86818d4..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/LogListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * An interface for receiving logging data on active nodes. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -public interface LogListener { - /** - * called when the node started processing - * It shall clear any old log buffers. When required - * @param node The node which started - */ - public void deviceStarted(TreeNode node); - /** - * add runtime log information - * @param node The node from which this data is coming - * @param txt The actual logging data - * @param success A flag which determines if the node is in error - * or is still OK - */ - public void addLogData(TreeNode node, String txt, boolean success); - /** - * called to notfy termination of a device - * @param node The node from which the message originated - * @param success A flag determining if the operation was a - * success or not. - */ - public void deviceFinished(TreeNode node, boolean success); - /** - * Notification of a command being sent to the underlying system. - * Makes only sense in systems which work with commands. - * @param tn The TreeNode sending the command - * @param command The command sent - */ - public void commandSent(TreeNode tn, String command); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/LongValue.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/LongValue.java deleted file mode 100755 index 454a5eb1..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/LongValue.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * This is value class for long ints. - * - * copyright: GPL - * - * Mark Koennecke, February 2008 - */ -package ch.psi.num.mountaingum.tree; - -import ch.psi.num.mountaingum.util.DynamicLongArray; - -public class LongValue extends NodeValue { - protected DynamicLongArray data; - protected boolean arrayDirty; - protected boolean textDirty; - - public LongValue(int rank, int dim[]){ - this.type = INT; - this.rank = rank; - this.dim = dim; - textData = new String("0"); - data = new DynamicLongArray(); - textDirty = false; - } - - public void setFromString(String data){ - super.setFromString(data); - arrayDirty = true; - textDirty = false; - } - public String toString(){ - if(textDirty){ - textData = data.toString(); - textDirty = false; - } - return textData; - } - public void setDim(int dim[]){ - super.setDim(dim); - arrayDirty = true; - textDirty = true; - } - public int getLength(){ - return data.getLength(); - } - public long[] getData(){ - if(arrayDirty){ - data.setFromText(textData.trim()); - arrayDirty = false; - } - return data.getData(); - } - public long getValue(int idx){ - return data.getValue(idx); - } - public void setData(long data[]){ - this.data.reset(); - this.data.append(data); - textDirty = true; - } - public void append(long i){ - data.append(i); - textDirty = true; - } - public void append(double d){ - data.append((long)Math.abs(d)); - textDirty = true; - } - public void append(int i){ - data.append((long)i); - textDirty = true; - } - public long[] getRawData(){ - return data.getRawArray(); - } - - public void reset() { - super.reset(); - data.reset(); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeListListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeListListener.java deleted file mode 100755 index e88cef58..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeListListener.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This defines a listener for the case when a node list has been changed. - * See TreeNodeList.java for more details. - * - * copyright: GPL - * - * Mark Koennecke, August 2007 - */ -package ch.psi.num.mountaingum.tree; - -public interface NodeListListener { - public void nodeListChanged(TreeNodeList l); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeSearchFunc.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeSearchFunc.java deleted file mode 100755 index b337f4c3..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeSearchFunc.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This is a function used when searhing for child nodes - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -import ch.psi.num.mountaingum.func.IFunc; - -public class NodeSearchFunc implements IFunc { - private String name; - - public NodeSearchFunc(String name){ - this.name = name; - } - public Object apply(Object o) { - TreeNode n = (TreeNode)o; - if(name.equalsIgnoreCase(n.getName())){ - return n; - } - return null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeValue.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeValue.java deleted file mode 100755 index 600ed17b..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/NodeValue.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * This is the class representing the value of a parameter node - * in MountainGum. Incidentally it is also the node for text data. - * Further subclasses support integer and float data. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -public class NodeValue { - /** - * type codes - */ - public final static int TEXT = 0; - public final static int INT = 1; - public final static int FLOAT = 2; - public final static int LONG = 3; - - protected int type; - protected int rank; - protected int dim[]; - protected String textData; - - public NodeValue(){ - type = TEXT; - rank = 1; - dim = new int[1]; - dim[0] = 0; - } - public NodeValue(int type, int rank, int dim[]){ - this.type = type; - this.rank = rank; - this.dim = dim; - textData = new String("Undefined"); - } - - public String toString(){ - return textData; - } - - public void setFromString(String data){ - textData = data; - } - - public int getType() { - return type; - } - - public int getRank() { - return rank; - } - - public int[] getDim() { - return dim; - } - - public void setDim(int[] dim) { - this.dim = dim; - } - protected boolean testWhiteSpace(String text){ - int i; - - for(i = 0; i < text.length(); i++){ - if(!Character.isWhitespace(text.charAt(i))){ - return false; - } - } - return true; - } - public int getLength(){ - return 1; - } - public void reset(){ - textData = "Undefined"; - } - /** - * These appends make most sense for numbers, not for strings, what this - * really is. - * @param i - */ - public void append(int i){ - textData = Integer.toString(i); - } - public void append(double i){ - textData = Double.toString(i); - } - public void append(long i){ - textData = Long.toString(i); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ParameterNode.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ParameterNode.java deleted file mode 100755 index c2a462cd..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/ParameterNode.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This is a node representing a parameter. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -import ch.psi.num.mountaingum.batch.BatchAdapter; -import ch.psi.num.mountaingum.func.FuncUtil; -import ch.psi.num.mountaingum.func.IFunc; -import ch.psi.num.mountaingum.func.IteratorStream; -import ch.psi.num.mountaingum.sys.SysRegistry; - -public abstract class ParameterNode extends ExecutableNode { - protected NodeValue v; - protected boolean initialized; - - public boolean isInitialized() { - return initialized; - } - public ParameterNode(TreeNode p, String name){ - super(p,name); - v = new NodeValue(); - readOnly = false; - initialized = false; - } - abstract public void setValue(String val); - public void enqueueValue(String val){ - BatchAdapter ba = SysRegistry.getBatchAdapter(); - ParameterNode pn = (ParameterNode)ba.cloneBatchNode(this); - pn.getValue().setFromString(val); - ba.append(pn); - } - abstract public void queryValue(); - public void updateValue(String v){ - this.v.setFromString(v); - initialized = true; - } - - public NodeValue getValue(){ - return v; - } - private class UpdateNotify implements IFunc { - private TreeNode me; - UpdateNotify(TreeNode m){ - me = m; - } - public Object apply(Object o){ - UpdateListener ll = (UpdateListener)o; - ll.nodeUpdated(me); - return null; - } - } - public void notifyUpdate(){ - initialized = true; - FuncUtil.map(new IteratorStream(updateListeners), new UpdateNotify(this)); - } - public void configure(int type, int rank, int dim[]){ - v = TreeUtil.makeNodeValue(type, rank, dim); - } - public void dispose() { - super.dispose(); - v = null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/PropertySearchFunc.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/PropertySearchFunc.java deleted file mode 100755 index 8c2c0ba2..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/PropertySearchFunc.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This is a node processor which searches for a given property - * with a given value. - * - * copyright: GPL - * - * Mark Koennecke, November 2008 - */ -package ch.psi.num.mountaingum.tree; - -import ch.psi.num.mountaingum.func.IFunc; - -public class PropertySearchFunc implements IFunc { - private String key, value; - - public PropertySearchFunc(String k, String v){ - key = k; - value = v; - } - - public Object apply(Object o) { - TreeNode n = (TreeNode)o; - String myValue = n.getProperty(key); - if(myValue != null){ - if(myValue.compareToIgnoreCase(value) == 0){ - return o; - } - } - return null; - } - -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeListener.java deleted file mode 100755 index 420a65ab..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeListener.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * a lsitener for changes to the tree structure - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -public interface TreeListener { - public void treeStructureChanged(TreeNode parent); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeNode.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeNode.java deleted file mode 100755 index ffc227e9..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeNode.java +++ /dev/null @@ -1,298 +0,0 @@ -/** - * The representation of a basic node in the tree - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; -import java.util.Properties; -import java.util.LinkedList; -import ch.psi.num.mountaingum.func.*; - -public class TreeNode { - public final static int APPEND = -10; - public final static int PREPEND = -1; - - protected TreeNode parent; - protected TreeNode babies; - protected TreeNode previous, next; - protected boolean hidden; - - protected Properties p; - - LinkedList treeListeners; - - public TreeNode(TreeNode mama, String name){ - this.parent = mama; - babies = null; - previous = next = null; - p = new Properties(); - p.setProperty("name", name); - treeListeners = new LinkedList(); - hidden = false; - } - /** - * node insertion - * @param where to insert - * @param child node to insert - */ - public void insertNode(int where, TreeNode child){ - TreeNode current = babies; - int count = 0; - - if(babies == null){ - babies = child; - child.previous = null; - child.next = null; - return; - } - - - child.setParent(this); - switch(where){ - case PREPEND: - child.next = babies; - babies.previous = child; - babies = child; - break; - case APPEND: - while(current.next != null){ - current = current.next; - } - child.next = null; - child.previous = current; - current.next = child; - break; - default: - while(current.next != null && count < where){ - current = current.next; - count++; - } - child.next = current.next; - child.previous = current; - current.next = child; - break; - } - } - /** - * count children - * @return number of children - */ - public int countChildren(){ - TreeNode current = babies; - int count = 0; - while(current != null){ - count++; - current = current.next; - } - return count; - } - /** - * return child at idx - * @param idx index of child - * @return null when found, TreeNod else - */ - public TreeNode getChild(int idx){ - int count = 0; - TreeNode current = babies; - while(current != null && count < idx){ - current = current.next; - count++; - } - return current; - } - /* - * remove all children of this node - */ - public void deleteChildren(){ - babies = null; - } - public void deleteChild(TreeNode tn){ - if(tn == null){ - return; - } - - if(tn == babies){ - babies = tn.next; - tn.next.previous = null; - return; - } - - TreeNode prev = tn.previous; - TreeNode next = tn.next; - if(prev != null){ - prev.next = next; - } - if(next != null){ - next.previous = prev; - } - tn = null; - } - /** - * get the parent of this node - * @return A parent, can be null when root node - */ - public TreeNode getParent() { - return parent; - } - /** - * set parent of node - * @param parent new parent - */ - public void setParent(TreeNode parent) { - this.parent = parent; - } - /** - * set a node property - * @param key name of property - * @param value value of property - */ - public void setProperty(String key, String value){ - p.setProperty(key, value); - } - public void removeProperty(String key){ - p.remove(key); - } - /** - * get a property - * @param key The key of the property to find - * @return a value or null - */ - public String getProperty(String key){ - return p.getProperty(key); - } - /** - * get the node name - * @return The name of the node - */ - public String getName(){ - return p.getProperty("name"); - } - /** - * add a TreeListener - * @param l The listener to add - */ - public void addTreeListener(TreeListener l){ - treeListeners.add(l); - } - /** - * remove a TreeListener - * @param l The TreeListener to remove - */ - public void removeTreeListener(TreeListener l){ - treeListeners.remove(l); - } - private class TreeNotify implements IFunc { - TreeNode me; - - public TreeNotify(TreeNode n){ - me = n; - } - public Object apply(Object o){ - TreeListener l = (TreeListener)o; - l.treeStructureChanged(me); - return null; - } - }; - public void notifyTreeListeners(){ - FuncUtil.map(new ArrayStream(treeListeners.toArray()), new TreeNotify(this)); - } - private class TreeStream implements IStream { - private TreeNode parent, current; - private boolean start; - public TreeStream(TreeNode parent){ - this.parent = parent; - current = parent; - start = true; - } - public Object next(){ - TreeNode n = current; - - if(current == parent && start == true){ - start = false; - current = babies; - return n; - } - if(current == null){ - return null; - } - /* - * if there are babies go into them - */ - if(current.babies != null){ - current = current.babies; - return n; - } - /** - * if no more babies, go to next node - */ - if(current.next != null){ - current = current.next; - } else { - /* move up: - * there are two conditions here: if current becomes the - * parent again we are finished.If there is no sibling one - * up we have to go up further until we find siblings - */ - do{ - current = current.parent; - }while(current != null && current.next == null); - if(current == null || current == parent){ - current = null; - } else { - current = current.next; - } - } - return n; - } - } - /** - * get a stream to process all child nodes, recursively - * @return A suitable stream for operating on all sub nodes. - */ - public IStream getTreeStream(){ - return new TreeStream(this); - } - private class CopyProp implements IFunc{ - private TreeNode target; - CopyProp(TreeNode target){ - this.target = target; - } - public Object apply(Object o) { - String name = (String)o; - String val = p.getProperty(name); - target.setProperty(name, val); - return null; - } - } - public void copyProperties(TreeNode target){ - FuncUtil.map(new EnumerationStream(p.propertyNames()), new CopyProp(target)); - } - public boolean isHidden() { - return hidden; - } - public void setHidden(boolean hidden) { - this.hidden = hidden; - } - public String toString() { - return getProperty("name"); - } - public void dispose(){ - TreeNode son, tmp; - - parent = null; - treeListeners = null; - p = null; - - son = babies; - while(son != null){ - son.dispose(); - tmp = son.next; - son.previous = null; - son.next = null; - son = tmp; - } - babies = null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeNodeList.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeNodeList.java deleted file mode 100755 index 950fcad1..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeNodeList.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is an abstract class which maintains a list of nodes which fulfill - * some condition which derived classes define through their implementation of - * the abstract method test(). This class registers to the whole subtree - * to be searched as a TreeChangeListener. When the tree changes the list - * of nodes is updated and all NodeListListeners are updated. This class - * was invented to maintain the list of all drivables, but it can be put to - * other uses as well. - * - * copyrigth: GPL - * - * Mark Koennecke, August 2007 - */ -package ch.psi.num.mountaingum.tree; - -import java.util.LinkedList; - -import ch.psi.num.mountaingum.func.FuncUtil; -import ch.psi.num.mountaingum.func.IFunc; -import ch.psi.num.mountaingum.func.IStream; -import ch.psi.num.mountaingum.func.IteratorStream; - -public abstract class TreeNodeList implements TreeListener { - protected String searchPath; - protected LinkedList nodeList; - protected LinkedList listListeners; - - public TreeNodeList(String sp){ - searchPath = sp; - nodeList = new LinkedList(); - listListeners = new LinkedList(); - TreeNode root = TreeRegistry.getInstance().getRoot(); - root.addTreeListener(this); - treeStructureChanged(root); - } - - protected abstract boolean test(TreeNode n); - - private class TestNode implements IFunc { - - public Object apply(Object o) { - TreeNode n = (TreeNode)o; - if(test(n)){ - nodeList.add(n); - } - n.removeTreeListener(TreeNodeList.this); - n.addTreeListener(TreeNodeList.this); - return null; - } - - } - public void treeStructureChanged(TreeNode parent) { - TreeNode root = TreeUtil.nodeForPath(searchPath); - if(root != null){ - nodeList.clear(); - FuncUtil.map(root.getTreeStream(), new TestNode()); - notifyListeners(); - } - } - public void addNodeListListener(NodeListListener l){ - listListeners.add(l); - } - public void removeNodeListListener(NodeListListener l){ - listListeners.remove(l); - } - public IStream getNodeStream(){ - return new IteratorStream(nodeList); - } - private class InvokeListener implements IFunc { - - public Object apply(Object o) { - NodeListListener l = (NodeListListener)o; - l.nodeListChanged(TreeNodeList.this); - return null; - } - } - private void notifyListeners() { - FuncUtil.map(new IteratorStream(listListeners), new InvokeListener()); - } - - public String getSearchPath() { - return searchPath; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeRegistry.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeRegistry.java deleted file mode 100755 index ca83c673..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeRegistry.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This is a central registry for Tree related things and editors and - * displays to use with TreeNodes. This is a singleton. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; -import java.util.HashMap; - - -public class TreeRegistry { - private static TreeRegistry instance; - private TreeNode root; - private HashMap pathRegistry; - private HashMap nodeListRegistry; - - private TreeRegistry(){ - root = new TreeNode(null,""); - root.insertNode(TreeNode.APPEND, new TreeNode(root,"Not_connected")); - pathRegistry = new HashMap(); - nodeListRegistry = new HashMap(); - } - - public static TreeRegistry getInstance(){ - if(instance == null){ - instance = new TreeRegistry(); - } - return instance; - } - public TreeNode getRoot(){ - return root; - } - public void registerEditorPath(String editor, String path){ - pathRegistry.put(editor, path); - } - public String getEditorPath(String editor){ - return (String)pathRegistry.get(editor); - } - public void registerNodeList(String key, TreeNodeList l){ - nodeListRegistry.put(key, l); - } - public void removeNodeList(String key){ - nodeListRegistry.remove(key); - } - public TreeNodeList getNodeList(String key){ - return (TreeNodeList)nodeListRegistry.get(key); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeUtil.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeUtil.java deleted file mode 100755 index d7cd6186..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/TreeUtil.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * This is a class with various utility functions for helping out with trees. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - * - * Added nodeForProperty, Mark Koennecke, November 2008 - */ -package ch.psi.num.mountaingum.tree; -import java.util.StringTokenizer; -import java.util.List; -import java.util.LinkedList; -import java.util.Collections; -import java.util.Iterator; -import ch.psi.num.mountaingum.func.*; -import ch.psi.num.mountaingum.sys.SysRegistry; - -public class TreeUtil { - public static NodeValue makeNodeValue(int type, int rank, int dim[]){ - NodeValue v; - switch(type) { - case NodeValue.INT: - v = new IntValue(rank,dim); - break; - case NodeValue.LONG: - v = new LongValue(rank,dim); - break; - case NodeValue.FLOAT: - v = new DoubleValue(rank,dim); - break; - default: - v = new NodeValue(NodeValue.TEXT,rank,dim); - break; - } - return v; - } - public static TreeNode nodeForPath(String path){ - return searchNode(TreeRegistry.getInstance().getRoot(),path); - } - public static TreeNode searchNode(TreeNode parent, String path){ - TreeNode current = null; - String name; - List l; - - StringTokenizer st = new StringTokenizer(path,"/",false); - current = parent; - while(st.hasMoreElements()){ - name = st.nextToken(); - NodeSearchFunc f = new NodeSearchFunc(name); - l = FuncUtil.map(new ChildStream(current), f); - if(l.isEmpty()){ - return null; - } else { - current = (TreeNode)l.get(0); - } - } - return current; - } - public static String pathForNode(TreeNode n){ - String name; - StringBuffer path = new StringBuffer(); - - if(n.getParent() == null){ - return "/"; - } - - LinkedList l = new LinkedList(); - while(n != null){ - l.add(n.getName()); - n = n.getParent(); - } - Collections.reverse(l); - Iterator it = l.iterator(); - while(it.hasNext()){ - name = (String)it.next(); - if(name.length() > 0){ - path.append("/"); - path.append(name); - } - } - return path.toString(); - } - public static TreeNode findChild(TreeNode parent, String name){ - ChildStream cs = new ChildStream(parent); - TreeNode tn; - String testName; - - while((tn = (TreeNode)cs.next()) != null){ - testName = tn.getName(); - if(testName.equalsIgnoreCase(name)){ - return tn; - } - } - return null; - } - public static double[] getNodeValueAsDouble(ParameterNode p){ - NodeValue v = p.getValue(); - int i; - switch(v.getType()){ - case NodeValue.TEXT: - return null; - case NodeValue.INT: - IntValue iv = (IntValue)v; - int idata[] = iv.getData(); - double d[] = new double[idata.length]; - for(i = 0; i < idata.length; i++){ - d[i] = (double)idata[i]; - } - return d; - case NodeValue.LONG: - LongValue lv = (LongValue)v; - long ldata[] = lv.getData(); - double dl[] = new double[ldata.length]; - for(i = 0; i < ldata.length; i++){ - dl[i] = (double)ldata[i]; - } - return dl; - case NodeValue.FLOAT: - DoubleValue fv = (DoubleValue)v; - return fv.getData(); - default: - SysRegistry.getLogger().debug("getNodeValueAsDouble called with bad type code"); - return null; - } - } - public static double getNodeValue(ParameterNode pn, int idx){ - NodeValue v = pn.getValue(); - switch(v.getType()){ - case NodeValue.INT: - IntValue iv = (IntValue)v; - if(iv.getLength()-1 <= idx){ - return (double)iv.getValue(idx); - } else { - return -9999.99; - } - case NodeValue.LONG: - LongValue lv = (LongValue)v; - if(lv.getLength()-1 <= idx){ - return (double)lv.getValue(idx); - } else { - return -9999.99; - } - case NodeValue.FLOAT: - DoubleValue fv = (DoubleValue)v; - if(fv.getLength()-1 <= idx){ - return fv.getValue(idx); - } else { - return -9999.99; - } - } - return -9999.99; - } - public static void copyNodeValue(ParameterNode source, ParameterNode target) { - NodeValue nvs = source.getValue(); - NodeValue nvt = target.getValue(); - if(nvs.getType() != nvt.getType()){ - SysRegistry.getLogger().debug("Type mismatch while trying to copy node values"); - return; - } - switch(nvs.getType()){ - case NodeValue.FLOAT: - DoubleValue ds = (DoubleValue)nvs; - DoubleValue dt = (DoubleValue)nvt; - dt.setData(ds.getData()); - break; - case NodeValue.INT: - IntValue ids = (IntValue)nvs; - IntValue idt = (IntValue)nvt; - idt.setData(ids.getData()); - break; - case NodeValue.LONG: - LongValue lds = (LongValue)nvs; - LongValue ldt = (LongValue)nvt; - ldt.setData(lds.getData()); - break; - case NodeValue.TEXT: - nvt.setFromString(nvs.toString()); - break; - } - target.notifyUpdate(); - } - public static void copyNodeValueToDouble(ParameterNode node, double[] data) { - NodeValue v = node.getValue(); - int i; - switch(v.getType()){ - case NodeValue.TEXT: - break; - case NodeValue.INT: - IntValue iv = (IntValue)v; - int idata[] = iv.getRawData(); - for(i = 0; i < Math.min(idata.length, data.length); i++){ - data[i] = (double)idata[i]; - } - break; - case NodeValue.LONG: - LongValue lv = (LongValue)v; - long ldata[] = lv.getRawData(); - for(i = 0; i < Math.min(ldata.length, data.length); i++){ - data[i] = (double)ldata[i]; - } - break; - case NodeValue.FLOAT: - DoubleValue fv = (DoubleValue)v; - double ddata[] = fv.getRawData(); - System.arraycopy(ddata, 0, data, 0, data.length); - break; - default: - SysRegistry.getLogger().debug("copyNodeValueToDouble called with bad type code"); - break; - } - } - public static TreeNode nodeForProperty(TreeNode parent, String key, String value){ - PropertySearchFunc prs = new PropertySearchFunc(key,value); - List l = FuncUtil.map(parent.getTreeStream(), prs); - if(l.isEmpty()){ - return null; - } else { - return (TreeNode)l.get(0); - } - } - /* - * make a copy of the hierarchy under and including source consisting of - * InternalParameter Nodes. - * @param source The node to copy - * @result A copy of the subtree including source - */ - public static TreeNode privateDeepCopy(TreeNode source){ - InternalParameter result = null; - TreeNode child, myChild; - ParameterNode p; - - result = new InternalParameter(null, source.getName()); - if(source instanceof ParameterNode){ - p = (ParameterNode) source; - result.setValue(p.getValue().toString()); - } - source.copyProperties(result); - ChildStream children = new ChildStream(source); - while((child = (TreeNode)children.next()) != null){ - myChild = privateDeepCopy(child); - result.insertNode(TreeNode.APPEND, myChild); - } - return result; - } - /** - * locate the root of the hierarchy. - * @param in The node to start the search from - * @return The root node - */ - public static TreeNode findRoot(TreeNode in){ - TreeNode cur = in; - while(cur.getParent() != null){ - cur = cur.getParent(); - } - return cur; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/UpdateListener.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/UpdateListener.java deleted file mode 100755 index a18167ad..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/tree/UpdateListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * An interface for receiving updates about the node status. - * - * copyright: GPL - * - * Mark Koennecke, June 2007 - */ -package ch.psi.num.mountaingum.tree; - -public interface UpdateListener { - /** - * called when the node has new data - * @param n The TreeNode which had been updated. - */ - public void nodeUpdated(TreeNode n); - /** - * called when the node status changed: i.e. from readonly to editable - * etc. This may happen after a privilege change - * @param node The TreeNode whose state changed. - */ - public void nodeStatusChanged(TreeNode node); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/DataRange.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/DataRange.java deleted file mode 100755 index 7a4a0dd0..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/DataRange.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * This is just a little class for holding the range of a data set. - * - * copyright: GPL - * - * Mark Koennecke, August 2007 - */ -package ch.psi.num.mountaingum.ui; - -public class DataRange { - public double min, max; - - public DataRange(){ - min = Double.MAX_VALUE; - max = Double.MIN_VALUE; - } - public void calculate(double d[]){ - min = Double.MAX_VALUE; - max = -min; - for(int i = 0; i < d.length; i++){ - if(d[i] < min){ - min = d[i]; - } - if(d[i] > max){ - max = d[i]; - } - } - } - public boolean isValid(){ - if(min == Double.MAX_VALUE || max == Double.MIN_VALUE){ - return false; - } - return true; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/Graph.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/Graph.java deleted file mode 100755 index 242ec9c2..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/Graph.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This abstract class implements some of the plumbing required to update - * a graph when either the axis or the data associated with it changes. This - * together with GrapData and GraphAxis. Derived classes are supposed to - * implement makePlot() and changeData() - * - * copyright: GPL - * - * Mark Koennecke, August 2007 - */ -package ch.psi.num.mountaingum.ui; - -import java.util.HashMap; -import java.util.Iterator; - -import ch.psi.num.mountaingum.func.FuncUtil; -import ch.psi.num.mountaingum.func.IFunc; -import ch.psi.num.mountaingum.func.IteratorStream; - -public abstract class Graph { - protected GraphAxis xAxis; - protected GraphAxis yAxis; - protected HashMap data; - - public Graph(){ - data = new HashMap(); - xAxis = null; - yAxis = null; - } - /** - * makePlot is supposed to redraw the entire plot, axis, data - * and all from scratch. It is called after major changes, such as - * changes to axis or styles have been detected. - */ - public abstract void makePlot(); - /** - * changeData is called when only the plotted data is changed but - * nothing else. This ought to replace only the data, but it may call - * makePlot when the underlying graphics system does not support the - * exchange of the plot data only. - */ - public abstract void changeData(GraphData g); - public GraphAxis getXAxis() { - return xAxis; - } - public void setXAxis(GraphAxis axis) { - xAxis = axis; - xAxis.setGraph(this); - } - public GraphAxis getYAxis() { - return yAxis; - } - public void setYAxis(GraphAxis axis) { - yAxis = axis; - yAxis.setGraph(this); - } - public void addData(GraphData gd){ - gd.setGraph(this); - data.put(gd.getName(), gd); - } - public GraphData getData(String name){ - return (GraphData)data.get(name); - } - public void clearAll(){ - data.clear(); - } - public DataRange getMaxDataRange(){ - DataRange res = new DataRange(); - DataRange cur; - GraphData gd = null; - - IteratorStream it = new IteratorStream(data.values()); - while((gd = (GraphData)it.next()) != null){ - cur = gd.getDataRange(); - if(cur.max > res.max){ - res.max = cur.max; - } - if(cur.min < res.min){ - res.min = cur.min; - } - } - return res; - } - private class DataUpdate implements IFunc { - - public Object apply(Object o) { - GraphData gd = (GraphData)o; - if(gd != null){ - gd.getNode().queryValue(); - } - return null; - } - - } - public boolean isValid() { - if(xAxis == null || data.isEmpty()){ - return false; - } - DataRange dr = xAxis.getDataRange(); - return dr.isValid(); - } - public void refresh(){ - if(xAxis != null){ - xAxis.getNode().getValue(); - } - if(yAxis != null){ - yAxis.getNode().getValue(); - } - FuncUtil.map(new IteratorStream(data.values()), new DataUpdate()); - } - public void dispose() { - Iterator it = data.values().iterator(); - while(it.hasNext()){ - GraphData dg = (GraphData)it.next(); - try{ - dg.finalize(); - }catch(Throwable t){} - } - data = null; - xAxis = null; - yAxis = null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/GraphAxis.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/GraphAxis.java deleted file mode 100755 index 6230d427..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/GraphAxis.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This holds data for an Axis. It watches over log axis and makes the - * plot redraw ehen the data on the watcehd node changes. - * - * copyright: GPL - * - * Mark Koennecke, August 2007 - */ -package ch.psi.num.mountaingum.ui; - -import ch.psi.num.mountaingum.tree.ParameterNode; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.tree.TreeUtil; - -public class GraphAxis extends GraphData { - - protected boolean log; - public GraphAxis(String name, ParameterNode p) { - super(name, p); - log = false; - } - public boolean isLog() { - return log; - } - public void setLog(boolean log) { - this.log = log; - if(graph != null){ - graph.makePlot(); - } - } - public void nodeUpdated(TreeNode n){ - //System.out.println(name + " updated "); - if(graph != null){ - graph.makePlot(); - } - } - public String getAxisName(){ - ParameterNode pn = (ParameterNode)TreeUtil.findChild(node,"name"); - if(pn != null){ - return pn.getValue().toString(); - } else { - return node.getName(); - } - } - public int findIndex(double value){ - int i; - //TODO: fix up for descending axis - getData(); - for(i = 1; i < data.length; i++){ - if(data[i] > value){ - return i - 1; - } - } - return data.length-1; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/GraphData.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/GraphData.java deleted file mode 100755 index d4a79b5f..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/GraphData.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * This class manages the data associated with a graphical component: i.e, - * axis data or the data to be plotted. - * - * copyright: GPL - * - * Mark Koennecke, August 2007 - * - * Copying arrays all the time introduced reference leaks. Thus this - * was rewritten to maintain a local copy of the node data for the - * graphics and copy data from the node on each request. A local - * copy of the data is required as the plot logic may require to - * modify data. And if you do not allocate memory, it cannot - * leak! - * - * Mark Koennecke, June 2008 - */ -package ch.psi.num.mountaingum.ui; - - -import ch.psi.num.mountaingum.sys.SysRegistry; -import ch.psi.num.mountaingum.tree.ParameterNode; -import ch.psi.num.mountaingum.tree.TreeNode; -import ch.psi.num.mountaingum.tree.TreeUtil; -import ch.psi.num.mountaingum.tree.UpdateListener; - -public class GraphData implements UpdateListener { - protected Graph graph; - protected String name; - protected ParameterNode node; - protected Object style; - protected double data[]; - - public GraphData(String name, ParameterNode p){ - this.name = name; - style = null; - node = p; - graph = null; - node.addUpdateListener(this); - data = null; - } - - public void nodeStatusChanged(TreeNode node) { - // nothing to do here - } - - public void nodeUpdated(TreeNode n) { - if(graph != null){ - SysRegistry.getLogger().debug("GraphData received new data"); - //System.out.println("GraphData received new data"); - graph.changeData(this); - } - } - public double[] getData(){ - if(data == null || node.getValue().getLength() != data.length){ - data = new double[node.getValue().getLength()]; - } - TreeUtil.copyNodeValueToDouble(node, data); - return data; - } - public double getDataValue(int idx){ - if(data == null){ - getData(); - } - return data[idx]; - } - /** - * when plotting logarithmically, values below or equal to zero - * fuck up. This fixes this. - * @return A spick and spank data set ready for log plotting. - */ - public double[] getDataLogWashed(){ - getData(); - for(int i = 0; i < data.length; i++){ - if(data[i] <= .0){ - data[i] = .1; - } - } - return data; - } - public Graph getGraph() { - return graph; - } - - public DataRange getDataRange(){ - DataRange dr = new DataRange(); - double d[] = getData(); - if(d != null){ - dr.calculate(d); - } - d = null; - return dr; - } - public int getDataLength(){ - return node.getValue().getLength(); - } - public void setGraph(Graph graph) { - this.graph = graph; - } - - public Object getStyle() { - return style; - } - - public void setStyle(Object style) { - this.style = style; - if(graph != null){ - graph.makePlot(); - } - } - - public String getName() { - return name; - } - - public String getAxisName(){ - ParameterNode pn = (ParameterNode)TreeUtil.findChild(node,"name"); - if(pn != null){ - return pn.getValue().toString(); - } else { - return name; - } - } - - public int findIndex(double val){ - int res = 0; - if(data == null){ - return 0; - } - while(data[res] < val && res < data.length -1){ - res++; - } - return res; - } - public ParameterNode getNode() { - return node; - } - public String getTitle(){ - ParameterNode pn = (ParameterNode)TreeUtil.findChild(node.getParent(), "title"); - if(pn != null){ - return pn.getValue().toString(); - } else { - return node.getParent().getName(); - } - } - public double getValue(int pos[]){ - if(data == null){ - getData(); - } - return data[pos[0]]; - } - public void finalize() throws Throwable { - data = null; - graph = null; - node = null; - //System.out.println("Killing GraphData.." ); - super.finalize(); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/UIAdapter.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/UIAdapter.java deleted file mode 100755 index 58c22564..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/UIAdapter.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This is the adapter to the UI lower level code may use. Currently - * there is not much except displaying an error. This is the default - * implementation. Applications may choose to override this and set an - * improved instance at the UIRegistry. - * - * copyright: GPL - * - * Mark Koennecke, July 2007 - */ -package ch.psi.num.mountaingum.ui; - -import ch.psi.num.mountaingum.sys.SysRegistry; - -public class UIAdapter { - public void displayError(String txt){ - SysRegistry.getLogger().error(txt); - } - public void runInUIThread(Runnable r){ - SysRegistry.getLogger().error("Running in UI Thread not implemented"); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/UIRegistry.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/UIRegistry.java deleted file mode 100755 index 44fe3be9..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/ui/UIRegistry.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * A static class to access and adpater to the UI. To be used by lower level code. - * - * copyright: GPL - * - * Mark Koennecke, July 2007 - */ -package ch.psi.num.mountaingum.ui; - -public class UIRegistry { - private static UIAdapter adapter = null; - - public static void setAdapter(UIAdapter a){ - adapter = a; - } - public static UIAdapter getAdapter(){ - if(adapter == null){ - adapter = new UIAdapter(); - } - return adapter; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Array2DUtil.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Array2DUtil.java deleted file mode 100755 index f3745510..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Array2DUtil.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * This is a utility class for defining some array manipulation methods. This will be - * used to rotate, mirror or otherwise manipulate 2D arrays in order to create an image - * which satisfies the instrument scientists. Please note that I usally work with 1D - * arrays which in reality are 2D arrays. - * - * copyright: see file COPYRIGHT - * - * Mark Koennecke, March 2007 - */ -package ch.psi.num.mountaingum.util; - -public class Array2DUtil { - /* - * rotate the array by 90 degree which is synonymous with swapping - * the dimensions. - * @param src The source array with dims oriXdim, oriYDim - * @param target The target array where the data will be oriYDim, oriXdim - * @param oriXdim the xsize of src - * @param oriYdim the ysize of src. - */ - public void rotate90(double src[], double target[], int oriXdim, int oriYdim) - throws Exception { - int indSrc, indTarget, x, y; - - if(src.length != target.length){ - throw new Exception("Data size mismatch"); - } - - //System.out.println("Dimensions, x, y: " + oriXdim + ", " + oriYdim); - for(y = 0; y < oriYdim; y++){ - for(x = 0; x < oriXdim; x++){ - indSrc = calcIndex(x,y,oriXdim, oriYdim); - indTarget = calcIndex(y,x,oriYdim, oriXdim); - //System.out.println("Mapping " + indSrc + " to " + indTarget); - target[indTarget] = src[indSrc]; - } - } - } - /* - * mirorY the dimensions. Puts y0 on top ymax to 0 - * @param src The source array with dims oriXdim, oriYDim - * @param target The target array where the data will be mirrored - * @param oriXdim the xsize of src - * @param oriYdim the ysize of src. - */ - public void mirrorY(double src[], double target[], int oriXdim, int oriYdim) - throws Exception { - int indSrc, indTarget, x, y; - - if(src.length != target.length){ - throw new Exception("Data size mismatch"); - } - - for(y = 0; y < oriYdim; y++){ - for(x = 0; x < oriXdim; x++){ - indSrc = calcIndex(x,y,oriXdim, oriYdim); - indTarget = calcIndex(x,oriYdim - y,oriXdim, oriYdim); - target[indTarget] = src[indSrc]; - } - } - } - /* - * mirorX the dimensions. Puts x0 to xmax and vice versa - * @param src The source array with dims oriXdim, oriYDim - * @param target The target array where the data will be mirrored - * @param oriXdim the xsize of src - * @param oriYdim the ysize of src. - */ - public void mirrorX(double src[], double target[], int oriXdim, int oriYdim) - throws Exception { - int indSrc, indTarget, x, y; - - if(src.length != target.length){ - throw new Exception("Data size mismatch"); - } - - for(y = 0; y < oriYdim; y++){ - for(x = 0; x < oriXdim; x++){ - indSrc = calcIndex(x,y,oriXdim, oriYdim); - indTarget = calcIndex(oriXdim - x -1,y,oriXdim, oriYdim); - target[indTarget] = src[indSrc]; - } - } - } - /* - * rotate the array by 90 degree which is synonymous with swapping - * the dimensions. - * @param src The source array with dims oriXdim, oriYDim - * @param target The target array where the data will be oriYDim, oriXdim - * @param oriXdim the xsize of src - * @param oriYdim the ysize of src. - */ - public void rotate90(int src[], int target[], int oriXdim, int oriYdim) - throws Exception { - int indSrc, indTarget, x, y; - - if(src.length != target.length){ - throw new Exception("Data size mismatch"); - } - - //System.out.println("Dimensions, x, y: " + oriXdim + ", " + oriYdim); - for(y = 0; y < oriYdim; y++){ - for(x = 0; x < oriXdim; x++){ - indSrc = calcIndex(x,y,oriXdim, oriYdim); - indTarget = calcIndex(y,x,oriYdim, oriXdim); - //System.out.println("Mapping " + indSrc + " to " + indTarget); - target[indTarget] = src[indSrc]; - } - } - } - /* - * mirorY the dimensions. Puts y0 on top ymax to 0 - * @param src The source array with dims oriXdim, oriYDim - * @param target The target array where the data will be mirrored - * @param oriXdim the xsize of src - * @param oriYdim the ysize of src. - */ - public void mirrorY(int src[], int target[], int oriXdim, int oriYdim) - throws Exception { - int indSrc, indTarget, x, y; - - if(src.length != target.length){ - throw new Exception("Data size mismatch"); - } - - for(y = 0; y < oriYdim; y++){ - for(x = 0; x < oriXdim; x++){ - indSrc = calcIndex(x,y,oriXdim, oriYdim); - indTarget = calcIndex(x,oriYdim - y,oriXdim, oriYdim); - target[indTarget] = src[indSrc]; - } - } - } - /* - * mirorX the dimensions. Puts x0 to xmax and vice versa - * @param src The source array with dims oriXdim, oriYDim - * @param target The target array where the data will be mirrored - * @param oriXdim the xsize of src - * @param oriYdim the ysize of src. - */ - public void mirrorX(int src[], int target[], int oriXdim, int oriYdim) - throws Exception { - int indSrc, indTarget, x, y; - - if(src.length != target.length){ - throw new Exception("Data size mismatch"); - } - - for(y = 0; y < oriYdim; y++){ - for(x = 0; x < oriXdim; x++){ - indSrc = calcIndex(x,y,oriXdim, oriYdim); - indTarget = calcIndex(oriXdim - x -1,y,oriXdim, oriYdim); - target[indTarget] = src[indSrc]; - } - } - } - /** - * make a projection on the x axis - * @param srcData The data to project from - * @param xdim x dimension - * @param ydim y dimension - * @param xstart x index to start projection - * @param xend y index to end projection - * @param ystart y index to starting summing - * @param yend y index of end of summing - */ - public double[] projectX(double srcData[], double projData[], - int xdim, int ydim, int xstart, int xend, - int ystart, int yend){ - int i, j, k, idx; - - int length = xend - xstart; - for(i = xstart, k = 0; i < xend; i++, k++){ - projData[k] = .0; - for(j = ystart; j < yend; j++){ - idx = calcIndex(i,j,xdim,ydim); - projData[k] += srcData[idx]; - } - } - return projData; - } - /** - * make a projection on the Y axis - * @param srcData The data to project from - * @param xdim x dimension - * @param ydim y dimension - * @param xstart x index to start summing - * @param xend y index to end summing - * @param ystart y index to starting projecting - * @param yend y index to end projecting - */ - public double[] projectY(double srcData[], double projData[], - int xdim, int ydim, int xstart, int xend, - int ystart, int yend){ - int i, j, k, idx; - - int length = yend - ystart; - for(i = ystart, k = 0; i < yend; i++, k++){ - projData[k] = .0; - for(j = xstart; j < xend; j++){ - idx = calcIndex(j,i,xdim,ydim); - projData[k] += srcData[idx]; - } - } - return projData; - } - - /** - * calculate the index of a data item in the array - * @param x The x coordinate - * @param y The y coordinate - * @param xdim The x size - * @param ydim The y size - * @return An index into the array. - */ - private int calcIndex(int x, int y, int xdim, int ydim){ - int address = 0; - - address = y * xdim + x; - return address; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/ArrayTools.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/ArrayTools.java deleted file mode 100755 index a0522fa7..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/ArrayTools.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * ArrayTools.java - * Copyright (c) 2004, KTH NADA. - * - * This file is part of SweSum^2 (see http://swesum.nada.kth.se/), - * and 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 2, 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 software; see the file COPYING. If not, see - * http://opensource.org/licenses/gpl-license.php - * - * Martin Hassel, 2004-feb-01 - * http://www.nada.kth.se/~xmartin/ - * - */ - -//package moj.util; -package ch.psi.num.mountaingum.util; - -/** - * A small utility class that contains methods for converting between strings - * and arrays, as well as increasing and decreasing the size of arrays. - * - * @author Martin Hassel - * @version 2004-Oct-18 - */ - -public final class ArrayTools { - - //// String to Array methods //// - - /** - * Converts a string of numbers to a byte array. Observe that a byte - * ranges from -127 to 127 - * - * @param str String of numbers to convert - * @param fieldSeparator String that separates each number - * @return an array of bytes - */ - public static byte[] splitBytes(String str, String fieldSeparator){ - String[] fields = str.split(fieldSeparator); - byte[] tmp = new byte[fields.length]; - for(int i = 0; i < tmp.length; i++) - tmp[i] = Byte.parseByte(fields[i]); - return tmp; - } - - /** - * Converts a string of numbers to a short array - * - * @param str String of numbers to convert - * @param fieldSeparator String that separates each number - * @return an array of shorts - */ - public static short[] splitShorts(String str, String fieldSeparator){ - String[] fields = str.split(fieldSeparator); - short[] tmp = new short[fields.length]; - for(int i = 0; i < tmp.length; i++) - tmp[i] = Short.parseShort(fields[i]); - return tmp; - } - - /** - * Converts a string of numbers to an integer array - * - * @param str String of numbers to convert - * @param fieldSeparator String that separates each number - * @return an array of integers - */ - public static int[] splitInts(String str, String fieldSeparator){ - String[] fields = str.split(fieldSeparator); - int[] tmp = new int[fields.length]; - for(int i = 0; i < tmp.length; i++) - tmp[i] = Integer.parseInt(fields[i]); - return tmp; - } - - /** - * Converts a string of numbers to a long array - * - * @param str String of numbers to convert - * @param fieldSeparator String that separates each number - * @return an array of shorts - */ - public static long[] splitLongs(String str, String fieldSeparator){ - String[] fields = str.split(fieldSeparator); - long[] tmp = new long[fields.length]; - for(int i = 0; i < tmp.length; i++) - tmp[i] = Long.parseLong(fields[i]); - return tmp; - } - - /** - * Convert a string of reals to a float array. - * - * @param str String of numbers to convert - * @param fieldSeparator String that separates each number - * @return an array of floats - */ - public static float[] splitFloats(String str, String fieldSeparator){ - String[] fields = str.split(fieldSeparator); - float[] tmp = new float[fields.length]; - for(int i = 0; i < tmp.length; i++) - tmp[i] = Float.parseFloat(fields[i]); - return tmp; - } - - /** - * Convert a string of reals to a double array. - * - * @param str String of numbers to convert - * @param fieldSeparator String that separates each number - * @return an array of doubles - */ - public static double[] splitDoubles(String str, String fieldSeparator){ - String[] fields = str.split(fieldSeparator); - double[] tmp = new double[fields.length]; - for(int i = 0; i < tmp.length; i++) - tmp[i] = Double.parseDouble(fields[i]); - return tmp; - } - - //// Re-sizing methods //// - - /** - * Resizes an array of bytes. If the new size - * is smaller only newSize elements will be copied. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static byte[] setSize(byte[] a, int newSize) { - if(newSize < 0) throw new IllegalArgumentException("Negative array size"); - byte[] v = new byte[newSize]; - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - /** - * Resizes an array of chars. If the new size - * is smaller only newSize elements will be copied. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static char[] resize(char[] a, int newSize) { - if(newSize < 0) throw new IllegalArgumentException("Negative array size"); - char[] v = new char[newSize]; - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - /** - * Resizes an array of shors. If the new size - * is smaller only newSize elements will be copied. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static short[] resize(short[] a, int newSize) { - if(newSize < 0) throw new IllegalArgumentException("Negative array size"); - short[] v = new short[newSize]; - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - /** - * Resizes an array of ints. If the new size - * is smaller only newSize elements will be copied. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static int[] resize(int[] a, int newSize) { - if(newSize < 0) throw new IllegalArgumentException("Negative array size"); - int[] v = new int[newSize]; - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - /** - * Resizes an array of longs. If the new size - * is smaller only newSize elements will be copied. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static long[] resize(long[] a, int newSize) { - if(newSize < 0) throw new IllegalArgumentException("Negative array size"); - long[] v = new long[newSize]; - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - /** - * Resizes an array of floats. If the new size - * is smaller only newSize elements will be copied. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static float[] resize(float[] a, int newSize) { - if(newSize < 0) throw new IllegalArgumentException("Negative array size"); - float[] v = new float[newSize]; - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - /** - * Resizes an array of doubles. If the new size - * is smaller only newSize elements will be copied. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static double[] resize(double[] a, int newSize) { - if(newSize < 0) - throw new IllegalArgumentException("Negative array size"); - double[] v = new double[newSize]; - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - /** - * Resizes an array of Objects. If the new size - * is smaller overflowing elements will be discarded. - * - * @param a the original array - * @param newSize the size of the new array - * @return a new array with the original elements in a copied to it - */ - public static Object[] resize(Object[] a, int newSize) { - if(newSize < 0) throw new IllegalArgumentException("Negative array size"); - Class arrayClass = a.getClass().getComponentType(); - Object[] v = (Object[]) java.lang.reflect.Array.newInstance(arrayClass, newSize); - System.arraycopy(a,0,v,0,newSize > a.length ? a.length : newSize); - return v; - } - - //// Array to String methods //// - - /** - * Converts a array of numbers into a String. - * - * @param array the array to convert - * @param fieldSeparator string that separates each element - * @return a String representation of the array - */ - public static String join(byte[] array, String fieldSeparator) { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < array.length; i++) - sb.append(array[i]+fieldSeparator); - sb.setLength(sb.length() > 0 ? sb.length()-1 : 0); - return sb.toString(); - } - - /** - * Converts a array of numbers into a String. - * - * @param array the array to convert - * @param fieldSeparator string that separates each element - * @return a String representation of the array - */ - public static String join(short[] array, String fieldSeparator) { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < array.length; i++) - sb.append(array[i]+fieldSeparator); - sb.setLength(sb.length() > 0 ? sb.length()-1 : 0); - return sb.toString(); - } - - /** - * Converts a array of numbers into a String. - * - * @param array the array to convert - * @param fieldSeparator string that separates each element - * @return a String representation of the array - */ - public static String join(int[] array, String fieldSeparator) { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < array.length; i++) - sb.append(array[i]+fieldSeparator); - sb.setLength(sb.length() > 0 ? sb.length()-1 : 0); - return sb.toString(); - } - - /** - * Converts a array of numbers into a String. - * - * @param array the array to convert - * @param fieldSeparator string that separates each element - * @return a String representation of the array - */ - public static String join(long[] array, String fieldSeparator) { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < array.length; i++) - sb.append(array[i]+fieldSeparator); - sb.setLength(sb.length() > 0 ? sb.length()-1 : 0); - return sb.toString(); - } - - /** - * Converts a array of reals into a String. - * - * @param array the array to convert - * @param fieldSeparator string that separates each element - * @return a String representation of the array - */ - public static String join(float[] array, String fieldSeparator) { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < array.length; i++) - sb.append(array[i]+fieldSeparator); - sb.setLength(sb.length() > 0 ? sb.length()-1 : 0); - return sb.toString(); - } - - /** - * Converts a array of reals into a String. - * - * @param array the array to convert - * @param fieldSeparator string that separates each element - * @return a String representation of the array - */ - public static String join(double[] array, String fieldSeparator) { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < array.length; i++) - sb.append(array[i]+fieldSeparator); - sb.setLength(sb.length() > 0 ? sb.length()-1 : 0); - return sb.toString(); - } - - /** - * Converts an array of Objects into a String. - * - * @param array the array to convert - * @param fieldSeparator string that separates each element - * @return a String representation of the array - */ - public static String join(Object[] array, String fieldSeparator) { - StringBuffer sb = new StringBuffer(); - for(int i = 0; i < array.length; i++) - sb.append(array[i]+fieldSeparator); - sb.setLength(sb.length() > 0 ? sb.length()-1 : 0); - return sb.toString(); - } - /** - * prints statistics on an array - * @param d The array to analyze - */ - public static void printStats(int d[]){ - int min = Integer.MAX_VALUE; - long max = -min; - int maxIndex = 0; - int i; - long sum = 0; - - for(i = 0; i < d.length; i++){ - sum += d[i]; - if(d[i] < min){ - min = d[i]; - } - if(d[i] > max){ - max = d[i]; - maxIndex = i; - } - } - System.out.println("Min, max, maxIndex, avg = " + min +", " + - max +", " + maxIndex + ", " + (double)sum/d.length); - } - /** - * prints statistics on an array - * @param d The array to analyze - */ - public static void printStats(double d[]){ - double min = Integer.MAX_VALUE; - double max = -min; - int maxIndex = 0; - int i; - long sum = 0; - - for(i = 0; i < d.length; i++){ - sum += d[i]; - if(d[i] < min){ - min = d[i]; - } - if(d[i] > max){ - max = d[i]; - maxIndex = i; - } - } - System.out.println("Min, max, maxIndex, avg = " + min +", " + - max +", " + maxIndex + ", " + (double)sum/d.length); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicDoubleArray.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicDoubleArray.java deleted file mode 100755 index f34f56d7..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicDoubleArray.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * A dynamic array of doubles. As Java does not have such an animal and using the - * object based standard collection classes from Java would lead to the creation - * of many small objects. Which is inefficient. - * - * copyright: GPL - * - * Mark Koennecke, July 2007 - */ -package ch.psi.num.mountaingum.util; - -public class DynamicDoubleArray { - protected double data[]; - protected int capacity, length; - - public DynamicDoubleArray(){ - capacity = 8; - length = 0; - data = new double[capacity]; - } - public void reset(){ - length = 0; - } - public void append(double i){ - data[length] = i; - length++; - if(length >= capacity - 2){ - capacity = capacity*2; - data = ArrayTools.resize(data, capacity); - } - } - public void append(double d[]){ - if(d.length + length >= capacity - 1){ - capacity = d.length + length*2; - data = ArrayTools.resize(data, capacity); - } - System.arraycopy(d, 0, data, length, d.length); - length += d.length; - } - public int getLength(){ - return length; - } - public String toText(){ - StringBuffer stb = new StringBuffer(); - for(int i = 0; i < length; i++) { - stb.append(data[i]); - stb.append(' '); - } - return stb.toString(); - } - public String toString(){ - return toText(); - } - public void setFromText(String txt){ - data = ArrayTools.splitDoubles(txt, "\\p{Space}+"); - length = data.length; - capacity = length; - } - public double[] getData(){ - double r[]; - r = new double[length]; - System.arraycopy(data,0 , r, 0, length); - return r; - } - public double getValue(int idx){ - return data[idx]; - } - /** - * access the raw array: take extra care! The array is certainly longer - * the length but onbly length values are defined. - * Changes to the array which would affect length are not properly hounoured - * @return a dangerous pointer to the raw data array. - */ - public double[] getRawArray(){ - return data; - } - protected void finalize() throws Throwable { - super.finalize(); - data = null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicIntArray.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicIntArray.java deleted file mode 100755 index 96ba2823..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicIntArray.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * A dynamic array of ints. As Java does not have such an animal and using the - * object based standard collection classes from Java would lead to the creation - * of many small objects. Which is inefficient. - * - * copyright: GPL - * - * Mark Koennecke, July 2007 - */ -package ch.psi.num.mountaingum.util; - -public class DynamicIntArray { - protected int data[]; - protected int capacity, length; - - public DynamicIntArray(){ - capacity = 128; - length = 0; - data = new int[128]; - } - public void reset(){ - length = 0; - } - public void append(int i){ - data[length] = i; - length++; - if(length >= capacity - 1){ - capacity = capacity*2; - int[] duta = ArrayTools.resize(data, capacity); - data = null; - data = duta; - } - } - public void append(int d[]){ - int duta[]; - if(d.length + length >= capacity - 1){ - capacity = d.length + length*2; - duta = ArrayTools.resize(data, capacity); - data = null; - data = duta; - } - System.arraycopy(d, 0, data, length, d.length); - length += d.length; - } - public int getLength(){ - return length; - } - public String toText(){ - StringBuffer stb = new StringBuffer(); - for(int i = 0; i < length; i++) { - stb.append(data[i]); - stb.append(' '); - } - return stb.toString(); - } - public void setFromText(String txt){ - data = ArrayTools.splitInts(txt, "\\p{Space}+"); - length = data.length; - capacity = length; - } - public String toString(){ - return toText(); - } - public int[] getData(){ - int r[]; - r = new int[length]; - System.arraycopy(data,0 , r, 0, length); - return r; - } - public int getValue(int idx){ - return data[idx]; - } - /** - * access the raw array: take extra care! The array is certainly longer - * then length but only length values are defined. - * Changes to the array which would affect length are not properly honoured - * @return a dangerous pointer to the raw data array. - */ - public int[] getRawArray(){ - return data; - } - protected void finalize() throws Throwable { - super.finalize(); - data = null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicLongArray.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicLongArray.java deleted file mode 100755 index 3da8b87e..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/DynamicLongArray.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This is a dynamic array for long values. Needed to store time stamps - * - * copyright: GPL - * - * Mark Koennecke, February 2008 - */ -package ch.psi.num.mountaingum.util; - -public class DynamicLongArray { - protected long data[]; - protected int capacity, length; - - public DynamicLongArray(){ - capacity = 128; - length = 0; - data = new long[128]; - } - public void reset(){ - length = 0; - } - public void append(long i){ - data[length] = i; - length++; - if(length >= capacity - 1){ - capacity = capacity*2; - data = ArrayTools.resize(data, capacity); - } - } - public void append(long d[]){ - if(d.length + length >= capacity - 1){ - capacity = d.length + length*2; - data = ArrayTools.resize(data, capacity); - } - System.arraycopy(d, 0, data, length, d.length); - length += d.length; - } - public int getLength(){ - return length; - } - public String toText(){ - StringBuffer stb = new StringBuffer(); - for(int i = 0; i < length; i++) { - stb.append(data[i]); - stb.append(' '); - } - return stb.toString(); - } - public void setFromText(String txt){ - data = ArrayTools.splitLongs(txt, "\\p{Space}+"); - length = data.length; - capacity = length; - } - public String toString(){ - return toText(); - } - public long[] getData(){ - long r[]; - r = new long[length]; - System.arraycopy(data,0 , r, 0, length); - return r; - } - public long getValue(int idx){ - return data[idx]; - } - /** - * access the raw array: take extra care! The array is certainly longer - * then length but only length values are defined. - * Changes to the array which would affect length are not properly honoured - * @return a dangerous pointer to the raw data array. - */ - public long[] getRawArray(){ - return data; - } - protected void finalize() throws Throwable { - super.finalize(); - data = null; - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Fmt.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Fmt.java deleted file mode 100755 index e3c9b895..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Fmt.java +++ /dev/null @@ -1,610 +0,0 @@ -// Fmt - some simple single-arg sprintf-like routines -// -// Copyright (C) 1996 by Jef Poskanzer . All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// Visit the ACME Labs Java page for up-to-date versions of this and other -// fine Java utilities: http://www.acme.com/java/ -package ch.psi.num.mountaingum.util; - -// package Acme; - -/// Some simple single-arg sprintf-like routines. -//

-// It is apparently impossible to declare a Java method that accepts -// variable numbers of any type of argument. You can declare it to take -// Objects, but numeric variables and constants are not in fact Objects. -//

-// However, using the built-in string concatenation, it's almost as -// convenient to make a series of single-argument formatting routines. -//

-// Fmt can format the following types: -//

-// byte short int long float double char String Object -//
-// For each type there is a set of overloaded methods, each returning -// a formatted String. There's the plain formatting version: -//
-// Fmt.fmt( x )
-// 
-// There's a version specifying a minimum field width: -//
-// Fmt.fmt( x, minWidth )
-// 
-// And there's a version that takes flags: -//
-// Fmt.fmt( x, minWidth, flags )
-// 
-// Currently available flags are: -//
-// Fmt.ZF - zero-fill
-// Fmt.LJ - left justify
-// Fmt.HX - hexadecimal
-// Fmt.OC - octal
-// 
-// The HX and OC flags imply unsigned output. -//

-// For doubles and floats, there's a significant-figures parameter before -// the flags: -//

-// Fmt.fmt( d )
-// Fmt.fmt( d, minWidth )
-// Fmt.fmt( d, minWidth, sigFigs )
-// Fmt.fmt( d, minWidth, sigFigs, flags )
-// 
-//

-// Fetch the software.
-// Fetch the entire Acme package. -//


-// Similar classes: -//
    -//
  • Andrew Scherpbier's FormatString -// Tries to allow variable numbers of arguments by -// supplying overloaded routines with different combinations of parameters, -// but doesn't actually supply that many. The floating point conversion -// is described as "very incomplete". -//
  • Core Java's Format. -// The design seems a little weird. They want you to create an instance, -// passing the format string to the constructor, and then call an instance -// method with your data to do the actual formatting. The extra steps are -// pointless; better to just use static methods. -//
- -public class Fmt - { - - // Flags. - /// Zero-fill. - public static final int ZF = 1; - /// Left justify. - public static final int LJ = 2; - /// Hexadecimal. - public static final int HX = 4; - /// Octal. - public static final int OC = 8; - // Was a number - internal use. - private static final int WN = 16; - - // byte - public static String fmt( byte b ) - { - return fmt( b, 0, 0 ); - } - public static String fmt( byte b, int minWidth ) - { - return fmt( b, minWidth, 0 ); - } - public static String fmt( byte b, int minWidth, int flags ) - { - boolean hexadecimal = ( ( flags & HX ) != 0 ); - boolean octal = ( ( flags & OC ) != 0 ); - if ( hexadecimal ) - return fmt( Integer.toString( b & 0xff, 16 ), minWidth, flags|WN ); - else if ( octal ) - return fmt( Integer.toString( b & 0xff, 8 ), minWidth, flags|WN ); - else - return fmt( Integer.toString( b & 0xff ), minWidth, flags|WN ); - } - - // short - public static String fmt( short s ) - { - return fmt( s, 0, 0 ); - } - public static String fmt( short s, int minWidth ) - { - return fmt( s, minWidth, 0 ); - } - public static String fmt( short s, int minWidth, int flags ) - { - boolean hexadecimal = ( ( flags & HX ) != 0 ); - boolean octal = ( ( flags & OC ) != 0 ); - if ( hexadecimal ) - return fmt( - Integer.toString( s & 0xffff, 16 ), minWidth, flags|WN ); - else if ( octal ) - return fmt( - Integer.toString( s & 0xffff, 8 ), minWidth, flags|WN ); - else - return fmt( Integer.toString( s ), minWidth, flags|WN ); - } - - // int - public static String fmt( int i ) - { - return fmt( i, 0, 0 ); - } - public static String fmt( int i, int minWidth ) - { - return fmt( i, minWidth, 0 ); - } - public static String fmt( int i, int minWidth, int flags ) - { - boolean hexadecimal = ( ( flags & HX ) != 0 ); - boolean octal = ( ( flags & OC ) != 0 ); - if ( hexadecimal ) - return fmt( - Long.toString( i & 0xffffffffL, 16 ), minWidth, flags|WN ); - else if ( octal ) - return fmt( - Long.toString( i & 0xffffffffL, 8 ), minWidth, flags|WN ); - else - return fmt( Integer.toString( i ), minWidth, flags|WN ); - } - - // long - public static String fmt( long l ) - { - return fmt( l, 0, 0 ); - } - public static String fmt( long l, int minWidth ) - { - return fmt( l, minWidth, 0 ); - } - public static String fmt( long l, int minWidth, int flags ) - { - boolean hexadecimal = ( ( flags & HX ) != 0 ); - boolean octal = ( ( flags & OC ) != 0 ); - if ( hexadecimal ) - { - if ( ( l & 0xf000000000000000L ) != 0 ) - return fmt( - Long.toString( l >>> 60, 16 ) + - fmt( l & 0x0fffffffffffffffL, 15, HX|ZF ), - minWidth, flags|WN ); - else - return fmt( Long.toString( l, 16 ), minWidth, flags|WN ); - } - else if ( octal ) - { - if ( ( l & 0x8000000000000000L ) != 0 ) - return fmt( - Long.toString( l >>> 63, 8 ) + - fmt( l & 0x7fffffffffffffffL, 21, OC|ZF ), - minWidth, flags|WN ); - else - return fmt( Long.toString( l, 8 ), minWidth, flags|WN ); - } - else - return fmt( Long.toString( l ), minWidth, flags|WN ); - } - - // float - public static String fmt( float f ) - { - return fmt( f, 0, 0, 0 ); - } - public static String fmt( float f, int minWidth ) - { - return fmt( f, minWidth, 0, 0 ); - } - public static String fmt( float f, int minWidth, int sigFigs ) - { - return fmt( f, minWidth, sigFigs, 0 ); - } - public static String fmt( float f, int minWidth, int sigFigs, int flags ) - { - if ( sigFigs != 0 ) - return fmt( - sigFigFix( Float.toString( f ), sigFigs ), minWidth, - flags|WN ); - else - return fmt( Float.toString( f ), minWidth, flags|WN ); - } - - // double - public static String fmt( double d ) - { - return fmt( d, 0, 0, 0 ); - } - public static String fmt( double d, int minWidth ) - { - return fmt( d, minWidth, 0, 0 ); - } - public static String fmt( double d, int minWidth, int sigFigs ) - { - return fmt( d, minWidth, sigFigs, 0 ); - } - public static String fmt( double d, int minWidth, int sigFigs, int flags ) - { - if ( sigFigs != 0 ) - return fmt( - sigFigFix( doubleToString( d ), sigFigs ), minWidth, - flags|WN ); - else - return fmt( doubleToString( d ), minWidth, flags|WN ); - } - - // char - public static String fmt( char c ) - { - return fmt( c, 0, 0 ); - } - public static String fmt( char c, int minWidth ) - { - return fmt( c, minWidth, 0 ); - } - public static String fmt( char c, int minWidth, int flags ) - { - // return fmt( Character.toString( c ), minWidth, flags ); - // Character currently lacks a static toString method. Workaround - // is to make a temporary instance and use the instance toString. - return fmt( new Character( c ).toString(), minWidth, flags ); - } - - // Object - public static String fmt( Object o ) - { - return fmt( o, 0, 0 ); - } - public static String fmt( Object o, int minWidth ) - { - return fmt( o, minWidth, 0 ); - } - public static String fmt( Object o, int minWidth, int flags ) - { - return fmt( o.toString(), minWidth, flags ); - } - - // String - public static String fmt( String s ) - { - return fmt( s, 0, 0 ); - } - public static String fmt( String s, int minWidth ) - { - return fmt( s, minWidth, 0 ); - } - public static String fmt( String s, int minWidth, int flags ) - { - int len = s.length(); - boolean zeroFill = ( ( flags & ZF ) != 0 ); - boolean leftJustify = ( ( flags & LJ ) != 0 ); - boolean hexadecimal = ( ( flags & HX ) != 0 ); - boolean octal = ( ( flags & OC ) != 0 ); - boolean wasNumber = ( ( flags & WN ) != 0 ); - if ( ( hexadecimal || octal || zeroFill ) && ! wasNumber ) - throw new InternalError( "Acme.Fmt: number flag on a non-number" ); - if ( zeroFill && leftJustify ) - throw new InternalError( "Acme.Fmt: zero-fill left-justify is silly" ); - if ( hexadecimal && octal ) - throw new InternalError( "Acme.Fmt: can't do both hex and octal" ); - if ( len >= minWidth ) - return s; - int fillWidth = minWidth - len; - StringBuffer fill = new StringBuffer( fillWidth ); - for ( int i = 0; i < fillWidth; ++i ) - if ( zeroFill ) - fill.append( '0' ); - else - fill.append( ' ' ); - if ( leftJustify ) - return s + fill; - else if ( zeroFill && s.startsWith( "-" ) ) - return "-" + fill + s.substring( 1 ); - else - return fill + s; - } - - - // Internal routines. - - private static String sigFigFix( String s, int sigFigs ) - { - // First dissect the floating-point number string into sign, - // integer part, fraction part, and exponent. - String sign; - String unsigned; - if ( s.startsWith( "-" ) || s.startsWith( "+" ) ) - { - sign = s.substring( 0, 1 ); - unsigned = s.substring( 1 ); - } - else - { - sign = ""; - unsigned = s; - } - String mantissa; - String exponent; - int eInd = unsigned.indexOf( 'e' ); - if ( eInd == -1 ) - { - mantissa = unsigned; - exponent = ""; - } - else - { - mantissa = unsigned.substring( 0, eInd ); - exponent = unsigned.substring( eInd ); - } - StringBuffer number, fraction; - int dotInd = mantissa.indexOf( '.' ); - if ( dotInd == -1 ) - { - number = new StringBuffer( mantissa ); - fraction = new StringBuffer( "" ); - } - else - { - number = new StringBuffer( mantissa.substring( 0, dotInd ) ); - fraction = new StringBuffer( mantissa.substring( dotInd + 1 ) ); - } - - int numFigs = number.length(); - int fracFigs = fraction.length(); - if ( ( numFigs == 0 || number.equals( "0" ) ) && fracFigs > 0 ) - { - // Don't count leading zeros in the fraction. - numFigs = 0; - for ( int i = 0; i < fraction.length(); ++i ) - { - if ( fraction.charAt( i ) != '0' ) - break; - --fracFigs; - } - } - int mantFigs = numFigs + fracFigs; - if ( sigFigs > mantFigs ) - { - // We want more figures; just append zeros to the fraction. - for ( int i = mantFigs; i < sigFigs; ++i ) - fraction.append( '0' ); - } - else if ( sigFigs < mantFigs && sigFigs >= numFigs ) - { - // Want fewer figures in the fraction; chop. - fraction.setLength( - fraction.length() - ( fracFigs - ( sigFigs - numFigs ) ) ); - // Round? - } - else if ( sigFigs < numFigs ) - { - // Want fewer figures in the number; turn them to zeros. - fraction.setLength( 0 ); // should already be zero, but make sure - for ( int i = sigFigs; i < numFigs; ++i ) - number.setCharAt( i, '0' ); - // Round? - } - // Else sigFigs == mantFigs, which is fine. - - if ( fraction.length() == 0 ) - return sign + number + exponent; - else - return sign + number + "." + fraction + exponent; - } - - - /// Improved version of Double.toString(), returns more decimal places. - //

- // The JDK 1.0.2 version of Double.toString() returns only six decimal - // places on some systems. In JDK 1.1 full precision is returned on - // all platforms. - // @deprecated - // @see java.lang.Double#toString - public static String doubleToString( double d ) - { - // Handle special numbers first, to avoid complications. - if ( Double.isNaN( d ) ) - return "NaN"; - if ( d == Double.NEGATIVE_INFINITY ) - return "-Inf"; - if ( d == Double.POSITIVE_INFINITY ) - return "Inf"; - - // Grab the sign, and then make the number positive for simplicity. - boolean negative = false; - if ( d < 0.0D ) - { - negative = true; - d = -d; - } - - // Get the native version of the unsigned value, as a template. - String unsStr = Double.toString( d ); - - // Dissect out the exponent. - String mantStr, expStr; - int exp; - int eInd = unsStr.indexOf( 'e' ); - if ( eInd == -1 ) - { - mantStr = unsStr; - expStr = ""; - exp = 0; - } - else - { - mantStr = unsStr.substring( 0, eInd ); - expStr = unsStr.substring( eInd + 1 ); - if ( expStr.startsWith( "+" ) ) - exp = Integer.parseInt( expStr.substring( 1 ) ); - else - exp = Integer.parseInt( expStr ); - } - - // Dissect out the number part. - String numStr; - int dotInd = mantStr.indexOf( '.' ); - if ( dotInd == -1 ) - numStr = mantStr; - else - numStr = mantStr.substring( 0, dotInd ); - long num; - if ( numStr.length() == 0 ) - num = 0; - else - num = Integer.parseInt( numStr ); - - // Build the new mantissa. - StringBuffer newMantBuf = new StringBuffer( numStr + "." ); - double p = Math.pow( 10, exp ); - double frac = d - num * p; - String digits = "0123456789"; - int nDigits = 16 - numStr.length(); // about 16 digits in a double - for ( int i = 0; i < nDigits; ++i ) - { - p /= 10.0D; - int dig = (int) ( frac / p ); - if ( dig < 0 ) dig = 0; - if ( dig > 9 ) dig = 9; - newMantBuf.append( digits.charAt( dig ) ); - frac -= dig * p; - } - - if ( (int) ( frac / p + 0.5D ) == 1 ) - { - // Round up. - boolean roundMore = true; - for ( int i = newMantBuf.length() - 1; i >= 0; --i ) - { - int dig = digits.indexOf( newMantBuf.charAt( i ) ); - if ( dig == -1 ) - continue; - ++dig; - if ( dig == 10 ) - { - newMantBuf.setCharAt( i, '0' ); - continue; - } - newMantBuf.setCharAt( i, digits.charAt( dig ) ); - roundMore = false; - break; - } - if ( roundMore ) - { - // If this happens, we need to prepend a 1. But I haven't - // found a test case yet, so I'm leaving it out for now. - // But if you get this message, please let me know! - newMantBuf.append( "ROUNDMORE" ); - } - } - - // Chop any trailing zeros. - int len = newMantBuf.length(); - while ( newMantBuf.charAt( len - 1 ) == '0' ) - newMantBuf.setLength( --len ); - // And chop a trailing dot, if any. - if ( newMantBuf.charAt( len - 1 ) == '.' ) - newMantBuf.setLength( --len ); - - // Done. - return ( negative ? "-" : "" ) + - newMantBuf + - ( expStr.length() != 0 ? ( "e" + expStr ) : "" ); - } - - -/****************************************************************************** - /// Test program. - public static void main( String[] args ) - { - System.out.println( "Starting tests." ); - show( Fmt.fmt( "Hello there." ) ); - show( Fmt.fmt( 123 ) ); - show( Fmt.fmt( 123, 10 ) ); - show( Fmt.fmt( 123, 10, Fmt.ZF ) ); - show( Fmt.fmt( 123, 10, Fmt.LJ ) ); - show( Fmt.fmt( -123 ) ); - show( Fmt.fmt( -123, 10 ) ); - show( Fmt.fmt( -123, 10, Fmt.ZF ) ); - show( Fmt.fmt( -123, 10, Fmt.LJ ) ); - show( Fmt.fmt( (byte) 0xbe, 22, Fmt.OC ) ); - show( Fmt.fmt( (short) 0xbabe, 22, Fmt.OC ) ); - show( Fmt.fmt( 0xcafebabe, 22, Fmt.OC ) ); - show( Fmt.fmt( 0xdeadbeefcafebabeL, 22, Fmt.OC ) ); - show( Fmt.fmt( 0x8000000000000000L, 22, Fmt.OC ) ); - show( Fmt.fmt( (byte) 0xbe, 16, Fmt.HX ) ); - show( Fmt.fmt( (short) 0xbabe, 16, Fmt.HX ) ); - show( Fmt.fmt( 0xcafebabe, 16, Fmt.HX ) ); - show( Fmt.fmt( 0xdeadbeefcafebabeL, 16, Fmt.HX ) ); - show( Fmt.fmt( 0x8000000000000000L, 16, Fmt.HX ) ); - show( Fmt.fmt( 'c' ) ); - show( Fmt.fmt( new java.util.Date() ) ); - show( Fmt.fmt( 123.456F ) ); - show( Fmt.fmt( 123456000000000000.0F ) ); - show( Fmt.fmt( 123.456F, 0, 8 ) ); - show( Fmt.fmt( 123.456F, 0, 7 ) ); - show( Fmt.fmt( 123.456F, 0, 6 ) ); - show( Fmt.fmt( 123.456F, 0, 5 ) ); - show( Fmt.fmt( 123.456F, 0, 4 ) ); - show( Fmt.fmt( 123.456F, 0, 3 ) ); - show( Fmt.fmt( 123.456F, 0, 2 ) ); - show( Fmt.fmt( 123.456F, 0, 1 ) ); - show( Fmt.fmt( 123456000000000000.0F, 0, 4 ) ); - show( Fmt.fmt( -123.456F, 0, 4 ) ); - show( Fmt.fmt( -123456000000000000.0F, 0, 4 ) ); - show( Fmt.fmt( 123.0F ) ); - show( Fmt.fmt( 123.0D ) ); - show( Fmt.fmt( 1.234567890123456789F ) ); - show( Fmt.fmt( 1.234567890123456789D ) ); - show( Fmt.fmt( 1234567890123456789F ) ); - show( Fmt.fmt( 1234567890123456789D ) ); - show( Fmt.fmt( 0.000000000000000000001234567890123456789F ) ); - show( Fmt.fmt( 0.000000000000000000001234567890123456789D ) ); - show( Fmt.fmt( 12300.0F ) ); - show( Fmt.fmt( 12300.0D ) ); - show( Fmt.fmt( 123000.0F ) ); - show( Fmt.fmt( 123000.0D ) ); - show( Fmt.fmt( 1230000.0F ) ); - show( Fmt.fmt( 1230000.0D ) ); - show( Fmt.fmt( 12300000.0F ) ); - show( Fmt.fmt( 12300000.0D ) ); - show( Fmt.fmt( Float.NaN ) ); - show( Fmt.fmt( Float.POSITIVE_INFINITY ) ); - show( Fmt.fmt( Float.NEGATIVE_INFINITY ) ); - show( Fmt.fmt( Double.NaN ) ); - show( Fmt.fmt( Double.POSITIVE_INFINITY ) ); - show( Fmt.fmt( Double.NEGATIVE_INFINITY ) ); - show( Fmt.fmt( 1.0F / 8.0F ) ); - show( Fmt.fmt( 1.0D / 8.0D ) ); - System.out.println( "Done with tests." ); - } - - private static void show( String str ) - { - System.out.println( "#" + str + "#" ); - } -******************************************************************************/ - - } diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/ListSequence.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/ListSequence.java deleted file mode 100755 index a480024e..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/ListSequence.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * This is linked list implementation of the Sequence interface. This is inefficient - * for text editing but as Maountaingum batch queues are not expected to hold more - * then a hundred entries, this is OK. - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.util; - -import java.util.LinkedList; - -public class ListSequence implements Sequence { - - private LinkedList l; - public ListSequence(){ - l = new LinkedList(); - } - public void delete(int pos) { - l.remove(pos); - } - public void delete(int start, int end) { - for(int i = start; i < end; i++){ - l.remove(start); - } - } - public boolean empty() { - return l.isEmpty(); - } - public void insert(int position, Object o) { - l.add(position,o); - } - - public void insert(int position, Sequence s) { - for(int i = 0; i < s.length(); i++){ - l.add(position+i,s.itemAt(i)); - } - } - - public Object itemAt(int pos) { - return l.get(pos); - } - - public int length() { - return l.size(); - } -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Sequence.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Sequence.java deleted file mode 100755 index 16449373..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/Sequence.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This is an interface for managing a sequence of edit items, like in - * a text editor. It is inspired by the paper: - * - * Charles Crowley: Data Structures for Text Sequences - * - * I have a gut feeling that I need this interface though the implementation for - * Mountaingum will be based on a primitive linked list. - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.util; - -public interface Sequence { - /** - * is the sequence empty? - * @return true or flase - */ - public boolean empty(); - /** - * insert o at position - * @param position The position where to insert the item - * @param o The item to insert - */ - public void insert(int position, Object o); - /** - * insert a sequence - * @param position the position where to start inserting the sequence - * @param s The sequence to insert - */ - public void insert(int position, Sequence s); - /** - * delete the item at pos - * @param pos The index of the item to delete. - */ - public void delete(int pos); - /** - * delete several items - * @param start - * @param end - */ - public void delete(int start, int end); - /** - * return the item at pos - * @param pos The index into the sequence - * @return The element at pos or null. - */ - public Object itemAt(int pos); - /** - * return the length of the sequence - * @return The length - */ - public int length(); -} diff --git a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/SequenceStream.java b/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/SequenceStream.java deleted file mode 100755 index 607df7c4..00000000 --- a/contrib/applications/nxplot/mountaingumsys/src/ch/psi/num/mountaingum/util/SequenceStream.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This is a stream wrapper for a sequence - * - * copyright: GPL - * - * Mark Koennecke, January 2008 - */ -package ch.psi.num.mountaingum.util; - -import ch.psi.num.mountaingum.func.IStream; - -public class SequenceStream implements IStream { - private int count, length; - private Sequence s; - - public SequenceStream(Sequence s){ - this.s = s; - count = 0; - length = s.length(); - } - public Object next() { - if(count < length){ - Object o = s.itemAt(count); - count++; - return o; - } - return null; - } -} diff --git a/contrib/applications/nxplot/mountaingumuibase/.project b/contrib/applications/nxplot/mountaingumuibase/.project deleted file mode 100755 index f65924c2..00000000 --- a/contrib/applications/nxplot/mountaingumuibase/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - mountaingumuibase - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/mountaingumuibase/.settings/org.eclipse.jdt.core.prefs b/contrib/applications/nxplot/mountaingumuibase/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index a67c8081..00000000 --- a/contrib/applications/nxplot/mountaingumuibase/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Oct 21 11:46:43 CEST 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/contrib/applications/nxplot/mountaingumuibase/META-INF/MANIFEST.MF b/contrib/applications/nxplot/mountaingumuibase/META-INF/MANIFEST.MF deleted file mode 100755 index e8ab1e74..00000000 --- a/contrib/applications/nxplot/mountaingumuibase/META-INF/MANIFEST.MF +++ /dev/null @@ -1,71 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Mountaingumuibase -Bundle-SymbolicName: mountaingumuibase;singleton:=true -Bundle-Version: 1.0.0 -Bundle-Vendor: Mark Koennecke, PSI -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: mountaingumsys;bundle-version="0.1.0", - org.eclipse.nebula.compositetable;bundle-version="1.0.0", - sgtgraphics;bundle-version="3.1.0", - org.eclipse.swt;bundle-version="3.3.2", - org.eclipse.ui;bundle-version="3.3.1", - org.eclipse.core.runtime;bundle-version="3.3.100" -Export-Package: ch.psi.num.mountaingum.ui.EditorView; - uses:="org.eclipse.swt.events, - ch.psi.num.mountaingum.sys, - org.eclipse.swt.custom, - ch.psi.num.mountaingum.ui.eclipse, - org.eclipse.ui.part, - ch.psi.num.mountaingum.tree, - org.eclipse.swt.widgets", - ch.psi.num.mountaingum.ui.GraphicsView; - uses:="ch.psi.num.mountaingum.func, - ch.psi.num.mountaingum.util, - org.eclipse.swt.printing, - org.eclipse.swt.events, - org.eclipse.ui, - org.eclipse.ui.part, - ch.psi.num.mountaingum.tree, - gov.noaa.pmel.sgt.swing, - ch.psi.num.mountaingum.ui, - gov.noaa.pmel.util, - org.eclipse.jface.action, - gov.noaa.pmel.sgt, - gov.noaa.pmel.sgt.dm, - ch.psi.num.mountaingum.ui.eclipse, - org.eclipse.jface.viewers, - org.eclipse.swt.widgets", - ch.psi.num.mountaingum.ui.GraphicsView.maps, - ch.psi.num.mountaingum.ui.QuickView; - uses:="org.eclipse.jface.action, - org.eclipse.swt.events, - org.eclipse.ui.actions, - org.eclipse.ui.part, - ch.psi.num.mountaingum.tree, - org.eclipse.swt.widgets", - ch.psi.num.mountaingum.ui.TreeViewer; - uses:="org.eclipse.jface.resource, - org.eclipse.swt.nebula.widgets.compositetable, - org.eclipse.swt.events, - org.eclipse.swt.custom, - ch.psi.num.mountaingum.tree, - org.eclipse.ui.part, - ch.psi.num.mountaingum.ui.EditorView, - org.eclipse.jface.viewers, - ch.psi.num.mountaingum.ui.eclipse, - org.eclipse.swt.graphics, - org.eclipse.swt.widgets", - ch.psi.num.mountaingum.ui.eclipse; - uses:="org.eclipse.jface.action, - gov.noaa.pmel.sgt, - org.eclipse.swt.printing, - org.eclipse.ui, - ch.psi.num.mountaingum.tree, - org.eclipse.swt.widgets", - ch.psi.num.mountaingum.ui.util; - uses:="org.eclipse.swt.graphics, - ch.psi.num.mountaingum.tree, - org.eclipse.swt.widgets, - org.eclipse.jface.dialogs", - ch.psi.num.mountaingum.ui.util.eclipse;uses:="org.eclipse.jface.action,org.eclipse.ui" diff --git a/contrib/applications/nxplot/mountaingumuibase/build.properties b/contrib/applications/nxplot/mountaingumuibase/build.properties deleted file mode 100755 index e9863e28..00000000 --- a/contrib/applications/nxplot/mountaingumuibase/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml diff --git a/contrib/applications/nxplot/mountaingumuibase/icons/lock-icon.png b/contrib/applications/nxplot/mountaingumuibase/icons/lock-icon.png deleted file mode 100755 index 472627c8..00000000 Binary files a/contrib/applications/nxplot/mountaingumuibase/icons/lock-icon.png and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumuibase/icons/lock25.gif b/contrib/applications/nxplot/mountaingumuibase/icons/lock25.gif deleted file mode 100755 index 64d360ce..00000000 Binary files a/contrib/applications/nxplot/mountaingumuibase/icons/lock25.gif and /dev/null differ diff --git a/contrib/applications/nxplot/mountaingumuibase/plugin.xml b/contrib/applications/nxplot/mountaingumuibase/plugin.xml deleted file mode 100755 index 16aab725..00000000 --- a/contrib/applications/nxplot/mountaingumuibase/plugin.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/mountaingumuibase/schema/mountaingumuibase.NodeEditor.exsd b/contrib/applications/nxplot/mountaingumuibase/schema/mountaingumuibase.NodeEditor.exsd deleted file mode 100755 index d9ef58bf..00000000 --- a/contrib/applications/nxplot/mountaingumuibase/schema/mountaingumuibase.NodeEditor.exsd +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - NodeEditor is a extension point which allows to contribute specialized viewers or -editors for TreeNodes. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - December 2007 - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/nxplot-platform.lis b/contrib/applications/nxplot/nxplot-platform.lis deleted file mode 100644 index 678ab417..00000000 --- a/contrib/applications/nxplot/nxplot-platform.lis +++ /dev/null @@ -1,180 +0,0 @@ -com.ibm.icu_4.0.1.v20090822.jar -com.ibm.icu.source_4.0.1.v20090822.jar -javax.servlet_2.5.0.v200806031605.jar -org.eclipse.ant.core_3.2.100.v20090817_r351.jar -org.eclipse.compare.core_3.5.0.I20090430-0408.jar -org.eclipse.compare.win32_1.0.0.I20090430-0408.jar -org.eclipse.compare.win32.source_1.0.0.I20090430-0408.jar -org.eclipse.core.commands_3.5.0.I20090525-2000.jar -org.eclipse.core.commands.source_3.5.0.I20090525-2000.jar -org.eclipse.core.contenttype_3.4.1.R35x_v20090826-0451.jar -org.eclipse.core.contenttype.source_3.4.1.R35x_v20090826-0451.jar -org.eclipse.core.databinding_1.2.0.M20090819-0800.jar -org.eclipse.core.databinding.beans_1.2.0.I20090525-2000.jar -org.eclipse.core.databinding.beans.source_1.2.0.I20090525-2000.jar -org.eclipse.core.databinding.observable_1.2.0.M20090902-0800.jar -org.eclipse.core.databinding.observable.source_1.2.0.M20090902-0800.jar -org.eclipse.core.databinding.property_1.2.0.M20090819-0800.jar -org.eclipse.core.databinding.property.source_1.2.0.M20090819-0800.jar -org.eclipse.core.databinding.source_1.2.0.M20090819-0800.jar -org.eclipse.core.expressions_3.4.100.v20090429-1800.jar -org.eclipse.core.expressions.source_3.4.100.v20090429-1800.jar -org.eclipse.core.filebuffers_3.5.0.v20090526-2000.jar -org.eclipse.core.filesystem_1.2.0.v20090507.jar -org.eclipse.core.filesystem.hpux.ia64_32_1.0.0.v20080604-1400.jar -org.eclipse.core.filesystem.hpux.PA_RISC_1.0.0.v20080604-1400.jar -org.eclipse.core.filesystem.linux.ppc_1.0.100.v20080604-1400.jar -org.eclipse.core.filesystem.linux.x86_1.2.0.v20080604-1400.jar -org.eclipse.core.filesystem.linux.x86_64_1.0.100.v20080604-1400.jar -org.eclipse.core.filesystem.macosx_1.1.0.v20090112.jar -org.eclipse.core.filesystem.qnx.x86_1.0.0.v20080604-1400.jar -org.eclipse.core.filesystem.solaris.sparc_1.0.100.v20080604-1400.jar -org.eclipse.core.filesystem.win32.x86_1.1.0.v20080604-1400.jar -org.eclipse.core.filesystem.win32.x86_64_1.1.0.v20090316-0910.jar -org.eclipse.core.jobs_3.4.100.v20090429-1800.jar -org.eclipse.core.jobs.source_3.4.100.v20090429-1800.jar -org.eclipse.core.net_1.2.1.r35x_20090812-1200.jar -org.eclipse.core.net.linux.x86_1.1.0.I20081021.jar -org.eclipse.core.net.win32.x86_1.0.0.I20080909.jar -org.eclipse.core.net.win32.x86_64_1.0.0.I20090306-1030.jar -org.eclipse.core.resources_3.5.1.R35x_v20090826-0451.jar -org.eclipse.core.resources.compatibility_3.4.0.v20090505.jar -org.eclipse.core.resources.win32.x86_3.5.0.v20081020.jar -org.eclipse.core.runtime_3.5.0.v20090525.jar -org.eclipse.core.runtime.compatibility.auth_3.2.100.v20090413.jar -org.eclipse.core.runtime.compatibility.auth.source_3.2.100.v20090413.jar -org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800 -org.eclipse.core.runtime.source_3.5.0.v20090525.jar -org.eclipse.core.variables_3.2.200.v20090521.jar -org.eclipse.ecf_3.0.0.v20090831-1906.jar -org.eclipse.ecf.filetransfer_3.0.0.v20090831-1906.jar -org.eclipse.ecf.identity_3.0.0.v20090831-1906.jar -org.eclipse.ecf.provider.filetransfer_3.0.1.v20090831-1906.jar -org.eclipse.ecf.provider.filetransfer.ssl_1.0.0.v20090831-1906.jar -org.eclipse.ecf.ssl_1.0.0.v20090831-1906.jar -org.eclipse.equinox.app_1.2.0.v20090520-1800.jar -org.eclipse.equinox.app.source_1.2.0.v20090520-1800.jar -org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100.jar -org.eclipse.equinox.common.source_3.5.1.R35x_v20090807-1100.jar -org.eclipse.equinox.concurrent_1.0.0.v20090520-1800.jar -org.eclipse.equinox.ds_1.1.1.R35x_v20090806.jar -org.eclipse.equinox.ds.source_1.1.1.R35x_v20090806.jar -org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar -org.eclipse.equinox.launcher.carbon.macosx_1.0.200.v20090520-1835 -org.eclipse.equinox.launcher.cocoa.macosx_1.0.1.R35x_v20090707 -org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.0.1.R35x_v20090707 -org.eclipse.equinox.launcher.gtk.linux.ppc_1.0.200.v20090519 -org.eclipse.equinox.launcher.gtk.linux.s390_1.0.100.v20090426-1530 -org.eclipse.equinox.launcher.gtk.linux.s390x_1.0.100.v20090426-1530 -org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520 -org.eclipse.equinox.launcher.gtk.linux.x86_64_1.0.200.v20090519 -org.eclipse.equinox.launcher.gtk.solaris.sparc_1.0.201.R35x_v20090720 -org.eclipse.equinox.launcher.gtk.solaris.x86_1.0.201.R35x_v20090720 -org.eclipse.equinox.launcher.motif.aix.ppc_1.0.200.v20090519 -org.eclipse.equinox.launcher.motif.hpux.ia64_32_1.0.100.v20090519 -org.eclipse.equinox.launcher.motif.hpux.PA_RISC_1.0.100.v20090306-1900 -org.eclipse.equinox.launcher.motif.linux.x86_1.0.200.v20090520 -org.eclipse.equinox.launcher.motif.solaris.sparc_1.0.300.HEAD -org.eclipse.equinox.launcher.source_1.0.201.R35x_v20090715.jar -org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519 -org.eclipse.equinox.launcher.win32.win32.x86_64_1.0.200.v20090519 -org.eclipse.equinox.launcher.wpf.win32.x86_1.0.200.v20090519 -org.eclipse.equinox.p2.artifact.repository_1.0.101.R35x_v20090721.jar -org.eclipse.equinox.p2.core_1.0.101.R35x_v20090819.jar -org.eclipse.equinox.p2.engine_1.0.101.R35x_v20090825.jar -org.eclipse.equinox.p2.jarprocessor_1.0.100.v20090520-1905.jar -org.eclipse.equinox.p2.metadata_1.0.100.v20090525.jar -org.eclipse.equinox.p2.metadata.repository_1.0.101.R35x_v20090812.jar -org.eclipse.equinox.p2.repository_1.0.1.v20090901-1041.jar -org.eclipse.equinox.preferences_3.2.300.v20090520-1800.jar -org.eclipse.equinox.preferences.source_3.2.300.v20090520-1800.jar -org.eclipse.equinox.registry_3.4.100.v20090520-1800.jar -org.eclipse.equinox.registry.source_3.4.100.v20090520-1800.jar -org.eclipse.equinox.security_1.0.100.v20090520-1800.jar -org.eclipse.equinox.security.macosx_1.100.0.v20090520-1800.jar -org.eclipse.equinox.security.macosx.source_1.100.0.v20090520-1800.jar -org.eclipse.equinox.security.win32.x86_1.0.100.v20090520-1800.jar -org.eclipse.equinox.security.win32.x86.source_1.0.100.v20090520-1800.jar -org.eclipse.equinox.simpleconfigurator_1.0.101.R35x_v20090807-1100.jar -org.eclipse.equinox.simpleconfigurator.source_1.0.101.R35x_v20090807-1100.jar -org.eclipse.equinox.util_1.0.100.v20090520-1800.jar -org.eclipse.equinox.util.source_1.0.100.v20090520-1800.jar -org.eclipse.help_3.4.1.v20090805_35x.jar -org.eclipse.help.source_3.4.1.v20090805_35x.jar -org.eclipse.jdt.launching.macosx_3.2.0.v20090527.jar -org.eclipse.jdt.launching.macosx.source_3.2.0.v20090527.jar -org.eclipse.jdt.launching.ui.macosx_1.0.0.v20090527.jar -org.eclipse.jdt.launching.ui.macosx.source_1.0.0.v20090527.jar -org.eclipse.jface_3.5.1.M20090826-0800.jar -org.eclipse.jface.databinding_1.3.1.M20090826-0800.jar -org.eclipse.jface.databinding.source_1.3.1.M20090826-0800.jar -org.eclipse.jface.source_3.5.1.M20090826-0800.jar -org.eclipse.jface.text_3.5.1.r351_v20090708-0800.jar -org.eclipse.osgi_3.5.1.R35x_v20090827.jar -org.eclipse.osgi.services_3.2.0.v20090520-1800.jar -org.eclipse.osgi.services.source_3.2.0.v20090520-1800.jar -org.eclipse.osgi.source_3.5.1.R35x_v20090827.jar -org.eclipse.rcp_3.5.0.v200909170800.jar -org.eclipse.rcp.source_3.5.0.v200909170800.jar -org.eclipse.swt_3.5.1.v3555a.jar -org.eclipse.swt.carbon.macosx_3.5.1.v3555a.jar -org.eclipse.swt.carbon.macosx.source_3.5.1.v3555a.jar -org.eclipse.swt.cocoa.macosx_3.5.1.v3555a.jar -org.eclipse.swt.cocoa.macosx.source_3.5.1.v3555a.jar -org.eclipse.swt.cocoa.macosx.x86_64_3.5.1.v3555a.jar -org.eclipse.swt.cocoa.macosx.x86_64.source_3.5.1.v3555a.jar -org.eclipse.swt.gtk.linux.ppc_3.5.1.v3555a.jar -org.eclipse.swt.gtk.linux.ppc.source_3.5.1.v3555a.jar -org.eclipse.swt.gtk.linux.s390_3.5.0.v3550b.jar -org.eclipse.swt.gtk.linux.s390.source_3.5.0.v3550b.jar -org.eclipse.swt.gtk.linux.s390x_3.5.0.v3550b.jar -org.eclipse.swt.gtk.linux.s390x.source_3.5.0.v3550b.jar -org.eclipse.swt.gtk.linux.x86_3.5.1.v3555a.jar -org.eclipse.swt.gtk.linux.x86_64_3.5.1.v3555a.jar -org.eclipse.swt.gtk.linux.x86_64.source_3.5.1.v3555a.jar -org.eclipse.swt.gtk.linux.x86.source_3.5.1.v3555a.jar -org.eclipse.swt.gtk.solaris.sparc_3.5.1.v3555a.jar -org.eclipse.swt.gtk.solaris.sparc.source_3.5.1.v3555a.jar -org.eclipse.swt.gtk.solaris.x86_3.5.1.v3555a.jar -org.eclipse.swt.gtk.solaris.x86.source_3.5.1.v3555a.jar -org.eclipse.swt.motif.aix.ppc_3.5.1.v3555a.jar -org.eclipse.swt.motif.aix.ppc.source_3.5.1.v3555a.jar -org.eclipse.swt.motif.hpux.ia64_32_3.5.1.v3555a.jar -org.eclipse.swt.motif.hpux.ia64_32.source_3.5.1.v3555a.jar -org.eclipse.swt.motif.hpux.PA_RISC_3.5.0.HEAD.jar -org.eclipse.swt.motif.hpux.PA_RISC.source_3.5.0.HEAD.jar -org.eclipse.swt.motif.linux.x86_3.5.1.v3555a.jar -org.eclipse.swt.motif.linux.x86.source_3.5.1.v3555a.jar -org.eclipse.swt.motif.solaris.sparc_3.5.1.v3555a.jar -org.eclipse.swt.motif.solaris.sparc.source_3.5.1.v3555a.jar -org.eclipse.swt.photon.qnx.x86_3.5.1.v3555a.jar -org.eclipse.swt.photon.qnx.x86.source_3.5.1.v3555a.jar -org.eclipse.swt.win32.win32.x86_3.5.1.v3555a.jar -org.eclipse.swt.win32.win32.x86_64_3.5.1.v3555a.jar -org.eclipse.swt.win32.win32.x86_64.source_3.5.1.v3555a.jar -org.eclipse.swt.win32.win32.x86.source_3.5.1.v3555a.jar -org.eclipse.swt.wpf.win32.x86_3.5.1.v3555a.jar -org.eclipse.swt.wpf.win32.x86.source_3.5.1.v3555a.jar -org.eclipse.text_3.5.0.v20090513-2000.jar -org.eclipse.ui_3.5.1.M20090902-1000.jar -org.eclipse.ui.carbon_4.0.0.I20090525-2000.jar -org.eclipse.ui.carbon.source_4.0.0.I20090525-2000.jar -org.eclipse.ui.cocoa_1.0.0.I20090525-2000.jar -org.eclipse.ui.cocoa.source_1.0.0.I20090525-2000.jar -org.eclipse.ui.console_3.4.0.v20090513.jar -org.eclipse.ui.editors_3.5.0.v20090527-2000.jar -org.eclipse.ui.forms_3.4.1.v20090714_35x.jar -org.eclipse.ui.ide_3.5.1.M20090826-0800.jar -org.eclipse.ui.source_3.5.1.M20090902-1000.jar -org.eclipse.ui.views_3.4.1.M20090826-0800.jar -org.eclipse.ui.win32_3.2.100.v20090429-1800.jar -org.eclipse.ui.win32.source_3.2.100.v20090429-1800.jar -org.eclipse.ui.workbench_3.5.1.M20090826-0800a.jar -org.eclipse.ui.workbench.source_3.5.1.M20090826-0800a.jar -org.eclipse.ui.workbench.texteditor_3.5.0.v20090603.jar -org.eclipse.update.configurator_3.3.0.v20090312.jar -org.eclipse.update.configurator.source_3.3.0.v20090312.jar -org.eclipse.update.core.linux_3.2.100.v20081008.jar -org.eclipse.update.core.linux.source_3.2.100.v20081008.jar -org.eclipse.update.core.win32_3.2.100.v20080107.jar -org.eclipse.update.core.win32.source_3.2.100.v20080107.jar diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/.classpath b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/.classpath deleted file mode 100755 index e48a290e..00000000 --- a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/.project b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/.project deleted file mode 100755 index 82b03fd2..00000000 --- a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.nebula.compositetable - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/META-INF/MANIFEST.MF b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/META-INF/MANIFEST.MF deleted file mode 100755 index 099b1e22..00000000 --- a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/META-INF/MANIFEST.MF +++ /dev/null @@ -1,16 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Compositetable Plug-in -Bundle-SymbolicName: org.eclipse.nebula.compositetable -Bundle-Version: 1.0.0 -Bundle-ClassPath: . -Bundle-Vendor: The Nebula Project, from outer space -Bundle-Localization: plugin -Export-Package: org.eclipse.swt.nebula.widgets.compositetable, - org.eclipse.swt.nebula.widgets.compositetable.day, - org.eclipse.swt.nebula.widgets.compositetable.day.internal, - org.eclipse.swt.nebula.widgets.compositetable.internal, - org.eclipse.swt.nebula.widgets.compositetable.month, - org.eclipse.swt.nebula.widgets.compositetable.month.internal, - org.eclipse.swt.nebula.widgets.compositetable.timeeditor -Require-Bundle: org.eclipse.swt diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/build.properties b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/build.properties deleted file mode 100755 index 876835f3..00000000 --- a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = . -output.. = . -bin.includes = META-INF/,\ - org/ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbsoluteLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbsoluteLayout.class deleted file mode 100755 index f20bf7fc..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbsoluteLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractGridRowLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractGridRowLayout.class deleted file mode 100755 index 88269fef..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractGridRowLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$1.class deleted file mode 100755 index 1533fcb6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$2.class deleted file mode 100755 index 3c7d15e6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$3.class deleted file mode 100755 index afe70f8b..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$4.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$4.class deleted file mode 100755 index 90d8c6ac..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader$4.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader.class deleted file mode 100755 index 06bfceb0..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractNativeHeader.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSelectableRow.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSelectableRow.class deleted file mode 100755 index a829a075..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSelectableRow.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader$1.class deleted file mode 100755 index 7ec76f0a..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader$2.class deleted file mode 100755 index 23d71ce8..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader.class deleted file mode 100755 index 262c9683..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/AbstractSortableHeader.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ColumnControlListener.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ColumnControlListener.class deleted file mode 100755 index ff1b813c..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ColumnControlListener.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTable$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTable$1.class deleted file mode 100755 index 3e3d25df..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTable$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTable.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTable.class deleted file mode 100755 index 2813f204..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTable.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTableLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTableLayout.class deleted file mode 100755 index 0d4de345..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/CompositeTableLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/DeleteAdapter.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/DeleteAdapter.class deleted file mode 100755 index 3bb1e5ff..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/DeleteAdapter.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$1.class deleted file mode 100755 index 1fddaf9a..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$2.class deleted file mode 100755 index 59a42c03..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$3.class deleted file mode 100755 index c5aa8a6b..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$4.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$4.class deleted file mode 100755 index adbaf998..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$4.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$5.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$5.class deleted file mode 100755 index ba53d93f..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$5.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$6.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$6.class deleted file mode 100755 index 6bb349cc..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder$6.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder.class deleted file mode 100755 index a0e9fd48..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/EmptyTablePlaceholder.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/GridRowLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/GridRowLayout.class deleted file mode 100755 index 0fc82af1..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/GridRowLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$1.class deleted file mode 100755 index 8844d5b1..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$2.class deleted file mode 100755 index fb701d60..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$HeaderControlListener.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$HeaderControlListener.class deleted file mode 100755 index d9c90e62..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout$HeaderControlListener.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout.class deleted file mode 100755 index 4203c440..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/HeaderLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IDeleteHandler.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IDeleteHandler.class deleted file mode 100755 index 3502b5d1..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IDeleteHandler.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IInsertHandler.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IInsertHandler.class deleted file mode 100755 index 36996d12..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IInsertHandler.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IRowContentProvider.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IRowContentProvider.class deleted file mode 100755 index 800ea96d..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IRowContentProvider.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IRowFocusListener.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IRowFocusListener.class deleted file mode 100755 index df186347..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/IRowFocusListener.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$1.class deleted file mode 100755 index 26659e28..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$10.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$10.class deleted file mode 100755 index 883b8e3a..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$10.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$11.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$11.class deleted file mode 100755 index 50df1531..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$11.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$12.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$12.class deleted file mode 100755 index c849b0a3..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$12.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$2.class deleted file mode 100755 index 2583b9af..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$3.class deleted file mode 100755 index 9a9f5bc5..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$4.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$4.class deleted file mode 100755 index 920752bf..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$4.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$5.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$5.class deleted file mode 100755 index 552ee7bf..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$5.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$6.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$6.class deleted file mode 100755 index c2a20438..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$6.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$7.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$7.class deleted file mode 100755 index 78a21912..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$7.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$8.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$8.class deleted file mode 100755 index fb5a502d..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$8.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$9.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$9.class deleted file mode 100755 index 995f5abe..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable$9.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable.class deleted file mode 100755 index f8bc7ebb..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/InternalCompositeTable.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout$1.class deleted file mode 100755 index 3a52d515..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout$GridColumnControlListener.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout$GridColumnControlListener.class deleted file mode 100755 index 1c2329bf..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout$GridColumnControlListener.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout.class deleted file mode 100755 index 6ecfa845..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ResizableGridRowLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/RowConstructionListener.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/RowConstructionListener.class deleted file mode 100755 index 3b19edc6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/RowConstructionListener.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/RowFocusAdapter.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/RowFocusAdapter.class deleted file mode 100755 index d257eb52..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/RowFocusAdapter.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ScrollEvent.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ScrollEvent.class deleted file mode 100755 index 98618da4..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ScrollEvent.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ScrollListener.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ScrollListener.class deleted file mode 100755 index 5622fae3..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/ScrollListener.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$1.class deleted file mode 100755 index da9c7de7..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$2.class deleted file mode 100755 index 4efb4751..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$3.class deleted file mode 100755 index 44aecbd6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow.class deleted file mode 100755 index 1c8d5795..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/TableRow.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableItemEvent.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableItemEvent.class deleted file mode 100755 index 69451ea0..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableItemEvent.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableItemEventHandler.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableItemEventHandler.class deleted file mode 100755 index fcbc396e..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableItemEventHandler.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableSelectionChangeListener.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableSelectionChangeListener.class deleted file mode 100755 index 03043a27..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/CalendarableSelectionChangeListener.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$1.class deleted file mode 100755 index d1771ac1..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$10.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$10.class deleted file mode 100755 index d40cdf88..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$10.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$11.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$11.class deleted file mode 100755 index 2f7bab34..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$11.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$12.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$12.class deleted file mode 100755 index e61cf030..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$12.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$13.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$13.class deleted file mode 100755 index 85b4b8c9..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$13.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$2.class deleted file mode 100755 index 1f7d2ec6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$3.class deleted file mode 100755 index c942c65a..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$4.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$4.class deleted file mode 100755 index 70a25583..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$4.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$5.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$5.class deleted file mode 100755 index 7f19c4fe..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$5.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$6.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$6.class deleted file mode 100755 index a50f6330..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$6.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$7.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$7.class deleted file mode 100755 index a2584e8d..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$7.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$8.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$8.class deleted file mode 100755 index 3c0a6eae..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$8.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$9.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$9.class deleted file mode 100755 index 952995cb..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor$9.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor.class deleted file mode 100755 index cd70314e..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditor.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditorSelection.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditorSelection.class deleted file mode 100755 index c7b3aa50..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/DayEditorSelection.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/ICalendarableItemControl.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/ICalendarableItemControl.class deleted file mode 100755 index 30e13092..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/ICalendarableItemControl.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/NewEvent.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/NewEvent.class deleted file mode 100755 index 5f277766..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/NewEvent.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/SelectionChangeEvent.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/SelectionChangeEvent.class deleted file mode 100755 index a92943b6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/SelectionChangeEvent.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl$1.class deleted file mode 100755 index 859363a0..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl$2.class deleted file mode 100755 index 8874b480..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl.class deleted file mode 100755 index 721fcc29..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/DayEditorCalendarableItemControl.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/EventLayoutComputer$EventLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/EventLayoutComputer$EventLayout.class deleted file mode 100755 index 77b4676f..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/EventLayoutComputer$EventLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/EventLayoutComputer.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/EventLayoutComputer.class deleted file mode 100755 index 7999c770..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/EventLayoutComputer.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlice$TimeSliceAcrossTimeLayout.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlice$TimeSliceAcrossTimeLayout.class deleted file mode 100755 index c5111ec5..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlice$TimeSliceAcrossTimeLayout.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlice.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlice.class deleted file mode 100755 index 8b5d4cf0..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlice.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$1.class deleted file mode 100755 index f3f7d141..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$2.class deleted file mode 100755 index c836b687..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$3.class deleted file mode 100755 index 97056e62..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$4.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$4.class deleted file mode 100755 index be044fe6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$4.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$5.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$5.class deleted file mode 100755 index 7f0b0fab..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$5.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$6.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$6.class deleted file mode 100755 index 46890c75..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot$6.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot.class deleted file mode 100755 index 0a81a975..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/TimeSlot.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/clock.png b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/clock.png deleted file mode 100755 index d43f6cad..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/clock.png and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/clock.svg b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/clock.svg deleted file mode 100755 index 2ca33c59..00000000 --- a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/day/internal/clock.svg +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/DuckType$Wrapper.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/DuckType$Wrapper.class deleted file mode 100755 index 5fd779fd..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/DuckType$Wrapper.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/DuckType.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/DuckType.class deleted file mode 100755 index 535e05bd..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/DuckType.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ISelectableRegionControl.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ISelectableRegionControl.class deleted file mode 100755 index d0518ff0..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ISelectableRegionControl.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ReflectedMethod.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ReflectedMethod.class deleted file mode 100755 index 7f702ca4..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ReflectedMethod.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ReflectedProperty.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ReflectedProperty.class deleted file mode 100755 index 280ac103..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/ReflectedProperty.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/RelaxedDuckType.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/RelaxedDuckType.class deleted file mode 100755 index 968027a1..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/internal/RelaxedDuckType.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$1.class deleted file mode 100755 index b3f4b4ff..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$2.class deleted file mode 100755 index eebbf55e..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$3.class deleted file mode 100755 index be53aa93..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar.class deleted file mode 100755 index ec32b9f6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendar.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendarSelectedDay.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendarSelectedDay.class deleted file mode 100755 index 92fe904e..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/MonthCalendarSelectedDay.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$1.class deleted file mode 100755 index c7729981..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$2.class deleted file mode 100755 index 545a44bb..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$3.class deleted file mode 100755 index 16db9cc6..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$4.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$4.class deleted file mode 100755 index 3a4743f0..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day$4.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day.class deleted file mode 100755 index 33aa6555..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Day.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$1.class deleted file mode 100755 index 8e7fe9b5..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$2.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$2.class deleted file mode 100755 index 3e988d21..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$2.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$3.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$3.class deleted file mode 100755 index 95371c81..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$3.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$4.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$4.class deleted file mode 100755 index d62613f9..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl$4.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl.class deleted file mode 100755 index c8fd27bb..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/MonthCalendarableItemControl.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Week.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Week.class deleted file mode 100755 index 85da55ba..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/Week.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/WeekHeader.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/WeekHeader.class deleted file mode 100755 index 89cbb915..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/month/internal/WeekHeader.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/AbstractEventEditor.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/AbstractEventEditor.class deleted file mode 100755 index b921f4b5..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/AbstractEventEditor.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableItem$1.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableItem$1.class deleted file mode 100755 index 8e8c9f2a..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableItem$1.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableItem.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableItem.class deleted file mode 100755 index 8d34ae3a..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableItem.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableModel.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableModel.class deleted file mode 100755 index 2231bc47..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/CalendarableModel.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/EventContentProvider.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/EventContentProvider.class deleted file mode 100755 index 25c5ec48..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/EventContentProvider.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/EventCountProvider.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/EventCountProvider.class deleted file mode 100755 index 9b70044a..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/EventCountProvider.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/IEventEditor.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/IEventEditor.class deleted file mode 100755 index e9b652e4..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/IEventEditor.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/ModelObject.class b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/ModelObject.class deleted file mode 100755 index e9f9f9a3..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/org/eclipse/swt/nebula/widgets/compositetable/timeeditor/ModelObject.class and /dev/null differ diff --git a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/src.zip b/contrib/applications/nxplot/org.eclipse.nebula.compositetable/src.zip deleted file mode 100755 index 0cbb560b..00000000 Binary files a/contrib/applications/nxplot/org.eclipse.nebula.compositetable/src.zip and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/.classpath b/contrib/applications/nxplot/sgtgraphics/.classpath deleted file mode 100755 index 1fa3e680..00000000 --- a/contrib/applications/nxplot/sgtgraphics/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/contrib/applications/nxplot/sgtgraphics/.project b/contrib/applications/nxplot/sgtgraphics/.project deleted file mode 100755 index ae3e7a30..00000000 --- a/contrib/applications/nxplot/sgtgraphics/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - sgtgraphics - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/sgtgraphics/META-INF/MANIFEST.MF b/contrib/applications/nxplot/sgtgraphics/META-INF/MANIFEST.MF deleted file mode 100755 index e1899be5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/META-INF/MANIFEST.MF +++ /dev/null @@ -1,10 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Sgtgraphics Plug-in -Bundle-SymbolicName: sgtgraphics -Bundle-Version: 3.1.0 -Bundle-Localization: plugin -Export-Package: gov.noaa.pmel.sgt, - gov.noaa.pmel.sgt.dm, - gov.noaa.pmel.sgt.swing, - gov.noaa.pmel.util diff --git a/contrib/applications/nxplot/sgtgraphics/bin/META-INF/MANIFEST.MF b/contrib/applications/nxplot/sgtgraphics/bin/META-INF/MANIFEST.MF deleted file mode 100755 index 9bdb9833..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/META-INF/MANIFEST.MF +++ /dev/null @@ -1,62 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: gov.noaa.pmel.sgt.beans.PanelModelEditor - -Name: gov/noaa/pmel/sgt/beans/Page.class -Java-Bean: True - -Name: gov/noaa/pmel/sgt/beans/PageBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/sgt/beans/DataModel.class -Java-Bean: True - -Name: gov/noaa/pmel/sgt/beans/DataModelBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/sgt/beans/PanelModel.class -Java-Bean: True - -Name: gov/noaa/pmel/sgt/beans/PanelModelBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/sgt/beans/PanelModelCustomizer.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JSlider2.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JDateTimeGetter.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JSlider2DateBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JSlider2BeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JSlider2Date.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JStretchPanel.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JSlider2Double.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/beans/DateTimeEditor.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/beans/GeoDateEditor.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/beans/SliderHandle.class -Java-Bean: False - -Name: gov/noaa/pmel/swing/JSlider2DoubleBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JStretchPanelBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JDateTimeGetterBeanInfo.class -Design-Time-Only: True diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/eps/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/eps/package.html deleted file mode 100755 index 874d0856..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/eps/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Provides EPIC netCDF file support. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/io/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/io/package.html deleted file mode 100755 index 2b665a2f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/io/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Provides for input and output through data streams, serialization and the file system. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/PaneIcon16.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/PaneIcon16.gif deleted file mode 100755 index 5ebb6e2e..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/PaneIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/PaneIcon32.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/PaneIcon32.gif deleted file mode 100755 index 33b6e997..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/PaneIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/README.txt b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/README.txt deleted file mode 100755 index f7c64b69..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -This directory contains the scientific graphics toolkit (sgt). -The sgt is jdk1.2 compatible. - -Thanks to: - -Laurent Beigbeder for development of LogAxis and LogTransform. (2003-02-26) - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-2.0.txt b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-2.0.txt deleted file mode 100755 index 091b58c9..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-2.0.txt +++ /dev/null @@ -1,158 +0,0 @@ - Notes for Scientific Graphics Toolkit (sgt) - version 2.0 - February 12, 2001 - -$Id: RELEASE-NOTES-2.0.txt,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - -The major incompatability is the package name changes. The root package -gov.noaa.noaaserver has been changed to gov.noaa.pmel. This was done -to reflect the organization of origin rather than the project -responsible for the toolkits inception. The -gov.noaa.noaaserver.sgt.datamodel package was renamed to the shorted -gov.noaa.pmel.sgt.dm, since all the packages were renamed anyway. - -Packages gov.noaa.pmel.sgt.contour, gov.noaa.pmel.sgt.swing, and -gov.noaa.pmel.sgt.swing.prop added. These packages were added to -support contouring, swing, and attribute editing with swing dialogs. -The swing components replace and extend the awt classes which have -been deprecated. The current development plan for sgt includes -removing the deprecated classes from sgt. - -Package gov.noaa.pmel.sgt.demo older awt classes moved to -gov.noaa.pmel.sgt.demo.awt. These classes were moved out of demo to -prelude the dropping of support for awt. - -Packages gov.noaa.pmel.sgt.awt and gov.noaa.pmel.sgt.util have been -deprecated. These packages contain classes based on awt whose -functionality has been superceeded by classes in -gov.noaa.pmel.sgt.swing and gov.noaa.pmel.sgt.swing.prop. - -NOTE: - -Package gov.noaa.pmel.sgt (formerly gov.noaa.noaaserver.sgt) - -New Interfaces: - AbstractPane - ContourLevelAccess - IndexedColor - LabelDrawer - Moveable - TransformAccess - TransformColor - -New Classes: - CLIndexedColorMap - CLTransformColorMap - ContourLineAttribute - DefaultContourLineAttribute - IndexedColorMap - JPane - LabelDrawer1 - LabelDrawer2 - LayerStack - PlotMark - PointCollectionKey - TransformColorMap - -New Exception: - DataNotFoundException - -Classes moved to gov.noaa.pmel.util: - GeoDate - Point2D - Range - Range2D - Rectangle2D - TimePoint - TimeRange - IllegalTimeValueException - -Package gov.noaa.pmel.sgt.dm (formerly gov.noaa.noaaserver.sgt.datamodel) - -New Classes: - PointCollection - - -Package gov.noaa.pmel.sgt.awt (formerly gov.noaa.noaaserver.sgt.awt) - Entire package deprecated support of awt will be removed after - version 2.0. See gov.noaa.pmel.sgt.swing for replacement classes. - -Package gov.noaa.pmel.sgt.contour - Contour and ContourLine support contouring in sgt. These classes - used by GridCartesianRenderer. The classes were designed so that - the ContourLine would be accessible by the user application. - Labeling is handled such that labels can be added or removed after - the contour line has been generated. - -Package gov.noaa.pmel.sgt.demo (formerly gov.noaa.noaaserver.sgt.demo) - -New Classes: (These classes all use swing) - JGridDemo - JLayoutDemo - JPointDemo - JProfileDemo - JRealTimeDemo - JTimeSeriesDemo - PseudoRealTimeData - TAOMap - -Classes moved to gov.noaa.pmel.sgt.demo.awt - GridDemo - LayoutDemo - PointDemo - ProfileDemo - TimeSeriesDemo - - -Package gov.noaa.pmel.sgt.util (formerly gov.noaa.noaaserver.sgt.util) - Package deprecated. Support for awt will be removed after version - 2.0. See gov.noaa.pmel.sgt.swing.prop for replacement utility - classes. - - JClassTree moved to gov.noaa.pmel.sgt.swing and Units moved to - gov.noaa.pmel.util - -Utility classes in package gov.noaa.pmel.util - -New classes: - Domain - Point2D.Float - SoTDomain - SoTPoint - SoTRange - SoTRange.Double - SoTRange.GeoDate - SoTValue - SoTValue.Double - SoTValue.GeoDate - -The SoT classes were introduced to make creating Time/Space neutral -applications easier. The SoT classes are used by the Transform and -Axis classes. - -JDK 1.1.8 compatability. - -The following classes will not compile using a jdk 1.1.8 compiler. - - JPane (imports java.awt.print.*, java.awt.Graphics2D) - LabelDrawer2 (depends on Java2D) - JGraphicLayout (extends JPane) - JPlotLayout (extends JPane) - JLineProfileLayout (extends JPane, deprecated) - - All the demonstration applications in gov.noaa.pmel.sgt.demo use - JPane. - - The following ..swing.prop classes refrence JPane - GridAttributeDialog - LogoDialog - PointAttributeDialog - SGLabelDialog - SpaceAxisDialog - TimeAxisDialog - -While these classes won't compile using jdk1.1.8, if compiled with a -Java 2 compiler they will run under jdk1.1.8 if you don't print. The -swing classes haven't been tested under the jdk1.1.8 swing -implementation. - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-2.1.txt b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-2.1.txt deleted file mode 100755 index 69d6e217..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-2.1.txt +++ /dev/null @@ -1,68 +0,0 @@ - Scientific Graphics Toolkit (sgt) Version 2.1 - Release Notes - -$Id: RELEASE-NOTES-2.1.txt,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - -Introduction: -------------- - -This document describes the changes in the Scientific Graphics Toolkit -from version 2.0 to 2.1. - -Bug reports, comments, and suggestions can be sent to -dwd@pmel.noaa.gov or sgt@epic.noaa.gov. - -New Features: -------------- - -Two major new features have been added to SGT since its last -release. Both features require Java2D, which is available in JDK -version 1.2 and newer. - -Vectors. The datatype SGTVector has been implemented and the - VectorAttribute, VectorKey, VectorCartesianRenderer, and - VectorAttributeDialog classes have been added to support vector - drawing. The VectorAttribute class enables users to customize - vector head attributes (e.g. scale, min and max head size), color, - line attributes (width, cap and miter style), and optionally - placing a plot mark at the vector origin. See the javadoc for - more information. - - JPlotLayout has been expanded to include support for the - SGTVector datatype. - -Stroke lines. Stroke lines, where the width, dash properties, cap and - miter styles, are all selectable have been added. Line and - contour plotting now make use of the new stroke lines. - -Line key title. To better support dynamic changes in data a SGLabel - can be specified to describe a data object in a LineKey, - PointCollectionKey, and VectorKey. This feature was added so that - the key could be automatically updated when the data changed. - -GridAttributeDialog, LineAttributeDialog, PointAttributeDialog, and - VectorAttributeDialog now allow multiple JPanes to be registered. - This enables the dialog to notifiy both the main graphic JPane and - a JPane that contains a key that attribute changes have occured. - -Bug Fixes and Improvements: ---------------------------- - -A bug that required a Graphics object to be available before -setBatch(false) could be called has been fixed. This feature uses the -new init() method that is available in Pane and JPane. The init() -method is called with the Pane or JPane first becomes visible, -initializing those features that require a Graphics object reference. - -Several bugs have been fixed in JPlotLayout, relating to LineKey -placement, and using the new init() method. - -Known Issues This Release: --------------------------- - -GridAttributeDialog is still not complete. It presently only works -with an IndexedColorMap. - -Java2D is required for the new Stroke lines and Vector graphics to -work. - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-3.0.txt b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-3.0.txt deleted file mode 100755 index c797baff..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/RELEASE-NOTES-3.0.txt +++ /dev/null @@ -1,509 +0,0 @@ - Scientific Graphics Toolkit (sgt) Version 3.0 - SGT Beans Initial Release - Release Notes - -$Id: RELEASE-NOTES-3.0.txt,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - -Introduction: -------------- - -This document describes the changes in the Scientific Graphics Toolkit -from version 2.1 to 3.0 and introduces the first release of SGT Beans. - -Bug reports, comments, and suggestions can be sent to -Donald.W.Denbo@noaa.gov, sgt@epic.noaa.gov or preferrably reported -using the Mantis system at http://heron.pmel.noaa.gov:8082/mantis. - -New Features: -------------- - -The biggest new feature is the initial delivery of SGT Beans. The -three main beans Page, PanelModel, and DataModel can be used to -produce graphics more easily. These beans also enable a user to more -easily change the layout of existing graphics. [I will be making a -tutorial available in about 2 months.] - -New classes have been added to support graphical annotation. And a -new GeoDateArray class has been added to improve performance. - -Bug Fixes: ----------- - -To many to list. The major fixes include using repaint() internally -to make the drawing more robust. Problems with placing multiple JPanes -in a single JFrame have been addressed and printing has been updated -to work after the above bug fixes :-). - -Known Existing Problems: ------------------------- - -SGT Beans require jdk 1.4. This requirement is because I use -XMLEncoder to serialize SGT Beans. - -The JRealTimeDemo demonstrates a problem that occurs when SGT is -forced to redraw too rapidly. On Solaris, the JPanel goes blank until -the repainting is done. - -Printing SGT Beans with titled borders cause the graphic to be shifted -down but not rescaled. The result is the border overplot on the -graphic. - -The Page SGT Bean doesn't account for the extra space a pixel -rendering requires, causing the pixels to overlap the axes. - -Future Features: ---------------- - -Presently SGT Beans don't use a LayoutManager to position Panels on -the Page. I will be developing the interface and visual customization -classes necessary to support SpringLayout. Eventually :-(. - -Deprecated Classes: ------------------- - -The following classes are now deprecated and will be removed at some -future sgt release. - -gov.noaa.pmel.sgt.Pane -- use gov.noaa.pmel.sgt.JPane -gov.noaa.pmel.sgt.swing.JLineProfileLayout -- use gov.noaa.pmel.sgt.swing.JPlotLayout - -in gov.noaa.pmel.util: - -SoTRange.GeoDate -- use SoTRange.Time -SoTValue.GeoDate -- use SoTValue.Time -TimePoint -- use SoTPoint -TimeRange -- use SoTRange - -New Packages: -------------- - -gov.noaa.pmel.sgt.beans - -New Classes: ------------- -For details see the JavaDoc. - -gov.noaa.pmel.sgt - AnnotationCartesianRenderer - AttributeChangeEvent - DataKey - LayerControl - NegativeLogException - -gov.noaa.pmel.sgt.demo - JLogLogDemo - BeanDemo - -gov.noaa.pmel.sgt.dm - Annotation - Annote - SGT3DVector - -gov.noaa.pmel.sgt.swing.prop - ColorDialog - ColorEntryPanel - RulerDialog - -gov.noaa.pmel.swing - FocusableSwatch - MRJUtil - Swatch - SwatchGroup - ThreeDotsButton - ThreeDotsIcon - -gov.noaa.pmel.util - EPICSystem - GeoDateArray - SimpleFileFilter - -New Methods and Constructors: ------------------------------ -For details see the JavaDoc. - -gov.noaa.pmel.sgt - AbstractPane - new fields - DEFAULT_SCALE - TO_FIT - SHRINK_TO_FIT - new methods - Object[] getObjectsAt(int x,int y), - Object[] getObjectsAt(Point pt) - Point getZoomStart() - void setMouseEventsEnabled(boolean en) - boolean isMouseEventsEnabled() - void setPageScaleMode(int mode) - int getPageScaleMode() - - Attribute - new methods - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - Axis - new methods - void setLineColor(Color color) - Color getLineColor() - - AxisTransform - new constructors - AxisTransform(double p1, double p2, long t1, long t2) - new methods - double getTransP(long t) - long getLongTimeTransU(double p) - - CLIndexedColorMap - new methods - Color getColorByIndex(int indx) - - CartesianGraph - new methods - void setClip(long tmin, long tmax, double min, double max) - double getXUtoD2(double u) - double getYUtoD2(double u) - double getXUtoP(long t) - double getYUtoP(long t) - int getXUtoD(long t) - int getYUtoD(long t) - double getXUtoD2(GeoDate t) - double getYUtoD2(GeoDate t) - double getXUtoD2(long t) - double getYUtoD2(long t) - int getXUtoD(SoTValue val) - int getYUtoD(SoTValue val) - double getXUtoD2(SoTValue val) - double getYUtoD2(SoTValue val) - double getXUtoP(SoTValue val) - double getYUtoP(SoTValue val) - SoTValue getXPtoSoT(double p) - SoTValue getYPtoSoT(double p) - long getXPtoLongTime(double p) - long getYPtoLongTime(double p) - SoTPoint getPtoU(Point2D.Double loc) - SGTData getDataAt(Point pt) - - CartesianRenderer - new methdos - SGTData getDataAt(int x, int y) - SGTData getDataAt(Point pt) - - ColorKey - Fixed vertical orientation. - new constructor - ColorKey(Point2D.Double pt, Dimension2D size, int valign, int halign) - new methods - void addGraph(CartesianRenderer rend, SGLabel label) - void setColumns(int col) - void setLineLengthP(double len) - - ColorMap - new methods - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - Graph - new methods - SGTData getDataAt(Point pt) - - GridAttribute - new methods - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - GridCartesianRenderer - new methdos - SGTData getDataAt(Point pt) - unimplemented - - IndexedColor - new methods - Color getColorByIndex(int index) - - IndexedColorMap - new methods - Color getColorByIndex(int index) - - JPane - new methods - String getVersion() - Point getZoomStart() - Object[] getObjectsAt(int x, int y) - Object[] getObjectsAt(Point pt) - void setMouseEventsEnabled(boolean enable) - boolean isMouseEventsEnabled() - void setPageScaleMode(int mode) - int getPageScaleMode() - - Layer - new methods - double getXPtoD2(double xp) - double getYPtoD2(double yp) - LayerChild findChild(String id) - Iterator childIterator() - LayerChild[] getChildren() - Object[] getObjectsAt(int x, int y, boolean check) - - LayerContainer - unimplemented - - LayerStack - unimplemented - - LineAttribute - new methods - boolean equals(Object obj) - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - LineCartesianRenderer - new methods - SGTData getDataAt(Point pt) - unimplemented - - LineKey - new methods - void addGraph(CartesianRenderer rend, SGLabel label) - - LinearTransform - new methods - double getTransP(long t) - long getLongTimeTransU(double p) - - LogAxis - new implementation - - LogTransform - new implementation - - Pane - mew methods - String getVersion() - Point getZoomStart() - Object[] getObjectsAt(int x, int y) - Object[] getObjectsAt(point pt) - void setMouseEventsEnabled(boolean enable) - boolean isMouseEventsEnabled() - void setPageScaleMode(int mode) - int getPageScaleMode() - - PaneProxy - new methods - String getVersion() - Object[] getObjectsAt(int x, int y) - void setMouseEventsEnabled(boolean enable) - boolean isMouseEventsEnabled() - - PointAttribute - new methods - boolean equals(Object obj) - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - PointCartesianRenderer - new methods - SGTData getDataAt(Point pt) - unimplemented - - PointCollectionKey - new methods - void addGraph(CartesianRenderer rend, SGLabel label) - - Ruler - new methods - int getLabelInterval() - void setLabelInterval(int interval) - int getSignificantDigits() - void setSignificantDigist(int sig) - String getLabelFormat() - void setLabelFormat(String format) - Color getLabelColor() - void setLabelColor(Color color) - Color getLineColor() - void setLineColor(Color color) - - SGLabel - new methods - boolean equals(Object obj) - - VectorAttribute - new methods - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - VectorCartesianRenderer - new methods - SGTData getDataAt(Point pt) - unimplemented - - VectorKey - new methods - void setLineLengthP(double len) - void addGraph(CartesianRenderer rend, SGLabel label) - -gov.noaa.pmel.sgt.beans - all new package - -gov.noaa.pmel.sgt.contour - -gov.noaa.pmel.sgt.demo - -gov.noaa.pmel.sgt.dm - SGTGrid - new methods - GeoDateArray getGeoDateArray() - GeoDateArray getGeoDateArrayEdges() - - SGTLine - new methods - GeoDateArray getGeoDateArray() - - SGTPoint - new methods - long getLongTime() - - SGTTuple - - SGTVector - - SimpleGrid - new methods - GeoDateArray getGeoDateArray() - GeoDateArray getGeoDateArrayEdges() - void setTimeEdges(GeoDateArray tarray) - void setTimeArray(GeoDateArray tarray) - - SimpleLine - new constructor - SimpleLine(GeoDateArray tloc, double[] yloc, String title) - SimpleLine(double[] xloc, GeoDateArray tloc, String title) - new methods - GeoDateArray getGeoDateArray() - void setTimeArray(GeodDateArray tarray) - - SimplePoint - new constructor - SimplePoint(SoTPoint loc, String title) - new methods - long getLongTime() - void setTime(GeoDate date) - void setTime(long t) - - SimpleTuple - new methods - void setXArray(GeoDateArray tArray) - void setYArray(GeoDateArray tArray) - GeoDateArray getGeoDateArray() - -gov.noaa.pmel.sgt.swing - Draggable - new method - void setLocation(Point loc, boolean fireEvent) - - JGraphicLayout - new methods - Attribute findAttribute(String id) - void setAllClip(long tmin, long tmax, double min, double max) - - JPlotLayout - new methods - SoTDomain getGraphDomain() - - UserIcon - new methods - SoTPoint getLocationU() - void setLocationUNoVeto(SoTPoint loc) - void setLocationU(SoTPoint loc) - - ValueIcon - new methods - SoTPoint getLocationU() - void setLocationUNoVeto(SoTPoint loc) - void setLocationU(SoTPoint loc) - - ValueIconFormat - new methods - void setTimeFormat(String tfrmt) - String format(SoTPoint pt) - -gov.noaa.pmel.sgt.swing.prop - -gov.noaa.pmel.swing - SelectTimeDialog - new method - void setRange(long min, long max) - -gov.noaa.pmel.util - Domain - new constructors - Domain(Range2D xRange, Range2D yrange, boolean xRev, boolean yRev) - Domain(TimeRange tRange, Range2D yRange, boolean xRev, boolean yRev) - Domain(Range2D xRange, TimeRange tRange, boolean xRev, boolean yRev) - new methods - void setYReversed(boolean rev) - boolean isYReversed() - void setXReversed(boolean rev) - boolean isXReversed() - - Point2D - new methods - boolean equals(Object obj) - Point2D copy() - - Rectangle2D - new subclass - Rectangle2D.Float - new methods - void setWidth(double w) - double getWidth() - void setHeight(double h) - double getHeight() - void setX(double x) - double getX() - void setY(double y) - double getY() - Rectangle2D copy() - - SoTDomain - new constructor - SoTDomain(SoTRange xRange, SoTRange yRange, boolean xRev, boolean yRev) - new methods - SoTPoint getCenter() - void setXReversed(boolean rev) - boolean isXReversed() - void setYReversed(boolean rev) - boolean isYReversed() - - SoTPoint - new constructors - SoTPoint(double x, long y) - SoTPoint(long x, double y) - new methods - void setX(SoTValue x) - void setY(SoTValue y) - void add(SoTPoint point) - SoTPoint copy() - - SoTRange - new subclass - SoTRange.Time - - SoTValue - new sublcass - SoTValue.Time - new methods - void add(SoTValue val) - long getLongTime() - GeoDate getGeoDate() - - TimeRange - new constructor - TimeRange(long start, long end, long delta) diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/DataModelIcon16.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/DataModelIcon16.gif deleted file mode 100755 index 65a026f3..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/DataModelIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/DataModelIcon32.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/DataModelIcon32.gif deleted file mode 100755 index 5df53387..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/DataModelIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PageIcon16.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PageIcon16.gif deleted file mode 100755 index 292709ee..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PageIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PageIcon32.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PageIcon32.gif deleted file mode 100755 index 31ec4eb0..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PageIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PanelModelIcon16.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PanelModelIcon16.gif deleted file mode 100755 index 5fe6cc06..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PanelModelIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PanelModelIcon32.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PanelModelIcon32.gif deleted file mode 100755 index 6dfe217a..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/PanelModelIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignBottom24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignBottom24.gif deleted file mode 100755 index 62e921d4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignBottom24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignCenter24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignCenter24.gif deleted file mode 100755 index f19d8ed4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignCenter24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignJustifyHorizontal24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignJustifyHorizontal24.gif deleted file mode 100755 index 32a1070d..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignJustifyHorizontal24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignJustifyVertical24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignJustifyVertical24.gif deleted file mode 100755 index f5d4a00b..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignJustifyVertical24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignLeft24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignLeft24.gif deleted file mode 100755 index 4db364c0..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignLeft24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignRight24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignRight24.gif deleted file mode 100755 index 9c82ad46..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignRight24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignTop24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignTop24.gif deleted file mode 100755 index 8fd07a2e..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/AlignTop24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/DataModelSimple.png b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/DataModelSimple.png deleted file mode 100755 index dae8b724..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/DataModelSimple.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Edit24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Edit24.gif deleted file mode 100755 index a5af7d7c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Edit24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/New24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/New24.gif deleted file mode 100755 index 1cc488d4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/New24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewDataGroup24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewDataGroup24.gif deleted file mode 100755 index db272f72..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewDataGroup24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewLabel24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewLabel24.gif deleted file mode 100755 index 60589ed5..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewLabel24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewLegend24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewLegend24.gif deleted file mode 100755 index 57bfaf8c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/NewLegend24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Open24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Open24.gif deleted file mode 100755 index 2086bc29..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Open24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/PanelModelSimple.png b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/PanelModelSimple.png deleted file mode 100755 index b2cc5dd1..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/PanelModelSimple.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Preferences24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Preferences24.gif deleted file mode 100755 index 2e727b2c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Preferences24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Remove24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Remove24.gif deleted file mode 100755 index fa40604c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Remove24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/RunTimeSimple.png b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/RunTimeSimple.png deleted file mode 100755 index d90a4eb1..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/RunTimeSimple.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Save24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Save24.gif deleted file mode 100755 index bfa98a8d..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/Save24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/SaveAs24.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/SaveAs24.gif deleted file mode 100755 index 97eb6fa3..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/images/SaveAs24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/package.html deleted file mode 100755 index 6b00eda7..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/beans/package.html +++ /dev/null @@ -1,20 +0,0 @@ - - -Classes and interfaces that make up SGT Beans. The classes -Page, DataModel, and PanelModel -are the core bean classes. Classes that extend -PropertyPanel or DragBox are used with both -PanelModelCustomizer (called from IDE's) and -PanelModelEditor (designed to be called from users -code). - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/contour/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/contour/package.html deleted file mode 100755 index 3be8be18..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/contour/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - -Contour and polygon fill support. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/BeanDemoPanelModel.xml b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/BeanDemoPanelModel.xml deleted file mode 100755 index e36330cc..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/BeanDemoPanelModel.xml +++ /dev/null @@ -1,695 +0,0 @@ - - - - - 0 - - - - 501 - 400 - - - - - UpperRight - - - - 0 - - 255 - 255 - 255 - 255 - - - 255 - 255 - 255 - 255 - - - 124 - 124 - 124 - 255 - - - 178 - 178 - 178 - 255 - - - - - - 300 - 0 - 200 - 293 - - - - - Random - - - - - 0.4166666567325592 - - - 2.097222328186035 - - - 0.5 - - - 0.0833333358168602 - - - - - 1 - - - 0 - - - - 394 - 278 - 34 - 10 - - - - - Helvetica - 0 - 12 - - - - - 411 - 276 - - - - false - - - - Random - - - - - - - - - - - - - - - - - - - - 3.125 - - - 0.4166666567325592 - - - 0.0833333358168602 - - - 0.5 - - - - - 1 - - - - 308 - 128 - 10 - 34 - - - - - Helvetica - 0 - 12 - - - - - 316 - 145 - - - - false - - - 1 - - - - Random - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Random - - - - 0.18055555 - - - 0.44444445 - - - - - - - - - - UpperRight - - - - Label0 - - - - - 0.25 - - - 0.75 - - - 1.0138888359069824 - - - 3.75 - - - - - Label0 - - - Bean Demo - - - - - - - - UpperLeft - - - - 0 - - 255 - 255 - 255 - 255 - - - 255 - 255 - 255 - 255 - - - 124 - 124 - 124 - 255 - - - 178 - 178 - 178 - 255 - - - - - - 0 - 0 - 300 - 293 - - - - - Grid - - - - - 0.4166666567325592 - - - 2.375 - - - 0.5 - - - 0.0833333358168602 - - - - - 1 - - - 0 - - - - 102 - 279 - 38 - 11 - - - - - Helvetica - 0 - 13 - - - - - 121 - 277 - - - - false - - - - Grid - - - - - - - - - - - - - - - - - - - - 3.277777671813965 - - - 0.4166666567325592 - - - 0.0833333358168602 - - - 0.5 - - - - - 1 - - - - 7 - 121 - 11 - 38 - - - - - Helvetica - 0 - 13 - - - - - 16 - 140 - - - - false - - - 1 - - - - Grid - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Grid - - - - 1.2916666 - - - 0.29166666 - - - - - - - - - - UpperLeft - - - - ColorKey - - - - - 3.2916667461395264 - - - 1.125 - - - 2.930555582046509 - - - 0.4861111044883728 - - - - - ColorKey - - - 1 - - - 1 - - - - - - - - Bottom - - - - 0 - - 255 - 255 - 255 - 255 - - - 255 - 255 - 255 - 255 - - - 124 - 124 - 124 - 255 - - - 178 - 178 - 178 - 255 - - - - - - 0 - 293 - 500 - 107 - - - - - TimeSeries - - - - 3 - - - - 0.4166666567325592 - - - 6.291666507720947 - - - 0.5 - - - 0.0833333358168602 - - - - TimeSeries - - - - - - 172800000 - - - - - - - - 978307200000 - - - - - - - - 946684800000 - - - - - - - - - - - - 0.875 - - - 0.4166666567325592 - - - 0.0833333358168602 - - - 0.5 - - - - 4 - - - - 1 - - - - 15 - 317 - 10 - 34 - - - - - Helvetica - 0 - 12 - - - - - 23 - 334 - - - - false - - - 1 - - - - TimeSeries - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TimeSeries - - - - 0.15277778 - - - 0.11111111 - - - - - - - - - - Bottom - - - - - - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/TAO.dat b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/TAO.dat deleted file mode 100755 index e7a9736e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/TAO.dat +++ /dev/null @@ -1,59 +0,0 @@ -0;-95;0N 95W -2;-95;2N 95W -4;-95;4N 95W -5;-95;5N 95W -8;-95;8N 95W --2;-95;2S 95W --5;-95;5S 95W --8;-95;8S 95W -10;-95;10N 95W -12;-95;12N 95W -0;-110;0N 110W -2;-110;2N 110W -5;-110;5N 110W -8;-110;8N 110W --2;-110;2S 110W --5;-110;5S 110W --8;-110;8S 110W -0;-125;0N 125W -2;-125;2N 125W -5;-125;5N 125W -8;-125;8N 125W --2;-125;2S 125W --5;-125;5S 125W --8;-125;8S 125W -0;-140;0N 140W -2;-140;2N 140W -5;-140;5N 140W -7;-140;7N 140W -9;-140;9N 140W --2;-140;2S 140W --5;-140;5S 140W -0;-155;0N 155W -2;-155;2N 155W -5;-155;5N 155W -8;-155;8N 155W --2;-155;2S 155W --5;-155;5S 155W --8;-155;8S 155W -0;-170;0N 170W -2;-170;2N 170W -5;-170;5N 170W -8;-170;8N 170W --2;-170;2S 170W --5;-170;5S 170W --8;-170;8S 170W -0;-180;0N 180W -2;-180;2N 180W -5;-180;5N 180W -8;-180;8N 180W --2;-180;2S 180W --5;-180;5S 180W --8;-180;8S 180W -0;165;0N 165E -2;165;2N 165E -5;165;5N 165E -8;165;8N 165E --2;165;2S 165E --5;165;5S 165E --8;165;8S 165E diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/TRITON.dat b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/TRITON.dat deleted file mode 100755 index 63e856e8..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/TRITON.dat +++ /dev/null @@ -1,13 +0,0 @@ -0;156;0N 156E -2;156;2N 156E -5;156;5N 156E -8;156;8N 156E --2;156;2S 156E --5;156;5S 156E -0;147;0N 147E -2;147;2N 147E -5;147;5N 147E -0;137;0N 137E -2;137;2N 137E -5;137;5N 137E -7;137;7N 137E diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/coarserezcoast.bin b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/coarserezcoast.bin deleted file mode 100755 index 0af33235..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/coarserezcoast.bin and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/finerezcoast.bin b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/finerezcoast.bin deleted file mode 100755 index c9491a5a..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/finerezcoast.bin and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/ncBrowse48.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/ncBrowse48.gif deleted file mode 100755 index 35b8d687..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/ncBrowse48.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/ncBrowse96.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/ncBrowse96.gif deleted file mode 100755 index a476dcd4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/ncBrowse96.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/package.html deleted file mode 100755 index eeec276d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/package.html +++ /dev/null @@ -1,17 +0,0 @@ - - -JApplets and applications that demonstrate the use of -sgt. Some of these examples use the -gov.noaa.pmel.sgt.swing and -gov.noaa.pmel.sgt.swing.prop classes. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/query.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/query.gif deleted file mode 100755 index 3f98ed16..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/demo/query.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/dm/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/dm/package.html deleted file mode 100755 index 660d1e44..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/dm/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - -Classes and interfaces that define the sgt datamodel. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/overview.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/overview.html deleted file mode 100755 index 54fde6d5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/overview.html +++ /dev/null @@ -1,46 +0,0 @@ - - -

The Scientific Graphics Toolkit (SGT) is designed -to allow a graphics client developer a great deal of flexibility and -freedom. sgt is a package that greatly aids a developer -in creating graphics applets. sgt is not a general -purpose graphics package, but provides the tools to enable scientific -graphics to be easily incorporated into applications or -Applets.

- -

SGT has three main components, the {@link gov.noaa.pmel.sgt.JPane JPane}, -on which all graphics are drawn. The -{@link gov.noaa.pmel.sgt.Layer Layer}, of which several can be -associated with a single JPane, that insulates the -developer from device coordinates. And the -{@link gov.noaa.pmel.sgt.Graph Graph}, of -which a single instance can be associated with a Layer, -that transforms form user coordinates (e.g. cm/sec, time, etc) to the -layer coordinate system (physical coordinates). - -

Examples demonstrating the use of SGT are available in the {@link -gov.noaa.pmel.sgt.demo demo} package. These examples show how to -create SGT applications from scratch and how to use the {@link -gov.noaa.pmel.sgt.swing.JPlotLayout JPlotLayout} utility class. A tutorial - on using SGT to develop interactive graphics is now available. - -

The gov.noaa.pmel.sgt.awt and gov.noaa.pmel.sgt.util packages have -been deprecated. The functionality in gov.noaa.pmel.sgt.swing and -gov.noaa.pmel.sgt.swing.prop completely replaces the deprecated -classes. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- -@see gov.noaa.pmel.sgt.JPane -@see gov.noaa.pmel.sgt.Layer -@see gov.noaa.pmel.sgt.Graph - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/package.html deleted file mode 100755 index dbd23de4..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/package.html +++ /dev/null @@ -1,43 +0,0 @@ - - -Core classes for the Scientific Graphics Toolkit. - -

The Java Scientific Graphics Toolkit (sgt) is designed -to allow a graphics client developer a great deal of flexibility and -freedom. sgt is a package that greatly aids a developer -in creating graphics applets. sgt is not a general -purpose graphics package, but provides the tools to enable scientific -graphics to be easily incorporated into applications or -Applets.

- -

SGT has three main components, the JPane, on which all -graphics are drawn. The Layer, of which several can be -associated with a single JPane, that insulates the -developer from device coordinates. And the Graph, of -which a single instance can be associated with a Layer, -that transforms form user coordinates (e.g. cm/sec, time, etc) to the -layer coordinate system (physical coordinates). - -

Examples demonstrating the use of SGT are available in the {@link -gov.noaa.pmel.sgt.demo demo} package. These examples show how to -create SGT applications from scratch and how to use the {@link -gov.noaa.pmel.sgt.swing.JPlotLayout JPlotLayout} utility class. A tutorial - on using SGT to develop interactive graphics is now available. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- -@see gov.noaa.pmel.sgt.Pane -@see gov.noaa.pmel.sgt.JPane -@see gov.noaa.pmel.sgt.Layer -@see gov.noaa.pmel.sgt.Graph - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plot/Notes.txt b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plot/Notes.txt deleted file mode 100755 index 032994c1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plot/Notes.txt +++ /dev/null @@ -1,51 +0,0 @@ - JPlotPane Notes - - 11/30/2000 - -* Create JPlotPane - 1) create and initealizes managers. (Print, DnD, Layer, ...) - 2) other initialization efforts. - 3) clear pane? - -* addData(SGTData, PlotLayerHints) to JPlotPane - 1) create PlotLayer (data, hints) - - create Graph - - create Renderer and bind data - 2) invoke PlotLayerManager - as newLayer(PlotLayer) or reLayout() <- is this needed? - - - if newLayer - + get X-Y types (space/time, units) - + using hints match with existing LayerStack - + if needed create new LayerStack & add to JPlotPane - else find stack to add layer to... - + create new transform if needed or bind to existing transform - + create new axes if needed - - - if modified Layer - + check for X-Y axes owner - + check for transforms - + update Key - (once a PlotLayer is assigned to a LayerStack it - stays there unless explictly moved) - -* hints (should hints include values?) - 1) Keys (location- on layer, new layer, table, popup; position) - 2) Transforms (scale/offset, share, new) - 3) Axes (share, new, location) - 4) PlotLayer ... - -* modes - 1) Zoom - 2) Object Select - 3) Data Select - 4) Layer DnD (LayerStack is DnD client/server?) - 5) Default (none? Zoom?) - - -* LayerManager - 1) LayerManager should have its rules about what can be overlayed! - For example, raster grid should not be over a contour grid! - 2) LayerManager should be able to re-order the Layers in a - LayerStack? - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plot/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plot/package.html deleted file mode 100755 index 5068b357..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plot/package.html +++ /dev/null @@ -1,23 +0,0 @@ - - -Classes for the automatic layout of multiple Layers. - -

The classes in this package are designed to work together to create -an automated system for plot layout. Eventually, I hope to include -managers for printing, Drag-and-Drop, and plot layout. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- -@see gov.noaa.pmel.sgt.JPane -@see gov.noaa.pmel.sgt.Layer -@see gov.noaa.pmel.sgt.Graph - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plotmarkcodes.gif b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plotmarkcodes.gif deleted file mode 100755 index 6b2fbce5..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/plotmarkcodes.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/package.html deleted file mode 100755 index ec2d7223..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - -Components that use the package javax.swing. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/plotmarkcodes.png b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/plotmarkcodes.png deleted file mode 100755 index 16d181a4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/plotmarkcodes.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/prop/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/prop/package.html deleted file mode 100755 index 4147f9ea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/prop/package.html +++ /dev/null @@ -1,22 +0,0 @@ - - -Property dialogs for sgt components using -javax.swing. Dialogs that edit the properties of -attributes and other sgt objects do not, in general, work -on a copy of the object. Because the references to attributes are -one-way if a copy were created the editing would not affect most of -the references. If you want these dialogs to work on copies instead of -the actual object, the creation of the copy and updating of the -original, if the changes are applied, will need to be done in the -users application. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/sgt_logo.png b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/sgt_logo.png deleted file mode 100755 index 0d2f5cd7..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/sgt/swing/sgt_logo.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/space/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/space/package.html deleted file mode 100755 index 37f92e20..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/space/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - -Collaborative support classes for JavaSpaces and Jini. - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/swing/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/swing/package.html deleted file mode 100755 index f34bc46d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/swing/package.html +++ /dev/null @@ -1,10 +0,0 @@ - - -Classes and beans developed from the javax.swing package. - -

This package contains both gui classes that begin with a "J") -and non-visual support classes.

- - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/text/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/text/package.html deleted file mode 100755 index 3cc47829..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/text/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Provides classes and interfaces for handling text, dates, numbers, and messages. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/util/package.html b/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/util/package.html deleted file mode 100755 index 1b399125..00000000 --- a/contrib/applications/nxplot/sgtgraphics/bin/gov/noaa/pmel/util/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Contains date and time facilities and miscellaneous utility classes. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/build.properties b/contrib/applications/nxplot/sgtgraphics/build.properties deleted file mode 100755 index 34d2e4d2..00000000 --- a/contrib/applications/nxplot/sgtgraphics/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/contrib/applications/nxplot/sgtgraphics/src/META-INF/MANIFEST.MF b/contrib/applications/nxplot/sgtgraphics/src/META-INF/MANIFEST.MF deleted file mode 100755 index 9bdb9833..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/META-INF/MANIFEST.MF +++ /dev/null @@ -1,62 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: gov.noaa.pmel.sgt.beans.PanelModelEditor - -Name: gov/noaa/pmel/sgt/beans/Page.class -Java-Bean: True - -Name: gov/noaa/pmel/sgt/beans/PageBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/sgt/beans/DataModel.class -Java-Bean: True - -Name: gov/noaa/pmel/sgt/beans/DataModelBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/sgt/beans/PanelModel.class -Java-Bean: True - -Name: gov/noaa/pmel/sgt/beans/PanelModelBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/sgt/beans/PanelModelCustomizer.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JSlider2.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JDateTimeGetter.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JSlider2DateBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JSlider2BeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JSlider2Date.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JStretchPanel.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/JSlider2Double.class -Java-Bean: True - -Name: gov/noaa/pmel/swing/beans/DateTimeEditor.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/beans/GeoDateEditor.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/beans/SliderHandle.class -Java-Bean: False - -Name: gov/noaa/pmel/swing/JSlider2DoubleBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JStretchPanelBeanInfo.class -Design-Time-Only: True - -Name: gov/noaa/pmel/swing/JDateTimeGetterBeanInfo.class -Design-Time-Only: True diff --git a/contrib/applications/nxplot/sgtgraphics/src/doc_stylesheet.css b/contrib/applications/nxplot/sgtgraphics/src/doc_stylesheet.css deleted file mode 100755 index fc492951..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/doc_stylesheet.css +++ /dev/null @@ -1,30 +0,0 @@ -/* Javadoc style sheet */ - -/* Define colors, fonts and other style attributes here to override the defaults */ - -/* Page background color */ -body { background-color: #FFFFFF } -/* code { color: #FF0000 } */ - -/* Table colors */ -#TableHeadingColor { background: #CCCCFF } /* Dark mauve */ -#TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ -#TableRowColor { background: #FFFFFF } /* White */ - -/* Font used in left-hand frame lists */ -#FrameTitleFont { font-size: normal; font-family: normal } -#FrameHeadingFont { font-size: normal; font-family: normal } -#FrameItemFont { font-size: normal; font-family: normal } - -/* Example of smaller, sans-serif font in frames */ -/* #FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ - -/* Navigation bar fonts and colors */ -#NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */ -#NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ -#NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} -#NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} - -#NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} -#NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/eps/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/eps/package.html deleted file mode 100755 index 874d0856..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/eps/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Provides EPIC netCDF file support. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/io/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/io/package.html deleted file mode 100755 index 2b665a2f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/io/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Provides for input and output through data streams, serialization and the file system. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AbstractPane.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AbstractPane.java deleted file mode 100755 index 8311e4d5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AbstractPane.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * $Id: AbstractPane.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Point; -import java.beans.PropertyChangeListener; - -/** - * Defines the basic sgt Pane functionality. Pane and - * JPane implement the AbstractPane - * interface. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - * @see Pane - * @see JPane - */ -public interface AbstractPane { - /** - * Align to top of printer page. - */ - public static final int TOP = 0; - /** - * Align to middle of printer page. - */ - public static final int MIDDLE = 1; - /** - * Align to bottom of printer page. - */ - public static final int BOTTOM = 2; - /** - * Align to left of printer page. - */ - public static final int LEFT = 0; - /** - * Align to center of printer page. - */ - public static final int CENTER = 1; - /** - * Align to right of printer page. - */ - public static final int RIGHT = 2; - /** - * Align to location specified on printer page. - */ - public static final int SPECIFIED_LOCATION = -1; - /** - * Fit onto printer page. Magnify or shrink to fit onto printer page. - * @since 3.0 - */ - public static final int TO_FIT = 0; - /** - * Default scale for printing. A value of 1.0 physical units = 72 pts. - * @since 3.0 - */ - public static final int DEFAULT_SCALE = 1; - /** - * Shrink to fit onto printer page. Will not magnify if graphic will already fit. - * @since 3.0 - */ - public static final int SHRINK_TO_FIT = 2; - /** - * The AbstractPane and all of the attached Classes - * will be drawn. Drawing will occur in an offscreen image and then - * copied to the screen. A new offscreen image is created on the - * first call to draw() or if the size of the pane has been - * changed. The offscreen image will be used as a "double" buffer - * when the screen requires redrawing. - *

- * Each Layer that has been added will be drawn in the - * order added, except if that order has been change using the - * moveLayerUp() or moveLayerDown() methods. - * - * @see java.awt.Graphics - * @see Layer - */ - public void draw(); - /** - * The AbstractPane and all of the attached Classes - * will be drawn. Drawing will occur using the supplied - * Graphics object. - * - * @param g User supplied Graphics object - * - * @see java.awt.Graphics - */ - public void draw(Graphics g); - /** - * The AbstractPane and all of the attached Classes - * will be drawn. Drawing will occur using the supplied - * Graphics object. And clipping will be done to the - * width and height. - * - * @param g User supplied Graphics object - * @param width clipping width - * @param height clipping height - * - * @see java.awt.Graphics - */ - public void draw(Graphics g, int width, int height); - /** - * This method is called when the AbstractPane first becomes - * visible. The types of operations that should be implemented here include - * those that require a valid Graphics object. - */ - public void init(); - /** - * Test if the current Graphics object is a printer. - * - * @return true if a printer - */ - public boolean isPrinter(); - /** - * Return an array of objects whose bounds include x,y. - * - * @since 3.0 - */ - public Object[] getObjectsAt(int x, int y); - /** - * Return an array of objects whose bounds are at point pt. - * - * @since 3.0 - */ - public Object[] getObjectsAt(Point pt); - /** - * Get the printer page size. - * - * @return page size - */ - public java.awt.Dimension getPageSize(); - /** - * Get the Pane identifier. - * - * @return String containing the Pane identifier. - */ - public String getId(); - /** - * Set the Pane identifier - */ - public void setId(String id); - /** - * Set printing scale mode. Allowable choices are TO_FIT, - * SHRINK_TO_FIT and - * DEFAULT_SCALE. Default = DEFAULT_SCALE. - * @param mode print page scaling - * @since 3.0 - * @see AbstractPane#DEFAULT_SCALE - * @see AbstractPane#TO_FIT - * @see AbstractPane#SHRINK_TO_FIT - */ - public void setPageScaleMode(int mode); - /** - * Set alignment for printing. - * - * @param vert vertical alignment - * @param horz horizontal alignment - * @see AbstractPane#TOP - * @see AbstractPane#MIDDLE - * @see AbstractPane#BOTTOM - * @see AbstractPane#LEFT - * @see AbstractPane#CENTER - * @see AbstractPane#RIGHT - * @see AbstractPane#SPECIFIED_LOCATION - */ - public void setPageAlign(int vert, int horz); - /** - * Set vertical alignment for printing. Allowed choices include TOP, - * MIDDLE, and BOTTOM for vert and - * LEFT, CENTER, and RIGHT - * for horz. Either can be SPECIFIED_LOCATION. - * - * @param vert vertical alignment - * @see AbstractPane#TOP - * @see AbstractPane#MIDDLE - * @see AbstractPane#BOTTOM - * @see AbstractPane#SPECIFIED_LOCATION - */ - public void setPageVAlign(int vert); - /** - * Set horizontal alignment for printing. Allowed choices include TOP, - * MIDDLE, and BOTTOM. - * - * @param horz horizontal alignment - * @see AbstractPane#LEFT - * @see AbstractPane#CENTER - * @see AbstractPane#RIGHT - * @see AbstractPane#SPECIFIED_LOCATION - */ - public void setPageHAlign(int horz); - /** - * Get printing scale mode. - * @return AUTO_SCALE, TO_FIT, or SHRINK_TO_FIT - * @since 3.0 - * @see AbstractPane#DEFAULT_SCALE - * @see AbstractPane#TO_FIT - * @see AbstractPane#SHRINK_TO_FIT - */ - public int getPageScaleMode(); - /** - * Get vertical alignment for printing. Allowed choices include - * LEFT, CENTER, and RIGHT. - * - * @return vertical alignment - * @see AbstractPane#TOP - * @see AbstractPane#MIDDLE - * @see AbstractPane#BOTTOM - * @see AbstractPane#SPECIFIED_LOCATION - */ - public int getPageVAlign(); - /** - * Get horizontal alignment for printing. - * - * @return horizontal alignment - * @see AbstractPane#LEFT - * @see AbstractPane#CENTER - * @see AbstractPane#RIGHT - * @see AbstractPane#SPECIFIED_LOCATION - */ - public int getPageHAlign(); - /** - * Set the printer page origin. Valid for HAlign = SPECIFIED_LOCATION or - * VAlign = SPECIFIED_LOCATION. - */ - public void setPageOrigin(java.awt.Point p); - /** - * Get the printer page origin. Valid for HAlign = SPECIFIED_LOCATION or - * VAlign = SPECIFIED_LOCATION. - */ - public java.awt.Point getPageOrigin(); - /** - * Get the first Layer associated with the Pane - * - * @return the first Layer object - */ - public Layer getFirstLayer(); - /** - * Get the Layer associated with the - * Pane indicated by the id. - * - * @param id identifier. - * @exception LayerNotFoundException The Layer indicated by the id was not found. - */ - public Layer getLayer(String id) throws LayerNotFoundException; - /** - * Get the Layer associated with the - * Pane indicated by the data id. - * - * @param id data identifier - * @exception LayerNotFoundException The Layer indicated by the id was not found. - * - * @see gov.noaa.pmel.sgt.dm.SGTData - */ - public Layer getLayerFromDataId(String id) throws LayerNotFoundException; - /* - * methods to get mouse input results - */ - /** - * Return the last object selected. Returns only objects - * that are part of Layers currently connected to the - * pane. AbstractPane tests - * each layer after a MOUSE_DOWN event for an object whose bounding box - * contains the mouse. The pane object then passes the event on to the next - * level. - */ - public Object getSelectedObject(); - /** - * Primarily used internally by sgt. This can also be used to mark - * an object as selected for use in an event handler. - */ - public void setSelectedObject(Object obj); - /** - * Return the device coordinates of the zoom action. The coordinates are - * in device units and may require transformation to the physical units or - * user units. - * - * @return zoom rectangle - */ - public java.awt.Rectangle getZoomBounds(); - /** - * Return the device coordinates of the start of the zoom action. The Point - * is in device coordinates and may require transformation to physical units - * or user units. Zoom start may be useful to indicate which graph to zoom. - * - * @return zoom start - * @since 3.0 - */ - public Point getZoomStart(); - /** - * Get the current selected object at a point. Used internally by - * sgt. - */ - public Object getObjectAt(int x, int y); - /** - * Get the bounding rectangle in pixels (device units). - * - * @return Rectangle object containing the bounding box for the pane. - **/ - public java.awt.Rectangle getBounds(); - /** - * Get the Component associated with - * the pane. - */ - public java.awt.Component getComponent(); - /* - * methods to handle ChangeEvent and PropertyChangeEvent's - */ - /** - * Turn on/off batching of updates to the pane. While - * batching is true property change events will - * not cause pane to redraw. When batching is - * turned back on if the pane has been modified it - * will then redraw. - */ - public void setBatch(boolean batch, String msg); - /** - * Turn on/off batching of updates to the pane. While - * batching is true property change events will - * not cause pane to redraw. When batching is - * turned back on if the pane has been modified it - * will then redraw. - */ - public void setBatch(boolean batch); - /** - * Is batching turned on? - */ - public boolean isBatch(); - /** - * Notify the pane that something has changed and a redraw - * is required. Used internally by sgt. - */ - public void setModified(boolean mod, String mess); - /** - * Has the plot been modified? - */ - public boolean isModified(); - /** - * Enable/disable the handling of MouseEvents by - * SGT. Disabling mouse events will turn off object selection, - * moveable, selectable, draggable, and zooming. - * - * @since 3.0 - */ - public void setMouseEventsEnabled(boolean enable); - /** - * Are MouseEvents enabled for processing by SGT? - * - * @since 3.0 - */ - public boolean isMouseEventsEnabled(); - /* - * Pane PropertyChange methods - */ - /** - * Add a PropertyChangeListener to the list. Properties for - * Pane and JPane include - * "objectSelected" and "zoomRectangle". - */ - public void addPropertyChangeListener(PropertyChangeListener l); - /** - * Remove the PropertyChangeListener from the list. - */ - public void removePropertyChangeListener(PropertyChangeListener l); - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AnnotationCartesianRenderer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AnnotationCartesianRenderer.java deleted file mode 100755 index fc8ac7ac..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AnnotationCartesianRenderer.java +++ /dev/null @@ -1,467 +0,0 @@ -/* - * $Id: AnnotationCartesianRenderer.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import java.awt.*; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Rectangle2D; -import java.awt.geom.GeneralPath; -//import java.awt.geom.*; - -import java.beans.PropertyChangeEvent; -import java.util.Iterator; - -import gov.noaa.pmel.sgt.dm.Annotation; -import gov.noaa.pmel.sgt.dm.Annote; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTPoint; -import gov.noaa.pmel.sgt.dm.SGTData; - -import gov.noaa.pmel.util.SoTPoint; -//import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.Point2D; - -/** - * Renders Annote and Annotation objects. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ -public class AnnotationCartesianRenderer extends CartesianRenderer { - /** - * @link aggregation - * @undirected - * @label annotation - * @supplierCardinality 1 - */ - private Annotation data_ = null; - - public AnnotationCartesianRenderer(CartesianGraph cg, - Annotation annotation, - Attribute attr) { - cg_ = cg; - data_ = annotation; - } - - public Attribute getAttribute() { - return null; - } - - public CartesianGraph getCartesianGraph() { - return cg_; - } - - public SGTData getDataAt(Point pt) { - SGTData data = null; - Annote note = null; - Iterator iter; -// System.out.println("point: " + pt); - Rectangle bnds; - - if(data_.hasLine()) { - iter = data_.getLineIterator(); - while(iter.hasNext()) { - note = (Annote)iter.next(); - bnds = note.getBounds(cg_); -// System.out.println("Line.Bounds: " + bnds); - if(note.getBounds(cg_).contains(pt)) { - return note; - } - } - } - if(data_.hasPoint()) { - iter = data_.getPointIterator(); - while(iter.hasNext()) { - note = (Annote)iter.next(); - bnds = note.getBounds(cg_); -// System.out.println("Point.Bounds: " + bnds); - if(bnds.contains(pt)) { - return note; - } - } - } - if(data_.hasText()) { - iter = data_.getTextIterator(); - while(iter.hasNext()) { - note = (Annote)iter.next(); - bnds = note.getBounds(cg_); -// System.out.println("Text.Bounds: " + bnds); - if(bnds.contains(pt)) { - return note; - } - } - } - if(data_.hasOval()) { - iter = data_.getOvalIterator(); - while(iter.hasNext()) { - note = (Annote)iter.next(); - bnds = note.getBounds(cg_); -// System.out.println("Oval.Bounds: " + bnds); - if(bnds.contains(pt)) { - return note; - } - } - } - if(data_.hasRect()) { - iter = data_.getRectIterator(); - while(iter.hasNext()) { - note = (Annote)iter.next(); - bnds = note.getBounds(cg_); -// System.out.println("Rect.Bounds: " + bnds); - if(bnds.contains(pt)) { - return note; - } - } - } - return data; - } -/** - * Render Annotation using java.awt.Graphic2D primatives. - */ - public void draw(Graphics g) { - if(cg_.clipping_) { -// System.out.println("clipping: on"); - int xmin, xmax, ymin, ymax; - int x, y, width, height; - if(cg_.xTransform_.isSpace()) { - xmin = cg_.getXUtoD(cg_.xClipRange_.start); - xmax = cg_.getXUtoD(cg_.xClipRange_.end); - } else { - xmin = cg_.getXUtoD(cg_.tClipRange_.start); - xmax = cg_.getXUtoD(cg_.tClipRange_.end); - } - if(cg_.yTransform_.isSpace()) { - ymin = cg_.getYUtoD(cg_.yClipRange_.start); - ymax = cg_.getYUtoD(cg_.yClipRange_.end); - } else { - ymin = cg_.getYUtoD(cg_.tClipRange_.start); - ymax = cg_.getYUtoD(cg_.tClipRange_.end); - } - if(xmin < xmax) { - x = xmin; - width = xmax - xmin; - } else { - x=xmax; - width = xmin - xmax; - } - if(ymin < ymax) { - y = ymin; - height = ymax - ymin; - } else { - y = ymax; - height = ymin - ymax; - } - g.setClip(x, y, width, height); - } - Graphics2D g2 = (Graphics2D)g; - Iterator iter; - if(data_.hasLine()) { - SGTLine line; - LineAttribute attr; - Annote.Line pLine; - iter = data_.getLineIterator(); - while(iter.hasNext()) { - pLine = (Annote.Line)iter.next(); - line = pLine.getLine(); - attr = pLine.getAttribute(); - // - renderLine(g2, line, attr); - } - } - if(data_.hasPoint()) { - SGTPoint point; - PointAttribute attr; - Annote.Point pPoint; - iter = data_.getPointIterator(); - while(iter.hasNext()) { - pPoint = (Annote.Point)iter.next(); - point = pPoint.getPoint(); - attr = pPoint.getAttribute(); - // - renderPoint(g2, point, attr); - } - } - if(data_.hasText()) { - SGLabel text; - SoTPoint location; - Annote.Text pText; - iter = data_.getTextIterator(); - while(iter.hasNext()) { - pText = (Annote.Text)iter.next(); - text = pText.getText(); - location = pText.getLocation(); - // - renderText(g2, location, text); - } - } - if(data_.hasOval()) { - SoTPoint pt1; - SoTPoint pt2; - LineAttribute attr; - Color color; - Annote.Oval pOval; - iter = data_.getOvalIterator(); - while(iter.hasNext()) { - pOval = (Annote.Oval)iter.next(); - pt1 = pOval.getUpperLeft(); - pt2 = pOval.getLowerRight(); - attr = pOval.getLineAttribute(); - color = pOval.getFillColor(); - // - renderOval(g2, pt1, pt2, attr, color); - } - } - if(data_.hasRect()) { - SoTPoint pt1; - SoTPoint pt2; - LineAttribute attr; - Color color; - Annote.Rect pRect; - iter = data_.getRectIterator(); - while(iter.hasNext()) { - pRect = (Annote.Rect)iter.next(); - pt1 = pRect.getUpperLeft(); - pt2 = pRect.getLowerRight(); - attr = pRect.getLineAttribute(); - color = pRect.getFillColor(); - // - renderRect(g2, pt1, pt2, attr, color); - } - } - /**@todo: implement this gov.noaa.pmel.sgt.CartesianRenderer abstract method*/ - // - // reset clip - // - Rectangle rect = cg_.getLayer().getPane().getBounds(); - g.setClip(rect); - } - - public void propertyChange(PropertyChangeEvent evt) { - modified("AnnotationCartesianRenderer: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - /** - * Render oval using Graphics2D - */ - private void renderOval(Graphics2D g2, SoTPoint pt1, SoTPoint pt2, - LineAttribute attr, Color color) { - Stroke stroke = getStrokeFromLineAttribute(attr); - // - float xPt1 = (float)cg_.getXUtoD2(pt1.getX()); - float yPt1 = (float)cg_.getYUtoD2(pt1.getY()); - float xPt2 = (float)cg_.getXUtoD2(pt2.getX()); - float yPt2 = (float)cg_.getYUtoD2(pt2.getY()); - float width = xPt2 - xPt1; - float height = yPt2 - yPt1; -// - Shape oval = new Ellipse2D.Float(xPt1, yPt1, width, height); - Paint savedPaint = g2.getPaint(); - Stroke savedStroke = g2.getStroke(); - Color savedColor = g2.getColor(); - // - if(color != null) { - g2.setPaint(color); - g2.fill(oval); - } - if(stroke != null) { - g2.setStroke(stroke); - g2.setColor(attr.getColor()); - g2.draw(oval); - } - g2.setPaint(savedPaint); - g2.setStroke(savedStroke); - g2.setColor(savedColor); - } - /** - * Render rect using Graphics2D - */ - private void renderRect(Graphics2D g2, SoTPoint pt1, SoTPoint pt2, - LineAttribute attr, Color color) { - Stroke stroke = getStrokeFromLineAttribute(attr); - // - float xPt1 = (float)cg_.getXUtoD2(pt1.getX()); - float yPt1 = (float)cg_.getYUtoD2(pt1.getY()); - float xPt2 = (float)cg_.getXUtoD2(pt2.getX()); - float yPt2 = (float)cg_.getYUtoD2(pt2.getY()); - float width = xPt2 - xPt1; - float height = yPt2 - yPt1; -// - Shape rect = new Rectangle2D.Float(xPt1, yPt1, width, height); - Paint savedPaint = g2.getPaint(); - Stroke savedStroke = g2.getStroke(); - Color savedColor = g2.getColor(); - // - if(color != null) { - g2.setPaint(color); - g2.fill(rect); - } - if(stroke != null) { - g2.setStroke(stroke); - g2.setColor(attr.getColor()); - g2.draw(rect); - } - g2.setPaint(savedPaint); - g2.setStroke(savedStroke); - g2.setColor(savedColor); - } -/** - * Render line using Graphics2D - */ - private void renderLine(Graphics2D g2, SGTLine line, LineAttribute attr) { - LineCartesianRenderer lcr = new LineCartesianRenderer(cg_, line, attr); - lcr.draw(g2); - /* - Stroke savedStroke = g2.getStroke(); - Color savedColor = g2.getColor(); - // - Stroke stroke = getStrokeFromLineAttribute(attr); - // build line - float[] xd; - float[] yd; - if(line.isXTime()) { - long[] xu = line.getGeoDateArray().getTime(); - xd = new float[xu.length]; - for(int i=0; i < xu.length; i++) { - xd[i] = (float)cg_.getXUtoD2(xu[i]); - } - } else { - double[] xu = line.getXArray(); - xd = new float[xu.length]; - for(int i=0; i < xu.length; i++) { - xd[i] = (float)cg_.getXUtoD2(xu[i]); - } - } - if(line.isYTime()) { - long[] yu = line.getGeoDateArray().getTime(); - yd = new float[yu.length]; - for(int i=0; i < yu.length; i++) { - yd[i] = (float)cg_.getYUtoD2(yu[i]); - } - } else { - double[] yu = line.getYArray(); - yd = new float[yu.length]; - for(int i=0; i < yu.length; i++) { - yd[i] = (float)cg_.getYUtoD2(yu[i]); - } - } - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xd.length); -// - int start = 0; - for(int i=0; i < xd.length; i++) { - if(!(Float.isNaN(xd[i]) || Float.isNaN(yd[i]))) { - path.moveTo(xd[i], yd[i]); - start = i+1; - break; - } - } - boolean move = false; - for(int i=start; i < xd.length; i++) { - if(Float.isNaN(xd[i]) || Float.isNaN(yd[i])) { - move = true; - continue; - } - if(move) { - path.moveTo(xd[i], yd[i]); - move = false; - } else { - path.lineTo(xd[i], yd[i]); - } - } - if(stroke != null) g2.setStroke(stroke); - g2.setColor(attr.getColor()); - g2.draw(path); - g2.setColor(savedColor); - g2.setStroke(savedStroke); */ - } -/** - * Render point using Graphics2D - */ - private void renderPoint(Graphics2D g, SGTPoint point, PointAttribute attr) { - PointCartesianRenderer pcr = new PointCartesianRenderer(cg_, point, attr); - pcr.draw(g); - } -/** - * Render label using Graphics2D - */ - private void renderText(Graphics2D g, SoTPoint loc, SGLabel text) { - double xp; - double yp; - if(loc.getX().isTime()) { - xp = cg_.getXUtoP(loc.getX().getLongTime()); - } else { - xp = cg_.getXUtoP(((Number)loc.getX().getObjectValue()).doubleValue()); - } - if(loc.getY().isTime()) { - yp = cg_.getYUtoP(loc.getY().getLongTime()); - } else { - yp = cg_.getYUtoP(((Number)loc.getY().getObjectValue()).doubleValue()); - } - text.setLocationP(new Point2D.Double(xp, yp)); - text.setLayer(cg_.getLayer()); - try { - text.draw(g); - } catch (LayerNotFoundException ex) { - ex.printStackTrace(); - } - } - - - private Stroke getStrokeFromLineAttribute(LineAttribute attr) { - BasicStroke stroke = null; - if(attr == null) return stroke; - switch(attr.getStyle()) { -// case LineAttribute.MARK: -// drawMark(g, xout, yout, lsize, attr); -// break; -// case LineAttribute.HIGHLIGHT: -// stroke_.drawHighlight(g, xout, yout, lsize, attr); -// break; - case LineAttribute.HEAVY: - stroke = new BasicStroke(attr.getWidth()); - break; - case LineAttribute.DASHED: - float[] dashes = {4.0f, 4.0f}; - stroke = new BasicStroke(1.0f, - BasicStroke.CAP_SQUARE, - BasicStroke.JOIN_MITER, - 10.0f, - dashes, - 0.0f); - break; - case LineAttribute.STROKE: - float[] arr = attr.getDashArray(); - if(arr == null || (arr.length <= 1)) { - stroke = new BasicStroke(attr.getWidth(), - attr.getCapStyle(), - attr.getMiterStyle(), - attr.getMiterLimit()); - } else { - stroke = new BasicStroke(attr.getWidth(), - attr.getCapStyle(), - attr.getMiterStyle(), - attr.getMiterLimit(), - attr.getDashArray(), - attr.getDashPhase()); - } - break; -// case LineAttribute.MARK_LINE: -// drawMark(g, xout, yout, lsize, attr); - default: -// case LineAttribute.SOLID: -// g.drawPolyline(xout, yout, lsize); - } - return stroke; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Attribute.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Attribute.java deleted file mode 100755 index c69d05ae..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Attribute.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * $Id: Attribute.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.beans.PropertyChangeListener; - -/** - * Defines an interface for classes that provide rendering - * information for sgt.dm classes. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public interface Attribute extends java.io.Serializable { - - /** - * Return a printable representation of the object. - * - * @return Description - */ - public String toString(); - /** - * Add listener for changes to attribute properties. The properties - * that can be listened for depend on the implementing class. - * - * @since 2.0 - */ - public void addPropertyChangeListener(PropertyChangeListener listener); - /** - * Remove change listener. - * - * @since 2.0 - */ - public void removePropertyChangeListener(PropertyChangeListener listener); - /** - * Set attribute id. - * - * @since 3.0 - */ - public void setId(String id); - /** - * Get attribute id. - * - * @since 3.0 - */ - public String getId(); - /** - * Batch the changes to the attribute. - * - * @since 3.0 - */ - public void setBatch(boolean batch); - /** - * Batch the changes to the attribute and set local flag. - * Determines whether AttributeChangeEvent will be set local. - * - * @since 3.0 - */ - public void setBatch(boolean batch, boolean local); - /** - * Is the attribute in batch mode? - * - * @since 3.0 - */ - public boolean isBatch(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AttributeChangeEvent.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AttributeChangeEvent.java deleted file mode 100755 index ab94a2ff..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AttributeChangeEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * $Id: AttributeChangeEvent.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import java.beans.PropertyChangeEvent; - -/** - * A class for wrapping local and remote property change events for attributes. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ -public class AttributeChangeEvent extends PropertyChangeEvent { - private boolean local_ = true; - - public AttributeChangeEvent(Object source, - String propertyName, - Object oldValue, - Object newValue) { - this(source, propertyName, oldValue, newValue, true); - } - - public AttributeChangeEvent(Object source, - String propertyName, - Object oldValue, - Object newValue, - boolean local) { - super(source, propertyName, oldValue, newValue); - local_ = local; - } - - public boolean isLocal() { - return local_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Axis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Axis.java deleted file mode 100755 index 64e75e5d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Axis.java +++ /dev/null @@ -1,734 +0,0 @@ -/* - * $Id: Axis.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Debug; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Font; -import java.awt.Color; - -/** - * Abstract base class for Cartesian axes. Cartesian axes are - * designed to be used with - * the CartesianGraph class. Axes and AxisTransforms - * can be registed with an Axis. This allows changes in both - * the physical range and user range to be immediatedly updated - * for the registered AxisTransforms and axes. - *

- * Cartesian axes can have their user coordinates be double values or time (as - * GeoDate objects). These have been separated into - * two child objects. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @see SpaceAxis - * @see TimeAxis -**/ -public abstract class Axis implements Selectable { - private String ident_; - /** @directed - * @label graph - */ - protected CartesianGraph graph_; - protected Vector registeredAxes_; - protected Vector registeredTransforms_; - protected Color lineColor_; - protected int numSmallTics_; - protected double largeTicHeight_; - protected double smallTicHeight_; - protected double thickTicWidth_; - protected int ticPosition_; - protected int labelPosition_; - protected int labelInterval_; - protected Font labelFont_; - protected Color labelColor_; - protected double labelHeight_; - protected int sigDigits_; - protected String labelFormat_; - - /** - * @link aggregation - * @label title - */ - protected SGLabel title_; - protected Range2D pRange_; - protected boolean space_; - protected int orientation_; - protected boolean selected_; - protected boolean selectable_; - protected boolean visible_; - /** - * Place the label and/or tic on the positive side of the axis. - * The right side of VERTICAL axes and the top of - * HORIZONTAL axes. - */ - public static final int POSITIVE_SIDE = 0; - /** - * Place the label and/or tic on the negative side of the axis. - * The left side of VERTICAL axes and the bottom of - * HORIZONTAL axes. - */ - public static final int NEGATIVE_SIDE = 1; - /** - * Do not draw a label and/or tic. - */ - public static final int NO_LABEL = 2; - /** - * Draw the tics on both sides of the axes. - */ - public static final int BOTH_SIDES = 2; - /** - * Draw a horizontal axis. - */ - public static final int HORIZONTAL = 0; - /** - * Draw a vertical axis. - */ - public static final int VERTICAL = 1; - public static final int AUTO = 3; - protected abstract void updateRegisteredTransforms(); - protected abstract void updateRegisteredAxes(); - // - protected void drawXTic(Graphics g,double xp,double yp,double ticHeight) { - int x0, y0, y1; - double yp0, yp1; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yp0 = yp + ticHeight; - } else { - yp0 = yp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yp1 = yp - ticHeight; - } else { - yp1 = yp; - } - x0 = graph_.getLayer().getXPtoD(xp); - y0 = graph_.getLayer().getYPtoD(yp0); - y1 = graph_.getLayer().getYPtoD(yp1); - g.drawLine(x0, y0, x0, y1); - } - // - protected void drawThickXTic(Graphics g,double xp,double yp,double ticHeight) { - int x0, x1, y0, y1, xc; - int ticW, ticH; - double yp0, yp1; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yp0 = yp + ticHeight; - } else { - yp0 = yp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yp1 = yp - ticHeight; - } else { - yp1 = yp; - } - xc = graph_.getLayer().getXPtoD(xp); - x0 = graph_.getLayer().getXPtoD(xp - thickTicWidth_/2.0); - x1 = graph_.getLayer().getXPtoD(xp + thickTicWidth_/2.0); - y0 = graph_.getLayer().getYPtoD(yp0); - y1 = graph_.getLayer().getYPtoD(yp1); - if((x1-x0) < 3) { - x0 = xc - 1; - x1 = xc + 1; - } - ticW = x1 - x0; - ticH = y1 - y0; - g.fillRect(x0, y0, ticW, ticH); - /* g.drawLine(x0-1, y0, x0-1, y1); - g.drawLine(x0, y0, x0, y1); - g.drawLine(x0+1, y0, x0+1, y1); */ - } - // - protected void drawYTic(Graphics g,double xp,double yp,double ticHeight) { - int x0, x1, y0; - double xp0, xp1; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xp0 = xp + ticHeight; - } else { - xp0 = xp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xp1 = xp - ticHeight; - } else { - xp1 = xp; - } - y0 = graph_.getLayer().getYPtoD(yp); - x0 = graph_.getLayer().getXPtoD(xp0); - x1 = graph_.getLayer().getXPtoD(xp1); - g.drawLine(x0, y0, x1, y0); - } - // - protected void drawThickYTic(Graphics g,double xp,double yp,double ticHeight) { - int x0, x1, y0; - double xp0, xp1; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xp0 = xp + ticHeight; - } else { - xp0 = xp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xp1 = xp - ticHeight; - } else { - xp1 = xp; - } - y0 = graph_.getLayer().getYPtoD(yp); - x0 = graph_.getLayer().getXPtoD(xp0); - x1 = graph_.getLayer().getXPtoD(xp1); - g.drawLine(x0, y0-1, x1, y0-1); - g.drawLine(x0, y0, x1, y0); - g.drawLine(x0, y0+1, x1, y0+1); - } - /** - * Default constructor for Axis. - */ - public Axis() { - this(""); - } - /** - * Constructor for Axis. Sets the axis identifier and initializes - * the defaults. Default values are: - * - *

-   *    numberSmallTics = 0
-   *    largeTicHeightP = 0.1
-   *    smallTicHeightP = 0.05
-   *     thickTicWidth_ = 0.025
-   *        ticPosition = NEGATIVE_SIDE
-   *      labelPosition = NEGATIVE_SIDE
-   *      labelInterval = 2
-   *          labelFont = Font("Helvetica", Font.ITALIC, 10);
-   *         labelColor = Color.black;
-   *       labelHeightP = 0.15
-   *  significantDigits = 2;
-   *        labelFormat = ""
-   *              title = null
-   *        orientation = HORIZONTAL
-   *         selectable = true
-   *            visible = true
-   *  
- * - * @param id axis identifier - */ - public Axis(String id) { - ident_ = id; - registeredAxes_ = new Vector(); - registeredTransforms_ = new Vector(); - // - // set defaults - // - lineColor_ = Color.black; - numSmallTics_ = 0; - largeTicHeight_ = 0.1; - smallTicHeight_ = 0.05; - thickTicWidth_ = 0.025; - ticPosition_ = NEGATIVE_SIDE; - labelPosition_ = NEGATIVE_SIDE; - labelInterval_ = 2; - labelHeight_ = 0.15; - sigDigits_ = 2; - labelFormat_ = ""; - title_ = null; - orientation_ = HORIZONTAL; - labelFont_ = new Font("Helvetica", Font.ITALIC, 10); - labelColor_ = Color.black; - selected_ = false; - selectable_ = true; - visible_ = true; - } - /** - * Create a copy of the axis. - * - * @return the copy - */ - public abstract Axis copy(); - // - abstract void draw(Graphics g); - void setGraph(CartesianGraph g) { - graph_ = g; - } - /** - * Get the Graph associated with the axis. - * - * @return Graph object. - */ - public CartesianGraph getGraph() { - return graph_; - } - /** - * Get the parent pane. - * @return AbstractPane - * @since 2.0 - */ - public AbstractPane getPane() { - return graph_.getPane(); - } - /** - * Used internally by sgt. - * @since 2.0 - */ - public void modified(String mess) { - // if(Debug.EVENT) System.out.println("Axis: modified()"); - if(graph_ != null) - graph_.modified(mess); - } - /** - * Register an axis. Registered axes will be notified of changes - * to the user coordinate range. - * - * @param axis An Axis object. - */ - public void register(Axis axis) { - registeredAxes_.addElement(axis); - } - /** - * Register an AxisTransform. Registered - * AxisTransforms will be - * notified of changes to the user coordinate range and physical - * coordinate range. - * - * @param trns A AxisTransform object. - */ - public void register(AxisTransform trns) { - registeredTransforms_.addElement(trns); - } - /** - * Unregister an axis. Axis will no longer be notified of - * changes in the user range. - * - * @param axis An Axis object. - */ - public void clear(Axis axis) { - if(!registeredAxes_.isEmpty()) { - registeredAxes_.removeElement(axis); - } - } - /** - * Unregister an AxisTransform. The AxisTransform - * will no longer be - * notified of changes to the user or physical coordinate range. - * - * @param trns A AxisTransform ojbect. - */ - public void clear(AxisTransform trns) { - if(!registeredTransforms_.isEmpty()) { - registeredTransforms_.removeElement(trns); - } - } - /** - * Unregister all axes. No axes will be notified of changes in the - * user range. - */ - public void clearAllRegisteredAxes() { - registeredAxes_.removeAllElements(); - } - /** - * Unregister all AxisTransforms. No - * AxisTransforms will be - * notified of changes in the user of physical range. - */ - public void clearAllRegisteredTransforms() { - registeredTransforms_.removeAllElements(); - } - /** - * Get the number of currently registered transforms. - * - * @return number of registered transforms - */ - public int getNumberRegisteredTransforms() { - return registeredTransforms_.size(); - } - /** - * Get the number of currently registered axes. - * - * @return number of registered axes - */ - public int getNumberRegisteredAxes() { - return registeredAxes_.size(); - } - /** - * Set the large tic height in physical units. - * - * @param lthgt large tic height. - */ - public void setLargeTicHeightP(double lthgt) { - if(largeTicHeight_ != lthgt) { - largeTicHeight_ = lthgt; - modified("Axis: setLargeTicHeightP()"); - } - } - /** - * Get the large tic height. - * - * @return large tic height in physcial units. - */ - public double getLargeTicHeightP() { - return largeTicHeight_; - } - /** - * Set the number of small tics between large tics. - * - * @param nstic number of small tics. - */ - public void setNumberSmallTics(int nstic) { - if(numSmallTics_ != nstic) { - numSmallTics_ = nstic; - modified("Axis: setNumerSmallTics()"); - } - } - /** - * Get the number of small tics between large tics. - * - * @return number of small tics. - */ - public int getNumberSmallTics() { - return numSmallTics_; - } - /** - * Set the small tic height in physical units. - * - * @param sthgt small tic height. - */ - public void setSmallTicHeightP(double sthgt) { - if(smallTicHeight_ != sthgt) { - smallTicHeight_ = sthgt; - modified("Axis: setSmallTicHeightP()"); - } - } - /** - * Get the small tic height. - * - * @return small tic height in physical units. - */ - public double getSmallTicHeightP() { - return smallTicHeight_; - } - /** - * Set the thick tic width in physical units. - * Minimum thickness is 3 pixels. - * - * @param wid thick tic width. - */ - public void setThickTicWidthP(double wid) { - if(thickTicWidth_ != wid) { - thickTicWidth_ = wid; - modified("Axis: setThickTicWidthP()"); - } - } - /** - * Get the thick tic width. - * - * @return thick tic width in physical units. - */ - public double getThickTicWidthP() { - return thickTicWidth_; - } - /** - * Set the tic position. Tic position can be POSITIVE_SIDE, - * NEGATIVE_SIDE, or BOTH_SIDES. - * - * @param tpos tic position - */ - public void setTicPosition(int tpos) { - if(ticPosition_ != tpos) { - ticPosition_ = tpos; - modified("Axis: setTicPosition()"); - } - } - /** - * Get the tic position. - * - * @return tic position - */ - public int getTicPosition() { - return ticPosition_; - } - /** - * Set the label position. Label position can be POSITIVE_SIDE, - * NEGATIVE_SIDE, and NO_LABEL. - * - * @param labp label position. - */ - public void setLabelPosition(int labp) { - if(labelPosition_ != labp) { - labelPosition_ = labp; - modified("Axis: setLabelPosition()"); - } - } - /** - * Get the label position. - * - * @return label position - */ - public int getLabelPosition() { - return labelPosition_; - } - /** - * Set the label font. - * - * @param fnt label font - */ - public void setLabelFont(Font fnt) { - if(labelFont_ == null || !labelFont_.equals(fnt)) { - labelFont_ = fnt; - modified("Axis: setLabelFont()"); - } - } - /** - * Get the label font. - * - * @return label font - */ - public Font getLabelFont() { - return labelFont_; - } - /** - * Set the line and tick color. - * @param color line and tick color - * @since 3.0 - */ - public void setLineColor(Color color) { - if(lineColor_ == null || !lineColor_.equals(color)) { - lineColor_ = color; - modified("Axis: setLineColor()"); - } - } - /** - * Get the line color. - * @since 3.0 - * @return color - */ - public Color getLineColor() { - return lineColor_; - } - /** - * Set the label color. - * @param color label color - * @since 2.0 - */ - public void setLabelColor(Color color) { - if(labelColor_ == null || !labelColor_.equals(color)) { - labelColor_ = color; - modified("Axis: setLabelColor()"); - } - } - /** - * Get the label color. - * @since 2.0 - * @return color - */ - public Color getLabelColor() { - return labelColor_; - } - /** - * Set the label height in physical units. - * - * @param lhgt label height. - */ - public void setLabelHeightP(double lhgt) { - if(labelHeight_ != lhgt) { - labelHeight_ = lhgt; - modified("Axis: setLabelHeightP()"); - } - } - /** - * Get the label height. - * - * @return label height - */ - public double getLabelHeightP() { - return labelHeight_; - } - /** - * Set the axis title. - * - * @param title axis title - */ - public void setTitle(SGLabel title) { - if(title_ == null || !title_.equals(title)) { - title_ = title; - title_.setMoveable(false); - modified("Axis: setTitle()"); - } - } - /** - * Get the axis title. - * - * @return axis title - */ - public SGLabel getTitle() { - return title_; - } - /** - * Set the physical range. This method updates any registered Transforms. - * If no Transforms are registered, the setRangeP method has no effect. - * - * @param pr physcial range - */ - public void setRangeP(Range2D pr) { - if(pRange_ == null || !pRange_.equals(pr)) { - pRange_ = pr; - updateRegisteredTransforms(); - modified("Axis: setRangeP()"); - } - } - /** - * Get the physical range. Obtains the physical range from the - * associated CartesianGraph object and attached Transform. - * - * @return physical range - */ - public Range2D getRangeP() { - if(orientation_ == HORIZONTAL) { - return graph_.xTransform_.getRangeP(); - } else { - return graph_.yTransform_.getRangeP(); - } - } - /** - * Set the axis identifier. - * - * @param id identifier - **/ - public void setId(String id) { - ident_ = id; - } - /** - * Get the axis identifier. - * - * @return identifier - */ - public String getId() { - return ident_; - } - /** - * Set axis orientation. Allowed orientations are - * HORIZONATAL and VERTICAL. - * - * @param or orientation - */ - public void setOrientation(int or) { - if(orientation_ != or) { - orientation_ = or; - modified("Axis: setOrientation()"); - } - } - /** - * Get axis orientation - * - * @return axis orientation - */ - public int getOrientation() { - return orientation_; - } - /** - * Tests if axis is space. - * - * @return true if space - */ - public boolean isSpace() { - return space_; - } - /** - * Tests if axis is time. - * - * @return true if time - */ - public boolean isTime() { - return !space_; - } - /** - * Get the bounding box for the axis in device units. - * - * @return bounding box - */ - public abstract Rectangle getBounds(); - /** - * Get a String representation of the Axis. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - public void setSelected(boolean sel) { - selected_ = sel; - } - /** - * Determines if the axis has been selected. - * @return true, if selected - * @since 2.0 - */ - public boolean isSelected() { - return selected_; - } - /** - * Set the selectable state. - * @since 2.0 - */ - public void setSelectable(boolean select) { - selectable_ = select; - } - /** - * Determines if the axis is selectable. - * @since 2.0 - */ - public boolean isSelectable() { - return selectable_; - } - /** - * Determines if the axis is visible. - * @since 2.0 - */ - public boolean isVisible() { - return visible_; - } - /** - * Set the visibility state. - * @since 2.0 - */ - public void setVisible(boolean visible) { - if(visible_ != visible) { - visible_ = visible; - modified("Axis: setVisible()"); - } - } - /** - * Set the axis location. - * @since 2.0 - */ - public abstract void setLocationU(SoTPoint pt); - /** - * Get current axis location. - * @since 2.0 - */ - public abstract SoTPoint getSoTLocationU(); - /** - * Set user range. - * @since 2.0 - */ - public abstract void setRangeU(SoTRange range); - /** - * Get user range. - * @since 2.0 - */ - public abstract SoTRange getSoTRangeU(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AxisNotFoundException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AxisNotFoundException.java deleted file mode 100755 index 08a3c8ef..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AxisNotFoundException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: AxisNotFoundException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Axis was not found during operation. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class AxisNotFoundException extends SGException { - public AxisNotFoundException() { - super(); -} - public AxisNotFoundException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AxisTransform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AxisTransform.java deleted file mode 100755 index feadc17c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/AxisTransform.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * $Id: AxisTransform.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - - package gov.noaa.pmel.sgt; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTRange; - -/** - * Abstract base class for cartesian axis transforms. Adds additional - * functionality to Transform necessary for use with - * axes. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public abstract class AxisTransform implements Transform { - protected PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - // serialVersion ref 1.9.2.2 - private static final long serialVersionUID = -1577305732337537031L; - protected double p1_; - protected double p2_; - protected double u1_; - protected double u2_; - protected long t1_; - protected long t2_; - protected boolean space_; - protected String ident_; - /** - * Default constructor. Creates a transform with arguments - * AxisTransform(0.0, 1.0, 0.0, 1.0). - **/ - public AxisTransform() { - this(0.0, 1.0, 0.0, 1.0); - } - /** - * AxisTransform space constructor. - * This constructor is used to define - * transforms that use double values. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @param u1 minimum value, user coordinates - * @param u2 maximum value, user coordinates - * @see LinearTransform - **/ - public AxisTransform(double p1,double p2,double u1,double u2) { - this.p1_ = p1; - this.p2_ = p2; - this.u1_ = u1; - this.u2_ = u2; - space_ = true; - computeTransform(); - ident_ = "space transform"; - } - /** - * AxisTransform space constructor. - * This constructor is used to define - * transforms that use values. - * - * @param pr physical coordinate range - * @param ur user coordinate range - * @see Range2D - * @see LinearTransform - **/ - public AxisTransform(Range2D pr,Range2D ur) { - this(pr.start, pr.end, ur.start, ur.end); - } - /** - * AxisTransform time constructor. - * This constructor is used to define - * transforms that use GeoDate values. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @param t1 minimum time - * @param t2 maximum time - * @see GeoDate - * @see LinearTransform - **/ - public AxisTransform(double p1,double p2,GeoDate t1,GeoDate t2) { - p1_ = p1; - p2_ = p2; - t1_ = t1.getTime(); - t2_ = t2.getTime(); - space_ = false; - computeTransform(); - ident_ = "time transform"; - } - /** - * AxisTransform time constructor. - * This constructor is used to define - * transforms that use long values to represent - * number of milliseconds since 1970-01-01. - * - * @since 3.0 - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @param t1 minimum time - * @param t2 maximum time - * @see LinearTransform - **/ - public AxisTransform(double p1, double p2, long t1, long t2) { - p1_ = p1; - p2_ = p2; - t1_ = t1; - t2_ = t2; - space_ = false; - computeTransform(); - ident_ = "time transform"; - } - /** - * AxisTransform time constructor. - * This constructor is used to define - * transforms that use values. - * - * @param pr physical coordinates range - * @param tr time range - * @see Range2D - * @see TimeRange - * @see GeoDate - * @see LinearTransform - **/ - public AxisTransform(Range2D pr, TimeRange tr) { - this(pr.start, pr.end, tr.start, tr.end); - } - /** - * AxisTransform SoT constructor. This constructor - * uses the SoTRange class enabling the construction of - * a Time or Space transform. - * - * @since 2.0 - */ - public AxisTransform(Range2D pr, SoTRange str) { - if(str.isTime()) { - t1_ = str.getStart().getLongTime(); - t2_ = str.getEnd().getLongTime(); - space_ = false; - } else { - u1_ = ((SoTRange.Double)str).start; - u2_ = ((SoTRange.Double)str).end; - space_ = true; - } - setRangeP(pr); - computeTransform(); - } - /** - * Set physical coordinate range. - *
Property Change: rangeP. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @see LinearTransform - **/ - public void setRangeP(double p1,double p2) { - if(p1_ != p1 || p2_ != p2) { - Range2D tempOld = new Range2D(p1_, p2_); - this.p1_ = p1; - this.p2_ = p2; - computeTransform(); - changes_.firePropertyChange("rangeP", - tempOld, - new Range2D(p1_, p2_)); - } - } - /** - * Set transform identifier. - * - * @param id transform identifier - **/ - public void setId(String id) { - ident_ = id; - } - /** - * Get transform identifier. - * - * @return identifier - **/ - public String getId() { - return ident_; - } - /** - * Set physical coordinate range. - * - * @param prange physcial coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeP(Range2D prange) { - setRangeP(prange.start, prange.end); - } - /** - * Get the physical coordinate range. - * - * @return physcial coordinate range - * @see Range2D - **/ - public Range2D getRangeP() { - return new Range2D(p1_, p2_); - } - /** - * Set the user coordinate range for space values. - *
Property Change: rangeU. - * - * @param u1 minimum value, user coordinates - * @param u2 maximum value, user coordinates - * @see LinearTransform - **/ - public void setRangeU(double u1,double u2) { - if(u1_ != u1 || u2_ != u2) { - Range2D tempOld = new Range2D(u1_, u2_); - this.u1_ = u1; - this.u2_ = u2; - space_ = true; - computeTransform(); - changes_.firePropertyChange("rangeU", - tempOld, - new Range2D(u1_, u2_)); - } - } - /** - * Set the user coordinate range for Range2D values. - * - * @param urange user coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeU(Range2D urange) { - setRangeU(urange.start, urange.end); - } - /** - * Get the user coordinate range for double values. - * - * @return user range - * @see Range2D - **/ - public Range2D getRangeU() { - return new Range2D(u1_, u2_); - } - /** - * Set the user coordinate range for GeoDate values. - *
Property Change: rangeU. - * - * @param t1 minimum time - * @param t2 maximum time - * @see GeoDate - * @see LinearTransform - **/ - public void setRangeU(GeoDate gt1, GeoDate gt2) { - setRangeU(gt1.getTime(), gt2.getTime()); - } - /** - * - * @since 3.0 - */ - public void setRangeU(long t1, long t2) { - if(!(t1_ == t1) || !(t2_ == t2)) { - SoTRange tempOld = new SoTRange.Time(t1_, t2_); - t1_ = t1; - t2_ = t2; - space_ = false; - computeTransform(); - changes_.firePropertyChange("rangeU", - tempOld, - new SoTRange.Time(t1_, t2_)); - } - } - /** - * Set the user coordinate range for TimeRange value. - * - * @param trange time range - * @see TimeRange - * @see LinearTransform - **/ - public void setRangeU(TimeRange trange) { - setRangeU(trange.start, trange.end); - } - /** - * Get the user coordinate range for GeoDate values. - * - * @return time range - * @see TimeRange - **/ - public TimeRange getTimeRangeU() { - return new TimeRange(new GeoDate(t1_), new GeoDate(t2_)); - } - /** - * Set the user range with a SoTRange object. - * @since 2.0 - */ - public void setRangeU(SoTRange str) { - if(str.isTime()) { - setRangeU(str.getStart().getLongTime(), - str.getEnd().getLongTime()); - } else { - setRangeU(((SoTRange.Double)str).start, - ((SoTRange.Double)str).end); - } - } - /** - * Get the user range as a SoTRange object. - * @since 2.0 - */ - public SoTRange getSoTRangeU() { - if(space_) { - return new SoTRange.Double(u1_, u2_); - } else { - return new SoTRange.Time(t1_, t2_); - } - } - /** - * Test if transform has user double values. - * - * @return true if user coordinates are double values - **/ - public boolean isSpace() { - return space_; - } - /** - * Test if transform has user GeoDate values. - * - * @return true if user coordinates are GeoDate values. - * @see GeoDate - **/ - public boolean isTime() { - return !space_; - } - abstract double getTransP(GeoDate t); - /** - * @since 3.0 - */ - abstract double getTransP(long t); - abstract GeoDate getTimeTransU(double p); - /** - * @since 3.0 - */ - abstract long getLongTimeTransU(double p); - abstract void computeTransform(); - abstract AxisTransform copy(); - - /** - * Get physical value as a function of SoTValue. - * @since 2.0 - */ - public abstract double getTransP(SoTValue value); - /** - * Get user transform value as a SoTValue - * @since 2.0 - */ - public abstract SoTValue getSoTTransU(double value); - /** - * Add listener to changes in LinearTransform - * properties. - * @since 2.0 - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - changes_.addPropertyChangeListener(listener); - } - /** - * Remove listener from list. - * @since 2.0 - */ - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CLIndexedColorMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CLIndexedColorMap.java deleted file mode 100755 index 25d3301f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CLIndexedColorMap.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * $Id: CLIndexedColorMap.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; - -/** - * CLIndexedColorMap provides a mapping from a value to a - * Color. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public class CLIndexedColorMap extends ColorMap - implements Cloneable, PropertyChangeListener, - IndexedColor, ContourLevelsAccess { - protected Color[] colors_; - - /** - * @label cl - * @link aggregation - */ - protected ContourLevels cl_ = null; - /** - * Initialize the color map with int arrays of red, green, and blue. - * The arrays must be the same length. Sets up ColorMap - * for INDEXED access. - * - * @param red Array of the red component 0 - 255. - * @param green Array of the green component 0 - 255. - * @param blue Array of the blue component 0 - 255. - * - * @see java.awt.Color - */ - public CLIndexedColorMap(int[] red,int[] green,int[] blue) { - int indx; - colors_ = new Color[red.length]; - for (indx=0; indx < red.length; indx++) { - colors_[indx] = new Color(red[indx], green[indx], blue[indx]); - } - } - /** - * Initialize the color map with float arrays of red, green, and blue. - * The arrays must be the same length. Sets up ColorMap - * for INDEXED access. - * - * @param red Array of the red component 0.0 - 1.0. - * @param green Array of the green component 0.0 - 1.0. - * @param blue Array of the blue component 0.0 - 1.0. - * - * @see java.awt.Color - */ - public CLIndexedColorMap(float[] red,float[] green,float[] blue) { - int indx; - colors_ = new Color[red.length]; - for (indx=0; indx < red.length; indx++) { - colors_[indx] = new Color(red[indx], green[indx], blue[indx]); - } - } - /** - * Initialize the color map with an array of Color - * objects. Sets up ColorMap for - * INDEXED access. - * - * @param colors Array of the Color objects. - * - * @see java.awt.Color - */ - public CLIndexedColorMap(Color[] colors) { - colors_ = colors; - } - /** - * Create a copy of the ColorMap - */ - public ColorMap copy() { - ColorMap newMap; - try { - newMap = (ColorMap)clone(); - } catch (CloneNotSupportedException e) { - newMap = new CLIndexedColorMap(colors_); - } - return newMap; - } - /** - * Get a Color. - * - * @since 3.0 - * @return color - */ - public Color getColorByIndex(int indx) { - if(cl_ != null) { - try { - return getColor(cl_.getLevel(indx)); - } catch (ContourLevelNotFoundException cfnf) { - return colors_[colors_.length-1]; - } - } else { - return Color.white; - } - } - /** - * Get a Color. - * - * @param val Value - * @return Color - */ - public Color getColor(double val) { - double ival = val; - int indx; - indx = cl_.getIndex(ival); - if(indx < 0) indx=0; - if(indx > colors_.length-1) indx = colors_.length-1; - return colors_[indx]; - } - - /** - * Get the current user range for the Transform. - * - * @return user range - */ - public Range2D getRange() { - return cl_.getRange(); - } - /** - * Change the Color. - * - * @param colr new Color - * @param indx index of color - */ - public void setColor(int index, Color colr) { - setColor(index, colr.getRed(), colr.getGreen(), colr.getBlue()); - } - /** - * Change the Color. - *
Property Change: color. - * - * @param red red component - * @param green green component - * @param blue blue component - * @param indx index of color - */ - public void setColor(int indx, int red, int green, int blue) { - if(indx < 0 || indx > colors_.length) return; - Color newColor = new Color(red, green, blue); - if(!colors_[indx].equals(newColor)) { - Color tempOld = colors_[indx]; - colors_[indx] = newColor; - firePropertyChange("color", - tempOld, - newColor); - } - } - /** - * Get the maximum color index. - * - * @return maximum legal color index - */ - public int getMaximumIndex() { - return colors_.length - 1; - } - /** - * Set ContourLevels. - *
Property Change: color. - * - * @param cl ContourLevels - */ - public void setContourLevels(ContourLevels cl) { - if(cl_ == null || !cl_.equals(cl)) { - ContourLevels tempOld = cl_; - cl_ = cl; - firePropertyChange("contourLevels", - tempOld, - cl_); - } - } - /** - * Get ContourLevels. - * - * @return ContourLevels - */ - public ContourLevels getContourLevels() { - return cl_; - } - public boolean equals(ColorMap cm) { - if(cm == null || !(cm instanceof CLIndexedColorMap)) return false; - if(cl_ == null || !cl_.equals(((CLIndexedColorMap)cm).cl_)) return false; - if(colors_.length != ((CLIndexedColorMap)cm).colors_.length) return false; - for(int i=0; i < colors_.length; i++) { - if(!colors_[i].equals(((CLIndexedColorMap)cm).colors_[i])) return false; - } - return true; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CLTransformColorMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CLTransformColorMap.java deleted file mode 100755 index 669e7176..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CLTransformColorMap.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * $Id: CLTransformColorMap.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; - -/** - * CLTransformColorMap provides a mapping from a value - * to a Color via a ContourLevel object. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public class CLTransformColorMap extends ColorMap - implements Cloneable, PropertyChangeListener, TransformColor, ContourLevelsAccess { - /** - * Red Transform - - * @supplierCardinality 0..1 - * @clientRole rTrans_ - * @link aggregationByValue - */ - private Transform rTrans_ = null; - /** - * Green Transform - - * @supplierCardinality 0..1 - * @clientRole gTrans_ - * @link aggregationByValue - */ - private Transform gTrans_ = null; - /** - * Blue Transform - - * @supplierCardinality 0..1 - * @clientRole bTrans_ - * @link aggregationByValue - */ - private Transform bTrans_ = null; - /** - * if not null use LEVEL_INDEXED or LEVEL_TRANSFORM - * @shapeType AggregationLink - * @label cl - */ - private ContourLevels cl_ = null; - /** - * Initialize the color map to use red, green, and blue transforms. - * Each Transform should have identical user - * ranges. The physical range will be set to 0.0 to 1.0 for each - * color component. - * - * @see Transform - */ - public CLTransformColorMap(Transform rTrans,Transform gTrans,Transform bTrans) { - rTrans_ = rTrans; - rTrans_.setRangeP(0.0, 1.0); - gTrans_ = gTrans; - gTrans_.setRangeP(0.0, 1.0); - bTrans_ = bTrans; - bTrans_.setRangeP(0.0, 1.0); - } - /** - * Create a copy of the ColorMap object. - */ - public ColorMap copy() { - ColorMap newMap; - try { - newMap = (ColorMap)clone(); - } catch (CloneNotSupportedException e) { - newMap = null; - } - return newMap; - } - /** - * Get a Color. - * - * @param val Value - * @return Color - * - */ - public Color getColor(double val) { - double ival = val; - int indx; - ival = (double)cl_.getIndex(ival)/(double)cl_.getMaximumIndex(); - float red = (float)rTrans_.getTransP(ival); - float green = (float)gTrans_.getTransP(ival); - float blue = (float)bTrans_.getTransP(ival); - return new Color(red, green, blue); - } - /** - * Get the current user range for the Transforms. - * - * @return user range - */ - public Range2D getRange() { - return cl_.getRange(); - } - /** - * Set the color Transforms. - *
Property Change: redColorTransform, - * greenColorTransform, and - * blueColorTransform. - * - * @param rTrans red Transform - * @param gTrans green Transform - * @param bTrans blue Transform - */ - public void setColorTransforms(Transform rTrans, - Transform gTrans, - Transform bTrans) { - if(!rTrans_.equals(rTrans) || - !gTrans_.equals(gTrans) || - !bTrans_.equals(bTrans)) { - if(rTrans_ != null) rTrans_.removePropertyChangeListener(this); - if(gTrans_ != null) gTrans_.removePropertyChangeListener(this); - if(bTrans_ != null) bTrans_.removePropertyChangeListener(this); - - Transform tempOld = rTrans_; - rTrans_ = rTrans; - rTrans_.setRangeP(0.0, 1.0); - firePropertyChange("redColorTransform", - tempOld, - rTrans_); - tempOld = gTrans_; - gTrans_ = gTrans; - gTrans_.setRangeP(0.0, 1.0); - firePropertyChange("greenColorTransform", - tempOld, - gTrans_); - tempOld = bTrans_; - bTrans_ = bTrans; - bTrans_.setRangeP(0.0, 1.0); - firePropertyChange("blueColorTransform", - tempOld, - bTrans_); - - rTrans_.addPropertyChangeListener(this); - gTrans_.addPropertyChangeListener(this); - bTrans_.addPropertyChangeListener(this); - } - } - /** - * Set the red transform. - */ - public void setRedTransform(Transform red) { - rTrans_ = red; - } - /** - * Get the red color Transform. - * - * @return red Transform - */ - public Transform getRedTransform() { - return rTrans_; - } - /** - * Set the green transform. - */ - public void setGreenTransform(Transform green) { - gTrans_ = green; - } - /** - * Get the green color Transform. - * - * @return green Transform - */ - public Transform getGreenTransform() { - return gTrans_; - } - /** - * Set the blue transform. - */ - public void setBlueTransform(Transform blue) { - bTrans_ = blue; - } - /** - * Get the blue color Transform. - * - * @return blue Transform - */ - public Transform getBlueTransform() { - return bTrans_; - } - /** - * Set ContourLevels. - *
Property Change: contourLevels. - * - * @param cl ContourLevels - */ - public void setContourLevels(ContourLevels cl) { - if(!cl_.equals(cl)) { - ContourLevels tempOld = cl_; - cl_ = cl; - firePropertyChange("contourLevels", - tempOld, - cl_); - } - } - /** - * Get ContourLevels for the color mappings. - * - * @return ContourLevels - */ - public ContourLevels getContourLevels() { - return cl_; - } - /** - * Test for color map equality - */ - public boolean equals(ColorMap cm) { - if(cm == null || !(cm instanceof CLTransformColorMap)) return false; - if(!cl_.equals(((CLTransformColorMap)cm).cl_)) return false; - if(!(rTrans_.equals(((CLTransformColorMap)cm).rTrans_) && - gTrans_.equals(((CLTransformColorMap)cm).gTrans_) && - bTrans_.equals(((CLTransformColorMap)cm).bTrans_))) return false; - return true; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CartesianGraph.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CartesianGraph.java deleted file mode 100755 index c79f7a25..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CartesianGraph.java +++ /dev/null @@ -1,1006 +0,0 @@ -/* - * $Id: CartesianGraph.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTData; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTPoint; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Event; -import java.awt.Rectangle; -import java.awt.Point; -import java.beans.PropertyChangeEvent; - -/** - * The CartesianGraph provides the transformation from user to - * physical coordinates. A Cartesian graph has - * horizontal and vertical transforms, from user to physical - * coordinates, that are independent. - * For example, yp = f(yu) and xp = g(xu), where - * f() and g() are the vertical and horizontal transformations. - * Multiple horizontal and vertical, X and Y, axes can be associated with - * a CartesianGraph and their mapping of user to physical - * coordinates is based on the AxisTransforms used. - * The CartesianGraph also provide the support for - * the rendering of data. The specific renderer is chosen based on - * the type of SGTData and the data Attribute used. - *

- * The following demonstrates how a CartesianGraph may be - * used. - * - *

- *   // Create a CartesianGraph and transforms.
- *
- *    CartesianGraph graph;
- *    LinearTransform xt, yt;
- *    Range2D xPhysRange, xUserRange;
- *    Range2D yPhysRange, yUserRange;
- *    Point2D.Double origin;
- *
- *    graph = new CartesianGraph("Point Graph");
- *    layer.setGraph(graph);
- *    xt = new LinearTransform(xPhysRange, xUserRange);
- *    yt = new LinearTransform(yPhysRange, yUserRange);
- *    graph.setXTransform(xt);
- *    graph.setYTransform(yt);
- *    origin = new Point2D.Double(xUserRange.start,
- *                                yUserRange.start);
- *
- *     // Create the bottom axis, set its range in user units
- *     // and its origin. Add the axis to the graph.
- *
- *    PlainAxis xbot;
- *
- *    xbot = new PlainAxis("Botton Axis");
- *    xbot.setRangeU(xUserRange);
- *    xbot.setLocationU(origin);
- *    graph.addXAxis(xbot);
- *
- *     // Create the left axis, set its range in user units
- *     // and its origin. Add the axis to the graph.
- *
- *    PlainAxis yleft;
- *
- *    yleft = new PlainAxis("Left Axis");
- *    yleft.setRangeU(yUserRange);
- *    yleft.setLocationU(origin);
- *    graph.addYAxis(yleft);
- *
- *     // Create a PointAttribute for the display of the
- *     // Collection of points. The points will be marked
- *     // with a red triangle and labelled at the NE corner
- *     // in blue.
- *
- *    PointAttribute pattr;
- *
- *    pattr = new PointAttribute(10, Color.red);
- *
- *     // Associate the attribute and the point Collection
- *     // with the graph.
- *
- *    graph.setData(col, pattr);
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public class CartesianGraph extends Graph { - /**@associates Axis - * @supplierCardinality 0..* - * @clientRole xAxis_ */ - protected Vector xAxis_; - /** @associates Axis - * @clientRole yAxis_ - * @supplierCardinality 0..* */ - protected Vector yAxis_; - /** @clientRole xTransform_ - * @link aggregation - * @undirected */ - protected AxisTransform xTransform_; - /** @clientRole tTransfrom_ - * @link aggregation - * @undirected */ - protected AxisTransform yTransform_; - protected boolean clipping_ = false; - protected Range2D xClipRange_; - protected Range2D yClipRange_; - protected SoTRange.Time tClipRange_; - /**@shapeType AggregationLink - * @undirected - * @clientCardinality 1 - * @supplierCardinality 1 - * @label renderer */ - private CartesianRenderer renderer_; - /** - * Default constructor. - */ - public CartesianGraph() { - this(""); - } - /** - * CartesianGraph constructor. - * Creates default unity transforms. - * - * @param id CartesianGraph identifier - */ - public CartesianGraph(String id) { - this(id, new LinearTransform(0.0, 1.0, 0.0, 1.0), - new LinearTransform(0.0, 1.0, 0.0, 1.0)); - } - /** - * Create a new CartesianGraph. Sets the identifier - * and sets the x and y transforms. - * - * @param id identifier - * @param xt x transform - * @param yt y transform - */ - public CartesianGraph(String id,AxisTransform xt,AxisTransform yt) { - super(id); - xAxis_ = new Vector(2,2); - yAxis_ = new Vector(2,2); - xTransform_ = xt; - if(xTransform_ != null) xTransform_.addPropertyChangeListener(this); - yTransform_ = yt; - if(yTransform_ != null) yTransform_.addPropertyChangeListener(this); - } - /** - * Create a copy of the CartesianGraph - */ - public Graph copy() { - throw new MethodNotImplementedError(); - } - /** - * Associates SGTData and Attribute with the - * CartesianGraph. - * A renderer is constucted based on the two arguements. - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
- *

SGTData - *

- *

Attribute - *

- *

CartesianRenderer - *

SGTPointPontAttributePointCartesianRenderer
SGTLineLineAttributeLineCartesianRenderer
SGTGridGridAttributeGridCartesianRenderer
SGTVectorVectorAttributeVectorCartesianRenderer
CollectionPointAttributePointCartesianRenderer
CollectionLineAttributeLineCartesianRenderer
CollectionVectorAttributeVectorCartesianRenderer
Annotationn/aAnnotationCartesianRenderer
- *

- * @param data data to be rendered - * @param attr rendering style information - * @see CartesianRenderer#getRenderer - */ - public void setData(SGTData data, Attribute attr) { - renderer_ = CartesianRenderer.getRenderer(this, data, attr); - data.addPropertyChangeListener(this); - } - /** - * Get the renderer instance being used by the graph. - * - * @return renderer - */ - public CartesianRenderer getRenderer() { - return renderer_; - } - /** - * Set the renderer used by the graph. - * - * @param rend a renderer object - */ - public void setRenderer(CartesianRenderer rend) { - renderer_ = rend; - } - /** - * Draw the graph, axes, and render the data. This method should - * not be directly called. - * - * @see Pane#draw - */ - public void draw(Graphics g) { - if(renderer_ != null) renderer_.draw(g); - if(!xAxis_.isEmpty()) { - for(Enumeration it = xAxis_.elements(); it.hasMoreElements();) { - ((Axis)it.nextElement()).draw(g); - } - } - if(!yAxis_.isEmpty()) { - for(Enumeration it = yAxis_.elements(); it.hasMoreElements();) { - ((Axis)it.nextElement()).draw(g); - } - } - } - /** - * Set the clipping rectangle in user coordinates. - * - * @param xmin minimum horizontal coordinate - * @param xmax maximum horizontal coordinate - * @param ymin minimum vertical coordinate - * @param ymax maximum vertical coordinate - */ - public void setClip(double xmin,double xmax,double ymin,double ymax) { - if(xTransform_.isSpace() && yTransform_.isSpace()) { - clipping_ = true; - xClipRange_ = new Range2D(xmin, xmax); - yClipRange_ = new Range2D(ymin, ymax); - } else { - clipping_ = false; - } - } - /** - * Set the clipping rectangle in user coordinates. - * - * @param tmin mimimum time - * @param tmax maximum time - * @param min miminum user coordinate - * @param max maximum user coordinate - */ - public void setClip(GeoDate tmin, GeoDate tmax, double min, double max) { - if(xTransform_.isTime() || yTransform_.isTime()) { - clipping_ = true; - tClipRange_ = new SoTRange.Time(tmin.getTime(), tmax.getTime()); - if(xTransform_.isTime()) { - yClipRange_ = new Range2D(min, max); - } else { - xClipRange_ = new Range2D(min, max); - } - } else { - clipping_ = false; - } - } - /** - * Set the clipping rectangle in user coordinates. - * - * @since 3.0 - * @param tmin mimimum time - * @param tmax maximum time - * @param min miminum user coordinate - * @param max maximum user coordinate - */ - public void setClip(long tmin, long tmax, double min, double max) { - if(xTransform_.isTime() || yTransform_.isTime()) { - clipping_ = true; - tClipRange_ = new SoTRange.Time(tmin, tmax); - if(xTransform_.isTime()) { - yClipRange_ = new Range2D(min, max); - } else { - xClipRange_ = new Range2D(min, max); - } - } else { - clipping_ = false; - } - } - /** - * Set the clipping rectangle in user coordinates. - * @since 2.0 - */ - public void setClip(SoTRange xr, SoTRange yr) { - if(xr.isTime() || yr.isTime()) { - SoTRange.Double dub; - long tstart; - long tend; - if(xr.isTime()) { - tstart = xr.getStart().getLongTime(); - tend = xr.getEnd().getLongTime(); - dub = (SoTRange.Double)yr; - } else { - tstart = yr.getStart().getLongTime(); - tend = yr.getEnd().getLongTime(); - dub = (SoTRange.Double)xr; - } - setClip(tstart, tend, dub.start, dub.end); - } else { - SoTRange.Double xrd = (SoTRange.Double)xr; - SoTRange.Double yrd = (SoTRange.Double)yr; - setClip(xrd.start, xrd.end, yrd.start, yrd.end); - } - } - /** - * Set the clipping property. - * - * @param clip clipping - */ - public void setClipping(boolean clip) { - clipping_ = clip; - } - /** - * Test the clipping property. - * - * @return true if clipping is active - */ - public boolean isClipping() { - return clipping_; - } - /** - * Add a X axis (Axis.HORIZONTAL) to the graph. - * - * @param id axis identifier - * @param axis X axis - * @see Axis - * @see PlainAxis - */ - public void addXAxis(String id,Axis axis) { - if(id.length() != 0) axis.setId(id); - addXAxis(axis); - } - /** - * Add a X axis (Axis.HORIZONTAL) to the graph. - * Uses the existing axis identifier. - * - * @param axis X axis - * @see Axis - * @see PlainAxis - */ - public void addXAxis(Axis axis) { - axis.setOrientation(Axis.HORIZONTAL); - axis.setGraph(this); - xAxis_.addElement(axis); - } - /** - * Get a reference to an X axis. - * - * @param id axis identifier - * @return axis found - * @exception AxisNotFoundException An axis was not found with the correct identifier. - * @see Axis - * @see PlainAxis - */ - public Axis getXAxis(String id) throws AxisNotFoundException { - if(!xAxis_.isEmpty()) { - Axis ax; - for(Enumeration it = xAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() == id) return ax; - } - throw new AxisNotFoundException(); - } else { - throw new AxisNotFoundException(); - } - } - /** - * Remove an X axis from the graph. - * - * @param id axis identifier - * @exception AxisNotFoundException An axis was not found with the correct identifier. - * @see Axis - * @see PlainAxis - */ - public void removeXAxis(String id) throws AxisNotFoundException { - if(!xAxis_.isEmpty()) { - Axis ax; - for(Enumeration it = xAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() == id) xAxis_.removeElement(ax); - } - throw new AxisNotFoundException(); - } else { - throw new AxisNotFoundException(); - } - } - /** - * Remove an X axis from the graph. - * - * @exception AxisNotFoundException An axis was not found with the correct identifier. - * @see Axis - * @see PlainAxis - */ - public void removeXAxis(Axis axis) throws AxisNotFoundException { - if(!xAxis_.isEmpty()) { - Axis ax; - for(Enumeration it = xAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.equals(axis)) xAxis_.removeElement(ax); - } - throw new AxisNotFoundException(); - } else { - throw new AxisNotFoundException(); - } - } - /** - * Remove all X axes from the graph. - */ - public void removeAllXAxes() { - xAxis_.removeAllElements(); - } - /** - * Get the number of X axes associated with the graph. - * - * @return number of axes - * @see Axis - * @see PlainAxis - */ - public int getNumberXAxis() { - return xAxis_.size(); - } - /** - * Get an Enumeration object for the X axes. - * - * @return enumeration - */ - public Enumeration xAxisElements() { - return xAxis_.elements(); - } - /** - * Add a Y axis (Axis.VERTICAL) to the graph. - * - * @param id axis identifier - * @param axis Y axis - * @see Axis - * @see PlainAxis - */ - public void addYAxis(String id,Axis axis) { - if(id.length() != 0) axis.setId(id); - addYAxis(axis); - } - /** - * Add a Y axis (Axis.VERTICAL) to the graph. - * Uses the existing axis identifier. - * - * @param axis Y axis - * @see Axis - * @see PlainAxis - */ - public void addYAxis(Axis axis) { - axis.setOrientation(Axis.VERTICAL); - axis.setGraph(this); - yAxis_.addElement(axis); - } - /** - * Get a reference to an Y axis. - * - * @param id axis identifier - * @return axis found - * @exception AxisNotFoundException An axis was not found with the correct identifier. - * @see Axis - * @see PlainAxis - */ - public Axis getYAxis(String id) throws AxisNotFoundException { - if(!yAxis_.isEmpty()) { - Axis ax; - for(Enumeration it = yAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() == id) return ax; - } - throw new AxisNotFoundException(); - } else { - throw new AxisNotFoundException(); - } - } - /** - * Remove an Y axis from the graph. - * - * @param id axis identifier - * @exception AxisNotFoundException An axis was not found with the correct identifier. - * @see Axis - * @see PlainAxis - */ - public void removeYAxis(String id) throws AxisNotFoundException { - if(!yAxis_.isEmpty()) { - Axis ax; - for(Enumeration it = yAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() == id) yAxis_.removeElement(ax); - } - throw new AxisNotFoundException(); - } else { - throw new AxisNotFoundException(); - } - } - /** - * Remove an Y axis from the graph. - * - * @exception AxisNotFoundException An axis was not found with the correct identifier. - * @see Axis - * @see PlainAxis - */ - public void removeYAxis(Axis axis) throws AxisNotFoundException { - if(!yAxis_.isEmpty()) { - Axis ax; - for(Enumeration it = yAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.equals(axis)) yAxis_.removeElement(ax); - } - throw new AxisNotFoundException(); - } else { - throw new AxisNotFoundException(); - } - } - /** - * Remove all Y axes from the graph. - */ - public void removeAllYAxes() { - yAxis_.removeAllElements(); - } - /** - * Get the number of Y axes associated with the graph. - * - * @return number of axes - * @see Axis - * @see PlainAxis - */ - public int getNumberYAxis() { - return yAxis_.size(); - } - /** - * Get an Enumeration object for the Y axes. - * - * @return enumeration - */ - public Enumeration yAxisElements() { - return yAxis_.elements(); - } - /** - * Set the X AxisTransform. This transform is used to convert - * to and from user to physical coordinates. - * - * @param xfrm X transform - * @see AxisTransform - * @see LinearTransform - */ - public void setXTransform(AxisTransform xfrm) { - if(xTransform_ != null) xTransform_.removePropertyChangeListener(this); - xTransform_ = xfrm; - xTransform_.addPropertyChangeListener(this); - } - /** - * Get the current X AxisTransform. - * - * @return X Transform - * @see AxisTransform - * @see LinearTransform - */ - public AxisTransform getXTransform() { - return xTransform_; - } - /** - * Set the Y AxisTransform. This transform is used to convert - * to and from user to physical coordinates. - * - * @param xfrm Y transform - * @see AxisTransform - * @see LinearTransform - */ - public void setYTransform(AxisTransform xfrm) { - if(yTransform_ != null) yTransform_.removePropertyChangeListener(this); - yTransform_ = xfrm; - yTransform_.addPropertyChangeListener(this); - } - /** - * Get the current Y AxisTransform. - * - * @return Y Transform - * @see AxisTransform - * @see LinearTransform - */ - public AxisTransform getYTransform() { - return yTransform_; - } - // - Object getObjectAt(Point pt) { - Rectangle bnds; - Axis ax; - SGLabel lab; - if(!xAxis_.isEmpty()) { - for(Enumeration it = xAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - bnds = ax.getBounds(); - if(bnds.contains(pt)) { - return ax; - } - lab = ax.getTitle(); - if((lab != null) && (lab.getLayer() != null)) { - bnds = lab.getBounds(); - if(bnds.contains(pt)) { - return lab; - } - } - } - } - if(!yAxis_.isEmpty()) { - for(Enumeration it = yAxis_.elements(); it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - bnds = ax.getBounds(); - if(bnds.contains(pt)) { - return ax; - } - lab = ax.getTitle(); - if(lab != null) { - bnds = lab.getBounds(); - if(bnds.contains(pt)) { - return lab; - } - } - } - } - return (Object) null; - } - /** - * Transform user X coordinate to physical coordinate. - * @since 2.0 - */ - public double getXUtoP(double u) { - return xTransform_.getTransP(u); - } - /** - * Transform user X coordinate to device coordinate. - * @since 2.0 - */ - public int getXUtoD(double u) { - if(Double.isNaN(u)) return Integer.MIN_VALUE; - return getLayer().getXPtoD(xTransform_.getTransP(u)); - } - /** - * Transform user X coordinate to device coordinate. - * @since 3.0 - */ - public double getXUtoD2(double u) { - if(Double.isNaN(u)) return u; - return getLayer().getXPtoD2(xTransform_.getTransP(u)); - } - /** - * Transform GeoDate to physical coordinate. - * @since 2.0 - */ - public double getXUtoP(GeoDate t) { - return xTransform_.getTransP(t); - } - /** - * Transform long to physical coordinate. - * @since 3.0 - */ - public double getXUtoP(long t) { - return xTransform_.getTransP(t); - } - /** - * Transform GeoDate to device coordinate. - * @since 2.0 - */ - public int getXUtoD(GeoDate t) { - if(t == null) return Integer.MIN_VALUE; - return getLayer().getXPtoD(xTransform_.getTransP(t)); - } - /** - * Transform long to device coordinate. - * @since 3.0 - */ - public int getXUtoD(long t) { - if(t == Long.MAX_VALUE) return Integer.MIN_VALUE; - return getLayer().getXPtoD(xTransform_.getTransP(t)); - } - /** - * Transform GeoDate to device coordinate. - * @since 3.0 - */ - public double getXUtoD2(GeoDate t) { - if(t == null) return Double.NaN; - return getLayer().getXPtoD2(xTransform_.getTransP(t)); - } - /** - * Transform long to device coordinate. - * @since 3.0 - */ - public double getXUtoD2(long t) { - if(t == Long.MAX_VALUE) return Double.NaN; - return getLayer().getXPtoD2(xTransform_.getTransP(t)); - } - /** - * Transform X SoTValue to device coordinate. - * @since 3.0 - */ - public int getXUtoD(SoTValue val) { - if(val.isTime()) { - return getXUtoD(val.getLongTime()); - } else { - return getXUtoD(((SoTValue.Double)val).getValue()); - } - } - /** - * Transform Y SoTValue to device coordinate. - * @since 3.0 - */ - public int getYUtoD(SoTValue val) { - if(val.isTime()) { - return getYUtoD(val.getLongTime()); - } else { - return getYUtoD(((SoTValue.Double)val).getValue()); - } - } - /** - * Transform X SoTValue to device coordinate. - * @since 3.0 - */ - public double getXUtoD2(SoTValue val) { - if(val.isTime()) { - return getXUtoD2(val.getLongTime()); - } else { - return getXUtoD2(((SoTValue.Double)val).getValue()); - } - } - /** - * Transform Y SoTValue to device coordinate. - * @since 3.0 - */ - public double getYUtoD2(SoTValue val) { - if(val.isTime()) { - return getYUtoD2(val.getLongTime()); - } else { - return getYUtoD2(((SoTValue.Double)val).getValue()); - } - } - /** - * Transform X SoTValue to physical coordinate. - * @since 3.0 - */ - public double getXUtoP(SoTValue val) { - if(val.isTime()) { - return getXUtoP(val.getLongTime()); - } else { - return getXUtoP(((SoTValue.Double)val).getValue()); - } - } - /** - * Transform Y SoTValue to physical coordinate. - * @since 3.0 - */ - public double getYUtoP(SoTValue val) { - if(val.isTime()) { - return getYUtoP(val.getLongTime()); - } else { - return getYUtoP(((SoTValue.Double)val).getValue()); - } - } - /** - * Transform physical X coordinate to user coordinate using SoTValue - * @param p physical coordinate - * @return user coorindinate - * @since 3.0 - */ - public SoTValue getXPtoSoT(double p) { - if(xTransform_.isTime()) { - return new SoTValue.Time(xTransform_.getLongTimeTransU(p)); - } else { - return new SoTValue.Double(xTransform_.getTransU(p)); - } - } - /** - * Transform physical X coordinate to user coordinate. - * - * @param p physical coorindate - * @return user coordinate - **/ - public double getXPtoU(double p) { - return xTransform_.getTransU(p); - } - /** - * Transform physical X coordinate to time. - * - * @param p physical coordinate - * @return time - **/ - public GeoDate getXPtoTime(double p) { - return xTransform_.getTimeTransU(p); - } - /** - * Transform physical X coordinate to time. - * - * @param p physical coordinate - * @return time - * @since 3.0 - **/ - public long getXPtoLongTime(double p) { - return xTransform_.getLongTimeTransU(p); - } - /** - * Transform physical coordinate to a SoTPoint - * - * @since 3.0 - * @param p physical coordinate - * @return SoTPoint - **/ - public SoTPoint getPtoU(Point2D.Double loc) { - SoTValue xv; - SoTValue yv; - // x - transform - if(xTransform_.isTime()) { - xv = new SoTValue.Time(getXPtoLongTime(loc.x)); - } else { - xv = new SoTValue.Double(getXPtoU(loc.x)); - } - if(yTransform_.isTime()) { - yv = new SoTValue.Time(getYPtoLongTime(loc.y)); - } else { - yv = new SoTValue.Double(getYPtoU(loc.y)); - } - return new SoTPoint(xv, yv); - } - /** - * Transoform user Y coordinate to physical coordinate. - * @since 2.0 - */ - public double getYUtoP(double u) { - return yTransform_.getTransP(u); - } - /** - * Transform user Y coordinate to device coordinate - * @since 2.0 - */ - public int getYUtoD(double u) { - if(Double.isNaN(u)) return Integer.MIN_VALUE; - return getLayer().getYPtoD(yTransform_.getTransP(u)); - } - /** - * Transform user Y coordinate to device coordinate - * @since 3.0 - */ - public double getYUtoD2(double u) { - if(Double.isNaN(u)) return u; - return getLayer().getYPtoD2(yTransform_.getTransP(u)); - } - /** - * Transform time to physical coordinate. - * @since 2.0 - */ - public double getYUtoP(GeoDate t) { - return yTransform_.getTransP(t); - } - /** - * Transform time to physical coordinate. - * @since 3.0 - */ - public double getYUtoP(long t) { - if(t == Long.MAX_VALUE) return Double.NaN; - return yTransform_.getTransP(t); - } - /** - * Transform time to device coordinate. - * @since 2.0 - */ - public int getYUtoD(GeoDate t) { - if(t == null) return Integer.MIN_VALUE; - return getLayer().getYPtoD(yTransform_.getTransP(t)); - } - /** - * Transform time to device coordinate. - * @since 3.0 - */ - public int getYUtoD(long t) { - if(t == Long.MAX_VALUE) return Integer.MIN_VALUE; - return getLayer().getYPtoD(yTransform_.getTransP(t)); - } - /** - * Transform time to device coordinate. - * @since 3.0 - */ - public double getYUtoD2(GeoDate t) { - if(t == null) return Double.NaN; - return getLayer().getYPtoD2(yTransform_.getTransP(t)); - } - /** - * Transform time to device coordinate. - * @since 3.0 - */ - public double getYUtoD2(long t) { - if(t == Long.MAX_VALUE) return Double.NaN; - return getLayer().getYPtoD2(yTransform_.getTransP(t)); - } - /** - * Transform physical Y coordinate to user coordinate using SoTValue - * @param p physical coordinate - * @return user coorindinate - * @since 3.0 - */ - public SoTValue getYPtoSoT(double p) { - if(yTransform_.isTime()) { - return new SoTValue.Time(yTransform_.getLongTimeTransU(p)); - } else { - return new SoTValue.Double(yTransform_.getTransU(p)); - } - } - /** - * Transform physical Y coordinate to user coordinate. - * - * @param p physical coorindate - * @return user coordinate - **/ - public double getYPtoU(double p) { - return yTransform_.getTransU(p); - } - /** - * Transform physical Y coordinate to time. - * - * @param p physical coordinate - * @return time - **/ - public GeoDate getYPtoTime(double p) { - return yTransform_.getTimeTransU(p); - } - /** - * Transform physical Y coordinate to time. - * - * @param p physical coordinate - * @return time - * @since 3.0 - **/ - public long getYPtoLongTime(double p) { - return yTransform_.getLongTimeTransU(p); - } - - public void propertyChange(PropertyChangeEvent evt) { - // if(Debug.EVENT) { - // System.out.println("CartesianGraph: " + evt); - // System.out.println(" " + evt.getPropertyName()); - // } - modified("CartesianGraph: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - /** - * Find data at point - * @since 3.0 - */ - public SGTData getDataAt(Point pt) { - return renderer_.getDataAt(pt); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CartesianRenderer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CartesianRenderer.java deleted file mode 100755 index b01ff225..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/CartesianRenderer.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * $Id: CartesianRenderer.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTPoint; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.SGTImage; -import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.dm.SGTVector; -import gov.noaa.pmel.sgt.dm.Annotation; - -import gov.noaa.pmel.util.Debug; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Point; -import java.beans.PropertyChangeListener; - -/** - * CartesianRenderer defines an interface to enable data to - * be rendered on a CartesianGraph. - * - * @see CartesianGraph - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public abstract class CartesianRenderer implements PropertyChangeListener { - /** - * Factory method to create a new Renderer instance given - * the SGTData object and Attribute. - * For example, a LineCartesianRenderer - * is created if SGTData object is a SGTLine. - *

- * A renderer is constucted based on the two arguements. - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
- *

SGTData - *

- *

Attribute - *

- *

CartesianRenderer - *

SGTPointPointAttributePointCartesianRenderer
SGTLineLineAttributeLineCartesianRenderer
SGTGridGridAttributeGridCartesianRenderer
SGTVectorVectorAttributeVectorCartesianRenderer
CollectionPointAttributePointCartesianRenderer
CollectionLineAttributeLineCartesianRenderer
CollectionVectorAttributeVectorCartesianRenderer
Annotationn/aAnnotationCartesianRenderer
- *

- * - * @param dmo DataModel object - */ - public static CartesianRenderer getRenderer(CartesianGraph cg, - SGTData dmo, - Attribute attr) { - if(dmo instanceof SGTPoint) { - return new PointCartesianRenderer(cg, - (SGTPoint)dmo, - (PointAttribute)attr); - } else if(dmo instanceof SGTLine) { - return new LineCartesianRenderer(cg, - (SGTLine)dmo, - (LineAttribute)attr); - } else if(dmo instanceof SGTGrid) { - return new GridCartesianRenderer(cg, - (SGTGrid)dmo, - (GridAttribute)attr); - } else if(dmo instanceof SGTVector) { - return new VectorCartesianRenderer(cg, - (SGTVector)dmo, - (VectorAttribute)attr); - } else if(dmo instanceof Collection) { - Object fe = ((Collection)dmo).firstElement(); - if(fe instanceof SGTPoint) { - return new PointCartesianRenderer(cg, - (Collection)dmo, - (PointAttribute)attr); - } else if(fe instanceof SGTLine) { - return new LineCartesianRenderer(cg, - (Collection)dmo, - (LineAttribute)attr); - } else if(fe instanceof SGTVector) { - return new VectorCartesianRenderer(cg, - (Collection)dmo, - (VectorAttribute)attr); - } - } else if(dmo instanceof Annotation) { - return new AnnotationCartesianRenderer(cg, - (Annotation)dmo, - null); - } - return null; - } - /** - * Render the SGTData object. This method should - * never be called directly. - * - * @see Pane#draw - */ - public abstract void draw(Graphics g); - /** - * Get the Attribute associated with the - * renderer. - * - * @return the Attribute - */ - public abstract Attribute getAttribute(); - /** - * Get the CartesianGraph associated with the - * renderer. - * @since 2.0 - * - * @return the CartesianGraph - */ - public abstract CartesianGraph getCartesianGraph(); -/** @directed - * @label cg*/ - protected CartesianGraph cg_; - /** - * Get parent pane. - * @since 2.0 - */ - public AbstractPane getPane() { - return cg_.getPane(); - } - /** - * For internal sgt use. - * @since 2.0 - */ - public void modified(String mess) { - if(cg_ != null) - cg_.modified(mess); - } - /** - * Find data object. - * @since 3.0 - */ - public SGTData getDataAt(int x, int y) { - return getDataAt(new Point(x, y)); - } - /** - * Find data object. - * @since 3.0 - */ - public abstract SGTData getDataAt(Point pt); -} - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ChildNotFoundException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ChildNotFoundException.java deleted file mode 100755 index 2f68ecb5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ChildNotFoundException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: ChildNotFoundException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Child was not found during operation. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class ChildNotFoundException extends SGException { - public ChildNotFoundException() { - super(); -} - public ChildNotFoundException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ColorKey.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ColorKey.java deleted file mode 100755 index d0ca29be..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ColorKey.java +++ /dev/null @@ -1,744 +0,0 @@ -/* - * $Id: ColorKey.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Color; -import java.awt.Font; -import java.awt.Insets; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.awt.Point; - -// jdk1.2 -//import java.awt.geom.Rectangle2D; -//import java.awt.geom.Point2D; - -/** - * The ColorKey class provides a graphical depiction - * of the relationship between a ColorMap - * and user values. A single ColorKey can be - * attached to a Layer. A ColorMap - * is associated with the Key and therefor with a specific transformation - * and optionally a SGTData object. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @see Ruler - * @see ColorMap - * @see Layer -**/ -public class ColorKey implements Cloneable, DataKey, - PropertyChangeListener { - // Scale members - /**@label title - * @link aggregationByValue - * @undirected - */ - private SGLabel title_ = null; - // - private String ident_; - /** @directed */ - private Layer layer_; - /**@label scale - * @link aggregationByValue */ - private Ruler scale_ = new Ruler(); // mod Tom Ewing - private int valign_; - private int halign_; - private int orient_; - private int style_; - private boolean selected_; - private boolean selectable_; - private boolean visible_; - /** - * maximum bounds of key in p-space - */ -// private Rectangle2D.Double pbounds_; - private Point2D.Double porigin_; - private Dimension2D psize_; - /** - * top, left, bottom, right in p-space - */ - private double[] insets_ = {0.05, 0.15, 0.05, 0.15}; - private double barWidth_ = 0.2; - - /** - * @label cm - */ - private ColorMap cm_ = null; - /** - * Use plain line border. - */ - public static final int PLAIN_LINE = 0; - /** - * Use raised border. - */ - public static final int RAISED = 1; - /** - * Do not draw a border. - */ - public static final int NO_BORDER = 2; - /** - * Align to top of key. - */ - public static final int TOP = 0; - /** - * Align to middle of key. - */ - public static final int MIDDLE = 1; - /** - * Align to bottom of key. - */ - public static final int BOTTOM = 2; - /** - * Align to left of key. - */ - public static final int LEFT = 0; - /** - * Align to center of key. - */ - public static final int CENTER = 1; - /** - * Align to right of key. - */ - public static final int RIGHT = 2; - /** - * Orient key horizontally. - */ - public static final int HORIZONTAL = 1; - /** - * Orient key vertically. - */ - public static final int VERTICAL = 2; - -// private boolean moveable_ = false; -// private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - /** - * Default ColorKey constructor. The location and size - * must be specified before the ColorKey is - * attached to a layer! - **/ - public ColorKey() { - this(new Rectangle2D.Double(), BOTTOM, LEFT); - } - /** - * ColorKey constructor that include location, size, - * and alignment information. Default orientation is - * HORIZONTAL. - * - * @param pr a Rectangle2D object that includes location and size - * @param valign vertical alignment - * @param halign horizontal alignment - **/ - public ColorKey(Rectangle2D.Double pr,int valign,int halign) { - this(new Point2D.Double(pr.x, pr.y), - new Dimension2D(pr.width, pr.height), - valign, halign); - } - /** - * @since 3.0 - */ - public ColorKey(Point2D.Double pt, Dimension2D size, int valign, int halign) { - porigin_ = pt; - psize_ = size; -// pbounds_ = new Rectangle2D.Double(pt.x, pt.y, size.width, size.height); - valign_ = valign; - halign_ = halign; - // - // set defaults - // - orient_ = HORIZONTAL; - selected_ = false; - selectable_ = true; - visible_ = true; - style_ = PLAIN_LINE; -// moveable_ = false; - - } - /** - * Create a copy of ColorKey. - * - * @return a copy of the key - */ - public LayerChild copy() { - ColorKey newKey; - try { - newKey = (ColorKey)clone(); - } catch (CloneNotSupportedException e) { - newKey = new ColorKey(); - } - return (LayerChild)newKey; - } - /** - * Sets the selected property. - * @since 2.0 - * - * @param sel true if selected, false if not. - */ - public void setSelected(boolean sel) { - selected_ = sel; - } - /** - * Returns true if the selected property is set. - * - * @return true is selected, false if not. - */ - public boolean isSelected() { - return selected_; - } - /** - * Sets the selectable property. - * @since 2.0 - */ - public void setSelectable(boolean select) { - selectable_ = select; - } - /** - * Tests the selectable property. - * @since 2.0 - */ - public boolean isSelectable() { - return selectable_; - } - /** - * Set ColorKey identifier. - * - * @param id key identifier - */ - public void setId(String id) { - ident_ = id; - } - /** - * Get ColorKey identifier - * - * @return identifier - */ - public String getId() { - return ident_; - } - /** - * Set parent Layer. Method should not be called - * directly, called when the Layer.addChild - * method is called. - * - * @param l parent layer - */ - public void setLayer(Layer l) { - layer_ = l; - } - /** - * Returns the layer the ColorKey is attached. - * - * @return The parent layer. - * @see Layer - **/ - public Layer getLayer() { - return layer_; - } - /** - * Get the parent pane. - * @since 2.0 - */ - public AbstractPane getPane() { - return layer_.getPane(); - } - /** - * For internal sgt use. - * @since 2.0 - */ - public void modified(String mess) { - // if(Debug.EVENT) System.out.println("ColorKey: modified()"); - if(layer_ != null) - layer_.modified(mess); - } - /** - * Set color map. - * - * @param cm color map - */ - public void setColorMap(ColorMap cm) { - if(cm_ == null || !cm_.equals(cm)) { - if(cm_ != null) cm_.removePropertyChangeListener(this); - cm_ = cm; - cm_.addPropertyChangeListener(this); - modified("ColorKey: setColorMap()"); - } - } - /** - * Add a GridCartesianRenderer and label to the ColorKey. - * - * @param rend GridCartesianRenderer object - * @param label descriptive label - * @since 3.0 - */ - public void addGraph(CartesianRenderer rend, SGLabel label) - throws IllegalArgumentException { - if(!(rend instanceof GridCartesianRenderer)) - throw new IllegalArgumentException("Renderer is not a GridCartesianRenderer"); - GridAttribute ga = (GridAttribute)((GridCartesianRenderer)rend).getAttribute(); - ColorMap cm = ga.getColorMap(); - setColorMap(cm); - setTitle(label); - // addVectorGraph((VectorCartesianRenderer)rend, label); - } - /** - * Get color map. - * - * @return color map - */ - public ColorMap getColorMap() { - return cm_; - } - /** - * Set border style. - * - * @param style border style - * @see #PLAIN_LINE - * @see #RAISED - * @see #NO_BORDER - */ - public void setBorderStyle(int style) { - if(style_ != style) { - style_ = style; - modified("LineKey: setBorderStyle()"); - } - } - /** - * Get border style. - * - * @return border style - */ - public int getBorderStyle() { - return style_; - } - /** - * Set color key alignment. - * - * @param vert vertical alignment - * @param horz horizontal alignment - */ - public void setAlign(int vert,int horz) { - if(valign_ != vert || halign_ != horz) { - valign_ = vert; - halign_ = horz; - modified("ColorKey: setAlign()"); - } - } - /** - * Set orientation. - * - * @param orient key orientation - */ - public void setOrientation(int orient) { - if(orient_ != orient) { - orient_ = orient; - modified("ColorKey: setOrientation()"); - } - } - /** - * Set vertical alignment - * - * @param vert vertical alignment - */ - public void setVAlign(int vert) { - if(valign_ != vert) { - valign_ = vert; - modified("ColorKey: setVAlign()"); - } - } - /** - * Set horizontal alignment - * - * @param horz horizontal alignment - */ - public void setHAlign(int horz) { - if(halign_ != horz) { - halign_ = horz; - modified("ColorKey: setHAlign()"); - } - } - /** - * Get vertical alignment - * - * @return vertical alignment - */ - public int getVAlign() { - return valign_; - } - /** - * Get horizontal alignment - * - * @return horizontal alignment - */ - public int getHAlign() { - return halign_; - } - /** - * Set location of key in physical coordinates. - * - * @param loc key location - */ - public void setLocationP(Point2D.Double loc) { - if(porigin_.x != loc.x || porigin_.y != loc.y) { -// Point2D.Double temp = new Point2D.Double(pbounds_.x, pbounds_.y); - porigin_.x = loc.x; - porigin_.y = loc.y; - modified("ColorKey: setLocationP()"); -// changes_.firePropertyChange("location", temp, loc); - } - } - /** - * Set the size of the key in physical coordinates. - * - * @param d size of key - */ - public void setSizeP(Dimension2D d) { - if(psize_.width != d.width || psize_.height != d.height) { - psize_.width = d.width; - psize_.height = d.height; - modified("ColorKey: setSizeP()"); - } - } - /** - * Set the bounds of the key in physical coordinates. - * - * @param r bounding rectangle - */ - public void setBoundsP(Rectangle2D.Double r) { - if(Debug.EVENT) System.out.println("ColorKey: porigin = " + - porigin_ + ", r = " + r); - setLocationP(new Point2D.Double(r.x, r.y)); - setSizeP(new Dimension2D(r.width, r.height)); -// if(pbounds_ == null || !pbounds_.equals(r)) { -// pbounds_ = r; -// modified("ColorKey: setBoundsP()"); -// } - } - /** - * Get the bounding rectangle for the key in physical - * coordinates. - * - * @return bounding rectangle - */ - public Rectangle2D.Double getBoundsP() { - return new Rectangle2D.Double(porigin_.x, porigin_.y, - psize_.width, psize_.height); - } - /** - * Gets the bounding rectangle in device - * coordinates. - * - * @return bounding rectangle - */ - public Rectangle getBounds() { - int x, y, height, width; - x = layer_.getXPtoD(porigin_.x); - y = layer_.getYPtoD(porigin_.y); - width = layer_.getXPtoD(porigin_.x + psize_.width) - x; - height = layer_.getYPtoD(porigin_.y - psize_.height) - y; - switch(halign_) { - case RIGHT: - x = x - width; - break; - case CENTER: - x = x - width/2; - } - switch(valign_) { - case BOTTOM: - y = y - height; - break; - case MIDDLE: - y = y - height/2; - } - if(false) { - StringBuffer sbuf = new StringBuffer("\nColorKey.getBounds(): "); - switch(halign_) { - case RIGHT: - sbuf.append("RIGHT"); - break; - case LEFT: - sbuf.append("LEFT"); - break; - case CENTER: - sbuf.append("CENTER"); - break; - } - sbuf.append(", "); - switch(valign_) { - case TOP: - sbuf.append("TOP"); - break; - case BOTTOM: - sbuf.append("BOTTOM"); - break; - case MIDDLE: - sbuf.append("MIDDLE"); - break; - } - System.out.println(sbuf); - System.out.println(" orig = " + porigin_ + ", " + "size = " + psize_); - System.out.println(" x,y,width,height = " + x + ", " + y + ", " + - width + ", " + height); - System.out.println(" layer.getBounds() = " + layer_.getBounds()); - System.out.println(" layer.getBoundsP() = " + layer_.getBoundsP()); - } - return new Rectangle(x, y, width, height); - } - /** - * Change the selected objects bounding rectangle in - * device coordinates. The object will move to the new bounding - * rectangle. - * - * @param r new bounding rectangle - */ - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - /** - * Change the selected objects bounding rectangle in - * device coordinates. The object will move to the new bounding - * rectangle. - * - * @param x horizontal location, positive right - * @param y vertical location, positive down - * @param width horizontal size - * @param height vertical size - */ - public void setBounds(int x, int y, int width, int height) { - switch(halign_) { - case RIGHT: - x = x + width; - break; - case CENTER: - x = x + width/2; - } - switch(valign_) { - case BOTTOM: - y = y + height; - break; - case MIDDLE: - y = y + height/2; - } -// Point orig = new Point(layer_.getXPtoD(pbounds_.x), -// layer_.getYPtoD(pbounds_.y)); - double xp = layer_.getXDtoP(x); - double yp = layer_.getYDtoP(y); - if(porigin_.x != xp || porigin_.y != yp) { - porigin_.x = xp; - porigin_.y = yp; - modified("ColorKey: setBounds()"); -// changes_.firePropertyChange("location", -// orig, new Point(x,y)); - } - } - /** - * Set the title of the key. - * - * @param title key title - */ - public void setTitle(SGLabel title) { - if(title_ == null || !title_.equals(title)) { - title_ = title; - modified("ColorKey: setTitle()"); - } - } - /** - * Get the key's title. - * - * @return the title - */ - public SGLabel getTitle() { - return title_; - } - /** - * Get the Ruler associated - * with the key. - * - * @return the ruler - */ - public Ruler getRuler() { - return scale_; - } - /** - * Draw the ColorKey. This method should not be directly called. - * - * @see Pane#draw - */ - public void draw(Graphics g) { - Rectangle bounds; - double xp, yp; // lower-left coordinates in p-space - double ptop, pbottom, pleft, pright; // insets in p-space - double delta; - if(!visible_) return; - ptop = insets_[0]; - pbottom =insets_[2]; - pleft = insets_[1]; - pright = insets_[3]; - xp = porigin_.x; - yp = porigin_.y; - switch(halign_) { - case RIGHT: - xp = xp - psize_.width; - break; - case CENTER: - xp = xp - psize_.width/2; - } - switch(valign_) { - case TOP: - yp = yp - psize_.height; - break; - case MIDDLE: - yp = yp - psize_.height/2; - } - bounds = getBounds(); - g.setColor(Color.black); - switch(style_) { - case PLAIN_LINE: - g.drawRect(bounds.x, bounds.y, bounds.width-1, bounds.height-1); - break; - case RAISED: - break; - default: - case NO_BORDER: - } - - if(cm_ == null) return; - Range2D uRange = cm_.getRange(); - // - if(Double.isNaN(uRange.delta)) { - Range2D rnge = Graph.computeRange(uRange.start, uRange.end, 10); - delta = rnge.delta; - } else { - delta = uRange.delta; - } - if(orient_ == HORIZONTAL) { - drawBar(g, xp + pleft, yp + psize_.height - ptop, - psize_.width - pleft - pright, - psize_.height - ptop - pbottom); - //scale_ = new Ruler(); // mod Tom Ewing - scale_.setOrientation(Ruler.HORIZONTAL); - scale_.setLayer(layer_); - scale_.setTitle(title_); - scale_.setTicPosition(Ruler.NEGATIVE_SIDE); - scale_.setLabelPosition(Ruler.NEGATIVE_SIDE); - scale_.setBoundsP(new Rectangle2D.Double(xp + pleft, - yp + psize_.height - ptop - barWidth_, - psize_.width - pleft - pright, - psize_.height - ptop - pbottom)); - scale_.setRangeU(new Range2D(uRange.start, uRange.end, delta)); - scale_.draw(g); - } else { - drawBar(g, xp + pleft, yp + pbottom, - psize_.width - pleft - pright, - psize_.height - ptop - pbottom); - //scale_ = new Ruler(); // mod dwd - scale_.setOrientation(Ruler.VERTICAL); - scale_.setLayer(layer_); - scale_.setTitle(title_); - scale_.setTicPosition(Ruler.POSITIVE_SIDE); - scale_.setLabelPosition(Ruler.POSITIVE_SIDE); - scale_.setBoundsP(new Rectangle2D.Double(xp + pleft + barWidth_, - yp + pbottom, - psize_.width - pleft - pright, - psize_.height - ptop - pbottom)); - scale_.setRangeU(new Range2D(uRange.start, uRange.end, delta)); - scale_.draw(g); - } - } - // - void drawBar(Graphics g, - double plocx, double plocy, - double pwidth, double pheight) { - int yloc, xloc, xend, yend; - int dBarHeight, dBarWidth; - Range2D uRange = cm_.getRange(); - AxisTransform sTrans; - if(orient_ == HORIZONTAL) { - dBarHeight = layer_.getYPtoD(plocy - barWidth_) - - layer_.getYPtoD(plocy); - sTrans = new LinearTransform(plocx, plocx + pwidth, - uRange.start, uRange.end); - yloc = layer_.getYPtoD(plocy); - xloc = layer_.getXPtoD(sTrans.getTransP(uRange.start)); - xend = layer_.getXPtoD(sTrans.getTransP(uRange.end)); - for(int i=xloc; i <= xend; i++) { - g.setColor(cm_.getColor(sTrans.getTransU(layer_.getXDtoP(i)))); - g.fillRect(i, yloc, 1, dBarHeight); - } - } else { - dBarWidth = layer_.getXPtoD(plocx + barWidth_) - layer_.getXPtoD(plocx); - sTrans = new LinearTransform(plocy, plocy + pheight, - uRange.start, uRange.end); - xloc = layer_.getXPtoD(plocx); - yloc = layer_.getYPtoD(sTrans.getTransP(uRange.start)); - yend = layer_.getYPtoD(sTrans.getTransP(uRange.end)); - for(int i=yend; i <= yloc; i++) { - g.setColor(cm_.getColor(sTrans.getTransU(layer_.getXDtoP(i)))); - g.fillRect(xloc, i, dBarWidth, 1); - } - } - } - /** - * Get a string representation of the key. - * - * @return string representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - /** - * Check if ColorKey is visible. - * @since 2.0 - */ - public boolean isVisible() { - return visible_; - } - /** - * Set visibility state for ColorKey. - * @since 2.0 - */ - public void setVisible(boolean visible) { - if(visible_ != visible) { - visible_ = visible; - modified("ColorKey: setVisible()"); - } - } - public void propertyChange(PropertyChangeEvent evt) { - modified("ColorKey: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - - /** - * Set columns. Unimplmented. - * @param col - * @since 3.0 - */ - public void setColumns(int col) {} - /** - * Set line lenght. Unimplemented. - * @since 3.0 - */ - public void setLineLengthP(double len) {} - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ColorMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ColorMap.java deleted file mode 100755 index c42a7090..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ColorMap.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * $Id: ColorMap.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; -import java.io.Serializable; - -/** - * ColorMap provides a mapping from an index or - * value to a Color. Several methods of mapping an - * index or value to a Color are summarized below.
- * - *

- *
IndexedColorMap
- *
Color is determined from an array, - * the index computed from a Transform. - *
TransformColorMap
- *
Red, green, blue Color components - * are computed from Transforms. - *
CLIndexedColorMap
- *
Color is determined from and array, - * the index computed from a ContourLevels object. - *
CLTransformColorMap
- *
Red, green, blue Color components - * are computed from Transforms, using - * the index computed from a ContourLevels - * object divided by the maximum index value. - *
- * - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -abstract public class ColorMap implements Cloneable, PropertyChangeListener, Serializable { - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - protected boolean batch_ = false; - protected boolean local_ = true; - protected boolean modified_ = false; - abstract public ColorMap copy(); - /** - * Get a Color. - * - * @param val Value - * @return Color - * - */ - abstract public Color getColor(double val); - - /** - * Get the current user range for the Transforms or - * ContourLevel. - * - * @return user range - */ - abstract public Range2D getRange(); - /** - * Test for equality of color maps. - */ - abstract public boolean equals(ColorMap cm); - /** - * Add listener to changes in ColorMap properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - changes_.addPropertyChangeListener(listener); - } - /** - * Remove listener. - */ - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } - public void propertyChange(PropertyChangeEvent evt) { - if(Debug.EVENT) { - System.out.println("ColorMap: " + evt); - System.out.println(" " + evt.getPropertyName()); - } - firePropertyChange(evt.getPropertyName(), - evt.getOldValue(), - evt.getNewValue()); - } - - protected void firePropertyChange(String name, Object oldValue, Object newValue) { - if(batch_) { - modified_ = true; - return; - } - AttributeChangeEvent ace = new AttributeChangeEvent(this, name, - oldValue, newValue, - local_); - changes_.firePropertyChange(ace); - modified_ = false; - } - - /** - * Batch the changes to the ColorMap. - * - * @since 3.0 - */ - public void setBatch(boolean batch) { - setBatch(batch, true); - } - /** - * Batch the changes to the ColorMap and set local flag. - * Determines whether AttributeChangeEvent will be set local. - * - * @since 3.0 - */ - public void setBatch(boolean batch, boolean local) { - local_ = local; - batch_ = batch; - if(!batch && modified_) firePropertyChange("batch", Boolean.TRUE, Boolean.FALSE); - } - /** - * Is the attribute in batch mode? - * - * @since 3.0 - */ - public boolean isBatch() { - return batch_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevelNotFoundException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevelNotFoundException.java deleted file mode 100755 index 7ace1645..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevelNotFoundException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: ContourLevelNotFoundException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Contour level does not exist. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class ContourLevelNotFoundException extends SGException { - public ContourLevelNotFoundException() { - super(); -} - public ContourLevelNotFoundException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevels.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevels.java deleted file mode 100755 index b9af084e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevels.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * $Id: ContourLevels.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; - -import java.util.Vector; -import java.util.Hashtable; -import java.util.Enumeration; -import java.awt.Color; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * Contains levels and line styles for contour graphics. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public class ContourLevels implements Cloneable { - /** - * @label defaultAttr - * @link aggregationByValue - * @supplierCardinality 1 - */ - private DefaultContourLineAttribute defaultAttr_ = - new DefaultContourLineAttribute(); - private Vector levels_ = new Vector(); - private Hashtable lineAttrMap_ = new Hashtable(); - private boolean sorted_ = false; - /** - * @label solid - * @link aggregationByValue - */ - static private ContourLineAttribute solid_ = - new ContourLineAttribute(ContourLineAttribute.SOLID); - - /** - * @label heavy - * @link aggregationByValue - */ - static private ContourLineAttribute heavy_ = - new ContourLineAttribute(ContourLineAttribute.HEAVY); - - /** - * @label dashed - * @link aggregationByValue - */ - static private ContourLineAttribute dashed_ = - new ContourLineAttribute(ContourLineAttribute.DASHED); - - private PropertyChangeSupport changes_ = - new PropertyChangeSupport(this); - - /** - * @directed - * @label lineAttrMap - * @link aggregation - * @supplierCardinality 1..* - */ - private ContourLineAttribute lnkLineAttribute; - /** - * Construct a default ContourLevels object from a double[]. - */ - static public ContourLevels getDefault(double[] array) { - ContourLevels cl = new ContourLevels(); - double val = 0.0; - for(int i=0; i < array.length; i++) { - cl.addLevel(array[i]); - } - return cl; - } - /** - * Construct a default ContourLevels object from a - * Range2D. - */ - static public ContourLevels getDefault(Range2D range) { - ContourLevels cl = new ContourLevels(); - double val = range.start; - while(val <= range.end) { - cl.addLevel(val); - val = val + range.delta; - } - return cl; - } - /** - * Create a deep copy. - */ - public ContourLevels copy() { - ContourLevels newcls; - try { - newcls = (ContourLevels)clone(); - // newcls.defaultAttr_ = - // (DefaultContourLineAttribute)this.defaultAttr_.copy(); - newcls.levels_ = (Vector)this.levels_.clone(); - newcls.lineAttrMap_ = (Hashtable)this.lineAttrMap_.clone(); - } catch (CloneNotSupportedException e) { - newcls = null; - } - return newcls; - } - /** - * Get the contour level elements. - */ - public Enumeration levelElements() { - if(!sorted_) sort(); - return levels_.elements(); - } - /** - * Set a the ContourLineAttribute for a value. - */ - public void setContourLineAttribute(double val, ContourLineAttribute l) - throws ContourLevelNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Set a the ContourLineAttribute for an index. - */ - public void setContourLineAttribute(int indx, ContourLineAttribute l) - throws ContourLevelNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Get the ContourLineAttribute for a value. - */ - public ContourLineAttribute getContourLineAttribute(double val) - throws ContourLevelNotFoundException { - ContourLineAttribute attr = - (ContourLineAttribute)lineAttrMap_.get(new Double(val)); - if(attr == null) { - throw new ContourLevelNotFoundException(); - } - return attr; - } - /** - * Get the ContourLineAttribute for an index. - */ - public ContourLineAttribute getContourLineAttribute(int indx) - throws ContourLevelNotFoundException { - if(!sorted_) sort(); - return getContourLineAttribute(getLevel(indx)); - } - /** - * Get the DefaultContourLineAtrribute - */ - public DefaultContourLineAttribute getDefaultContourLineAttribute() { - return defaultAttr_; - } - /** - * Get the DefaultContourLineAttribute for index. - */ - public DefaultContourLineAttribute getDefaultContourLineAttribute(int indx) - throws ContourLevelNotFoundException { - if(!sorted_) sort(); - return - defaultAttr_.setContourLineAttribute(getContourLineAttribute(getLevel(indx))); - } - /** - * Get the DefaultContourLineAttribute for value. - */ - public DefaultContourLineAttribute getDefaultContourLineAttribute(double val) - throws ContourLevelNotFoundException { - if(!sorted_) sort(); - return - defaultAttr_.setContourLineAttribute(getContourLineAttribute(val)); - } - /** - * Set the DefaultContourLineAttribute - */ - public void setDefaultContourLineAttribute(DefaultContourLineAttribute attr) { - defaultAttr_ = attr; - } - /** - * Add a contour level with default ContourLineAttribute. - */ - public void addLevel(double val) { - ContourLineAttribute attr = null; - if(val < 0.0) { - attr = (ContourLineAttribute)dashed_.copy(); - } else if (val > 0.0) { - attr = (ContourLineAttribute)solid_.copy(); - } else { - attr = (ContourLineAttribute)heavy_.copy(); - } - attr.setStyleOverridden(true); - addLevel(val, attr); - } - /** - * Add a contour level with a specified - * ContourLineAttribute. - */ - public void addLevel(double val, ContourLineAttribute l) { - Double value = new Double(val); - levels_.addElement(value); - lineAttrMap_.put(value, l); - sorted_ = false; - } - /** - * Get the value of level by index. - */ - public double getLevel(int indx) - throws ContourLevelNotFoundException { - if(indx < 0 || indx >= levels_.size()) - throw new ContourLevelNotFoundException(); - if(!sorted_) sort(); - Double value = (Double)levels_.elementAt(indx); - return value.doubleValue(); - } - /** - * Remove a level by value. - */ - public void removeLevel(double val) - throws ContourLevelNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Remove a level by index. - */ - public void removeLevel(int indx) - throws ContourLevelNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Get the index of a level by value - */ - public int getIndex(Double dval) { - if(!sorted_) sort(); - return levels_.indexOf(dval); - } - /** - * Get the index of a level by value - */ - public int getIndex(double val) { - if(!sorted_) sort(); - return getIndex(new Double(val)); - } - /** - * Get the maximum level index. - */ - public int getMaximumIndex() { - return levels_.size() - 1; - } - /** - * Get the range of levels - */ - public Range2D getRange() { - double min = Double.MAX_VALUE; - double max = Double.MIN_VALUE; - double value; - for(int i=0; i < levels_.size(); i++) { - value = ((Double)levels_.get(i)).doubleValue(); - min = Math.min(min, value); - max = Math.max(max, value); - } - return new Range2D(min, max); - } - /** - * Get the number of levels. - */ - public int size() { - return levels_.size(); - } - - private void sort() { - // - // use brain-dead bubble sort (there will be few lines) - // - int i, temp; - int size = levels_.size(); - Double a, b; - int[] index = new int[size]; - boolean flipped = true; - for(i=0; i < size; i++) { - index[i] = i; - } - while(flipped) { - flipped = false; - for(i=0; i < size-1; i++) { - a = (Double)levels_.elementAt(index[i]); - b = (Double)levels_.elementAt(index[i+1]); - if(a.doubleValue() > b.doubleValue()) { - // if(a.compareTo(b) > 0) { // jdk1.2 - temp = index[i]; - index[i] = index[i+1]; - index[i+1] = temp; - flipped = true; - } - } - } - Vector oldValues = levels_; - levels_ = new Vector(size); - for(i=0; i < size; i++) { - levels_.addElement(oldValues.elementAt(index[i])); - } - sorted_ = true; - } - - /** - * Add listener to changes in ColorMap properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - changes_.addPropertyChangeListener(listener); - } - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevelsAccess.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevelsAccess.java deleted file mode 100755 index 13ab55b4..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLevelsAccess.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * $Id: ContourLevelsAccess.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; -/** - * Defines the functionality for accessing contour level information - * for color maps. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public interface ContourLevelsAccess { - - ContourLevels getContourLevels(); - - void setContourLevels(ContourLevels contourLevels); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLineAttribute.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLineAttribute.java deleted file mode 100755 index bfaf42d5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/ContourLineAttribute.java +++ /dev/null @@ -1,627 +0,0 @@ -/* - * $Id: ContourLineAttribute.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; - -/** - * Sets the rendering style for a contour line. - * Color, width, and dash characteristics are - * ContourLineAttribute properties. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - * @see LineCartesianRenderer - * @see ContourLevels - */ -public class ContourLineAttribute extends LineAttribute { - // - private String labelText_; - private boolean labelEnabled_ = false; - private Color labelColor_; - private Font labelFont_; - private double labelHeightP_; - private String labelFormat_; - private boolean autoLabel_ = true; - // - private boolean labelColorOverridden_ = false; - private boolean labelEnabledOverridden_ = false; - private boolean labelHeightPOverridden_ = false; - private boolean labelFontOverridden_ = false; - private boolean labelFormatOverridden_ = false; - // - private boolean colorOverridden_ = false; - private boolean styleOverridden_ = false; - private boolean widthOverridden_ = false; - private boolean dashArrayOverridden_ = false; - private boolean dashPhaseOverridden_ = false; - private boolean capStyleOverridden_ = false; - private boolean miterStyleOverridden_ = false; - private boolean miterLimitOverridden_ = false; - /** - * Default constructor. - */ - public ContourLineAttribute() { - super(); - init(); - } - /** - * Constructor using default Color. Default are: - *
-   *   labelColor = Color.black
-   * labelHeightP = 0.16
-   *    labelFont = null
-   *  labelFormat = ""
-   * 
- */ - public ContourLineAttribute(int style) { - super(style); - init(); - } - /** - * ContourLineAttribute constructor. - * - * @param style line style - * @param color line Color - * @see java.awt.Color - **/ - public ContourLineAttribute(int style, Color color) { - super(style, color); - init(); - } - /** - * ContourLineAttribute constructor for plot marks. - * - * @param style line sytle - * @param mark plot mark - * @param color line Color - **/ - public ContourLineAttribute(int style, int mark, Color color) { - super(style, mark, color); - init(); - } - - private void init() { - labelColor_ = Color.black; - labelHeightP_ = 0.16; - labelFont_ = null; - labelFormat_ = ""; - } - - /** - * Copy the ContourLineAttribute. - * - * @return new ContourLineAttribute - */ - public Object copy() { - ContourLineAttribute newLine; - try { - newLine = (ContourLineAttribute)clone(); - } catch (CloneNotSupportedException e) { - newLine = new ContourLineAttribute(); - } - return newLine; - } - /** - * Set the text to be used for labelling the contour line. - *
Property Change: labelText. - */ - public void setLabelText(String label) { - if(labelText_ == null || !labelText_.equals(label)) { - String tempOld = labelText_; - labelText_ = label; - labelEnabled_ = !(labelText_ == null); - changes_.firePropertyChange("labelText", - tempOld, - labelText_); - } - } - /** - * Get the label text. - */ - public String getLabelText() { - return labelText_; - } - /** - * Enable/disable the contour label. - *
Property Change: labelEnabled. - */ - public void setLabelEnabled(boolean sle) { - if(labelEnabled_ != sle) { - labelEnabledOverridden_ = true; - Boolean tempOld = new Boolean(labelEnabled_); - labelEnabled_ = sle; - changes_.firePropertyChange("labelEnabled", - tempOld, - new Boolean(labelEnabled_)); - } - } - /** - * Test if the contour label is enabled. - */ - public boolean isLabelEnabled() { - return labelEnabled_; - } - /** - * Change the color of the contour label - *
Property Change: labelColor. - */ - public void setLabelColor(Color color) { - if(!labelColor_.equals(color)) { - labelColorOverridden_ = true; - Color tempOld = labelColor_; - labelColor_ = color; - changes_.firePropertyChange("labelColor", - tempOld, - labelColor_); - } - } - /** - * Get the color of the contour label - */ - public Color getLabelColor() { - return labelColor_; - } - /** - * Set the label height in physical units - *
Property Change: labelHeightP. - */ - public void setLabelHeightP(double height) { - if(labelHeightP_ != height) { - labelHeightPOverridden_ = true; - Double tempOld = new Double(labelHeightP_); - labelHeightP_ = height; - changes_.firePropertyChange("labelHeightP", - tempOld, - new Double(labelHeightP_)); - } - } - /** - * Get the label height in physical units - */ - public double getLabelHeightP() { - return labelHeightP_; - } - /** - * Set the contour label font. - *
Property Change: labelFont. - */ - public void setLabelFont(Font font) { - if(labelFont_ == null || !labelFont_.equals(font)) { - labelFontOverridden_ = true; - Font tempOld = labelFont_; - labelFont_ = font; - changes_.firePropertyChange("labelFont", - tempOld, - labelFont_); - } - } - /** - * Get the contour label font - */ - public Font getLabelFont() { - return labelFont_; - } - /** - * Set the format for the contour label. The format is used with - * Format. - *
Property Change: labelFormat. - * @see Format - */ - public void setLabelFormat(String format) { - if(!labelFormat_.equals(format)) { - labelFormatOverridden_ = true; - String tempOld = labelFormat_; - labelFormat_ = format; - changes_.firePropertyChange("labelFormat", - tempOld, - labelFormat_); - } - } - /** - * Get the contour label format - */ - public String getLabelFormat() { - return labelFormat_; - } - /** - * Create contour label from value and format. - *
Property Change: autoLabel. - */ - public void setAutoLabel(boolean auto) { - if(autoLabel_ != auto) { - Boolean tempOld = new Boolean(autoLabel_); - autoLabel_ = auto; - changes_.firePropertyChange("autoLabel", - tempOld, - new Boolean(autoLabel_)); - } - } - /** - * Is auto labelling on? - */ - public boolean isAutoLabel() { - return autoLabel_; - } - /** - * Test if labelEnabled is overridden by - * DefaultContourLineAttribute. - */ - public boolean isLabelEnabledOverridden() { - return labelEnabledOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * labelEnabled. - *
Property Change: labelEnabledOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setLabelEnabledOverridden(boolean override) { - if(labelEnabledOverridden_ != override) { - Boolean tempOld = new Boolean(labelEnabledOverridden_); - labelEnabledOverridden_ = override; - changes_.firePropertyChange("labelEnabledOverridden", - tempOld, - new Boolean(labelEnabledOverridden_)); - } - } - /** - * Test if labelColor is overridden by - * DefaultContourLineAttribute. - */ - public boolean isLabelColorOverridden() { - return labelColorOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * labelColor. - *
Property Change: labelColorOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setLabelColorOverridden(boolean override) { - if(labelColorOverridden_ != override) { - Boolean tempOld = new Boolean(labelColorOverridden_); - labelColorOverridden_ = override; - changes_.firePropertyChange("labelColorOverridden", - tempOld, - new Boolean(labelColorOverridden_)); - } - } - /** - * Test if labelHeightP is overridden by - * DefaultContourLineAttribute. - */ - public boolean isLabelHeightPOverridden() { - return labelHeightPOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * labelHeightP. - *
Property Change: labelHeightPOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setLabelHeightPOverridden(boolean override) { - if(labelHeightPOverridden_ != override) { - Boolean tempOld = new Boolean(labelHeightPOverridden_); - labelHeightPOverridden_ = override; - changes_.firePropertyChange("labelHeightPOverridden", - tempOld, - new Boolean(labelHeightPOverridden_)); - } - } - /** - * Test if labelFont is overridden by - * DefaultContourLineAttribute. - */ - public boolean isLabelFontOverridden() { - return labelFontOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * labelFont. - *
Property Change: labelFontOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setLabelFontOverridden(boolean override) { - if(labelFontOverridden_ != override) { - Boolean tempOld = new Boolean(labelFontOverridden_); - labelFontOverridden_ = override; - changes_.firePropertyChange("labelFontOverridden", - tempOld, - new Boolean(labelFontOverridden_)); - } - } - /** - * Test if labelFormat is overridden by - * DefaultContourLineAttribute. - */ - public boolean isLabelFormatOverridden() { - return labelFormatOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * labelFormat. - *
Property Change: labelFormatOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setLabelFormatOverridden(boolean override) { - if(labelFormatOverridden_ != override) { - Boolean tempOld = new Boolean(labelFormatOverridden_); - labelFormatOverridden_ = override; - changes_.firePropertyChange("labelFormatOverridden", - tempOld, - new Boolean(labelFormatOverridden_)); - } - } - public void setDashArray(float[] dashes) { - dashArrayOverridden_ = true; - super.setDashArray(dashes); - } - /** - * Test if dashArray is overridden by - * DefaultContourLineAttribute. - */ - public boolean isDashArrayOverridden() { - return dashArrayOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * dashArray. - *
Property Change: dashArrayOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setDashArrayOverridden(boolean override) { - if(dashArrayOverridden_ != override) { - Boolean tempOld = new Boolean(dashArrayOverridden_); - dashArrayOverridden_ = override; - changes_.firePropertyChange("dashArrayOverridden", - tempOld, - new Boolean(dashArrayOverridden_)); - } - } - public void setDashPhase(float phase) { - dashPhaseOverridden_ = true; - super.setDashPhase(phase); - } - /** - * Test if dashPhase is overridden by - * DefaultContourLineAttribute. - */ - public boolean isDashPhaseOverridden() { - return dashPhaseOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * dashPhase. - *
Property Change: dashPhaseOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setDashPhaseOverridden(boolean override) { - if(dashPhaseOverridden_ != override) { - Boolean tempOld = new Boolean(dashPhaseOverridden_); - dashPhaseOverridden_ = override; - changes_.firePropertyChange("dashPhaseOverridden", - tempOld, - new Boolean(dashPhaseOverridden_)); - } - } - public void setStyle(int st) { - if(st == MARK || st == MARK_LINE) return; - styleOverridden_ = true; - super.setStyle(st); - } - /** - * Test if style is overridden by - * DefaultContourLineAttribute. - */ - public boolean isStyleOverridden() { - return styleOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * style. - *
Property Change: styleOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setStyleOverridden(boolean override) { - if(styleOverridden_ != override) { - Boolean tempOld = new Boolean(styleOverridden_); - styleOverridden_ = override; - changes_.firePropertyChange("styleOverridden", - tempOld, - new Boolean(styleOverridden_)); - } - } - public void setColor(Color c) { - colorOverridden_ = true; - super.setColor(c); - } - /** - * Test if color is overridden by - * DefaultContourLineAttribute. - */ - public boolean isColorOverridden() { - return colorOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * color. - *
Property Change: colorOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setColorOverridden(boolean override) { - if(colorOverridden_ != override) { - Boolean tempOld = new Boolean(colorOverridden_); - colorOverridden_ = override; - changes_.firePropertyChange("colorOverridden", - tempOld, - new Boolean(colorOverridden_)); - } - } - public void setWidth(float t) { - widthOverridden_ = true; - super.setWidth(t); - } - /** - * Test if width is overridden by - * DefaultContourLineAttribute. - */ - public boolean isWidthOverridden() { - return widthOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * width. - *
Property Change: widthOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setWidthOverridden(boolean override) { - if(widthOverridden_ != override) { - Boolean tempOld = new Boolean(widthOverridden_); - widthOverridden_ = override; - changes_.firePropertyChange("widthOverridden", - tempOld, - new Boolean(widthOverridden_)); - } - } - public void setCapStyle(int style) { - capStyleOverridden_ = true; - super.setCapStyle(style); - } - /** - * Test if cap style is overridden by - * DefaultContourLineAttribute. - */ - public boolean isCapStyleOverridden() { - return capStyleOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * cap style. - *
Property Change: capStyleOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setCapStyleOverridden(boolean override) { - if(capStyleOverridden_ != override) { - Boolean tempOld = new Boolean(capStyleOverridden_); - capStyleOverridden_ = override; - changes_.firePropertyChange("capStyleOverridden", - tempOld, - new Boolean(capStyleOverridden_)); - } - } - public void setMiterStyle(int style) { - miterStyleOverridden_ = true; - super.setMiterStyle(style); - } - /** - * Test if miter style is overridden by - * DefaultContourLineAttribute. - */ - public boolean isMiterStyleOverridden() { - return miterStyleOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * miter style. - *
Property Change: miterStyleOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setMiterStyleOverridden(boolean override) { - if(miterStyleOverridden_ != override) { - Boolean tempOld = new Boolean(miterStyleOverridden_); - miterStyleOverridden_ = override; - changes_.firePropertyChange("miterStyleOverridden", - tempOld, - new Boolean(miterStyleOverridden_)); - } - } - public void setMiterLimit(float t) { - miterLimitOverridden_ = true; - super.setMiterLimit(t); - } - /** - * Test if miter limit is overridden by - * DefaultContourLineAttribute. - */ - public boolean isMiterLimitOverridden() { - return miterLimitOverridden_; - } - /** - * Enable/disable having DefaultContourLineAttribute - * override ContourLineAttribute behavior of - * miter limit. - *
Property Change: miterLimitOverridden. - * - * @see DefaultContourLineAttribute - */ - public void setMiterLimitOverridden(boolean override) { - if(miterLimitOverridden_ != override) { - Boolean tempOld = new Boolean(miterLimitOverridden_); - miterLimitOverridden_ = override; - changes_.firePropertyChange("miterLimitOverridden", - tempOld, - new Boolean(miterLimitOverridden_)); - } - } - public String toString() { - Color col = getColor(); - int style = getStyle(); - String sstyle; - if(style == SOLID) { - sstyle = "SOLID"; - } else if(style == DASHED) { - sstyle = "DASHED"; - } else if(style == HEAVY) { - sstyle = "HEAVY"; - } else if(style == HIGHLIGHT) { - sstyle = "HIGHLIGHT"; - } else if(style == MARK) { - sstyle = "MARK - unsupported"; - } else if(style == MARK_LINE) { - sstyle = "MARK_LINE - unsupported"; - } else if(style == STROKE) { - sstyle = "STROKE"; - } else { - sstyle = ""; - } - String scol = "[" + col.getRed() + "," + col.getGreen() + - "," + col.getBlue() + "]"; - return sstyle + ", " + scol + ", labelEnabled=" + labelEnabled_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataKey.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataKey.java deleted file mode 100755 index ab668936..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataKey.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * $Id: DataKey.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; - -/** - * Inticates the class is a key or legend. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 3.0 - * @stereotype container - **/ -public interface DataKey extends LayerChild { - public void setLocationP(Point2D.Double locP); - public void addGraph(CartesianRenderer rend, SGLabel label) - throws IllegalArgumentException; - public void setAlign(int vert, int horz); - public void setHAlign(int horz); - public void setVAlign(int vert); - public void setBorderStyle(int style); - public void setBoundsP(Rectangle2D.Double r); - public void setColumns(int col); - public void setLineLengthP(double len); -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotAssignedException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotAssignedException.java deleted file mode 100755 index 53d034cc..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotAssignedException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: DataNotAssignedException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Graph could not be produced because no data has been assigned. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class DataNotAssignedException extends SGException { - public DataNotAssignedException() { - super(); -} - public DataNotAssignedException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotFoundException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotFoundException.java deleted file mode 100755 index f32fce28..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotFoundException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * $Id: DataNotFoundException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Graph could not be produced because no data has been assigned. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public class DataNotFoundException extends SGException { - public DataNotFoundException() { - super(); -} - public DataNotFoundException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotSameShapeException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotSameShapeException.java deleted file mode 100755 index 7b1169b6..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DataNotSameShapeException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: DataNotSameShapeException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Operation could not be completed since grids are not the same shape. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class DataNotSameShapeException extends SGException { - public DataNotSameShapeException() { - super(); -} - public DataNotSameShapeException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DayMonthAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DayMonthAxis.java deleted file mode 100755 index febda2a2..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DayMonthAxis.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * $Id: DayMonthAxis.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.util.TimeRange; - -/** - * Draws time axes using the day/month style. - * - *
- *        |...........|...........|...........|...........|
- *             3           4           5           6
- *                             jun 93
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @see Axis - * @see TimeAxis - */ -class DayMonthAxis implements TimeAxisStyle { - static final int MONTH_TEST__ = 3; - static final String defaultMinorLabelFormat__ = "dd"; - static final String defaultMajorLabelFormat__ = "yyyy-MM"; - static final int defaultNumSmallTics__ = 0; - int defaultMinorLabelInterval_ = 2; - int defaultMajorLabelInterval_ = 1; - static final double incrementValue__ = 1.0; - static final int incrementUnits__ = GeoDate.DAYS; - /** - * DayMonthAxis constructor. - */ - public DayMonthAxis() { - } - public double computeLocation(double prev,double now) { - return (prev + now)*0.5; - } - public void computeDefaults(GeoDate delta) { - long days = delta.getTime()/GeoDate.MSECS_IN_DAY; - if(days > 30) { - defaultMinorLabelInterval_ = 5; - } else if(days > 10) { - defaultMinorLabelInterval_ = 2; - } else { - defaultMinorLabelInterval_ = 1; - } - } - public int getMinorValue(GeoDate time) { - return time.getGMTDay(); - } - public int getMajorValue(GeoDate time) { - return time.getGMTMonth(); - } - public boolean isRoomForMajorLabel(GeoDate delta) { - return delta.getTime()/GeoDate.MSECS_IN_DAY > MONTH_TEST__; - } - public boolean isStartOfMinor(GeoDate time) { - return time.getGMTDay() == 1; - } - public String getDefaultMinorLabelFormat() { - return defaultMinorLabelFormat__; - } - public String getDefaultMajorLabelFormat() { - return defaultMajorLabelFormat__; - } - public int getDefaultNumSmallTics() { - return defaultNumSmallTics__; - } - public int getDefaultMinorLabelInterval() { - return defaultMinorLabelInterval_; - } - public int getDefaultMajorLabelInterval() { - return defaultMajorLabelInterval_; - } - public GeoDate getStartTime(TimeRange tRange) { - boolean time_increasing; - GeoDate time = null; - time_increasing = tRange.end.after(tRange.start); - try { - if(time_increasing) { - time = new GeoDate(tRange.start.getGMTMonth(), - tRange.start.getGMTDay(), - tRange.start.getGMTYear(), 0, 0, 0, 0); - if(!time.equals(tRange.start)) time.increment(1.0, GeoDate.DAYS); - } else { - time = new GeoDate(tRange.end.getGMTMonth(), - tRange.end.getGMTDay(), - tRange.end.getGMTYear(), 0, 0, 0, 0); - if(!time.equals(tRange.end)) time.increment(1.0, GeoDate.DAYS); - } - } catch (IllegalTimeValue e) {} - return time; - } - public double getIncrementValue() { - return incrementValue__; - } - public int getIncrementUnits() { - return incrementUnits__; - } - public String toString() { - return "DayMonthAxis"; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DefaultContourLineAttribute.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DefaultContourLineAttribute.java deleted file mode 100755 index a0506f94..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/DefaultContourLineAttribute.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * $Id: DefaultContourLineAttribute.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; -import java.lang.CloneNotSupportedException; - -/** - * Sets the default rendering style for contour line data. - * Color, width, and dash characteristics are - * DefaultContourLineAttribute properties. For individual - * contour lines, the characteristics can be overridden by - * ContourLineAttribute when used with - * ContourLevels. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - * @see GridCartesianRenderer - * @see ContourLevels - * @see ContourLineAttribute - */ -public class DefaultContourLineAttribute extends LineAttribute { - /** - * @label attr - */ - private ContourLineAttribute attr_; - private boolean labelEnabled_ = true; - private Color labelColor_; - private Font labelFont_; - private double labelHeightP_; - private int sigDigits_; - private String labelFormat_; - /** - * Default constructor. Defaults are: - *
-   *   labelColor = Color.black
-   * labelHeightP = 0.16
-   *    labelFont = null
-   *  labelFormat = ""
-   *    sigDigits = 2
-   * 
- */ - public DefaultContourLineAttribute() { - super(SOLID, Color.black); - labelColor_ = Color.black; - labelHeightP_ = 0.16; - labelFont_ = null; - sigDigits_ = 2; - labelFormat_ = ""; - } - /** - * Set the ContourLineAttribute that will potentially - * override attributes. - */ - public DefaultContourLineAttribute setContourLineAttribute(ContourLineAttribute attr) { - attr_ = attr; - return this; - } - /** - * Get the associated ContourLineAttribute - */ - public ContourLineAttribute getContourLineAttribute() { - return attr_; - } - /** - * Set label text for associated ContourLineAttribute. - */ - public void setLabelText(String label) { - if(attr_ != null) attr_.setLabelText(label); - } - /** - * Return label text from associated - * ContourLineAttribute, if none return empty string. - */ - public String getLabelText() { - if(attr_ != null) { - return attr_.getLabelText(); - } else { - return ""; - } - } - /** - * Enable/disable the contour label. - *
Property Change: labelEnabled. - */ - public void setLabelEnabled(boolean sle) { - if(labelEnabled_ != sle) { - Boolean tempOld = new Boolean(labelEnabled_); - labelEnabled_ = sle; - changes_.firePropertyChange("labelEnabled", - tempOld, - new Boolean(labelEnabled_)); - } - } - /** - * Test if the contour label is enabled. Use associated - * ContourLineAttribute if it exists and has - * labelEnabledOverrideen set to false. - */ - public boolean isLabelEnabled() { - if(attr_ != null && attr_.isLabelEnabledOverridden()) { - return attr_.isLabelEnabled(); - } else { - return labelEnabled_; - } - } - /** - * Set the default contour label color - *
Property Change: labelColor. - */ - public void setLabelColor(Color color) { - if(!labelColor_.equals(color)) { - Color tempOld = labelColor_; - labelColor_ = color; - changes_.firePropertyChange("labelColor", - tempOld, - labelColor_); - } - } - /** - * Get the contour label color. Use associated - * ContourLineAttribute if it exists and has - * labelColorOverrideen set to false. - */ - public Color getLabelColor() { - if(attr_ != null && attr_.isLabelColorOverridden()) { - return attr_.getLabelColor(); - } else { - return labelColor_; - } - } - /** - * Set the default contour label height. - *
Property Change: labelHeightP. - */ - public void setLabelHeightP(double height) { - if(labelHeightP_ != height) { - Double tempOld = new Double(labelHeightP_); - labelHeightP_ = height; - changes_.firePropertyChange("labelHeightP", - tempOld, - new Double(labelHeightP_)); - } - } - /** - * Get the contour label height. Use associated - * ContourLineAttribute if it exists and has - * labelHeightPOverrideen set to false. - */ - public double getLabelHeightP() { - if(attr_ != null && attr_.isLabelHeightPOverridden()) { - return attr_.getLabelHeightP(); - } else { - return labelHeightP_; - } - } - /** - * Set the default contour label font. - *
Property Change: labelFont. - */ - public void setLabelFont(Font font) { - if(labelFont_ == null || !labelFont_.equals(font)) { - Font tempOld = labelFont_; - labelFont_ = font; - changes_.firePropertyChange("labelFont", - tempOld, - labelFont_); - } - } - /** - * Get the contour label font. Use associated - * ContourLineAttribute if it exists and has - * labelFontOverrideen set to false. - */ - public Font getLabelFont() { - if(attr_ != null && attr_.isLabelFontOverridden()) { - return attr_.getLabelFont(); - } else { - return labelFont_; - } - } - /** - * Set the number of significant digits for auto labelling. - *
Property Change: significantDigits. - */ - public void setSignificantDigits(int sig) { - if(sigDigits_ != sig) { - Integer tempOld = new Integer(sigDigits_); - sigDigits_ = sig; - changes_.firePropertyChange("significantDigits", - tempOld, - new Integer(sigDigits_)); - } - } - /** - * Get the number of significant digits for auto labelling. - */ - public int getSignificantDigits() { - return sigDigits_; - } - /** - * Set the default contour label format. - *
Property Change: labelFormat. - */ - public void setLabelFormat(String format) { - if(!labelFormat_.equals(format)) { - String tempOld = labelFormat_; - labelFormat_ = format; - changes_.firePropertyChange("labelFormat", - tempOld, - labelFormat_); - } - } - /** - * Get the contour label format. Use associated - * ContourLineAttribute if it exists and has - * labelFormatOverrideen set to false. - */ - public String getLabelFormat() { - if(attr_ != null && attr_.isLabelFormatOverridden()) { - return attr_.getLabelFormat(); - } else { - return labelFormat_; - } - } - /** - * Test if auto label is enabled. Use associated - * ContourLineAttribute if it exists otherwise always - * returns true. - */ - public boolean isAutoLabel() { - if(attr_ != null) { - return attr_.isAutoLabel(); - } else { - return true; - } - } - /** - * Get dash array. Use associated - * ContourLineAttribute if it exists and has - * dashArrayOverrideen set to false. - */ - public float[] getDashArray() { - if(attr_ != null && attr_.isDashArrayOverridden()) { - return attr_.getDashArray(); - } else { - return super.getDashArray(); - } - } - /** - * Get the dash phase. Use associated - * ContourLineAttribute if it exists and has - * dashPhaseOverrideen set to false. - */ - public float getDashPhase() { - if(attr_ != null && attr_.isDashPhaseOverridden()) { - return attr_.getDashPhase(); - } else { - return super.getDashPhase(); - } - } - /** - * Override the default setStyle. Legal styles do not - * include MARK or MARK_LINE. - */ - public void setStyle(int st) { - if(st == MARK || st == MARK_LINE) return; - super.setStyle(st); - } - /** - * Get the contour line style. Use associated - * ContourLineAttribute if it exists and has - * styleOverrideen set to false. - */ - public int getStyle() { - if(attr_ != null && attr_.isStyleOverridden()) { - return attr_.getStyle(); - } else { - return super.getStyle(); - } - } - /** - * Get the contour line color. Use associated - * ContourLineAttribute if it exists and has - * colorOverrideen set to false. - */ - public Color getColor() { - if(attr_ != null && attr_.isColorOverridden()) { - return attr_.getColor(); - } else { - return super.getColor(); - } - } - /** - * Get the contour line width. Use associated - * ContourLineAttribute if it exists and has - * widthOverrideen set to false. - */ - public float getWidth() { - if(attr_ != null && attr_.isWidthOverridden()) { - return attr_.getWidth(); - } else { - return super.getWidth(); - } - } - /** - * Get the contour line cap style. Use associated - * ContourLineAttribute if it exists and has - * capStyleOverrideen set to false. - */ - public int getCapStyle() { - if(attr_ != null && attr_.isCapStyleOverridden()) { - return attr_.getCapStyle(); - } else { - return super.getCapStyle(); - } - } - /** - * Get the contour line miter style. Use associated - * ContourLineAttribute if it exists and has - * miterStyleOverrideen set to false. - */ - public int getMiterStyle() { - if(attr_ != null && attr_.isMiterStyleOverridden()) { - return attr_.getMiterStyle(); - } else { - return super.getMiterStyle(); - } - } - /** - * Get the contour line miter limit. Use associated - * ContourLineAttribute if it exists and has - * miterLimitOverrideen set to false. - */ - public float getMiterLimit() { - if(attr_ != null && attr_.isMiterLimitOverridden()) { - return attr_.getMiterLimit(); - } else { - return super.getMiterLimit(); - } - } - - public String toString() { - Color col = getColor(); - int style = getStyle(); - String sstyle; - if(style == SOLID) { - sstyle = "SOLID"; - } else if(style == DASHED) { - sstyle = "DASHED"; - } else if(style == HEAVY) { - sstyle = "HEAVY"; - } else if(style == HIGHLIGHT) { - sstyle = "HIGHLIGHT"; - } else if(style == MARK) { - sstyle = "MARK - unsupported"; - } else if(style == MARK_LINE) { - sstyle = "MARK_LINE - unsupported"; - } else if(style == STROKE) { - sstyle = "STROKE"; - } else { - sstyle = ""; - } - String scol = "[" + col.getRed() + "," + col.getGreen() + - "," + col.getBlue() + "]"; - return sstyle + ", " + scol + ", labelEnabled=" + labelEnabled_; - } - - public Object copy() { - DefaultContourLineAttribute newAttr; - try { - newAttr = (DefaultContourLineAttribute)clone(); - } catch (CloneNotSupportedException e) { - newAttr = new DefaultContourLineAttribute(); - } - return newAttr; - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Format.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Format.java deleted file mode 100755 index 7a6791ae..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Format.java +++ /dev/null @@ -1,534 +0,0 @@ -/* - * $Id: Format.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * Gary Cornell and Cay S. Horstmann, Core Java (Book/CD-ROM) - * Published By SunSoft Press/Prentice-Hall - * Copyright (C) 1996 Sun Microsystems Inc. - * All Rights Reserved. ISBN 0-13-596891-7 - * - * Permission to use, copy, modify, and distribute this - * software and its documentation for NON-COMMERCIAL purposes - * and without fee is hereby granted provided that this - * copyright notice appears in all copies. - * - * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR - * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS - * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED - * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - */ - -package gov.noaa.pmel.sgt; -import java.io.*; -/** - * A class for formatting numbers that follows printf conventions. - * Also implements C-like atoi and atof functions - * - * @version 1.01 15 Feb 1996 - * @since 1.0 - * @author Cay Horstmann - */ -public class Format { - private int width; - private int precision; - private String pre; - private String post; - private boolean leading_zeroes; - private boolean show_plus; - private boolean alternate; - private boolean show_space; - private boolean left_align; - private char fmt; - private static long parseLong(String s,int base) { - int i = 0; int sign = 1; - long r = 0; - - while (i < s.length() && Character.isWhitespace(s.charAt(i))) i++; - if (i < s.length() && s.charAt(i) == '-') { sign = -1; i++; } - else if (i < s.length() && s.charAt(i) == '+') { i++; } - while (i < s.length()) - { char ch = s.charAt(i); - if ('0' <= ch && ch < '0' + base) - r = r * base + ch - '0'; - else if ('A' <= ch && ch < 'A' + base - 10) - r = r * base + ch - 'A' + 10 ; - else if ('a' <= ch && ch < 'a' + base - 10) - r = r * base + ch - 'a' + 10 ; - else - return r * sign; - i++; - } - return r * sign; - } - /** - * a test stub for the format class - */ - /*public static void main(String[] a) - { double x = 1.23456789012; - double xx= 1.0000006; - double y = 123; - double z = 1.2345e30; - double w = 1.02; - double u = 1.234e-5; - int d = 0xCAFE; - Format.print(System.out, "xx = |%.6f|\n", xx); - Format.print(System.out, "x = |%f|\n", x); - Format.print(System.out, "u = |%20f|\n", u); - Format.print(System.out, "x = |% .5f|\n", x); - Format.print(System.out, "w = |%20.5f|\n", w); - Format.print(System.out, "x = |%020.5f|\n", x); - Format.print(System.out, "x = |%+20.5f|\n", x); - Format.print(System.out, "x = |%+020.5f|\n", x); - Format.print(System.out, "x = |% 020.5f|\n", x); - Format.print(System.out, "y = |%#+20.5f|\n", y); - Format.print(System.out, "y = |%-+20.5f|\n", y); - Format.print(System.out, "z = |%20.5f|\n", z); - - Format.print(System.out, "x = |%e|\n", x); - Format.print(System.out, "u = |%20e|\n", u); - Format.print(System.out, "x = |% .5e|\n", x); - Format.print(System.out, "w = |%20.5e|\n", w); - Format.print(System.out, "x = |%020.5e|\n", x); - Format.print(System.out, "x = |%+20.5e|\n", x); - Format.print(System.out, "x = |%+020.5e|\n", x); - Format.print(System.out, "x = |% 020.5e|\n", x); - Format.print(System.out, "y = |%#+20.5e|\n", y); - Format.print(System.out, "y = |%-+20.5e|\n", y); - - Format.print(System.out, "x = |%g|\n", x); - Format.print(System.out, "z = |%g|\n", z); - Format.print(System.out, "w = |%g|\n", w); - Format.print(System.out, "u = |%g|\n", u); - Format.print(System.out, "y = |%.2g|\n", y); - Format.print(System.out, "y = |%#.2g|\n", y); - - Format.print(System.out, "d = |%d|\n", d); - Format.print(System.out, "d = |%20d|\n", d); - Format.print(System.out, "d = |%020d|\n", d); - Format.print(System.out, "d = |%+20d|\n", d); - Format.print(System.out, "d = |% 020d|\n", d); - Format.print(System.out, "d = |%-20d|\n", d); - Format.print(System.out, "d = |%20.8d|\n", d); - Format.print(System.out, "d = |%x|\n", d); - Format.print(System.out, "d = |%20X|\n", d); - Format.print(System.out, "d = |%#20x|\n", d); - Format.print(System.out, "d = |%020X|\n", d); - Format.print(System.out, "d = |%20.8x|\n", d); - Format.print(System.out, "d = |%o|\n", d); - Format.print(System.out, "d = |%020o|\n", d); - Format.print(System.out, "d = |%#20o|\n", d); - Format.print(System.out, "d = |%#020o|\n", d); - Format.print(System.out, "d = |%20.12o|\n", d); - - Format.print(System.out, "s = |%-20s|\n", "Hello"); - Format.print(System.out, "s = |%-20c|\n", '!'); - }*/ - - private static String repeat(char c,int n) { - if (n <= 0) return ""; StringBuffer s = new StringBuffer(n); - for (int i = 0; i < n; i++) s.append(c); - return s.toString(); - } - private static String convert(long x,int n,int m,String d) { - if (x == 0) return "0"; String r = ""; - while (x != 0) - { r = d.charAt((int)(x & m)) + r; - x = x >>> n; - } - return r; - } - private String pad(String r) { - String p = repeat(' ', width - r.length()); if (left_align) return pre + r + p + post; - else return pre + p + r + post; - } - private String sign(int s,String r) { - String p = ""; if (s < 0) p = "-"; - else if (s > 0) - { if (show_plus) p = "+"; - else if (show_space) p = " "; - } - else - { if (fmt == 'o' && alternate && r.length() > 0 && r.charAt(0) != '0') p = "0"; - else if (fmt == 'x' && alternate) p = "0x"; - else if (fmt == 'X' && alternate) p = "0X"; - } - int w = 0; - if (leading_zeroes) - w = width; - else if ((fmt == 'd' || fmt == 'i' || fmt == 'x' || fmt == 'X' || fmt == 'o') - && precision > 0) w = precision; - - return p + repeat('0', w - p.length() - r.length()) + r; - } - private String fixed_format(double d) { - String f = ""; - if (d > Long.MAX_VALUE) return exp_format(d); - //here is the first change to the code (04/03/02) - long l=(long) (d+=0.5*Math.pow(10D,-precision)); - //long l = (long)(precision == 0 ? d + 0.5 : d); - f =f + l; - double fr = d - l; // fractional part - if (fr >= 1 || fr < 0 && precision != 0) return exp_format(d); - - return f + frac_part(fr); - } - // precondition: 0 <= fr < 1 - private String frac_part(double fr) { - String z = ""; - if (precision > 0){ - double factor = 1; - String leading_zeroes = ""; - for (int i = 1; i <= precision && factor <= Double.MAX_VALUE; i++) { - factor *= 10; - leading_zeroes = leading_zeroes + "0"; - } - //here is the second change to the code (04/03/02) - long l = (long) (factor * fr ); - //long l = (long) (factor * fr + 0.5); - z = leading_zeroes + l; - z = z.substring(z.length() - precision, z.length()); - } - - - if (precision > 0 || alternate) z = "." + z; - if ((fmt == 'G' || fmt == 'g') && !alternate) - // remove trailing zeroes and decimal point - { int t = z.length() - 1; - while (t >= 0 && z.charAt(t) == '0') t--; - if (t >= 0 && z.charAt(t) == '.') t--; - z = z.substring(0, t + 1); - } - return z; - } - private String exp_format(double d) { - String f = ""; int e = 0; - double dd = d; - double factor = 1; - if (dd == 0) return "0"; - while (dd > 10) { e++; factor /= 10; dd = dd / 10; } - while (dd < 1) { e--; factor *= 10; dd = dd * 10; } - if ((fmt == 'g' || fmt == 'G') && e >= -4 && e < precision) - return fixed_format(d); - - d = d * factor; - f = f + fixed_format(d); - - if (fmt == 'e' || fmt == 'g') - f = f + "e"; - else - f = f + "E"; - - String p = "000"; - if (e >= 0) - { f = f + "+"; - p = p + e; - } - else - { f = f + "-"; - p = p + (-e); - } - - return f + p.substring(p.length() - 3, p.length()); - } - /** - * Formats the number following printf conventions. - * Main limitation: Can only handle one format parameter at a time - * Use multiple Format objects to format more than one number - * @param s the format string following printf conventions - * The string has a prefix, a format code and a suffix. The prefix and suffix - * become part of the formatted output. The format code directs the - * formatting of the (single) parameter to be formatted. The code has the - * following structure - *
    - *
  • a % (required) - *
  • a modifier (optional) - *
    - *
    +
    forces display of + for positive numbers - *
    0
    show leading zeroes - *
    -
    align left in the field - *
    space
    prepend a space in front of positive numbers - *
    #
    use "alternate" format. Add 0 or 0x for octal or hexadecimal numbers. Don't suppress trailing zeroes in general floating point format. - *
    - *
  • an integer denoting field width (optional) - *
  • a period followed by an integer denoting precision (optional) - *
  • a format descriptor (required) - *
    - *
    f
    floating point number in fixed format - *
    e, E
    floating point number in exponential notation (scientific format). The E format results in an uppercase E for the exponent (1.14130E+003), the e format in a lowercase e. - *
    g, G
    floating point number in general format (fixed format for small numbers, exponential format for large numbers). Trailing zeroes are suppressed. The G format results in an uppercase E for the exponent (if any), the g format in a lowercase e. - *
    d, i
    integer in decimal - *
    x
    integer in hexadecimal - *
    o
    integer in octal - *
    s
    string - *
    c
    character - *
    - *
- * @exception IllegalArgumentException if bad format - */ - public Format(String s) { - width = 0; precision = -1; - pre = ""; - post = ""; - leading_zeroes = false; - show_plus = false; - alternate = false; - show_space = false; - left_align = false; - fmt = ' '; - - int state = 0; - int length = s.length(); - int parse_state = 0; - // 0 = prefix, 1 = flags, 2 = width, 3 = precision, - // 4 = format, 5 = end - int i = 0; - - while (parse_state == 0) - { if (i >= length) parse_state = 5; - else if (s.charAt(i) == '%') - { if (i < length - 1) - { if (s.charAt(i + 1) == '%') - { pre = pre + '%'; - i++; - } - else - parse_state = 1; - } - else throw new java.lang.IllegalArgumentException(); - } - else - pre = pre + s.charAt(i); - i++; - } - while (parse_state == 1) - { if (i >= length) parse_state = 5; - else if (s.charAt(i) == ' ') show_space = true; - else if (s.charAt(i) == '-') left_align = true; - else if (s.charAt(i) == '+') show_plus = true; - else if (s.charAt(i) == '0') leading_zeroes = true; - else if (s.charAt(i) == '#') alternate = true; - else { parse_state = 2; i--; } - i++; - } - while (parse_state == 2) - { if (i >= length) parse_state = 5; - else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') - { width = width * 10 + s.charAt(i) - '0'; - i++; - } - else if (s.charAt(i) == '.') - { parse_state = 3; - precision = 0; - i++; - } - else - parse_state = 4; - } - while (parse_state == 3) - { if (i >= length) parse_state = 5; - else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') - { precision = precision * 10 + s.charAt(i) - '0'; - i++; - } - else - parse_state = 4; - } - if (parse_state == 4) - { if (i >= length) parse_state = 5; - else fmt = s.charAt(i); - i++; - } - if (i < length) - post = s.substring(i, length); - } - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the double to print - */ - public static void print(java.io.PrintStream s,String fmt,double x) { - s.print(new Format(fmt).form(x)); - } - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the long to print - */ - public static void print(java.io.PrintStream s,String fmt,long x) { - s.print(new Format(fmt).form(x)); - } - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the character to - */ - public static void print(java.io.PrintStream s,String fmt,char x) { - s.print(new Format(fmt).form(x)); - } - /** - * prints a formatted number following printf conventions - * @param s a PrintStream, fmt the format string - * @param x a string that represents the digits to print - */ - public static void print(java.io.PrintStream s,String fmt,String x) { - s.print(new Format(fmt).form(x)); - } - /** - * Converts a string of digits (decimal, octal or hex) to an integer - * @param s a string - * @return the numeric value of the prefix of s representing a base 10 integer - */ - public static int atoi(String s) { - return (int)atol(s); - } - /** - * Converts a string of digits (decimal, octal or hex) to a long integer - * @param s a string - * @return the numeric value of the prefix of s representing a base 10 integer - */ - public static long atol(String s) { - int i = 0; - while (i < s.length() && Character.isWhitespace(s.charAt(i))) i++; - if (i < s.length() && s.charAt(i) == '0') - { if (i + 1 < s.length() && (s.charAt(i + 1) == 'x' || s.charAt(i + 1) == 'X')) - return parseLong(s.substring(i + 2), 16); - else return parseLong(s, 8); - } - else return parseLong(s, 10); - } - /** - * Computes the format based on desired prescision and - * minimum, maximum values. - * - * @param min minimum value - * @param max maximum value - * @param pres prescision - */ - public static String computeFormat(double min,double max,int pres) { - double dx, xx; - int ip, id, ib; - String frmt; - - dx = Math.abs(max - min); - xx = Math.abs(max); - if(xx < Math.abs(min)) xx = Math.abs(min); - if(pres >= 0 && (xx >= 1000000.0f || xx < 0.001f)) { - id = pres -1; - if(id < 0) id=0; - frmt = "%" + "." + id + "e"; - } else { - ip = Math.abs(pres); - id = ip - (int)(log10(dx) + 0.5); - if(id < 0) id = 0; - frmt = "%" + "." + id + "f"; - } - return frmt; - } - static final double log10(double x) { - return 0.4342944819*Math.log(x); - } - /** - * Converts a string of digits to an double - * @param s a string - */ - public static double atof(String s) { - int i = 0; int sign = 1; - double r = 0; // integer part - double f = 0; // fractional part - double p = 1; // exponent of fractional part - int state = 0; // 0 = int part, 1 = frac part - - while (i < s.length() && Character.isWhitespace(s.charAt(i))) i++; - if (i < s.length() && s.charAt(i) == '-') { sign = -1; i++; } - else if (i < s.length() && s.charAt(i) == '+') { i++; } - while (i < s.length()) - { char ch = s.charAt(i); - if ('0' <= ch && ch <= '9') - { if (state == 0) - r = r * 10 + ch - '0'; - else if (state == 1) - { p = p / 10; - r = r + p * (ch - '0'); - } - } - else if (ch == '.') - { if (state == 0) state = 1; - else return sign * r; - } - else if (ch == 'e' || ch == 'E') - { long e = (int)parseLong(s.substring(i + 1), 10); - return sign * r * Math.pow(10, e); - } - else return sign * r; - i++; - } - return sign * r; - } - /** - * Formats a double into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - * @exception IllegalArgumentException if bad argument - */ - public String form(double x) { - String r; if (precision < 0) precision = 6; - int s = 1; - if (x < 0) { x = -x; s = -1; } - if (fmt == 'f'){ - r = fixed_format(x); - } - else if (fmt == 'e' || fmt == 'E' || fmt == 'g' || fmt == 'G') - r = exp_format(x); - else throw new java.lang.IllegalArgumentException(); - return pad(sign(s, r)); - } - /** - * Formats a long integer into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - */ - public String form(long x) { - String r; int s = 0; - if (fmt == 'd' || fmt == 'i') - { s = 1; - if (x < 0) { x = -x; s = -1; } - r = "" + x; - } - else if (fmt == 'o') - r = convert(x, 3, 7, "01234567"); - else if (fmt == 'x') - r = convert(x, 4, 15, "0123456789abcdef"); - else if (fmt == 'X') - r = convert(x, 4, 15, "0123456789ABCDEF"); - else throw new java.lang.IllegalArgumentException(); - - return pad(sign(s, r)); - } - /** - * Formats a character into a string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ - public String form(char c) { - if (fmt != 'c') throw new java.lang.IllegalArgumentException(); - - String r = "" + c; - return pad(r); - } - /** - * Formats a string into a larger string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ - public String form(String s) { - if (fmt != 's') throw new java.lang.IllegalArgumentException(); - if (precision >= 0) s = s.substring(0, precision); - return pad(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Graph.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Graph.java deleted file mode 100755 index 95585f49..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Graph.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * $Id: Graph.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.Debug; - -import gov.noaa.pmel.sgt.dm.SGTData; - -import java.awt.Graphics; -import java.awt.Event; -import java.awt.Point; -import java.beans.PropertyChangeListener; - -/** - * Abstract base class for all graphics drawn on a Layer. The - * Graph class defines the interfaces for the user to physical - * coordinate, user to device, and physical to user coordinate systems. - *

- * The following demonstrates how a {@link CartesianGraph} may be - * used. - *

- *

- *   // Create a CartesianGraph and transforms.
- *
- *    CartesianGraph graph;
- *    LinearTransform xt, yt;
- *    Range2D xPhysRange, xUserRange;
- *    Range2D yPhysRange, yUserRange;
- *    Point2D.Double origin;
- *
- *    graph = new CartesianGraph("Point Graph");
- *    layer.setGraph(graph);
- *    xt = new LinearTransform(xPhysRange, xUserRange);
- *    yt = new LinearTransform(yPhysRange, yUserRange);
- *    graph.setXTransform(xt);
- *    graph.setYTransform(yt);
- *    origin = new Point2D.Double(xUserRange.start,
- *                                yUserRange.start);
- *
- *     // Create the bottom axis, set its range in user units
- *     // and its origin. Add the axis to the graph.
- *
- *    PlainAxis xbot;
- *
- *    xbot = new PlainAxis("Botton Axis");
- *    xbot.setRangeU(xUserRange);
- *    xbot.setLocationU(origin);
- *    graph.addXAxis(xbot);
- *
- *     // Create the left axis, set its range in user units
- *     // and its origin. Add the axis to the graph.
- *
- *    PlainAxis yleft;
- *
- *    yleft = new PlainAxis("Left Axis");
- *    yleft.setRangeU(yUserRange);
- *    yleft.setLocationU(origin);
- *    graph.addYAxis(yleft);
- *
- *     // Create a PointAttribute for the display of the
- *     // Collection of points. The points will be marked
- *     // with a red triangle and labelled at the NE corner
- *     // in blue.
- *
- *    PointAttribute pattr;
- *
- *    pattr = new PointAttribute(10, Color.red);
- *
- *     // Associate the attribute and the point Collection
- *     // with the graph.
- *
- *    graph.setData(col, pattr);
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @see Layer - * @see LinearTransform - * @see PlainAxis - * @see SGLabel - * @see CartesianGraph - */ -public abstract class Graph implements PropertyChangeListener { - private String ident_; -/** @directed - * @label layer */ - protected Layer layer_; - /** - * Default constructor. - **/ - public Graph() { - this(""); - } - /** - * Constructor for Graph class. - * - * @param id identifier - **/ - public Graph(String id) { - ident_ = id; - } - /** - * Copy the Graph object and all attached classes. - */ - public abstract Graph copy(); - /** - * Get the Graph identifier - * - * @return ident - **/ - public String getId() { - return ident_; - } - // - abstract void draw(Graphics g); - // - void setLayer(Layer l) { - layer_ = l; - } - /** - * Get the associated Layer. - * - * @return Layer object - **/ - public Layer getLayer() { - return layer_; - } - /** - * Return parent pane. - * @since 2.0 - */ - public AbstractPane getPane() { - return layer_.getPane(); - } - /** - * Used internally by sgt. - * @since 2.0 - */ - public void modified(String mess) { - if(layer_ != null) - layer_.modified(mess); - } - /** - * Compute a "nice" range from a range and number of intervals. - * - * @param range min and max values - * @param num number of intervals - * @return "nice" range - */ - public static Range2D computeRange(Range2D range,int num) { - return computeRange(range.start, range.end, num); - } - /** - * Compute a "nice" range from a range and number of intervals. - * - * @since 2.0 - * @param range min and max values - * @param num number of intervals - * @return "nice" range - */ - public static SoTRange computeRange(SoTRange range, int num) { - if(!range.isTime()) { - SoTRange.Double drange = (SoTRange.Double)range; - return new SoTRange.Double(computeRange(drange.start, - drange.end, num)); - } - return null; - } - /** - * Compute a "nice" range from the minimum, maximum, and number of intervals. - * - * @param min minimum value - * @param max maximum value - * @param num number of intervals - * @return "nice" range - * - **/ - public static Range2D computeRange(double min,double max,int num) { - int interval = Math.abs(num); - double temp, pow, delta; - int nt; - boolean reversed = false; - // - // check inputs to make sure that they are valid - // - if(min == max) { - if(min == 0.0) { - min = -1.0; - max = 1.0; - } else { - min = 0.9*max; - max = 1.1*max; - } - } - if(min > max) { - temp = min; - min = max; - max = temp; - reversed = true; - } - if(interval == 0) interval = 1; - // - // find the approximate size of the interval - // - temp = (max - min)/(double)interval; - if(temp == 0.0) temp = max; - if(temp == 0.0) { - min = -1.0; - max = 1.0; - temp = 2.0/(double)interval; - } - // - // scale the interval size by powers of ten to a value between - // one and ten - // - nt = (int)log10(temp); - if(temp < 1.0) nt--; - pow = Math.pow(10.0, (double)nt); - temp = temp/pow; - // - // find the closest permissible value for the interval size - // - if(temp < 1.414213562) { - delta = pow; - } else if(temp < 3.162277660) { - delta = 2.0 * pow; - } else if(temp < 7.071067812) { - delta = 5.0 * pow; - } else { - delta = 10.0 * pow; - } - // - // calculate the minimum value of the range - // - temp = min / delta; - nt = (int) temp; - if(temp < 0.0) nt--; - min = delta*nt; - // - // calculate the maximum value of the range - // - temp = max /delta; - nt = (int) temp; - if(temp > 0.0) nt++; - max = delta*nt; - // - if(reversed) { - temp = min; - min = max; - max = temp; - delta = -delta; - } - return new Range2D(min, max, delta); - } - static final double log10(double x) { - return 0.4342944819*Math.log(x); - } - // - abstract Object getObjectAt(Point pt); - /** - * Get a String representation of the - * Graph. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - /** - * Find data at a Point - * @since 3.0 - */ - public abstract SGTData getDataAt(Point pt); -} - - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/GridAttribute.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/GridAttribute.java deleted file mode 100755 index e11b1298..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/GridAttribute.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * $Id: GridAttribute.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Debug; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; - -/** - * Sets the rendering style for grid data. ColorMap, - * ContourLevels are GridAttribute properties. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @see GridCartesianRenderer - * @see ContourLevels - */ -public class GridAttribute implements Attribute, - Cloneable, - PropertyChangeListener { - private transient PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - // serial version ref 1.18 - private static final long serialVersionUID = 3822340406728567524L; - private boolean batch_ = false; - private boolean local_ = true; - private boolean modified_ = false; - private String id_ = null; - /**@shapeType AggregationLink - * @label cmap*/ - private ColorMap cmap_; - /**@shapeType AggregationLink - * @label clev*/ - private ContourLevels clev_; - private int style_; - /** - * Raster style. - */ - public static final int RASTER = 0; - /** - * Area fill style. - **/ - public static final int AREA_FILL = 1; - /** - * Contour line style. - */ - public static final int CONTOUR = 2; - /** - * Raster and Contour style. - * @since 2.0 - */ - public static final int RASTER_CONTOUR = 3; - /** - * Area fill and Contour style. - * @since 2.0 - */ - public static final int AREA_FILL_CONTOUR = 4; - /** - * Default constructor. Default style is RASTER and - * default ColorMap is null. - **/ - public GridAttribute() { - this(RASTER, null); - } - /** - * GridAttribute constructor for RASTER and - * AREA_FILL styles. - * - * @param style grid style - * @param cmap ColorMap - **/ - public GridAttribute(int style,ColorMap cmap) { - style_ = style; - cmap_ = cmap; - if(cmap_ != null) cmap_.addPropertyChangeListener(this); - } - /** - * GridAttribute constructor for CONTOUR style. - * - * @param clev ContourLevels - */ - public GridAttribute(ContourLevels clev) { - style_ = CONTOUR; - cmap_ = null; - clev_ = clev; - } - /** - * Set the ContourLevels. - *
Property Change: contourLevels. - * - * @param clev ContourLevels - */ - public void setContourLevels(ContourLevels clev) { - if(clev_ == null || !clev_.equals(clev)) { - ContourLevels tempOld = clev_; - clev_ = clev; - firePropertyChange("contourLevels", - tempOld, - clev_); - } - } - /** - * Get the ContourLevels. - * - * @return ContourLevels - */ - public ContourLevels getContourLevels() { - return clev_; - } - /** - * Copy the GridAttribute. - * - * @return new GridAttribute - */ - public GridAttribute copy() { - GridAttribute newGrid; - try { - newGrid = (GridAttribute)clone(); - } catch (CloneNotSupportedException e) { - newGrid = new GridAttribute(); - } - return newGrid; - } - /** - * Set the grid style. - *
Property Change: style. - * - * @param st grid style - **/ - public void setStyle(int st) { - if(style_ != st) { - Integer tempOld = new Integer(style_); - style_ = st; - firePropertyChange("style", - tempOld, - new Integer(style_)); - } - } - /** - * Get grid style. - * - * @return grid style - **/ - public int getStyle() { - return style_; - } - /** - * Tests if GridAttribute style is either - * RASTER or RASTER_CONTOUR. - * @since 2.0 - */ - public boolean isRaster() { - return (style_ == RASTER || - style_ == RASTER_CONTOUR); - } - /** - * Tests if GridAttribute style is either - * CONTOUR, RASTER_CONTOUR, or AREA_FILL_CONTOUR. - * @since 2.0 - */ - public boolean isContour() { - return (style_ == CONTOUR || - style_ == RASTER_CONTOUR || - style_ == AREA_FILL_CONTOUR); - } - /** - * Tests if GridAttribute style is eigther - * AREA_FILL or AREA_FILL_CONTOUR. - * @since 2.0 - */ - public boolean isAreaFill() { - return (style_ == AREA_FILL || - style_ == AREA_FILL_CONTOUR); - } - /** - * Get the ColorMap. - * - * @return the ColorMap - **/ - public ColorMap getColorMap() { - return cmap_; - } - /** - * Set the ColorMap. - *
Property Change: colorMap. - * - * @param cmap the ColorMap - */ - public void setColorMap(ColorMap cmap) { - if(cmap_ == null && cmap == null) { - return; - } else { - if(cmap_ != null) cmap_.removePropertyChangeListener(this); - if(cmap_ == null || !cmap_.equals(cmap)) { - ColorMap tempOld = cmap_; - cmap_ = cmap; - firePropertyChange("colorMap", - tempOld, - cmap_); - cmap_.addPropertyChangeListener(this); - } - } - } - /** - * Get a String representation of the - * GridAttribute. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1); - } - /** - * Add listener to changes in GridAttribute properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.addPropertyChangeListener(listener); - } - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } - - public void propertyChange(PropertyChangeEvent evt) { - if(Debug.EVENT) { - System.out.println("GridAttribute: " + evt); - System.out.println(" " + evt.getPropertyName()); - } - changes_.firePropertyChange(evt); - } - /** - * @since 3.0 - */ - public void setId(String id) { - id_ = id; - } - /** - * @since 3.0 - */ - public String getId() { - return id_; - } - - protected void firePropertyChange(String name, Object oldValue, Object newValue) { - if(batch_) { - modified_ = true; - return; - } - AttributeChangeEvent ace = new AttributeChangeEvent(this, name, - oldValue, newValue, - local_); - changes_.firePropertyChange(ace); - modified_ = false; - } - - /** - * @since 3.0 - */ - public void setBatch(boolean batch) { - setBatch(batch, true); - } - - /** - * @since 3.0 - */ - public void setBatch(boolean batch, boolean local) { - local_ = local; - batch_ = batch; - if(!batch && modified_) firePropertyChange("batch", Boolean.TRUE, Boolean.FALSE); - } - - /** - * @since 3.0 - */ - public boolean isBatch() { - return batch_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/GridCartesianRenderer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/GridCartesianRenderer.java deleted file mode 100755 index 25c26f23..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/GridCartesianRenderer.java +++ /dev/null @@ -1,623 +0,0 @@ -/* - * $Id: GridCartesianRenderer.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.contour.Contour; -import gov.noaa.pmel.sgt.contour.ContourLine; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.Graphics; -import java.awt.Color; -import java.awt.Rectangle; -import java.awt.Font; -import java.awt.Point; -import java.awt.FontMetrics; -import java.util.Enumeration; -import java.beans.PropertyChangeEvent; - -/** - * Produces a cartesian plot from a SGTGrid object. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public class GridCartesianRenderer extends CartesianRenderer { - /**@shapeType AggregationLink - * @label grid - * @undirected - * @supplierCardinality 1*/ - private SGTGrid grid_; - /**@shapeType AggregationLink - * @label attr - * @undirected - * @supplierCardinality 1*/ - private GridAttribute attr_ = null; - - /** - * @link aggregationByValue - * @supplierCardinality 1 - * @label con - */ - private Contour con_ = null; - // - private void drawRaster(Graphics g) { - int nT, nX, nY, nZ; - int[] xp, yp; - int i, j; - Color color; - int xSize, ySize, count; - double[] xValues, yValues, gValues; - double val; - GeoDate[] tValues; - // - if(grid_.isXTime()) { - if(grid_.getTimeArray().length <= 2) return; - if(grid_.hasXEdges()) { - tValues = grid_.getTimeEdges(); - xSize = tValues.length; - xp = new int[xSize]; - for(count=0; count < xSize; count++) { - xp[count] = cg_.getXUtoD(tValues[count]); - } - } else { - tValues = grid_.getTimeArray(); - xSize = tValues.length; - xp = new int[xSize+1]; - xp[0] = cg_.getXUtoD(tValues[0].subtract( - (tValues[1].subtract(tValues[0])).divide(2.0))); - for(count=1; count < xSize; count++) { - xp[count] = cg_.getXUtoD( - (tValues[count-1].add(tValues[count])).divide(2.0)); - } - xp[xSize] = cg_.getXUtoD(tValues[xSize-1].add( - (tValues[xSize-1].subtract(tValues[xSize-2])).divide(2.0))); - } - } else { - if(grid_.getXArray().length <= 2) return; - if(grid_.hasXEdges()) { - xValues = grid_.getXEdges(); - xSize = xValues.length; - xp = new int[xSize]; - for(count=0; count < xSize; count++) { - xp[count] = cg_.getXUtoD(xValues[count]); - } - } else { - xValues = grid_.getXArray(); - xSize = xValues.length; - xp = new int[xSize+1]; - xp[0] = cg_.getXUtoD(xValues[0]-(xValues[1]-xValues[0])*0.5); - for(count=1; count < xSize; count++) { - xp[count] = cg_.getXUtoD((xValues[count-1]+xValues[count])*0.5); - } - xp[xSize] = cg_.getXUtoD(xValues[xSize-1]+ - (xValues[xSize-1]-xValues[xSize-2])*0.5); - } - } - if(grid_.isYTime()) { - if(grid_.getTimeArray().length <= 2) return; - if(grid_.hasYEdges()) { - tValues = grid_.getTimeEdges(); - ySize = tValues.length; - yp = new int[ySize]; - for(count=0; count < ySize; count++) { - yp[count] = cg_.getYUtoD(tValues[count]); - } - } else { - tValues = grid_.getTimeArray(); - ySize = tValues.length; - yp = new int[ySize+1]; - yp[0] = cg_.getYUtoD(tValues[0].subtract( - (tValues[1].subtract(tValues[0])).divide(2.0))); - for(count=1; count < ySize; count++) { - yp[count] = cg_.getYUtoD((tValues[count-1].add( - tValues[count])).divide(2.0)); - } - yp[ySize] = cg_.getYUtoD(tValues[ySize-1].add( - (tValues[ySize-1].subtract(tValues[ySize-2])).divide(2.0))); - } - } else { - if(grid_.getYArray().length <= 2) return; - if(grid_.hasYEdges()) { - yValues = grid_.getYEdges(); - ySize = yValues.length; - yp = new int[ySize]; - for(count=0; count < ySize; count++) { - yp[count] = cg_.getYUtoD(yValues[count]); - } - } else { - yValues = grid_.getYArray(); - ySize = yValues.length; - yp = new int[ySize+1]; - yp[0] = cg_.getYUtoD(yValues[0]-(yValues[1]-yValues[0])*0.5); - for(count=1; count < ySize; count++) { - yp[count] = cg_.getYUtoD((yValues[count-1]+yValues[count])*0.5); - } - yp[ySize] = cg_.getYUtoD(yValues[ySize-1]+ - (yValues[ySize-1]-yValues[ySize-2])*0.5); - } - } - // - // draw raster - // - gValues = grid_.getZArray(); - count=0; - for(i=0; i < xSize; i++) { - for(j=0; j < ySize; j++) { - val = gValues[count]; - if(!Double.isNaN(val)) { - color = attr_.getColorMap().getColor(val); - g.setColor(color); - drawRect(g, xp[i], yp[j], xp[i+1], yp[j+1]); - } - count++; - } - } - } - /** - * Get the Attribute associated with - * the SGTGrid data. - * - * @return Attribute - */ - public Attribute getAttribute() { - return attr_; - } - /** - * Set the GridAttribute for the renderer. - * @since 2.0 - */ - public void setAttribute(GridAttribute attr) { - if(attr_ != null) attr_.removePropertyChangeListener(this); - attr_ = attr; - attr_.addPropertyChangeListener(this); - } - private void drawRect(Graphics g,int x1,int y1,int x2,int y2) { - int x, y, width, height; - if(x1 < x2) { - x = x1; - width = x2 - x1; - } else { - x=x2; - width = x1 - x2; - } - if(y1 < y2) { - y = y1; - height = y2 - y1; - } else { - y = y2; - height = y1 - y2; - } - g.fillRect(x, y, width, height); - } - /** - * Default constructor. The GridCartesianRenderer should - * be created using the CartesianRenderer.getRenderer - * method. - * - * @see CartesianRenderer#getRenderer - * @see Graph - **/ - public GridCartesianRenderer(CartesianGraph cg) { - this(cg, null, null); - } - /** - * Construct a GridCartesianRenderer. - * The GridCartesianRenderer should - * be created using the CartesianRenderer.getRenderer - * method. - * - * @see CartesianRenderer#getRenderer - * @see Graph - **/ - public GridCartesianRenderer(CartesianGraph cg, SGTGrid data) { - this(cg, data, null); - } - /** - * Construct a GridCartesianRenderer. - * The GridCartesianRenderer should - * be created using the CartesianRenderer.getRenderer - * method. - * - * @see CartesianRenderer#getRenderer - * @see Graph - **/ - public GridCartesianRenderer(CartesianGraph cg, SGTGrid grid, GridAttribute attr) { - cg_ = cg; - grid_ = grid; - attr_ = attr; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - /** - * Render the SGTData. This method should not - * be directly called. - * - * @param g graphics context - * - * @see Pane#draw - */ - public void draw(Graphics g) { - if(cg_.clipping_) { - int xmin, xmax, ymin, ymax; - int x, y, width, height; - if(cg_.xTransform_.isSpace()) { - xmin = cg_.getXUtoD(cg_.xClipRange_.start); - xmax = cg_.getXUtoD(cg_.xClipRange_.end); - } else { - xmin = cg_.getXUtoD(cg_.tClipRange_.start); - xmax = cg_.getXUtoD(cg_.tClipRange_.end); - } - if(cg_.yTransform_.isSpace()) { - ymin = cg_.getYUtoD(cg_.yClipRange_.start); - ymax = cg_.getYUtoD(cg_.yClipRange_.end); - } else { - ymin = cg_.getYUtoD(cg_.tClipRange_.start); - ymax = cg_.getYUtoD(cg_.tClipRange_.end); - } - if(xmin < xmax) { - x = xmin; - width = xmax - xmin; - } else { - x=xmax; - width = xmin - xmax; - } - if(ymin < ymax) { - y = ymin; - height = ymax - ymin; - } else { - y = ymax; - height = ymin - ymax; - } - g.setClip(x, y, width, height); - } - if(attr_.isRaster()) { - drawRaster(g); - } - if(attr_.isAreaFill()) { - // - // This is a temporary method based on the - // PPLUS area fill algorthim - // - // To be replaced by a area fill method that - // uses the ContourLines - // - double[] x = xArrayP(); - double[] y = yArrayP(); - double[] z = grid_.getZArray(); - int i,j; - int nx = x.length; - int ny = y.length; - double[] xt = new double[5]; - double[] yt = new double[5]; - double[] zt = new double[5]; - for(i=0; i < nx-1; i++) { - for(j=0; j < ny-1; j++) { - xt[0] = x[i]; - yt[0] = y[j]; - zt[0] = z[j + i*ny]; - // - xt[1] = x[i+1]; - yt[1] = y[j]; - zt[1] = z[j + (i+1)*ny]; - // - xt[2] = x[i+1]; - yt[2] = y[j+1]; - zt[2] = z[j+1 + (i+1)*ny]; - // - xt[3] = xt[0]; - yt[3] = yt[2]; - zt[3] = z[j+1 + i*ny]; - // - // repeat first point - // - xt[4] = xt[0]; - yt[4] = yt[0]; - zt[4] = zt[0]; - // - fillSquare(g, xt, yt, zt); - } - } - } - if(attr_.isContour()) { - double val; - String label; - Range2D range = computeRange(10); - Format format; - // con_ = new Contour(cg_, grid_, range); - con_ = new Contour(cg_, grid_, attr_.getContourLevels()); - ContourLevels clevels = con_.getContourLevels(); - DefaultContourLineAttribute attr; - // - // set labels - // - for(int i=0; i < clevels.size(); i++) { - try { - val = clevels.getLevel(i); - attr = clevels.getDefaultContourLineAttribute(i); - if(attr.isAutoLabel()) { - if(attr.getLabelFormat().length() <= 0) { - format = new Format(Format.computeFormat(range.start, - range.end, - attr.getSignificantDigits())); - } else { - format = new Format(attr.getLabelFormat()); - } - label = format.form(val); - attr.setLabelText(label); - } - } catch (ContourLevelNotFoundException e) { - System.out.println(e); - } - } - con_.generateContourLines(); - con_.generateContourLabels(g); - Enumeration elem = con_.elements(); - ContourLine cl; - while(elem.hasMoreElements()) { - cl = (ContourLine)elem.nextElement(); - if(Debug.CONTOUR) { - System.out.println(" level = " + cl.getLevel() + - ", length = " + cl.getKmax() + - ", closed = " + cl.isClosed()); - } - cl.draw(g); - } - } - // - // reset clip - // - Rectangle rect = cg_.getLayer().getPane().getBounds(); - g.setClip(rect); - } - - private void fillSquare(Graphics g, double[] x, - double[] y, double[] z) { - ContourLevels clevels = attr_.getContourLevels(); - IndexedColor cmap = (IndexedColor)attr_.getColorMap(); - int i,j,cindex, npoly, maxindex; - double zlev, zlevp1, f; - Color col; - double[] xpoly = new double[20]; - double[] ypoly = new double[20]; - double zmin = Math.min(z[0], z[1]); - double zmax = Math.max(z[0], z[1]); - for(i=2; i <= 3; i++) { - zmin = Math.min(zmin, z[i]); - zmax = Math.max(zmax, z[i]); - } - if(Double.isNaN(zmax)) return; - maxindex = clevels.getMaximumIndex(); - for(cindex=-1; cindex <= maxindex; cindex++) { - try { - if(cindex == -1) { - zlev = -Double.MAX_VALUE; - } else { - zlev = clevels.getLevel(cindex); - } - if(cindex == maxindex) { - zlevp1 = Double.MAX_VALUE; - } else { - zlevp1 = clevels.getLevel(cindex+1); - } - } catch (ContourLevelNotFoundException e) { - System.out.println(e); - break; - } - col = cmap.getColorByIndex(cindex+1); - if(zmin > zlevp1 || zmax < zlev) continue; - if(zmin >= zlev && zmax <= zlevp1) { - fillPolygon(g, col, x, y, 4); - return; - } - npoly = -1; - for(j=0; j < 4; j++) { /* sides */ - if(z[j] < zlev) { - // - // z[j] is below - // - if(z[j+1] > zlevp1) { - // - // z[j+1] is above - // - npoly=npoly+1; - f = (z[j]-zlev)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - // - npoly=npoly+1; - f = (z[j]-zlevp1)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - } else if(z[j+1] >= zlev && - z[j+1] <= zlevp1) { - // - // z[j+1] is inside - // - npoly=npoly+1; - f = (z[j]-zlev)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - // - npoly=npoly+1; - xpoly[npoly] = x[j+1]; - ypoly[npoly] = y[j+1]; - } - } else if(z[j] > zlevp1) { - // - // z[j] is above - // - if(z[j+1] < zlev) { - // - // z[j+1] is below - // - npoly=npoly+1; - f = (z[j]-zlevp1)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - // - npoly=npoly+1; - f = (z[j]-zlev)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - } else if(z[j+1] >= zlev && z[j+1] <= zlevp1) { - // - // z[j+1] is inside - // - npoly=npoly+1; - f = (z[j]-zlevp1)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - // - npoly=npoly+1; - xpoly[npoly] = x[j+1]; - ypoly[npoly] = y[j+1]; - } - } else { - // - // x[j] is inside - // - if(z[j+1] > zlevp1) { - // - // z[j+1] is above - // - npoly=npoly+1; - f = (z[j]-zlevp1)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - } else if(z[j+1] < zlev) { - // - // z[j+1] is below - // - npoly=npoly+1; - f = (z[j]-zlev)/(z[j]-z[j+1]); - xpoly[npoly] = x[j] - f*(x[j]-x[j+1]); - ypoly[npoly] = y[j] - f*(y[j]-y[j+1]); - } else { - // - // z[j+1] is inside - // - npoly=npoly+1; - xpoly[npoly] = x[j+1]; - ypoly[npoly] = y[j+1]; - } - } - } - fillPolygon(g, col, xpoly, ypoly, npoly+1); - } - } - - private void fillPolygon(Graphics g, Color c, - double[] x, double[] y, - int npoints) { - Layer layer = cg_.getLayer(); - int[] xt = new int[20]; - int[] yt = new int[20]; - g.setColor(c); - for(int i=0; i < npoints; i++) { - xt[i] = layer.getXPtoD(x[i]); - yt[i] = layer.getYPtoD(y[i]); - } - g.fillPolygon(xt, yt, npoints); - } - - private double[] xArrayP() { - int i; - double[] p; - if(grid_.isXTime()) { - GeoDate[] t = grid_.getTimeArray(); - p = new double[t.length]; - for(i=0; i < t.length; i++) { - p[i] = cg_.getXUtoP(t[i]); - } - } else { - double[] x = grid_.getXArray(); - p = new double[x.length]; - for(i=0; i < x.length; i++) { - p[i] = cg_.getXUtoP(x[i]); - } - } - return p; - } - - private double[] yArrayP() { - int i; - double[] p; - if(grid_.isYTime()) { - GeoDate[] t = grid_.getTimeArray(); - p = new double[t.length]; - for(i=0; i < t.length; i++) { - p[i] = cg_.getYUtoP(t[i]); - } - } else { - double[] y = grid_.getYArray(); - p = new double[y.length]; - for(i=0; i < y.length; i++) { - p[i] = cg_.getYUtoP(y[i]); - } - } - return p; - } - - private Range2D computeRange(int levels) { - Range2D range; - double zmin = Double.POSITIVE_INFINITY; - double zmax = Double.NEGATIVE_INFINITY; - double[] array = grid_.getZArray(); - for(int i=0; i < array.length; i++) { - if(!Double.isNaN(array[i])) { - zmin = Math.min(zmin, array[i]); - zmax = Math.max(zmax, array[i]); - } - } - range = Graph.computeRange(zmin, zmax, levels); - return range; - } - /** - * Get the SGTGrid. - * - * @return SGTGrid - */ - public SGTGrid getGrid() { - return grid_; - } - /** - * Get the associated CartesianGraph object. - * @since 2.0 - * @return CartesianGraph - */ - public CartesianGraph getCartesianGraph() { - return cg_; - } - - public void propertyChange(PropertyChangeEvent evt) { -// if(Debug.EVENT) { -// System.out.println("GridCartesianRenderer: " + evt); -// System.out.println(" " + evt.getPropertyName()); -// } - modified("GridCartesianRenderer: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - /** - * @since 3.0 - */ - public SGTData getDataAt(Point pt) { - return null; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/HourDayAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/HourDayAxis.java deleted file mode 100755 index 063691fe..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/HourDayAxis.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * $Id: HourDayAxis.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.IllegalTimeValue; - -/** - * Draws time axes using the hour/day style. - * - *
- *                  |..........|..........|..........|..........|
- *                       3           4         5           6
- *                                    jun 7
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @see Axis - * @see TimeAxis - */ -class HourDayAxis implements TimeAxisStyle { - static final int HOUR_TEST__ = 4; - static final String defaultMinorLabelFormat__ = "HH"; - static final String defaultMajorLabelFormat__ = "yyyy-MM-dd"; - static final int defaultNumSmallTics__ = 0; - int defaultMinorLabelInterval_ = 2; - int defaultMajorLabelInterval_ = 1; - static final double incrementValue__ = 1.0; - static final int incrementUnits__ = GeoDate.HOURS; - /** - * HourDayAxis constructor. - * - * @param id axis identifier - **/ - public HourDayAxis() { - } - public double computeLocation(double prev,double now) { - return prev; - } - public void computeDefaults(GeoDate delta) { - long days = delta.getTime()/GeoDate.MSECS_IN_DAY; - long msec = delta.getTime() % GeoDate.MSECS_IN_DAY; - if(days > 2) { - defaultMinorLabelInterval_ = 6; - } else if((days > 0) || (msec > 43200000)) { - defaultMinorLabelInterval_ = 2; - } else { - defaultMinorLabelInterval_ = 1; - } - } - public int getMinorValue(GeoDate time) { - return time.getGMTHours(); - } - public int getMajorValue(GeoDate time) { - return time.getGMTDay(); - } - public boolean isRoomForMajorLabel(GeoDate delta) { - return 24.0*(((double)delta.getTime())/((double)GeoDate.MSECS_IN_DAY)) > HOUR_TEST__; - } - public boolean isStartOfMinor(GeoDate time) { - return time.getGMTHours() == 0; - } - public String getDefaultMinorLabelFormat() { - return defaultMinorLabelFormat__; - } - public String getDefaultMajorLabelFormat() { - return defaultMajorLabelFormat__; - } - public int getDefaultNumSmallTics() { - return defaultNumSmallTics__; - } - public int getDefaultMinorLabelInterval() { - return defaultMinorLabelInterval_; - } - public int getDefaultMajorLabelInterval() { - return defaultMajorLabelInterval_; - } - public GeoDate getStartTime(TimeRange tRange) { - boolean time_increasing; - GeoDate time = null; - time_increasing = tRange.end.after(tRange.start); - try { - if(time_increasing) { - time = new GeoDate(tRange.start.getGMTMonth(), - tRange.start.getGMTDay(), - tRange.start.getGMTYear(), - tRange.start.getGMTHours(), 0, 0, 0); - if(!time.equals(tRange.start)) time.increment(1.0f, GeoDate.HOURS); - } else { - time = new GeoDate(tRange.end.getGMTMonth(), - tRange.end.getGMTDay(), - tRange.end.getGMTYear(), - tRange.end.getGMTHours(), 0, 0, 0); - if(!time.equals(tRange.end)) time.increment(1.0f, GeoDate.HOURS); - } - } catch (IllegalTimeValue e) {} - return time; - } - public double getIncrementValue() { - return incrementValue__; - } - public int getIncrementUnits() { - return incrementUnits__; - } - public String toString() { - return "HourDayAxis"; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/IndexedColor.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/IndexedColor.java deleted file mode 100755 index cb93151e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/IndexedColor.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * $Id: IndexedColor.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.Color; - -/** - * Defines the access methods for color maps that support indexed color. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - **/ -public interface IndexedColor { - - /** - * - * @param index - * @return - * @since 3.0 - */ - Color getColorByIndex(int index); - - void setColor(int index, Color color); - - void setColor(int index, int red, int green, int blue); - /** - * Get the maximum legal value of the color index. - */ - int getMaximumIndex(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/IndexedColorMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/IndexedColorMap.java deleted file mode 100755 index d2b7ea07..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/IndexedColorMap.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * $Id: IndexedColorMap.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; - -/** - * IndexedColorMap provides a mapping from a value to a - * Color. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public class IndexedColorMap extends ColorMap - implements Cloneable, PropertyChangeListener, IndexedColor, TransformAccess { - protected Color[] colors_; - /** - * index Transform. Default transform is Linear. - * @supplierCardinality 0..1 - * @clientRole iTrans_ - * @link aggregationByValue - */ - private Transform iTrans_ = new LinearTransform(0.0, 1.0, 0.0, 1.0); - /** - * Initialize the color map with int arrays of red, green, and blue. - * The arrays must be the same length. Sets up ColorMap - * for INDEXED access. - * - * @param red Array of the red component 0 - 255. - * @param green Array of the green component 0 - 255. - * @param blue Array of the blue component 0 - 255. - * - * @see java.awt.Color - */ - public IndexedColorMap(int[] red,int[] green,int[] blue) { - int indx; - colors_ = new Color[red.length]; - for (indx=0; indx < red.length; indx++) { - colors_[indx] = new Color(red[indx], green[indx], blue[indx]); - } - iTrans_.setRangeP(0.0, (double)colors_.length); - } - /** - * Initialize the color map with float arrays of red, green, and blue. - * The arrays must be the same length. Sets up ColorMap - * for INDEXED access. - * - * @param red Array of the red component 0.0 - 1.0. - * @param green Array of the green component 0.0 - 1.0. - * @param blue Array of the blue component 0.0 - 1.0. - * - * @see java.awt.Color - */ - public IndexedColorMap(float[] red,float[] green,float[] blue) { - int indx; - colors_ = new Color[red.length]; - for (indx=0; indx < red.length; indx++) { - colors_[indx] = new Color(red[indx], green[indx], blue[indx]); - } - iTrans_.setRangeP(0.0, (double)colors_.length); - } - /** - * Initialize the color map with an array of Color - * objects. Sets up ColorMap for - * INDEXED access. - * - * @param colors Array of the Color objects. - * - * @see java.awt.Color - */ - public IndexedColorMap(Color[] colors) { - colors_ = colors; - iTrans_.setRangeP(0.0, (double)colors_.length); - } - /** - * Create a copy of the ColorMap - */ - public ColorMap copy() { - ColorMap newMap; - try { - newMap = (ColorMap)clone(); - } catch (CloneNotSupportedException e) { - newMap = new IndexedColorMap(colors_); - } - return newMap; - } - /** - * Get a Color. - * - * @return color - * @since 3.0 - */ - public Color getColorByIndex(int indx) { - return colors_[indx]; - } - - /** - * Get a Color. - * - * @param val Value - * @return Color - * - */ - public Color getColor(double val) { - double ival = val; - int indx; - indx = (int)Math.round(iTrans_.getTransP(ival)); - if(indx < 0) indx=0; - if(indx > colors_.length-1) indx = colors_.length-1; - return colors_[indx]; - } - /** - * Set the user range for the Transform. - * - */ - public void setRange(Range2D range) { - iTrans_.setRangeU(range); - } - /** - * Get the current user range for the Transform. - * - * @return user range - */ - public Range2D getRange() { - return iTrans_.getRangeU(); - } - /** - * Change the Color. - * - * @param colr new Color - * @param indx index of color - */ - public void setColor(int index, Color colr) { - setColor(index, colr.getRed(), colr.getGreen(), colr.getBlue()); - } - /** - * Change the Color. - *
Property Change: color. - * - * @param red red component - * @param green green component - * @param blue blue component - * @param indx index of color - */ - public void setColor(int indx, int red, int green, int blue) { - if(indx < 0 || indx > colors_.length) return; - Color newColor = new Color(red, green, blue); - if(!colors_[indx].equals(newColor)) { - Color tempOld = colors_[indx]; - colors_[indx] = newColor; - firePropertyChange("color", - tempOld, - newColor); - } - } - /** - * Get the maximum color index. - * - * @return maximum legal color index - */ - public int getMaximumIndex() { - return colors_.length - 1; - } - /** - * Set the transform for the color mapping. - *
Property Change: transform. - * - * @param trans index color Transform - */ - public void setTransform(Transform trans) { - if(!trans.equals(iTrans_)) { - Transform tempOld = iTrans_; - if(iTrans_ != null) iTrans_.removePropertyChangeListener(this); - iTrans_ = trans; - iTrans_.setRangeP(0.0, (double)colors_.length); - firePropertyChange("transform", - tempOld, - iTrans_); - iTrans_.addPropertyChangeListener(this); - } - } - /** - * Get the transform for the color mapping. - * - * @return index color Transform - */ - public Transform getTransform() { - return iTrans_; - } - public boolean equals(ColorMap cm) { - if(cm == null || !(cm instanceof IndexedColorMap)) return false; - if(!iTrans_.equals(((IndexedColorMap)cm).iTrans_)) return false; - if(colors_.length != ((IndexedColorMap)cm).colors_.length) return false; - for(int i=0; i < colors_.length; i++) { - if(!colors_[i].equals(((IndexedColorMap)cm).colors_[i])) return false; - } - return true; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/InvalidMethodError.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/InvalidMethodError.java deleted file mode 100755 index 8d135e0b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/InvalidMethodError.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * $Id: InvalidMethodError.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Method called with invalid arguements. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class InvalidMethodError extends java.lang.Error { - public InvalidMethodError() { - super(); -} - public InvalidMethodError(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/JPane.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/JPane.java deleted file mode 100755 index 88966905..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/JPane.java +++ /dev/null @@ -1,754 +0,0 @@ -/* - * $Id: JPane.java,v 1.1.1.2 2008/12/19 13:29:30 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.sgt.beans.Panel; - -import java.awt.Rectangle; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.AWTEvent; - -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeListener; - -import javax.swing.SwingConstants; -//import javax.swing.RepaintManager; -import javax.swing.border.Border; -import java.awt.print.*; -import java.awt.Graphics2D; -import java.awt.Color; -import java.awt.geom.AffineTransform; - -/** - * The JPane class is extended from - * javax.swing.JLayeredPane - * and is the basis for using the gov.noaa.pmel.sgt - * package with swing components. - *

- * The Java scientific graphics toolkit is designed to allow a - * graphics client developer a great deal of flexibility and freedom. - * sgt is a package that greatly aids a developer in - * creating graphics applets. sgt is not a general - * purpose graphics package, but provides the tools to enable - * scientific graphics to be easily incorporated into JApplet. - *

- * sgt has three main components, the "pane", on which - * all graphics are drawn. The JPane is a fairly simple - * class and all drawing is done in "device" coordinates (pixels). - * By default, the JPane will draw on the screen, but it is - * designed to allow drawing in an offscreen buffer that can be - * printed (for applications). - *

- * The next component is the Layer. Several - * Layers can be associated with a single - * JPane. The Layer class insulates - * the developer from the details of device coordinates by - * using "physical" coordinates. Physical coordinates are - * a right-hand coordinate systems with an origin of (0.0, 0.0) in the - * lower-left-hand corner and have the same scale in both the vertical - * and horizontal directions. Thus, a Layer that is - * 5.0 units wide and 3.0 units high can be made larger and smaller - * on the screen by resizing the JPane, but will not be - * distorted. The Layer class is responsible for - * displaying labels, keys (color, vector, and line), and rulers. - * A Layer can contain a single Graph. - *

- * Finally, the Graph component transforms from - * user coordinates (e.g. cm/sec, time, degC, or meters) to - * physical coordinates. The Graph - * classes handle the display of axes and data. Children of - * the Graph class are capable of creating Cartesian, - * polar, and map graphics. For Cartesian graphs, several different - * axes (log, plain and time), transforms (linear, log, and - * tablelookup), and CartesianGraph (pixel, - * line, vector, and contour) classes are available. These classes can be - * combined in almost any combination. - *

- * While only one dataset may be plotted per Layer, - * co-plotting is supported by allowing layers to use the same - * transform objects. The order that the layers are plotted can - * be changed, allowing the developer (or user) to control what - * may be obscured. - *

- * Member functions, in package gov.noaa.pmel.sgt, - * follow the following naming convention. Member functions that - * have a P, U, or nothing at the end of the - * function name are of type double in Physical - * units, type double in User units, and type int in Device - * units, respectively. - * Variables that start with p, u, t, or d are coordinates of type physical, - * user, time, or device, respectively. - *

- * All graphics are rendered when the draw() method is invoked. - *

- * Mouse Events - *

- * Mouse events are processed by the JPane object to support - * object selection and zooming. Object selection is accomplished by - * left clicking the mouse on the desired object. JPane - * then fires a PropertyChangeEvent of type - * "objectSelected" that can be listened for by the users application. - * The user application then invokes the - * getSelectedObject() method. Zooming is accomplished in - * several steps. - *

- * - *

- * 1) Begin a zoom operation by pressing the left button.
- * 2) Describe a zoom rectangle by dragging the mouse with the left
- *    button down.
- * 3) Finish the zoom operation by releasing the left mouse button.
- * 
- * - *

- * When the mouse button has been release JPane fires a - * PropertyChangeEvent of type "zoomRectangle" that can - * be listened for by the users application. The user application can - * then obtain the zoom rectangle by invoking the - * getZoomBounds() method. - * - * - *

- * ...
- * //
- * // register the PropertyChangeListener listener with pane
- * // (assuming that application implements PropertyChangeListener)
- * //
- * mainPane_.addPropertyChangeListener(this);
- * //
- * ...
- * //
- * // Implement the propertyChange() method and listen for events
- * //
- *  public void propertyChange(PropertyChangeEvent event) {
- *    //
- *    // Listen for property change events from JPane
- *    //
- *    String name = event.getPropertyName();
- *    if(name.equals("zoomRectangle")) {
- *      //
- *      // compute zoom rectangle in user units
- *      //
- *      Range2D xr = new Range2D();
- *      Range2D yr = new Range2D();
- *      Rectangle zm = (Rectangle)event.getNewValue();
- *      //
- *      // if rectangle size is one pixel or less return
- *      //
- *      if(zm.width <= 1 || zm.height <= 1) return;
- *      xr.start = graph_.getXPtoU(layer_.getXDtoP(zm.x));
- *      xr.end = graph_.getXPtoU(layer_.getXDtoP(zm.x + zm.width));
- *      if(xr.start > xr.end) {
- *        double temp = xr.start;
- *        xr.start = xr.end;
- *        xr.end = temp;
- *      }
- *      yr.start = graph_.getYPtoU(layer_.getYDtoP(zm.y));
- *      yr.end = graph_.getYPtoU(layer_.getYDtoP(zm.y + zm.height));
- *      if(yr.start > yr.end) {
- *        double temp = yr.start;
- *        yr.start = yr.end;
- *        yr.end = temp;
- *      }
- *      //
- *      // turn batching on so all changes will appear at the
- *      // same time
- *      //
- *      mainPane_.setBatch(true);
- *      //
- *      // set range for transforms
- *      //
- *      xt_.setRangeU(xr);
- *      yt_.setRangeU(yr);
- *      //
- *      // set range and origin for axes
- *      //
- *      Point2D.Double orig = new Point2D.Double(xr.start, yr.start);
- *      xbot_.setRangeU(xr);
- *      xbot_.setLocationU(orig);
- *
- *      yleft_.setRangeU(yr);
- *      yleft_.setLocationU(orig);
- *      //
- *      // set clipping on all graphs
- *      //
- *      Component[] comps = mainPane_.getComponents();
- *      Layer ly;
- *      for(int i=0; i < comps.length; i++) {
- *        if(comps[i] instanceof Layer) {
- *          ly = (Layer)comps[i];
- *          ((CartesianGraph)ly.getGraph()).setClip(xr.start, xr.end,
- *                                                  yr.start, yr.end);
- *        }
- *      }
- *      //
- *      // done with sgt modifications, turn batching off
- *      //
- *      mainPane_.setBatch(false);
- *    } else if(name.equals("objectSelected")) {
- *      //
- *      // An sgt object has been selected.
- *      // If it is a PointCartesianRenderer that means the key has been
- *      // selected and so open a dialog to modified the PointAttribute.
- *      //
- *      if(event.getNewValue() instanceof PointCartesianRenderer) {
- *	  PointAttribute pattr =
- *	    ((PointCartesianRenderer)event.getNewValue()).getPointAttribute();
- *	  if(pAttrDialog_ == null) {
- *	    pAttrDialog_ = new PointAttributeDialog();
- *	  }
- *	  pAttrDialog_.setPointAttribute(pattr, mainPane_);
- *	  pAttrDialog_.setVisible(true);
- *      } else {
- *	  //
- *	  // Print the name of the object selected.
- *	  //
- *	  System.out.println("objectSelected = " + event.getNewValue());
- *      }
- *    }
- *  }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.2 $, $Date: 2008/12/19 13:29:30 $ - * @since 2.0 - * @see Layer - * @see Graph - * @see java.awt.Graphics -**/ -public class JPane extends javax.swing.JLayeredPane -//public class JPane extends javax.swing.JComponent - implements AbstractPane, javax.swing.Scrollable, Printable { - // - private PaneProxy proxy_; - private int horizBlockIncrement = -1; - private int vertBlockIncrement = -1; - private int horizUnitIncrement = 1; - private int vertUnitIncrement = 1; - // - /**@shapeType AggregationLink - * @supplierCardinality 1..* - * @label components*/ - /*# Layer lnkUnnamed*/ - - /** - * Constructs a Pane. - * - * @param id the Pane identifier - * @param size the size of the Pane in pixels - **/ - public JPane(String id, Dimension size) { - super(); - proxy_ = new PaneProxy(this, id, size); - setSize(size); - // - // setup for Low-Level Events - // - this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | - AWTEvent.MOUSE_MOTION_EVENT_MASK); - setDoubleBuffered(false); - // - // RepaintManager currentManager = RepaintManager.currentManager(this); - // currentManager.setDoubleBufferingEnabled(false); - // - } - /** - * Default constructor. The identifier is set to an empty string and - * the size is set to a width and height of 50 pixels. A default constructor - * is required to work as a component with Visual Cafe. - * - *
-   * import gov.noaa.pmel.sgt.JPane;
-   * ...
-   * JPane pane;
-   * ...
-   * pane = new JPane("main graph", new Dimension(400, 500));
-   * pane.setLayout(new StackedLayout());
-   * ...
-   * 
- * - * @see StackedLayout - * - **/ - public JPane() { - this(new String(""), new Dimension(50,50)); - } - /** - * Return the version of SGT. - * @since 3.0 - */ - public static String getVersion() { - return PaneProxy.getVersion(); - } - public void draw() { - proxy_.setOpaque(isOpaque()); - proxy_.draw(); - } - /** - * No initialization required. - */ - public void init() { - } - public void draw(Graphics g) { - proxy_.setOpaque(isOpaque()); - proxy_.draw(g); - } - public void draw(Graphics g, int width, int height) { - proxy_.setOpaque(isOpaque()); - proxy_.draw(g, width, height); - } - public boolean isPrinter() { - return proxy_.isPrinter(); - } - /** - * Internal method to access jdk1.1 or Java2D line drawing. - */ - public static StrokeDrawer getStrokeDrawer() { - return PaneProxy.strokeDrawer; - } - public Dimension getPageSize() { - return proxy_.getPageSize(); - } - /** - * Override default painting by swing. - */ - public void paintComponent(Graphics g) { - //System.out.println("Jpane.paintComponent called"); - super.paintComponent(g); - proxy_.paint(g); - } - - /** - * Adds the specified component to the end of the Pane. - * - * @param comp the component to be added - * @return component argument - */ - public Component add(Component comp) { - if(comp instanceof LayerControl) { - ((LayerControl)comp).setPane(this); - } - return super.add(comp); - } - /** - * Adds the specified component to the Pane at the - * given position. - * - * @param comp the component to be added - * @param index the position at which to insert the component, or -1 - to insert the component at the end. - * @return component argument - */ - public Component add(Component comp, int index) { - if(comp instanceof LayerControl) { - ((LayerControl)comp).setPane(this); - } - return super.add(comp, index); - } - /** - * Adds the specified component to the end of this Pane. - * Also notifies the layout manager to add the component to this - * Pane's layout using the specified constraints object. - * - * @param comp the component to be added - * @param constraints an object expressing layout constraints for - this component - */ - public void add(Component comp, Object constraints) { - super.add(comp, constraints); - if(comp instanceof LayerControl) { - ((LayerControl)comp).setPane(this); - } - } - /** - * Adds the specified component to the end of this Pane - * at the specified index. - * Also notifies the layout manager to add the component to this - * Pane's layout using the specified constraints object. - * - * @param comp the component to be added - * @param constraints an object expressing layout constraints for - this component - * @param index the position in the Pane's list at which to - insert the component -1 means insert at the end. - */ - public void add(Component comp, Object constraints, int index) { - super.add(comp, constraints, index); - if(comp instanceof LayerControl) { - ((LayerControl)comp).setPane(this); - } - } - /** - * Adds the specified component to this Pane. It - * is strongly advised to use add(Component, Object), in place - * of this method. - */ - public Component add(String name, Component comp) { - if(comp instanceof LayerControl) { - ((LayerControl)comp).setPane(this); - } - return super.add(name, comp); - } - - public String getId() { - return proxy_.getId(); - } - public void setId(String id) { - proxy_.setId(id); - } - public void setPageAlign(int vert,int horz) { - proxy_.setPageAlign(vert, horz); - } - public void setPageVAlign(int vert) { - proxy_.setPageVAlign(vert); - } - public void setPageHAlign(int horz) { - proxy_.setPageHAlign(horz); - } - public int getPageVAlign() { - return proxy_.getPageVAlign(); - } - public int getPageHAlign() { - return proxy_.getPageHAlign(); - } - public void setPageOrigin(Point p) { - proxy_.setPageOrigin(p); - } - public Point getPageOrigin() { - return proxy_.getPageOrigin(); - } - /** - * Set the size. - */ - public void setSize(Dimension d) { - super.setSize(d); - if(Debug.DEBUG) System.out.println("JPane: setSize()"); - proxy_.setSize(d); - } - public Layer getFirstLayer() { - return proxy_.getFirstLayer(); - } - public Layer getLayer(String id) throws LayerNotFoundException { - return proxy_.getLayer(id); - } - public Layer getLayerFromDataId(String id) throws LayerNotFoundException { - return proxy_.getLayerFromDataId(id); - } - /** - * Move the Layer up in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer up causes the - * Layer to be drawn later and over earlier - * layers. - * - * @param lyr Layer object. - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerUp(Layer lyr) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Move the Layer up in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer up causes the - * Layer to be drawn later and over earlier - * layers. - * - * @param id identifier. - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerUp(String id) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Move the Layer down in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer down causes the - * Layer to be drawn earlier. - * - * @param lyr Layer object. - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerDown(Layer lyr) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Move the Layer down in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer down causes the - * Layer to be drawn earlier. - * - * @param id identifier - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerDown(String id) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - public Object getSelectedObject() { - return proxy_.getSelectedObject(); - } - public void setSelectedObject(Object obj) { - proxy_.setSelectedObject(obj); - } - /** - * Overrides the default event methods. - **/ - public void processMouseEvent(MouseEvent event) { - if(!proxy_.processMouseEvent(event)) - super.processMouseEvent(event); - } - /** - * Used internally by sgt. - */ - public void processMouseMotionEvent(MouseEvent event) { - if(!proxy_.processMouseMotionEvent(event)) - super.processMouseMotionEvent(event); - } - /** - * Get the current zoom bounding box. - */ - public Rectangle getZoomBounds() { - return proxy_.getZoomBounds(); - } - /** - * @since 3.0 - */ - public Point getZoomStart() { - return proxy_.getZoomStart(); - } - public Object getObjectAt(int x, int y) { - return proxy_.getObjectAt(x,y); - } - /** - * @since 3.0 - */ - public Object[] getObjectsAt(int x, int y) { - return proxy_.getObjectsAt(x,y); - } - /** - * @since 3.0 - */ - public Object[] getObjectsAt(Point pt) { - return proxy_.getObjectsAt(pt.x, pt.y); - } - public Component getComponent() { - return (Component)this; - } - - public Dimension getMaximumSize() { - return proxy_.getMaximumSize(); - } - public Dimension getMinimumSize() { - return proxy_.getMinimumSize(); - } - public Dimension getPreferredSize() { - return proxy_.getPreferredSize(); - } - /** - * Get a String representatinof the - * Pane. - * - * @return String representation - */ - public String toString() { - return proxy_.toString(); - } - public void setBatch(boolean batch, String msg) { - proxy_.setBatch(batch, msg); - } - public void setBatch(boolean batch) { - proxy_.setBatch(batch, ""); - } - public boolean isBatch() { - return proxy_.isBatch(); - } - public void setModified(boolean mod, String mess) { - proxy_.setModified(mod, mess); - } - public boolean isModified() { - return proxy_.isModified(); - } - /** - * @since 3.0 - */ - public void setMouseEventsEnabled(boolean enable) { - proxy_.setMouseEventsEnabled(enable); - } - /** - * @since 3.0 - */ - public boolean isMouseEventsEnabled() { - return proxy_.isMouseEventsEnabled(); - } - /** - * Set the horizontal and vertical block increments. - */ - public void setScrollableBlockIncrement(int horiz, int vert) { - horizBlockIncrement = horiz; - vertBlockIncrement = vert; - } - public int getScrollableBlockIncrement(Rectangle visibleRect, - int orientation, - int direction) { - if(orientation == SwingConstants.HORIZONTAL) { - if(horizBlockIncrement <= 0) { - return getVisibleRect().width; - } else { - return horizBlockIncrement; - } - } else { - if(vertBlockIncrement <= 0) { - return getVisibleRect().height; - } else { - return vertBlockIncrement; - } - } - } - /** - * Set the horizontal and vertical unit increments. - */ - public void setScrollableUnitIncrement(int horiz, int vert) { - horizUnitIncrement = horiz; - vertUnitIncrement = vert; - } - public int getScrollableUnitIncrement(Rectangle visibleRect, - int orientation, - int direction) { - if(orientation == SwingConstants.HORIZONTAL) { - if(horizUnitIncrement <= 0) { - return 1; - } else { - return horizUnitIncrement; - } - } else { - if(vertUnitIncrement <= 0) { - return 1; - } else { - return vertUnitIncrement; - } - } - } - public Dimension getPreferredScrollableViewportSize() { - return getSize(); - } - public boolean getScrollableTracksViewportHeight() { - return false; - } - public boolean getScrollableTracksViewportWidth() { - return false; - } - - public int print(Graphics g, PageFormat pf, int pageIndex) { - if(pageIndex > 0) { - return NO_SUCH_PAGE; - } else { - drawPage(g, pf); - return PAGE_EXISTS; - } - } - public void setPageScaleMode(int mode) { - proxy_.setPageScaleMode(mode); - } - public int getPageScaleMode() { - return proxy_.getPageScaleMode(); - } - - public void drawPage(Graphics g, PageFormat pf, boolean scale) { - if(scale) { - drawPage(g, pf); - } else { - proxy_.drawPage(g, pf.getImageableWidth(), pf.getImageableHeight()); - } - } - /** - * Used by internally by sgt. - */ - protected void drawPage(Graphics g, PageFormat pf) { - Dimension d = getSize(); - Point pageOrigin = null; - pageOrigin = proxy_.getPageOrigin(); - if(pageOrigin == null) pageOrigin = new Point(0,0); - Graphics2D g2 = (Graphics2D)g; - - double scale = 1.0; - double dx = pf.getImageableX(); - double dy = pf.getImageableY(); - int scaleMode = proxy_.getPageScaleMode(); - if(scaleMode == AbstractPane.TO_FIT || - scaleMode == AbstractPane.SHRINK_TO_FIT) { - double yf = pf.getImageableHeight()/d.getHeight(); - double xf = pf.getImageableWidth()/d.getWidth(); - if(xf < yf) { - scale = xf; - } else if(xf > yf) { - scale = yf; - } - if(scaleMode == AbstractPane.SHRINK_TO_FIT && scale > 1.0) scale = 1.0; - } - - switch(proxy_.getPageHAlign()) { - default: - case AbstractPane.CENTER: - dx += (pf.getImageableWidth() - scale*d.getWidth())/2.0; - break; - case AbstractPane.RIGHT: - dx += pf.getImageableWidth() - scale*d.getWidth(); - break; - case AbstractPane.LEFT: - // do nothing - break; - case AbstractPane.SPECIFIED_LOCATION: - dx += pageOrigin.x; - break; - } - - switch(proxy_.getPageVAlign()) { - default: - case AbstractPane.TOP: - // do nothing - break; - case AbstractPane.BOTTOM: - dy += pf.getImageableHeight() - scale*d.getHeight(); - break; - case AbstractPane.MIDDLE: - dy += (pf.getImageableHeight() - scale*d.getHeight())/2.0; - break; - case AbstractPane.SPECIFIED_LOCATION: - dy += pageOrigin.y; - break; - } - g.clipRect(-1000, -1000, 2000, 2000); -// g.clipRect(Integer.MIN_VALUE, Integer.MIN_VALUE, -// Integer.MAX_VALUE, Integer.MAX_VALUE); - g2.translate(dx, dy); - g2.scale(scale, scale); - proxy_.drawPage(g, pf.getImageableWidth(), pf.getImageableHeight()); - } - /* - * Pane PropertyChange methods - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - proxy_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - proxy_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer.java deleted file mode 100755 index 8173296b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * $Id: LabelDrawer.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; - -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import java.io.Serializable; - -/** - * Defines the methods that implement label drawing in sgt. This - * interface is necessary since sgt v2.0 will use Java2D functionality - * to draw labels if it is available. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public interface LabelDrawer extends Serializable { - /** - * Used internally by sgt. - */ - public void draw(Graphics g) throws LayerNotFoundException; - /** - * Set the label text. - * - * @param lbl the label text - **/ - public void setText(String lbl); - /** - * Get the label text. - * - * @return the label text - **/ - public String getText(); - /** - * Get the color. - * - * @return The current color of the label. - **/ - public Color getColor(); - /** - * Set the color. - * - * @param color The color of the label. - * @see java.awt.Color - **/ - public void setColor(Color clr); - /** - * Set the font. - * - * @param fnt The Font to use to draw the label. - * @see java.awt.Font - **/ - public void setFont(Font font); - /** - * Get the font. - * - * @return The current font for the label. - **/ - public Font getFont(); - /** - * Used internally by sgt. - **/ - public void setLayer(Layer layer); - /** - * Get the layer. - * - * @return the layer object. - **/ - public Layer getLayer(); - /** - * Set the orientation. The orientation can be HORIZONTAL or - * VERTICAL. - * - * @param orient The orientation. - **/ - public void setOrientation(int orient); - /** - * Get the origentation. - * - * @return the orientation - **/ - public int getOrientation(); - /** - * Set the horizontal alignment. The alignment can be LEFT, CENTER, - * or RIGHT. - * - * @param horz The horizontal alignment. - **/ - public void setHAlign(int halign); - /** - * Get the horizontal alignment. - * - * @return the horizontal alignment. - **/ - public int getHAlign(); - /** - * Set the vertical alignment. The alignment can be TOP, MIDDLE, - * or BOTTOM. - * - * @param vert The vertical alignment. - **/ - public void setVAlign(int valign); - /** - * Get the vertical alignment. - * - * @return the vertical alignment. - **/ - public int getVAlign(); - /** - * Set the label position in device coordinates. - * - * @param loc label position - **/ - public void setLocation(Point loc); - /** - * Get the label position in device coordinates. - * - * @return the label position - **/ - public Point getLocation(); - /** - * Set the label bounds in device units. - * - * @param x x location of label - * @param y y location of label - * @param width label width - * @param height label height - */ - public void setBounds(int x, int y, int width, int height); - /** - * Get the label bounds in device units. - * - * @return the label bounds - **/ - public Rectangle getBounds(); - /** - * Set the label reference location in physcial coordinates. - * - * @param loc physical location of label - **/ - public void setLocationP(Point2D.Double loc); - /** - * Get the label reference location in physcial coordinates. - * - * @return the labels position. - **/ - public Point2D.Double getLocationP(); - /** - * Get the label reference location in physcial coordinates. - * - * @return the labels position. - **/ - public Rectangle2D.Double getBoundsP(); - /** - * Draw label at arbitrary rotation. Warning: Rotated labels are - * not drawn very well when using JDK1.1. For best results use - * JDK1.2 or newer. - */ - public void setAngle(double angle); - /** - * Get label drawing angle. - */ - public double getAngle(); - /** - * Set the height of the label in physical coordinates. - * - * @param hgt The label height. - **/ - public void setHeightP(double hgt); - /** - * Get the label height in physical coordinates. - * - * @return The label height. - **/ - public double getHeightP(); - /** - * Set visibility of label. - */ - public void setVisible(boolean vis); - /** - * Is label visible? - */ - public boolean isVisible(); - /** - * Get the string width in device units. - */ - public float getStringWidth(Graphics g); - /** - * Get the string height in device units. - */ - public float getStringHeight(Graphics g); -} - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer1.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer1.java deleted file mode 100755 index e46e102c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer1.java +++ /dev/null @@ -1,578 +0,0 @@ -/* - * $Id: LabelDrawer1.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.image.PixelGrabber; -import java.awt.image.MemoryImageSource; -import java.awt.image.ColorModel; -import java.awt.image.ImageObserver; -import java.awt.*; - -/** - * Implements label drawing for JDK1.1 - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public class LabelDrawer1 implements LabelDrawer, Cloneable { - private String label_; - private Color clr_; - private Font font_; - private transient Layer layer_; - private int orient_; - private int halign_; - private int valign_; - private Point dorigin_; - private Rectangle dbounds_; - private Point2D.Double porigin_; - private Rectangle2D.Double pbounds_; - private Polygon dpolygon_; - private double angle_; - private double sinthta_; - private double costhta_; - private double height_; - private boolean visible_; - private Rectangle savedBounds_ = null; - private Point savedLoc_ = null; - - public LabelDrawer1(String lbl, double hgt, Point2D.Double loc, - int valign, int halign) { - label_ = lbl; - height_ = hgt; - porigin_ = loc; - valign_ = valign; - halign_ = halign; - // - dbounds_ = new Rectangle(); - dorigin_ = new Point(0,0); - pbounds_ = new Rectangle2D.Double(); - } - - public LabelDrawer copy() { - LabelDrawer1 newLabel = null; -// try { -// newLabel = (LabelDrawer1)clone(); -// } catch (CloneNotSupportedException e) { -// newLabel = new LabelDrawer1(ident_, label_, height_, -// porigin_, valign_, halign_); -// newLabel.setColor(clr_); -// newLabel.setFont(font_); -// if(orient_ == ANGLE) { -// newLabel.setAngle(angle_); -// } else { -// newLabel.setOrientation(orient_); -// } -// } - return newLabel; - } - public void draw(Graphics g) throws LayerNotFoundException { - FontMetrics fmet; - int xs, ys; - if((label_.length() <= 0) || !visible_ || g == null) return; - if(layer_ == (Layer) null) throw new LayerNotFoundException(); - // - // set label heigth in physical units - // - computeBoundsD(g); - fmet = g.getFontMetrics(); - if(clr_ == null) { - g.setColor(layer_.getPane().getComponent().getForeground()); - } else { - g.setColor(clr_); - } - if(orient_ == SGLabel.HORIZONTAL) { - xs = dbounds_.x; - ys = dbounds_.y + fmet.getMaxAscent(); - g.drawString(label_, xs, ys); - } else if(orient_ == SGLabel.VERTICAL) { - // - // draw text in offscreen image (horizontal) - // - int i, j; - // make sure bounds are >= 1 pixel! RWS - if(dbounds_.height < 1) dbounds_.height = 1; - if(dbounds_.width < 1) dbounds_.width = 1; - // - Image buf = layer_.getPane().getComponent().createImage(dbounds_.height, dbounds_.width); - Graphics gbuf = buf.getGraphics(); - gbuf.setFont(g.getFont()); - // - gbuf.setColor(layer_.getPane().getComponent().getBackground()); - gbuf.fillRect(0, 0, dbounds_.height, dbounds_.width); - if(clr_ == null) { - gbuf.setColor(layer_.getPane().getComponent().getForeground()); - } else { - gbuf.setColor(clr_); - } - gbuf.drawString(label_, 0, fmet.getMaxAscent()); - // - // create offscreen image (vertical) and copy pixels - // - int[] bufpix = new int[dbounds_.width * dbounds_.height]; - int[] vbufpix = new int[dbounds_.width * dbounds_.height]; - PixelGrabber pg = - new PixelGrabber(buf, 0, 0, dbounds_.height, dbounds_.width, - bufpix, 0, dbounds_.height); - try { - pg.grabPixels(); - } catch (InterruptedException e) {System.out.println(e);} - for(i=0; i < dbounds_.height; i++) { - for(j=0; j < dbounds_.width; j++) { - vbufpix[j + (dbounds_.height - i - 1)*dbounds_.width] - = bufpix[i + j*dbounds_.height]; - } - } - ColorModel cm = ColorModel.getRGBdefault(); - Image vbuf = layer_.getPane().getComponent().createImage( - new MemoryImageSource(dbounds_.width, - dbounds_.height, - cm, - vbufpix, - 0, - dbounds_.width)); - // - // copy offscreen area to screen (with rotation) - // - g.setPaintMode(); - g.drawImage(vbuf, dbounds_.x, dbounds_.y, - layer_.getPane().getComponent()); - } else { - // - // Angled text, draw in offscreen image and rotate - // - if(dbounds_.height < 1 || dbounds_.width < 1) return; - int i, j; - int ii, jj; - int pixel; - // - int[] xpoly = dpolygon_.xpoints; - int[] ypoly = dpolygon_.ypoints; - int rectHeight = fmet.getMaxAscent() + fmet.getMaxDescent(); - int rectWidth = fmet.stringWidth(label_); - int xoff, yoff; - Image buf = - layer_.getPane().getComponent().createImage(rectWidth, rectHeight); - Graphics gbuf = buf.getGraphics(); - gbuf.setFont(g.getFont()); - // - gbuf.setColor(layer_.getPane().getComponent().getBackground()); - gbuf.fillRect(0, 0, rectWidth, rectHeight); - if(clr_ == null) { - gbuf.setColor(layer_.getPane().getComponent().getForeground()); - } else { - gbuf.setColor(clr_); - } - gbuf.drawString(label_, 0, fmet.getMaxAscent()); - // - // create offscreen image (vertical) and copy pixels - // - int[] bufpix = new int[rectWidth * rectHeight]; - int[] vbufpix = new int[dbounds_.width * dbounds_.height]; - PixelGrabber pg = - new PixelGrabber(buf, 0, 0, rectWidth, rectHeight, - bufpix, 0, rectWidth); - try { - pg.grabPixels(); - } catch (InterruptedException e) {System.out.println(e);} - // - // compute transformation - // - xoff = 0; - yoff = 0; - for(i=1; i < 4; i++) { - xoff = Math.min(xoff, xpoly[i]-xpoly[0]); - yoff = Math.min(yoff, ypoly[i]-ypoly[0]); - } - xoff = -xoff; - yoff = -yoff; - // double[] dx = {0.0, 0.5, -0.5, 0.5, -0.5}; - // double[] dy = {0.0, 0.5, -0.5, -0.5, 0.5}; - double[] dx = {0.0, 0.5}; - double[] dy = {0.0, 0.5}; - double it, jt; - for(j=0; j < rectHeight; j++) { - for(i=0; i < rectWidth; i++) { - for(int k=0; k < dx.length; k++) { - it = i + dx[k]; - jt = j + dy[k]; - // pixel = bufpix[i + j*rectWidth]; - pixel = bufpix[i + j*rectWidth]; - if(pixel == -1) continue; - // ii = (int)(i*costhta_ + j*sinthta_ + 0.5) + xoff; - // jj = (int)(j*costhta_ - i*sinthta_ + 0.5) + yoff; - ii = (int)(it*costhta_ + jt*sinthta_ + 0.5) + xoff; - jj = (int)(jt*costhta_ - it*sinthta_ + 0.5) + yoff; - if(ii < 0) ii=0; - if(ii >= dbounds_.width) ii = dbounds_.width-1; - if(jj < 0) jj=0; - if(jj >= dbounds_.height) jj = dbounds_.height-1; - vbufpix[ii + jj*dbounds_.width] = pixel; - } - } - } - ColorModel cm = ColorModel.getRGBdefault(); - Image vbuf = layer_.getPane().getComponent().createImage( - new MemoryImageSource(dbounds_.width, - dbounds_.height, - cm, - vbufpix, - 0, - dbounds_.width)); - // - // copy offscreen area to screen (with rotation) - // - g.setPaintMode(); - g.drawImage(vbuf, dbounds_.x, dbounds_.y, - layer_.getPane().getComponent()); - } - } - - public void setText(String lbl) { - label_ = lbl; - } - public String getText() { - return label_; - } - - public void setColor(Color clr) { - clr_ = clr; - } - public Color getColor() { - return clr_; - } - - public void setFont(Font font) { - font_ = font; - } - public Font getFont() { - return font_; - } - - public void setLayer(Layer layer) { - layer_ = layer; - if(savedBounds_ != null) { - setBounds(savedBounds_.x, savedBounds_.y, - savedBounds_.width, savedBounds_.height); - savedBounds_ = null; - } - if(savedLoc_ != null) { - setLocation(savedLoc_); - savedLoc_ = null; - } - } - public Layer getLayer() { - return layer_; - } - - public void setOrientation(int orient) { - if(orient_ != orient) { - if(orient == SGLabel.HORIZONTAL) { - costhta_ = 1.0; - sinthta_ = 0.0; - } else if(orient == SGLabel.VERTICAL) { - costhta_ = 0.0; - sinthta_ = 1.0; - } - orient_ = orient; - } - } - public int getOrientation() { - return orient_; - } - - public void setHAlign(int halign) { - halign_ = halign; - } - public int getHAlign() { - return halign_; - } - - public void setVAlign(int valign) { - valign_ = valign; - } - public int getVAlign() { - return valign_; - } - - public void setLocation(Point loc) { - if(layer_ == null) { - savedLoc_ = new Point(loc); - return; - } - computeBoundsD(layer_.getPane().getComponent().getGraphics()); - // if(dbounds_.x != loc.x || dbounds_.y != loc.y) { - // Point temp = new Point(dbounds_.x, dbounds_.y); - setBounds(loc.x, loc.y, dbounds_.width, dbounds_.height); -// changes_.firePropertyChange("location", -// temp, -// loc); - // } - } - public Point getLocation() { - if(savedLoc_ != null) return savedLoc_; - return dorigin_; - } - - public void setBounds(int x, int y, int width, int height) { - int swidth, sascent, xd, yd; - FontMetrics fmet; - if(layer_ == null) { - savedBounds_ = new Rectangle(x, y, width, height); - return; - } - Graphics g = layer_.getPane().getComponent().getGraphics(); - if(g == null) return; - g.setFont(font_); - fmet = g.getFontMetrics(); - sascent = fmet.getAscent(); - if(orient_ == SGLabel.HORIZONTAL) { - swidth = width; - xd = x; - // yd = y + fmet.getMaxAscent(); - yd = y -fmet.getMaxDescent() + height; - switch(valign_) { - case SGLabel.TOP: - yd = yd - sascent; - break; - case SGLabel.MIDDLE: - yd = yd - sascent/2; - break; - case SGLabel.BOTTOM: - } - switch(halign_) { - case SGLabel.RIGHT: - xd = xd + swidth; - break; - case SGLabel.CENTER: - xd = xd + swidth/2; - break; - case SGLabel.LEFT: - } - } else { - swidth = height; - yd = y + height; - xd = x + fmet.getMaxAscent(); - switch(valign_) { - case SGLabel.TOP: - xd = xd - sascent; - break; - case SGLabel.MIDDLE: - xd = xd - sascent/2; - break; - case SGLabel.BOTTOM: - } - switch(halign_) { - case SGLabel.RIGHT: - yd = yd - swidth; - break; - case SGLabel.CENTER: - yd = yd - swidth/2; - break; - case SGLabel.LEFT: - } - } - if(dorigin_.x != xd || dorigin_.y != yd) { - dorigin_.x = xd; - dorigin_.y = yd; - porigin_.x = layer_.getXDtoP(xd); - porigin_.y = layer_.getYDtoP(yd); - // modified("LabelDrawer1: setBounds()"); - } - } - public Rectangle getBounds() { - if(savedBounds_ != null) return savedBounds_; - if(layer_ != null) computeBoundsD(layer_.getPane().getComponent().getGraphics()); - return dbounds_; - } - - public void setLocationP(Point2D.Double loc) { - porigin_ = loc; - } - public Point2D.Double getLocationP() { - return porigin_; - } - - public Rectangle2D.Double getBoundsP() { - computeBoundsD(layer_.getPane().getComponent().getGraphics()); - return pbounds_; - } - - public void setAngle(double angle) { - angle_ = angle; - double thta = angle_*Math.PI/180.0; - if(Math.abs(thta) < 0.001) { - orient_ = SGLabel.HORIZONTAL; - costhta_ = 1.0; - sinthta_ = 0.0; - } else if(Math.abs(thta - 90.0) < 0.001) { - orient_ = SGLabel.VERTICAL; - costhta_ = 0.0; - sinthta_ = 1.0; - } else { - orient_ = SGLabel.ANGLE; - costhta_ = Math.cos(thta); - sinthta_ = Math.sin(thta); - } - } - public double getAngle() { - return angle_; - } - - public void setHeightP(double hgt) { - height_ = hgt; - } - public double getHeightP() { - return height_; - } - - public void setVisible(boolean vis) { - visible_ = vis; - } - public boolean isVisible() { - return visible_; - } - - private void computeBoundsD(Graphics g) { - int swidth, sheight, sascent, xd, yd; - int xorig, yorig; - int[] xt = new int[4]; - int[] yt = new int[4]; - int[] xn = new int[4]; - int[] yn = new int[4]; - FontMetrics fmet; - // - // compute size of font and adjust to be height tall! - // - if(g == null) return; - font_ = computeFontSize(g); - g.setFont(font_); - fmet = g.getFontMetrics(); - // - swidth = fmet.stringWidth(label_); - sascent = fmet.getAscent(); - // - xd = layer_.getXPtoD(porigin_.x); - yd = layer_.getYPtoD(porigin_.y); - // - // set device origin - // - dorigin_.x = xd; - dorigin_.y = yd; - xorig = xd; - yorig = yd; - // - switch(valign_) { - case SGLabel.TOP: - yd = yd + sascent; - break; - case SGLabel.MIDDLE: - yd = yd + sascent/2; - break; - case SGLabel.BOTTOM: - } - switch(halign_) { - case SGLabel.RIGHT: - xd = xd - swidth; - break; - case SGLabel.CENTER: - xd = xd - swidth/2; - break; - case SGLabel.LEFT: - } - xt[0] = xd; - xt[1] = xt[0]; - xt[2] = xt[0] + swidth; - xt[3] = xt[2]; - - sheight = fmet.getMaxAscent() + fmet.getMaxDescent(); - yt[0] = yd + fmet.getMaxDescent() - sheight; - yt[1] = yt[0] + sheight; - yt[2] = yt[1]; - yt[3] = yt[0]; - // - // rotate - // - for(int i=0; i < 4; i++) { - xn[i] = (int)((xt[i]-xorig)*costhta_ + (yt[i]-yorig)*sinthta_) + xorig; - yn[i] = (int)((yt[i]-yorig)*costhta_ - (xt[i]-xorig)*sinthta_) + yorig; - } - dpolygon_ = new Polygon(xn, yn, 4); - dbounds_ = dpolygon_.getBounds(); - // - // compute pbounds - // - pbounds_.x = layer_.getXDtoP(dbounds_.x); - pbounds_.y = layer_.getYDtoP(dbounds_.y); - pbounds_.width = layer_.getXDtoP(dbounds_.x + - dbounds_.width) - pbounds_.x; - pbounds_.height = pbounds_.y - - layer_.getYDtoP(dbounds_.y + dbounds_.height); - } - - // - // a bad method to compute the font size! - // - Font computeFontSize(Graphics g) { - Font tfont; - FontMetrics fmet; - int pt_0, pt_1, hgt; - int count = 1; - double hgt_0, hgt_1, del_0, del_1; - double a, b; - // - // first guess - // - if(g == null) return font_; - hgt = layer_.getXPtoD(height_) - layer_.getXPtoD(0.0f); - pt_0 = hgt - 3; - tfont = new Font(font_.getName(), font_.getStyle(), pt_0); - g.setFont(tfont); - fmet = g.getFontMetrics(); - hgt = fmet.getAscent() + fmet.getDescent(); - hgt_0 = layer_.getXDtoP(hgt) - layer_.getXDtoP(0); - pt_0 = tfont.getSize(); - pt_1 = (int)((double)pt_0*(height_/hgt_0)); - while((pt_0 != pt_1) && (count < 5)) { - tfont = new Font(font_.getName(), font_.getStyle(), pt_1); - g.setFont(tfont); - fmet = g.getFontMetrics(); - hgt = fmet.getAscent() + fmet.getDescent(); - hgt_1 = layer_.getXDtoP(hgt) - layer_.getXDtoP(0); - del_0 = Math.abs(height_ - hgt_0); - del_1 = Math.abs(height_ - hgt_1); - if((Math.abs(pt_0 - pt_1) <= 1) && (del_0 > del_1)) return tfont; - pt_0 = pt_1; - hgt_0 = hgt_1; - pt_1 = (int)((double)pt_0*(height_/hgt_0)); - count++; - } - return tfont; - } - - public float getStringWidth(Graphics g) { - if(g == null) return 0.0f; - FontMetrics fmet = g.getFontMetrics(font_); - return (float)fmet.stringWidth(label_); - } - - public float getStringHeight(Graphics g) { - if(g == null) return 0.0f; - FontMetrics fmet = g.getFontMetrics(font_); - return (float)(fmet.getAscent()*0.75)+1.0f; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer2.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer2.java deleted file mode 100755 index 7bc09e52..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelDrawer2.java +++ /dev/null @@ -1,580 +0,0 @@ -/* - * $Id: LabelDrawer2.java,v 1.1.1.2 2008/12/19 13:29:30 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.swing.MRJUtil; - -import java.awt.*; -import java.beans.*; -import java.awt.image.PixelGrabber; -import java.awt.image.MemoryImageSource; -import java.awt.image.ColorModel; -import java.awt.image.ImageObserver; -import java.awt.geom.AffineTransform; -import java.awt.font.TextAttribute; -import java.awt.font.TextLayout; -import java.awt.font.FontRenderContext; -import java.text.AttributedString; - -/** - * Implements label drawing using Java2D functionality. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.2 $, $Date: 2008/12/19 13:29:30 $ - * @since 2.0 - */ -public class LabelDrawer2 implements LabelDrawer, Cloneable { - private String label_; - private Color clr_; - private Font font_; - private Graphics storedGraphics; - private transient Layer layer_; - private int orient_; - private int halign_; - private int valign_; - private Point dorigin_; - private Rectangle dbounds_; - private Point2D.Double porigin_; - private Rectangle2D.Double pbounds_; - private Polygon dpolygon_; - private double angle_; - private double sinthta_; - private double costhta_; - private double height_; - private boolean visible_; - private static boolean fixMetrics_ = MRJUtil.fixFontMetrics(); - - private int xoff_ = 0; - private int yoff_ = 0; - - private boolean alwaysAntiAlias_ = true; - - private Rectangle savedBounds_ = null; - private Point savedLoc_ = null; - - public LabelDrawer2(String lbl, double hgt, Point2D.Double loc, - int valign, int halign) { - label_ = lbl; - height_ = hgt; - porigin_ = loc; - valign_ = valign; - halign_ = halign; - // - dbounds_ = new Rectangle(); - dorigin_ = new Point(0,0); - pbounds_ = new Rectangle2D.Double(); - storedGraphics = null; - } - - public LabelDrawer copy() { - LabelDrawer1 newLabel = null; -// try { -// newLabel = (LabelDrawer1)clone(); -// } catch (CloneNotSupportedException e) { -// newLabel = new LabelDrawer1(ident_, label_, height_, -// porigin_, valign_, halign_); -// newLabel.setColor(clr_); -// newLabel.setFont(font_); -// if(orient_ == ANGLE) { -// newLabel.setAngle(angle_); -// } else { -// newLabel.setOrientation(orient_); -// } -// } - return newLabel; - } - - public void draw(Graphics g) throws LayerNotFoundException { - int xs, ys; - if((label_.length() <= 0) || !visible_ || g == null) return; - if(layer_ == (Layer) null) throw new LayerNotFoundException(); - // - // set label heigth in physical units - // - computeBoundsD(g); - if(clr_ == null) { - g.setColor(layer_.getPane().getComponent().getForeground()); - } else { - g.setColor(clr_); - } - if(orient_ == SGLabel.HORIZONTAL) { - xs = dbounds_.x + xoff_; - ys = dbounds_.y + yoff_; - drawString(g, xs, ys); - } else if(orient_ == SGLabel.VERTICAL) { - // - // draw text in offscreen image (horizontal) - // - xs = dbounds_.x + xoff_; - ys = dbounds_.y + yoff_; - drawString(g, xs, ys); - } else { - // - // Angled text, draw in offscreen image and rotate - // - xs = layer_.getXPtoD(porigin_.x); - ys = layer_.getYPtoD(porigin_.y); - drawString(g, xs, ys); - } - } - - public void setText(String lbl) { - label_ = lbl; - } - public String getText() { - return label_; - } - - public void setColor(Color clr) { - clr_ = clr; - } - public Color getColor() { - return clr_; - } - - public void setFont(Font font) { - font_ = font; - } - public Font getFont() { - return font_; - } - - public void setLayer(Layer layer) { - layer_ = layer; - if(savedBounds_ != null) { - setBounds(savedBounds_.x, savedBounds_.y, - savedBounds_.width, savedBounds_.height); - savedBounds_ = null; - } - if(savedLoc_ != null) { - setLocation(savedLoc_); - savedLoc_ = null; - } - } - public Layer getLayer() { - return layer_; - } - - public void setOrientation(int orient) { - if(orient_ != orient) { - if(orient == SGLabel.HORIZONTAL) { - costhta_ = 1.0; - sinthta_ = 0.0; - } else if(orient == SGLabel.VERTICAL) { - costhta_ = 0.0; - sinthta_ = 1.0; - } - orient_ = orient; - } - } - public int getOrientation() { - return orient_; - } - - public void setHAlign(int halign) { - halign_ = halign; - } - public int getHAlign() { - return halign_; - } - - public void setVAlign(int valign) { - valign_ = valign; - } - public int getVAlign() { - return valign_; - } - - public void setLocation(Point loc) { - if(layer_ == null) { - savedLoc_ = new Point(loc); - return; - } - computeBoundsD(layer_.getPane().getComponent().getGraphics()); - if(dbounds_.x != loc.x || dbounds_.y != loc.y) { - setBounds(loc.x, loc.y, dbounds_.width, dbounds_.height); - } - } - public Point getLocation() { - if(savedLoc_ != null) return savedLoc_; - return dorigin_; - } - - public void setBounds(int x, int y, int width, int height) { - int swidth, sascent, xd, yd; - if(layer_ == null) { - savedBounds_ = new Rectangle(x, y, width, height); - return; - } - Graphics g = layer_.getPane().getComponent().getGraphics(); - if(g == null) return; - font_ = computeFontSize(g); - FontRenderContext frc = getFontRenderContext((Graphics2D)g); - TextLayout tlayout; - if(label_.length() == 0) { - tlayout = new TextLayout(" ", font_, frc); - } else { - tlayout = new TextLayout(label_, font_, frc); - } - java.awt.geom.Rectangle2D tbounds = tlayout.getBounds(); - int theight = (int)tbounds.getHeight(); - int twidth = (int)tbounds.getWidth(); - int tx = (int)tbounds.getX(); - int ty = (int)tbounds.getY(); - if(fixMetrics_) ty -= (int)(0.7*tlayout.getAscent()); // hack for MacOS X java.runtime.version = 1.4.1_01-39 - sascent = (int)tlayout.getAscent(); - - if(orient_ == SGLabel.HORIZONTAL) { - swidth = width; - xd = x; - yd = y - ty; - switch(valign_) { - case SGLabel.TOP: - yd = yd - sascent; - break; - case SGLabel.MIDDLE: - yd = yd + (ty + theight/2); - break; - case SGLabel.BOTTOM: - } - switch(halign_) { - case SGLabel.RIGHT: - xd = xd + swidth; - break; - case SGLabel.CENTER: - xd = xd + swidth/2; - break; - case SGLabel.LEFT: - } - } else { - swidth = height; - yd = y + height; - xd = x - ty; - switch(valign_) { - case SGLabel.TOP: - xd = xd - sascent; - break; - case SGLabel.MIDDLE: - xd = xd - sascent/2; - break; - case SGLabel.BOTTOM: - } - switch(halign_) { - case SGLabel.RIGHT: - yd = yd - swidth; - break; - case SGLabel.CENTER: - yd = yd - swidth/2; - break; - case SGLabel.LEFT: - } - } - if(dorigin_.x != xd || dorigin_.y != yd) { - dorigin_.x = xd; - dorigin_.y = yd; - porigin_.x = layer_.getXDtoP(xd); - porigin_.y = layer_.getYDtoP(yd); - } - } - public Rectangle getBounds() { - if(savedBounds_ != null) return savedBounds_; - if(layer_ != null) computeBoundsD(layer_.getPane().getComponent().getGraphics()); - return dbounds_; - } - - public void setLocationP(Point2D.Double loc) { - porigin_ = loc; - } - public Point2D.Double getLocationP() { - return porigin_; - } - - public Rectangle2D.Double getBoundsP() { - computeBoundsD(layer_.getPane().getComponent().getGraphics()); - return pbounds_; - } - - public void setAngle(double angle) { - angle_ = angle; - double thta = angle_*Math.PI/180.0; - if(Math.abs(thta) < 0.001) { - orient_ = SGLabel.HORIZONTAL; - costhta_ = 1.0; - sinthta_ = 0.0; - } else if(Math.abs(thta - 90.0) < 0.001) { - orient_ = SGLabel.VERTICAL; - costhta_ = 0.0; - sinthta_ = 1.0; - } else { - orient_ = SGLabel.ANGLE; - costhta_ = Math.cos(thta); - sinthta_ = Math.sin(thta); - } - } - public double getAngle() { - return angle_; - } - - public void setHeightP(double hgt) { - height_ = hgt; - } - public double getHeightP() { - return height_; - } - - public void setVisible(boolean vis) { - visible_ = vis; - } - public boolean isVisible() { - return visible_; - } - - private void computeBoundsD(Graphics g) { - int sascent, xd, yd; - int xorig, yorig; - int[] xt = new int[4]; - int[] yt = new int[4]; - int[] xn = new int[4]; - int[] yn = new int[4]; - // - // compute size of font and adjust to be height tall! - // - if(g == null) return; - font_ = computeFontSize(g); - FontRenderContext frc = getFontRenderContext((Graphics2D)g); - TextLayout tlayout; - if(label_.length() == 0) { - tlayout = new TextLayout(" ", font_, frc); - } else { - tlayout = new TextLayout(label_, font_, frc); - } - java.awt.geom.Rectangle2D tbounds = tlayout.getBounds(); - -// System.out.println("LabelDrawer2('" + label_ + "'): fixMetrics = " + fixMetrics_); -// System.out.println("LabelDrawer2('" + label_ + "'): TextLayout.bounds = " + tbounds); -// System.out.println("LabelDrawer2('" + label_ + "'): ascent, descent = " + tlayout.getAscent() + ", " + tlayout.getDescent()); -// System.out.println("LabelDrawer2('" + label_ + "'): leading, baseline = " + tlayout.getLeading() + ", " + tlayout.getBaseline()); -// System.out.println("LabelDrawer2('" + label_ + "'): TextLayout = " + tlayout); - - int theight = (int)tbounds.getHeight(); - int twidth = (int)tbounds.getWidth(); - int tx = (int)tbounds.getX(); - int ty = (int)tbounds.getY(); - if(fixMetrics_) ty -= (int)(0.7*tlayout.getAscent()); // hack for MacOS X java.runtime.version = 1.4.1_01-39 - sascent = (int)tlayout.getAscent(); - // - xd = layer_.getXPtoD(porigin_.x); - yd = layer_.getYPtoD(porigin_.y); - // - // set device origin - // - dorigin_.x = xd; - dorigin_.y = yd; - xorig = xd; - yorig = yd; - // - switch(valign_) { - case SGLabel.TOP: - yd = yd + sascent; - break; - case SGLabel.MIDDLE: - yd = yd - (ty + theight/2); - break; - case SGLabel.BOTTOM: - } - switch(halign_) { - case SGLabel.RIGHT: - xd = xd - twidth; - break; - case SGLabel.CENTER: - xd = xd - twidth/2; - break; - case SGLabel.LEFT: - } - if(orient_ == SGLabel.HORIZONTAL) { - xoff_ = 0; - yoff_ = -ty; - } else if(orient_ == SGLabel.VERTICAL) { - xoff_ = -ty; - yoff_ = twidth; - } - xt[0] = xd + tx; - xt[1] = xt[0]; - xt[2] = xt[0] + twidth; - xt[3] = xt[2]; - - yt[0] = yd + ty; - yt[1] = yt[0] + theight; - yt[2] = yt[1]; - yt[3] = yt[0]; - // - // rotate - // - for(int i=0; i < 4; i++) { - xn[i] = (int)((xt[i]-xorig)*costhta_ + (yt[i]-yorig)*sinthta_) + xorig; - yn[i] = (int)((yt[i]-yorig)*costhta_ - (xt[i]-xorig)*sinthta_) + yorig; - } - - dpolygon_ = new Polygon(xn, yn, 4); - dbounds_ = dpolygon_.getBounds(); - // - // compute pbounds - // - pbounds_.x = layer_.getXDtoP(dbounds_.x); - pbounds_.y = layer_.getYDtoP(dbounds_.y); - pbounds_.width = layer_.getXDtoP(dbounds_.x + - dbounds_.width) - pbounds_.x; - pbounds_.height = pbounds_.y - - layer_.getYDtoP(dbounds_.y + dbounds_.height); - } - - // - // a bad method to compute the font size! - // - Font computeFontSize(Graphics g) { - Font tfont; - int pt_0, pt_1, hgt; - int count = 1; - double hgt_0, hgt_1, del_0, del_1; - double a, b; - FontRenderContext frc = getFontRenderContext((Graphics2D)g); - TextLayout tlayout; - // - // first guess - // - if(g == null || g == storedGraphics) return font_; // return original font! - storedGraphics = g; - - hgt = layer_.getXPtoD(height_) - layer_.getXPtoD(0.0f); - pt_0 = hgt - 3; - tfont = new Font(font_.getName(), font_.getStyle(), pt_0); - if(label_.length() == 0) { - tlayout = new TextLayout(" ", tfont, frc); - } else { - tlayout = new TextLayout(label_, tfont, frc); - } - hgt = (int)(tlayout.getAscent() + tlayout.getDescent()); - hgt_0 = layer_.getXDtoP(hgt) - layer_.getXDtoP(0); - pt_0 = tfont.getSize(); - pt_1 = (int)((double)pt_0*(height_/hgt_0)); - while((pt_0 != pt_1) && (count < 5)) { - tfont = new Font(font_.getName(), font_.getStyle(), pt_1); - if(label_.length() == 0) { - tlayout = new TextLayout(" ", tfont, frc); - } else { - tlayout = new TextLayout(label_, tfont, frc); - } - hgt = (int)(tlayout.getAscent() + tlayout.getDescent()); - hgt_1 = layer_.getXDtoP(hgt) - layer_.getXDtoP(0); - del_0 = Math.abs(height_ - hgt_0); - del_1 = Math.abs(height_ - hgt_1); - if((Math.abs(pt_0 - pt_1) <= 1) && (del_0 > del_1)) return tfont; - pt_0 = pt_1; - hgt_0 = hgt_1; - pt_1 = (int)((double)pt_0*(height_/hgt_0)); - count++; - } - return tfont; - } - - private void drawString(Graphics g, int x, int y) { - float angle; - if(g == null) return; - if(orient_ == SGLabel.HORIZONTAL) { - angle = 0.0f; - } else if(orient_ == SGLabel.VERTICAL) { - angle = -90.0f; - } else { - angle = -(float)angle_; - } - RenderingHints oldRenderingHints = null; - Graphics2D g2 = (Graphics2D)g; - if(angle != 0.0f || alwaysAntiAlias_) { - oldRenderingHints = g2.getRenderingHints(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON); - } - AffineTransform oldTransform = g2.getTransform(); - // System.out.println("\n angle = " + angle + ", text = " + label_); - // System.out.println("oldTransform = " + oldTransform); - AttributedString as = new AttributedString(label_); - as.addAttribute(TextAttribute.FONT, font_); - g2.translate(x, y); - // System.out.println("translated = " + g2.getTransform()); - g2.rotate(Math.PI * angle/180.0); - // System.out.println("newTransform = " + g2.getTransform()); - g2.drawString(as.getIterator(), 0, 0); - g2.setTransform(oldTransform); - if(angle != 0.0f || alwaysAntiAlias_) { - g2.setRenderingHints(oldRenderingHints); - } - // -// g2.setStroke(normal); -// Color oldColor = g.getColor(); -// g.setColor(Color.red); -// int x1= x - 5; -// int x2= x + 5; -// int y1= y - 5; -// int y2= y + 5; -// g.drawLine(x1, y, x2, y); -// g.drawLine(x, y1, x, y2); -// g.setColor(oldColor); - - } - public float getStringWidth(Graphics g) { - if(g == null) return 0.0f; - font_ = computeFontSize(g); - FontRenderContext frc = getFontRenderContext((Graphics2D)g); - TextLayout tlayout; - if(label_.length() == 0) { - tlayout = new TextLayout(" ", font_, frc); - } else { - tlayout = new TextLayout(label_, font_, frc); - } - java.awt.geom.Rectangle2D tbounds = tlayout.getBounds(); - return (float)tbounds.getWidth(); - } - public float getStringHeight(Graphics g) { - if(g == null) return 0.0f; - font_ = computeFontSize(g); - FontRenderContext frc = getFontRenderContext((Graphics2D)g); - TextLayout tlayout; - if(label_.length() == 0) { - tlayout = new TextLayout(" ", font_, frc); - } else { - tlayout = new TextLayout(label_, font_, frc); - } - java.awt.geom.Rectangle2D tbounds = tlayout.getBounds(); - return (float)tbounds.getHeight(); - } - - FontRenderContext getFontRenderContext(Graphics2D g2) { - if(g2 == null) return null; - RenderingHints oldRenderingHints = null; - if(angle_ != 0.0 || alwaysAntiAlias_) { - oldRenderingHints = g2.getRenderingHints(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - } - FontRenderContext frc = g2.getFontRenderContext(); - if(angle_ != 0.0 || alwaysAntiAlias_) { - g2.setRenderingHints(oldRenderingHints); - } - return frc; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelNotFoundException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelNotFoundException.java deleted file mode 100755 index 1e4cb415..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LabelNotFoundException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: LabelNotFoundException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Label was not found during operation. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class LabelNotFoundException extends SGException { - public LabelNotFoundException() { - super(); -} - public LabelNotFoundException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Layer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Layer.java deleted file mode 100755 index f22993b1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Layer.java +++ /dev/null @@ -1,871 +0,0 @@ -/* - * $Id: Layer.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.dm.SGTData; - -import gov.noaa.pmel.sgt.swing.Draggable; - -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Debug; - -import java.util.Vector; -import java.util.Enumeration; -import java.util.Iterator; -import java.awt.*; - -// jdk1.2 -//import java.awt.geom.Rectangle2D; - -/** - * A Layer contains a single Graph object - * and multiple LayerChild objects. - * There can be many Layer objects associated with each - * Pane object and - * the Layer objects can share Transform - * and Axis objects, but are not - * required to. The Layer is also where keys - * related to Color, Vectors, and - * Lines are attached. The can be at most one key of each type attached to a - * Layer. - *

- * The Layer object transforms physical coordinates - * to device coordinates. All objects that attach to a - * Layer use physical coordinates. - * The exception to this is the Graph object - * (and its children), since these objects transform user - * coordinates to physical coordinates. - *

- * The following is a simple example of using the Pane, - * Layer, and SGLabel objects - * together. In this example, the Pane and - * Layer objects are created such that, - * in the absence of any resizing, 100 pixels is equal to 1.0 - * physical units. Two labels are created, the first contains - * the current time and is located in the bottom left of - * the Layer. The second label is a title that is - * positioned near the top and centered. - *

- * Pane pane;
- * Layer layer;
- * SGLabel title;
- * SGLabel label;
- * GeoDate stime;
- * ...
- * //
- * // Instantiate Pane, Layer, and GeoDate objects.
- * //
- * pane = new Pane("test pane", new Dimension(400, 300));
- * pane.setLayout(new StackedLayout());
- * layer = new Layer("Test Layer", new Dimension2D(4.0, 3.0));
- * stime = new GeoDate();
- * //
- * // Instatiate an SGLabel object as label, set its text to the
- * // current time and position it near the lower-left corner
- * // of the layer.
- * //
- * label = new SGLabel("test", stime.toString(), new Point2D.Double(0.05, 0.05));
- * //
- * // Set properties for label.
- * //
- * label.setAlign(SGLabel.BOTTOM, SGLabel.LEFT);
- * label.setColor(Color.magenta);
- * label.setHeightP(0.15);
- * label.setFont(new Font("Dialog", Font.PLAIN, 10));
- * //
- * // Add label to layer.
- * //
- * layer.addChild(label);
- * //
- * // Instatiate an SGLabel object as title, set its text and position
- * // it near the top of the layer and centered. Set the properties
- * // for title.
- * //
- * title = new SGLabel("title", "SciGraph Test!", new Point2D.Double(2.125, 2.9));
- * title.setAlign(SGLabel.TOP, SGLabel.CENTER);
- * title.setHeightP(0.25);
- * title.setFont(new Font("Helvetica", Font.BOLD, 14));
- * //
- * // Add title to layer and add layer to pane.
- * //
- * layer.addChild(title);
- * pane.add(layer);
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @see Pane - * @see Graph - * @see ColorKey - * @see SGLabel - * @see LineKey - * @see gov.noaa.pmel.util.GeoDate -**/ -public class Layer extends Component implements Cloneable, LayerControl { - private String ident_; - /**@shapeType AggregationLink - * @clientCardinality 1 - * @label graph*/ - private Graph graph_; - /**@shapeType AggregationLink - @associates LayerChild - @supplierCardinality 0..* - * @undirected - * @label children */ - private Vector children_; - private double pWidth_; - private double pHeight_; - private double ax_; - private double ay_; - private int xoff_; - private int yoff_; - private double xoff2_; - private double yoff2_; - protected AbstractPane pane_; - - private void computeScale() { - Dimension d; - boolean hasG2 = getGraphics() instanceof Graphics2D; - // compute xoff and yoff as double then truncate to int - Rectangle pbnds = pane_.getBounds(); - Rectangle bnds = getBounds(); - if(pane_.isPrinter()) { - ax_ = 72; // java2 is in 1/72 of an inch - ay_ = ax_; - xoff2_ = (bnds.width - ax_*pWidth_)/2.0 + bnds.x; - yoff2_ = bnds.height - (bnds.height - ay_*pHeight_)/2.0 + bnds.y; - } else { - // not printer - ax_ = (double)bnds.width/pWidth_; - ay_ = (double)bnds.height/pHeight_; - if(ax_ > ay_) { - ax_ = ay_; - } else if(ay_ > ax_) { - ay_ = ax_; - } - xoff2_ = (bnds.width - ax_*pWidth_)/2.0 + bnds.x - pbnds.x; - yoff2_ = bnds.height - (bnds.height - ay_*pHeight_)/2.0 + bnds.y - pbnds.y; - } - xoff_ = (int)xoff2_; - yoff_ = (int)yoff2_; - if(Debug.DEBUG && pane_.isPrinter()) { - System.out.println("Layer.computeScale["+getId()+"] printer = " + pane_.isPrinter()); - System.out.println(" xd(min) = " + getXPtoD(0.0)); - System.out.println(" xd(max) = " + getXPtoD(pWidth_)); - System.out.println(" yd(min) = " + getYPtoD(0.0)); - System.out.println(" yd(max) = " + getYPtoD(pHeight_)); - } - } - /** - * Set the size of the Layer in device units. - * - * @param sze dimension of the Layer - */ - public void setSize(Dimension sze) { - super.setSize(sze); - computeScale(); - modified("Layer: setSize(Dimension)"); - } - /** - * Set the size of the Layer in device units. - * - * @param w width of the Layer - * @param h height of the Layer - */ - public void setSize(int w, int h) { - super.setSize(w, h); - computeScale(); - modified("Layer: setSize(int,int)"); - } - /** - * Set the location of the Layer in device units. - * - * @param pt location of the Layer - */ - public void setLocation(Point pt) { - super.setLocation(pt); - computeScale(); - modified("Layer: setLocation(Point)"); - } - /** - * Set the location of the Layer in device units. - * - * @param x horizontal location of the Layer - * @param y vertical location of the Layer - */ - public void setLocation(int x, int y) { - super.setLocation(x, y); - computeScale(); - modified("Layer: setLocation(int,int)"); - } - /** - * Set the bounds of the Layer in device units. - * - * @param x horizontal location of the Layer - * @param y vertical location of the Layer - * @param w width of the Layer - * @param h height of the Layer - */ - public void setBounds(int x, int y, int w, int h) { - super.setBounds(x, y, w, h); - computeScale(); -// System.out.println("Layer.setBounds(" + x + ", " + y + ", " + -// w + ", " + h + ")"); - modified("Layer: setBounds(int,int,int,int)"); - } - /** - * Set the bounds of the Layer in device units. - * - * @param bnds bounds of the Layer - */ - public void setBounds(Rectangle bnds) { - super.setBounds(bnds); - computeScale(); - modified("Layer: setBounds(Rectangle)"); - } - /** - * Transform physical units to device for x coordinate. - * - * @param xp x physical coordinate - * @return x device coordinate - * @since 2.0 - */ - public int getXPtoD(double xp) { - return (int)(ax_*xp) + xoff_; - } - /** - * Transform physcial units to device for y coordinate. - * - * @param yp y physical coordinate - * @return y device coordinate - * @since 2.0 - */ - public int getYPtoD(double yp) { - return yoff_ - (int)(ay_*yp); - } - /** - * Transform physical units to device for x coordinate. - * - * @param xp x physical coordinate - * @return x device coordinate - * @since 3.0 - */ - public double getXPtoD2(double xp) { - return ax_*xp + xoff2_; - } - /** - * Transform physcial units to device for y coordinate. - * - * @param yp y physical coordinate - * @return y device coordinate - * @since 3.0 - */ - public double getYPtoD2(double yp) { - return yoff2_ - ay_*yp; - } - protected double getXSlope() { - return ax_; - } - protected double getYSlope() { - return ay_; - } - protected double getXOffset() { - return xoff2_; - } - protected double getYOffset() { - return yoff2_; - } - /** - * Transform device units to physical for the x direction. - * - * @param xd device x coordinate - * - * @return physical x coordinate - */ - public double getXDtoP(int xd) { - return (double)(xd - xoff2_)/ax_; - } - /** - * Transform device units to physical for the y direction. - * - * @param yd device y coordinate - * - * @return physical y coordinate - */ - public double getYDtoP(int yd) { - return (double)(yoff2_ - yd)/ay_; - } - /** - * Create a Layer object. - * The Layer is created with a default - * width and height equal to 1.0. - * - * @param id identifier for Layer - **/ - public Layer(String id) { - this(id, new Dimension2D(1.0, 1.0)); - } - /** - * Create a Layer object. - * The Layer is created with the specified - * dimensions and identifier. - * - * @param id identifier for Layer - * @param psize The physical dimensions of the Layer - **/ - public Layer(String id,Dimension2D psize) { - ident_ = id; - pWidth_ = psize.width; - pHeight_ = psize.height; - children_ = new Vector(5,5); - } - /** - * Default constructor for Layer. - * The Layer is created with an - * empty identifier and a width and height equal to 1.0f. - **/ - public Layer() { - this(""); - } - /** - * Copy the Layer and its attached classes. - * - * @return copy - */ - public Layer copy() { - Layer newLayer; - try { - newLayer = (Layer)clone(); - } catch (CloneNotSupportedException e) { - newLayer = new Layer(ident_, new Dimension2D(pWidth_, pHeight_)); - } - // - // copy children - // - newLayer.children_ = new Vector(5,5); - // - if(!children_.isEmpty()) { - LayerChild newChild; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - newChild = ((LayerChild)it.nextElement()).copy(); - newLayer.addChild(newChild); - } - } - // - // copy Graph - // - if(graph_ != (Graph) null) { - Graph newGraph = graph_.copy(); - newLayer.setGraph(newGraph); - } - return newLayer; - } - /** - * Draw the Layer and its attached classes. - * - * @param g graphics context - * @exception PaneNotFoundException if a pane object is not found - **/ - public void draw(Graphics g) throws PaneNotFoundException { - if(pane_ == null) throw new PaneNotFoundException(); - computeScale(); - - if(false) { - System.out.println("\nLayer.draw(g): " + ident_); - System.out.println(" layer.getBounds(" + ident_ + ") = " + getBounds()); - System.out.println(" layer.getBoundsP(" + ident_ + ") = " + getBoundsP()); - System.out.println(" pane.getBounds(" + pane_.getId() + ") = " + pane_.getBounds()); - } -/* int x0, y0, x1, y1; - x0 = getXPtoD(0.0f); - y0 = getYPtoD(0.0f); - Rectangle2D.Double psize_ = getBoundsP(); - x1 = getXPtoD(psize_.width); - y1 = getYPtoD(psize_.height); - g.setColor(Color.blue); - g.drawRect(x0,y1,x1-x0-1,y0-y1-1); */ -// System.out.println("Layer.draw(g): " + ident_ + ", [" + ax_ + ", " + ay_ + "], [" + -// xoff2_ + ", " + yoff2_ + "]"); - - // - // draw Graph - // - if(graph_ != (Graph) null) graph_.draw(g); - // - // draw children - // - if(!children_.isEmpty()) { - LayerChild child; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - child = (LayerChild)it.nextElement(); - if(!(child instanceof Draggable)) { - try { - child.draw(g); - } catch(LayerNotFoundException e) { - } - } - } - } - } - - public void drawDraggableItems(Graphics g) throws PaneNotFoundException { - if(pane_ == null) throw new PaneNotFoundException(); - // - // draw draggable items - // - if(!children_.isEmpty()) { - LayerChild child; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - child = (LayerChild)it.nextElement(); - if(child instanceof Draggable) { - try { - child.draw(g); - } catch(LayerNotFoundException e) { - } - } - } - } - } - /** - * Associate a graph with the layer. Only one graph or its children may be attached to a - * layer. Multiple graphs are created by using multiple layers. - * - * @param gr graph - * @return True if attachment was succesful - * @see Graph - **/ - public boolean setGraph(Graph gr) { - graph_ = gr; - graph_.setLayer(this); - modified("Layer: setGraph()"); - return true; - } - /** - * Get the Graph attached to the layer. - * - * @return Reference to the Graph. - **/ - public Graph getGraph() { - return graph_; - } - /** - * Add a LayerChild to the Layer. - * Each Layer can contain as many children as needed. - * - * @param child A LayerChild - * @see SGLabel - * @see LineKey - * @see ColorKey - * @see Ruler - **/ - public void addChild(LayerChild child) { - child.setLayer(this); - children_.addElement(child); - modified("Layer: addChild()"); - } - /** - * Remove a LayerChild object from the Layer. - * - * @param child A ChildLayer object associated with the Layer - * @exception ChildNotFoundException The child is not associated with the Layer - * @see SGLabel - * @see LineKey - * @see ColorKey - * @see Ruler - **/ - public void removeChild(LayerChild child) throws ChildNotFoundException { - if(!children_.isEmpty()) { - LayerChild chld; - boolean found = false; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - chld = (LayerChild)it.nextElement(); - if(chld.equals(child)) { - children_.removeElement(child); - found = true; - modified("Layer: removeChild(LayerChild)"); - } - } - if(!found) throw new ChildNotFoundException(); - } else { - throw new ChildNotFoundException(); - } - } - /** - * Remove a LayerChild object from the Layer. - * - * @param labid An identifier for a LayerChild associated with the Layer - * @exception ChildNotFoundException The child is not associated with the Layer - * @see SGLabel - * @see LineKey - * @see ColorKey - * @see Ruler - **/ - public void removeChild(String labid) throws ChildNotFoundException { - if(!children_.isEmpty()) { - boolean found = false; - LayerChild child; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - child = (LayerChild)it.nextElement(); - if(child.getId().equals(labid)) { - children_.removeElement(child); - found = true; - modified("Layer: removeChild(String)"); - } - } - if(!found) throw new ChildNotFoundException(); - } else { - throw new ChildNotFoundException(); - } - } - - /** - * Find LayerChild in Layer. - * @param id LayerChild identifier - * @return LayerChild - * @since 3.0 - */ - public LayerChild findChild(String id) { - LayerChild child = null; - for(Enumeration it=children_.elements(); it.hasMoreElements();) { - child = (LayerChild)it.nextElement(); - if(child.getId().equals(id)) return child; - } - return null; - } - /** - * Tests if a LayerChild is attached to the - * Layer. - * - * @param child LayerChild to test - * @return true if attached to Layer - * @since 2.0 - */ - public boolean isChildAttached(LayerChild child) { - boolean found = false; - if(!children_.isEmpty()) { - LayerChild chld; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - chld = (LayerChild)it.nextElement(); - if(chld.equals(child)) { - children_.removeElement(child); - found = true; - break; - } - } - } - return found; - } - /** - * Remove all LayerChild objects from the Layer. - */ - public void removeAllChildren() { - children_.removeAllElements(); - modified("Layer: removeAllChildren()"); - } - /** - * Get a child associated with the Layer. - * - * @param labid A LayerChild object identifier - * @return layerChild with id - * @exception ChildNotFoundException The child is not associated with the Layer - * @see SGLabel - * @see LineKey - * @see ColorKey - * @see Ruler - **/ - public LayerChild getChild(String labid) throws ChildNotFoundException { - if(!children_.isEmpty()) { - LayerChild child; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - child = (LayerChild)it.nextElement(); - if(child.getId() == labid) return child; - } - throw new ChildNotFoundException(); - } else { - throw new ChildNotFoundException(); - } - } - /** - * Create a Enumeration for the - * LayerChild's associated with the Layer. - * - * @return Enumeration for the LayerChild objects. - * @see Enumeration - * @see SGLabel - * @see LineKey - * @see ColorKey - * @see Ruler - **/ - public Enumeration childElements() { - return children_.elements(); - } - - /** - * @since 3.0 - */ - public Iterator childIterator() { - return children_.iterator(); - } - - /** - * @since 3.0 - */ - public LayerChild[] getChildren() { - LayerChild[] childs = new LayerChild[0]; - childs = (LayerChild[])children_.toArray(childs); - return childs; - } - /** - * Set the size of the Layer in physical coordinates. - * - * @param psize The physical size of the Layer. - **/ - public void setSizeP(Dimension2D psize) { - pWidth_ = psize.width; - pHeight_ = psize.height; - computeScale(); - modified("Layer: setSizeP()"); - } - /** - * Get the Layer size in physical coordinates. - * This returns the physical coordinate size - * of the Layer. - * - * @return A Dimension2D containing the physical size of the Layer. - * @see Dimension2D - **/ - public Dimension2D getSizeP() { - return new Dimension2D(pWidth_, pHeight_); - } - /** - * Get the Layer bounds in physical coordinates. - * The origin of the bounding rectangle, - * for a Layer, is always (0,0). - * - * @return A Rectangle2D.Double containing the physical bounds of the Layer. - * @see java.awt.geom.Rectangle2D.Double - **/ - public Rectangle2D.Double getBoundsP() { - return new Rectangle2D.Double(0.0, 0.0, - pWidth_, pHeight_); - } - /** - * Get the Layer identifier. - * - * @return The identifier. - **/ - public String getId() { - return ident_; - } - /** - * Set the Layer identifier. - * - * @param id identifier - **/ - public void setId(String id) { - ident_ = id; - } - /** - * Set the Pane the Layer is associated with. - * This method is called by Pane when the - * Pane.add method is exectued. - * - * @param p The Pane - **/ - public void setPane(AbstractPane p) { - pane_ = p; - computeScale(); - modified("Layer: setPane()"); - } - /** - * Get the Pane the Layer is associated - * with. - * - * @return Refence to the Pane - **/ - public AbstractPane getPane() { - return pane_; - } - /** - * Used internally by sgt. - * @param mess message - * @since 2.0 - */ - public void modified(String mess) { - if(pane_ != null) { -// if(Debug.EVENT) System.out.println("Layer: modified(" + mess + ")"); - pane_.setModified(true, mess); - } - } - /** - * Find object associated with a MOUSE_DOWN event. The getObjectAt method - * scans through all the objects associated with the layer to find one - * whose bounding box contains the mouse location. - * - * This method should not be called by a user. - * - * @param pt device coordinates - * @param check if true requires that object isSelectable - * @return object at location - **/ - public Object getObjectAt(int x, int y, boolean check) { - return getObjectAt(new Point(x, y), check); - } - /** - * Find object associated with a MOUSE_DOWN event. The getObjectAt method - * scans through all the objects associated with the layer to find one - * whose bounding box contains the mouse location. - * - * This method should not be called by a user. - * - * @param pt device coordinates - * @return object at location - **/ - public Object getObjectAt(int x,int y) { - return getObjectAt(new Point(x, y), true); - } - /** - * Find object associated with a MOUSE_DOWN event. The getObjectAt method - * scans through all the objects associated with the layer to find one - * whose bounding box contains the mouse location. - * - * This method should not be called by a user. - * - * @param pt device coordinates - * @param check if true requires that object isSelectable - * @return object at location - **/ - public Object getObjectAt(Point pt, boolean check) { - Rectangle bnds; - Object obj; - if(!children_.isEmpty()) { - LayerChild child; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - child = (LayerChild)it.nextElement(); - bnds = child.getBounds(); - if(bnds.contains(pt) && (!check || child.isSelectable()) && - child.isVisible()) { - if(child instanceof LineKey) { - return ((LineKey)child).getObjectAt(pt); - } else if(child instanceof PointCollectionKey) { - return ((PointCollectionKey)child).getObjectAt(pt); - } else if(child instanceof VectorKey) { - return ((VectorKey)child).getObjectAt(pt); - } else { - return child; - } - } - } - } - if(graph_ != null) { - obj = graph_.getObjectAt(pt); - if(obj != null) return obj; - } - return (Object) null; - } - - /** - * Find objects associated with a MOUSE_DOWN event. The getObjecstAt method - * scans through all the objects associated with the layer to find those - * whose bounding box contains the mouse location. - * - * This method should not be called by a user. - * - * @param x mouse coordinate - * @param y mouse coordinate - * @param check if selectable - * @return object array - * @since 3.0 - */ - public Object[] getObjectsAt(int x, int y, boolean check) { - Point pt = new Point(x, y); - Vector obList = new Vector(); - Object obj = null; - Rectangle bnds; - if(!children_.isEmpty()) { - LayerChild child; - for(Enumeration it = children_.elements(); it.hasMoreElements();) { - child = (LayerChild)it.nextElement(); - bnds = child.getBounds(); - if(bnds.contains(pt) && (!check || child.isSelectable()) && - child.isVisible()) { - if(child instanceof LineKey) { - obj = ((LineKey)child).getObjectAt(pt); - if(obj != null) obList.add(obj); - } else if(child instanceof PointCollectionKey) { - obj = ((PointCollectionKey)child).getObjectAt(pt); - if(obj != null) obList.add(obj); - } else if(child instanceof VectorKey) { - obj = ((VectorKey)child).getObjectAt(pt); - if(obj != null) obList.add(obj); - } else { - if(child != null) obList.add(child); - } - } - } - } - if(graph_ != null) { - obj = graph_.getObjectAt(pt); - if(obj != null) obList.add(obj); - } - - return obList.toArray(); - } - /** - * Get a String representation of the - * Layer. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - /** - * Checks to see if a data id matches that data attached to the - * Graph. - * @param id data identifier - * @return true if data is in layer - * @since 2.0 - */ - public boolean isDataInLayer(String id) { - if(graph_ instanceof CartesianGraph) { - CartesianRenderer cr = ((CartesianGraph)graph_).getRenderer(); - if(cr instanceof LineCartesianRenderer) { - if(((LineCartesianRenderer)cr).hasCollection()) { - Collection co = ((LineCartesianRenderer)cr).getCollection(); - for(Enumeration it = co.elements(); it.hasMoreElements();) { - if(((SGTData)it.nextElement()).getId().equals(id)) return true; - } - } else { - return ((LineCartesianRenderer)cr).getLine().getId().equals(id); - } - } else if(cr instanceof GridCartesianRenderer) { - return ((GridCartesianRenderer)cr).getGrid().getId().equals(id); - } else if(cr instanceof PointCartesianRenderer) { - if(((PointCartesianRenderer)cr).hasCollection()) { - Collection co = ((PointCartesianRenderer)cr).getCollection(); - for(Enumeration it = co.elements(); it.hasMoreElements();) { - if(((SGTData)it.nextElement()).getId().equals(id)) return true; - } - } else { - return ((PointCartesianRenderer)cr).getPoint().getId().equals(id); - } - } - } - return false; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerChild.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerChild.java deleted file mode 100755 index 85fae96c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerChild.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * $Id: LayerChild.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; -import java.awt.Graphics; -import java.awt.Rectangle; - -/** - * LayerChild defines an interface to allow classes to be - * associated with a Layer. The interface is sufficient to - * provide scaling, translation, and mouse selection. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public interface LayerChild extends Selectable { - - /** - * Draw the LayerChild. - * - * @param g Graphics context - * @exception LayerNotFoundException No layer is associated with the LayerChild. - */ - public void draw(Graphics g) throws LayerNotFoundException ; - - /** - * Get the associated Layer. - * - * @return Associated layer - */ - public Layer getLayer(); - - /** - * Associate a Layer with the LayerChild. - * - * @param l Parent layer. - */ - public void setLayer(Layer l); - - /** - * Get the identifier. - * - * @return LayerChild identification. - */ - public String getId(); - - /** - * Set the identifier. - * - * @param id LayerChild identification. - */ - public void setId(String id); - - /** - * Create a copy of the LayerChild. - * - * @return A copy of the LayerChild. - */ - public LayerChild copy(); - - /** - * Return a string that represents the LayerChild. - * - * @return Stringified LayerChild representation. - */ - public String toString(); - - /** - * Check if LayerChild is visible. - * - * @since 2.0 - * @return true if visible - */ - public boolean isVisible(); - - /** - * Set visibility for a LayerChild. - * - * @since 2.0 - * @param visible visible if true - */ - public void setVisible(boolean visible); - /** - * Get AbstractPane of the LayerChild. - * @since 2.0 - */ - public AbstractPane getPane(); - /** - * Used by sgt internally. - * @since 2.0 - */ - public void modified(String mess); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerContainer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerContainer.java deleted file mode 100755 index ae738ee7..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerContainer.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * $Id: LayerContainer.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; -import java.beans.*; -/** - * A Container designed hold Layers. - * The LayerContainer improves the flexiblity in - * laying out multiple stacked Layers on a Pane. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @see StackedLayout - * @see Pane - * @see Layer - */ -public class LayerContainer extends java.awt.Container implements LayerControl { - AbstractPane pane_; - - public LayerContainer() { - super(); - } - /** - * Used internally by sgt. - */ - public void setPane(AbstractPane pane) { - pane_ = pane; - } - /** - * Used internally by sgt. - */ - public void draw(Graphics g) throws PaneNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Used internally by sgt. - * @since 2.0 - */ - public void drawDraggableItems(Graphics g) throws PaneNotFoundException { - /**@todo Implement this gov.noaa.pmel.sgt.LayerControl method*/ - throw new java.lang.UnsupportedOperationException("Method drawDraggableItems() not yet implemented."); - } - - /** - * Get identifier. - * @return identifier/name - */ - public String getId() { - return getName(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerControl.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerControl.java deleted file mode 100755 index 7359fbe0..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerControl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id: LayerControl.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.Graphics; - -/** - * Used internally by SGT to work with Layer and - * LayerContainer. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 3.0 - **/ -public interface LayerControl { - /** - * Used internally by sgt. - * @param pane Parent pane - */ - void setPane(AbstractPane pane); - /** - * Used internally by sgt. - * @param g Graphics object - * @throws PaneNotFoundException Pane not found. - */ - void draw(Graphics g) throws PaneNotFoundException; - /** - * Used internally by sgt. - * @since 2.0 - * @param g Graphics object. - * @throws PaneNotFoundException Pane not found. - */ - void drawDraggableItems(Graphics g) throws PaneNotFoundException; - - /** - * Get identifier of layer. Internally uses getName() method for Panel. - * @since 3.0 - * @return identifier - */ - String getId(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerNotFoundException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerNotFoundException.java deleted file mode 100755 index 97f4fa52..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerNotFoundException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: LayerNotFoundException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Operation failed because the layer was not found. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class LayerNotFoundException extends SGException { - public LayerNotFoundException() { - super(); - } - public LayerNotFoundException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerStack.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerStack.java deleted file mode 100755 index 879b4f18..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LayerStack.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * $Id: LayerStack.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.Container; -import java.awt.Graphics; -/** - * LayerStack is used to manage a group of layers together. - * @since 2.x - */ -public class LayerStack extends Container implements LayerControl { - public LayerStack() { - setLayout(new StackedLayout()); - } - public void setPane(AbstractPane pane) { - /**@todo Implement this gov.noaa.pmel.sgt.LayerControl method*/ - throw new java.lang.UnsupportedOperationException("Method setPane() not yet implemented."); - } - public void draw(Graphics g) { - /**@todo Implement this gov.noaa.pmel.sgt.LayerControl method*/ - throw new java.lang.UnsupportedOperationException("Method draw() not yet implemented."); - } - public void drawDraggableItems(Graphics g) { - /**@todo Implement this gov.noaa.pmel.sgt.LayerControl method*/ - throw new java.lang.UnsupportedOperationException("Method drawDraggableItems() not yet implemented."); - } - public String getId() { - return getName(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineAttribute.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineAttribute.java deleted file mode 100755 index 35e750ea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineAttribute.java +++ /dev/null @@ -1,475 +0,0 @@ -/* - * $Id: LineAttribute.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * Sets the rendering style for line data. - * Color, width, and dash characteristics are - * LineAttribute properties. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @see LineCartesianRenderer - * @see ContourLevels - */ -public class LineAttribute implements Attribute, Cloneable { - protected transient PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - - private boolean batch_ = false; - private boolean local_ = true; - private boolean modified_ = false; - private String id_ = null; - private Color color_ = Color.black; - private int style_; - private int mark_ = 1; - private double markHeightP_ = 0.2; - private float width_ = 2.0f; - private float dashes_[] = {12.0f, 12.0f}; - private float dashPhase_ = 0.0f; - private int cap_style_ = CAP_SQUARE; - private int miter_style_ = JOIN_MITER; - private float miter_limit_ = 10.0f; - - private static float HEAVY_WIDTH = 2.0f; - /** - * Solid line style. - */ - public static final int SOLID = 0; - /** - * Dashed line style. - */ - public static final int DASHED = 1; - /** - * Heavy line style - * @since 2.0 - */ - public static final int HEAVY = 2; - /** - * Highlighted line style. Accomplished by drawing - * the line over a contrasting polygon of the same shape. - */ - public static final int HIGHLIGHT = 3; - /** - * Mark line style. - * - * @see PlotMark - **/ - public static final int MARK = 4; - /** - * Mark with connecting lines style. - */ - public static final int MARK_LINE = 5; - /** - * Stroke. - */ - public static final int STROKE = 6; - /** - * Cap styles - */ - public static final int CAP_BUTT = 0; - public static final int CAP_ROUND = 1; - public static final int CAP_SQUARE = 2; - /** - * Join styles - */ - public static final int JOIN_MITER = 0; - public static final int JOIN_ROUND = 1; - public static final int JOIN_BEVEL = 2; - - - /** - * Default constructor. Default style is SOLID and - * default color is red. - **/ - public LineAttribute() { - this(SOLID, Color.red); - } - /** - * Construct LineAttribute with Color.black. - */ - public LineAttribute(int style) { - style_ = style; - if(style_ == HEAVY) width_ = HEAVY_WIDTH; - } - - /** - * LineAttribute constructor. - * - * @param style line style - * @param color line Color - * @see java.awt.Color - **/ - public LineAttribute(int style,Color color) { - this(style, 1, color); - } - /** - * LineAttribute constructor for plot marks. - * - * @param style line sytle - * @param mark plot mark - * @param color line Color - **/ - public LineAttribute(int style,int mark,Color color) { - style_ = style; - mark_ = mark; - color_ = color; - } - /** - * Copy the LineAttribute. - * - * @return new LineAttribute - */ - public Object copy() { - LineAttribute newLine; - try { - newLine = (LineAttribute)clone(); - } catch (CloneNotSupportedException e) { - newLine = new LineAttribute(); - } - return newLine; - } - - /** - * @since 3.0 - */ - public boolean equals(Object obj) { - if(obj == null || !(obj instanceof LineAttribute)) return false; - LineAttribute attr = (LineAttribute)obj; - if((id_ != attr.getId()) || - (!color_.equals(attr.getColor())) || - (style_ != attr.getStyle())) return false; - if(style_ == MARK || style_ == MARK_LINE) { - if((mark_ != attr.getMark()) || - (markHeightP_ != attr.getMarkHeightP())) return false; - } - if(style_ == HEAVY) { - if(width_ != attr.getWidth()) return false; - } - if(style_ == STROKE) { - if(width_ != attr.getWidth()) return false; - if(dashes_.length != attr.getDashArray().length) { - return false; - } else { - float[] dar = attr.getDashArray(); - for(int i=0; i < dashes_.length; i++) { - if(dashes_[i] != dar[i]) return false; - } - } - if((dashPhase_ != attr.getDashPhase()) || - (cap_style_ != attr.getCapStyle()) || - (miter_style_ != attr.getMiterStyle()) || - (miter_limit_ != attr.getMiterLimit())) return false; - } - return true; - } - /** - * Set mark height. - *
Property Change: markHeightP. - * - * @param markh mark height - **/ - public void setMarkHeightP(double markh) { - if(markHeightP_ != markh) { - Double tempOld = new Double(markHeightP_); - markHeightP_ = markh; - firePropertyChange("markHeightP", - tempOld, - new Double(markHeightP_)); - } - } - /** - * Get mark height - * - * @return mark height - **/ - public double getMarkHeightP() { - return markHeightP_; - } - /** - * Set the line style. - *
Property Change: style. - * - * @param st line style - **/ - public void setStyle(int st) { - if(style_ != st) { - Integer tempOld = new Integer(style_); - style_ = st; - firePropertyChange("style", - tempOld, - new Integer(style_)); - } - } - /** - * Set the line Color. - *
Property Change: color. - * - * @param c line Color - **/ - public void setColor(Color c) { - if(!color_.equals(c)) { - Color tempOld = color_; - color_ = c; - firePropertyChange("color", - tempOld, - color_); - } - } - /** - * Set the line width in physical units. - *
Property Change: width. - * - * @param t line width - **/ - public void setWidth(float t) { - if(width_ != t) { - Float tempOld = new Float(width_); - width_ = t; - firePropertyChange("width", - tempOld, - new Float(width_)); - } - } - /** - * Set the dash characteristics. Lengths are in physical units. - *
Property Change: dashArray. - * - **/ - public void setDashArray(float[] dashes) { - if(dashes == null) return; - boolean changed = false; - if(dashes_.length != dashes.length) { - changed = true; - } else { - for(int i = 0; i < dashes_.length; i++) { - if(dashes_[i] != dashes[i]) { - changed = true; - break; - } - } - } - if(changed) { - float[] tempOld = dashes_; - dashes_ = dashes; - firePropertyChange("dashArray", - tempOld, - dashes_); - } - } - /** - * Get line dash array. - * @since 2.0 - */ - public float[] getDashArray() { - return dashes_; - } - /** - * Set line dash phase. - *
Property Change: dashPhase. - * @since 2.0 - */ - public void setDashPhase(float phase) { - if(dashPhase_ != phase) { - Float tempOld = new Float(dashPhase_); - dashPhase_ = phase; - firePropertyChange("dashPhase", - tempOld, - new Float(dashPhase_)); - } - } - /** - * Get line dash phase. - * @since 2.0 - */ - public float getDashPhase() { - return dashPhase_; - } - /** - * Get line style. - * - * @return line style - **/ - public int getStyle() { - return style_; - } - /** - * Get line Color. - * - * @return line Color - **/ - public Color getColor() { - return color_; - } - /** - * Get line width. - * - * @return line width in physcial coordinates. - **/ - public float getWidth() { - return width_; - } - /** - * Set plot mark - *
Property Change: mark. - * - * @param mark the plot mark - **/ - public void setMark(int mark) { - if(mark_ != mark) { - Integer tempOld = new Integer(mark_); - if(mark <= 0) mark = 1; - if(mark > 51) mark = 51; - mark_ = mark; - firePropertyChange("mark", - tempOld, - new Integer(mark_)); - } - } - /** - * Get plot mark - * - * @return plot mark - **/ - public int getMark() { - return mark_; - } - /** - * Set the current line cap style. Cap styles include - * CAP_BUTT, CAP_ROUND, and - * CAP_SQUARE. - *
Property Change: capStyle. - */ - public void setCapStyle(int style) { - if(cap_style_ != style) { - Integer tempOld = new Integer(cap_style_); - cap_style_ = style; - firePropertyChange("capStyle", - tempOld, - new Integer(cap_style_)); - } - } - /** - * Get the current line cap style. - */ - public int getCapStyle() { - return cap_style_; - } - /** - * Set the current miter style. Styles include - * JOIN_MITER, JOIN_ROUND, and - * JOIN_BEVEL. - *
Property Change: miterStyle. */ - public void setMiterStyle(int style) { - if(miter_style_ != style) { - Integer tempOld = new Integer(miter_style_); - miter_style_ = style; - firePropertyChange("miterStyle", - tempOld, - new Integer(miter_style_)); - } - } - /** - * Get the current miter sytle. - */ - public int getMiterStyle() { - return miter_style_; - } - /** - * Set the miter limit. - *
Property Change: miterLimit. - */ - public void setMiterLimit(float limit) { - if(miter_limit_ != limit) { - Float tempOld = new Float(miter_limit_); - miter_limit_ = limit; - firePropertyChange("miterLimit", - tempOld, - new Float(miter_limit_)); - } - } - /** - * Get the current miter limit. - */ - public float getMiterLimit() { - return miter_limit_; - } - /** - * Get a String representation of the - * LineAttribute. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1); - } - /** - * Add listener to changes in LineAttribute properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.addPropertyChangeListener(listener); - } - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } - /** - * @since 3.0 - */ - public void setId(String id) { - id_ = id; - } - /** - * @since 3.0 - */ - public String getId() { - return id_; - } - - protected void firePropertyChange(String name, Object oldValue, Object newValue) { - if(batch_) { - modified_ = true; - return; - } - AttributeChangeEvent ace = new AttributeChangeEvent(this, name, - oldValue, newValue, - local_); - changes_.firePropertyChange(ace); - modified_ = false; - } - /** - * @since 3.0 - */ - public void setBatch(boolean batch) { - setBatch(batch, true); - } - /** - * @since 3.0 - */ - public void setBatch(boolean batch, boolean local) { - local_ = local; - batch_ = batch; - if(!batch && modified_) firePropertyChange("batch", Boolean.TRUE, Boolean.FALSE); - } - /** - * @since 3.0 - */ - public boolean isBatch() { - return batch_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineCartesianRenderer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineCartesianRenderer.java deleted file mode 100755 index eddea612..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineCartesianRenderer.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * $Id: LineCartesianRenderer.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.Collection; - -//import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Debug; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Event; -import java.awt.Point; -import java.awt.Color; -import java.awt.Rectangle; -import java.beans.PropertyChangeEvent; - -/** - * Produces a line plot with optional coloring from a second data set. If - * a second data set is specified it must have the same shape as the first. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public class LineCartesianRenderer extends CartesianRenderer { - /**@shapeType AggregationLink - * @label attr - * @undirected - * @supplierCardinality 1 */ - private LineAttribute attr_ = null; - /**@shapeType AggregationLink - * @supplierCardinality 0..1 - * @label line - * @undirected */ - private SGTLine line_ = null; - /**@shapeType AggregationLink - * @supplierCardinality 0..1 */ - private Collection collection_ = null; - - private StrokeDrawer stroke_ = null; - - /** - * Get the Attribute associated with the data. - */ - public Attribute getAttribute() { - return attr_; - } - private void drawLine(Graphics g, SGTLine line, LineAttribute attr) { - int[] xp, yp; - int[] xout, yout; - int count, size, nout; - double[] xValues, yValues; - long[] xTValues, yTValues; - - if(line.isXTime()) { - xTValues = line.getGeoDateArray().getTime(); - size = xTValues.length; - xp = new int[size]; - for(count=0; count < size; count++) { - xp[count] = cg_.getXUtoD(xTValues[count]); - } - } else { - xValues = line.getXArray(); - size = xValues.length; - xp = new int[size]; - for(count=0; count < size; count++) { - xp[count] = cg_.getXUtoD(xValues[count]); - } - } - // - if(line.isYTime()) { - yTValues = line.getGeoDateArray().getTime(); - size = yTValues.length; - yp = new int[size]; - for(count=0; count < size; count++) { - yp[count] = cg_.getYUtoD(yTValues[count]); - } - } else { - yValues = line.getYArray(); - size = yValues.length; - yp = new int[size]; - for(count=0; count < size; count++) { - yp[count] = cg_.getYUtoD(yValues[count]); - } - } - // - // check for missing values a Double.NaN is converted to a Integer.MIN_VALUE - // - int first = 0; - int lsize = 0; - xout = new int[size]; - yout = new int[size]; - while (first < size) { - nout=-1; - line: - for(count=first; count < size; count++) { - if(xp[count] != Integer.MIN_VALUE && yp[count] != Integer.MIN_VALUE) { - nout++; - xout[nout] = xp[count]; - yout[nout] = yp[count]; - } else if (nout >= 0) { - break line; - } - } - first = count + 1; - lsize = nout + 1; - if(lsize <= 0) return; - // - // draw regular line - // - switch(attr.getStyle()) { - case LineAttribute.MARK: - drawMark(g, xout, yout, lsize, attr); - break; - case LineAttribute.HIGHLIGHT: - stroke_.drawHighlight(g, xout, yout, lsize, attr); - break; - case LineAttribute.HEAVY: - stroke_.drawHeavy(g, xout, yout, lsize, attr); - break; - case LineAttribute.DASHED: - stroke_.drawDashed(g, xout, yout, lsize, attr); - break; - case LineAttribute.STROKE: - stroke_.drawStroke(g, xout, yout , lsize, attr); - break; - case LineAttribute.MARK_LINE: - drawMark(g, xout, yout, lsize, attr); - default: - case LineAttribute.SOLID: - g.drawPolyline(xout, yout, lsize); - } - } - } - /** - * Draw a mark at the requested location. This routine is used by LineCartesianGraph and - * LineKey. - * - * @param g Graphics object - * @param xp horizontal coordinate - * @param yp vertical coordinate - * @param attr line attribute - * @see LineKey - */ - protected void drawMark(Graphics g, int[] xp, int[] yp, - int npoints, LineAttribute attr) { - Layer ly = cg_.getLayer(); - PlotMark pm = new PlotMark(attr); - - for(int i=0; i < npoints; i++) { - pm.paintMark(g, ly, xp[i], yp[i]); - } - } - - /** - * Default constructor. - * - * @see CartesianGraph - * @see Graph - **/ - public LineCartesianRenderer(CartesianGraph cg) { - this(cg, (SGTLine)null, null); - } - /** - * Construct a LineCartesianRenderer. The default - * LineAttribute will be used. - * - * @param cg the parent CartesianGraph - * @param data an SGTLine object - * - * @see CartesianGraph - * @see Graph - **/ - public LineCartesianRenderer(CartesianGraph cg, SGTLine line) { - this(cg, line, null); - cg_ = cg; - line_ = line; - } - /** - * Construct a LineCartesianRenderer. - * - * @param cg the parent CartesianGraph - * @param data an SGTLine - * @param line the LineAttribute - * @see CartesianGraph - * @see Graph - **/ - public LineCartesianRenderer(CartesianGraph cg, SGTLine line, LineAttribute attr) { - cg_ = cg; - line_ = line; - attr_ = attr; - if(attr_ != null) attr_.addPropertyChangeListener(this); - stroke_ = PaneProxy.strokeDrawer; - } - /** - * Construct a LineCartesianRenderer. - * - * @param cg the parent CartesianGraph - * @param col a Collection of SGTLine objects - * @param line the LineAttribute - * @see CartesianGraph - * @see Graph - **/ - public LineCartesianRenderer(CartesianGraph cg, Collection col, LineAttribute attr) { - cg_ = cg; - collection_ = col; - attr_ = attr; - if(attr_ != null) attr_.addPropertyChangeListener(this); - stroke_ = PaneProxy.strokeDrawer; - } - /** - * Render the SGTData. This method should not - * be directly called. - * - * @param g graphics context - * - * @see Pane#draw - */ - public void draw(Graphics g) { - LineAttribute attr; - Object line; - - if(cg_.clipping_) { - int xmin, xmax, ymin, ymax; - int x, y, width, height; - if(cg_.xTransform_.isSpace()) { - xmin = cg_.getXUtoD(cg_.xClipRange_.start); - xmax = cg_.getXUtoD(cg_.xClipRange_.end); - } else { - xmin = cg_.getXUtoD(cg_.tClipRange_.start); - xmax = cg_.getXUtoD(cg_.tClipRange_.end); - } - if(cg_.yTransform_.isSpace()) { - ymin = cg_.getYUtoD(cg_.yClipRange_.start); - ymax = cg_.getYUtoD(cg_.yClipRange_.end); - } else { - ymin = cg_.getYUtoD(cg_.tClipRange_.start); - ymax = cg_.getYUtoD(cg_.tClipRange_.end); - } - if(xmin < xmax) { - x = xmin; - width = xmax - xmin; - } else { - x=xmax; - width = xmin - xmax; - } - if(ymin < ymax) { - y = ymin; - height = ymax - ymin; - } else { - y = ymax; - height = ymin - ymax; - } - g.setClip(x, y, width, height); - } - if(attr_ == null) { - attr = new LineAttribute(LineAttribute.SOLID, - cg_.getPane().getComponent().getForeground()); - } else { - attr = attr_; - } - g.setColor(attr.getColor()); - if(collection_ == null) { - drawLine(g, line_, attr); - } else { - for(Enumeration li = collection_.elements(); li.hasMoreElements();) { - line = li.nextElement(); - if(line instanceof SGTLine) { - drawLine(g, (SGTLine)line, attr); - } - } - } - - // - // reset clip - // - Rectangle rect = cg_.getLayer().getPane().getBounds(); - g.setClip(rect); - } - /** - * Set the LineAttribute. The line appearance is controlled by - * this object. - * - * @param l LineAttribute - **/ - public void setLineAttribute(LineAttribute l) { - if(attr_ != null) attr_.removePropertyChangeListener(this); - attr_ = l; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - /** - * Get the LineAttribute. - * - * @return LineAttribute - **/ - public LineAttribute getLineAttribute() { - return attr_; - } - /** - * Test if a Collection of SGTLine - * was using to construct this renderer. - * - * @return true if Collection was used - */ - public boolean hasCollection() { - return (collection_ != null); - } - /** - * Get the Collection of SGTLine objects. - * - * @return Collection - */ - public Collection getCollection() { - return collection_; - } - /** - * Get the SGTLine object. - * - * @return SGTLine - */ - public SGTLine getLine(){ - return line_; - } - /** - * Get the associated CartesianGraph object. - * - * @return CartesianGraph - */ - public CartesianGraph getCartesianGraph() { - return cg_; - } - - public void propertyChange(PropertyChangeEvent evt) { -// if(Debug.EVENT) { -// System.out.println("LineCartesianRenderer: " + evt); -// System.out.println(" " + evt.getPropertyName()); -// } - modified("LineCartesianRenderer: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - /** - * @since 3.0 - */ - public SGTData getDataAt(Point pt) { - return null; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineKey.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineKey.java deleted file mode 100755 index 4c293c26..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LineKey.java +++ /dev/null @@ -1,748 +0,0 @@ -/* - * $Id: LineKey.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Debug; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Point; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeSupport; - -// jdk1.2 -//import java.awt.geom.Point2D; - -/** - * LineKey is used to create a key for the - * LineCartesianRenderer. Multiple - * lines can be included in the key. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 -**/ -public class LineKey implements Cloneable, - DataKey, Moveable, PropertyChangeListener { - private String ident_; -/** @directed */ - private Layer layer_; - /** @link aggregation - * @supplierCardinality * - * @label line*/ - /*#LineCartesianRenderer lnkLineCartesianRenderer;*/ - private Vector line_; - /** @link aggregation - * @supplierCardinality * - * @label label*/ - /*#SGLabel lnkSGLabel;*/ - private Vector label_; - private int columns_; - private int style_; - private int valign_; - private int halign_; - private Point2D.Double porigin_; - private double lineLengthP_; - private int maxLabelLength_; - private int maxLabelHeight_; - private StrokeDrawer stroke_ = null; - private boolean selected_; - private boolean selectable_; - private boolean visible_; - private boolean moveable_; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private static final int VERTICAL_BORDER_ = 3; - private static final int HORIZONTAL_BORDER_ = 15; - private static final int COLUMN_SPACE_ = 10; - private static final int ROW_SPACE_ = 3; - private static final int LABEL_SPACE_ = 15; - /** - * Use plain line border. - */ - public static final int PLAIN_LINE = 0; - /** - * Use raised border. - */ - public static final int RAISED = 1; - /** - * Do not draw a border. - */ - public static final int NO_BORDER = 2; - /** - * Align to top of key. - */ - public static final int TOP = 0; - /** - * Align to middle of key. - */ - public static final int MIDDLE = 1; - /** - * Align to bottom of key. - */ - public static final int BOTTOM = 2; - /** - * Align to left of key. - */ - public static final int LEFT = 0; - /** - * Align to center of key. - */ - public static final int CENTER = 1; - /** - * Align to right of key. - */ - public static final int RIGHT = 2; - - - /** - * Default constructor. - */ - public LineKey() { - this(new Point2D.Double(0.0, 0.0), BOTTOM, LEFT); - } - /** - * - */ - public LineKey(Point2D.Double loc,int valign,int halign) { - porigin_ = loc; - valign_ = valign; - halign_ = halign; - line_ = new Vector(2,2); - label_ = new Vector(2,2); - // - // set defaults - // - style_ = PLAIN_LINE; - columns_ = 1; - ident_ = ""; - lineLengthP_ = 0.3f; - selected_ = false; - selectable_ = true; - visible_ = true; - moveable_ = true; - stroke_ = PaneProxy.strokeDrawer; - } - /** - * Create of copy of LineKey. - */ - public LayerChild copy() { - LineKey newKey; - try { - newKey = (LineKey)clone(); - } catch (CloneNotSupportedException e) { - newKey = new LineKey(); - } - newKey.line_ = new Vector(2,2); - newKey.label_ = new Vector(2,2); - return newKey; - } - public void setSelected(boolean sel) { - selected_ = sel; - } - public boolean isSelected() { - return selected_; - } - public void setSelectable(boolean select) { - selectable_ = select; - } - public boolean isSelectable() { - return selectable_; - } - public boolean isMoveable() { - return moveable_; - } - public void setMoveable(boolean moveable) { - moveable_ = moveable; - } - /** - * Set parent layer. - * - * @param l parent layer - */ - public void setLayer(Layer l) { - layer_ = l; - } - /** - * Get layer. - * - * @return layer - */ - public Layer getLayer() { - return layer_; - } - - public AbstractPane getPane() { - return layer_.getPane(); - } - - public void modified(String mess) { - if(layer_ != null) - layer_.modified(mess); - } - /** - * Set LineKey identifier. - * - * @param id key identifier - */ - public void setId(String id) { - ident_ = id; - } - /** - * Get LineKey identifier - * - * @return identifier - */ - public String getId() { - return ident_; - } - /** - * Set line length. - * - * @param len line length - */ - public void setLineLengthP(double len) { - if(lineLengthP_ != len) { - lineLengthP_ = len; - modified("LineKey: setLineLengthP()"); - } - } - /** - * Get line length - * - * @return line length - */ - public double getLineLengthP() { - return lineLengthP_; - } - /** - * Set the number of columns. - * - * @param col number of columns - */ - public void setColumns(int col) { - if(columns_ != col) { - columns_ = col; - modified("LineKey: setColumms()"); - } - } - /** - * Get the number of columns. - * - * @return number of columns - */ - public int getColumns() { - return columns_; - } - /** - * Set border style. - * - * @param style border style - * @see #PLAIN_LINE - * @see #RAISED - * @see #NO_BORDER - */ - public void setBorderStyle(int style) { - if(style_ != style) { - style_ = style; - modified("LineKey: setBorderStyle()"); - } - } - /** - * Get border style. - * - * @return border style - */ - public int getBorderStyle() { - return style_; - } - /** - * Set alignment. - * - * @param vert vertical alignment - * @param horz horizontal alignment - */ - public void setAlign(int vert,int horz) { - if(valign_ != vert || halign_ != horz) { - valign_ = vert; - halign_ = horz; - modified("LineKey: setAlign()"); - } - } - /** - * Set vertical alignment - * - * @param vert vertical alignment - */ - public void setVAlign(int vert) { - if(valign_ != vert) { - valign_ = vert; - modified("LineKey: setVAlign()"); - } - } - /** - * Set horizontal alignment - * - * @param horz horizontal alignment - */ - public void setHAlign(int horz) { - if(halign_ != horz) { - halign_ = horz; - modified("LineKey: setHAlign()"); - } - } - /** - * Get vertical alignment - * - * @return vertical alignment - */ - public int getVAlign() { - return valign_; - } - /** - * Get horizontal alignment - * - * @return horizontal alignment - */ - public int getHAlign() { - return halign_; - } - /** - * Set location of key - *
Property Change: location. - * - * @param loc key location - */ - public void setLocationP(Point2D.Double loc) { - if(porigin_ == null || !porigin_.equals(loc)) { - Point2D.Double temp = porigin_; - porigin_ = loc; - changes_.firePropertyChange("location", - temp, - porigin_); - modified("LineKey: setLocationP()"); - } - } - /** - * Set the bounds of the LineKey in physical units. - */ - public void setBoundsP(Rectangle2D.Double r) { - setLocationP(new Point2D.Double(r.x, r.y)); - } - /** - * Get key bounds in physical coordinates. - * Not presently implemented. - */ - public Rectangle2D.Double getBoundsP() { - throw new MethodNotImplementedError(); - } - /** - * Get location of key. - * - * @return Key location - */ - public Point2D.Double getLocationP() { - return porigin_; - } - /** - * Add a LineCartesianRenderer and label to the LineKey. - * - * @param line LineCartesianGraph object - * @param label descriptive label - */ - public void addLineGraph(LineCartesianRenderer line, SGLabel label) { - line_.addElement(line); - label.setLayer(layer_); - label.setMoveable(false); - label.setSelectable(false); - label_.addElement(label); - ((LineAttribute)line.getAttribute()).addPropertyChangeListener(this); - modified("LineKey: addLineGraph()"); - } - /** - * Add a LineCartesianRenderer and label to the LineKey. - * - * @param rend LineCartesianRenderer object - * @param label descriptive label - * @since 3.0 - */ - public void addGraph(CartesianRenderer rend, SGLabel label) - throws IllegalArgumentException { - if(!(rend instanceof LineCartesianRenderer)) - throw new IllegalArgumentException("Renderer is not a LineCartesianRenderer"); - addLineGraph((LineCartesianRenderer)rend, label); - } - /** - * Remove a line from the LineKey. - * - */ - public void removeLineGraph(SGLabel label) { - } - /** - * Remove a line from the LineKey. - * - */ - public void removeLineRenderer(LineCartesianRenderer line) { - } - /** - * Remove a line from the LineKey. - * - */ - public void removeLineGraph(String ident) { - } - /** - * Remove all lines from the LineKey. - */ - public void clearAll() { - LineAttribute attr; - for(Enumeration e = line_.elements(); e.hasMoreElements(); ) { - attr = (LineAttribute)((LineCartesianRenderer)e.nextElement()).getAttribute(); - attr.removePropertyChangeListener(this); - } - line_.removeAllElements(); - label_.removeAllElements(); - modified("LineKey: clearAll()"); - } - /** - * Remove line associated with data id from LineKey. - * @since 2.0 - */ - public void clear(String data_id) { - LineCartesianRenderer lcr; - int indx = -1; - for(Enumeration it = line_.elements(); it.hasMoreElements();) { - indx++; - lcr = (LineCartesianRenderer)it.nextElement(); - if(lcr.getLine().getId().equals(data_id)) { - lcr.getAttribute().removePropertyChangeListener(this); - line_.removeElement(lcr); - label_.removeElementAt(indx); - modified("LineKey: clear()"); - break; - } - } - } - /** - * Return rowheight of key in pixels. - * @since 2.0 - */ - public int getRowHeight() { - Rectangle bounds; - bounds = getBounds(); - return ROW_SPACE_ + maxLabelHeight_; - } - /** - * Draw the Key. - */ - public void draw(Graphics g) { - double maxLabelLength, maxLabelHeight; - int numLines, numRows, i, lineLength; - int col, row, ytemp; - double xloc, labelSpace; - double[] xp, yp; - int[] xd, yd; - int[] xout, yout; - Rectangle bounds; - LineCartesianRenderer render = null; - SGLabel label; - LineAttribute attr = null; - // - numLines = line_.size(); - if((numLines <= 0) || !visible_) return; - - numRows = numLines/columns_; - if(numLines%columns_ != 0) numRows++; - - xp = new double[columns_]; - xd = new int[columns_]; - yp = new double[numRows]; - yd = new int[numRows]; - xout = new int[2]; - yout = new int[2]; - - g.setColor(layer_.getPane().getComponent().getForeground()); - bounds = getBounds(); - // - // compute location of rows and columns in device and physical coordinates - // - lineLength = layer_.getXPtoD(lineLengthP_) - layer_.getXPtoD(0.0f); - labelSpace = layer_.getXDtoP(LABEL_SPACE_) - layer_.getXDtoP(0); - // - yd[0] = bounds.y + VERTICAL_BORDER_ + maxLabelHeight_; - yp[0] = layer_.getYDtoP(yd[0]); - for(i=1; i < numRows; i++) { - yd[i] = yd[i-1] + ROW_SPACE_ + maxLabelHeight_; - yp[i] = layer_.getYDtoP(yd[i]); - } - xd[0] = bounds.x + HORIZONTAL_BORDER_; - xp[0] = layer_.getXDtoP(xd[0]); - for(i=1; i < columns_; i++) { - xd[i] = xd[i-1] + COLUMN_SPACE_ + lineLength + LABEL_SPACE_ + maxLabelLength_; - xp[i] = layer_.getXDtoP(xd[i]); - } - // - row = 0; - col = 0; - Object obj; - Enumeration labelIt = label_.elements(); - for(Enumeration lineIt = line_.elements(); lineIt.hasMoreElements();) { - obj = lineIt.nextElement(); - render = (LineCartesianRenderer)obj; - attr = (LineAttribute)render.getAttribute(); - label = (SGLabel)labelIt.nextElement(); - // - // draw line - // - g.setColor(attr.getColor()); - xout[0] = xd[col]; - xout[1] = xout[0] + lineLength; - yout[0] = yd[row] - maxLabelHeight_/2; - yout[1] = yout[0]; - switch(attr.getStyle()) { - case LineAttribute.MARK: - render.drawMark(g, xout, yout, 2, attr); - break; - case LineAttribute.HIGHLIGHT: - stroke_.drawHighlight(g, xout, yout, 2, attr); - break; - case LineAttribute.HEAVY: - stroke_.drawHeavy(g, xout, yout, 2, attr); - break; - case LineAttribute.DASHED: - stroke_.drawDashed(g, xout, yout, 2, attr); - break; - case LineAttribute.STROKE: - stroke_.drawStroke(g, xout, yout , 2, attr); - break; - case LineAttribute.MARK_LINE: - render.drawMark(g, xout, yout, 2, attr); - default: - case LineAttribute.SOLID: - g.drawLine(xout[0], yout[0], xout[1], yout[1]); - } - // - xloc = xp[col] + lineLengthP_ + labelSpace; - label.setLocationP(new Point2D.Double(xloc, yp[row])); - try { - label.draw(g); - } catch (SGException e) {} - // - col++; - if(col >= columns_) { - col = 0; - row++; - } - } - switch(style_) { - case PLAIN_LINE: - g.drawRect(bounds.x, bounds.y, bounds.width-1, bounds.height-1); - break; - case RAISED: - break; - default: - case NO_BORDER: - } - } - /** - * Get the bounding rectangle. - * - * @return bounding rectangle - */ - public Rectangle getBounds() { - int lineLength; - int numLines, rows; - int x, y, height, width; - - numLines = line_.size(); - if(numLines <= 0) return new Rectangle(0, 0, 0, 0); - // - // find longest label - // - maxLabelLength_ = 0; - maxLabelHeight_ = 0; - SGLabel label; - for(Enumeration it = label_.elements(); it.hasMoreElements();) { - label = (SGLabel)it.nextElement(); - Rectangle sz = label.getBounds(); - maxLabelLength_ = Math.max(maxLabelLength_, sz.width); - maxLabelHeight_ = Math.max(maxLabelHeight_, sz.height); - } - // - rows = numLines/columns_; - if(numLines%columns_ != 0) rows++; - lineLength = layer_.getXPtoD(lineLengthP_) - layer_.getXPtoD(0.0f); - width = 2*HORIZONTAL_BORDER_ + columns_*(lineLength + LABEL_SPACE_ + maxLabelLength_) - + (columns_ - 1)*COLUMN_SPACE_; - height = 2*VERTICAL_BORDER_ + rows*maxLabelHeight_ + (rows-1)*ROW_SPACE_; - // - x = layer_.getXPtoD(porigin_.x); - y = layer_.getYPtoD(porigin_.y); - switch(halign_) { - case RIGHT: - x = x - width; - break; - case CENTER: - x = x - width/2; - } - switch(valign_) { - case BOTTOM: - y = y - height; - break; - case MIDDLE: - y = y - height/2; - } - return new Rectangle(x, y, width, height); - } - public Point getLocation() { - Rectangle bnds = getBounds(); - return new Point(bnds.x, bnds.y); - } - public void setLocation(Point loc) { - Rectangle bnds = getBounds(); - setBounds(loc.x, loc.y, bnds.width, bnds.height); - } - /** - * Set the bounds of the LineKey. - */ - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - /** - * Set the bounds of the LineKey. - *
Property Change: location. - */ - public void setBounds(int x, int y, int width, int height) { - switch(halign_) { - case RIGHT: - x = x + width; - break; - case CENTER: - x = x + width/2; - } - switch(valign_) { - case BOTTOM: - y = y + height; - break; - case MIDDLE: - y = y + height/2; - } - double xp = layer_.getXDtoP(x); - double yp = layer_.getYDtoP(y); - if(porigin_.x != xp || porigin_.y != yp) { - Point2D.Double temp = porigin_; - porigin_.x = xp; - porigin_.y = yp; - changes_.firePropertyChange("location", - temp, - new Point2D.Double(xp, yp)); - modified("LineKey: setBounds()"); - } - } - Object getObjectAt(Point pt) { - Rectangle lbnds; - Rectangle bounds; - LineCartesianRenderer line; - int[] xout, yout; - int[] xd, yd; - int numLines, numRows; - int lineLength; - double labelSpace; - int i; - - numLines = line_.size(); - if(numLines <= 0) return null; - - numRows = numLines/columns_; - if(numLines%columns_ != 0) numRows++; - - xd = new int[columns_]; - yd = new int[numRows]; - xout = new int[2]; - yout = new int[2]; - bounds = getBounds(); - // - // compute location of rows and columns in device and physical coordinates - // - lineLength = layer_.getXPtoD(lineLengthP_) - layer_.getXPtoD(0.0); - labelSpace = layer_.getXDtoP(LABEL_SPACE_) - layer_.getXDtoP(0); - // - yd[0] = bounds.y + VERTICAL_BORDER_ + maxLabelHeight_; - for(i=1; i < numRows; i++) { - yd[i] = yd[i-1] + ROW_SPACE_ + maxLabelHeight_; - } - xd[0] = bounds.x + HORIZONTAL_BORDER_; - for(i=1; i < columns_; i++) { - xd[i] = xd[i-1] + COLUMN_SPACE_ + lineLength + LABEL_SPACE_ + maxLabelLength_; - } - // loop over all the lines - int row = 0; - int col = 0; - for(Enumeration lineIt = line_.elements(); lineIt.hasMoreElements();) { - line = (LineCartesianRenderer)lineIt.nextElement(); - xout[0] = xd[col]; - xout[1] = xout[0] + lineLength + LABEL_SPACE_ + maxLabelLength_; -// xout[1] = xout[0] + lineLength + LABEL_SPACE_; - yout[0] = yd[row] - maxLabelHeight_; - yout[1] = yd[row]; - lbnds = new Rectangle(xout[0], yout[0], - xout[1] - xout[0], - yout[1] - yout[0]); - if(lbnds.contains(pt)) { - return line; - } - // - col++; - if(col >= columns_) { - col = 0; - row++; - } - } - if(bounds.contains(pt)) { - return this; - } - return null; - } - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - public boolean isVisible() { - return visible_; - } - public void setVisible(boolean visible) { - if(visible_ != visible) { - visible_ = visible; - modified("LineKey: setVisible()"); - } - } - public void propertyChange(PropertyChangeEvent evt) { -// if(Debug.EVENT) { -// System.out.println("LineKey: " + evt); -// System.out.println(" " + evt.getPropertyName()); -// } - modified("LineKey: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LinearTransform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LinearTransform.java deleted file mode 100755 index 538ea7fc..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LinearTransform.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * $Id: LinearTransform.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTRange; - -/** - * Performs a linear transformation on cartesian axes. If the - * transformtion is for space the equation is phys = a*user + b - * and if time is phys = at*time + bt. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public class LinearTransform extends AxisTransform implements Cloneable { - double at_; - double bt_; - double a_; - double b_; - /** - * Default constructor. Creates a transform with arguments - * Transform(0.0, 1.0, 0.0, 1.0). - **/ - public LinearTransform() { - super(); - } - /** - * LinearTransform constructor. - * This constructor is used to define - * transforms that use double user values. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @param u1 minimum value, user coordinates - * @param u2 maximum value, user coordinates - **/ - public LinearTransform(double p1,double p2,double u1,double u2) { - super(p1, p2, u1, u2); - } - /** - * LinearTransform constructor. This constructor is used to define - * transforms that use double user values. - * - * @param pr physical coordinate range - * @param ur user coordinate range - * @see Range2D - **/ - public LinearTransform(Range2D pr,Range2D ur) { - super(pr, ur); - } - /** - * LinearTransform constructor. This constructor is used to define - * transforms that use GeoDate user values. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @param t1 minimum time - * @param t2 maximum time - * @see GeoDate - **/ - public LinearTransform(double p1,double p2,GeoDate t1,GeoDate t2) { - super(p1, p2, t1, t2); - } - /** - * LinearTransform constructor. This constructor is used to define - * transforms that use GeoDate user values. - * - * @param pr physical coordinates range - * @param tr time range - * @see Range2D - * @see TimeRange - * @see GeoDate - **/ - public LinearTransform(Range2D pr,TimeRange tr) { - super(pr, tr); - } - /** - * LinearTransform constructor. This constructor is used to define - * transforms that use SoTRange user values. - * - * @since 2.0 - * @param pr physical coordinates range - * @param str space or time range - * @see SoTRange - * @see Range2D - **/ - public LinearTransform(Range2D pr, SoTRange str) { - super(pr, str); - } - /** - * Transform from user to physical coordinates. - * - * @param u user value - * @return physical value - */ - public double getTransP(double u) { - return a_*u + b_; - } - /** - * Create a copy of the LinearTransform. - * - * @return the copy - */ - public AxisTransform copy() { - LinearTransform newTransform; - try { - newTransform = (LinearTransform)clone(); - } catch (CloneNotSupportedException e) { - newTransform = new LinearTransform(); - } - return (AxisTransform)newTransform; - } - // - /** - * Transform from time to physical coordinates. - * - * @param t time - * @return user value - */ - public double getTransP(GeoDate t) { - return (double)(at_*t.getTime() + bt_); - } - public double getTransP(SoTValue v) { - if(v.isTime()) { - long t = v.getLongTime(); - return (double)at_*t + bt_; - } else { - double u = ((SoTValue.Double)v).getValue(); - return a_*u + b_; - } - } - /** - * Transform from long representation of time - * to physical coordinates. - * - * @since 3.0 - */ - public double getTransP(long t) { - return (double)at_*t + bt_; - } - /** - * Transform from physical to user coordinates. - * - * @param p physical value - * @return user value - */ - public double getTransU(double p) { - return (p - b_)/a_; - } - /** - * Transform from physical coordinates to time. - * - * @param p physical value - * @return time value - */ - public GeoDate getTimeTransU(double p) { - return new GeoDate((long)((p - bt_)/at_)); - } - /** - * Transform from physical coordinates to long - * representation of time. - * - * @since 3.0 - * @param p physical value - * @return milliseconds since 1970-01-01 - */ - public long getLongTimeTransU(double p) { - return (long)((p - bt_)/at_); - } - - public SoTValue getSoTTransU(double p) { - if(!space_) { - return new SoTValue.Time((long)((p - bt_)/at_)); - } else { - return new SoTValue.Double((p - b_)/a_); - } - } - - // - void computeTransform() { - if(space_) { - double denom; - denom = u1_ - u2_; - if(denom == 0) { - a_ = 1.0f; - b_ = 0.0f; - } else { - a_ = (p1_ - p2_)/denom; - b_ = p1_ - a_*u1_; - } - } else { - double denom; - denom = t1_ - t2_; - if(denom == 0) { - at_ = 1.0; - bt_ = 0.0; - } else { - at_ = (p1_ - p2_)/denom; - bt_ = p1_ - at_*t1_; - } - } - } - - public String toString() { - return "LinearTransform: " + a_ + ", " + b_ + "; " + at_ + ", " + bt_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LogAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LogAxis.java deleted file mode 100755 index 7f815740..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LogAxis.java +++ /dev/null @@ -1,422 +0,0 @@ -/* - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -// RCS $Id: LogAxis.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - -package gov.noaa.pmel.sgt; - -import java.awt.Graphics; -import java.awt.Rectangle; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; - -/** - * Axis class for creation of "log" axes. An {@link gov.noaa.pmel.sgt.demo.JLogLogDemo - * exmample} is available demonstrating LogAxis use. - * - *--------------------------------------------------------------------------
- * NAME : LogAxis.java
- * FUNCTION : Draws axes using "log" style axis.
- * ORIGIN : GFI INFORMATIQUE
- * PROJECT : SONC DPS
- * -------------------------------------------------------------------------
- * HISTORY
- * VERSION : 03/07/2002 : V0.0 : LBE
- * old version had no fonctionality. It was just written - * for future evolutions. This new version complete the class
- * END-HISTORY
- * ------------------------------------------------------------------------
- * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 3.0 - * - */ - -public class LogAxis extends SpaceAxis implements Cloneable { - public LogAxis(String id) { - super(id); - space_ = true; - numSmallTics_ = 9; //fixed number. only 8 shown - } - - - public Axis copy() { - LogAxis newAxis; - try { - newAxis = (LogAxis)clone(); - } catch (CloneNotSupportedException e) { - newAxis = new LogAxis(getId()); - } - return (Axis)newAxis; - } - - - void draw(Graphics g) { - //throw new MethodNotImplementedError(); - int xloc, yloc, xend, yend; - int istop, i; - double j; - double xt, yt, dir, x, y, xp, yp; - double xtitle, ytitle; - double delta = uRange_.delta; - Format format; - String labelText; - SGLabel title = getTitle(); - if(!visible_) return; - if(Double.isNaN(delta)) delta = (uRange_.end - uRange_.start)/10.0; - if(title != null) title.setLayer(graph_.getLayer()); - // - g.setColor(graph_.getLayer().getPane().getComponent().getForeground()); - // - - if(labelFormat_.length() <= 0) { - format = new Format(Format.computeFormat(uRange_.start, uRange_.end, sigDigits_)); - } else { - format = new Format(labelFormat_); - } - if(orientation_ == Axis.HORIZONTAL) { - if(Debug.DEBUG) System.out.println("LogAxis: start drawing XAxis"); - if(uLocation_ == null) { - yloc = graph_.getYUtoD(tLocation_.t); - yp = graph_.getYUtoP(tLocation_.t); - } else { - yloc = graph_.getYUtoD(uLocation_.y); - yp = graph_.getYUtoP(uLocation_.y); - } - xloc = graph_.getXUtoD(uRange_.start); - xend = graph_.getXUtoD(uRange_.end); - g.drawLine(xloc, yloc, xend, yloc); - - //X tics drawing - dir = delta > 0? 1.0: -1.0; - xt = (int)((uRange_.start/delta + (dir*uRange_.start > 0? 1.0: -1.0)*0.00001))*delta; - - if(dir*xt < dir*uRange_.start) xt += delta; - istop = (int)((uRange_.end - xt)/delta + 0.00001); - - if(uRange_.start<=0) return; - - int imin = (int)(Math.ceil(Math.log(uRange_.start)/Math.log(10))); // first large tic - int imax = (int)(Math.floor(Math.log(uRange_.end)/Math.log(10))); //last large tic - int nblabel = imax-imin +1; - - -/* System.out.println("uRange.start/end: "+uRange_.start+"/"+uRange_.end); - System.out.println("uRangeP: "+graph_.getYUtoP(uRange_.start)+"/"+graph_.getYUtoP(uRange_.end)); -*/ - double min = (double)Math.pow(10,imin); - double max = (double)Math.pow(10,imax); - - xt=min; - x = xt; - xp = graph_.getXUtoP(x); - - for (j=min/10.0d;juRange_.start) drawXTic(g, xp, yp, smallTicHeight_); - } - - for (j=min;j<=max;j=j*10.0d) { - if(j>min) drawSmallXTics(g, j/10, uRange_.end, j, yp); - //if(j>min) drawSmallXTics(g, yp, j/10, uRange_.end, j); - xp = graph_.getXUtoP(j); - drawXTic(g, xp, yp, largeTicHeight_); - } - drawSmallXTics(g, j, uRange_.end, j, yp); - //drawSmallXTics(g, yp, j, uRange_.end, j); - - // - if(labelInterval_ <= 0 || labelPosition_ == NO_LABEL) return; - - SGLabel label; - int vertalign; - int horzalign; - - if(dir*uRange_.start <= 0 && dir*uRange_.end >= 0) { - x = ((int)(uRange_.start/(delta*labelInterval_) - 0.00001))*delta*labelInterval_; - } else { - x = xt; - } - istop = (int)((uRange_.end - x)/(delta*labelInterval_) + 0.00001); - long jump = 10; // label display on each tic - if(istop 0? 1.0: -1.0; - yt = (int)((uRange_.start/delta) + (dir*uRange_.start > 0? 1.0: -1.0)*0.00001)*delta; - if(dir*yt < dir*uRange_.start) yt += delta; - istop = (int)((uRange_.end - yt)/delta + 0.00001); - - if(uRange_.start<=0) return; - - int imin = (int)(Math.ceil(Math.log(uRange_.start)/Math.log(10))); // premier large tic - int imax = (int)(Math.floor(Math.log(uRange_.end)/Math.log(10))); //dernier large tic - int nblabel = imax-imin +1; - - //System.out.println("uRange.start/end: "+uRange_.start+"/"+uRange_.end); - //System.out.println("uRangeP: "+graph_.getYUtoP(uRange_.start)+"/"+graph_.getYUtoP(uRange_.end)); - - - double min = (double)Math.pow(10,imin); - double max = (double)Math.pow(10,imax); - - - yt=min; - y = yt; - yp = graph_.getYUtoP(y); - - for (j=min/10.0d;juRange_.start) drawYTic(g, xp, yp, smallTicHeight_); - } - - for (j=min;j<=max;j=j*10.0d) { - if(j>min) drawSmallYTics(g, xp, j/10, uRange_.end, j); - yp = graph_.getYUtoP(j); - drawYTic(g, xp, yp, largeTicHeight_); - } - drawSmallYTics(g, xp, j, uRange_.end, j); - - // - if(labelInterval_ <= 0 || labelPosition_ == NO_LABEL) return; - // - SGLabel label; - int vertalign; - int horzalign; - - if(dir*uRange_.start <= 0 && dir*uRange_.end >= 0) { - y = ((int)(uRange_.start/(delta*labelInterval_) - 0.00001))*delta*labelInterval_; - } else { - y = yt; - } - - istop = (int)((uRange_.end - y)/(delta*labelInterval_) + 0.00001); - long jump = 10; // label display on each tic - if(istopmaxWidthP) maxWidthP = widthP; - } - } - - if(labelPosition_ == NEGATIVE_SIDE) { - vertalign = SGLabel.BOTTOM; - horzalign = SGLabel.RIGHT; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xt = xp - TIC_RATIO*largeTicHeight_; - } else { - xt = xp - TIC_GAP; - } - //xtitle = xt - LABEL_RATIO*labelHeight_-LABEL_RATIO*maxWidthP*0.5; - xtitle = xt - maxWidthP; - } else { - vertalign = SGLabel.TOP; - horzalign = SGLabel.LEFT; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xt = xp + TIC_RATIO*largeTicHeight_; - } else { - xt = xp + TIC_GAP; - } - //xtitle = xt + LABEL_RATIO*labelHeight_ + maxWidthP; - xtitle = xt + maxWidthP; - } - - //g.drawLine(l.getXPtoD(xt),l.getYPtoD(0.0),l.getXPtoD(xt),l.getYPtoD(4.0)); - //g.drawLine(l.getXPtoD(xtitle),l.getYPtoD(0.0),l.getXPtoD(xtitle),l.getYPtoD(4.0)); - - for(j=min; j <= max; j*=jump) { - yt = graph_.getYUtoP(j);//-LABEL_RATIO*labelHeight_*0.25; - //System.out.println("affich["+j+"]: 10e"+Math.round( Math.log(j)/Math.log(10) )); - labelText = "10e"+Math.round(Math.log(j)/Math.log(10)); - label = new SGLabel("coordinate", labelText, new Point2D.Double(xt, yt)); - label.setAlign(SGLabel.CENTER, horzalign); - label.setOrientation(SGLabel.HORIZONTAL); - label.setFont(labelFont_); - label.setColor(labelColor_); - label.setHeightP(labelHeight_); - label.setLayer(graph_.getLayer()); - try { - label.draw(g); - } catch (LayerNotFoundException e) {} - //y = j*10;//delta*labelInterval_; - } - if(title_ != null) { - ytitle = graph_.getYUtoP(uRange_.end) + graph_.getYUtoP(uRange_.start); - yt = ytitle*0.5; - xt = xtitle; - title.setLocationP(new Point2D.Double(xt, yt)); - title.setAlign(vertalign, SGLabel.CENTER); - title.setOrientation(SGLabel.VERTICAL); - try { - title.draw(g); - } catch (LayerNotFoundException e) {} - } - } - } - - /** - * Get the bounding box for the axis in device units. - * - * @return bounding box - * @see Rectangle - **/ - public Rectangle getBounds() { - double xp, yp, ymin, ymax, xmin, xmax; - int xd, yd, width, height, x, y; - if(orientation_ == Axis.HORIZONTAL) { - xd = graph_.getXUtoD(uRange_.start); - if(uLocation_ == null) { - yp = graph_.getYUtoP(tLocation_.t); - } else { - yp = graph_.getYUtoP(uLocation_.y); - } - width = graph_.getXUtoD(uRange_.end) - xd; - x = xd; - ymin = yp; - ymax = yp; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - ymax = ymax + largeTicHeight_; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - ymin = ymin - largeTicHeight_; - } - if(labelPosition_ == POSITIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - ymax = ymax + (1.0 -TIC_RATIO)*largeTicHeight_ + labelHeight_; - } else { - ymax = ymax + TIC_GAP + labelHeight_; - } - } else if(labelPosition_ == NEGATIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - ymin = ymin - (1.0 - TIC_RATIO)*largeTicHeight_ - labelHeight_; - } else { - ymin = ymin - TIC_GAP - labelHeight_; - } - } - y = graph_.getLayer().getYPtoD(ymax); - height = graph_.getLayer().getYPtoD(ymin) - y; - } else { - yd = graph_.getYUtoD(uRange_.start); - if(uLocation_ == null) { - xp = graph_.getXUtoP(tLocation_.t); - } else { - xp = graph_.getXUtoP(uLocation_.x); - } - y = graph_.getYUtoD(uRange_.end); - height = yd - y; - xmin = xp; - xmax = xp; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xmax = xmax + largeTicHeight_; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xmin = xmin - largeTicHeight_; - } - if(labelPosition_ == POSITIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xmax = xmax + (1.0 -TIC_RATIO)*largeTicHeight_ + labelHeight_; - } else { - xmax = xmax + TIC_GAP + labelHeight_; - } - } else if(labelPosition_ == NEGATIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xmin = xmin - (1.0 - TIC_RATIO)*largeTicHeight_ - labelHeight_; - } else { - xmin = xmin - TIC_GAP - labelHeight_; - } - } - x = graph_.getLayer().getXPtoD(xmin); - width = graph_.getLayer().getXPtoD(xmax) - x; - } - return new Rectangle(x, y, width, height); - } - - public void setBounds(int x, int y, int width, int height) { - } - public void setBounds(Rectangle rect) { - setBounds(rect.x, rect.y, rect.width, rect.height); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LogTransform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LogTransform.java deleted file mode 100755 index 8e833b5b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/LogTransform.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -// RCS $Id: LogTransform.java,v 1.1.1.2 2008/12/19 13:29:31 koennecke Exp $ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTRange; - -/** - * Transform class for creation of "log" axes. An {@link gov.noaa.pmel.sgt.demo.JLogLogDemo - * example} is available demonstrating LogTransform use. - * - *--------------------------------------------------------------------------
- * NAME : LogTransform.java
- * FUNCTION : Performs a logarithm transform on a cartesian axis.
- * ORIGIN : GFI INFORMATIQUE
- * PROJECT : SONC DPS
- * -------------------------------------------------------------------------
- * HISTORY
- * VERSION : 03/07/2002 LBE
- * old version had no functionality. It was just written
- * for future evolutions. This new version complete the class
- * END-HISTORY
- * ------------------------------------------------------------------------
- * @author Donald Denbo - * @version $Revision: 1.1.1.2 $, $Date: 2008/12/19 13:29:31 $ - * @since 3.0 - */ -public class LogTransform extends AxisTransform implements Cloneable { - double at_; - double bt_; - double a_; - double b_; - int min_=-50; - - public LogTransform() { - super(); - } - public LogTransform(double p1,double p2,double u1,double u2){ - super(p1, p2, u1, u2); - } - public LogTransform(Range2D pr,Range2D ur){ - super(pr, ur); - } - public LogTransform(double p1,double p2,GeoDate t1,GeoDate t2){ - super(p1, p2, t1, t2); - } - public LogTransform(Range2D pr,TimeRange tr) { - super(pr, tr); - } - public LogTransform(Range2D pr, SoTRange str){ - super(pr, str); - } - - AxisTransform copy() { - LogTransform newTransform; - try { - newTransform = (LogTransform)clone(); - } catch (CloneNotSupportedException e) { - newTransform = new LogTransform(); - } - return (AxisTransform)newTransform; - } - - public double getTransP(double u) { - try { - if(u1_<=0 || u2_<=0) { - //System.out.println("ERROR Negative LOG"); - throw new NegativeLogException("Can't Log negative values"); - } - }catch(NegativeLogException e){e.printStackTrace();} - return a_*(Math.log(u)/Math.log(10)) + b_; - } - public double getTransP(GeoDate t) { - throw new MethodNotImplementedError(); - } - public double getTransP(long t) { - throw new MethodNotImplementedError(); - } - public double getTransP(SoTValue v) { - if(v.isTime()) { - throw new MethodNotImplementedError(); - } else { - double u = ((SoTValue.Double)v).getValue(); - try { // - if(u<=0) throw new NegativeLogException("Can't Log negative values"); - }catch(NegativeLogException e){e.printStackTrace();} - return a_*(Math.log(u)/Math.log(10)) + b_; - } - } - - public double getTransU(double p) { - if((p-b_)/a_Property Change: location. - * - * @param loc logo location - */ - public void setLocationP(Point2D.Double loc) { - if(porigin_ == null || !porigin_.equals(loc)) { - Point2D.Double temp = porigin_; - porigin_ = loc; - changes_.firePropertyChange("location", - temp, - porigin_); - modified("Logo: setLocationP()"); - } - } - /** - * Get location of logo. - * - * @return Logo location - */ - public Point2D.Double getLocationP() { - return porigin_; - } - /** - * Draw the Logo. If the imageURL was specified the image - * is retrieved using the URL and MediaTracker. The image - * is displayed after it is loaded. - */ - public void draw(Graphics g) { - Rectangle bnds; - if(!visible_) return; - if (imageURL_ != null && layer_ != null && image_ == null) { - image_ = layer_.getPane().getComponent().getToolkit().getImage(imageURL_); - if (image_ != null) { - MediaTracker mt = new MediaTracker(layer_.getPane().getComponent()); - try { - mt.addImage(image_, 0); - mt.waitForAll(); - if(mt.isErrorAny()) - System.err.println("Logo: Error loading image"); - } - catch (InterruptedException ie) { } - System.out.println("MediaTracker: " + mt.checkAll()); - } - } - layer_.getPane().getComponent().invalidate(); - if(image_ != null) { - bnds = getBounds(); - g.drawImage(image_, bnds.x, bnds.y, - layer_.getPane().getComponent()); - } - } - /** - * Get the bounding rectangle. - * - * @return bounding rectangle - */ - public Rectangle getBounds() { - Rectangle bounds; - int x, y; - int width, height; - if(image_ != null) { - width = image_.getWidth(layer_.getPane().getComponent()); - height = image_.getHeight(layer_.getPane().getComponent()); - x = layer_.getXPtoD(porigin_.x); - y = layer_.getYPtoD(porigin_.y); - switch(halign_) { - case RIGHT: - x = x - width; - break; - case CENTER: - x = x - width/2; - } - switch(valign_) { - case BOTTOM: - y = y - height; - break; - case MIDDLE: - y = y - height/2; - } - return new Rectangle(x, y, width, height); - } - return null; - } - public Point getLocation() { - Rectangle bnds = getBounds(); - return new Point(bnds.x, bnds.y); - } - - public void setLocation(Point loc) { - Rectangle bnds = getBounds(); - setBounds(loc.x, loc.y, bnds.width, bnds.height); - } - /** - * Set the bounds of the Logo - */ - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - /** - * Set the bounds of the Logo - *
Property Change: location. - */ - public void setBounds(int x, int y, int width, int height) { - switch(halign_) { - case RIGHT: - x = x + width; - break; - case CENTER: - x = x + width/2; - } - switch(valign_) { - case BOTTOM: - y = y + height; - break; - case MIDDLE: - y = y + height/2; - } - double xp = layer_.getXDtoP(x); - double yp = layer_.getYDtoP(y); - if(porigin_.x != xp || porigin_.y != yp) { - Point2D.Double temp = porigin_; - porigin_.x = xp; - porigin_.y = yp; - changes_.firePropertyChange("location", - temp, - new Point2D.Double(xp, yp)); - modified("Logo: setBounds()"); - } - } - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - public boolean isVisible() { - return visible_; - } - public void setVisible(boolean visible) { - if(visible_ != visible) { - visible_ = visible; - modified("Logo: setVisible()"); - } - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MapGraph.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MapGraph.java deleted file mode 100755 index 7d9913ea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MapGraph.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * $Id: MapGraph.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTData; - -import java.awt.Graphics; -import java.awt.Point; -import java.beans.PropertyChangeEvent; - -/** - * Base class for all Map based Graphs and projections. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.x - */ -public class MapGraph extends Graph implements Cloneable { - /**@shapeType AggregationLink*/ - private MapProj mproj_; - public MapGraph() { - } - public Graph copy() { - MapGraph newGraph; - try { - newGraph = (MapGraph)clone(); - } catch (CloneNotSupportedException e) { - newGraph = new MapGraph(); - } - return (Graph)newGraph; - } - void draw(Graphics g) { - throw new MethodNotImplementedError(); - } - public void attachProj(MapProj proj) { - throw new MethodNotImplementedError(); - } - public Object getObjectAt(Point pt) { - throw new MethodNotImplementedError(); - } - - public void propertyChange(PropertyChangeEvent evt) { - } - /** - * @since 3.0 - */ - public SGTData getDataAt(Point pt) { - throw new MethodNotImplementedError(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MapProj.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MapProj.java deleted file mode 100755 index 8cd4fe87..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MapProj.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * $Id: MapProj.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Base class for Map projections. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.x - */ -public class MapProj { - public MapProj() { - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MethodNotImplementedError.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MethodNotImplementedError.java deleted file mode 100755 index e547f8db..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MethodNotImplementedError.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * $Id: MethodNotImplementedError.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Method called has not been implemented. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - */ -public class MethodNotImplementedError extends java.lang.Error { - public MethodNotImplementedError() { - super(); - } - public MethodNotImplementedError(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MinuteHourAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MinuteHourAxis.java deleted file mode 100755 index 65f90195..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MinuteHourAxis.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * $Id: MinuteHourAxis.java,v 1.1.1.2 2008/12/19 13:29:31 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.IllegalTimeValue; - -/** - * Draws time axes using the minute/hour style. - * - *
- *                  |..........|..........|..........|..........|
- *                       10         20         30         40
- *                                 13:00 7-Jun-87
- * or
- *
- *                  |..........|..........|..........|..........|
- *                     13:10       13:20     13:30      13:40
- *                                     7-Jun-87
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.2 $, $Date: 2008/12/19 13:29:31 $ - * @see Axis - * @see TimeAxis - */ -class MinuteHourAxis implements TimeAxisStyle { - static final int MINUTE_TEST__ = 31; - static final String defaultMinorLabelFormat__ = "mm"; - static final String defaultMajorLabelFormat__ = "yyyy-MM-dd HH"; - static final int defaultNumSmallTics__ = 0; - int defaultMinorLabelInterval_ = 2; - int defaultMajorLabelInterval_ = 1; - static final double incrementValue__ = 1.0; - static final int incrementUnits__ = GeoDate.MINUTES; - /** - * MinuteHourAxis constructor. - * - * @param id axis identifier - **/ - public MinuteHourAxis() { - } - public double computeLocation(double prev,double now) { - return prev; - } - public void computeDefaults(GeoDate delta) { - long msec = delta.getTime() % GeoDate.MSECS_IN_DAY; - if(msec > 7200000) { - defaultMinorLabelInterval_ = 15; - defaultMajorLabelInterval_ = 2; - } else if(msec > 1800000) { - defaultMinorLabelInterval_ = 5; - defaultMajorLabelInterval_ = 1; - } else { - defaultMinorLabelInterval_ = 1; - defaultMajorLabelInterval_ = 1; - } - } - public int getMinorValue(GeoDate time) { - return time.getGMTMinutes(); - } - public int getMajorValue(GeoDate time) { - return time.getGMTHours() + 1; - } - public boolean isRoomForMajorLabel(GeoDate delta) { - return (1440.0*((double)delta.getTime())/((double)GeoDate.MSECS_IN_DAY)) > MINUTE_TEST__; - } - public boolean isStartOfMinor(GeoDate time) { - return time.getGMTMinutes() == 0; - } - public String getDefaultMinorLabelFormat() { - return defaultMinorLabelFormat__; - } - public String getDefaultMajorLabelFormat() { - return defaultMajorLabelFormat__; - } - public int getDefaultNumSmallTics() { - return defaultNumSmallTics__; - } - public int getDefaultMinorLabelInterval() { - return defaultMinorLabelInterval_; - } - public int getDefaultMajorLabelInterval() { - return defaultMajorLabelInterval_; - } - public GeoDate getStartTime(TimeRange tRange) { - boolean time_increasing; - GeoDate time = null; - time_increasing = tRange.end.after(tRange.start); - try { - if(time_increasing) { - time = new GeoDate(tRange.start.getGMTMonth(), - tRange.start.getGMTDay(), - tRange.start.getGMTYear(), - tRange.start.getGMTHours(), - tRange.start.getGMTMinutes(), 0, 0); - if(!time.equals(tRange.start)) time.increment(1.0, GeoDate.MINUTES); - } else { - time = new GeoDate(tRange.end.getGMTMonth(), - tRange.end.getGMTDay(), - tRange.end.getGMTYear(), - tRange.end.getGMTHours(), - tRange.end.getGMTMinutes(), 0, 0); - if(!time.equals(tRange.end)) time.increment(1.0, GeoDate.MINUTES); - } - } catch (IllegalTimeValue e) {} - return time; - } - public double getIncrementValue() { - return incrementValue__; - } - public int getIncrementUnits() { - return incrementUnits__; - } - public String toString() { - return "MinuteHourAxis"; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MonthYearAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MonthYearAxis.java deleted file mode 100755 index a93e519a..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/MonthYearAxis.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * $Id: MonthYearAxis.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.IllegalTimeValue; - -/** - * Draws time axes using the month/year style. - * - *
- *            |..........|..........|..........|..........|
- *                 mar         apr        may      jun
- *                               1980
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @see Axis - * @see TimeAxis - */ -class MonthYearAxis implements TimeAxisStyle { - static final int YEAR_TEST__ = 31; - static final String defaultMinorLabelFormat__ = "MMM"; - static final String defaultMajorLabelFormat__ = "yyyy"; - static final int defaultNumSmallTics__ = 0; - int defaultMinorLabelInterval_ = 2; - int defaultMajorLabelInterval_ = 1; - static final double incrementValue__ = 1.0; - static final int incrementUnits__ = GeoDate.MONTHS; - /** - * MonthYearAxis constructor. - * - * @param id axis identifier - **/ - public MonthYearAxis() { - } - public double computeLocation(double prev,double now) { - return (prev + now)*0.5; - } - public void computeDefaults(GeoDate delta) { - if(delta.getTime()/GeoDate.MSECS_IN_DAY > 240) { - defaultMinorLabelInterval_ = 2; - } else { - defaultMinorLabelInterval_ = 1; - } - } - public int getMinorValue(GeoDate time) { - return time.getGMTMonth(); - } - public int getMajorValue(GeoDate time) { - return time.getGMTYear(); - } - public boolean isRoomForMajorLabel(GeoDate delta) { - return delta.getTime()/GeoDate.MSECS_IN_DAY > YEAR_TEST__; - } - public boolean isStartOfMinor(GeoDate time) { - return time.getGMTMonth() == 1; - } - public String getDefaultMinorLabelFormat() { - return defaultMinorLabelFormat__; - } - public String getDefaultMajorLabelFormat() { - return defaultMajorLabelFormat__; - } - public int getDefaultNumSmallTics() { - return defaultNumSmallTics__; - } - public int getDefaultMinorLabelInterval() { - return defaultMinorLabelInterval_; - } - public int getDefaultMajorLabelInterval() { - return defaultMajorLabelInterval_; - } - public GeoDate getStartTime(TimeRange tRange) { - boolean time_increasing; - GeoDate time = null; - time_increasing = tRange.end.after(tRange.start); - try { - if(time_increasing) { - time = new GeoDate(tRange.start.getGMTMonth(), 1, - tRange.start.getGMTYear(), 0, 0, 0, 0); - if(!time.equals(tRange.start)) time.increment(1.0, GeoDate.MONTHS); - } else { - time = new GeoDate(tRange.end.getGMTMonth(), 1, - tRange.end.getGMTYear(), 0, 0, 0, 0); - if(!time.equals(tRange.end)) time.increment(1.0, GeoDate.MONTHS); - } - } catch (IllegalTimeValue e) {} - return time; - } - public double getIncrementValue() { - return incrementValue__; - } - public int getIncrementUnits() { - return incrementUnits__; - } - public String toString() { - return "MonthYearAxis"; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Moveable.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Moveable.java deleted file mode 100755 index 1c264b4f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Moveable.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * $Id: Moveable.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.Point; -import java.awt.Rectangle; -import java.beans.PropertyChangeListener; - -/** - * Interface indicates that object can be moved with a mouse drag. - * Objects are notified of movement via the PropertyChange mechanism. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 2.0 - */ -public interface Moveable { - /** - * Gets the bounding rectangle in device coordinates. - * - * @since 2.0 - * @return bounding rectangle - */ - public Rectangle getBounds(); - /** - * Gets the location in device coordinates. - * - * @since 2.0 - * @return location - */ - public Point getLocation(); - /** - * Sets the location in device coordinates. - * @since 2.0 - * - */ - public void setLocation(Point point); - /** - * Returns true if the current state is moveable - * - * @since 2.0 - * @return true if moveable - */ - public boolean isMoveable(); - /** - * Set the moveable property. - * - * @since 2.0 - * @param select if true object is moveable - */ - public void setMoveable(boolean move); - /** - * Add a new PropertyChangeListener. Properties will include - * "moved". Implementation of the following two methods will - * normally be via the PropertyChangeSupport class. - * @since 2.0 - */ - public void addPropertyChangeListener(PropertyChangeListener l); - /** - * Remove a listener. - * @since 2.0 - */ - public void removePropertyChangeListener(PropertyChangeListener l); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/NegativeLogException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/NegativeLogException.java deleted file mode 100755 index 07dee4c7..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/NegativeLogException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * $Id: NegativeLogException.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Negative number used in LogTransform. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - */ -public class NegativeLogException extends SGException { - - public NegativeLogException() { - super(); - } - public NegativeLogException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Pane.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Pane.java deleted file mode 100755 index 6c09e595..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Pane.java +++ /dev/null @@ -1,500 +0,0 @@ -/* - * $Id: Pane.java,v 1.1.1.1 2007/09/07 06:32:00 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Debug; - -import java.awt.Rectangle; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Component; -import java.awt.Container; -import java.awt.Graphics; -import java.awt.AWTEvent; - -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeListener; - -/** - * The Pane class is extended from java.awt.Container - * and is the basis for the gov.noaa.pmel.sgt package. - *

- * The Java scientific graphics toolkit is designed to allow a - * graphics client developer a great deal of flexibility and freedom. - * sgt is a package that greatly aids a developer in - * creating graphics applets. sgt is not a general - * purpose graphics package, but provides the tools to enable - * scientific graphics to be easily incorporated into Applets. - *

- * sgt has three main components, the "pane", on which - * all graphics are drawn. The Pane is a fairly simple - * class and all drawing is done in "device" coordinates (pixels). - * By default, the Pane will draw on the screen, but it is - * designed to allow drawing in an offscreen buffer that can be - * printed (for applications). - *

- * The next component is the Layer. Several - * Layers can be associated with a single - * Pane. The Layer class insulates - * the developer from the details of device coordinates by - * using "physical" coordinates. Physical coordinates are - * a right-hand coordinate systems with an origin of (0.0, 0.0) in the - * lower-left-hand corner and have the same scale in both the vertical - * and horizontal directions. Thus, a Layer that is - * 5.0 units wide and 3.0 units high can be made larger and smaller - * on the screen by resizing the Pane, but will not be - * distorted. The Layer class is responsible for - * displaying labels, keys (color, vector, and line), and rulers. - * A Layer can contain a single Graph. - *

- * Finally, the Graph component transforms from - * user coordinates (e.g. cm/sec, time, degC, or meters) to - * physical coordinates. The Graph - * classes handle the display of axes and data. Children of - * the Graph class are capable of creating Cartesian, - * polar, and map graphics. For Cartesian graphs, several different - * axes (log, plain and time), transforms (linear, log, and - * tablelookup), and CartesianGraph (pixel, - * line, vector, and contour) classes are available. These classes can be - * combined in almost any combination. - *

- * While only one dataset may be plotted per Layer, - * co-plotting is supported by allowing layers to use the same - * transform objects. The order that the layers are plotted can - * be changed, allowing the developer (or user) to control what - * may be obscured. - *

- * Member functions, in package gov.noaa.pmel.sgt, - * follow the following naming convention. Member functions that - * have a P, U, or nothing at the end of the - * function name are of type double in Physical - * units, type double in User units, and type int in Device - * units, respectively. - * Variables that start with p, u, t, or d are coordinates of type physical, - * user, time, or device, respectively. - *

- * All graphics are rendered when the draw() method is invoked. - *

- * Mouse Events - *

- * Mouse events are processed by the JPane object to support - * object selection and zooming. Object selection is accomplished by - * left clicking the mouse on the desired object. JPane - * then fires a PropertyChangeEvent of type - * "objectSelected" that can be listened for by the users application. - * The user application then invokes the - * getSelectedObject() method. Zooming is accomplished in - * several steps. - *

- * - *

- * 1) Begin a zoom operation by pressing the left button.
- * 2) Describe a zoom rectangle by dragging the mouse with the left
- *    button down.
- * 3) Finish the zoom operation by releasing the left mouse button.
- * 
- * - *

- * When the mouse button has been release JPane fires a - * PropertyChangeEvent of type "zoomRectangle" that can - * be listened for by the users application. The user application can - * then obtain the zoom rectangle by invoking the - * getZoomBounds() method. - * - *

An example of object selection and zooming can be found in the - * {@link JPane} documentation. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:00 $ - * @since 1.0 - * @deprecated As of sgt 3.0, use {@link gov.noaa.pmel.sgt.JPane JPane}. - * @see Layer - * @see Graph - * @see java.awt.Graphics -**/ -public class Pane extends Container implements AbstractPane { - // - private PaneProxy proxy_; - // - /**@shapeType AggregationLink - * @supplierCardinality 1..**/ - /*# Layer lnkUnnamed*/ - /** - * Constructs a Pane. - * - * @param id the Pane identifier - * @param size the size of the Pane in pixels - **/ - public Pane(String id, Dimension size) { - proxy_ = new PaneProxy(this, id, size); - setSize(size); - // - // setup for Low-Level Events - // - this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | - AWTEvent.MOUSE_MOTION_EVENT_MASK); - } - /** - * Default constructor. The identifier is set to an empty string and - * the size is set to a width and height of 50 pixels. A default constructor - * is required to work as a component with Visual Cafe. - * - *

-   * import gov.noaa.pmel.sgt.Pane;
-   * ...
-   * Pane pane;
-   * ...
-   * pane = new Pane("main graph", new Dimension(400, 500));
-   * pane.setLayout(new StackedLayout());
-   * ...
-   * 
- * - * @see StackedLayout - * - **/ - public Pane() { - this(new String(""), new Dimension(50,50)); - } - /** - * Return the version of SGT. - * @since 3.0 - */ - public static String getVersion() { - return PaneProxy.getVersion(); - } - public void draw() { - proxy_.draw(); - } - /** - * No initialization required by Pane. - */ - public void init() { - } - public void draw(Graphics g) { - proxy_.draw(g); - } - public void draw(Graphics g, int width, int height) { - proxy_.draw(g, width, height); - } - public boolean isPrinter() { - return proxy_.isPrinter(); - } - /** - * Internal access to jdk1.1 or Java2D line drawing. - */ - public static StrokeDrawer getStrokeDrawer() { - return PaneProxy.strokeDrawer; - } - public Dimension getPageSize() { - return proxy_.getPageSize(); - } - /** - * Updates the Pane - */ - public void update(Graphics g) { - if(Debug.DEBUG) System.out.println("Pane: " + proxy_.getId() + ": update(g)"); - super.update(g); - paint(g); - } - /** - * Override of the parent paint method. This method should not be - * called by a user. - **/ - public void paint(Graphics g) { - proxy_.paint(g); - } - /** - * Adds the specified component to the end of the Pane. - * - * @param comp the component to be added - * @return component argument - */ - public Component add(Component comp) { - if(comp instanceof Layer) { - ((Layer)comp).setPane(this); - } else if(comp instanceof LayerContainer) { - ((LayerContainer)comp).setPane(this); - } - return super.add(comp); - } - /** - * Adds the specified component to the Pane at the - * given position. - * - * @param comp the component to be added - * @param index the position at which to insert the component, or -1 - to insert the component at the end. - * @return component argument - */ - public Component add(Component comp, int index) { - if(comp instanceof Layer) { - ((Layer)comp).setPane(this); - } else if(comp instanceof LayerContainer) { - ((LayerContainer)comp).setPane(this); - } - return super.add(comp, index); - } - /** - * Adds the specified component to the end of this Pane. - * Also notifies the layout manager to add the component to this - * Pane's layout using the specified constraints object. - * - * @param comp the component to be added - * @param constraints an object expressing layout constraints for - this component - */ - public void add(Component comp, Object constraints) { - super.add(comp, constraints); - if(comp instanceof Layer) { - ((Layer)comp).setPane(this); - } else if(comp instanceof LayerContainer) { - ((LayerContainer)comp).setPane(this); - } - } - /** - * Adds the specified component to the end of this Pane - * at the specified index. - * Also notifies the layout manager to add the component to this - * Pane's layout using the specified constraints object. - * - * @param comp the component to be added - * @param constraints an object expressing layout constraints for - this component - * @param index the position in the Pane's list at which to - insert the component -1 means insert at the end. - */ - public void add(Component comp, Object constraints, int index) { - super.add(comp, constraints, index); - if(comp instanceof Layer) { - ((Layer)comp).setPane(this); - } else if(comp instanceof LayerContainer) { - ((LayerContainer)comp).setPane(this); - } - } - /** - * Adds the specified component to this Pane. It - * is strongly advised to use add(Component, Object), in place - * of this method. - */ - public Component add(String name, Component comp) { - if(comp instanceof Layer) { - ((Layer)comp).setPane(this); - } else if(comp instanceof LayerContainer) { - ((LayerContainer)comp).setPane(this); - } - return super.add(name, comp); - } - - public String getId() { - return proxy_.getId(); - } - public void setId(String id) { - proxy_.setId(id); - } - public void setPageAlign(int vert,int horz) { - proxy_.setPageAlign(vert, horz); - } - public void setPageVAlign(int vert) { - proxy_.setPageVAlign(vert); - } - public void setPageHAlign(int horz) { - proxy_.setPageHAlign(horz); - } - public int getPageVAlign() { - return proxy_.getPageVAlign(); - } - public int getPageHAlign() { - return proxy_.getPageHAlign(); - } - public void setPageOrigin(Point p) { - proxy_.setPageOrigin(p); - } - public Point getPageOrigin() { - return proxy_.getPageOrigin(); - } - /** - * Set the size. - */ - public void setSize(Dimension d) { - super.setSize(d); - proxy_.setSize(d); - } - public Layer getFirstLayer() { - return proxy_.getFirstLayer(); - } - public Layer getLayer(String id) throws LayerNotFoundException { - return proxy_.getLayer(id); - } - public Layer getLayerFromDataId(String id) throws LayerNotFoundException { - return proxy_.getLayerFromDataId(id); - } - /** - * Move the Layer up in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer up causes the - * Layer to be drawn later and over earlier - * layers. - * - * @param lyr Layer object. - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerUp(Layer lyr) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Move the Layer up in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer up causes the - * Layer to be drawn later and over earlier - * layers. - * - * @param id identifier. - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerUp(String id) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Move the Layer down in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer down causes the - * Layer to be drawn earlier. - * - * @param lyr Layer object. - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerDown(Layer lyr) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - /** - * Move the Layer down in the stack. - * The order of the layers determine when they - * are drawn. Moving the Layer down causes the - * Layer to be drawn earlier. - * - * @param id identifier - * @exception LayerNotFoundException The specified Layer was not found in the list. - * @see Layer - **/ - public void moveLayerDown(String id) throws LayerNotFoundException { - throw new MethodNotImplementedError(); - } - public Object getSelectedObject() { - return proxy_.getSelectedObject(); - } - public void setSelectedObject(Object obj) { - proxy_.setSelectedObject(obj); - } - /** - * Overrides the default event methods. - **/ - public void processMouseEvent(MouseEvent event) { - if(!proxy_.processMouseEvent(event)) - super.processMouseEvent(event); - } - - public void processMouseMotionEvent(MouseEvent event) { - if(!proxy_.processMouseMotionEvent(event)) - super.processMouseMotionEvent(event); - } - public Rectangle getZoomBounds() { - return proxy_.getZoomBounds(); - } - /** - * @since 3.0 - */ - public Point getZoomStart() { - return proxy_.getZoomStart(); - } - public Object getObjectAt(int x, int y) { - return proxy_.getObjectAt(x, y); - } - /** - * @since 3.0 - */ - public Object[] getObjectsAt(int x, int y) { - return proxy_.getObjectsAt(x, y); - } - /** - * @since 3.0 - */ - public Object[] getObjectsAt(Point pt) { - return proxy_.getObjectsAt(pt.x, pt.y); - } - public Component getComponent() { - return (Component)this; - } - public Dimension getMaximumSize() { - return proxy_.getMaximumSize(); - } - public Dimension getMinimumSize() { - return proxy_.getMinimumSize(); - } - public Dimension getPreferredSize() { - return proxy_.getPreferredSize(); - } - /** - * Get a String representatinof the - * Pane. - * - * @return String representation - */ - public String toString() { - return proxy_.toString(); - } - public void setBatch(boolean batch, String msg) { - proxy_.setBatch(batch, msg); - } - public void setBatch(boolean batch) { - proxy_.setBatch(batch, ""); - } - public boolean isBatch() { - return proxy_.isBatch(); - } - public void setModified(boolean mod, String mess) { - proxy_.setModified(mod, mess); - } - public boolean isModified() { - return proxy_.isModified(); - } - /** - * @since 3.0 - */ - public void setMouseEventsEnabled(boolean enable) { - proxy_.setMouseEventsEnabled(enable); - } - /** - * @since 3.0 - */ - public boolean isMouseEventsEnabled() { - return proxy_.isMouseEventsEnabled(); - } - public void setPageScaleMode(int mode) { - proxy_.setPageScaleMode(mode); - } - public int getPageScaleMode() { - return proxy_.getPageScaleMode(); - } - /* - * Pane PropertyChange methods - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - proxy_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - proxy_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneBeanInfo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneBeanInfo.java deleted file mode 100755 index 651adce6..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneBeanInfo.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import java.beans.*; - -/** - * BeanInfo for Pane. - */ -public class PaneBeanInfo extends SimpleBeanInfo { - // getAdditionalBeanInfo method allows to return any number of additional - // BeanInfo objects which provide information about the Bean that this BeanInfo - // describes. - public BeanInfo[] getAdditionalBeanInfo() { - try { - BeanInfo[] bi = new BeanInfo[1]; - bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass()); - return bi; - } - catch (IntrospectionException e) { - throw new Error(e.toString()); - } - } - - // getIcon returns an image object which can be used by toolboxes, toolbars - // to represent this bean. Icon images are in GIF format. - public java.awt.Image getIcon(int iconKind) { - if (iconKind == BeanInfo.ICON_COLOR_16x16 || - iconKind == BeanInfo.ICON_MONO_16x16) { - java.awt.Image img = loadImage("PaneIcon16.gif"); - return img; - } - if (iconKind == BeanInfo.ICON_COLOR_32x32 || - iconKind == BeanInfo.ICON_MONO_32x32) { - java.awt.Image img = loadImage("PaneIcon32.gif"); - return img; - } - return null; - } - - // getPropertyDescriptors returns an array of PropertyDescriptors which describe - // the editable properties of this bean. - public PropertyDescriptor[] getPropertyDescriptors() { - try { - PropertyDescriptor id = new PropertyDescriptor("id", beanClass); - id.setBound(false); - id.setDisplayName("Pane Identifier"); - - PropertyDescriptor rv[] = {id}; - return rv; - } catch (IntrospectionException e) { - throw new Error(e.toString()); - } - } - - public BeanDescriptor getBeanDescriptor() { - return new BeanDescriptor(beanClass); - } - - private final static Class beanClass = Pane.class; -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneIcon16.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneIcon16.gif deleted file mode 100755 index 5ebb6e2e..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneIcon32.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneIcon32.gif deleted file mode 100755 index 33b6e997..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneNotFoundException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneNotFoundException.java deleted file mode 100755 index 69728cff..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneNotFoundException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: PaneNotFoundException.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Operation failed because the layer was not found. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - */ -public class PaneNotFoundException extends SGException { - public PaneNotFoundException() { - super(); -} - public PaneNotFoundException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneProxy.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneProxy.java deleted file mode 100755 index 9eaca02d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PaneProxy.java +++ /dev/null @@ -1,913 +0,0 @@ -/* - * $Id: PaneProxy.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.swing.Draggable; -import gov.noaa.pmel.sgt.beans.Panel; - -import gov.noaa.pmel.util.Debug; - -import java.awt.Graphics2D; -import java.awt.Stroke; - -import java.awt.Dimension; -import java.awt.Image; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Point; -import java.awt.PrintGraphics; -import java.awt.Container; -import java.awt.Component; -import java.awt.Color; -import java.awt.Cursor; - -import java.awt.event.MouseEvent; -import java.awt.event.InputEvent; - -import java.util.Vector; -import java.util.Properties; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * PaneProxy implements the functionality common to JPane - * and Pane. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - */ -class PaneProxy { - public static String SGTVersion = "3.0"; - public static boolean Java2D = false; - public static StrokeDrawer strokeDrawer = null; - - private Container pane_; - - private String ident_; - private Dimension panesize_; - private Image offscreen_; - private Dimension pagesize_; - private Point pageOrigin_ = new Point(0, 0); - private boolean printer_ = false; - private boolean opaque_ = true; - private int halign_ = AbstractPane.CENTER; - private int valign_ = AbstractPane.MIDDLE; - private int printMode_ = AbstractPane.SHRINK_TO_FIT; - private Object selectedobject_; - private Object old_selectedobject_ = null; - private Rectangle selectedRect_; - private Rectangle zoom_rect_ = new Rectangle(0, 0, 0, 0); - private Rectangle old_zoom_rect_; - private Point zoom_start_ = new Point(0, 0); - private boolean in_zoom_ = false; - private boolean in_select_ = false; - private boolean in_move_ = false; - private boolean moved_ = false; - private boolean draggable_ = false; - private boolean moveable_ = false; - private Point move_ref_; - private boolean batch_ = true; - private boolean modified_ = false; - private boolean ignoreModified_ = false; - private boolean firstDraw_ = true; - private boolean mouseEventsEnabled_ = true; - - private PropertyChangeSupport changes_ = null; - - public PaneProxy(Container pane, String id, Dimension size) { - ident_ = id; - panesize_ = size; - pane_ = pane; - changes_ = new PropertyChangeSupport(pane_); - // - testJava2D(); - } - /** - * @since 3.0 - */ - public static String getVersion() { - return SGTVersion; - } - - private void testJava2D() { - Class cl; - boolean java2d = true; - try { - cl = Class.forName("java.awt.Graphics2D"); - } catch (ClassNotFoundException e) { - java2d = false; - } - Java2D = java2d; - if(Java2D) { - strokeDrawer = new StrokeDrawer2(); - } else { - strokeDrawer = new StrokeDrawer1(); - } - } - - public Dimension getSize() { - return panesize_; - } - - void draw() { - ignoreModified_ = true; - if(Debug.DEBUG) System.out.println("PaneProxy: [" + ident_ + "] " + - " draw(), batch=" + batch_); - printer_ = false; - Graphics g = pane_.getGraphics(); - // - // test existance of graphics context. - // - if(g == null) { - ignoreModified_ = false; - return; - } - if(firstDraw_) { - ((AbstractPane)pane_).init(); - firstDraw_ = false; - } - Graphics goff; - Dimension isze = pane_.getSize(); - if(offscreen_ == (Image) null) { - offscreen_ = pane_.createImage(isze.width, isze.height); - } else { - if(isze.width != panesize_.width || isze.height != panesize_.height) { - offscreen_ = pane_.createImage(isze.width, isze.height); - } - } - panesize_ = isze; - goff = offscreen_.getGraphics(); - // super.paint(g); - Rectangle clip = pane_.getBounds(); - goff.setClip(0, 0, clip.width, clip.height); - - drawLayers(goff); - g.drawImage(offscreen_, 0, 0, pane_); - drawDraggableItems(g); - modified_ = false; - ignoreModified_ = false; - pane_.repaint(); - } - - void draw(Graphics g) { - Rectangle clip = pane_.getBounds(); - draw(g, clip.width, clip.height); - } - - void draw(Graphics g, int width, int height) { - ignoreModified_ = true; - if(Debug.DEBUG) System.out.println("PaneProxy: [" + ident_ + "] draw(g), batch="+batch_); - if(g instanceof PrintGraphics) { - printer_ = true; - pagesize_ = ((PrintGraphics)g).getPrintJob().getPageDimension(); - } else { - printer_ = false; - pagesize_ = null; - } - g.setClip(0, 0, width, height); - drawLayers(g); - drawDraggableItems(g); - modified_ = false; - ignoreModified_ = false; - } - - void drawPage(Graphics g, double width, double height) { - ignoreModified_ = true; - if(Debug.DEBUG) System.out.println("PaneProxy: [" + ident_ + "] drawPage(g), batch="+batch_); - printer_ = true; - - Color saved = g.getColor(); - g.setColor(pane_.getBackground()); - Rectangle r = pane_.getBounds(); - g.fillRect(r.x, r.y, r.width, r.height); - g.setColor(saved); - - drawLayers(g); - drawDraggableItems(g); - modified_ = false; - ignoreModified_ = false; - printer_ = false; - } - void setOpaque(boolean opaque) { - opaque_ = opaque; - } - boolean isOpaque() { - return opaque_; - } - void drawLayers(Graphics g) { - if(!printer_) { - if(opaque_) { - Rectangle r = pane_.getBounds(); - g.setColor(pane_.getBackground()); - g.fillRect(0, 0, r.width, r.height); - } - g.setColor(pane_.getForeground()); - } -// System.out.println("PaneProxy.drawLayers("+getId()+"): print = " + printer_ + ", pane = " + pane_.getBounds()); - // g.drawRect(2,2,r.width-5,r.height-5); - // - // draw Layers - // - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - try { - if(comps[i] instanceof Layer) { - ((Layer)comps[i]).draw(g); - } else if(comps[i] instanceof LayerControl) { - ((LayerControl)comps[i]).draw(g); - } - /* if(printer_ && comps[i] instanceof Panel) { - ((Panel)comps[i]).paintBorder(g); - } */ - } catch (PaneNotFoundException e) {} - } - } - void drawDraggableItems(Graphics g) { - if(Debug.DEBUG) System.out.println("PaneProxy: [" + ident_ + - "] drawDraggableItems, batch="+batch_); - // - // draw draggable items in each layer - // - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - try { - if(comps[i] instanceof LayerControl) { - ((LayerControl)comps[i]).drawDraggableItems(g); - } - } catch (PaneNotFoundException e) {} - } - } - - void paint(Graphics g) { - if(Debug.DEBUG || Debug.DRAW_TRACE) - System.out.println("PaneProxy: [" + ident_ + - "] paint(g): "+g.getClipBounds()+ - ", batch="+batch_+", modified="+modified_); - Dimension isze = pane_.getSize(); - if(isze.width != panesize_.width || isze.height != panesize_.height) offscreen_ = null; - if(offscreen_ != null && !modified_) { - g.drawImage(offscreen_, 0, 0, pane_); - drawDraggableItems(g); - } else { - if(Debug.DRAW_TRACE) System.out.println("PaneProxy: [" + ident_ + - "] paint: calling draw(), batch="+batch_); - draw(); - } - modified_ = false; - } - - String getId() { - return ident_; - } - void setId(String id) { - ident_ = id; - } - void setPageAlign(int vert, int horz) { - valign_ = vert; - halign_ = horz; - } - void setPageVAlign(int vert) { - valign_ = vert; - } - void setPageHAlign(int horz) { - halign_ = horz; - } - int getPageVAlign() { - return valign_; - } - int getPageHAlign() { - return halign_; - } - void setPageOrigin(Point p) { - pageOrigin_ = p; - } - Point getPageOrigin() { - return pageOrigin_; - } - boolean isPrinter() { - return printer_; - } - Dimension getPageSize() { - return pagesize_; - } - void setSize(Dimension d) { - panesize_ = d; - offscreen_ = null; - } - Layer getFirstLayer() { - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - return (Layer)comps[i]; - } - } - return null; - } - Layer getLayer(String id) throws LayerNotFoundException { - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - if(((Layer)comps[i]).getId() == id) return (Layer)comps[i]; - } else if(comps[i] instanceof Panel) { - if(((Panel)comps[i]).hasLayer(id)) return (Layer)((Panel)comps[i]).getLayer(id); - } - } - throw new LayerNotFoundException(); - } - - Layer getLayerFromDataId(String id) throws LayerNotFoundException { - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - if(((Layer)comps[i]).isDataInLayer(id)) return (Layer)comps[i]; - } else if(comps[i] instanceof Panel) { - if(((Panel)comps[i]).isDataInPanel(id)) return (Layer)((Panel)comps[i]).getLayerFromDataId(id); - } - } - throw new LayerNotFoundException(); - } - Object getSelectedObject() { - return selectedobject_; - } - void setSelectedObject(Object obj) { - old_selectedobject_ = selectedobject_; - selectedobject_ = obj; - } - Rectangle getZoomBounds() { - return zoom_rect_; - } - /** - * @since 3.0 - */ - Point getZoomStart() { - return zoom_start_; - } - - Object getObjectAt(int x, int y) { - Object obj = null; - Component[] comps = pane_.getComponents(); - if(comps.length != 0) { - Layer ly; - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - obj = ((Layer)comps[i]).getObjectAt(x, y, false); - if(obj != null) return obj; - } else if(comps[i] instanceof Panel) { - obj = ((Panel)comps[i]).getObjectAt(x, y, false); - if(obj != null) return obj; - } - } - } - return obj; - } - /** - * @since 3.0 - */ - Object[] getObjectsAt(int x, int y) { - Vector obList = new Vector(); - Object obj = null; - Component[] comps = pane_.getComponents(); - if(comps.length != 0) { - Layer ly; - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - obj = ((Layer)comps[i]).getObjectAt(x, y, false); - if(obj != null) obList.addElement(obj); - } else if(comps[i] instanceof Panel) { - obj = ((Panel)comps[i]).getObjectAt(x, y, false); - if(obj != null) obList.addElement(obj); - } - } - } - return obList.toArray(); - } - - boolean processMouseEvent(MouseEvent event) { - boolean event_handled = false; - if(!mouseEventsEnabled_) return event_handled; - if (event.getID() == MouseEvent.MOUSE_CLICKED) { - event_handled = Pane_MouseClicked(event); - } else if (event.getID() == MouseEvent.MOUSE_PRESSED) { - event_handled = Pane_MouseDown(event); - } else if (event.getID() == MouseEvent.MOUSE_RELEASED) { - event_handled = Pane_MouseUp(event); - } - return event_handled; - } - - boolean processMouseMotionEvent(MouseEvent event) { - boolean event_handled = false; - if(!mouseEventsEnabled_) return event_handled; - if (event.getID() == MouseEvent.MOUSE_DRAGGED) { - event_handled = Pane_MouseDrag(event); - } else if(event.getID() == MouseEvent.MOUSE_MOVED) { - event_handled = Pane_MouseMoved(event); - } - return event_handled; - } - - private boolean Pane_MouseClicked(MouseEvent event) { - Object obj; - Rectangle rect; - Selectable savedobj = null; - int mod = event.getModifiers(); - // - // button 1 must be clicked. Modifiers are now allowed! - // - // if(!(((mod & MouseEvent.BUTTON1_MASK) != 0) && - // ((mod - MouseEvent.BUTTON1_MASK) == 0))) return false; - if(!((mod & MouseEvent.BUTTON1_MASK) != 0)) return false; - in_zoom_ = false; - in_select_ = false; -// if(in_move_ && !moved_ && selectedobject_ instanceof Selectable) { - if(!moved_ && selectedobject_ instanceof Selectable) { - if(Debug.DEBUG) System.out.println("MouseClicked (in_move_ && !moved_ && Selectable)"); - // - // second click of selected object de-select - // - if(((Selectable)selectedobject_).isSelected()) { - if(Debug.DEBUG) System.out.println("MouseClicked (isSelected)"); - savedobj = (Selectable)selectedobject_; - // - // remove box - // - Graphics g = pane_.getGraphics(); - if(moveable_) { - g.setColor(Color.red); - } else { - g.setColor(Color.blue); - } - g.setXORMode(pane_.getBackground()); - g.drawRect(selectedRect_.x, selectedRect_.y, - selectedRect_.width, selectedRect_.height); - g.setPaintMode(); - savedobj.setSelected(false); - pane_.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - return false; - } - } - // old_selectedobject_ = selectedobject_; - selectedobject_ = null; - Component[] comps = pane_.getComponents(); - if(comps.length != 0) { - Layer ly; - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - obj = ((Layer)comps[i]).getObjectAt(event.getX(), event.getY()); - if(obj != null) { - selectedobject_ = obj; - break; - } - } else if(comps[i] instanceof Panel) { - obj = ((Panel)comps[i]).getObjectAt(event.getX(), event.getY(), false); - if(obj != null) { - selectedobject_ = obj; - break; - } - } - } - if(selectedobject_ instanceof Selectable) { - if(Debug.DEBUG) System.out.println("MouseClicked (new Selectable)"); - if(!selectedobject_.equals(savedobj) && - ((Selectable)selectedobject_).isSelectable()) { - if(Debug.DEBUG) System.out.println("MouseClicked (new isSelectable)"); - ((Selectable)selectedobject_).setSelected(true); - // - // mouseclick on selectable object select object - // - in_select_ = true; - if(!in_move_) { - if(Debug.DEBUG) System.out.println("MouseClicked (new !in_move_)"); - // - // if in_move_ = true, already have drawn box - // - // - // draw initial box - // - selectedRect_ = new Rectangle(((Selectable)selectedobject_).getBounds()); - Graphics g = pane_.getGraphics(); - if(moveable_) { - g.setColor(Color.red); - } else { - g.setColor(Color.blue); - } - g.setXORMode(pane_.getBackground()); - g.drawRect(selectedRect_.x, selectedRect_.y, - selectedRect_.width, selectedRect_.height); - g.setPaintMode(); - } - in_move_ = false; - changes_.firePropertyChange("objectSelected", - old_selectedobject_, - selectedobject_); - } - } else if(selectedobject_ != null) { - // - // selectedobject is in a Key - // - changes_.firePropertyChange("objectSelected", - old_selectedobject_, - selectedobject_); - } - } - return false; // pass event to next level - } - private boolean Pane_MouseMoved(MouseEvent event) { - if(in_select_) { - if(selectedRect_.contains(event.getX(), event.getY())) { - pane_.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - } else { - pane_.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - return true; - } else { - pane_.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - return false; - } - private boolean Pane_MouseDown(MouseEvent event) { - Object obj; - Selectable savedobj = null; - // - // continue only if button1 is pressed - // - if((event.getModifiers() & InputEvent.BUTTON1_MASK) == 0) return false; - // - // reset logicals - // - - old_zoom_rect_ = new Rectangle(zoom_rect_); - - zoom_rect_.x = 0; - zoom_rect_.y = 0; - zoom_rect_.width = 0; - zoom_rect_.height = 0; - - if(event.isShiftDown()) { - // - // shift mousedown start zoom - // - in_zoom_ = true; - zoom_start_.x = event.getX(); - zoom_start_.y = event.getY(); - zoom_rect_.x = event.getX(); - zoom_rect_.y = event.getY(); - zoom_rect_.width = 1; - zoom_rect_.height = 1; - Graphics g = pane_.getGraphics(); - g.setColor(pane_.getForeground()); - g.setXORMode(pane_.getBackground()); - g.drawRect(zoom_rect_.x, zoom_rect_.y, - zoom_rect_.width, zoom_rect_.height); - g.setPaintMode(); - return true; // handled event here! - } else if(event.isControlDown()) { - // - // control mousedown ends zoom - // - return false; // pass event to next level - } else if(in_select_ && moveable_ && - selectedRect_.contains(event.getX(), event.getY())) { - if(Debug.DEBUG) System.out.println("MouseDown (in_select_ && in Rect)"); - // - // object selected start move operation - // - in_move_ = true; - moved_ = false; - move_ref_ = new Point(event.getX(), event.getY()); - return true; - } else if(in_select_ && !moveable_ && - selectedRect_.contains(event.getX(), event.getY())) { - in_move_ = false; - moved_ = false; - return true; - } else { - // - // object not selected begin move operation - // - if(selectedobject_ instanceof Selectable) - savedobj = (Selectable)selectedobject_; - else - savedobj = null; - selectedobject_ = null; - Component[] comps = pane_.getComponents(); - if(comps.length != 0) { - Layer ly; - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - obj = ((Layer)comps[i]).getObjectAt(event.getX(), event.getY()); - if(obj != null) { - selectedobject_ = obj; - break; - } - } else if(comps[i] instanceof Panel) { - obj = ((Panel)comps[i]).getObjectAt(event.getX(), event.getY(), false); - if(obj != null) { - selectedobject_ = obj; - break; - } - } - } - if(selectedobject_ instanceof Selectable) { - if(Debug.DEBUG) System.out.println("MouseDown (Selectable)"); - // - // found selectable object begin single operation move - // - if(((Selectable)selectedobject_).isSelectable()) { - if(Debug.DEBUG) System.out.println("MouseDown (isSelectable)"); - draggable_ = selectedobject_ instanceof Draggable; - if(selectedobject_ instanceof Moveable) { - moveable_ = ((Moveable)selectedobject_).isMoveable(); - } else { - moveable_ = false; - } - if(moveable_ || draggable_) { - in_move_ = true; - } else { - in_move_ = false; - } - moved_ = false; - if(Debug.DEBUG) System.out.println("MouseDown (isDraggable) " + draggable_); - ((Selectable)selectedobject_).setSelected(false); - selectedRect_ = new Rectangle(((Selectable)selectedobject_).getBounds()); - if(!draggable_ && moveable_) { - // - // draw initial box - // - Graphics g = pane_.getGraphics(); - g.setColor(Color.red); - g.setXORMode(pane_.getBackground()); - g.drawRect(selectedRect_.x, selectedRect_.y, - selectedRect_.width, selectedRect_.height); - g.setPaintMode(); - } - if(!draggable_) pane_.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - move_ref_ = new Point(event.getX(), event.getY()); - return true; - } - } - } - // - // mousedown start zoom if object not found - // - in_zoom_ = true; - zoom_start_.x = event.getX(); - zoom_start_.y = event.getY(); - zoom_rect_.x = event.getX(); - zoom_rect_.y = event.getY(); - zoom_rect_.width = 1; - zoom_rect_.height = 1; - Graphics g = pane_.getGraphics(); - g.setColor(pane_.getForeground()); - g.setXORMode(pane_.getBackground()); - g.drawRect(zoom_rect_.x, zoom_rect_.y, - zoom_rect_.width, zoom_rect_.height); - g.setPaintMode(); - return true; // handled event here! - } - // return false; - } - private boolean Pane_MouseDrag(MouseEvent event) { - boolean handled = false; - // - // continue only if button1 is pressed - // - // if((event.getModifiers() & InputEvent.BUTTON1_MASK) == 0) return handled; - - if(in_zoom_) { - handled = true; - Graphics g = pane_.getGraphics(); - g.setColor(pane_.getForeground()); - g.setXORMode(pane_.getBackground()); - g.drawRect(zoom_rect_.x, zoom_rect_.y, - zoom_rect_.width, zoom_rect_.height); - zoom_rect_.width = event.getX() - zoom_start_.x; - if(zoom_rect_.width < 0) { - zoom_rect_.x = event.getX(); - zoom_rect_.width = Math.abs(zoom_rect_.width); - } else { - zoom_rect_.x = zoom_start_.x; - } - zoom_rect_.height = event.getY() - zoom_start_.y; - if(zoom_rect_.height < 0) { - zoom_rect_.y = event.getY(); - zoom_rect_.height = Math.abs(zoom_rect_.height); - } else { - zoom_rect_.y = zoom_start_.y; - } - g.drawRect(zoom_rect_.x, zoom_rect_.y, - zoom_rect_.width, zoom_rect_.height); - g.setPaintMode(); - } else if(in_move_) { - handled = true; - moved_ = true; - Graphics g = pane_.getGraphics(); - if(!draggable_ && moveable_) { - g.setColor(Color.red); - g.setXORMode(pane_.getBackground()); - g.drawRect(selectedRect_.x, selectedRect_.y, - selectedRect_.width, selectedRect_.height); - } else if(draggable_){ - ((LayerChild)selectedobject_).setVisible(false); - Rectangle rect = ((LayerChild)selectedobject_).getBounds(); - pane_.repaint(rect.x - 1, rect.y - 1, - rect.width + 2, rect.height + 2); - } - selectedRect_.x += event.getX() - move_ref_.x; - selectedRect_.y += event.getY() - move_ref_.y; - if(!draggable_ && moveable_) { - g.drawRect(selectedRect_.x, selectedRect_.y, - selectedRect_.width, selectedRect_.height); - g.setPaintMode(); - } else if(draggable_) { - try { - ((LayerChild)selectedobject_).setVisible(true); - ((Draggable)selectedobject_).setLocation(new - Point(selectedRect_.x, selectedRect_.y), false); - // ((Draggable)selectedobject_).setLocationNoVeto(selectedRect_.x, - // selectedRect_.y); - ((LayerChild)selectedobject_).draw(g); - } catch (LayerNotFoundException e) {} - } - move_ref_ = new Point(event.getX(), event.getY()); - } - return handled; - } - private boolean Pane_MouseUp(MouseEvent event) { - // - // continue only if button1 is pressed - // - if((event.getModifiers() & InputEvent.BUTTON1_MASK) == 0) return false; - - if(in_zoom_) { - // - // finish zoom - // - in_zoom_ = false; - Graphics g = pane_.getGraphics(); - g.setColor(pane_.getForeground()); - g.setXORMode(pane_.getBackground()); - g.drawRect(zoom_rect_.x, zoom_rect_.y, - zoom_rect_.width, zoom_rect_.height); - changes_.firePropertyChange("zoomRectangle", old_zoom_rect_, zoom_rect_); - // if(!event.isShiftDown()) return true; // abort zoom! - return false; // pass event to next level - } else if(in_move_ && moved_) { - if(Debug.DEBUG) System.out.println("MouseUp (in_move_ && moved_)"); - // - // finish move - // - Graphics g = pane_.getGraphics(); - if(!draggable_ && moveable_) { - g.setColor(Color.red); - g.setXORMode(pane_.getBackground()); - g.drawRect(selectedRect_.x, selectedRect_.y, - selectedRect_.width, selectedRect_.height); - g.setPaintMode(); - } - // redraw, but should this only be if actually moved? - if(Debug.DRAW_TRACE)System.out.println("PaneProxy: Pane_MouseUp: calling draw(), batch="+batch_); - Point loc = new Point(selectedRect_.x, selectedRect_.y); - if(draggable_) { - ((Draggable)selectedobject_).setLocation(loc); - paint(g); - } else if(moveable_){ - ((Moveable)selectedobject_).setLocation(loc); - //draw(); - modified_ = true; - pane_.repaint(); - } - in_move_ = false; - in_select_ = false; - moved_ = false; - draggable_ = false; - moveable_ = false; - ((Selectable)selectedobject_).setSelected(false); - pane_.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - return true; - } - return false; - } - Dimension getMaximumSize() { - return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); - } - /** - * Returns the minimum size of this Pane. - * - * @return minimum size - */ - Dimension getMinimumSize() { - return new Dimension(panesize_.width, panesize_.height); - } - /** - * Returns the preferred size of this Pane. - * - * @return preferred size - */ - Dimension getPreferredSize() { - return new Dimension(panesize_.width, panesize_.height); - } - /** - * Get a String representatinof the - * Pane. - * - * @return String representation - */ - public String toString() { - String name = pane_.getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - void setBatch(boolean batch, String msg) { - batch_ = batch; - if(Debug.EVENT) System.out.println("PaneProxy: [" + ident_ + - "] setBatch("+batch_+"): "+msg); - if(!batch_ && modified_) { - /* - * batching turned off and environment has been modified - * re-draw pane() - */ - if(Debug.EVENT) - System.out.println("PaneProxy: [" + ident_ + - "] modified=true, draw(): batch off"); - //draw(); - if(Debug.DRAW_TRACE)System.out.println("PaneProxy: [" + ident_ + - "] setBatch: calling repaint(), batch="+batch_ - +", modified="+modified_); - pane_.repaint(); -// modified_ = false; - } - } - boolean isBatch() { - return batch_; - } - void setIgnoreModified(boolean ig) { - ignoreModified_ = ig; - } - void clearModified() { - modified_ = false; - } - void setModified(boolean mod, String mess) { - if(ignoreModified_) return; - modified_ = mod; - if(Debug.EVENT && batch_) { - System.out.println("PaneProxy: [" + ident_ + - "] setModified("+modified_+"), Batch on: " + mess); - } - if(modified_ && !batch_) { - if(Debug.EVENT) - System.out.println("PaneProxy: [" + ident_ + - "] setModified("+modified_+"), Batch off: " + mess); - //draw(); - if(Debug.DRAW_TRACE)System.out.println("PaneProxy.setModified: calling repaint(), batch="+batch_ - + ", modified="+modified_); - pane_.repaint(); - } - } - boolean isModified() { - return modified_; - } - /** - * @since 3.0 - */ - void setMouseEventsEnabled(boolean enable) { - mouseEventsEnabled_ = enable; - } - /** - * @since 3.0 - */ - boolean isMouseEventsEnabled() { - return mouseEventsEnabled_; - } - /** - * @since 3.0 - */ - void setPageScaleMode(int mode) { - printMode_ = mode; - } - /** - * @since 3.0 - */ - int getPageScaleMode() { - return printMode_; - } - /* - * Pane PropertyChange methods - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PlainAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PlainAxis.java deleted file mode 100755 index 342fe1f6..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PlainAxis.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * $Id: PlainAxis.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.util.Vector; -// jdk1.2 -//import java.awt.geom.Point2D; - -/** - * Axis class for creation of standard "plain" linear axes. An - * {@link SpaceAxis example} is available demonstrating - * PlainAxis use. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - */ -public class PlainAxis extends SpaceAxis implements Cloneable { - static final double TIC_GAP = 0.05; - static final double TIC_RATIO = 1.3; - static final double LABEL_RATIO = 1.1; - /** - * Default constructor for PlainAxis. - **/ - public PlainAxis() { - this(""); - } - /** - * Constructor for Axis. Sets the axis identifier and initializes - * the defaults. - * - * @param id axis identification - **/ - public PlainAxis(String id) { - super(id); - } - public Axis copy() { - PlainAxis newAxis; - try { - newAxis = (PlainAxis)clone(); - } catch (CloneNotSupportedException e) { - newAxis = new PlainAxis(); - } - // - // remove registered axes and transforms - // - newAxis.registeredAxes_ = new Vector(2,2); - newAxis.registeredTransforms_ = new Vector(2,2); - // - return newAxis; - } - // - void draw(Graphics g) { - int xloc, yloc, xend, yend; - int istop, i; - double xt, yt, dir, x, y, xp, yp; - double xtitle, ytitle; - double delta = uRange_.delta; - Format format; - String labelText; - SGLabel title = getTitle(); - if(!visible_) return; - if(Double.isNaN(delta)) delta = (uRange_.end - uRange_.start)/10.0; - if(title != null) title.setLayer(graph_.getLayer()); - // - if(lineColor_ == null) { - g.setColor(graph_.getLayer().getPane().getComponent().getForeground()); - } else { - g.setColor(lineColor_); - } - // - if(labelFormat_.length() <= 0) { - format = new Format(Format.computeFormat(uRange_.start, uRange_.end, sigDigits_)); - } else { - format = new Format(labelFormat_); - } - if(orientation_ == Axis.HORIZONTAL) { - if(uLocation_ == null) { - yloc = graph_.getYUtoD(tLocation_.t); - yp = graph_.getYUtoP(tLocation_.t); - } else { - yloc = graph_.getYUtoD(uLocation_.y); - yp = graph_.getYUtoP(uLocation_.y); - } - xloc = graph_.getXUtoD(uRange_.start); - xend = graph_.getXUtoD(uRange_.end); - g.drawLine(xloc, yloc, xend, yloc); - // - dir = delta > 0? 1.0: -1.0; - xt = ((uRange_.start/delta + (dir*uRange_.start > 0? 1.0: -1.0)*0.00001))*delta; - if(dir*xt < dir*uRange_.start) xt += delta; - istop = (int)((uRange_.end - xt)/delta + 0.00001); - x = xt; - xp = graph_.getXUtoP(x); - drawSmallXTics(g, x, uRange_.start, -delta, yp); - drawXTic(g, xp, yp, largeTicHeight_); - for(i=0; i < istop; i++) { - drawSmallXTics(g, x, uRange_.end, delta, yp); - x += delta; - xp = graph_.getXUtoP(x); - drawXTic(g, xp, yp, largeTicHeight_); - } - drawSmallXTics(g, x, uRange_.end, delta, yp); - // - if(labelInterval_ <= 0 || labelPosition_ == NO_LABEL) return; - // - SGLabel label; - int vertalign; - if(labelPosition_ == POSITIVE_SIDE) { - vertalign = SGLabel.BOTTOM; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yt = yp + TIC_RATIO*largeTicHeight_; - } else { - yt = yp + TIC_GAP; - } - ytitle = yt + LABEL_RATIO*labelHeight_; - } else { - vertalign = SGLabel.TOP; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yt = yp - TIC_RATIO*largeTicHeight_; - } else { - yt = yp - TIC_GAP; - } - ytitle = yt - LABEL_RATIO*labelHeight_; - } - if(dir*uRange_.start <= 0 && dir*uRange_.end >= 0) { - x = ((int)(uRange_.start/(delta*labelInterval_) - 0.00001))*delta*labelInterval_; - } else { - x = xt; - } - istop = (int)((uRange_.end - x)/(delta*labelInterval_) + 0.00001); - for(i=0; i <= istop; i++) { - xt = graph_.getXUtoP(x); - labelText = format.form(x); - label = new SGLabel("coordinate", labelText, new Point2D.Double(xt, yt)); - label.setAlign(vertalign, SGLabel.MIDDLE); - label.setOrientation(SGLabel.HORIZONTAL); - label.setFont(labelFont_); - label.setColor(labelColor_); - label.setHeightP(labelHeight_); - label.setLayer(graph_.getLayer()); - try { - label.draw(g); - } catch (LayerNotFoundException e) {} - x = x + delta*labelInterval_; - } - if(title_ != null) { - xtitle = (uRange_.end + uRange_.start)*0.5; - yt = ytitle; - xt = graph_.getXUtoP(xtitle); - title.setLocationP(new Point2D.Double(xt, yt)); - title.setAlign(vertalign, SGLabel.CENTER); - title.setOrientation(SGLabel.HORIZONTAL); - try { - title.draw(g); - } catch (LayerNotFoundException e) {} - } - } else { // orientation is vertical - if(uLocation_ == null) { - xloc = graph_.getXUtoD(tLocation_.t); - xp = graph_.getXUtoP(tLocation_.t); - } else { - xloc = graph_.getXUtoD(uLocation_.x); - xp = graph_.getXUtoP(uLocation_.x); - } - yloc = graph_.getYUtoD(uRange_.start); - yend = graph_.getYUtoD(uRange_.end); - g.drawLine(xloc, yloc, xloc, yend); - // - dir = delta > 0? 1.0: -1.0; - yt = ((uRange_.start/delta) + (dir*uRange_.start > 0? 1.0: -1.0)*0.00001)*delta; - if(dir*yt < dir*uRange_.start) yt += delta; - istop = (int)((uRange_.end - yt)/delta + 0.00001); - y = yt; - yp = graph_.getYUtoP(y); - drawSmallYTics(g, xp, y, uRange_.start, -delta); - drawYTic(g, xp, yp, largeTicHeight_); - for(i=0; i < istop; i++) { - drawSmallYTics(g, xp, y, uRange_.end, delta); - y += delta; - yp = graph_.getYUtoP(y); - drawYTic(g, xp, yp, largeTicHeight_); - } - drawSmallYTics(g, xp, y, uRange_.end, delta); - // - if(labelInterval_ <= 0 || labelPosition_ == NO_LABEL) return; - // - SGLabel label; - int vertalign; - if(labelPosition_ == NEGATIVE_SIDE) { - vertalign = SGLabel.BOTTOM; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xt = xp - TIC_RATIO*largeTicHeight_; - } else { - xt = xp - TIC_GAP; - } - xtitle = xt - LABEL_RATIO*labelHeight_; - } else { - vertalign = SGLabel.TOP; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xt = xp + TIC_RATIO*largeTicHeight_; - } else { - xt = xp + TIC_GAP; - } - xtitle = xt + LABEL_RATIO*labelHeight_; - } - if(dir*uRange_.start <= 0 && dir*uRange_.end >= 0) { - y = ((int)(uRange_.start/(delta*labelInterval_) - 0.00001))*delta*labelInterval_; - } else { - y = yt; - } - istop = (int)((uRange_.end - y)/(delta*labelInterval_) + 0.00001); - for(i=0; i <= istop; i++) { - yt = graph_.getYUtoP(y); - labelText = format.form(y); - label = new SGLabel("coordinate", labelText, new Point2D.Double(xt, yt)); - label.setAlign(vertalign, SGLabel.CENTER); - label.setOrientation(SGLabel.VERTICAL); - label.setFont(labelFont_); - label.setColor(labelColor_); - label.setHeightP(labelHeight_); - label.setLayer(graph_.getLayer()); - try { - label.draw(g); - } catch (LayerNotFoundException e) {} - y = y + delta*labelInterval_; - } - if(title_ != null) { - ytitle = (uRange_.end + uRange_.start)*0.5; - yt = graph_.getYUtoP(ytitle); - xt = xtitle; - title.setLocationP(new Point2D.Double(xt, yt)); - title.setAlign(vertalign, SGLabel.CENTER); - title.setOrientation(SGLabel.VERTICAL); - try { - title.draw(g); - } catch (LayerNotFoundException e) {} - } - } - } - /** - * Get the bounding box for the axis in device units. - * - * @return bounding box - * @see Rectangle - **/ - public Rectangle getBounds() { - double xp, yp, ymin, ymax, xmin, xmax; - int xd, yd, width, height, x, y; - if(orientation_ == Axis.HORIZONTAL) { - xd = graph_.getXUtoD(uRange_.start); - if(uLocation_ == null) { - yp = graph_.getYUtoP(tLocation_.t); - } else { - yp = graph_.getYUtoP(uLocation_.y); - } - width = graph_.getXUtoD(uRange_.end) - xd; - x = xd; - ymin = yp; - ymax = yp; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - ymax = ymax + largeTicHeight_; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - ymin = ymin - largeTicHeight_; - } - if(labelPosition_ == POSITIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - ymax = ymax + (1.0 -TIC_RATIO)*largeTicHeight_ + labelHeight_; - } else { - ymax = ymax + TIC_GAP + labelHeight_; - } - } else if(labelPosition_ == NEGATIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - ymin = ymin - (1.0 - TIC_RATIO)*largeTicHeight_ - labelHeight_; - } else { - ymin = ymin - TIC_GAP - labelHeight_; - } - } - y = graph_.getLayer().getYPtoD(ymax); - height = graph_.getLayer().getYPtoD(ymin) - y; - } else { - yd = graph_.getYUtoD(uRange_.start); - if(uLocation_ == null) { - xp = graph_.getXUtoP(tLocation_.t); - } else { - xp = graph_.getXUtoP(uLocation_.x); - } - y = graph_.getYUtoD(uRange_.end); - height = yd - y; - xmin = xp; - xmax = xp; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xmax = xmax + largeTicHeight_; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xmin = xmin - largeTicHeight_; - } - if(labelPosition_ == POSITIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xmax = xmax + (1.0 -TIC_RATIO)*largeTicHeight_ + labelHeight_; - } else { - xmax = xmax + TIC_GAP + labelHeight_; - } - } else if(labelPosition_ == NEGATIVE_SIDE) { - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xmin = xmin - (1.0 - TIC_RATIO)*largeTicHeight_ - labelHeight_; - } else { - xmin = xmin - TIC_GAP - labelHeight_; - } - } - x = graph_.getLayer().getXPtoD(xmin); - width = graph_.getLayer().getXPtoD(xmax) - x; - } - return new Rectangle(x, y, width, height); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PlotMark.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PlotMark.java deleted file mode 100755 index e0d5bf39..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PlotMark.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * $Id: PlotMark.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.Component; -import java.awt.Graphics; -import java.awt.BorderLayout; -import java.awt.FontMetrics; -import java.awt.Font; -import java.awt.Color; - -import javax.swing.*; - -import gov.noaa.pmel.util.Dimension2D; - -/** - * Support class used to draw a PlotMark. Plot mark codes are defined - * in the following table.
- * - *

- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.0 - * @see PointCartesianRenderer - * @see gov.noaa.pmel.sgt.swing.PlotMarkIcon - */ -public class PlotMark { - protected int mark_; - protected int tableSize_ = 51; - protected int firstPoint_; - protected int lastPoint_; - protected double markHeight_; - protected int fillMark_ = 44; - protected boolean fill_ = false; - protected boolean circle_ = false; - - protected static final int[][] markTable - = {{ 5, 9}, { 11, 15}, { 14, 15}, { 11, 12}, // 0 - { 26, 31}, { 32, 37}, { 38, 43}, { 44, 49}, // 4 - { 1, 5}, { 64, 67}, { 5, 15}, { 50, 54}, // 8 - { 1, 9}, { 55, 63}, { 15, 19}, { 21, 25}, // 12 - { 50, 53}, { 51, 54}, { 72, 77}, { 84, 98}, // 16 - { 18, 22}, { 11, 19}, { 64, 66}, { 68, 71}, // 20 - { 68, 70}, { 78, 83}, {102, 106}, {113, 118}, // 24 - {119, 124}, {125, 130}, {131, 136}, {105, 110}, // 28 - {107, 112}, {137, 139}, { 99, 106}, {103, 108}, // 32 - {140, 144}, {140, 147}, {156, 163}, {148, 155}, // 36 - {170, 183}, {184, 189}, {188, 193}, {164, 169}, // 40 - { 1, 5}, { 64, 67}, { 55, 63}, { 15, 19}, // 44 - { 68, 71}, {164, 169}, {164, 169}}; // 48 - - - protected static final int[] table - = { 9, 41, 45, 13, 9, 45, 0, 13, 41, 0, // 0 - 25, 29, 0, 11, 43, 29, 11, 25, 43, 11, // 10 - 25, 29, 11, 43, 29, 18, 27, 34, 0, 27, // 20 - 24, 20, 27, 36, 0, 27, 30, 20, 27, 18, // 30 - 0, 3, 27, 36, 27, 34, 0, 27, 51, 41, // 40 - 13, 45, 9, 41, 4, 2, 16, 32, 50, 52, // 50 - 38, 22, 4, 9, 29, 41, 9, 13, 25, 45, // 60 - 13, 13, 27, 31, 0, 27, 45, 9, 27, 29, // 70 - 0, 27, 41, 13, 20, 18, 9, 0, 18, 34, // 80 - 0, 20, 36, 0, 45, 36, 34, 41, 19, 35, // 90 - 0, 21, 17, 33, 37, 21, 19, 35, 33, 17, // 100 - 21, 37, 20, 29, 25, 0, 17, 33, 21, 37, // 110 - 35, 19, 17, 33, 21, 37, 19, 35, 33, 17, // 120 - 21, 19, 43, 0, 37, 33, 21, 37, 25, 12, // 130 - 44, 0, 42, 10, 0, 17, 37, 26, 30, 0, // 140 - 12, 44, 0, 8, 40, 13, 45, 0, 43, 11, // 150 - 0, 9, 41, 4, 41, 30, 9, 52, 4, 12, // 160 - 20, 21, 13, 12, 0, 9, 45, 0, 33, 41, // 170 - 42, 34, 33, 14, 44, 10, 0, 9, 41, 0, // 180 - 42, 12, 46, 0, 0, 0, 0, 0, 0, 0}; // 190 - - /** - * Construct a PlotMark using the code and height from the - * LineAttribute. - */ - public PlotMark(LineAttribute attr) { - setLineAttribute(attr); - } - /** - * Construct a PlotMark using the code and height from the - * PointAttribute. - */ - public PlotMark(PointAttribute attr) { - setPointAttribute(attr); - } - /** - * Construct a PlotMark using the code from the - * mark code. Default height = 0.08. - */ - public PlotMark(int mark) { - setMark(mark); - markHeight_ = 0.08; - } - /** - * Set the mark and height from the PointAttribute. - */ - public void setPointAttribute(PointAttribute attr) { - int mark = attr.getMark(); - setMark(mark); - markHeight_ = attr.getMarkHeightP()/8.0; - } - /** - * Set the mark and height from the LineAttribute. - */ - public void setLineAttribute(LineAttribute attr) { - int mark = attr.getMark(); - setMark(mark); - markHeight_ = attr.getMarkHeightP()/8.0; - } - /** - * Set the mark. - */ - public void setMark(int mark) { - if(mark <= 0) mark = 0; - fill_ = mark > fillMark_; - circle_ = mark >= 50; - if(circle_) fill_ = mark == 51; - if(mark > tableSize_) mark = tableSize_; - firstPoint_ = markTable[mark-1][0]-1; - lastPoint_ = markTable[mark-1][1]; - mark_ = mark; - } - /** - * Get the mark code. - */ - public int getMark() { - return mark_; - } - /** - * Set the mark height. - */ - public void setMarkHeightP(double mHeight) { - markHeight_ = mHeight/8.0; - } - /** - * Get the mark height - */ - public double getMarkHeightP() { - return markHeight_*8.0; - } - /** - * Used internally by sgt. - */ - public void paintMark(Graphics g, Layer ly, int xp, int yp) { - int count, ib; - int xdOld = 0, ydOld = 0; - int movex, movey; - int xt, yt; - double xscl = ly.getXSlope()*markHeight_; - double yscl = ly.getYSlope()*markHeight_; - - if(circle_) { - xt = (int)(xscl*-2) + xp; - yt = (int)(xscl*-2) + yp; - int w = (int)(xscl*4.0) - 1; - if(fill_) { - g.fillOval(xt, yt, w, w); - } else { - g.drawOval(xt, yt, w, w); - } - return; - } - - int[] xl = new int[lastPoint_-firstPoint_]; - int[] yl = new int[lastPoint_-firstPoint_]; - - boolean penf = false; - int i=0; - for(count = firstPoint_; count < lastPoint_; count++) { - ib = table[count]; - if(ib == 0) { - penf = false; - } else { - movex = (ib>>3) - 3; - movey = -((ib&7) - 3); - - xt = (int)(xscl*(double)movex) + xp; - yt = (int)(yscl*(double)movey) + yp; - - if(penf) { - if(fill_) { - xl[i] = xt; - yl[i] = yt; - i++; - } else { - g.drawLine(xdOld, ydOld, xt, yt); - } - } - penf = true; - xdOld = xt; - ydOld = yt; - } - if(fill_) g.fillPolygon(xl, yl, i); - } - } - - public static void main(String[] args) { - /** - * hack code to create a "list" of plot marks. - */ - JFrame frame = new JFrame("Plot Marks"); - frame.getContentPane().setLayout(new BorderLayout()); - frame.setSize(500, 700); - JPane pane = new JPane("Plot Mark Pane", frame.getSize()); - Layer layer = new Layer("Plot Mark Layer", new Dimension2D(5.0, 7.0)); - pane.setBatch(true); - pane.setLayout(new StackedLayout()); - frame.getContentPane().add(pane, BorderLayout.CENTER); - pane.add(layer); - frame.setVisible(true); - pane.setBatch(false); - PlotMark pm = new PlotMark(1); - Graphics g = pane.getGraphics(); - g.setFont(new Font("Helvetica", Font.PLAIN, 18)); - pm.setMarkHeightP(0.32); - int w = pane.getSize().width; - int h = pane.getSize().height; - g.setColor(Color.white); - g.fillRect(0, 0, w, h); - g.setColor(Color.black); - FontMetrics fm = g.getFontMetrics(); - int hgt = fm.getAscent()/2; - String label; - int xt = 100; - int yt = 400; - int wid = 0; - int mark = 1; - for(int j=0; j < 13; j++) { - yt = 45*j + 100; - for(int i=0; i < 4; i++) { - xt = 120*i + 75; - label = mark + ":"; - wid = fm.stringWidth(label) + 20; - g.setColor(Color.blue.brighter()); - g.drawString(label, xt - wid, yt); - pm.setMark(mark); - g.setColor(Color.black); - pm.paintMark(g, layer, xt, yt - hgt); - mark++; - if(mark > 51) break; - } - } - } - - public String toString() { - return "PlotMark: " + mark_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointAttribute.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointAttribute.java deleted file mode 100755 index 6de3e6e3..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointAttribute.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * $Id: PointAttribute.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * Set the rendereing style for point data. - * Color, width, and mark type are - * PointAttribute properties. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - * @see CartesianGraph - * @see PointCartesianRenderer - * @see PlotMark - */ -public class PointAttribute implements Attribute, Cloneable { - private transient PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - // serial version ref 1.10.2.2 - private static final long serialVersionUID = -1147362012307247472L; - private boolean batch_ = false; - private boolean local_ = true; - private boolean modified_ = false; - private String id_ = ""; - private Color color_; - private int mark_; - private double markHeightP_; - private double pwidth_; - // - private boolean drawLabel_ = false; - private int labelPosition_; - private Font labelFont_ = null; - private Color labelColor_ = null; - private double labelHeightP_; - /** - * Position label over the point - */ - public static final int CENTERED = 0; - /** - * Position label north of the point - */ - public static final int N = 1; - /** - * Position label northeast of the point - */ - public static final int NE = 2; - /** - * Position label east of the point - */ - public static final int E = 3; - /** - * Position label southeast of the point - */ - public static final int SE = 4; - /** - * Position label south of the point - */ - public static final int S = 5; - /** - * Position label southwest of the point - */ - public static final int SW = 6; - /** - * Position label west of the point - */ - public static final int W = 7; - /** - * Position label northwest of the point - */ - public static final int NW = 8; - /** - * Default constructor. Default mark is 2 and - * default color is red. - **/ - public PointAttribute() { - this(2, Color.red); -} - /** - * Constructor for plot marks. - * - * @param mark plot mark - * @param color Point color - * @see PlotMark - **/ - public PointAttribute(int mark, Color color) { - mark_ = mark; - color_ = color; - markHeightP_ = 0.1; - labelHeightP_ = 0.1; - labelColor_ = Color.black; - drawLabel_ = false; - } - /** - * Copy the PointAttribute. - * - * @return new PointAttribute - */ - public PointAttribute copy() { - PointAttribute newPoint; - try { - newPoint = (PointAttribute)clone(); - } catch (CloneNotSupportedException e) { - newPoint = new PointAttribute(); - } - return newPoint; - } - /** - * @since 3.0 - */ - public boolean equals(Object obj) { - if(obj == null || !(obj instanceof PointAttribute)) return false; - PointAttribute attr = (PointAttribute)obj; - if((!id_.equals(attr.getId())) || - (!color_.equals(attr.getColor())) || - (mark_ != attr.getMark()) || - (markHeightP_ != attr.getMarkHeightP()) || - (pwidth_ != attr.getWidthP()) || - (drawLabel_ != attr.isDrawLabel())) return false; - if(drawLabel_) { - if(labelFont_ == null) { - if(attr.getLabelFont() != null) return false; - } else { - if(attr.getLabelFont() == null) return false; - if(!labelFont_.equals(attr.getLabelFont())) return false; - } - if(labelColor_ == null) { - if(attr.getLabelColor() != null) return false; - } else { - if(attr.getLabelColor() == null) return false; - if(!labelColor_.equals(attr.getLabelColor())) return false; - } - if((labelPosition_ != attr.getLabelPosition()) || - (labelHeightP_ != attr.getLabelHeightP())) return false; - } - return true; - } - /** - * Set mark height. - *
Property Change: markHeightP. - * - * @param markh mark height - **/ - public void setMarkHeightP(double markh) { - if(markHeightP_ != markh) { - Double tempOld = new Double(markHeightP_); - markHeightP_ = markh; - firePropertyChange("markHeightP", - tempOld, - new Double(markHeightP_)); - } - } - /** - * Get mark height - * - * @return mark height - **/ - public double getMarkHeightP() { - return markHeightP_; - } - /** - * Set the point Color. - *
Property Change: color. - * - * @param c point Color - **/ - public void setColor(Color c) { - if(!color_.equals(c)) { - Color tempOld = color_; - color_ = c; - firePropertyChange("color", - tempOld, - color_); - } - } - /** - * Set the Point width in physical units. - *
Property Change: widthP. - * - * @param t Point width - **/ - public void setWidthP(double t) { - if(pwidth_ != t) { - Double tempOld = new Double(pwidth_); - pwidth_ = t; - firePropertyChange("widthP", - tempOld, - new Double(pwidth_)); - } - } - /** - * Get Point Color. - * - * @return Point Color - **/ - public Color getColor() { - return color_; - } - /** - * Get Point width. - * - * @return Point width in physcial coordinates. - **/ - public double getWidthP() { - return pwidth_; - } - /** - * Set plot mark - *
Property Change: mark. - * - * @param mark the plot mark - * @see PlotMark - **/ - public void setMark(int mark) { - if(mark_ != mark) { - Integer tempOld = new Integer(mark_); - mark_ = mark; - firePropertyChange("mark", - tempOld, - new Integer(mark_)); - } - } - /** - * Get plot mark - * - * @return plot mark - * @see PlotMark - **/ - public int getMark() { - return mark_; - } - /** - * Set label position. - *
Property Change: labelPosition. - */ - public void setLabelPosition(int pos) { - if(labelPosition_ != pos) { - Integer tempOld = new Integer(labelPosition_); - labelPosition_ = pos; - firePropertyChange("labelPosition", - tempOld, - new Integer(labelPosition_)); - } - } - /** - * Get label position. - */ - public int getLabelPosition() { - return labelPosition_; - } - /** - * Set label Color. - *
Property Change: labelColor. - */ - public void setLabelColor(Color col) { - if(labelColor_ == null || !labelColor_.equals(col)) { - Color tempOld = labelColor_; - labelColor_ = col; - firePropertyChange("labelColor", - tempOld, - labelColor_); - } - } - /** - * Get label Color. - */ - public Color getLabelColor() { - return labelColor_; - } - /** - * Set label Font. - *
Property Change: labelFont. - */ - public void setLabelFont(Font font) { - if(labelFont_ == null || !labelFont_.equals(font)) { - Font tempOld = labelFont_; - labelFont_ = font; - firePropertyChange("labelFont", - tempOld, - labelFont_); - } - } - /** - * Get label Font. - */ - public Font getLabelFont() { - return labelFont_; - } - /** - * Set label height. - *
Property Change: labelHeightP. - */ - public void setLabelHeightP(double h) { - if(labelHeightP_ != h) { - Double tempOld = new Double(labelHeightP_); - labelHeightP_ = h; - firePropertyChange("labelHeightP", - tempOld, - new Double(labelHeightP_)); - } - } - /** - * Get label height. - */ - public double getLabelHeightP() { - return labelHeightP_; - } - /** - * Set label drawing. - *
Property Change: drawLabel. - */ - public void setDrawLabel(boolean dl) { - if(drawLabel_ != dl) { - Boolean tempOld = new Boolean(drawLabel_); - drawLabel_ = dl; - firePropertyChange("drawLabel", - tempOld, - new Boolean(drawLabel_)); - } - } - /** - * Is label drawing on? - */ - public boolean isDrawLabel() { - return drawLabel_; - } - /** - * Get a String representation of the - * PointAttribute. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1); - } - /** - * Add listener to changes in PointAttribute properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.addPropertyChangeListener(listener); - } - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } - /** - * @since 3.0 - */ - public void setId(String id) { - id_ = id; - } - /** - * @since 3.0 - */ - public String getId() { - return id_; - } - - protected void firePropertyChange(String name, Object oldValue, Object newValue) { - if(batch_) { - modified_ = true; - return; - } - AttributeChangeEvent ace = new AttributeChangeEvent(this, name, - oldValue, newValue, - local_); - changes_.firePropertyChange(ace); - modified_ = false; - } - /** - * @since 3.0 - */ - public void setBatch(boolean batch) { - setBatch(batch, true); - } - /** - * @since 3.0 - */ - public void setBatch(boolean batch, boolean local) { - batch_ = batch; - local_ = local; - if(!batch && modified_) firePropertyChange("batch", Boolean.TRUE, Boolean.FALSE); - } - /** - * @since 3.0 - */ - public boolean isBatch() { - return batch_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointCartesianRenderer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointCartesianRenderer.java deleted file mode 100755 index 47489ad9..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointCartesianRenderer.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * $Id: PointCartesianRenderer.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTPoint; -import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.dm.SGTData; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Event; -import java.awt.Point; -import java.awt.Color; -import java.awt.Rectangle; -import java.beans.PropertyChangeEvent; - -/** - * Produces a point plot with optional coloring from a second data set. If - * a second data set is specified it must have the same shape as the first. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.0 - */ -public class PointCartesianRenderer extends CartesianRenderer { - /**@shapeType AggregationLink - * @label attr - * @supplierCardinality 1 - * @undirected */ - private PointAttribute attr_ = null; - /**@shapeType AggregationLink - * @supplierCardinality 0..1 - * @label point - * @undirected */ - private SGTPoint point_ = null; - /**@shapeType AggregationLink - * @supplierCardinality 0..1 */ - private Collection collection_ = null; - - /** - * Get the Attribute associated with the data. - */ - public Attribute getAttribute() { - return attr_; - } - private void drawPoint(Graphics g, SGTPoint point, PlotMark pm) { - int xp, yp; - - if(pm.getMark() == 0) return; - - if(point.isXTime()) { - xp = cg_.getXUtoD(point.getLongTime()); - } else { - xp = cg_.getXUtoD(point.getX()); - } - if(point.isYTime()) { - yp = cg_.getYUtoD(point.getLongTime()); - } else { - yp = cg_.getYUtoD(point.getY()); - } - // - // check for missing values a Double.NaN is converted to a Integer.MIN_VALUE - // - if(xp == Integer.MIN_VALUE || yp == Integer.MIN_VALUE) { - return; - } - // - // draw regular point - // - pm.paintMark(g, cg_.getLayer(), xp, yp); - } - private void drawLabel(Graphics g, SGTPoint point, PointAttribute attr) { - int valign, halign; - Point2D.Double loc; - double xp, yp; - double xl, yl, loff; - Layer ly = cg_.getLayer(); - - if(point.isXTime()) { - xp = cg_.getXUtoP(point.getLongTime()); - } else { - xp = cg_.getXUtoP(point.getX()); - } - if(point.isYTime()) { - yp = cg_.getYUtoP(point.getLongTime()); - } else { - yp = cg_.getYUtoP(point.getY()); - } - - loff = attr.getMarkHeightP()/2.0; - xl = 0.0; - yl = 0.0; - switch(attr.getLabelPosition()) { - case PointAttribute.CENTERED: - valign = SGLabel.MIDDLE; - halign = SGLabel.CENTER; - break; - case PointAttribute.N: - valign = SGLabel.BOTTOM; - halign = SGLabel.CENTER; - yl = loff; - break; - default: - case PointAttribute.NE: - valign = SGLabel.BOTTOM; - halign = SGLabel.LEFT; - yl = loff; - xl = loff; - break; - case PointAttribute.E: - valign = SGLabel.MIDDLE; - halign = SGLabel.LEFT; - xl = loff; - break; - case PointAttribute.SE: - valign = SGLabel.TOP; - halign = SGLabel.LEFT; - yl = -loff; - xl = loff; - break; - case PointAttribute.S: - valign = SGLabel.TOP; - halign = SGLabel.CENTER; - yl = -loff; - break; - case PointAttribute.SW: - valign = SGLabel.TOP; - halign = SGLabel.RIGHT; - yl = -loff; - xl = -loff; - break; - case PointAttribute.W: - valign = SGLabel.MIDDLE; - halign = SGLabel.RIGHT; - xl = -loff; - break; - case PointAttribute.NW: - valign = SGLabel.BOTTOM; - halign = SGLabel.RIGHT; - yl = loff; - xl = -loff; - break; - } - SGLabel pl = new SGLabel("point", - point.getTitle(), - attr.getLabelHeightP(), - new Point2D.Double(xp + xl, yp + yl), - valign, - halign); - pl.setColor(attr.getLabelColor()); - pl.setFont(attr.getLabelFont()); - pl.setLayer(ly); - try { - pl.draw(g); - } catch (LayerNotFoundException e) {} - - } - /** - * Default constructor. - * - * @see CartesianGraph - * @see Graph - **/ - public PointCartesianRenderer(CartesianGraph cg) { - this(cg, (SGTPoint)null, null); - } - /** - * Construct a PointCartesianRenderer. The default - * PointAttribute will be used. - * - * @param cg the parent CartesianGraph - * @param data an SGTPoint object - * - * @see CartesianGraph - * @see Graph - **/ - public PointCartesianRenderer(CartesianGraph cg, SGTPoint point) { - this(cg, point, null); - cg_ = cg; - point_ = point; - } - /** - * Construct a PointCartesianRenderer. - * - * @param cg the parent CartesianGraph - * @param data an SGTPoint object - * @param Point the PointAttribute - * @see CartesianGraph - * @see Graph - **/ - public PointCartesianRenderer(CartesianGraph cg, SGTPoint point, PointAttribute attr) { - cg_ = cg; - point_ = point; - attr_ = attr; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - /** - * Construct a PointCartesianRenderer. - * - * @param cg the parent CartesianGraph - * @param col a Collection of SGTPoint objects - * @param point the PointAttribute - * @see CartesianGraph - * @see Graph - **/ - public PointCartesianRenderer(CartesianGraph cg, Collection col, PointAttribute attr) { - cg_ = cg; - collection_ = col; - attr_ = attr; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - public void draw(Graphics g) { - PointAttribute attr; - Object point; - PlotMark pm; - - if(cg_.clipping_) { - int xmin, xmax, ymin, ymax; - int x, y, width, height; - if(cg_.xTransform_.isSpace()) { - xmin = cg_.getXUtoD(cg_.xClipRange_.start); - xmax = cg_.getXUtoD(cg_.xClipRange_.end); - } else { - xmin = cg_.getXUtoD(cg_.tClipRange_.start); - xmax = cg_.getXUtoD(cg_.tClipRange_.end); - } - if(cg_.yTransform_.isSpace()) { - ymin = cg_.getYUtoD(cg_.yClipRange_.start); - ymax = cg_.getYUtoD(cg_.yClipRange_.end); - } else { - ymin = cg_.getYUtoD(cg_.tClipRange_.start); - ymax = cg_.getYUtoD(cg_.tClipRange_.end); - } - if(xmin < xmax) { - x = xmin; - width = xmax - xmin; - } else { - x=xmax; - width = xmin - xmax; - } - if(ymin < ymax) { - y = ymin; - height = ymax - ymin; - } else { - y = ymax; - height = ymin - ymax; - } - g.setClip(x, y, width, height); - } - if(attr_ == null) { - attr = new PointAttribute(2, - cg_.layer_.getPane().getComponent().getForeground()); - } else { - attr = attr_; - } - pm = new PlotMark(attr); - if(collection_ == null) { - g.setColor(attr.getColor()); - drawPoint(g, point_, pm); - if(attr.isDrawLabel()) drawLabel(g, point_, attr); - } else { - for(Enumeration li = collection_.elements(); li.hasMoreElements();) { - point = li.nextElement(); - if(point instanceof SGTPoint) { - g.setColor(attr.getColor()); - drawPoint(g, (SGTPoint)point, pm); - if(attr.isDrawLabel()) drawLabel(g, (SGTPoint)point, attr); - } - } - } - - // - // reset clip - // - Rectangle rect = cg_.getLayer().getPane().getBounds(); - g.setClip(rect); - } - /** - * Set the Point attribute object. The Point appearance is controlled by - * this object. - * - * @param l Point attribute - **/ - public void setPointAttribute(PointAttribute l) { - if(attr_ != null) attr_.removePropertyChangeListener(this); - attr_ = l; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - /** - * Get the Point attribute object. - * - * @return Point attribute - **/ - public PointAttribute getPointAttribute() { - return attr_; - } - /** - * Is point data as a collection? - */ - public boolean hasCollection() { - return (collection_ != null); - } - /** - * Get the Collection of points. - */ - public Collection getCollection() { - return collection_; - } - public SGTPoint getPoint() { - return point_; - } - /** - * Get the associated CartesianGraph object. - * - * @return CartesianGraph - */ - public CartesianGraph getCartesianGraph() { - return cg_; - } - - public void propertyChange(PropertyChangeEvent evt) { -// if(Debug.EVENT) { -// System.out.println("PointCartesianRenderer: " + evt); -// System.out.println(" " + evt.getPropertyName()); -// } - modified("PointCartesianRenderer: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - /** - * @since 3.0 - */ - public SGTData getDataAt(Point pt) { - return null; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointCollectionKey.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointCollectionKey.java deleted file mode 100755 index 5c179f0a..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PointCollectionKey.java +++ /dev/null @@ -1,733 +0,0 @@ -/* - * $Id: PointCollectionKey.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Debug; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Point; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeSupport; - -// jdk1.2 -//import java.awt.geom.Point2D; - -/** - * PointCollectionKey is used to create a key for the - * PointCartesianRenderer. Multiple - * lines can be included in the key. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.0 -**/ -public class PointCollectionKey implements Cloneable, - DataKey, Moveable, PropertyChangeListener { - private String ident_; -/** @directed */ - private Layer layer_; - private Vector points_; - private Vector label_; - private int columns_; - private int style_; - private int valign_; - private int halign_; - private Point2D.Double porigin_; - private double lineLengthP_; - private int maxLabelLength_; - private int maxLabelHeight_; - private boolean selected_; - private boolean selectable_; - private boolean visible_; - private boolean moveable_; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private static final int VERTICAL_BORDER_ = 3; - private static final int HORIZONTAL_BORDER_ = 15; - private static final int COLUMN_SPACE_ = 10; - private static final int ROW_SPACE_ = 3; - private static final int LABEL_SPACE_ = 15; - /** - * Use plain line border. - */ - public static final int PLAIN_LINE = 0; - /** - * Use raised border. - */ - public static final int RAISED = 1; - /** - * Do not draw a border. - */ - public static final int NO_BORDER = 2; - /** - * Align to top of key. - */ - public static final int TOP = 0; - /** - * Align to middle of key. - */ - public static final int MIDDLE = 1; - /** - * Align to bottom of key. - */ - public static final int BOTTOM = 2; - /** - * Align to left of key. - */ - public static final int LEFT = 0; - /** - * Align to center of key. - */ - public static final int CENTER = 1; - /** - * Align to right of key. - */ - public static final int RIGHT = 2; - - /** - * @link aggregation - * @supplierCardinality * - * @label points - */ - /*#PointCartesianRenderer lnkPointCartesianRenderer;*/ - - /** @link aggregation - * @label label - * @supplierCardinality **/ - /*#SGLabel lnkSGLabel;*/ - - /** - * Default constructor. - */ - public PointCollectionKey() { - this(new Point2D.Double(0.0, 0.0), BOTTOM, LEFT); - } - /** - * Create PointCollectionKey. - */ - public PointCollectionKey(Point2D.Double loc,int valign,int halign) { - porigin_ = loc; - valign_ = valign; - halign_ = halign; - points_ = new Vector(2,2); - label_ = new Vector(2,2); - // - // set defaults - // - style_ = PLAIN_LINE; - columns_ = 1; - ident_ = ""; - lineLengthP_ = 0.3f; - selected_ = false; - selectable_ = true; - visible_ = true; - moveable_ = true; - } - /** - * Create of copy of PointCollectionKey. - */ - public LayerChild copy() { - PointCollectionKey newKey; - try { - newKey = (PointCollectionKey)clone(); - } catch (CloneNotSupportedException e) { - newKey = new PointCollectionKey(); - } - newKey.points_ = new Vector(2,2); - newKey.label_ = new Vector(2,2); - return newKey; - } - public void setSelected(boolean sel) { - selected_ = sel; - } - public boolean isSelected() { - return selected_; - } - public void setSelectable(boolean select) { - selectable_ = select; - } - public boolean isSelectable() { - return selectable_; - } - public boolean isMoveable() { - return moveable_; - } - public void setMoveable(boolean moveable) { - moveable_ = moveable; - } - /** - * Set parent layer. - * - * @param l parent layer - */ - public void setLayer(Layer l) { - layer_ = l; - } - /** - * Get layer. - * - * @return layer - */ - public Layer getLayer() { - return layer_; - } - - public AbstractPane getPane() { - return layer_.getPane(); - } - - public void modified(String mess) { - if(layer_ != null) - layer_.modified(mess); - } - /** - * Set PointCollectionKey identifier. - * - * @param id key identifier - */ - public void setId(String id) { - ident_ = id; - } - /** - * Get PointCollectionKey identifier - * - * @return identifier - */ - public String getId() { - return ident_; - } - /** - * Set line length. - * - * @param len line length - */ - public void setLineLengthP(double len) { - if(lineLengthP_ != len) { - lineLengthP_ = len; - modified("PointCollectionKey: setLineLengthP()"); - } - } - /** - * Get line length - * - * @return line length - */ - public double getLineLengthP() { - return lineLengthP_; - } - /** - * Set the number of columns. - * - * @param col number of columns - */ - public void setColumns(int col) { - if(columns_ != col) { - columns_ = col; - modified("PointCollectionKey: setColumms()"); - } - } - /** - * Get the number of columns. - * - * @return number of columns - */ - public int getColumns() { - return columns_; - } - /** - * Set border style. - * - * @param style border style - * @see #PLAIN_LINE - * @see #RAISED - * @see #NO_BORDER - */ - public void setBorderStyle(int style) { - if(style_ != style) { - style_ = style; - modified("PointCollectionKey: setBorderStyle()"); - } - } - /** - * Get border style. - * - * @return border style - */ - public int getBorderStyle() { - return style_; - } - /** - * Set alignment. - * - * @param vert vertical alignment - * @param horz horizontal alignment - */ - public void setAlign(int vert,int horz) { - if(valign_ != vert || halign_ != horz) { - valign_ = vert; - halign_ = horz; - modified("PointCollectionKey: setAlign()"); - } - } - /** - * Set vertical alignment - * - * @param vert vertical alignment - */ - public void setVAlign(int vert) { - if(valign_ != vert) { - valign_ = vert; - modified("PointCollectionKey: setVAlign()"); - } - } - /** - * Set horizontal alignment - * - * @param horz horizontal alignment - */ - public void setHAlign(int horz) { - if(halign_ != horz) { - halign_ = horz; - modified("PointCollectionKey: setHAlign()"); - } - } - /** - * Get vertical alignment - * - * @return vertical alignment - */ - public int getVAlign() { - return valign_; - } - /** - * Get horizontal alignment - * - * @return horizontal alignment - */ - public int getHAlign() { - return halign_; - } - /** - * Set location of key - *
Property Change: location. - * - * @param loc key location - */ - public void setLocationP(Point2D.Double loc) { - if(porigin_ == null || !porigin_.equals(loc)) { - Point2D.Double temp = porigin_; - porigin_ = loc; - changes_.firePropertyChange("location", - temp, - porigin_); - modified("PointCollectionKey: setLocationP()"); - } - } - /** - * Set the bounds, in physical units, of the PointCollectionKey - */ - public void setBoundsP(Rectangle2D.Double r) { - setLocationP(new Point2D.Double(r.x, r.y)); - } - public Rectangle2D.Double getBoundsP() { - throw new MethodNotImplementedError(); - } - /** - * Get location of key. - * - * @return Key location - */ - public Point2D.Double getLocationP() { - return porigin_; - } - /** - * Add a PointCartesianRenderer and label to the PointCollectionKey. - * - * @param line PointCartesianRenderer object - * @param label descriptive label - */ - public void addPointGraph(PointCartesianRenderer points, SGLabel label) { - points_.addElement(points); - label.setLayer(layer_); - label.setMoveable(false); - label.setSelectable(false); - label_.addElement(label); - ((PointAttribute)points.getAttribute()).addPropertyChangeListener(this); - modified("PointCollectionKey: addPointGraph()"); - } - /** - * Add a PointCartesianRenderer and label to the PointCollectionKey. - * - * @param rend CartesianRenderer object - * @param label descriptive label - * @since 3.0 - */ - public void addGraph(CartesianRenderer rend, SGLabel label) - throws IllegalArgumentException { - if(!(rend instanceof PointCartesianRenderer)) - throw new IllegalArgumentException("Renderer is not a PointCartesianRenderer"); - addPointGraph((PointCartesianRenderer)rend, label); - } - /** - * Remove a line from the PointCollectionKey. - * - */ - public void removePointGraph(SGLabel label) { - } - /** - * Remove a line from the PointCollectionKey. - * - */ - public void removePointRenderer(PointCartesianRenderer line) { - } - /** - * Remove a line from the PointCollectionKey. - * - */ - public void removePointGraph(String ident) { - } - /** - * Remove all lines from the PointCollectionKey. - */ - public void clearAll() { - PointAttribute attr; - for(Enumeration e = points_.elements(); e.hasMoreElements(); ) { - attr = (PointAttribute)((PointCartesianRenderer)e.nextElement()).getAttribute(); - attr.removePropertyChangeListener(this); - } - points_.removeAllElements(); - label_.removeAllElements(); - modified("PointCollectionKey: clearAll()"); - } - /** - * Remove data from key by id. - */ - public void clear(String data_id) { - PointCartesianRenderer pcr; - int indx = -1; - for(Enumeration it = points_.elements(); it.hasMoreElements();) { - indx++; - pcr = (PointCartesianRenderer)it.nextElement(); -// if(pcr.getLine().getId().equals(data_id)) { -// pcr.getAttribute().removePropertyChangeListener(this); -// points_.removeElement(lcr); -// label_.removeElementAt(indx); -// modified("PointCollectionKey: clear()"); -// break; -// } - } - } - /** - * Return height of key row in pixels. - */ - public int getRowHeight() { - Rectangle bounds; - bounds = getBounds(); - return ROW_SPACE_ + maxLabelHeight_; - } - /** - * Draw the Key. - */ - public void draw(Graphics g) { - double maxLabelLength, maxLabelHeight; - int numLines, numRows, i, lineLength; - int col, row, ytemp; - double xloc, labelSpace; - double[] xp, yp; - int[] xd, yd; - int[] xout, yout; - Rectangle bounds; - PointCartesianRenderer render = null; - SGLabel label; - PointAttribute attr = null; - // - numLines = points_.size(); - if((numLines <= 0) || !visible_) return; - - numRows = numLines/columns_; - if(numLines%columns_ != 0) numRows++; - - xp = new double[columns_]; - xd = new int[columns_]; - yp = new double[numRows]; - yd = new int[numRows]; - xout = new int[2]; - yout = new int[2]; - - g.setColor(layer_.getPane().getComponent().getForeground()); - bounds = getBounds(); - // - // compute location of rows and columns in device and physical coordinates - // - lineLength = layer_.getXPtoD(lineLengthP_) - layer_.getXPtoD(0.0f); - labelSpace = layer_.getXDtoP(LABEL_SPACE_) - layer_.getXDtoP(0); - // - yd[0] = bounds.y + VERTICAL_BORDER_ + maxLabelHeight_; - yp[0] = layer_.getYDtoP(yd[0]); - for(i=1; i < numRows; i++) { - yd[i] = yd[i-1] + ROW_SPACE_ + maxLabelHeight_; - yp[i] = layer_.getYDtoP(yd[i]); - } - xd[0] = bounds.x + HORIZONTAL_BORDER_; - xp[0] = layer_.getXDtoP(xd[0]); - for(i=1; i < columns_; i++) { - xd[i] = xd[i-1] + COLUMN_SPACE_ + lineLength + LABEL_SPACE_ + maxLabelLength_; - xp[i] = layer_.getXDtoP(xd[i]); - } - // - row = 0; - col = 0; - Object obj; - Enumeration labelIt = label_.elements(); - for(Enumeration lineIt = points_.elements(); lineIt.hasMoreElements();) { - obj = lineIt.nextElement(); - render = (PointCartesianRenderer)obj; - attr = (PointAttribute)render.getAttribute(); - label = (SGLabel)labelIt.nextElement(); - // - // draw line - // - g.setColor(attr.getColor()); - xout[0] = xd[col]; - xout[1] = xout[0] + lineLength; - yout[0] = yd[row] - maxLabelHeight_/2; - yout[1] = yout[0]; - - // hack because mark is a little too high - int ymark = yout[0] -; - PlotMark pm = new PlotMark(attr); - pm.setMarkHeightP(label.getHeightP()); - pm.paintMark(g, layer_, xout[0], ymark); - pm.paintMark(g, layer_, xout[1], ymark); - // - xloc = xp[col] + lineLengthP_ + labelSpace; - label.setLocationP(new Point2D.Double(xloc, yp[row])); - try { - label.draw(g); - } catch (SGException e) {} - // - col++; - if(col >= columns_) { - col = 0; - row++; - } - } - switch(style_) { - case PLAIN_LINE: - g.drawRect(bounds.x, bounds.y, bounds.width-1, bounds.height-1); - break; - case RAISED: - break; - default: - case NO_BORDER: - } - } - /** - * Get the bounding rectangle. - * - * @return bounding rectangle - */ - public Rectangle getBounds() { - int lineLength; - int numLines, rows; - int x, y, height, width; - - numLines = points_.size(); - if(numLines <= 0) return new Rectangle(0, 0, 0, 0); - // - // find longest label - // - maxLabelLength_ = 0; - maxLabelHeight_ = 0; - SGLabel label; - for(Enumeration it = label_.elements(); it.hasMoreElements();) { - label = (SGLabel)it.nextElement(); - Rectangle sz = label.getBounds(); - maxLabelLength_ = Math.max(maxLabelLength_, sz.width); - maxLabelHeight_ = Math.max(maxLabelHeight_, sz.height); - } - // - rows = numLines/columns_; - if(numLines%columns_ != 0) rows++; - lineLength = layer_.getXPtoD(lineLengthP_) - layer_.getXPtoD(0.0f); - width = 2*HORIZONTAL_BORDER_ + - columns_*(lineLength + LABEL_SPACE_ + maxLabelLength_) + - (columns_ - 1)*COLUMN_SPACE_; - height = 2*VERTICAL_BORDER_ + rows*maxLabelHeight_ + - (rows-1)*ROW_SPACE_; - // temp fudge - height = height + 5; - // - x = layer_.getXPtoD(porigin_.x); - y = layer_.getYPtoD(porigin_.y); - switch(halign_) { - case RIGHT: - x = x - width; - break; - case CENTER: - x = x - width/2; - } - switch(valign_) { - case BOTTOM: - y = y - height; - break; - case MIDDLE: - y = y - height/2; - } - return new Rectangle(x, y, width, height); - } - public Point getLocation() { - Rectangle bnds = getBounds(); - return new Point(bnds.x, bnds.y); - } - public void setLocation(Point loc) { - Rectangle bnds = getBounds(); - setBounds(loc.x, loc.y, bnds.width, bnds.height); - } - /** - * Set the bounds, in pixels, of the PointCollectionKey - */ - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - /** - * Set the bounds, in pixels, of the PointCollectionKey - *
Property Change: location. - */ - public void setBounds(int x, int y, int width, int height) { - switch(halign_) { - case RIGHT: - x = x + width; - break; - case CENTER: - x = x + width/2; - } - switch(valign_) { - case BOTTOM: - y = y + height; - break; - case MIDDLE: - y = y + height/2; - } - double xp = layer_.getXDtoP(x); - double yp = layer_.getYDtoP(y); - if(porigin_.x != xp || porigin_.y != yp) { - Point2D.Double temp = porigin_; - porigin_.x = xp; - porigin_.y = yp; - changes_.firePropertyChange("location", - temp, - new Point2D.Double(xp, yp)); - modified("PointCollectionKey: setBounds()"); - } - } - Object getObjectAt(Point pt) { - Rectangle lbnds; - Rectangle bounds; - PointCartesianRenderer point; - int[] xout, yout; - int[] xd, yd; - int numLines, numRows; - int lineLength; - double labelSpace; - int i; - - numLines = points_.size(); - if(numLines <= 0) return null; - - numRows = numLines/columns_; - if(numLines%columns_ != 0) numRows++; - - xd = new int[columns_]; - yd = new int[numRows]; - xout = new int[2]; - yout = new int[2]; - bounds = getBounds(); - // - // compute location of rows and columns in device and physical coordinates - // - lineLength = layer_.getXPtoD(lineLengthP_) - layer_.getXPtoD(0.0); - labelSpace = layer_.getXDtoP(LABEL_SPACE_) - layer_.getXDtoP(0); - // - yd[0] = bounds.y + VERTICAL_BORDER_ + maxLabelHeight_; - for(i=1; i < numRows; i++) { - yd[i] = yd[i-1] + ROW_SPACE_ + maxLabelHeight_; - } - xd[0] = bounds.x + HORIZONTAL_BORDER_; - for(i=1; i < columns_; i++) { - xd[i] = xd[i-1] + COLUMN_SPACE_ + lineLength + LABEL_SPACE_ + maxLabelLength_; - } - // loop over all the lines - int row = 0; - int col = 0; - for(Enumeration lineIt = points_.elements(); lineIt.hasMoreElements();) { - point = (PointCartesianRenderer)lineIt.nextElement(); - xout[0] = xd[col]; -// xout[1] = xout[0] + lineLength + LABEL_SPACE_ + maxLabelLength_; - xout[1] = xout[0] + lineLength + LABEL_SPACE_; - yout[0] = yd[row] - maxLabelHeight_; - yout[1] = yd[row]; - lbnds = new Rectangle(xout[0], yout[0], - xout[1] - xout[0], - yout[1] - yout[0]); - if(lbnds.contains(pt)) { - return point; - } - // - col++; - if(col >= columns_) { - col = 0; - row++; - } - } - if(bounds.contains(pt)) { - return this; - } - return null; - } - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - public boolean isVisible() { - return visible_; - } - public void setVisible(boolean visible) { - if(visible_ != visible) { - visible_ = visible; - modified("PointCollectionKey: setVisible()"); - } - } - public void propertyChange(PropertyChangeEvent evt) { -// if(Debug.EVENT) { -// System.out.println("PointCollectionKey: " + evt); -// System.out.println(" " + evt.getPropertyName()); -// } - modified("PointCollectionKey: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PolarGraph.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PolarGraph.java deleted file mode 100755 index ba5c6e21..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/PolarGraph.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * $Id: PolarGraph.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTData; - -import java.awt.Graphics; -import java.awt.Point; -import java.beans.PropertyChangeEvent; - -/** - * Description of Class PolarGraph - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.x - */ -public class PolarGraph extends Graph implements Cloneable { - public PolarGraph() { - } - public Graph copy() { - PolarGraph newGraph; - try { - newGraph = (PolarGraph)clone(); - } catch (CloneNotSupportedException e) { - newGraph = new PolarGraph(); - } - return (Graph)newGraph; - } - void draw(Graphics g) { - throw new MethodNotImplementedError(); - } - public Object getObjectAt(Point pt) { - throw new MethodNotImplementedError(); - } - public SGTData getDataAt(Point pt) { - throw new MethodNotImplementedError(); - } - - public void propertyChange(PropertyChangeEvent evt) { - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/README.txt b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/README.txt deleted file mode 100755 index f7c64b69..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -This directory contains the scientific graphics toolkit (sgt). -The sgt is jdk1.2 compatible. - -Thanks to: - -Laurent Beigbeder for development of LogAxis and LogTransform. (2003-02-26) - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-2.0.txt b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-2.0.txt deleted file mode 100755 index 091b58c9..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-2.0.txt +++ /dev/null @@ -1,158 +0,0 @@ - Notes for Scientific Graphics Toolkit (sgt) - version 2.0 - February 12, 2001 - -$Id: RELEASE-NOTES-2.0.txt,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - -The major incompatability is the package name changes. The root package -gov.noaa.noaaserver has been changed to gov.noaa.pmel. This was done -to reflect the organization of origin rather than the project -responsible for the toolkits inception. The -gov.noaa.noaaserver.sgt.datamodel package was renamed to the shorted -gov.noaa.pmel.sgt.dm, since all the packages were renamed anyway. - -Packages gov.noaa.pmel.sgt.contour, gov.noaa.pmel.sgt.swing, and -gov.noaa.pmel.sgt.swing.prop added. These packages were added to -support contouring, swing, and attribute editing with swing dialogs. -The swing components replace and extend the awt classes which have -been deprecated. The current development plan for sgt includes -removing the deprecated classes from sgt. - -Package gov.noaa.pmel.sgt.demo older awt classes moved to -gov.noaa.pmel.sgt.demo.awt. These classes were moved out of demo to -prelude the dropping of support for awt. - -Packages gov.noaa.pmel.sgt.awt and gov.noaa.pmel.sgt.util have been -deprecated. These packages contain classes based on awt whose -functionality has been superceeded by classes in -gov.noaa.pmel.sgt.swing and gov.noaa.pmel.sgt.swing.prop. - -NOTE: - -Package gov.noaa.pmel.sgt (formerly gov.noaa.noaaserver.sgt) - -New Interfaces: - AbstractPane - ContourLevelAccess - IndexedColor - LabelDrawer - Moveable - TransformAccess - TransformColor - -New Classes: - CLIndexedColorMap - CLTransformColorMap - ContourLineAttribute - DefaultContourLineAttribute - IndexedColorMap - JPane - LabelDrawer1 - LabelDrawer2 - LayerStack - PlotMark - PointCollectionKey - TransformColorMap - -New Exception: - DataNotFoundException - -Classes moved to gov.noaa.pmel.util: - GeoDate - Point2D - Range - Range2D - Rectangle2D - TimePoint - TimeRange - IllegalTimeValueException - -Package gov.noaa.pmel.sgt.dm (formerly gov.noaa.noaaserver.sgt.datamodel) - -New Classes: - PointCollection - - -Package gov.noaa.pmel.sgt.awt (formerly gov.noaa.noaaserver.sgt.awt) - Entire package deprecated support of awt will be removed after - version 2.0. See gov.noaa.pmel.sgt.swing for replacement classes. - -Package gov.noaa.pmel.sgt.contour - Contour and ContourLine support contouring in sgt. These classes - used by GridCartesianRenderer. The classes were designed so that - the ContourLine would be accessible by the user application. - Labeling is handled such that labels can be added or removed after - the contour line has been generated. - -Package gov.noaa.pmel.sgt.demo (formerly gov.noaa.noaaserver.sgt.demo) - -New Classes: (These classes all use swing) - JGridDemo - JLayoutDemo - JPointDemo - JProfileDemo - JRealTimeDemo - JTimeSeriesDemo - PseudoRealTimeData - TAOMap - -Classes moved to gov.noaa.pmel.sgt.demo.awt - GridDemo - LayoutDemo - PointDemo - ProfileDemo - TimeSeriesDemo - - -Package gov.noaa.pmel.sgt.util (formerly gov.noaa.noaaserver.sgt.util) - Package deprecated. Support for awt will be removed after version - 2.0. See gov.noaa.pmel.sgt.swing.prop for replacement utility - classes. - - JClassTree moved to gov.noaa.pmel.sgt.swing and Units moved to - gov.noaa.pmel.util - -Utility classes in package gov.noaa.pmel.util - -New classes: - Domain - Point2D.Float - SoTDomain - SoTPoint - SoTRange - SoTRange.Double - SoTRange.GeoDate - SoTValue - SoTValue.Double - SoTValue.GeoDate - -The SoT classes were introduced to make creating Time/Space neutral -applications easier. The SoT classes are used by the Transform and -Axis classes. - -JDK 1.1.8 compatability. - -The following classes will not compile using a jdk 1.1.8 compiler. - - JPane (imports java.awt.print.*, java.awt.Graphics2D) - LabelDrawer2 (depends on Java2D) - JGraphicLayout (extends JPane) - JPlotLayout (extends JPane) - JLineProfileLayout (extends JPane, deprecated) - - All the demonstration applications in gov.noaa.pmel.sgt.demo use - JPane. - - The following ..swing.prop classes refrence JPane - GridAttributeDialog - LogoDialog - PointAttributeDialog - SGLabelDialog - SpaceAxisDialog - TimeAxisDialog - -While these classes won't compile using jdk1.1.8, if compiled with a -Java 2 compiler they will run under jdk1.1.8 if you don't print. The -swing classes haven't been tested under the jdk1.1.8 swing -implementation. - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-2.1.txt b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-2.1.txt deleted file mode 100755 index 69d6e217..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-2.1.txt +++ /dev/null @@ -1,68 +0,0 @@ - Scientific Graphics Toolkit (sgt) Version 2.1 - Release Notes - -$Id: RELEASE-NOTES-2.1.txt,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - -Introduction: -------------- - -This document describes the changes in the Scientific Graphics Toolkit -from version 2.0 to 2.1. - -Bug reports, comments, and suggestions can be sent to -dwd@pmel.noaa.gov or sgt@epic.noaa.gov. - -New Features: -------------- - -Two major new features have been added to SGT since its last -release. Both features require Java2D, which is available in JDK -version 1.2 and newer. - -Vectors. The datatype SGTVector has been implemented and the - VectorAttribute, VectorKey, VectorCartesianRenderer, and - VectorAttributeDialog classes have been added to support vector - drawing. The VectorAttribute class enables users to customize - vector head attributes (e.g. scale, min and max head size), color, - line attributes (width, cap and miter style), and optionally - placing a plot mark at the vector origin. See the javadoc for - more information. - - JPlotLayout has been expanded to include support for the - SGTVector datatype. - -Stroke lines. Stroke lines, where the width, dash properties, cap and - miter styles, are all selectable have been added. Line and - contour plotting now make use of the new stroke lines. - -Line key title. To better support dynamic changes in data a SGLabel - can be specified to describe a data object in a LineKey, - PointCollectionKey, and VectorKey. This feature was added so that - the key could be automatically updated when the data changed. - -GridAttributeDialog, LineAttributeDialog, PointAttributeDialog, and - VectorAttributeDialog now allow multiple JPanes to be registered. - This enables the dialog to notifiy both the main graphic JPane and - a JPane that contains a key that attribute changes have occured. - -Bug Fixes and Improvements: ---------------------------- - -A bug that required a Graphics object to be available before -setBatch(false) could be called has been fixed. This feature uses the -new init() method that is available in Pane and JPane. The init() -method is called with the Pane or JPane first becomes visible, -initializing those features that require a Graphics object reference. - -Several bugs have been fixed in JPlotLayout, relating to LineKey -placement, and using the new init() method. - -Known Issues This Release: --------------------------- - -GridAttributeDialog is still not complete. It presently only works -with an IndexedColorMap. - -Java2D is required for the new Stroke lines and Vector graphics to -work. - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-3.0.txt b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-3.0.txt deleted file mode 100755 index c797baff..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/RELEASE-NOTES-3.0.txt +++ /dev/null @@ -1,509 +0,0 @@ - Scientific Graphics Toolkit (sgt) Version 3.0 - SGT Beans Initial Release - Release Notes - -$Id: RELEASE-NOTES-3.0.txt,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - -Introduction: -------------- - -This document describes the changes in the Scientific Graphics Toolkit -from version 2.1 to 3.0 and introduces the first release of SGT Beans. - -Bug reports, comments, and suggestions can be sent to -Donald.W.Denbo@noaa.gov, sgt@epic.noaa.gov or preferrably reported -using the Mantis system at http://heron.pmel.noaa.gov:8082/mantis. - -New Features: -------------- - -The biggest new feature is the initial delivery of SGT Beans. The -three main beans Page, PanelModel, and DataModel can be used to -produce graphics more easily. These beans also enable a user to more -easily change the layout of existing graphics. [I will be making a -tutorial available in about 2 months.] - -New classes have been added to support graphical annotation. And a -new GeoDateArray class has been added to improve performance. - -Bug Fixes: ----------- - -To many to list. The major fixes include using repaint() internally -to make the drawing more robust. Problems with placing multiple JPanes -in a single JFrame have been addressed and printing has been updated -to work after the above bug fixes :-). - -Known Existing Problems: ------------------------- - -SGT Beans require jdk 1.4. This requirement is because I use -XMLEncoder to serialize SGT Beans. - -The JRealTimeDemo demonstrates a problem that occurs when SGT is -forced to redraw too rapidly. On Solaris, the JPanel goes blank until -the repainting is done. - -Printing SGT Beans with titled borders cause the graphic to be shifted -down but not rescaled. The result is the border overplot on the -graphic. - -The Page SGT Bean doesn't account for the extra space a pixel -rendering requires, causing the pixels to overlap the axes. - -Future Features: ---------------- - -Presently SGT Beans don't use a LayoutManager to position Panels on -the Page. I will be developing the interface and visual customization -classes necessary to support SpringLayout. Eventually :-(. - -Deprecated Classes: ------------------- - -The following classes are now deprecated and will be removed at some -future sgt release. - -gov.noaa.pmel.sgt.Pane -- use gov.noaa.pmel.sgt.JPane -gov.noaa.pmel.sgt.swing.JLineProfileLayout -- use gov.noaa.pmel.sgt.swing.JPlotLayout - -in gov.noaa.pmel.util: - -SoTRange.GeoDate -- use SoTRange.Time -SoTValue.GeoDate -- use SoTValue.Time -TimePoint -- use SoTPoint -TimeRange -- use SoTRange - -New Packages: -------------- - -gov.noaa.pmel.sgt.beans - -New Classes: ------------- -For details see the JavaDoc. - -gov.noaa.pmel.sgt - AnnotationCartesianRenderer - AttributeChangeEvent - DataKey - LayerControl - NegativeLogException - -gov.noaa.pmel.sgt.demo - JLogLogDemo - BeanDemo - -gov.noaa.pmel.sgt.dm - Annotation - Annote - SGT3DVector - -gov.noaa.pmel.sgt.swing.prop - ColorDialog - ColorEntryPanel - RulerDialog - -gov.noaa.pmel.swing - FocusableSwatch - MRJUtil - Swatch - SwatchGroup - ThreeDotsButton - ThreeDotsIcon - -gov.noaa.pmel.util - EPICSystem - GeoDateArray - SimpleFileFilter - -New Methods and Constructors: ------------------------------ -For details see the JavaDoc. - -gov.noaa.pmel.sgt - AbstractPane - new fields - DEFAULT_SCALE - TO_FIT - SHRINK_TO_FIT - new methods - Object[] getObjectsAt(int x,int y), - Object[] getObjectsAt(Point pt) - Point getZoomStart() - void setMouseEventsEnabled(boolean en) - boolean isMouseEventsEnabled() - void setPageScaleMode(int mode) - int getPageScaleMode() - - Attribute - new methods - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - Axis - new methods - void setLineColor(Color color) - Color getLineColor() - - AxisTransform - new constructors - AxisTransform(double p1, double p2, long t1, long t2) - new methods - double getTransP(long t) - long getLongTimeTransU(double p) - - CLIndexedColorMap - new methods - Color getColorByIndex(int indx) - - CartesianGraph - new methods - void setClip(long tmin, long tmax, double min, double max) - double getXUtoD2(double u) - double getYUtoD2(double u) - double getXUtoP(long t) - double getYUtoP(long t) - int getXUtoD(long t) - int getYUtoD(long t) - double getXUtoD2(GeoDate t) - double getYUtoD2(GeoDate t) - double getXUtoD2(long t) - double getYUtoD2(long t) - int getXUtoD(SoTValue val) - int getYUtoD(SoTValue val) - double getXUtoD2(SoTValue val) - double getYUtoD2(SoTValue val) - double getXUtoP(SoTValue val) - double getYUtoP(SoTValue val) - SoTValue getXPtoSoT(double p) - SoTValue getYPtoSoT(double p) - long getXPtoLongTime(double p) - long getYPtoLongTime(double p) - SoTPoint getPtoU(Point2D.Double loc) - SGTData getDataAt(Point pt) - - CartesianRenderer - new methdos - SGTData getDataAt(int x, int y) - SGTData getDataAt(Point pt) - - ColorKey - Fixed vertical orientation. - new constructor - ColorKey(Point2D.Double pt, Dimension2D size, int valign, int halign) - new methods - void addGraph(CartesianRenderer rend, SGLabel label) - void setColumns(int col) - void setLineLengthP(double len) - - ColorMap - new methods - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - Graph - new methods - SGTData getDataAt(Point pt) - - GridAttribute - new methods - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - GridCartesianRenderer - new methdos - SGTData getDataAt(Point pt) - unimplemented - - IndexedColor - new methods - Color getColorByIndex(int index) - - IndexedColorMap - new methods - Color getColorByIndex(int index) - - JPane - new methods - String getVersion() - Point getZoomStart() - Object[] getObjectsAt(int x, int y) - Object[] getObjectsAt(Point pt) - void setMouseEventsEnabled(boolean enable) - boolean isMouseEventsEnabled() - void setPageScaleMode(int mode) - int getPageScaleMode() - - Layer - new methods - double getXPtoD2(double xp) - double getYPtoD2(double yp) - LayerChild findChild(String id) - Iterator childIterator() - LayerChild[] getChildren() - Object[] getObjectsAt(int x, int y, boolean check) - - LayerContainer - unimplemented - - LayerStack - unimplemented - - LineAttribute - new methods - boolean equals(Object obj) - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - LineCartesianRenderer - new methods - SGTData getDataAt(Point pt) - unimplemented - - LineKey - new methods - void addGraph(CartesianRenderer rend, SGLabel label) - - LinearTransform - new methods - double getTransP(long t) - long getLongTimeTransU(double p) - - LogAxis - new implementation - - LogTransform - new implementation - - Pane - mew methods - String getVersion() - Point getZoomStart() - Object[] getObjectsAt(int x, int y) - Object[] getObjectsAt(point pt) - void setMouseEventsEnabled(boolean enable) - boolean isMouseEventsEnabled() - void setPageScaleMode(int mode) - int getPageScaleMode() - - PaneProxy - new methods - String getVersion() - Object[] getObjectsAt(int x, int y) - void setMouseEventsEnabled(boolean enable) - boolean isMouseEventsEnabled() - - PointAttribute - new methods - boolean equals(Object obj) - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - PointCartesianRenderer - new methods - SGTData getDataAt(Point pt) - unimplemented - - PointCollectionKey - new methods - void addGraph(CartesianRenderer rend, SGLabel label) - - Ruler - new methods - int getLabelInterval() - void setLabelInterval(int interval) - int getSignificantDigits() - void setSignificantDigist(int sig) - String getLabelFormat() - void setLabelFormat(String format) - Color getLabelColor() - void setLabelColor(Color color) - Color getLineColor() - void setLineColor(Color color) - - SGLabel - new methods - boolean equals(Object obj) - - VectorAttribute - new methods - void setId(String id) - String getId() - void setBatch(boolean batch) - void setBatch(boolean batch, boolean local) - boolean isBatch() - - VectorCartesianRenderer - new methods - SGTData getDataAt(Point pt) - unimplemented - - VectorKey - new methods - void setLineLengthP(double len) - void addGraph(CartesianRenderer rend, SGLabel label) - -gov.noaa.pmel.sgt.beans - all new package - -gov.noaa.pmel.sgt.contour - -gov.noaa.pmel.sgt.demo - -gov.noaa.pmel.sgt.dm - SGTGrid - new methods - GeoDateArray getGeoDateArray() - GeoDateArray getGeoDateArrayEdges() - - SGTLine - new methods - GeoDateArray getGeoDateArray() - - SGTPoint - new methods - long getLongTime() - - SGTTuple - - SGTVector - - SimpleGrid - new methods - GeoDateArray getGeoDateArray() - GeoDateArray getGeoDateArrayEdges() - void setTimeEdges(GeoDateArray tarray) - void setTimeArray(GeoDateArray tarray) - - SimpleLine - new constructor - SimpleLine(GeoDateArray tloc, double[] yloc, String title) - SimpleLine(double[] xloc, GeoDateArray tloc, String title) - new methods - GeoDateArray getGeoDateArray() - void setTimeArray(GeodDateArray tarray) - - SimplePoint - new constructor - SimplePoint(SoTPoint loc, String title) - new methods - long getLongTime() - void setTime(GeoDate date) - void setTime(long t) - - SimpleTuple - new methods - void setXArray(GeoDateArray tArray) - void setYArray(GeoDateArray tArray) - GeoDateArray getGeoDateArray() - -gov.noaa.pmel.sgt.swing - Draggable - new method - void setLocation(Point loc, boolean fireEvent) - - JGraphicLayout - new methods - Attribute findAttribute(String id) - void setAllClip(long tmin, long tmax, double min, double max) - - JPlotLayout - new methods - SoTDomain getGraphDomain() - - UserIcon - new methods - SoTPoint getLocationU() - void setLocationUNoVeto(SoTPoint loc) - void setLocationU(SoTPoint loc) - - ValueIcon - new methods - SoTPoint getLocationU() - void setLocationUNoVeto(SoTPoint loc) - void setLocationU(SoTPoint loc) - - ValueIconFormat - new methods - void setTimeFormat(String tfrmt) - String format(SoTPoint pt) - -gov.noaa.pmel.sgt.swing.prop - -gov.noaa.pmel.swing - SelectTimeDialog - new method - void setRange(long min, long max) - -gov.noaa.pmel.util - Domain - new constructors - Domain(Range2D xRange, Range2D yrange, boolean xRev, boolean yRev) - Domain(TimeRange tRange, Range2D yRange, boolean xRev, boolean yRev) - Domain(Range2D xRange, TimeRange tRange, boolean xRev, boolean yRev) - new methods - void setYReversed(boolean rev) - boolean isYReversed() - void setXReversed(boolean rev) - boolean isXReversed() - - Point2D - new methods - boolean equals(Object obj) - Point2D copy() - - Rectangle2D - new subclass - Rectangle2D.Float - new methods - void setWidth(double w) - double getWidth() - void setHeight(double h) - double getHeight() - void setX(double x) - double getX() - void setY(double y) - double getY() - Rectangle2D copy() - - SoTDomain - new constructor - SoTDomain(SoTRange xRange, SoTRange yRange, boolean xRev, boolean yRev) - new methods - SoTPoint getCenter() - void setXReversed(boolean rev) - boolean isXReversed() - void setYReversed(boolean rev) - boolean isYReversed() - - SoTPoint - new constructors - SoTPoint(double x, long y) - SoTPoint(long x, double y) - new methods - void setX(SoTValue x) - void setY(SoTValue y) - void add(SoTPoint point) - SoTPoint copy() - - SoTRange - new subclass - SoTRange.Time - - SoTValue - new sublcass - SoTValue.Time - new methods - void add(SoTValue val) - long getLongTime() - GeoDate getGeoDate() - - TimeRange - new constructor - TimeRange(long start, long end, long delta) diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Ruler.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Ruler.java deleted file mode 100755 index ba298f94..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Ruler.java +++ /dev/null @@ -1,748 +0,0 @@ -/* - * $Id: Ruler.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Font; -import java.awt.Color; -// jdk1.2 -//import java.awt.geom.Rectangle2D; -//import java.awt.geom.Point2D; - -/** - * Description of Class Ruler - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - */ -public class Ruler implements Cloneable, LayerChild { - private String ident_; -/** @directed */ - private Layer layer_; - private int orient_; - // - private boolean selected_; - private boolean selectable_; - private boolean visible_; - /**@label title - * @link aggregationByValue */ - private SGLabel title_ = null; - private String labelFormat_ = ""; - protected Range2D uRange_; -// protected Point2D.Double uLocation_; - protected Rectangle2D.Double pBounds_; - protected int numSmallTics_ = 0; - protected double largeTicHeight_ = 0.1; - protected double smallTicHeight_ = 0.05; - protected int ticPosition_ = NEGATIVE_SIDE; - protected int labelPosition_ = NEGATIVE_SIDE; - protected int labelInterval_ = 2; - protected Font labelFont_ = new Font("Helvetica", Font.ITALIC, 10); - protected Color labelColor_ = Color.black; - protected Color lineColor_ = Color.black; - // protected double labelHeight_ = 0.15; - protected double labelHeight_ = 0.20; - protected int sigDigits_ = 2; - /** - * Orient Key horizontally. - */ - public static final int HORIZONTAL = 1; - /** - * Orient Key vertically. - */ - public static final int VERTICAL = 2; - /** - * Place the label and/or tic on the positive side of the axis. - * The right side of VERTICAL axes and the top of HORIZONTAL axes. - */ - public static final int POSITIVE_SIDE = 0; - /** - * Place the label and/or tic on the negative side of the axis. - * The left side of VERTICAL axes and the bottom of HORIZONTAL axes. - */ - public static final int NEGATIVE_SIDE = 1; - /** - * Do not draw a label and/or tic. - */ - public static final int NO_LABEL = 2; - /** - * Draw the tics on both sides of the axes. - */ - public static final int BOTH_SIDES = 2; - // - static final double TIC_GAP = 0.05; - static final double TIC_RATIO = 1.3; - static final double LABEL_RATIO = 1.3; - protected void drawXTic(Graphics g,double xp,double yp,double ticHeight) { - int x0, y0, y1; - double yp0, yp1; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yp0 = yp + ticHeight; - } else { - yp0 = yp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yp1 = yp - ticHeight; - } else { - yp1 = yp; - } - x0 = layer_.getXPtoD(xp); - y0 = layer_.getYPtoD(yp0); - y1 = layer_.getYPtoD(yp1); - g.drawLine(x0, y0, x0, y1); - } - // - protected void drawYTic(Graphics g,double xp,double yp,double ticHeight) { - int x0, x1, y0; - double xp0, xp1; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xp0 = xp + ticHeight; - } else { - xp0 = xp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xp1 = xp - ticHeight; - } else { - xp1 = xp; - } - y0 = layer_.getYPtoD(yp); - x0 = layer_.getXPtoD(xp0); - x1 = layer_.getXPtoD(xp1); - g.drawLine(x0, y0, x1, y0); - } - // - protected void drawSmallXTics(Graphics g,double xu,double xtest,double del,double yp) { - int x0, y0, y1, i; - double yp0, yp1, smdel, xt; - if(numSmallTics_ <= 0) return; - // yp = graph_.getYUtoP(yu); - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yp0 = yp + smallTicHeight_; - } else { - yp0 = yp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yp1 = yp - smallTicHeight_; - } else { - yp1 = yp; - } - y0 = layer_.getYPtoD(yp0); - y1 = layer_.getYPtoD(yp1); - smdel = del/(numSmallTics_ + 1); - for(i=0; i <= numSmallTics_; i++) { - xt = xu + smdel*i; - if((xtest - xt)/del >= 0) { - x0 = layer_.getXPtoD(xt); - g.drawLine(x0, y0, x0, y1); - } - } - } - // - protected void drawSmallYTics(Graphics g,double xp,double yu,double ytest,double del) { - int x0, x1, y0, i; - double xp0, xp1, smdel, yt; - if(numSmallTics_ <= 0) return; - // xp = graph_.getXUtoP(xu); - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xp0 = xp + smallTicHeight_; - } else { - xp0 = xp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xp1 = xp - smallTicHeight_; - } else { - xp1 = xp; - } - x0 = layer_.getXPtoD(xp0); - x1 = layer_.getXPtoD(xp1); - smdel = del/(numSmallTics_ + 1); - for(i=0; i <= numSmallTics_; i++) { - yt = yu + smdel*i; - if((ytest - yt)/del >= 0) { - y0 = layer_.getYPtoD(yt); - g.drawLine(x0, y0, x1, y0); - } - } - } - /** - * Default constructor for Ruler. - */ - public Ruler() { - this(""); -} - /** - * Constructor for Ruler. Sets the ruler identifier and initializes - * the defaults. Default values are: - * - *

-   *   numberSmallTics = 0
-   *   largeTicHeightP = 0.1
-   *   smallTicHeightP = 0.05
-   *       ticPosition = NEGATIVE_SIDE
-   *     labelPosition = NEGATIVE_SIDE
-   *     labelInterval = 2
-   *         labelFont = Font("Helvetica", Font.ITALIC, 10);
-   *      labelHeightP = 0.15
-   * significantDigits = 2;
-   *       labelFormat = ""
-   *             title = null
-   *       orientation = HORIZONTAL
-   *                Id = ""
-   * 
- * - * @param id axis identification - */ - public Ruler(String ident) { - ident_ = ident; - selected_ = false; - selectable_ = true; - visible_ = true; - } - public LayerChild copy() { - Ruler newRuler; - try { - newRuler = (Ruler)clone(); - } catch (CloneNotSupportedException e) { - newRuler = new Ruler(); - } - return (LayerChild)newRuler; - } - public void setSelected(boolean sel) { - selected_ = sel; - } - public boolean isSelected() { - return selected_; - } - public void setSelectable(boolean select) { - selectable_ = select; - } - public boolean isSelectable() { - return selectable_; - } - /** - * Set the large tic height in physical units. - * - * @param lthgt large tic height. - */ - public void setLargeTicHeightP(double lthgt) { - if(largeTicHeight_ != lthgt) { - largeTicHeight_ = lthgt; - modified("Ruler: setLargeTicHeightP()"); - } - } - /** - * Get the large tic height. - * - * @return large tic height in physcial units. - */ - public double getLargeTicHeightP() { - return largeTicHeight_; - } - /** - * Set the number of small tics between large tics. - * - * @param nstic number of small tics. - */ - public void setNumberSmallTics(int nstic) { - if(numSmallTics_ != nstic) { - numSmallTics_ = nstic; - modified("Ruler: setNumberSmallTics()"); - } - } - /** - * Get the number of small tics between large tics. - * - * @return number of small tics. - */ - public int getNumberSmallTics() { - return numSmallTics_; - } - /** - * Set the small tic height in physical units. - * - * @param sthgt small tic height. - */ - public void setSmallTicHeightP(double sthgt) { - if(smallTicHeight_ != sthgt) { - smallTicHeight_ = sthgt; - modified("Ruler: setSmallTicHeightP()"); - } - } - /** - * Get the small tic height. - * - * @return small tic height in physical units. - */ - public double getSmallTicHeightP() { - return smallTicHeight_; - } - /** - * Set the tic position. Tic position can be POSITIVE_SIDE, NEGATIVE_SIDE, - * or BOTH_SIDES. - * - * @param tpos tic position - */ - public void setTicPosition(int tpos) { - if(ticPosition_ != tpos) { - ticPosition_ = tpos; - modified("Ruler: setTicPosition()"); - } - } - /** - * Get the tic position. - * - * @return tic position - */ - public int getTicPosition() { - return ticPosition_; - } - /** - * Set the label position. Label position can be POSITIVE_SIDE, NEGATIVE_SIDE, - * and NO_LABEL. - * - * @param lapb label position. - */ - public void setLabelPosition(int labp) { - if(labelPosition_ != labp) { - labelPosition_ = labp; - modified("Ruler: setLabelPosition()"); - } - } - /** - * Get the label position. - * - * @return label position - */ - public int getLabelPosition() { - return labelPosition_; - } - /** - * Set the label font. - * - * @param fnt label font - */ - public void setLabelFont(Font fnt) { - if(labelFont_ == null || !labelFont_.equals(fnt)) { - labelFont_ = fnt; - modified("Ruler: setLabelFont()"); - } - } - /** - * Get the label font. - * - * @return label font - */ - public Font getLabelFont() { - return labelFont_; - } - /** - * Set the label height in physical units. - * - * @param lhgt label height. - */ - public void setLabelHeightP(double lhgt) { - if(labelHeight_ != lhgt) { - labelHeight_ = lhgt; - modified("Ruler: setLabelHeightP()"); - } - } - /** - * Get the label height. - * - * @return label height - */ - public double getLabelHeightP() { - return labelHeight_; - } - /** - * Set the axis identifier. - * - * @param id identifier - **/ - public void setId(String id) { - ident_ = id; - } - /** - * Set the axis identifier. - * - * @param id identifier - **/ - public String getId() { - return ident_; - } - public void setLayer(Layer l) { - layer_ = l; - } - public Layer getLayer() { - return layer_; - } - public AbstractPane getPane() { - return layer_.getPane(); - } - public void modified(String mess) { - // if(Debug.EVENT) System.out.println("Ruler: modified()"); - if(layer_ != null) - layer_.modified(mess); - } - /** - * Change the user unit range of Ruler - */ - public void setRangeU(Range2D range) { - if(uRange_ == null || !uRange_.equals(range)) { - uRange_ = range; - modified("Ruler: setRangeU()"); - } - } - public Range2D getRangeU() { - return uRange_; - } - /** - * Set the bounding box for the axis in physical units. - * - * @return bounding box - */ - public void setBoundsP(Rectangle2D.Double bounds) { - if(pBounds_ == null || !pBounds_.equals(bounds)) { - if(Debug.EVENT) - System.out.println("pBounds_ = " + - pBounds_ + - ", bounds = " + - bounds); - pBounds_ = bounds; - modified("Ruler: setBoundsP()"); - } - } - /** - * Get the bounding box for the axis in physical units. - * - * @return bounding box - */ - public Rectangle2D.Double getBoundsP() { - return pBounds_; - } - /** - * Set ruler orientation. Allowed orientations are HORIZONATAL and - * VERTICAL. - * - * @param or orientation - */ - public void setOrientation(int orient) { - if(orient_ != orient) { - orient_ = orient; - modified("Ruler: setOrientation()"); - } - } - /** - * Get axis orientation - * - * @return axis orientation - */ - public int getOrientation() { - return orient_; - } - /** - * Set the axis title. - * - * @param title axis title - */ - public void setTitle(SGLabel title) { - if(title_ == null || !title_.equals(title)) { - title_ = title; - modified("Ruler: setTitle()"); - } - } - /** - * Get the axis title. - * - * @return axis title - */ - public SGLabel getTitle() { - return title_; - } - /** - * Get the bounding box for the axis in device units. - * - * @return bounding box - */ - public Rectangle getBounds() { - int x, y, height, width; - x = layer_.getXPtoD(pBounds_.x); - y = layer_.getYPtoD(pBounds_.y); - width = layer_.getXPtoD(pBounds_.x + pBounds_.width) - x; - height = layer_.getYPtoD(pBounds_.y - pBounds_.height) - y; - if(orient_ == HORIZONTAL) { - y = y - height; - } - return new Rectangle(x, y, width, height); - } - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - public void setBounds(int x, int y, int width, int height) { - } - public void draw(Graphics g) { - int xloc, yloc, xend, yend; - int istop, i; - double xt, yt, dir, x, y, xp, yp; - double xtitle, ytitle; - Format format; - String labelText = null; - AxisTransform sTrans; - if(!visible_) return; - if(title_ != null) title_.setLayer(layer_); - // - if(lineColor_ == null) { - g.setColor(layer_.getPane().getComponent().getForeground()); - } else { - g.setColor(lineColor_); - } - // - if(labelFormat_.length() <= 0) { - format = new Format(Format.computeFormat(uRange_.start, uRange_.end, sigDigits_)); - } else { - format = new Format(labelFormat_); - } - if(orient_ == HORIZONTAL) { - sTrans = new LinearTransform(pBounds_.x, pBounds_.x + pBounds_.width, - uRange_.start, uRange_.end); - yloc = layer_.getYPtoD(pBounds_.y); - yp = pBounds_.y; - xloc = layer_.getXPtoD(sTrans.getTransP(uRange_.start)); - xend = layer_.getXPtoD(sTrans.getTransP(uRange_.end)); - g.drawLine(xloc, yloc, xend, yloc); - // - dir = uRange_.delta > 0? 1.0: -1.0; - xt = (int)((uRange_.start/uRange_.delta + (dir*uRange_.start > 0? 1.0: -1.0)*0.00001))*uRange_.delta; - if(dir*xt < dir*uRange_.start) xt += uRange_.delta; - istop = (int)((uRange_.end - xt)/uRange_.delta + 0.00001); - x = xt; - xp = sTrans.getTransP(x); - drawSmallXTics(g, x, uRange_.start, -uRange_.delta, yp); - drawXTic(g, xp, yp, largeTicHeight_); - for(i=0; i < istop; i++) { - drawSmallXTics(g, x, uRange_.end, uRange_.delta, yp); - x += uRange_.delta; - xp = sTrans.getTransP(x); - drawXTic(g, xp, yp, largeTicHeight_); - } - drawSmallXTics(g, x, uRange_.end, uRange_.delta, yp); - // - if(labelInterval_ <= 0 || labelPosition_ == NO_LABEL) return; - // - SGLabel label; - int vertalign; - if(labelPosition_ == POSITIVE_SIDE) { - vertalign = SGLabel.BOTTOM; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yt = yp + TIC_RATIO*largeTicHeight_; - } else { - yt = yp + TIC_GAP; - } - ytitle = yt + LABEL_RATIO*labelHeight_; - } else { - vertalign = SGLabel.TOP; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yt = yp - TIC_RATIO*largeTicHeight_; - } else { - yt = yp - TIC_GAP; - } - ytitle = yt - LABEL_RATIO*labelHeight_; - } - if(dir*uRange_.start <= 0 && dir*uRange_.end >= 0) { - x = ((int)(uRange_.start/(uRange_.delta*labelInterval_) - - 0.00001))*uRange_.delta*labelInterval_; - } else { - x = xt; - } - istop = (int)((uRange_.end - x)/(uRange_.delta*labelInterval_) + 0.00001); - for(i=0; i <= istop; i++) { - xt = sTrans.getTransP(x); - labelText = format.form(x); - label = new SGLabel("coordinate", labelText, new Point2D.Double(xt, yt)); - label.setFont(labelFont_); - label.setHeightP(labelHeight_); - label.setAlign(vertalign, SGLabel.CENTER); - label.setLayer(layer_); - label.setColor(labelColor_); - try { - label.draw(g); - } catch (LayerNotFoundException e) {} - x = x + uRange_.delta*labelInterval_; - } - if(title_ != null) { - xtitle = (uRange_.end + uRange_.start)*0.5; - yt = ytitle; - xt = sTrans.getTransP(xtitle); - title_.setLocationP(new Point2D.Double(xt, yt)); - title_.setAlign(vertalign, SGLabel.CENTER); - title_.setOrientation(SGLabel.HORIZONTAL); - try { - title_.draw(g); - } catch (LayerNotFoundException e) {} - } - } else { // orientation is vertical - sTrans = new LinearTransform(pBounds_.y, pBounds_.y + pBounds_.height, - uRange_.start, uRange_.end); - xloc = layer_.getXPtoD(pBounds_.x); - xp = pBounds_.x; - yloc = layer_.getYPtoD(sTrans.getTransP(uRange_.start)); - yend = layer_.getYPtoD(sTrans.getTransP(uRange_.end)); - g.drawLine(xloc, yloc, xloc, yend); - // - dir = uRange_.delta > 0? 1.0: -1.0; - yt = (int)((uRange_.start/uRange_.delta) + (dir*uRange_.start > 0? 1.0: -1.0)*0.00001)*uRange_.delta; - if(dir*yt < dir*uRange_.start) yt += uRange_.delta; - istop = (int)((uRange_.end - yt)/uRange_.delta + 0.00001); - y = yt; - yp = sTrans.getTransP(y); - drawSmallYTics(g, xp, y, uRange_.start, -uRange_.delta); - drawYTic(g, xp, yp, largeTicHeight_); - for(i=0; i < istop; i++) { - drawSmallYTics(g, xp, y, uRange_.end, uRange_.delta); - y += uRange_.delta; - yp = sTrans.getTransP(y); - drawYTic(g, xp, yp, largeTicHeight_); - } - drawSmallYTics(g, xp, y, uRange_.end, uRange_.delta); - // - if(labelInterval_ <= 0 || labelPosition_ == NO_LABEL) return; - // - SGLabel label; - int vertalign; - if(labelPosition_ == NEGATIVE_SIDE) { - vertalign = SGLabel.BOTTOM; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xt = xp - TIC_RATIO*largeTicHeight_; - } else { - xt = xp - TIC_GAP; - } - xtitle = xt - LABEL_RATIO*labelHeight_; - } else { - vertalign = SGLabel.TOP; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xt = xp + TIC_RATIO*largeTicHeight_; - } else { - xt = xp + TIC_GAP; - } - xtitle = xt + LABEL_RATIO*labelHeight_; - } - if(dir*uRange_.start <= 0 && dir*uRange_.end >= 0) { - y = ((int)(uRange_.start/(uRange_.delta*labelInterval_) - 0.00001))*uRange_.delta*labelInterval_; - } else { - y = yt; - } - istop = (int)((uRange_.end - y)/(uRange_.delta*labelInterval_) + 0.00001); - for(i=0; i <= istop; i++) { - yt = sTrans.getTransP(y); - labelText = format.form(y); - label = new SGLabel("coordinate", labelText, new Point2D.Double(xt, yt)); - label.setAlign(vertalign, SGLabel.CENTER); - label.setOrientation(SGLabel.VERTICAL); - label.setFont(labelFont_); - label.setHeightP(labelHeight_); - label.setLayer(layer_); - try { - label.draw(g); - } catch (LayerNotFoundException e) {} - y = y + uRange_.delta*labelInterval_; - } - if(title_ != null) { - ytitle = (uRange_.end + uRange_.start)*0.5; - yt = sTrans.getTransP(ytitle); - xt = xtitle; - title_.setLocationP(new Point2D.Double(xt, yt)); - title_.setAlign(vertalign, SGLabel.CENTER); - title_.setOrientation(SGLabel.VERTICAL); - try { - title_.draw(g); - } catch (LayerNotFoundException e) {} - } - } - } - public boolean isVisible() { - return visible_; - } - public void setVisible(boolean visible) { - if(visible_ != visible) { - visible_ = visible; - modified("Ruler: setVisible()"); - } - } - /** - * @since 3.0 - */ - public int getLabelInterval() { - return labelInterval_; - } - /** - * @since 3.0 - */ - public void setLabelInterval(int labelInterval) { - labelInterval_ = labelInterval; - } - /** - * @since 3.0 - */ - public int getSignificantDigits() { - return sigDigits_; - } - /** - * @since 3.0 - */ - public void setSignificantDigits(int sigDigits) { - sigDigits_ = sigDigits; - } - /** - * @since 3.0 - */ - public String getLabelFormat() { - return labelFormat_; - } - /** - * @since 3.0 - */ - public void setLabelFormat(String labelFormat) { - labelFormat_ = labelFormat; - } - /** - * @since 3.0 - */ - public Color getLabelColor() { - return labelColor_; - } - /** - * @since 3.0 - */ - public void setLabelColor(Color labelColor) { - labelColor_ = labelColor; - } - /** - * @since 3.0 - */ - public Color getLineColor() { - return lineColor_; - } - /** - * @since 3.0 - */ - public void setLineColor(Color lineColor) { - lineColor_ = lineColor; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SGException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SGException.java deleted file mode 100755 index 4d1f11ea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SGException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: SGException.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -/** - * Base class for gov.noaa.pmel.sgt exceptions. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - */ -public class SGException extends java.lang.Exception { - public SGException() { - super(); - } - public SGException(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SGLabel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SGLabel.java deleted file mode 100755 index ba86de4e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SGLabel.java +++ /dev/null @@ -1,577 +0,0 @@ -/* - * $Id: SGLabel.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.image.PixelGrabber; -import java.awt.image.MemoryImageSource; -import java.awt.image.ColorModel; -import java.awt.image.ImageObserver; -import java.awt.*; -import java.beans.*; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -// jdk1.2 -//import java.awt.geom.Rectangle2D; -//import java.awt.geom.Point2D; - -/** - * Draws text on a layer object. SGLabel uses the drawString() method - * of the Graphics class. SGLabel allows the user to align the text - * both vertically (TOP, MIDDLE, and BOTTOM) and horizontally - * (LEFT, MIDDLE, and RIGHT). The font, color, and height (in user - * coordinates) can also be specified. The SGLabel can also be drawn - * either HORIZONTAL or VERTICAL. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - * @see java.awt.Graphics - */ -public class SGLabel implements Cloneable, LayerChild, Moveable, Serializable { - private String ident_; - private LabelDrawer proxy_; - private boolean selected_; - private boolean selectable_; - private boolean moveable_; - private transient PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - /** - * Align top of label - **/ - public static final int TOP = 0; - /** - * Align middle of label - **/ - public static final int MIDDLE = 1; - /** - * Align bottom of label - **/ - public static final int BOTTOM = 2; - /** - * Align left of label - **/ - public static final int LEFT = 0; - /** - * Align center of label - **/ - public static final int CENTER = 1; - /** - * Align right of label - **/ - public static final int RIGHT = 2; - /** - * Orient label horizontal - */ - public static final int HORIZONTAL = 0; - /** - * Orient label vertical - */ - public static final int VERTICAL = 1; - /** - * Orient label at an angle - * @since 2.0 - */ - public static final int ANGLE = 2; - - static { - try { - BeanInfo info = Introspector.getBeanInfo(SGLabel.class); - PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); - for(int i=0; i < descriptors.length; i++) { - PropertyDescriptor pd = descriptors[i]; - if(pd.getName().equals("layer")) { - pd.setValue("transient", Boolean.TRUE); - } - } - } catch (IntrospectionException ie) { - ie.printStackTrace(); - } - } - /** - * Quick SGLabel constructor. Default alignment of BOTTOM and LEFT are - * used. Default height is 0.12. - * - * @param id Label identifier - * @param lbl String to be plotted. - */ - public SGLabel(String id,String lbl,Point2D.Double loc) { - this(id, lbl, 0.12, loc, BOTTOM, LEFT); - } - /** - * Long SGLabel constructor. - * - * @param id Label identifier - * @param lbl String to be plotted - * @param hgt String height in physical units - * @param loc Location to plot label in physical units - * @param valign Vertical alignment - * @param halign Horizontal alignment - **/ - public SGLabel(String id, String lbl, double hgt, - Point2D.Double loc, int valign, int halign) { - if(PaneProxy.Java2D) { - proxy_ = new LabelDrawer2(lbl, hgt, loc, valign, halign); - } else { - proxy_ = new LabelDrawer1(lbl, hgt, loc, valign, halign); - } - ident_ = id; - proxy_.setOrientation(HORIZONTAL); - proxy_.setAngle(0.0); - proxy_.setColor(null); - proxy_.setFont(new Font("Helvetica", Font.PLAIN, 14)); - selected_ = false; - selectable_ = true; - proxy_.setVisible(true); - moveable_ = true; - } -// private void bindStringDrawer() { -// Class cl; -// boolean java2d = true; -// try { -// cl = Class.forName("java.awt.Graphics2D"); -// } catch (ClassNotFoundException e) { -// java2d = false; -// } -// if(java2d) { -// stringDraw_ = new StringDrawer2(); -// } else { -// stringDraw_ = new StringDrawer1(); -// } -// } - - public LayerChild copy() { - SGLabel newLabel; - try { - newLabel = (SGLabel)clone(); - } catch (CloneNotSupportedException e) { - newLabel = new SGLabel(ident_, - proxy_.getText(), - proxy_.getHeightP(), - proxy_.getLocationP(), - proxy_.getVAlign(), - proxy_.getHAlign()); - newLabel.setColor(proxy_.getColor()); - newLabel.setFont(proxy_.getFont()); - if(proxy_.getOrientation() == ANGLE) { - newLabel.setAngle(proxy_.getAngle()); - } else { - newLabel.setOrientation(proxy_.getOrientation()); - } - } - return newLabel; - } - /** - * @since 3.0 - */ - public boolean equals(Object obj) { - if(obj == null || !(obj instanceof SGLabel)) return false; - SGLabel sg = (SGLabel)obj; -/* boolean t1 = !ident_.equals(sg.getId()); - boolean t2 = !proxy_.getText().equals(sg.getText()); - boolean t3 = proxy_.getHeightP() != sg.getHeightP(); - boolean t4 = !proxy_.getLocationP().equals(sg.getLocationP()); - boolean t5 = proxy_.getVAlign() != sg.getVAlign(); - boolean t6 = proxy_.getHAlign() != sg.getHAlign(); - boolean t7 = (proxy_.getColor() != null) && !proxy_.getColor().equals(sg.getColor()); - boolean t8 = (proxy_.getFont() != null) && !proxy_.getFont().equals(sg.getFont()); - boolean t9 = proxy_.getOrientation() != sg.getOrientation(); - if(t1 || t2 || t3 || t4 || t5 || t6 || t7 || t8 || t9) return false; */ - if((!ident_.equals(sg.getId())) || - (!proxy_.getText().equals(sg.getText())) || - (proxy_.getHeightP() != sg.getHeightP()) || - (!proxy_.getLocationP().equals(sg.getLocationP())) || - (proxy_.getVAlign() != sg.getVAlign()) || - (proxy_.getHAlign() != sg.getHAlign()) || - (proxy_.getColor() != null) && (!proxy_.getColor().equals(sg.getColor())) || - (proxy_.getFont() != null) && (!proxy_.getFont().equals(sg.getFont())) || - (proxy_.getOrientation() != sg.getOrientation())) return false; - if(proxy_.getOrientation() == ANGLE) { - if(proxy_.getAngle() != sg.getAngle()) return false; - } - return true; - } - - public void draw(Graphics g) throws LayerNotFoundException { - proxy_.draw(g); - } - public void setSelected(boolean sel) { - selected_ = sel; - } - public boolean isSelected() { - return selected_; - } - public void setSelectable(boolean select) { - selectable_ = select; - } - public boolean isSelectable() { - return selectable_; - } - /** - * Set the color. - * - * @param color The color of the label. - * @see java.awt.Color - **/ - public void setColor(Color color) { - Color clr = proxy_.getColor(); - if(clr == null || !clr.equals(color)) { - proxy_.setColor(color); - modified("SGLabel: setColor()"); - } - } - /** - * Get the color. - * - * @return The current color of the label. - **/ - public Color getColor() { - return proxy_.getColor(); - } - /** - * Set the font. - * - * @param fnt The Font to use to draw the label. - * @see java.awt.Font - **/ - public void setFont(Font fnt) { - Font font = proxy_.getFont(); - if(font == null || !font.equals(fnt)) { - proxy_.setFont(fnt); - modified("SGLabel: setFont()"); - } - } - /** - * Get the font. - * - * @return The current font for the label. - **/ - public Font getFont() { - return proxy_.getFont(); - } - /** - * Set the height of the label in physical coordinates. - * - * @param hgt The label height. - **/ - public void setHeightP(double hgt) { - double height = proxy_.getHeightP(); - if(height != hgt) { - proxy_.setHeightP(hgt); - modified("SGLabel: setHeightP()"); - } - } - /** - * Get the label height in physical coordinates. - * - * @return The label height. - **/ - public double getHeightP() { - return proxy_.getHeightP(); - } - /** - * Set the vertical and horizontal alignment. The vertical alignment - * can be TOP, MIDDLE, or BOTTOM, and the horizontal alignment - * LEFT, CENTER, or RIGHT. - * - * @param vert The vertical alignment. - * @param horz The horizontal alignment. - **/ - public void setAlign(int vert,int horz) { - int valign = proxy_.getVAlign(); - int halign = proxy_.getHAlign(); - if(valign != vert || halign != horz) { - proxy_.setVAlign(vert); - proxy_.setHAlign(horz); - modified("SGLabel: setAlign()"); - } - } - /** - * Set the horizontal alignment. The alignment can be LEFT, CENTER, - * or RIGHT. - * - * @param horz The horizontal alignment. - **/ - public void setHAlign(int horz) { - int halign = proxy_.getHAlign(); - if(halign != horz) { - proxy_.setHAlign(horz); - modified("SGLabeo: setHAlign()"); - } - } - /** - * Get the horizontal alignment. - * - * @return the horizontal alignment. - **/ - public int getHAlign() { - return proxy_.getHAlign(); - } - /** - * Set the vertical alignment. The alignment can be TOP, MIDDLE, - * or BOTTOM. - * - * @param vert The vertical alignment. - **/ - public void setVAlign(int vert) { - int valign = proxy_.getVAlign(); - if(valign != vert) { - proxy_.setVAlign(vert); - modified("SGLabel: setVAlign()"); - } - } - /** - * Get the vertical alignment. - * - * @return the vertical alignment. - **/ - public int getVAlign() { - return proxy_.getVAlign(); - } - /** - * Set the label reference location in physcial coordinates. - *
Property Change: location. - * - * @param loc physical location of label - **/ - public void setLocationP(Point2D.Double loc) { - Point2D.Double porigin = proxy_.getLocationP(); - if(porigin == null || !porigin.equals(loc)) { - Point2D.Double temp = porigin; - porigin = loc; - proxy_.setLocationP(loc); - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.firePropertyChange("location", - temp, - porigin); - modified("SGLabel: setLocationP()"); - } - } - /** - * Get the label reference location in physcial coordinates. - * - * @return the labels position. - **/ - public Point2D.Double getLocationP() { - return proxy_.getLocationP(); - } - /** - * Set the orientation. The orientation can be HORIZONTAL or - * VERTICAL. - * - * @param orient The orientation. - **/ - public void setOrientation(int orient) { - int or = proxy_.getOrientation(); - if(or != orient) { - proxy_.setOrientation(orient); - modified("SGLabel: setOrientation()"); - } - } - /** - * Get the origentation. - * - * @return the orientation - **/ - public int getOrientation() { - return proxy_.getOrientation(); - } - /** - * Draw label at arbitrary rotation. Warning: Rotated labels are - * not drawn very well when using JDK1.1. For best results use - * JDK1.2 or newer. - * @since 2.0 - */ - public void setAngle(double angle) { - proxy_.setAngle(angle); - } - /** - * Get label drawing angle. - * @since 2.0 - */ - public double getAngle() { - return proxy_.getAngle(); - } - /** - * - **/ - public void setLayer(Layer l) { - proxy_.setLayer(l); - } - /** - * Get the layer. - * - * @return the layer object. - **/ - public Layer getLayer() { - return proxy_.getLayer(); - } - - public AbstractPane getPane() { - return proxy_.getLayer().getPane(); - } - - public void modified(String text) { - Layer layer = proxy_.getLayer(); - if(layer != null) { - layer.modified(text); - } - } - - /** - * Get the label text. - * - * @return the label text - **/ - public String getText() { - return proxy_.getText(); - } - /** - * Set the label text. - * - * @param lbl the label text - **/ - public void setText(String lbl) { - String label = proxy_.getText(); - if(label == null || !label.equals(lbl)) { - proxy_.setText(lbl); - modified("SGLabel: setText()"); - } - } - /** - * Get the label identifier. - * - * @return the identifier - **/ - public String getId() { - return ident_; - } - /** - * Set the label identifier. - * - * @param id the label identifier - */ - public void setId(String id) { - ident_ = id; - } - /** - * Get the label height in device coordinates. - * - * @return the label height - **/ - public int getHeight() { - return 0; - } - /** - * Get the label position in device coordinates. - * - * @return the label position - **/ - public Point getLocation() { - return proxy_.getLocation(); - } - /** - * Set the label reference location in pixel coordinates. - *
Property Change: location. - * - * @param loc physical location of label - **/ - public void setLocation(Point loc) { - Point dloc = proxy_.getLocation(); - if(dloc.x != loc.x || dloc.y != loc.y) { - Point temp = new Point(dloc.x, dloc.y); - proxy_.setLocation(loc); - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.firePropertyChange("location", - temp, - loc); - } - } - /** - * Get the label bounds in physical units. - * - * @return the label bounds - **/ - public Rectangle2D.Double getBoundsP() { - return proxy_.getBoundsP(); - } - /** - * Get the label bounds in device units. - * - * @return the label bounds - **/ - public Rectangle getBounds() { - return proxy_.getBounds(); - } - /** - * Set the label bounds in device units. - */ - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - /** - * Set the label bounds in device units. - */ - public void setBounds(int x, int y, int width, int height) { - proxy_.setBounds(x, y, width, height); - } - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - public boolean isVisible() { - return proxy_.isVisible(); - } - public void setVisible(boolean visible) { - boolean vis = proxy_.isVisible(); - if(vis != visible) { - proxy_.setVisible(visible); - modified("SGLabel: setVisible()"); - } - } - public boolean isMoveable() { - return moveable_; - } - public void setMoveable(boolean moveable) { - if(moveable_ != moveable) { - moveable_ = moveable; - modified("SGLabel: setMoveable()"); - } - } - /** - * Get the string width in device units. - * @since 2.0 - */ - public float getStringWidth(Graphics g) { - return proxy_.getStringWidth(g); - } - /** - * Get the string height in device units. - * @since 2.0 - */ - public float getStringHeight(Graphics g) { - return proxy_.getStringHeight(g); - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Selectable.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Selectable.java deleted file mode 100755 index a28ad960..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Selectable.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * $Id: Selectable.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.Rectangle; - -/** - * Interface indicates that object can be selected with a mouse click. - * To be moveable the object must implement the Moveable - * interface. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - * @see Moveable - */ -public interface Selectable { - /** - * Sets the selected property. - * - * @param sel true if selected, false if not. - */ - public void setSelected(boolean sel); - /** - * Returns true if the object's selected property is set. - * - * @return true if selected, false if not. - */ - public boolean isSelected(); - /** - * Gets the bounding rectangle in device - * coordinates. - * - * @return bounding rectangle - */ - public Rectangle getBounds(); - /** - * Returns true if the current state is selectable. - * - * @return true if selectable - */ - public boolean isSelectable(); - /** - * Set the Selectable property. - * - * @param select if true object is selectable - */ - public void setSelectable(boolean select); - /** - * Change the selected objects bounding rectangle - * in device coordinates. - * The object will move to the new bounding rectangle. - * - * @param bnds new bounding rectangle - */ -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SineTransform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SineTransform.java deleted file mode 100755 index 98330f59..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SineTransform.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * $Id: SineTransform.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTRange; - -/** - * Performs a sine(x) transform on a cartesian axis. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.x - */ -public class SineTransform extends AxisTransform implements Cloneable { - public SineTransform() { - super(); - } - public SineTransform(double p1,double p2,double u1,double u2) { - super(p1, p2, u1, u2); - } - public SineTransform(Range2D pr,Range2D ur) { - super(pr, ur); - } - public SineTransform(double p1,double p2,GeoDate t1,GeoDate t2) { - super(p1, p2, t1, t2); - } - public SineTransform(Range2D pr,TimeRange tr) { - super(pr, tr); - } - public SineTransform(Range2D pr, SoTRange str) { - super(pr, str); - } - public AxisTransform copy() { - SineTransform newTransform; - try { - newTransform = (SineTransform)clone(); - } catch (CloneNotSupportedException e) { - newTransform = new SineTransform(); - } - return (AxisTransform)newTransform; - } - public double getTransP(double u) { - throw new MethodNotImplementedError(); - } - public double getTransP(GeoDate t) { - throw new MethodNotImplementedError(); - } - public double getTransP(long t) { - throw new MethodNotImplementedError(); - } - public double getTransP(SoTValue v) { - throw new MethodNotImplementedError(); - } - public double getTransU(double p) { - throw new MethodNotImplementedError(); - } - public GeoDate getTimeTransU(double p) { - throw new MethodNotImplementedError(); - } - public long getLongTimeTransU(double p) { - throw new MethodNotImplementedError(); - } - public SoTValue getSoTTransU(double p) { - throw new MethodNotImplementedError(); - } - void computeTransform() { - throw new MethodNotImplementedError(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SpaceAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SpaceAxis.java deleted file mode 100755 index 616159ef..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/SpaceAxis.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * $Id: SpaceAxis.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.TimePoint; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTRange; - -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Color; -import java.awt.Rectangle; -// jdk1.2 -//import java.awt.geom.Point2D; - -/** - * Abstract base class for axes whose user coordinates are double values. - * The following is an example of using a {@link PlainAxis}. - * - *
- * import gov.noaa.pmel.sgt.PlainAxis;
- * import gov.noaa.pmel.sgt.LinearTransform;
- * import gov.noaa.pmel.sgt.Graph;
- * ...
- * Graph graph;
- * PlainAxis xbot, xtop;
- * LinearTransform xt;
- * Point2D.Double lowerleft = new Point2D.Double(10.0, 100.0);
- * ...
- * //
- * // Instatiate xt and set it as the x transform.
- * //
- * xt = new LinearTransform(0.75, 3.5, 10.0, 100.0);
- * graph.setXTransform(xt);
- * ...
- * //
- * // Instatiate xbot and set its range, delta, and
- * // location.  Set xbot the numberSmallTics property
- * // for xbot.
- * //
- * xbot = new PlainAxis("Bottom Axis");
- * xbot.setRangeU(new Range2D(10.0, 100.0));
- * xbot.setDeltaU(20.0);
- * xbot.setNumberSmallTics(4);
- * xbot.setLocationU(lowerleft);
- * //
- * // Create title for xbot.
- * //
- * Font xbfont = new Font("Helvetica", Font.ITALIC, 14);
- * xbot.setLabelFont(xbfont);
- * SGLabel xtitle = new SGLabel("xaxis title",
- *                              "Test X-Axis Title",
- *                              new Point2D.Double(0.0, 0.0));
- * Font xtfont = new Font("Helvetica", Font.PLAIN, 14);
- * xtitle.setFont(xtfont);
- * xtitle.setHeightP(0.2);
- * xbot.setTitle(xtitle);
- * graph.setXAxis(xbot);
- * ...
- * //
- * // Instatiate xtop and set its range, delta, and
- * // location.  Set xtop properties on ticPosition and
- * // labelPosition.
- * //
- * xtop = new PlainAxis("Top Axis");
- * xtop.setRangeU(new Range2D(10.0, 100.0));
- * xtop.setDeltaU(20.0);
- * xtop.setNumberSmallTics(0);
- * xtop.setLocationU(new Point2D.Double(10.0, 300.0));
- * xtop.setLabelFont(xbfont);
- * xtop.setTicPosition(Axis.POSITIVE_SIDE);
- * xtop.setLabelPosition(Axis.NO_LABEL);
- * graph.setXAxis(xtop);
- * ...
- * //
- * // Register the x transform and the top x axis with the bottom x axis.
- * // By registering xt and xtop, any updates to the user or physical range
- * // of xbot will be automatically performed on xt and xtop.
- * //
- * xbot.register(xt);
- * xbot.register(xtop);
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - * @see Axis - * @see PlainAxis - * @see TimeAxis -**/ -public abstract class SpaceAxis extends Axis { - protected Range2D uRange_; - protected Point2D.Double uLocation_; - protected TimePoint tLocation_; - static final double TIC_GAP = 0.05; - static final double TIC_RATIO = 1.3; - static final double LABEL_RATIO = 1.3; - // - protected void updateRegisteredTransforms() { - if(!registeredTransforms_.isEmpty()) { - AxisTransform trns; - for(Enumeration it = registeredTransforms_.elements(); - it.hasMoreElements();) { - trns = (AxisTransform)it.nextElement(); - trns.setRangeP(pRange_); - trns.setRangeU(uRange_); - } - } - } - // - protected void updateRegisteredAxes() { - if(!registeredAxes_.isEmpty()) { - SpaceAxis ax; - for(Enumeration it = registeredAxes_.elements(); - it.hasMoreElements();) { - ax = (SpaceAxis)it.nextElement(); - ax.setRangeU(uRange_); - ax.setRangeP(pRange_); - } - } - } - // - protected void drawSmallXTics(Graphics g,double xu,double xtest,double del,double yp) { - int x0, y0, y1, i; - double yp0, yp1, smdel, xt; - if(numSmallTics_ <= 0) return; - // yp = graph_.getYUtoP(yu); - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yp0 = yp + smallTicHeight_; - } else { - yp0 = yp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yp1 = yp - smallTicHeight_; - } else { - yp1 = yp; - } - y0 = graph_.getLayer().getYPtoD(yp0); - y1 = graph_.getLayer().getYPtoD(yp1); - smdel = del/(numSmallTics_ + 1); - for(i=0; i <= numSmallTics_; i++) { - xt = xu + smdel*i; - if((xtest - xt)/del >= 0) { - x0 = graph_.getXUtoD(xt); - g.drawLine(x0, y0, x0, y1); - } - } - } - // - protected void drawSmallYTics(Graphics g,double xp,double yu,double ytest,double del) { - int x0, x1, y0, i; - double xp0, xp1, smdel, yt; - if(numSmallTics_ <= 0) return; - // xp = graph_.getXUtoP(xu); - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xp0 = xp + smallTicHeight_; - } else { - xp0 = xp; - } - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xp1 = xp - smallTicHeight_; - } else { - xp1 = xp; - } - x0 = graph_.getLayer().getXPtoD(xp0); - x1 = graph_.getLayer().getXPtoD(xp1); - smdel = del/(numSmallTics_ + 1); - for(i=0; i <= numSmallTics_; i++) { - yt = yu + smdel*i; - if((ytest - yt)/del >= 0) { - y0 = graph_.getYUtoD(yt); - g.drawLine(x0, y0, x1, y0); - } - } - } - /** - * Default constructor for SpaceAxis. - **/ - public SpaceAxis() { - this(""); - } - /** - * Constructor for Axis. Sets the axis identifier and initializes - * the defaults. - * - * @param id axis identification - **/ - public SpaceAxis(String id) { - super(id); - space_ = true; - numSmallTics_ = 0; - } - /** - * Set the number of significant digits in the label. This is - * used if a format is not specified. - * - * @param nsig number of significant digits - **/ - public void setSignificantDigits(int nsig) { - if(sigDigits_ != nsig) { - sigDigits_ = nsig; - modified("SpaceAxis: setSignificantDigits()"); - } - } - /** - * Get the number of significant digits in the label. - * - * @return number of significant digits. - **/ - public int getSignificantDigits() { - return sigDigits_; - } - /** - * Set the label interval. - * - * @param lint label interval. - **/ - public void setLabelInterval(int lint) { - if(labelInterval_ != lint) { - labelInterval_ = lint; - modified("SpaceAxis: setLabelInterval()"); - } - } - /** - * Get the label interval. - * - * @return label interval - **/ - public int getLabelInterval() { - return labelInterval_; - } - /** - * Set the label format. Format should be in the sprintf style. - * The formating uses the Format class in the Core Java book. - * A null or empty string will cause formating to use the significant - * digits. - * - *
-   * Gary Cornell and Cay S. Horstmann, Core Java (Book/CD-ROM)
-   * Published By SunSoft Press/Prentice-Hall
-   * Copyright (C) 1996 Sun Microsystems Inc.
-   * All Rights Reserved. ISBN 0-13-596891-7
-   * 
- * - * @param frmt label format. - **/ - public void setLabelFormat(String frmt) { - if(labelFormat_ == null || !labelFormat_.equals(frmt)) { - if(frmt == null) { - labelFormat_ = ""; - } else { - labelFormat_ = frmt; - } - modified("SpaceAxis: setLabelFormat()"); - } - } - /** - * Get the label format. - * - * @return label format - **/ - public String getLabelFormat() { - return labelFormat_; - } - /** - * Set the user range to draw the axis. Registered Axes and AxisTransforms - * will be updated. - * - * @param ur range in user coordinates - **/ - public void setRangeU(Range2D ur) { - if(uRange_ == null || !uRange_.equals(ur)) { - uRange_ = ur; - updateRegisteredAxes(); - updateRegisteredTransforms(); - modified("SpaceAxis: setRangeU()"); - } - } - public void setRangeU(SoTRange ur) { - setRangeU(new Range2D(((SoTRange.Double)ur).start, - ((SoTRange.Double)ur).end, - ((SoTRange.Double)ur).delta)); - } - /** - * Get the user range. - * - * @return range in user coordinates - **/ - public Range2D getRangeU() { - return uRange_; - } - public SoTRange getSoTRangeU() { - return new SoTRange.Double(uRange_); - } - /** - * Set the increment between large tics. - * - * @param delta increment in user coordinates - **/ - public void setDeltaU(double delta) { - if(uRange_.delta != delta) { - uRange_.delta = delta; - modified("SpaceAxis: setDeltaU()"); - } - } - /** - * Get the increment between large tics. - * - * @return user coordinate increment - **/ - public double getDeltaU() { - return uRange_.delta; - } - /** - * Set the origin in user units of the axis. - * - * @param upt origin in user units - **/ - public void setLocationU(TimePoint uptt) { - if(tLocation_ == null || !tLocation_.equals(uptt)) { - tLocation_ = uptt; - uLocation_ = null; - modified("SpaceAxis: setLocationU(TimePoint)"); - } - } - /** - * Set the origin in user units of the axis. - * - * @param upt origin in user units - **/ - public void setLocationU(Point2D.Double upt) { - if(uLocation_ == null || !uLocation_.equals(upt)) { - uLocation_ = upt; - tLocation_ = null; - modified("SpaceAxis: setLocationU(Point2D)"); - } - } - public void setLocationU(SoTPoint upt) { - double x; - double y; - if(upt.isXTime() || upt.isYTime()) { - long t; - if(upt.isXTime()) { - t = upt.getX().getLongTime(); - x = ((SoTValue.Double)upt.getY()).getValue(); - } else { - t = upt.getY().getLongTime(); - x = ((SoTValue.Double)upt.getX()).getValue(); - } - setLocationU(new TimePoint(x, new GeoDate(t))); - } else { - x = ((SoTValue.Double)upt.getX()).getValue(); - y = ((SoTValue.Double)upt.getY()).getValue(); - setLocationU(new Point2D.Double(x,y)); - } - } - /** - * Get the origin in user units of the axis - * - * @return origin - **/ - public Point2D.Double getLocationU() { - return uLocation_; - } - /** - * Get the origin in user units of the axis - * - * @return origin - **/ - public TimePoint getTimeLocationU() { - return tLocation_; - } - public SoTPoint getSoTLocationU() { - if(tLocation_ == null) { - return new SoTPoint(uLocation_.x, uLocation_.y); - } else { - if(orientation_ == HORIZONTAL) { - return new SoTPoint(tLocation_.t, tLocation_.x); - } else { - return new SoTPoint(tLocation_.x, tLocation_.t); - } - } - } - // - abstract void draw(Graphics g); - /** - * Get the bounding box for the axis in device units. - * - * @return bounding box - * @see Rectangle - **/ - public abstract Rectangle getBounds(); - - public void modified(String mess) { - // if(Debug.EVENT) System.out.println("SpaceAxis: modified()"); - if(graph_ != null) - graph_.modified(mess); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StackedLayout.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StackedLayout.java deleted file mode 100755 index 76ddafea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StackedLayout.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * $Id: StackedLayout.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.beans.Panel; -import java.awt.LayoutManager; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.Component; -import java.awt.Insets; - -/** - * StackedLayout works with Pane to - * position multiple Layers directly over each other. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - * @see Pane#setLayout - * @see Layer - */ -public class StackedLayout implements LayoutManager { - public Dimension preferredLayoutSize(Container parent) { - synchronized (parent.getTreeLock()) { - return parent.getSize(); - } - } - public Dimension minimumLayoutSize(Container parent) { - synchronized (parent.getTreeLock()) { - return parent.getSize(); - } - } - public void layoutContainer(Container parent) { - synchronized (parent.getTreeLock()) { - JPane pane = null; - boolean batch = false; - if(parent instanceof JPane) { - pane = (JPane)parent; - batch = pane.isBatch(); - pane.setBatch(true, "StackedLayout"); - } else if(parent instanceof Panel) { - pane = ((Panel)parent).getPane(); - batch = pane.isBatch(); - pane.setBatch(true, "StackedLayout"); - } - Insets insets = parent.getInsets(); - Rectangle rect = parent.getBounds(); - int ncomponents = parent.getComponentCount(); - int x, y, w, h; - x = rect.x + insets.left; - y = rect.y + insets.top; - w = rect.width - (insets.left + insets.right); - h = rect.height - (insets.top + insets.bottom); - for(int i=0; i < ncomponents; i++) { - parent.getComponent(i).setBounds(x, y, w, h); - } - if(!batch) pane.setBatch(false, "StackedLayout"); - } - } - public void removeLayoutComponent(Component comp) { - } - public void addLayoutComponent(String name, Component comp) { - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer.java deleted file mode 100755 index eff9149f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * $Id: StrokeDrawer.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; - - -/** - * Defines the methods that implement stroke drawing in sgt. This - * interface is necessary since sgt v2.0 will use Java2D functionality - * to draw strokes if it is available. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.1 - */ -public interface StrokeDrawer { - - public void drawHeavy(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr); - - public void drawDashed(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr); - - public void drawStroke(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr); - - public void drawHighlight(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr); -} - - - - - - - - - - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer1.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer1.java deleted file mode 100755 index 9e419b81..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer1.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * $Id: StrokeDrawer1.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; - -/** - * Implements stroke drawing for JDK1.1 - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.1 - */ -public class StrokeDrawer1 implements StrokeDrawer, Cloneable { - - public void drawHeavy(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr) { - g.drawPolyline(xout, yout, size); - } - - public void drawDashed(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr) { - g.drawPolyline(xout, yout, size); - } - - public void drawStroke(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr) { - g.drawPolyline(xout, yout, size); - } - - public void drawHighlight(Graphics g, int[] x, int[] y, int size, - LineAttribute attr) { - int[] xr = new int[size]; - int[] yr = new int[size]; - int i; - Color col = attr.getColor(); - Color rev = new Color(255 - col.getRed(), - 255 - col.getGreen(), - 255 - col.getBlue()); - // - // simple hightlight draw with pixel displacements in reverse - // color - // - g.setPaintMode(); - for(i=0; i < size; i++) { - xr[i] = x[i] + 1; - yr[i] = y[i] + 1; - } - g.setColor(col); - g.drawPolyline(xr, yr, size); - for(i=0; i < size; i++) { - xr[i] = x[i] - 1; - yr[i] = y[i] - 1; - } - g.drawPolyline(xr, yr, size); - g.setColor(rev); - g.drawPolyline(x, y, size); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer2.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer2.java deleted file mode 100755 index 8257ec74..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/StrokeDrawer2.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * $Id: StrokeDrawer2.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; -import java.awt.geom.*; - -/** - * Implements stroke drawing using Java2D functionality. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.1 - */ -public class StrokeDrawer2 implements StrokeDrawer, Cloneable { - - public void drawHeavy(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr) { - Graphics2D g2 = (Graphics2D)g; - Stroke saved = g2.getStroke(); - BasicStroke stroke = new BasicStroke(attr.getWidth()); - g2.setStroke(stroke); - g2.drawPolyline(xout, yout, size); - g2.setStroke(saved); - } - - public void drawDashed(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr) { - Graphics2D g2 = (Graphics2D)g; - Stroke saved = g2.getStroke(); - float[] dashes = {4.0f, 4.0f}; - BasicStroke stroke = new BasicStroke(1.0f, - BasicStroke.CAP_SQUARE, - BasicStroke.JOIN_MITER, - 10.0f, - dashes, - 0.0f); - g2.setStroke(stroke); - g2.drawPolyline(xout, yout, size); - g2.setStroke(saved); - } - - public void drawStroke(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr) { - - Graphics2D g2 = (Graphics2D)g; - Stroke saved = g2.getStroke(); - BasicStroke stroke; - float[] arr = attr.getDashArray(); - if(arr == null || (arr.length <= 1)) { - stroke = new BasicStroke(attr.getWidth(), - attr.getCapStyle(), - attr.getMiterStyle(), - attr.getMiterLimit()); - } else { - stroke = new BasicStroke(attr.getWidth(), - attr.getCapStyle(), - attr.getMiterStyle(), - attr.getMiterLimit(), - attr.getDashArray(), - attr.getDashPhase()); - } - g2.setStroke(stroke); - g2.drawPolyline(xout, yout, size); - g2.setStroke(saved); - } - - public void drawHighlight(Graphics g, int[] xout, int[] yout, int size, - LineAttribute attr) { - Graphics2D g2 = (Graphics2D)g; - Stroke saved = g2.getStroke(); - BasicStroke stroke = new BasicStroke(2.75f); - Color col = attr.getColor(); - Color rev = new Color(255 - col.getRed(), - 255 - col.getGreen(), - 255 - col.getBlue()); - g2.setColor(rev); - g2.setStroke(stroke); - g2.drawPolyline(xout, yout, size); - g2.setColor(col); - g2.setStroke(saved); - g2.drawPolyline(xout, yout, size); - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TableLookupTransform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TableLookupTransform.java deleted file mode 100755 index 8b5304ab..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TableLookupTransform.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * $Id: TableLookupTransform.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * Description of Class TableLookupTransform - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.x - */ -public class TableLookupTransform implements Cloneable, Transform { - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private double[] pvals_; - private double[] uvals_; - public TableLookupTransform() { - } - public TableLookupTransform(double p1,double p2,double u1,double u2) { - } - public TableLookupTransform(Range2D pr,Range2D ur) { - } - public TableLookupTransform(double[] p,double[] u) throws DataNotSameShapeException { - } - public void setRangeP(Range2D pr) { - throw new MethodNotImplementedError(); - } - public void setRangeP(double pmin,double pmax) { - throw new MethodNotImplementedError(); - } - public Range2D getRangeP() { - throw new MethodNotImplementedError(); - } - public void setRangeU(Range2D ur) { - throw new MethodNotImplementedError(); - } - public void setRangeU(double umin,double umax) { - throw new MethodNotImplementedError(); - } - public Range2D getRangeU() { - throw new MethodNotImplementedError(); - } - public void setDoInteger(boolean si) { - throw new MethodNotImplementedError(); - } - public boolean getDoInteger() { - throw new MethodNotImplementedError(); - } - public double getTransP(double u) { - throw new MethodNotImplementedError(); - } - public double getTransU(double p) { - throw new MethodNotImplementedError(); - } - void computeTransform() { - throw new MethodNotImplementedError(); - } - /** - * Add listener to changes in TableLookupTransform properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - changes_.addPropertyChangeListener(listener); - } - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TimeAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TimeAxis.java deleted file mode 100755 index a0be4d43..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TimeAxis.java +++ /dev/null @@ -1,784 +0,0 @@ -/* - * $Id: TimeAxis.java,v 1.1.1.2 2008/12/19 13:29:32 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.TimePoint; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTRange; - -import java.util.Enumeration; -import java.util.Vector; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Color; -// jdk1.2 -//import java.awt.geom.Point2D; - -/** - * Base class for time axes. A time axis is an axis whose user units - * are GeoDate objects. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.2 $, $Date: 2008/12/19 13:29:32 $ - * @since 1.0 - * @see Axis - */ -public class TimeAxis extends Axis implements Cloneable{ - // - protected TimeRange tRange_; - protected TimePoint tLocation_; - // - protected String minorLabelFormat_; - protected int minorLabelInterval_; - protected String majorLabelFormat_; - protected int majorLabelInterval_; - // - protected double yminor_; - // - protected double ymajor_; - protected double xminor_; - protected double xmajor_; - protected int vertalign_; - // - /**@shapeType AggregationLink - @associates TimeAxisStyle - * @supplierCardinality 1 - * @byValue */ - protected TimeAxisStyle txt_; - protected int axisStyle_; - static final double TIC_RATIO__ = 1.3; - static final double TIC_GAP__ = 0.05; - static final double LABEL_RATIO__ = 1.0; - static final double MAJOR_LABEL_RATIO__ = 1.25; - - static final double defaultLargeTicHeight__ = 0.1; - static final double defaultSmallTicHeight__ = 0.05; - static final int defaultTicPosition__ = Axis.NEGATIVE_SIDE; - static final int defaultLabelPosition__ = Axis.NEGATIVE_SIDE; - static final double defaultLabelHeight__ = 0.15; - /** - * Automatically select the time axis style - */ - public static final int AUTO = 0; - /** - * Use the YearDecadeAxis style. - *
-   *   |..........|..........|..........|..........|
-   *        84         85         86         87
-   *                       1980
-   * 
- */ - public static final int YEAR_DECADE = 1; - /** - * Use the MonthYearAxis style. - *
-   *   |..........|..........|..........|..........|
-   *        Mar        Apr        May       Jun
-   *                       1980
-   * 
- */ - public static final int MONTH_YEAR = 2; - /** - * Use the DayMonthAxis style. - *
-   *   |..........|..........|..........|..........|
-   *        3          4          5           6
-   *                        1993-04
-   * 
- */ - public static final int DAY_MONTH = 3; - /** - * Use the HourDayAxis style. - *
-   *   |..........|..........|..........|..........|
-   *   03         04         05         06         07
-   *                     1987-06-07
-   * 
- */ - public static final int HOUR_DAY = 4; - /** - * Use the MinuteHourAxis style. - *
-   *   |..........|..........|..........|..........|
-   *   15         30         45         00         15
-   *                   1987-06-07 13
-   * 
- */ - public static final int MINUTE_HOUR = 5; - - private void setAuto() { - TimeAxisStyle newStyle = null; - - GeoDate delta = tRange_.end.subtract(tRange_.start); - double days = ((double)Math.abs(delta.getTime()))/((double)GeoDate.MSECS_IN_DAY); - if(Debug.TAXIS) { - System.out.println("setAuto: days = " + days); - } - if(days > 1000.0) { - if(!(txt_ instanceof YearDecadeAxis)) { - newStyle = (TimeAxisStyle)new YearDecadeAxis(); - } - } else if(days > 91.0) { - if(!(txt_ instanceof MonthYearAxis)) { - newStyle = (TimeAxisStyle)new MonthYearAxis(); - } - } else if(days > 5.0) { - if(!(txt_ instanceof DayMonthAxis)) { - newStyle = (TimeAxisStyle)new DayMonthAxis(); - } - } else if((days > 0.1666667)) { // 6 hours - if(!(txt_ instanceof HourDayAxis)) { - newStyle = (TimeAxisStyle)new HourDayAxis(); - } - } else { - if(!(txt_ instanceof MinuteHourAxis)) { - newStyle = (TimeAxisStyle)new MinuteHourAxis(); - } - } - if(newStyle != null) { - txt_ = newStyle; - // } else { - // return; - } - txt_.computeDefaults(delta); - - minorLabelFormat_ = txt_.getDefaultMinorLabelFormat(); - majorLabelFormat_ = txt_.getDefaultMajorLabelFormat(); - minorLabelInterval_ = txt_.getDefaultMinorLabelInterval(); - majorLabelInterval_ = txt_.getDefaultMajorLabelInterval(); - numSmallTics_ = txt_.getDefaultNumSmallTics(); -// largeTicHeight_ = txt_.getDefaultLargeTicHeight(); -// smallTicHeight_ = txt_.getDefaultSmallTicHeight(); -// ticPosition_ = txt_.getDefaultTicPosition(); -// labelPosition_ = txt_.getDefaultLabelPosition(); -// labelHeight_ = txt_.getDefaultLabelHeight(); - if(Debug.TAXIS) { - System.out.println(" style, ticPosition, labelPostiion = " + - txt_.toString() + ", " + ticPosition_ + ", " + labelPosition_); - System.out.println(" minorFormat, majorFormat, minorInterval, majorInterval = " + - minorLabelFormat_ + ", " + majorLabelFormat_ + ", " + - minorLabelInterval_ + ", " + majorLabelInterval_); - System.out.println(" smallTics, largeHgt, smallHgt, labelHgt = " + - numSmallTics_ + ", " + largeTicHeight_ + ", " + smallTicHeight_ + ", " + labelHeight_); - } - } - protected void updateRegisteredTransforms() { - if(!registeredTransforms_.isEmpty()) { - AxisTransform trns; - for(Enumeration it = registeredTransforms_.elements(); - it.hasMoreElements();) { - trns = (AxisTransform)it.nextElement(); - trns.setRangeP(pRange_); - trns.setRangeU(tRange_); - } - } - } - // - protected void updateRegisteredAxes() { - if(!registeredAxes_.isEmpty()) { - TimeAxis ax; - for(Enumeration it = registeredAxes_.elements(); - it.hasMoreElements();) { - ax = (TimeAxis)it.nextElement(); - ax.setRangeU(tRange_); - ax.setRangeP(pRange_); - } - } - } - protected void setupDraw(double val) { - if(orientation_ == Axis.HORIZONTAL) { - if(labelPosition_ == POSITIVE_SIDE) { - vertalign_ = SGLabel.BOTTOM; - if(minorLabelInterval_ == 0) { - yminor_ = val; - } else if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - yminor_ = val + TIC_RATIO__*largeTicHeight_; - } else { - yminor_ = val + TIC_GAP__; - } - ymajor_ = yminor_ + LABEL_RATIO__*labelHeight_; - } else { - vertalign_ = SGLabel.TOP; - if(minorLabelInterval_ == 0) { - yminor_ = val; - } else if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - yminor_ = val - TIC_RATIO__*largeTicHeight_; - } else { - yminor_ = val - TIC_GAP__; - } - ymajor_ = yminor_ - LABEL_RATIO__*labelHeight_; - } - } else { - if(labelPosition_ == NEGATIVE_SIDE) { - vertalign_ = SGLabel.BOTTOM; - if(minorLabelInterval_ == 0) { - xminor_ = val; - } else if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xminor_ = val - TIC_RATIO__*largeTicHeight_; - } else { - xminor_ = val - TIC_GAP__; - } - xmajor_ = xminor_ - LABEL_RATIO__*labelHeight_; - } else { - vertalign_ = SGLabel.TOP; - if(minorLabelInterval_ == 0) { - xminor_ = val; - } else if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xminor_ = val + TIC_RATIO__*largeTicHeight_; - } else { - xminor_ = val + TIC_GAP__; - } - xmajor_ = xminor_ + LABEL_RATIO__*labelHeight_; - } - } - } - protected void drawMinorLabel(Graphics g,double val,GeoDate time) { - SGLabel label; - Color saved = g.getColor(); - if(orientation_ == Axis.HORIZONTAL) { - label = new SGLabel("minor", time.toString(minorLabelFormat_), - new Point2D.Double(val, yminor_)); - label.setOrientation(SGLabel.HORIZONTAL); - } else { - label = new SGLabel("minor", time.toString(minorLabelFormat_), - new Point2D.Double(xminor_, val)); - label.setOrientation(SGLabel.VERTICAL); - } - label.setAlign(vertalign_, SGLabel.CENTER); - label.setFont(labelFont_); - label.setColor(labelColor_); - label.setHeightP(labelHeight_); - label.setLayer(graph_.getLayer()); - try { - label.draw(g); - } catch (LayerNotFoundException e) {} - g.setColor(saved); - } - protected void drawMajorLabel(Graphics g,double val,GeoDate time) { - Color saved = g.getColor(); - SGLabel label; - if(orientation_ == Axis.HORIZONTAL) { - label = new SGLabel("major", time.toString(majorLabelFormat_), - new Point2D.Double(val, ymajor_)); - label.setOrientation(SGLabel.HORIZONTAL); - } else { - label = new SGLabel("major", time.toString(majorLabelFormat_), - new Point2D.Double(xmajor_, val)); - label.setOrientation(SGLabel.VERTICAL); - } - label.setAlign(vertalign_, SGLabel.CENTER); - label.setFont(labelFont_); - label.setColor(labelColor_); - label.setHeightP(MAJOR_LABEL_RATIO__*labelHeight_); - label.setLayer(graph_.getLayer()); - try { - label.draw(g); - } catch (LayerNotFoundException e) {} - g.setColor(saved); - } - // - /** - * Default contructor. - **/ - public TimeAxis(int style) { - this("", style); - } - /** - * TimeAxis constructor. - * - * @param id axis identifier - **/ - public TimeAxis(String id,int style) { - super(id); - minorLabelInterval_ = 2; - majorLabelInterval_ = 1; - numSmallTics_ = 0; - space_ = false; - axisStyle_ = style; - // - if(axisStyle_ == AUTO || axisStyle_ == MONTH_YEAR) { - txt_ = (TimeAxisStyle)new MonthYearAxis(); - } else if(axisStyle_ == YEAR_DECADE) { - txt_ = (TimeAxisStyle)new YearDecadeAxis(); - } else if(axisStyle_ == DAY_MONTH) { - txt_ = (TimeAxisStyle)new DayMonthAxis(); - } else if(axisStyle_ == HOUR_DAY) { - txt_ = (TimeAxisStyle)new HourDayAxis(); - } else { - txt_ = (TimeAxisStyle)new MinuteHourAxis(); - } - minorLabelFormat_ = txt_.getDefaultMinorLabelFormat(); - majorLabelFormat_ = txt_.getDefaultMajorLabelFormat(); - minorLabelInterval_ = txt_.getDefaultMinorLabelInterval(); - majorLabelInterval_ = txt_.getDefaultMajorLabelInterval(); - numSmallTics_ = txt_.getDefaultNumSmallTics(); -// - largeTicHeight_ = defaultLargeTicHeight__; - smallTicHeight_ = defaultSmallTicHeight__; - ticPosition_ = defaultTicPosition__; - labelPosition_ = defaultLabelPosition__; - labelHeight_ = defaultLabelHeight__; - tRange_ = null; - tLocation_ = null; - } - public Axis copy() { - TimeAxis newAxis; - try { - newAxis = (TimeAxis)clone(); - } catch (CloneNotSupportedException e) { - newAxis = new TimeAxis(getStyle()); - } - // - // remove registered axes and transforms - // - newAxis.registeredAxes_ = new Vector(2,2); - newAxis.registeredTransforms_ = new Vector(2,2); - // - return newAxis; - } - /** - * Set the minor and major label formats. - * - * @param minor minor label format - * @param major major label format - **/ - public void setLabelFormat(String minor,String major) { - if(minorLabelFormat_ == null || - majorLabelFormat_ == null || - !minorLabelFormat_.equals(minor) || - !majorLabelFormat_.equals(major)) { - - minorLabelFormat_ = minor; - majorLabelFormat_ = major; - modified("TimeAxis: setLabelFormat()"); - } - } - /** - * Set the minor label format. - * - * @param minor minor label format - **/ - public void setMinorLabelFormat(String minor) { - if(minorLabelFormat_ == null || !minorLabelFormat_.equals(minor)) { - minorLabelFormat_ = minor; - modified("TimeAxis: setMinorLabelFormat()"); - } - } - /** - * Set the major label format. - * - * @param major major label format - **/ - public void setMajorLabelFormat(String major) { - if(majorLabelFormat_ == null || !majorLabelFormat_.equals(major)) { - majorLabelFormat_ = major; - modified("TimeAxis: setMajorLabelFormat()"); - } - } - /** - * Get the minor label format. - * - * @return minor label format - **/ - public String getMinorLabelFormat() { - return minorLabelFormat_; - } - /** - * Get the major label format. - * - * @return major label format - **/ - public String getMajorLabelFormat() { - return majorLabelFormat_; - } - /** - * Set the minor and major label intervals. - * - * @param minor minor label interval - * @param major major label interval - **/ - public void setLabelInterval(int minor,int major) { - if(minorLabelInterval_ != minor || majorLabelInterval_ != major) { - minorLabelInterval_ = minor; - majorLabelInterval_ = major; - modified("TimeAxis: setLabelInterval()"); - } - } - /** - * Set the minor label interval. - * - * @param minor minor label interval - **/ - public void setMinorLabelInterval(int minor) { - if(minorLabelInterval_ != minor) { - minorLabelInterval_ = minor; - modified("TimeAxis: setMinorLabelInterval()"); - } - } - /** - * Set the major label interval. - * - * @param major major label interval - **/ - public void setMajorLabelInterval(int major) { - if(majorLabelInterval_ != major) { - majorLabelInterval_ = major; - modified("TimeAxis: setMajorLabelInterval()"); - } - } - /** - * Get the minor label interval. - * - * @return minor label interval - **/ - public int getMinorLabelInterval() { - return minorLabelInterval_; - } - /** - * Get the major label interval. - * - * @return major label interval - **/ - public int getMajorLabelInterval() { - return majorLabelInterval_; - } - /** - * Set the time axis style. - * - * @param style new time axis style - */ - public void setStyle(int style) { - if(axisStyle_ != style) { - axisStyle_ = style; - if(axisStyle_ == AUTO && tRange_ != null) { - setAuto(); - } - modified("TimeAxis: setStyle()"); - } - } - /** - * Get the time axis style. - * - * @return time axis style - */ - public int getStyle() { - return axisStyle_; - } - /** - * Set the user range to draw the axis. Registered Axes and Transforms - * will be updated. - * - * @param tr TimeRange of axis. - **/ - public void setRangeU(TimeRange tr) { - if(tRange_ == null || !tRange_.equals(tr)) { - tRange_ = tr; - if(axisStyle_ == AUTO) { - setAuto(); - } - updateRegisteredAxes(); - updateRegisteredTransforms(); - modified("TimeAxis: setRangeU()"); - } - } - /** - * Get the time range of the axis. - * - * @return TimeRange of axis - **/ - public TimeRange getTimeRangeU() { - return tRange_; - } - public void setRangeU(SoTRange tr) { - setRangeU(new TimeRange(tr.getStart().getLongTime(), - tr.getEnd().getLongTime(), - tr.getDelta().getLongTime())); - } - public SoTRange getSoTRangeU() { - return new SoTRange.Time(tRange_); - } - /** - * Set the origin in user units of the axis. - * - * @param tp origin of axis in user units - **/ - public void setLocationU(TimePoint tp) { - if(tLocation_ == null || !tLocation_.equals(tp)) { - tLocation_ = tp; - modified("TimeAxis: setLocationU()"); - } - } - public void setLocationU(SoTPoint tp) { - double x; - long t; - if(tp.isXTime()) { - t = tp.getX().getLongTime(); - x = ((SoTValue.Double)tp.getY()).getValue(); - } else { - t = tp.getY().getLongTime(); - x = ((SoTValue.Double)tp.getX()).getValue(); - } - setLocationU(new TimePoint(x, new GeoDate(t))); - } - /** - * Returns origin as a SoTPoint. - */ - public SoTPoint getSoTLocationU() { - if(orientation_ == HORIZONTAL) { - return new SoTPoint(tLocation_.t, tLocation_.x); - } else { - return new SoTPoint(tLocation_.x, tLocation_.t); - } - } - /** - * Get the origin in user units. - * - * @return origin in user units - **/ - public TimePoint getLocationU() { - return tLocation_; - } - // - public Rectangle getBounds() { - double xp, yp, ymin, ymax, xmin, xmax; - int xd, yd, width, height, x, y; - if(orientation_ == Axis.HORIZONTAL) { - // - yp = graph_.getYUtoP(tLocation_.x); - - setupDraw(yp); - - xd = graph_.getXUtoD(tRange_.start); - width = graph_.getXUtoD(tRange_.end) - xd; - x = xd; - ymax = yp; - ymin = yp; - if(labelPosition_ == POSITIVE_SIDE) { - ymax = ymajor_ + MAJOR_LABEL_RATIO__*labelHeight_; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - ymin = ymin - 1.3*largeTicHeight_; - } - } else { - ymin = ymajor_ - MAJOR_LABEL_RATIO__*labelHeight_; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - ymax = ymax + 1.3*largeTicHeight_; - } - } - y = graph_.getLayer().getYPtoD(ymax); - height = graph_.getLayer().getYPtoD(ymin) - y; - } else { - xp = graph_.getXUtoP(tLocation_.x); - - setupDraw(xp); - yd = graph_.getYUtoD(tRange_.start); - y = graph_.getYUtoD(tRange_.end); - height = yd - y; - xmin = xp; - xmax = xp; - if(labelPosition_ == POSITIVE_SIDE) { - xmax = xmajor_ + MAJOR_LABEL_RATIO__*labelHeight_; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == NEGATIVE_SIDE) { - xmin = xmin - 1.3*largeTicHeight_; - } - } else { - xmin = xmajor_ - MAJOR_LABEL_RATIO__*labelHeight_; - if(ticPosition_ == BOTH_SIDES || ticPosition_ == POSITIVE_SIDE) { - xmax = xmax + 1.3*largeTicHeight_; - } - } - x = graph_.getLayer().getXPtoD(xmin); - width = graph_.getLayer().getXPtoD(xp) - x; - } - return new Rectangle(x, y, width, height); - } - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - public void setBounds(int x, int y, int width, int height) { - } - public void modified(String mess) { - // if(Debug.EVENT) System.out.println("TimeAxis: modified()"); - if(graph_ != null) - graph_.modified(mess); - } - // - void draw(Graphics g) { - int xloc, yloc, xend, yend; - int vertalign; - int minor_val, minor_val_old; - int major_val, major_val_old; - double xp, yp; - double xp_minor_old, yp_minor_old; - double x, y; - double xp_major_old, yp_major_old; - boolean draw_minor, draw_major; - boolean time_increasing; - GeoDate time = new GeoDate(); - GeoDate minor_time_old; - GeoDate major_time_old; - GeoDate time_end = new GeoDate(); - SGLabel label; - if(!visible_) return; - // - if(lineColor_ == null) { - g.setColor(graph_.getLayer().getPane().getComponent().getForeground()); - } else { - g.setColor(lineColor_); - } - // - draw_minor = minorLabelInterval_ != 0 && labelPosition_ != NO_LABEL; - draw_major = majorLabelInterval_ != 0 && labelPosition_ != NO_LABEL; - // - time_increasing = tRange_.end.after(tRange_.start); - // - time = txt_.getStartTime(tRange_); - if(time_increasing) { - time_end = new GeoDate(tRange_.end); - } else { - time_end = new GeoDate(tRange_.start); - } - //System.out.println("start" + time.toLocaleString() + " end " + time_end.toLocaleString()); - // - if(orientation_ == Axis.HORIZONTAL) { - yloc = graph_.getYUtoD(tLocation_.x); - xloc = graph_.getXUtoD(tRange_.start); - xend = graph_.getXUtoD(tRange_.end); - g.drawLine(xloc, yloc, xend, yloc); - // - yp = graph_.getYUtoP(tLocation_.x); - xp = graph_.getXUtoP(time); - - setupDraw(yp); - - if(txt_.isStartOfMinor(time)) { - drawThickXTic(g, xp, yp, 1.3f*largeTicHeight_); - } else { - drawXTic(g, xp, yp, largeTicHeight_); - } - major_val = txt_.getMajorValue(time); - major_val_old = major_val; - minor_val_old = txt_.getMinorValue(time); - xp_major_old = xp; - xp_minor_old = xp; - minor_time_old = new GeoDate(time); - major_time_old = new GeoDate(time); - time.increment(txt_.getIncrementValue(), txt_.getIncrementUnits()); - // - while (time.before(time_end)) { - xp = graph_.getXUtoP(time); - minor_val = txt_.getMinorValue(time); - if(txt_.isStartOfMinor(time)) { - drawThickXTic(g, xp, yp, 1.3f*largeTicHeight_); - } else { - drawXTic(g, xp, yp, largeTicHeight_); - } - if(draw_minor && minor_val_old%minorLabelInterval_ == 0) { - x = txt_.computeLocation(xp_minor_old, xp); - drawMinorLabel(g, x, minor_time_old); - } - major_val = txt_.getMajorValue(time); - if(major_val != major_val_old) { - if(draw_major && major_val_old%majorLabelInterval_ == 0) { - x = (xp_major_old + xp)*0.5; - drawMajorLabel(g, x, major_time_old); - } - xp_major_old = xp; - major_val_old = major_val; - major_time_old = new GeoDate(time); - } - xp_minor_old = xp; - minor_val_old = minor_val; - minor_time_old = new GeoDate(time); - time.increment(txt_.getIncrementValue(), txt_.getIncrementUnits()); - } // end of while - if(draw_major && major_val_old%majorLabelInterval_ == 0) { - GeoDate delta = time_end.subtract(major_time_old); - if(txt_.isRoomForMajorLabel(delta)) { - xp = graph_.getXUtoP(time_end); - x = (xp_major_old + xp)*0.5; - drawMajorLabel(g, x, major_time_old); - } - } - } else { // vertical axis - xloc = graph_.getXUtoD(tLocation_.x); - yloc = graph_.getYUtoD(tRange_.start); - yend = graph_.getYUtoD(tRange_.end); - g.drawLine(xloc, yloc, xloc, yend); - // - xp = graph_.getXUtoP(tLocation_.x); - yp = graph_.getYUtoP(time); - - setupDraw(xp); - - if(txt_.isStartOfMinor(time)) { - drawThickYTic(g, xp, yp, 1.3f*largeTicHeight_); - } else { - drawYTic(g, xp, yp, largeTicHeight_); - } - major_val = txt_.getMajorValue(time); - major_val_old = major_val; - minor_val_old = txt_.getMinorValue(time); - yp_major_old = yp; - yp_minor_old = yp; - minor_time_old = new GeoDate(time); - major_time_old = new GeoDate(time); - time.increment(txt_.getIncrementValue(), txt_.getIncrementUnits()); - // - while (time.before(time_end)) { - yp = graph_.getYUtoP(time); - minor_val = txt_.getMinorValue(time); - if(txt_.isStartOfMinor(time)) { - drawThickYTic(g, xp, yp, 1.3f*largeTicHeight_); - } else { - drawYTic(g, xp, yp, largeTicHeight_); - } - if(draw_minor && minor_val_old%minorLabelInterval_ == 0) { - y = txt_.computeLocation(yp_minor_old, yp); - drawMinorLabel(g, y, minor_time_old); - } - major_val = txt_.getMajorValue(time); - if(major_val != major_val_old) { - if(draw_major && major_val_old%majorLabelInterval_ == 0) { - y = (yp_major_old + yp)*0.5; - drawMajorLabel(g, y, major_time_old); - } - yp_major_old = yp; - major_val_old = major_val; - major_time_old = new GeoDate(time); - } - yp_minor_old = yp; - minor_val_old = minor_val; - minor_time_old = new GeoDate(time); - time.increment(txt_.getIncrementValue(), txt_.getIncrementUnits()); - } // end of while - if(draw_major && major_val_old%majorLabelInterval_ == 0) { - GeoDate delta = time_end.subtract(major_time_old); - if(txt_.isRoomForMajorLabel(delta)) { - yp = graph_.getYUtoP(time_end); - y = (yp_major_old + yp)*0.5; - drawMajorLabel(g, y, major_time_old); - } - } - } - } - public void setTitle(SGLabel title) { - // Time axes don't use title_ - title_ = null; - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TimeAxisStyle.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TimeAxisStyle.java deleted file mode 100755 index f46a86e8..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TimeAxisStyle.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * $Id: TimeAxisStyle.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; - -import java.awt.Graphics; -import java.awt.Rectangle; - -/** - * TimeAxisStyle defines an interface to - * create a specific time axis style. Currently there are - * five time axes styles, MINUTE_HOUR, - * HOUR_DAY, DAY_MONTH, - * MONTH_YEAR, and YEAR_DECADE. All time - * axes have two labeling levels, minor and major. For example, - * DAY_MONTH style has a minor level of days and a - * major level of months. - * - * @see TimeAxis - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - */ -public interface TimeAxisStyle { - /** - * Get the minor time value for labeling. - * - * @param time current date - * @return minor time value - */ - public int getMinorValue(GeoDate time); - /** - * Get the major time value for labeling. - * - * @param time current date - * @return major time value - */ - public int getMajorValue(GeoDate time); - /** - * Determines if there is enough room in delta time - * for another major label. - * - * @return true if enough room exists - */ - public boolean isRoomForMajorLabel(GeoDate delta); - /** - * Determines if time is the start of a - * minor interval. - * - * @return true if start of minor interval - */ - public boolean isStartOfMinor(GeoDate time); - /** - * Get the default minor label format. The default minor labels are - * "mm", "HH", "dd", "MMM", and "yy" for MINUTE_HOUR, - * HOUR_DAY, DAY_MONTH, MONTH_YEAR, - * and YEAR_DECADE, respectively. - * - * @return minor label format - */ - public String getDefaultMinorLabelFormat(); - /** - * Get the default major label format. The default major labels are - * "yyyy-MM-dd HH", "yyyy-MM-dd", "yyyy-MM", "yyyy", and "yyyy" for - * MINUTE_HOUR, - * HOUR_DAY, DAY_MONTH, MONTH_YEAR, - * and YEAR_DECADE, respectively. - * - * @return major label format - */ - public String getDefaultMajorLabelFormat(); - /** - * Get the default minor label interval. - * - * @return minor label interval - */ - public int getDefaultMinorLabelInterval(); - /** - * Get the default major label interval. - * - * @return major label interval - */ - public int getDefaultMajorLabelInterval(); - /** - * Get the default number of small tics between - * each minor tic. - * - * @return number of small tics - */ - public int getDefaultNumSmallTics(); - /** - * Returns a beginning time rounded to the nearest minor - * increment. For example, for DAY_MONTH - * if time is increasing then round to the day before - * tRange.start otherwise - * the nearest day after tRange.end. - * - * @param tRange time range of the axis - */ - public GeoDate getStartTime(TimeRange trange); - /** - * Get the increment value for the minor labeling. The value - * is 1.0 for all styles. - * - * @return increment value - */ - public double getIncrementValue(); - /** - * Get the increment units for the minor labeling. The value is - * GeoDate.MINUTES, GeoDate.HOURS, - * GeoDate.DAYS, GeoDate.MONTHS, and - * GoeDate.YEARS for MINUTE_HOUR, - * HOUR_DAY, DAY_MONTH, MONTH_YEAR, - * and YEAR_DECADE, respectively. - * - * @return increment units - * @see GeoDate - */ - public int getIncrementUnits(); - /** - * Determine the minor label interval from the time - * extent of the axis. For example, if delta is greater - * than 30 days, greater than 10 and less that 30 days, or - * less than 10 days, the interval is 5, 2, or 1, respectively, - * for DAY_MONTH style. - * - * @param delta time extent - */ - public void computeDefaults(GeoDate delta); - /** - * Determines the location of the minor time label. Positions - * the label between the tic marks for DAY_MONTH, - * MONTH_YEAR, and YEAR_DECADE, or - * at the tic mark for MINUTES_HOURS and - * HOURS_DAYS. - * - * @param prev previous tic location - * @param now current tic location - */ - public double computeLocation(double prev,double now); - - public String toString(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Transform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Transform.java deleted file mode 100755 index 7847f7bf..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/Transform.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * $Id: Transform.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.beans.PropertyChangeListener; - -import gov.noaa.pmel.util.Range2D; -import java.io.Serializable; - -/** - * Transform defines an interface for transformations between - * user and physical coordinates. - * - * @see AxisTransform - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 1.0 - */ -public interface Transform extends Serializable { - /** - * Set physical coordinate range. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @see LinearTransform - **/ - public void setRangeP(double p1,double p2); - /** - * Set physical coordinate range. - * - * @param prange physcial coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeP(Range2D prange); - /** - * Get the physical coordinate range. - * - * @return physcial coordinate range - * @see Range2D - **/ - public Range2D getRangeP(); - /** - * Set the user coordinate range for double values. - * - * @param u1 minimum value, user coordinates - * @param u2 maximum value, user coordinates - * @see LinearTransform - **/ - public void setRangeU(double u1,double u2); - /** - * Set the user coordinate range for double values. - * - * @param urange user coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeU(Range2D urange); - /** - * Get the user coordinate range for double values. - * - * @return user range - * @see Range2D - **/ - public Range2D getRangeU(); - /** - * Transform from user to physical coordinates. - * - * @param u user value - * @return physical value - */ - abstract double getTransP(double u); - /** - * Transform from physical to user coordinates. - * - * @param p physical value - * @return user value - */ - abstract double getTransU(double p); - /** - * Add listener for changes to transform properties. - * @since 2.0 - */ - public void addPropertyChangeListener(PropertyChangeListener listener); - /** - * Remove listener. - * @since 2.0 - */ - public void removePropertyChangeListener(PropertyChangeListener listener); -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformAccess.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformAccess.java deleted file mode 100755 index de679903..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformAccess.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * $Id: TransformAccess.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; - -/** - * Interface indicates that the color map uses a transform to map - * levels. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.0 - */ -public interface TransformAccess { - void setRange(Range2D range); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformColor.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformColor.java deleted file mode 100755 index 048ec938..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformColor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * $Id: TransformColor.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -/** - * Interface provides support for accessing color transforms for a - * color map. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.0 - */ -public interface TransformColor { - Transform getRedTransform(); - - void setRedTransform(Transform redTransform); - - Transform getGreenTransform(); - - void setGreenTransform(Transform greenTransform); - - Transform getBlueTransform(); - - void setBlueTransform(Transform blueTransform); - - void setColorTransforms(Transform red, Transform green, Transform blue); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformColorMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformColorMap.java deleted file mode 100755 index 41df368f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/TransformColorMap.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * $Id: TransformColorMap.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Debug; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; - -/** - * TransformColorMap provides a mapping from a value - * to a Color. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.0 - */ -public class TransformColorMap extends ColorMap - implements Cloneable, PropertyChangeListener, - TransformColor, TransformAccess { - /** - * Red Transform - - * @supplierCardinality 0..1 - * @clientRole rTrans_ - * @link aggregationByValue - */ - private Transform rTrans_ = null; - /** - * Green Transform - - * @supplierCardinality 0..1 - * @clientRole gTrans_ - * @link aggregationByValue - */ - private Transform gTrans_ = null; - /** - * Blue Transform - - * @supplierCardinality 0..1 - * @clientRole bTrans_ - * @link aggregationByValue - */ - private Transform bTrans_ = null; - /** - * Initialize the color map to use red, green, and blue transforms. Sets up - * ColorMap for TRANSFORM access. - * Each Transform should have identical user - * ranges. The physical range will be set to 0.0 to 1.0 for each - * color component. - * - * @see Transform - */ - public TransformColorMap(Transform rTrans,Transform gTrans,Transform bTrans) { - rTrans_ = rTrans; - rTrans_.setRangeP(0.0, 1.0); - gTrans_ = gTrans; - gTrans_.setRangeP(0.0, 1.0); - bTrans_ = bTrans; - bTrans_.setRangeP(0.0, 1.0); - } - /** - * Create a copy of the ColorMap object. - */ - public ColorMap copy() { - ColorMap newMap; - try { - newMap = (ColorMap)clone(); - } catch (CloneNotSupportedException e) { - newMap = null; - } - return newMap; - } - /** - * Get a Color. Returns a Color by - * one of four methods. INDEXED, TRANSFORM, - * LEVEL_INDEXED, and LEVEL_TRANSFORM. - * - * @param val Value - * @return Color - * - */ - public Color getColor(double val) { - double ival = val; - float red = (float)rTrans_.getTransP(ival); - float green = (float)gTrans_.getTransP(ival); - float blue = (float)bTrans_.getTransP(ival); - return new Color(red, green, blue); - } - /** - * Set the user range for all the Transforms. - * - */ - public void setRange(Range2D range) { - rTrans_.setRangeU(range); - gTrans_.setRangeU(range); - bTrans_.setRangeU(range); - } - /** - * Get the current user range for the Transforms. - * - * @return user range - */ - public Range2D getRange() { - return rTrans_.getRangeU(); - } - /** - * Set the color Transforms. - *
Property Change: redColorTransform, - * greenColorTransform, and - * blueColorTransform. - * - * @param rTrans red Transform - * @param gTrans green Transform - * @param bTrans blue Transform - */ - public void setColorTransforms(Transform rTrans, - Transform gTrans, - Transform bTrans) { - if(!rTrans_.equals(rTrans) || - !gTrans_.equals(gTrans) || - !bTrans_.equals(bTrans)) { - if(rTrans_ != null) rTrans_.removePropertyChangeListener(this); - if(gTrans_ != null) gTrans_.removePropertyChangeListener(this); - if(bTrans_ != null) bTrans_.removePropertyChangeListener(this); - - Transform tempOld = rTrans_; - rTrans_ = rTrans; - rTrans_.setRangeP(0.0, 1.0); - firePropertyChange("redColorTransform", - tempOld, - rTrans_); - tempOld = gTrans_; - gTrans_ = gTrans; - gTrans_.setRangeP(0.0, 1.0); - firePropertyChange("greenColorTransform", - tempOld, - gTrans_); - tempOld = bTrans_; - bTrans_ = bTrans; - bTrans_.setRangeP(0.0, 1.0); - firePropertyChange("blueColorTransform", - tempOld, - bTrans_); - - rTrans_.addPropertyChangeListener(this); - gTrans_.addPropertyChangeListener(this); - bTrans_.addPropertyChangeListener(this); - } - } - /** - * Set the red color Transform - */ - public void setRedTransform(Transform red) { - rTrans_ = red; - } - /** - * Get the red color Transform. - * - * @return red Transform - */ - public Transform getRedTransform() { - return rTrans_; - } - /** - * Set the green color Transform - */ - public void setGreenTransform(Transform green) { - gTrans_ = green; - } - /** - * Get the green color Transform. - * - * @return green Transform - */ - public Transform getGreenTransform() { - return gTrans_; - } - /** - * Set the blue color Transform - */ - public void setBlueTransform(Transform blue) { - bTrans_ = blue; - } - /** - * Get the blue color Transform. - * - * @return blue Transform - */ - public Transform getBlueTransform() { - return bTrans_; - } - - public boolean equals(ColorMap cm) { - if(cm == null || !(cm instanceof TransformColorMap)) return false; - if(!(rTrans_.equals(((TransformColorMap)cm).rTrans_) && - gTrans_.equals(((TransformColorMap)cm).gTrans_) && - bTrans_.equals(((TransformColorMap)cm).bTrans_))) return false; - return true; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorAttribute.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorAttribute.java deleted file mode 100755 index 402b0c25..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorAttribute.java +++ /dev/null @@ -1,556 +0,0 @@ -/* - * $Id: VectorAttribute.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import java.awt.*; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * Sets the rendering style for line data. - * Color, width, and dash characteristics are - * VectorAttribute properties. - *
Warning: The SGT implementation of - * Vectors requires Java2D. To use Vectors you must be using jdk1.2 or - * newer. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.1 - * @see LineCartesianRenderer - * @see ContourLevels - */ -public class VectorAttribute - implements Attribute, Cloneable, java.io.Serializable { - - protected transient PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private boolean batch_ = false; - private boolean local_ = true; - private boolean modified_ = false; - private String id_ = null; - private int vectorStyle_ = HEAD; - private Color vectorColor_ = Color.black; - private double vectorScale_ = 0.01; // User units to physical - private double vectorMaxSize_ = 100.0; - private double offsetAngle_ = 0.0; - - private double headScale_ = 1.0; // User units to physical - private double headMaxSize_ = 100.0; - private double headMinSize_ = 0.05; - private double headFixedSize_ = 0.2; // Physical units - - private int originStyle_ = NO_MARK; - private Color markColor_ = Color.black; - private int mark_ = 1; - private double markHeightP_ = 0.2; - - private float width_ = 1.0f; - private int capStyle_ = LineAttribute.CAP_SQUARE; - private int miterStyle_ = LineAttribute.JOIN_MITER; - private float miterLimit_ = 10.0f; - /** - * Vector head style, None. No arrow head will be drawn. - */ - public static final int NO_HEAD = 0; - /** - * Vector head style, Un-scaled (default). Head will be drawn a - * constant size. - */ - public static final int HEAD = 1; - /** - * Vector head style, Scaled. The size of the head will be - * proportional to the length of the vector. - */ - public static final int SCALED_HEAD = 2; - /** - * Vector origin style, no mark (default). The origin of the vector - * will be drawn without a plot mark. - */ - public static final int NO_MARK = 0; - /** - * Vector origin style, Mark. A plot mark will be drawn at the - * origin of the vector. - */ - public static final int MARK = 1; - /** - * Default constructor. Default vector style is HEAD, - * default color is red, and scale = 1.0; - **/ - public VectorAttribute() { - this(1.0, Color.red); - } - /** - * VectorAttribute constructor. Default vector style - * is HEAD. - * - * @param scale vector scale - * @param color vector Color - * @see java.awt.Color - **/ - public VectorAttribute(double scale, Color color) { - vectorStyle_ = HEAD; - vectorScale_ = scale; - vectorColor_ = color; - } - /** - * VectorAttribute constructor. - * - * @param style vector style - * @param scale vector scale - * @param color vector Color - * @param head_scale scale of vector head - * @see java.awt.Color - **/ - public VectorAttribute(int style, double scale, Color color, - double head_scale) { - vectorStyle_ = style; - vectorScale_ = scale; - vectorColor_ = color; - headScale_ = head_scale; - } - /** - * Copy the VectorAttribute. - * - * @return new VectorAttribute - */ - public Object copy() { - VectorAttribute newVector; - try { - newVector = (VectorAttribute)clone(); - } catch (CloneNotSupportedException e) { - newVector = new VectorAttribute(); - } - return newVector; - } - /** - * Change the head style. Options include NO_HEAD, - * HEAD, and SCALED_HEAD. - *
Property Change: vectorStyle. - * - * @see #setVectorColor(java.awt.Color) - * @see #setVectorMaxSize(double) - * @see #setVectorScale(double) - * @see #setOffsetAngle(double) - * - */ - public void setVectorStyle(int style) { - if(vectorStyle_ != style) { - Integer tempOld = new Integer(vectorStyle_); - vectorStyle_ = style; - firePropertyChange("vectorStyle", - tempOld, - new Integer(vectorStyle_)); - } - } - /** Get the vector head style. */ - public int getVectorStyle() { - return vectorStyle_; - } - /** - * Change the vector color. - *
Property Change: vectorColor. - * - */ - public void setVectorColor(Color color) { - if(!vectorColor_.equals(color)) { - Color tempOld = vectorColor_; - vectorColor_ = color; - firePropertyChange("vectorColor", - tempOld, - vectorColor_); - } - } - /** Get the vector color. */ - public Color getVectorColor() { - return vectorColor_; - } - /** - * Change the vector scale. The vector length is determined - * by the data value times the vector scale. The - * vector length is bounded by the maximum allowed - * vector length. - *
Property Change: vectorScale. - * - * @see #setVectorMaxSize(double) - * - */ - public void setVectorScale(double scale) { - if(vectorScale_ != scale) { - Double tempOld = new Double(vectorScale_); - vectorScale_ = scale; - firePropertyChange("vectorScale", - tempOld, - new Double(vectorScale_)); - } - } - /** Geth the vector head scale. */ - public double getVectorScale() { - return vectorScale_; - } - /** - * Set the maximum size for a vector. - *
Property Change: vectorMaxSize. - * - */ - public void setVectorMaxSize(double size) { - if(vectorMaxSize_ != size) { - Double tempOld = new Double(vectorMaxSize_); - vectorMaxSize_ = size; - firePropertyChange("vectorMaxSize", - tempOld, - new Double(vectorMaxSize_)); - } - } - /** Get the maximum vector length allowed. */ - public double getVectorMaxSize() { - return vectorMaxSize_; - } - /** - * Set the angle (clockwize positive) to rotate the vector. - *
Property Change: offsetAngle. - * @param angle in degrees - */ - public void setOffsetAngle(double angle) { - if(offsetAngle_ != angle) { - Double tempOld = new Double(offsetAngle_); - offsetAngle_ = angle; - firePropertyChange("offsetAngle", - tempOld, - new Double(offsetAngle_)); - } - } - /** Get the vector rotation angle. */ - public double getOffsetAngle() { - return offsetAngle_; - } - /** - * Change the vector head scale. The vector head size is determined - * by the length of the vector times the vector head scale. The - * vector head size is bounded by the minimum and maximum allowed - * head size. - *
Property Change: headScale. - * - * @see #setHeadMinSize(double) - * @see #setHeadMaxSize(double) - * - */ - public void setHeadScale(double scale) { - if(headScale_ != scale) { - Double tempOld = new Double(headScale_); - headScale_ = scale; - firePropertyChange("headScale", - tempOld, - new Double(headScale_)); - } - } - /** Get the vector head scale. */ - public double getHeadScale() { - return headScale_; - } - /** - * Set the maximum size for a scaled vector head. - *
Property Change: headMaxSize. - * - */ - public void setHeadMaxSize(double size) { - if(headMaxSize_ != size) { - Double tempOld = new Double(headMaxSize_); - headMaxSize_ = size; - firePropertyChange("headMaxSize", - tempOld, - new Double(headMaxSize_)); - } - } - /** Get the maximum vector head size. */ - public double getHeadMaxSize() { - return headMaxSize_; - } - /** - * Set the minimum size for a scaled vector head. - *
Property Change: headMinSize. - * - */ - public void setHeadMinSize(double size) { - if(headMinSize_ != size) { - Double tempOld = new Double(headMinSize_); - headMinSize_ = size; - firePropertyChange("headMinSize", - tempOld, - new Double(headMinSize_)); - } - } - /** Get the minimum vector head size. */ - public double getHeadMinSize() { - return headMinSize_; - } - /** - * Set the fixed size for a unscaled vector head. - *
Property Change: headFixedSize. - * - */ - public void setHeadFixedSize(double size) { - if(headFixedSize_ != size) { - Double tempOld = new Double(headFixedSize_); - headFixedSize_ = size; - firePropertyChange("headFixedSize", - tempOld, - new Double(headFixedSize_)); - } - } - /** Get the fixed vector head size. */ - public double getHeadFixedSize() { - return headFixedSize_; - } - /** - * Set the vector origin style. Options are NO_MARK - * and MARK. - *
Property Change: originStyle. - * - * @see #setMarkColor(java.awt.Color) - * @see #setMark(int) - * @see #setMarkHeightP(double) - */ - public void setOriginStyle(int style) { - if(originStyle_ != style) { - Integer tempOld = new Integer(originStyle_); - originStyle_ = style; - firePropertyChange("originStyle", - tempOld, - new Integer(originStyle_)); - } - } - /** Get vector origin style. */ - public int getOriginStyle() { - return originStyle_; - } - /** - * Set the color for the origin mark. - *
Property Change: markColor. - */ - public void setMarkColor(Color color) { - if(!markColor_.equals(color)) { - Color tempOld = markColor_; - markColor_ = color; - firePropertyChange("markColor", - tempOld, - markColor_); - } - } - /** Get the color for the origin mark. */ - public Color getMarkColor() { - return markColor_; - } - /** - * Set the mark for the origin. - *
Property Change: mark. - * - * @param mark the plot mark - * @see PlotMark - */ - public void setMark(int mark) { - if(mark_ != mark) { - Integer tempOld = new Integer(mark_); - if(mark <= 0) mark = 1; - if(mark > 51) mark = 51; - mark_ = mark; - firePropertyChange("mark", - tempOld, - new Integer(mark_)); - } - } - /** - * Get plot mark for the origin. - * - * @return plot mark - **/ - public int getMark() { - return mark_; - } - /** - * Set mark height for the origin. - *
Property Change: markHeightP. - * - * @param markh mark height - **/ - public void setMarkHeightP(double markh) { - if(markHeightP_ != markh) { - Double tempOld = new Double(markHeightP_); - markHeightP_ = markh; - firePropertyChange("markHeightP", - tempOld, - new Double(markHeightP_)); - } - } - /** - * Get mark height for the origin. - * - * @return mark height - **/ - public double getMarkHeightP() { - return markHeightP_; - } - /** - * Set the line width in physical units. - *
Property Change: width. - * - * @param t line width - **/ - public void setWidth(float t) { - if(width_ != t) { - Float tempOld = new Float(width_); - width_ = t; - firePropertyChange("width", - tempOld, - new Float(width_)); - } - } - /** - * Get line width. - * - * @return line width in physcial coordinates. - **/ - public float getWidth() { - return width_; - } - /** - * Set the line Cap Style. Styles include - * LineAttribute.CAP_BUTT, - * LineAttribute.CAP_ROUND, and - * LineAttribute.CAP_SQUARE. - *
Property Change: capStyle. - * - * @see LineAttribute#CAP_BUTT - * @see LineAttribute#CAP_ROUND - * @see LineAttribute#CAP_SQUARE - */ - public void setCapStyle(int style) { - if(capStyle_ != style) { - Integer tempOld = new Integer(capStyle_); - capStyle_ = style; - firePropertyChange("capStyle", - tempOld, - new Integer(capStyle_)); - } - } - /** Get the line cap style. */ - public int getCapStyle() { - return capStyle_; - } - /** - * Set the line miter style. Styles include - * LineAttribute.JOIN_BEVEL, - * LineAttribute.JOIN_MITER, and - * LineAttribute.JOIN_ROUND. - *
Property Change: miterStyle. - * - * @see LineAttribute#JOIN_BEVEL - * @see LineAttribute#JOIN_MITER - * @see LineAttribute#JOIN_ROUND - */ - public void setMiterStyle(int style) { - if(miterStyle_ != style) { - Integer tempOld = new Integer(miterStyle_); - miterStyle_ = style; - firePropertyChange("miterStyle", - tempOld, - new Integer(miterStyle_)); - } - - } - /** Get the line miter sytle. */ - public int getMiterStyle() { - return miterStyle_; - } - /** - * Set the line miter limit. - *
Property Change: miterLimit. - */ - public void setMiterLimit(float limit) { - if(miterLimit_ != limit) { - Float tempOld = new Float(miterLimit_); - miterLimit_ = limit; - firePropertyChange("miterLimit", - tempOld, - new Float(miterLimit_)); - } - } - /** Get the line miter limit. */ - public float getMiterLimit() { - return miterLimit_; - } - - /** - * Get a String representation of the - * VectorAttribute. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1); - } - /** - * Add listener to changes in VectorAttribute properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.addPropertyChangeListener(listener); - } - public void removePropertyChangeListener(PropertyChangeListener listener) { - changes_.removePropertyChangeListener(listener); - } - /** - * @since 3.0 - */ - public void setId(String id) { - id_ = id; - } - /** - * @since 3.0 - */ - public String getId() { - return id_; - } - - protected void firePropertyChange(String name, Object oldValue, Object newValue) { - if(batch_) { - modified_ = true; - return; - } - AttributeChangeEvent ace = new AttributeChangeEvent(this, name, - oldValue, newValue, - local_); - changes_.firePropertyChange(ace); - modified_ = false; - } - /** - * @since 3.0 - */ - public void setBatch(boolean batch) { - setBatch(batch, true); - } - /** - * @since 3.0 - */ - public void setBatch(boolean batch, boolean local) { - local_ = local; - batch_ = batch; - if(!batch && modified_) firePropertyChange("batch", Boolean.TRUE, Boolean.FALSE); - } - /** - * @since 3.0 - */ - public boolean isBatch() { - return batch_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorCartesianRenderer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorCartesianRenderer.java deleted file mode 100755 index 6cfb90e4..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorCartesianRenderer.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * $Id: VectorCartesianRenderer.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.sgt.dm.SGTVector; -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.Collection; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Debug; - -import java.awt.Graphics2D; -import java.awt.BasicStroke; -import java.awt.Stroke; -import java.awt.geom.GeneralPath; -//import java.awt.geom.AffineTransform; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Event; -import java.awt.Point; -import java.awt.Color; -import java.awt.Rectangle; -import java.beans.PropertyChangeEvent; - -/** - * Produces a vector plot. If - * a second data set is specified it must have the same shape as the first. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.1 - */ -public class VectorCartesianRenderer extends CartesianRenderer { - /** - * @link aggregation - * @label attr - */ - private VectorAttribute attr_ = null; - - /** - * @link aggregation - * @label vector - */ - private SGTVector vector_ = null; - private Collection collection_ = null; - private float slope_; - private float xoff_; - private float yoff_; - - /** - * Get the Attribute associated with the data. - */ - public Attribute getAttribute() { - return attr_; - } - - private void drawVector(Graphics g, SGTVector vector, - VectorAttribute attr) { - - Layer ly = cg_.getLayer(); - Graphics2D g2 = (Graphics2D)g; - slope_ = (float)ly.getXSlope(); - xoff_ = (float)ly.getXOffset(); - yoff_ = (float)ly.getYOffset(); - GeneralPath gp = null; - Stroke savedStroke = g2.getStroke(); - BasicStroke stroke = new BasicStroke(attr_.getWidth(), - attr_.getCapStyle(), - attr_.getMiterStyle(), - attr_.getMiterLimit()); - g2.setStroke(stroke); - // - // a 1 unit lenght vector with a headScale of 1.0 will - // create a head barb that is 1.05948 long. A factor of - // 0.94386 is required to remove this effect - // - float scale = (float)attr_.getVectorScale(); - float headScale = (float)attr_.getHeadScale()*0.94386f; - float fixedScale = (float)(headScale*attr_.getHeadFixedSize()); - float minSize = (float)attr_.getHeadMinSize(); - float maxSize = (float)attr_.getHeadMaxSize(); - double angle = attr_.getOffsetAngle()*0.017453293; - float tScale; - float[] xp, yp; - int[] xtail, ytail; - int xdhead, ydhead; - int xdtemp, ydtemp; - float xphead, yphead; - int count, size, nout, idx; - double[] xValues, yValues; - GeoDate[] xTValues, yTValues; - double[] uValues, vValues; - float vx, vy, vclen; - double vdx, vdy; - - float hx1, hx2; - float hy1, hy2; - float headX, headY; - float orgX, orgY; - // - // get axes - // - if(vector.isXTime()) { - xTValues = vector.getU().getTimeArray(); - size = xTValues.length; - xp = new float[size]; - for(count=0; count < size; count++) { - xp[count] = (float)cg_.getXUtoP(xTValues[count]); - } - } else { - xValues = vector.getU().getXArray(); - size = xValues.length; - xp = new float[size]; - for(count=0; count < size; count++) { - xp[count] = (float)cg_.getXUtoP(xValues[count]); - } - } - // - if(vector.isYTime()) { - yTValues = vector.getU().getTimeArray(); - size = yTValues.length; - yp = new float[size]; - for(count=0; count < size; count++) { - yp[count] = (float)cg_.getYUtoP(yTValues[count]); - } - } else { - yValues = vector.getU().getYArray(); - size = yValues.length; - yp = new float[size]; - for(count=0; count < size; count++) { - yp[count] = (float)cg_.getYUtoP(yValues[count]); - } - } - // - // get u & v - // - uValues = vector.getU().getZArray(); - vValues = vector.getV().getZArray(); - // - xtail = new int[uValues.length]; - ytail = new int[uValues.length]; - count = 0; -// int nx = xp.length; - int ny = yp.length; - int idx_ny; - for(int i=0; i < xp.length; i++) { - idx_ny = i*ny; - for(int j=0; j < yp.length; j++) { - idx = j + idx_ny; - if(Double.isNaN(uValues[idx]) || Double.isNaN(vValues[idx])) continue; - orgX = xPtoD(xp[i]); - orgY = yPtoD(yp[j]); - xtail[count] = (int)orgX; - ytail[count] = (int)orgY; - vdx = uValues[idx]*scale; - vdy = vValues[idx]*scale; - if(angle != 0.0) { - vx = (float)(vdx*Math.cos(angle)-vdy*Math.sin(angle)); - vy = (float)(vdy*Math.cos(angle)+vdx*Math.sin(angle)); - } else { - vx = (float)vdx; - vy = (float)vdy; - } - xphead = xp[i] + vx; - yphead = yp[j] + vy; - // - // draw line - // - gp = new GeneralPath(); - gp.moveTo(orgX, orgY); - headX = xPtoD(xphead); - headY = yPtoD(yphead); - gp.lineTo(headX, headY); - // - // draw head - // - // if(true) continue; - vclen = (float)Math.sqrt((double)(vx*vx+vy*vy)); - if(vclen == 0.0) { - g.drawLine((int)headX, (int)headY, (int)headX, (int)headY); - } else { - if(attr_.getVectorStyle() != VectorAttribute.NO_HEAD) { - if(attr_.getVectorStyle() == VectorAttribute.HEAD) { - // unscaled head - tScale = fixedScale/vclen; - hx1 = xPtoD(xphead + (-vx-0.35f*vy)*tScale); - hy1 = yPtoD(yphead + (-vy+0.35f*vx)*tScale); - hx2 = xPtoD(xphead + (-vx+0.35f*vy)*tScale); - hy2 = yPtoD(yphead + (-vy-0.35f*vx)*tScale); - gp.moveTo(hx1, hy1); - gp.lineTo(headX, headY); - gp.lineTo(hx2, hy2); - } else { - // scaled head - if(vclen >= maxSize) { - tScale = maxSize*headScale/vclen; - } else if(vclen <= minSize) { - tScale = minSize*headScale/vclen; - } else { - tScale = headScale; - } - hx1 = xPtoD(xphead + (-vx-0.35f*vy)*tScale); - hy1 = yPtoD(yphead + (-vy+0.35f*vx)*tScale); - hx2 = xPtoD(xphead + (-vx+0.35f*vy)*tScale); - hy2 = yPtoD(yphead + (-vy-0.35f*vx)*tScale); - gp.moveTo(hx1, hy1); - gp.lineTo(headX, headY); - gp.lineTo(hx2, hy2); - } - } - } - count++; - g2.draw(gp); - } - } - g2.setStroke(savedStroke); - // - // draw mark - // - if(attr_.getOriginStyle() == VectorAttribute.MARK) { - g.setColor(attr_.getMarkColor()); - drawMark(g, xtail, ytail, xtail.length, attr_); - } - } - - private float xPtoD(float xp) { - return slope_*xp + xoff_; - } - - private float yPtoD(float yp) { - return yoff_ - slope_*yp; - } - /** - * Draw a mark at the requested location. This routine is used by - * VectorCartesianGraph and VectorKey. - * - * @param g Graphics object - * @param xp horizontal coordinate - * @param yp vertical coordinate - * @param attr vector attribute - * @see VectorKey - */ - protected void drawMark(Graphics g, int[] xp, int[] yp, - int npoints, VectorAttribute attr) { - Layer ly = cg_.getLayer(); - - PlotMark pm = new PlotMark(attr.getMark()); - pm.setMarkHeightP(attr.getMarkHeightP()); - - for(int i=0; i < npoints; i++) { - pm.paintMark(g, ly, xp[i], yp[i]); - } - } - - /** - * Default constructor. - * - * @see CartesianGraph - * @see Graph - **/ - public VectorCartesianRenderer(CartesianGraph cg) { - this(cg, (SGTVector)null, null); - } - /** - * Construct a VectorCartesianRenderer. The default - * VectorAttribute will be used. - * - * @param cg the parent CartesianGraph - * @param data an SGTVector object - * - * @see CartesianGraph - * @see Graph - **/ - public VectorCartesianRenderer(CartesianGraph cg, SGTVector vector) { - this(cg, vector, null); - cg_ = cg; - vector_ = vector; - } - /** - * Construct a VectorCartesianRenderer. - * - * @param cg the parent CartesianGraph - * @param vector a SGTVector - * @param attr the VectorAttribute - * @see CartesianGraph - * @see Graph - **/ - public VectorCartesianRenderer(CartesianGraph cg, - SGTVector vector, - VectorAttribute attr) { - cg_ = cg; - vector_ = vector; - attr_ = attr; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - /** - * Construct a VectorCartesianRenderer. - * - * @param cg the parent CartesianGraph - * @param col a Collection of SGTVector objects - * @param attr the VectorAttribute - * @see CartesianGraph - * @see Graph - **/ - public VectorCartesianRenderer(CartesianGraph cg, Collection col, - VectorAttribute attr) { - cg_ = cg; - collection_ = col; - attr_ = attr; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - /** - * Render the SGTData. This method should not - * be directly called. - * - * @param g graphics context - * - * @see Pane#draw - */ - public void draw(Graphics g) { - VectorAttribute attr; - Object vector; - - if(cg_.clipping_) { - int xmin, xmax, ymin, ymax; - int x, y, width, height; - if(cg_.xTransform_.isSpace()) { - xmin = cg_.getXUtoD(cg_.xClipRange_.start); - xmax = cg_.getXUtoD(cg_.xClipRange_.end); - } else { - xmin = cg_.getXUtoD(cg_.tClipRange_.start); - xmax = cg_.getXUtoD(cg_.tClipRange_.end); - } - if(cg_.yTransform_.isSpace()) { - ymin = cg_.getYUtoD(cg_.yClipRange_.start); - ymax = cg_.getYUtoD(cg_.yClipRange_.end); - } else { - ymin = cg_.getYUtoD(cg_.tClipRange_.start); - ymax = cg_.getYUtoD(cg_.tClipRange_.end); - } - if(xmin < xmax) { - x = xmin; - width = xmax - xmin; - } else { - x=xmax; - width = xmin - xmax; - } - if(ymin < ymax) { - y = ymin; - height = ymax - ymin; - } else { - y = ymax; - height = ymin - ymax; - } - g.setClip(x, y, width, height); - } - if(attr_ == null) { - attr = new VectorAttribute(1.0, - cg_.getPane().getComponent().getForeground()); - } else { - attr = attr_; - } - g.setColor(attr.getVectorColor()); - if(collection_ == null) { - drawVector(g, vector_, attr); - } else { - for(Enumeration li = collection_.elements(); li.hasMoreElements();) { - vector = li.nextElement(); - if(vector instanceof SGTVector) { - drawVector(g, (SGTVector)vector, attr); - } - } - } - - // - // reset clip - // - Rectangle rect = cg_.getLayer().getPane().getBounds(); - g.setClip(rect); - } - /** - * Set the VectorAttribute. The line appearance is controlled by - * this object. - * - * @param l VectorAttribute - **/ - public void setVectorAttribute(VectorAttribute l) { - if(attr_ != null) attr_.removePropertyChangeListener(this); - attr_ = l; - if(attr_ != null) attr_.addPropertyChangeListener(this); - } - /** - * Get the VectorAttribute. - * - * @return VectorAttribute - **/ - public VectorAttribute getVectorAttribute() { - return attr_; - } - /** - * Test if a Collection of SGTVector - * was using to construct this renderer. - * - * @return true if Collection was used - */ - public boolean hasCollection() { - return (collection_ != null); - } - /** - * Get the Collection of SGTVector objects. - * - * @return Collection - */ - public Collection getCollection() { - return collection_; - } - /** - * Get the SGTVector object. - * - * @return SGTVector - */ - public SGTVector getVector(){ - return vector_; - } - /** - * Get the associated CartesianGraph object. - * - * @return CartesianGraph - */ - public CartesianGraph getCartesianGraph() { - return cg_; - } - - public void propertyChange(PropertyChangeEvent evt) { - // if(Debug.EVENT) { - // System.out.println("VectorCartesianRenderer: " + evt); - // System.out.println(" " + evt.getPropertyName()); - // } - modified("VectorCartesianRenderer: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - public SGTData getDataAt(Point pt) { - return null; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorKey.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorKey.java deleted file mode 100755 index 8b4805b9..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/VectorKey.java +++ /dev/null @@ -1,910 +0,0 @@ -/* - * $Id: VectorKey.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Debug; - -import java.util.Vector; -import java.util.Enumeration; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Stroke; -import java.awt.BasicStroke; -import java.awt.geom.GeneralPath; -import java.awt.Rectangle; -import java.awt.Point; -import java.text.DecimalFormat; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeSupport; - -/** - * VectorKey is used to create a key for the - * VectorCartesianRenderer. Multiple - * lines can be included in the key. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 2.1 -**/ -public class VectorKey implements Cloneable, - DataKey, Moveable, PropertyChangeListener { - private String ident_; - /** @directed */ - private Layer layer_; - /** @link aggregation - * @supplierCardinality * - * @label vectors*/ - /*#VectorCartesianRenderer lnkVectorCartesianRenderer; */ - private Vector vectors_; - /** - *@link aggregation - * @associates <{SGLabel}> - * @label label - * @supplierCardinality * - * @undirected - */ - /* private Vector lnkSGLabel; */ - private Vector label_; - private Vector scaleLabel_; - private int columns_; - private int style_; - private int valign_; - private int halign_; - private Point2D.Double porigin_; - private double vectorLengthP_; - private int maxLabelLength_; - private int maxLabelHeight_; - private int maxScaleLength_; - private String floatScaleFormat_ = "###.##"; - private String expScaleFormat_ = "0.####E0"; - private DecimalFormat floatFormat_; - private DecimalFormat expFormat_; - private float xoff_; - private float yoff_; - private float slope_; - private boolean selected_; - private boolean selectable_; - private boolean visible_; - private boolean moveable_; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private static final int VERTICAL_BORDER_ = 3; - private static final int HORIZONTAL_BORDER_ = 15; - private static final int COLUMN_SPACE_ = 10; - private static final int ROW_SPACE_ = 3; - private static final int LABEL_SPACE_ = 10; - private static final int SCALE_SPACE_ = 7; - /** - * Use plain line border. - */ - public static final int PLAIN_LINE = 0; - /** - * Use raised border. - */ - public static final int RAISED = 1; - /** - * Do not draw a border. - */ - public static final int NO_BORDER = 2; - /** - * Align to top of key. - */ - public static final int TOP = 0; - /** - * Align to middle of key. - */ - public static final int MIDDLE = 1; - /** - * Align to bottom of key. - */ - public static final int BOTTOM = 2; - /** - * Align to left of key. - */ - public static final int LEFT = 0; - /** - * Align to center of key. - */ - public static final int CENTER = 1; - /** - * Align to right of key. - */ - public static final int RIGHT = 2; - - - /** - * Default constructor. - */ - public VectorKey() { - this(new Point2D.Double(0.0, 0.0), BOTTOM, LEFT); - } - /** - * Create VectorKey. - */ - public VectorKey(Point2D.Double loc,int valign,int halign) { - porigin_ = loc; - valign_ = valign; - halign_ = halign; - vectors_ = new Vector(2,2); - label_ = new Vector(2,2); - scaleLabel_ = new Vector(2,2); - // - // set defaults - // - style_ = PLAIN_LINE; - columns_ = 1; - ident_ = ""; - vectorLengthP_ = 0.3f; - selected_ = false; - selectable_ = true; - visible_ = true; - moveable_ = true; - - floatFormat_ = new DecimalFormat(floatScaleFormat_); - expFormat_ = new DecimalFormat(expScaleFormat_); - } - /** - * Create of copy of VectorKey. - */ - public LayerChild copy() { - VectorKey newKey; - try { - newKey = (VectorKey)clone(); - } catch (CloneNotSupportedException e) { - newKey = new VectorKey(); - } - newKey.vectors_ = new Vector(2,2); - newKey.label_ = new Vector(2,2); - return newKey; - } - public void setSelected(boolean sel) { - selected_ = sel; - } - public boolean isSelected() { - return selected_; - } - public void setSelectable(boolean select) { - selectable_ = select; - } - public boolean isSelectable() { - return selectable_; - } - public boolean isMoveable() { - return moveable_; - } - public void setMoveable(boolean moveable) { - moveable_ = moveable; - } - /** - * Set parent layer. - * - * @param l parent layer - */ - public void setLayer(Layer l) { - layer_ = l; - } - /** - * Get layer. - * - * @return layer - */ - public Layer getLayer() { - return layer_; - } - - public AbstractPane getPane() { - return layer_.getPane(); - } - - public void modified(String mess) { - if(layer_ != null) - layer_.modified(mess); - } - /** - * Set VectorKey identifier. - * - * @param id key identifier - */ - public void setId(String id) { - ident_ = id; - } - /** - * Get VectorKey identifier - * - * @return identifier - */ - public String getId() { - return ident_; - } - /** - * Set line length. - * - * @param len line length - */ - public void setVectorLengthP(double len) { - if(vectorLengthP_ != len) { - vectorLengthP_ = len; - modified("VectorKey: setVectorLengthP()"); - } - } - /** - * @since 3.0 - */ - public void setLineLengthP(double len) { - setVectorLengthP(len); - } - /** - * Get line length - * - * @return line length - */ - public double getVectorLengthP() { - return vectorLengthP_; - } - /** - * Set the number of columns. - * - * @param col number of columns - */ - public void setColumns(int col) { - if(columns_ != col) { - columns_ = col; - modified("VectorKey: setColumms()"); - } - } - /** - * Get the number of columns. - * - * @return number of columns - */ - public int getColumns() { - return columns_; - } - /** - * Set border style. - * - * @param style border style - * @see #PLAIN_LINE - * @see #RAISED - * @see #NO_BORDER - */ - public void setBorderStyle(int style) { - if(style_ != style) { - style_ = style; - modified("VectorKey: setBorderStyle()"); - } - } - /** - * Get border style. - * - * @return border style - */ - public int getBorderStyle() { - return style_; - } - /** - * Set alignment. - * - * @param vert vertical alignment - * @param horz horizontal alignment - */ - public void setAlign(int vert,int horz) { - if(valign_ != vert || halign_ != horz) { - valign_ = vert; - halign_ = horz; - modified("VectorKey: setAlign()"); - } - } - /** - * Set vertical alignment - * - * @param vert vertical alignment - */ - public void setVAlign(int vert) { - if(valign_ != vert) { - valign_ = vert; - modified("VectorKey: setVAlign()"); - } - } - /** - * Set horizontal alignment - * - * @param horz horizontal alignment - */ - public void setHAlign(int horz) { - if(halign_ != horz) { - halign_ = horz; - modified("VectorKey: setHAlign()"); - } - } - /** - * Get vertical alignment - * - * @return vertical alignment - */ - public int getVAlign() { - return valign_; - } - /** - * Get horizontal alignment - * - * @return horizontal alignment - */ - public int getHAlign() { - return halign_; - } - /** - * Set location of key - *
Property Change: location. - * - * @param loc key location - */ - public void setLocationP(Point2D.Double loc) { - if(porigin_ == null || !porigin_.equals(loc)) { - Point2D.Double temp = porigin_; - porigin_ = loc; - changes_.firePropertyChange("location", - temp, - porigin_); - modified("VectorKey: setLocationP()"); - } - } - /** - * Set the bounds, in physical units, of the VectorKey - */ - public void setBoundsP(Rectangle2D.Double r) { - setLocationP(new Point2D.Double(r.x, r.y)); - } - public Rectangle2D.Double getBoundsP() { - throw new MethodNotImplementedError(); - } - /** - * Get location of key. - * - * @return Key location - */ - public Point2D.Double getLocationP() { - return porigin_; - } - /** - * Add a VectorCartesianRenderer and label to the VectorKey. - * - * @param line VectorCartesianRenderer object - * @param label descriptive label - */ - public void addVectorGraph(VectorCartesianRenderer vector, SGLabel label) { - vectors_.addElement(vector); - label.setLayer(layer_); - label.setMoveable(false); - label.setSelectable(false); - label_.addElement(label); - SGLabel scale = new SGLabel("scale label", - " ", - label.getHeightP(), - label.getLocationP(), - label.getVAlign(), - label.getHAlign()); - scale.setFont(label.getFont()); - scale.setLayer(label.getLayer()); - scale.setMoveable(false); - scale.setSelectable(false); - scaleLabel_.addElement(scale); - ((VectorAttribute)vector.getAttribute()).addPropertyChangeListener(this); - modified("VectorKey: addVectorGraph()"); - } - /** - * Add a VectorCartesianRenderer and label to the VectorKey. - * - * @param rend CartesianRenderer object - * @param label descriptive label - * @since 3.0 - */ - public void addGraph(CartesianRenderer rend, SGLabel label) - throws IllegalArgumentException { - if(!(rend instanceof VectorCartesianRenderer)) - throw new IllegalArgumentException("Renderer is not a VectorCartesianRenderer"); - addVectorGraph((VectorCartesianRenderer)rend, label); - } - /** - * Remove a line from the VectorKey. - * - */ - public void removeVectorGraph(SGLabel label) { - } - /** - * Remove a line from the VectorKey. - * - */ - public void removeVectorRenderer(VectorCartesianRenderer line) { - } - /** - * Remove a line from the VectorKey. - * - */ - public void removeVectorGraph(String ident) { - } - /** - * Remove all lines from the VectorKey. - */ - public void clearAll() { - VectorAttribute attr; - for(Enumeration e = vectors_.elements(); e.hasMoreElements(); ) { - attr = (VectorAttribute)((VectorCartesianRenderer)e.nextElement()).getAttribute(); - attr.removePropertyChangeListener(this); - } - vectors_.removeAllElements(); - label_.removeAllElements(); - modified("VectorKey: clearAll()"); - } - /** - * Remove data from key by id. - */ - public void clear(String data_id) { - VectorCartesianRenderer vcr; - int indx = -1; - for(Enumeration it = vectors_.elements(); it.hasMoreElements();) { - indx++; - vcr = (VectorCartesianRenderer)it.nextElement(); - // if(pcr.getLine().getId().equals(data_id)) { - // pcr.getAttribute().removePropertyChangeListener(this); - // points_.removeElement(lcr); - // label_.removeElementAt(indx); - // modified("VectorKey: clear()"); - // break; - // } - } - } - /** - * Return height of key row in pixels. - */ - public int getRowHeight() { - Rectangle bounds; - bounds = getBounds(); - return ROW_SPACE_ + maxLabelHeight_; - } - /** - * Draw the Key. - */ - public void draw(Graphics g) { - double maxLabelLength, maxLabelHeight; - int numLines, numRows, i; - float vectorLength; - float vectorLengthU; - int col, row, ytemp; - double xloc, labelSpace, scaleSpace, scaleLength; - double[] xp, yp; - int[] xd, yd; - int[] xout, yout; - float hx1, hx2; - float hy1, hy2; - float headX, headY; - float orgX, orgY; - float xphead, yphead; - float tScale, fixedScale; - float scale; - float headScale; - float minSize; - float maxSize; - Rectangle bounds; - VectorCartesianRenderer render = null; - SGLabel label; - SGLabel scaleLabel; - String scaleStr; - VectorAttribute attr = null; - Graphics2D g2 = (Graphics2D)g; - GeneralPath gp; - Stroke savedStroke = g2.getStroke(); - BasicStroke stroke; - slope_ = (float)layer_.getXSlope(); - xoff_ = (float)layer_.getXOffset(); - yoff_ = (float)layer_.getYOffset(); - // - numLines = vectors_.size(); - if((numLines <= 0) || !visible_) return; - - numRows = numLines/columns_; - if(numLines%columns_ != 0) numRows++; - - xp = new double[columns_]; - xd = new int[columns_]; - yp = new double[numRows]; - yd = new int[numRows]; - xout = new int[2]; - yout = new int[2]; - - g.setColor(layer_.getPane().getComponent().getForeground()); - bounds = getBounds(); - // - // compute location of rows and columns in device and physical coordinates - // - vectorLength = xPtoD((float)vectorLengthP_) - xPtoD(0.0f); - labelSpace = layer_.getXDtoP(LABEL_SPACE_) - layer_.getXDtoP(0); - scaleLength = layer_.getXDtoP(maxScaleLength_) - layer_.getXDtoP(0); - scaleSpace = layer_.getXDtoP(SCALE_SPACE_) - layer_.getXDtoP(0); - // - yd[0] = bounds.y + VERTICAL_BORDER_ + maxLabelHeight_; - yp[0] = layer_.getYDtoP(yd[0]); - for(i=1; i < numRows; i++) { - yd[i] = yd[i-1] + ROW_SPACE_ + maxLabelHeight_; - yp[i] = layer_.getYDtoP(yd[i]); - } - xd[0] = bounds.x + HORIZONTAL_BORDER_; - xp[0] = layer_.getXDtoP(xd[0]); - for(i=1; i < columns_; i++) { - xd[i] = xd[i-1] + COLUMN_SPACE_ + (int)vectorLength + - SCALE_SPACE_ + maxScaleLength_ + - LABEL_SPACE_ + maxLabelLength_; - xp[i] = layer_.getXDtoP(xd[i]); - } - // - row = 0; - col = 0; - Object obj; - Enumeration labelIt = label_.elements(); - Enumeration scaleIt = scaleLabel_.elements(); - for(Enumeration lineIt = vectors_.elements(); lineIt.hasMoreElements();) { - obj = lineIt.nextElement(); - render = (VectorCartesianRenderer)obj; - attr = (VectorAttribute)render.getAttribute(); - label = (SGLabel)labelIt.nextElement(); - scaleLabel = (SGLabel)scaleIt.nextElement(); - // - // draw line - // - g2.setColor(attr.getVectorColor()); - stroke = new BasicStroke(attr.getWidth(), - attr.getCapStyle(), - attr.getMiterStyle(), - attr.getMiterLimit()); - scale = (float)attr.getVectorScale(); - headScale = (float)attr.getHeadScale()*0.94386f; - fixedScale = (float)(headScale*attr.getHeadFixedSize()); - minSize = (float)attr.getHeadMinSize(); - maxSize = (float)attr.getHeadMaxSize(); - vectorLengthU = (float)(vectorLengthP_/scale); - g2.setStroke(stroke); - gp = new GeneralPath(); - orgX = (float)xd[col]; - orgY = (float)(yd[row] - maxLabelHeight_/2); - headX = orgX + vectorLength; - headY = orgY; - xphead = xDtoP(headX); - yphead = yDtoP(headY); - gp.moveTo(orgX, orgY); - gp.lineTo(headX, headY); - // - // add head - // - if(vectorLength == 0.0) { - g.drawLine((int)headX, (int)headY, (int)headX, (int)headY); - } else { - if(attr.getVectorStyle() != VectorAttribute.NO_HEAD) { - if(attr.getVectorStyle() == VectorAttribute.HEAD) { - // unscaled head - tScale = fixedScale; - hx1 = xPtoD(xphead - tScale); - hy1 = yPtoD(yphead + 0.35f*tScale); - hx2 = xPtoD(xphead - tScale); - hy2 = yPtoD(yphead - 0.35f*tScale); - gp.moveTo(hx1, hy1); - gp.lineTo(headX, headY); - gp.lineTo(hx2, hy2); - } else { - // scaled head - if(vectorLengthP_ >= maxSize) { - tScale = maxSize*headScale; - } else if(vectorLengthP_ <= minSize) { - tScale = minSize*headScale; - } else { - tScale = (float)(vectorLengthP_*headScale); - } - hx1 = xPtoD(xphead - tScale); - hy1 = yPtoD(yphead + 0.35f*tScale); - hx2 = xPtoD(xphead - tScale); - hy2 = yPtoD(yphead - 0.35f*tScale); - gp.moveTo(hx1, hy1); - gp.lineTo(headX, headY); - gp.lineTo(hx2, hy2); - } - } - } - - g2.draw(gp); - g2.setStroke(savedStroke); - // - // draw mark - // - xout[0] = (int)orgX; - yout[0] = (int)orgY; - if(attr.getOriginStyle() == VectorAttribute.MARK) { - g.setColor(attr.getMarkColor()); - render.drawMark(g, xout, yout, 1, attr); - } - // - // scale label - // - xloc = xp[col] + vectorLengthP_ + scaleSpace; - if(vectorLengthU > 1000.0 || vectorLengthU < 0.01) { - scaleStr = expFormat_.format(vectorLengthU); - } else { - scaleStr = floatFormat_.format(vectorLengthU); - } - scaleLabel.setText(scaleStr); - scaleLabel.setLocationP(new Point2D.Double(xloc, yp[row])); - - // - // user label - // - xloc = xloc + scaleLength + labelSpace; - label.setLocationP(new Point2D.Double(xloc, yp[row])); - try { - scaleLabel.draw(g); - label.draw(g); - } catch (SGException e) { System.out.println(e);} - // - col++; - if(col >= columns_) { - col = 0; - row++; - } - } - switch(style_) { - case PLAIN_LINE: - g.drawRect(bounds.x, bounds.y, bounds.width-1, bounds.height-1); - break; - case RAISED: - break; - default: - case NO_BORDER: - } - } - - private float xPtoD(float xp) { - return slope_*xp + xoff_; - } - - private float yPtoD(float yp) { - return yoff_ - slope_*yp; - } - - private float xDtoP(float xd) { - return (xd - xoff_)/slope_; - } - - private float yDtoP(float yd) { - return (yoff_ - yd)/slope_; - } - - /** - * Get the bounding rectangle. - * - * @return bounding rectangle - */ - public Rectangle getBounds() { - int vectorLength; - int numLines, rows; - int x, y, height, width; - - numLines = vectors_.size(); - if(numLines <= 0) return new Rectangle(0, 0, 0, 0); - // - // find longest label and scale - // - maxLabelLength_ = 0; - maxLabelHeight_ = 0; - maxScaleLength_ = 0; - Object obj; - VectorCartesianRenderer render; - VectorAttribute attr; - double vectorLengthU; - Enumeration lineIt = vectors_.elements(); - Enumeration scaleIt = scaleLabel_.elements(); - SGLabel label; - String scaleStr; - SGLabel scaleLabel; - for(Enumeration it = label_.elements(); it.hasMoreElements();) { - label = (SGLabel)it.nextElement(); - Rectangle sz = label.getBounds(); - maxLabelLength_ = Math.max(maxLabelLength_, sz.width); - maxLabelHeight_ = Math.max(maxLabelHeight_, sz.height); - // - obj = lineIt.nextElement(); - render = (VectorCartesianRenderer)obj; - attr = (VectorAttribute)render.getAttribute(); - vectorLengthU = vectorLengthP_/attr.getVectorScale(); - if(vectorLengthU > 1000.0 || vectorLengthU < 0.01) { - scaleStr = expFormat_.format(vectorLengthU); - } else { - scaleStr = floatFormat_.format(vectorLengthU); - } - scaleLabel = (SGLabel)scaleIt.nextElement(); - scaleLabel.setText(scaleStr); - sz = scaleLabel.getBounds(); - maxScaleLength_ = Math.max(maxScaleLength_, sz.width); - } - // - rows = numLines/columns_; - if(numLines%columns_ != 0) rows++; - vectorLength = layer_.getXPtoD(vectorLengthP_) - layer_.getXPtoD(0.0f); - width = 2*HORIZONTAL_BORDER_ + - columns_*(vectorLength + SCALE_SPACE_ + maxScaleLength_ + - LABEL_SPACE_ + maxLabelLength_) + - (columns_ - 1)*COLUMN_SPACE_; - height = 2*VERTICAL_BORDER_ + rows*maxLabelHeight_ + - (rows-1)*ROW_SPACE_; - // temp fudge - height = height + 5; - // - x = layer_.getXPtoD(porigin_.x); - y = layer_.getYPtoD(porigin_.y); - switch(halign_) { - case RIGHT: - x = x - width; - break; - case CENTER: - x = x - width/2; - } - switch(valign_) { - case BOTTOM: - y = y - height; - break; - case MIDDLE: - y = y - height/2; - } - return new Rectangle(x, y, width, height); - } - public Point getLocation() { - Rectangle bnds = getBounds(); - return new Point(bnds.x, bnds.y); - } - public void setLocation(Point loc) { - Rectangle bnds = getBounds(); - setBounds(loc.x, loc.y, bnds.width, bnds.height); - } - /** - * Set the bounds, in pixels, of the VectorKey - */ - public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); - } - /** - * Set the bounds, in pixels, of the VectorKey - *
Property Change: location. - */ - public void setBounds(int x, int y, int width, int height) { - switch(halign_) { - case RIGHT: - x = x + width; - break; - case CENTER: - x = x + width/2; - } - switch(valign_) { - case BOTTOM: - y = y + height; - break; - case MIDDLE: - y = y + height/2; - } - double xp = layer_.getXDtoP(x); - double yp = layer_.getYDtoP(y); - if(porigin_.x != xp || porigin_.y != yp) { - Point2D.Double temp = porigin_; - porigin_.x = xp; - porigin_.y = yp; - changes_.firePropertyChange("location", - temp, - new Point2D.Double(xp, yp)); - modified("VectorKey: setBounds()"); - } - } - Object getObjectAt(Point pt) { - Rectangle lbnds; - Rectangle bounds; - VectorCartesianRenderer vector; - int[] xout, yout; - int[] xd, yd; - int numLines, numRows; - int vectorLength; - double labelSpace, scaleSpace; - int i; - - numLines = vectors_.size(); - if(numLines <= 0) return null; - - numRows = numLines/columns_; - if(numLines%columns_ != 0) numRows++; - - xd = new int[columns_]; - yd = new int[numRows]; - xout = new int[2]; - yout = new int[2]; - bounds = getBounds(); - // - // compute location of rows and columns in device and physical coordinates - // - vectorLength = layer_.getXPtoD(vectorLengthP_) - layer_.getXPtoD(0.0); - labelSpace = layer_.getXDtoP(LABEL_SPACE_) - layer_.getXDtoP(0); - scaleSpace = layer_.getXDtoP(SCALE_SPACE_) - layer_.getXDtoP(0); - // - yd[0] = bounds.y + VERTICAL_BORDER_ + maxLabelHeight_; - for(i=1; i < numRows; i++) { - yd[i] = yd[i-1] + ROW_SPACE_ + maxLabelHeight_; - } - xd[0] = bounds.x + HORIZONTAL_BORDER_; - for(i=1; i < columns_; i++) { - xd[i] = xd[i-1] + COLUMN_SPACE_ + vectorLength + SCALE_SPACE_ + - maxScaleLength_ + LABEL_SPACE_ + maxLabelLength_; - } - // loop over all the lines - int row = 0; - int col = 0; - for(Enumeration lineIt = vectors_.elements(); lineIt.hasMoreElements();) { - vector = (VectorCartesianRenderer)lineIt.nextElement(); - xout[0] = xd[col]; - // xout[1] = xout[0] + vectorLength + 2*LABEL_SPACE_ + - // maxScaleLenght_ + maxLabelLength_; - xout[1] = xout[0] + vectorLength + SCALE_SPACE_; - yout[0] = yd[row] - maxLabelHeight_; - yout[1] = yd[row]; - lbnds = new Rectangle(xout[0], yout[0], - xout[1] - xout[0], - yout[1] - yout[0]); - - if(lbnds.contains(pt)) { - return vector; - } - // - col++; - if(col >= columns_) { - col = 0; - row++; - } - } - if(bounds.contains(pt)) { - return this; - } - return null; - } - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + ident_; - } - public boolean isVisible() { - return visible_; - } - public void setVisible(boolean visible) { - if(visible_ != visible) { - visible_ = visible; - modified("VectorKey: setVisible()"); - } - } - public void propertyChange(PropertyChangeEvent evt) { - // if(Debug.EVENT) { - // System.out.println("VectorKey: " + evt); - // System.out.println(" " + evt.getPropertyName()); - // } - modified("VectorKey: propertyChange(" + - evt.getSource().toString() + "[" + - evt.getPropertyName() + "]" + ")"); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/YearDecadeAxis.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/YearDecadeAxis.java deleted file mode 100755 index 673c0903..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/YearDecadeAxis.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * $Id: YearDecadeAxis.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.IllegalTimeValue; - -/** - * Draws time axes using the year/decade style. - * - *
- *            |..........|..........|..........|..........|
- *                 84         85         86         87
- *                               1980
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @see Axis - * @see TimeAxis - */ -class YearDecadeAxis implements TimeAxisStyle { - static final int DECADE_TEST__ = 1000; - static final String defaultMinorLabelFormat__ = "yy"; - // static final String defaultMajorLabelFormat__ = "yyyy"; - static final String defaultMajorLabelFormat__ = "decade"; - int defaultMinorLabelInterval_ = 2; - int defaultMajorLabelInterval_ = 1; - static final int defaultNumSmallTics__ = 0; - static final double incrementValue__ = 1.0; - static final int incrementUnits__ = GeoDate.YEARS; - /** - * YearDecadeAxis constructor. - * - * @param id axis identifier - **/ - public YearDecadeAxis() { - } - public void computeDefaults(GeoDate delta) { - if(delta.getTime()/GeoDate.MSECS_IN_DAY > 2500) { - defaultMinorLabelInterval_ = 2; - } else { - defaultMinorLabelInterval_ = 1; - } - } - public double computeLocation(double prev,double now) { - return (prev + now)*0.5; - } - public int getMinorValue(GeoDate time) { - return time.getGMTYear() - (time.getGMTYear()/10)*10 + 1; - } - public int getMajorValue(GeoDate time) { - return (time.getGMTYear()/10)*10; - } - public boolean isRoomForMajorLabel(GeoDate delta) { - return delta.getTime()/GeoDate.MSECS_IN_DAY > DECADE_TEST__; - } - public boolean isStartOfMinor(GeoDate time) { - return (time.getGMTYear() % 10) == 0; - } - public String getDefaultMinorLabelFormat() { - return defaultMinorLabelFormat__; - } - public String getDefaultMajorLabelFormat() { - return defaultMajorLabelFormat__; - } - public int getDefaultNumSmallTics() { - return defaultNumSmallTics__; - } - public int getDefaultMajorLabelInterval() { - return defaultMajorLabelInterval_; - } - public int getDefaultMinorLabelInterval() { - return defaultMinorLabelInterval_; - } - public GeoDate getStartTime(TimeRange tRange) { - boolean time_increasing; - GeoDate time = null; - time_increasing = tRange.end.after(tRange.start); - try { - if(time_increasing) { - time = new GeoDate(1, 1, tRange.start.getGMTYear(), 0, 0, 0, 0); - if(!time.equals(tRange.start)) time.increment(1.0, GeoDate.YEARS); - } else { - time = new GeoDate(1, 1, tRange.end.getGMTYear(), 0, 0, 0, 0); - if(!time.equals(tRange.end)) time.increment(1.0, GeoDate.YEARS); - } - } catch (IllegalTimeValue e) {} - return time; - } - public double getIncrementValue() { - return incrementValue__; - } - public int getIncrementUnits() { - return incrementUnits__; - } - public String toString() { - return "YearDecadeAxis"; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolder.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolder.java deleted file mode 100755 index ac4b6746..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolder.java +++ /dev/null @@ -1,972 +0,0 @@ -/* - * $Id: AxisHolder.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import gov.noaa.pmel.sgt.*; -import gov.noaa.pmel.util.*; -import java.awt.*; -import java.beans.*; -import java.io.*; -import java.util.*; -import javax.swing.event.*; - -/** - * Contains the data necessary to instantiate an axis. - * This class is used with DataGroup. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -public class AxisHolder implements Serializable { - private Vector changeListeners; - - /** - * @label dataGroup - */ - private DataGroup dataGroup_; - transient private ChangeEvent changeEvent_ = new ChangeEvent(this); - // general axis properties - /** - * axisType = DataGroup.PLAIN, DataGroup.TIME, or DataGroup.LOG - */ - private int axisType = -1; // must be defined - /** - * axisOrientation = DataGroup.X_DIR or DataGroup.Y_DIR - */ - private int axisOrientation = -1; // must be defined - /** - * transformType = DataGroup.LINEAR, DataGroup.LOG, DataGroup.REFERENCE - */ - private int transformType = DataGroup.LINEAR; - private String transformGroup = ""; - /** - *
-   * axisPosition = DataGroup.TOP, DataGroup.BOTTOM, (for x axes)
-   *                DataGroup.LEFT, DataGroup.RIGHT, (for y axes)
-   *                DataGroup.MANUAL
-   * 
- */ - private int axisPosition = -1; - /** - * used if axisPosition = MANUAL, always computed - */ - private Point2D.Double axisOriginP = new Point2D.Double(0.0, 0.0); - private boolean locationAtOrigin = false; - private Color axisColor = Color.black; - private boolean autoRange = true; - /** - * used if axisPosition = MANUAL, always computed - */ - private Rectangle2D boundsP = new Rectangle2D.Double(0.0, 0.0, 0.0, 0.0); -// private double originP = 0.0; // y origin for X_DIR, x origin for Y_DIR if axisPosition = MANUAL - private SoTRange userRange = new SoTRange.Double(1.0, 10.0, 1.0); - private Color labelColor = Color.black; - private Font labelFont = new Font("Helvetica", Font.ITALIC, 10); - private double labelHeightP = 0.15; - /** - *
-   * labelPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
-   *                 Axis.NEGATIVE_SIDE, Axis.NO_LABEL
-   * 
- */ - private int labelPosition = Axis.AUTO; // Expert - private double largeTicHeightP = 0.1; // Expert - private double smallTicHeightP = 0.05; // Expert - private int numSmallTics = 0; - private double thickTicWidth = 0.025; // Expert - /** - *
-   * ticPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
-   *               Axis.NEGATIVE_SIDE, Axis.BOTH_SIDES
-   * 
- */ - private int ticPosition = Axis.AUTO; // Expert - private SGLabel title = new SGLabel("title", "", 0.20, - new Point2D.Double(0.0, 0.0), - SGLabel.BOTTOM, SGLabel.LEFT); - private boolean titleAuto = true; - private boolean selectable = true; - private boolean visible = true; - // SpaceAxis properties - private String labelFormat = ""; // Expert - private int labelInterval = 2; - private int labelSignificantDigits = 2; - // TimeAxis properties defaults appropriate for MONTH_YEAR - private String minorFormat = "MMM"; // Expert - private String majorFormat = "yyyy"; // Expert - private int minorInterval = 2; // Expert - private int majorInterval = 1; // Expert - /** - *
-   * timeAxisStyle = TimeAxis.AUTO, TimeAxis.DAY_MONTH, TimeAxis.HOUR_DAY,
-   *                 TimeAxis.MINUTE_HOUR, TimeAxis.MONTH_YEAR,
-   *                 TimeAxis.YEAR_DECADE
-   * 
- */ - private int timeAxisStyle = TimeAxis.AUTO; - - private boolean suppressEvent_ = false; - - /** - * Static code to make sure that dataGroup doesn't get serialized by - * XMLEncode - */ - static { - try { - BeanInfo info = Introspector.getBeanInfo(AxisHolder.class); - PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); - for(int i=0; i < descriptors.length; i++) { - PropertyDescriptor pd = descriptors[i]; - if(pd.getName().equals("dataGroup")) { - pd.setValue("transient", Boolean.TRUE); - } - } - } catch (IntrospectionException ie) { - ie.printStackTrace(); - } - } - - /** - * Default constructor. The methods setAxisType, setAxisOrientation, and - * setDataGroup must be called. - */ - public AxisHolder() { - title.setColor(Color.black); - } - - /** - * Construct a new AxisHolder. This constructor includes the - * necessary fields. - * - * @param type Type of axis - * @param dir Direction of axis - * @param dataGroup DataGroup parent - * @see #setAxisType setAxisType - * @see #setAxisOrientation setAxisOrientation - * @see #setDataGroup setDataGroup - */ - public AxisHolder(int type, int dir, DataGroup dataGroup) { - axisType = type; - axisOrientation = dir; - dataGroup_ = dataGroup; - if(axisOrientation == DataGroup.X_DIR) { - title.setText("X Axis"); - axisPosition = DataGroup.BOTTOM; - } else { - title.setText("Y Axis"); - axisPosition = DataGroup.LEFT; - } - transformGroup = dataGroup.getId(); - title.setColor(Color.black); - } - - /** - * Get the DataGroup parent. - * @return DataGroup parent - */ - public DataGroup getDataGroup() { - return dataGroup_; - } - - /** - * Set the parent DataGroup. No default. - * - * @param dataGroup Parent object to AxisHolder - */ - public void setDataGroup(DataGroup dataGroup) { - dataGroup_ = dataGroup; - transformGroup = dataGroup_.getId(); - } - - /** - * Test if the axis time. - * @return True if axis is time. - */ - public boolean isTime() { - return axisType == DataGroup.TIME; - } - - /** - * Remove a ChangeListener. - * @param l ChangeListener to remove - */ - public synchronized void removeChangeListener(ChangeListener l) { - if (changeListeners != null && changeListeners.contains(l)) { - Vector v = (Vector) changeListeners.clone(); - v.removeElement(l); - changeListeners = v; - } - } - - /** - * Add a ChangeListener. Listener will be notified if a change - * occurs. - * @param l ChangeListener to add. - */ - public synchronized void addChangeListener(ChangeListener l) { - Vector v = changeListeners == null ? new Vector(2) : (Vector) changeListeners.clone(); - if (!v.contains(l)) { - v.addElement(l); - changeListeners = v; - } - } - - /** - * Remove all ChangeListeners that implement the - * DesignListener interface. - * - * @see DesignListener - */ - public synchronized void removeDesignChangeListeners() { - if(changeListeners != null) { - Vector v = (Vector) changeListeners.clone(); - Iterator iter = v.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof DesignListener) changeListeners.removeElement(obj); - } - } - } - - /** - * Remove all ChangeListeners. - */ - public void removeAllChangeListeners() { - changeListeners.removeAllElements(); - } - - void fireStateChanged() { - if(suppressEvent_) return; - if (changeListeners != null) { - Vector listeners = changeListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - ((ChangeListener) listeners.elementAt(i)).stateChanged(changeEvent_); - } - } - } - // general axis properties - - /** - * Set the axis type. The possible types include: - *
-   * axisType = DataGroup.PLAIN, DataGroup.TIME, or DataGroup.LOG
-   * 
- * No default. - * @param axisType (see above) - */ - public void setAxisType(int axisType) { - int saved = this.axisType; - this.axisType = axisType; - if(saved != this.axisType) fireStateChanged(); - } - - /** - * Get the axis type. - * @return axis type - */ - public int getAxisType() { - return axisType; - } - - /** - * Get the axis orientation. - * @return axis orientation. - */ - public int getAxisOrientation() { - return axisOrientation; - } - - /** - * Set the axis orientation. Orientations are: - *
-   * axisOrientation = DataGroup.X_DIR or DataGroup.Y_DIR
-   * 
- * No default. - * @param dir axis orientation - */ - public void setAxisOrientation(int dir) { - axisOrientation = dir; - if(axisOrientation == DataGroup.X_DIR) { - title.setText("X Axis"); - axisPosition = DataGroup.BOTTOM; - } else { - title.setText("Y Axis"); - axisPosition = DataGroup.LEFT; - } - } - - /** - * Set axis color. Default = black. - * @param axisColor axis color - */ - public void setAxisColor(Color axisColor) { - Color saved = new Color(this.axisColor.getRed(), - this.axisColor.getGreen(), - this.axisColor.getBlue(), - this.axisColor.getAlpha()); - this.axisColor = axisColor; - if(!saved.equals(this.axisColor)) fireStateChanged(); - } - - /** - * Get the axis color. - * @return axis color - */ - public Color getAxisColor() { - return axisColor; - } - - /** - * Set autoRange property. True to automatically compute the axis range from - * the data. Default = true. - * @param autoRange auto range - */ - public void setAutoRange(boolean autoRange) { - boolean saved = this.autoRange; - this.autoRange = autoRange; - if(saved != autoRange) fireStateChanged(); - } - - /** - * Test if the axis in autoRange mode. - * @return True, if in autoRange mode. - */ - public boolean isAutoRange() { - return autoRange; - } - - /** - * Set the user range. User range is only used if autoRange is false. - * Default = (1, 10, 1) - * @param userRange user supplied range - */ - public void setUserRange(SoTRange userRange) { - SoTRange saved = userRange.copy(); - this.userRange = userRange; - if(!saved.equals(this.userRange)) fireStateChanged(); - } - - /** - * Get the user range. - * @return user range - */ - public SoTRange getUserRange() { - return userRange; - } - - /** - * Set axis label color. Default = black. - * @param labelColor label color - */ - public void setLabelColor(Color labelColor) { - Color saved = new Color(this.labelColor.getRed(), - this.labelColor.getGreen(), - this.labelColor.getBlue(), - this.labelColor.getAlpha()); - this.labelColor = labelColor; - if(!saved.equals(this.labelColor)) fireStateChanged(); - } - - /** - * Get the axis label color. - * @return axis label color - */ - public Color getLabelColor() { - return labelColor; - } - - /** - * Set the axis label font. Default = ("Helvetica", ITALIC, 10). - * @param labelFont label font - */ - public void setLabelFont(Font labelFont) { - Font saved = new Font(this.labelFont.getName(), - this.labelFont.getStyle(), - this.labelFont.getSize()); - this.labelFont = labelFont; - if(!saved.equals(this.labelFont)) fireStateChanged(); - } - - /** - * Get the axis label font. - * @return axis label font - */ - public Font getLabelFont() { - return labelFont; - } - - /** - * Set label height in physical coordinates (inches). Default = 0.15. - * @param labelHeightP label height - */ - public void setLabelHeightP(double labelHeightP) { - double saved = this.labelHeightP; - this.labelHeightP = labelHeightP; - if(saved != this.labelHeightP) fireStateChanged(); - } - - /** - * Get label height. - * @return label height in physical coordinates - */ - public double getLabelHeightP() { - return labelHeightP; - } - - /** - * Set the label position. Label position can be: - *
-   * labelPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
-   *                 Axis.NEGATIVE_SIDE, Axis.NO_LABEL
-   * 
- * Default = AUTO. - * @param labelPosition label position - */ - public void setLabelPosition(int labelPosition) { - int saved = this.labelPosition; - this.labelPosition = labelPosition; - if(saved != this.labelPosition) fireStateChanged(); - } - -/** - * Test if label position in auto mode. - * @return true if in auto mode - */ - public boolean isLabelPositionAuto() { - return labelPosition == Axis.AUTO; - } - - /** - * If labelPosition is AUTO then return computed labelPosition, - * otherwise return stored value - * @return label position - */ - public int getLabelPosition() { - int labPos = Axis.NEGATIVE_SIDE; - if(isLabelPositionAuto()) { - switch(axisPosition) { - case DataGroup.MANUAL: - case DataGroup.BOTTOM: - case DataGroup.LEFT: - labPos = Axis.NEGATIVE_SIDE; - break; - case DataGroup.TOP: - case DataGroup.RIGHT: - labPos = Axis.POSITIVE_SIDE; - break; - } - } else { - labPos = labelPosition; - } - return labPos; - } - - /** - * Set bounds of axis in physical coordinates. Default = (0, 0, 0, 0). - * @param boundsP axis bounds - */ - public void setBoundsP(Rectangle2D boundsP) { - Rectangle2D saved = getBoundsP(); -// if(this.boundsP != null) saved = this.boundsP.copy(); - this.boundsP = boundsP; - boolean changed = true; - if(saved != null) changed = !saved.equals(this.boundsP); - if(changed) fireStateChanged(); - } - - /** - * Get axis bounds. - * @return axis bounds in physical coordinates. - */ - public Rectangle2D getBoundsP() { - return boundsP; - /** @todo bounds isn't cloned should be see note */ -// return boundsP == null? null: boundsP.copy(); - } - - /** - * Get range of axis (long direction) in physical coordinates. - * The bounds are used to determine the axis range. - * @return axis range (long direction) - */ - public Range2D getRangeP() { - Rectangle2D.Double dbl = (Rectangle2D.Double)boundsP; - if(axisOrientation == DataGroup.X_DIR) { - return new Range2D(dbl.x, dbl.x + dbl.width); - } else { - return new Range2D(dbl.y, dbl.y + dbl.height); - } - } - - /** - * Set large tic height in physical coordinates. Default = 0.1. - * @param largeTicHeightP large tic height - */ - public void setLargeTicHeightP(double largeTicHeightP) { - double saved = this.largeTicHeightP; - this.largeTicHeightP = largeTicHeightP; - if(saved != this.largeTicHeightP) fireStateChanged(); - } - - /** - * Get large tic height. - * @return large tic height in physical coordinates. - */ - public double getLargeTicHeightP() { - return largeTicHeightP; - } - - /** - * Set small tic height in physical coordinates. Default = 0.05. - * @param smallTicHeightP small tic height - */ - public void setSmallTicHeightP(double smallTicHeightP) { - double saved = this.smallTicHeightP; - this.smallTicHeightP = smallTicHeightP; - if(saved != this.smallTicHeightP) fireStateChanged(); - } - - /** - * Get small tic height. - * @return small tic height in physical coordinates - */ - public double getSmallTicHeightP() { - return smallTicHeightP; - } - - /** - * Set the number of small tics between the large tics. This should be one less - * than the number of intervals you want. Default = 0. - * @param numSmallTics number of small tics - */ - public void setNumSmallTics(int numSmallTics) { - int saved = this.numSmallTics; - this.numSmallTics = numSmallTics; - if(saved != this.numSmallTics) fireStateChanged(); - } - - /** - * Get the number of small tics. - * @return number of small tics between large tics - */ - public int getNumSmallTics() { - return numSmallTics; - } - - /** - * Set the thick tic width (for Time axes). Default = 0.025. - * @param thickTicWidth thick tic width - */ - public void setThickTicWidth(double thickTicWidth) { - double saved = this.thickTicWidth; - this.thickTicWidth = thickTicWidth; - if(saved != this.thickTicWidth) fireStateChanged(); - } - - /** - * Get the thick tic width. Valid for Time axes - * @return thick tic width - */ - public double getThickTicWidth() { - return thickTicWidth; - } - - /** - * Set the tic position. Tic position include: - *
-   * ticPosition = Axis.AUTO, Axis.POSITIVE_SIDE,
-   *               Axis.NEGATIVE_SIDE, Axis.BOTH_SIDES
-   * 
- * Default = AUTO. - * @param ticPosition tic position - */ - public void setTicPosition(int ticPosition) { - int saved = this.ticPosition; - this.ticPosition = ticPosition; - if(saved != this.ticPosition) fireStateChanged(); - } - -/** - * Test if tic position in auto mode. - * @return true if in auto mode - */ - public boolean isTicPositionAuto() { - return ticPosition == Axis.AUTO; - } - - /** - * If ticPosition is AUTO then returns computed position, otherwise - * returns stored value. - * @return tic position - */ - public int getTicPosition() { - int ticPos = Axis.NEGATIVE_SIDE; - if(isTicPositionAuto()) { - switch(axisPosition) { - case DataGroup.MANUAL: - case DataGroup.BOTTOM: - case DataGroup.LEFT: - ticPos = Axis.NEGATIVE_SIDE; - break; - case DataGroup.TOP: - case DataGroup.RIGHT: - ticPos = Axis.POSITIVE_SIDE; - break; - } - } else { - ticPos = ticPosition; - } - return ticPos; - } - - /** - * Set the axis title. Axis title is a SGLabel enabling the Color, - * Font, size to be set. - * @param title axis title - */ - public void setTitle(SGLabel title) { - SGLabel saved = (SGLabel)this.title.copy(); - this.title = title; - if(!saved.equals(this.title)) fireStateChanged(); - } - - /** - * Get the axis title. - * @return axis title - */ - public SGLabel getTitle() { - return title; - } - - /** - * Set the selecatability of the axis. If true, axis can be selected with - * the mouse. Default = true. - * @param selectable selectable - */ - public void setSelectable(boolean selectable) { - boolean saved = this.selectable; - this.selectable = selectable; - if(saved != this.selectable) fireStateChanged(); - } - - /** - * Test if the axis selectable. - * @return true, if the axis can be selected - */ - public boolean isSelectable() { - return selectable; - } - - /** - * Set/unset the axis visibility. If true, the axis will be displayed. - * Default = true. - * @param visible visible - */ - public void setVisible(boolean visible) { - boolean saved = this.visible; - this.visible = visible; - if(saved != this.visible) fireStateChanged(); - } - - /** - * Test if the axis visible. - * @return true, if axis is set visible - */ - public boolean isVisible() { - return visible; - } - // spaceaxis properties - - /** - * Set the axis label format. Not used with time axes. Default = "" - * @param labelFormat axis label format - */ - public void setLabelFormat(String labelFormat) { - String saved = this.labelFormat; - this.labelFormat = labelFormat; - if(!saved.equals(this.labelFormat)) fireStateChanged(); - } - - /** - * Get the label format. - * @return label format. - */ - public String getLabelFormat() { - return labelFormat; - } - - /** - * Set the label interval. Not used with time axes. Default = 2. - * @param labelInterval axis label interval - */ - public void setLabelInterval(int labelInterval) { - int saved = this.labelInterval; - this.labelInterval = labelInterval; - if(saved != this.labelInterval) fireStateChanged(); - } - - /** - * Get the label interval. - * @return label interval - */ - public int getLabelInterval() { - return labelInterval; - } - - /** - * Set the axis label significant digits. Not used with time axes. - * Default = 2. - * @param labelSignificantDigits axis label significant digits - */ - public void setLabelSignificantDigits(int labelSignificantDigits) { - int saved = this.labelSignificantDigits; - this.labelSignificantDigits = labelSignificantDigits; - if(saved != this.labelSignificantDigits) fireStateChanged(); - } - - /** - * Get axis label significant digits - * @return significant digits - */ - public int getLabelSignificantDigits() { - return labelSignificantDigits; - } - // timeaxis properties - - /** - * Set the time axis minor label format. Default = "MMM", appropriate for MONTH_YEAR. - * @param minorFormat time axis minor format - */ - public void setMinorFormat(String minorFormat) { - String saved = this.minorFormat; - this.minorFormat = minorFormat; - if(!saved.equals(this.minorFormat)) fireStateChanged(); - } - - /** - * Get time axis minor label format. - * @return minor label format - */ - public String getMinorFormat() { - return minorFormat; - } - - /** - * Get the time axis major label format. Default = "yyyy", appropriate for MONTH_YEAR. - * @param majorFormat time axis major format - */ - public void setMajorFormat(String majorFormat) { - String saved = this.majorFormat; - this.majorFormat = majorFormat; - if(!saved.equals(this.majorFormat)) fireStateChanged(); - } - - /** - * Get time axis major label format - * @return major label format - */ - public String getMajorFormat() { - return majorFormat; - } - - /** - * Set time axis minor label interval. Default = 2. - * @param minorInterval time axis minor interval - */ - public void setMinorInterval(int minorInterval) { - int saved = this.minorInterval; - this.minorInterval = minorInterval; - if(saved != this.minorInterval) fireStateChanged(); - } - - /** - * Get time axis minor label interval - * @return minor label interval - */ - public int getMinorInterval() { - return minorInterval; - } - - /** - * Set time axis major label interval. Default = 1. - * @param majorInterval time axis major interval - */ - public void setMajorInterval(int majorInterval) { - int saved = this.majorInterval; - this.majorInterval = majorInterval; - if(saved != this.majorInterval) fireStateChanged(); - } - - /** - * Get time axis major label interval - * @return major label interval - */ - public int getMajorInterval() { - return majorInterval; - } - - /** - * Set the time axis style. Styles include: - *
-   * timeAxisStyle = TimeAxis.AUTO, TimeAxis.DAY_MONTH, TimeAxis.HOUR_DAY,
-   *                 TimeAxis.MINUTE_HOUR, TimeAxis.MONTH_YEAR,
-   *                 TimeAxis.YEAR_DECADE
-   * 
- * Default = AUTO. - * @param timeAxisStyle time axis style - */ - public void setTimeAxisStyle(int timeAxisStyle) { - int saved = this.timeAxisStyle; - this.timeAxisStyle = timeAxisStyle; - if(saved != this.timeAxisStyle) fireStateChanged(); - } - - /** - * Get the time axis style. - * @return time axis style - */ - public int getTimeAxisStyle() { - return timeAxisStyle; - } - - /** - * Set the axis transform type. Transform types include: - *
-   * transformType = DataGroup.LINEAR, DataGroup.LOG, DataGroup.REFERENCE
-   * 
- * Default = LINEAR. - * @param transformType axis transform type - */ - public void setTransformType(int transformType) { - int saved = this.transformType; - this.transformType = transformType; - if(saved != this.transformType) fireStateChanged(); - } - - /** - * Get the axis transform type. - * @return transform type - */ - public int getTransformType() { - return transformType; - } - - /** - * Set the transform group. The transform group is used when the - * transformType = DataGroup.REFERENCE. The transformGroup is the - * DataGroup id containing the transform to be referenced. - * No default. - * @param transformGroup axis transform group name - */ - public void setTransformGroup(String transformGroup) { - String saved = this.transformGroup; - this.transformGroup = transformGroup; - if(saved == null || !saved.equals(this.transformGroup)) fireStateChanged(); - } - - /** - * Get transform group name. - * @return transform group - */ - public String getTransformGroup() { - return transformGroup; - } - - /** - * Set the axis position. Axis positions include: - *
-   * axisPosition = DataGroup.TOP, DataGroup.BOTTOM, (for x axes)
-   *                DataGroup.LEFT, DataGroup.RIGHT, (for y axes)
-   *                DataGroup.MANUAL
-   * 
- * No default. - * @param axisPosition axis position - */ - public void setAxisPosition(int axisPosition) { - int saved = this.axisPosition; - this.axisPosition = axisPosition; - if(saved != this.axisPosition) fireStateChanged(); - } - - /** - * Get the axis position - * @return axis position - */ - public int getAxisPosition() { - return axisPosition; - } - - /** - * Set the axis origin in physical coordinates. This is used when axisPosition = MANUAL. - * Default = (0, 0). - * @param axisOriginP axis origin - */ - public void setAxisOriginP(Point2D.Double axisOriginP) { - Point2D saved = getAxisOriginP(); -// if(this.axisOriginP != null) saved = this.axisOriginP.copy(); - this.axisOriginP = axisOriginP; - boolean changed = true; - if(saved != null) changed = !saved.equals(this.axisOriginP); -// if(Page.DEBUG) System.out.println("AxisHolder.setAxisOriginP: " + changed + -// ", " + saved + ", " + this.axisOriginP); - if(changed) fireStateChanged(); - } - - /** - * Get axis origin. - * @return axis origin - */ - public Point2D.Double getAxisOriginP() { - return axisOriginP == null? null: (Point2D.Double)axisOriginP.copy(); - } - - /** - * Set axis at origin of perpendicular axis. Not implemented. - * Default = false. - * @param locationAtOrigin set location at origin - */ - public void setLocationAtOrigin(boolean locationAtOrigin) { - boolean saved = this.locationAtOrigin; - this.locationAtOrigin = locationAtOrigin; - if(saved != this.locationAtOrigin) fireStateChanged(); - } - - /** - * Test if the axis at the origin. Not presently implemented. - * @return true, if axis will be at origin - */ - public boolean isLocationAtOrigin() { - return locationAtOrigin; - } - - /** - * Set the title auto property. Set true to determine the title from the - * data. Default = true. - * @param titleAuto auto title property - */ - public void setTitleAuto(boolean titleAuto) { - boolean saved = this.titleAuto; - this.titleAuto = titleAuto; - if(saved != this.titleAuto) fireStateChanged(); - } - - /** - * Test if the title in auto mode. - * @return true, if title is automatically generated - */ - public boolean isTitleAuto() { - return titleAuto; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolderDragBox.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolderDragBox.java deleted file mode 100755 index 781b7dbe..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolderDragBox.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * $Id: AxisHolderDragBox.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.sgt.Axis; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -class AxisHolderDragBox extends DragBox implements ChangeListener { - // box dimensions -// private static int BOX_HEIGHT = 25; - private static int TIC_LENGTH = 10; - private static int TIC_SPACE = 5; - private static int TIC_INCREMENT = 25; - private static int TITLE_HEIGHT = 10; - private static int TITLE_SPACE = 5; - // handle - public static final int ORIGIN = 0; - public static final int SIZE = 1; - public static final int DUMMY_ORIGIN = 2; - public static final int DUMMY_SIZE = 3; - // - private AxisHolder axHolder_; - private Rectangle boundsD_ = null; - private Point originD_ = null; - private String id_ = null; - private DataGroup dg_ = null; - - public AxisHolderDragBox(AxisHolder axHolder, DataGroup dg, PanelHolder pHolder) { - super(pHolder); - axHolder_ = axHolder; - axHolder_.addChangeListener(this); - dg_ = dg; - dg_.addChangeListener(this); - for(int i=0; i < handles_.length; i++) { - handles_[i] = new Rectangle(0,0,0,0); - } - id_ = axHolder_.getDataGroup().getId() + - (axHolder_.getAxisOrientation() == DataGroup.X_DIR? "_X": "_Y"); - - Point2D.Double orig = axHolder_.getAxisOriginP(); - if(orig != null) originD_ = toLocation(orig); - Rectangle2D.Double bnds = (Rectangle2D.Double)axHolder_.getBoundsP(); - if(bnds != null) boundsD_ = toRectangle(bnds); - - update("AxisHolderDragBox.new()"); - } - - public AxisHolder getAxisHolder() { - return axHolder_; - } - - public void setBounds(Rectangle bounds) { -// System.out.println("AxisHolderDragBox.setBounds: bounds updated"); - boundsD_ = bounds; - axHolder_.setBoundsP(toRectangle(bounds)); - computeHandles(); - } - - public void setOrigin(Point pt) { - originD_ = pt; - axHolder_.setAxisOriginP(toLocation(originD_)); - computeHandles(); - } - - public Point getOrigin() { - return (Point)originD_.clone(); - } - - public Point getLocation() { - return new Point(boundsD_.x, boundsD_.y); - } - - public void setId(String id) { - // operation not allowed - } - - public void draw(Graphics g) { - Color savedColor = g.getColor(); - if(selected_) { - g.setColor(Color.red); - } else { - g.setColor(Color.darkGray); - } - int xticStart, xticEnd; - int yticStart, yticEnd; - int xorg, yorg; - Rectangle dgBounds = computeDataGroupBounds(); // if not MANUAL - if(axHolder_.getAxisOrientation() == DataGroup.X_DIR) { - // XAxis - if(axHolder_.getAxisPosition() != DataGroup.MANUAL) { - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.BOTTOM: - yorg = dgBounds.y + dgBounds.height; - break; - case DataGroup.TOP: - yorg = dgBounds.y; - break; - } - } else { // MANUAL - yorg = originD_.y; - } - switch(axHolder_.getTicPosition()) { - default: - case Axis.NEGATIVE_SIDE: - yticStart = yorg; - yticEnd = yorg + TIC_LENGTH; - break; - case Axis.POSITIVE_SIDE: - yticStart = yorg - TIC_LENGTH; - yticEnd = yorg; - break; - case Axis.BOTH_SIDES: - yticStart = yorg - TIC_LENGTH; - yticEnd = yorg + TIC_LENGTH; - } - if(axHolder_.isVisible()) { - g.drawRect(boundsD_.x, boundsD_.y, - boundsD_.width, boundsD_.height); - g.drawLine(boundsD_.x, yorg, boundsD_.x+boundsD_.width, yorg); - // Some X tics - for(int i=boundsD_.x; i < boundsD_.x+boundsD_.width; i += TIC_INCREMENT) { - g.drawLine(i, yticStart, i, yticEnd); - } - } - } else { // Y_DIR - // YAxis - if(axHolder_.getAxisPosition() != DataGroup.MANUAL) { - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.LEFT: - xorg = dgBounds.x; - break; - case DataGroup.RIGHT: - xorg = dgBounds.x + dgBounds.width; - break; - } - } else { // MANUAL - xorg = originD_.x; - } - switch(axHolder_.getTicPosition()) { - default: - case Axis.NEGATIVE_SIDE: - xticStart = xorg; - xticEnd = xorg - TIC_LENGTH; - break; - case Axis.POSITIVE_SIDE: - xticStart = xorg + TIC_LENGTH; - xticEnd = xorg; - break; - case Axis.BOTH_SIDES: - xticStart = xorg - TIC_LENGTH; - xticEnd = xorg + TIC_LENGTH; - } - if(axHolder_.isVisible()) { - g.drawRect(boundsD_.x, boundsD_.y, - boundsD_.width, boundsD_.height); - g.drawLine(xorg, boundsD_.y, xorg, boundsD_.y+boundsD_.height); - // Some Y tics - for(int i=boundsD_.y; i < boundsD_.y+boundsD_.height; i += TIC_INCREMENT) { - g.drawLine(xticStart, i, xticEnd, i); - } - } - // Name -/* if(dg_.getXPosition() == DataGroup.BOTTOM) { - yString += BOX_HEIGHT - 2; - } else { - yString += BOX_HEIGHT - TIC_LENGTH - 2; - } - g.drawString(dg_.getId(), boundsD_.x + 5, yString); */ - } - if(selected_) { - for(int i=0; i < handles_.length; i++) { - Rectangle r = handles_[i]; - g.fillRect(r.x, r.y, r.width-1, r.height-1); - } - } - - g.setColor(savedColor); - } - - private Rectangle computeDataGroupBounds() { - Rectangle panel = pHolder_.getBounds(); - Margin margin = dg_.getMargin(); - float dpi = pHolder_.getPanelModel().getDpi(); - int left = (int)(margin.left*dpi); - int right = (int)(margin.right*dpi); - int top = (int)(margin.top*dpi); - int bottom = (int)(margin.bottom*dpi); - return new Rectangle(panel.x + left, - panel.y + top, - panel.width - (left + right), - panel.height - (top + bottom)); - } - - private static int exCount_ = 0; - - public void update(String message) { - /** @todo can't use dgBounds when MANUAL! */ -// if(Page.DEBUG) System.out.println("AxisHolderDragBox.update(" + message + ")"); -// if(Page.DEBUG && exCount_++ <= 25) (new Exception()).printStackTrace(); -// if(exCount_ >= 25) System.exit(0); - int ticPos = Axis.NEGATIVE_SIDE; - int labPos = Axis.NEGATIVE_SIDE; - int x, y, width, height; - int xOrig, yOrig; - Rectangle dgBounds = computeDataGroupBounds(); - if(axHolder_.getAxisOrientation() == DataGroup.X_DIR) { - width = dgBounds.width; - x = dgBounds.x; - ticPos = axHolder_.getTicPosition(); - labPos = axHolder_.getLabelPosition(); - if(axHolder_.getAxisPosition() != DataGroup.MANUAL) { - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.BOTTOM: - y = dgBounds.y + dgBounds.height; - break; - case DataGroup.TOP: - y = dgBounds.y; - break; - } - } else { // MANUAL - y = originD_.y; - x = boundsD_.x; - width = boundsD_.width; - } - xOrig = x; - yOrig = y; - - height = TIC_SPACE + TITLE_SPACE; - switch(labPos) { - case Axis.NEGATIVE_SIDE: - height += TITLE_HEIGHT; - break; - case Axis.POSITIVE_SIDE: - height += TITLE_HEIGHT; - y -= (TITLE_HEIGHT + TITLE_SPACE); - break; - case Axis.NO_LABEL: - } - switch(ticPos) { - case Axis.NEGATIVE_SIDE: - height += TIC_LENGTH; - break; - case Axis.POSITIVE_SIDE: - height += TIC_LENGTH; - y -= (TIC_LENGTH + TIC_SPACE); - break; - case Axis.BOTH_SIDES: - height += 2*TIC_LENGTH + TIC_SPACE; - y -= (TIC_LENGTH + TIC_SPACE); - break; - } - } else { // Y_DIR - height = dgBounds.height; - y = dgBounds.y; - ticPos = axHolder_.getTicPosition(); - labPos = axHolder_.getLabelPosition(); - if(axHolder_.getAxisPosition() != DataGroup.MANUAL) { - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.LEFT: - x = dgBounds.x; - break; - case DataGroup.RIGHT: - x = dgBounds.x + dgBounds.width; - break; - } - } else { // MANUAL - x = originD_.x; - y = boundsD_.y; - height = boundsD_.height; - } - xOrig = x; - yOrig = y; - - width = TIC_SPACE + TITLE_SPACE; - switch(labPos) { - case Axis.NEGATIVE_SIDE: - width += TITLE_HEIGHT; - x -= (TITLE_HEIGHT + TITLE_SPACE); - break; - case Axis.POSITIVE_SIDE: - width += TITLE_HEIGHT; - break; - case Axis.NO_LABEL: - } - switch(ticPos) { - case Axis.NEGATIVE_SIDE: - width += TIC_LENGTH; - x -= (TIC_LENGTH + TIC_SPACE); - break; - case Axis.POSITIVE_SIDE: - width += TIC_LENGTH; - break; - case Axis.BOTH_SIDES: - width += 2*TIC_LENGTH + TIC_SPACE; - x -= (TIC_LENGTH + TIC_SPACE); - break; - } - } - setOrigin(new Point(xOrig, yOrig)); - setBounds(new Rectangle(x, y, width, height)); - computeHandles(); - } - - public void setLocation(Point point) { - boundsD_.x = point.x; - boundsD_.y = point.y; - axHolder_.setBoundsP(toRectangle(boundsD_)); - computeHandles(); - } - - public Rectangle getBounds() { - return (Rectangle)boundsD_.clone(); - } - - public String getId() { - return id_; - } - - public void stateChanged(ChangeEvent e) { - update("AxisHolderDragBox.stateChanged()"); - } - - private Rectangle2D getBoundsP() { - return null; - } - - protected void computeHandles() { - if(boundsD_ == null) return; - int x, y; - int ticPos = axHolder_.getTicPosition(); - Rectangle dgBounds = computeDataGroupBounds(); - if(axHolder_.getAxisOrientation() == DataGroup.X_DIR) { - if(axHolder_.getAxisPosition() != DataGroup.MANUAL) { - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.BOTTOM: - y = dgBounds.y + dgBounds.height; - break; - case DataGroup.TOP: - y = dgBounds.y; - break; - } - } else { // MANUAL - y = originD_.y; - } - if(ticPos == Axis.POSITIVE_SIDE || - ticPos == Axis.BOTH_SIDES) { - y -= handleSize_ + 1; - } - handles_[ORIGIN].setBounds(boundsD_.x + 1, - y, - handleSize_, handleSize_); - handles_[SIZE].setBounds(boundsD_.x + boundsD_.width - handleSize_ + 1, - boundsD_.y + (boundsD_.height - handleSize_)/2, - handleSize_, handleSize_); - } else { // Y_DIR - if(axHolder_.getAxisPosition() != DataGroup.MANUAL) { - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.LEFT: - x = dgBounds.x; - break; - case DataGroup.RIGHT: - x = dgBounds.x + dgBounds.width; - break; - } - } else { // MANUAL - x = originD_.x; - } - if(ticPos == Axis.NEGATIVE_SIDE || - ticPos == Axis.BOTH_SIDES) { - x -= handleSize_; - } - handles_[ORIGIN].setBounds(x, - boundsD_.y + boundsD_.height - handleSize_ + 1, - handleSize_, handleSize_); - handles_[SIZE].setBounds(boundsD_.x + (boundsD_.width - handleSize_)/2, - boundsD_.y + 1, - handleSize_, handleSize_); - } - } - - public void mouseOperation(int op, int dx, int dy) { - if(op == -1) return; -// System.out.println("AxisHolderDragBox.mouseOperation(" + op + -// ", " + dx + ", " + dy + ")"); - Point pt; - Rectangle rect; - switch (op) { - case ORIGIN: - pt = getLocation(); - pt.x += dx; - pt.y += dy; - setLocation(pt); - pt = getOrigin(); - pt.x += dx; - pt.y += dy; - setOrigin(pt); - break; - case SIZE: - rect = getBounds(); - if(axHolder_.getAxisOrientation() == DataGroup.X_DIR) { - rect.width += dx; - } else { - rect.height -= dy; - rect.y += dy; - } - setBounds(rect); - break; - case DUMMY_ORIGIN: - case DUMMY_SIZE: - } - axHolder_.setAxisPosition(DataGroup.MANUAL); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolderPropertyPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolderPropertyPanel.java deleted file mode 100755 index 7c903d33..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/AxisHolderPropertyPanel.java +++ /dev/null @@ -1,694 +0,0 @@ -/* - * $Id: AxisHolderPropertyPanel.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.Color; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import javax.swing.JComponent; -import javax.swing.JTextField; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.Icon; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import java.util.Vector; -import java.util.Iterator; -import java.util.StringTokenizer; - -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.IllegalTimeValue; - -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.swing.ColorSwatchIcon; -import gov.noaa.pmel.sgt.swing.prop.SGLabelDialog; -import gov.noaa.pmel.sgt.swing.prop.FontDialog; -import gov.noaa.pmel.sgt.swing.prop.ColorDialog; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -class AxisHolderPropertyPanel extends PropertyPanel - implements ActionListener, FocusListener, ChangeListener { - private boolean expert_ = false; - private String[] pNames_ = - { "AutoScale", "AxisColor", "Axis Position", - "Axis Location", "AxisType", "Bounds", - "Label Color", "Label Font", "Label Format", - "Label Height", "Label Interval", "Label Position", - "Label SignificantDigits", "Large TicHeight", "Location At Origin", - "Major Format", "Major Interval", "Minor Format", - "Minor Interval", "Num Small Tics", "OriginP", - "Selectable", - "Small TicHeight", "Tic Position", "Time AxisStyle", - "Title Auto", "Title", "Transform Type", - "User Range", "Visible"}; - private boolean[] expertItem = - { false, true, false, //autoScale - true, false, true, //axisLocation - true, false, true, //labelColor - false, false, true, //labelHeight - false, true, true, //sigDigits - true, true, true, //majorFormat - true, false, true, //minorInterval - true, //selectable - true, true, false, //smallTicheight - false, false, false, //titleAuto - false, false}; //userRange - private JComponent[] comps_ = new JComponent[pNames_.length]; - private AxisHolder axHolder_; - private PanelHolder pHolder_; - private boolean suppressEvent_ = false; - private int autoScale, userRange; - private int titleAuto, title; - private String format_ = "yyyy-MM-dd hh:mm"; - private String[] xAxisPosition = {"Bottom", "Top", "Manual"}; - private String[] yAxisPosition = {"Left", "Right", "Manual"}; - - public AxisHolderPropertyPanel(AxisHolder axHolder, boolean expert) { - axHolder_ = axHolder; - axHolder_.addChangeListener(this); - expert_ = expert; - pHolder_ = axHolder_.getDataGroup().getPanelHolder(); - create(); - } - - public void setAxisHolder(AxisHolder axHolder, boolean expert) { - if(axHolder_ != null) axHolder_.removeChangeListener(this); - axHolder_ = axHolder; - axHolder_.addChangeListener(this); - expert_ = expert; - reset(); - } - - void update() { - int i = -1; - suppressEvent_ = true; - int item = -1; - ((JCheckBox)comps_[++i]).setSelected(axHolder_.isAutoRange()); - updateColor((JButton)comps_[++i], axHolder_.getAxisColor()); - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.BOTTOM: - item = 0; - break; - case DataGroup.TOP: - item = 1; - break; - case DataGroup.LEFT: - item = 0; - break; - case DataGroup.RIGHT: - item = 1; - break; - case DataGroup.MANUAL: - item = 2; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JLabel)comps_[++i]).setText(format(axHolder_.getAxisOriginP(), true)); - switch(axHolder_.getAxisType()) { - default: - case DataGroup.PLAIN: - item = 0; - break; - case DataGroup.TIME: - item = 1; - break; - case DataGroup.LOG: - item = 2; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JLabel)comps_[++i]).setText(format((Rectangle2D.Double)axHolder_.getBoundsP(), true)); // bounds? - updateColor((JButton)comps_[++i], axHolder_.getLabelColor()); - updateFont((JButton)comps_[++i], axHolder_.getLabelFont()); - ((JTextField)comps_[++i]).setText(axHolder_.getLabelFormat()); - ((JTextField)comps_[++i]).setText(format(axHolder_.getLabelHeightP())); - ((JTextField)comps_[++i]).setText(format(axHolder_.getLabelInterval())); - if(axHolder_.isLabelPositionAuto()) { - item = 0; - } else { - switch(axHolder_.getLabelPosition()) { - default: - break; - case Axis.NEGATIVE_SIDE: - item = 1; - break; - case Axis.POSITIVE_SIDE: - item = 2; - break; - case Axis.NO_LABEL: - item = 3; - break; - } - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JTextField)comps_[++i]).setText(format(axHolder_.getLabelSignificantDigits())); - ((JTextField)comps_[++i]).setText(format(axHolder_.getLargeTicHeightP())); - ((JCheckBox)comps_[++i]).setSelected(axHolder_.isLocationAtOrigin()); - ((JTextField)comps_[++i]).setText(axHolder_.getMajorFormat()); - ((JTextField)comps_[++i]).setText(format(axHolder_.getMajorInterval())); - ((JTextField)comps_[++i]).setText(axHolder_.getMajorFormat()); - ((JTextField)comps_[++i]).setText(format(axHolder_.getMinorInterval())); - ((JTextField)comps_[++i]).setText(format(axHolder_.getNumSmallTics())); - ((JTextField)comps_[++i]).setText(format(axHolder_.getAxisOriginP(), true)); - ((JCheckBox)comps_[++i]).setSelected(axHolder_.isSelectable()); - ((JTextField)comps_[++i]).setText(format(axHolder_.getSmallTicHeightP())); - if(axHolder_.isTicPositionAuto()) { - item = 0; - } else { - switch(axHolder_.getTicPosition()) { - default: - break; - case Axis.NEGATIVE_SIDE: - item = 1; - break; - case Axis.POSITIVE_SIDE: - item = 2; - break; - case Axis.BOTH_SIDES: - item = 3; - break; - } - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - switch(axHolder_.getTimeAxisStyle()) { - default: - case TimeAxis.AUTO: - item = 0; - break; - case TimeAxis.DAY_MONTH: - item = 1; - break; - case TimeAxis.HOUR_DAY: - item = 2; - break; - case TimeAxis.MINUTE_HOUR: - item = 3; - break; - case TimeAxis.MONTH_YEAR: - item = 4; - break; - case TimeAxis.YEAR_DECADE: - item = 5; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JCheckBox)comps_[++i]).setSelected(axHolder_.isTitleAuto()); - updateSGLabel((JButton)comps_[++i], axHolder_.getTitle()); - Vector transItems = new Vector(5); - transItems.add("LinearTransform"); - transItems.add("LogTransform"); - addOtherDataGroupTransforms(transItems); - item = findTransformItem(transItems, axHolder_.getTransformType(), - axHolder_.getTransformGroup()); - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JTextField)comps_[++i]).setText(format(axHolder_.getUserRange(), false)); - ((JCheckBox)comps_[++i]).setSelected(axHolder_.isVisible()); - - suppressEvent_ = false; - } - - void create() { - int i = -1; - int item = -1; - comps_[++i] = createCheckBox(axHolder_.isAutoRange(), pNames_[i], this); - autoScale = i; - comps_[++i] = createColor(axHolder_.getAxisColor(), pNames_[i], this); - String[] axisPosition; - if(axHolder_.getAxisOrientation() == DataGroup.X_DIR) { - axisPosition = xAxisPosition; - } else { - axisPosition = yAxisPosition; - } - switch(axHolder_.getAxisPosition()) { - default: - case DataGroup.BOTTOM: - item = 0; - break; - case DataGroup.TOP: - item = 1; - break; - case DataGroup.LEFT: - item = 0; - break; - case DataGroup.RIGHT: - item = 1; - break; - case DataGroup.MANUAL: - item = 2; - break; - } - comps_[++i] = createComboBox(axisPosition, item, pNames_[i], this, true); - comps_[++i] = createLabel(format(axHolder_.getAxisOriginP(), true)); - String[] axisItems = {"PlainAxis", "TimeAxis", "LogAxis"}; - switch(axHolder_.getAxisType()) { - default: - case DataGroup.PLAIN: - item = 0; - break; - case DataGroup.TIME: - item = 1; - break; - case DataGroup.LOG: - item = 2; - break; - } - comps_[++i] = createComboBox(axisItems, item, pNames_[i], this, true); - comps_[++i] = createLabel(format((Rectangle2D.Double)axHolder_.getBoundsP(), true)); // bounds ? - comps_[++i] = createColor(axHolder_.getLabelColor(), pNames_[i], this); - comps_[++i] = createFont(axHolder_.getLabelFont(), pNames_[i], this); - comps_[++i] = createTextField(axHolder_.getLabelFormat(), pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getLabelHeightP()), pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getLabelInterval()), pNames_[i], this, true); - String[] labelPos = {"Auto", "Negative Side", "Positive Side", "No Label"}; - if(axHolder_.isLabelPositionAuto()) { - item = 0; - } else { - switch(axHolder_.getLabelPosition()) { - default: - break; - case Axis.NEGATIVE_SIDE: - item = 1; - break; - case Axis.POSITIVE_SIDE: - item = 2; - break; - case Axis.NO_LABEL: - item = 3; - break; - } - } - comps_[++i] = createComboBox(labelPos, item, pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getLabelSignificantDigits()), pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getLargeTicHeightP()), pNames_[i], this, true); - comps_[++i] = createCheckBox(axHolder_.isLocationAtOrigin(), pNames_[i], this); - comps_[++i] = createTextField(axHolder_.getMajorFormat(), pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getMajorInterval()), pNames_[i], this, true); - comps_[++i] = createTextField(axHolder_.getMinorFormat(), pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getMinorInterval()), pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getNumSmallTics()), pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getAxisOriginP(), true), pNames_[i], this, true); - comps_[++i] = createCheckBox(axHolder_.isSelectable(), pNames_[i], this); - comps_[++i] = createTextField(format(axHolder_.getSmallTicHeightP()), pNames_[i], this, true); - String[] ticPos = {"Auto", "Negative Side", "Positive Side", "Both Sides"}; - if(axHolder_.isTicPositionAuto()) { - item = 0; - } else { - switch(axHolder_.getTicPosition()) { - default: - break; - case Axis.NEGATIVE_SIDE: - item = 1; - break; - case Axis.POSITIVE_SIDE: - item = 2; - break; - case Axis.BOTH_SIDES: - item = 3; - break; - } - } - comps_[++i] = createComboBox(ticPos, item, pNames_[i], this, true); - String[] timeStyle = {"Auto", "Day-Month", "Hour-Day", - "Minute-Hour", "Month-Year", "Year-Decade"}; - switch(axHolder_.getTimeAxisStyle()) { - default: - case TimeAxis.AUTO: - item = 0; - break; - case TimeAxis.DAY_MONTH: - item = 1; - break; - case TimeAxis.HOUR_DAY: - item = 2; - break; - case TimeAxis.MINUTE_HOUR: - item = 3; - break; - case TimeAxis.MONTH_YEAR: - item = 4; - break; - case TimeAxis.YEAR_DECADE: - item = 5; - break; - } - comps_[++i] = createComboBox(timeStyle, item, pNames_[i], this, true); - comps_[++i] = createCheckBox(axHolder_.isTitleAuto(), pNames_[i], this); - titleAuto = i; - comps_[++i] = createSGLabel(axHolder_.getTitle(), pNames_[i], this); - title = i; - - Vector transItems = new Vector(5); - transItems.add("LinearTransform"); - transItems.add("LogTransform"); - addOtherDataGroupTransforms(transItems); - item = findTransformItem(transItems, axHolder_.getTransformType(), - axHolder_.getTransformGroup()); - comps_[++i] = createComboBox(transItems, item, pNames_[i], this, true); - comps_[++i] = createTextField(format(axHolder_.getUserRange(), false), pNames_[i], this, true); - userRange = i; - comps_[++i] = createCheckBox(axHolder_.isVisible(), pNames_[i], this); - setFieldsEnabled(); -// - int row = 0; - for(i=0; i < comps_.length; i++) { - if(expert_ || ! expertItem[i]) { - addProperty(++row, pNames_[i], comps_[i], false); - } - } - addProperty(row + 1, " ", new JLabel(" "), true); - } - - void resetFields() { - for(int i=0; i < comps_.length; i++) { - if(comps_[i] instanceof JTextField) { - ((JTextField)comps_[i]).removeActionListener(this); - ((JTextField)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JCheckBox) { - ((JCheckBox)comps_[i]).removeActionListener(this); - ((JCheckBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JComboBox) { - ((JComboBox)comps_[i]).removeActionListener(this); - ((JComboBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JButton) { - ((JButton)comps_[i]).removeActionListener(this); - ((JButton)comps_[i]).removeFocusListener(this); - } - } - } - - public void actionPerformed(ActionEvent e) { - if(suppressEvent_) return; - Object obj = e.getSource(); -// String str = null; - String command = e.getActionCommand(); - processEvent(obj, command); - setFieldsEnabled(); -// System.out.println(e.paramString() + ",rslt=" + str); - } - - private void setFieldsEnabled() { - ((JTextField)comps_[userRange]).setEnabled(!((JCheckBox)comps_[autoScale]).isSelected()); -// ((JButton)comps_[title]).setEnabled(!((JCheckBox)comps_[titleAuto]).isSelected()); - } - - private void processEvent(Object obj, String command) { - if(Page.DEBUG) System.out.println("AxisHolderPropertyPanel.processEvent(" + obj + ", " + command + ")"); - int item = -1; - String str = null; - SoTRange range = null; - if(command.equals("AutoScale")) { - axHolder_.setAutoRange(((JCheckBox)obj).isSelected()); - } else if(command.equals("AxisColor")) { - ColorDialog cd = new ColorDialog(getFrame(), "Select Axis Color", true); - cd.setColor(axHolder_.getAxisColor()); - cd.setVisible(true); - Color newcolor = cd.getColor(); - if(newcolor != null) axHolder_.setAxisColor(newcolor); - } else if(command.equals("Axis Position")) { - str = (String)((JComboBox)obj).getSelectedItem(); - item = -1; - if(str.equals("Bottom")) { - item = DataGroup.BOTTOM; - } else if(str.equals("Top")) { - item = DataGroup.TOP; - } else if(str.equals("Left")) { - item = DataGroup.LEFT; - } else if(str.equals("Right")) { - item = DataGroup.RIGHT; - } else if(str.equals("Manual")) { - item = DataGroup.MANUAL; - } - axHolder_.setAxisPosition(item); - } else if(command.equals("Axis Location")) { -/** @todo SoTPoint axisLocation */ - } else if(command.equals("AxisType")) { - str = (String)((JComboBox)obj).getSelectedItem(); - axHolder_.setAxisType(axis(str)); - if(str.equals("PlainAxis") || str.equals("TimeAxis")) { - axHolder_.setTransformType(DataGroup.LINEAR); - } else if(str.equals("LogAxis")) { - axHolder_.setTransformType(DataGroup.LOG); - } - if(str.equals("TimeAxis") && !axHolder_.getUserRange().isTime()) { - try { - range = new SoTRange.Time(new GeoDate("2000-01-01 00:00", format_), - new GeoDate("2001-01-01 00:00", format_), - new GeoDate(172800000)); - } catch (IllegalTimeValue itv) { - itv.printStackTrace(); - } - axHolder_.setUserRange(range); - } - } else if(command.equals("Bounds")) { - Rectangle2D bounds = parseBounds(((JTextField)obj).getText()); - if(bounds != null) axHolder_.setBoundsP(bounds); - } else if(command.equals("Label Color")) { - ColorDialog cd = new ColorDialog(getFrame(), "Select Label Color", true); - cd.setColor(axHolder_.getAxisColor()); - cd.setVisible(true); - Color newcolor = cd.getColor(); - if(newcolor != null) axHolder_.setLabelColor(newcolor); - } else if(command.equals("Label Font")) { - FontDialog fd = new FontDialog("Label Font"); - int result = fd.showDialog(axHolder_.getLabelFont()); - if(result == fd.OK_RESPONSE) { - axHolder_.setLabelFont(fd.getFont()); - } - } else if(command.equals("Label Format")) { - axHolder_.setLabelFormat(((JTextField)obj).getText()); - } else if(command.equals("Label Height")) { - axHolder_.setLabelHeightP(Double.parseDouble(((JTextField)obj).getText())); - } else if(command.equals("Label Interval")) { - axHolder_.setLabelInterval(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Label Position")) { - str = (String)((JComboBox)obj).getSelectedItem(); - item = -1; - if(str.equals("Auto")) { - item = Axis.AUTO; - } else if(str.equals("Negative Side")) { - item = Axis.NEGATIVE_SIDE; - } else if(str.equals("Positive Side")) { - item = Axis.POSITIVE_SIDE; - } else if(str.equals("No Label")) { - item = Axis.NO_LABEL; - } - axHolder_.setLabelPosition(item); - } else if(command.equals("Label SignificantDigits")) { - axHolder_.setLabelSignificantDigits(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Large TicHeight")) { - axHolder_.setLargeTicHeightP(Double.parseDouble(((JTextField)obj).getText())); - } else if(command.equals("Location At Origin")) { - axHolder_.setLocationAtOrigin(((JCheckBox)obj).isSelected()); - } else if(command.equals("Major Format")) { - axHolder_.setMajorFormat(((JTextField)obj).getText()); - } else if(command.equals("Major Interval")) { - axHolder_.setMajorInterval(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Minor Format")) { - axHolder_.setMinorFormat(((JTextField)obj).getText()); - } else if(command.equals("Minor Interval")) { - axHolder_.setMinorInterval(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Num Small Tics")) { - axHolder_.setNumSmallTics(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("OriginP")) { - axHolder_.setAxisOriginP(parsePoint2D(((JTextField)obj).getText())); - } else if(command.equals("Selectable")) { - axHolder_.setSelectable(((JCheckBox)obj).isSelected()); - } else if(command.equals("Small TicHeight")) { - axHolder_.setSmallTicHeightP(Double.parseDouble(((JTextField)obj).getText())); - } else if(command.equals("Tic Position")) { - str = (String)((JComboBox)obj).getSelectedItem(); - item = -1; - if(str.equals("Auto")) { - item = Axis.AUTO; - } else if(str.equals("Negative Side")) { - item = Axis.NEGATIVE_SIDE; - } else if(str.equals("Positive Side")) { - item = Axis.POSITIVE_SIDE; - } else if(str.equals("Both Sides")) { - item = Axis.BOTH_SIDES; - } - axHolder_.setTicPosition(item); - } else if(command.equals("Time AxisStyle")) { - str = (String)((JComboBox)obj).getSelectedItem(); - item = -1; - if(str.equals("Auto")) { - item = TimeAxis.AUTO; - } else if(str.equals("Day-Month")) { - item = TimeAxis.DAY_MONTH; - } else if(str.equals("Hour-Day")) { - item = TimeAxis.HOUR_DAY; - } else if(str.equals("Minute-Hour")) { - item = TimeAxis.MINUTE_HOUR; - } else if(str.equals("Month-Year")) { - item = TimeAxis.MONTH_YEAR; - } else if(str.equals("Year-Decade")) { - item = TimeAxis.YEAR_DECADE; - } - axHolder_.setTimeAxisStyle(item); - } else if(command.equals("Title Auto")) { - axHolder_.setTitleAuto(((JCheckBox)obj).isSelected()); - } else if(command.equals("Title")) { - SGLabelDialog sgd = new SGLabelDialog("Axis Title"); - sgd.setSGLabel(axHolder_.getTitle()); - sgd.setModal(true); - sgd.setVisible(true); - axHolder_.fireStateChanged(); - } else if(command.equals("Transform Type")) { - str = (String)((JComboBox)obj).getSelectedItem(); - int trans = transform(str); - if(trans == DataGroup.REFERENCE) { - axHolder_.setTransformGroup(str.substring(5)); - } - axHolder_.setTransformType(trans); - if(trans == DataGroup.REFERENCE && circularReference(DataGroup.X_DIR, str.substring(5))) { - JOptionPane.showMessageDialog(this, "Creates a circular reference in DataGroup transform", - "Error Selecting Transform", JOptionPane.ERROR_MESSAGE); - axHolder_.setTransformType(-1); - axHolder_.setTransformGroup(null); - ((JComboBox)obj).setSelectedIndex(-1); - return; - } - } else if(command.equals("User Range")) { - range = parseRange(((JTextField)obj).getText(), axHolder_.isTime()); - if(range != null) axHolder_.setUserRange(range); - } else if(command.equals("Visible")) { - axHolder_.setVisible(((JCheckBox)obj).isSelected()); - } - update(); - } - - private int axis(String value) { - if(value.equals("PlainAxis")) { - return DataGroup.PLAIN; - } else if(value.equals("TimeAxis")) { - return DataGroup.TIME; - } else if(value.equals("LogAxis")) { - return DataGroup.LOG; - } - return -1; - } - - private int transform(String value) { - if(value.equals("LinearTransform")) { - return DataGroup.LINEAR; - } else if(value.equals("LogTransform")) { - return DataGroup.LOG; - } else { - return DataGroup.REFERENCE; - } - } - - public void focusGained(FocusEvent e) { - } - - public void focusLost(FocusEvent e) { - Object obj = e.getSource(); - if(obj instanceof JTextField) { - JTextField tf = (JTextField)obj; - String name = tf.getName(); - processEvent(obj, name); - } - } - - public void stateChanged(ChangeEvent e) { - update(); - } - - void addOtherDataGroupTransforms(Vector list) { -// PanelHolder ph = axHolder_.getDataGroup().getPanelHolder(); - if(pHolder_.getDataGroupSize() <= 1) return; - Iterator iter = pHolder_.dataGroupIterator(); - while(iter.hasNext()) { - DataGroup dg = (DataGroup)iter.next(); - if(dg.getId().equals(axHolder_.getDataGroup().getId())) continue; - list.add("Use: " + dg.getId()); - } - } - - int findTransformItem(Vector transItems, int transType, - String transformGroup) { - int item = -1; - switch(transType) { - default: - case DataGroup.LINEAR: - item = 0; - break; - case DataGroup.LOG: - item = 1; - break; - case DataGroup.REFERENCE: - if(transItems.size() >= 3) { - for(int i = 2; i < transItems.size(); i++) { - if(((String)transItems.get(i)).endsWith(transformGroup)) { - return i; - } - } - } - break; - } - return item; - } - - boolean circularReference(int dir, String datagroup) { -// PanelHolder ph = axHolder_.getDataGroup().getPanelHolder(); - String dgLast = datagroup; - boolean stillLooking = true; - int tType = -1; - String newDG = null; - while(stillLooking) { - DataGroup dg = pHolder_.findDataGroup(dgLast); - if(dir == DataGroup.X_DIR) { - tType = dg.getXAxisHolder().getTransformType(); - } else { - tType = dg.getYAxisHolder().getTransformType(); - } - if(tType != DataGroup.REFERENCE) return false; - if(dir == DataGroup.X_DIR) { - newDG = dg.getXAxisHolder().getTransformGroup(); - } else { - newDG = dg.getYAxisHolder().getTransformGroup(); - } - if(datagroup.equals(newDG)) return true; - dgLast = newDG; - } - return false; - } - - public void setExpert(boolean expert) { - boolean save = expert_; - expert_ = expert; - if(expert_ != save) reset(); - } - - public boolean isExpert() { - return expert_; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/BorderDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/BorderDialog.java deleted file mode 100755 index ce15d518..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/BorderDialog.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * $Id: BorderDialog.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import javax.swing.*; -import javax.swing.border.*; -import java.awt.event.*; - -import gov.noaa.pmel.swing.ThreeDotsButton; -import gov.noaa.pmel.sgt.swing.prop.ColorEntryPanel; -import gov.noaa.pmel.sgt.swing.prop.FontDialog; - -/** - * Edit/create a Border object to be used with PanelHolder. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -public class BorderDialog extends JDialog { - private JPanel panel1 = new JPanel(); - private BorderLayout borderLayout1 = new BorderLayout(); - private JPanel cardPanel = new JPanel(); - private JPanel bevelPanel = new JPanel(); - private JPanel jPanel3 = new JPanel(); - private JPanel etchedPanel = new JPanel(); - private JLabel jLabel1 = new JLabel(); - private JPanel borderPanel = new JPanel(); - private BorderLayout borderLayout2 = new BorderLayout(); - private CardLayout cardLayout1 = new CardLayout(); - private JPanel linePanel = new JPanel(); - private GridBagLayout gridBagLayout8 = new GridBagLayout(); - private GridBagLayout gridBagLayout5 = new GridBagLayout(); - private GridBagLayout gridBagLayout3 = new GridBagLayout(); - private JPanel buttonPanel = new JPanel(); - private JButton okButton = new JButton(); - private JButton cancelButton = new JButton(); - private JPanel emptyPanel = new JPanel(); - private String[] args = {"None", "Beveled", - "Etched", "Line"}; - private String[] typeargs = {"Raised", "Lowered"}; - private JComboBox borderTypeCB = new JComboBox(args); - private JComboBox bevelStyleCB = new JComboBox(typeargs); - private JComboBox etchedStyleCB = new JComboBox(typeargs); - - private Border border_ = null; - private Border working_ = null; - private JLabel jLabel2 = new JLabel(); - private JLabel jLabel3 = new JLabel(); - private JLabel jLabel4 = new JLabel(); - private JLabel jLabel5 = new JLabel(); - private JLabel jLabel6 = new JLabel(); - private ColorEntryPanel bevelHOColorPanel = new ColorEntryPanel(); - private ColorEntryPanel bevelHIColorPanel = new ColorEntryPanel(); - private ColorEntryPanel bevelSOColorPanel = new ColorEntryPanel(); - private ColorEntryPanel bevelSIColorPanel = new ColorEntryPanel(); - private JLabel jLabel8 = new JLabel(); - private JLabel jLabel10 = new JLabel(); - private JLabel jLabel11 = new JLabel(); - private ColorEntryPanel etchedSColorPanel = new ColorEntryPanel(); - private ColorEntryPanel etchedHColorPanel = new ColorEntryPanel(); - private JLabel jLabel12 = new JLabel(); - private JLabel jLabel13 = new JLabel(); - private JLabel jLabel9 = new JLabel(); - private ColorEntryPanel lineColorPanel = new ColorEntryPanel(); - private JTextField lineTF = new JTextField(); - private JCheckBox lineCB = new JCheckBox(); - private JPanel titledPanel = new JPanel(); - private JCheckBox titledCB = new JCheckBox(); - private GridBagLayout gridBagLayout1 = new GridBagLayout(); - private JTextField titleTF = new JTextField(); - private JLabel jLabel7 = new JLabel(); - private JLabel jLabel14 = new JLabel(); - private JPanel jPanel1 = new JPanel(); - String[] justargs = {"Left", "Center", "Right"}; - private JComboBox justCB = new JComboBox(justargs); - private JLabel jLabel15 = new JLabel(); - String[] posargs = {"Above Top", "Top", "Below Top", - "Above Bottom", "Bottom", "Below Bottom"}; - private JComboBox positionCB = new JComboBox(posargs); - private GridBagLayout gridBagLayout2 = new GridBagLayout(); - private JLabel jLabel16 = new JLabel(); - private JLabel jLabel17 = new JLabel(); - private ColorEntryPanel titleColorPanel = new ColorEntryPanel(); - private ThreeDotsButton fontEditor = new ThreeDotsButton(); - private FlowLayout flowLayout1 = new FlowLayout(); - private JPanel fontPanel = new javax.swing.JPanel(); - private JLabel fontLabel = new javax.swing.JLabel(); - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - private Font labelFont_ = getFont(); - private boolean createNewBorder_ = true; - - /** - * Dialog constructor. - * @param frame parent frame - * @param title dialog title - * @param modal set true if modal dialog - */ - public BorderDialog(Frame frame, String title, boolean modal) { - super(frame, title, modal); - init(frame); - } - - /** - * Default constructor. - */ - public BorderDialog() { - this(null, "", false); - } - - private void init(Window win) { - try { - jbInit(); - pack(); - } - catch(Exception ex) { - ex.printStackTrace(); - } - this.setSize(520, 520); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "none"); - if(win != null) { - Rectangle fBounds = win.getBounds(); - Point fLoc = win.getLocationOnScreen(); - Rectangle bounds = getBounds(); - int x = fLoc.x + fBounds.width/2 - bounds.width/2; - int y = fLoc.y + fBounds.height/2 - bounds.height/2; - setLocation(x, y); - } else { - setLocation(200, 200); - } - } - - /** - * Set the border. - * @param border initialize dialog to this - */ - public void setBorder(Border border) { - border_ = border; - if(border_ instanceof TitledBorder) { - titledCB.setSelected(true); - working_ = ((TitledBorder)border_).getBorder(); - } else { - titledCB.setSelected(false); - working_ = border_; - } - init(); - } - - /** - * Get the new Border. - * @return border - */ - public Border getBorder() { - return border_; - } - - private void jbInit() throws Exception { - panel1.setLayout(borderLayout1); - cardPanel.setLayout(cardLayout1); - borderTypeCB.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - borderTypeCB_actionPerformed(e); - } - }); - bevelPanel.setLayout(gridBagLayout5); - etchedPanel.setLayout(gridBagLayout3); - jLabel1.setText("Border Type"); - borderPanel.setMinimumSize(new Dimension(163, 300)); - borderPanel.setPreferredSize(new Dimension(167, 300)); - borderPanel.setLayout(borderLayout2); - linePanel.setLayout(gridBagLayout8); - okButton.setText("OK"); - okButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - okButton_actionPerformed(e); - } - }); - cancelButton.setText("Cancel"); - cancelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - cancelButton_actionPerformed(e); - } - }); - jLabel2.setText("Style:"); - jLabel3.setText("Highlight Outer:"); - jLabel4.setText("Highlight Inner:"); - jLabel5.setText("Shadow Outer:"); - jLabel6.setText("Shadow Inner:"); - jLabel8.setText("Shadow:"); - jLabel10.setText("Highlight:"); - jLabel11.setText("Style:"); - jLabel12.setText("Color:"); - jLabel13.setText("Thickness:"); - jLabel9.setText("Rounded Corners:"); - lineTF.setText("2"); - lineTF.setColumns(5); - lineColorPanel.setTitle("Set Line Color"); - bevelHOColorPanel.setTitle("Set Highlight Outer Color"); - bevelHIColorPanel.setTitle("Set Highlight Inner Color"); - bevelSOColorPanel.setTitle("Set Shadow Outer Color"); - bevelSIColorPanel.setTitle("Set Shadow Inner Color"); - etchedHColorPanel.setTitle("Set Highlight Color"); - etchedSColorPanel.setTitle("Set Shadow Color"); - buttonPanel.setBorder(BorderFactory.createEtchedBorder()); - titledPanel.setBorder(BorderFactory.createEtchedBorder()); - titledPanel.setLayout(gridBagLayout1); - titledCB.setText("Titled"); - titledCB.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - titledCB_actionPerformed(e); - } - }); - jLabel7.setText("Title:"); - jLabel14.setText("Position:"); - jLabel15.setText("Justification:"); - jPanel1.setLayout(gridBagLayout2); - jLabel16.setText("Color:"); - jLabel17.setText("Font:"); - titleColorPanel.setEnabled(false); - titleColorPanel.setTitle("Set Title Color"); - fontEditor.setEnabled(false); - fontEditor.setAlignmentY((float) 0.0); - fontEditor.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - fontEditor_actionPerformed(e); - } - }); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.setLayout(flowLayout1); - fontLabel.setAlignmentY((float) 0.0); - fontLabel.setText("Dialog, 12, Bold"); - fontLabel.setForeground(java.awt.Color.black); - titleTF.setEnabled(false); - positionCB.setEnabled(false); - justCB.setEnabled(false); - cardPanel.setMinimumSize(new Dimension(451, 225)); - cardPanel.setPreferredSize(new Dimension(451, 225)); - cardPanel.setToolTipText(""); - panel1.setMinimumSize(new Dimension(163, 360)); - panel1.setPreferredSize(new Dimension(187, 360)); - getContentPane().add(panel1); - panel1.add(borderPanel, BorderLayout.CENTER); - jPanel3.add(jLabel1, null); - jPanel3.add(borderTypeCB, null); - borderPanel.add(titledPanel, BorderLayout.SOUTH); - borderPanel.add(cardPanel, BorderLayout.CENTER); - borderPanel.add(jPanel3, BorderLayout.NORTH); - cardPanel.add(bevelPanel, "bevel"); - bevelPanel.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - bevelPanel.add(bevelStyleCB, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - bevelPanel.add(jLabel3, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - bevelPanel.add(jLabel4, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - bevelPanel.add(jLabel5, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - bevelPanel.add(jLabel6, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - bevelPanel.add(bevelHOColorPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - bevelPanel.add(bevelHIColorPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - bevelPanel.add(bevelSOColorPanel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - bevelPanel.add(bevelSIColorPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - cardPanel.add(etchedPanel, "etched"); - etchedPanel.add(jLabel8, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - etchedPanel.add(jLabel10, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - etchedPanel.add(jLabel11, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - etchedPanel.add(etchedSColorPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - etchedPanel.add(etchedStyleCB, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - etchedPanel.add(etchedHColorPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - cardPanel.add(linePanel, "line"); - linePanel.add(jLabel9, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - linePanel.add(lineColorPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - linePanel.add(jLabel12, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - linePanel.add(jLabel13, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - panel1.add(buttonPanel, BorderLayout.SOUTH); - buttonPanel.add(okButton, null); - buttonPanel.add(cancelButton, null); - cardPanel.add(emptyPanel, "none"); - linePanel.add(lineTF, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - linePanel.add(lineCB, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - titledPanel.add(titledCB, new GridBagConstraints(0, 0, 1, 1, 0.7, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 15, 0)); - titledPanel.add(titleTF, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 15), 0, 0)); - titledPanel.add(jLabel7, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - titledPanel.add(jLabel14, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - titledPanel.add(jPanel1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - jPanel1.add(positionCB, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - jPanel1.add(jLabel15, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - jPanel1.add(justCB, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - titledPanel.add(jLabel16, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - titledPanel.add(titleColorPanel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - titledPanel.add(jLabel17, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 10, 5), 0, 0)); - titledPanel.add(fontPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 10, 5), 0, 0)); - fontPanel.add(fontLabel, null); - fontPanel.add(fontEditor, null); - positionCB.setSelectedIndex(1); - } - - void init() { -// working_ = null; - createNewBorder_ = false; - String type = "none"; - int index = 0; - if(working_ != null) { - if(working_ instanceof BevelBorder) { - BevelBorder bb = (BevelBorder)working_; - -/* working_ = new BevelBorder(bb.getBevelType(), - bb.getHighlightOuterColor(), - bb.getHighlightInnerColor(), - bb.getShadowOuterColor(), - bb.getShadowInnerColor()); */ - - bevelHIColorPanel.setColor(bb.getHighlightInnerColor(this)); - bevelHOColorPanel.setColor(bb.getHighlightOuterColor(this)); - bevelSIColorPanel.setColor(bb.getShadowInnerColor(this)); - bevelSOColorPanel.setColor(bb.getShadowOuterColor(this)); - - int style = bb.getBevelType(); - if(style == BevelBorder.RAISED) { - bevelStyleCB.setSelectedItem("Raised"); - } else if(style == BevelBorder.LOWERED) { - bevelStyleCB.setSelectedItem("Lowered"); - } - - type = "bevel"; - index = 1; - } else if(working_ instanceof EtchedBorder) { - EtchedBorder eb = (EtchedBorder)working_; - -/* working_ = new EtchedBorder(eb.getEtchType(), - eb.getHighlightColor(), - eb.getShadowColor()); */ - - etchedHColorPanel.setColor(eb.getHighlightColor(this)); - etchedSColorPanel.setColor(eb.getShadowColor(this)); - - int style = eb.getEtchType(); - if(style == EtchedBorder.RAISED) { - etchedStyleCB.setSelectedItem("Raised"); - } else if(style == EtchedBorder.LOWERED) { - etchedStyleCB.setSelectedItem("Lowered"); - } - - type = "etched"; - index = 2; - } else if(working_ instanceof LineBorder) { - LineBorder lb = (LineBorder)working_; - -/* working_ = new LineBorder(lb.getLineColor(), - lb.getThickness(), - lb.getRoundedCorners()); */ - - lineColorPanel.setColor(lb.getLineColor()); - - int thick = lb.getThickness(); - lineTF.setText(Integer.toString(thick)); - boolean round = lb.getRoundedCorners(); - lineCB.setSelected(round); - - type = "line"; - index = 3; - } - if(titledCB.isSelected()) { - TitledBorder tb = (TitledBorder)border_; - titleTF.setText(tb.getTitle()); - titleColorPanel.setColor(tb.getTitleColor()); - int tindex = -1; - switch(tb.getTitlePosition()) { - case TitledBorder.ABOVE_TOP: - tindex = 0; - break; - default: - case TitledBorder.TOP: - tindex = 1; - break; - case TitledBorder.BELOW_TOP: - tindex = 2; - break; - case TitledBorder.ABOVE_BOTTOM: - tindex = 3; - break; - case TitledBorder.BOTTOM: - tindex = 4; - break; - case TitledBorder.BELOW_BOTTOM: - tindex = 5; - break; - } - positionCB.setSelectedIndex(tindex); - tindex = -1; - switch(tb.getTitleJustification()) { - default: - case TitledBorder.LEFT: - tindex = 0; - break; - case TitledBorder.CENTER: - tindex = 1; - break; - case TitledBorder.RIGHT: - tindex = 2; - break; - } - justCB.setSelectedIndex(tindex); - labelFont_ = tb.getTitleFont(); - fontLabel.setText(fontString(labelFont_)); - } - } - setTitledEnabled(titledCB.isEnabled()); - borderTypeCB.setSelectedIndex(index); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, type); - createNewBorder_ = true; - } - - void borderTypeCB_actionPerformed(ActionEvent e) { - if(Page.DEBUG) System.out.println("ActionPerformed: new value = " + borderTypeCB.getSelectedItem()); - int index = borderTypeCB.getSelectedIndex(); - switch(index) { - case 0: - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "none"); - break; - case 1: - if(createNewBorder_) working_ = new BevelBorder(BevelBorder.LOWERED); - init(); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "bevel"); - break; - case 2: - if(createNewBorder_) working_ = new EtchedBorder(EtchedBorder.LOWERED); - init(); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "etched"); - break; - case 3: - if(createNewBorder_) working_ = new LineBorder(Color.gray); - init(); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "line"); - break; - default: - JOptionPane.showMessageDialog(this, "Selection Not Yet Implemented", - "Not Implemented", JOptionPane.ERROR_MESSAGE); - borderTypeCB.setSelectedIndex(0); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "none"); - } - - } - - void cancelButton_actionPerformed(ActionEvent e) { - setVisible(false); - dispose(); - } - - void okButton_actionPerformed(ActionEvent e) { - String borderType = (String)borderTypeCB.getSelectedItem(); - if(borderType.equals("None")) { - working_ = null; - titledCB.setSelected(false); - } else if(borderType.equals("Beveled")) { - Color highlighto = bevelHOColorPanel.getColor(); - Color highlighti = bevelHIColorPanel.getColor(); - Color shadowo = bevelSOColorPanel.getColor(); - Color shadowi = bevelSIColorPanel.getColor(); - int style = BevelBorder.RAISED; - if(etchedStyleCB.getSelectedIndex() == 1) { - style = BevelBorder.LOWERED; - } - working_ = new BevelBorder(style, highlighto, highlighti, - shadowo, shadowi); - } else if(borderType.equals("Etched")) { - Color highlight = etchedHColorPanel.getColor(); - Color shadow = etchedSColorPanel.getColor(); - int style = EtchedBorder.RAISED; - if(etchedStyleCB.getSelectedIndex() == 1) { - style = EtchedBorder.LOWERED; - } - working_ = new EtchedBorder(style, highlight, shadow); - } else if(borderType.equals("Line")) { - Color color = lineColorPanel.getColor(); - int thick = Integer.parseInt(lineTF.getText()); - boolean round = lineCB.isSelected(); - - working_ = new LineBorder(color, thick, round); - } - if(titledCB.isSelected()) { - int just = 0; - int pos = 0; - String posStr = (String)positionCB.getSelectedItem(); - if(posStr.equals("Above Top")) { - pos = TitledBorder.ABOVE_TOP; - } else if (posStr.equals("Below Top")) { - pos = TitledBorder.BELOW_TOP; - } else if (posStr.equals("Above Bottom")) { - pos = TitledBorder.ABOVE_BOTTOM; - } else if (posStr.equals("Bottom")) { - pos = TitledBorder.BOTTOM; - } else if (posStr.equals("Below Bottom")) { - pos = TitledBorder.BELOW_BOTTOM; - } else { - pos = TitledBorder.TOP; - } - String justStr = (String)justCB.getSelectedItem(); - if(justStr.equals("Rigt")) { - just = TitledBorder.RIGHT; - } else if(justStr.equals("Center")) { - just = TitledBorder.CENTER; - } else { - just = TitledBorder.LEFT; - } - border_ = new TitledBorder(working_, - titleTF.getText(), - just, - pos, - labelFont_, - titleColorPanel.getColor()); - } else { - border_ = working_; - } - setVisible(false); - dispose(); - } - - void titledCB_actionPerformed(ActionEvent e) { - if(Page.DEBUG) System.out.println("ActionPerformed: new value = " + titledCB.isSelected()); - setTitledEnabled(titledCB.isSelected()); - if(titledCB.isSelected()) { - if(border_ instanceof TitledBorder) { - ((TitledBorder)border_).setBorder(working_); - } else { - border_ = new TitledBorder(working_, - titleTF.getText()); - init(); - } - } - } - - void setTitledEnabled(boolean en) { - titleTF.setEnabled(en); - positionCB.setEnabled(en); - justCB.setEnabled(en); - titleColorPanel.setEnabled(en); - fontEditor.setEnabled(en); - } - - void fontEditor_actionPerformed(ActionEvent e) { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroup.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroup.java deleted file mode 100755 index 6681ff2b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroup.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * $Id: DataGroup.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.Insets; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Graphics; -import java.awt.Color; - -import gov.noaa.pmel.sgt.AxisTransform; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Rectangle2D; -import javax.swing.event.*; -import java.util.*; -import java.io.*; -import java.beans.*; - -/** - * A holder for the X and Y transforms and optionally references to the - * X and Y axes for a CartesianGraph. This class is used with DataModel - * and Panel. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -public class DataGroup implements Serializable, ChangeListener { - // axis position - /** - * X axis placed at top of DataGroup area. - */ - public static final int TOP = 0; - /** - * X axis placed at bottom of DataGroup area. - */ - public static final int BOTTOM = 1; - /** - * Y axis placed left of DataGroup area. - */ - public static final int LEFT = 2; - /** - * Y axis placed right of DataGroup area. - */ - public static final int RIGHT = 3; - /** - * Axes placed in default locations. - */ - public static final int MANUAL = 4; - // axis transform / axis type - /** - * Linear transform type. - */ - public static final int LINEAR = 0; - /** - * Log transform type. - */ - public static final int LOG = 1; - /** - * Refer to a transform in another DataGroup. - */ - public static final int REFERENCE = 2; - /** - * Time axis type. - */ - public static final int TIME = 3; - /** - * Plain linear axis type. - */ - public static final int PLAIN = 4; - // - /** - * X direction. - */ - public static final int X_DIR = 0; - /** - * Y direction. - */ - public static final int Y_DIR = 1; - // - private String id = ""; - // - /** - * @label margin - */ - private Margin margin = new Margin(0.25f, 0.5f, 0.5f, 0.25f); - private boolean zoomable = true; - // - /** - * @label xAxisHolder - * @supplierCardinality 1 - * @undirected - * @link aggregation - */ - private AxisHolder xAxisHolder_ = new AxisHolder(PLAIN, X_DIR, this); - /** - * @label yAxisHolder - * @link aggregation - * @undirected - * @supplierCardinality 1 - */ - private AxisHolder yAxisHolder_ = new AxisHolder(PLAIN, Y_DIR, this); - // - private boolean zAutoScale = true; - private SoTRange zRangeU = new SoTRange.Double(0.0, 1.0, 0.1); - private int numberAutoContourLevels = 10; - // - /** - * @label pHolder - */ - private PanelHolder pHolder_ = null; - transient private Vector changeListeners; - transient private ChangeEvent changeEvent_ = new ChangeEvent(this); - transient private boolean instantiated = false; - - static { - try { - BeanInfo info = Introspector.getBeanInfo(DataGroup.class); - PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); - for(int i=0; i < descriptors.length; i++) { - PropertyDescriptor pd = descriptors[i]; - if(pd.getName().equals("instantiated")) { - pd.setValue("transient", Boolean.TRUE); - } else if(pd.getName().equals("panelHolder")) { - pd.setValue("transient", Boolean.TRUE); - } - } - } catch (IntrospectionException ie) { - ie.printStackTrace(); - } - } - /** - * Default constructor. PanelHodler is set to null. - * X and Y transforms are LINEAR and axes PLAIN. - */ - public DataGroup() { - this("Default Id", null); - } - /** - * Simple constructor. X and Y transforms are LINEAR and axes PLAIN. - * @param id data group id - * @param ph panelholder parent - */ - public DataGroup(String id, PanelHolder ph) { - this(id, ph, - LINEAR, PLAIN, - LINEAR, PLAIN); - } - /** - * Full constructor. - * @param id data group id - * @param ph panelholder parent - * @param xt x transform type - * @param xAxis x axis type - * @param yt y transform type - * @param yAxis y axis type - */ - public DataGroup(String id, PanelHolder ph, - int xt, int xAxis, - int yt, int yAxis) { - this.id = id; - pHolder_ = ph; - if(xAxisHolder_ == null) { - xAxisHolder_ = new AxisHolder(xAxis, X_DIR, this); - } else { - xAxisHolder_.setAxisType(xAxis); - xAxisHolder_.setAxisOrientation(X_DIR); - xAxisHolder_.setDataGroup(this); - } - xAxisHolder_.setTransformType(xt); - xAxisHolder_.addChangeListener(this); - if(yAxisHolder_ == null) { - yAxisHolder_ = new AxisHolder(yAxis, Y_DIR, this); - } else { - yAxisHolder_.setAxisType(yAxis); - yAxisHolder_.setAxisOrientation(Y_DIR); - yAxisHolder_.setDataGroup(this); - } - yAxisHolder_.setTransformType(yt); - yAxisHolder_.addChangeListener(this); - } - /** - * Set panelhodler parent. - * @param ph panelholder parent - */ - public void setPanelHolder(PanelHolder ph) { - if(pHolder_ != null) removeChangeListener(pHolder_); - pHolder_ = ph; - addChangeListener(pHolder_); - } - /** - * Get parent. - * @return panelholder parent - */ - public PanelHolder getPanelHolder() { - return pHolder_; - } - /** - * Get X axisholder - * @return x axisholder - */ - public AxisHolder getXAxisHolder() { - return xAxisHolder_; - } - /** - * Set X axisholder - * @param xah x axisholder - */ - public void setXAxisHolder(AxisHolder xah) { - xAxisHolder_ = xah; - xAxisHolder_.addChangeListener(this); - } - /** - * Get Y axisholder. - * @return y axisholder - */ - public AxisHolder getYAxisHolder() { - return yAxisHolder_; - } - /** - * Set Y axisholder - * @param yah y axisholder - */ - public void setYAxisHolder(AxisHolder yah) { - yAxisHolder_ = yah; - yAxisHolder_.addChangeListener(this); - } - /** - * Get datagroup id. - * @return datagroup id - */ - public String getId() { - return id; - } - /** - * Set datagroup id. - * @param id datagroup id - */ - public void setId(String id) { - String saved = this.id; - this.id = id; - if(!saved.equals(this.id)) fireStateChanged(); - } - /** - * Get the margin. - * @return margin - */ - public Margin getMargin() { - return (Margin)margin.copy(); - } - /** - * Set the margin. The margin is used to automatically place the axes in a - * Panel. The margin is the distance from each edge of the - * Panel to the DataGroup. - * Default is (0.25f, 0.5f, 0.5f, 0.25f) - * @param margin margin - */ - public void setMargin(Margin margin) { - Margin saved = this.margin; - this.margin = margin; - if(!saved.equals(this.margin)) fireStateChanged(); - } - /** - * Set the Margin. Default is (0.25f, 0.5f, 0.5f, 0.25f) - * @param top top margin - * @param left left margin - * @param bottom bottom margin - * @param right right margin - */ - public void setMargin(float top, float left, float bottom, float right) { - Margin saved = margin; - margin = new Margin(top, left, bottom, right); - if(!saved.equals(margin)) fireStateChanged(); - } - /** - * Remove all ChangeListeners. - */ - public void removeAllChangeListeners() { - changeListeners = null; - } - /** - * Set auto Z scale. Auto Z scale is only effective for grids. Default = true. - * @param zAutoScale autoscale if true - */ - public void setZAutoScale(boolean zAutoScale) { - boolean saved = this.zAutoScale; - this.zAutoScale = zAutoScale; - if(saved != zAutoScale) fireStateChanged(); - } - /** - * Is auto Z scale? - * @return true, if auto z scale - */ - public boolean isZAutoScale() { - return zAutoScale; - } - /** - * Set Z range, user units. Only used if Auto Z Scale is false. Default = - * (0, 1, 0.1). - * @param zRange Z range - */ - public void setZRangeU(SoTRange zRange) { - zRangeU = zRange; - } - /** - * Get Z range. - * @return Z range - */ - public SoTRange getZRangeU() { - return zRangeU; - } - /** - * Set datagroup zoomable. If true, datagroup can be zoomed using the mouse. - * Default = true. - * @param zoomable datagroup zoomable - */ - public void setZoomable(boolean zoomable) { - boolean saved = this.zoomable; - this.zoomable = zoomable; - if(saved != this.zoomable) fireStateChanged(); - } - /** - * Is datagroup zoomable? - * @return true, if datagroup zoomable - */ - public boolean isZoomable() { - return zoomable; - } - /** - * Remove changelistener. - * @param l changelistener - */ - public synchronized void removeChangeListener(ChangeListener l) { - if (changeListeners != null && changeListeners.contains(l)) { - Vector v = (Vector) changeListeners.clone(); - v.removeElement(l); - changeListeners = v; - } - } - /** - * Add changelistener - * @param l changelistener - */ - public synchronized void addChangeListener(ChangeListener l) { - Vector v = changeListeners == null ? new Vector(2) : (Vector) changeListeners.clone(); - if (!v.contains(l)) { - v.addElement(l); - changeListeners = v; - } - } - /** - * Remove all ChangeListeners that implement the - * DesignListener interface. - * - * @see DesignListener - */ - public synchronized void removeDesignChangeListeners() { - if(changeListeners != null) { - Vector v = (Vector) changeListeners.clone(); - Iterator iter = v.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof DesignListener) changeListeners.removeElement(obj); - } - } - } - - protected void fireStateChanged() { - if (changeListeners != null) { - Vector listeners = changeListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - ((ChangeListener) listeners.elementAt(i)).stateChanged(changeEvent_); - } - } - } - /** - * Set instantiated. Once associated DataGroupLayer object has been created - * this property is set true. Used internally. - * @param instantiated true if instantiated - */ - public void setInstantiated(boolean instantiated) { - this.instantiated = instantiated; - } - /** - * Is datagrouplayer instantiated? - * @return true, if datagrouplayer instantiated - */ - public boolean isInstantiated() { - return instantiated; - } - /** - * ChangeListner callback. - * @param e ChangeEvent - */ - public void stateChanged(ChangeEvent e) { - fireStateChanged(); - } - /** - * Get number of auto contour levels. Valid for grid type data only. - * @return number of auto contour levels - */ - public int getNumberAutoContourLevels() { - return numberAutoContourLevels; - } - /** - * Set number of auto contour levels. Valid for grid type data only. - * @param numberAutoContourLevels number of contour levels - */ - public void setNumberAutoContourLevels(int numberAutoContourLevels) { - int saved = this.numberAutoContourLevels; - this.numberAutoContourLevels = numberAutoContourLevels; - if(saved != this.numberAutoContourLevels) fireStateChanged(); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupDragBox.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupDragBox.java deleted file mode 100755 index e12b1a21..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupDragBox.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * $Id: DataGroupDragBox.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -//import gov.noaa.pmel.util.Rectangle2D; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.geom.Rectangle2D; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -class DataGroupDragBox extends DragBox implements ChangeListener { - private Rectangle boundsD_ = new Rectangle(); - private DataGroup dg_ = null; - private AxisHolderDragBox xAxDB_ = null; - private AxisHolderDragBox yAxDB_ = null; - - public DataGroupDragBox(DataGroup dg, PanelHolder pHolder) { - super(pHolder); - dg_ = dg; - dg_.addChangeListener(this); - for(int i=0; i < handles_.length; i++) { - handles_[i] = new Rectangle(0,0,0,0); - } - update("DataGroupDragBox.new()"); - } - - public DataGroup getDataGroup() { - return dg_; - } - - public void setBounds(Rectangle bounds) { - boundsD_ = bounds; - dg_.setMargin(computeMargin()); - computeHandles(); - } - - private Margin computeMargin() { - Rectangle panel = pHolder_.getBounds(); - float dpi = pHolder_.getPanelModel().getDpi(); - float top = ((float)(boundsD_.y - panel.y))/dpi; - float bottom = ((float)((panel.y + panel.height) - (boundsD_.y + boundsD_.height)))/dpi; - float left = ((float)(boundsD_.x - panel.x))/dpi; - float right = ((float)((panel.x + panel.width) - (boundsD_.x + boundsD_.width)))/dpi; - return new Margin(top, left, bottom, right); - } - - public void draw(Graphics g) { - Rectangle bounds = getBounds(); - Color savedColor = g.getColor(); - if(selected_) { - g.setColor(Color.red); - } else { - g.setColor(Color.green); - } - // draw AxisHolder - - // draw rectangle dashed - Rectangle2D rect = new Rectangle2D.Float(bounds.x, bounds.y, - bounds.width, bounds.height); - Graphics2D g2 = (Graphics2D)g; - Stroke saved = g2.getStroke(); - float[] dashes = {4.0f, 4.0f}; - BasicStroke stroke = new BasicStroke(1.0f, - BasicStroke.CAP_SQUARE, - BasicStroke.JOIN_MITER, - 10.0f, - dashes, - 0.0f); - g2.setStroke(stroke); - g2.draw(rect); - g2.setStroke(saved); - // Name -/* if(dg_.getXPosition() == DataGroup.BOTTOM) { - yString += BOX_HEIGHT - 2; - } else { - yString += BOX_HEIGHT - TIC_LENGTH - 2; - } - g.drawString(dg_.getId(), xBoundsD_.x + 5, yString); */ - - if(selected_) { - for(int i=0; i < handles_.length; i++) { - Rectangle r = handles_[i]; - g.fillRect(r.x, r.y, r.width-1, r.height-1); - } - } - - g.setColor(savedColor); - } - - - public void update(String message) { -// if(Page.DEBUG) System.out.println("DataGroupDragBox.update(" + message + ")"); - Rectangle panel = pHolder_.getBounds(); - Margin margin = dg_.getMargin(); - float dpi = pHolder_.getPanelModel().getDpi(); - int left = (int)(margin.left*dpi); - int right = (int)(margin.right*dpi); - int top = (int)(margin.top*dpi); - int bottom = (int)(margin.bottom*dpi); - boundsD_.x = panel.x + left; - boundsD_.y = panel.y + top; - boundsD_.width = panel.width - (left + right); - boundsD_.height = panel.height - (top + bottom); - computeHandles(); - } - - public void setLocation(Point pt) { - boundsD_.x = pt.x; - boundsD_.y = pt.y; - dg_.setMargin(computeMargin()); - computeHandles(); - } - - public Point getLocation() { - return new Point(boundsD_.x, boundsD_.y); - } - - public Rectangle getBounds() { - return boundsD_; - } - - public String getId() { - return dg_.getId(); - } - - public void setId(String id) { - dg_.setId(id); - } - - public void setAxisHolderDB(AxisHolderDragBox x, AxisHolderDragBox y) { - xAxDB_ = x; - yAxDB_ = y; - } - - public AxisHolderDragBox getXAxisHolderDB() { - return xAxDB_; - } - - public AxisHolderDragBox getYAxisHolderDB() { - return yAxDB_; - } - - public void stateChanged(ChangeEvent e) { - update("DataGroupDragBox.stateChanged()"); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupLayer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupLayer.java deleted file mode 100755 index c1080dd3..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupLayer.java +++ /dev/null @@ -1,782 +0,0 @@ -/* - * $Id: DataGroupLayer.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.util.List; -import java.util.Vector; -import java.util.Iterator; - -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.Point; -import java.awt.Graphics; - -import javax.swing.JOptionPane; - -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.AxisTransform; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.LogTransform; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.LogAxis; -import gov.noaa.pmel.sgt.AxisNotFoundException; -import gov.noaa.pmel.sgt.Attribute; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.CartesianRenderer; -import gov.noaa.pmel.sgt.PaneNotFoundException; -import gov.noaa.pmel.sgt.DataKey; -import gov.noaa.pmel.sgt.ColorMap; -import gov.noaa.pmel.sgt.TransformAccess; -import gov.noaa.pmel.sgt.ContourLevelsAccess; -import gov.noaa.pmel.sgt.ContourLevels; - -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTDomain; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; - -/** - * A holder for DataGroup and Layer associated with - * axes and Graph. Multiple sets of data can be added to a DataGroupLayer, - * but each will share the same DataGroup. I.e., the same axes and - * transforms. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - * @see Page Page for UML diagram - * @stereotype container - **/ -public class DataGroupLayer extends Layer { - private List dataLayers_ = new Vector(); - - /** - * @label dg - */ - private DataGroup dg_ = null; - - /** - * @label pHolder - */ - private PanelHolder pHolder_ = null; - private Panel panel_ = null; - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private boolean clipping_ = false; - private SoTDomain clipDomain_ = null; - // - private SoTRange xZoomRange_ = null; - private SoTRange yZoomRange_ = null; - private boolean inZoom_ = false; - // - private SGLabel xLabel_ = null; - private SGLabel yLabel_ = null; - - /** - * Default constructor. Panel and DataGroup must - * be specified. - */ - public DataGroupLayer() { - this(null, null); - } - - /** - * Construct DataGroupLayer. - * @param panel parent - * @param dg datagroup - */ - public DataGroupLayer(Panel panel, DataGroup dg) { - super(); - panel_ = panel; - setPane(panel.getPane()); - pHolder_ = dg.getPanelHolder(); - setGraph(new CartesianGraph("Graph")); - dg_ = dg; - setId(dg_.getId()); - update(); - } - - /** - * Get the Panel parent. - * @return panel - */ - public Panel getPanel() { - return panel_; - } - - /** - * Get DataGroup - * @return the datagroup - */ - public DataGroup getDataGroup() { - return dg_; - } - - /** - * Get Layer Iterator. - * @return iterator of Layers - */ - public Iterator getLayerIterator() { - return dataLayers_.iterator(); - } - - /** - * Get a List of the Layers. - * @return layer list - */ - public List getLayerList() { - return dataLayers_; - } - - private String getNextLayerId() { - int count = dataLayers_.size() + 1; - return getId() + "_" + count; - } - - /** - * Add data to the DataGroupLayer. - * @param data SGTData - * @param attr Attribute associated with data - * @param key DataKey - * @throws DataTargetMismatchException - */ - public void addData(SGTData data, Attribute attr, DataKey key) throws DataTargetMismatchException { - if(Page.DEBUG) { - System.out.println("DataGroupLayer.addData: data = " + data.toString()); - System.out.println("DataGroupLayer.addData: xTime = " + data.isXTime() + ", yTime = " + data.isYTime()); - System.out.println("DataGroupLayer.addData: attr = " + attr.toString()); - System.out.println("DataGroupLayer.addData: key = " + key); - System.out.println("DataGroupLayer.addData: xRange = " + data.getXRange()); - System.out.println("DataGroupLayer.addData: yRange = " + data.getYRange()); - if(data instanceof SGTGrid) - System.out.println("DataGroupLayer.addData: zRange = " + ((SGTGrid)data).getZRange()); - else - System.out.println("DataGroupLayer.addData: zRange = "); - } - /** @todo add data check */ - CartesianGraph graph = (CartesianGraph)getGraph(); - if((graph.getXTransform().isTime() != data.isXTime()) || - graph.getYTransform().isTime() != data.isYTime()) { - JOptionPane.showMessageDialog(this, "Added data does not have the\n" + - "same axis types as the DataGroup\n\n" + - "Time or Space axis does not match.", - "DataGroup Error", JOptionPane.ERROR_MESSAGE); - throw new DataTargetMismatchException("Data - Axis Mismatch"); - } - - CartesianRenderer rend = graph.getRenderer(); - if(rend == null) { // first data on DataGroupLayer - xRange_ = data.getXRange(); - yRange_ = data.getYRange(); - graph.setData(data, attr); - dataLayers_.add(this); - - StringBuffer label = new StringBuffer(data.getXMetaData().getName()); - String units = data.getXMetaData().getUnits(); - if(units != null && units.length() > 0) { - label.append(" (").append(units).append(")"); - } - xLabel_ = new SGLabel("X Axis Label", label.toString(), new Point2D.Double(0.0, 0.0)); - - label = new StringBuffer(data.getYMetaData().getName()); - units = data.getYMetaData().getUnits(); - if(units != null && units.length() > 0) { - label.append(" (").append(units).append(")"); - } - yLabel_ = new SGLabel("Y Axis Label", label.toString(), new Point2D.Double(0.0, 0.0)); - } else { // adding data to DataGroupLayer - xRange_.add(data.getXRange()); - yRange_.add(data.getYRange()); - // more data, create new layer - Layer ly = new Layer(getNextLayerId()); - CartesianGraph cg = new CartesianGraph("Graph_"+ly.getId(), - graph.getXTransform(), graph.getYTransform()); - ly.setPane(getPane()); - ly.setSizeP(getSizeP()); - ly.setBounds(getBounds()); - ly.setGraph(cg); - cg.setData(data, attr); - dataLayers_.add(ly); - if(clipping_) cg.setClip(clipDomain_.getXRange(), clipDomain_.getYRange()); - graph = cg; - } - - if(dg_.isZAutoScale() && attr != null && attr instanceof GridAttribute) { - Range2D zRange = ((SGTGrid)data).getZRange(); - ColorMap cmap = ((GridAttribute)attr).getColorMap(); - if(cmap instanceof TransformAccess) { - ((TransformAccess)cmap).setRange(zRange); - } else if(cmap instanceof ContourLevelsAccess) { - ContourLevels cl = ((ContourLevelsAccess)cmap).getContourLevels(); - int levels = dg_.getNumberAutoContourLevels(); - Range2D newRange = Graph.computeRange(zRange, levels); - ((ContourLevelsAccess)cmap).setContourLevels(ContourLevels.getDefault(newRange)); - } - } - - if(key != null) { - rend = graph.getRenderer(); - SGLabel label = getLabel(data, key); - key.addGraph(rend, label); - } - update(); - } - - private SGLabel getLabel(SGTData data, DataKey key) { - SGLabel lineTitle = data.getKeyTitle(); - if(lineTitle == null) { - lineTitle = xLabel_; - } - Legend lg = pHolder_.findLegend(key.getId()); - lineTitle.setHeightP(lg.getKeyLabelHeightP()); - return lineTitle; - } - - /** - * Update DataGroupLayer. Used internally. - */ - public void update() { - Rectangle bnds = pHolder_.getBounds(); - double dpi = pHolder_.getPanelModel().getDpi(); - double width = bnds.width/dpi; - double height = bnds.height/dpi; - SoTRange xRange = null; - SoTRange yRange = null; - SoTPoint xOrig = null; - SoTPoint yOrig = null; - - boolean batch = getPane().isBatch(); - getPane().setBatch(true); - - AxisHolder xAxHolder = dg_.getXAxisHolder(); - AxisHolder yAxHolder = dg_.getYAxisHolder(); - CartesianGraph gr = (CartesianGraph)getGraph(); - - this.setSizeP(new Dimension2D(width, height)); - // determine correct range - if(inZoom_) { - xRange = xZoomRange_; - yRange = yZoomRange_; - } else { - if(!xAxHolder.isAutoRange() || xRange_ == null) { - xRange = xAxHolder.getUserRange(); - } else { - xRange = xRange_; - } - if(!yAxHolder.isAutoRange() || yRange_ == null) { - yRange = yAxHolder.getUserRange(); - } else { - yRange = yRange_; - } - } - // transform setup - updateTransform(DataGroup.X_DIR, xRange); - updateTransform(DataGroup.Y_DIR, yRange); - // determine axes origins - // xaxis - Margin marg = dg_.getMargin(); - if(xAxHolder.getAxisPosition() == DataGroup.MANUAL) { - xOrig = new SoTPoint(gr.getXPtoSoT(xAxHolder.getAxisOriginP().x), - gr.getYPtoSoT(xAxHolder.getAxisOriginP().y)); - } else { - SoTValue yloc = null; - SoTRange range = null; - if(yAxHolder.getAxisPosition() == DataGroup.MANUAL) { - if(gr.getYTransform().isTime()) { - range = new SoTRange.Time(gr.getYPtoLongTime(marg.bottom), - gr.getYPtoLongTime(marg.top)); - } else { - range = new SoTRange.Double(gr.getYPtoU(marg.bottom), gr.getYPtoU(marg.top)); - } - } else { - range = yRange; - } - switch(xAxHolder.getAxisPosition()) { - case DataGroup.BOTTOM: - yloc = range.getStart(); - break; - case DataGroup.TOP: - yloc = range.getEnd(); - break; - } - xOrig = new SoTPoint(xRange.getStart(), yloc); - } - // yaxis - if(yAxHolder.getAxisPosition() == DataGroup.MANUAL) { - yOrig = new SoTPoint(gr.getXPtoSoT(yAxHolder.getAxisOriginP().x), - gr.getYPtoSoT(yAxHolder.getAxisOriginP().y)); - } else { - SoTValue xloc = null; - SoTRange range = null; - if(xAxHolder.getAxisPosition() == DataGroup.MANUAL) { - if(gr.getXTransform().isTime()) { - range = new SoTRange.Time(gr.getXPtoLongTime(marg.left), - gr.getXPtoLongTime(marg.right)); - } else { - range = new SoTRange.Double(gr.getXPtoU(marg.left), gr.getXPtoU(marg.right)); - } - } else { - range = xRange; - } - switch(yAxHolder.getAxisPosition()) { - case DataGroup.LEFT: - xloc = range.getStart(); - break; - case DataGroup.RIGHT: - xloc = range.getEnd(); - break; - } - yOrig = new SoTPoint(xloc, yRange.getStart()); - } - - updateAxis(DataGroup.X_DIR, xRange, xOrig, xLabel_); - updateAxis(DataGroup.Y_DIR, yRange, yOrig, yLabel_); - - getPane().setBatch(batch); - - if(Page.DEBUG) { - System.out.println("layer: " + getSize() + ", " + getSizeP()); - System.out.println("xTrans: " + gr.getXTransform().getRangeP() + ", " + - gr.getXTransform().getSoTRangeU()); - System.out.println("yTrans: " + gr.getYTransform().getRangeP() + ", " + - gr.getYTransform().getSoTRangeU()); - } - } - - private void updateTransform(int dir, SoTRange range) { - AxisTransform at; - AxisHolder ah; - CartesianGraph gr = (CartesianGraph)getGraph(); - - if(dir == DataGroup.X_DIR) { - ah = dg_.getXAxisHolder(); - at = gr.getXTransform(); - } else { - ah = dg_.getYAxisHolder(); - at = gr.getYTransform(); - } - - switch(ah.getTransformType()) { - case DataGroup.LINEAR: - if(at instanceof LinearTransform) { - at.setRangeU(range); - at.setRangeP(ah.getRangeP()); - } else { - at = new LinearTransform(ah.getRangeP(), range); - gr.setXTransform(at); - } - break; - case DataGroup.LOG: - if(at instanceof LogTransform) { - at.setRangeU(range); - at.setRangeP(ah.getRangeP()); - } else { - at = new LogTransform(ah.getRangeP(), range); - gr.setXTransform(at); - } - break; - case DataGroup.REFERENCE: - at = getReferenceTransform(DataGroup.X_DIR, ah.getTransformGroup()); - gr.setXTransform(at); - } - } - - private void updateAxis(int dir, SoTRange range, - SoTPoint origin, SGLabel title) { - String axis; - Axis ax = null; - AxisTransform at; - AxisHolder ah; - boolean newAxis = true; - CartesianGraph gr = (CartesianGraph)getGraph(); - - if(dir == DataGroup.X_DIR) { - axis = "X Axis"; - ah = dg_.getXAxisHolder(); - at = gr.getXTransform(); - } else { - axis = "Y Axis"; - ah = dg_.getYAxisHolder(); - at = gr.getYTransform(); - } - - try { - ax = gr.getXAxis(axis); - } catch (AxisNotFoundException anfe) { - ax = null; - } - newAxis = false; - switch(ah.getAxisType()) { - case DataGroup.PLAIN: - PlainAxis pax = null; - if(ax != null) { - if(ax instanceof PlainAxis) { - pax = (PlainAxis)ax; - } else { - pax = new PlainAxis(axis); - newAxis = true; - } - } else { - pax = new PlainAxis(axis); - newAxis = true; - } - ax = pax; - pax.setRangeP(ah.getRangeP()); - pax.setRangeU(range); - pax.setLabelFormat(ah.getLabelFormat()); - pax.setLabelInterval(ah.getLabelInterval()); - pax.setSignificantDigits(ah.getLabelSignificantDigits()); - break; - case DataGroup.TIME: - TimeAxis tax = null; - if(ax != null) { - if(ax instanceof TimeAxis) { - tax = (TimeAxis)ax; - } else { - tax = new TimeAxis(axis, ah.getTimeAxisStyle()); - newAxis = true; - } - } else { - tax = new TimeAxis(axis, ah.getTimeAxisStyle()); - newAxis = true; - } - ax = tax; - tax.setRangeP(ah.getRangeP()); - tax.setRangeU(range); - if(ah.getTimeAxisStyle() != TimeAxis.AUTO) { - tax.setLabelFormat(ah.getMinorFormat(), - ah.getMajorFormat()); - tax.setLabelInterval(ah.getMinorInterval(), - ah.getMajorInterval()); - } - break; - case DataGroup.LOG: - LogAxis lax = null; - if(ax != null) { - if(ax instanceof LogAxis) { - lax = (LogAxis)ax; - } else { - lax = new LogAxis(axis); - newAxis = true; - } - } else { - lax = new LogAxis(axis); - newAxis = true; - } - ax = lax; - lax.setRangeP(ah.getRangeP()); - lax.setRangeU(range); - lax.setLabelFormat(ah.getLabelFormat()); - lax.setLabelInterval(ah.getLabelInterval()); - lax.setSignificantDigits(ah.getLabelSignificantDigits()); - } - if(dir == DataGroup.X_DIR) { - ax.setOrientation(Axis.HORIZONTAL); - } else { - ax.setOrientation(Axis.VERTICAL); - } - ax.setLocationU(origin); - ax.setLineColor(ah.getAxisColor()); - ax.setTicPosition(ah.getTicPosition()); - ax.setLabelColor(ah.getLabelColor()); - ax.setLabelFont(ah.getLabelFont()); - ax.setLabelHeightP(ah.getLabelHeightP()); - ax.setLargeTicHeightP(ah.getLargeTicHeightP()); - ax.setNumberSmallTics(ah.getNumSmallTics()); - ax.setSmallTicHeightP(ah.getSmallTicHeightP()); - ax.setThickTicWidthP(ah.getThickTicWidth()); - ax.setLabelPosition(ah.getLabelPosition()); - ax.setVisible(ah.isVisible()); - if(title != null && ah.isTitleAuto()) { - SGLabel def = ah.getTitle(); - title.setColor(def.getColor()); - title.setFont(def.getFont()); - title.setHeightP(def.getHeightP()); - title.setVisible(def.isVisible()); - ax.setTitle(title); - } else { - ax.setTitle(ah.getTitle()); - } - ax.register(at); - if(dir == DataGroup.X_DIR) { - if(gr.getNumberXAxis() > 0 && newAxis) { - gr.removeAllXAxes(); - } - if(newAxis) gr.addXAxis(ax); - } else { - if(gr.getNumberYAxis() > 0 && newAxis) { - gr.removeAllYAxes(); - } - if(newAxis) gr.addYAxis(ax); - } - } - - // - // replicate Layer methods and pass on to - // all children Layer's - // - public void draw(Graphics g) throws PaneNotFoundException { - super.draw(g); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).draw(g); - } - } - - public void drawDraggableItems(Graphics g) throws PaneNotFoundException { - super.drawDraggableItems(g); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).drawDraggableItems(g); - } - } - - public void setBounds(int x, int y, int w, int h) { - super.setBounds(x, y, w, h); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).setBounds(x, y, w, h); - } - } - - public void setBounds(Rectangle rect) { - super.setBounds(rect); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).setBounds(rect); - } - } - - public void setLocation(int x, int y) { - super.setLocation(x, y); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).setLocation(x, y); - } - } - - public void setLocation(Point pt) { - super.setLocation(pt); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).setLocation(pt); - } - } - - public void setSize(Dimension size) { - super.setSize(size); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).setSize(size); - } - } - - public void setSize(int w, int h) { - super.setSize(w, h); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).setSize(w, h); - } - } - - public void setSizeP(Dimension2D size) { - super.setSizeP(size); - for(int i=1; i < dataLayers_.size(); i++) { - ((Layer)dataLayers_.get(i)).setSizeP(size); - } - } - - private AxisTransform getReferenceTransform(int dir, String datagroup) { -// PanelHolder ph = dg_.getPanelHolder(); - String dgLast = datagroup; - boolean stillLooking = true; - int tType = -1; - String newDG = null; - while(stillLooking) { - DataGroup dg = pHolder_.findDataGroup(dgLast); - if(dir == DataGroup.X_DIR) { - tType = dg.getXAxisHolder().getTransformType(); - } else { - tType = dg.getYAxisHolder().getTransformType(); - } - if(tType != DataGroup.REFERENCE) { - CartesianGraph graph = null; - Layer dgl = null; - /** @todo resolve instatiation order issue */ - if(dir == DataGroup.X_DIR) { - dgl = panel_.findDataGroupLayer(dg.getXAxisHolder().getTransformGroup()); - graph = (CartesianGraph)dgl.getGraph(); - if(graph == null) return null; // graph and transform not yet created - return graph.getXTransform(); - } else { - dgl = panel_.findDataGroupLayer(dg.getYAxisHolder().getTransformGroup()); - graph = (CartesianGraph)dgl.getGraph(); - if(graph == null) return null; - return graph.getYTransform(); - } - } - if(dir == DataGroup.X_DIR) { - newDG = dg.getXAxisHolder().getTransformGroup(); - } else { - newDG = dg.getYAxisHolder().getTransformGroup(); - } - dgLast = newDG; - } - return null; - } - - /** - * Set clipping for DataGroupLayer - * @param clip if true clip data to bounds. - */ - public void setClipping(boolean clip) { - if(!dg_.isZoomable()) return; - if(Page.DEBUG) System.out.println("DataGroupLayer: " + getId() + ": clip = " + clip); - clipping_ = clip; - setAllClipping(clipping_); - } - - /** - * Zoom DataGroupLayer. Zoom to Rectangle if zoom - * operation started within bounds. - * @param start start point - * @param rect zoom rectangle - */ - void zoomTo(Point start, Rectangle rect) { - if(!dg_.isZoomable()) return; - CartesianGraph graph = (CartesianGraph)getGraph(); - Rectangle gbnds = getGraphBounds(); - Rectangle bnds = getPanelBounds(); - if(!gbnds.contains(start)) return; - setClipping(true); - double xStartP = getXDtoP(rect.x); - double yStartP = getYDtoP(rect.y + rect.height); - double xEndP = getXDtoP(rect.x + rect.width); - double yEndP = getYDtoP(rect.y); - SoTRange xRangeU = null; - SoTRange yRangeU = null; - if(graph.getXTransform().isTime()) { - xRangeU = new SoTRange.Time(graph.getXPtoLongTime(xStartP), graph.getXPtoLongTime(xEndP)); - } else { - xRangeU = new SoTRange.Double(graph.getXPtoU(xStartP), graph.getXPtoU(xEndP)); - } - if(graph.getYTransform().isTime()) { - yRangeU = new SoTRange.Time(graph.getYPtoLongTime(yStartP), graph.getYPtoLongTime(yEndP)); - } else { - yRangeU = new SoTRange.Double(graph.getYPtoU(yStartP), graph.getYPtoU(yEndP)); - } - inZoom_ = true; - setDomain(new SoTDomain(xRangeU, yRangeU)); - } - - /** - * Reset the zoom for this DataGroupLayer if it contains the point. - * @param x x device coordinate - * @param y y device coordinate - */ - void resetZoom(int x, int y) { - if(!dg_.isZoomable()) return; - Rectangle bnds = getGraphBounds(); - if(!bnds.contains(x, y)) return; - if(Page.DEBUG) System.out.println("DataGroupLayer: " + getId() + ": " + x +", " + y); - inZoom_ = false; - xZoomRange_ = null; - yZoomRange_ = null; - setClipping(false); - update(); - } - /** - * Reset the zoom for this DataGroupLayer. - */ - public void resetZoom() { - inZoom_ = false; - xZoomRange_ = null; - yZoomRange_ = null; - setClipping(false); - update(); - } - - /** - * Set DataGroupLayer domain. - * @param domain domain - */ - public void setDomain(SoTDomain domain) { - setXRange(domain.getXRange(), domain.isXReversed()); - setYRange(domain.getYRange(), domain.isYReversed()); - if(clipping_) { - clipDomain_ = domain; - setAllClip(domain); - } else { - clipDomain_ = null; - setAllClipping(false); - } - update(); - if(Page.DEBUG) { - System.out.println("DataGroupLayer().setDomain: " + getId()); - System.out.println(" domain.XRange = " + domain.getXRange()); - System.out.println(" domain.YRange = " + domain.getYRange()); - System.out.println(" isClipping = " + clipping_); - } - } - - private void setXRange(SoTRange range, boolean reversed) { - xZoomRange_ = range.copy(); - } - - private void setYRange(SoTRange range, boolean reversed) { - yZoomRange_ = range.copy(); - } - - private void setAllClip(SoTDomain domain) { - Iterator iter = dataLayers_.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof Layer) { - Layer ly = (Layer)obj; - ((CartesianGraph)ly.getGraph()).setClip(domain.getXRange(), - domain.getYRange()); - } - } - } - - private void setAllClipping(boolean clip) { - Iterator iter = dataLayers_.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof Layer) { - Layer ly = (Layer)obj; - ((CartesianGraph)ly.getGraph()).setClipping(clip); - } - } - } - - private Rectangle getPanelBounds() { - return pHolder_.getBounds(); - } - - private Rectangle getGraphBounds() { - CartesianGraph graph = (CartesianGraph)getGraph(); - AxisTransform xTrans = graph.getXTransform(); - AxisTransform yTrans = graph.getYTransform(); - Range2D xRange = xTrans.getRangeP(); - Range2D yRange = yTrans.getRangeP(); - int x = getXPtoD(xRange.start); - int y = getYPtoD(yRange.end); - int width = getXPtoD(xRange.end) - x; - int height = getYPtoD(yRange.start) - y; - return new Rectangle(x, y, width, height); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupPropertyPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupPropertyPanel.java deleted file mode 100755 index 56b7879c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataGroupPropertyPanel.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * $Id: DataGroupPropertyPanel.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import javax.swing.*; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.Iterator; - -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.LogAxis; -import gov.noaa.pmel.sgt.LogTransform; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; - -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.IllegalTimeValue; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -class DataGroupPropertyPanel extends PropertyPanel - implements ActionListener, ChangeListener, FocusListener { - private boolean expert_ = false; - private String[] pNames_ = {"Id", "Margin", "Zoomable", "Z AutoScale", "Z Auto Levels", "Z User Range"}; - private JComponent[] comps_ = new JComponent[pNames_.length]; - private DataGroup dataGroup_ = null; - private boolean suppressEvent_ = false; - private int zAutoScale, zUserRange, zAutoLevels; - - public DataGroupPropertyPanel(DataGroup dg, boolean expert) { - super(); - dataGroup_ = dg; - dataGroup_.addChangeListener(this); - expert_ = expert; - create(); - } - - public void setDataGroup(DataGroup dg, boolean expert) { - if(dataGroup_ != null) dataGroup_.removeChangeListener(this); - dataGroup_ = dg; - dataGroup_.addChangeListener(this); - expert_ = expert; - reset(); - } - - void update() { - int i = -1; - suppressEvent_ = true; - int item = -1; - ((JTextField)comps_[++i]).setText(dataGroup_.getId()); - ((JLabel)comps_[++i]).setText(dataGroup_.getMargin().toString()); - ((JCheckBox)comps_[++i]).setSelected(dataGroup_.isZoomable()); - // - // z stuff - // - ((JCheckBox)comps_[++i]).setSelected(dataGroup_.isZAutoScale()); - ((JTextField)comps_[++i]).setText(format(dataGroup_.getNumberAutoContourLevels())); - ((JTextField)comps_[++i]).setText(format(dataGroup_.getZRangeU(), false)); - // - setFieldsEnabled(); - // - suppressEvent_ = false; - } - - void create() { - int i = -1; - int item = -1; - comps_[++i] = createTextField(dataGroup_.getId(), pNames_[i], this, !dataGroup_.isInstantiated()); - comps_[++i] = createLabel(dataGroup_.getMargin().toString()); - comps_[++i] = createCheckBox(dataGroup_.isZoomable(), pNames_[i], this); - // - // z stuff - // - comps_[++i] = createCheckBox(dataGroup_.isZAutoScale(), pNames_[i], this); - zAutoScale = i; - comps_[++i] = createTextField(format(dataGroup_.getNumberAutoContourLevels()), pNames_[i], this, true); - zAutoLevels = i; - comps_[++i] = createTextField(format(dataGroup_.getZRangeU(), false), pNames_[i], this, true); - zUserRange = i; - // - setFieldsEnabled(); -// - for(i=0; i < comps_.length; i++) { - addProperty(i+1, pNames_[i], comps_[i], false); - } - addProperty(comps_.length + 1, " ", new JLabel(" "), true); - } - - void resetFields() { - for(int i=0; i < comps_.length; i++) { - if(comps_[i] instanceof JTextField) { - ((JTextField)comps_[i]).removeActionListener(this); - ((JTextField)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JCheckBox) { - ((JCheckBox)comps_[i]).removeActionListener(this); - ((JCheckBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JComboBox) { - ((JComboBox)comps_[i]).removeActionListener(this); - ((JComboBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JButton) { - ((JButton)comps_[i]).removeActionListener(this); - ((JButton)comps_[i]).removeFocusListener(this); - } - } - } - - private void setFieldsEnabled() { - ((JTextField)comps_[zUserRange]).setEnabled(!((JCheckBox)comps_[zAutoScale]).isSelected()); - ((JTextField)comps_[zAutoLevels]).setEnabled(((JCheckBox)comps_[zAutoScale]).isSelected()); - } - - private void processEvent(Object obj, String command) { - String str = null; - SoTRange range = null; - if(command.equals("Id")) { - String oldId = dataGroup_.getId(); - dataGroup_.getPanelHolder().getDataGroups().remove(oldId); - dataGroup_.setId(((JTextField)obj).getText()); - dataGroup_.getPanelHolder().getDataGroups().put(dataGroup_.getId(), dataGroup_); - } else if(command.equals("Zoomable")) { - dataGroup_.setZoomable(((JCheckBox)obj).isSelected()); - } else if(command.equals("Z AutoScale")) { - dataGroup_.setZAutoScale(((JCheckBox)obj).isSelected()); - } else if(command.equals("Z Auto Levels")) { - dataGroup_.setNumberAutoContourLevels(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Z User Range")) { - range = parseRange(((JTextField)obj).getText(), false); - if(range != null) dataGroup_.setZRangeU(range); - } - } - - public void actionPerformed(ActionEvent e) { - if(suppressEvent_) return; - Object obj = e.getSource(); -// String str = null; - String command = e.getActionCommand(); - processEvent(obj, command); - setFieldsEnabled(); -// System.out.println(e.paramString() + ",rslt=" + str); - } - - - public void stateChanged(ChangeEvent e) { - update(); - } - - public void focusGained(FocusEvent e) { -// Object obj = e.getSource(); -// System.out.println("DataGroupPropertyPanel.focusGained: " + obj.toString()); - } - - public void focusLost(FocusEvent e) { - Object obj = e.getSource(); - if(obj instanceof JTextField) { - JTextField tf = (JTextField)obj; - String name = tf.getName(); - processEvent(obj, name); - } - } - -/* SoTRange parseRange(String value, boolean isTime) { - StringTokenizer tok = new StringTokenizer(value, ",\t\n\r\f"); - if(tok.countTokens() != 3) { - JOptionPane.showMessageDialog(this, "Three values required", "Illegal Response", JOptionPane.ERROR_MESSAGE); - return null; - } - SoTRange range = null; - double start = Double.parseDouble(tok.nextToken().trim()); - double end = Double.parseDouble(tok.nextToken().trim()); - double delta = Double.parseDouble(tok.nextToken().trim()); - range = new SoTRange.Double(start, end, delta); - return range; - } */ - - public void setExpert(boolean expert) { - boolean save = expert_; - expert_ = expert; - if(expert_ != save) reset(); - } - - public boolean isExpert() { - return expert_; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataHolder.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataHolder.java deleted file mode 100755 index 37220f45..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataHolder.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * $Id: DataHolder.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.Attribute; - -/** - * Object to associate SGTData, Attribute, - * Panel, and DataGroup. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -class DataHolder { - /** - * @undirected - * @supplierCardinality 1 - * @link aggregation - * @label data - */ - private SGTData data_; - - /** - * @link aggregation - * @undirected - * @supplierCardinality 1 - * @label attr - */ - private Attribute attr_; - - /** - * @supplierCardinality 1 - * @label pHolder - */ - private PanelHolder pHolder_; - - /** - * @supplierCardinality 1 - * @label dataGroup */ - private DataGroup dataGroup_; - - /** - * @label legend - */ - private Legend legend_; - - /** - * @label dModel - */ - private DataModel dModel_; - - public DataHolder(DataModel model, SGTData data, Attribute attr, - PanelHolder pHolder, DataGroup dataGroup, - Legend legend) { - dModel_ = model; - data_ = data; - attr_ = attr; - pHolder_ = pHolder; - dataGroup_ = dataGroup; - legend_ = legend; - } - - SGTData getData() { - return data_; - } - - Attribute getAttribute() { - return attr_; - } - - PanelHolder getPanelHolder() { - return pHolder_; - } - - DataGroup getDataGroup() { - return dataGroup_; - } - - Legend getLegend() { - return legend_; - } - - public void notifyPanel() throws DataTargetMismatchException { - dModel_.getPage().findPanel(pHolder_).addData(data_, attr_, dataGroup_, legend_); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModel.java deleted file mode 100755 index fc940ab8..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModel.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * $Id: DataModel.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.util.List; -import java.util.Vector; -import java.util.Iterator; - -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.Attribute; - -/** - * A model that supplies the relationship between SGTData objects, - * its Attribute and the - * Panel and DataGroup in which it is displayed and the - * Legend. - *

Some classes have been omitted for display purposes. - *

- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - * @stereotype bean - **/ -public class DataModel { - private PropertyChangeSupport support_ = new PropertyChangeSupport(this); - private List dataList_; - - /** - * @label page - */ - private Page page; - - /** @link aggregation - * @supplierCardinality 1..* - * @label dataList*/ - /*#DataHolder lnkDataHolder;*/ - - /** - * Default constructor. - */ - public DataModel() { - dataList_ = new Vector(); - } - - /** - * Add data to the DataModel. Throws a "addData" property change. - * @param data SGTData - * @param attr Attribute for data - * @param pHolder PanelHolder - * @param dataGroup DataGroup - * @param legend Legend - */ - public void addData(SGTData data, Attribute attr, - PanelHolder pHolder, DataGroup dataGroup, - Legend legend) { - DataHolder dh = new DataHolder(this, data, attr, pHolder, - dataGroup, legend); - dataList_.add(dh); - support_.firePropertyChange("addData", null, dh); - } - - /** - * Get Iterator of the DataHolder objects. - * @return - */ - public Iterator dataIterator() { - return dataList_.iterator(); - } - - /** - * Add property change listener. - * @param l property change listener - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - support_.addPropertyChangeListener(l); - } - - /** - * Listen for specific property change. - * @param name property name - * @param l property change listner - */ - public void addPropertyChangeListener(String name, PropertyChangeListener l) { - support_.addPropertyChangeListener(name, l); - } - - /** - * Remove property change listener. - * @param l property change listener - */ - public void removePropertyChangeListener(PropertyChangeListener l) { - support_.removePropertyChangeListener(l); - } - - /** - * Remove specific property change listener - * @param name property name - * @param l property change listener - */ - public void removePropertyChangeListener(String name, PropertyChangeListener l) { - support_.removePropertyChangeListener(name, l); - } - - /** - * Set Page. - * @param page Page - */ - public void setPage(Page page) { - this.page = page; - } - - /** - * Get Page. - * @return Page - */ - public Page getPage() { - return page; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelBeanInfo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelBeanInfo.java deleted file mode 100755 index 6be376e1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelBeanInfo.java +++ /dev/null @@ -1,45 +0,0 @@ -package gov.noaa.pmel.sgt.beans; - -import java.beans.*; - -/** - * BeanInfo object for DataModel. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -public class DataModelBeanInfo extends SimpleBeanInfo { - private Class beanClass = DataModel.class; - private String iconColor16x16Filename = "DataModelIcon16.gif"; - private String iconColor32x32Filename = "DataModelIcon32.gif"; - private String iconMono16x16Filename; - private String iconMono32x32Filename; - - public DataModelBeanInfo() { - } - public PropertyDescriptor[] getPropertyDescriptors() { - try { - PropertyDescriptor _page = new PropertyDescriptor("page", beanClass, "getPage", "setPage"); - PropertyDescriptor[] pds = new PropertyDescriptor[] { - _page}; - return pds; - } - catch(IntrospectionException ex) { - ex.printStackTrace(); - return null; - } - } - public java.awt.Image getIcon(int iconKind) { - switch (iconKind) { - case BeanInfo.ICON_COLOR_16x16: - return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null; - case BeanInfo.ICON_COLOR_32x32: - return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null; - case BeanInfo.ICON_MONO_16x16: - return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null; - case BeanInfo.ICON_MONO_32x32: - return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null; - } - return null; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelEditor.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelEditor.java deleted file mode 100755 index 575c4da4..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelEditor.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id: DataModelEditor.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import javax.swing.JComponent; - -/** - * Used at run-time to modify the DataModel. Not implemented at this - * time. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -class DataModelEditor extends JComponent { - /** - * @supplierCardinality 1 - */ - private DataModel dataModel_; - - public DataModelEditor() { - super(); - dataModel_ = null; - } - - public DataModelEditor(DataModel model) { - super(); - setDataModel(model); - } - - public DataModel getDataModel(){ - return dataModel_; - } - - public void setDataModel(DataModel dataModel){ - dataModel_ = dataModel; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelIcon16.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelIcon16.gif deleted file mode 100755 index 65a026f3..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelIcon32.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelIcon32.gif deleted file mode 100755 index 5df53387..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataModelIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataTargetMismatchException.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataTargetMismatchException.java deleted file mode 100755 index 16879c65..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DataTargetMismatchException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * $Id: DataTargetMismatchException.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -/** - * SGTData does not match the target of Panel and - * DataGroup or Legend type. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - * @stereotype bean - **/ -public class DataTargetMismatchException extends Exception { - - public DataTargetMismatchException() { - super(); - } - - public DataTargetMismatchException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DesignListener.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DesignListener.java deleted file mode 100755 index 354a6f42..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DesignListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * $Id: DesignListener.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -/** - * Used to identify those objects that only need to have their listeners active - * during design-time. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -interface DesignListener { -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DesignPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DesignPanel.java deleted file mode 100755 index 6a7905c2..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DesignPanel.java +++ /dev/null @@ -1,541 +0,0 @@ -/* - * $Id: DesignPanel.java,v 1.1.1.1 2007/09/07 06:32:01 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - - -import java.awt.Color; -import java.awt.Point; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Dimension; -import java.awt.Component; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.awt.event.MouseEvent; -import java.awt.event.InputEvent; - -import java.util.Vector; -import java.util.Iterator; -import java.util.HashMap; -import java.util.Map; -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:01 $ - * @since 3.0 - **/ -class DesignPanel extends JComponent implements MouseListener, - MouseMotionListener, ChangeListener, DesignListener, PropertyChangeListener { - public static final int ALIGN_TOP = 0; - public static final int ALIGN_BOTTOM = 1; - public static final int ALIGN_LEFT = 2; - public static final int ALIGN_RIGHT = 3; - public static final int JUSTIFY_VERTICAL = 4; - public static final int JUSTIFY_HORIZONTAL = 5; - - private Map pDragBoxes_ = new HashMap(); - private Vector selectedBoxes_ = new Vector(); - private boolean inMove_ = false; - private DragBox dragBox_ = null; - private int dragState_ = -1; - private Point move_ref_ = null; - private PanelModel model_ = null; - private DataGroup selectedDG_ = null; - private Dimension size = new Dimension(100, 100); - -// private boolean inSelect_ = false; - private int selectCount_ = 0; - private Point firstSelectedPoint_ = new Point(-1, -1); - private DragBox[] selectList_ = null; - private static int SELECT_DISTANCE = 2; - - public DesignPanel() { - super(); - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - } - - public DesignPanel(PanelModel model) { - this(); - setPanelModel(model); - } - - void jbInit() { - addMouseListener(this); - addMouseMotionListener(this); - } - - public Dimension getMinimumSize() { - return size; - } - - public Dimension getPreferredSize() { - return size; - } - - public Dimension getMaximumSize() { - return size; - } - - public Dimension getWorkSize() { - return size; - } - - public void setPanelModel(PanelModel model) { - pDragBoxes_.clear(); - selectedBoxes_.clear(); - - if(model != null) model.removeChangeListener(this); - model_ = model; - if(model_ == null) return; - - model_.addChangeListener(this); - Page pg = model_.getPage(); - if(pg == null) { - size = model_.getPageSize(); - System.out.println("No page found!: size = " + size); - setSize(size); - } else { - size = pg.getSize(); - if(Page.DEBUG) System.out.println("DeisignPanel: size = " + size); - setSize(size); - } - - Iterator iter = model_.panelIterator(); - while(iter.hasNext()) { - PanelHolder ph = (PanelHolder)iter.next(); - ph.addChangeListener(this); - PanelHolderDragBox pdb = new PanelHolderDragBox(ph); - pDragBoxes_.put(ph, pdb); - } - repaint(); - } - - public PanelModel getPanelModel() { - return model_; - } - - public void addPanel(PanelHolderDragBox panel) { - panel.getPanelHolder().addChangeListener(this); - pDragBoxes_.put(panel.getPanelHolder(), panel); - } - - public void addDataGroup(DataGroup dg) { - PanelHolder ph = getSelectedPanel(); - if(ph == null) return; - PanelHolderDragBox pdb = (PanelHolderDragBox)pDragBoxes_.get(ph); - if(pdb == null) return; - if(ph.getDataGroupSize() >= 1) { - dg.getXAxisHolder().setAxisPosition(DataGroup.TOP); - dg.getYAxisHolder().setAxisPosition(DataGroup.RIGHT); - } - pdb.addDragBox(dg); - ph.addDataGroup(dg); - // little fix - } - - public void addLabel(Label label) { - PanelHolder ph = getSelectedPanel(); - if(ph == null) return; - PanelHolderDragBox pdb = (PanelHolderDragBox)pDragBoxes_.get(ph); - if(pdb == null) return; - pdb.addDragBox(label); - ph.addLabel(label); - } - - public void addLegend(Legend legend) { - PanelHolder ph = getSelectedPanel(); - if(ph == null) return; - PanelHolderDragBox pdb = (PanelHolderDragBox)pDragBoxes_.get(ph); - pdb.addDragBox(legend); - ph.addLegend(legend); - } - - public void alignBoxes(int mode) { - int count = getSelectedCount(); - if(count < 0) return; - int y, x; - PanelHolderDragBox pdb; - PanelHolderDragBox box = (PanelHolderDragBox)selectedBoxes_.firstElement(); - Rectangle bounds = box.getBounds(); - switch (mode) { - case ALIGN_TOP: - if(count <= 1) return; - y = bounds.y; - for(int i=1; i < count; i++) { - pdb = (PanelHolderDragBox)selectedBoxes_.elementAt(i); - pdb.setLocation(pdb.getLocation().x, y); - } - break; - case ALIGN_BOTTOM: - if(count <= 1) return; - int y2 = bounds.y + bounds.height; - for(int i=1; i < count; i++) { - pdb = (PanelHolderDragBox)selectedBoxes_.elementAt(i); - y = y2 - pdb.getBounds().height; - pdb.setLocation(pdb.getLocation().x, y); - } - break; - case ALIGN_LEFT: - if(count <= 1) return; - x = bounds.x; - for(int i=1; i < count; i++) { - pdb = (PanelHolderDragBox)selectedBoxes_.elementAt(i); - pdb.setLocation(x, pdb.getLocation().y); - } - break; - case ALIGN_RIGHT: - if(count <= 1) return; - int x2 = bounds.x + bounds.width; - for(int i=1; i < count; i++) { - pdb = (PanelHolderDragBox)selectedBoxes_.elementAt(i); - x = x2 - pdb.getBounds().width; - pdb.setLocation(x, pdb.getLocation().y); - } - break; - case JUSTIFY_VERTICAL: - if(count >= 2) { - for(int i=1; i < count; i++) { - pdb = (PanelHolderDragBox)selectedBoxes_.elementAt(i); - Rectangle bnds = pdb.getBounds(); - bnds.y = bounds.y; - bnds.height = bounds.height; - pdb.setBounds(bnds); - } - } else { - Dimension sze = getWorkSize(); - bounds.y = 0; - bounds.height = sze.height; - box.setBounds(bounds); - } - break; - case JUSTIFY_HORIZONTAL: - if(count >= 2) { - for(int i=1; i < count; i++) { - pdb = (PanelHolderDragBox)selectedBoxes_.elementAt(i); - Rectangle bnds = pdb.getBounds(); - bnds.x = bounds.x; - bnds.width = bounds.width; - pdb.setBounds(bnds); - } - } else { - Dimension sze = getWorkSize(); - bounds.x = 0; - bounds.width = sze.width; - box.setBounds(bounds); - } - } - repaint(); - } - - public void removeSelected() { - PanelHolderDragBox pdb; - PanelHolder ph; - if(selectedBoxes_.size() == 1) { - pdb = (PanelHolderDragBox)selectedBoxes_.firstElement(); - pdb.getPanelHolder().removeAllChangeListeners(); - // remove contents - DragBox[] dbArray = pdb.getDragBoxArray(); - for(int i=0; i < dbArray.length; i++) { - ph = pdb.getPanelHolder(); - if(dbArray[i] instanceof DataGroupDragBox) { - DataGroup ag = ((DataGroupDragBox)dbArray[i]).getDataGroup(); - ph.removeDataGroup(ag); - pdb.removeDragBox((DataGroupDragBox)dbArray[i]); - } else if(dbArray[i] instanceof LegendDragBox) { - Legend legend = ((LegendDragBox)dbArray[i]).getLegend(); - ph.removeLegend(legend); - pdb.removeDragBox((LegendDragBox)dbArray[i]); - } else if(dbArray[i] instanceof LabelDragBox) { - Label label = ((LabelDragBox)dbArray[i]).getLabel(); - ph.removeLabel(label); - pdb.removeDragBox((LabelDragBox)dbArray[i]); - } - } - // pdb.getPanelHolder().removeChangeListener(this); - ph = pdb.getPanelHolder(); - pDragBoxes_.remove(ph); - model_.removePanel(ph); - ph.removeAllChangeListeners(); - } else { - Iterator iter = pDragBoxes_.values().iterator(); - while(iter.hasNext()) { - pdb = (PanelHolderDragBox)iter.next(); - Iterator dbIter = pdb.getDragBoxIterator(); - while(dbIter.hasNext()) { - DragBox db = (DragBox)dbIter.next(); - if(db.isSelected()) { - ph = pdb.getPanelHolder(); - if(db instanceof DataGroupDragBox) { - DataGroup ag = ((DataGroupDragBox)db).getDataGroup(); - ph.removeDataGroup(ag); - pdb.removeDragBox((DataGroupDragBox)db); - } else if(db instanceof LegendDragBox) { - Legend legend = ((LegendDragBox)db).getLegend(); - ph.removeLegend(legend); - pdb.removeDragBox((LegendDragBox)db); - } else if(db instanceof LabelDragBox) { - Label label = ((LabelDragBox)db).getLabel(); - ph.removeLabel(label); - pdb.removeDragBox((LabelDragBox)db); - } - break; - } - } - } - } - repaint(); - } - - boolean isAxisHolderDragBoxSelected() { - PanelHolderDragBox pdb; - Iterator iter = pDragBoxes_.values().iterator(); - while(iter.hasNext()) { - pdb = (PanelHolderDragBox)iter.next(); - Iterator dbIter = pdb.getDragBoxIterator(); - while(dbIter.hasNext()) { - DragBox db = (DragBox)dbIter.next(); - if(db.isSelected() && db instanceof AxisHolderDragBox) { - return true; - } - } - } - return false; - } - - boolean isChildDragBoxSelected() { - PanelHolderDragBox pdb; - Iterator iter = pDragBoxes_.values().iterator(); - while(iter.hasNext()) { - pdb = (PanelHolderDragBox)iter.next(); - Iterator dbIter = pdb.getDragBoxIterator(); - while(dbIter.hasNext()) { - DragBox db = (DragBox)dbIter.next(); - if(db.isSelected()) { - return true; - } - } - } - return false; - } - - int getSelectedCount() { - return selectedBoxes_.size(); - } - - PanelHolder getSelectedPanel() { - if(selectedBoxes_.size() != 1) return null; - return ((PanelHolderDragBox)selectedBoxes_.firstElement()).getPanelHolder(); - } - - public void paintComponent(Graphics g) { - g.setColor(model_.getPageBackgroundColor()); - g.fillRect(0, 0, size.width, size.height); - Iterator iter = pDragBoxes_.values().iterator(); - while(iter.hasNext()) { - ((PanelHolderDragBox)iter.next()).draw(g); - } - } - - void clearAllSelections() { - Iterator pIter = pDragBoxes_.values().iterator(); - while(pIter.hasNext()) { - PanelHolderDragBox pdb = (PanelHolderDragBox)pIter.next(); - pdb.setSelected(false); - Iterator dbIter = pdb.getDragBoxIterator(); - while(dbIter.hasNext()) { - ((DragBox)dbIter.next()).setSelected(false); - } - } - } - - private DragBox[] dragBoxesThatContain(Point pt) { - PanelHolderDragBox pDragBox; - Vector boxes = new Vector(4); - Iterator pIter = pDragBoxes_.values().iterator(); - while(pIter.hasNext()) { - pDragBox = (PanelHolderDragBox)pIter.next(); - if(pDragBox.contains(pt)) { - Iterator dbIter = pDragBox.getDragBoxIterator(); - while(dbIter.hasNext()) { - DragBox db = (DragBox)dbIter.next(); - if(db.contains(pt)) { - boxes.add(db); // add dragBox - } - } // dbIter - boxes.add(pDragBox); // add panelDragBox - } // pDragBox contains pt - } // pIter - return (DragBox[])boxes.toArray(new DragBox[boxes.size()]); - } - - private void resetSelect() { - selectList_ = null; - selectCount_ = 0; - firstSelectedPoint_.setLocation(-1,-1); - } - - private boolean newSelectPoint(Point pt) { - int dx = Math.abs(pt.x - firstSelectedPoint_.x); - int dy = Math.abs(pt.y - firstSelectedPoint_.y); - - return dx > SELECT_DISTANCE || dy > SELECT_DISTANCE; - } - - // mouse listener - public void mouseClicked(MouseEvent e) { - // object selection/deselection - DragBox dragBox = null; - boolean dble = e.getClickCount() >= 2; - int mods = e.getModifiers(); - Point pt = e.getPoint(); - boolean shiftctrl = (mods & InputEvent.CTRL_MASK) != 0 || - (mods & InputEvent.SHIFT_MASK) != 0; - // get selected DragBox - if(selectList_ == null || newSelectPoint(pt)) { - selectList_ = dragBoxesThatContain(pt); - if(selectList_.length <= 0) { - resetSelect(); - // nothing selected - clearAllSelections(); - int old = getSelectedCount(); - selectedBoxes_.removeAllElements(); - repaint(); - firePropertyChange("allUnselected", null, null); - - inMove_ = false; - dragState_ = -1; - return; - } - selectCount_ = 0; - firstSelectedPoint_.setLocation(pt); - dragBox = selectList_[selectCount_]; - } else { - selectCount_++; - if(selectCount_ >= selectList_.length) selectCount_ = 0; - dragBox = selectList_[selectCount_]; - } - // process selected DragBox - if(dragBox instanceof PanelHolderDragBox) { - if(!shiftctrl && !dragBox.isSelected()) { - clearAllSelections(); - selectedBoxes_.removeAllElements(); - } - dragBox.setSelected(!dragBox.isSelected()); - if(dragBox.isSelected()) { - selectedBoxes_.add(dragBox); - } else { - selectedBoxes_.remove(dragBox); - } - repaint(); - firePropertyChange("panelSelected", null, dragBox); - return; - } else { - clearAllSelections(); - selectedBoxes_.removeAllElements(); - dragBox.setSelected(true); - repaint(); - if(dragBox instanceof DataGroupDragBox) { - firePropertyChange("dataGroupSelected", null, dragBox); - } else if(dragBox instanceof AxisHolderDragBox) { - firePropertyChange("axisSelected", null, dragBox); - } else if(dragBox instanceof LabelDragBox) { - firePropertyChange("labelSelected", null, dragBox); - } else if(dragBox instanceof LegendDragBox) { - firePropertyChange("legendSelected", null, dragBox); - } - return; - } - } - - public void mousePressed(MouseEvent e) { - // initiate object move/resize - PanelHolderDragBox pDragBox = null; - DragBox db = null; - dragState_ = -1; - Iterator iter = pDragBoxes_.values().iterator(); - while(iter.hasNext()) { - pDragBox = (PanelHolderDragBox)iter.next(); - if(pDragBox.isSelected() && pDragBox.handlesContain(e.getPoint())) { - dragBox_ = pDragBox; - dragState_ = dragBox_.getSelectedHandle(); - inMove_ = true; - move_ref_ = new Point(e.getX(), e.getY()); - break; - } - // look for DragBoxes - Iterator dbIter = pDragBox.getDragBoxIterator(); - while(dbIter.hasNext()) { - db = (DragBox)dbIter.next(); - if(db.isSelected() && db.handlesContain(e.getPoint())) { - dragBox_ = db; - dragState_ = dragBox_.getSelectedHandle(); - inMove_ = true; - move_ref_ = new Point(e.getX(), e.getY()); - break; - } - } // dbIter - } // iter - } - - public void mouseReleased(MouseEvent e) { - inMove_ = false; - dragState_ = -1; - } - public void mouseEntered(MouseEvent e) { - } - public void mouseExited(MouseEvent e) { - } - // mouse motion listener - public void mouseDragged(MouseEvent e) { - resetSelect(); - Point pt = null; - Rectangle rect = null; - int x = e.getX(); - int y = e.getY(); - if(inMove_) { - int dx = x - move_ref_.x; - int dy = y - move_ref_.y; - dragBox_.mouseOperation(dragState_, dx, dy); - repaint(); - move_ref_ = new Point(x, y); - } // inMove_ - } - public void mouseMoved(MouseEvent e) { - } - - public void stateChanged(ChangeEvent e) { - size = model_.getPageSize(); - repaint(); - } - - public String toString() { - return getClass().getName() + '@' + Integer.toHexString(hashCode()); - } - public void propertyChange(PropertyChangeEvent evt) { - if(evt.getPropertyName().equals("pageSize")) { - size = model_.getPageSize(); - setSize(size); - repaint(); - } - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DragBox.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DragBox.java deleted file mode 100755 index 066662b3..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/DragBox.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * $Id: DragBox.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.Color; -import java.awt.Rectangle; -import java.awt.Point; -import java.awt.Graphics; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -abstract class DragBox implements DesignListener { - public static final int UPPER_LEFT = 0; - public static final int UPPER_RIGHT = 1; - public static final int LOWER_LEFT = 2; - public static final int LOWER_RIGHT = 3; - public static final int CENTER = 4; - - protected static int handleSize_ = 8; - protected Rectangle[] handles_ = new Rectangle[5]; - protected int selectedHandle_ = -1; - protected boolean selected_ = false; - protected Color selectedColor_ = Color.red; - protected Color unSelectedColor_ = Color.darkGray; - protected Color color_ = unSelectedColor_; - protected PanelHolder pHolder_; - - public DragBox(PanelHolder ph) { - pHolder_ = ph; - } - - public void setSelected(boolean sel) { - selected_ = sel; - if(selected_) { - color_ = selectedColor_; - } else { - color_ = unSelectedColor_; - } - } - - public boolean isSelected() { - return selected_; - } - - public boolean handlesContain(Point pt) { - for(int i=0; i < handles_.length; i++) { - if(handles_[i].contains(pt)) { - selectedHandle_ = i; - return true; - } - } - selectedHandle_ = -1; - return false; - } - - protected void computeHandles() { - Rectangle bounds = getBounds(); - handles_[UPPER_LEFT].setBounds(bounds.x, - bounds.y, - handleSize_, handleSize_); - handles_[UPPER_RIGHT].setBounds(bounds.x+bounds.width-handleSize_, - bounds.y, - handleSize_, handleSize_); - handles_[LOWER_LEFT].setBounds(bounds.x, - bounds.y+bounds.height-handleSize_, - handleSize_, handleSize_); - handles_[LOWER_RIGHT].setBounds(bounds.x+bounds.width-handleSize_, - bounds.y+bounds.height-handleSize_, - handleSize_, handleSize_); - handles_[CENTER].setBounds(bounds.x+(bounds.width-handleSize_)/2, - bounds.y+(bounds.height-handleSize_)/2, - handleSize_, handleSize_); - } - - public void mouseOperation(int op, int dx, int dy) { - if(op == -1) return; - Point pt; - Rectangle rect; - if(op == DragBox.CENTER) { - pt = getLocation(); - pt.x += dx; - pt.y += dy; - setLocation(pt); - } else { - rect = getBounds(); - int x2 = rect.x + rect.width; - int y2 = rect.y + rect.height; - switch (op) { - case DragBox.UPPER_LEFT: - rect.x += dx; - rect.y += dy; - break; - case DragBox.UPPER_RIGHT: - x2 += dx; - rect.y += dy; - break; - case DragBox.LOWER_LEFT: - rect.x += dx; - y2 += dy; - break; - case DragBox.LOWER_RIGHT: - x2 += dx; - y2 += dy; - } - rect.width = x2 - rect.x; - rect.height = y2 - rect.y; - setBounds(rect); - } - } - - public boolean contains(Point pt) { - return getBounds().contains(pt); - } - - public int getSelectedHandle() { - return selectedHandle_; - } - - Point2D.Double toLocation(Point pd) { - return new Point2D.Double(toXLocation(pd.x), - toYLocation(pd.y)); - } - - Point toLocation(Point2D.Double pp) { - return new Point(toXLocation(pp.x), - toYLocation(pp.y)); - } - - Rectangle2D.Double toRectangle(Rectangle rd) { - return new Rectangle2D.Double(toXLocation(rd.x), - toYLocation(rd.y + rd.height), - transform(rd.width), - transform(rd.height)); - } - - Rectangle toRectangle(Rectangle2D.Double rp) { - int h = transform(rp.height); - return new Rectangle(toXLocation(rp.x), - toYLocation(rp.y) - h, - transform(rp.width), - h); - } - - double toXLocation(int xd) { - return (xd - pHolder_.getBounds().x)/pHolder_.getPanelModel().getDpi(); - } - - double toYLocation(int yd) { - return (pHolder_.getBounds().height - yd + - pHolder_.getBounds().y)/pHolder_.getPanelModel().getDpi(); - } - - int toXLocation(double xp) { - return (int)(xp*pHolder_.getPanelModel().getDpi()+0.5f) + - pHolder_.getBounds().x; - } - - int toYLocation(double yp) { - return pHolder_.getBounds().height - (int)(yp*pHolder_.getPanelModel().getDpi()+0.5f) + - pHolder_.getBounds().y; - } - - double transform(int dev) { - return dev/pHolder_.getPanelModel().getDpi(); - } - - int transform(double phy) { - return (int)(phy*pHolder_.getPanelModel().getDpi()+0.5f); - } - - abstract public void draw(Graphics g); - abstract public void update(String message); - abstract public void setId(String id); - abstract public String getId(); - abstract public void setBounds(Rectangle bounds); - abstract public Rectangle getBounds(); - abstract public void setLocation(Point pt); - abstract public Point getLocation(); -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Label.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Label.java deleted file mode 100755 index 09338576..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Label.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * $Id: Label.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import javax.swing.event.*; -import java.awt.Color; -import java.awt.Font; -import java.util.*; -import java.io.*; -import java.beans.*; - -import gov.noaa.pmel.sgt.SGLabel; - -/** - * Encapsulates SGLabel properties. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -public class Label implements Serializable { - transient private PanelHolder pHolder_ = null; - private String id = ""; - private Rectangle2D.Double boundsP = new Rectangle2D.Double(0.0, 0.0, 0.0, 0.0); - transient private Vector changeListeners; - transient private ChangeEvent changeEvent_ = new ChangeEvent(this); - private String text = ""; - private int justification = SGLabel.LEFT; - private boolean visible = true; - private boolean instantiated = false; - - private boolean selectable = true; - private Color color = Color.black; - private Font font = new Font("Helvetica", Font.PLAIN, 10); - private int orientation = SGLabel.HORIZONTAL; - - static { - try { - BeanInfo info = Introspector.getBeanInfo(Label.class); - PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); - for(int i=0; i < descriptors.length; i++) { - PropertyDescriptor pd = descriptors[i]; - if(pd.getName().equals("instantiated")) { - pd.setValue("transient", Boolean.TRUE); - } else if(pd.getName().equals("panelHolder")) { - pd.setValue("transient", Boolean.TRUE); - } - } - } catch (IntrospectionException ie) { - ie.printStackTrace(); - } - } - /** - * Default constructor. Width and height are set to 0.0, name and location are - * null. - */ - public Label() { - this(null, null, 0.0f, 0.0f); - } - /** - * Label constructor. - * @param id label identifier - * @param loc location in physical coordinates - * @param wid width in physical coordinates - * @param hgt height in physical coorindates. - */ - public Label(String id, Point2D.Double loc, double wid, double hgt) { - this.id = id; - if(loc == null) { - boundsP = null; - } else { - boundsP = new Rectangle2D.Double(loc.x, loc.y, wid, hgt); - } - } - /** - * Get Label identifier. - * @return identification - */ - public String getId() { - return id; - } - /** - * Set label identifier. - * @param id identifier - */ - public void setId(String id) { - String saved = this.id; - this.id = id; - if(this.id == null || !this.id.equals(saved)) - fireStateChanged(); - } - /** - * Set Label bounds. - * @param bounds bounds in physical coordinates. - */ - public void setBoundsP(Rectangle2D.Double bounds) { - Rectangle2D.Double saved = boundsP; - boundsP = bounds; - if(saved == null || !saved.equals(boundsP)) fireStateChanged(); - } - /** - * Get Label bounds. - * @return bounds - */ - public Rectangle2D.Double getBoundsP() { - return boundsP; - } - /** - * Set Label location. Updates x and y in bounds. - * @param locationP location in physical coordinates. - */ - public void setLocationP(Point2D.Double locationP) { - double x = boundsP.x; - double y = boundsP.y; - - boundsP.x = locationP.x; - boundsP.y = locationP.y; - if(x != boundsP.x || y != boundsP.y) - fireStateChanged(); - } - /** - * Get Label location - * @return location in physical coordinates - */ - public Point2D.Double getLocationP() { - return new Point2D.Double(boundsP.x, boundsP.y); - } - /** - * Set Label height. Updates height in bounds. - * @param heightP height in physical coordinates - */ - public void setHeightP(double heightP) { - double saved = boundsP.height; - boundsP.height = (float)heightP; - if(boundsP.height != saved) - fireStateChanged(); - } - /** - * Get Label height. - * @return height - */ - public double getHeightP() { - return boundsP.height; - } - - /** - * Set label width. Updates width in bounds. - * @param widthP width in physcial coordinates - */ - public void setWidthP(double widthP) { - double saved = boundsP.width; - boundsP.width = (float)widthP; - if(boundsP.width != saved) - fireStateChanged(); - } - /** - * Get label width. - * @return width - */ - public double getWidthP() { - return boundsP.width; - } - /** - * Remove change listener. - * @param l change listener. - */ - public synchronized void removeChangeListener(ChangeListener l) { - if (changeListeners != null && changeListeners.contains(l)) { - Vector v = (Vector) changeListeners.clone(); - v.removeElement(l); - changeListeners = v; - } - } - /** - * Remove all change listeners. - */ - public void removeAllChangeListeners() { - changeListeners = null; - } - - public synchronized void addChangeListener(ChangeListener l) { - Vector v = changeListeners == null ? new Vector(2) : (Vector) changeListeners.clone(); - if (!v.contains(l)) { - v.addElement(l); - changeListeners = v; - } - } - /** - * Remove change listeners that implement DesignListener. - */ - public synchronized void removeDesignChangeListeners() { - if(changeListeners != null) { - Vector v = (Vector) changeListeners.clone(); - Iterator iter = v.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof DesignListener) changeListeners.removeElement(obj); - } - } - } - - protected void fireStateChanged() { - if (changeListeners != null) { - Vector listeners = changeListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - ((ChangeListener) listeners.elementAt(i)).stateChanged(changeEvent_); - } - } - } - /** - * Set label text. - * @param text label text - */ - public void setText(String text) { - String saved = this.text; - this.text = text; - if(this.text == null || !this.text.equals(saved)) - fireStateChanged(); - } - /** - * Get label text. - * @return text - */ - public String getText() { - return text; - } - /** - * Set label visiblity. Visible if true. Default = true. - * @param visible label visiblity - */ - public void setVisible(boolean visible) { - boolean saved = this.visible; - this.visible = visible; - if(saved != this.visible) fireStateChanged(); - } - /** - * Is Label visible? - * @return true, if label is visible - */ - public boolean isVisible() { - return visible; - } - /** - * Set instantiation for label. Used internally. Set when SGLabel is instantiated - * from Label. - * @param instantiated SGLabel instantiated - */ - public void setInstantiated(boolean instantiated) { - this.instantiated = instantiated; - } - /** - * Is SGLabel instatiated? - * @return true, if SGLabel is instantiated - */ - public boolean isInstantiated() { - return instantiated; - } - /** - * Set panelholder. - * @param pHolder panel holder - */ - public void setPanelHolder(PanelHolder pHolder) { - pHolder_ = pHolder; - } - /** - * Get panel holder. - * @return panel holder - */ - public PanelHolder getPanelHolder() { - return pHolder_; - } - /** - * Get label justification. - * @return justification. - */ - public int getJustification() { - return justification; - } - /** - * Set label justification. Justification can be SGLabel.LEFT, SGLabel.RIGHT, - * or SGLabel.CENTER. - * Default = SGLabel.LEFT. - * @param justification label justification - * @see gov.noaa.pmel.sgt.SGLabel - */ - public void setJustification(int justification) { - int saved = this.justification; - this.justification = justification; - if(saved != this.justification) fireStateChanged(); - } - /** - * Get label color. - * @return color - */ - public Color getColor() { - return color; - } - /** - * Get label font. - * @return font - */ - public Font getFont() { - return font; - } - /** - * Set label color. Default = Color.black. - * @param color label color - */ - public void setColor(Color color) { - Color saved = this.color; - this.color = color; - if(!saved.equals(this.color)) fireStateChanged(); - } - /** - * Set label font. Default = Helvectia, PLAIN - * @param font label font - */ - public void setFont(Font font) { - Font saved = this.font; - this.font = font; - if(!saved.equals(this.font)) fireStateChanged(); - } - /** - * Get label orientation. - * @return orientation - */ - public int getOrientation() { - return orientation; - } - /** - * Set label orientation. Legal values are SGLabel.HORIZONTAL and - * SGLabel.VERTICAL. Default = SGLabel.HORIZONTAL. - * @param orientation label orientation - * @see gov.noaa.pmel.sgt.SGLabel - */ - public void setOrientation(int orientation) { - int saved = this.orientation; - this.orientation = orientation; - if(saved != this.orientation) fireStateChanged(); - } - /** - * Is label selectable? - * @return true if label is selectable - */ - public boolean isSelectable() { - return selectable; - } - /** - * Set label selectable. - * @param selectable true if label is selectable - */ - public void setSelectable(boolean selectable) { - boolean saved = this.selectable; - this.selectable = selectable; - if(saved != this.selectable) fireStateChanged(); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LabelDragBox.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LabelDragBox.java deleted file mode 100755 index 4f3e1275..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LabelDragBox.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * $Id: LabelDragBox.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import java.util.Iterator; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -class LabelDragBox extends DragBox implements ChangeListener { - Label label_ = null; - Rectangle boundsD_ = null; - - // deal with angles later - - public LabelDragBox(Label label, PanelHolder pHolder) { - super(pHolder); - label_ = label; - label_.addChangeListener(this); - for(int i=0; i < handles_.length; i++) { - handles_[i] = new Rectangle(0,0,0,0); - } - boundsD_ = toRectangle(label_.getBoundsP()); - computeHandles(); - } - - public Label getLabel() { - return label_; - } - - public void setBounds(Rectangle bounds) { - boundsD_ = bounds; - label_.setBoundsP(toRectangle(boundsD_)); - computeHandles(); - } - - public void draw(Graphics g) { - Rectangle bounds = getBounds(); - Color saved = g.getColor(); - g.setColor(Color.darkGray); - g.drawString(getId(), bounds.x + 5, bounds.y + 12); - g.setColor(color_); - if(label_.isVisible()) g.drawRect(bounds.x, bounds.y, bounds.width-1, bounds.height-1); - if(selected_) { - for(int i=0; i < handles_.length; i++) { - Rectangle r = handles_[i]; - g.fillRect(r.x, r.y, r.width-1, r.height-1); - } - } - g.setColor(saved); - } - - public void setLocation(Point point) { - boundsD_.x = point.x; - boundsD_.y = point.y; - label_.setBoundsP(toRectangle(boundsD_)); - computeHandles(); - } - - public Point getLocation() { - return new Point(boundsD_.x, boundsD_.y); - } - - public Rectangle getBounds() { - return boundsD_; - } - - public String getId() { - return label_.getId(); - } - - public void update(String message) { - boundsD_ = toRectangle(label_.getBoundsP()); - computeHandles(); - } - - public void setId(String id) { - label_.setId(id); - } - - public void stateChanged(ChangeEvent e) { - update("LabelDragBox.stateChanged()"); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LabelPropertyPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LabelPropertyPanel.java deleted file mode 100755 index 276dbc1e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LabelPropertyPanel.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * $Id: LabelPropertyPanel.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.text.DecimalFormat; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; - -import gov.noaa.pmel.sgt.swing.prop.ColorDialog; -import gov.noaa.pmel.sgt.swing.prop.FontDialog; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.Point2D; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -class LabelPropertyPanel extends PropertyPanel implements ActionListener, ChangeListener, FocusListener { - private boolean expert_ = false; - private Label label_; - private static DecimalFormat format_ = new DecimalFormat("#.###"); - private String[] pNames_ = {"Color", "Font", "Height", "Id", "Justification", - "Location", "Orientation", "Selectable", "Text", "Visible", "Width"}; - private JComponent[] comps_ = new JComponent[pNames_.length]; - private String[] justType = {"Left", "Center", "Right"}; - private String[] orientType = {"Horizontal", "Vertical"}; - - public LabelPropertyPanel(Label label, boolean expert) { - super(); - label_ = label; - label_.addChangeListener(this); - expert_ = expert; - create(); - } - - public void setLabel(Label label, boolean expert) { - if(label_ != null) label_.removeChangeListener(this); - label_ = label; - label_.addChangeListener(this); - expert_ = expert; - reset(); - } - - void update() { - int item = -1; - int i = -1; - updateColor((JButton)comps_[++i], label_.getColor()); - updateFont((JButton)comps_[++i], label_.getFont()); - ((JTextField)comps_[++i]).setText(format(label_.getHeightP(), format_)); - ((JTextField)comps_[++i]).setText(label_.getId()); - switch(label_.getJustification()) { - default: - case SGLabel.LEFT: - item = 0; - break; - case SGLabel.CENTER: - item = 1; - break; - case SGLabel.RIGHT: - item = 2; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JLabel)comps_[++i]).setText(format(label_.getLocationP(), true)); - switch(label_.getOrientation()) { - default: - case SGLabel.HORIZONTAL: - item = 0; - break; - case SGLabel.VERTICAL: - item = 1; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JCheckBox)comps_[++i]).setSelected(label_.isSelectable()); - ((JTextField)comps_[++i]).setText(label_.getText()); - ((JCheckBox)comps_[++i]).setSelected(label_.isVisible()); - ((JTextField)comps_[++i]).setText(format(label_.getWidthP(), format_)); - } - - void create() { - int i = -1; - int item = -1; - comps_[++i] = createColor(label_.getColor(), pNames_[i], this); - comps_[++i] = createFont(label_.getFont(), pNames_[i], this); - comps_[++i] = createTextField(format(label_.getHeightP(), format_), pNames_[i], this, true); - comps_[++i] = createTextField(label_.getId(), pNames_[i], this, !label_.isInstantiated()); - switch(label_.getJustification()) { - default: - case SGLabel.LEFT: - item = 0; - break; - case SGLabel.CENTER: - item = 1; - break; - case SGLabel.RIGHT: - item = 2; - break; - } - comps_[++i] = createComboBox(justType, item, pNames_[i], this, true); - comps_[++i] = createLabel(format(label_.getLocationP(), true)); - switch(label_.getOrientation()) { - default: - case SGLabel.HORIZONTAL: - item = 0; - break; - case SGLabel.VERTICAL: - item = 1; - break; - } - comps_[++i] = createComboBox(orientType, item, pNames_[i], this, true); - comps_[++i] = createCheckBox(label_.isSelectable(), pNames_[i], this); - comps_[++i] = createTextField(label_.getText(), pNames_[i], this, true); - comps_[++i] = createCheckBox(label_.isVisible(), pNames_[i], this); - comps_[++i] = createTextField(format(label_.getWidthP(), format_), pNames_[i], this, true); - for(i=0; i < comps_.length; i++) { - addProperty(i+1, pNames_[i], comps_[i], false); - } - addProperty(comps_.length + 1, " ", new JLabel(" "), true); - } - - private void processEvent(Object obj, String command) { - if(command.equals("Id")) { - String oldId = label_.getId(); - label_.getPanelHolder().getLabels().remove(oldId); - label_.setId(((JTextField)obj).getText()); - label_.getPanelHolder().getLabels().put(label_.getId(), label_); - } else if(command.equals("Justification")) { - String str = (String)((JComboBox)obj).getSelectedItem(); - int item = -1; - if(str.equals("Left")) { - item = SGLabel.LEFT; - } else if(str.equals("Center")) { - item = SGLabel.CENTER; - } else if(str.equals("Right")) { - item = SGLabel.RIGHT; - } - label_.setJustification(item); - } else if(command.equals("Text")) { - label_.setText(((JTextField)obj).getText()); - } else if(command.equals("Location")) { - label_.setLocationP(parsePoint2D(((JTextField)obj).getText())); - } else if(command.equals("Height")) { - label_.setHeightP(Float.parseFloat(((JTextField)obj).getText())); - } else if(command.equals("Width")) { - label_.setWidthP(Float.parseFloat(((JTextField)obj).getText())); - } else if(command.equals("Visible")) { - label_.setVisible(((JCheckBox)obj).isSelected()); - } else if(command.equals("Color")) { - ColorDialog cd = new ColorDialog(getFrame(), "Select Label Color", true); - cd.setColor(label_.getColor()); - cd.setVisible(true); - Color newcolor = cd.getColor(); - if(newcolor != null) label_.setColor(newcolor); - } else if(command.equals("Font")) { - FontDialog fd = new FontDialog("Label Font"); - int result = fd.showDialog(label_.getFont()); - if(result == fd.OK_RESPONSE) { - label_.setFont(fd.getFont()); - } - } else if(command.equals("Orientation")) { - int old = label_.getOrientation(); - String str = (String)((JComboBox)obj).getSelectedItem(); - int item = -1; - if(str.equals("Horizontal")) { - item = SGLabel.HORIZONTAL; - } else if(str.equals("Vertical")) { - item = SGLabel.VERTICAL; - } - label_.setOrientation(item); - /** - * if orientation has changed redefine DragBox. - */ - if(old != item) { - Point2D.Double loc = label_.getLocationP(); - double w = label_.getWidthP(); - double h = label_.getHeightP(); - double x; - double y; - label_.setWidthP(label_.getHeightP()); - label_.setHeightP(w); - switch(label_.getJustification()) { - case SGLabel.CENTER: - if(item == SGLabel.VERTICAL) { - x = loc.x + w*0.5 - h; - y = loc.y - w*0.5; - } else { - x = loc.x - h*0.5 + w; - y = loc.y + h*0.5; - } - break; - default: - case SGLabel.LEFT: - if(item == SGLabel.VERTICAL) { - x = loc.x - h; - y = loc.y; - } else { - x = loc.x + w; - y = loc.y; - } - break; - case SGLabel.RIGHT: - if(item == SGLabel.VERTICAL) { - x = loc.x + w - h; - y = loc.y - w; - } else { - x = loc.x - h + w; - y = loc.y + h; - } - } - label_.setLocationP(new Point2D.Double(x,y)); - } - } else if(command.equals("Selectable")) { - label_.setSelectable(((JCheckBox)obj).isSelected()); - } - } - - void resetFields() { - for(int i=0; i < comps_.length; i++) { - if(comps_[i] instanceof JTextField) { - ((JTextField)comps_[i]).removeActionListener(this); - ((JTextField)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JCheckBox) { - ((JCheckBox)comps_[i]).removeActionListener(this); - ((JCheckBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JComboBox) { - ((JComboBox)comps_[i]).removeActionListener(this); - ((JComboBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JButton) { - ((JButton)comps_[i]).removeActionListener(this); - ((JButton)comps_[i]).removeFocusListener(this); - } - } - } - - public void actionPerformed(ActionEvent e) { - Object obj = e.getSource(); - String command = e.getActionCommand(); - processEvent(obj, command); - } - public void stateChanged(ChangeEvent e) { - update(); - } - public void focusGained(FocusEvent e) { - } - public void focusLost(FocusEvent e) { - Object obj = e.getSource(); - if(obj instanceof JTextField) { - JTextField tf = (JTextField)obj; - String name = tf.getName(); - processEvent(obj, name); - } - } - public void setExpert(boolean expert) { - expert_ = expert; - } - - public boolean isExpert() { - return expert_; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Legend.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Legend.java deleted file mode 100755 index aebe6d07..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Legend.java +++ /dev/null @@ -1,606 +0,0 @@ -/* - * $Id: Legend.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.LayerChild; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import javax.swing.event.*; -import java.util.*; -import java.io.*; -import java.beans.*; -import java.awt.Color; -import java.awt.Font; -/** - * Encapsulates reference to SGTData and key. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -public class Legend implements Serializable { - transient private ChangeEvent changeEvent_ = new ChangeEvent(this); - transient private PanelHolder pHolder_ = null; - // properties for all keys. - private String id = ""; - private Rectangle2D.Double boundsP = new Rectangle2D.Double(0.0, 0.0, 0.0, 0.0); - private boolean visible = true; - private boolean instantiated = false; - // VectorKey, LineKey, PointCollectionKey specific properties - private double lineLength = 0.3; - private int columns = 1; - // ColorKey specific properties - private Color scaleColor = Color.black; //advanced - private double scaleLabelHeightP = 0.2; - private int scaleNumberSmallTics = 0; // advanced - private int scaleLabelInterval = 2; - private Font scaleLabelFont = new Font("Helvetica", Font.PLAIN, 10); //advanced - private double scaleLargeTicHeightP = 0.1; //advanced - private double scaleSmallTicHeightP = 0.05; //advanced - private boolean scaleVisible = true; //advanced - private int scaleSignificantDigits = 2; - private String scaleLabelFormat = ""; //advanced - private double keyLabelHeightP = 0.16; //advanced - // - private int borderStyle = NO_BORDER; - /** - * Plain line border style. - */ - public static final int PLAIN_LINE = 0; - /** - * Raised line border style. - */ - public static final int RAISED = 1; - /** - * No border line border style. - */ - public static final int NO_BORDER = 2; - - private int type = LINE; - /** - * LineKey legend type - */ - public static final int LINE = 0; - /** - * ColorKey legend type - */ - public static final int COLOR = 1; - /** - * VectorKey legend type - */ - public static final int VECTOR = 2; - /** - * PointCollectionKey legend type - */ - public static final int POINT = 3; - - transient private Vector changeListeners; - static { - try { - BeanInfo info = Introspector.getBeanInfo(Legend.class); - PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); - for(int i=0; i < descriptors.length; i++) { - PropertyDescriptor pd = descriptors[i]; - if(pd.getName().equals("instantiated")) { - pd.setValue("transient", Boolean.TRUE); - } else if(pd.getName().equals("panelHolder")) { - pd.setValue("transient", Boolean.TRUE); - } - } - } catch (IntrospectionException ie) { - ie.printStackTrace(); - } - } - - /** - * Default constructor. Legend id and bounds set to null. - */ - public Legend() { - this(null, null); - } - /** - * Legend constructor. - * @param id legend identifier - * @param boundsP bounds in physical units - */ - public Legend(String id, Rectangle2D.Double boundsP) { - this.id = id; - this.boundsP = boundsP; - } - - /** - * Set legend identifier. - * @param id identifier - */ - public void setId(String id) { - String saved = this.id; - this.id = id; - if(saved == null || !saved.equals(this.id)) fireStateChanged(); - } - /** - * Get legend identifier - * @return ident - */ - public String getId() { - return id; - } - - /** - * Set legend bounds. - * @param boundsP bounds in physical coordinates - */ - public void setBoundsP(Rectangle2D.Double boundsP) { - Rectangle2D.Double saved = this.boundsP; - this.boundsP = boundsP; - if(saved == null || !saved.equals(this.boundsP)) fireStateChanged(); - } - /** - * Get Legend bounds. - * @return bounds - */ - public Rectangle2D.Double getBoundsP() { - return boundsP; - } - - /** - * Set the location of the TOP-LEFT corner - * @param locationP upper left corner in physical coordinates - */ - public void setLocationP(Point2D.Double locationP) { - double x = boundsP.x; - double y = boundsP.y - boundsP.height; - - boundsP.x = locationP.x; - boundsP.y = locationP.y; - if(x != boundsP.x || y != boundsP.y) - fireStateChanged(); - } - /** - * Get the location of the upper left corner. - * @return upper left corner - */ - public Point2D.Double getLocationP() { - return new Point2D.Double(boundsP.x, boundsP.y + boundsP.height); - } - - /** - * Set legend height. - * @param heightP height on physical coordinates - */ - public void setHeightP(double heightP) { - double saved = boundsP.height; - boundsP.height = (float)heightP; - if(boundsP.height != saved) - fireStateChanged(); - } - /** - * Get legend height. - * @return height - */ - public double getHeightP() { - return boundsP.height; - } - - /** - * Set legend width - * @param widthP width in physcial coordinates - */ - public void setWidthP(double widthP) { - double saved = boundsP.width; - boundsP.width = (float)widthP; - if(boundsP.width != saved) - fireStateChanged(); - } - /** - * Get legend width - * @return width - */ - public double getWidthP() { - return boundsP.width; - } - - /** - * Remove change listener. - * @param l change listener - */ - public synchronized void removeChangeListener(ChangeListener l) { - if (changeListeners != null && changeListeners.contains(l)) { - Vector v = (Vector) changeListeners.clone(); - v.removeElement(l); - changeListeners = v; - } - } - /** - * Add change listener. - * @param l change listener - */ - public synchronized void addChangeListener(ChangeListener l) { - if(Page.DEBUG) System.out.println("Legend.addChangeListener(" + l + ")"); - Vector v = changeListeners == null ? new Vector(2) : (Vector) changeListeners.clone(); - if (!v.contains(l)) { - v.addElement(l); - changeListeners = v; - } - } - /** - * Remove change listeners that implement DesignListener. - */ - public synchronized void removeDesignChangeListeners() { - if(changeListeners != null) { - Vector v = (Vector) changeListeners.clone(); - Iterator iter = v.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof DesignListener) changeListeners.removeElement(obj); - } - } - } - /** - * Remove all change listeners. - */ - public synchronized void removeAllChangeListeners() { - changeListeners = null; - } - - protected void fireStateChanged() { - if (changeListeners != null) { - Vector listeners = changeListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - ((ChangeListener) listeners.elementAt(i)).stateChanged(changeEvent_); - } - } - } - - /** - * Set visibility for legend. - * @param visible visibility state - */ - public void setVisible(boolean visible) { - boolean saved = this.visible; - this.visible = visible; - if(saved != this.visible) fireStateChanged(); - } - /** - * Test if legend visible. - * @return true, if legend is visible - */ - public boolean isVisible() { - return visible; - } - - /** - * Set legend state to instatiated. This is called internally when the - * property Key has been instatiated. - * @param instantiated instatiation state - */ - public void setInstantiated(boolean instantiated) { - this.instantiated = instantiated; - } - /** - * Test if the key instantiated. - * @return true, if key has been instantiated - */ - public boolean isInstantiated() { - return instantiated; - } - /** - * Test if legend of type COLOR. - * @return true, if legend is COLOR - */ - public boolean isColor() { - return type == Legend.COLOR; - } - - /** - * Get legend type. - * @return legend type. - */ - public int getType() { - return type; - } - /** - * Set legend type. Types include COLOR, LINE, - * POINT, and VECTOR. - * @param type legend type - */ - public void setType(int type) { - this.type = type; - } - - /** - * Get legend border style. - * @return border style - */ - public int getBorderStyle() { - return borderStyle; - } - /** - * Set legend border style. Border styles include: PLAIN_LINE, - * RAISED, and NO_BORDER. Default = NO_BORDER. - * @param borderStyle border style - */ - public void setBorderStyle(int borderStyle) { - int saved = this.borderStyle; - this.borderStyle = borderStyle; - if(saved != this.borderStyle) fireStateChanged(); - } - - /** - * Get number of columns. Not used with COLOR legends. - * @return number of columns - */ - public int getColumns() { - return columns; - } - /** - * Set number of columns. Not used with COLOR legends. Default = 1. - * @param columns number of columns - */ - public void setColumns(int columns) { - int saved = this.columns; - this.columns = columns; - if(saved != this.columns) fireStateChanged(); - } - - /** - * Get the legend line, or vector length in physical coordinages. - * Not used with COLOR legends. - * @return line or vector length - */ - public double getLineLength() { - return lineLength; - } - /** - * Set the legend line or vector lenght in physical units. - * Not used with COLOR legends. - * Defautl = 0.3 - * @param lineLength line or vector length - */ - public void setLineLength(double lineLength) { - double saved = this.lineLength; - this.lineLength = lineLength; - if(saved != this.lineLength) fireStateChanged(); - } - - /** - * Get COLOR legend scale color. Only used with COLOR - * legends. - * @return scale color - */ - public Color getScaleColor() { - return scaleColor; - } - /** - * Set COLOR legend scale color. Only used with COLOR - * legends. Deault = black. - * @param scaleColor scale color - */ - public void setScaleColor(Color scaleColor) { - Color saved = new Color(this.scaleColor.getRed(), - this.scaleColor.getGreen(), - this.scaleColor.getBlue(), - this.scaleColor.getAlpha()); - this.scaleColor = scaleColor; - if(!saved.equals(this.scaleColor)) fireStateChanged(); - } - - /** - * Get COLOR legend scale font. Only used with COLOR - * legends. - * @return scale font - */ - public Font getScaleLabelFont() { - return scaleLabelFont; - } - /** - * Set COLOR legend scale font. Only used with COLOR - * legends. Deault = ("Helvetica", PLAIN, 10). - * @param scaleLabelFont scale font - */ - public void setScaleLabelFont(Font scaleLabelFont) { - Font saved = new Font(this.scaleLabelFont.getName(), - this.scaleLabelFont.getStyle(), - this.scaleLabelFont.getSize()); - this.scaleLabelFont = scaleLabelFont; - if(!saved.equals(this.scaleLabelFont)) fireStateChanged(); - } - - /** - * Get COLOR legend scale label height in physical coordinates. - * Only used with COLOR legends. - * @return scale label height - */ - public double getScaleLabelHeightP() { - return scaleLabelHeightP; - } - /** - * Set COLOR legend scale label heigth. Only used with COLOR - * legends. Deault = 0.2. - * @param scaleLabelHeightP scale label height - */ - public void setScaleLabelHeightP(double scaleLabelHeightP) { - double saved = this.scaleLargeTicHeightP; - this.scaleLabelHeightP = scaleLabelHeightP; - if(saved != this.scaleLabelHeightP) fireStateChanged(); - } - - /** - * Get COLOR legend scale label interval. - * Only used with COLOR legends. - * @return scale label interval - */ - public int getScaleLabelInterval() { - return scaleLabelInterval; - } - /** - * Set COLOR legend scale label interval. Only used with COLOR - * legends. Deault = 2. - * @param scaleLabelInterval scale label interval - */ - public void setScaleLabelInterval(int scaleLabelInterval) { - int saved = this.scaleLabelInterval; - this.scaleLabelInterval = scaleLabelInterval; - if(saved != this.scaleLabelInterval) fireStateChanged(); - } - - /** - * Get COLOR legend scale number of small tics. - * Only used with COLOR legends. - * @return scale number of small tics - */ - public int getScaleNumberSmallTics() { - return scaleNumberSmallTics; - } - /** - * Set COLOR legend scale number of small tics. Only used with COLOR - * legends. Deault = 0. - * @param scaleNumberSmallTics scale number of small tics - */ - public void setScaleNumberSmallTics(int scaleNumberSmallTics) { - int saved = this.scaleNumberSmallTics; - this.scaleNumberSmallTics = scaleNumberSmallTics; - if(saved != this.scaleNumberSmallTics) fireStateChanged(); - } - - /** - * Get COLOR legend scale label format. - * Only used with COLOR legends. - * @return scale label format - */ - public String getScaleLabelFormat() { - return scaleLabelFormat; - } - /** - * Set COLOR legend scale label format. Only used with COLOR - * legends. Deault = "". - * @param scaleLabelFormat scale label format - */ - public void setScaleLabelFormat(String scaleLabelFormat) { - String saved = this.scaleLabelFormat; - this.scaleLabelFormat = scaleLabelFormat; - if(!saved.equals(this.scaleLabelFormat)) fireStateChanged(); - } - - /** - * Get COLOR legend scale large tick height. - * Only used with COLOR legends. - * @return scale large tick height - */ - public double getScaleLargeTicHeightP() { - return scaleLargeTicHeightP; - } - /** - * Set COLOR legend scale large tick height in physical - * coordinates. Only used with COLOR - * legends. Deault = 0.1. - * @param scaleLargeTicHeightP scale large tick height - */ - public void setScaleLargeTicHeightP(double scaleLargeTicHeightP) { - double saved = this.scaleLargeTicHeightP; - this.scaleLargeTicHeightP = scaleLargeTicHeightP; - if(saved != this.scaleLargeTicHeightP) fireStateChanged(); - } - - /** - * Get COLOR legend scale significant digits. - * Only used with COLOR legends. - * @return scale significant digits - */ - public int getScaleSignificantDigits() { - return scaleSignificantDigits; - } - /** - * Set COLOR legend scale significant digits. Only used with COLOR - * legends. Deault = 2. - * @param scaleSignificantDigits scale significant digits - */ - public void setScaleSignificantDigits(int scaleSignificantDigits) { - int saved = this.scaleSignificantDigits; - this.scaleSignificantDigits = scaleSignificantDigits; - if(saved != this.scaleSignificantDigits) fireStateChanged(); - } - - /** - * Get COLOR legend scale small tick height. - * Only used with COLOR legends. - * @return scale small tick height - */ - public double getScaleSmallTicHeightP() { - return scaleSmallTicHeightP; - } - /** - * Set COLOR legend scale small tick height in physical - * coordinates. Only used with COLOR - * legends. Deault = 0.05. - * @param scaleSmallTicHeightP scale small tick height - */ - public void setScaleSmallTicHeightP(double scaleSmallTicHeightP) { - double saved = this.scaleSmallTicHeightP; - this.scaleSmallTicHeightP = scaleSmallTicHeightP; - if(saved != this.scaleSmallTicHeightP) fireStateChanged(); - } - - /** - * Test if COLOR legend scale visible. - * Only used with COLOR legends. - * @return true, if scale visible - */ - public boolean isScaleVisible() { - return scaleVisible; - } - /** - * Set COLOR legend scale visible. Only used with COLOR - * legends. Deault = true. - * @param scaleVisible scale visible - */ - public void setScaleVisible(boolean scaleVisible) { - boolean saved = this.scaleVisible; - this.scaleVisible = scaleVisible; - if(saved != this.scaleVisible) fireStateChanged(); - } - - /** - * Get PanelHolder parent. - * @return panelholder - */ - public PanelHolder getPanelHolder() { - return pHolder_; - } - /** - * Set PanelHolder parent. - * @param pHolder panelholder - */ - public void setPanelHolder(PanelHolder pHolder) { - pHolder_ = pHolder; - } - - /** - * Get key label height. - * @return key label height - */ - public double getKeyLabelHeightP() { - return keyLabelHeightP; - } - /** - * Set key label height in physical coordinates. - * Default = 0.16. - * @param keyLabelHeightP key label height - */ - public void setKeyLabelHeightP(double keyLabelHeightP) { - double saved = this.keyLabelHeightP; - this.keyLabelHeightP = keyLabelHeightP; - if(saved != this.keyLabelHeightP) fireStateChanged(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LegendDragBox.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LegendDragBox.java deleted file mode 100755 index e22c4938..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LegendDragBox.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * $Id: LegendDragBox.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; - -import gov.noaa.pmel.util.Rectangle2D; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -class LegendDragBox extends DragBox implements ChangeListener { - private Legend legend_ = null; - private Rectangle boundsD_ = null; - - public LegendDragBox(Legend legend, PanelHolder pHolder) { - super(pHolder); - legend_ = legend; - legend_.addChangeListener(this); - boundsD_ = toRectangle(legend_.getBoundsP()); - for(int i=0; i < handles_.length; i++) { - handles_[i] = new Rectangle(0,0,0,0); - } - computeHandles(); - } - - public Legend getLegend() { - return legend_; - } - - public void setBounds(Rectangle bounds) { - boundsD_ = bounds; - legend_.setBoundsP(toRectangle(boundsD_)); - computeHandles(); - } - - public void draw(Graphics g) { - Rectangle bounds = getBounds(); - Color saved = g.getColor(); - g.setColor(Color.darkGray); - g.drawString(getId(), bounds.x + 5, bounds.y + 12); - g.setColor(color_); - if(legend_.isVisible()) - g.drawRect(bounds.x, bounds.y, bounds.width-1, bounds.height-1); - if(selected_) { - for(int i=0; i < handles_.length; i++) { - Rectangle r = handles_[i]; - g.fillRect(r.x, r.y, r.width-1, r.height-1); - } - } - g.setColor(saved); - } - - public void setLocation(Point pt) { - boundsD_.x = pt.x; - boundsD_.y = pt.y; - legend_.setBoundsP(toRectangle(boundsD_)); - computeHandles(); - } - - public Point getLocation() { - return new Point(boundsD_.x, boundsD_.y); - } - - public Rectangle getBounds() { - return boundsD_; - } - - public String getId() { - return legend_.getId(); - } - - public void update(String message) { -// if(Page.DEBUG) System.out.println("LegendDragBox.update(" + message + ")"); - boundsD_ = toRectangle(legend_.getBoundsP()); - computeHandles(); - } - - public void setId(String id) { - legend_.setId(id); - } - - public void stateChanged(ChangeEvent e) { - update("LegendDragBox.stateChanged()"); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LegendPropertyPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LegendPropertyPanel.java deleted file mode 100755 index d85b290b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/LegendPropertyPanel.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * $Id: LegendPropertyPanel.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import javax.swing.*; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.Color; -import java.awt.Font; -import java.text.DecimalFormat; - -import gov.noaa.pmel.sgt.Ruler; -import gov.noaa.pmel.sgt.swing.prop.FontDialog; -import gov.noaa.pmel.sgt.swing.prop.ColorDialog; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -class LegendPropertyPanel extends PropertyPanel implements ActionListener, ChangeListener, FocusListener { - private boolean expert_ = false; - private Legend legend_; - private String[] pNames_ = - { "Border", "Columns", "Height", - "Id", "Key Label HeightP", "Line Length", - "Location", - "Type", "Scale Color", "Scale Label Font", - "Scale Label Format", "Scale Label HeightP", "Scale Label Interval", - "Scale Large Tic HeightP", "Scale Num Small Tics", "Scale Significant Digits", - "Scale Small Tic HeightP", "Scale Visible", "Visible", - "Width"}; - private boolean[] inColor_ = - { true, false, true, - true, true, false, - true, - true, true, true, - true, true, true, - true, true, true, - true, true, true, - true}; - private boolean[] inColorOnly_ = - { false, false, false, - false, false, false, - false, - false, true, true, - true, true, true, - true, true, true, - true, true, false, - false}; - private boolean[] expertItem_ = - { false, false, false, - false, true, false, - false, - false, true, true, - true, true, false, - true, true, false, - true, true, false, - false}; - private JComponent[] comps_ = new JComponent[pNames_.length]; - private String[] keyType = {"Line", "Color", "Vector", "Point"}; - private String[] borderType = {"Plain Line", "Raised", "No Border"}; - private static DecimalFormat format_ = new DecimalFormat("#.###"); - - public LegendPropertyPanel(Legend legend, boolean expert) { - super(); - legend_ = legend; - expert_ = expert; - legend_.addChangeListener(this); - reset(); - } - - public void setLegend(Legend legend, boolean expert) { - if(legend_ != null) legend_.removeChangeListener(this); - legend_ = legend; - legend_.addChangeListener(this); - expert_ = expert; -// update(); - reset(); - } - - void update() { - int item = -1; - int i = -1; - switch(legend_.getBorderStyle()) { - default: - case Legend.PLAIN_LINE: - item = 0; - break; - case Legend.RAISED: - item = 1; - break; - case Legend.NO_BORDER: - item = 2; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JTextField)comps_[++i]).setText(Integer.toString(legend_.getColumns())); - ((JTextField)comps_[++i]).setText(format(legend_.getHeightP(), format_)); - ((JTextField)comps_[++i]).setText(legend_.getId()); - ((JTextField)comps_[++i]).setText(format(legend_.getKeyLabelHeightP())); - ((JTextField)comps_[++i]).setText(format(legend_.getLineLength())); - ((JTextField)comps_[++i]).setText(format(legend_.getLocationP(), false)); - switch(legend_.getType()) { - default: - case Legend.LINE: - item = 0; - break; - case Legend.COLOR: - item = 1; - break; - case Legend.VECTOR: - item = 2; - break; - case Legend.POINT: - item = 3; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - updateColor((JButton)comps_[++i], legend_.getScaleColor()); - updateFont((JButton)comps_[++i], legend_.getScaleLabelFont()); - ((JTextField)comps_[++i]).setText(legend_.getScaleLabelFormat()); - ((JTextField)comps_[++i]).setText(format(legend_.getScaleLabelHeightP())); - ((JTextField)comps_[++i]).setText(format(legend_.getScaleLabelInterval())); - ((JTextField)comps_[++i]).setText(format(legend_.getScaleLargeTicHeightP())); - ((JTextField)comps_[++i]).setText(format(legend_.getScaleNumberSmallTics())); - ((JTextField)comps_[++i]).setText(format(legend_.getScaleSignificantDigits())); - ((JTextField)comps_[++i]).setText(format(legend_.getScaleSmallTicHeightP())); - ((JCheckBox)comps_[++i]).setSelected(legend_.isScaleVisible()); - ((JCheckBox)comps_[++i]).setSelected(legend_.isVisible()); - ((JTextField)comps_[++i]).setText(format(legend_.getWidthP(), format_)); - } - - void create() { - int item = -1; - int i = -1; - switch(legend_.getBorderStyle()) { - default: - case Legend.PLAIN_LINE: - item = 0; - break; - case Legend.RAISED: - item = 1; - break; - case Legend.NO_BORDER: - item = 2; - break; - } - comps_[++i] = createComboBox(borderType, item, pNames_[i], this, true); - comps_[++i] = createTextField(Integer.toString(legend_.getColumns()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getHeightP(), format_), pNames_[i], this, true); - comps_[++i] = createTextField(legend_.getId(), pNames_[i], this, !legend_.isInstantiated()); - comps_[++i] = createTextField(format(legend_.getKeyLabelHeightP()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getLineLength()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getLocationP(), false), pNames_[i], this, true); - String[] axisPosition; - switch(legend_.getType()) { - default: - case Legend.LINE: - item = 0; - break; - case Legend.COLOR: - item = 1; - break; - case Legend.VECTOR: - item = 2; - break; - case Legend.POINT: - item = 3; - break; - } - comps_[++i] = createComboBox(keyType, item, pNames_[i], this, !legend_.isInstantiated()); - comps_[++i] = createColor(legend_.getScaleColor(), pNames_[i], this); - comps_[++i] = createFont(legend_.getScaleLabelFont(), pNames_[i], this); - comps_[++i] = createTextField(legend_.getScaleLabelFormat(), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getScaleLabelHeightP()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getScaleLabelInterval()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getScaleLargeTicHeightP()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getScaleNumberSmallTics()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getScaleSignificantDigits()), pNames_[i], this, true); - comps_[++i] = createTextField(format(legend_.getScaleSmallTicHeightP()), pNames_[i], this, true); - comps_[++i] = createCheckBox(legend_.isScaleVisible(), pNames_[i], this); - comps_[++i] = createCheckBox(legend_.isVisible(), pNames_[i], this); - comps_[++i] = createTextField(format(legend_.getWidthP(), format_), pNames_[i], this, true); - - for(i=0; i < comps_.length; i++) { - if(expert_ || ! expertItem_[i]) - if(legend_.isColor()) { - if(inColor_[i]) { - addProperty(i+1, pNames_[i], comps_[i], false); - } - } else { - if(!inColorOnly_[i]) { - addProperty(i+1, pNames_[i], comps_[i], false); - } - } - } - addProperty(comps_.length + 1, " ", new JLabel(" "), true); - } - - void resetFields() { - for(int i=0; i < comps_.length; i++) { - if(comps_[i] instanceof JTextField) { - ((JTextField)comps_[i]).removeActionListener(this); - ((JTextField)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JCheckBox) { - ((JCheckBox)comps_[i]).removeActionListener(this); - ((JCheckBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JComboBox) { - ((JComboBox)comps_[i]).removeActionListener(this); - ((JComboBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JButton) { - ((JButton)comps_[i]).removeActionListener(this); - ((JButton)comps_[i]).removeFocusListener(this); - } - } - } - private void processEvent(Object obj, String command) { - if(command.equals("Height")) { - legend_.setHeightP(Float.parseFloat(((JTextField)obj).getText())); - } else if(command.equals("Id")) { - String oldId = legend_.getId(); - legend_.getPanelHolder().getLegends().remove(oldId); - legend_.setId(((JTextField)obj).getText()); - legend_.getPanelHolder().getLegends().put(legend_.getId(), legend_); - } else if(command.equals("Key Label HeightP")) { - legend_.setKeyLabelHeightP(Double.parseDouble(((JTextField)obj).getText())); - } else if(command.equals("Border")) { - String str = (String)((JComboBox)obj).getSelectedItem(); - int item = -1; - if(str.equals("Plain Line")) { - item = Legend.PLAIN_LINE; - } else if(str.equals("Raised")) { - item = Legend.RAISED; - } else if(str.equals("No Border")) { - item = Legend.NO_BORDER; - } - legend_.setBorderStyle(item); - } else if(command.equals("Columns")) { - legend_.setColumns(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Line Length")) { - legend_.setLineLength(Double.parseDouble(((JTextField)obj).getText())); - } else if(command.equals("Location")) { - legend_.setLocationP(parsePoint2D(((JTextField)obj).getText())); - } else if(command.equals("Type")) { - String str = (String)((JComboBox)obj).getSelectedItem(); - int item = -1; - if(str.equals("Line")) { - item = Legend.LINE; - } else if(str.equals("Color")) { - item = Legend.COLOR; - } else if(str.equals("Vector")) { - item = Legend.VECTOR; - } else if(str.equals("Point")) { - item = Legend.POINT; - } - legend_.setType(item); - reset(); - } else if(command.equals("Scale Color")) { - ColorDialog cd = new ColorDialog(getFrame(), "Select Axis Color", true); - cd.setColor(legend_.getScaleColor()); - cd.setVisible(true); - Color newcolor = cd.getColor(); - if(newcolor != null) legend_.setScaleColor(newcolor); - } else if(command.equals("Scale Label Font")) { - FontDialog fd = new FontDialog("Label Font"); - int result = fd.showDialog(legend_.getScaleLabelFont()); - if(result == fd.OK_RESPONSE) { - legend_.setScaleLabelFont(fd.getFont()); - } - } else if(command.equals("Scale Label Format")) { - legend_.setScaleLabelFormat(((JTextField)obj).getText()); - } else if(command.equals("Scale Label HeightP")) { - legend_.setScaleLabelHeightP(Double.parseDouble(((JTextField)obj).getText())); - } else if(command.equals("Scale Label Interval")) { - legend_.setScaleLabelInterval(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Scale Large Tic HeightP")) { - legend_.setScaleLargeTicHeightP(Double.parseDouble(((JTextField)obj).getText())); - } else if(command.equals("Scale Num Small Tics")) { - legend_.setScaleNumberSmallTics(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Scale Significant Digits")) { - legend_.setScaleSignificantDigits(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Scale Small Tic HeightP")) { - legend_.setScaleSmallTicHeightP(Integer.parseInt(((JTextField)obj).getText())); - } else if(command.equals("Scale Visible")) { - legend_.setScaleVisible(((JCheckBox)obj).isSelected()); - } else if(command.equals("Visible")) { - legend_.setVisible(((JCheckBox)obj).isSelected()); - } else if(command.equals("Width")) { - legend_.setWidthP(Float.parseFloat(((JTextField)obj).getText())); - } - } - - public void actionPerformed(ActionEvent e) { - Object obj = e.getSource(); - String command = e.getActionCommand(); - processEvent(obj, command); - } - - public void stateChanged(ChangeEvent e) { - update(); - } - public void focusGained(FocusEvent e) { - } - public void focusLost(FocusEvent e) { - Object obj = e.getSource(); - if(obj instanceof JTextField) { - JTextField tf = (JTextField)obj; - String name = tf.getName(); - processEvent(obj, name); - } - } - public void setExpert(boolean expert) { - boolean save = expert_; - expert_ = expert; - if(expert_ != save) reset(); - } - - public boolean isExpert() { - return expert_; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Margin.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Margin.java deleted file mode 100755 index b534d1a3..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Margin.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * $Id: Margin.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.io.*; - -/** - * Margin class. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -public class Margin implements Cloneable, Serializable { - /** - * Left margin. - */ - public float left = Float.NaN; - /** - * Right margin. - */ - public float right = Float.NaN; - /** - * Top margin. - */ - public float top = Float.NaN; - /** - * Bottom margin. - */ - public float bottom = Float.NaN; - /** - * Default constructor. Sets all margin components to 0.0. - */ - public Margin() { - this(0.0f, 0.0f, 0.0f, 0.0f); - } - /** - * Margin constructor. - * @param top top margin - * @param left left margin - * @param bottom bottom margin - * @param right right margin - */ - public Margin(float top, float left, float bottom, float right) { - this.top = top; - this.left = left; - this.bottom = bottom; - this.right = right; - - } - /** - * Copy Margin object. - * @return Margin - */ - public Margin copy() { - try { - return (Margin)clone(); - } catch (CloneNotSupportedException ex) { - } - return null; - } - /** - * Set top margin. - * @param top top margin - */ - public void setTop(float top) { - this.top = top; - } - /** - * Get top margin. - * @return top margin - */ - public float getTop() { - return top; - } - /** - * Set bottom margin. - * @param bottom bottom margin - */ - public void setBottom(float bottom) { - this.bottom = bottom; - } - /** - * Get bottom margin - * @return bottom margin - */ - public float getBottom() { - return bottom; - } - /** - * Set left margin. - * @param left left margin - */ - public void setLeft(float left) { - this.left = left; - } - /** - * Get left margin. - * @return left margin - */ - public float getLeft() { - return left; - } - - /** - * Set right margin. - * @param right right margin - */ - public void setRight(float right) { - this.right = right; - } - /** - * Get right margin. - * @return right margin - */ - public float getRight() { - return right; - } - /** - * Get string representation of Margin. - * @return string - */ - public String toString() { - return Float.toString(top) + ", " + Float.toString(left) + - ", " + Float.toString(bottom) + ", " + Float.toString(right); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Page.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Page.java deleted file mode 100755 index fb35e486..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Page.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * $Id: Page.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.StackedLayout; -import gov.noaa.pmel.sgt.swing.JClassTree; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Point2D; -//import gov.noaa.pmel.util.SoTDomain; - -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.BorderLayout; -import java.awt.Component; - -import java.util.Vector; -import java.util.Iterator; -import javax.swing.JComponent; -import javax.swing.border.EtchedBorder; -import javax.swing.border.Border; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.InputEvent; -import java.awt.Rectangle; -import java.awt.Point; - -import java.beans.*; -import java.io.*; -import java.awt.print.PageFormat; -import java.awt.print.PrinterException; -import java.awt.print.Printable; - -/** - * Main SGT JavaBean in conjunction with a DataModel and PanelModel - * will create a graphic. - * - *

Some classes have been omitted for display purposes. - *

- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - * @stereotype bean - **/ -public class Page extends JComponent implements PropertyChangeListener, Serializable, Printable { - public static final boolean DEBUG = false; - /** - * @link aggregation - * @supplierCardinality 1 - * @undirected - * @label dataModel - */ - private DataModel dataModel; - - /** - * @link aggregation - * @supplierCardinality 1 - * @undirected - * @label panelModel - */ - private PanelModel panelModel; - - /** - *@link aggregation - * @associates <{Panel}> - * @supplierCardinality 1..* - * @clientCardinality 1 - * @undirected - */ -// transient private Vector panels_; - - /** - * @link aggregationByValue - * @clientCardinality 1 - * @supplierCardinality 1 - * @undirected - * @label pane - */ - private JPane pane_; - private String name; - transient private boolean isDesignTime_ = Beans.isDesignTime(); - - /** - * Page constructor. - */ - public Page() { - pane_ = new JPane("SGT Bean Pane", new Dimension(200, 200)); - pane_.addPropertyChangeListener(this); - pane_.setBackground(Color.white); - pane_.setOpaque(true); - this.setOpaque(true); - this.setLayout(new BorderLayout()); - this.setBackground(Color.white); - this.add(pane_, BorderLayout.CENTER); - pane_.addMouseListener(new PageMouse()); - } - - /** - * Get JPane associated with Page - * @return JPane - */ - public JPane getJPane() { - return pane_; - } - - /** - * Get JPane size. - * @return JPane size - */ - public Dimension getJPaneSize() { - return pane_.getSize(); - } - - protected void paintComponent(Graphics g) { - super.paintComponent(g); - } - - /** - * Get DataModel. - * @return DataModel - * @see DataModel - */ - public DataModel getDataModel() { - return dataModel; - } - - /** - * Set DataModel. DataModel is used to define the - * relationship between SGTData and the graphical representation. - * @param dataModel DataModel - * @see DataModel - */ - public void setDataModel(DataModel dataModel) { - if(DEBUG) System.out.println("Page.setDataModel()"); - - DataModel saved = this.dataModel; - if(this.dataModel != null) this.dataModel.removePropertyChangeListener(this); - if(dataModel != null) dataModel.addPropertyChangeListener(this); - - this.dataModel = dataModel; - this.dataModel.setPage(this); - if(isDesignTime_) repaint(); - firePropertyChange("dataModel", saved, this.dataModel); - } - - /** - * Get PanelModel. - * @return PanelModel - * @see PanelModel - */ - public PanelModel getPanelModel(){ - return panelModel; - } - - /** - * Set PanelModel. The PanelModel contains the information - * that indicates placement of Panels and DataGroupLayers. - * @param panelModel PanelModel - * @see PanelModel - */ - public void setPanelModel(PanelModel panelModel){ - if(DEBUG) System.out.println("Page.setPanelModel()"); - PanelModel saved = this.panelModel; - setSize(panelModel.getPageSize()); - setBackground(panelModel.getPageBackgroundColor()); - setPreferredSize(panelModel.getPageSize()); - this.panelModel = panelModel; - this.panelModel.setPage(this); - updatePanels(); - if(isDesignTime_) repaint(); - firePropertyChange("panelModel", saved, this.panelModel); - } - - public String getName() { - return name; - } - public void setBackground(Color color) { - super.setBackground(color); - pane_.setBackground(color); - } - public void setName(String name) { - firePropertyChange("name", this.name, name); - this.name = name; - } - - public void propertyChange(PropertyChangeEvent evt) { - Object source = evt.getSource(); - String property = evt.getPropertyName(); - if(source instanceof PanelModel) { - if(DEBUG) System.out.println("Page.propertyChange(PanelModel): " + property); - updatePanels(); - } else if(source instanceof DataModel) { - Object obj = evt.getNewValue(); - if(obj instanceof DataHolder) { - try { - pane_.setBatch(true); - ((DataHolder)obj).notifyPanel(); - pane_.setModified(true, "Page"); - pane_.setBatch(false); - } catch (DataTargetMismatchException dtme) { - dtme.printStackTrace(); - } - } - if(DEBUG) System.out.println("Page.propertyChange(DataModel): " + property); - } else if(source == pane_) { - if(property.equals("objectSelected")) { - - } else if(property.equals("zoomRectangle")) { - - } - if(DEBUG) System.out.println("Page.propertyChange(JPane): " + property); - - } - } - - private void updatePanels() { - // check for deleted PanelHolders - setSize(panelModel.getPageSize()); - setBackground(panelModel.getPageBackgroundColor()); - setPrintHAlign(panelModel.getPrintHAlign()); - setPrintVAlign(panelModel.getPrintVAlign()); - setPrintOrigin(panelModel.getPrintOrigin()); - setPrintScaleMode(panelModel.getPrintScaleMode()); - pane_.setBatch(true); - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Panel) { - Panel pnl = (Panel)comps[i]; - if(!panelModel.hasPanelHolder(pnl.getName())) { - pane_.remove(pnl); - } - } - } - // check for new PanelHolders then create otherwise update - Panel panel = null; - Iterator phIter = panelModel.panelIterator(); - while(phIter.hasNext()) { - PanelHolder ph = (PanelHolder)phIter.next(); - panel = findPanel(ph); - if(panel == null) { - panel = new Panel(ph); - ph.setInstantiated(true); -// panel.setBorder(new EtchedBorder()); - pane_.add(panel); - } else { - panel.update(); - } - } - validate(); - pane_.setModified(true, "Page"); - pane_.setBatch(false); - } - - /** - * Find the Panel associated with PanelHolder, a - * PanelModel component. - * @param pHolder PanelHolder - * @return Panel - * @see PanelModel - * @see PanelHolder - * @see Panel - */ - public Panel findPanel(PanelHolder pHolder) { - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Panel) { - if(((Panel)comps[i]).getName().equals(pHolder.getId())) return (Panel)comps[i]; - } - } - return null; - } - - private void pageMousePressed(MouseEvent event) { - if(!event.isControlDown()) return; - - pane_.setBatch(true); - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Panel) { - Panel pnl = (Panel)comps[i]; - pnl.resetZoom(event.getX(), event.getY()); - } - } - pane_.setBatch(false); - } - - /** - * Reset the zoom for all Panels and DataGroupLayers. - */ - public void resetZoom() { - pane_.setBatch(true); - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Panel) { - Panel pnl = (Panel)comps[i]; - pnl.resetZoom(); - } - } - pane_.setBatch(false); - } - - private void pageMouseClicked(MouseEvent event) { - if(event.isControlDown()) return; // ignore zoom resets - if(event.isPopupTrigger()) System.out.println("Page.pageMouseClicked(): isPopupTrigger()"); - Object obj = pane_.getSelectedObject(); - if((event.getModifiers()&InputEvent.BUTTON3_MASK) != 0) System.out.println("Page.pageMouseClicked(): Button3!"); - } - - private void pageMouseReleased(MouseEvent event) { - // - // continue only if button1 is pressed - // - if((event.getModifiers()&InputEvent.BUTTON1_MASK) == 0) return; - Rectangle zm = pane_.getZoomBounds(); - Point zmStart = pane_.getZoomStart(); - if(zm.width <= 1 || zm.height <= 1) return; - - pane_.setBatch(true); - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Panel) { - Panel pnl = (Panel)comps[i]; - pnl.zoomTo(zmStart, zm); - } - } - pane_.setBatch(false); - } - - class PageMouse extends MouseAdapter { - public void mousePressed(MouseEvent event) { - if(!pane_.isMouseEventsEnabled()) return; - pageMousePressed(event); - } - - public void mouseClicked(MouseEvent event) { - if(!pane_.isMouseEventsEnabled()) return; - pageMouseClicked(event); - } - - public void mouseReleased(MouseEvent event) { - if(!pane_.isMouseEventsEnabled()) return; - pageMouseReleased(event); - } - } - public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { - int result = NO_SUCH_PAGE; - Color saveColor = getBackground(); - if(panelModel.isPrintWhitePage()) { - setBackground(Color.white); - } - result = pane_.print(g, pf, pageIndex); - if(result == PAGE_EXISTS && panelModel.isPrintBorders()) { - Component[] comps = pane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Panel) { - Panel pnl = (Panel)comps[i]; - Rectangle r = pnl.getBounds(); - Border bdr = pnl.getBorder(); - bdr.paintBorder(pnl, g, r.x, r.y, r.width, r.height); - } - } - } - setBackground(saveColor); - return result; - } - /** - * Set printing scale mode. Legal values are AbstractPane.DEFAULT_SCALE, - * AbstractPane.TO_FIT, and AbstractPane.SHRINK_TO_FIT. Default = - * AbstractPane.DEFAULT_SCALE. - * @param mode scale mode - * @see gov.noaa.pmel.sgt.AbstractPane#DEFAULT_SCALE AbstractPane.DEFAULT_SCALE - * @see gov.noaa.pmel.sgt.AbstractPane#TO_FIT AbstractPane.TO_FIT - * @see gov.noaa.pmel.sgt.AbstractPane#SHRINK_TO_FIT AbstractPane.SHRINK_TO_FIT - */ - public void setPrintScaleMode(int mode) { - pane_.setPageScaleMode(mode); - } - /** - * Get printing scale mode. - * @return scale mode - */ - public int getPrintScaleMode() { - return pane_.getPageScaleMode(); - } - /** - * Set vertical alignment for printing. Legal values are AbstractPane.TOP, - * AbstractPane.MIDDLE, AbstractPane.BOTTOM, and AbstractPane.SPECIFIED_LOCATION. - * Default = AbstractPane.TOP; - * @param pageVAlign vertical alignment - * @see gov.noaa.pmel.sgt.AbstractPane#TOP AbstractPane.TOP - * @see gov.noaa.pmel.sgt.AbstractPane#MIDDLE AbstractPane.MIDDLE - * @see gov.noaa.pmel.sgt.AbstractPane#BOTTOM AbstractPane.BOTTOM - * @see gov.noaa.pmel.sgt.AbstractPane#SPECIFIED_LOCATION AbstractPane.SPECIFIED_LOCATION - */ - public void setPrintVAlign(int vert) { - pane_.setPageVAlign(vert); - } - /** - * Set horizontal alignment for printing. Legal values are AbstractPane.LEFT, - * AbstractPane.CENTER, AbstractPane.RIGHT, and AbstractPane.SPECIFIED_LOCATION. - * Default = AbstractPane.CENTER. - * @param pageHAlign horizontal alignment - * @see gov.noaa.pmel.sgt.AbstractPane#LEFT AbstractPane.LEFT - * @see gov.noaa.pmel.sgt.AbstractPane#CENTER AbstractPane.CENTER - * @see gov.noaa.pmel.sgt.AbstractPane#RIGHT AbstractPane.RIGHT - * @see gov.noaa.pmel.sgt.AbstractPane#SPECIFIED_LOCATION AbstractPane.SPECIFIED_LOCATION - */ - public void setPrintHAlign(int horz) { - pane_.setPageHAlign(horz); - } - /** - * Get vertical alignment for printing. - * @return vertical alignment. - */ - public int getPrintVAlign() { - return pane_.getPageVAlign(); - } - /** - * Get horizontal alignment for printing. - * @return horizontal alignment - */ - public int getPrintHAlign() { - return pane_.getPageHAlign(); - } - /** - * Set page origin for printing. Will be used if the horizontal or vertical alignment is - * AbstractPane.SPECIFIED_LOCATION. Default = (0,0). - * @param pageOrigin page origin - * @see gov.noaa.pmel.sgt.AbstractPane AbstractPane - */ - public void setPrintOrigin(Point pt) { - pane_.setPageOrigin(pt); - } - /** - * Get page origin for printing. - * @return page origin. - */ - public Point getPrintOrigin() { - return pane_.getPageOrigin(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageBeanInfo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageBeanInfo.java deleted file mode 100755 index c3f9b5ae..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageBeanInfo.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * $Id: PageBeanInfo.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.beans.*; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -public class PageBeanInfo extends SimpleBeanInfo { - private Class beanClass = Page.class; - private String iconColor16x16Filename = "PageIcon16.gif"; - private String iconColor32x32Filename = "PageIcon32.gif"; - private String iconMono16x16Filename; - private String iconMono32x32Filename; - - public PageBeanInfo() { - } - public PropertyDescriptor[] getPropertyDescriptors() { - try { - PropertyDescriptor _background = new PropertyDescriptor("background", beanClass, null, "setBackground"); - PropertyDescriptor _dataModel = new PropertyDescriptor("dataModel", beanClass, "getDataModel", "setDataModel"); - PropertyDescriptor _JPane = new PropertyDescriptor("JPane", beanClass, "getJPane", null); - PropertyDescriptor _JPaneSize = new PropertyDescriptor("JPaneSize", beanClass, "getJPaneSize", null); - PropertyDescriptor _name = new PropertyDescriptor("name", beanClass, "getName", "setName"); - PropertyDescriptor _panelModel = new PropertyDescriptor("panelModel", beanClass, "getPanelModel", "setPanelModel"); - PropertyDescriptor _printHAlign = new PropertyDescriptor("printHAlign", beanClass, "getPrintHAlign", "setPrintHAlign"); - PropertyDescriptor _printOrigin = new PropertyDescriptor("printOrigin", beanClass, "getPrintOrigin", "setPrintOrigin"); - PropertyDescriptor _printScaleMode = new PropertyDescriptor("printScaleMode", beanClass, "getPrintScaleMode", "setPrintScaleMode"); - PropertyDescriptor _printVAlign = new PropertyDescriptor("printVAlign", beanClass, "getPrintVAlign", "setPrintVAlign"); - PropertyDescriptor[] pds = new PropertyDescriptor[] { - _background, - _dataModel, - _JPane, - _JPaneSize, - _name, - _panelModel, - _printHAlign, - _printOrigin, - _printScaleMode, - _printVAlign}; - return pds; - } - catch(IntrospectionException ex) { - ex.printStackTrace(); - return null; - } - } - public java.awt.Image getIcon(int iconKind) { - switch (iconKind) { - case BeanInfo.ICON_COLOR_16x16: - return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null; - case BeanInfo.ICON_COLOR_32x32: - return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null; - case BeanInfo.ICON_MONO_16x16: - return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null; - case BeanInfo.ICON_MONO_32x32: - return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null; - } - return null; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageIcon16.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageIcon16.gif deleted file mode 100755 index 292709ee..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageIcon32.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageIcon32.gif deleted file mode 100755 index 31ec4eb0..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PageIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Panel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Panel.java deleted file mode 100755 index c8acab4a..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/Panel.java +++ /dev/null @@ -1,605 +0,0 @@ -/* - * $Id: Panel.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.Graphics; -import java.awt.Component; -import java.awt.Rectangle; -import java.awt.Color; -import java.awt.Point; -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; -import java.util.Vector; -import java.util.Collection; - -import javax.swing.JComponent; -import javax.swing.border.Border; - -import gov.noaa.pmel.sgt.AbstractPane; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.LayerControl; -import gov.noaa.pmel.sgt.LayerChild; -import gov.noaa.pmel.sgt.StackedLayout; -import gov.noaa.pmel.sgt.PaneNotFoundException; -import gov.noaa.pmel.sgt.ChildNotFoundException; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.Attribute; -import gov.noaa.pmel.sgt.DataKey; -import gov.noaa.pmel.sgt.LineKey; -import gov.noaa.pmel.sgt.ColorKey; -import gov.noaa.pmel.sgt.VectorKey; -import gov.noaa.pmel.sgt.PointCollectionKey; -import gov.noaa.pmel.sgt.Ruler; -import gov.noaa.pmel.sgt.dm.SGTData; - -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; - -/** - * A Layer container that provides a StackedLayout of - * the Layers. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - * @stereotype container - **/ -public class Panel extends JComponent implements LayerControl { - /** - * @label pane - */ - private JPane pane_ = null; - - /** - * @directed - * @label pHolder - */ - private PanelHolder pHolder_ = null; - - /** - * @label labelLayer - */ - private Layer labelLayer_ = null; - - /** - * @label legendLayer - */ - private Layer legendLayer_ = null; - /** @link aggregation - * @supplierCardinality * */ - /*#DataGroupLayer lnkDataGroupLayer; */ - private Map dataGroupLayerList_ = new HashMap(2); - - /** - * Panel constructor. PanelHolder will need to be - * set. - * @param name Panel name - */ - public Panel(String name) { - super(); - setName(name); - setLayout(new StackedLayout()); - } - - /** - * Panel constructor with PanelHolder argument. - * Panel name set from PanelHolder identifier. - * @param ph PanelHolder - */ - public Panel(PanelHolder ph) { - this(ph.getId()); - pHolder_ = ph; - update(); - } - - /** - * Set PanelHolder. PanelHolder contains the layout - * information and DataGroups associated with the Panel. - * @param ph PanelHolder - */ - public void setPanelHolder(PanelHolder ph) { - pHolder_ = ph; - setName(pHolder_.getId()); - update(); - } - - /** - * Traverses the PanelHolder and adds any new objects and - * updates exisiting objects. - */ - public void update() { - float dpi = pHolder_.getPanelModel().getDpi(); - setBounds(pHolder_.getBounds()); - double width = getBounds().width/dpi; - double height = getBounds().height/dpi; - Dimension2D psize = new Dimension2D(width, height); - if(pane_ != null) { - boolean batch = pane_.isBatch(); - pane_.setBatch(true); - if(labelLayer_ == null) { - labelLayer_ = new Layer("Label Layer", psize); - add(labelLayer_); - labelLayer_.setPane(pane_); - } else { - labelLayer_.setSizeP(psize); - } - if(legendLayer_ == null) { - legendLayer_ = new Layer("Legend Layer", psize); - add(legendLayer_); - legendLayer_.setPane(pane_); - } else { - legendLayer_.setSizeP(psize); - } - - this.setBorder(pHolder_.getBorder()); - - invalidate(); - try { - updateLabels(); - updateLegends(); - updateDataGroups(); - } catch (ChildNotFoundException e) { - e.printStackTrace(); - } - pane_.setBatch(batch); - } - } - - private void updateLabels() throws ChildNotFoundException { - Iterator lbIter = pHolder_.labelIterator(); -// remove deleted labels from layer - // note cant remove from an Iterator! - LayerChild[] children = labelLayer_.getChildren(); - for(int i=0; i < children.length; i++) { - LayerChild child = children[i]; - if(!pHolder_.hasLabel(child.getId())) { - labelLayer_.removeChild(child); - } - } -// add or update labels to layer - while(lbIter.hasNext()) { - SGLabel sgl = null; - Label label = (Label)lbIter.next(); - LayerChild child = labelLayer_.findChild(label.getId()); - - Point2D.Double loc = label.getLocationP(); - Rectangle2D.Double bnds = label.getBoundsP(); - double hgt; - if(label.getOrientation() == SGLabel.HORIZONTAL) { - hgt = label.getHeightP(); - switch(label.getJustification()) { - case SGLabel.LEFT: - break; - case SGLabel.CENTER: - loc.x = loc.x + bnds.getWidth()*0.5; - break; - case SGLabel.RIGHT: - loc.x = loc.x + bnds.getWidth(); - break; - } - } else { - hgt = label.getWidthP(); - loc.x += bnds.getWidth(); - switch(label.getJustification()) { - case SGLabel.LEFT: - break; - case SGLabel.CENTER: - loc.y = loc.y + bnds.getHeight()*0.5; - break; - case SGLabel.RIGHT: - loc.y = loc.y + bnds.getHeight(); - break; - } - } - if(child == null) { - sgl = new SGLabel(label.getId(), - label.getText(), - hgt, - loc, - SGLabel.BOTTOM, - label.getJustification()); - sgl.setVisible(label.isVisible()); - sgl.setSelectable(label.isSelectable()); - sgl.setOrientation(label.getOrientation()); - sgl.setColor(label.getColor()); - sgl.setFont(label.getFont()); - labelLayer_.addChild(sgl); - label.setInstantiated(true); - } else { - sgl = (SGLabel)child; - sgl.setText(label.getText()); - sgl.setHeightP(hgt); - sgl.setLocationP(loc); - sgl.setHAlign(label.getJustification()); - sgl.setVisible(label.isVisible()); - sgl.setSelectable(label.isSelectable()); - sgl.setOrientation(label.getOrientation()); - sgl.setColor(label.getColor()); - sgl.setFont(label.getFont()); - } - } - } - - private void updateLegends() { - Iterator lgIter = pHolder_.legendIterator(); - while(lgIter.hasNext()) { - DataKey key = null; - Legend legend = (Legend)lgIter.next(); - LayerChild child = legendLayer_.findChild(legend.getId()); - Rectangle2D.Double boundsP = legend.getBoundsP(); - if(child == null) { - switch(legend.getType()) { - case Legend.LINE: - key = new LineKey(legend.getLocationP(), - LineKey.TOP, LineKey.LEFT); - break; - case Legend.COLOR: - key = new ColorKey(legend.getLocationP(), - new Dimension2D(boundsP.width, boundsP.height), - ColorKey.TOP, ColorKey.LEFT); - break; - case Legend.VECTOR: - key = new VectorKey(legend.getLocationP(), - VectorKey.TOP, VectorKey.LEFT); - break; - case Legend.POINT: - key = new PointCollectionKey(legend.getLocationP(), - PointCollectionKey.TOP, PointCollectionKey.LEFT); - break; - } - key.setId(legend.getId()); - legendLayer_.addChild(key); - legend.setInstantiated(true); - } else { - key = (DataKey)child; - key.setLocationP(legend.getLocationP()); -// key.setBoundsP(legend.getBoundsP()); - } - if(legend.isColor()) { - ColorKey ckey = (ColorKey)key; - ckey.setSizeP(new Dimension2D(boundsP.width, boundsP.height)); - Ruler scale = ckey.getRuler(); - scale.setLabelColor(legend.getScaleColor()); - scale.setLineColor(legend.getScaleColor()); - scale.setLabelFont(legend.getScaleLabelFont()); - scale.setLabelHeightP(legend.getScaleLabelHeightP()); - scale.setLabelInterval(legend.getScaleLabelInterval()); - scale.setNumberSmallTics(legend.getScaleNumberSmallTics()); - scale.setLargeTicHeightP(legend.getScaleLargeTicHeightP()); - scale.setSmallTicHeightP(legend.getScaleSmallTicHeightP()); - scale.setSignificantDigits(legend.getScaleSignificantDigits()); - scale.setLabelFormat(legend.getScaleLabelFormat()); - scale.setVisible(legend.isScaleVisible()); - if(boundsP.width >= boundsP.height) { - ckey.setOrientation(ColorKey.HORIZONTAL); - } else { - ckey.setOrientation(ColorKey.VERTICAL); - } - } - key.setBorderStyle(legend.getBorderStyle()); - key.setColumns(legend.getColumns()); - key.setLineLengthP(legend.getLineLength()); - key.setVisible(legend.isVisible()); - } - } - - private void updateDataGroups() { - float dpi = pHolder_.getPanelModel().getDpi(); - setBounds(pHolder_.getBounds()); - double width = getBounds().width/dpi; - double height = getBounds().height/dpi; - Dimension2D psize = new Dimension2D(width, height); - - Iterator dgIter = pHolder_.dataGroupIterator(); - // remove delete DataGroups from panel/pane - Component[] comps = getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - Layer ly = (Layer)comps[i]; - if(ly != labelLayer_ && ly != legendLayer_) { - if(!pHolder_.hasDataGroup(ly.getId())) { - this.remove(ly); - } - } - } - } - // create/update DataGroup layers - while(dgIter.hasNext()) { - DataGroup ag = (DataGroup)dgIter.next(); - // find DataGroupLayer - DataGroupLayer dgl = findDataGroupLayer(ag.getId()); - if(dgl == null) { - dgl = new DataGroupLayer(this, ag); - add(dgl); - dgl.setSizeP(psize); - ag.setInstantiated(true); - dataGroupLayerList_.put(dgl.getId(), dgl); - } else { - dgl.update(); - } - } - } - - /** - * Find object associated with a MOUSE_DOWN event. The getObjectAt method - * scans through all the objects associated with the Panel to find one - * whose bounding box contains the mouse location. - * - * This method should not be called by a user. - * - * @param x mouse coordinate - * @param y mouse coordinate - * @param check if true requires that object isSelectable - * @return object at location - **/ - public Object getObjectAt(int x, int y, boolean check) { - Object obj = null; - - obj = labelLayer_.getObjectAt(x, y, check); - if(obj != null) return obj; - obj = legendLayer_.getObjectAt(x, y, check); - if(obj != null) return obj; - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - obj = ((DataGroupLayer)iter.next()).getObjectAt(x, y, check); - if(obj != null) return obj; - } - return obj; - } - - /** - * Zoom DataGroupLayers in Panel. - * Zoom to Rectangle if zoom operation started within bounds. - * @param start start point - * @param rect zoom rectangle - */ - void zoomTo(Point start, Rectangle rect) { - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - ((DataGroupLayer)iter.next()).zoomTo(start, rect); - } - } - - /** - * Reset the zoom for DataGroupLayers in this Panel - * if it contains the point. - * @param x x device coordinate - * @param y y device coordinate - */ - void resetZoom(int x, int y) { - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - ((DataGroupLayer)iter.next()).resetZoom(x, y); - } - } - - /** - * Reset the zoom for all DataGroupLayers in this Panel. - */ - public void resetZoom() { - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - ((DataGroupLayer)iter.next()).resetZoom(); - } - } - /** - * Set clipping for DataGroupLayers in this Panel. - * @param clip if true clip data to bounds. - */ - public void setClipping(boolean clip) { - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - ((DataGroupLayer)iter.next()).setClipping(clip); - } - } - - /** - * Does this Panel contain this Layer? - * @param id layer identification - * @return true, if Layer is in Panel - */ - public boolean hasLayer(String id) { - if(id.equals(labelLayer_.getId())) return true; - if(id.equals(legendLayer_.getId())) return true; - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - if(id.equals(((DataGroupLayer)iter.next()).getId())) return true; - } - return false; - } - - /** - * Get Layer from this Panel. Returns null - * if Layer is not found. - * @param id Layer identifier - * @return Layer - */ - public Layer getLayer(String id) { - if(id.equals(labelLayer_.getId())) return labelLayer_; - if(id.equals(legendLayer_.getId())) return legendLayer_; - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - DataGroupLayer dgl = (DataGroupLayer)iter.next(); - if(id.equals(dgl.getId())) return dgl; - } - return null; - } - - /** - * Checks to see if a data id matches that data attached to the - * Graph. - * @param id data identifier - * @return true if data is in Panel - */ - public boolean isDataInPanel(String id) { - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - DataGroupLayer dgl = (DataGroupLayer)iter.next(); - if(dgl.isDataInLayer(id)) return true; - } - return false; - } - - /** - * Get Layer from this Panel. Returns null - * if Layer is not found. - * @param id SGTData identifier - * @return Layer - */ - public Layer getLayerFromDataId(String id) { - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - DataGroupLayer dgl = (DataGroupLayer)iter.next(); - if(dgl.isDataInLayer(id)) return dgl; - } - return null; - } - - /** - * Find objects associated with a MOUSE_DOWN event. The getObjecstAt method - * scans through all the objects associated with the Panel to find those - * whose bounding box contains the mouse location. - * - * This method should not be called by a user. - * - * @param x mouse coordinate - * @param y mouse coordinate - * @param check if selectable - * @return object array - */ - public Object[] getObjectsAt(int x, int y, boolean check) { - Object[] obj = null; - Vector obList = new Vector(); - - obj = labelLayer_.getObjectsAt(x, y, check); - if(obj != null) { - for(int i=0; i < obj.length; i++) { - obList.addElement(obj[i]); - } - } - obj = legendLayer_.getObjectsAt(x, y, check); - if(obj != null) { - for(int i=0; i < obj.length; i++) { - obList.addElement(obj[i]); - } - } - Iterator iter = dataGroupLayerList_.values().iterator(); - while(iter.hasNext()) { - obj = ((DataGroupLayer)iter.next()).getObjectsAt(x, y, check); - if(obj != null) { - for(int i=0; i < obj.length; i++) { - obList.addElement(obj[i]); - } - } - } - - return obList.toArray(); - } - - /** - * Find DataGroupLayer in Panel. - * @param id DataGroupLayer identifier - * @return DataGroupLayer - */ - public DataGroupLayer findDataGroupLayer(String id) { - return (DataGroupLayer)dataGroupLayerList_.get(id); - } - - /** - * Get the JPane the Panel is associated - * with. - * - * @return Refence to the Pane - **/ - public JPane getPane() { - return pane_; - } - - /** - * Set the Pane the Panel is associated with. - * This method is called by Pane when the - * Pane.add method is exectued. - * - * @param pane The Pane - **/ - public void setPane(AbstractPane pane) { - pane_ = (JPane)pane; - update(); - } - - public void draw(Graphics g) throws PaneNotFoundException { - if(!pHolder_.isUsePageBackground()) { - Color saved = g.getColor(); - Rectangle r = pHolder_.getBounds(); - g.setColor(pHolder_.getBackground()); - g.fillRect(r.x, r.y, r.width, r.height); - g.setColor(saved); - } - Component[] comps = this.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof LayerControl) { - ((LayerControl)comps[i]).draw(g); - } - } - } - - public void drawDraggableItems(Graphics g) throws PaneNotFoundException { - Component[] comps = this.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof LayerControl) { - ((LayerControl)comps[i]).drawDraggableItems(g); - } - } - } - - /** - * Add data to this Panel and DataGroup. legend can - * be null. - * @param data SGTData to be added - * @param attr Attribute - * @param dataGroup DataGroup to add data to - * @param legend Lenged for data - * @throws DataTargetMismatchException - */ - public void addData(SGTData data, Attribute attr, - DataGroup dataGroup, Legend legend) - throws DataTargetMismatchException { - DataGroupLayer agLayer = findDataGroupLayer(dataGroup.getId()); - DataKey key = null; - if(legend != null) key = (DataKey)legendLayer_.findChild(legend.getId()); - - agLayer.addData(data, attr, key); - } - - /** - * Get the identifier for the Panel - * @return identifier/name - */ - public String getId() { - return getName(); - } - - /** - * Get a String representation of the - * Layer. - * - * @return String representation - */ - public String toString() { - String name = getClass().getName(); - return name.substring(name.lastIndexOf(".")+1) + ": " + pHolder_.getId(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolder.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolder.java deleted file mode 100755 index 8c877915..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolder.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * $Id: PanelHolder.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - - -import java.awt.Rectangle; -import java.awt.Color; -import javax.swing.event.*; -import javax.swing.border.Border; -import javax.swing.border.LineBorder; -import java.util.*; -import java.io.*; -import java.beans.*; - -/** - * Object to hold all the objects necessary to describe a Panel. - * Associated objects include Label, DataGroup, and - * Legend. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - * @see Label - * @see Panel - * @see PanelModel PanelModel for UML diagram - * @see DataGroup - * @see Legend - **/ -public class PanelHolder implements ChangeListener, Serializable { - private String id = ""; - private Rectangle bounds = new Rectangle(0, 0, 100, 50); - /** @link aggregation - * @supplierCardinality * - * @label labels */ - /*#Label lnkLabel; */ - private Map labels_ = new HashMap(5); - /** @link aggregation - * @supplierCardinality 1..* - * @label dataGroups */ - /*#DataGroup lnkDataGroup; */ - private Map dataGroups_ = new HashMap(2); - /** @link aggregation - * @supplierCardinality * - * @label legends */ - /*#Legend lnkLegend; */ - private Map legends_ = new HashMap(1); - - /** - * @label pModel - */ - transient private PanelModel pModel_ = null; - transient private ChangeEvent changeEvent_ = new ChangeEvent(this); - transient private Vector changeListeners; - private boolean visible = true; - transient private boolean instantiated = false; - private Border border = new LineBorder(Color.gray, 2); - private Color background = Color.white; - private boolean usePageBackground = true; - - static { - try { - BeanInfo info = Introspector.getBeanInfo(PanelHolder.class); - PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); - for(int i=0; i < descriptors.length; i++) { - PropertyDescriptor pd = descriptors[i]; - if(pd.getName().equals("instantiated")) { - pd.setValue("transient", Boolean.TRUE); - } else if(pd.getName().equals("panelModel")) { - pd.setValue("transient", Boolean.TRUE); - } - } - } catch (IntrospectionException ie) { - ie.printStackTrace(); - } - } - /** - * Default constructor. Sets PanelHolder identifier and - * PanelModel parent to null. - */ - public PanelHolder() { - this(null, null); - } - /** - * PanelHolder constructor. - * @param id PanelHolder identifier - * @param pModel PanelModel parent - */ - public PanelHolder(String id, PanelModel pModel) { - this.id = id; - pModel_ = pModel; - } - /** - * PanelHolder constructor. This constructor has arguments to - * pass Maps of Label, DataGroup, and - * Legend objects. The Map key is the objects identifier. - * @param id PanelHolder identifier - * @param pModel PanelModel parent - * @param bounds bounds - * @param labels Map containing Labels - * @param dataGroups Map containing DataGroups - * @param legends Map contiaining Legends - */ - public PanelHolder(String id, PanelModel pModel, - Rectangle bounds, - Map labels, - Map dataGroups, Map legends) { - this.id = id; - pModel_ = pModel; - this.bounds = bounds; - if(labels != null) { - labels_ = new HashMap(labels); - } - if(dataGroups != null) { - dataGroups_ = new HashMap(dataGroups); - } - if(legends != null) { - legends_ = new HashMap(legends); - } - } - /** - * Set the PanelModel parent. - * @param pModel PanelModel - */ - public void setPanelModel(PanelModel pModel) { - if(pModel_ != null) removeChangeListener(pModel_); - pModel_ = pModel; - addChangeListener(pModel_); - } - /** - * Get the PanelModel. - * @return PanelModel - */ - public PanelModel getPanelModel() { - return pModel_; - } - /** - * Add Label to the PanelHolder. - * @param label Label - */ - public void addLabel(Label label) { - label.addChangeListener(this); - label.setPanelHolder(this); - labels_.put(label.getId(), label); - fireStateChanged(); - } - /** - * Remove Label from the PanelHolder. - * @param label Label - */ - public void removeLabel(Label label) { - label.removeAllChangeListeners(); - labels_.remove(label.getId()); - fireStateChanged(); - } - /** - * Add DataGroup to the PanelHolder. - * @param dataGroup DataGroup - */ - public void addDataGroup(DataGroup dataGroup) { - dataGroup.addChangeListener(this); - dataGroups_.put(dataGroup.getId(), dataGroup); - fireStateChanged(); - } - /** - * Remove DataGroup from the PanelHolder. - * @param dataGroup DataGroup - */ - public void removeDataGroup(DataGroup dataGroup) { - dataGroup.removeAllChangeListeners(); - dataGroup.getXAxisHolder().removeAllChangeListeners(); - dataGroup.getYAxisHolder().removeAllChangeListeners(); - dataGroups_.remove(dataGroup.getId()); - fireStateChanged(); - } - /** - * Add Legend to the PanelHolder. - * @param legend Legend - */ - public void addLegend(Legend legend) { - legend.addChangeListener(this); - legend.setPanelHolder(this); - legends_.put(legend.getId(), legend); - fireStateChanged(); - } - /** - * Remove Legend from the PanelHolder. - * @param legend Legend - */ - public void removeLegend(Legend legend) { - legend.removeAllChangeListeners(); - legends_.remove(legend.getId()); - fireStateChanged(); - } - /** - * Set PanelHolder identifier. - * @param id identifier - */ - public void setId(String id) { - String old = this.id; - this.id = id; - if(old == null || !old.equals(this.id)) fireStateChanged(); - } - /** - * Get PanelHolder identifier - * @return identifier - */ - public String getId() { - return id; - } - /** - * Get number of Label objects in Map. - * @return number of Labels - */ - public int getLabelSize() { - return labels_.size(); - } - /** - * Get number of DataGroup objects in Map. - * @return number of DataGroups - */ - public int getDataGroupSize() { - return dataGroups_.size(); - } - /** - * Get number of Legend objects in Map. - * @return number of Legends - */ - public int getLegendSize() { - return legends_.size(); - } - /** - * Get an Iterator of Label objects. - * @return Iterator - */ - public Iterator labelIterator() { - return labels_.values().iterator(); - } - /** - * Get an Iterator of DataGroup objects. - * @return Iterator - */ - public Iterator dataGroupIterator() { - return dataGroups_.values().iterator(); - } - /** - * Get an Iterator of Legend objects. - * @return Iterator - */ - public Iterator legendIterator() { - return legends_.values().iterator(); - } - /** - * Set bounds of Panel. - * @param bounds bounds - */ - public void setBounds(Rectangle bounds) { - Rectangle old = this.bounds; - this.bounds = bounds; - fireStateChanged(); - } - /** - * Get bounds of Panel. - * @return bounds - */ - public Rectangle getBounds() { - return bounds; - /** @todo bounds isn't cloned should be see note */ -// return (Rectangle)bounds.clone(); // the clone didn't work with XMLEncoder for some reason - } - /** - * Remove all ChangeListeners. - */ - public void removeAllChangeListeners() { - changeListeners = null; - } - /** - * ChangeListner callback. - * @param e ChangeEvent - */ - public void stateChanged(ChangeEvent e) { - if (changeListeners != null) { - Vector listeners = changeListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - ((ChangeListener) listeners.elementAt(i)).stateChanged(e); - } - } - } - /** - * Remove changelistener. - * @param l changelistener - */ - public synchronized void removeChangeListener(ChangeListener l) { - if (changeListeners != null && changeListeners.contains(l)) { - Vector v = (Vector) changeListeners.clone(); - v.removeElement(l); - changeListeners = v; - } - } - /** - * Add changelistener - * @param l changelistener - */ - public synchronized void addChangeListener(ChangeListener l) { - Vector v = changeListeners == null ? new Vector(2) : (Vector) changeListeners.clone(); - if (!v.contains(l)) { - v.addElement(l); - changeListeners = v; - } - } - /** - * Remove all ChangeListeners that implement the - * DesignListener interface. - * - * @see DesignListener - */ - public synchronized void removeDesignChangeListeners() { - if(changeListeners != null) { - Vector v = (Vector) changeListeners.clone(); - Iterator iter = v.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof DesignListener) changeListeners.removeElement(obj); - } - } - } - - protected void fireStateChanged() { - if (changeListeners != null) { - Vector listeners = changeListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - ((ChangeListener) listeners.elementAt(i)).stateChanged(changeEvent_); - } - } - } - /** - * Set Panel visible. - * @param visible true if visible - */ - public void setVisible(boolean visible) { - boolean saved = this.visible; - this.visible = visible; - if(saved != this.visible) fireStateChanged(); - } - /** - * Is Panel visible? - * @return true, if Panel is visible - */ - public boolean isVisible() { - return visible; - } - /** - * Set instantiated. Once associated Panel object has been created - * this property is set true. Used internally. - * @param instantiated true if instantiated - */ - public void setInstantiated(boolean instantiated) { - this.instantiated = instantiated; - } - /** - * Is panel instantiated? - * @return true, if Panel instantiated - */ - public boolean isInstantiated() { - return instantiated; - } - /** - * Find a DataGroup by identifier. - * @param id identifier - * @return DataGroup - */ - public DataGroup findDataGroup(String id) { - return (DataGroup)dataGroups_.get(id); - } - /** - * Find Label by identifier. - * @param id identifier - * @return Label - */ - public Label findLabel(String id) { - return (Label)labels_.get(id); - } - /** - * Find Legend by identifier. - * @param id identifier - * @return Legend - */ - public Legend findLegend(String id) { - return (Legend)legends_.get(id); - } - /** - * Does PanelHolder contain DataGroup? - * @param id DataGroup identifier - * @return true, if DataGroup exists - */ - public boolean hasDataGroup(String id) { - return dataGroups_.containsKey(id); - } - /** - * Does PanelHolder contain Label? - * @param id Label identifier - * @return Label - */ - public boolean hasLabel(String id) { - return labels_.containsKey(id); - } - /** - * Does PanelHolder contain Legend? - * @param id Legend identifier - * @return Legend - */ - public boolean hasLegend(String id) { - return legends_.containsKey(id); - } - /** - * Return Border for Panel. - * @return Border - */ - public Border getBorder() { - return border; - } - /** - * Set Border for Panel. Default = LineBorder(gray, 2) - * @param border Border - */ - public void setBorder(Border border) { - Border saved = this.border; - this.border = border; - if(saved == null || !saved.equals(this.border)) fireStateChanged(); - } - /** - * Get Map of Labels. - * @return Map - */ - public Map getLabels() { - return labels_; - } - /** - * Set Map of Labels. Key in Map contains - * Label identifier. - * @param labels Label Map - */ - public void setLabels(Map labels) { - labels_ = labels; - Iterator iter = labelIterator(); - while(iter.hasNext()) { - ((Label)iter.next()).addChangeListener(this); - } - fireStateChanged(); - } - /** - * Get Map containing Legends. - * @return Map - */ - public Map getLegends() { - return legends_; - } - /** - * Set Map of Legends. Key in Map contains - * Legend identifier. - * @param legends Legend Map - */ - public void setLegends(Map legends) { - legends_ = legends; - Iterator iter = legendIterator(); - while(iter.hasNext()) { - ((Legend)iter.next()).addChangeListener(this); - } - fireStateChanged(); - } - /** - * Get Map containing DataGroups. - * @return Map - */ - public Map getDataGroups() { - return dataGroups_; - } - /** - * Set Map of DataGroups. Key in Map contains - * DataGroup identifier. - * @param dataGroups DataGroup Map - */ - public void setDataGroups(Map dataGroups) { - dataGroups_ = dataGroups; - Iterator iter = dataGroupIterator(); - while(iter.hasNext()) { - ((DataGroup)iter.next()).addChangeListener(this); - } - fireStateChanged(); - } - /** - * Get background color. Will use the page background if usePageBackground property - * is true. - * @return color - */ - public Color getBackground() { - return background; - } - /** - * Set the Panel background color. - * @param background color - */ - public void setBackground(Color background) { - Color saved = this.background; - this.background = background; - if(!saved.equals(this.background)) fireStateChanged(); - } - /** - * Use the page background color? - * @return true if using page background color - */ - public boolean isUsePageBackground() { - return usePageBackground; - } - /** - * Set the Panel to use the Page background color. - * @param pageBackground true to use page background color - */ - public void setUsePageBackground(boolean pageBackground) { - boolean saved = this.usePageBackground; - this.usePageBackground = pageBackground; - if(saved != this.usePageBackground) fireStateChanged(); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolderDragBox.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolderDragBox.java deleted file mode 100755 index 6849dea2..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolderDragBox.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * $Id: PanelHolderDragBox.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Point; -import java.awt.Color; -import java.awt.Insets; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import gov.noaa.pmel.sgt.SGLabel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -class PanelHolderDragBox extends DragBox implements ChangeListener { - private List dragBox_ = new Vector(); - private boolean ignoreStateChange_ = false; - - public PanelHolderDragBox(PanelHolder ph) { - super(ph); -// ph.setPanelDragBox(this); - ignoreStateChange_ = true; - pHolder_.addChangeListener(this); - Iterator iter = pHolder_.dataGroupIterator(); - while(iter.hasNext()) { - DataGroup dg = (DataGroup)iter.next(); - DataGroupDragBox agdb = new DataGroupDragBox(dg, pHolder_); - AxisHolderDragBox xAxdb = new AxisHolderDragBox(dg.getXAxisHolder(), dg, pHolder_); - AxisHolderDragBox yAxdb = new AxisHolderDragBox(dg.getYAxisHolder(), dg, pHolder_); - dragBox_.add(xAxdb); - dragBox_.add(yAxdb); - dragBox_.add(agdb); - } - iter = pHolder_.labelIterator(); - while(iter.hasNext()) { - LabelDragBox ldb = new LabelDragBox((Label)iter.next(), pHolder_); - dragBox_.add(ldb); - } - iter = pHolder_.legendIterator(); - while(iter.hasNext()) { - LegendDragBox lgdb = new LegendDragBox((Legend)iter.next(), pHolder_); - dragBox_.add(lgdb); - } - - for(int i=0; i < handles_.length; i++) { - handles_[i] = new Rectangle(0,0,0,0); - } - ignoreStateChange_ = false; - computeHandles(); - } - - public PanelHolder getPanelHolder() { - return pHolder_; - } - - public DragBox[] getDragBoxArray() { - DragBox[] dba = new DragBox[1]; - return (DragBox[])dragBox_.toArray(dba); - } - - public Iterator getDragBoxIterator() { - return dragBox_.iterator(); - } - - public void setSelected(boolean sel) { - super.setSelected(sel); - if(!selected_) { - Iterator iter = dragBox_.iterator(); - while(iter.hasNext()) { - ((DragBox)iter.next()).setSelected(sel); - } - } - } - - public void update(String message) { -// if(Page.DEBUG) System.out.println("PanelDragBox.update(" + message + ")"); - computeHandles(); - Iterator iter = dragBox_.iterator(); - while(iter.hasNext()) { - ((DragBox)iter.next()).update(message); - } - } - - public void draw(Graphics g) { - Color saved = g.getColor(); - Rectangle bounds = pHolder_.getBounds(); - if(!pHolder_.isUsePageBackground()) { - g.setColor(pHolder_.getBackground()); - g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); - } - g.setColor(Color.darkGray); - g.drawString(pHolder_.getId(), bounds.x + 10, bounds.y + 12); - g.drawString("["+bounds.width+"x"+bounds.height+"]", - bounds.x + 10, bounds.y + 22); - g.setColor(color_); - if(pHolder_.isVisible()) g.drawRect(bounds.x, bounds.y, bounds.width-1, bounds.height-1); - if(selected_) { - for(int i=0; i < handles_.length; i++) { - Rectangle r = handles_[i]; - g.fillRect(r.x, r.y, r.width-1, r.height-1); - } - } - - if(pHolder_.isVisible()) { - Iterator iter = dragBox_.iterator(); - while(iter.hasNext()) { - ((DragBox)iter.next()).draw(g); - } - } - - g.setColor(saved); - } - - public String getId() { - return pHolder_.getId(); - } - - public void setId(String id) { - pHolder_.setId(id); - } - - public void setBounds(Rectangle bounds) { - ignoreStateChange_ = true; - pHolder_.setBounds(bounds); - update("PanelDragBox.setBounds()"); - ignoreStateChange_ = false; - } - - public Rectangle getBounds() { - return pHolder_.getBounds(); - } - - public void setLocation(Point pt) { - setLocation(pt.x, pt.y); - } - - public void setLocation(int x, int y) { - Rectangle bounds = pHolder_.getBounds(); - bounds.x = x; - bounds.y = y; - ignoreStateChange_ = true; - pHolder_.setBounds(bounds); - update("PanelDragBox.setLocation()"); - ignoreStateChange_ = false; - } - - public Point getLocation() { - Rectangle bounds = pHolder_.getBounds(); - return new Point(bounds.x, bounds.y); - } - - public void addDragBox(DataGroup ag) { - DataGroupDragBox agdb = new DataGroupDragBox(ag, pHolder_); - AxisHolderDragBox xAxdb = new AxisHolderDragBox(ag.getXAxisHolder(), ag, pHolder_); - AxisHolderDragBox yAxdb = new AxisHolderDragBox(ag.getYAxisHolder(), ag, pHolder_); - agdb.setAxisHolderDB(xAxdb, yAxdb); - dragBox_.add(xAxdb); - dragBox_.add(yAxdb); - dragBox_.add(agdb); - } - - public void addDragBox(Legend legend) { - LegendDragBox ldb = new LegendDragBox(legend, pHolder_); - dragBox_.add(ldb); - } - - public void addDragBox(Label label) { - LabelDragBox lbdb = new LabelDragBox(label, pHolder_); - dragBox_.add(lbdb); - } - - public void removeDragBox(DataGroupDragBox ag) { - dragBox_.remove(ag.getXAxisHolderDB()); - dragBox_.remove(ag.getYAxisHolderDB()); - dragBox_.remove(ag); - update("PanelDragBox.removeDragBox(DataGroupDragBox)"); - } - - public void removeDragBox(LegendDragBox legend) { - dragBox_.remove(legend); - update("PanelDragBox.removeDragBox(LegendDragBox)"); - } - - public void removeDragBox(LabelDragBox label) { - dragBox_.remove(label); - update("PanelDragBox.removeDragBox(LabelDragBox)"); - } - - public void stateChanged(ChangeEvent e) { - if(ignoreStateChange_) return; - update("PanelDragBox.stateChanged"); -/* System.out.println("PanelDragBox.stateChanged(" + - e.getSource().getClass().getName() + ")"); */ - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolderPropertyPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolderPropertyPanel.java deleted file mode 100755 index c48156ac..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelHolderPropertyPanel.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * $Id: PanelHolderPropertyPanel.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import javax.swing.*; -import javax.swing.border.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; - -import gov.noaa.pmel.sgt.swing.prop.ColorDialog; -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -class PanelHolderPropertyPanel extends PropertyPanel implements ActionListener, ChangeListener, FocusListener { - private boolean expert_ = false; - private PanelHolder pHolder_ = null; - private String[] pNames_ = {"Background", "Border", "Bounds", "Data Groups", - "Id", "Labels", "Legends", "Page Background", "Visible"}; - private JComponent[] comps_ = new JComponent[pNames_.length]; - - public PanelHolderPropertyPanel(PanelHolder ph, boolean expert) { - super(); - pHolder_ = ph; - pHolder_.addChangeListener(this); - expert_ = expert; - create(); - } - - public void setPanelHolder(PanelHolder ph, boolean expert) { - if(pHolder_ != null) pHolder_.removeChangeListener(this); - pHolder_ = ph; - pHolder_.addChangeListener(this); - expert_ = expert; - reset(); - } - - void create() { - int i = -1; - comps_[++i] = createColor(pHolder_.getBackground(), pNames_[i], this); - comps_[++i] = createBorder(pHolder_.getBorder(), pNames_[i], this); - Rectangle b = pHolder_.getBounds(); - comps_[++i] = createLabel(b.x + ", " + b.y + ", " + b.width + ", " + b.height); - comps_[++i] = createLabel(pHolder_.getDataGroupSize()); - comps_[++i] = createTextField(pHolder_.getId(), pNames_[i], this, !pHolder_.isInstantiated()); - comps_[++i] = createLabel(pHolder_.getLabelSize()); - comps_[++i] = createLabel(pHolder_.getLegendSize()); - comps_[++i] = createCheckBox(pHolder_.isUsePageBackground(), pNames_[i], this); - comps_[++i] = createCheckBox(pHolder_.isVisible(), pNames_[i], this); - for(i=0; i < comps_.length; i++) { - addProperty(i+1, pNames_[i], comps_[i], false); - } - addProperty(comps_.length + 1, " ", new JLabel(" "), true); - } - - void resetFields() { - for(int i=0; i < comps_.length; i++) { - if(comps_[i] instanceof JTextField) { - ((JTextField)comps_[i]).removeActionListener(this); - ((JTextField)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JCheckBox) { - ((JCheckBox)comps_[i]).removeActionListener(this); - ((JCheckBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JComboBox) { - ((JComboBox)comps_[i]).removeActionListener(this); - ((JComboBox)comps_[i]).removeFocusListener(this); - } else if(comps_[i] instanceof JButton) { - ((JButton)comps_[i]).removeActionListener(this); - ((JButton)comps_[i]).removeFocusListener(this); - } - } - } - - void update() { - int i = -1; - updateColor((JButton)comps_[++i], pHolder_.getBackground()); - updateBorder((JButton)comps_[++i], pHolder_.getBorder()); - Rectangle b = pHolder_.getBounds(); - ((JLabel)comps_[++i]).setText(b.x + ", " + b.y + ", " + b.width + ", " + b.height); - ((JLabel)comps_[++i]).setText(Integer.toString(pHolder_.getDataGroupSize())); - ((JTextField)comps_[++i]).setText(pHolder_.getId()); - ((JLabel)comps_[++i]).setText(Integer.toString(pHolder_.getLabelSize())); - ((JLabel)comps_[++i]).setText(Integer.toString(pHolder_.getLegendSize())); - ((JCheckBox)comps_[++i]).setSelected(pHolder_.isUsePageBackground()); - ((JCheckBox)comps_[++i]).setSelected(pHolder_.isVisible()); - } - - private void processEvent(Object obj, String command) { - if(command.equals("Border")) { - BorderDialog bd = new BorderDialog(null, "Select Border", true); - bd.setBorder(pHolder_.getBorder()); - bd.setVisible(true); - pHolder_.setBorder(bd.getBorder()); - } else if(command.equals("Id")) { - String oldId = pHolder_.getId(); - pHolder_.getPanelModel().getPanelList().remove(oldId); - pHolder_.setId(((JTextField)obj).getText()); - pHolder_.getPanelModel().getPanelList().put(pHolder_.getId(), pHolder_); - } else if(command.equals("Visible")) { - pHolder_.setVisible(((JCheckBox)obj).isSelected()); - } else if(command.equals("Background")) { - ColorDialog cd = new ColorDialog(getFrame(), "Select Axis Color", true); - cd.setColor(pHolder_.getBackground()); - cd.setVisible(true); - Color newcolor = cd.getColor(); - if(newcolor != null) { - pHolder_.setBackground(newcolor); - updateColor((JButton)obj, newcolor); - } - } else if(command.equals("Page Background")) { - pHolder_.setUsePageBackground(((JCheckBox)obj).isSelected()); - } - } - - public void actionPerformed(ActionEvent e) { - Object obj = e.getSource(); - String command = e.getActionCommand(); - processEvent(obj, command); - } - public void stateChanged(ChangeEvent e) { - update(); - } - public void focusGained(FocusEvent e) { - } - public void focusLost(FocusEvent e) { - Object obj = e.getSource(); - if(obj instanceof JTextField) { - JTextField tf = (JTextField)obj; - String name = tf.getName(); - processEvent(obj, name); - } - } - - private JButton createBorder (Border value, - String action, ActionListener listen) { - JButton jb = new JButton(getBorderDescription(value)); - jb.setActionCommand(action); - if(listen != null) jb.addActionListener(listen); - return jb; - } - - private void updateBorder(JButton comp, Border value) { - comp.setText(getBorderDescription(value)); - } - - private String getBorderDescription(Border border) { - String description = "None"; - if(border != null) { - if(border instanceof BevelBorder) { - description = "Beveled"; - } else if(border instanceof EtchedBorder) { - description = "Etched"; - } else if(border instanceof LineBorder) { - description = "Line"; - } else if(border instanceof TitledBorder) { - description = "Titled"; - } - } - return description; - } - - public void setExpert(boolean expert) { - expert_ = expert; - } - - public boolean isExpert() { - return expert_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModel.java deleted file mode 100755 index 2334c68c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModel.java +++ /dev/null @@ -1,602 +0,0 @@ -/* - * $Id: PanelModel.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.Rectangle; -import java.awt.Dimension; -import java.awt.Color; -import java.awt.Point; - -import java.util.List; -import java.util.Vector; -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; - -import java.beans.*; - -import gov.noaa.pmel.sgt.LayerChild; -import gov.noaa.pmel.sgt.AbstractPane; -import java.io.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; - -/** - * A model that supports the Panel structure of a Plot. - * Information includes the DataGroups and LayerChildren that - * are included in a Panel. A Panel consist of several - * Layers, at least one for each DataGroup. - *

- * The layout of the Panels will eventually be accomplished using the SpringLayout. - * This will provide a flexible and easy method to position the Panels - * in arbitrary positions. Currently the Panels are positioned in - * absolution location. - *

Some classes have been omitted for display purposes. - *

- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - * @stereotype bean - **/ -public class PanelModel implements Serializable, ChangeListener, ComponentListener, PropertyChangeListener{ - transient private PropertyChangeSupport support_ = new PropertyChangeSupport(this); - private Map panelList = new HashMap(4); - private float dpi = 72.0f; // pixel to user scale (dots per inch); - private Dimension pageSize = new Dimension(400, 300); - private Color pageBackgroundColor = Color.white; - private int printHAlign = AbstractPane.CENTER; - private int printVAlign = AbstractPane.TOP; - private int printMode = AbstractPane.DEFAULT_SCALE; - private Point printOrigin = new Point(0, 0); - private boolean printBorders = false; - private boolean printWhitePage = true; - transient private boolean batch = false; - transient private boolean modified = false; -// - transient private ChangeEvent changeEvent_ = new ChangeEvent(this); - transient private Vector changeListeners; - - /** - * @label page - */ - transient private Page page; - - /** @link aggregation - * @supplierCardinality 1..* - * @label panelList*/ - /*#PanelHolder lnkPanelHolder;*/ - - /** - * PanelModel constructor. - */ - public PanelModel() { - } - /** - * Create a new PanelModel from an object serialized using - * XMLEncoder. For example, - * - *

-   *   PanelModel pModel;
-   *   Page page = new Page();
-   *       try {
-   *    pModel = PanelModel.loadFromXML(new BufferedInputStream(
-   *                       new FileInputStream(outpath)));
-   *    page.setPanelModel(pModel);
-   *  } catch (FileNotFoundException fnfe) {
-   *    JOptionPane.showMessageDialog(this, "Error openning file",
-   *                                  "File Open Error", JOptionPane.ERROR_MESSAGE);
-   *  } catch (InvalidObjectException ioe) {
-   *    JOptionPane.showMessageDialog(this, "File does not contain a PanelModel",
-   *                                  "PanelModel Not Found",
-   *                                  JOptionPane.ERROR_MESSAGE);
-   *  }
-   *
-   * 
- * @param is InputStream - * @return PanelModel object - * @throws InvalidObjectException - * @see java.beans.XMLEncoder - */ - static public PanelModel loadFromXML(InputStream is) throws InvalidObjectException { - PanelModel pModel = null; - XMLDecoder xd = new XMLDecoder(is); - Object obj = xd.readObject(); - xd.close(); - if(obj instanceof PanelModel) { - pModel = (PanelModel)obj; - pModel.repair(); - } else { - throw new InvalidObjectException("XML file does not contain a PanelModel"); - } - return pModel; - } - /** - * Save PanelModel and its supporting classes as a XML stream using - * the XMLEncoder. - * @param os OutputStream - */ - public void saveToXML(OutputStream os) { - XMLEncoder xe = new XMLEncoder(os); - xe.writeObject(this); - xe.close(); - } - /** - * Create a new Panel and add to PanelModel. - * @param id Panel identifier - * @param bounds bounds of Panel - * @param labels Label Map - * @param dataGroups DataGroup Map - * @param legends Legend Map - */ - public void addPanel(String id, Rectangle bounds, Map labels, - Map dataGroups, Map legends) { - PanelHolder ph = new PanelHolder(id, this, bounds, labels, dataGroups, legends); - addPanel(ph); - } - /** - * Add a PanelHolder to PanelModel. - * @param ph PanelHolder - */ - public void addPanel(PanelHolder ph) { - int sze = panelList.size(); - ph.addChangeListener(this); - panelList.put(ph.getId(), ph); - firePropertyChange("panelList", sze, panelList.size()); - } - /** - * Remove Panel from PanelModel. - * @param ph PanelHolder - */ - public void removePanel(PanelHolder ph) { - int sze = panelList.size(); - ph.removeChangeListener(this); - panelList.remove(ph.getId()); - firePropertyChange("panelList", sze, panelList.size()); - } - /** - * Get Iterator of PanelHolder objects. - * @return Iterator - */ - public Iterator panelIterator() { - return panelList.values().iterator(); - } - /** - * Get number of PanelHolder objects in Map. - * @return count - */ - public int getPanelCount() { - return panelList.size(); - } - /** - * Does the PanelModel contain this PanelHolder? - * @param id PanelHolder identifier - * @return true, if PanelHolder exists. - */ - public boolean hasPanelHolder(String id) { - return findPanelHolder(id) != null; - } - /** - * Find the PanelHolder from its identifier. - * @param id PanelHolder identifier - * @return PanelHolder - */ - public PanelHolder findPanelHolder(String id) { - return (PanelHolder)panelList.get(id); - } - /** - * Add property change listener. - * @param l property change listener - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - support_.addPropertyChangeListener(l); - } - /** - * Listen for specific property change. - * @param name property name - * @param l property change listner - */ - public void addPropertyChangeListener(String name, PropertyChangeListener l) { - support_.addPropertyChangeListener(name, l); - } - /** - * Remove property change listener. - * @param l property change listener - */ - public void removePropertyChangeListener(PropertyChangeListener l) { - support_.removePropertyChangeListener(l); - } - /** - * Remove specific property change listener - * @param name property name - * @param l property change listener - */ - public void removePropertyChangeListener(String name, PropertyChangeListener l) { - support_.removePropertyChangeListener(name, l); - } - /** - * Get dots per inch value. - * @return dots per inch - */ - public float getDpi() { - return dpi; - } - - /** - * Set dots per inch. Fires property "dpi" when changed. - * @param dpi dots per inch - */ - public void setDpi(float dpi) { - float saved = this.dpi; - this.dpi = dpi; - if(saved != this.dpi) firePropertyChange("dpi", new Float(saved), new Float(this.dpi)); - } - /** - * ChangeListner callback. - * @param e ChangeEvent - */ - public void stateChanged(ChangeEvent e) { - Object source = e.getSource(); - firePropertyChange("panel", null, source); - } - - private void firePropertyChange(String name, Object oldValue, Object newValue) { - if(batch) { - modified = true; - } else { - support_.firePropertyChange(name, oldValue, newValue); - } - } - - private void firePropertyChange(String name, int oldValue, int newValue) { - if(batch) { - modified = true; - } else { - support_.firePropertyChange(name, oldValue, newValue); - } - } - /** - * Set batching for changes to PanelModel. Fires property "batch" - * when PanelModel has changed and batch is set to false. - * @param batch batch value - */ - public void setBatch(boolean batch) { - this.batch = batch; - if(!this.batch && modified) { - modified = false; - support_.firePropertyChange("batch", null, null); - } - } - /** - * Registers ChangeListeners and sets back references in PanelModel and - * its children. - */ - private void repair() { - // traverse PanelModel and create all event links - Iterator iter = panelIterator(); - while(iter.hasNext()) { - PanelHolder ph = (PanelHolder)iter.next(); - ph.removeAllChangeListeners(); - ph.addChangeListener(this); - ph.setPanelModel(this); - Iterator dgIter = ph.dataGroupIterator(); - while(dgIter.hasNext()) { - DataGroup dg = (DataGroup)dgIter.next(); - dg.removeAllChangeListeners(); - dg.addChangeListener(ph); - dg.setPanelHolder(ph); - dg.getXAxisHolder().removeAllChangeListeners(); - dg.getXAxisHolder().addChangeListener(dg); - dg.getXAxisHolder().setDataGroup(dg); - dg.getYAxisHolder().removeAllChangeListeners(); - dg.getYAxisHolder().addChangeListener(dg); - dg.getYAxisHolder().setDataGroup(dg); - } - Iterator lbIter = ph.labelIterator(); - while(lbIter.hasNext()) { - Label lb = (Label)lbIter.next(); - lb.removeAllChangeListeners(); - lb.addChangeListener(ph); - lb.setPanelHolder(ph); - } - Iterator lgIter = ph.legendIterator(); - while(lgIter.hasNext()) { - Legend lg = (Legend)lgIter.next(); - lg.removeAllChangeListeners(); - lg.addChangeListener(ph); - lg.setPanelHolder(ph); - } - } - } - /** - * Is batching turned on? - * @return true, if batch is on - */ - public boolean isBatch() { - return batch; - } - /** - * Set Page parent. Called from Page when added to - * Page object. - * @param page Page - */ - public void setPage(Page page) { - if(this.page != null) removePropertyChangeListener(this.page); - this.page = page; - addPropertyChangeListener(this.page); - page.addComponentListener(this); - page.addPropertyChangeListener(this); - pageSize = page.getSize(); - } - /** - * Get Page parent - * @return Page - */ - public Page getPage() { - return page; - } - /** - * Get Map containing PanelHolder objects. - * @return Map - */ - public Map getPanelList() { - return panelList; - } - /** - * Set PanelHolder Map. - * @param panelList Map - */ - public void setPanelList(Map panelList) { - if(Page.DEBUG) System.out.println("PanelModel.setPanelList(): size = " + panelList.size()); - this.panelList = panelList; - Iterator iter = panelIterator(); - while(iter.hasNext()) { - PanelHolder ph = (PanelHolder)iter.next(); - ph.addChangeListener(this); - } - firePropertyChange("panelList", 0, panelList.size()); // should this be fired? - } - /** - * Get Page size. - * @return Page dimensions - */ - public Dimension getPageSize() { - return pageSize; - } - /** - * Set Page size. - * @param pageSize Page dimension - */ - public void setPageSize(Dimension pageSize) { - Dimension saved = this.pageSize; - this.pageSize = pageSize; - if(!saved.equals(this.pageSize)) { - firePropertyChange("pageSize", saved, pageSize); - fireStateChanged(); - } - } - /** - * Listener to update Page size if it changes. - * @param e ComponentEvent - */ - public void componentResized(ComponentEvent e) { - pageSize = page.getSize(); - } - /** - * Unused. - */ - public void componentMoved(ComponentEvent e) { } - /** - * Unused. - */ - public void componentShown(ComponentEvent e) { } - /** - * Unused. - */ - public void componentHidden(ComponentEvent e) { } - /** - * Get the background color for Page. - * @return color - */ - public Color getPageBackgroundColor() { - return pageBackgroundColor; - } - /** - * Set Page background color. - * @param pageBackgroundColor background color - */ - public void setPageBackgroundColor(Color pageBackgroundColor) { - Color saved = this.pageBackgroundColor; - this.pageBackgroundColor = pageBackgroundColor; - if(!saved.equals(this.pageBackgroundColor)) { - firePropertyChange("pageBackgroundColor", saved, this.pageBackgroundColor); - fireStateChanged(); - } - } - /** - * Print borders? - * @return true, if borders will be printed - */ - public boolean isPrintBorders() { - return printBorders; - } - /** - * Print with white background? - * @return true, print on white background - */ - public boolean isPrintWhitePage() { - return printWhitePage; - } - /** - * Set the print borders property. Default = false. - * @param printBorders true to print borders - */ - public void setPrintBorders(boolean printBorders) { - boolean saved = this.printBorders; - this.printBorders = printBorders; - if(saved != this.printBorders) - firePropertyChange("printBorders", new Boolean(saved), - new Boolean(this.printBorders)); - } - /** - * Set the print on white background property. Default = true. - * @param printWhitePage true to use white for background color - */ - public void setPrintWhitePage(boolean printWhitePage) { - boolean saved = this.printWhitePage; - this.printWhitePage = printWhitePage; - if(saved != this.printWhitePage) - firePropertyChange("printWhitePage", new Boolean(saved), - new Boolean(this.printWhitePage)); - } - public void propertyChange(PropertyChangeEvent evt) { - if(Page.DEBUG) System.out.println("PanelModel.propertyChange("+evt.getPropertyName()+")"); - } - /** - * Remove changelistener. - * @param l changelistener - */ - public synchronized void removeChangeListener(ChangeListener l) { - if (changeListeners != null && changeListeners.contains(l)) { - Vector v = (Vector) changeListeners.clone(); - v.removeElement(l); - changeListeners = v; - } - } - /** - * Remove all ChangeListeners that implement the - * DesignListener interface. - * - * @see DesignListener - */ - public synchronized void removeDesignChangeListeners() { - if(changeListeners != null) { - Vector v = (Vector) changeListeners.clone(); - Iterator iter = v.iterator(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof DesignListener) changeListeners.removeElement(obj); - } - } - } - - /** - * Add changelistener - * @param l changelistener - */ - public synchronized void addChangeListener(ChangeListener l) { - Vector v = changeListeners == null ? new Vector(2) : (Vector) changeListeners.clone(); - if (!v.contains(l)) { - v.addElement(l); - changeListeners = v; - } - } - protected void fireStateChanged() { - if (changeListeners != null) { - Vector listeners = changeListeners; - int count = listeners.size(); - for (int i = 0; i < count; i++) { - ((ChangeListener) listeners.elementAt(i)).stateChanged(changeEvent_); - } - } - } - /** - * Get horizontal alignment for printing. - * @return horizontal alignment - */ - public int getPrintHAlign() { - return printHAlign; - } - /** - * Set horizontal alignment for printing. Legal values are AbstractPane.LEFT, - * AbstractPane.CENTER, AbstractPane.RIGHT, and AbstractPane.SPECIFIED_LOCATION. - * Default = AbstractPane.CENTER. - * @param pageHAlign horizontal alignment - * @see gov.noaa.pmel.sgt.AbstractPane#LEFT AbstractPane.LEFT - * @see gov.noaa.pmel.sgt.AbstractPane#CENTER AbstractPane.CENTER - * @see gov.noaa.pmel.sgt.AbstractPane#RIGHT AbstractPane.RIGHT - * @see gov.noaa.pmel.sgt.AbstractPane#SPECIFIED_LOCATION AbstractPane.SPECIFIED_LOCATION - */ - public void setPrintHAlign(int printHAlign) { - int saved = this.printHAlign; - this.printHAlign = printHAlign; - if(saved != this.printHAlign) - firePropertyChange("printHAlign", saved, this.printHAlign); - } - /** - * Set page origin for printing. Will be used if the horizontal or vertical alignment is - * AbstractPane.SPECIFIED_LOCATION. Default = (0,0). - * @param pageOrigin page origin - * @see gov.noaa.pmel.sgt.AbstractPane AbstractPane - */ - public void setPrintOrigin(Point printOrigin) { - Point saved = this.printOrigin; - this.printOrigin = printOrigin; - if(!saved.equals(this.printOrigin)) - firePropertyChange("printOrigin", saved, this.printOrigin); - } - /** - * Get page origin for printing. - * @return page origin. - */ - public Point getPrintOrigin() { - return printOrigin; - } - /** - * Get vertical alignment for printing. - * @return vertical alignment. - */ - public int getPrintVAlign() { - return printVAlign; - } - /** - * Set vertical alignment for printing. Legal values are AbstractPane.TOP, - * AbstractPane.MIDDLE, AbstractPane.BOTTOM, and AbstractPane.SPECIFIED_LOCATION. - * Default = AbstractPane.TOP; - * @param pageVAlign vertical alignment - * @see gov.noaa.pmel.sgt.AbstractPane#TOP AbstractPane.TOP - * @see gov.noaa.pmel.sgt.AbstractPane#MIDDLE AbstractPane.MIDDLE - * @see gov.noaa.pmel.sgt.AbstractPane#BOTTOM AbstractPane.BOTTOM - * @see gov.noaa.pmel.sgt.AbstractPane#SPECIFIED_LOCATION AbstractPane.SPECIFIED_LOCATION - */ - public void setPrintVAlign(int printVAlign) { - int saved = this.printVAlign; - this.printVAlign = printVAlign; - if(saved != this.printVAlign) - firePropertyChange("printVAlign", saved, this.printVAlign); - } - /** - * Get printing scale mode. - * @return scale mode - */ - public int getPrintScaleMode() { - return printMode; - } - /** - * Set printing scale mode. Legal values are AbstractPane.DEFAULT_SCALE, - * AbstractPane.TO_FIT, and AbstractPane.SHRINK_TO_FIT. Default = - * AbstractPane.DEFAULT_SCALE. - * @param mode scale mode - * @see gov.noaa.pmel.sgt.AbstractPane#DEFAULT_SCALE AbstractPane.DEFAULT_SCALE - * @see gov.noaa.pmel.sgt.AbstractPane#TO_FIT AbstractPane.TO_FIT - * @see gov.noaa.pmel.sgt.AbstractPane#SHRINK_TO_FIT AbstractPane.SHRINK_TO_FIT - */ - public void setPrintScaleMode(int mode) { - int saved = this.printMode; - this.printMode = mode; - if(saved != this.printMode) - firePropertyChange("printScaleMode", saved, this.printMode); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelBeanInfo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelBeanInfo.java deleted file mode 100755 index 1032251f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelBeanInfo.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * $Id: PanelModelBeanInfo.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.beans.*; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - */ -public class PanelModelBeanInfo extends SimpleBeanInfo { - private Class beanClass = PanelModel.class; - private Class customizerClass = PanelModelCustomizer.class; - private String iconColor16x16Filename = "PanelModelIcon16.gif"; - private String iconColor32x32Filename = "PanelModelIcon32.gif"; - private String iconMono16x16Filename; - private String iconMono32x32Filename; - - public PanelModelBeanInfo() { - } - - public BeanDescriptor getBeanDescriptor() { - return new BeanDescriptor(beanClass, customizerClass); - } - - public PropertyDescriptor[] getPropertyDescriptors() { - try { - PropertyDescriptor _batch = new PropertyDescriptor("batch", beanClass, null, null); - _batch.setValue("transient", Boolean.TRUE); - PropertyDescriptor _dpi = new PropertyDescriptor("dpi", beanClass, "getDpi", "setDpi"); - PropertyDescriptor _modified = new PropertyDescriptor("modified", beanClass, null, null); - _modified.setValue("transient", Boolean.TRUE); - PropertyDescriptor _page = new PropertyDescriptor("page", beanClass, "getPage", "setPage"); - _page.setValue("transient", Boolean.TRUE); - PropertyDescriptor _panelList = new PropertyDescriptor("panelList", beanClass, "getPanelList", "setPanelList"); - PropertyDescriptor _panelCount = new PropertyDescriptor("panelCount", beanClass, "getPanelCount", null); - PropertyDescriptor _pageSize = new PropertyDescriptor("pageSize", beanClass, "getPageSize", "setPageSize"); - PropertyDescriptor _pageBackgroundColor = - new PropertyDescriptor("pageBackgroundColor", beanClass, "getPageBackgroundColor", "setPageBackgroundColor"); - PropertyDescriptor _printWhitePage = - new PropertyDescriptor("printWhitePage", beanClass, "isPrintWhitePage", "setPrintWhitePage"); - PropertyDescriptor _printBorders = - new PropertyDescriptor("printBorders", beanClass, "isPrintBorders", "setPrintBorders"); - PropertyDescriptor _pageHAlign = - new PropertyDescriptor("printHAlign", beanClass, "getPrintHAlign", "setPrintHAlign"); - PropertyDescriptor _pageVAlign = - new PropertyDescriptor("printVAlign", beanClass, "getPrintVAlign", "setPrintVAlign"); - PropertyDescriptor _printMode = - new PropertyDescriptor("printScaleMode", beanClass, "getPrintScaleMode", "setPrintScaleMode"); - PropertyDescriptor _pageOrigin = - new PropertyDescriptor("printOrigin", beanClass, "getPrintOrigin", "setPrintOrigin"); - PropertyDescriptor[] pds = new PropertyDescriptor[] { - _batch, - _dpi, - _modified, - _page, - _pageBackgroundColor, - _pageSize, - _panelList, - _panelCount, - _printWhitePage, - _printBorders, - _pageHAlign, - _pageVAlign, - _printMode, - _pageOrigin}; - return pds; - } - catch(IntrospectionException ex) { - ex.printStackTrace(); - return null; - } - } - public java.awt.Image getIcon(int iconKind) { - switch (iconKind) { - case BeanInfo.ICON_COLOR_16x16: - return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null; - case BeanInfo.ICON_COLOR_32x32: - return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null; - case BeanInfo.ICON_MONO_16x16: - return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null; - case BeanInfo.ICON_MONO_32x32: - return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null; - } - return null; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelCustomizer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelCustomizer.java deleted file mode 100755 index c7aa1c0d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelCustomizer.java +++ /dev/null @@ -1,679 +0,0 @@ -/* - * $Id: PanelModelCustomizer.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.beans.Customizer; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.BufferedOutputStream; -import java.io.FileOutputStream; -import javax.swing.filechooser.FileFilter; -import java.awt.*; -import javax.swing.*; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; -import javax.swing.table.TableColumnModel; -import javax.swing.table.TableColumn; -import javax.swing.ListSelectionModel; -import javax.swing.border.*; -import java.util.Vector; -import java.util.Iterator; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.SimpleFileFilter; -import gov.noaa.pmel.swing.MRJUtil; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; -/** - * Used at design time to customize a PanelModel. This class is also - * used by PanelModelEditor for run-time changes to the PanelModel. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - * @see PanelModelEditor - * @see PanelModel - */ -public class PanelModelCustomizer extends JComponent implements Customizer, PropertyChangeListener { - /** - * @supplierCardinality 1 - */ - private PanelModel panelModel_ = null; - private JFileChooser fileChooser_ = null; - private BorderLayout borderLayout1 = new BorderLayout(); - private JPanel messagePanel = new JPanel(); - private JTextField message = new JTextField(); - private BorderLayout borderLayout2 = new BorderLayout(); - private JPanel mainPanel = new JPanel(); - private BorderLayout borderLayout3 = new BorderLayout(); - private JPanel layoutPanel = new JPanel(); - private BorderLayout borderLayout4 = new BorderLayout(); - private JPanel toolPanel = new JPanel(); - private JButton newPanelButton = new JButton(); - - /** - *@link aggregationByValue - * @associates <{PanelView}> - * @supplierCardinality * - */ - /* private Vector lnkPanelView; */ - private DesignPanel designPanel_ = new DesignPanel(); - private FlowLayout flowLayout1 = new FlowLayout(); - private JButton alignBottomButton = new JButton(); - private JButton alignTopButton = new JButton(); - private JButton alignLeftButton = new JButton(); - private JButton alignRightButton = new JButton(); - private JButton justVerticalButton = new JButton(); - private JButton justHorizontalButton = new JButton(); - private ImageIcon alignBottom_ = new ImageIcon(getClass().getResource("images/AlignBottom24.gif"),"Align Bottom"); - private ImageIcon alignTop_ = new ImageIcon(getClass().getResource("images/AlignTop24.gif"),"Align Top"); - private ImageIcon alignLeft_ = new ImageIcon(getClass().getResource("images/AlignLeft24.gif"),"Align Left"); - private ImageIcon alignRight_ = new ImageIcon(getClass().getResource("images/AlignRight24.gif"),"Align Right"); - private ImageIcon justifyVertical_ = new ImageIcon(getClass().getResource("images/AlignJustifyVertical24.gif"),"Justify Vertical"); - private ImageIcon justifyHorizontal_ = new ImageIcon(getClass().getResource("images/AlignJustifyHorizontal24.gif"),"Justify Horizontal"); - private ImageIcon newPanel_ = new ImageIcon(getClass().getResource("images/New24.gif"), "New Panel"); - private ImageIcon newDataGroup_ = new ImageIcon(getClass().getResource("images/NewDataGroup24.gif"), "New Data Group"); - private ImageIcon newLabel_ = new ImageIcon(getClass().getResource("images/NewLabel24.gif"), "New Label"); - private ImageIcon newLegend_ = new ImageIcon(getClass().getResource("images/NewLegend24.gif"), "New Legend"); - private ImageIcon removePanel_ = new ImageIcon(getClass().getResource("images/Remove24.gif"), "Remove Panel"); - private ImageIcon saveAsPanel_ = new ImageIcon(getClass().getResource("images/SaveAs24.gif"), "Save PanelModel"); - private ImageIcon openPanel_ = new ImageIcon(getClass().getResource("images/Open24.gif"), "Open PanelModel"); - private Component component2; - private Component component3; - private JButton removeButton = new JButton(); - private Component component1; - private JPanel propertyPanel = new JPanel(); - private JPanel leftPanel = new JPanel(); - private TitledBorder propertyBorder; - private JScrollPane jScrollPane1 = new JScrollPane(); - private BorderLayout borderLayout5 = new BorderLayout(); - private JButton newDataGroupButton = new JButton(); - private JButton newLabelButton = new JButton(); - private JButton newLegendButton = new JButton(); - private JScrollPane designScroller = new JScrollPane(); - - private PanelHolderPropertyPanel phPropertyPanel_ = null; - private LabelPropertyPanel labelPropertyPanel_ = null; - private LegendPropertyPanel legendPropertyPanel_ = null; - private DataGroupPropertyPanel agPropertyPanel_ = null; - private AxisHolderPropertyPanel ahPropertyPanel_ = null; - private PanelModelPropertyPanel pmPropertyPanel_ = null; - private PropertyPanel currentPropertyPanel_ = null; - - private JPanel grayPanel = new JPanel(); - private BorderLayout borderLayout6 = new BorderLayout(); - private BorderLayout borderLayout7 = new BorderLayout(); - private JPanel jPanel1 = new JPanel(); - private JCheckBox expertCB = new JCheckBox(); - private GridBagLayout gridBagLayout2 = new GridBagLayout(); - private JButton openPanelButton = new JButton(); - private JButton saveAsPanelButton = new JButton(); - private Component component5; - - /** - * PanelModelCustomizer constructor. - */ - public PanelModelCustomizer() { - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - designPanel_.addPropertyChangeListener(this); - setPanelButtons(0); - } - - /** - * Set a PanelModel to be customized. - * @param panelModel PanelModel - * @see PanelModel - */ - public void setObject(Object panelModel) { - panelModel_ = (PanelModel)panelModel; - designPanel_.setPanelModel(panelModel_); - pmPropertyPanel_ = new PanelModelPropertyPanel(panelModel_); - setDefaultPanel(); - if(Page.DEBUG) System.out.println("Customizer setObject()"); - } - - private void jbInit() throws Exception { - component2 = Box.createHorizontalStrut(8); - component3 = Box.createHorizontalStrut(8); - component1 = Box.createHorizontalStrut(8); - propertyBorder = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153),2),"Parameter"); - component5 = Box.createHorizontalStrut(8); - this.setLayout(borderLayout1); - message.setText("Important information will go here."); - messagePanel.setLayout(borderLayout2); - messagePanel.setBorder(BorderFactory.createLoweredBevelBorder()); - mainPanel.setLayout(borderLayout3); - layoutPanel.setLayout(borderLayout4); - leftPanel.setLayout(borderLayout7); - newPanelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - newPanelButton_actionPerformed(e); - } - }); - toolPanel.setLayout(flowLayout1); - toolPanel.setBorder(BorderFactory.createEtchedBorder()); - designPanel_.setLayout(null); - alignBottomButton.setToolTipText("Align Bottom"); - alignBottomButton.setIcon(alignBottom_); - alignBottomButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - alignBottomButton_actionPerformed(e); - } - }); - alignLeftButton.setToolTipText("Align Left"); - alignLeftButton.setIcon(alignLeft_); - alignLeftButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - alignLeftButton_actionPerformed(e); - } - }); - alignTopButton.setToolTipText("Align Top"); - alignTopButton.setIcon(alignTop_); - alignTopButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - alignTopButton_actionPerformed(e); - } - }); - alignRightButton.setToolTipText("Align Right"); - alignRightButton.setIcon(alignRight_); - alignRightButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - alignRightButton_actionPerformed(e); - } - }); - newPanelButton.setToolTipText("New Panel"); - newPanelButton.setIcon(newPanel_); - justVerticalButton.setToolTipText("Justify Vertically"); - justVerticalButton.setIcon(justifyVertical_); - justVerticalButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - justVerticalButton_actionPerformed(e); - } - }); - justHorizontalButton.setToolTipText("Justify Horizontally"); - justHorizontalButton.setIcon(justifyHorizontal_); - justHorizontalButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - justHorizontalButton_actionPerformed(e); - } - }); - removeButton.setToolTipText("Remove Panel"); - removeButton.setIcon(removePanel_); - removeButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - removeButton_actionPerformed(e); - } - }); - this.setPreferredSize(new Dimension(800, 600)); - propertyPanel.setBorder(propertyBorder); - propertyPanel.setMinimumSize(new Dimension(240, 10)); - propertyPanel.setPreferredSize(new Dimension(240, 10)); - propertyPanel.setLayout(borderLayout5); - propertyBorder.setTitle("Properties"); - newDataGroupButton.setToolTipText("New Data Group"); - newDataGroupButton.setIcon(newDataGroup_); - newDataGroupButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - newDataGroupButton_actionPerformed(e); - } - }); - newLabelButton.setToolTipText("New Label"); - newLabelButton.setIcon(newLabel_); - newLabelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - newLabelButton_actionPerformed(e); - } - }); - newLegendButton.setToolTipText("New Legend"); - newLegendButton.setIcon(newLegend_); - newLegendButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - newLegendButton_actionPerformed(e); - } - }); - grayPanel.setBackground(Color.lightGray); - grayPanel.setLayout(borderLayout6); - expertCB.setText("Expert"); - expertCB.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - expertCB_actionPerformed(e); - } - }); - jPanel1.setLayout(gridBagLayout2); - openPanelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - openPanelButton_actionPerformed(e); - } - }); - openPanelButton.setEnabled(false); - openPanelButton.setToolTipText("Open Panel"); - openPanelButton.setIcon(openPanel_); - saveAsPanelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - saveAsPanelButton_actionPerformed(e); - } - }); - saveAsPanelButton.setToolTipText("Save Panel"); - saveAsPanelButton.setIcon(saveAsPanel_); - this.add(messagePanel, BorderLayout.SOUTH); - messagePanel.add(message, BorderLayout.CENTER); - this.add(mainPanel, BorderLayout.CENTER); - mainPanel.add(layoutPanel, BorderLayout.CENTER); - toolPanel.add(openPanelButton, null); - toolPanel.add(saveAsPanelButton, null); - toolPanel.add(component5, null); - toolPanel.add(newPanelButton, null); - toolPanel.add(newDataGroupButton, null); - toolPanel.add(newLabelButton, null); - toolPanel.add(newLegendButton, null); - toolPanel.add(component3, null); - toolPanel.add(removeButton, null); - toolPanel.add(component1, null); - toolPanel.add(alignBottomButton, null); - toolPanel.add(alignTopButton, null); - toolPanel.add(alignLeftButton, null); - toolPanel.add(alignRightButton, null); - toolPanel.add(component2, null); - toolPanel.add(justVerticalButton, null); - toolPanel.add(justHorizontalButton, null); - layoutPanel.add(designScroller, BorderLayout.CENTER); - designScroller.getViewport().add(grayPanel, null); - grayPanel.add(designPanel_, BorderLayout.CENTER); - leftPanel.add(propertyPanel, BorderLayout.CENTER); - layoutPanel.add(leftPanel, BorderLayout.WEST); - propertyPanel.add(jScrollPane1, BorderLayout.CENTER); - leftPanel.add(jPanel1, BorderLayout.NORTH); - jPanel1.add(expertCB, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - layoutPanel.add(toolPanel, BorderLayout.NORTH); - - if(!MRJUtil.isAquaLookAndFeel()) { - alignBottomButton.setMargin(new Insets(0, 0, 0, 0)); - alignLeftButton.setMargin(new Insets(0, 0, 0, 0)); - alignTopButton.setMargin(new Insets(0, 0, 0, 0)); - alignRightButton.setMargin(new Insets(0, 0, 0, 0)); - newPanelButton.setMargin(new Insets(0, 0, 0, 0)); - justVerticalButton.setMargin(new Insets(0, 0, 0, 0)); - justHorizontalButton.setMargin(new Insets(0, 0, 0, 0)); - removeButton.setMargin(new Insets(0, 0, 0, 0)); - newDataGroupButton.setMargin(new Insets(0, 0, 0, 0)); - newLabelButton.setMargin(new Insets(0, 0, 0, 0)); - newLegendButton.setMargin(new Insets(0, 0, 0, 0)); - openPanelButton.setMargin(new Insets(0, 0, 0, 0)); - saveAsPanelButton.setMargin(new Insets(0,0,0,0)); - } - openPanelButton.setFocusable(false); - saveAsPanelButton.setFocusable(false); - } - - public Dimension getMinimumSize() { - return new Dimension(600, 400); - } - - public Dimension getMaximumSize() { - return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); - } - - public Dimension getPreferredSize() { - return new Dimension(800, 600); - } - - void newPanelButton_actionPerformed(ActionEvent e) { - PanelHolder ph = new PanelHolder("Panel" + panelModel_.getPanelCount(), - panelModel_, - new Rectangle(20, 20, 200, 300), - null, null, null); - PanelHolderDragBox pi = new PanelHolderDragBox(ph); - panelModel_.addPanel(ph); - designPanel_.addPanel(pi); - designPanel_.repaint(); - } - - void newDataGroupButton_actionPerformed(ActionEvent e) { - PanelHolder ph = designPanel_.getSelectedPanel(); - if(ph == null) return; - DataGroup ag = new DataGroup("DataGroup" + ph.getDataGroupSize(), ph); - designPanel_.addDataGroup(ag); - designPanel_.repaint(); - } - - void newLabelButton_actionPerformed(ActionEvent e) { - PanelHolder ph = designPanel_.getSelectedPanel(); - if(ph == null) return; - Label label = new Label("Label" + ph.getLabelSize(), - new Point2D.Double(1.5, 1.5), - 0.75, 0.25); - designPanel_.addLabel(label); - designPanel_.repaint(); - } - - void newLegendButton_actionPerformed(ActionEvent e) { - PanelHolder ph = designPanel_.getSelectedPanel(); - if(ph == null) return; - Legend legend = new Legend("Legend" + ph.getLegendSize(), - new Rectangle2D.Double(1.0, 1.0, 1.5, 0.25)); - designPanel_.addLegend(legend); - designPanel_.repaint(); - - } - - public void propertyChange(PropertyChangeEvent evt) { - String pName = evt.getPropertyName(); - Object val = evt.getNewValue(); - if(Page.DEBUG) System.out.println("PanelModelCustomizer.propertyChange: " + pName + ", " + evt.getNewValue()); - setPanelButtons(designPanel_.getSelectedCount()); - if(designPanel_.getSelectedCount() > 1) { - setDefaultPanel(); - return; - } - if(pName.equals("message")) { - message.setText((String)evt.getNewValue()); - } else if(pName.equals("allUnselected")) { - setDefaultPanel(); - } else if(pName.equals("panelSelected")) { - if(val instanceof PanelHolderDragBox) { - PanelHolderDragBox pdb = (PanelHolderDragBox)val; - if(pdb.isSelected()) { - setPanelPropertyPanel(pdb.getPanelHolder()); - } else { - setDefaultPanel(); - } - } - } else if(pName.equals("dataGroupSelected")) { - if(val instanceof DataGroupDragBox) { - DataGroupDragBox ag = (DataGroupDragBox)val; - if(ag.isSelected()) { - setDataGroupPropertyPanel(ag.getDataGroup()); - } else { - setDefaultPanel(); - } - } - } else if(pName.equals("axisSelected")) { - if(val instanceof AxisHolderDragBox) { - AxisHolderDragBox ah = (AxisHolderDragBox)val; - if(ah.isSelected()) { - setAxisHolderPropertyPanel(ah.getAxisHolder()); - } else { - setDefaultPanel(); - } - } - } else if(pName.equals("labelSelected")) { - if(val instanceof LabelDragBox) { - LabelDragBox ldb = (LabelDragBox)val; - if(ldb.isSelected()) { - setLabelPropertyPanel(ldb.getLabel()); - } else { - setDefaultPanel(); - } - } - } else if(pName.equals("legendSelected")) { - if(val instanceof LegendDragBox) { - LegendDragBox ldb = (LegendDragBox)val; - if(ldb.isSelected()) { - setLegendPropertyPanel(ldb.getLegend()); - } else { - setDefaultPanel(); - } - } - } else if(pName.equals("ancestor")) { -/* if(Page.DEBUG) { - System.out.println("PanelModelCustomizer.propertyChange()"); - System.out.println(" propertyName = " + evt.getPropertyName()); - System.out.println(" source = " + evt.getSource()); - System.out.println(" oldValue = " + evt.getOldValue()); - System.out.println(" newValue = " + evt.getNewValue()); - System.out.println(" propagationId = " + evt.getPropagationId()); - } */ -// panelModel_.getPage().setBackground(panelModel_.getPageBackgroundColor()); -// panelModel_.getPage().setSize(panelModel_.getPageSize()); - if(evt.getNewValue() == null) { - // clean up ChangeListeners - Iterator iter; - if(panelModel_ == null) return; - Iterator pIter = panelModel_.panelIterator(); - while(pIter.hasNext()) { - PanelHolder ph = (PanelHolder)pIter.next(); - iter = ph.labelIterator(); - while(iter.hasNext()) { - Label label = (Label)iter.next(); - label.removeDesignChangeListeners(); - } - iter = ph.legendIterator(); - while(iter.hasNext()) { - Legend legend = (Legend)iter.next(); - legend.removeDesignChangeListeners(); - } - iter = ph.dataGroupIterator(); - while(iter.hasNext()) { - DataGroup dg = (DataGroup)iter.next(); - dg.getXAxisHolder().removeDesignChangeListeners(); - dg.getYAxisHolder().removeDesignChangeListeners(); - dg.removeDesignChangeListeners(); - } - ph.removeDesignChangeListeners(); - } - panelModel_.removeDesignChangeListeners(); - } /* else { - System.out.println("change focus here?"); - System.out.println("PanelModelCustomizer.isVisible() = " + isVisible()); - if(newPanelButton.requestFocusInWindow()) { - System.out.println("focus may be granted"); - } else { - System.out.println("focus wont be granted"); - } - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); -// KeyboardFocusManager.getCurrentKeyboardFocusManager().upFocusCycle(); -// KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(); - - } */ - } - } - - private void setDefaultPanel() { - jScrollPane1.getViewport().removeAll(); - jScrollPane1.getViewport().add(pmPropertyPanel_, null); - currentPropertyPanel_ = pmPropertyPanel_; - } - - private void setPanelPropertyPanel(PanelHolder ph) { - if(ph == null) { - setDefaultPanel(); - return; - } - if(phPropertyPanel_ == null) { - phPropertyPanel_ = new PanelHolderPropertyPanel(ph, expertCB.isSelected()); - } else { - phPropertyPanel_.setPanelHolder(ph, expertCB.isSelected()); - } - jScrollPane1.getViewport().removeAll(); - jScrollPane1.getViewport().add(phPropertyPanel_); - currentPropertyPanel_ = phPropertyPanel_; - } - - private void setDataGroupPropertyPanel(DataGroup dg) { - if(dg == null) { - setDefaultPanel(); - return; - } - if(agPropertyPanel_ == null) { - agPropertyPanel_ = new DataGroupPropertyPanel(dg, expertCB.isSelected()); - } else { - agPropertyPanel_.setDataGroup(dg, expertCB.isSelected()); - } - jScrollPane1.getViewport().removeAll(); - jScrollPane1.getViewport().add(agPropertyPanel_); - currentPropertyPanel_ = agPropertyPanel_; - } - - private void setAxisHolderPropertyPanel(AxisHolder ah) { - if(ah == null) { - setDefaultPanel(); - return; - } - if(ahPropertyPanel_ == null) { - ahPropertyPanel_ = new AxisHolderPropertyPanel(ah, expertCB.isSelected()); - } else { - ahPropertyPanel_.setAxisHolder(ah, expertCB.isSelected()); - } - jScrollPane1.getViewport().removeAll(); - jScrollPane1.getViewport().add(ahPropertyPanel_); - currentPropertyPanel_ = ahPropertyPanel_; - } - - private void setLabelPropertyPanel(Label lab) { - if(lab == null) { - setDefaultPanel(); - return; - } - if(labelPropertyPanel_ == null) { - labelPropertyPanel_ = new LabelPropertyPanel(lab, expertCB.isSelected()); - } else { - labelPropertyPanel_.setLabel(lab, expertCB.isSelected()); - } - jScrollPane1.getViewport().removeAll(); - jScrollPane1.getViewport().add(labelPropertyPanel_); - currentPropertyPanel_ = labelPropertyPanel_; - } - - private void setLegendPropertyPanel(Legend legend) { - if(legend == null) { - setDefaultPanel(); - return; - } - if(legendPropertyPanel_ == null) { - legendPropertyPanel_ = new LegendPropertyPanel(legend, expertCB.isSelected()); - } else { - legendPropertyPanel_.setLegend(legend, expertCB.isSelected()); - } - jScrollPane1.getViewport().removeAll(); - jScrollPane1.getViewport().add(legendPropertyPanel_); - currentPropertyPanel_ = legendPropertyPanel_; - } - - private void setPanelButtons(int enabledCount) { - boolean enabled = enabledCount >= 2; - - alignBottomButton.setEnabled(enabled); - alignTopButton.setEnabled(enabled); - alignLeftButton.setEnabled(enabled); - alignRightButton.setEnabled(enabled); - - enabled = enabledCount >= 1; - justVerticalButton.setEnabled(enabled); - justHorizontalButton.setEnabled(enabled); - - enabled = enabledCount == 1; - removeButton.setEnabled(enabled); - newDataGroupButton.setEnabled(enabled); - newLabelButton.setEnabled(enabled); - newLegendButton.setEnabled(enabled); - - enabled = designPanel_.isChildDragBoxSelected(); - if(enabled) { - removeButton.setEnabled(!designPanel_.isAxisHolderDragBoxSelected()); - } - } - - void alignBottomButton_actionPerformed(ActionEvent e) { - designPanel_.alignBoxes(DesignPanel.ALIGN_BOTTOM); - } - - void alignTopButton_actionPerformed(ActionEvent e) { - designPanel_.alignBoxes(DesignPanel.ALIGN_TOP); - } - - void alignLeftButton_actionPerformed(ActionEvent e) { - designPanel_.alignBoxes(DesignPanel.ALIGN_LEFT); - } - - void alignRightButton_actionPerformed(ActionEvent e) { - designPanel_.alignBoxes(DesignPanel.ALIGN_RIGHT); - } - - void justVerticalButton_actionPerformed(ActionEvent e) { - designPanel_.alignBoxes(DesignPanel.JUSTIFY_VERTICAL); - } - - void justHorizontalButton_actionPerformed(ActionEvent e) { - designPanel_.alignBoxes(DesignPanel.JUSTIFY_HORIZONTAL); - } - - void removeButton_actionPerformed(ActionEvent e) { - designPanel_.removeSelected(); - setDefaultPanel(); - setPanelButtons(0); - } - - void expertCB_actionPerformed(ActionEvent e) { - currentPropertyPanel_.setExpert(expertCB.isSelected()); - } - - void openPanelButton_actionPerformed(ActionEvent e) { - // problem with open since PanelModelCustomizer work on the original - // object. Right now there isn't a method for replacing the PanelModel - // inside the customizer. However, I can save it! - } - - void saveAsPanelButton_actionPerformed(ActionEvent e) { - File file; - FileFilter filt; - String ext; - String outpath; - String[] xmlFile = new String[]{".xml"}; - SimpleFileFilter xmlFilt = new SimpleFileFilter(xmlFile, "XML Serialized Bean"); - - if(fileChooser_ == null) { - fileChooser_ = new JFileChooser(); - } - fileChooser_.setFileFilter(fileChooser_.getAcceptAllFileFilter()); - fileChooser_.resetChoosableFileFilters(); - fileChooser_.addChoosableFileFilter(xmlFilt); - fileChooser_.setFileFilter(xmlFilt); - - int result = fileChooser_.showSaveDialog(this); - if(result == JFileChooser.APPROVE_OPTION) { - file = fileChooser_.getSelectedFile(); - filt = fileChooser_.getFileFilter(); - outpath = file.getPath(); - if(filt instanceof SimpleFileFilter) { - ext = ((SimpleFileFilter)filt).getExtension(); - String name = file.getName().toLowerCase(); - if(!name.endsWith(ext)) { - outpath += ext; - } - } - try { - panelModel_.saveToXML(new BufferedOutputStream( - new FileOutputStream(outpath, false))); - } catch (FileNotFoundException fnfe) { - JOptionPane.showMessageDialog(this, "Error creating file, rename and try again", - "File Save Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelEditor.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelEditor.java deleted file mode 100755 index 48cbaf89..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelEditor.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * $Id: PanelModelEditor.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import java.io.InvalidObjectException; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import javax.swing.*; -import javax.swing.filechooser.*; -import java.awt.event.*; - -import gov.noaa.pmel.util.SimpleFileFilter; - -/** - * Run-time and stand-alone editor to modify a PanelModel. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - * @see PanelModelCustomizer - **/ -public class PanelModelEditor extends JFrame { - private PanelModel panelModel_ = null; - private static boolean isApp_ = false; - private boolean throwClosing = true; - private String openPath_ = null; - private static String title_ = "Panel Model Editor"; - // - private JFileChooser fileChooser_ = null; - private JPanel pmcPanel = new JPanel(); - private JPanel buttonPanel = new JPanel(); - private JMenuBar menuBar = new JMenuBar(); - private JButton okButton = new JButton(); - private PanelModelCustomizer pmc = new PanelModelCustomizer(); - private BorderLayout borderLayout1 = new BorderLayout(); - private JMenu fileMenu = new JMenu(); - private JMenuItem openFileMI = new JMenuItem(); - private JMenuItem saveFileMI = new JMenuItem(); - private JMenuItem exitFileMI = new JMenuItem(); - private JMenuItem saveAsFileMI = new JMenuItem(); - private JMenuItem newFileMI = new JMenuItem(); - - /** - * PanelModelEditor constructor. - * @param pModel PanelModel - */ - public PanelModelEditor(PanelModel pModel) { - this(); - setPanelModel(pModel); - } - - /** - * Default constructor. - */ - public PanelModelEditor() { - try { - jbInit(); - pack(); - } - catch(Exception e) { - e.printStackTrace(); - } - } - - /** - * Main method for stand-alone application to create/modify PanelModels - * that have been serialized using XMLEncoder. - * @param args Arguement String - * @see java.beans.XMLEncoder - */ - public static void main(String[] args) { - isApp_ = true; - PanelModelEditor pme = new PanelModelEditor(new PanelModel()); - pme.setTitle(title_); - pme.setVisible(true); - } - - private void jbInit() throws Exception { - okButton.setText("OK"); - okButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - okButton_actionPerformed(e); - } - }); - pmcPanel.setLayout(borderLayout1); - fileMenu.setText("File"); - openFileMI.setActionCommand("Open"); - openFileMI.setText("Open..."); - openFileMI.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - openFileMI_actionPerformed(e); - } - }); - saveFileMI.setActionCommand("Save"); - saveFileMI.setText("Save"); - saveFileMI.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - saveFileMI_actionPerformed(e); - } - }); - exitFileMI.setText("Exit"); - exitFileMI.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - exitFileMI_actionPerformed(e); - } - }); - saveAsFileMI.setActionCommand("SaveAs"); - saveAsFileMI.setText("Save As..."); - saveAsFileMI.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - saveAsFileMI_actionPerformed(e); - } - }); - if(isApp_)this.setJMenuBar(menuBar); - newFileMI.setText("New"); - newFileMI.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - newFileMI_actionPerformed(e); - } - }); - this.getContentPane().add(pmcPanel, BorderLayout.CENTER); - if(!isApp_) this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); - buttonPanel.add(okButton, null); - pmcPanel.add(pmc, BorderLayout.CENTER); - menuBar.add(fileMenu); - fileMenu.add(newFileMI); - fileMenu.addSeparator(); - fileMenu.add(openFileMI); - fileMenu.add(saveFileMI); - fileMenu.add(saveAsFileMI); - fileMenu.addSeparator(); - fileMenu.add(exitFileMI); - - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(WindowEvent e) { - if(throwClosing) pmf_windowClosing(e); - } - }); - Dimension dim = pmc.getPreferredSize(); - setSize(new Dimension(473, 354)); - //Center the window - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension frameSize = getSize(); - if (frameSize.height > screenSize.height) { - frameSize.height = screenSize.height; - } - if (frameSize.width > screenSize.width) { - frameSize.width = screenSize.width; - } - setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); - } - - void pmf_windowClosing(WindowEvent e) { - if(Page.DEBUG) System.out.println("windowClosing"); - throwClosing = false; - setVisible(false); - if(panelModel_ != null) panelModel_.setBatch(false); - dispose(); - if(isApp_) System.exit(0); - } - - void okButton_actionPerformed(ActionEvent e) { - throwClosing = false; - pmf_windowClosing(null); - } - - /** - * Get PanelModel. - * @return PanelModel - */ - public PanelModel getPanelModel() { - return panelModel_; - } - - /** - * Set PanelModel. - * @param panelModel PanelModel - */ - public void setPanelModel(PanelModel panelModel) { - panelModel_ = panelModel; - if(panelModel_ != null) { - panelModel_.setBatch(true); - pmc.setObject(panelModel_); - } - } - - void openFileMI_actionPerformed(ActionEvent e) { - PanelModel pModel = null; - File file; - String ext; - String[] xmlFile = new String[]{".xml"}; - SimpleFileFilter xmlFilt = new SimpleFileFilter(xmlFile, "XML Serialized Bean"); - - if(fileChooser_ == null) { - fileChooser_ = new JFileChooser(); - } - fileChooser_.setFileFilter(fileChooser_.getAcceptAllFileFilter()); - fileChooser_.resetChoosableFileFilters(); - fileChooser_.addChoosableFileFilter(xmlFilt); - fileChooser_.setFileFilter(xmlFilt); - - int result = fileChooser_.showOpenDialog(this); - if(result == JFileChooser.APPROVE_OPTION) { - file = fileChooser_.getSelectedFile(); - openPath_ = file.getPath(); - setTitle(title_ + ": " + openPath_); - try { - pModel = PanelModel.loadFromXML(new BufferedInputStream( - new FileInputStream(openPath_))); - setPanelModel(pModel); - } catch (FileNotFoundException fnfe) { - JOptionPane.showMessageDialog(this, "Error openning file", - "File Open Error", JOptionPane.ERROR_MESSAGE); - } catch (InvalidObjectException ioe) { - JOptionPane.showMessageDialog(this, "File does not contain a PanelModel", - "PanelModel Not Found", - JOptionPane.ERROR_MESSAGE); - } - } - } - - void saveAsFileMI_actionPerformed(ActionEvent e) { - File file; - FileFilter filt; - String ext; - String outpath; - String[] xmlFile = new String[]{".xml"}; - SimpleFileFilter xmlFilt = new SimpleFileFilter(xmlFile, "XML Serialized Bean"); - - if(fileChooser_ == null) { - fileChooser_ = new JFileChooser(); - } - fileChooser_.setFileFilter(fileChooser_.getAcceptAllFileFilter()); - fileChooser_.resetChoosableFileFilters(); - fileChooser_.addChoosableFileFilter(xmlFilt); - fileChooser_.setFileFilter(xmlFilt); - - int result = fileChooser_.showSaveDialog(this); - if(result == JFileChooser.APPROVE_OPTION) { - file = fileChooser_.getSelectedFile(); - filt = fileChooser_.getFileFilter(); - outpath = file.getPath(); - if(filt instanceof SimpleFileFilter) { - ext = ((SimpleFileFilter)filt).getExtension(); - String name = file.getName().toLowerCase(); - if(!name.endsWith(ext)) { - outpath += ext; - } - } - if(new File(outpath).exists()) { - JOptionPane.showMessageDialog(this, "File already exists, rename and try again", - "File Save Error", JOptionPane.ERROR_MESSAGE); - return; - } - try { - panelModel_.saveToXML(new BufferedOutputStream( - new FileOutputStream(outpath, false))); - } catch (FileNotFoundException fnfe) { - JOptionPane.showMessageDialog(this, "Error creating file, rename and try again", - "File Save Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - } - - void saveFileMI_actionPerformed(ActionEvent e) { - if(openPath_ == null) return; - try { - panelModel_.saveToXML(new BufferedOutputStream( - new FileOutputStream(openPath_, false))); - } catch (FileNotFoundException fnfe) { - JOptionPane.showMessageDialog(this, "Error creating file, rename and try again", - "File Save Error", JOptionPane.ERROR_MESSAGE); - return; - } - } - - void exitFileMI_actionPerformed(ActionEvent e) { - throwClosing = false; - pmf_windowClosing(null); - } - - void newFileMI_actionPerformed(ActionEvent e) { - setPanelModel(new PanelModel()); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelIcon16.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelIcon16.gif deleted file mode 100755 index 5fe6cc06..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelIcon16.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelIcon32.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelIcon32.gif deleted file mode 100755 index 6dfe217a..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelIcon32.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelPropertyPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelPropertyPanel.java deleted file mode 100755 index 0be71a2a..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PanelModelPropertyPanel.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * $Id: PanelModelPropertyPanel.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import javax.swing.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import gov.noaa.pmel.sgt.swing.prop.ColorDialog; -import gov.noaa.pmel.sgt.AbstractPane; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -class PanelModelPropertyPanel extends PropertyPanel implements PropertyChangeListener, ActionListener { - private boolean expert_ = false; - private PanelModel pModel_ = null; - private String[] pNames_ = {"DPI", "Page Color", "Page Size", "Panels", - "Print Borders", - "Print HAlign", "Print Origin", "Print Scale Mode", "Print VAlign", - "Print White"}; - private JComponent[] comps_ = new JComponent[pNames_.length]; - private String[] vAlignItems = {"Top", "Middle", "Bottom", "Specified Location"}; - private String[] hAlignItems = {"Left", "Center", "Right", "Specified Location"}; - private String[] sModeItems = {"Default", "To Fit", "Shrink To Fit"}; - - public PanelModelPropertyPanel(PanelModel pm) { - super(); - pModel_ = pm; - pModel_.addPropertyChangeListener(this); - - create(); - } - - public void propertyChange(PropertyChangeEvent evt) { - update(); - } - - void create() { - int i = -1; - int item = -1; - comps_[++i] = createLabel(Float.toString(pModel_.getDpi())); - comps_[++i] = createColor(pModel_.getPageBackgroundColor(), pNames_[i], this); - comps_[++i] = createTextField(format(pModel_.getPageSize(), false),pNames_[i], this, true); - comps_[++i] = createLabel(pModel_.getPanelCount()); - comps_[++i] = createCheckBox(pModel_.isPrintBorders(), pNames_[i], this); - switch(pModel_.getPrintHAlign()) { - case AbstractPane.LEFT: - item = 0; - break; - default: - case AbstractPane.CENTER: - item = 1; - break; - case AbstractPane.RIGHT: - item = 2; - break; - case AbstractPane.SPECIFIED_LOCATION: - item = 3; - break; - } - comps_[++i] = createComboBox(hAlignItems, item, pNames_[i], this, true); - comps_[++i] = createTextField(format(pModel_.getPrintOrigin(), false), pNames_[i], this, true); - switch(pModel_.getPrintScaleMode()) { - default: - case AbstractPane.DEFAULT_SCALE: - item = 0; - break; - case AbstractPane.TO_FIT: - item = 1; - break; - case AbstractPane.SHRINK_TO_FIT: - item = 2; - break; - } - comps_[++i] = createComboBox(sModeItems, item, pNames_[i], this, true); - switch(pModel_.getPrintVAlign()) { - default: - case AbstractPane.TOP: - item = 0; - break; - case AbstractPane.MIDDLE: - item = 1; - break; - case AbstractPane.BOTTOM: - item = 2; - break; - case AbstractPane.SPECIFIED_LOCATION: - item = 3; - break; - } - comps_[++i] = createComboBox(vAlignItems, item, pNames_[i], this, true); - comps_[++i] = createCheckBox(pModel_.isPrintWhitePage(), pNames_[i], this); - for(i=0; i < comps_.length; i++) { - addProperty(i+1, pNames_[i], comps_[i], false); - } - addProperty(comps_.length + 1, " ", new JLabel(" "), true); - } - - void update() { - int i = -1; - int item = -1; - ((JLabel)comps_[++i]).setText(Float.toString(pModel_.getDpi())); - updateColor((JButton)comps_[++i], pModel_.getPageBackgroundColor()); - ((JTextField)comps_[++i]).setText(format(pModel_.getPageSize(), false)); - ((JLabel)comps_[++i]).setText(Integer.toString(pModel_.getPanelCount())); - ((JCheckBox)comps_[++i]).setSelected(pModel_.isPrintBorders()); - switch(pModel_.getPrintHAlign()) { - case AbstractPane.LEFT: - item = 0; - break; - default: - case AbstractPane.CENTER: - item = 1; - break; - case AbstractPane.RIGHT: - item = 2; - break; - case AbstractPane.SPECIFIED_LOCATION: - item = 3; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JTextField)comps_[++i]).setText(format(pModel_.getPrintOrigin(), false)); - switch(pModel_.getPrintScaleMode()) { - default: - case AbstractPane.DEFAULT_SCALE: - item = 0; - break; - case AbstractPane.TO_FIT: - item = 1; - break; - case AbstractPane.SHRINK_TO_FIT: - item = 2; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - switch(pModel_.getPrintVAlign()) { - default: - case AbstractPane.TOP: - item = 0; - break; - case AbstractPane.MIDDLE: - item = 1; - break; - case AbstractPane.BOTTOM: - item = 2; - break; - case AbstractPane.SPECIFIED_LOCATION: - item = 3; - break; - } - ((JComboBox)comps_[++i]).setSelectedIndex(item); - ((JCheckBox)comps_[++i]).setSelected(pModel_.isPrintWhitePage()); - } - - private void processEvent(Object obj, String command) { - String str; - int item = -1; - if(command.equals("Page Size")) { - Dimension size = parseDimension(((JTextField)obj).getText()); - pModel_.setPageSize(size); - if(pModel_.getPage() != null) pModel_.getPage().setSize(size); - } else if(command.equals("Page Color")) { - ColorDialog cd = new ColorDialog(getFrame(), "Select Axis Color", true); - cd.setColor(pModel_.getPageBackgroundColor()); - cd.setVisible(true); - Color newcolor = cd.getColor(); - if(newcolor != null) { - pModel_.setPageBackgroundColor(newcolor); - updateColor((JButton)obj, newcolor); - } - } else if(command.equals("Print Borders")) { - pModel_.setPrintBorders(((JCheckBox)obj).isSelected()); - } else if(command.equals("Print HAlign")) { - str = (String)((JComboBox)obj).getSelectedItem(); - item = -1; - if(str.equals("Left")) { - item = AbstractPane.LEFT; - } else if(str.equals("Center")) { - item = AbstractPane.CENTER; - } else if(str.equals("Right")) { - item = AbstractPane.RIGHT; - } else if(str.equals("Specified Location")) { - item = AbstractPane.SPECIFIED_LOCATION; - } - pModel_.setPrintHAlign(item); - } else if(command.equals("Print Origin")) { - Point pt = parsePoint(((JTextField)obj).getText()); - if(pt != null) pModel_.setPrintOrigin(pt); - - } else if(command.equals("Print Scale Mode")) { - str = (String)((JComboBox)obj).getSelectedItem(); - item = -1; - if(str.equals("Default")) { - item = AbstractPane.DEFAULT_SCALE; - } else if(str.equals("To Fit")) { - item = AbstractPane.TO_FIT; - } else if(str.equals("Shrink To Fit")) { - item = AbstractPane.SHRINK_TO_FIT; - } - pModel_.setPrintScaleMode(item); - } else if(command.equals("Print VAlign")) { - str = (String)((JComboBox)obj).getSelectedItem(); - item = -1; - if(str.equals("Top")) { - item = AbstractPane.TOP; - } else if(str.equals("Middle")) { - item = AbstractPane.MIDDLE; - } else if(str.equals("Bottom")) { - item = AbstractPane.BOTTOM; - } else if(str.equals("Specified Location")) { - item = AbstractPane.SPECIFIED_LOCATION; - } - pModel_.setPrintVAlign(item); - } else if(command.equals("Print White")) { - pModel_.setPrintWhitePage(((JCheckBox)obj).isSelected()); - } - } - - void resetFields() { } - - public void setExpert(boolean expert) { - expert_ = expert; - } - - public boolean isExpert() { - return expert_; - } - public void actionPerformed(ActionEvent e) { - Object obj = e.getSource(); - String command = e.getActionCommand(); - processEvent(obj, command); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PropertyPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PropertyPanel.java deleted file mode 100755 index 69685658..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/PropertyPanel.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * $Id: PropertyPanel.java,v 1.1.1.1 2007/09/07 06:32:02 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.beans; - -import java.awt.*; -import javax.swing.*; -import java.awt.event.ActionListener; -import java.awt.event.FocusListener; -import java.util.EventListener; -import java.util.Vector; -import java.text.DecimalFormat; -import java.util.StringTokenizer; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.sgt.swing.ColorSwatchIcon; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:02 $ - * @since 3.0 - **/ -abstract class PropertyPanel extends JComponent implements DesignListener { - private PanelHolder pHolder_ = null; - private JLabel jLabel1 = new JLabel(); - private JLabel jLabel3 = new JLabel(); - private GridBagLayout gridBagLayout1 = new GridBagLayout(); - private Font hdrFont_ = new Font("Dialog", 1, 9); - private Font textFont_ = new Font("Dialog", 0, 9); - private Insets lInset = new Insets(2, 1, 1, 3); - private Insets rInset = new Insets(2, 3, 1, 1); - private static DecimalFormat numberFormat_ = new DecimalFormat("#.##"); - private String dateFormat_ = "yyyy-MM-dd hh:mm"; - - public PropertyPanel() { - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - } - - private void jbInit() throws Exception { - jLabel1.setText("Property"); - jLabel1.setFont(hdrFont_); - jLabel1.setForeground(Color.black); - jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); - this.setLayout(gridBagLayout1); - jLabel3.setText("Value"); - jLabel3.setFont(hdrFont_); - jLabel3.setForeground(Color.black); - this.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, lInset, 5, 5)); - this.add(jLabel3, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, rInset, 10, 5)); - } - - abstract void resetFields(); - - public void reset() { - this.removeAll(); - resetFields(); - try { - jbInit(); - } catch (Exception e) { - e.printStackTrace(); - } - create(); - revalidate(); - } - - protected void addProperty(int row, String propertyName, JComponent component, boolean last) { - double weighty; - int left, right; - JLabel label = new JLabel(propertyName); - label.setHorizontalAlignment(SwingConstants.RIGHT); - label.setFont(textFont_); - component.setFont(textFont_); - if(last) { - weighty = 1.0; - left = GridBagConstraints.NORTHEAST; - right = GridBagConstraints.NORTHWEST; - } else { - weighty = 0.0; - left = GridBagConstraints.EAST; - right = GridBagConstraints.WEST; - } - this.add(label, new GridBagConstraints(0, row, 1, 1, 0.0, weighty, - left, GridBagConstraints.BOTH, lInset, 5, 5)); - this.add(component, new GridBagConstraints(1, row, 1, 1, 1.0, weighty, - right, GridBagConstraints.HORIZONTAL, rInset, 5, 5)); - } - - abstract void update(); - abstract void create(); - - protected JTextField createTextField(String text, - String action, EventListener listen, - boolean edit) { - JTextField tf = new JTextField(text); - tf.setActionCommand(action); - tf.setName(action); - tf.setEditable(edit); - if(listen != null) { - if(listen instanceof ActionListener) tf.addActionListener((ActionListener)listen); - if(listen instanceof FocusListener) tf.addFocusListener((FocusListener)listen); - } - return tf; - } - - protected JLabel createLabel(String text) { - JLabel jl = new JLabel(text); - return jl; - } - - protected JLabel createLabel(int value) { - return new JLabel(Integer.toString(value)); - } - - protected JCheckBox createCheckBox(boolean value, - String action, ActionListener listen) { - JCheckBox cb = new JCheckBox("", value); - cb.setHorizontalTextPosition(SwingConstants.LEFT); - cb.setActionCommand(action); - if(listen != null) cb.addActionListener(listen); - return cb; - } - - protected JComboBox createComboBox(Vector list, int item, - String action, ActionListener listen, - boolean edit) { - return createComboBox(list.toArray(), item, action, listen, edit); - } - - protected JComboBox createComboBox(Object[] list, int item, - String action, ActionListener listen, - boolean edit) { - JComboBox cb = new JComboBox(list); - cb.setSelectedIndex(item); - cb.setActionCommand(action); - cb.setEditable(edit); - cb.setEnabled(edit); - if(listen != null) cb.addActionListener(listen); - return cb; - } - - protected JButton createSGLabel(SGLabel value, - String action, ActionListener listen) { - if(value == null) return new JButton("null"); - JButton jb = new JButton(value.getText()); - jb.setFont(value.getFont()); - jb.setForeground(value.getColor()); -// jb.setHorizontalTextPosition(SwingConstants.LEFT); - jb.setActionCommand(action); - if(listen != null) jb.addActionListener(listen); - return jb; - } - - protected Point2D.Double parsePoint2D(String value) { - StringTokenizer tok = new StringTokenizer(value, ",\t\n\r\f"); - if(tok.countTokens() != 2) { - JOptionPane.showMessageDialog(this, "Four values required", "Illegal Response", JOptionPane.ERROR_MESSAGE); - return null; - } - double x = Double.parseDouble(tok.nextToken().trim()); - double y = Double.parseDouble(tok.nextToken().trim()); - return new Point2D.Double(x, y); - } - - protected Point parsePoint(String value) { - StringTokenizer tok = new StringTokenizer(value, ",\t\n\r\f"); - if(tok.countTokens() != 2) { - JOptionPane.showMessageDialog(this, "Two values required", "Illegal Response", JOptionPane.ERROR_MESSAGE); - return null; - } - int x = Integer.parseInt(tok.nextToken().trim()); - int y = Integer.parseInt(tok.nextToken().trim()); - return new Point(x, y); - } - - protected Dimension parseDimension(String value) { - StringTokenizer tok = new StringTokenizer(value, ",\t\n\r\f"); - if(tok.countTokens() != 2) { - JOptionPane.showMessageDialog(this, "Two values required", "Illegal Response", JOptionPane.ERROR_MESSAGE); - return null; - } - int width = Integer.parseInt(tok.nextToken().trim()); - int height = Integer.parseInt(tok.nextToken().trim()); - return new Dimension(width, height); - } - - protected Rectangle2D parseBounds(String value) { - StringTokenizer tok = new StringTokenizer(value, ",\t\n\r\f"); - if(tok.countTokens() != 4) { - JOptionPane.showMessageDialog(this, "Four values required", "Illegal Response", JOptionPane.ERROR_MESSAGE); - return null; - } - double x = Double.parseDouble(tok.nextToken().trim()); - double y = Double.parseDouble(tok.nextToken().trim()); - double width = Double.parseDouble(tok.nextToken().trim()); - double height = Double.parseDouble(tok.nextToken().trim()); - return new Rectangle2D.Double(x, y, width, height); - } - - protected SoTRange parseRange(String value, boolean isTime) { - StringTokenizer tok = new StringTokenizer(value, ",\t\n\r\f"); - if(tok.countTokens() != 3) { - JOptionPane.showMessageDialog(this, "Three values required", "Illegal Response", JOptionPane.ERROR_MESSAGE); - return null; - } - SoTRange range = null; - if(isTime) { -// String format = "yyyy-MM-dd hh:mm"; - try { - GeoDate start = new GeoDate(tok.nextToken().trim(), dateFormat_); - GeoDate end = new GeoDate(tok.nextToken().trim(), dateFormat_); - long dlta = Long.parseLong(tok.nextToken().trim())*86400000; - GeoDate delta = new GeoDate(dlta); - range = new SoTRange.Time(start, end, delta); - } catch (IllegalTimeValue itv) { - JOptionPane.showMessageDialog(this, "Illegal Time Value", "Illegal Response", JOptionPane.ERROR_MESSAGE); - return null; - } - } else { - double start = Double.parseDouble(tok.nextToken().trim()); - double end = Double.parseDouble(tok.nextToken().trim()); - double delta = Double.parseDouble(tok.nextToken().trim()); - range = new SoTRange.Double(start, end, delta); - } - return range; - } - - protected String colorString(Color value) { - StringBuffer sbuf = new StringBuffer("["); - sbuf.append(value.getRed()).append(", "); - sbuf.append(value.getGreen()).append(", "); - sbuf.append(value.getRed()); - if(value.getAlpha() == 255) { - sbuf.append("]"); - } else { - sbuf.append(", ").append(value.getAlpha()).append("]"); - } - return sbuf.toString(); - } - - protected JButton createColor(Color value, - String action, ActionListener listen) { - Icon icon = new ColorSwatchIcon(value, 32, 20); - JButton jb = new JButton(colorString(value), icon); - jb.setActionCommand(action); - if(listen != null) jb.addActionListener(listen); - return jb; - } - - protected void updateColor(JButton comp, Color value) { - comp.setText(colorString(value)); - Icon icon = new ColorSwatchIcon(value, 32, 20); - comp.setIcon(icon); - } - - protected JButton createFont(Font value, - String action, ActionListener listen) { - JButton jb = new JButton(value.getName()); - jb.setFont(value); -// jb.setHorizontalTextPosition(SwingConstants.LEFT); - jb.setActionCommand(action); - if(listen != null) jb.addActionListener(listen); - return jb; - } - - protected void updateFont(JButton comp, Font value) { - comp.setText(value.getName()); - comp.setFont(value); - } - protected void updateSGLabel(JButton comp, SGLabel value) { - comp.setFont(value.getFont()); - comp.setText(value.getText()); - comp.setForeground(value.getColor()); - } - - protected String format(Point val, boolean brackets) { - StringBuffer buf = new StringBuffer(); - if(brackets) buf.append("["); - buf.append(format(val.x)).append(", "); - buf.append(format(val.y)); - if(brackets) buf.append("]"); - return buf.toString(); - } - - protected String format(Dimension val, boolean brackets) { - StringBuffer buf = new StringBuffer(); - if(brackets) buf.append("["); - buf.append(format(val.width)).append(", "); - buf.append(format(val.height)); - if(brackets) buf.append("]"); - return buf.toString(); - } - - protected String format(Rectangle2D.Double val, boolean brackets) { - StringBuffer buf = new StringBuffer(); - if(brackets) buf.append("["); - buf.append(format(val.x)).append(", "); - buf.append(format(val.y)).append(", "); - buf.append(format(val.width)).append(", "); - buf.append(format(val.height)); - if(brackets) buf.append("]"); - return buf.toString(); - } - - protected String format(Point2D.Double val, boolean brackets) { - StringBuffer buf = new StringBuffer(); - if(brackets) buf.append("["); - buf.append(format(val.x)).append(", "); - buf.append(format(val.y)); - if(brackets) buf.append("]"); - return buf.toString(); - } - - protected String format(Range2D val, boolean brackets) { - StringBuffer buf = new StringBuffer(); - if(brackets) buf.append("["); - buf.append(format(val.start)).append(", "); - buf.append(format(val.end)).append(", "); - buf.append(format(val.delta)); - if(brackets) buf.append("]"); - return buf.toString(); - } - - protected String format(SoTRange.Double val, boolean brackets) { - StringBuffer buf = new StringBuffer(); - if(brackets) buf.append("["); - buf.append(format(val.start)).append(", "); - buf.append(format(val.end)).append(", "); - buf.append(format(val.delta)); - if(brackets) buf.append("]"); - return buf.toString(); - } - - protected String format(SoTRange.Time val, boolean brackets) { - StringBuffer buf = new StringBuffer(); - if(brackets) buf.append("["); - buf.append(val.getStart().toString()).append(", "); - buf.append(val.getEnd().toString()).append(", "); - buf.append(Long.toString(val.getDelta().getLongTime()/86400000)); // days - if(brackets) buf.append("]"); - return buf.toString(); - } - - protected String format(SoTRange val, boolean brackets) { - if(val instanceof SoTRange.Float) { - return format((SoTRange.Float)val, brackets); - } else if(val instanceof SoTRange.Double) { - return format((SoTRange.Double)val, brackets); - } else if(val instanceof SoTRange.Time) { - return format((SoTRange.Time)val, brackets); - } - return ""; - } - - protected String format(SoTPoint val, boolean brackets) { - if(val == null) return "null"; - return val.toString(); - } - - protected String format(float value) { - return numberFormat_.format(value); - } - - protected String format(float value, DecimalFormat format) { - return format.format(value); - } - - protected String format(double value, DecimalFormat format) { - return format.format(value); - } - - protected String format(double value) { - DecimalFormat format = new DecimalFormat("#.##"); - return format.format(value); - } - - protected void paintBorder(Graphics g) { - int x0=0, x1=0, x2=0; - int y; - int y1=0; - int y0=0; - - Component[] comps = getComponents(); - - for(int i=0; i < comps.length;i += 2) { - if(i == 0) { - x0 = comps[0].getBounds().x - lInset.left; - x1 = comps[0].getBounds().x + comps[0].getBounds().width + lInset.right; - x2 = comps[1].getBounds().x + comps[1].getBounds().width; - y0 = comps[0].getBounds().y - lInset.top; - } - y = comps[i].getBounds().y - lInset.top; - if(i >= comps.length - 2) { - y1 = y; - } - g.drawLine(0, y, x2, y); - } - g.drawLine(x0, y0, x0, y1); - g.drawLine(x1, y0, x1, y1); - g.drawLine(x2, y0, x2, y1); - } - - public String toString() { - return getClass().getName() + '@' + Integer.toHexString(hashCode()); - } - - Frame getFrame() { - Window fr = javax.swing.SwingUtilities.getWindowAncestor(this); - if(fr != null && fr instanceof Frame) { - return (Frame)fr; - } - return null; - } - - abstract public void setExpert(boolean expert); - abstract public boolean isExpert(); -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignBottom24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignBottom24.gif deleted file mode 100755 index 62e921d4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignBottom24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignCenter24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignCenter24.gif deleted file mode 100755 index f19d8ed4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignCenter24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignJustifyHorizontal24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignJustifyHorizontal24.gif deleted file mode 100755 index 32a1070d..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignJustifyHorizontal24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignJustifyVertical24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignJustifyVertical24.gif deleted file mode 100755 index f5d4a00b..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignJustifyVertical24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignLeft24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignLeft24.gif deleted file mode 100755 index 4db364c0..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignLeft24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignRight24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignRight24.gif deleted file mode 100755 index 9c82ad46..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignRight24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignTop24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignTop24.gif deleted file mode 100755 index 8fd07a2e..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/AlignTop24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/DataModelSimple.png b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/DataModelSimple.png deleted file mode 100755 index dae8b724..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/DataModelSimple.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Edit24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Edit24.gif deleted file mode 100755 index a5af7d7c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Edit24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/New24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/New24.gif deleted file mode 100755 index 1cc488d4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/New24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewDataGroup24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewDataGroup24.gif deleted file mode 100755 index db272f72..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewDataGroup24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewLabel24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewLabel24.gif deleted file mode 100755 index 60589ed5..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewLabel24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewLegend24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewLegend24.gif deleted file mode 100755 index 57bfaf8c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/NewLegend24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Open24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Open24.gif deleted file mode 100755 index 2086bc29..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Open24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/PanelModelSimple.png b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/PanelModelSimple.png deleted file mode 100755 index b2cc5dd1..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/PanelModelSimple.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Preferences24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Preferences24.gif deleted file mode 100755 index 2e727b2c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Preferences24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Remove24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Remove24.gif deleted file mode 100755 index fa40604c..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Remove24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/RunTimeSimple.png b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/RunTimeSimple.png deleted file mode 100755 index d90a4eb1..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/RunTimeSimple.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Save24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Save24.gif deleted file mode 100755 index bfa98a8d..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/Save24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/SaveAs24.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/SaveAs24.gif deleted file mode 100755 index 97eb6fa3..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/images/SaveAs24.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/package.html deleted file mode 100755 index 6b00eda7..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/beans/package.html +++ /dev/null @@ -1,20 +0,0 @@ - - -Classes and interfaces that make up SGT Beans. The classes -Page, DataModel, and PanelModel -are the core bean classes. Classes that extend -PropertyPanel or DragBox are used with both -PanelModelCustomizer (called from IDE's) and -PanelModelEditor (designed to be called from users -code). - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Contour.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Contour.java deleted file mode 100755 index 1b3ee26d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Contour.java +++ /dev/null @@ -1,913 +0,0 @@ -/* - * $Id: Contour.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.contour; - -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.ContourLineAttribute; -import gov.noaa.pmel.sgt.DefaultContourLineAttribute; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.LayerNotFoundException; -import gov.noaa.pmel.sgt.ContourLevels; -import gov.noaa.pmel.sgt.ContourLevelNotFoundException; - -import gov.noaa.pmel.sgt.dm.SGTGrid; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Debug; - -import java.awt.Graphics; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; - -import java.util.Vector; -import java.util.Enumeration; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -/** - * Contour constructs a set of ContourLine objects based on - * the ContourLevels, SGTGrid, and mask - * supplied. Used by - * GridCartesianRenderer for GridAttribute - * types of CONTOUR. - * - * @author D. W. Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - * @see ContourLine - * @see ContourLevels - * @see gov.noaa.pmel.sgt.GridCartesianRenderer - * @see gov.noaa.pmel.sgt.GridAttribute - * @see ContourLineAttribute - * @see DefaultContourLineAttribute - */ -public class Contour implements PropertyChangeListener { - /** - * @label grid - */ - private SGTGrid grid_; - /** - * A non-zero mask value will cause a point to be excluded. - * @label mask - */ - private SGTGrid mask_; - private CartesianGraph cg_; - /** - * @label contourLevels - */ - private ContourLevels contourLevels_; - private double zmin_; - private double zmax_; - private boolean upToDate_; - private GeoDate tref_ = null; - private boolean xTime_ = false; - private boolean yTime_ = false; - private double[] px_; - private double[] py_; - private double[] z_; - private double[] xx_; - private double[] yy_; - private double[] zz_; - private boolean[] used_; - private int[] kabov_; - private int[] isin_ = {0, 1, 0, -1}; - private double weezee_; - private int nx_; - private int ny_; - - /** - * @associates - * @link aggregation - * @supplierCardinality 1..* - * @label contourLines - */ - private Vector contourLines_; - - /** - * @link aggregationByValue - * @supplierCardinality 1 - * @label sides - */ - private Sides sides_; - - /** - * @link aggregationByValue - * @supplierCardinality 1 - * @label gridFlag - */ - private GridFlag gridFlag_; - // - private static double DSLAB = 2.0; - private static double SLAB1F = 0.4; - /** - * Construct a Contour object using a range to define - * the ContourLevels. - */ - public Contour(CartesianGraph cg, SGTGrid grid, Range2D range) { - cg_ = cg; - grid_ = grid; - contourLevels_ = ContourLevels.getDefault(range); - init(); - upToDate_ = false; - } - /** - * Construct a Contour object using an array of levels to define - * the ContourLevels. - */ - public Contour(CartesianGraph cg, SGTGrid grid, double[] levels) { - cg_ = cg; - grid_ = grid; - contourLevels_ = ContourLevels.getDefault(levels); - init(); - upToDate_ = false; - } - - /** - * Construct a Contour object using a - * ContourLevels object. - */ - public Contour(CartesianGraph cg, SGTGrid grid, ContourLevels conLevels) { - cg_ = cg; - grid_ = grid; - contourLevels_ = conLevels; - contourLevels_.addPropertyChangeListener(this); - init(); - upToDate_ = false; - } - /** - * Get a reference to the ContourLevels object. - */ - public ContourLevels getContourLevels() { - return contourLevels_; - } - /** - * Set a SGTGrid object to be used to mask the data - * grid. The Z values are used to determine the masking, values of - * NaN and non-zero are set as MISSING. - */ - public void setMask(SGTGrid mask) { - if(mask_ == null || !mask_.equals(mask)) upToDate_ = false; - mask_ = mask; - } - /** - * Get the mask. - */ - public SGTGrid getMask() { - return mask_; - } - /** - * Return the Enumeration of a Vector - * containing the ContourLine objects. - */ - public Enumeration elements() { - if(!upToDate_) generateContourLines(); - return contourLines_.elements(); - } - /** - * Reponds to changes in the ContourLevels object. - */ - public void propertyChange(PropertyChangeEvent event) { - } - - private void init() { - GeoDate[] ttemp; - if(grid_.isXTime()) { - xTime_ = true; - ttemp = grid_.getTimeArray(); - tref_ = ttemp[0]; - px_ = getTimeOffsetArray(ttemp, tref_); - nx_ = grid_.getTSize(); - } else { - px_ = grid_.getXArray(); - nx_ = grid_.getXSize(); - } - if(grid_.isYTime()) { - yTime_ = true; - ttemp = grid_.getTimeArray(); - tref_ = ttemp[0]; - py_ = getTimeOffsetArray(ttemp, tref_); - ny_ = grid_.getTSize(); - } else { - py_ = grid_.getYArray(); - ny_ = grid_.getYSize(); - } - if(Debug.CONTOUR) { - System.out.println("nx_ = " + nx_ + ", ny_ = " + ny_); - } - /** - * side definitions - * ________ - * | 2 | - * | | - * 3| |1 - * | | - * |________| - * 0 - */ - sides_ = new Sides(nx_, ny_); - // - // make the corner arrays index from 0 to 3 - // - xx_ = new double[4]; - yy_ = new double[4]; - zz_ = new double[4]; - used_ = new boolean[4]; - kabov_ = new int[4]; - z_ = grid_.getZArray(); - } - - private double[] getTimeOffsetArray(GeoDate[] tarray, GeoDate tref) { - double[] array = new double[tarray.length]; - for(int i=0; i < tarray.length; i++) { - array[i] = tarray[i].offset(tref); - } - return array; - } - - private GeoDate[] getTimeArray(double[] array, GeoDate tref) { - GeoDate[] tarray = new GeoDate[array.length]; - for(int i=0; i < array.length; i++) { - tarray[i] = new GeoDate(tref); - tarray[i].increment(array[i], GeoDate.DAYS); - } - return tarray; - } - /** - * Given the current ContourLevels, mask, and - * SGTGrid generate the ContourLines. - */ - public void generateContourLines() { - double zrange; - double zc; - int kabij, kabip1, kabjp1; - int used0, used3; - int ll; - int i=0; - int j=0; - int ii, jj; - ContourLine cl; - int lin, k, kmax, nseg; - boolean reversed; - double xt, yt, frac; - double flm1, flp1; - int lp1, lp2, lm1; - int kda, kdb; - int exit; - - if(upToDate_) return; - - contourLines_ = new Vector(); - upToDate_ = true; - computeMinMax(); - // - // compute a small non-zero value for testing - // - zrange = (zmax_ - zmin_)*1.1; - if(zrange <= 0.0) return; - weezee_ = zrange*0.0002; - // - // loop over all contour levels - // - Enumeration lenum = contourLevels_.levelElements(); - while(lenum.hasMoreElements()) { - // - // initialize for level - // - zc = ((Double)lenum.nextElement()).doubleValue(); - if(Debug.CONTOUR) { - System.out.println("zc = " + zc); - } - if(zc <= zmin_ || zc >= zmax_) continue; - sides_.clear(); - if(mask_ != null) { - gridFlag_ = new GridFlag(grid_, mask_, zc); - } else { - gridFlag_ = new GridFlag(grid_, zc); - } - for(ii=0; ii < nx_; ii++) { /* 1001 */ - loop1000: - for(jj=0; jj < ny_; jj++) { /* 1000 */ - i = ii; - j = jj; - kabij = gridFlag_.getValue(i, j); - if(i < nx_-1) { - kabip1 = gridFlag_.getValue(i+1, j); - } else { - kabip1 = 10; - } - if(j < ny_-1) { - kabjp1 = gridFlag_.getValue(i, j+1); - } else { - kabjp1 = 10; - } - used0 = sides_.getSide(i, j, 0); - used3 = sides_.getSide(i, j, 3); - ll=0; /* bottom side */ - if(kabij + kabip1 + used0 == 0) { - computeCorners(i, j, zc); - } else if(kabij + kabjp1 + used3 == 0) { - ll=3; /* left side */ - computeCorners(i, j, zc); - } else { - continue; - } - // - // setup for new contour line - // - lin = ll; - k = 0; - nseg = 1; - reversed = false; - cl = new ContourLine(); - try { - cl.setAttributes(contourLevels_.getDefaultContourLineAttribute(), - contourLevels_.getContourLineAttribute(zc)); - } catch (ContourLevelNotFoundException e) { - System.out.println(e); - } - cl.setLevel(zc); - cl.setCartesianGraph(cg_); - cl.setTime(tref_, xTime_, yTime_); - contourLines_.addElement(cl); /* add to list */ - cl.addPoint(0.0, 0.0); /* dummy k=1 point */ - // - // Given entrance to square(i,j) on side lin, - // record the entrance point x(k), y(k). - // Set lin to used - // - // lin lp1 lp2 lm1 - // _________________________ - // 0 1 2 3 - // 1 2 3 0 - // 2 3 0 1 - // 3 0 1 2 - // - loop350: - while(true) { /* 350 */ - lp1 = lin + 1 - ((lin+1)/4)*4; - lp2 = lp1 + 1 - ((lp1+1)/4)*4; - lm1 = lp2 + 1 - ((lp2+1)/4)*4; - if(!reversed) { - k = k + 1; - frac = (zc - zz_[lin])/(zz_[lp1] - zz_[lin]); - xt = xx_[lin] + (xx_[lp1] - xx_[lin])*frac; - yt = yy_[lin] + (yy_[lp1] - yy_[lin])*frac; - cl.addPoint(xt, yt); - sides_.setSideUsed(i, j, lin, true); - } - // - // See if an exit exists on side l-1, l+1, or l+2. - // If so choose the one closest to side l. If the - // exit already used terminate x,y. - // - reversed = false; - exit = lm1; - if(kabov_[lin] + kabov_[lm1] == 0) { - if(kabov_[lp1] + kabov_[lp2] == 0) { - flm1 = (zc - zz_[lin])/(zz_[lm1] - zc); - flp1 = (zc - zz_[lp1])/(zz_[lp2] - zc); - if(!(used_[lp1] || - (flm1 <= flp1 && !used_[lm1]))) { - exit = lp1; - } - } - } else { - if(kabov_[lp1] + kabov_[lp2] == 0) { - exit = lp1; - } else { - exit = lp2; - if(kabov_[lp2] + kabov_[lm1] != 0) { /* 470 */ - if(kabov_[lp2] + kabov_[lm1] <= 15) { - kda = lin; - kdb = lp2; - if(kabov_[lp2] > 5) { - kda = lm1; - kdb = lp1; - } - k = k + 1; - frac = (zc - zz_[kda])/(zz_[kdb] - zz_[kda]); - xt = xx_[kda] + (xx_[kdb] - xx_[kda])*frac; - yt = yy_[kda] + (yy_[kdb] - yy_[kda])*frac; - cl.addPoint(xt, yt); - } - if(nseg > 1) { - kmax = k; - // - // pt(1) = pt(2) - // pt(kmax+1) = pt(kmax) - // - cl.setElementAt((Point2D.Double)cl.elementAt(1), 0); - cl.addPoint((Point2D.Double)cl.elementAt(k)); - cl.setClosed(false); - cl.setKmax(kmax); - continue loop1000; - } - reversed = true; - nseg = 2; - cl.reverseElements(k); - i=ii; - j=jj; - exit = ll; - // - // Find square entered by present exit. - // - // exit i j lin - // _________________________ - // 0 i j-1 2 - // 1 i+1 j 3 - // 2 i j+1 0 - // 3 i-1 j 1 - // - i = i + isin_[exit]; - j = j + isin_[3-exit]; - lin = exit + 2 - ((exit+2)/4)*4; - computeCorners(i, j, zc); - continue loop350; - } - } - } - if(used_[exit]) { - kmax = k + 1; - // - // pt(kmax) = pt(2) - // pt(1) = pt(k) - // pt(kmax+1) = pt(3) - // - cl.addPoint((Point2D.Double)cl.elementAt(1)); - cl.setElementAt((Point2D.Double)cl.elementAt(k), 0); - cl.addPoint((Point2D.Double)cl.elementAt(2)); - cl.setClosed(true); - cl.setKmax(kmax); - continue loop1000; - } - i = i + isin_[exit]; - j = j + isin_[3-exit]; - lin = exit + 2 - ((exit+2)/4)*4; - computeCorners(i, j, zc); - } /* 350 */ - } /* 1000 */ - } /* 1001 */ - } /* levels */ - } - - private void computeCorners(int i, int j, double zc) { - int jl, lp1, il; - boolean[] used = {false, false, false, false}; - // - // Get xx,yy,zz,kabov for each corner and - // used for each side. - // - // lcorner il jl lp1 - // 0 i j 1 - // 1 i+1 j 2 - // 2 i+1 j+1 3 - // 3 i j+1 0 - // - // - // lcorner definitions: - // (i,j+1) __________ (i+1,j+1) - // | 2 | - // | | - // 3| |1 - // | | - // |__________| - // (i,j) 0 (i+1,j) - // - for(int lcorner=0; lcorner < 4; lcorner++) { /* 620 */ - jl = j + lcorner/2; - lp1 = lcorner + 1 - ((lcorner+1)/4)*4; - il = i + lp1/2; - zz_[lcorner] = Double.NaN; - kabov_[lcorner] = 10; - if(((il+1)*(nx_-il) > 0) && ((jl+1)*(ny_-jl) > 0) && - (!gridFlag_.isMissing(il, jl))) { - used[lcorner] = sides_.isSideUsed(i, j, lcorner); - zz_[lcorner] = setZ(z(il, jl), zc); - if(zz_[lcorner] < zc) { - kabov_[lcorner] = -1; - } else { - kabov_[lcorner] = 1; - } - } - xx_[lcorner] = px_[Math.max(0,Math.min(il,nx_-1))]; - yy_[lcorner] = py_[Math.max(0,Math.min(jl,ny_-1))]; - } /* 620 */ - used_[0] = used[0]; - used_[1] = used[1]; - used_[2] = used[2]; - used_[3] = used[3]; - } - - private double z(int i, int j) { - return z_[j + i*ny_]; - } - - private double setZ(double z, double zc) { - double diff = z - zc; - if(Math.abs(diff) < weezee_) { - return zc + weezee_ * (diff>0.0?1.0:-1.0); - } else { - return z; - } - } - - private void computeMinMax() { - double[] grid = grid_.getZArray(); - double[] mask = null; - boolean haveMask = mask_ != null; - if(haveMask) mask = mask_.getZArray(); - - zmin_ = Double.POSITIVE_INFINITY; - zmax_ = Double.NEGATIVE_INFINITY; - - for(int i=0; i < grid.length; i++) { - if(!Double.isNaN(grid[i]) && - !(haveMask && (mask[i] == 0.0))) { - zmin_ = Math.min(zmin_, grid[i]); - zmax_ = Math.max(zmax_, grid[i]); - } - } - } - /** - * Given the computed ContourLines and the - * ContourLineAttribute generate the contour labels. - * Must be only invoked after generateConourLines(). - */ - public void generateContourLabels(Graphics g) { - int i, j, k, kk, km1, kp1; - int nx, ny; - double dx, dy, dzdx, dzdy, dzdg; - GeoDate tref = null; - GeoDate time; - double[] x, y, z, s; - double dxx, dyy, smax; - double space = 0.0; - double ark = 1.0; - boolean roomFound; - double slab1, stest; - double width, hgt; - double xa, xb, ya, yb, aa, bb, cc, zxy; - double xendl, yendl; - // double xst, yst, xstp, ystp; - double xlab, ylab, hhgt, angle; - SGLabel label; - double[] px, py; - boolean xIncreasing, yIncreasing; - double dlev, cspace; - Enumeration elem = contourLines_.elements(); - ContourLine cl; - while(elem.hasMoreElements()) { - cl = (ContourLine)elem.nextElement(); - int kmax = cl.getKmax(); - int lev = contourLevels_.getIndex(cl.getLevel()); - if(Debug.CONTOUR) { - // System.out.println("drawLabelContourLine: lev = " + lev + - // ", level = " + cl.getLevel()); - } - DefaultContourLineAttribute cattr = cl.getDefaultContourLineAttribute(); - cattr.setContourLineAttribute(cl.getContourLineAttribute()); - if(kmax <= 1 || !cattr.isLabelEnabled()) continue; - // - // create SGLabel at a dummy location and no rotation - // - label = new SGLabel("CLevel", - cattr.getLabelText(), - cattr.getLabelHeightP(), - new Point2D.Double(0.0,0.0), - SGLabel.BOTTOM, - SGLabel.LEFT); - if(cattr.getLabelFont() != null) label.setFont(cattr.getLabelFont()); - label.setColor(cattr.getLabelColor()); - label.setLayer(cg_.getLayer()); - // - // compute hgt and width from font - // - int swidth = (int)label.getStringWidth(g); - int sheight = (int)label.getStringHeight(g); - width = cg_.getLayer().getXDtoP(swidth) - cg_.getLayer().getXDtoP(0); - // - hgt = cg_.getLayer().getYDtoP(0) - cg_.getLayer().getYDtoP(sheight); - // - hhgt = hgt*0.5; - width = width + hhgt; - if(Debug.CONTOUR) { - // System.out.println("drawLabeledContourLine: hhgt,width = " + - // hhgt + ", " + width); - } - // - px = xArrayP(); - py = yArrayP(); - z = grid_.getZArray(); - xIncreasing = px[0] < px[1]; - yIncreasing = py[0] < py[1]; - nx = px.length; - ny = py.length; - // - x = new double[kmax+1]; - y = new double[kmax+1]; - s = new double[kmax+1]; - if(cl.isXTime() || cl.isYTime()) { - tref = cl.getReferenceTime(); - } - s[1] = 0.0; - // - // convert ContourLine to physical units - // - x = cl.getXArrayP(); - y = cl.getYArrayP(); - // - // compute s[k] - // - for(k=2; k <= kmax; k++) { - dxx = x[k] - x[k-1]; - dyy = y[k] - y[k-1]; - s[k] = s[k-1] + Math.sqrt(dxx*dxx+dyy*dyy); - } - smax = s[kmax]; - slab1 = smax*SLAB1F; - stest = Math.max(0.0, DSLAB - slab1); - k=1; - // - // check conditions for labelling - // - while(k < kmax) { /* 755 */ - km1 = Math.max(k-1, 1); - stest = stest + s[k] - s[km1]; - // - // Test if there is enough room for a label - // - if(stest < DSLAB || (smax - s[k]) <= 2.0*width) { - // drawLineSegment(g, x[k], y[k], x[k+1], y[k+1]); - k=k+1; - continue; - } - kp1 = k + 1; - // - // gradient test - // - if(lev != 0) { - try { - dlev = Math.abs(contourLevels_.getLevel(lev) - - contourLevels_.getLevel(lev-1)); - if(xIncreasing) { - for(i=0; i < nx-1; i++) { - if(x[k] >= px[i] && x[k] <= px[i+1]) break; - } - } else { - for(i=0; i < nx-1; i++) { - if(x[k] <= px[i] && x[k] >= px[i+1]) break; - } - } - if(yIncreasing) { - for(j=0; j < ny-1; j++) { - if(y[k] >= py[j] && y[k] <= py[j+1]) break; - } - } else { - for(j=0; j < ny-1; j++) { - if(y[k] <= py[j] && y[k] >= py[j+1]) break; - } - } - i = Math.min(i, nx-2); - j = Math.min(j, ny-2); - dx = px[i+1] - px[i]; - dy = py[j+1] - py[j]; - if(Double.isNaN(z[j+(i+1)*ny])) { - dzdx = 0.0; - } else { - dzdx = (z[j+(i+1)*ny] - z[j+i*ny])/dx; - } - if(Double.isNaN(z[j+1+i*ny])) { - dzdy = 0.0; - } else { - dzdy = (z[j+1+i*ny] - z[j+i*ny])/dy; - } - // - // dzdg = sqrt(dzdx*dzdx+dzdy*dzdy) - // - // replace with less prone to overflow - // calculation - // - dzdg = Math.abs(dzdx) + Math.abs(dzdy); - if(dzdg != 0.0) { - cspace = dlev/dzdg; - // - // is there room for label height? - // (was 0.75) - if(cspace < hgt*1.0) { - // drawLineSegment(g, x[k], y[k], x[k+1], y[k+1]); - k=k+1; - continue; - } - } - } catch (ContourLevelNotFoundException e) { - System.out.println(e); - } - } - // - // test line arc - // - roomFound = false; - for(kk=kp1; kk <= kmax; kk++) { - dxx = x[kk] - x[k]; - dyy = y[kk] - y[k]; - space = Math.sqrt(dxx*dxx + dyy*dyy); - ark = s[kk] - s[k]; - if(space >= width) { - roomFound = true; - break; - } - } - if(space/ark < 0.80 || !roomFound) { - // drawLineSegment(g, x[k], y[k], x[k+1], y[k+1]); - k=k+1; - continue; - } else { - // - // add label to contour line - // - cl.addLabel(k, (SGLabel)label.copy(), hgt, width); - // - // draw the label - // - stest = 0.0; /* 810 */ -// xa = x[kk-1] - x[k]; -// xb = x[kk] - x[kk-1]; -// ya = y[kk-1] - y[k]; -// yb = y[kk] - y[kk-1]; -// aa = xb*xb + yb*yb; -// bb = xa*xb + ya*yb; -// cc = xa*xa + ya*ya - width*width; -// zxy = (-bb + Math.sqrt(bb*bb - aa*cc))/aa; -// dxx = xa + xb*zxy; -// dyy = ya + yb*zxy; -// xendl = x[k] + dxx; -// yendl = y[k] + dyy; -// // -// // compute label angle -// // -// angle = 90.0; -// if(dyy < 0.0) angle = -90.0; -// if(dxx != 0.0) { -// angle = Math.atan(dyy/dxx)*180.0/Math.PI; -// } -// // -// // compute label position -// // -// if(dxx >= 0) { -// xlab = x[k] + hhgt*(0.5*dxx + dyy)/width; -// ylab = y[k] + hhgt*(0.5*dyy - dxx)/width; -// } else { -// xlab = xendl - hhgt*(0.5*dxx + dyy)/width; -// ylab = yendl - hhgt*(0.5*dyy - dxx)/width; -// } -// label.setAngle(angle); -// label.setLocationP(new Point2D.Double(xlab, ylab)); -// try { -// label.draw(g); -// // drawRotatedRectangle(g, angle, xlab, ylab, width-hhgt, hgt); -// } catch (LayerNotFoundException e) { -// System.out.println(e); -// } -// drawLineSegment(g, xendl, yendl, x[kk], y[kk]); - k = kk; - } - } - } - } - - private void drawRotatedRectangle(Graphics g, - double angle, - double x0, double y0, - double width, double height) { - double sinthta = Math.sin(angle*Math.PI/180.0); - double costhta = Math.cos(angle*Math.PI/180.0); - double[] x, y; - double xp, yp; - int[] xd, yd; - double xorig, yorig; - x = new double[4]; - y = new double[4]; - xd = new int[5]; - yd = new int[5]; - xorig = x0; - yorig = y0; - x[0] = x0; - y[0] = y0; - x[1] = x[0] + width; - y[1] = y[0]; - x[2] = x[1]; - y[2] = y[0] + height; - x[3] = x[0]; - y[3] = y[2]; - for(int i=0; i < 4; i++) { - xp = (x[i]-xorig)*costhta - (y[i]-yorig)*sinthta + xorig; - yp = (y[i]-yorig)*costhta + (x[i]-xorig)*sinthta + yorig; - xd[i] = cg_.getLayer().getXPtoD(xp); - yd[i] = cg_.getLayer().getYPtoD(yp); - } - xd[4] = xd[0]; - yd[4] = yd[0]; - g.setColor(Color.blue); - g.drawPolyline(xd, yd, 5); - g.setColor(Color.black); - } - -// private void drawLineSegment(Graphics g, double x0, double y0, -// double x1, double y1) { /* 900 */ -// int xd0, yd0, xd1, yd1; -// xd0 = cg_.getLayer().getXPtoD(x0); -// yd0 = cg_.getLayer().getYPtoD(y0); -// xd1 = cg_.getLayer().getXPtoD(x1); -// yd1 = cg_.getLayer().getYPtoD(y1); -// g.drawLine(xd0, yd0, xd1, yd1); -// } - - private double[] xArrayP() { - int i; - double[] p; - if(grid_.isXTime()) { - GeoDate[] t = grid_.getTimeArray(); - p = new double[t.length]; - for(i=0; i < t.length; i++) { - p[i] = cg_.getXUtoP(t[i]); - } - } else { - double[] x = grid_.getXArray(); - p = new double[x.length]; - for(i=0; i < x.length; i++) { - p[i] = cg_.getXUtoP(x[i]); - } - } - return p; - } - - private double[] yArrayP() { - int i; - double[] p; - if(grid_.isYTime()) { - GeoDate[] t = grid_.getTimeArray(); - p = new double[t.length]; - for(i=0; i < t.length; i++) { - p[i] = cg_.getYUtoP(t[i]); - } - } else { - double[] y = grid_.getYArray(); - p = new double[y.length]; - for(i=0; i < y.length; i++) { - p[i] = cg_.getYUtoP(y[i]); - } - } - return p; - } - -// private void drawContourLine(Graphics g, ContourLine cl) { -// GeoDate tref, time; -// Point2D.Double[] pt; -// int i; -// // int size = cl.size(); -// int size = cl.getKmax() + 1; -// if(size <= 3) return; -// int[] xp = new int[size]; -// int[] yp = new int[size]; -// pt = new Point2D.Double[size]; -// for(i=0; i < size; i++) { -// pt[i] = (Point2D.Double)cl.elementAt(i); -// } -// if(cl.isXTime()) { -// tref = cl.getReferenceTime(); -// for(i=0; i < size; i++) { -// time = (new GeoDate(tref)).increment(pt[i].x, GeoDate.DAYS); -// xp[i] = cg_.getXUtoD(time); -// } -// } else { -// for(i=0; i < size; i++) { -// xp[i] = cg_.getXUtoD(pt[i].x); -// } -// } -// if(cl.isYTime()) { -// tref = cl.getReferenceTime(); -// for(i=0; i < size; i++) { -// time = (new GeoDate(tref)).increment(pt[i].y, GeoDate.DAYS); -// yp[i] = cg_.getYUtoD(time); -// } -// } else { -// for(i=0; i < size; i++) { -// yp[i] = cg_.getYUtoD(pt[i].y); -// } -// } -// g.drawPolyline(xp, yp, size); -// } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/ContourLabel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/ContourLabel.java deleted file mode 100755 index bb821e53..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/ContourLabel.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * $Id: ContourLabel.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.contour; - -import gov.noaa.pmel.sgt.SGLabel; - -/** - * Container for information about where labels should - * be inserted on a ContourLine. - * - * @author D. W. Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ -class ContourLabel { - int index; - - /** - * @label label - * @link aggregationByValue - * @supplierCardinality 1 - */ - SGLabel label; - double width; - double height; - - public ContourLabel(int indx, SGLabel lab, double hgt, double wid) { - index = indx; - label = lab; - width = wid; - height = hgt; - } - public SGLabel getLabel() { - return label; - } - public int getIndex() { - return index; - } - public double getWidth() { - return width; - } - public double getHeight() { - return height; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/ContourLine.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/ContourLine.java deleted file mode 100755 index ad03cd5d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/ContourLine.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * $Id: ContourLine.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.contour; - -import java.util.Vector; -import java.util.Enumeration; - -import java.awt.Graphics; -import java.awt.Color; - -import gov.noaa.pmel.sgt.ContourLineAttribute; -import gov.noaa.pmel.sgt.DefaultContourLineAttribute; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.LayerNotFoundException; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.StrokeDrawer; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.GeoDate; - -/** - * ContourLine contains a single closed or open contour - * and a list of its labels. - * The level, closedness, and path are properties. - * The path is stored as a Vector of Point2D - * user coordinate values. ContourLine objects are - * created by Contour and drawn by - * GridCartesianRenderer. Time coordinates are stored in - * the Point2D objects releative to a reference time. - * - * @author D. W. Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - * @see Contour - * @see ContourLineAttribute - * @see DefaultContourLineAttribute - * @see gov.noaa.pmel.sgt.GridCartesianRenderer - */ -public class ContourLine extends Vector { - private StrokeDrawer stroke_ = null; - - private boolean closed_ = false; - private double level_; - private GeoDate timeRef_ = null; - private boolean xTime_ = false; - private boolean yTime_ = false; - private int kmax_; - - /** - * @label attr - */ - private ContourLineAttribute attr_ = null; - private DefaultContourLineAttribute defaultAttr_ = null; - private Vector conLabels_; - - /** - * @supplierCardinality * - * @link aggregationByValue - */ - private ContourLabel lnkContourLabel; - - private CartesianGraph cg_; - /** - * Default constructor. - */ - public ContourLine() { - super(); - conLabels_ = new Vector(); - stroke_ = JPane.getStrokeDrawer(); - } - /** - * Constructor setting initial size and extend values of coordinate - * Vector. - */ - public ContourLine(int size, int extend) { - super(size, extend); - conLabels_ = new Vector(); - stroke_ = JPane.getStrokeDrawer(); - } - /** - * Constructor setting initial size of coordinate Vector. - */ - public ContourLine(int size) { - super(size); - conLabels_ = new Vector(); - stroke_ = JPane.getStrokeDrawer(); - } - /** - * Set the parent CartesianGraph. Used internally by - * sgt. - */ - public void setCartesianGraph(CartesianGraph cg) { - cg_ = cg; - } - /** - * Set the attributes for the contour line. - */ - public void setAttributes(DefaultContourLineAttribute def, ContourLineAttribute attr) { - defaultAttr_ = def; - attr_ = attr; - } - /** - * Set the ContourLineAttribute - */ - public void setContourLineAttribute(ContourLineAttribute attr) { - attr_ = attr; - } - - /** - * Get the ContourLineAttribute - */ - public ContourLineAttribute getContourLineAttribute() { - return attr_; - } - /** - * Set the DefaultContourLineAttribute - */ - public void setDefaultContourLineAttribute(DefaultContourLineAttribute def) { - defaultAttr_ = def; - } - /** - * Get the DefaultContourLineAttribute - */ - public DefaultContourLineAttribute getDefaultContourLineAttribute() { - return defaultAttr_; - } - - void setClosed(boolean closed){ - closed_ = closed; - } - /** - * Is the contour line closed? - */ - public boolean isClosed() { - return closed_; - } - /** - * The level value of the contour line. - */ - public double getLevel(){ - return level_; - } - - void setLevel(double level){ - level_ = level; - } - - void addPoint(double x, double y) { - addElement(new Point2D.Double(x, y)); - } - - void addPoint(Point2D.Double point) { - addElement(point); - } - - void setKmax(int kmax) { - kmax_ = kmax; - } - /** - * Get the number of points in the contour line. - */ - public int getKmax() { - return kmax_; - } - - void setTime(GeoDate tref, boolean xtime, boolean ytime) { - timeRef_ = tref; - xTime_ = xtime; - yTime_ = ytime; - } - - void setReferenceTime(GeoDate tref) { - timeRef_ = tref; - } - /** - * Get reference time for the time point of the Point2D object. - */ - public GeoDate getReferenceTime() { - return timeRef_; - } - - void setXTime(boolean time) { - xTime_ = time; - } - /** - * Is the x coordinate time? - */ - public boolean isXTime() { - return xTime_; - } - - void setYTime(boolean time) { - yTime_ = time; - } - /** - * Is the y coordinate time? - */ - public boolean isYTime() { - return yTime_; - } - - void reverseElements(int k) { - /* k is reversal length */ - Point2D.Double point; - int kkr; - int kh = 1 + k/2; - for(int kk=1; kk < kh; kk++) { - kkr = k+1-kk; - point = (Point2D.Double)elementAt(kk); - setElementAt(elementAt(kkr), kk); - setElementAt(point, kkr); - } - } - /** - * Add a label to the contour line. - */ - public void addLabel(int point, SGLabel lab, double hgt, double wid) { - ContourLabel clab = new ContourLabel(point, lab, hgt, wid); - conLabels_.addElement(clab); - } - /** - * Remove all labels. - */ - public void removeAllLabels() { - conLabels_.removeAllElements(); - } - /** - * Used internally by sgt. - */ - public void draw(Graphics g) { - int k, kk, loc, kp1; - double[] x = new double[kmax_+1]; - double[] y = new double[kmax_+1]; - ContourLabel clab; - double width, hhgt; - double dxx, dyy, space; - double xa, xb, ya, yb, aa, bb, cc, zxy; - double xendl, yendl, angle; - double xlab, ylab; - SGLabel label; - GeoDate time; - defaultAttr_.setContourLineAttribute(attr_); - Color lineColor = defaultAttr_.getColor(); - // - // convert ContourLine to physical units - // - x = getXArrayP(); - y = getYArrayP(); - // - // loop through labels - // - k=1; - Enumeration cenum = conLabels_.elements(); - while(cenum.hasMoreElements()) { - clab = (ContourLabel)cenum.nextElement(); - loc = clab.getIndex(); - width = clab.getWidth(); - hhgt = clab.getHeight()*0.5; - label = clab.getLabel(); - // - g.setColor(lineColor); - drawLine(g, x, y, k, loc); - // - k = loc; - kp1 = k + 1; - for(kk=kp1; kk <= kmax_; kk++) { - dxx = x[kk] - x[k]; - dyy = y[kk] - y[k]; - space = Math.sqrt(dxx*dxx+dyy*dyy); - if(space >= width) break; - } - xa = x[kk-1] - x[k]; - xb = x[kk] - x[kk-1]; - ya = y[kk-1] - y[k]; - yb = y[kk] - y[kk-1]; - aa = xb*xb + yb*yb; - bb = xa*xb + ya*yb; - cc = xa*xa + ya*ya - width*width; - zxy = (-bb + Math.sqrt(bb*bb - aa*cc))/aa; - dxx = xa + xb*zxy; - dyy = ya + yb*zxy; - xendl = x[k] + dxx; - yendl = y[k] + dyy; - // - // compute label angle - // - angle = 90.0; - if(dyy < 0.0) angle = -90.0; - if(dxx != 0.0) { - angle = Math.atan(dyy/dxx)*180.0/Math.PI; - } - // - // compute label position - // - if(dxx >= 0) { - xlab = x[k] + hhgt*(0.5*dxx + dyy)/width; - ylab = y[k] + hhgt*(0.5*dyy - dxx)/width; - } else { - xlab = xendl - hhgt*(0.5*dxx + dyy)/width; - ylab = yendl - hhgt*(0.5*dyy - dxx)/width; - } - label.setAngle(angle); - label.setLocationP(new Point2D.Double(xlab, ylab)); - try { - label.draw(g); - } catch (LayerNotFoundException e) { - System.out.println(e); - } - g.setColor(lineColor); - drawLineSegment(g, xendl, yendl, x[kk], y[kk]); - k=kk; - } - if(k < kmax_) { - g.setColor(lineColor); - drawLine(g, x, y, k, kmax_); - } - } - - private void drawLine(Graphics g, double[] x, double[] y, - int kstart, int kend) { - int size = kend-kstart+1; - int[] xp = new int[size]; - int[] yp = new int[size]; - int i, k; - for(i=0, k=kstart; k <= kend; k++, i++) { - xp[i] = cg_.getLayer().getXPtoD(x[k]); - yp[i] = cg_.getLayer().getYPtoD(y[k]); - } - switch(defaultAttr_.getStyle()) { - case LineAttribute.HIGHLIGHT: - stroke_.drawHighlight(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - case LineAttribute.HEAVY: - stroke_.drawHeavy(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - case LineAttribute.DASHED: - stroke_.drawDashed(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - case LineAttribute.STROKE: - stroke_.drawStroke(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - default: - case LineAttribute.MARK: - case LineAttribute.MARK_LINE: - case LineAttribute.SOLID: - g.drawPolyline(xp, yp, size); - } - } - - private void drawLineSegment(Graphics g, double x0, double y0, - double x1, double y1) { - int[] xp, yp; - int size = 2; - xp = new int[2]; - yp = new int[2]; - xp[0] = cg_.getLayer().getXPtoD(x0); - yp[0] = cg_.getLayer().getYPtoD(y0); - xp[1] = cg_.getLayer().getXPtoD(x1); - yp[1] = cg_.getLayer().getYPtoD(y1); - switch(defaultAttr_.getStyle()) { - case LineAttribute.HIGHLIGHT: - stroke_.drawHighlight(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - case LineAttribute.HEAVY: - stroke_.drawHeavy(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - case LineAttribute.DASHED: - stroke_.drawDashed(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - case LineAttribute.STROKE: - stroke_.drawStroke(g, xp, yp, size, (LineAttribute)defaultAttr_); - break; - default: - case LineAttribute.MARK: - case LineAttribute.MARK_LINE: - case LineAttribute.SOLID: - g.drawPolyline(xp, yp, size); - } - } - /** - * Get x physical coordinates of the contour line. - */ - public double[] getXArrayP() { - double[] xp = null; - Point2D.Double pt; - GeoDate time; - if(cg_ != null) { - xp = new double[kmax_+1]; - for(int k=0; k <= kmax_; k++) { - pt = (Point2D.Double)elementAt(k); - if(isXTime()) { - time = (new GeoDate(timeRef_)).increment(pt.x, GeoDate.DAYS); - xp[k] = cg_.getXUtoP(time); - } else { - xp[k] = cg_.getXUtoP(pt.x); - } - } - } - return xp; - } - /** - * Get y physical coordinates of the contour line. - */ - public double[] getYArrayP() { - double[] yp = null; - Point2D.Double pt; - GeoDate time; - if(cg_ != null) { - yp = new double[kmax_+1]; - for(int k=0; k <= kmax_; k++) { - pt = (Point2D.Double)elementAt(k); - if(isYTime()) { - time = (new GeoDate(timeRef_)).increment(pt.x, GeoDate.DAYS); - yp[k] = cg_.getYUtoP(time); - } else { - yp[k] = cg_.getYUtoP(pt.y); - } - } - } - return yp; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/GridFlag.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/GridFlag.java deleted file mode 100755 index ad9c857a..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/GridFlag.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * $Id: GridFlag.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.contour; - -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.sgt.dm.SGTGrid; - -/** - * Used to set and test whether a grid value is less than, equal, or - * greater than a contour level. - * - * @author D. W. Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ -class GridFlag { - public final static int LESS_THAN_ZC = -1; - public final static int MISSING = 10; - public final static int GREATER_THAN_ZC = 1; - - private double[] array_; - private double[] mask_ = null; - private byte[] value_; - private int nx_; - private int ny_; - - public GridFlag(SGTGrid grid, double zc) { - this(grid, null, zc); - } - - public GridFlag(SGTGrid grid, SGTGrid mask, double zc) { - if(grid.isXTime()) { - nx_ = grid.getTSize(); - } else { - nx_ = grid.getXSize(); - } - if(grid.isYTime()) { - ny_ = grid.getTSize(); - } else { - ny_ = grid.getYSize(); - } - value_ = new byte[nx_*ny_]; - array_ = grid.getZArray(); - setLevel(zc); - if(mask != null) setMask(mask); - } - - public void setMask(SGTGrid mask) { - mask_ = mask.getZArray(); - applyMask(); - } - - void applyMask() { - if(mask_ == null) return; - for(int i=0; i < nx_*ny_; i++) { - if(Double.isNaN(mask_[i]) || mask_[i] != 0.0) { - value_[i] = MISSING; - } - } - } - - public void setLevel(double zc) { - for(int i=0; i < nx_*ny_; i++) { - if(!Double.isNaN(array_[i])) { - if(array_[i] <= zc) { - value_[i] = LESS_THAN_ZC; - } else { - value_[i] = GREATER_THAN_ZC; - } - } else { - value_[i] = MISSING; - } - } - applyMask(); - } - - int index(int i, int j) { - return j + ny_*i; - } - /** - * True if grid(i,j) is missing. - */ - public boolean isMissing(int i, int j) { - int ind = index(i,j); - if(Debug.CONTOUR) { - if(ind < 0 || ind >= nx_*ny_) { - System.out.println("GridFlag.isMissing(): (i,j) = (" + i + ", " + j + ")"); - } - } - return (value_[ind] == MISSING); - } - - public boolean isGreater(int i, int j ) { - int ind = index(i,j); - if(Debug.CONTOUR) { - if(ind < 0 || ind >= nx_*ny_) { - System.out.println("GridFlag.isGreater(): (i,j) = (" + i + ", " + j + ")"); - } - } - return (value_[ind] == GREATER_THAN_ZC); - } - - public int getValue(int i, int j) { - int ind = index(i,j); - if(Debug.CONTOUR) { - if(ind < 0 || ind >= nx_*ny_) { - System.out.println("GridFlag.getValue(): (i,j) = (" + i + ", " + j + ")"); - } - } - return value_[ind]; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/PolygonGenerator.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/PolygonGenerator.java deleted file mode 100755 index fac5f63d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/PolygonGenerator.java +++ /dev/null @@ -1,8 +0,0 @@ -/* Generated by Together */ - -package gov.noaa.pmel.sgt.contour; -/** - * Not implemented. - */ -public class PolygonGenerator { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/PolygonRenderer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/PolygonRenderer.java deleted file mode 100755 index 01b6476c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/PolygonRenderer.java +++ /dev/null @@ -1,8 +0,0 @@ -/* Generated by Together */ - -package gov.noaa.pmel.sgt.contour; -/** - * Not implemented. - */ -public class PolygonRenderer { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Sides.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Sides.java deleted file mode 100755 index 2cd54118..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Sides.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * $Id: Sides.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.contour; - -import gov.noaa.pmel.util.Debug; - -import java.util.BitSet; - -/** - * Used to keep track of which sides have been used during the contour - * line generation process. - * - * @author D. W. Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ -class Sides { - BitSet sides_; - int nx_; - int ny_; - int ny2_; - - public Sides(int nx, int ny) { - nx_ = nx; - ny_ = ny; - ny2_ = ny_*2; - sides_ = new BitSet(ny2_*nx_); - } - - public boolean isSideUsed(int i, int j, int side) { - int ind = index(i,j,side); - if(ind < 0 || ind > ny2_*nx_-1) { - if(Debug.CONTOUR) { - System.out.println("Sides.isSideUsed(): (i,j,side) = " + i + ", " + j + ", " + side); - } - return false; - } - return sides_.get(ind); - } - - public void setSideUsed(int i, int j, int side, boolean set) { - int ind = index(i,j,side); - if(Debug.CONTOUR) { - if(ind < 0 || ind > ny2_*nx_-1) { - System.out.println("Sides.setSideUsed(): (i,j,side) = " + i + ", " + j + ", " + side); - } - } - if(set) { - sides_.set(ind); - } else { - sides_.clear(ind); - } - } - - public int getSide(int i, int j, int side) { - int ind = index(i,j,side); - if(ind < 0 || ind > ny2_*nx_-1) { - if(Debug.CONTOUR) { - System.out.println("Sides.getSide(): (i,j,side) = " + i + ", " + j + ", " + side); - } - return 0; - } - return sides_.get(ind)?1:0; - } - - int index(int i, int j, int side) { - int index = -10; - if(side == 1) { /* i+1,j right */ - index = 1 + j*2 + (i+1)*ny2_; - } else if(side == 2) { /* i,j+1 top */ - index = (j+1)*2 + i*ny2_; - } else if(side == 0) { /* i,j bottom */ - index = j*2 + i*ny2_; - } else if(side == 3) { /* i,j left */ - index = 1 + j*2 + i*ny2_; - } - return index; - } - public void clear() { - sides_ = new BitSet(ny2_*nx_); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Tree.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Tree.java deleted file mode 100755 index 52cb166c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/Tree.java +++ /dev/null @@ -1,8 +0,0 @@ -/* Generated by Together */ - -package gov.noaa.pmel.sgt.contour; -/** - * Not implemented. - */ -public class Tree { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/TreeEnumerator.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/TreeEnumerator.java deleted file mode 100755 index c5075877..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/TreeEnumerator.java +++ /dev/null @@ -1,14 +0,0 @@ -/* Generated by Together */ - -package gov.noaa.pmel.sgt.contour; -/** - * Not implemented. - */ -public class TreeEnumerator implements java.util.Enumeration { - public boolean hasMoreElements() { - return false; - } - public Object nextElement() { - return null; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/TreeGenerator.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/TreeGenerator.java deleted file mode 100755 index 5e87bcdc..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/TreeGenerator.java +++ /dev/null @@ -1,8 +0,0 @@ -/* Generated by Together */ - -package gov.noaa.pmel.sgt.contour; -/** - * Not implemented. - */ -public class TreeGenerator { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/package.html deleted file mode 100755 index 3be8be18..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/contour/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - -Contour and polygon fill support. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/AddDataFrame.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/AddDataFrame.java deleted file mode 100755 index de388f57..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/AddDataFrame.java +++ /dev/null @@ -1,927 +0,0 @@ -/* - * $Id: AddDataFrame.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import java.awt.*; -import javax.swing.*; -import java.awt.event.*; -import javax.swing.border.*; -import java.util.Iterator; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.SGTVector; -import gov.noaa.pmel.sgt.Attribute; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.VectorAttribute; -import gov.noaa.pmel.sgt.beans.*; -import gov.noaa.pmel.sgt.ColorMap; -import gov.noaa.pmel.sgt.IndexedColorMap; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.sgt.beans.Page; - -import javax.swing.event.*; - -/** - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 3.0 - **/ -class AddDataFrame extends JFrame { - private BorderLayout borderLayout1 = new BorderLayout(); - private JPanel jPanel1 = new JPanel(); - private JPanel jPanel2 = new JPanel(); - private JButton okButton = new JButton(); - private JButton cancelButton = new JButton(); - private JPanel sourcePanel = new JPanel(); - private JPanel targetPanel = new JPanel(); - private GridBagLayout gridBagLayout1 = new GridBagLayout(); - private TitledBorder sourceBorder; - private TitledBorder targetBorder; - private Page page_ = null; - private JScrollPane jScrollPane1 = new JScrollPane(); - private GridBagLayout gridBagLayout2 = new GridBagLayout(); - private JScrollPane jScrollPane2 = new JScrollPane(); - private JScrollPane jScrollPane3 = new JScrollPane(); - private JList panelList = new JList(); - private JList axisGroupList = new JList(); - private JList legendList = new JList(); - private TitledBorder panelBorder; - private TitledBorder axisGroupBorder; - private TitledBorder legendBorder; - private BorderLayout borderLayout2 = new BorderLayout(); - private JPanel jPanel3 = new JPanel(); - private JLabel jLabel1 = new JLabel(); - private JComboBox dataTypeCB = new JComboBox(); - private JPanel cardPanel = new JPanel(); - private CardLayout cardLayout1 = new CardLayout(); - private JPanel oneDSpatialPanel = new JPanel(); - private JPanel twoDSpatialPanel = new JPanel(); - private JPanel oneDTimePanel = new JPanel(); - private JPanel twoDTimePanel = new JPanel(); - private JPanel pointPanel = new JPanel(); - private JLabel jLabel2 = new JLabel(); - private JComboBox dir1SCB = new JComboBox(); - private GridBagLayout gridBagLayout3 = new GridBagLayout(); - private JLabel jLabel3 = new JLabel(); - private JPanel jPanel5 = new JPanel(); - private JTextField delta1STF = new JTextField(); - private JTextField max1STF = new JTextField(); - private JTextField min1STF = new JTextField(); - private JLabel jLabel4 = new JLabel(); - private JComboBox type1SCB = new JComboBox(); - private JLabel jLabel5 = new JLabel(); - private JTextField amp1STF = new JTextField(); - private JLabel jLabel6 = new JLabel(); - private JTextField off1STF = new JTextField(); - private JLabel jLabel7 = new JLabel(); - private JTextField per1STF = new JTextField(); - private GridBagLayout gridBagLayout4 = new GridBagLayout(); - private Component component1; - private String[] args = {"1-d Spatial", "2-d Spatial", - "1-d Time", "2-d Time", "Point", "Vector"}; - private DefaultComboBoxModel dataTypeModel = new DefaultComboBoxModel(args); - - private String[] dir1Sargs = {"X_SERIES", "Y_SERIES", "PROFILE", "LOG_LOG"}; - private String[] dir2Sargs = {"XY_GRID", "XZ_GRID", "YZ_GRID"}; - private DefaultComboBoxModel dir1SModel = new DefaultComboBoxModel(dir1Sargs); - private DefaultComboBoxModel dir2SModel = new DefaultComboBoxModel(dir2Sargs); - - private String[] typeargs = {"SINE", "RANDOM"}; - private DefaultComboBoxModel typeModel = new DefaultComboBoxModel(typeargs); - private GridBagLayout gridBagLayout5 = new GridBagLayout(); - private JLabel jLabel8 = new JLabel(); - private JComboBox dir2SCB = new JComboBox(); - private JLabel jLabel9 = new JLabel(); - private JPanel jPanel4 = new JPanel(); - private JTextField delta12STF = new JTextField(); - private JTextField max12STF = new JTextField(); - private JTextField min12STF = new JTextField(); - private JLabel jLabel10 = new JLabel(); - private JPanel jPanel6 = new JPanel(); - private JTextField delta22STF = new JTextField(); - private JTextField max22STF = new JTextField(); - private JTextField min22STF = new JTextField(); - private JLabel jLabel11 = new JLabel(); - private JComboBox type2SCB = new JComboBox(); - private JLabel jLabel12 = new JLabel(); - private JTextField amp2STF = new JTextField(); - private JLabel jLabel13 = new JLabel(); - private JTextField off2STF = new JTextField(); - private JLabel jLabel14 = new JLabel(); - private JTextField per2STF = new JTextField(); - private GridBagLayout gridBagLayout6 = new GridBagLayout(); - private GridBagLayout gridBagLayout7 = new GridBagLayout(); - private Component component2; - private Component component3; - private GridBagLayout gridBagLayout8 = new GridBagLayout(); - private JTextField amp1TTF = new JTextField(); - private Component component4; - private JComboBox type1TCB = new JComboBox(); - private GridBagLayout gridBagLayout9 = new GridBagLayout(); - private JTextField max1TTF = new JTextField(); - private JLabel jLabel15 = new JLabel(); - private JTextField off1TTF = new JTextField(); - private JLabel jLabel16 = new JLabel(); - private JTextField per1TTF = new JTextField(); - private JLabel jLabel17 = new JLabel(); - private JTextField min1TTF = new JTextField(); - private JLabel jLabel18 = new JLabel(); - private JPanel jPanel7 = new JPanel(); - private JLabel jLabel19 = new JLabel(); - private JTextField delta1TTF = new JTextField(); - private JLabel jLabel20 = new JLabel(); - private GridBagLayout gridBagLayout10 = new GridBagLayout(); - private JLabel jLabel110 = new JLabel(); - private JLabel jLabel111 = new JLabel(); - private JLabel jLabel112 = new JLabel(); - private GridBagLayout gridBagLayout11 = new GridBagLayout(); - private JTextField delta22TTF = new JTextField(); - private Component component5; - private JTextField amp2TTF = new JTextField(); - private JComboBox type2TCB = new JComboBox(); - private JTextField max22TTF = new JTextField(); - private JPanel jPanel8 = new JPanel(); - private JTextField off2TTF = new JTextField(); - private JLabel jLabel113 = new JLabel(); - private JTextField min22TTF = new JTextField(); - private JLabel jLabel114 = new JLabel(); - private JTextField per2TTF = new JTextField(); - private JLabel jLabel21 = new JLabel(); - private JLabel jLabel22 = new JLabel(); - private Component component6; - private GridBagLayout gridBagLayout12 = new GridBagLayout(); - private JTextField max12TTF = new JTextField(); - private JTextField min12TTF = new JTextField(); - private JPanel jPanel9 = new JPanel(); - private JTextField delta12TTF = new JTextField(); - private GridBagLayout gridBagLayout13 = new GridBagLayout(); - private GridBagLayout gridBagLayout14 = new GridBagLayout(); - private JPanel jPanel10 = new JPanel(); - private JTextField delta2PTF = new JTextField(); - private JPanel jPanel11 = new JPanel(); - private JTextField max2PTF = new JTextField(); - private JLabel jLabel119 = new JLabel(); - private JTextField min1PTF = new JTextField(); - private JTextField delta1PTF = new JTextField(); - private JTextField max1PTF = new JTextField(); - private JLabel jLabel23 = new JLabel(); - private Component component7; - private Component component8; - private JTextField min2PTF = new JTextField(); - private GridBagLayout gridBagLayout15 = new GridBagLayout(); - private JLabel jLabel24 = new JLabel(); - private JTextField numPTF = new JTextField(); - private JPanel vectorPanel = new JPanel(); - private GridBagLayout gridBagLayout16 = new GridBagLayout(); - - public AddDataFrame() { - this(null); - } - - public AddDataFrame(Page page) { - page_ = page; - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - this.setSize(450, 600); - this.setLocation(200, 200); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "oneDSpatial"); - init(); - } - - public Page getPage() { - return page_; - } - - public void setPage(Page page) { - page_ = page; - init(); - } - - private void jbInit() throws Exception { - sourceBorder = new TitledBorder(""); - targetBorder = new TitledBorder(""); - panelBorder = new TitledBorder(""); - axisGroupBorder = new TitledBorder(""); - legendBorder = new TitledBorder(""); - component1 = Box.createHorizontalStrut(8); - component2 = Box.createHorizontalStrut(8); - component3 = Box.createHorizontalStrut(8); - component4 = Box.createHorizontalStrut(8); - component5 = Box.createHorizontalStrut(8); - component6 = Box.createHorizontalStrut(8); - component7 = Box.createHorizontalStrut(8); - component8 = Box.createHorizontalStrut(8); - this.getContentPane().setLayout(borderLayout1); - okButton.setText("OK"); - okButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - okButton_actionPerformed(e); - } - }); - cancelButton.setText("Cancel"); - cancelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - cancelButton_actionPerformed(e); - } - }); - jPanel2.setBorder(BorderFactory.createEtchedBorder()); - jPanel1.setLayout(gridBagLayout1); - sourcePanel.setBorder(sourceBorder); - sourcePanel.setMinimumSize(new Dimension(163, 300)); - sourcePanel.setPreferredSize(new Dimension(167, 300)); - sourcePanel.setLayout(borderLayout2); - sourceBorder.setTitle("Source"); - targetPanel.setBorder(targetBorder); - targetPanel.setLayout(gridBagLayout2); - targetBorder.setTitle("Target"); - this.setTitle("Add Data"); - jScrollPane1.setBorder(panelBorder); - panelBorder.setTitle("Panels"); - jScrollPane2.setBorder(axisGroupBorder); - axisGroupBorder.setTitle("AxisGroups"); - jScrollPane3.setBorder(legendBorder); - legendBorder.setTitle("Legends"); - jLabel1.setText("Data Type"); - cardPanel.setLayout(cardLayout1); - jLabel2.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel2.setText("Direction:"); - oneDSpatialPanel.setLayout(gridBagLayout3); - jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel3.setText("Range:"); - delta1STF.setText("0.5"); - delta1STF.setColumns(8); - max1STF.setText("10.0"); - max1STF.setColumns(8); - min1STF.setText("0.0"); - min1STF.setColumns(8); - jLabel4.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel4.setText("Type:"); - jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel5.setText("Amplitude:"); - amp1STF.setText("1.0"); - amp1STF.setColumns(8); - jLabel6.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel6.setText("Offset:"); - off1STF.setText("0.0"); - off1STF.setColumns(8); - jLabel7.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel7.setText("Period:"); - per1STF.setText("5.0"); - per1STF.setColumns(8); - jPanel5.setLayout(gridBagLayout4); - dataTypeCB.setModel(dataTypeModel); - dataTypeCB.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - dataTypeCB_actionPerformed(e); - } - }); - dir1SCB.setModel(dir1SModel); - type1SCB.setModel(typeModel); - panelList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - panelList_valueChanged(e); - } - }); - twoDSpatialPanel.setLayout(gridBagLayout5); - jLabel8.setText("Direction:"); - dir2SCB.setModel(dir2SModel); - jLabel9.setText("Range1:"); - delta12STF.setText("0.02"); - delta12STF.setColumns(8); - max12STF.setText("1.0"); - max12STF.setColumns(8); - min12STF.setText("0.0"); - min12STF.setColumns(8); - jLabel10.setText("Range2:"); - delta22STF.setText("0.02"); - delta22STF.setColumns(8); - max22STF.setText("1.0"); - max22STF.setColumns(8); - min22STF.setText("0.0"); - min22STF.setColumns(8); - jLabel11.setText("Type:"); - type2SCB.setModel(typeModel); - jLabel12.setText("Amplitude:"); - amp2STF.setText("0.5"); - amp2STF.setColumns(8); - jLabel13.setText("Offset:"); - off2STF.setText("0.5"); - off2STF.setColumns(8); - jLabel14.setText("Period:"); - per2STF.setText("0.2"); - per2STF.setColumns(8); - jPanel4.setLayout(gridBagLayout6); - jPanel6.setLayout(gridBagLayout7); - oneDTimePanel.setLayout(gridBagLayout8); - amp1TTF.setColumns(8); - amp1TTF.setText("1.0"); - type1TCB.setModel(typeModel); - max1TTF.setColumns(12); - max1TTF.setText("2001-06-12 00:00"); - jLabel15.setText("Period:"); - jLabel15.setHorizontalAlignment(SwingConstants.RIGHT); - off1TTF.setColumns(8); - off1TTF.setText("0.0"); - jLabel16.setText("Offset:"); - jLabel16.setHorizontalAlignment(SwingConstants.RIGHT); - per1TTF.setColumns(8); - per1TTF.setText("5.0"); - jLabel17.setText("Amplitude:"); - jLabel17.setHorizontalAlignment(SwingConstants.RIGHT); - min1TTF.setColumns(12); - min1TTF.setText("2001-02-11 00:00"); - jLabel18.setText("Type:"); - jLabel18.setHorizontalAlignment(SwingConstants.RIGHT); - jPanel7.setLayout(gridBagLayout9); - jLabel19.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel19.setText("Range:"); - delta1TTF.setText("2"); - delta1TTF.setColumns(4); - jLabel20.setText("Delta:"); - twoDTimePanel.setLayout(gridBagLayout10); - jLabel110.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel110.setText("Amplitude:"); - jLabel111.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel111.setText("Offset:"); - jLabel112.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel112.setText("Period:"); - delta22TTF.setColumns(4); - delta22TTF.setText("2"); - amp2TTF.setText("1.0"); - amp2TTF.setColumns(8); - type2TCB.setModel(typeModel); - max22TTF.setText("1990-06-02 00:00"); - max22TTF.setColumns(12); - jPanel8.setLayout(gridBagLayout11); - off2TTF.setColumns(8); - off2TTF.setText("0.0"); - jLabel113.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel113.setText("Time Range:"); - min22TTF.setColumns(12); - min22TTF.setText("1990-01-01 00:00"); - jLabel114.setText("Type:"); - jLabel114.setHorizontalAlignment(SwingConstants.RIGHT); - per2TTF.setColumns(8); - per2TTF.setText("5.0"); - jLabel21.setText("Time Delta:"); - jLabel22.setText("Depth Range:"); - max12TTF.setColumns(8); - max12TTF.setText("10.0"); - min12TTF.setColumns(8); - min12TTF.setText("0.0"); - jPanel9.setLayout(gridBagLayout12); - delta12TTF.setText("0.5"); - delta12TTF.setColumns(8); - pointPanel.setLayout(gridBagLayout13); - jPanel10.setLayout(gridBagLayout15); - delta2PTF.setText("0.1"); - delta2PTF.setColumns(8); - jPanel11.setLayout(gridBagLayout14); - max2PTF.setText("1.0"); - max2PTF.setColumns(8); - jLabel119.setText("Range2:"); - min1PTF.setText("0.0"); - min1PTF.setColumns(8); - delta1PTF.setText("0.1"); - delta1PTF.setColumns(8); - max1PTF.setText("1.0"); - max1PTF.setColumns(8); - jLabel23.setText("Range1:"); - min2PTF.setText("0.0"); - min2PTF.setColumns(8); - jLabel24.setText("Number Pts:"); - numPTF.setText("25"); - numPTF.setColumns(5); - vectorPanel.setLayout(gridBagLayout16); - this.getContentPane().add(jPanel1, BorderLayout.CENTER); - this.getContentPane().add(jPanel2, BorderLayout.SOUTH); - jPanel2.add(okButton, null); - jPanel2.add(cancelButton, null); - jPanel1.add(sourcePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - sourcePanel.add(jPanel3, BorderLayout.NORTH); - jPanel3.add(jLabel1, null); - jPanel3.add(dataTypeCB, null); - jPanel1.add(targetPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - targetPanel.add(jScrollPane1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - jScrollPane1.getViewport().add(panelList, null); - targetPanel.add(jScrollPane2, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - jScrollPane2.getViewport().add(axisGroupList, null); - targetPanel.add(jScrollPane3, new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - jScrollPane3.getViewport().add(legendList, null); - sourcePanel.add(cardPanel, BorderLayout.CENTER); - cardPanel.add(oneDSpatialPanel, "oneDSpatial"); - cardPanel.add(twoDSpatialPanel, "twoDSpatial"); - twoDSpatialPanel.add(jLabel8, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(dir2SCB, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(jLabel9, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(jPanel4, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - jPanel4.add(min12STF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel4.add(max12STF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0)); - jPanel4.add(delta12STF, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0)); - jPanel4.add(component2, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - twoDSpatialPanel.add(jLabel10, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(jPanel6, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - jPanel6.add(min22STF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel6.add(max22STF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel6.add(delta22STF, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel6.add(component3, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - twoDSpatialPanel.add(jLabel11, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(type2SCB, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(jLabel12, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(amp2STF, new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(jLabel13, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(off2STF, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(jLabel14, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDSpatialPanel.add(per2STF, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - cardPanel.add(oneDTimePanel, "oneDTime"); - jPanel7.add(min1TTF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); - jPanel7.add(max1TTF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel7.add(component4, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - oneDTimePanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(delta1TTF, new GridBagConstraints(1, 1, 1, 1, 0.01, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(amp1TTF, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(type1TCB, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(jLabel15, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(off1TTF, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(jLabel16, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(per1TTF, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(jLabel17, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(jLabel18, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDTimePanel.add(jPanel7, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - cardPanel.add(twoDTimePanel, "twoDTime"); - jPanel8.add(min22TTF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); - jPanel8.add(max22TTF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel8.add(component5, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - twoDTimePanel.add(off2TTF, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jLabel113, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jLabel114, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(per2TTF, new GridBagConstraints(1, 6, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jLabel22, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jPanel9, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - jPanel9.add(min12TTF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); - jPanel9.add(max12TTF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel9.add(delta12TTF, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel9.add(component6, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - twoDTimePanel.add(jLabel110, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jLabel111, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jLabel112, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(delta22TTF, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(amp2TTF, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(type2TCB, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - twoDTimePanel.add(jPanel8, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - cardPanel.add(pointPanel, "point"); - jPanel10.add(min2PTF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel10.add(max2PTF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel10.add(delta2PTF, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel10.add(component7, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - pointPanel.add(jPanel11, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - jPanel11.add(min1PTF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel11.add(max1PTF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0)); - jPanel11.add(delta1PTF, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0)); - jPanel11.add(component8, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - pointPanel.add(jLabel119, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - pointPanel.add(jLabel23, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - pointPanel.add(jPanel10, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - oneDSpatialPanel.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(dir1SCB, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(jLabel3, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(jPanel5, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - jPanel5.add(min1STF, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0)); - jPanel5.add(max1STF, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel5.add(delta1STF, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel5.add(component1, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - oneDSpatialPanel.add(jLabel4, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(type1SCB, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(amp1STF, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(jLabel6, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(off1STF, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(jLabel7, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - oneDSpatialPanel.add(per1STF, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - pointPanel.add(jLabel24, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - pointPanel.add(numPTF, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - cardPanel.add(vectorPanel, "vector"); - } - - void init() { - PanelModel pModel = page_.getPanelModel(); - Iterator pItor = pModel.panelIterator(); - String[] listData = new String[pModel.getPanelCount()]; - int i=0; - while(pItor.hasNext()) { - PanelHolder panel = (PanelHolder)pItor.next(); - listData[i++] = panel.getId(); - } - panelList.setListData(listData); - } - - void cancelButton_actionPerformed(ActionEvent e) { - setVisible(false); - dispose(); - } - - int getDirection(String dirValue) { - int dir = TestData.X_SERIES; - if(dirValue.equals("X_SERIES")) { - dir = TestData.X_SERIES; - } else if(dirValue.equals("Y_SERIES")) { - dir = TestData.Y_SERIES; - } else if(dirValue.equals("PROFILE")) { - dir = TestData.PROFILE; - } else if(dirValue.equals("LOG_LOG")) { - dir = TestData.LOG_LOG; - } else if(dirValue.equals("XY_GRID")) { - dir = TestData.XY_GRID; - } else if(dirValue.equals("XZ_GRID")) { - dir = TestData.XZ_GRID; - } else if(dirValue.equals("YZ_GRID")) { - dir = TestData.YZ_GRID; - } else if(dirValue.equals("TIME_SERIES")) { - dir = TestData.TIME_SERIES; - } else if(dirValue.equals("ZT_GRID")) { - dir = TestData.ZT_GRID; - } - return dir; - } - - int getType(String typeValue) { - int type = TestData.RANDOM; - if(typeValue.equals("SINE")) { - type = TestData.SINE; - } else if(typeValue.equals("RANDOM")) { - type = TestData.RANDOM; - } - return type; - } - - void okButton_actionPerformed(ActionEvent e) { - // - // define default colormap - // - int[] red = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 23, 39, 55, 71, 87,103, - 119,135,151,167,183,199,215,231, - 247,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,246,228,211,193,175,158,140}; - int[] green = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 11, 27, 43, 59, 75, 91,107, - 123,139,155,171,187,203,219,235, - 251,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0}; - int[] blue = - { 0,143,159,175,191,207,223,239, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - - SGTData data = null; - Attribute attr = null; - String dataType = (String)dataTypeCB.getSelectedItem(); - if(dataType.equals("1-d Spatial")) { - int dir = getDirection((String)dir1SCB.getSelectedItem()); - int type = getType((String)type1SCB.getSelectedItem()); - double min = Double.parseDouble(min1STF.getText()); - double max = Double.parseDouble(max1STF.getText()); - double delta = Double.parseDouble(delta1STF.getText()); - Range2D range = new Range2D(min, max, delta); - - float amp = Float.parseFloat(amp1STF.getText()); - float off = Float.parseFloat(off1STF.getText()); - float per = Float.parseFloat(per1STF.getText()); - - TestData td = new TestData(dir, range, type, amp, off, per); - data = td.getSGTData(); - attr = new LineAttribute(LineAttribute.SOLID, Color.blue); - } else if(dataType.equals("2-d Spatial")) { - ColorMap cmap; - int dir = getDirection((String)dir2SCB.getSelectedItem()); - int type = getType((String)type2SCB.getSelectedItem()); - double min1 = Double.parseDouble(min12STF.getText()); - double max1 = Double.parseDouble(max12STF.getText()); - double delta1 = Double.parseDouble(delta12STF.getText()); - Range2D range1 = new Range2D(min1, max1, delta1); - - double min2 = Double.parseDouble(min22STF.getText()); - double max2 = Double.parseDouble(max22STF.getText()); - double delta2 = Double.parseDouble(delta22STF.getText()); - Range2D range2 = new Range2D(min2, max2, delta2); - - float amp = Float.parseFloat(amp2STF.getText()); - float off = Float.parseFloat(off2STF.getText()); - float per = Float.parseFloat(per2STF.getText()); - - TestData td = new TestData(dir, range1, range2, type, amp, off, per); - data = td.getSGTData(); - cmap = new IndexedColorMap(red, green, blue); - LinearTransform ctrans = - new LinearTransform(0.0, (double)red.length, 0.0, 1.0); - ((IndexedColorMap)cmap).setTransform(ctrans); - attr = new GridAttribute(GridAttribute.RASTER, cmap); -// attr = new GridAttribute(); - }else if(dataType.equals("1-d Time")) { - int dir = TestData.TIME_SERIES; - int type = getType((String)type1TCB.getSelectedItem()); - - GeoDate start = null; - GeoDate end = null; - String format = "yyyy-MM-dd HH:mm"; - String min1 = min1TTF.getText(); - String max1 = max1TTF.getText(); - try { - start = new GeoDate(min1, format); - end = new GeoDate(max1, format); - } catch (IllegalTimeValue itf) { - String message = "Illegal time string " + "'" + min1 + "' or '" + max1 + "'" + - "\nshould be of the form " + format; - JOptionPane.showMessageDialog(this, message, - "Error in Time Value", JOptionPane.ERROR_MESSAGE); - return; - } - - float delta = Float.parseFloat(delta1TTF.getText()); - - float amp = Float.parseFloat(amp1TTF.getText()); - float off = Float.parseFloat(off1TTF.getText()); - float per = Float.parseFloat(per1TTF.getText()); - TestData td = new TestData(dir, new TimeRange(start, end), delta, - type, amp, off, per); - data = td.getSGTData(); - attr = new LineAttribute(LineAttribute.SOLID, Color.blue.brighter()); - } else if(dataType.equals("2-d Time")) { - ColorMap cmap; - int dir = TestData.ZT_GRID; - int type = getType((String)type2TCB.getSelectedItem()); - - double smin1 = Double.parseDouble(min12TTF.getText()); - double smax1 = Double.parseDouble(max12TTF.getText()); - double sdelta1 = Double.parseDouble(delta12TTF.getText()); - Range2D range1 = new Range2D(smin1, smax1, sdelta1); - - GeoDate start = null; - GeoDate end = null; - String format = "yyyy-MM-dd HH:mm"; - String min1 = min22TTF.getText(); - String max1 = max22TTF.getText(); - try { - start = new GeoDate(min1, format); - end = new GeoDate(max1, format); - } catch (IllegalTimeValue itf) { - String message = "Illegal time string " + "'" + min1 + "' or '" + max1 + "'" + - "\nshould be of the form " + format; - JOptionPane.showMessageDialog(this, message, - "Error in Time Value", JOptionPane.ERROR_MESSAGE); - return; - } - - float delta = Float.parseFloat(delta22TTF.getText()); - - float amp = Float.parseFloat(amp2TTF.getText()); - float off = Float.parseFloat(off2TTF.getText()); - float per = Float.parseFloat(per2TTF.getText()); - - TestData td = new TestData(dir, range1, new TimeRange(start, end), delta, - type, amp, off, per); - data = td.getSGTData(); - cmap = new IndexedColorMap(red, green, blue); - LinearTransform ctrans = - new LinearTransform(0.0, (double)red.length, 0.0, 1.0); - ((IndexedColorMap)cmap).setTransform(ctrans); - attr = new GridAttribute(GridAttribute.RASTER, cmap); - } else if(dataType.equals("Point")) { - double min1 = Double.parseDouble(min1PTF.getText()); - double max1 = Double.parseDouble(max1PTF.getText()); - double delta1 = Double.parseDouble(delta1PTF.getText()); - Range2D range1 = new Range2D(min1, max1, delta1); - - double min2 = Double.parseDouble(min2PTF.getText()); - double max2 = Double.parseDouble(max2PTF.getText()); - double delta2 = Double.parseDouble(delta2PTF.getText()); - Range2D range2 = new Range2D(min2, max2, delta2); - - int num = Integer.parseInt(numPTF.getText()); - - TestData td = new TestData(range1, range2, num); - data = td.getCollection(); - attr = new PointAttribute(10, Color.red); - ((PointAttribute)attr).setMarkHeightP(0.20); - } else if(dataType.equals("Vector")) { - SGTGrid uComp; - SGTGrid vComp; -// SGTVector vector; - TestData td; - /* - * Create a test grid with sinasoidal-ramp data. - */ - Range2D xr = new Range2D(190.0f, 250.0f, 3.0f); - Range2D yr = new Range2D(0.0f, 45.0f, 3.0f); - td = new TestData(TestData.XY_GRID, xr, yr, - TestData.SINE_RAMP, 20.0f, 10.f, 5.0f); - uComp = (SGTGrid)td.getSGTData(); - td = new TestData(TestData.XY_GRID, xr, yr, - TestData.SINE_RAMP, 20.0f, 0.f, 3.0f); - vComp = (SGTGrid)td.getSGTData(); - data = new SGTVector(uComp, vComp); - attr = new VectorAttribute(0.0075, Color.red); - ((VectorAttribute)attr).setHeadScale(0.5); - } - PanelHolder pHolder = null; - if(!panelList.isSelectionEmpty()) - pHolder = page_.getPanelModel().findPanelHolder((String)panelList.getSelectedValue()); - DataGroup axisGroup = null; - if(!axisGroupList.isSelectionEmpty()) - axisGroup = pHolder.findDataGroup((String)axisGroupList.getSelectedValue()); - Legend legend = null; - if(!legendList.isSelectionEmpty()) - legend = pHolder.findLegend((String)legendList.getSelectedValue()); - // - if((pHolder == null) || (axisGroup == null)) { - JOptionPane.showMessageDialog(this, "A Panel and DataGroup must be selected.\n\n" + - "Please select a Panel and DataGroup.", - "Panel/DataGroup Selection Error", - JOptionPane.ERROR_MESSAGE); - return; - } - page_.getDataModel().addData(data, attr, pHolder, axisGroup, legend); - setVisible(false); - dispose(); - } - - void dataTypeCB_actionPerformed(ActionEvent e) { - if(Page.DEBUG) System.out.println("ActionPerformed: new value = " + dataTypeCB.getSelectedItem()); - int index = dataTypeCB.getSelectedIndex(); - switch(index) { - case 0: // oneDSpatial - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "oneDSpatial"); - break; - case 1: // twoDSpatial - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "twoDSpatial"); - break; - case 2: // oneDTime - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "oneDTime"); - break; - case 3: // twoDTime - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "twoDTime"); - break; - case 4: //Point - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "point"); - break; - case 5: //Vector - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "vector"); - break; - default: - JOptionPane.showMessageDialog(this, "Selection Not Yet Implemented", - "Not Implemented", JOptionPane.ERROR_MESSAGE); - dataTypeCB.setSelectedIndex(0); - ((CardLayout)cardPanel.getLayout()).show(cardPanel, "oneDSpatial"); - } - } - - void panelList_valueChanged(ListSelectionEvent e) { - String pid = (String)panelList.getSelectedValue(); - PanelHolder pHolder = page_.getPanelModel().findPanelHolder(pid); - Iterator agItor = pHolder.dataGroupIterator(); - String[] agData = new String[pHolder.getDataGroupSize()]; - int i=0; - while(agItor.hasNext()) { - agData[i++] = ((DataGroup)agItor.next()).getId(); - } - axisGroupList.setListData(agData); - Iterator lgItor = pHolder.legendIterator(); - String[] lgData = new String[pHolder.getLegendSize()]; - i=0; - while(lgItor.hasNext()) { - lgData[i++] = ((Legend)lgItor.next()).getId(); - } - legendList.setListData(lgData); - } - - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemo.java deleted file mode 100755 index 314a2b1f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemo.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * $Id: BeanDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import javax.swing.UIManager; -import java.awt.*; - -/** - * Example demonstrating the use of the SGT Bean classes. This application - * looks for the BeanDemoPanelModel.xml file in the same directory as - * gov.noaa.pmel.sgt.beans. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 3.0 - **/ -public class BeanDemo { - private boolean packFrame = false; - - //Construct the application - public BeanDemo() { - BeanDemoFrame frame = new BeanDemoFrame(); - //Validate frames that have preset sizes - //Pack frames that have useful preferred size info, e.g. from their layout - if (packFrame) { - frame.pack(); - } - else { - frame.validate(); - } - //Center the window - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension frameSize = frame.getSize(); - if (frameSize.height > screenSize.height) { - frameSize.height = screenSize.height; - } - if (frameSize.width > screenSize.width) { - frameSize.width = screenSize.width; - } - frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); - frame.setVisible(true); - } - //Main method - public static void main(String[] args) { - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } - catch(Exception e) { - e.printStackTrace(); - } - new BeanDemo(); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemoFrame.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemoFrame.java deleted file mode 100755 index 58d2edbd..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemoFrame.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * $Id: BeanDemoFrame.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import java.awt.*; -import java.awt.print.*; -import java.awt.event.*; -import java.io.*; -import javax.swing.*; - -import gov.noaa.pmel.sgt.beans.*; -import gov.noaa.pmel.sgt.dm.*; -import gov.noaa.pmel.sgt.AbstractPane; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.ColorMap; -import gov.noaa.pmel.sgt.IndexedColorMap; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.Attribute; -import gov.noaa.pmel.sgt.swing.JClassTree; -import gov.noaa.pmel.util.*; -import gov.noaa.pmel.swing.JSystemPropertiesDialog; - -/** - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 3.0 - **/ -class BeanDemoFrame extends JFrame { - private Page page = new Page(); - private PanelModel panelModel = new PanelModel(); - private DataModel dataModel = new DataModel(); - private SGTData timeSeries; - private Attribute timeSeriesAttr; - private SGTData grid; - private Attribute gridAttr; - private SGTData line; - private Attribute lineAttr; - - private JPanel contentPane; - private JMenuBar jMenuBar1 = new JMenuBar(); - private JMenu jMenuFile = new JMenu(); - private JMenuItem jMenuFileExit = new JMenuItem(); - private JMenu jMenuHelp = new JMenu(); - private JMenuItem jMenuHelpAbout = new JMenuItem(); - private BorderLayout borderLayout1 = new BorderLayout(); - private JMenu jMenuView = new JMenu(); - private JMenuItem jMenuViewReset = new JMenuItem(); - private JMenuItem jMenuViewTree = new JMenuItem(); - private JPanel pagePanel = new JPanel(); - private BorderLayout borderLayout2 = new BorderLayout(); - private JMenuItem jMenuHelpProps = new JMenuItem(); - private JMenu jMenuEdit = new JMenu(); - private JMenuItem jMenuEditData = new JMenuItem(); - private JMenuItem jMenuEditPM = new JMenuItem(); - private JMenuItem jMenuFilePrint = new JMenuItem(); - private JMenuItem jMenuFilePage = new JMenuItem(); - - private PageFormat pageFormat = PrinterJob.getPrinterJob().defaultPage(); - - //Construct the frame - public BeanDemoFrame() { - enableEvents(AWTEvent.WINDOW_EVENT_MASK); - page.getJPane().setBackground(Color.lightGray); - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - createGraphic(); - pack(); - } - //Component initialization - private void jbInit() throws Exception { - //setIconImage(Toolkit.getDefaultToolkit().createImage(BeanDemoFrame.class.getResource("[Your Icon]"))); - contentPane = (JPanel) this.getContentPane(); - contentPane.setLayout(borderLayout1); -// this.setSize(new Dimension(501, 450)); - this.setTitle("SGT Bean Demo"); - jMenuFile.setText("File"); - jMenuFileExit.setText("Exit"); - jMenuFileExit.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuFileExit_actionPerformed(e); - } - }); - jMenuHelp.setText("Help"); - jMenuHelpAbout.setText("About"); - jMenuHelpAbout.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuHelpAbout_actionPerformed(e); - } - }); - jMenuView.setText("View"); - jMenuViewReset.setText("Reset All Zoom"); - jMenuViewReset.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuViewReset_actionPerformed(e); - } - }); - jMenuViewTree.setText("Class Tree..."); - jMenuViewTree.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuViewTree_actionPerformed(e); - } - }); - pagePanel.setLayout(borderLayout2); - jMenuHelpProps.setText("System Properties..."); - jMenuHelpProps.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuHelpProps_actionPerformed(e); - } - }); - jMenuEdit.setText("Edit"); - jMenuEditData.setText("Add Data..."); - jMenuEditData.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuEditData_actionPerformed(e); - } - }); - jMenuEditPM.setText("PanelModel"); - jMenuEditPM.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuEditPM_actionPerformed(e); - } - }); - jMenuFilePrint.setText("Print..."); - jMenuFilePrint.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuFilePrint_actionPerformed(e); - } - }); - jMenuFilePage.setText("Page Layout..."); - jMenuFilePage.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jMenuFilePage_actionPerformed(e); - } - }); - jMenuFile.add(jMenuFilePage); - jMenuFile.add(jMenuFilePrint); - jMenuFile.addSeparator(); - jMenuFile.add(jMenuFileExit); - jMenuHelp.add(jMenuHelpProps); - jMenuHelp.add(jMenuHelpAbout); - jMenuBar1.add(jMenuFile); - jMenuBar1.add(jMenuEdit); - jMenuBar1.add(jMenuView); - jMenuBar1.add(jMenuHelp); - jMenuView.add(jMenuViewReset); - jMenuView.add(jMenuViewTree); - contentPane.add(pagePanel, BorderLayout.CENTER); - jMenuEdit.add(jMenuEditData); - jMenuEdit.add(jMenuEditPM); - this.setJMenuBar(jMenuBar1); - } - //File | Exit action performed - private void jMenuFileExit_actionPerformed(ActionEvent e) { - System.exit(0); - } - //Help | About action performed - private void jMenuHelpAbout_actionPerformed(ActionEvent e) { - JOptionPane.showMessageDialog(this, "BeanDemo: SGT version 3.0", - "About BeanDemo", - JOptionPane.INFORMATION_MESSAGE); - } - //Overridden so we can exit when window is closed - protected void processWindowEvent(WindowEvent e) { - super.processWindowEvent(e); - if (e.getID() == WindowEvent.WINDOW_CLOSING) { - jMenuFileExit_actionPerformed(null); - } - } - - private void createGraphic() { - pagePanel.add(page, BorderLayout.CENTER); - page.setDataModel(dataModel); - try { - panelModel = PanelModel.loadFromXML(getClass().getResource("BeanDemoPanelModel.xml").openStream()); - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - page.setPanelModel(panelModel); - PanelHolder ul = panelModel.findPanelHolder("UpperLeft"); - DataGroup uldg = ul.findDataGroup("Grid"); - Legend ullg = ul.findLegend("ColorKey"); - createGrid(); - dataModel.addData(grid, gridAttr, ul, uldg, ullg); - - PanelHolder ur = panelModel.findPanelHolder("UpperRight"); - DataGroup urdg = ur.findDataGroup("Random"); - createLine(); - dataModel.addData(line, lineAttr, ur, urdg, null); - - PanelHolder bt = panelModel.findPanelHolder("Bottom"); - DataGroup btdg = bt.findDataGroup("TimeSeries"); - createTimeSeries(); - dataModel.addData(timeSeries, timeSeriesAttr, bt, btdg, null); - // get datasets - - } - - private void createTimeSeries() { - int dir = TestData.TIME_SERIES; - int type = TestData.RANDOM; - - GeoDate start = null; - GeoDate end = null; - String format = "yyyy-MM-dd HH:mm"; - String min1 = "2001-02-12 00:00"; - String max1 = "2001-06-10 00:00"; - try { - start = new GeoDate(min1, format); - end = new GeoDate(max1, format); - } catch (IllegalTimeValue itf) { - String message = "Illegal time string " + "'" + min1 + "' or '" + max1 + "'" + - "\nshould be of the form " + format; - JOptionPane.showMessageDialog(this, message, - "Error in Time Value", JOptionPane.ERROR_MESSAGE); - return; - } - - float delta = 2.0f; - - float amp = 1.0f; - float off = 0.0f; - float per = 5.0f; - TestData td = new TestData(dir, new TimeRange(start, end), delta, - type, amp, off, per); - timeSeries = td.getSGTData(); - timeSeriesAttr = new LineAttribute(LineAttribute.SOLID, Color.blue.brighter()); - } - - void createLine() { - int dir = TestData.X_SERIES; - int type = TestData.RANDOM; - double min = 0.0; - double max = 10.0; - double delta = 0.5; - Range2D range = new Range2D(min, max, delta); - - float amp = 1.0f; - float off = 0.0f; - float per = 5.0f; - - TestData td = new TestData(dir, range, type, amp, off, per); - line = td.getSGTData(); - lineAttr = new LineAttribute(LineAttribute.SOLID, Color.blue); - } - - void createGrid() { - ColorMap cmap; - int[] red = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 23, 39, 55, 71, 87,103, - 119,135,151,167,183,199,215,231, - 247,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,246,228,211,193,175,158,140}; - int[] green = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 11, 27, 43, 59, 75, 91,107, - 123,139,155,171,187,203,219,235, - 251,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0}; - int[] blue = - { 0,143,159,175,191,207,223,239, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - - int dir = TestData.XY_GRID; - int type = TestData.SINE; - double min1 = 0.0; - double max1 = 1.0; - double delta1 = 0.02; - Range2D range1 = new Range2D(min1, max1, delta1); - - double min2 = 0.0; - double max2 = 1.0; - double delta2 = 0.02; - Range2D range2 = new Range2D(min2, max2, delta2); - - float amp = 0.5f; - float off = 0.5f; - float per = 0.2f; - - TestData td = new TestData(dir, range1, range2, type, amp, off, per); - grid = td.getSGTData(); - cmap = new IndexedColorMap(red, green, blue); - LinearTransform ctrans = - new LinearTransform(0.0, (double)red.length, 0.0, 1.0); - ((IndexedColorMap)cmap).setTransform(ctrans); - gridAttr = new GridAttribute(GridAttribute.RASTER, cmap); - } - - void jMenuViewReset_actionPerformed(ActionEvent e) { - page.resetZoom(); - } - - void jMenuViewTree_actionPerformed(ActionEvent e) { - JClassTree ct = new JClassTree(); - ct.setModal(false); - ct.setJPane(page.getJPane()); - ct.show(); - } - - void jMenuEditData_actionPerformed(ActionEvent e) { - AddDataFrame adf = new AddDataFrame(page); - adf.setVisible(true); - } - - void jMenuEditPM_actionPerformed(ActionEvent e) { - PanelModelEditor pme = new PanelModelEditor(panelModel); - pme.setVisible(true); - } - - void jMenuHelpProps_actionPerformed(ActionEvent e) { - JSystemPropertiesDialog sysProps = - new JSystemPropertiesDialog(this, "System Properties", false); - sysProps.show(); - } - - void jMenuFilePrint_actionPerformed(ActionEvent e) { - Color saveColor; - JPane pane = page.getJPane(); - - PrinterJob printJob = PrinterJob.getPrinterJob(); - printJob.setPrintable(page, pageFormat); - printJob.setJobName("BeanDemo"); - if(printJob.printDialog()) { - try { - RepaintManager currentManager = RepaintManager.currentManager(pane); - currentManager.setDoubleBufferingEnabled(false); - printJob.print(); - currentManager.setDoubleBufferingEnabled(true); - } catch (PrinterException pe) { - System.out.println("Error printing: " + pe); - } - } - } - - void jMenuFilePage_actionPerformed(ActionEvent e) { - PrinterJob pj = PrinterJob.getPrinterJob(); - pageFormat = pj.pageDialog(pageFormat); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemoPanelModel.xml b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemoPanelModel.xml deleted file mode 100755 index e36330cc..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/BeanDemoPanelModel.xml +++ /dev/null @@ -1,695 +0,0 @@ - - - - - 0 - - - - 501 - 400 - - - - - UpperRight - - - - 0 - - 255 - 255 - 255 - 255 - - - 255 - 255 - 255 - 255 - - - 124 - 124 - 124 - 255 - - - 178 - 178 - 178 - 255 - - - - - - 300 - 0 - 200 - 293 - - - - - Random - - - - - 0.4166666567325592 - - - 2.097222328186035 - - - 0.5 - - - 0.0833333358168602 - - - - - 1 - - - 0 - - - - 394 - 278 - 34 - 10 - - - - - Helvetica - 0 - 12 - - - - - 411 - 276 - - - - false - - - - Random - - - - - - - - - - - - - - - - - - - - 3.125 - - - 0.4166666567325592 - - - 0.0833333358168602 - - - 0.5 - - - - - 1 - - - - 308 - 128 - 10 - 34 - - - - - Helvetica - 0 - 12 - - - - - 316 - 145 - - - - false - - - 1 - - - - Random - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Random - - - - 0.18055555 - - - 0.44444445 - - - - - - - - - - UpperRight - - - - Label0 - - - - - 0.25 - - - 0.75 - - - 1.0138888359069824 - - - 3.75 - - - - - Label0 - - - Bean Demo - - - - - - - - UpperLeft - - - - 0 - - 255 - 255 - 255 - 255 - - - 255 - 255 - 255 - 255 - - - 124 - 124 - 124 - 255 - - - 178 - 178 - 178 - 255 - - - - - - 0 - 0 - 300 - 293 - - - - - Grid - - - - - 0.4166666567325592 - - - 2.375 - - - 0.5 - - - 0.0833333358168602 - - - - - 1 - - - 0 - - - - 102 - 279 - 38 - 11 - - - - - Helvetica - 0 - 13 - - - - - 121 - 277 - - - - false - - - - Grid - - - - - - - - - - - - - - - - - - - - 3.277777671813965 - - - 0.4166666567325592 - - - 0.0833333358168602 - - - 0.5 - - - - - 1 - - - - 7 - 121 - 11 - 38 - - - - - Helvetica - 0 - 13 - - - - - 16 - 140 - - - - false - - - 1 - - - - Grid - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Grid - - - - 1.2916666 - - - 0.29166666 - - - - - - - - - - UpperLeft - - - - ColorKey - - - - - 3.2916667461395264 - - - 1.125 - - - 2.930555582046509 - - - 0.4861111044883728 - - - - - ColorKey - - - 1 - - - 1 - - - - - - - - Bottom - - - - 0 - - 255 - 255 - 255 - 255 - - - 255 - 255 - 255 - 255 - - - 124 - 124 - 124 - 255 - - - 178 - 178 - 178 - 255 - - - - - - 0 - 293 - 500 - 107 - - - - - TimeSeries - - - - 3 - - - - 0.4166666567325592 - - - 6.291666507720947 - - - 0.5 - - - 0.0833333358168602 - - - - TimeSeries - - - - - - 172800000 - - - - - - - - 978307200000 - - - - - - - - 946684800000 - - - - - - - - - - - - 0.875 - - - 0.4166666567325592 - - - 0.0833333358168602 - - - 0.5 - - - - 4 - - - - 1 - - - - 15 - 317 - 10 - 34 - - - - - Helvetica - 0 - 12 - - - - - 23 - 334 - - - - false - - - 1 - - - - TimeSeries - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TimeSeries - - - - 0.15277778 - - - 0.11111111 - - - - - - - - - - Bottom - - - - - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JDesktopDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JDesktopDemo.java deleted file mode 100755 index f1f5eb6b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JDesktopDemo.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * $Id: JDesktopDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import java.awt.*; -import java.awt.event.*; -import java.applet.*; -import javax.swing.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import gov.noaa.pmel.sgt.*; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Dimension2D; - -/** - * Example demonstrating the use of PropertyChangeEvents - * in the datamodel. JDesktopDemo constructs the plot - * from basic sgt objects. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.1 - */ - -public class JDesktopDemo extends JApplet implements PropertyChangeListener { - PseudoRealTimeData rtData_; - JPane pane_; - Layer layer_; - TimeAxis xbot_; - PlainAxis yleft_; - LinearTransform xt_, yt_; - boolean isStandalone = false; - BorderLayout borderLayout1 = new BorderLayout(); - JPanel buttonPanel = new JPanel(); - JButton startButton = new JButton(); - JButton stopButton = new JButton(); - JButton resetButton = new JButton(); - - /**Construct the applet*/ - public JDesktopDemo() { - } - /**Initialize the applet*/ - public void init() { - /* - * Create the data source - */ - rtData_ = new PseudoRealTimeData("rtDataSource", "Sea Level"); - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - /* - * add listener for data source. JDesktopDemo is listening - * for rangeModified events - */ - rtData_.addPropertyChangeListener(this); - } - /**Component initialization*/ - private void jbInit() throws Exception { - this.setSize(new Dimension(800, 440)); - this.getContentPane().setLayout(borderLayout1); - startButton.setText("start"); - startButton.addActionListener(new JDesktopDemo_startButton_actionAdapter(this)); - stopButton.setText("stop"); - stopButton.addActionListener(new JDesktopDemo_stopButton_actionAdapter(this)); - resetButton.setText("reset"); - resetButton.addActionListener(new JDesktopDemo_resetButton_actionAdapter(this)); - buttonPanel.setBorder(BorderFactory.createEtchedBorder()); - this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); - buttonPanel.add(startButton, null); - buttonPanel.add(stopButton, null); - buttonPanel.add(resetButton, null); - // - // construct JPane - // - pane_ = new JPane("Real Time Data Demo", new Dimension(800, 400)); - pane_.setBatch(true); - pane_.setLayout(new StackedLayout()); - pane_.setBackground(Color.white); - /* - * xsize, ysize are the width and height in physical units - * of the Layer graphics region. - * - * xstart, xend are the start and end points for the X axis - * ystart, yend are the start and end points for the Y axis - */ - double xsize = 6.0; - double xstart = 0.6; - double xend = 5.5; - double ysize = 3.0; - double ystart = 0.6; - double yend = 2.75; - /* - * Create the layer and add it to the Pane. - */ - CartesianGraph graph; - /* - * Get x and y ranges from data source. - */ - SoTRange.GeoDate xrange = (SoTRange.GeoDate)rtData_.getXRange(); - SoTRange.Double yrange = (SoTRange.Double)rtData_.getYRange(); - - xt_ = new LinearTransform(xstart, xend, xrange.start, xrange.end); - yt_ = new LinearTransform(ystart, yend, yrange.start, yrange.end); - - layer_ = new Layer("Layer 1", new Dimension2D(xsize, ysize)); - pane_.add(layer_); - - SGLabel title = new SGLabel("title", - "Real Time Demo", - new Point2D.Double((xstart+xend)/2.0, - ysize-0.05)); - title.setAlign(SGLabel.TOP, SGLabel.CENTER); - title.setFont(new Font("Serif", Font.PLAIN, 14)); - title.setHeightP(0.25); - title.setColor(Color.blue.darker()); - layer_.addChild(title); - /* - * Create a CartesianGraph and set transforms. - */ - graph = new CartesianGraph("Time Graph"); - layer_.setGraph(graph); - graph.setXTransform(xt_); - graph.setYTransform(yt_); - /* - * Create the bottom axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - SoTPoint origin = new SoTPoint(xrange.start, yrange.start); - xbot_ = new TimeAxis("Botton Axis", TimeAxis.AUTO); - xbot_.setRangeU(xrange); - xbot_.setLocationU(origin); - Font xbfont = new Font("Helvetica", Font.PLAIN, 14); - xbot_.setLabelFont(xbfont); - graph.addXAxis(xbot_); - /* - * Create the left axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - String yLabel = "Latitude"; - - yleft_ = new PlainAxis("Left Axis"); - yleft_.setRangeU(yrange); - yleft_.setLocationU(origin); - yleft_.setLabelFont(xbfont); - SGLabel ytitle = new SGLabel("yaxis title", yLabel, - new Point2D.Double(0.0, 0.0)); - Font ytfont = new Font("Helvetica", Font.PLAIN, 14); - ytitle.setFont(ytfont); - ytitle.setHeightP(0.2); - yleft_.setTitle(ytitle); - graph.addYAxis(yleft_); - - LineAttribute attr = new LineAttribute(); - graph.setData(rtData_, attr); - - this.getContentPane().add(pane_, BorderLayout.CENTER); - if(!isStandalone) pane_.setBatch(false); - } - /**Start the applet*/ - public void start() { - } - /**Stop the applet*/ - public void stop() { - rtData_.stopData(); - } - /**Destroy the applet*/ - public void destroy() { - rtData_.stopData(); - } - /**Get Applet information*/ - public String getAppletInfo() { - return "Applet Information"; - } - /**Main method*/ - public static void main(String[] args) { - JFrame desk = new JFrame("Desktop Demo"); - //EXIT_ON_CLOSE == 3 - desk.setDefaultCloseOperation(3); - desk.getContentPane().setLayout(new BorderLayout()); - desk.setSize(850, 500); - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - desk.setLocation((d.width - desk.getSize().width) / 2, - (d.height - desk.getSize().height) / 2); - JDesktopPane desktop = new JDesktopPane(); - desk.getContentPane().add(desktop, BorderLayout.CENTER); - JDesktopDemo applet = new JDesktopDemo(); - applet.isStandalone = true; - JInternalFrame frame = new JInternalFrame("Real Time Data Demo", - false, false, false, true); - frame.getContentPane().add(applet, BorderLayout.CENTER); - applet.init(); - applet.start(); - frame.setSize(800,440); - desktop.add(frame); - applet.pane_.setBatch(false); - desk.setVisible(true); - frame.setVisible(true); - } - - //static initializer for setting look & feel - static { - try { - //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - } - catch(Exception e) { - } - } - - void startButton_actionPerformed(ActionEvent e) { - rtData_.startData(); - } - - void stopButton_actionPerformed(ActionEvent e) { - rtData_.stopData(); - } - - void resetButton_actionPerformed(ActionEvent e) { - rtData_.stopData(); - rtData_.resetData(); - resetRange(); - } - private void resetRange() { - /* - * A change in the range has occured. Get new range - * and set transforms, axes, and origin appropriately. - */ - pane_.setBatch(true); - SoTRange.GeoDate xrange = (SoTRange.GeoDate)rtData_.getXRange(); - SoTRange.Double yrange = (SoTRange.Double)rtData_.getYRange(); - SoTPoint origin = new SoTPoint(xrange.start, yrange.start); - xt_.setRangeU(xrange); - yt_.setRangeU(yrange); - xbot_.setRangeU(xrange); - xbot_.setLocationU(origin); - yleft_.setRangeU(yrange); - yleft_.setLocationU(origin); - pane_.setBatch(false); - } - public void propertyChange(PropertyChangeEvent evt) { - /** - * dataModified property is handled by CartesianGraph - * only need to look for rangeModified here to make sure - * range is properly updated - */ - if("rangeModified".equals(evt.getPropertyName())) { - resetRange(); - } - } -} -/* - * wrappers for button events created by JBuilder - */ -class JDesktopDemo_startButton_actionAdapter implements ActionListener { - JDesktopDemo adaptee; - - JDesktopDemo_startButton_actionAdapter(JDesktopDemo adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.startButton_actionPerformed(e); - } -} - -class JDesktopDemo_stopButton_actionAdapter implements ActionListener { - JDesktopDemo adaptee; - - JDesktopDemo_stopButton_actionAdapter(JDesktopDemo adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.stopButton_actionPerformed(e); - } -} - -class JDesktopDemo_resetButton_actionAdapter implements ActionListener { - JDesktopDemo adaptee; - - JDesktopDemo_resetButton_actionAdapter(JDesktopDemo adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.resetButton_actionPerformed(e); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JGridDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JGridDemo.java deleted file mode 100755 index 297ec5fb..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JGridDemo.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * $Id: JGridDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.swing.JPlotLayout; -import gov.noaa.pmel.sgt.swing.JClassTree; -import gov.noaa.pmel.sgt.swing.prop.GridAttributeDialog; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.AbstractPane; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.ContourLevels; -import gov.noaa.pmel.sgt.CartesianRenderer; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.GridCartesianRenderer; -import gov.noaa.pmel.sgt.IndexedColorMap; -import gov.noaa.pmel.sgt.ColorMap; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.dm.SGTData; - - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.util.Debug; - -import java.awt.*; -import java.awt.print.*; -import java.awt.event.*; -import javax.swing.*; -/** - * Example demonstrating how to use JPlotLayout - * to create a raster-contour plot. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ -public class JGridDemo extends JApplet { - static JPlotLayout rpl_; - private GridAttribute gridAttr_; - JButton edit_; - JButton space_ = null; - JButton tree_; - JButton print_; - JButton layout_; - PageFormat pageFormat = PrinterJob.getPrinterJob().defaultPage(); - - public void init() { - /* - * Create the demo in the JApplet environment. - */ - getContentPane().setLayout(new BorderLayout(0,0)); - setBackground(java.awt.Color.white); - setSize(600,550); - JPanel main = new JPanel(); - rpl_ = makeGraph(); - JPanel button = makeButtonPanel(false); - rpl_.setBatch(true); - main.add(rpl_, BorderLayout.CENTER); - JPane gridKeyPane = rpl_.getKeyPane(); - gridKeyPane.setSize(new Dimension(600,100)); - main.add(gridKeyPane, BorderLayout.SOUTH); - getContentPane().add(main, "Center"); - getContentPane().add(button, "South"); - rpl_.setBatch(false); - - } - - JPanel makeButtonPanel(boolean mark) { - MyAction myAction = new MyAction(); - JPanel button = new JPanel(); - button.setLayout(new FlowLayout()); - print_ = new JButton("Print..."); - print_.addActionListener(myAction); - button.add(print_); - layout_ = new JButton("Page Layout..."); - layout_.addActionListener(myAction); - button.add(layout_); - tree_ = new JButton("Tree View"); - tree_.addActionListener(myAction); - button.add(tree_); - edit_ = new JButton("Edit GridAttribute"); - edit_.addActionListener(myAction); - button.add(edit_); - /* - * Optionally leave the "mark" button out of the button panel - */ - if(mark) { - space_ = new JButton("Add Mark"); - space_.addActionListener(myAction); - button.add(space_); - } - return button; - } - public static void main(String[] args) { - /* - * Create the demo as an application - */ - JGridDemo gd = new JGridDemo(); - /* - * Create a new JFrame to contain the demo. - */ - JFrame frame = new JFrame("Grid Demo"); - JPanel main = new JPanel(); - main.setLayout(new BorderLayout()); - frame.setSize(600,500); - frame.getContentPane().setLayout(new BorderLayout()); - /* - * Listen for windowClosing events and dispose of JFrame - */ - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - public void windowOpened(java.awt.event.WindowEvent event) { - rpl_.getKeyPane().draw(); - } - }); - /* - * Create button panel with "mark" button - */ - JPanel button = gd.makeButtonPanel(true); - /* - * Create JPlotLayout and turn batching on. With batching on the - * plot will not be updated as components are modified or added to - * the plot tree. - */ - rpl_ = gd.makeGraph(); - rpl_.setBatch(true); - /* - * Layout the plot, key, and buttons. - */ - main.add(rpl_, BorderLayout.CENTER); - JPane gridKeyPane = rpl_.getKeyPane(); - gridKeyPane.setBatch(true); // new line - gridKeyPane.setSize(new Dimension(600,100)); - rpl_.setKeyLayerSizeP(new Dimension2D(6.0, 1.0)); - rpl_.setKeyBoundsP(new Rectangle2D.Double(0.0, 1.0, 6.0, 1.0)); - main.add(gridKeyPane, BorderLayout.SOUTH); - frame.getContentPane().add(main, BorderLayout.CENTER); - frame.getContentPane().add(button, BorderLayout.SOUTH); - - JPanel foo = null; - JPanel bar = null; - JButton foobutton = null; - JButton barbutton = null; - -/* JPanel foo = new JPanel(); - foo.setLayout(new BorderLayout()); - JButton foobutton = new JButton("my foo button"); - foo.add(foobutton, BorderLayout.CENTER); - foo.setMaximumSize(new Dimension(700, 100)); - foo.setMinimumSize(new Dimension(600, 100)); - foo.setPreferredSize(new Dimension(600, 100)); - frame.getContentPane().add(foo, BorderLayout.NORTH); - JPanel bar = new JPanel(); - bar.setLayout(new BorderLayout()); - JButton barbutton = new JButton("my bar button"); - bar.add(barbutton, BorderLayout.CENTER); - bar.setMaximumSize(new Dimension(150, 2000)); - bar.setMinimumSize(new Dimension(150, 100)); - bar.setPreferredSize(new Dimension(150, 200)); - frame.getContentPane().add(bar, BorderLayout.WEST); */ - - frame.pack(); - frame.setVisible(true); - /* - * Turn batching off. JPlotLayout will redraw if it has been - * modified since batching was turned on. - */ - gridKeyPane.setBatch(false); // new line - rpl_.setBatch(false); - - if(Debug.DEBUG) { - System.out.println("Locations:"); - System.out.println(" foo = " + foo.getLocation()); - System.out.println(" foobutton = " + foobutton.getLocation()); - System.out.println(" bar = " + bar.getLocation()); - System.out.println(" barbutton = " + barbutton.getLocation()); - System.out.println(" main = " + main.getLocation()); - System.out.println(" rpl_ = " + rpl_.getLocation()); - System.out.println(" gridKeyPane = " + gridKeyPane.getLocation()); - System.out.println(" button = " + button.getLocation()); - System.out.println(" print_ = " + gd.print_.getLocation()); - System.out.println(" space_ = " + gd.space_.getLocation()); - System.out.println(" tree_ = " + gd.tree_.getLocation()); - System.out.println(" edit_ = " + gd.edit_.getLocation()); - } - } - - void edit_actionPerformed(java.awt.event.ActionEvent e) { - /* - * Create a GridAttributeDialog and set the renderer. - */ - GridAttributeDialog gad = new GridAttributeDialog(); - gad.setJPane(rpl_); - CartesianRenderer rend = ((CartesianGraph)rpl_.getFirstLayer().getGraph()).getRenderer(); - gad.setGridCartesianRenderer((GridCartesianRenderer)rend); - // gad.setGridAttribute(gridAttr_); - gad.setVisible(true); - } - - void tree_actionPerformed(java.awt.event.ActionEvent e) { - /* - * Create a JClassTree for the JPlotLayout objects - */ - JClassTree ct = new JClassTree(); - ct.setModal(false); - ct.setJPane(rpl_); - ct.show(); - } - - void print_actionPerformed(ActionEvent e) { - Color saveColor; - - PrinterJob printJob = PrinterJob.getPrinterJob(); - printJob.setPrintable(rpl_, pageFormat); - printJob.setJobName("Grid Demo"); - if(printJob.printDialog()) { - try { - saveColor = rpl_.getBackground(); - if(!saveColor.equals(Color.white)) { - rpl_.setBackground(Color.white); - } - rpl_.setPageAlign(AbstractPane.TOP, - AbstractPane.CENTER); - RepaintManager currentManager = RepaintManager.currentManager(rpl_); - currentManager.setDoubleBufferingEnabled(false); - printJob.print(); - currentManager.setDoubleBufferingEnabled(true); - rpl_.setBackground(saveColor); - } catch (PrinterException pe) { - System.out.println("Error printing: " + pe); - } - } - - } - - void layout_actionPerformed(ActionEvent e) { - PrinterJob pj = PrinterJob.getPrinterJob(); - pageFormat = pj.pageDialog(pageFormat); - } - - JPlotLayout makeGraph() { - /* - * This example uses a pre-created "Layout" for raster time - * series to simplify the construction of a plot. The - * JPlotLayout can plot a single grid with - * a ColorKey, time series with a LineKey, point collection with a - * PointCollectionKey, and general X-Y plots with a - * LineKey. JPlotLayout supports zooming, object selection, and - * object editing. - */ - SGTData newData; - TestData td; - JPlotLayout rpl; - ContourLevels clevels; - /* - * Create a test grid with sinasoidal-ramp data. - */ - Range2D xr = new Range2D(190.0f, 250.0f, 1.0f); - Range2D yr = new Range2D(0.0f, 45.0f, 1.0f); - td = new TestData(TestData.XY_GRID, xr, yr, - TestData.SINE_RAMP, 12.0f, 30.f, 5.0f); - newData = td.getSGTData(); - /* - * Create the layout without a Logo image and with the - * ColorKey on a separate Pane object. - */ - rpl = new JPlotLayout(true, false, false, "JGridDemo Pane", null, true); - rpl.setEditClasses(false); - /* - * Create a GridAttribute for CONTOUR style. - */ - Range2D datar = new Range2D(-20.0f, 45.0f, 5.0f); - clevels = ContourLevels.getDefault(datar); - gridAttr_ = new GridAttribute(clevels); - /* - * Create a ColorMap and change the style to RASTER_CONTOUR. - */ - ColorMap cmap = createColorMap(datar); - gridAttr_.setColorMap(cmap); - gridAttr_.setStyle(GridAttribute.RASTER_CONTOUR); - /* - * Add the grid to the layout and give a label for - * the ColorKey. - */ - rpl.addData(newData, gridAttr_, "First Data"); - /* - * Change the layout's three title lines. - */ - rpl.setTitles("Raster Plot Demo", - "using a JPlotLayout", - ""); - /* - * Resize the graph and place in the "Center" of the frame. - */ - rpl.setSize(new Dimension(600, 400)); - /* - * Resize the key Pane, both the device size and the physical - * size. Set the size of the key in physical units and place - * the key pane at the "South" of the frame. - */ -// rpl.setKeyLayerSizeP(new Dimension2D(6.0, 1.02)); -// rpl.setKeyBoundsP(new Rectangle2D.Double(0.01, 1.01, 5.98, 1.0)); - - return rpl; - } - - ColorMap createColorMap(Range2D datar) { - int[] red = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 23, 39, 55, 71, 87,103, - 119,135,151,167,183,199,215,231, - 247,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,246,228,211,193,175,158,140}; - int[] green = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 11, 27, 43, 59, 75, 91,107, - 123,139,155,171,187,203,219,235, - 251,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0}; - int[] blue = - { 0,143,159,175,191,207,223,239, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - - IndexedColorMap cmap = new IndexedColorMap(red, green, blue); - cmap.setTransform(new LinearTransform(0.0, (double)red.length, - datar.start, datar.end)); - return cmap; - } - - class MyAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object obj = event.getSource(); - if(obj == edit_) { - edit_actionPerformed(event); - } else if(obj == space_) { - System.out.println(" <>"); - } else if(obj == tree_) { - tree_actionPerformed(event); - } else if(obj == print_) { - print_actionPerformed(event); - } else if(obj == layout_) { - layout_actionPerformed(event); - } - } - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JLayoutDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JLayoutDemo.java deleted file mode 100755 index c46317a6..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JLayoutDemo.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * $Id: JLayoutDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.LineKey; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.StackedLayout; -import gov.noaa.pmel.sgt.Axis; - -import gov.noaa.pmel.sgt.dm.SimpleLine; - -import gov.noaa.pmel.sgt.swing.JClassTree; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.TimePoint; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTPoint; - -import java.util.Enumeration; -import java.awt.*; -import javax.swing.*; -import javax.swing.border.EtchedBorder; - -/** - * Example demonstrating how to use setLayout() with - * JPane to change how Layers are placed on - * a JPane. JLayoutDemo constructs the - * plots from basic sgt objects. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ -public class JLayoutDemo extends JApplet { - JPane mainPane_; - JClassTree tree_ = null; - boolean isApplet_ = true; - JFrame frame = null; - - public void init() { - /* - * Create a JLayoutDemo within a JApplet - */ - setLayout(new BorderLayout(0,0)); - setBackground(Color.white); - setSize(426,712); - - makeControlPanel(); - add(controlPanel, BorderLayout.SOUTH); - - makeGraph(); - add(mainPane_, BorderLayout.CENTER); - } - - public static void main(String[] args) { - /* - * Create a JLayoutDemo as an application. - */ - JLayoutDemo ld = new JLayoutDemo(); - ld.isApplet_ = false; - ld.frame = new JFrame("Layout Demo"); - ld.frame.setSize(426,712); - ld.frame.getContentPane().setLayout(new BorderLayout()); - ld.frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - }); - - ld. makeControlPanel(); - ld.frame.getContentPane().add(ld.controlPanel, BorderLayout.SOUTH); - - ld.makeGraph(); - ld.mainPane_.setBackground(Color.white); - ld.mainPane_.setBatch(true); - ld.frame.getContentPane().add(ld.mainPane_, BorderLayout.CENTER); - - ld.frame.setVisible(true); - ld.mainPane_.setBatch(false); - } - - void makeControlPanel() { - controlPanel.setLayout(new GridBagLayout()); -// controlPanel.setBackground(new java.awt.Color(200,200,200)); - controlPanel.setBounds(0,679,426,33); - controlPanel.setBorder(new EtchedBorder()); - gridtype.add(stacked); - stacked.setSelected(true); - stacked.setText("Overlayed"); - - GridBagConstraints gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gbc.weightx = 0.0; - gbc.weighty = 1.0; - gbc.anchor = GridBagConstraints.EAST; - gbc.fill = GridBagConstraints.BOTH; - gbc.insets = new Insets(5,15,5,5); - gbc.ipadx = 0; - gbc.ipady = 0; - controlPanel.add(stacked, gbc); - stacked.setBounds(15,5,84,23); - gridtype.add(grid); - grid.setText("Grid"); - - gbc.gridx = 1; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gbc.weightx = 0.5; - gbc.weighty = 1.0; - gbc.anchor = GridBagConstraints.WEST; - gbc.fill = GridBagConstraints.VERTICAL; - gbc.insets = new Insets(5,5,5,0); - gbc.ipadx = 0; - gbc.ipady = 0; - controlPanel.add(grid, gbc); - grid.setBounds(109,5,53,23); - showTree.setText("Show Class Tree"); - - gbc.gridx = 2; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.anchor = GridBagConstraints.EAST; - gbc.fill = GridBagConstraints.VERTICAL; - gbc.insets = new Insets(5,5,5,15); - gbc.ipadx = 0; - gbc.ipady = 0; - controlPanel.add(showTree, gbc); - showTree.setBackground(Color.yellow.brighter()); - showTree.setBounds(302,5,109,23); - - SymItem lSymItem = new SymItem(); - stacked.addItemListener(lSymItem); - grid.addItemListener(lSymItem); - SymAction lSymAction = new SymAction(); - showTree.addActionListener(lSymAction); - } - - void makeGraph() { - /* - * This example explicitly creates the JPane, Layers, Axes, and SGLabels. - */ - /* - * Create JPane, place in the center of the frame - * and set the layout to use the StackedLayout. StackedLayout is - * a custom layout manager designed to place Components directly - * over one another. - */ - mainPane_ = new JPane("Layout Demo", new Dimension(426, 400)); - mainPane_.setLayout(new StackedLayout()); - /* - * Create the two random time series using the TestData class and - * the SimpleLine classes from sgt.dm - */ - SimpleLine line; - SimpleLine line2; - GeoDate start = null; - GeoDate stop = null; - TimeRange tr; - TestData td; - try { - start = new GeoDate("1992-11-01", "yyyy-MM-dd"); - stop = new GeoDate("1993-02-20", "yyyy-MM-dd"); - } catch (IllegalTimeValue e) {} - tr = new TimeRange(start, stop); - td = new TestData(TestData.TIME_SERIES, tr, 1.0f, - TestData.RANDOM, 1.2f, 0.0f, 20.0f); - line = (SimpleLine)td.getSGTData(); - // - try { - start = new GeoDate("1992-11-01", "yyyy-MM-dd"); - stop = new GeoDate("1993-02-20", "yyyy-MM-dd"); - } catch (IllegalTimeValue e) {} - tr = new TimeRange(start, stop); - td = new TestData(TestData.TIME_SERIES, tr, 1.0f, - TestData.RANDOM, 1.2f, 0.5f, 30.0f); - line2 = (SimpleLine)td.getSGTData(); - /* - * Get the axis ranges from SGTLine - */ - SoTRange ynRange, yRange; - SoTRange tnRange; - String yLabel; - yRange = line.getYRange(); - yRange.add(line2.getYRange()); - tnRange = line.getXRange(); - /* - * compute the range for the y and time axes - * and get the y axis label from line's metadata - */ - ynRange = Graph.computeRange(yRange, 6); - yLabel = line.getYMetaData().getName(); - /* - * LayoutDemo will have two layers. - * One layer for each line to be drawn. - * The first layer will contain the axes and labels - * and the first set of data. The second layer will - * contain the second set of data. - */ - /* - * xsize, ysize are the width and height in physical units - * of the Layer graphics region. - * - * xstart, xend are the start and end points for the TimeAxis - * ystart, yend are the start and end points for the Y axis - */ - double xsize = 4.0; - double xstart = 0.6; - double xend = 3.25; - double ysize = 3.0; - double ystart = 0.6; - double yend = 2.50; - - Layer layer, layer2; - SGLabel label, title, ytitle; - CartesianGraph graph, graph2; - LinearTransform xt, yt; - PlainAxis yleft; - TimeAxis xbot; - LineKey lkey; - GeoDate stime; - /* - * create the first layer - */ - layer = new Layer("First Layer", new Dimension2D(xsize, ysize)); - /* - * create a time stamp label for the plot - * position the label at the lower left corner - * and add to the first layer - * (NOTE: the time will be displayed for the GMT time zone) - */ - stime = new GeoDate(); - label = new SGLabel("Date Stamp", stime.toString(), - new Point2D.Double(0.05, 0.05)); - label.setAlign(SGLabel.BOTTOM, SGLabel.LEFT); - label.setColor(Color.magenta); - label.setHeightP(0.15); - label.setFont(new Font("Dialog", Font.PLAIN, 10)); - layer.addChild(label); - /* - * create a title for the plot - * position the label centered on the graph - * and add to the first layer - */ - title = new SGLabel("Title", "Layout Demo", - new Point2D.Double(xsize/2.0, ysize)); - title.setAlign(SGLabel.TOP, SGLabel.CENTER); - title.setHeightP(0.20); - title.setFont(new Font("Helvetica", Font.BOLD, 14)); - layer.addChild(title); - /* - * create a LineKey - * the LineKey will be a legend for the two lines created - * position the key in the upper right corner - * and add to the first layer - */ - lkey = new LineKey(); - lkey.setId("Legend"); - lkey.setLocationP(new Point2D.Double(xsize - 0.01, ysize)); - lkey.setVAlign(LineKey.TOP); - lkey.setHAlign(LineKey.RIGHT); - layer.addChild(lkey); - /* - * add the first layer to the Pane - */ - mainPane_.add(layer); - /* - * create first CartesianGraph and transforms - */ - graph = new CartesianGraph("First Graph"); - xt = new LinearTransform(new Range2D(xstart, xend), tnRange); - graph.setXTransform(xt); - yt = new LinearTransform(new Range2D(ystart, yend), ynRange); - graph.setYTransform(yt); - /* - * Create the time axis, set its range in user units - * and its origin. Add the axis to the first graph. - */ - SoTPoint point = new SoTPoint(ynRange.getStart(), tnRange.getStart()); - xbot = new TimeAxis("Bottom Axis", TimeAxis.MONTH_YEAR); - xbot.setRangeU(tnRange); - xbot.setLocationU(point); - Font xbfont = new Font("Helvetica", Font.ITALIC, 14); - xbot.setLabelFont(xbfont); - xbot.setMinorLabelInterval(1); - graph.addXAxis(xbot); - /* - * Create the vertical axis, set its range in user units - * and its origin. Create the axis title and add the - * axis to the first graph. - */ - yleft = new PlainAxis("Left Axis"); - yleft.setRangeU(ynRange); - yleft.setLocationU(point); - yleft.setLabelFont(xbfont); - ytitle = new SGLabel("Y-Axis Title", yLabel, - new Point2D.Double(0.0, 0.0)); - Font ytfont = new Font("Helvetica", Font.PLAIN, 14); - ytitle.setFont(ytfont); - ytitle.setHeightP(0.2); - yleft.setTitle(ytitle); - graph.addYAxis(yleft); - /* - * Add the first graph to the first layer. - */ - layer.setGraph(graph); - /* - * Create a LineAttribute for the display of the first - * line. Associate the attribute and the line with the - * first graph. Add the line to the LineKey. - */ - LineAttribute attr; - - attr = new LineAttribute(LineAttribute.MARK, 20, Color.red); - attr.setMarkHeightP(0.1); - graph.setData(line, attr); - lkey.addLineGraph((LineCartesianRenderer)graph.getRenderer(), - new SGLabel("1st line", "Red Data", - new Point2D.Double(0.0, 0.0))); - /* - * Create the second layer and add it the the Pane. - * Create the second graph and associate it with the - * second layer. - */ - layer2 = new Layer("Second Layer", new Dimension2D(xsize, ysize)); - mainPane_.add(layer2); - graph2 = new CartesianGraph("Second Graph", xt, yt); - layer2.setGraph(graph2); - /* - * Create a LineAttribute for the display of the second - * line. Associate the attribute and the line with the - * second graph. Add the line to the LineKey. - */ - LineAttribute attr2; - attr2 = new LineAttribute(LineAttribute.MARK, 2, Color.blue); - attr2.setMarkHeightP(0.1); - graph2.setData(line2, attr2); - lkey.addLineGraph((LineCartesianRenderer)graph2.getRenderer(), - new SGLabel("2nd line", "Blue Data", - new Point2D.Double(0.0, 0.0))); - - } - - JPanel controlPanel = new JPanel(); - JCheckBox stacked = new JCheckBox(); - ButtonGroup gridtype = new ButtonGroup(); - JCheckBox grid = new JCheckBox(); - JButton showTree = new JButton(); - - class SymItem implements java.awt.event.ItemListener { - public void itemStateChanged(java.awt.event.ItemEvent event) { - Object object = event.getSource(); - if (object == stacked) - stacked_itemStateChanged(event); - else if (object == grid) - grid_itemStateChanged(event); - } - } - - /** - * Change the Pane layout to StackedLayout. - * - * @param event - */ - - void stacked_itemStateChanged(java.awt.event.ItemEvent event) { - /* - * Get the component list for mainPane_ and change - * the layout to StackedLayout. - */ - Component[] comps = mainPane_.getComponents(); - mainPane_.setBatch(true); - mainPane_.setLayout(new StackedLayout()); - /* - * Remove any axes that have been associated with - * the second graph. With the layers overlayed it - * is not necessary to have duplicate axes. - */ - Graph gr2 = ((Layer)comps[1]).getGraph(); - ((CartesianGraph)gr2).removeAllXAxes(); - ((CartesianGraph)gr2).removeAllYAxes(); - /* - * Tell the Applet that the mainPane_ needs to - * be layed out and re-draw the mainPane_. - */ - if(isApplet_) { - validate(); - } else { - frame.validate(); - } - mainPane_.setBatch(false); - if(tree_ != null) { - if(tree_.isVisible()) { - tree_.setJPane(mainPane_); - tree_.expandTree(); - } - } - } - - /** - * Change the Pane layout to GridLayout. - * - * @param event - */ - - void grid_itemStateChanged(java.awt.event.ItemEvent event) { - /* - * Get the component list for mainPane_ and change - * the layout to GridLayout. - */ - Component[] comps = mainPane_.getComponents(); - mainPane_.setBatch(true); - mainPane_.setLayout(new GridLayout(2,0)); - /* - * Get the first and second graphs from the first - * and second layers, respectively. - */ - Graph gr = ((Layer)comps[0]).getGraph(); - Graph gr2 = ((Layer)comps[1]).getGraph(); - /* - * Create copies of all X-Axes associated with the first - * graph for the second graph. If the axes are not copied then - * the second graph will have the second line plotted, but without - * any axes. - */ - for(Enumeration xa = ((CartesianGraph)gr).xAxisElements(); xa.hasMoreElements();) { - ((CartesianGraph)gr2).addXAxis(((Axis)xa.nextElement()).copy()); - } - /* - * Create copies of all Y-Axes associated with the first - * graph for the second graph. - */ - for(Enumeration ya = ((CartesianGraph)gr).yAxisElements(); ya.hasMoreElements();) { - ((CartesianGraph)gr2).addYAxis(((Axis)ya.nextElement()).copy()); - } - /* - * Tell the Applet that the mainPane_ needs to - * be layed out and re-draw the mainPane_. - */ - if(isApplet_) { - validate(); - } else { - frame.validate(); - } - // mainPane_.draw(); - mainPane_.setBatch(false); - if(tree_ != null) { - if(tree_.isVisible()) { - tree_.setJPane(mainPane_); - tree_.expandTree(); - } - } - } - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == showTree) - showTree_ActionPerformed(event); - } - } - - void showTree_ActionPerformed(java.awt.event.ActionEvent event) { - /* - * Create the ClassTree dialog to display the classes used - * in the mainPane_ and allow editing. - */ - if(tree_ == null) { - tree_ = new JClassTree("Classes for LayoutDemo"); - } - tree_.setJPane(mainPane_); - tree_.show(); - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JLogLogDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JLogLogDemo.java deleted file mode 100755 index f0f6841c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JLogLogDemo.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * $Id: JLogLogDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.Layer; -//import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.LogAxis; -import gov.noaa.pmel.sgt.LineKey; -//import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.LogTransform; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.SGLabel; -//import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.StackedLayout; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.swing.JClassTree; -//import gov.noaa.pmel.sgt.Logo; - -//import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.dm.SGTData; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.Dimension2D; - -import java.awt.*; -import javax.swing.*; - -/** - * Example demonstrating the creation of a simple - * graph using LogAxis. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 3.0 - */ - -public class JLogLogDemo extends JApplet { - JButton tree_; - JButton space_; - JPane mainPane_; - - public void init() { - setLayout(new BorderLayout(0,0)); - setSize(553,438); - - add(makeGraph(), BorderLayout.CENTER); - } - - public static void main(String[] args) { - JLogLogDemo pd = new JLogLogDemo(); - JFrame frame = new JFrame("Log-Log Demo"); - JPanel button = new JPanel(); - JPane graph; - button.setLayout(new FlowLayout()); - pd.tree_ = new JButton("Tree View"); - MyAction myAction = pd. new MyAction(); - pd.tree_.addActionListener(myAction); - button.add(pd.tree_); - pd.space_ = new JButton("Add Mark"); - pd.space_.addActionListener(myAction); - button.add(pd.space_); - frame.getContentPane().setLayout(new BorderLayout()); - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - }); - frame.setSize(553,438); - graph = pd.makeGraph(); - graph.setBatch(true); - frame.getContentPane().add(graph, BorderLayout.CENTER); - frame.getContentPane().add(button, BorderLayout.SOUTH); - frame.pack(); - frame.setVisible(true); - graph.setBatch(false); - } - - JPane makeGraph() { - /* - * This example creates a very simple plot from - * scratch (not using one of the sgt.awt classes) - * to display log-log line. - */ - /* - * Create a Pane, place in the center of the Applet - * and set the layout to be StackedLayout. - */ - mainPane_ = new JPane("Point Plot Demo", new Dimension(553,438)); - mainPane_.setLayout(new StackedLayout()); - mainPane_.setBackground(Color.white); - /* - * Create a line using the TestData class. - */ - Range2D xrange; - SoTRange yrange; - TestData td; - SGTData data; - xrange = new Range2D(50.0, 150000., 1.25); - td = new TestData(TestData.LOG_LOG, xrange, TestData.RANDOM, 10000.0f, 1.0f, 10.0f); - data = td.getSGTData(); - yrange = data.getYRange(); - /* - * xsize, ysize are the width and height in physical units - * of the Layer graphics region. - * - * xstart, xend are the start and end points for the X axis - * ystart, yend are the start and end points for the Y axis - */ - double xsize = 4.0; - double xstart = 0.6; - double xend = 3.5; - double ysize = 3.0; - double ystart = 0.6; - double yend = 2.75; - /* - * Create the layer and add it to the Pane. - */ - Layer layer; - - layer = new Layer("Layer 1", new Dimension2D(xsize, ysize)); - mainPane_.add(layer); - /* - * Create a CartesianGraph and transforms. - */ - CartesianGraph graph; - LogTransform xt, yt; - - graph = new CartesianGraph("Log-Log Graph"); - layer.setGraph(graph); - xt = new LogTransform(xstart, xend, xrange.start, xrange.end); - yt = new LogTransform(new Range2D(ystart, yend), yrange); - graph.setXTransform(xt); - graph.setYTransform(yt); - /* - * Create the bottom axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - LogAxis xbot; - String xLabel = "X Label"; - - xbot = new LogAxis("Botton Axis"); - xbot.setRangeU(xrange); - xbot.setLocationU(new SoTPoint(new SoTValue.Double(xrange.start), yrange.getStart())); - Font xbfont = new Font("Helvetica", Font.ITALIC, 14); - xbot.setLabelFont(xbfont); - SGLabel xtitle = new SGLabel("xaxis title", xLabel, - new Point2D.Double(0.0, 0.0)); - Font xtfont = new Font("Helvetica", Font.PLAIN, 14); - xtitle.setFont(xtfont); - xtitle.setHeightP(0.2); - xbot.setTitle(xtitle); - graph.addXAxis(xbot); - /* - * Create the left axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - LogAxis yleft; - String yLabel = "Y Label"; - - yleft = new LogAxis("Left Axis"); - yleft.setRangeU(yrange); - yleft.setLocationU(new SoTPoint(new SoTValue.Double(xrange.start), yrange.getStart())); - yleft.setLabelFont(xbfont); - SGLabel ytitle = new SGLabel("yaxis title", yLabel, - new Point2D.Double(0.0, 0.0)); - Font ytfont = new Font("Helvetica", Font.PLAIN, 14); - ytitle.setFont(ytfont); - ytitle.setHeightP(0.2); - yleft.setTitle(ytitle); - graph.addYAxis(yleft); - /* - * Create a LineAttribute for the display of the - * line. - */ - LineAttribute lattr; - lattr = new LineAttribute(LineAttribute.SOLID, Color.red); - /* - * Associate the attribute and the line - * with the graph. - */ - graph.setData(data, lattr); - - return mainPane_; - } - - void tree_actionPerformed(java.awt.event.ActionEvent e) { - JClassTree ct = new JClassTree(); - ct.setModal(false); - ct.setJPane(mainPane_); - ct.show(); - } - - class MyAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object obj = event.getSource(); - if(obj == space_) { - System.out.println(" <>"); - } - if(obj == tree_) - tree_actionPerformed(event); - } - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JPointDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JPointDemo.java deleted file mode 100755 index fd1ab096..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JPointDemo.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * $Id: JPointDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.LineKey; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.StackedLayout; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.swing.JClassTree; -import gov.noaa.pmel.sgt.Logo; - -import gov.noaa.pmel.sgt.dm.Collection; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Dimension2D; - -import java.awt.*; -import javax.swing.*; - -/** - * Example demonstrating the creation of a simple - * graph of many points. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ - -public class JPointDemo extends JApplet { - JButton tree_; - JButton space_; - JPane mainPane_; - - public void init() { - setLayout(new BorderLayout(0,0)); - setSize(553,438); - - add(makeGraph(), BorderLayout.CENTER); - } - - public static void main(String[] args) { - JPointDemo pd = new JPointDemo(); - JFrame frame = new JFrame("Point Demo"); - JPanel button = new JPanel(); - JPane graph; - button.setLayout(new FlowLayout()); - pd.tree_ = new JButton("Tree View"); - MyAction myAction = pd. new MyAction(); - pd.tree_.addActionListener(myAction); - button.add(pd.tree_); - pd.space_ = new JButton("Add Mark"); - pd.space_.addActionListener(myAction); - button.add(pd.space_); - frame.getContentPane().setLayout(new BorderLayout()); - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - }); - frame.setSize(553,438); - graph = pd.makeGraph(); - graph.setBatch(true); - frame.getContentPane().add(graph, BorderLayout.CENTER); - frame.getContentPane().add(button, BorderLayout.SOUTH); - frame.pack(); - frame.setVisible(true); - graph.setBatch(false); - } - - JPane makeGraph() { - /* - * This example creates a very simple plot from - * scratch (not using one of the sgt.awt classes) - * to display a Collection of points. - */ - /* - * Create a Pane, place in the center of the Applet - * and set the layout to be StackedLayout. - */ - mainPane_ = new JPane("Point Plot Demo", new Dimension(553,438)); - mainPane_.setLayout(new StackedLayout()); - mainPane_.setBackground(Color.white); - /* - * Create a Collection of points using the TestData class. - */ - Range2D xrange, yrange; - TestData td; - Collection col; - xrange = new Range2D(50.0, 150., 10.0); - yrange = new Range2D(-20.0, 20.0, 5.0); - td = new TestData(xrange, yrange, 50); - col = td.getCollection(); - /* - * xsize, ysize are the width and height in physical units - * of the Layer graphics region. - * - * xstart, xend are the start and end points for the X axis - * ystart, yend are the start and end points for the Y axis - */ - double xsize = 4.0; - double xstart = 0.6; - double xend = 3.5; - double ysize = 3.0; - double ystart = 0.6; - double yend = 2.75; - /* - * Create the layer and add it to the Pane. - */ - Layer layer; - - layer = new Layer("Layer 1", new Dimension2D(xsize, ysize)); - mainPane_.add(layer); - /* - * create and add image as a Logo to the layer - */ - Image img = this.getToolkit().getImage(getClass().getResource("ncBrowse48.gif")); - // - // wait for image to be loaded - // - if(img != null) { - MediaTracker mt = new MediaTracker(this); - try { - mt.addImage(img, 0); - mt.waitForAll(); - if(mt.isErrorAny()) - System.err.println("JPointDemo: Error loading image"); - } catch (InterruptedException e) {} - } - Logo logo = new Logo(new Point2D.Double(0.0, 0.0), Logo.BOTTOM, Logo.LEFT); - logo.setId("ncBrowse logo"); - logo.setImage(img); - layer.addChild(logo); - /* - * Create a CartesianGraph and transforms. - */ - CartesianGraph graph; - LinearTransform xt, yt; - - graph = new CartesianGraph("Point Graph"); - layer.setGraph(graph); - xt = new LinearTransform(xstart, xend, xrange.start, xrange.end); - yt = new LinearTransform(ystart, yend, yrange.start, yrange.end); - graph.setXTransform(xt); - graph.setYTransform(yt); - /* - * Create the bottom axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - PlainAxis xbot; - String xLabel = "X Label"; - - xbot = new PlainAxis("Botton Axis"); - xbot.setRangeU(xrange); - xbot.setLocationU(new Point2D.Double(xrange.start, yrange.start)); - Font xbfont = new Font("Helvetica", Font.ITALIC, 14); - xbot.setLabelFont(xbfont); - SGLabel xtitle = new SGLabel("xaxis title", xLabel, - new Point2D.Double(0.0, 0.0)); - Font xtfont = new Font("Helvetica", Font.PLAIN, 14); - xtitle.setFont(xtfont); - xtitle.setHeightP(0.2); - xbot.setTitle(xtitle); - graph.addXAxis(xbot); - /* - * Create the left axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - PlainAxis yleft; - String yLabel = "Y Label"; - - yleft = new PlainAxis("Left Axis"); - yleft.setRangeU(yrange); - yleft.setLocationU(new Point2D.Double(xrange.start, yrange.start)); - yleft.setLabelFont(xbfont); - SGLabel ytitle = new SGLabel("yaxis title", yLabel, - new Point2D.Double(0.0, 0.0)); - Font ytfont = new Font("Helvetica", Font.PLAIN, 14); - ytitle.setFont(ytfont); - ytitle.setHeightP(0.2); - yleft.setTitle(ytitle); - graph.addYAxis(yleft); - /* - * Create a PointAttribute for the display of the - * Collection of points. The points will be red with - * the label at the NE corner and in blue. - */ - PointAttribute pattr; - - pattr = new PointAttribute(20, Color.red); - pattr.setLabelPosition(PointAttribute.NE); - Font pfont = new Font("Helvetica", Font.PLAIN, 12); - pattr.setLabelFont(pfont); - pattr.setLabelColor(Color.blue); - pattr.setLabelHeightP(0.1); - pattr.setDrawLabel(true); - /* - * Associate the attribute and the point Collection - * with the graph. - */ - graph.setData(col, pattr); - - return mainPane_; - } - - void tree_actionPerformed(java.awt.event.ActionEvent e) { - JClassTree ct = new JClassTree(); - ct.setModal(false); - ct.setJPane(mainPane_); - ct.show(); - } - - class MyAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object obj = event.getSource(); - if(obj == space_) { - System.out.println(" <>"); - } - if(obj == tree_) - tree_actionPerformed(event); - } - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JProfileDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JProfileDemo.java deleted file mode 100755 index 88f6446c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JProfileDemo.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * $Id: JProfileDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.swing.JPlotLayout; -import gov.noaa.pmel.sgt.dm.SGTData; - -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Point2D; - -import java.awt.*; -import javax.swing.*; -/** - * Example demonstrating how to use JPlotLayout to create - * a profile plot. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ - - -public class JProfileDemo extends JApplet { - public void init() { - setLayout(null); - setSize(450,600); - add("Center", makeGraph()); - } - - public static void main(String[] args) { - JProfileDemo pd = new JProfileDemo(); - JFrame frame = new JFrame("Profile Demo"); - JPane graph; - frame.getContentPane().setLayout(new BorderLayout()); - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - }); - frame.setSize(450, 600); - graph = pd.makeGraph(); - graph.setBatch(true); - frame.getContentPane().add(graph, BorderLayout.CENTER); - frame.pack(); - frame.setVisible(true); - graph.setBatch(false); - } - - JPlotLayout makeGraph() { - /* - * This example uses a pre-created "Layout" for profile - * data to simplify the construction of a plot. The - * LineProfileLayout can plot multiple lines, with - * a legend and provides zooming and line hi-lighting - * capabilities. - */ - SGTData newData; - TestData td; - JPlotLayout lpl; - /* - * Create a test profile with random data. - */ - Range2D zrange = new Range2D(0.0, 495.0, 10.0); - td = new TestData(TestData.PROFILE, zrange, - TestData.RANDOM, 1.2f, 0.5f, 30.0f); - newData = td.getSGTData(); - /* - * Create the layout without a Logo image and with the - * LineKey on the main Pane object. Data object is used - * to automatically determine the type of plot to create. - */ - lpl = new JPlotLayout(newData, "Profile Demo", null, false); - /* - * Add first profile. - */ - lpl.addData(newData, "First Line"); - /* - * Create a second profile. - */ - td = new TestData(TestData.PROFILE, zrange, - TestData.RANDOM, 2.0f, 0.25f, 30.0f); - lpl.addData(td.getSGTData(), "Second Line"); - /* - * Change the layout's three title lines and place the Pane - * on the Applet. - */ - lpl.setTitles("Profile Demo", - "using a sgt.swing class", - "JPlotLayout"); - - lpl.setSize(new Dimension(450,600)); - lpl.setLayerSizeP(new Dimension2D(6.0, 8.0)); - lpl.setKeyLocationP(new Point2D.Double(6.0, 8.0)); - return lpl; - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JRealTimeDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JRealTimeDemo.java deleted file mode 100755 index aa811892..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JRealTimeDemo.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * $Id: JRealTimeDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import java.awt.*; -import java.awt.event.*; -import java.applet.*; -import javax.swing.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import gov.noaa.pmel.sgt.*; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Point2D; -//import gov.noaa.pmel.util.*; - -/** - * Example demonstrating the use of PropertyChangeEvents - * in the datamodel. JRealTimeDemo constructs the plot - * from basic sgt objects. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ - -public class JRealTimeDemo extends JApplet implements PropertyChangeListener { - PseudoRealTimeData rtData_; - JPane pane_; - Layer layer_; - TimeAxis xbot_; - PlainAxis yleft_; - LinearTransform xt_, yt_; - boolean isStandalone = false; - BorderLayout borderLayout1 = new BorderLayout(); - JPanel buttonPanel = new JPanel(); - JButton startButton = new JButton(); - JButton stopButton = new JButton(); - JButton resetButton = new JButton(); - - /**Construct the applet*/ - public JRealTimeDemo() { - } - /**Initialize the applet*/ - public void init() { - /* - * Create the data source - */ - rtData_ = new PseudoRealTimeData("rtDataSource", "Sea Level"); - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - /* - * add listener for data source. JRealTimeDemo is listening - * for rangeModified events - */ - rtData_.addPropertyChangeListener(this); - } - /**Component initialization*/ - private void jbInit() throws Exception { - this.setSize(new Dimension(800, 440)); - this.getContentPane().setLayout(borderLayout1); - startButton.setText("start"); - startButton.addActionListener(new JRealTimeDemo_startButton_actionAdapter(this)); - stopButton.setText("stop"); - stopButton.addActionListener(new JRealTimeDemo_stopButton_actionAdapter(this)); - resetButton.setText("reset"); - resetButton.addActionListener(new JRealTimeDemo_resetButton_actionAdapter(this)); - buttonPanel.setBorder(BorderFactory.createEtchedBorder()); - this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); - buttonPanel.add(startButton, null); - buttonPanel.add(stopButton, null); - buttonPanel.add(resetButton, null); - // - // construct JPane - // - pane_ = new JPane("Real Time Data Demo", new Dimension(800, 400)); - pane_.setBatch(true); - pane_.setLayout(new StackedLayout()); - pane_.setBackground(Color.white); - /* - * xsize, ysize are the width and height in physical units - * of the Layer graphics region. - * - * xstart, xend are the start and end points for the X axis - * ystart, yend are the start and end points for the Y axis - */ - double xsize = 6.0; - double xstart = 0.6; - double xend = 5.5; - double ysize = 3.0; - double ystart = 0.6; - double yend = 2.75; - /* - * Create the layer and add it to the Pane. - */ - CartesianGraph graph; - /* - * Get x and y ranges from data source. - */ - SoTRange.GeoDate xrange = (SoTRange.GeoDate)rtData_.getXRange(); - SoTRange.Double yrange = (SoTRange.Double)rtData_.getYRange(); - - xt_ = new LinearTransform(xstart, xend, xrange.start, xrange.end); - yt_ = new LinearTransform(ystart, yend, yrange.start, yrange.end); - - layer_ = new Layer("Layer 1", new Dimension2D(xsize, ysize)); - pane_.add(layer_); - - SGLabel title = new SGLabel("title", - "Real Time Demo", - new Point2D.Double((xstart+xend)/2.0, - ysize-0.05)); - title.setAlign(SGLabel.TOP, SGLabel.CENTER); - title.setFont(new Font("Serif", Font.PLAIN, 14)); - title.setHeightP(0.25); - title.setColor(Color.blue.darker()); - layer_.addChild(title); - /* - * Create a CartesianGraph and set transforms. - */ - graph = new CartesianGraph("Time Graph"); - layer_.setGraph(graph); - graph.setXTransform(xt_); - graph.setYTransform(yt_); - /* - * Create the bottom axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - SoTPoint origin = new SoTPoint(xrange.start, yrange.start); - xbot_ = new TimeAxis("Botton Axis", TimeAxis.AUTO); - xbot_.setRangeU(xrange); - xbot_.setLocationU(origin); - Font xbfont = new Font("Helvetica", Font.PLAIN, 14); - xbot_.setLabelFont(xbfont); - graph.addXAxis(xbot_); - /* - * Create the left axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - String yLabel = "Latitude"; - - yleft_ = new PlainAxis("Left Axis"); - yleft_.setRangeU(yrange); - yleft_.setLocationU(origin); - yleft_.setLabelFont(xbfont); - SGLabel ytitle = new SGLabel("yaxis title", yLabel, - new Point2D.Double(0.0, 0.0)); - Font ytfont = new Font("Helvetica", Font.PLAIN, 14); - ytitle.setFont(ytfont); - ytitle.setHeightP(0.2); - yleft_.setTitle(ytitle); - graph.addYAxis(yleft_); - - LineAttribute attr = new LineAttribute(); - graph.setData(rtData_, attr); - - this.getContentPane().add(pane_, BorderLayout.CENTER); - if(!isStandalone) pane_.setBatch(false); - } - /**Start the applet*/ - public void start() { - } - /**Stop the applet*/ - public void stop() { - rtData_.stopData(); - } - /**Destroy the applet*/ - public void destroy() { - rtData_.stopData(); - } - /**Get Applet information*/ - public String getAppletInfo() { - return "Applet Information"; - } - /**Main method*/ - public static void main(String[] args) { - JRealTimeDemo applet = new JRealTimeDemo(); - applet.isStandalone = true; - JFrame frame = new JFrame(); - //EXIT_ON_CLOSE == 3 - frame.setDefaultCloseOperation(3); - frame.setTitle("Real Time Data Demo"); - frame.getContentPane().add(applet, BorderLayout.CENTER); - applet.init(); - applet.start(); - frame.setSize(800,440); - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation((d.width - frame.getSize().width) / 2, - (d.height - frame.getSize().height) / 2); - frame.setVisible(true); - applet.pane_.setBatch(false); - } - - //static initializer for setting look & feel - static { - try { - //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - } - catch(Exception e) { - } - } - - void startButton_actionPerformed(ActionEvent e) { - rtData_.startData(); - } - - void stopButton_actionPerformed(ActionEvent e) { - rtData_.stopData(); - } - - void resetButton_actionPerformed(ActionEvent e) { - rtData_.stopData(); - rtData_.resetData(); - resetRange(); - } - private void resetRange() { - /* - * A change in the range has occured. Get new range - * and set transforms, axes, and origin appropriately. - */ - pane_.setBatch(true); - SoTRange.GeoDate xrange = (SoTRange.GeoDate)rtData_.getXRange(); - SoTRange.Double yrange = (SoTRange.Double)rtData_.getYRange(); - SoTPoint origin = new SoTPoint(xrange.start, yrange.start); - xt_.setRangeU(xrange); - yt_.setRangeU(yrange); - xbot_.setRangeU(xrange); - xbot_.setLocationU(origin); - yleft_.setRangeU(yrange); - yleft_.setLocationU(origin); - pane_.setBatch(false); - } - public void propertyChange(PropertyChangeEvent evt) { - /** - * dataModified property is handled by CartesianGraph - * only need to look for rangeModified here to make sure - * range is properly updated - */ - if("rangeModified".equals(evt.getPropertyName())) { - resetRange(); - } - } -} -/* - * wrappers for button events created by JBuilder - */ -class JRealTimeDemo_startButton_actionAdapter implements ActionListener { - JRealTimeDemo adaptee; - - JRealTimeDemo_startButton_actionAdapter(JRealTimeDemo adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.startButton_actionPerformed(e); - } -} - -class JRealTimeDemo_stopButton_actionAdapter implements ActionListener { - JRealTimeDemo adaptee; - - JRealTimeDemo_stopButton_actionAdapter(JRealTimeDemo adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.stopButton_actionPerformed(e); - } -} - -class JRealTimeDemo_resetButton_actionAdapter implements ActionListener { - JRealTimeDemo adaptee; - - JRealTimeDemo_resetButton_actionAdapter(JRealTimeDemo adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.resetButton_actionPerformed(e); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JTimeSeriesDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JTimeSeriesDemo.java deleted file mode 100755 index 9da96b8b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JTimeSeriesDemo.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * $Id: JTimeSeriesDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.swing.JPlotLayout; -import gov.noaa.pmel.sgt.swing.JClassTree; -import gov.noaa.pmel.sgt.swing.prop.LineAttributeDialog; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.LineAttribute; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.IllegalTimeValue; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTLine; - -import java.awt.*; -import javax.swing.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -/** - * Example demonstrating how to use JPlotLayout - * to create a time series plot. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ - -public class JTimeSeriesDemo extends JApplet { - JButton tree_; - JButton space_ = null; - JPane pane_; - MyMouse myMouse_; - LineAttributeDialog lad_; - - public void init() { - /* - * init is used when run as an JApplet - */ - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(600,500); - pane_ = makeGraph(); - pane_.setBatch(true); - JPanel button = makeButtonPanel(false); - getContentPane().add(pane_, BorderLayout.CENTER); - getContentPane().add(button, "South"); - pane_.setBatch(false); - } - - JPanel makeButtonPanel(boolean mark) { - JPanel button = new JPanel(); - button.setLayout(new FlowLayout()); - tree_ = new JButton("Tree View"); - MyAction myAction = new MyAction(); - tree_.addActionListener(myAction); - button.add(tree_); - /* - * optionally include "mark" button - */ - if(mark) { - space_ = new JButton("Add Mark"); - space_.addActionListener(myAction); - button.add(space_); - } - return button; - } - - public static void main(String[] args) { - /* - * main() is used when run as an application - */ - JTimeSeriesDemo tsd = new JTimeSeriesDemo(); - /* - * Create a JFrame to run JTimeSeriesDemo in. - */ - JFrame frame = new JFrame("Time Series Demo"); - JPanel button = tsd.makeButtonPanel(true); - frame.getContentPane().setLayout(new BorderLayout()); - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - }); - tsd.pane_ = tsd.makeGraph(); - tsd.pane_.setBatch(true); - frame.setSize(600, 500); - frame.getContentPane().add(tsd.pane_, BorderLayout.CENTER); - frame.getContentPane().add(button, BorderLayout.SOUTH); - frame.setVisible(true); - tsd.pane_.setBatch(false); - } - - JPlotLayout makeGraph() { - /* - * This example uses a pre-created "Layout" for time - * series to simplify the construction of a plot. The - * LineTimeSeriesLayout can plot multiple lines, with - * a legend and provides zooming and line hi-lighting - * capabilities. - */ - SGTData newData; - TestData td; - JPlotLayout ltsl; - /* - * Create a test time series with random data. - */ - GeoDate start = new GeoDate(); - GeoDate stop = new GeoDate(); - try { - start = new GeoDate("1968-11-01", "yyyy-MM-dd"); - stop = new GeoDate("2001-02-20", "yyyy-MM-dd"); - } catch (IllegalTimeValue e) {} - TimeRange tr = new TimeRange(start, stop); - td = new TestData(TestData.TIME_SERIES, tr, 10.0f, - TestData.RANDOM, 1.2f, 0.5f, 30.0f); - newData = td.getSGTData(); - System.out.println("series length = " + ((SGTLine)newData).getYArray().length); - /* - * Create the layout without a Logo image and with the - * LineKey on the main Pane object. - */ - ltsl = new JPlotLayout(newData, "Time Series Demo", null, false); - /* - * Add the time series to the layout and give a label for - * the legend. - */ - ltsl.addData(newData, "Random Data"); - /* - * Change the layout's three title lines and place the Pane - * on the Applet. - */ - ltsl.setTitles("Time Series Demo", - "using JPlotLayout", - ""); - - myMouse_ = new MyMouse(); - ltsl.addMouseListener(myMouse_); - - return ltsl; - } - - void tree_actionPerformed(java.awt.event.ActionEvent e) { - /* - * Create JClassTree showing object tree. - */ - JClassTree ct = new JClassTree(); - ct.setModal(false); - ct.setJPane(pane_); - ct.show(); - } - - class MyAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object obj = event.getSource(); - if(obj == space_) { - System.out.println(" <>"); - } - if(obj == tree_) - tree_actionPerformed(event); - } - } - - class MyMouse extends MouseAdapter { - /* - * process mouse events. - */ - public void mouseReleased(MouseEvent event) { - Object object = event.getSource(); - if(object == pane_) - maybeShowLineAttributeDialog(event); - } - - void maybeShowLineAttributeDialog(MouseEvent e) { - if(e.isPopupTrigger() || e.getClickCount() == 2) { - Object obj = pane_.getObjectAt(e.getX(), e.getY()); - pane_.setSelectedObject(obj); - if(obj instanceof LineCartesianRenderer) { - LineAttribute attr = ((LineCartesianRenderer)obj).getLineAttribute(); - if(lad_ == null) { - lad_ = new LineAttributeDialog(); - } - lad_.setLineAttribute(attr); - if(!lad_.isShowing()) - lad_.setVisible(true); - } - } - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JVectorDemo.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JVectorDemo.java deleted file mode 100755 index a129685e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/JVectorDemo.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * $Id: JVectorDemo.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.swing.JPlotLayout; -import gov.noaa.pmel.sgt.swing.JClassTree; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.AbstractPane; -import gov.noaa.pmel.sgt.VectorAttribute; -import gov.noaa.pmel.sgt.CartesianRenderer; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.SGTVector; -import gov.noaa.pmel.sgt.swing.prop.VectorAttributeDialog; - - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.IllegalTimeValue; - -import java.awt.*; -import javax.swing.*; -import javax.swing.border.EtchedBorder; -import java.awt.event.ActionEvent; - -import java.awt.print.PrinterJob; -import java.awt.print.PrinterException; - -/** - * Example demonstrating how to use JPlotLayout - * to create a raster-contour plot. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.1 - */ -public class JVectorDemo extends JApplet { - static JPlotLayout rpl_; - private VectorAttribute vectorAttr_; - JButton edit_; - JButton space_ = null; - JButton tree_; - JButton print_ = null; - - public void init() { - /* - * Create the demo in the JApplet environment. - */ - getContentPane().setLayout(new BorderLayout(0,0)); - setBackground(java.awt.Color.white); - setSize(600,430); - JPanel main = new JPanel(); - rpl_ = makeGraph(); - JPanel button = makeButtonPanel(false); - rpl_.setBatch(true); - main.add(rpl_, BorderLayout.CENTER); - getContentPane().add(main, "Center"); - getContentPane().add(button, "South"); - rpl_.setBatch(false); - } - - JPanel makeButtonPanel(boolean app) { - JPanel button = new JPanel(); - button.setLayout(new FlowLayout()); - MyAction myAction = new MyAction(); - if(app) { - print_ = new JButton("Print..."); - print_.addActionListener(myAction); - button.add(print_); - } - tree_ = new JButton("Tree View"); - tree_.addActionListener(myAction); - button.add(tree_); - edit_ = new JButton("Edit VectorAttribute"); - edit_.addActionListener(myAction); - button.add(edit_); - /* - * Optionally leave the "mark" button out of the button panel - */ - if(app) { - space_ = new JButton("Add Mark"); - space_.addActionListener(myAction); - button.add(space_); - } - return button; - } - public static void main(String[] args) { - /* - * Create the demo as an application - */ - JVectorDemo vd = new JVectorDemo(); - /* - * Create a new JFrame to contain the demo. - */ - JFrame frame = new JFrame("Vector Demo"); - JPanel main = new JPanel(); - main.setLayout(new BorderLayout()); - frame.setSize(600,400); - frame.getContentPane().setLayout(new BorderLayout()); - /* - * Listen for windowClosing events and dispose of JFrame - */ - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - }); - /* - * Create button panel with "mark" button - */ - JPanel button = vd.makeButtonPanel(true); - /* - * Create JPlotLayout and turn batching on. With batching on the - * plot will not be updated as components are modified or added to - * the plot tree. - */ - rpl_ = vd.makeGraph(); - rpl_.setBatch(true); - /* - * Layout the plot and buttons. - */ - main.add(rpl_, BorderLayout.CENTER); - frame.getContentPane().add(main, BorderLayout.CENTER); - frame.getContentPane().add(button, BorderLayout.SOUTH); - frame.pack(); - /* - * Turn batching off. JPlotLayout will redraw if it has been - * modified since batching was turned on. - */ - rpl_.setBatch(false); - - frame.setVisible(true); - } - - void print_actionPerformed(ActionEvent e) { - Color saveColor; - - PrinterJob printJob = PrinterJob.getPrinterJob(); - printJob.setPrintable(rpl_); - printJob.setJobName("Vector Demo"); - if(printJob.printDialog()) { - try { - saveColor = rpl_.getBackground(); - if(!saveColor.equals(Color.white)) { - rpl_.setBackground(Color.white); - } - rpl_.setPageAlign(AbstractPane.TOP, - AbstractPane.CENTER); - RepaintManager currentManager = RepaintManager.currentManager(rpl_); - currentManager.setDoubleBufferingEnabled(false); - printJob.print(); - currentManager.setDoubleBufferingEnabled(true); - rpl_.setBackground(saveColor); - } catch (PrinterException pe) { - System.out.println("Error printing: " + pe); - } - } - - } - - void edit_actionPerformed(ActionEvent e) { - /* - * Create a GridAttributeDialog and set the renderer. - */ - VectorAttributeDialog vad = new VectorAttributeDialog(); - vad.setJPane(rpl_); - vad.setVectorAttribute(vectorAttr_); - vad.setVisible(true); - } - - void tree_actionPerformed(ActionEvent e) { - /* - * Create a JClassTree for the JPlotLayout objects - */ - JClassTree ct = new JClassTree(); - ct.setModal(false); - ct.setJPane(rpl_); - ct.show(); - } - - JPlotLayout makeGraph() { - /* - * This example uses a pre-created "Layout" for raster time - * series to simplify the construction of a plot. The - * JPlotLayout can plot a single grid with - * a ColorKey, time series with a LineKey, point collection with a - * PointCollectionKey, and general X-Y plots with a - * LineKey. JPlotLayout supports zooming, object selection, and - * object editing. - */ - SGTGrid uComp; - SGTGrid vComp; - SGTVector vector; - TestData td; - JPlotLayout rpl; - /* - * Create a test grid with sinasoidal-ramp data. - */ - Range2D xr = new Range2D(190.0f, 250.0f, 3.0f); - Range2D yr = new Range2D(0.0f, 45.0f, 3.0f); - td = new TestData(TestData.XY_GRID, xr, yr, - TestData.SINE_RAMP, 20.0f, 10.f, 5.0f); - uComp = (SGTGrid)td.getSGTData(); - td = new TestData(TestData.XY_GRID, xr, yr, - TestData.SINE_RAMP, 20.0f, 0.f, 3.0f); - vComp = (SGTGrid)td.getSGTData(); - vector = new SGTVector(uComp, vComp); - /* - * Create the layout without a Logo image and with the - * VectorKey on the graph Pane. - */ - rpl = new JPlotLayout(JPlotLayout.VECTOR, - false, false, "test layout", null, false); - rpl.setEditClasses(false); - vectorAttr_ = new VectorAttribute(0.0075, Color.red); - vectorAttr_.setHeadScale(0.5); - /* - * Add the grid to the layout and give a label for - * the VectorKey. - */ - rpl.addData(vector, vectorAttr_, "First Data"); - /* - * Change the layout's three title lines. - */ - rpl.setTitles("Vector Plot Demo", - "using a JPlotLayout", - ""); - /* - * Resize the graph and place in the "Center" of the frame. - */ - rpl.setSize(new Dimension(600, 400)); - return rpl; - } - - class MyAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object obj = event.getSource(); - if(obj == edit_) { - edit_actionPerformed(event); - } else if(obj == space_) { - System.out.println(" <>"); - } else if(obj == tree_) { - tree_actionPerformed(event); - } else if(obj == print_) { - print_actionPerformed(event); - } - } - } -} - - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/PseudoRealTimeData.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/PseudoRealTimeData.java deleted file mode 100755 index d7a15db6..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/PseudoRealTimeData.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * $Id: PseudoRealTimeData.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTMetaData; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.IllegalTimeValue; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.Timer; - -/** - * Generates a real-time data stream using SGTLine and - * javax.swing.Timer. PseudoRealTimeData - * generates PropertyCchangeEvents - * whenever data is added "dataModified" or the data range changes - * "rangeModified". The "dataModified" event is directly handled by - * sgt and the "rangeModified" event needs to be handled - * by the graphics application. - * - *

PseudoRealTimeData demonstrates how a class that - * implements the SGTLine interface can use the - * getXRange() and getYRange() methods to - * produce "nice" plots. This class updates the data each time step, - * but updates the range only after a day has passed. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ - -public class PseudoRealTimeData implements SGTLine, ActionListener { - private SGTMetaData xMeta_; - private SGTMetaData yMeta_; - private SoTRange.GeoDate xRange_; - private SoTRange.Double yRange_; - private GeoDate[] xData_; - private double[] yData_; - private GeoDate tend_; - private int count_; - private String title_; - private SGLabel keyTitle_ = null; - private String id_; - private Timer timer_; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private GeoDate ref_ = null; - // bufsize should be integral multiple of majorIncrement plus 1 - private int bufsize_ = 241; - private int offset_; - // offsetIncrement should be same as majorIncrement - private int offsetIncrement_ = 24; - - private double minorIncrement_ = 1.0; - private double majorIncrement_ = 24.0; - private int units_ = GeoDate.HOURS; - - private double A0_ = 1.0; - private double A1_ = 0.375; - private double A2_ = 0.2; - private double omega0_ = 0.251327412; - private double omega1_ = 0.3; - /** - * Constructor. - */ - public PseudoRealTimeData(String id, String title) { - xMeta_ = new SGTMetaData("Time", ""); - yMeta_ = new SGTMetaData("PseudoData", "Ps/day"); - title_ = title; - id_ = id; - timer_ = new Timer(250, this); - resetData(); - } - /** - * Get x data array. Always returns null. - */ - public double[] getXArray() { - return null; - } - /** - * Get y data values. Creates a copy of the buffer array. - */ - public double[] getYArray() { - if(count_ > 0) { - double[] temp = new double[count_+offset_]; - for(int i=0; i < count_+offset_; i++) { - temp[i] = yData_[i]; - } - return temp; - } else { - return null; - } - } - public GeoDate[] getTimeArray() { - if(count_ > 0) { - GeoDate[] temp = new GeoDate[count_+offset_]; - for(int i=0; i < count_+offset_; i++) { - temp[i] = xData_[i]; - } - return temp; - } else { - return null; - } - } - /** - * @since 3.0 - */ - public GeoDateArray getGeoDateArray() { - return new GeoDateArray(getTimeArray()); - } - public SGTLine getAssociatedData() { - return null; - } - public boolean hasAssociatedData() { - return false; - } - public String getTitle() { - return title_; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - public String getId() { - return id_; - } - public SGTData copy() { - return null; - } - public boolean isXTime() { - return true; - } - public boolean isYTime() { - return false; - } - public SGTMetaData getXMetaData() { - return xMeta_; - } - public SGTMetaData getYMetaData() { - return yMeta_; - } - public SoTRange getXRange() { - return xRange_.copy(); - } - public SoTRange getYRange() { - return yRange_.copy(); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - /** - * Start the timer and begin/continue generating property change events. - */ - public void startData() { - timer_.start(); - } - /** - * Stop the timer. - */ - public void stopData() { - timer_.stop(); - } - /** - * Reset the demonstration to the begining. - */ - public void resetData() { - xData_ = new GeoDate[bufsize_]; - yData_ = new double[bufsize_]; - try { - ref_ = new GeoDate("1999-01-01 00:00", "yyyy-MM-dd HH:mm"); - } catch (IllegalTimeValue e) { - e.printStackTrace(); - } - tend_ = new GeoDate(ref_); - // Add a little fudge to get last tic on the axis - tend_.increment(10.0, GeoDate.SECONDS); - yRange_ = new SoTRange.Double(-1.5, 1.5); - xRange_ = new SoTRange.GeoDate(new GeoDate(ref_), - tend_.increment(majorIncrement_, units_)); - xData_[0] = new GeoDate(ref_); - yData_[0] = 0.0; - count_ = 1; - offset_ = 0; - } - - /** - * Handle timer ActionEvents - *
Property Change: rangeModified and - * DataModified - */ - public void actionPerformed(ActionEvent e) { - if((count_+offset_) >= bufsize_) { - offset_ = offset_ - offsetIncrement_; - for(int i=0; i < bufsize_-offsetIncrement_; i++) { - xData_[i] = xData_[i+offsetIncrement_]; - yData_[i] = yData_[i+offsetIncrement_]; - } - xRange_.start = xData_[0]; - } - xData_[count_+offset_] = new GeoDate(ref_.increment(minorIncrement_, units_)); - yData_[count_+offset_] = tSeries(count_); - if(xData_[count_+offset_].after(tend_)) { - SoTRange.GeoDate oldRange = (SoTRange.GeoDate)xRange_.copy(); - /** - * compute new range - */ - tend_.increment(majorIncrement_, units_); - xRange_.end = tend_; - changes_.firePropertyChange("rangeModified", oldRange, xRange_); - } else { - changes_.firePropertyChange("dataModified", - new Integer(count_), - new Integer(count_+1)); - } - count_++; - } - - private double tSeries(int val) { - return A0_*Math.sin(omega0_*val)+A1_*Math.sin(omega1_*val)+A2_*Math.random(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TAO.dat b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TAO.dat deleted file mode 100755 index e7a9736e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TAO.dat +++ /dev/null @@ -1,59 +0,0 @@ -0;-95;0N 95W -2;-95;2N 95W -4;-95;4N 95W -5;-95;5N 95W -8;-95;8N 95W --2;-95;2S 95W --5;-95;5S 95W --8;-95;8S 95W -10;-95;10N 95W -12;-95;12N 95W -0;-110;0N 110W -2;-110;2N 110W -5;-110;5N 110W -8;-110;8N 110W --2;-110;2S 110W --5;-110;5S 110W --8;-110;8S 110W -0;-125;0N 125W -2;-125;2N 125W -5;-125;5N 125W -8;-125;8N 125W --2;-125;2S 125W --5;-125;5S 125W --8;-125;8S 125W -0;-140;0N 140W -2;-140;2N 140W -5;-140;5N 140W -7;-140;7N 140W -9;-140;9N 140W --2;-140;2S 140W --5;-140;5S 140W -0;-155;0N 155W -2;-155;2N 155W -5;-155;5N 155W -8;-155;8N 155W --2;-155;2S 155W --5;-155;5S 155W --8;-155;8S 155W -0;-170;0N 170W -2;-170;2N 170W -5;-170;5N 170W -8;-170;8N 170W --2;-170;2S 170W --5;-170;5S 170W --8;-170;8S 170W -0;-180;0N 180W -2;-180;2N 180W -5;-180;5N 180W -8;-180;8N 180W --2;-180;2S 180W --5;-180;5S 180W --8;-180;8S 180W -0;165;0N 165E -2;165;2N 165E -5;165;5N 165E -8;165;8N 165E --2;165;2S 165E --5;165;5S 165E --8;165;8S 165E diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TAOMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TAOMap.java deleted file mode 100755 index c0656eea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TAOMap.java +++ /dev/null @@ -1,680 +0,0 @@ -/* - * $Id: TAOMap.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.PointCollectionKey; -import gov.noaa.pmel.sgt.PointCartesianRenderer; -import gov.noaa.pmel.sgt.StackedLayout; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.swing.JClassTree; -import gov.noaa.pmel.sgt.Logo; - -import gov.noaa.pmel.sgt.swing.ValueIcon; -import gov.noaa.pmel.sgt.swing.ValueIconFormat; -import gov.noaa.pmel.sgt.swing.prop.PointAttributeDialog; - -import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.dm.SimplePoint; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.dm.SimpleLine; -import gov.noaa.pmel.sgt.dm.SGTMetaData; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.SoTPoint; - -import java.awt.*; -import java.awt.event.ActionEvent; -import javax.swing.*; -import java.io.*; -import java.text.DecimalFormat; -import java.util.StringTokenizer; -import java.io.FileReader; -import java.io.BufferedReader; -import java.io.IOException; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -/** - * Example demonstrating the creation of a graph that displays point - * data from files and includes a coastline. TAOMap - * constructs the plot from basic sgt objects and uses - * the JPane PropertyChangeEvents to notify - * TAOMap of zoom requests and object selections. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 2.0 - */ -public class TAOMap extends JApplet implements PropertyChangeListener { - JButton tree_; - JButton space_ = null; - JButton reset_; - JPane mainPane_; - SGTLine coastLine_ = null; - CartesianGraph graph_; - LinearTransform xt_, yt_; - Layer layer_; - PlainAxis xbot_; - PlainAxis yleft_; - Range2D xrange_, yrange_; - PointAttributeDialog pAttrDialog_ = null; - - public void init() { - /* - * init() is called when TAOMap is run as an JApplet. - */ - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(553,438); - JPane graph = makeGraph(); - graph.setBatch(true); - - getContentPane().add(graph, "Center"); - getContentPane().add(makeButtonPanel(false), "South"); - addValueIcon(); - graph.setBatch(false); - } - - JPanel makeButtonPanel(boolean mark) { - /* - * Create the buttonPanel. Leave the "mark" button off when - * creating the panel for a JApplet. The mark button is used for - * debugging events. - */ - JPanel button = new JPanel(); - button.setLayout(new FlowLayout()); - /* - * Create button to open a JClassTree dialog - */ - tree_ = new JButton("Tree View"); - MyAction myAction = new MyAction(); - tree_.addActionListener(myAction); - button.add(tree_); - if(mark) { - /* - * Create the <> button - */ - space_ = new JButton("Add Mark"); - space_.addActionListener(myAction); - button.add(space_); - } - /* - * Create the zoom reset button. - */ - reset_ = new JButton("Reset Zoom"); - reset_.addActionListener(myAction); - button.add(reset_); - return button; - } - - public static void main(String[] args) { - /* - * main(String[] args) is called when TAOMap is run as an - * application - */ - TAOMap pd = new TAOMap(); - /* - * Create a JFrame to place TAOMap into. - */ - JFrame frame = new JFrame("TAO Mooring Map"); - JPane graph; - JPanel button; - frame.getContentPane().setLayout(new BorderLayout()); - /* - * Add listener to properly dispose of window when closed. - */ - frame.addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent event) { - JFrame fr = (JFrame)event.getSource(); - fr.setVisible(false); - fr.dispose(); - System.exit(0); - } - }); - frame.setSize(553,438); - graph = pd.makeGraph(); - /* - * make buttonPanel with "mark" button. - */ - button = pd.makeButtonPanel(true); - /* - * set batch to true. Changes to graph will not cause updates of - * the display. - */ - graph.setBatch(true); - frame.getContentPane().add(graph, BorderLayout.CENTER); - frame.getContentPane().add(button, BorderLayout.SOUTH); - frame.pack(); - frame.setVisible(true); - pd.addValueIcon(); - /* - * set batch to false. Any changes to graph will now cause graph - * to redraw. - */ - graph.setBatch(false); - - } - - JPane makeGraph() { - /* - * This example creates a very simple plot from - * scratch (not using one of the gov.noaa.pmel.sgt.swing classes) - * to display a Collection of points. - */ - coastLine_ = getCoastLine("finerezcoast.bin", 50200); - /* - * Create a Pane, place in the center of the Applet - * and set the layout to be StackedLayout. - */ - mainPane_ = new JPane("Point Plot Demo", new Dimension(553,438)); - mainPane_.setLayout(new StackedLayout()); - mainPane_.setBackground(Color.white); - /* - * Read two point collections, TAO.dat and TRITON.dat. These - * files contain coordinate and labelling information. - * - */ - Collection TAO; - Collection TRITON; - TAO = readPointCollection("TAO.dat"); - TRITON = readPointCollection("TRITON.dat"); - /* - * Although Collection has methods to query the x and y range of - * the coordinates we set the range to produce a "nice" graph. - */ - xrange_ = new Range2D(130.0, 270., 20.0); - yrange_ = new Range2D(-10.0, 14.0, 2.0); - /* - * xsize, ysize are the width and height in physical units - * of the Layer graphics region. - * - * xstart, xend are the start and end points for the X axis - * ystart, yend are the start and end points for the Y axis - */ - double xsize = 4.0; - double xstart = 0.45; - double xend = 3.75; - double ysize = 3.0; - double ystart = 0.45; - double yend = 2.95; - - /* - * Create the transforms that will be used for all layers - */ - xt_ = new LinearTransform(xstart, xend, xrange_.start, xrange_.end); - yt_ = new LinearTransform(ystart, yend, yrange_.start, yrange_.end); - - if(coastLine_ != null) { - /* - * Create the layer that will hold the coastline and add to the - * JPane. - */ - Layer layer = new Layer("CoastLine", new Dimension2D(xsize, ysize)); - mainPane_.add(layer); - /* - * Create the CartesianGraph, attach to the layer, set the - * transforms and add the coastline data. - */ - CartesianGraph cstgraph = new CartesianGraph("CoastLine Graph"); - layer.setGraph(cstgraph); - cstgraph.setXTransform(xt_); - cstgraph.setYTransform(yt_); - LineAttribute lattr = new LineAttribute(); - lattr.setColor(new Color(165, 42, 42)); - cstgraph.setData(coastLine_, lattr); - /* - * Since the coastline is for the entire world we clip the - * display to the current axes. - */ - cstgraph.setClip(xrange_.start, xrange_.end, - yrange_.start, yrange_.end); - cstgraph.setClipping(true); - } - /* - * Create the first "data" layer. This object reference is made - * class wide for convience later. - */ - layer_ = new Layer("Layer 1", new Dimension2D(xsize, ysize)); - mainPane_.add(layer_); - /* - * Create a CartesianGraph and set the transforms. - */ - graph_ = new CartesianGraph("Point Graph"); - layer_.setGraph(graph_); - graph_.setXTransform(xt_); - graph_.setYTransform(yt_); - /* - * This Graph contain the plots axes. - * Create the bottom axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - String xLabel = "Longitude"; - - xbot_ = new PlainAxis("Botton Axis"); - xbot_.setRangeU(xrange_); - xbot_.setLocationU(new Point2D.Double(xrange_.start, yrange_.start)); - Font xbfont = new Font("Helvetica", Font.ITALIC, 14); - xbot_.setLabelFont(xbfont); - SGLabel xtitle = new SGLabel("xaxis title", xLabel, - new Point2D.Double(0.0, 0.0)); - Font xtfont = new Font("Helvetica", Font.PLAIN, 14); - xtitle.setFont(xtfont); - xtitle.setHeightP(0.2); - xbot_.setTitle(xtitle); - graph_.addXAxis(xbot_); - /* - * Create the left axis, set its range in user units - * and its origin. Add the axis to the graph. - */ - String yLabel = "Latitude"; - - yleft_ = new PlainAxis("Left Axis"); - yleft_.setRangeU(yrange_); - yleft_.setLocationU(new Point2D.Double(xrange_.start, yrange_.start)); - yleft_.setLabelFont(xbfont); - SGLabel ytitle = new SGLabel("yaxis title", yLabel, - new Point2D.Double(0.0, 0.0)); - Font ytfont = new Font("Helvetica", Font.PLAIN, 14); - ytitle.setFont(ytfont); - ytitle.setHeightP(0.2); - yleft_.setTitle(ytitle); - graph_.addYAxis(yleft_); - /* - * create the point collection key - */ - PointCollectionKey key = new PointCollectionKey(); - key.setId("Mooring Key"); - key.setVAlign(PointCollectionKey.TOP); - key.setHAlign(PointCollectionKey.LEFT); - key.setBorderStyle(PointCollectionKey.PLAIN_LINE); - key.setLocationP(new Point2D.Double(xstart+0.1, yend)); - layer_.addChild(key); - /* - * Create a PointAttribute for the display of the - * Collection of points. The points will have a color or rgb - * (200,0,255) with the label at the NE corner and in a dark red. - */ - PointAttribute pattr; - Color markColor = new Color(200, 0, 255); - pattr = new PointAttribute(44, markColor); - pattr.setLabelPosition(PointAttribute.NE); - Font pfont = new Font("Helvetica", Font.PLAIN, 12); - pattr.setLabelFont(pfont); - pattr.setLabelColor(Color.red.darker()); - pattr.setLabelHeightP(0.08); - pattr.setDrawLabel(true); - /* - * Associate the attribute and the point Collection - * with the graph. - */ - graph_.setData(TAO, pattr); - SGLabel pointTitle = new SGLabel("TAO title", - "TAO Moorings", - new Point2D.Double(0.0, 0.0)); - pointTitle.setHeightP(0.16); - key.addPointGraph((PointCartesianRenderer)graph_.getRenderer(), - pointTitle); - /* - * create second layer for second file - */ - Layer layer2 = new Layer("Layer 2", new Dimension2D(xsize, ysize)); - mainPane_.add(layer2); - /* - * Create the graph and set the shared transforms. NOTE: this - * graph will not contain any axes. - */ - CartesianGraph graph2 = new CartesianGraph("Point Graph2"); - layer2.setGraph(graph2); - graph2.setXTransform(xt_); - graph2.setYTransform(yt_); - - PointAttribute pattr2; - pattr2 = new PointAttribute(13, markColor); - pattr2.setLabelPosition(PointAttribute.NE); - pattr2.setLabelFont(pfont); - pattr2.setLabelColor(Color.blue.darker()); - pattr2.setLabelHeightP(0.08); - pattr2.setDrawLabel(true); - - graph2.setData(TRITON, pattr2); - SGLabel pointTitle2 = new SGLabel("TRITON title", - "TRITON Moorings", - new Point2D.Double(0.0, 0.0)); - pointTitle2.setHeightP(0.16); - key.addPointGraph((PointCartesianRenderer)graph2.getRenderer(), - pointTitle2); - mainPane_.addPropertyChangeListener(this); - - return mainPane_; - } - - private void addValueIcon() { - /* - * add a ValueIcon. The value icon is used to show the current - * value for the user coordinates. - */ - ValueIcon vi = new ValueIcon(getClass().getResource("query.gif"), "value"); - - layer_.addChild(vi); - vi.setId("local query"); - try { - vi.setLocationU(new SoTPoint(220.0, -5.0)); - } catch (java.beans.PropertyVetoException e) { - e.printStackTrace(); - } - vi.setVisible(true); - vi.setSelectable(true); - vi.setValueFormat(new GeoFormat()); - - } - - void tree_actionPerformed(ActionEvent e) { - /* - * Create a JClassTree to display a graph of the sgt objects - */ - JClassTree ct = new JClassTree(); - ct.setModal(false); - ct.setJPane(mainPane_); - ct.show(); - } - - class MyAction implements java.awt.event.ActionListener { - public void actionPerformed(ActionEvent event) { - Object obj = event.getSource(); - if(obj == space_) { - System.out.println(" <>"); - } - if(obj == tree_) - tree_actionPerformed(event); - if(obj == reset_) - reset_actionPerformed(event); - } - } - - Collection readPointCollection(String file) { - /* - * method used to parse the station information. - * The file format is - * lat;lon;label - */ - SimplePoint sp = null; - BufferedReader in = null; - String line = null; - String title; - int lat, lon; - Collection pc = new Collection(file); - /* - * Get data file. The getResourceAsStream enables java to find - * the data inside of a jar file. - */ - InputStream is = getClass().getResourceAsStream(file); - /* - * Open reader and get first line - */ - try { - in = new BufferedReader(new InputStreamReader(is)); - line = in.readLine(); - } catch (IOException e) { - e.printStackTrace(); - } - while(line != null) { - StringTokenizer st = new StringTokenizer(line, ";"); - String token1 = st.nextToken(); - String token2 = st.nextToken(); - title = st.nextToken(); - lat = Integer.parseInt(token1); - lon = Integer.parseInt(token2); - if(lon < 0) lon = lon + 360; - lon = lon%360; - /* - * Create new SimplePoint with coordinates and title and - * add to Collection. - */ - sp = new SimplePoint((double)lon, (double)lat, title); - pc.addElement(sp); - /* - * Read the next line - */ - try { - line = in.readLine(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - return pc; - } - SGTLine getCoastLine(String coastFileName, int bufsize) { - /* - * Read coastline file - */ - SimpleLine line; - if(coastFileName.length() == 0) return null; - - double[] lat = new double[bufsize]; - double[] lon = new double[bufsize]; - int cpt = 0; - int cpt_save = 0; - int cut_count = 0; - InputStream is = getClass().getResourceAsStream(coastFileName); - try { - BufferedInputStream bis; - bis = new BufferedInputStream(is, 1000000); - DataInputStream inData = new DataInputStream(bis); - while (true) { - // get the number of entries - int numEntries = inData.readShort(); - if (numEntries == -1) - break; - - // get the lats and lons for this segment - cpt_save = cpt; - for (int i=0; i 0 && Math.abs(lon[cpt] - lon[cpt-1]) > 50.0) { - cut_count++; - } - cpt++; - } - - lat[cpt] = Double.NaN; - lon[cpt] = Double.NaN; - cpt++; - } - } catch (IOException e) { - e.printStackTrace(); - } - - System.out.println(cpt + " points read"); - System.out.println(cut_count + " cuts added"); - /* - * The coastline file is setup for +180/-180 range for - * longitudes. Since TAO and TRITON span the pacific we - * need to remap longitude to 0-360. Additional points need - * to be added so that lines don't wrap strangely. - */ - int length = cpt; - double[] latVal = new double[cpt + cut_count]; - double[] lonVal = new double[cpt + cut_count]; - cpt = 0; - for(int i=0; i < length; i++) { - if(i > 0 && Math.abs(lon[i] - lon[i-1]) > 50.0) { - latVal[cpt] = Double.NaN; - lonVal[cpt] = Double.NaN; - cpt++; - } - latVal[cpt] = lat[i]; - lonVal[cpt] = lon[i]; - cpt++; - } - - line = new SimpleLine(lonVal, latVal, "CoastLine"); - SGTMetaData yMeta = new SGTMetaData("Latitude", "degrees_N", - false, false); - SGTMetaData xMeta = new SGTMetaData("Longitude", "degrees_E", - false, true); - line.setXMetaData(xMeta); - line.setYMetaData(yMeta); - - return line; - } - - public void propertyChange(PropertyChangeEvent event) { - /* - * Listen for propery change events from JPane. - */ - String name = event.getPropertyName(); - if(name.equals("zoomRectangle")) { - /* - * compute zoom rectangle in user units - */ - Range2D xr = new Range2D(); - Range2D yr = new Range2D(); - Rectangle zm = (Rectangle)event.getNewValue(); - if(zm.width <= 1 || zm.height <= 1) return; - xr.start = graph_.getXPtoU(layer_.getXDtoP(zm.x)); - xr.end = graph_.getXPtoU(layer_.getXDtoP(zm.x + zm.width)); - if(xr.start > xr.end) { - double temp = xr.start; - xr.start = xr.end; - xr.end = temp; - } - yr.start = graph_.getYPtoU(layer_.getYDtoP(zm.y)); - yr.end = graph_.getYPtoU(layer_.getYDtoP(zm.y + zm.height)); - if(yr.start > yr.end) { - double temp = yr.start; - yr.start = yr.end; - yr.end = temp; - } - mainPane_.setBatch(true); - /* - * set range for transforms - */ - xt_.setRangeU(xr); - yt_.setRangeU(yr); - /* - * set range and origin for axes - */ - Point2D.Double orig = new Point2D.Double(xr.start, yr.start); - xbot_.setRangeU(xr); - xbot_.setLocationU(orig); - - yleft_.setRangeU(yr); - yleft_.setLocationU(orig); - /* - * set clipping on all graphs - */ - Component[] comps = mainPane_.getComponents(); - Layer ly; - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ly = (Layer)comps[i]; - ((CartesianGraph)ly.getGraph()).setClip(xr.start, xr.end, - yr.start, yr.end); - } - } - mainPane_.setBatch(false); - } else if(name.equals("objectSelected")) { - /* - * An sgt object has been selected. - * If it is a PointCartesianRenderer that means the key has been - * selected and so open a dialog to modified the PointAttribute. - */ - if(event.getNewValue() instanceof PointCartesianRenderer) { - PointAttribute pattr = - ((PointCartesianRenderer)event.getNewValue()).getPointAttribute(); - if(pAttrDialog_ == null) { - pAttrDialog_ = new PointAttributeDialog(); - } - pAttrDialog_.setPointAttribute(pattr, mainPane_); - pAttrDialog_.setVisible(true); - } else { - /* - * Print the name of the object selected. - */ - System.out.println("objectSelected = " + event.getNewValue()); - } - } - } - - void reset_actionPerformed(ActionEvent e) { - mainPane_.setBatch(true); - Layer ly; - /* - * clear clipping on all graphs but coast line. - */ - Component[] comps = mainPane_.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ly = (Layer)comps[i]; - if(ly.getId().equals("CoastLine")) { - ((CartesianGraph)ly.getGraph()).setClip(xrange_.start, - xrange_.end, - yrange_.start, - yrange_.end); - } else { - ((CartesianGraph)ly.getGraph()).setClipping(false); - } - } - } - /* - * reset range for transform - */ - xt_.setRangeU(xrange_); - yt_.setRangeU(yrange_); - /* - * reset range for axes and origin - */ - Point2D.Double orig = new Point2D.Double(xrange_.start, - yrange_.start); - xbot_.setRangeU(xrange_); - xbot_.setLocationU(orig); - yleft_.setRangeU(yrange_); - yleft_.setLocationU(orig); - - mainPane_.setBatch(false); - } - - class GeoFormat extends ValueIconFormat { - /* - * Create a specialized format for ValueIcon so that it handles - * longitude wrapping properly and hemisphere labelling. - */ - public GeoFormat() { - super("#####.##;#####.##W", "#####.##N;#####.##S"); - xfrm_.setPositiveSuffix("E"); - } - public String format(double x, double y) { - double xt = (x + 360.0) % 360.0; - if(x > 180.0) x = x - 360.0; - return "(" + xfrm_.format(x) + ", " + yfrm_.format(y) + ")"; - } - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TRITON.dat b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TRITON.dat deleted file mode 100755 index 63e856e8..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TRITON.dat +++ /dev/null @@ -1,13 +0,0 @@ -0;156;0N 156E -2;156;2N 156E -5;156;5N 156E -8;156;8N 156E --2;156;2S 156E --5;156;5S 156E -0;147;0N 147E -2;147;2N 147E -5;147;5N 147E -0;137;0N 137E -2;137;2N 137E -5;137;5N 137E -7;137;7N 137E diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TestData.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TestData.java deleted file mode 100755 index ec64ad83..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/TestData.java +++ /dev/null @@ -1,586 +0,0 @@ -/* - * $Id: TestData.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.demo; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.GeoDateArray; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTPoint; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.SGTMetaData; -import gov.noaa.pmel.sgt.dm.SimplePoint; -import gov.noaa.pmel.sgt.dm.SimpleLine; -import gov.noaa.pmel.sgt.dm.SimpleGrid; -import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.SGLabel; - -/** - * Create SGTData objects containing test data. - * These objects can be used for - * graphics and analysis testing purposes. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:03 $ - * @since 1.0 - */ -public class TestData { - /** - * create profile data - **/ - public final static int PROFILE = 1; - /** - * create longitude track data - **/ - public final static int X_SERIES = 2; - /** - * create latitude track data - **/ - public final static int Y_SERIES = 3; - /** - * create time series data - **/ - public final static int TIME_SERIES = 4; - /** - * create X-Y grid - */ - public final static int XY_GRID = 5; - /** - * create X-Y grid - */ - public final static int XZ_GRID = 6; - /** - * create X-Y grid - */ - public final static int YZ_GRID = 7; - /** - * create Z-T grid - */ - public final static int ZT_GRID = 10; - /** - * create log-log line - */ - public final static int LOG_LOG = 11; - /** - * create sine wave - **/ - public final static int SINE = 1; - /** - * create random data - **/ - public final static int RANDOM = 2; - /** - * create sine wave with a ramp - */ - public final static int SINE_RAMP = 3; - // - private int dataType_; - private SGTData data_; - private Collection coll_; - /** - * Create default test data. Will create profile (z) data with sine shape. - **/ - public TestData() { - this(PROFILE, new Range2D(0.0f, 100.0f, 10.0f), SINE, 1.0f, 0.0f, 25.0f); - } - /** - * Create one-dimensional spatial test data. - * - * @param dir direction of test data, TestData.X_SERIES, - * TestData.Y_SERIES, TestData.PROFILE, TestData.LOG_LOG - * @param range minimum and maximum overwhich to create - * @param type type of series, TestData.SINE or TestData.RANDOM - * @param amp amplitude - * @param off offset - * @param per period - * @see #PROFILE - * @see #X_SERIES - * @see #Y_SERIES - * @see #LOG_LOG - * @see #SINE - * @see #RANDOM - **/ - public TestData(int dir, Range2D range, - int type, float amp, float off, float per) { - SimpleLine sl; - SGTMetaData xMeta; - SGTMetaData yMeta; - - double[] axis; - double[] values; - double[] zero; - GeoDate tzero[] = new GeoDate[1]; - int count; - - zero = new double[1]; - tzero[0] = new GeoDate(); - zero[0] = 0; - tzero[0].now(); - if(dir != LOG_LOG) { - int num = (int)((range.end - range.start)/range.delta) + 1; - axis = new double[num]; - - for(count=0; count < num; count++) { - axis[count] = range.start + count*range.delta; - } - - values = getValues(axis, num, type, amp, off, per); - } else { - double log10 = Math.log(10.0); - double end10 = Math.log(range.end)/log10; - double start10 = Math.log(range.start)/log10; - double delta10 = Math.log(range.delta)/log10; - float amp10 = (float)(Math.log(amp)/log10); - float off10 = (float)(Math.log(off)/log10); - float per10 = (float)(Math.log(per)/log10); - int num = (int)((end10 - start10)/delta10) + 1; - axis = new double[num]; - - for(count=0; count < num; count++) { - axis[count] = start10 + count*delta10; - } - - // create values in log space - values = getValues(axis, num, type, amp10, off10, per10); - - // convert back ... - for(count=0; count < num; count++) { - axis[count] = Math.pow(10.0, axis[count]); - values[count] = Math.pow(10.0, values[count]); - } - } - SGLabel keyLabel = new SGLabel("Key Label", "", new Point2D.Double(0.0, 0.0)); - keyLabel.setHeightP(0.16); - // - // create SimpleLine object - // - switch(dir) { - case X_SERIES: - keyLabel.setText("X series ts data"); - xMeta = new SGTMetaData("lon", "degE"); - yMeta = new SGTMetaData("ts", "m s-1"); - sl = new SimpleLine(axis, values, "Test Series"); - break; - case Y_SERIES: - keyLabel.setText("Y series ts data"); - xMeta = new SGTMetaData("lat", "deg"); - yMeta = new SGTMetaData("ts", "m s-1"); - sl = new SimpleLine(axis, values, "Test Series"); - break; - default: - case PROFILE: - keyLabel.setText("Profile ts data"); - xMeta = new SGTMetaData("ts", "m s-1"); - yMeta = new SGTMetaData("depth", "m"); - sl = new SimpleLine(values, axis, "Test Series"); - break; - case LOG_LOG: - keyLabel.setText("Log/Log diameters"); - xMeta = new SGTMetaData("diameter", "m"); - yMeta = new SGTMetaData("count", ""); - sl = new SimpleLine(axis, values, "Test Log-Log Series"); - } - sl.setXMetaData(xMeta); - sl.setYMetaData(yMeta); - sl.setKeyTitle(keyLabel); - data_ = sl; - } - /** - * Create two-dimensional spatial test data. - * - * @param dir direction of test data, TestData.XY_GRID, TestData.XZ_GRID, TestData.YZ_GRID - * @param range1 minimum and maximum overwhich to create for first axis - * @param range2 minimum and maximum overwhich to create for second axis - * @param type type of series, TestData.SINE or TestData.RANDOM - * @param amp amplitude - * @param off offset - * @param per period - * @see #PROFILE - * @see #X_SERIES - * @see #Y_SERIES - * @see #SINE - * @see #RANDOM - **/ - public TestData(int dir, Range2D range1, Range2D range2, - int type, float amp, float off, float per) { - SimpleGrid sg; - SGTMetaData xMeta; - SGTMetaData yMeta; - SGTMetaData zMeta; - - double[] axis1, axis2; - double[] values; - double[] zero; - GeoDate tzero[] = new GeoDate[1]; - int count; - - zero = new double[1]; - tzero[0] = new GeoDate(); - zero[0] = 0; - tzero[0].now(); - int num1 = (int)((range1.end - range1.start)/range1.delta) + 1; - axis1 = new double[num1]; - int num2 = (int)((range2.end - range2.start)/range2.delta) + 1; - axis2 = new double[num2]; - - for(count=0; count < num1; count++) { - axis1[count] = range1.start + count*range1.delta; - } - for(count=0; count < num2; count++) { - axis2[count] = range2.start + count*range2.delta; - } - - values = getValues(axis1, num1, axis2, num2, type, amp, off, per); - - SGLabel keyLabel = new SGLabel("Key Label", "", new Point2D.Double(0.0, 0.0)); - keyLabel.setHeightP(0.16); - // - // create SimpleGrid - // - zMeta = new SGTMetaData("ts", "m s-1"); - switch(dir) { - case XY_GRID: - keyLabel.setText("XY test grid"); - xMeta = new SGTMetaData("lon", "degE"); - yMeta = new SGTMetaData("lat", "deg"); - sg = new SimpleGrid(values, axis1, axis2, "Test Series"); - break; - case XZ_GRID: - keyLabel.setText("XZ test grid"); - xMeta = new SGTMetaData("lon", "degE"); - yMeta = new SGTMetaData("depth", "m"); - sg = new SimpleGrid(values, axis1, axis2, "Test Series"); - break; - default: - case YZ_GRID: - keyLabel.setText("YZ test grid"); - xMeta = new SGTMetaData("lat", "deg"); - yMeta = new SGTMetaData("depth", "m"); - sg = new SimpleGrid(values, axis1, axis2, "Test Series"); - } - sg.setXMetaData(xMeta); - sg.setYMetaData(yMeta); - sg.setZMetaData(zMeta); - sg.setKeyTitle(keyLabel); - data_ = sg; - } - /** - * Create time series test data. - * - * @param dir direction of test data, TestData.TIME_SERIES - * @param range minimum and maximum overwhich to create - * @param delta space between points in days - * @param type type of series, TestData.SINE or TestData.RANDOM - * @param amp amplitude - * @param off offset - * @param per period - * @see #PROFILE - * @see #X_SERIES - * @see #Y_SERIES - * @see #SINE - * @see #RANDOM - **/ - public TestData(int dir, TimeRange range, float delta, - int type, float amp, float off, float per) { - SimpleLine sl; - SGTMetaData xMeta; - SGTMetaData yMeta; - - GeoDateArray taxis; - long[] tvalues; - double[] values; - double[] zero; - double totalTime; - int count, num; - - zero = new double[1]; - zero[0] = 0; - - totalTime = range.end.offset(range.start); - num = (int)(totalTime/(double)delta) + 1; - - tvalues = new long[num]; - long ref = range.start.getTime(); - long ldelta = ((long)delta)*86400000; -// taxis = new GeoDate[num]; - for(count=0; count < num; count++) { - tvalues[count] = ref + count*ldelta; -// taxis[count] = new GeoDate(range.start); -// taxis[count].increment(delta*count, GeoDate.DAYS); - } - taxis = new GeoDateArray(tvalues); - values = getValues(taxis, num, type, amp, off, per); - - SGLabel keyLabel = new SGLabel("Key Label", "", new Point2D.Double(0.0, 0.0)); - keyLabel.setHeightP(0.16); - // - // create SimpleLine - // - keyLabel.setText("Time series ts"); - xMeta = new SGTMetaData("time", ""); - yMeta = new SGTMetaData("ts", "m s-1"); - sl = new SimpleLine(taxis, values, "Test Series"); - sl.setXMetaData(xMeta); - sl.setYMetaData(yMeta); - sl.setKeyTitle(keyLabel); - data_ = sl; - } - /** - * Create time series test grid data. - * - * @param dir direction of test data, TestData.ZT_SERIES - * @param range minimum and maximum for space axis - * @param trange minimum and maximum overwhich to create - * @param delta space between points in days - * @param type type of series, TestData.SINE or TestData.RANDOM - * @param amp amplitude - * @param off offset - * @param per period - * @see #PROFILE - * @see #X_SERIES - * @see #Y_SERIES - * @see #SINE - * @see #RANDOM - **/ - public TestData(int dir, Range2D range, - TimeRange trange, float delta, - int type, float amp, float off, float per) { - SimpleGrid sg; - SGTMetaData xMeta; - SGTMetaData yMeta; - SGTMetaData zMeta; - - GeoDate[] taxis; - double[] values, axis; - double[] zero; - double totalTime; - int count, tnum, snum; - - zero = new double[1]; - zero[0] = 0; - - totalTime = trange.end.offset(trange.start); - tnum = (int)(totalTime/(double)delta) + 1; - - taxis = new GeoDate[tnum]; - for(count=0; count < tnum; count++) { - taxis[count] = new GeoDate(trange.start); - taxis[count].increment(delta*count, GeoDate.DAYS); - } - - snum = (int)((range.end - range.start)/range.delta) + 1; - axis = new double[snum]; - - for(count=0; count < snum; count++) { - axis[count] = range.start + count*range.delta; - } - - values = getValues(axis, snum, taxis, tnum, type, amp, off, per); - SGLabel keyLabel = new SGLabel("Key Label", "", new Point2D.Double(0.0, 0.0)); - keyLabel.setHeightP(0.16); - // - // create SimpleGrid - // - keyLabel.setText("time-depth grid"); - xMeta = new SGTMetaData("time", ""); - yMeta = new SGTMetaData("depth", "m"); - zMeta = new SGTMetaData("ts", "m s-1"); - sg = new SimpleGrid(values, taxis, axis, "Test Series"); - sg.setXMetaData(xMeta); - sg.setYMetaData(yMeta); - sg.setZMetaData(zMeta); - sg.setKeyTitle(keyLabel); - data_ = sg; - } - /** - * Create a Collection of points. - * - * @param xrnge range of values in x - * @param yrnge range of values in y - * @param num number of values to create - */ - public TestData(Range2D xrnge, Range2D yrnge, int num) { - SimplePoint sp; - double xamp, yamp, xoff, yoff; - double xp, yp; - String title; - coll_ = new Collection("Test Points", num); - xamp = xrnge.end - xrnge.start; - xoff = xrnge.start; - yamp = yrnge.end - yrnge.start; - yoff = yrnge.start; - for(int i=0; i < num; i++) { - xp = xamp*Math.random() + xoff; - yp = yamp*Math.random() + yoff; - title = "point"+i; - sp = new SimplePoint(xp, yp, title); - coll_.addElement((Object)sp); - } - } - - /** - * Get the Collection of points created with the point constructor. - * - * @return Collection of points - */ - public Collection getCollection() { - return coll_; - } - - /** - * Get a SGTGrid or SGTLine object depending on type of constructor - * used. - * - * @return SGTData object. - */ - public SGTData getSGTData() { - return data_; - } - private double[] getValues(double[] axis, int num, int type, - float amp, float off, float per) { - double[] values; - int count; - values = new double[num]; - switch(type) { - default: - case TestData.RANDOM: - for(count=0; count < num; count++) { - values[count] = amp*Math.random()+off; - } - break; - case TestData.SINE: - for(count=0; count < num; count++) { - values[count] = amp*Math.sin(axis[count]/per) + off; - } - } - return values; - } - - private double[] getValues(double[] axis1, int num1, double[] axis2, int num2, - int type, float amp, float off, float per) { - double[] values; - int count1, count2, count; - values = new double[num1*num2]; - switch(type) { - default: - case TestData.RANDOM: - for(count=0; count < num1*num2; count++) { - values[count] = amp*Math.random()+off; - } - break; - case TestData.SINE: - count=0; - for(count1=0; count1 < num1; count1++) { - for(count2=0; count2 < num2; count2++) { - values[count] = amp*Math.sin(axis1[count1]/per)* - Math.sin(axis2[count2]/per) + off; - count++; - } - } - break; - case TestData.SINE_RAMP: - count=0; - double ax1factr = 0.08*Math.abs(axis1[0]-axis1[num1-1])/ - Math.max(Math.abs(axis1[0]),Math.abs(axis1[num1-1])); - double ax2factr = 0.08*Math.abs(axis2[0]-axis2[num2-1])/ - Math.max(Math.abs(axis2[0]),Math.abs(axis2[num2-1])); - for(count1=0; count1 < num1; count1++) { - for(count2=0; count2 < num2; count2++) { - values[count] = amp*Math.sin(axis1[count1]/per)* - Math.sin(axis2[count2]/per) + off + - amp*(ax1factr*count1 - ax2factr*count2); - count++; - } - } - - } - return values; - } - - private double[] getValues(GeoDate[] axis, int num, int type, - float amp, float off, float per) { - double[] values; - double theta; - int count; - values = new double[num]; - switch(type) { - default: - case TestData.RANDOM: - for(count=0; count < num; count++) { - values[count] = amp*Math.random() + off; - } - break; - case TestData.SINE: - for(count=0; count < num; count++) { - theta = axis[count].offset(axis[0])/per; - values[count] = amp*Math.sin(theta) + off; - } - } - return values; - } - - private double[] getValues(GeoDateArray axis, int num, int type, - float amp, float off, float per) { - double[] values; - double theta; - float lper = per*86400000; - long[] tvalues = axis.getTime(); - int count; - values = new double[num]; - switch(type) { - default: - case TestData.RANDOM: - for(count=0; count < num; count++) { - values[count] = amp*Math.random() + off; - } - break; - case TestData.SINE: - for(count=0; count < num; count++) { - theta = (tvalues[count] - tvalues[0])/lper; - // theta = axis[count].offset(axis[0])/per; - values[count] = amp*Math.sin(theta) + off; - } - } - return values; - } - - private double[] getValues(double[] axis, int snum, GeoDate[] taxis, int tnum, - int type, float amp, float off, float per) { - double[] values; - double theta; - int tcount, scount, count; - values = new double[tnum*snum]; - switch(type) { - default: - case TestData.RANDOM: - for(count=0; count < tnum*snum; count++) { - values[count] = amp*Math.random() + off; - } - break; - case TestData.SINE: - count=0; - for(tcount=0; tcount < tnum; tcount++) { - theta = taxis[tcount].offset(taxis[0])/per; - for(scount=0; scount < snum; scount++) { - values[count] = amp*Math.sin(theta)*Math.sin(axis[scount]/per) + off; - count++; - } - } - } - return values; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/coarserezcoast.bin b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/coarserezcoast.bin deleted file mode 100755 index 0af33235..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/coarserezcoast.bin and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/finerezcoast.bin b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/finerezcoast.bin deleted file mode 100755 index c9491a5a..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/finerezcoast.bin and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/ncBrowse48.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/ncBrowse48.gif deleted file mode 100755 index 35b8d687..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/ncBrowse48.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/ncBrowse96.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/ncBrowse96.gif deleted file mode 100755 index a476dcd4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/ncBrowse96.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/package.html deleted file mode 100755 index eeec276d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/package.html +++ /dev/null @@ -1,17 +0,0 @@ - - -JApplets and applications that demonstrate the use of -sgt. Some of these examples use the -gov.noaa.pmel.sgt.swing and -gov.noaa.pmel.sgt.swing.prop classes. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/query.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/query.gif deleted file mode 100755 index 3f98ed16..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/demo/query.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Annotation.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Annotation.java deleted file mode 100755 index a21a8a79..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Annotation.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * $Id: Annotation.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.SGException; - -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTPoint; - -import java.util.List; -import java.util.Vector; -import java.util.Iterator; -import java.awt.Color; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeEvent; - -/** - * A container to hold Annote objects. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ -public class Annotation implements SGTData, PropertyChangeListener { - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private String title_ = null; - private String id_ = null; - - /** - * @label x - * @link aggregation - */ - private SGTMetaData xMeta_ = null; - - /** - * @link aggregation - * @label y - */ - private SGTMetaData yMeta_ = null; - private List text_ = new Vector(); - private List line_ = new Vector(); - private List point_ = new Vector(); - private List oval_ = new Vector(); - private List rect_ = new Vector(); - - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private boolean xTime_ = false; - private boolean yTime_ = false; - - public Annotation() { - this(null, false, false); - } - - public Annotation(String title) { - this(title, false, false); - } - - public Annotation(String title, boolean xTime, boolean yTime) { - title_ = title; - xTime_ = xTime; - yTime_ = yTime; - } - - public boolean remove(String id) { - Annote ann = findAnnote(id); - if(ann == null) return false; - return remove(ann); - } - - public boolean remove(Annote ann) { - if(ann instanceof Annote.Line) { - return removeLine(ann); - } else if(ann instanceof Annote.Oval) { - return removeOval(ann); - } else if(ann instanceof Annote.Point) { - return removePoint(ann); - } else if(ann instanceof Annote.Rect) { - return removeRect(ann); - } else if(ann instanceof Annote.Text) { - return removeText(ann); - } - return false; - } - - public void add(Annote ann) throws SGException { - if(ann instanceof Annote.Line) { - SGTLine line = ((Annote.Line)ann).getLine(); - if(xTime_ != line.isXTime() || yTime_ != line.isYTime()) - throw new SGException("Time axes do not match"); - ann.addPropertyChangeListener(this); - line_.add(ann); - changes_.firePropertyChange("lineAdded", true, false); - } else if(ann instanceof Annote.Oval) { - SoTPoint pt1 = ((Annote.Oval)ann).getUpperLeft(); - if(xTime_ != pt1.isXTime() || yTime_ != pt1.isYTime()) - throw new SGException("Time axes do not match"); - ann.addPropertyChangeListener(this); - oval_.add(ann); - changes_.firePropertyChange("ovalAdded", true, false); - } else if(ann instanceof Annote.Point) { - SGTPoint point = ((Annote.Point)ann).getPoint(); - if(xTime_ != point.isXTime() || yTime_ != point.isYTime()) - throw new SGException("Time axes do not match"); - ann.addPropertyChangeListener(this); - point_.add(ann); - changes_.firePropertyChange("pointAdded", true, false); - } else if(ann instanceof Annote.Rect) { - SoTPoint pt1 = ((Annote.Rect)ann).getUpperLeft(); - if(xTime_ != pt1.isXTime() || yTime_ != pt1.isYTime()) - throw new SGException("Time axes do not match"); - ann.addPropertyChangeListener(this); - rect_.add(ann); - changes_.firePropertyChange("rectAdded", true, false); - } else if(ann instanceof Annote.Text) { - SoTPoint loc = ((Annote.Text)ann).getLocation(); - if(xTime_ != loc.isXTime() || yTime_ != loc.isYTime()) - throw new SGException("Time axes do not match"); - ann.addPropertyChangeListener(this); - text_.add(ann); - changes_.firePropertyChange("textAdded", true, false); - } - } - - public Annote addLine(String id, SGTLine line, LineAttribute attr) - throws SGException { - if(xTime_ != line.isXTime() || yTime_ != line.isYTime()) - throw new SGException("Time axes do not match"); - Annote.Line aLine = new Annote.Line(id, line, attr); - aLine.addPropertyChangeListener(this); - line_.add(aLine); - - changes_.firePropertyChange("lineAdded", true, false); - return aLine; - } - - private boolean removeLine(Annote line) { - boolean result = false; - if(line instanceof Annote.Line) { - line.removePropertyChangeListener(this); - result = line_.remove(line); - if(result) changes_.firePropertyChange("lineRemoved", true, false); - } - return result; - } - - public Iterator getLineIterator() { - return line_.iterator(); - } - - public boolean hasLine() { - return !line_.isEmpty(); - } - - public Annote addPoint(String id, SGTPoint point, PointAttribute attr) - throws SGException { - if(xTime_ != point.isXTime() || yTime_ != point.isYTime()) - throw new SGException("Time axes do not match"); - Annote.Point aPoint = new Annote.Point(id, point, attr); - aPoint.addPropertyChangeListener(this); - point_.add(aPoint); - - changes_.firePropertyChange("pointAdded", true, false); - return aPoint; - } - - private boolean removePoint(Annote point) { - boolean result = false; - if(point instanceof Annote.Point) { - point.removePropertyChangeListener(this); - result = point_.remove(point); - if(result) changes_.firePropertyChange("pointRemoved", true, false); - } - return result; - } - - public Iterator getPointIterator() { - return point_.iterator(); - } - - public boolean hasPoint() { - return !point_.isEmpty(); - } - - public Annote addText(String id, SoTPoint loc, SGLabel text) - throws SGException { - if(xTime_ != loc.isXTime() || yTime_ != loc.isYTime()) - throw new SGException("Time axes do not match"); - Annote.Text aText = new Annote.Text(id, loc, text); - aText.addPropertyChangeListener(this); - text_.add(aText); - - changes_.firePropertyChange("textAdded", true, false); - return aText; - } - - private boolean removeText(Annote text) { - boolean result = false; - if(text instanceof Annote.Text) { - text.removePropertyChangeListener(this); - result = text_.remove(text); - if(result) changes_.firePropertyChange("textRemoved", true, false); - } - return result; - } - - public Iterator getTextIterator() { - return text_.iterator(); - } - - public boolean hasText() { - return !text_.isEmpty(); - } -/** - * Add an oval to the Annotation. If attr is non-null an oval - * outline will be drawn, if color is non-null it will be filled. - */ - public Annote addOval(String id, SoTPoint pt1, SoTPoint pt2, - LineAttribute attr, Color color) throws SGException { - if(xTime_ != pt1.isXTime() || yTime_ != pt1.isYTime()) - throw new SGException("Time axes do not match"); - Annote.Oval aOval = new Annote.Oval(id, pt1, pt2, attr, color); - aOval.addPropertyChangeListener(this); - oval_.add(aOval); - - changes_.firePropertyChange("ovalAdded", true, false); - return aOval; - } - - private boolean removeOval(Annote oval) { - boolean result = false; - if(oval instanceof Annote.Oval) { - oval.removePropertyChangeListener(this); - result = oval_.remove(oval); - if(result) changes_.firePropertyChange("ovalRemoved", true, false); - } - return result; - } - - public Iterator getOvalIterator() { - return oval_.iterator(); - } - - public boolean hasOval() { - return !oval_.isEmpty(); - } -/** - * Add an rectangle to the Annotation. If attr is non-null an rectangle - * outline will be drawn, if color is non-null it will be filled. - */ - public Annote addRect(String id, SoTPoint pt1, SoTPoint pt2, - LineAttribute attr, Color color) throws SGException { - if(xTime_ != pt1.isXTime() || yTime_ != pt1.isYTime()) - throw new SGException("Time axes do not match"); - Annote.Rect aRect = new Annote.Rect(id, pt1, pt2, attr, color); - aRect.addPropertyChangeListener(this); - rect_.add(aRect); - - changes_.firePropertyChange("rectAdded", true, false); - return aRect; - } - - private boolean removeRect(Annote rect) { - boolean result = false; - if(rect instanceof Annote.Rect) { - rect.removePropertyChangeListener(this); - result = rect_.remove(rect); - if(result) changes_.firePropertyChange("rectRemoved", true, false); - } - return result; - } - - public Iterator getRectIterator() { - return rect_.iterator(); - } - - public boolean hasRect() { - return !rect_.isEmpty(); - } - - public Annote findAnnote(String id) { - Annote tmp = null; - Iterator iter; - if(!line_.isEmpty()) { - iter = line_.iterator(); - while(iter.hasNext()) { - tmp = (Annote)iter.next(); - if(tmp.getAnnoteId().equals(id)) return tmp; - } - } - if(!point_.isEmpty()) { - iter = point_.iterator(); - while(iter.hasNext()) { - tmp = (Annote)iter.next(); - if(tmp.getAnnoteId().equals(id)) return tmp; - } - } - if(!oval_.isEmpty()) { - iter = oval_.iterator(); - while(iter.hasNext()) { - tmp = (Annote)iter.next(); - if(tmp.getAnnoteId().equals(id)) return tmp; - } - } - if(!rect_.isEmpty()) { - iter = rect_.iterator(); - while(iter.hasNext()) { - tmp = (Annote)iter.next(); - if(tmp.getAnnoteId().equals(id)) return tmp; - } - } - if(!text_.isEmpty()) { - iter = text_.iterator(); - while(iter.hasNext()) { - tmp = (Annote)iter.next(); - if(tmp.getAnnoteId().equals(id)) return tmp; - } - } - return null; - } - - public void setTitle(String title) { - title_ = title; - } - - public String getTitle() { - return title_; - } - - public SGLabel getKeyTitle() { - return null; - } - - public void setId(String id) { - id_ = id; - } - - public String getId() { - return id_; - } - - public SGTData copy() { - /**@todo: Implement this gov.noaa.pmel.sgt.dm.SGTData method*/ - throw new java.lang.UnsupportedOperationException("Method copy() not yet implemented."); - } - - public boolean isXTime() { - return xTime_; - } - - public boolean isYTime() { - return yTime_; - } - - public void setXMetaData(SGTMetaData meta) { - xMeta_ = meta; - } - - public SGTMetaData getXMetaData() { - return xMeta_; - } - - public void setYMetaData(SGTMetaData meta) { - yMeta_ = meta; - } - - public SGTMetaData getYMetaData() { - return yMeta_; - } - - public SoTRange getXRange() { - return xRange_; - } - - public SoTRange getYRange() { - return yRange_; - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - public void propertyChange(PropertyChangeEvent evt) { - changes_.firePropertyChange(evt); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Annote.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Annote.java deleted file mode 100755 index ed13c9f5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Annote.java +++ /dev/null @@ -1,708 +0,0 @@ -/* - * $Id: Annote.java,v 1.1.1.1 2007/09/07 06:32:03 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.SGLabel; - -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTDomain; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; - -import java.io.Serializable; -import java.awt.Color; -import java.awt.Rectangle; - -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; -/** - * Abstract class for annotations. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ -public abstract class Annote implements SGTData, Serializable, PropertyChangeListener { - protected transient PropertyChangeSupport changes_; - // serial version ref 1.7.2.5 - private static final long serialVersionUID = 7305616377566581275L; - protected String id_ = null; - -/** - * Class for line annotations. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ - public static class Line extends Annote { - SGTLine line; - LineAttribute attr; - - public Line(String id, SGTLine line, LineAttribute attr) { - id_ = id; - this.line = line; - this.attr = attr; - init(); - } - public void init() { - if(attr != null) attr.addPropertyChangeListener(this); - changes_ = new PropertyChangeSupport(this); - } - public SGTLine getLine() { - return line; - } - public LineAttribute getAttribute() { - return attr; - } - public SoTDomain getDomain() { - return new SoTDomain(line.getXRange(), line.getYRange()); - } - public Rectangle getBounds(Graph graph) { - return computeBounds(graph, this.getDomain()); - } - public void moveBy(SoTPoint point) { - double[] xu = null; - double[] yu = null; - long[] tu = null; - double delta; - long tdelta; - if(!(line instanceof SimpleLine)) return; - if(line.isXTime()) { - tu = line.getGeoDateArray().getTime(); - tdelta = point.getX().getLongTime(); - for(int i=0; i < tu.length; i++) { - tu[i] += tdelta; - } - ((SimpleLine)line).setTimeArray(new GeoDateArray(tu)); - } else { - xu = line.getXArray(); - delta = ((Number)point.getX().getObjectValue()).doubleValue(); - for(int i=0; i < xu.length; i++) { - xu[i] += delta; - } - ((SimpleLine)line).setXArray(xu); - } - if(line.isYTime()) { - tu = line.getGeoDateArray().getTime(); - tdelta = point.getY().getLongTime(); - for(int i=0; i < tu.length; i++) { - tu[i] += tdelta; - } - ((SimpleLine)line).setTimeArray(new GeoDateArray(tu)); - } else { - yu = line.getYArray(); - delta = ((Number)point.getY().getObjectValue()).doubleValue(); - for(int i=0; i < yu.length; i++) { - yu[i] += delta; - } - ((SimpleLine)line).setYArray(yu); - } - changes_.firePropertyChange("lineMoved", true, false); - } - public void setXArray(double[] xa) { - } - public void setYArray(double[] ya) { - } - public void setTimeArray(GeoDateArray gda) { - } - public void propertyChange(PropertyChangeEvent evt) { - changes_.firePropertyChange(evt); - } - /* SGTData required methods */ - public SGTData copy() { - SGTData copy = null; - try { - copy = (SGTData)this.clone(); - } catch (CloneNotSupportedException ex) { - ex.printStackTrace(); - } - return copy; - } - public String getId() { - return line.getId(); - } - public SGLabel getKeyTitle() { - return line.getKeyTitle(); - } - public String getTitle() { - return line.getTitle(); - } - public SGTMetaData getXMetaData() { - return line.getXMetaData(); - } - public SoTRange getXRange() { - return line.getXRange(); - } - public SGTMetaData getYMetaData() { - return line.getYMetaData(); - } - public SoTRange getYRange() { - return line.getYRange(); - } - public boolean isXTime() { - return line.isXTime(); - } - public boolean isYTime() { - return line.isYTime(); - } - } - -/** - * Class for point annotations. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ - public static class Point extends Annote { - SGTPoint point; - PointAttribute attr; - - public Point(String id, SGTPoint point, PointAttribute attr) { - id_ = id; - this.point = point; - this.attr = attr; - init(); - } - public void init() { - if(attr != null) attr.addPropertyChangeListener(this); - changes_ = new PropertyChangeSupport(this); - } - public SGTPoint getPoint() { - return point; - } - public PointAttribute getAttribute() { - return attr; - } - - public SoTDomain getDomain() { - return new SoTDomain(point.getXRange(), point.getYRange()); - } - - public Rectangle getBounds(Graph graph) { - /** @todo add text bounds */ - Rectangle rect = computeBounds(graph, this.getDomain()); - double hgt = attr.getMarkHeightP(); - int ihgt = graph.getLayer().getXPtoD(hgt); - rect.setBounds(rect.x-ihgt/2, - rect.y-ihgt/2, - ihgt, ihgt); - return rect; - } - - public void moveBy(SoTPoint pnt) { - double xu = 0.0; - double yu = 0.0; - long tu = 0; - double delta; - long tdelta; - if(!(point instanceof SimplePoint)) return; - if(point.isXTime()) { - tu = point.getLongTime(); - tdelta = pnt.getX().getLongTime(); - tu += tdelta; - ((SimplePoint)point).setTime(tu); - } else { - xu = point.getX(); - delta = ((Number)pnt.getX().getObjectValue()).doubleValue(); - xu += delta; - ((SimplePoint)point).setX(xu); - } - if(point.isYTime()) { - tu = point.getLongTime(); - tdelta = pnt.getY().getLongTime(); - tu += tdelta; - ((SimplePoint)point).setTime(tu); - } else { - yu = point.getY(); - delta = ((Number)pnt.getY().getObjectValue()).doubleValue(); - yu += delta; - ((SimplePoint)point).setY(yu); - } - changes_.firePropertyChange("pointMoved", true, false); - } - public void propertyChange(PropertyChangeEvent evt) { - changes_.firePropertyChange(evt); - } - /* SGTData required methods */ - public SGTData copy() { - SGTData copy = null; - try { - copy = (SGTData)this.clone(); - } catch (CloneNotSupportedException ex) { - ex.printStackTrace(); - } - return copy; - } - public String getId() { - return point.getId(); - } - public SGLabel getKeyTitle() { - return point.getKeyTitle(); - } - public String getTitle() { - return point.getTitle(); - } - public SGTMetaData getXMetaData() { - return point.getXMetaData(); - } - public SoTRange getXRange() { - return point.getXRange(); - } - public SGTMetaData getYMetaData() { - return point.getYMetaData(); - } - public SoTRange getYRange() { - return point.getYRange(); - } - public boolean isXTime() { - return point.isXTime(); - } - public boolean isYTime() { - return point.isYTime(); - } - } - -/** - * Class for text annotations. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ - public static class Text extends Annote { - SoTPoint location; - SGLabel text; - - public Text(String id, SoTPoint location, SGLabel text) { - id_ = id; - this.location = location; - this.text = text; - init(); - } - public void init() { - if(text != null) text.addPropertyChangeListener(this); - changes_ = new PropertyChangeSupport(this); - } - public SoTPoint getLocation() { - return location; - } - public SGLabel getText() { - return text; - } - public SoTDomain getDomain() { - - return null; - } - private SoTDomain getDomain(Graph graph) { - CartesianGraph cg = (CartesianGraph)graph; - SoTRange xRange = null; - SoTRange yRange = null; - Rectangle2D.Double bnds = text.getBoundsP(); -/** @todo rewrite to go directly to device units */ - double xloc = cg.getXUtoP(location.getX()); - double yloc = cg.getYUtoP(location.getY()); - double width = bnds.width; - double height = bnds.height; - if(location.isXTime()) { - long min = cg.getXPtoLongTime(xloc); - long max = cg.getXPtoLongTime(xloc + width); - xRange = new SoTRange.Time(min, max); - } else { - double min = cg.getXPtoU(xloc); - double max = cg.getXPtoU(xloc + width); - xRange = new SoTRange.Double(min, max); - } - if(location.isYTime()) { - long min = cg.getYPtoLongTime(yloc); - long max = cg.getYPtoLongTime(yloc + height); - yRange = new SoTRange.Time(min, max); - } else { - double min = cg.getYPtoU(yloc); - double max = cg.getYPtoU(yloc + height); - yRange = new SoTRange.Double(min, max); - } - return new SoTDomain(xRange, yRange); - } - public Rectangle getBounds(Graph graph) { - return computeBounds(graph, this.getDomain(graph)); - } - public void moveBy(SoTPoint point) { - location.add(point); - changes_.firePropertyChange("textMoved", true, false); - } - public void propertyChange(PropertyChangeEvent evt) { - changes_.firePropertyChange(evt); - } - /* SGTData required methods */ - public SGTData copy() { - SGTData copy = null; - try { - copy = (SGTData)this.clone(); - } catch (CloneNotSupportedException ex) { - ex.printStackTrace(); - } - return copy; - } - public String getId() { - return text.getId(); - } - public SGLabel getKeyTitle() { - return null; - } - public String getTitle() { - return null; - } - public SGTMetaData getXMetaData() { - return null; - } - public SoTRange getXRange() { - return null; - } - public SGTMetaData getYMetaData() { - return null; - } - public SoTRange getYRange() { - return null; - } - public boolean isXTime() { - return location.isXTime(); - } - public boolean isYTime() { - return location.isYTime(); - } - } - -/** - * Class for oval annotations. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ - public static class Oval extends Annote { - SoTPoint upperLeft; - SoTPoint lowerRight; - LineAttribute attr; - Color color; - SoTRange xRange_ = null; - SoTRange yRange_ = null; - - public Oval(String id, SoTPoint upperLeft, SoTPoint lowerRight, - LineAttribute attr, Color color) { - id_ = id; - this.upperLeft = upperLeft; - this.lowerRight = lowerRight; - this.attr = attr; - this.color = color; - init(); - computeRange(); - } - public void init() { - if(attr != null) attr.addPropertyChangeListener(this); - changes_ = new PropertyChangeSupport(this); - } - public SoTPoint getUpperLeft() { - return upperLeft; - } - public void setUpperLeft(SoTPoint ul) { - upperLeft = ul; - computeRange(); - changes_.firePropertyChange("ovalMoved", true, false); - } - public SoTPoint getLowerRight() { - return lowerRight; - } - public void setLowerRight(SoTPoint lr) { - lowerRight = lr; - computeRange(); - changes_.firePropertyChange("ovalMoved", true, false); - } - public void setLocation(SoTPoint ul, SoTPoint lr) { - upperLeft = ul; - lowerRight = lr; - computeRange(); - changes_.firePropertyChange("ovalMoved", true, false); - } - public LineAttribute getLineAttribute() { - return attr; - } - public Color getFillColor() { - return color; - } - public void setFillColor(Color color) { - this.color = color; - changes_.firePropertyChange("colorChanged", true, false); - } - public SoTDomain getDomain() { - return new SoTDomain(xRange_, yRange_); - } - public Rectangle getBounds(Graph graph) { - return computeBounds(graph, this.getDomain()); - } - public void moveBy(SoTPoint point) { - upperLeft.add(point); - lowerRight.add(point); - computeRange(); - changes_.firePropertyChange("ovalMoved", true, false); - } - private void computeRange() { - if(upperLeft.getX().isTime()) { - xRange_ = new SoTRange.Time(upperLeft.getX().getLongTime(), - lowerRight.getX().getLongTime()); - } else { - double xmin = ((Number)upperLeft.getX().getObjectValue()).doubleValue(); - double xmax = ((Number)lowerRight.getX().getObjectValue()).doubleValue(); - xRange_ = new SoTRange.Double(xmin, xmax); - } - if(upperLeft.getY().isTime()) { - yRange_ = new SoTRange.Time(lowerRight.getY().getLongTime(), - upperLeft.getY().getLongTime()); - } else { - double ymin = ((Number)lowerRight.getY().getObjectValue()).doubleValue(); - double ymax = ((Number)upperLeft.getY().getObjectValue()).doubleValue(); - yRange_ = new SoTRange.Double(ymin, ymax); - } - } - public void propertyChange(PropertyChangeEvent evt) { - changes_.firePropertyChange(evt); - } - /* SGTData required methods */ - public SGTData copy() { - SGTData copy = null; - try { - copy = (SGTData)this.clone(); - } catch (CloneNotSupportedException ex) { - ex.printStackTrace(); - } - return copy; - } - public String getId() { - return null; - } - public SGLabel getKeyTitle() { - return null; - } - public String getTitle() { - return null; - } - public SGTMetaData getXMetaData() { - return null; - } - public SoTRange getXRange() { - return xRange_; - } - public SGTMetaData getYMetaData() { - return null; - } - public SoTRange getYRange() { - return yRange_; - } - public boolean isXTime() { - return upperLeft.isXTime(); - } - public boolean isYTime() { - return upperLeft.isYTime(); - } - } - -/** - * Class for rectangle annotations. - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ - public static class Rect extends Annote { - SoTPoint upperLeft; - SoTPoint lowerRight; - LineAttribute attr; - Color color; - SoTRange xRange_ = null; - SoTRange yRange_ = null; - - public Rect(String id, SoTPoint upperLeft, SoTPoint lowerRight, - LineAttribute attr, Color color) { - id_ = id; - this.upperLeft = upperLeft; - this.lowerRight = lowerRight; - this.attr = attr; - this.color = color; - init(); - computeRange(); - } - public void init() { - if(attr != null) attr.addPropertyChangeListener(this); - changes_ = new PropertyChangeSupport(this); - } - public SoTPoint getUpperLeft() { - return upperLeft; - } - public void setUpperLeft(SoTPoint ul) { - upperLeft = ul; - computeRange(); - changes_.firePropertyChange("rectMoved", true, false); - } - public SoTPoint getLowerRight() { - return lowerRight; - } - public void setLowerRight(SoTPoint lr) { - lowerRight = lr; - computeRange(); - changes_.firePropertyChange("rectMoved", true, false); - } - public void setLocation(SoTPoint ul, SoTPoint lr) { - upperLeft = ul; - lowerRight = lr; - computeRange(); - changes_.firePropertyChange("rectMoved", true, false); - } - public LineAttribute getLineAttribute() { - return attr; - } - public Color getFillColor() { - return color; - } - public void setFillColor(Color color) { - this.color = color; - changes_.firePropertyChange("colorChanged", true, false); - } - public SoTDomain getDomain() { - return new SoTDomain(xRange_, yRange_); - } - public Rectangle getBounds(Graph graph) { - return computeBounds(graph, this.getDomain()); - } - public void moveBy(SoTPoint point) { - upperLeft.add(point); - lowerRight.add(point); - computeRange(); - changes_.firePropertyChange("rectMoved", true, false); - } - private void computeRange() { - if(upperLeft.getX().isTime()) { - xRange_ = new SoTRange.Time(upperLeft.getX().getLongTime(), - lowerRight.getX().getLongTime()); - } else { - double xmin = ((Number)upperLeft.getX().getObjectValue()).doubleValue(); - double xmax = ((Number)lowerRight.getX().getObjectValue()).doubleValue(); - xRange_ = new SoTRange.Double(xmin, xmax); - } - if(upperLeft.getY().isTime()) { - yRange_ = new SoTRange.Time(lowerRight.getY().getLongTime(), - upperLeft.getY().getLongTime()); - } else { - double ymin = ((Number)lowerRight.getY().getObjectValue()).doubleValue(); - double ymax = ((Number)upperLeft.getY().getObjectValue()).doubleValue(); - yRange_ = new SoTRange.Double(ymin, ymax); - } - } - public void propertyChange(PropertyChangeEvent evt) { - changes_.firePropertyChange(evt); - } - /* SGTData required methods */ - public SGTData copy() { - SGTData copy = null; - try { - copy = (SGTData)this.clone(); - } catch (CloneNotSupportedException ex) { - ex.printStackTrace(); - } - return copy; - } - public String getId() { - return null; - } - public SGLabel getKeyTitle() { - return null; - } - public String getTitle() { - return null; - } - public SGTMetaData getXMetaData() { - return null; - } - public SoTRange getXRange() { - return xRange_; - } - public SGTMetaData getYMetaData() { - return null; - } - public SoTRange getYRange() { - return yRange_; - } - public boolean isXTime() { - return upperLeft.isXTime(); - } - public boolean isYTime() { - return upperLeft.isYTime(); - } - } - - protected Annote() { - } - - protected Rectangle computeBounds(Graph graph, SoTDomain domain) { - Rectangle rect = null; - if(domain == null || !(graph instanceof CartesianGraph)) return rect; - CartesianGraph cg = (CartesianGraph)graph; - int xd, yd; - int width, height; - - int xd1 = cg.getXUtoD(domain.getXRange().getStart()); - int yd1 = cg.getYUtoD(domain.getYRange().getStart()); - int xd2 = cg.getXUtoD(domain.getXRange().getEnd()); - int yd2 = cg.getYUtoD(domain.getYRange().getEnd()); - if(xd1 < xd2) { - xd = xd1; - width = xd2 - xd1; - } else { - xd = xd2; - width = xd1 - xd2; - } - if(yd1 < yd2) { - yd = yd1; - height = yd2 - yd1; - } else { - yd = yd2; - height = yd1 - yd2; - } - rect = new Rectangle(xd, yd, width, height); - return rect; - } - - public abstract Rectangle getBounds(Graph graph); - public abstract SoTDomain getDomain(); - public abstract void moveBy(SoTPoint point); - public abstract void propertyChange(PropertyChangeEvent evt); - - public String getAnnoteId() { - return id_; - } - /** - * Init method used to setup serialized object. - */ - public abstract void init(); - - /* SGTData required methods */ - public void addPropertyChangeListener(PropertyChangeListener l) { - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - if(changes_ == null) changes_ = new PropertyChangeSupport(this); - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Cartesian.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Cartesian.java deleted file mode 100755 index 35fedbdb..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Cartesian.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * $Id: Cartesian.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -/** - * The Cartesian interface indicates to the - * sgt classes that - * X and Y coordinates are to be interpreted as Cartesian - * coordinates. X or Y can optionally, when independent, a time - * axis. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - */ -public interface Cartesian extends CoordinateSystem { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Collection.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Collection.java deleted file mode 100755 index ad484736..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Collection.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * $Id: Collection.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.SoTRange; - -import java.util.Vector; -import java.util.Enumeration; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; - -/** - * Collection is an extension to Vector - * designed to hold SGTData objects. These objects must - * have consistent x and y coordinate types. Otherwise, the - * isXTime(), isYTime(), - * getXMetaData(), getYMetaData(), and - * get?Ranges() methods will fail. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see SGTPoint - * @see SGTLine - * @see SGTGrid - * @see SGTVector - */ -public class Collection extends Vector implements SGTData, Cloneable { - private String title_; - private SGLabel keyTitle_ = null; - private String id_ = null; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private int colLen_ = 0; - - public Collection() { - this(""); - } - public Collection(String title) { - super(); - title_ = title; - } - public Collection(String title, int initialCapacity) { - super(initialCapacity); - title_ = title; - } - public Collection(String title, int initialCapacity, int increment) { - super(initialCapacity, increment); - title_ = title; - } - /** - * Create a copy. - * - * @see SGTData - */ - public SGTData copy() { - Collection newCollection; - newCollection = (Collection)clone(); - return (SGTData)newCollection; - } - /** - * Get the title. - */ - public String getTitle() { - return title_; - } - /** - * Set the title. - */ - public void setTitle(String title) { - title_ = title; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - public boolean isXTime() { - return ((SGTData)firstElement()).isXTime(); - } - public boolean isYTime() { - return ((SGTData)firstElement()).isYTime(); - } - public SGTMetaData getXMetaData() { - return ((SGTData)firstElement()).getXMetaData(); - } - public SGTMetaData getYMetaData() { - return ((SGTData)firstElement()).getYMetaData(); - } - public SoTRange getXRange() { - computeRange(); - return xRange_.copy(); - } - public SoTRange getYRange() { - computeRange(); - return yRange_.copy(); - } - private void computeRange() { - if(colLen_ == size()) return; - colLen_ = size(); - xRange_ = ((SGTData)firstElement()).getXRange(); - yRange_ = ((SGTData)firstElement()).getYRange(); - - Enumeration enume = elements(); - while(enume.hasMoreElements()) { - SGTData data = (SGTData)enume.nextElement(); - xRange_.add(data.getXRange()); - yRange_.add(data.getYRange()); - } - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/CoordinateSystem.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/CoordinateSystem.java deleted file mode 100755 index d75c31f7..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/CoordinateSystem.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * $Id: CoordinateSystem.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -/** - * Base class for coordinate system information - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see Cartesian - * @see Polar - */ -public interface CoordinateSystem { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Geographic.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Geographic.java deleted file mode 100755 index 392e2962..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Geographic.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * $Id: Geographic.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -/** - * The Geographic interface indicates to the - * sgt classes that - * X and Y coordinates are to be interpreted as longitude - * and latitude, respectively. The Geographic interface does not - * support X or Y being a time coordinate. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - */ -public interface Geographic extends CoordinateSystem { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/PointCollection.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/PointCollection.java deleted file mode 100755 index 02154c1d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/PointCollection.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * $Id: PointCollection.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import java.util.Vector; -import java.util.Enumeration; - -import gov.noaa.pmel.util.SoTRange; - -/** - * PointCollection is an extension to Vector - * designed to hold SGTPoint objects. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see SGTData - * @see SGTPoint - * @see SGTLine - * @see SGTGrid - * @see SGTVector - */ -public class PointCollection extends Collection { - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private int colLen_ = 0; - - /** - * @link aggregation - * @clientRole x - */ - private SGTMetaData xMetaData_; - - /** - * @link aggregation - * @clientRole y - */ - private SGTMetaData yMetaData_; - /** - * Default consturctor - */ - public PointCollection() { - this(""); - } - public PointCollection(String title) { - super(title); - } - public PointCollection(String title, int initialCapacity) { - super(title, initialCapacity); - } - public PointCollection(String title, int initialCapacity, int increment) { - super(title, initialCapacity, increment); - } - /** - * Create a copy. - * - * @see SGTData - */ - public SGTData copy() { - PointCollection newCollection; - newCollection = (PointCollection)clone(); - return (SGTData)newCollection; - } - public SoTRange getXRange() { - computeRange(); - return xRange_.copy(); - } - - public SoTRange getYRange() { - computeRange(); - return yRange_.copy(); - } - - private void computeRange() { - if(colLen_ == size()) return; - colLen_ = size(); - double xmin = Double.POSITIVE_INFINITY; - double xmax = Double.NEGATIVE_INFINITY; - double ymin = xmin; - double ymax = xmax; - double ptx, pty; - - int count = 0; - Enumeration e = elements(); - while(e.hasMoreElements()) { - Object obj = e.nextElement(); - if(obj instanceof SGTPoint) { - SGTPoint pt = (SGTPoint)obj; - ptx = pt.getX(); - pty = pt.getY(); - if(!(Double.isNaN(ptx) || Double.isNaN(pty))) { - xmin = Math.min(xmin, ptx); - xmax = Math.max(xmax, ptx); - ymin = Math.min(ymin, pty); - ymax = Math.max(ymax, pty); - count++; - } - } - } - if(count == 0) { - xRange_ = new SoTRange.Double(Double.NaN, Double.NaN); - yRange_ = new SoTRange.Double(Double.NaN, Double.NaN); - } else { - xRange_ = new SoTRange.Double(xmin, xmax); - yRange_ = new SoTRange.Double(ymin, ymax); - } - } - - public SGTMetaData getXMetaData(){ - return xMetaData_; - } - /** - * Set the SGTMetaData associated with the x axis. - */ - public void setXMetaData(SGTMetaData xMetaData){ - xMetaData_ = xMetaData; - } - - public SGTMetaData getYMetaData(){ - return yMetaData_; - } - /** - * Set the SGTMetaData associated with the y axis. - */ - public void setYMetaData(SGTMetaData yMetaData){ - yMetaData_ = yMetaData; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Polar.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Polar.java deleted file mode 100755 index 043e40dd..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/Polar.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * $Id: Polar.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -/** - * The Polar interface indicates to the sgt graphics - * toolkit that the X and Y coordinates are to be - * interpreted as R (radius) and Theta (angle), - * respectively. Neither X nor Y can be a time axis - * when using the Polar interface. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see CoordinateSystem - */ -public interface Polar extends CoordinateSystem { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGT3DGrid.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGT3DGrid.java deleted file mode 100755 index da37d47e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGT3DGrid.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * $Id: SGT3DGrid.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.SoTRange; - -/** - * Defines a data object to be of Grid type. Interpretation - * of X and Y is determined by the CoordinateSystem. For - * Cartesian, X and Y are the Cartesian coordinates. For - * Polar, X and Y are R (radius) and Theta (angle), respectively. - * - * The SGTGrid interface only specifies the methods required - * to access information. The methods used to construct an - * object that implements SGTGrid is left to the developer. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - * @see Cartesian - * @see Polar - * @see SimpleGrid - */ -public interface SGT3DGrid extends SGTData { - // additions to SGTData stuff - - /** - * Returns true if the Z coordinate is Time. - */ - public boolean isZTime(); - - /** - * Get the length of Z value array. - */ - public int getZSize(); - /** - * Get the range of measured values on this 3D grid. - */ - public Range2D getValRange(); - /** - * Get the array of temporal values. - */ - /** - * Get the Value SGTMetaData. - */ - public SGTMetaData getValMetaData(); - /** - * Z edges available? - */ - public boolean hasZEdges(); - /** - * Get the Y coordinate edges. The YEdge length will - * be one greater than the YArray length. - */ - public double[] getZEdges(); - /** - * Get the range of Y coordinate edges. - */ - public SoTRange getZEdgesRange(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGT3DVector.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGT3DVector.java deleted file mode 100755 index 03793561..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGT3DVector.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * $Id: SGT3DVector.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.SoTRange; - -import java.beans.PropertyChangeListener; -import java.io.Serializable; - -/** - * Defines a data object to be a Vector. Interpretation - * of U and V is determined by the CoordinateSystem. For - * Cartesian, U and V are the Cartesian vector - * components. For Polar , - * U and V are R (radius) and Theta (angle) vector components, - * respectively. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - */ -public class SGT3DVector extends SGTVector { - /**@shapeType AggregationLink - * @clientRole w comp*/ - SGTGrid wComp_; - /** - * Default constructor. - */ - public SGT3DVector() { - } - /** - * Construct a SGTVector from two components. The two components - * must match in both SGTData and CoordinateSystem Interfaces. - * Both components must be the same shape. - * - * @param uComp U component of the vector - * @param vComp V component of the vector - * @param vComp W component of the vector - */ - public SGT3DVector(SGTGrid uComp,SGTGrid vComp, SGTGrid wComp) { - uComp_ = uComp; - vComp_ = vComp; - wComp_ = wComp; - } - /** - * Create a copy. Creates a shallow copy. - * - * @see SGTData - */ - public SGTData copy() { - SGT3DVector newSGTVector; - try { - newSGTVector = (SGT3DVector)clone(); - } catch (CloneNotSupportedException e) { - newSGTVector = new SGT3DVector(this.uComp_, this.vComp_, this.wComp_); - } - return (SGTData)newSGTVector; - } - /** - * Get the W component. - * - * @return W component - */ - public SGTGrid getW() { - return wComp_; - } - - /** - * Set the W component. - * - * @param uComp W component - */ - public void setU(SGTGrid wComp) { - wComp_ = wComp; - } - - /** - * Set the vector components. - * - * @param uComp U component - * @param vComp V component - */ - public void setComponents(SGTGrid uComp, SGTGrid vComp, SGTGrid wComp) { - uComp_ = uComp; - vComp_ = vComp; - wComp_ = wComp; - } - - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - - - public void addPropertyChangeListener(PropertyChangeListener l) { - uComp_.addPropertyChangeListener(l); - vComp_.addPropertyChangeListener(l); - wComp_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - uComp_.removePropertyChangeListener(l); - vComp_.removePropertyChangeListener(l); - wComp_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTData.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTData.java deleted file mode 100755 index 758d4199..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTData.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * $Id: SGTData.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.SoTRange; - -import java.beans.PropertyChangeListener; - -/** - * Base class for sgt datamodel rank information. - * The SGTData class and its children are used by sgt - * to determine the rank (point, line, grid) of the - * data. Data values can be either double or - * GeoDate, which extends Date. Missing - * values are indicated by Double.NaN for type - * double and by null or by - * Long.MIN_VALUE milliseconds after (before) January 1, - * 1970 00:00:00 GMT for GeoDate. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTPoint - * @see SGTLine - * @see SGTGrid - */ -public interface SGTData { - /** - * Get the title. - */ - public String getTitle(); - /** - * Get a title formatted for a Key. JPlotLayout will use this - * if an explicit Key title is not given in the addData method. - * - * @see gov.noaa.pmel.sgt.SGLabel - * @see gov.noaa.pmel.sgt.ColorKey - * @see gov.noaa.pmel.sgt.LineKey - * @see gov.noaa.pmel.sgt.PointCollectionKey - * @see gov.noaa.pmel.sgt.VectorKey - */ - public SGLabel getKeyTitle(); - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId(); - /** - * Create a shallow copy. User should implement using the clone() - * method, which requires the Cloneable interface be inherited. - * If clone() is used, then references to objects are copied NOT - * the object itself. - * - *

For example,

- *
-   * public SGTData copy() {
-   *   SGTData newData;
-   *   try {
-   *     newData = (SGTData)clone();
-   *   } catch (CloneNotSupportedException e) {
-   *     newData = null;
-   *   }
-   *   return newData;
-   * }
-   * 
- * - * @return shallow copy - * @see java.lang.Object - */ - public SGTData copy(); - - /** - * Returns true if the X coordinate is Time. - */ - public boolean isXTime(); - - /** - * Returns true if the Y coordinate is Time. - */ - public boolean isYTime(); - - /** - * Returns the X SGTMetaData. - */ - public SGTMetaData getXMetaData(); - - /** - * Returns the Y SGTMetaData. - */ - public SGTMetaData getYMetaData(); - - /** - * Returns the range of the X coordinates. If all the data in the - * array is missing, this method will return Double.NaN - * as the start and end values for data of type double - * and return GeoDate(Long.MIN_VALUE) for data of type - * GeoDate. - * - * @see gov.noaa.pmel.util.GeoDate#isMissing() - */ - public SoTRange getXRange(); - - /** - * Returns the range of the Y coordinates. - * @see #getXRange() - */ - public SoTRange getYRange(); - - /** - * Add a PropertyChangeListener to the listener list. - */ - public void addPropertyChangeListener(PropertyChangeListener l); - - /** - * Remove a PropertyChangeListener from the listener list. - */ - public void removePropertyChangeListener(PropertyChangeListener l); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTFull3DVector.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTFull3DVector.java deleted file mode 100755 index 27ffc708..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTFull3DVector.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * $Id: SGTFull3DVector.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.SoTRange; - -import java.beans.PropertyChangeListener; -import java.io.Serializable; - -/** - * Defines a data object to be a Vector. Interpretation - * of U and V is determined by the CoordinateSystem. For - * Cartesian, U and V are the Cartesian vector - * components. For Polar , - * U and V are R (radius) and Theta (angle) vector components, - * respectively. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - */ -public class SGTFull3DVector implements SGTData, Cloneable, Serializable { - String title_; - SGLabel keyTitle_ = null; - String id_ = null; - /**@shapeType AggregationLink - * @clientRole u comp*/ - ThreeDGrid uComp_; - /**@shapeType AggregationLink - * @clientRole v comp*/ - ThreeDGrid vComp_; - /**@shapeType AggregationLink - * @clientRole w comp*/ - ThreeDGrid wComp_; - - /** - * Default constructor. - */ - public SGTFull3DVector() { - } - /** - * Construct a SGT3DVector from three components. The three components - * must match in both SGTData and CoordinateSystem Interfaces. - * All components must be the same shape. - * - * @param uComp U component of the vector - * @param vComp V component of the vector - * @param wComp W component of the vector - */ - public SGTFull3DVector(ThreeDGrid uComp, ThreeDGrid vComp, ThreeDGrid wComp) { - uComp_ = uComp; - vComp_ = vComp; - wComp_ = wComp; - } - /** - * Create a copy. Creates a shallow copy. - * - * @see SGTData - */ - public SGTData copy() { - SGTFull3DVector newSGTVector; - try { - newSGTVector = (SGTFull3DVector)clone(); - } catch (CloneNotSupportedException e) { - newSGTVector = new SGTFull3DVector(this.uComp_, this.vComp_, this.wComp_); - } - return newSGTVector; - } - /** - * Get the U component. - * - * @return U component - */ - public ThreeDGrid getU() { - return uComp_; - } - /** - * Get the V component. - * - * @return V component - */ - public ThreeDGrid getV() { - return vComp_; - } - /** - * Get the W component. - * - * @return W component - */ - public ThreeDGrid getW() { - return wComp_; - } - /** - * Set the U component. - * - * @param uComp U component - */ - public void setU(ThreeDGrid uComp) { - uComp_ = uComp; - } - /** - * Set the V component. - * - * @param vComp V component - */ - public void setV(ThreeDGrid vComp) { - vComp_ = vComp; - } - /** - * Set the W component. - * - * @param vComp W component - */ - public void setW(ThreeDGrid wComp) { - wComp_ = wComp; - } - /** - * Set the vector components. - * - * @param uComp U component - * @param vComp V component - */ - public void setComponents(ThreeDGrid uComp, ThreeDGrid vComp, ThreeDGrid wComp) { - uComp_ = uComp; - vComp_ = vComp; - wComp_ = wComp; - } - /** - * Set the vector's title. - * - * @param title - */ - public void setTitle(String title) { - title_ = title; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - /** Set the title formatted for the VectorKey. */ - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - /** - * Get the vector's title. - * - * @return the title - */ - public String getTitle() { - return title_; - } - public boolean isXTime() { - return uComp_.isXTime(); - } - public boolean isYTime() { - return uComp_.isYTime(); - } - public boolean isZTime() { - return uComp_.isZTime(); - } - public SGTMetaData getXMetaData() { - return uComp_.getXMetaData(); - } - public SGTMetaData getYMetaData() { - return uComp_.getYMetaData(); - } - public SGTMetaData getZMetaData() { - return uComp_.getZMetaData(); - } - public SoTRange getXRange() { - return uComp_.getXRange(); - } - public SoTRange getYRange() { - return uComp_.getYRange(); - } - public SoTRange getZRange() { - return uComp_.getZRange(); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - uComp_.addPropertyChangeListener(l); - vComp_.addPropertyChangeListener(l); - wComp_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - uComp_.removePropertyChangeListener(l); - vComp_.removePropertyChangeListener(l); - wComp_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTGrid.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTGrid.java deleted file mode 100755 index 138e0957..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTGrid.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * $Id: SGTGrid.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.SoTRange; - -/** - * Defines a data object to be of Grid type. Interpretation - * of X and Y is determined by the CoordinateSystem. For - * Cartesian, X and Y are the Cartesian coordinates. For - * Polar, X and Y are R (radius) and Theta (angle), respectively. - * - * The SGTGrid interface only specifies the methods required - * to access information. The methods used to construct an - * object that implements SGTGrid is left to the developer. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - * @see Cartesian - * @see Polar - * @see SimpleGrid - */ -public interface SGTGrid extends SGTData { - /** - * Get the array of X values. - */ - public double[] getXArray(); - /** - * Get the length of X value array. - */ - public int getXSize(); - /** - * Get the array of Y values. - */ - public double[] getYArray(); - /** - * Get the length of Y value array. - */ - public int getYSize(); - /** - * Get the array of Z values. - */ - public double[] getZArray(); - /** - * Get the range of Z values. - */ - public Range2D getZRange(); - /** - * Get the array of temporal values. - */ - public GeoDate[] getTimeArray(); - /** - * Get the GeoDateArray object. - * - * @since 3.0 - */ - public GeoDateArray getGeoDateArray(); - /** - * Get the length of temporal value array. - */ - public int getTSize(); - /** - * Get the Z SGTMetaData. - */ - public SGTMetaData getZMetaData(); - /** - * Get the associated data. The associated data must - * be of the same type (SGTGrid) and shape. - */ - public SGTGrid getAssociatedData(); - /** - * Is there associated data available? - */ - public boolean hasAssociatedData(); - /** - * Are X edges available? - */ - public boolean hasXEdges(); - /** - * Get the X coordinate edges. The XEdge length will - * be one greater than the XArray length. - */ - public double[] getXEdges(); - /** - * Get the range of X coordinate edges. - */ - public SoTRange getXEdgesRange(); - /** - * Are Y edges available? - */ - public boolean hasYEdges(); - /** - * Get the Y coordinate edges. The YEdge length will - * be one greater than the YArray length. - */ - public double[] getYEdges(); - /** - * Get the range of Y coordinate edges. - */ - public SoTRange getYEdgesRange(); - /** - * Get the Time edges. The TimeEdge length will - * be one greater than the TimeArray length. - */ - public GeoDate[] getTimeEdges(); - /** - * Get the GeoDateArray object. - * - * @since 3.0 - */ - public GeoDateArray getGeoDateArrayEdges(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTImage.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTImage.java deleted file mode 100755 index ddbf9830..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTImage.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * $Id: SGTImage.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import java.awt.Image; - -/** - * Defines a data object to be of Image type. Interpretation - * of X and Y is determined by the CoordinateSystem. For - * Cartesian, X and Y are the Cartesian coordinates. For - * Polar, - * X and Y are R (radius) and Theta (angle), respectively. - * - * The SGTImage interface only specifies the methods required - * to access information. The methods used to construct an - * object that implements SGTImage is left to the developer. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - * @see Cartesian - * @see Polar - */ -public interface SGTImage extends SGTData { - /** - * Get the X coordinate edges. - */ - public double[] getXEdges(); - /** - * Get the Y coordinate edges. - */ - public double[] getYEdges(); - /** - * Get the image. - */ - public Image getImage(); - /** - * Get the X coordinate SGTMetaData. - */ - public SGTMetaData getXMetaData(); - /** - * Get the Y coordinate SGTMetaData. - */ - public SGTMetaData getYMetaData(); - /** - * Get the pixel SGTMetaData. - */ - public SGTMetaData getZMetaData(); -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTLine.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTLine.java deleted file mode 100755 index af85e9de..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTLine.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * $Id: SGTLine.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; - -/** - * Defines a data object to be of Line type. Interpretation - * of X and Y is determined by the CoordinateSystem. For - * Cartesian, X and Y are the Cartesian coordinates. For - * Polar, - * X and Y are R (radius) and Theta (angle), respectively. - * - * The SGTLine interfaces only specifies the methods required - * to access information. The methods used to construct an - * object that implements SGTLine is left to the developer. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - * @see Cartesian - * @see Polar - * @see SimpleLine - */ -public interface SGTLine extends SGTData { - /** - * Get the array of X values. - */ - public double[] getXArray(); - /** - * Get the array of Y values. - */ - public double[] getYArray(); - /** - * Get the array of Time values. - */ - public GeoDate[] getTimeArray(); - /** - * Get the GeoDateArray object. - * - * @since 3.0 - */ - public GeoDateArray getGeoDateArray(); - /** - * Get the associated data. The associated data must - * be of the same type (SGTLine) and length. The Y - * array will be used. - */ - public SGTLine getAssociatedData(); - /** - * Is there associated data available? - */ - public boolean hasAssociatedData(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTMetaData.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTMetaData.java deleted file mode 100755 index 1b810950..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTMetaData.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * $Id: SGTMetaData.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.util.GeoDate; -import java.util.Properties; -/** - * MetaData container for the sgt datamodel. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - */ -public class SGTMetaData implements java.io.Serializable { - private String name_; - private String units_; - private boolean modulo_; - private double moduloValue_ = 0.0; - private GeoDate moduloTime_ = null; - private boolean reversed_; - private Properties props_ = null; - /** - * Default constructor. - */ - public SGTMetaData() { - this("", ""); - } - /** - * SGTMetaData constructor. - * - * @param name variable name - * @param units units of variable - */ - public SGTMetaData(String name,String units) { - this(name, units, false, false); - } - public SGTMetaData(String name, String units, boolean rev, boolean mod) { - name_ = name; - units_ = units; - reversed_ = rev; - modulo_ = mod; - } - /** - * Get the name associated with the variable or coordinate. - */ - public String getName() { - return name_; - } - /** - * Axis values are reversed. This axis defines a left-hand - * coordinate system. For example, northward, eastward, downward, - * is left-handed. - */ - public boolean isReversed() { - return reversed_; - } - /** - * Axis values are modulo. For example, 0 and 360 longitude are - * equivalent values. - */ - public boolean isModulo() { - return modulo_; - } - /** - * Set the modulo value. For example, 360 for longitude. - */ - public void setModuloValue(double val) { - moduloValue_ = val; - } - /** - * Set temporal modulo value. For example, 365 days, for yearly - * climatologies. - */ - public void setModuloTime(GeoDate val) { - moduloTime_ = val; - } - /** - * Get modulo value. - */ - public double getModuloValue() { - return moduloValue_; - } - /** - * Get temporal modulo value - */ - public GeoDate getModuloTime() { - return moduloTime_; - } - /** - * Set name of coordinate or variable - */ - public void setName(String name) { - name_ = name; - } - /** - * Set units of coordinate or variable - */ - public void setUnits(String units) { - units_ = units; - } - /** - * Set additional properties for the coordinate or variable. - */ - public void setProperties(Properties props) { - props_ = props; - } - /** - * Get variable or coordinate additional properties. - */ - public Properties getProperties() { - return props_; - } - /** - * Get property value given the key. - */ - public String getProperty(String key) { - return getProperty(key, ""); - } - /** - * Get property value given the key, if key is not defined use the - * default value. - */ - public String getProperty(String key,String defValue) { - if(props_ != null) { - return props_.getProperty(key, defValue); - } else { - return null; - } - } - /** - * Set a property for the variable or coordinate. - */ - public void setProperty(String key,String value) { - if(props_ == null) { - props_ = new Properties(); - } - props_.put(key, value); - } - /** - * Get variable or coordinate units. - */ - public String getUnits() { - return units_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTPoint.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTPoint.java deleted file mode 100755 index 5790f63b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTPoint.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * $Id: SGTPoint.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.util.GeoDate; - -/** - * Defines a data object to be of Point type. Interpretation - * of X and Y is determined by the CoordinateSystem. For - * Cartesian, X and Y are the Cartesian coordinates. For - * Polar, - * X and Y are R (radius) and Theta (angle), respectively. - * - * The SGTPoint interface only defines data access, not how - * the data will be constructed or set. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - * @see Cartesian - * @see Polar - * @see SimplePoint - */ -public interface SGTPoint extends SGTData { - /** - * Get the x coordinate. - */ - public double getX(); - /** - * Get the y coordinate. - */ - public double getY(); - /** - * Test if a value is associated with the SGTPoint. - */ - public boolean hasValue(); - /** - * Get the associated value. - */ - public double getValue(); - /** - * Get the SGTMetaData object associated with the value. - */ - public SGTMetaData getValueMetaData(); - /** - * Get the Time value. - */ - public GeoDate getTime(); - /** - * Get the time as long referenced from - * 1970-01-01. - * - * @since 3.0 - */ - public long getLongTime(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTTuple.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTTuple.java deleted file mode 100755 index 051ce1c1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTTuple.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * $Id: SGTTuple.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; -import gov.noaa.pmel.util.Range2D; - -/** - * Provides access to tuple organized data of either 2 or 3 dimensions. - * All arrays that are provided must be of equal length. - * Tuples can be used to provide un-structured 3-D data that can then - * be trianglulated to enable area fill or contouring. 3-d tuples - * are also useful in the construction of vectors. - * @since 2.x - */ -public interface SGTTuple extends SGTData { - public double[] getXArray(); - public double[] getYArray(); - public double[] getZArray(); - public int getSize(); - public GeoDate[] getTimeArray(); - /** - * Get the GeoDateArray object. - */ - public GeoDateArray getGeoDateArray(); - public double[] getAssociatedData(); - public boolean hasAssociatedData(); - public SGTMetaData getZMetaData(); - public Range2D getZRange(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTVector.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTVector.java deleted file mode 100755 index c7631537..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SGTVector.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * $Id: SGTVector.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.SoTRange; - -import java.beans.PropertyChangeListener; -import java.io.Serializable; - -/** - * Defines a data object to be a Vector. Interpretation - * of U and V is determined by the CoordinateSystem. For - * Cartesian, U and V are the Cartesian vector - * components. For Polar , - * U and V are R (radius) and Theta (angle) vector components, - * respectively. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTData - * @see CoordinateSystem - */ -public class SGTVector implements SGTData, Cloneable, Serializable { - String title_; - SGLabel keyTitle_ = null; - String id_ = null; - /**@shapeType AggregationLink - * @clientRole u comp*/ - SGTGrid uComp_; - /**@shapeType AggregationLink - * @clientRole v comp*/ - SGTGrid vComp_; - /** - * Default constructor. - */ - public SGTVector() { - } - /** - * Construct a SGTVector from two components. The two components - * must match in both SGTData and CoordinateSystem Interfaces. - * Both components must be the same shape. - * - * @param uComp U component of the vector - * @param vComp V component of the vector - */ - public SGTVector(SGTGrid uComp,SGTGrid vComp) { - uComp_ = uComp; - vComp_ = vComp; - } - /** - * Create a copy. Creates a shallow copy. - * - * @see SGTData - */ - public SGTData copy() { - SGTVector newSGTVector; - try { - newSGTVector = (SGTVector)clone(); - } catch (CloneNotSupportedException e) { - newSGTVector = new SGTVector(this.uComp_, this.vComp_); - } - return (SGTData)newSGTVector; - } - /** - * Get the U component. - * - * @return U component - */ - public SGTGrid getU() { - return uComp_; - } - /** - * Get the V component. - * - * @return V component - */ - public SGTGrid getV() { - return vComp_; - } - /** - * Set the U component. - * - * @param uComp U component - */ - public void setU(SGTGrid uComp) { - uComp_ = uComp; - } - /** - * Set the V component. - * - * @param vComp V component - */ - public void setV(SGTGrid vComp) { - vComp_ = vComp; - } - /** - * Set the vector components. - * - * @param uComp U component - * @param vComp V component - */ - public void setComponents(SGTGrid uComp, SGTGrid vComp) { - uComp_ = uComp; - vComp_ = vComp; - } - /** - * Set the vector's title. - * - * @param title - */ - public void setTitle(String title) { - title_ = title; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - /** Set the title formatted for the VectorKey. */ - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - /** - * Get the vector's title. - * - * @return the title - */ - public String getTitle() { - return title_; - } - public boolean isXTime() { - return uComp_.isXTime(); - } - public boolean isYTime() { - return uComp_.isYTime(); - } - public SGTMetaData getXMetaData() { - return uComp_.getXMetaData(); - } - public SGTMetaData getYMetaData() { - return uComp_.getYMetaData(); - } - public SoTRange getXRange() { - return uComp_.getXRange(); - } - public SoTRange getYRange() { - return uComp_.getYRange(); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - uComp_.addPropertyChangeListener(l); - vComp_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - uComp_.removePropertyChangeListener(l); - vComp_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleGrid.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleGrid.java deleted file mode 100755 index 007d9947..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleGrid.java +++ /dev/null @@ -1,488 +0,0 @@ -/** - * $Id: SimpleGrid.java,v 1.1.1.2 2008/12/19 13:29:38 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.SoTRange; - -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; -import java.io.Serializable; - -/** - * SimpleGrid provides an implementation of the - * SGTGrid and Cartesian interfaces. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.2 $, $Date: 2008/12/19 13:29:38 $ - * @since 1.0 - * @see SGTGrid - * @see Cartesian - */ -public class SimpleGrid implements SGTGrid, Cartesian, Cloneable, Serializable { -protected double[] xloc_; - protected double[] yloc_; -// protected GeoDate[] tloc_; - protected GeoDateArray tloc_; - protected double[] grid_; - protected double[] xEdges_; - protected double[] yEdges_; -// protected GeoDate[] tEdges_; - protected GeoDateArray tEdges_; - protected boolean hasXEdges_; - protected boolean hasYEdges_; - protected String title_; - protected SGLabel keyTitle_ = null; - protected String id_ = null; - protected boolean xTime_; - protected boolean yTime_; - /**@shapeType AggregationLink - * @clientRole x*/ - protected SGTMetaData xMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole y*/ - protected SGTMetaData yMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole z*/ - protected SGTMetaData zMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole associated data*/ - protected SGTGrid associatedData_; - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private SoTRange xEdgesRange_ = null; - private SoTRange yEdgesRange_ = null; - private Range2D zRange_ = null; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - - /** - * Default constructor. - */ - public SimpleGrid() { - this(null, (double[])null, (double[])null, ""); - } - /** - * Constructor for X and Y coordinates as double. - * - * @param grid Z values - * @param xloc X coordinates - * @param yloc Y coordinates - * @param title the title - */ - public SimpleGrid(double[] grid, double[] xloc, - double[] yloc, String title) { - grid_ = grid; - xloc_ = xloc; - yloc_ = yloc; - title_ = title; - xTime_ = false; - yTime_ = false; - hasXEdges_ = false; - hasYEdges_ = false; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(yloc); - zRange_ = computeRange2D(grid); - } - /** - * Constructor for X time and Y double. - * - * @param grid Z values - * @param tloc Time coordinates - * @param yloc Y coordinates - * @param title the title - */ - public SimpleGrid(double[] grid, GeoDate[] tloc, - double[] yloc,String title) { - grid_ = grid; - tloc_ = new GeoDateArray(tloc); - yloc_ = yloc; - title_ = title; - xTime_ = true; - yTime_ = false; - hasXEdges_ = false; - hasYEdges_ = false; - xRange_ = computeSoTRange(tloc_); - yRange_ = computeSoTRange(yloc); - zRange_ = computeRange2D(grid); - } - /** - * Constructor for X double and Y time. - * - * @param grid Z values - * @param xloc X coordinates - * @param tloc Time coordinates - * @param title the title - */ - public SimpleGrid(double[] grid, double[] xloc, - GeoDate[] tloc,String title) { - grid_ = grid; - xloc_ = xloc; - tloc_ = new GeoDateArray(tloc); - title_ = title; - xTime_ = false; - yTime_ = true; - hasXEdges_ = false; - hasYEdges_ = false; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(tloc_); - zRange_ = computeRange2D(grid); - } - /** - * Create a copy of the grid. - * - * @since 2.0 - * @see SGTData - */ - public SGTData copy() { - SGTGrid newGrid; - try { - newGrid = (SGTGrid)clone(); - } catch (CloneNotSupportedException e) { - newGrid = new SimpleGrid(); - } - return (SGTData)newGrid; - } - public double[] getXArray() { - return xloc_; - } - /** - * Get the length of the x axis - * - * @since 2.0 - */ - public int getXSize() { - return xloc_.length; - } - public double[] getYArray() { - return yloc_; - } - /** - * Get the length of the y axis - * - * @since 2.0 - */ - public int getYSize() { - return yloc_.length; - } - public double[] getZArray() { - return grid_; - } - public GeoDate[] getTimeArray() { - return tloc_.getGeoDate(); - } - /** - * Get the GeoDateArray object. - * - * @since 3.0 - */ - public GeoDateArray getGeoDateArray() { - return tloc_; - } - /** - * Get the length of the Time axis - * - * @since 2.0 - */ - public int getTSize() { - return tloc_.getLength(); - } - public boolean isXTime() { - return xTime_; - } - public boolean isYTime() { - return yTime_; - } - public SGTMetaData getXMetaData() { - return xMetaData_; - } - public SGTMetaData getYMetaData() { - return yMetaData_; - } - public SGTMetaData getZMetaData() { - return zMetaData_; - } - public String getTitle() { - return title_; - } - /** - * Set the associated data grid. - *
Property Change: associatedDataModified. - * - * @since 2.0 - */ - public void setAssociatedData(SGTGrid assoc) { - associatedData_ = assoc; - changes_.firePropertyChange("associatedDataModified", - null, - assoc); - } - public SGTGrid getAssociatedData() { - return associatedData_; - } - public boolean hasAssociatedData() { - return (associatedData_ != null); - } - public boolean hasXEdges() { - return hasXEdges_; - } - public double[] getXEdges() { - return xEdges_; - } - /** - * Set the values for the x grid edges. - */ - public void setXEdges(double[] edge) { - xEdges_ = edge; - hasXEdges_ = true; - xEdgesRange_ = computeSoTRange(edge); - } - public boolean hasYEdges() { - return hasYEdges_; - } - public double[] getYEdges() { - return yEdges_; - } - /** - * Set the values for the y grid edges. - */ - public void setYEdges(double[] edge) { - yEdges_ = edge; - hasYEdges_ = true; - yEdgesRange_ = computeSoTRange(edge); - } - public GeoDate[] getTimeEdges() { - return tEdges_.getGeoDate(); - } - /** - * Get the GeoDateArray object. - * - * @since 3.0 - */ - public GeoDateArray getGeoDateArrayEdges() { - return tEdges_; - } - /** - * Set the values for the temporal grid edges. - */ - public void setTimeEdges(GeoDate[] edge) { - setTimeEdges(new GeoDateArray(edge)); - } - /** - * @since 3.0 - */ - public void setTimeEdges(GeoDateArray tarray) { - tEdges_ = tarray; - if(xTime_) { - hasXEdges_ = true; - xEdgesRange_ = computeSoTRange(tarray); - } else if(yTime_){ - hasYEdges_ = true; - yEdgesRange_ = computeSoTRange(tarray); - } - } - /** - * Set the SGTMetaData associated with the x - * coordinate. - */ - public void setXMetaData(SGTMetaData md) { - xMetaData_ = md; - } - /** - * Set the SGTMetaData associated with the y - * coordinate. - */ - public void setYMetaData(SGTMetaData md) { - yMetaData_ = md; - } - /** - * Set the SGTMetaData associated with the z - * coordinate. - */ - public void setZMetaData(SGTMetaData md) { - zMetaData_ = md; - } - /** - * Set the grid title - */ - public void setTitle(String title) { - title_ = title; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - /** Set the title formatted for the VectorKey. */ - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @since 2.0 - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - /** - * Set the x coordinate grid centers - *
Property Change: dataModified. - */ - public void setXArray(double[] xloc) { - xloc_ = xloc; - xTime_ = false; - xRange_ = computeSoTRange(xloc); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(xloc.length)); - } - /** - * Set the y coordinate grid centers - *
Property Change: dataModified. - */ - public void setYArray(double[] yloc) { - yloc_ = yloc; - yTime_ = false; - yRange_ = computeSoTRange(yloc); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(yloc.length)); - } - /** - * Set the z grid values. - *
Property Change: dataModified. - */ - public void setZArray(double[] grid) { - grid_ = grid; - zRange_ = computeRange2D(grid); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(grid.length)); - } - /** - * set the temporal grid centers - *
Property Change: dataModified. - */ - public void setTimeArray(GeoDate[] tloc) { - setTimeArray(new GeoDateArray(tloc)); - } - /** - * @since 3.0 - */ - public void setTimeArray(GeoDateArray tarray) { - tloc_ = tarray; - if(xTime_) { - xRange_ = computeSoTRange(tarray); - } else if(yTime_) { - yRange_ = computeSoTRange(tarray); - } - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(tarray.getLength())); - } - public SoTRange getXRange() { - return xRange_.copy(); - } - public SoTRange getYRange() { - return yRange_.copy(); - } - public Range2D getZRange() { - return zRange_; - } - /** - * Return the range of the x edges - * - * @since 2.0 - */ - public SoTRange getXEdgesRange() { - return xEdgesRange_; - } - /** - * Return the range of the y edges - * - * @since 2.0 - */ - public SoTRange getYEdgesRange() { - return yEdgesRange_; - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - - private SoTRange computeSoTRange(double[] array) { - Range2D range = computeRange2D(array); - return new SoTRange.Double(range.start, range.end); - } - private SoTRange computeSoTRange(GeoDateArray tarray) { - long start = Long.MAX_VALUE; - long end = Long.MIN_VALUE; - long[] tar = tarray.getTime(); - int count = 0; - for(int i=0; i < tar.length; i++) { - if(!(tar[i] == Long.MAX_VALUE)) { - start = Math.min(start, tar[i]); - end = Math.max(end, tar[i]); - count++; - } - } - if(count == 0) { - return new SoTRange.Time(Long.MAX_VALUE, - Long.MAX_VALUE); - } else { - return new SoTRange.Time(start, end); - } - } - private Range2D computeRange2D(double[] array) { - double start = Double.POSITIVE_INFINITY; - double end = Double.NEGATIVE_INFINITY; - int count = 0; - for(int i=0; i < array.length; i++) { - if(!Double.isNaN(array[i])) { - start = Math.min(start, array[i]); - end = Math.max(end, array[i]); - count++; - } - } - if(count == 0) { - return new Range2D(Double.NaN, Double.NaN); - } else { - return new Range2D(start, end); - } - } - public void finalize() throws Throwable { - super.finalize(); - xloc_ = null; - yloc_ = null; - grid_ = null; - xEdges_ = null; - yEdges_ = null; - changes_ = null; - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleLine.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleLine.java deleted file mode 100755 index 171195cc..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleLine.java +++ /dev/null @@ -1,377 +0,0 @@ -/** - * $Id: SimpleLine.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; -import gov.noaa.pmel.util.SoTRange; - -import java.io.Serializable; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; - -/** - * SimpleLine provides an implementation of the - * SGTLine and Cartesian interfaces. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTLine - * @see Cartesian - */ -public class SimpleLine implements SGTLine, Cartesian, - Serializable, Cloneable { - protected double[] xloc_; - protected double[] yloc_; -// protected GeoDate[] tloc_; - protected GeoDateArray tloc_; - protected boolean xTime_; - protected boolean yTime_; - protected String title_; - protected SGLabel keyTitle_ = null; - protected String id_ = null; - /**@shapeType AggregationLink - * @clientRole x*/ - protected SGTMetaData xMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole y*/ - protected SGTMetaData yMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole associated data*/ - protected SGTLine associatedData_ = null; - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - /** - * Default constuctor. - */ - public SimpleLine() { - this((double[])null, (double[])null, ""); - } - /** - * Constructor for X and Y double. - * - * @param xloc X coordinates - * @param yloc Y coordinates - * @param title the Title - */ - public SimpleLine(double[] xloc,double[] yloc,String title) { - xloc_ = xloc; - yloc_ = yloc; - title_ = title; - xTime_ = false; - yTime_ = false; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(yloc); - } - /** - * Constructor for X Time and Y double. - * - * @param tloc Time coordinates - * @param yloc Y coordinates - * @param title the Title - */ - public SimpleLine(GeoDate[] tloc, double[] yloc, String title) { - tloc_ = new GeoDateArray(tloc); - yloc_ = yloc; - title_ = title; - xTime_ = true; - yTime_ = false; - xRange_ = computeSoTRange(tloc_); - yRange_ = computeSoTRange(yloc); - } - /** - * Constructor for X Time and Y double. - * - * @since 3.0 - * @param tloc Time coordinates - * @param yloc Y coordinates - * @param title the Title - */ - public SimpleLine(GeoDateArray tloc, double[] yloc, String title) { - tloc_ = tloc; - yloc_ = yloc; - title_ = title; - xTime_ = true; - yTime_ = false; - xRange_ = computeSoTRange(tloc_); - yRange_ = computeSoTRange(yloc); - } - /** - * Constructor for X double and Y Time. - * - * @since 3.0 - * @param xloc X coordinates - * @param tloc Time coordinates - * @param title the Title - */ - public SimpleLine(double[] xloc, GeoDateArray tloc, String title) { - xloc_ = xloc; - tloc_ = tloc; - title_ = title; - xTime_ = false; - yTime_ = true; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(tloc_); - } - /** - * Constructor for X double and Y Time. - * - * @param xloc X coordinates - * @param tloc Time coordinates - * @param title the Title - */ - public SimpleLine(double[] xloc, GeoDate[] tloc, String title) { - xloc_ = xloc; - tloc_ = new GeoDateArray(tloc); - title_ = title; - xTime_ = false; - yTime_ = true; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(tloc_); - } - /** - * Create a shallow copy. - * - * @since 2.0 - * @see SGTData - */ - public SGTData copy(){ - SGTLine newLine; - try { - newLine = (SGTLine)clone(); - } catch (CloneNotSupportedException e) { - newLine = new SimpleLine(); - } - return (SGTData)newLine; - } - /** - * Get the X coordinate array. - */ - public double[] getXArray() { - return xloc_; - } - /** - * Get the Y coordinate array. - */ - public double[] getYArray() { - return yloc_; - } - /** - * Get the Time coordinate array. - */ - public GeoDate[] getTimeArray() { - return tloc_.getGeoDate(); - } - /** - * Get the GeoDateArray object. - * - * @since 3.0 - */ - public GeoDateArray getGeoDateArray() { - return tloc_; - } - /** - * Is the X coordinate Time? - */ - public boolean isXTime() { - return xTime_; - } - /** - * Is the Y coordinate Time? - */ - public boolean isYTime() { - return yTime_; - } - /** - * Get the X coordinate metadata. - */ - public SGTMetaData getXMetaData() { - return xMetaData_; - } - /** - * Get the Y coordinate metadata - */ - public SGTMetaData getYMetaData() { - return yMetaData_; - } - /** - * Get the Title. - */ - public String getTitle() { - return title_; - } - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @since 2.0 - * @return unique identifier - * @see gov.noaa.pmel.sgt.JPane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - /** - * Set the data that will be associated with SGTLine - *
Property Change: associatedDataModified. - * - * @since 2.0 - */ - public void setAssociatedData(SGTLine assoc) { - associatedData_ = assoc; - changes_.firePropertyChange("associatedDataModified", - null, - assoc); - } - /** - * Get the associated data. - */ - public SGTLine getAssociatedData() { - return associatedData_; - } - /** - * Is there associated data? - */ - public boolean hasAssociatedData() { - return (associatedData_ != null); - } - /** - * Set the X coordinate metadata. - */ - public void setXMetaData(SGTMetaData md) { - xMetaData_ = md; - } - /** - * Set the Y coordinate metadata. - */ - public void setYMetaData(SGTMetaData md) { - yMetaData_ = md; - } - /** - * Set the title. - */ - public void setTitle(String title) { - title_ = title; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - /** Set the title formatted for the VectorKey. */ - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - /** - * Set the X coordinate array. - *
Property Change: dataModified. - */ - public void setXArray(double[] xloc) { - xloc_ = xloc; - xTime_ = false; - xRange_ = computeSoTRange(xloc); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(xloc.length)); - } - /** - * Set the Y coordinate array - *
Property Change: dataModified. - */ - public void setYArray(double[] yloc) { - yloc_ = yloc; - yTime_ = false; - yRange_ = computeSoTRange(yloc); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(yloc.length)); - } - /** - * Set the Time coordinate array - *
Property Change: dataModified. - */ - public void setTimeArray(GeoDate[] tloc) { - setTimeArray(new GeoDateArray(tloc)); - } - /** - * @since 3.0 - */ - public void setTimeArray(GeoDateArray tarray) { - tloc_ = tarray; - if(xTime_) { - xRange_ = computeSoTRange(tarray); - } else if(yTime_) { - yRange_ = computeSoTRange(tarray); - } - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(tarray.getLength())); - } - public SoTRange getXRange() { - return xRange_.copy(); - } - public SoTRange getYRange() { - return yRange_.copy(); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - private SoTRange computeSoTRange(double[] array) { - double dstart = Double.POSITIVE_INFINITY; - double dend = Double.NEGATIVE_INFINITY; - int count = 0; - for(int i=0; i < array.length; i++) { - if(!Double.isNaN(array[i])) { - dstart = Math.min(dstart, array[i]); - dend = Math.max(dend, array[i]); - count++; - } - } - if(count == 0) { - return new SoTRange.Double(Double.NaN, Double.NaN); - } else { - return new SoTRange.Double(dstart, dend); - } - } - private SoTRange computeSoTRange(GeoDateArray tarray) { - long tstart = Long.MAX_VALUE; - long tend = Long.MIN_VALUE; - long[] tar = tarray.getTime(); - int count = 0; - for(int i=0; i < tar.length; i++) { - if(!(tar[i] == Long.MAX_VALUE)) { - tstart = Math.min(tstart, tar[i]); - tend = Math.max(tend, tar[i]); - count++; - } - } - if(count == 0) { - return new SoTRange.Time(Long.MAX_VALUE, - Long.MAX_VALUE); - } else { - return new SoTRange.Time(tstart, tend); - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimplePoint.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimplePoint.java deleted file mode 100755 index 503d7bd5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimplePoint.java +++ /dev/null @@ -1,313 +0,0 @@ -/** - * $Id: SimplePoint.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.InvalidMethodError; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTValue; - -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; -import java.io.Serializable; - -/** - * SimplePoint provides an implementation of the - * SGTPoint and Cartesian interfaces. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTPoint - * @see Cartesian -*/ -public class SimplePoint implements SGTPoint, Cartesian, Cloneable, Serializable { - protected double xloc_ = Double.NaN; - protected double yloc_ = Double.NaN; - protected long tloc_; - protected boolean xTime_ = false; - protected boolean yTime_ = false; - protected double value_; - protected String title_; - protected SGLabel keyTitle_ = null; - protected String id_ = null; - /**@shapeType AggregationLink - * @clientRole value*/ - protected SGTMetaData valueMetaData_; - - /** - * @link aggregation - * @clientRole x - */ - protected SGTMetaData xMetaData_; - - /** - * @link aggregation - * @clientRole y*/ - protected SGTMetaData yMetaData_; - protected boolean hasValue_ = false; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - /** - * Default constructor. - */ - public SimplePoint() { - } - /** - * Simple Point constructor. - * - * @param xloc X coordinate - * @param yloc Y coordinate - * @param title the title - */ - public SimplePoint(double xloc,double yloc,String title) { - xloc_ = xloc; - yloc_ = yloc; - title_ = title; - } - /** - * Simple Point constructor. - * - * @since 3.0 - * - * @param loc SoTPoint - * @param title the title - */ - public SimplePoint(SoTPoint loc, String title) { - xTime_ = loc.isXTime(); - yTime_ = loc.isYTime(); - if(xTime_) { - tloc_ = loc.getX().getLongTime(); - } else { - xloc_ = ((Number)loc.getX().getObjectValue()).doubleValue(); - } - if(yTime_) { - tloc_ = loc.getY().getLongTime(); - } else { - yloc_ = ((Number)loc.getY().getObjectValue()).doubleValue(); - } - title_ = title; - } - /** - * Create a copy. - * - * @since 2.0 - * @see SGTData - */ - public SGTData copy() { - SGTPoint newPoint; - try { - newPoint = (SGTPoint)clone(); - } catch (CloneNotSupportedException e) { - newPoint = new SimplePoint(); - } - return (SGTData)newPoint; - } - /** - * Get the X coordinate. - */ - public double getX() { - return xloc_; - } - /** - * Get the Y coordinate - */ - public double getY() { - return yloc_; - } - /** - * Get the associated value. - */ - public double getValue() { - return value_; - } - /** - * Is there an associated value? - */ - public boolean hasValue() { - return hasValue_; - } - /** - * Get the time coordinate. - */ - public GeoDate getTime() { - return new GeoDate(tloc_); - } - /** - * Get the time in long referenced - * to 1970-01-01 - * - * @since 3.0 - */ - public long getLongTime() { - return tloc_; - } - /** - * Set the time coordinate - * - * @since 3.0 - */ - public void setTime(GeoDate date) { - setTime(date.getTime()); - } - /** - * @since 3.0 - */ - public void setTime(long t) { - long old = tloc_; - tloc_ = t; - changes_.firePropertyChange("dataModified", - new Long(old), - new Long(tloc_)); - } - /** - * Is the X coordinate Time? - */ - public boolean isXTime() { - return xTime_; - } - /** - * Is the Y coordinate Time? - */ - public boolean isYTime() { - return yTime_; - } - /** - * Get the title. - */ - public String getTitle() { - return title_; - } - /** - * Set the title. - */ - public void setTitle(String title) { - title_ = title; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - /** Set the title formatted for the VectorKey. */ - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @since 2.0 - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - /** - * Get the associated value SGTMetaData. - */ - public SGTMetaData getValueMetaData() { - return valueMetaData_; - } - /** - * Set the X coordinate. - *
Property Change: dataModified. - */ - public void setX(double xloc) { - double old = xloc_; - xloc_ = xloc; - changes_.firePropertyChange("dataModified", - new Double(old), - new Double(xloc_)); - } - /** - * Set the Y coordinate. - *
Property Change: dataModified. - */ - public void setY(double yloc) { - double old = yloc_; - yloc_ = yloc; - changes_.firePropertyChange("dataModified", - new Double(old), - new Double(yloc_)); - } - /** - * The the associated value and basic metadata. - *
Property Change: associatedDataModified. - * - * @param value associated data - * @param name values name - * @param units values units - */ - public void setValue(double value,String name,String units) { - double old = value_; - value_ = value; - valueMetaData_ = new SGTMetaData(name, units); - hasValue_ = true; - changes_.firePropertyChange("associatedDataModified", - new Double(old), - new Double(value_)); - } - /** - * Set the SGTMetaData associated with the x - * coordinate - * - * @since 2.0 - */ - public void setXMetaData(SGTMetaData md) { - xMetaData_ = md; - } - /** - * Set the SGTMetaData associated with the y - * coordinate - * - * @since 2.0 - */ - public void setYMetaData(SGTMetaData md) { - yMetaData_ = md; - } - public SGTMetaData getXMetaData() { - return xMetaData_; - } - public SGTMetaData getYMetaData() { - return yMetaData_; - } - public SoTRange getXRange() { - if(xTime_) { - return new SoTRange.Time(tloc_, tloc_); - } else { - return new SoTRange.Double(xloc_, xloc_); - } - } - public SoTRange getYRange() { - if(yTime_) { - return new SoTRange.Time(tloc_, tloc_); - } else { - return new SoTRange.Double(yloc_, yloc_); - } - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleTuple.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleTuple.java deleted file mode 100755 index 1b9a5d84..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/SimpleTuple.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * $Id: SimpleTuple.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.GeoDateArray; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.Range2D; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -/** - * SimpleTuple provides an implementation of the - * SGTTuple and Cartesian interfaces. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.x - * @see SGTTuple - * @see Cartesian - */ -public class SimpleTuple implements Cloneable, SGTTuple, Cartesian, Serializable { - private boolean xTime_ = false; - private boolean yTime_ = false; - private String title_ = null; - private SGLabel keyTitle_ = null; - private String id_ = null; - private double[] xArray_ = null; - private double[] yArray_ = null; -// private GeoDate[] tArray_ = null; - private GeoDateArray tArray_ = null; - private double[] zArray_ = null; - private double[] assocArray_ = null; - - /** - * @link aggregation - * @clientRole x - */ - protected SGTMetaData xMetaData_ = null; - - /** - * @link aggregation - * @clientRole y - */ - protected SGTMetaData yMetaData_ = null; - - /** - * @link aggregation - * @clientRole z*/ - protected SGTMetaData zMetaData_ = null; - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private Range2D zRange_ = null; - - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - - public SimpleTuple(double[] xArray, double[] yArray, String title) { - xArray_ = xArray; - yArray_ = yArray; - xTime_ = false; - yTime_ = false; - title_ = title; - xRange_ = computeSoTRange(xArray); - yRange_ = computeSoTRange(yArray); - } - - public SimpleTuple(GeoDate[] xArray, double[] yArray, String title) { - tArray_ = new GeoDateArray(xArray); - yArray_ = yArray; - xTime_ = true; - yTime_ = false; - title_ = title; - xRange_ = computeSoTRange(tArray_); - yRange_ = computeSoTRange(yArray); - } - - public SimpleTuple(double[] xArray, GeoDate[] yArray, String title) { - xArray_ = xArray; - tArray_ = new GeoDateArray(yArray); - xTime_ = false; - yTime_ = true; - title_ = title; - xRange_ = computeSoTRange(xArray); - yRange_ = computeSoTRange(tArray_); - } - - public SimpleTuple(double[] xArray, double[] yArray, - double[] zArray, String title) { - xArray_ = xArray; - yArray_ = yArray; - zArray_ = zArray; - xTime_ = false; - yTime_ = false; - title_ = title; - xRange_ = computeSoTRange(xArray); - yRange_ = computeSoTRange(yArray); - zRange_ = computeRange2D(zArray); - } - - public SimpleTuple(GeoDate[] xArray, double[] yArray, - double[] zArray, String title) { - tArray_ = new GeoDateArray(xArray); - yArray_ = yArray; - zArray_ = zArray; - xTime_ = true; - yTime_ = false; - title_ = title; - xRange_ = computeSoTRange(tArray_); - yRange_ = computeSoTRange(yArray); - zRange_ = computeRange2D(zArray); - } - - public SimpleTuple(double[] xArray, GeoDate[] yArray, - double[] zArray, String title) { - xArray_ = xArray; - tArray_ = new GeoDateArray(yArray); - zArray_ = zArray; - xTime_ = false; - yTime_ = true; - title_ = title; - xRange_ = computeSoTRange(xArray); - yRange_ = computeSoTRange(tArray_); - zRange_ = computeRange2D(zArray); - } - - public SimpleTuple() { - xTime_ = false; - yTime_ = false; - } - - public double[] getXArray() { - return xArray_; - } - - public void setXArray(double[] xArray) { - xArray_ = xArray; - xTime_ = false; - xRange_ = computeSoTRange(xArray); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(xArray.length)); - } - - public void setXArray(GeoDate[] tArray) { - setXArray(new GeoDateArray(tArray)); - } - /** - * @since 3.0 - */ - public void setXArray(GeoDateArray tArray) { - tArray_ = tArray; - xTime_ = true; - xArray_ = null; - xRange_ = computeSoTRange(tArray); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(tArray.getLength())); - } - - public double[] getYArray() { - return yArray_; - } - - public void setYArray(double[] yArray) { - yArray_ = yArray; - yTime_ = false; - yRange_ = computeSoTRange(yArray); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(yArray.length)); - } - - public void setYArray(GeoDate[] tArray) { - setYArray(new GeoDateArray(tArray)); - } - /** - * @since 3.0 - */ - public void setYArray(GeoDateArray tArray) { - tArray_ = tArray; - yTime_ = true; - yArray_ = null; - yRange_ = computeSoTRange(tArray); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(tArray.getLength())); - } - public double[] getZArray() { - return zArray_; - } - - public void setZArray(double[] zArray) { - zArray_ = zArray; - zRange_ = computeRange2D(zArray); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(zArray.length)); - } - - public int getSize() { - if(xTime_) { - return tArray_.getLength(); - } else { - return xArray_.length; - } - } - - public GeoDate[] getTimeArray() { - return tArray_.getGeoDate(); - } - /** - * @since 3.0 - */ - public GeoDateArray getGeoDateArray() { - return tArray_; - } - - public double[] getAssociatedData() { - return assocArray_; - } - - public void setAssociatedData(double[] assocArray) { - assocArray_ = assocArray; - } - - public boolean hasAssociatedData() { - return (assocArray_ != null); - } - - public SGTMetaData getZMetaData() { - return zMetaData_; - } - - public void setZMetaData(SGTMetaData zMeta) { - zMetaData_ = zMeta; - } - - public String getTitle() { - return title_; - } - - public void setTitle(String title) { - title_ = title; - } - - public SGLabel getKeyTitle() { - return keyTitle_; - } - - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - - public String getId() { - return id_; - } - - public void setId(String id) { - id_ = id; - } - - public SGTData copy() { - SGTTuple newTuple; - try { - newTuple = (SGTTuple)clone(); - } catch (CloneNotSupportedException e) { - newTuple = new SimpleTuple(); - } - return (SGTData)newTuple; - } - - public boolean isXTime() { - return xTime_; - } - - public boolean isYTime() { - return yTime_; - } - - public SGTMetaData getXMetaData() { - return xMetaData_; - } - - public void setXMetaData(SGTMetaData xMeta) { - xMetaData_ = xMeta; - } - - public SGTMetaData getYMetaData() { - return yMetaData_; - } - - public void setYMetaData(SGTMetaData yMeta) { - yMetaData_ = yMeta; - } - - public SoTRange getXRange() { - return xRange_; - } - - public SoTRange getYRange() { - return yRange_; - } - - public Range2D getZRange() { - return zRange_; - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - - private SoTRange computeSoTRange(double[] array) { - Range2D range = computeRange2D(array); - return new SoTRange.Double(range.start, range.end); - } - - private SoTRange computeSoTRange(GeoDateArray tarray) { - long start = Long.MAX_VALUE; - long end = Long.MIN_VALUE; - long[] tar = tarray.getTime(); - int count = 0; - for(int i=0; i < tar.length; i++) { - if(!(tar[i] == Long.MAX_VALUE)) { - start = Math.min(start, tar[i]); - end = Math.max(end, tar[i]); - count++; - } - } - if(count == 0) { - return new SoTRange.Time(Long.MAX_VALUE, - Long.MAX_VALUE); - } else { - return new SoTRange.Time(start, end); - } - } - - private Range2D computeRange2D(double[] array) { - double start = Double.POSITIVE_INFINITY; - double end = Double.NEGATIVE_INFINITY; - int count = 0; - for(int i=0; i < array.length; i++) { - if(!Double.isNaN(array[i])) { - start = Math.min(start, array[i]); - end = Math.max(end, array[i]); - count++; - } - } - if(count == 0) { - return new Range2D(Double.NaN, Double.NaN); - } else { - return new Range2D(start, end); - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/ThreeDGrid.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/ThreeDGrid.java deleted file mode 100755 index 083d52a3..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/ThreeDGrid.java +++ /dev/null @@ -1,584 +0,0 @@ -/** - * $Id: ThreeDGrid.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.dm; - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.SoTRange; - -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; -import java.io.Serializable; - -/** - * ThreeDGrid provides an implementation of the - * SGT3DGrid and Cartesian interfaces. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 1.0 - * @see SGTGrid - * @see Cartesian - */ -public class ThreeDGrid implements SGT3DGrid, Cartesian, Cloneable, Serializable { - protected double[] xloc_; - protected double[] yloc_; - protected double[] zloc_; - protected GeoDate[] tloc_; - protected double[] grid_; - protected double[] xEdges_; - protected double[] yEdges_; - protected double[] zEdges_; - protected GeoDate[] tEdges_; - protected boolean hasXEdges_; - protected boolean hasYEdges_; - protected boolean hasZEdges_; - protected String title_; - protected SGLabel keyTitle_ = null; - protected String id_ = null; - protected boolean xTime_; - protected boolean yTime_; - protected boolean zTime_; - /**@shapeType AggregationLink - * @clientRole x*/ - protected SGTMetaData xMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole y*/ - protected SGTMetaData yMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole z*/ - protected SGTMetaData zMetaData_ = null; - /**@shapeType AggregationLink - * @clientRole associated data*/ - protected SGTMetaData valMetaData_ = null; - protected SGTGrid associatedData_; - private SoTRange xRange_ = null; - private SoTRange yRange_ = null; - private SoTRange zRange_ = null; - private SoTRange xEdgesRange_ = null; - private SoTRange yEdgesRange_ = null; - private SoTRange zEdgesRange_ = null; - private Range2D valRange_ = null; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - - /** - * Default constructor. - */ - public ThreeDGrid() { - //this(null, (double[])null, (double[])null, (double[])null, ""); - } - - /** - * Constructor for X, Y, and Z coordinates as double. - * - * @param grid Z values - * @param xloc X coordinates - * @param yloc Y coordinates - * @param zloc Z coordinates - * @param title the title - */ - public ThreeDGrid(double[] grid, double[] xloc, - double[] yloc, double[] zloc, String title) { - grid_ = grid; - xloc_ = xloc; - yloc_ = yloc; - zloc_ = zloc; - title_ = title; - xTime_ = false; - yTime_ = false; - zTime_ = false; - hasXEdges_ = false; - hasYEdges_ = false; - hasZEdges_ = false; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(yloc); - zRange_ = computeSoTRange(yloc); - valRange_ = computeRange2D(grid); - } - - /** - * Constructor for X time and Y, Z double. - * - * @param grid values - * @param tloc Time coordinates - * @param yloc Y coordinates - * @param zloc Z coordinates - * @param title the title - */ - public ThreeDGrid(double[] grid, GeoDate[] tloc, - double[] yloc, double[] zloc, String title) { - grid_ = grid; - tloc_ = tloc; - yloc_ = yloc; - zloc_ = zloc; - title_ = title; - xTime_ = true; - yTime_ = false; - zTime_ = false; - hasXEdges_ = false; - hasYEdges_ = false; - hasZEdges_ = false; - xRange_ = computeSoTRange(tloc); - yRange_ = computeSoTRange(yloc); - zRange_ = computeSoTRange(zloc); - valRange_ = computeRange2D(grid); - } - /** - * Constructor for X, Z double and Y time. - * - * @param grid values - * @param xloc X coordinates - * @param xloc Z coordinates - * @param tloc Time coordinates - * @param title the title - */ - public ThreeDGrid(double[] grid, double[] xloc, - GeoDate[] tloc,double[] zloc, String title) { - grid_ = grid; - xloc_ = xloc; - tloc_ = tloc; - zloc_ = zloc; - title_ = title; - xTime_ = false; - yTime_ = true; - zTime_ = false; - hasXEdges_ = false; - hasYEdges_ = false; - hasZEdges_ = false; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(tloc); - zRange_ = computeSoTRange(zloc); - valRange_ = computeRange2D(grid); - } - - /** - * Constructor for X double and Y double, and Z time. - * - * @param grid Z values - * @param xloc X coordinates - * @param tloc Time coordinates - * @param title the title - */ - public ThreeDGrid(double[] grid, double[] xloc, - double[] yloc, GeoDate[] tloc, String title) { - grid_ = grid; - xloc_ = xloc; - yloc_ = yloc; - tloc_ = tloc; - title_ = title; - xTime_ = false; - yTime_ = false; - zTime_ = true; - hasXEdges_ = false; - hasYEdges_ = false; - hasZEdges_ = false; - xRange_ = computeSoTRange(xloc); - yRange_ = computeSoTRange(yloc); - zRange_ = computeSoTRange(tloc); - valRange_ = computeRange2D(grid); - } - - /** - * Create a copy of the grid. - * - * @since 2.0 - * @see SGTData - */ - public SGTData copy() { - SGT3DGrid newGrid; - try { - newGrid = (SGT3DGrid)clone(); - } catch (CloneNotSupportedException e) { - newGrid = new ThreeDGrid(); - } - return (SGTData)newGrid; - } - - public double[] getXArray() { - return xloc_; - } - - /** - * Get the length of the x axis - * - * @since 2.0 - */ - public int getXSize() { - return xloc_.length; - } - - public double[] getYArray() { - return yloc_; - } - /** - * Get the length of the y axis - * - * @since 2.0 - */ - - public int getYSize() { - return yloc_.length; - } - - public double[] getZArray() { - return zloc_; - } - - public int getZSize() { - return zloc_.length; - } - - public double[] getValArray() { - return grid_; - } - - public int getValArraySize() { - return grid_.length; - } - - public GeoDate[] getTimeArray() { - return tloc_; - } - /** - * Get the length of the Time axis - * - * @since 2.0 - */ - public int getTSize() { - return tloc_.length; - } - public boolean isXTime() { - return xTime_; - } - public boolean isYTime() { - return yTime_; - } - public boolean isZTime() { - return zTime_; - } - public void setXTime(boolean flag) { - xTime_ = flag; - } - public void setYTime(boolean flag) { - yTime_= flag; - } - public void setZTime(boolean flag) { - zTime_= flag; - } - public SGTMetaData getXMetaData() { - return xMetaData_; - } - public SGTMetaData getYMetaData() { - return yMetaData_; - } - public SGTMetaData getZMetaData() { - return zMetaData_; - } - public SGTMetaData getValMetaData() { - return valMetaData_; - } - public String getTitle() { - return title_; - } - /** - * Set the associated data grid. - *
Property Change: associatedDataModified. - * - * @since 2.0 - */ - public void setAssociatedData(SGTGrid assoc) { - associatedData_ = assoc; - changes_.firePropertyChange("associatedDataModified", - null, - assoc); - } - public SGTGrid getAssociatedData() { - return associatedData_; - } - public boolean hasAssociatedData() { - return (associatedData_ != null); - } - public boolean hasXEdges() { - return hasXEdges_; - } - public double[] getXEdges() { - return xEdges_; - } - - public boolean hasZEdges() { - return hasZEdges_; - } - /** - * Set the values for the z grid edges. - */ - public void setZEdges(double[] edge) { - zEdges_ = edge; - hasZEdges_ = true; - zEdgesRange_ = computeSoTRange(edge); - } - - public double[] getZEdges() { - return zEdges_; - } - /** - * Set the values for the x grid edges. - */ - public void setXEdges(double[] edge) { - xEdges_ = edge; - hasXEdges_ = true; - xEdgesRange_ = computeSoTRange(edge); - } - public boolean hasYEdges() { - return hasYEdges_; - } - public double[] getYEdges() { - return yEdges_; - } - /** - * Set the values for the y grid edges. - */ - public void setYEdges(double[] edge) { - yEdges_ = edge; - hasYEdges_ = true; - yEdgesRange_ = computeSoTRange(edge); - } - public GeoDate[] getTimeEdges() { - return tEdges_; - } - /** - * Set the values for the temporal grid edges. - */ - public void setTimeEdges(GeoDate[] edge) { - tEdges_ = edge; - if (xTime_) { - hasXEdges_ = true; - xEdgesRange_ = computeSoTRange(edge); - } - else if(yTime_){ - hasYEdges_ = true; - yEdgesRange_ = computeSoTRange(edge); - } - else if(zTime_){ - hasZEdges_ = true; - zEdgesRange_ = computeSoTRange(edge); - } - } - /** - * Set the SGTMetaData associated with the x - * coordinate. - */ - public void setXMetaData(SGTMetaData md) { - xMetaData_ = md; - } - /** - * Set the SGTMetaData associated with the y - * coordinate. - */ - public void setYMetaData(SGTMetaData md) { - yMetaData_ = md; - } - /** - * Set the SGTMetaData associated with the z - * coordinate. - */ - public void setZMetaData(SGTMetaData md) { - zMetaData_ = md; - } - /** - * Set the SGTMetaData associated with the z - * coordinate. - */ - public void setValMetaData(SGTMetaData md) { - valMetaData_ = md; - } - /** - * Set the grid title - */ - public void setTitle(String title) { - title_ = title; - } - public SGLabel getKeyTitle() { - return keyTitle_; - } - /** Set the title formatted for the VectorKey. */ - public void setKeyTitle(SGLabel title) { - keyTitle_ = title; - } - /** - * Get the unique identifier. The presence of the identifier - * is optional, but if it is present it should be unique. This - * field is used to search for the layer that contains the data. - * - * @since 2.0 - * @return unique identifier - * @see gov.noaa.pmel.sgt.Pane - * @see gov.noaa.pmel.sgt.Layer - */ - public String getId() { - return id_; - } - /** - * Set the unique identifier. - */ - public void setId(String ident) { - id_ = ident; - } - /** - * Set the x coordinate grid centers - *
Property Change: dataModified. - */ - public void setXArray(double[] xloc) { - xloc_ = xloc; - xTime_ = false; - xRange_ = computeSoTRange(xloc); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(xloc.length)); - } - /** - * Set the y coordinate grid centers - *
Property Change: dataModified. - */ - public void setYArray(double[] yloc) { - yloc_ = yloc; - yTime_ = false; - yRange_ = computeSoTRange(yloc); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(yloc.length)); - } - /** - * Set the z coordinate grid centers - *
Property Change: dataModified. - */ - public void setZArray(double[] zloc) { - zloc_ = zloc; - zTime_ = false; - zRange_ = computeSoTRange(zloc); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(zloc.length)); - } - /** - * Set the z grid values. - *
Property Change: dataModified. - */ - public void setValArray(double[] grid) { - grid_ = grid; - valRange_ = computeRange2D(grid); - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(grid.length)); - } - /** - * set the temporal grid centers - *
Property Change: dataModified. - */ - public void setTimeArray(GeoDate[] tloc) { - tloc_ = tloc; - if (xTime_) { - xRange_ = computeSoTRange(tloc); - } - else if(yTime_) { - yRange_ = computeSoTRange(tloc); - } - else if(zTime_) { - zRange_ = computeSoTRange(tloc); - } - changes_.firePropertyChange("dataModified", - new Integer(0), - new Integer(tloc.length)); - } - public SoTRange getXRange() { - return xRange_.copy(); - } - public SoTRange getYRange() { - return yRange_.copy(); - } - public SoTRange getZRange() { - return zRange_.copy(); - } - public Range2D getValRange() { - return valRange_; - } - /** - * Return the range of the x edges - * - * @since 2.0 - */ - public SoTRange getXEdgesRange() { - return xEdgesRange_; - } - /** - * Return the range of the y edges - * - * @since 2.0 - */ - public SoTRange getYEdgesRange() { - return yEdgesRange_; - } - - public SoTRange getZEdgesRange() { - return zEdgesRange_; - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - - private SoTRange computeSoTRange(double[] array) { - Range2D range = computeRange2D(array); - return new SoTRange.Double(range.start, range.end); - } - private SoTRange computeSoTRange(GeoDate[] tarray) { - long start = Long.MAX_VALUE; - long end = Long.MIN_VALUE; - long value; - int count = 0; - for(int i=0; i < tarray.length; i++) { - if(!(tarray[i] == null || tarray[i].isMissing())) { - value = tarray[i].getTime(); - start = Math.min(start, value); - end = Math.max(end, value); - count++; - } - } - if(count == 0) { - return new SoTRange.GeoDate(new GeoDate(Long.MIN_VALUE), - new GeoDate(Long.MAX_VALUE)); - } else { - return new SoTRange.GeoDate(new GeoDate(start), new GeoDate(end)); - } - } - private Range2D computeRange2D(double[] array) { - double start = Double.POSITIVE_INFINITY; - double end = Double.NEGATIVE_INFINITY; - int count = 0; - for(int i=0; i < array.length; i++) { - if(!Double.isNaN(array[i])) { - start = Math.min(start, array[i]); - end = Math.max(end, array[i]); - count++; - } - } - if(count == 0) { - return new Range2D(Double.NaN, Double.NaN); - } else { - return new Range2D(start, end); - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/package.html deleted file mode 100755 index 660d1e44..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/dm/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - -Classes and interfaces that define the sgt datamodel. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/overview.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/overview.html deleted file mode 100755 index 54fde6d5..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/overview.html +++ /dev/null @@ -1,46 +0,0 @@ - - -

The Scientific Graphics Toolkit (SGT) is designed -to allow a graphics client developer a great deal of flexibility and -freedom. sgt is a package that greatly aids a developer -in creating graphics applets. sgt is not a general -purpose graphics package, but provides the tools to enable scientific -graphics to be easily incorporated into applications or -Applets.

- -

SGT has three main components, the {@link gov.noaa.pmel.sgt.JPane JPane}, -on which all graphics are drawn. The -{@link gov.noaa.pmel.sgt.Layer Layer}, of which several can be -associated with a single JPane, that insulates the -developer from device coordinates. And the -{@link gov.noaa.pmel.sgt.Graph Graph}, of -which a single instance can be associated with a Layer, -that transforms form user coordinates (e.g. cm/sec, time, etc) to the -layer coordinate system (physical coordinates). - -

Examples demonstrating the use of SGT are available in the {@link -gov.noaa.pmel.sgt.demo demo} package. These examples show how to -create SGT applications from scratch and how to use the {@link -gov.noaa.pmel.sgt.swing.JPlotLayout JPlotLayout} utility class. A tutorial - on using SGT to develop interactive graphics is now available. - -

The gov.noaa.pmel.sgt.awt and gov.noaa.pmel.sgt.util packages have -been deprecated. The functionality in gov.noaa.pmel.sgt.swing and -gov.noaa.pmel.sgt.swing.prop completely replaces the deprecated -classes. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- -@see gov.noaa.pmel.sgt.JPane -@see gov.noaa.pmel.sgt.Layer -@see gov.noaa.pmel.sgt.Graph - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/package.html deleted file mode 100755 index dbd23de4..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/package.html +++ /dev/null @@ -1,43 +0,0 @@ - - -Core classes for the Scientific Graphics Toolkit. - -

The Java Scientific Graphics Toolkit (sgt) is designed -to allow a graphics client developer a great deal of flexibility and -freedom. sgt is a package that greatly aids a developer -in creating graphics applets. sgt is not a general -purpose graphics package, but provides the tools to enable scientific -graphics to be easily incorporated into applications or -Applets.

- -

SGT has three main components, the JPane, on which all -graphics are drawn. The Layer, of which several can be -associated with a single JPane, that insulates the -developer from device coordinates. And the Graph, of -which a single instance can be associated with a Layer, -that transforms form user coordinates (e.g. cm/sec, time, etc) to the -layer coordinate system (physical coordinates). - -

Examples demonstrating the use of SGT are available in the {@link -gov.noaa.pmel.sgt.demo demo} package. These examples show how to -create SGT applications from scratch and how to use the {@link -gov.noaa.pmel.sgt.swing.JPlotLayout JPlotLayout} utility class. A tutorial - on using SGT to develop interactive graphics is now available. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- -@see gov.noaa.pmel.sgt.Pane -@see gov.noaa.pmel.sgt.JPane -@see gov.noaa.pmel.sgt.Layer -@see gov.noaa.pmel.sgt.Graph - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/DragNDropManager.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/DragNDropManager.java deleted file mode 100755 index 234b7679..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/DragNDropManager.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * $Id: DragNDropManager.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.plot; - -/** - * @since 2.x - */ -public class DragNDropManager { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/JPlotPane.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/JPlotPane.java deleted file mode 100755 index 4e68d92d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/JPlotPane.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * $Id: JPlotPane.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.plot; - -import gov.noaa.pmel.sgt.JPane; -import java.util.Vector; -import gov.noaa.pmel.sgt.LayerStack; - -/** - * @since 2.x - */ -public class JPlotPane extends JPane { - /** - * @undirected - * @link aggregation - * @label currentMode - */ - private PlotPaneMode currentMode_; - - /** - * @link aggregationByValue - * @undirected - * @label layerManager - */ - private PlotLayerManager layerManager_; - - /** - * @link aggregationByValue - * @undirected - * @label printManager - */ - private PrintManager printManager_; - - /** - * @link aggregationByValue - * @undirected - * @label dragNDropManager - */ - private DragNDropManager dragNDropManager_; - - /** - *@link aggregation - * @associates <{LayerStack}> - * @undirected - * @supplierCardinality 1..* - * @label layerStack - */ - private Vector layerStack_; -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/Notes.txt b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/Notes.txt deleted file mode 100755 index 032994c1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/Notes.txt +++ /dev/null @@ -1,51 +0,0 @@ - JPlotPane Notes - - 11/30/2000 - -* Create JPlotPane - 1) create and initealizes managers. (Print, DnD, Layer, ...) - 2) other initialization efforts. - 3) clear pane? - -* addData(SGTData, PlotLayerHints) to JPlotPane - 1) create PlotLayer (data, hints) - - create Graph - - create Renderer and bind data - 2) invoke PlotLayerManager - as newLayer(PlotLayer) or reLayout() <- is this needed? - - - if newLayer - + get X-Y types (space/time, units) - + using hints match with existing LayerStack - + if needed create new LayerStack & add to JPlotPane - else find stack to add layer to... - + create new transform if needed or bind to existing transform - + create new axes if needed - - - if modified Layer - + check for X-Y axes owner - + check for transforms - + update Key - (once a PlotLayer is assigned to a LayerStack it - stays there unless explictly moved) - -* hints (should hints include values?) - 1) Keys (location- on layer, new layer, table, popup; position) - 2) Transforms (scale/offset, share, new) - 3) Axes (share, new, location) - 4) PlotLayer ... - -* modes - 1) Zoom - 2) Object Select - 3) Data Select - 4) Layer DnD (LayerStack is DnD client/server?) - 5) Default (none? Zoom?) - - -* LayerManager - 1) LayerManager should have its rules about what can be overlayed! - For example, raster grid should not be over a contour grid! - 2) LayerManager should be able to re-order the Layers in a - LayerStack? - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayer.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayer.java deleted file mode 100755 index b7d3f42e..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * $Id: PlotLayer.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.plot; - -import gov.noaa.pmel.sgt.Layer; -/** - * @since 2.x - */ -public class PlotLayer extends Layer { - public PlotLayerHints getPlotLayerHints(){ - return plotLayerHints_; - } - - public void setPlotLayerHints(PlotLayerHints plotLayerHints){ - this.plotLayerHints_ = plotLayerHints; - } - - /** - * @link aggregation - * @undirected - * @label plotLayerHints - */ - private PlotLayerHints plotLayerHints_; -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayerHints.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayerHints.java deleted file mode 100755 index 0898c6c1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayerHints.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * $Id: PlotLayerHints.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.plot; - -import java.util.Map; -import java.util.Set; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; - -/** - * @since 2.x - */ -public class PlotLayerHints implements Map, Cloneable { - HashMap hintmap = new HashMap(5); - - /** - * PlotKey Type hint key - */ - public static final String KEY_PLOTKEY_TYPE = "PlotKeyType"; - /** - * PlotKey Type hint values -- on layer - */ - public static final String VALUE_PLOTKEY_ON_LAYER = "OnLayer"; - /** - * PlotKey Type hint values -- on seperate layer - */ - public static final String VALUE_PLOTKEY_ON_SEPERATE_LAYER = "OnSeperateLayer"; - /** - * PlotKey Type hint values -- in pop-up window - */ - public static final String VALUE_PLOTKEY_IN_POPUP = "InPopUp"; - /** - * PlotKey Type hint values -- in JTable - */ - public static final String VALUE_PLOTKEY_IN_TABLE = "InTable"; - /** - * PlotKey Type hint values -- no key - */ - public static final String VALUE_PLOTKEY_NONE = "None"; - - /** - * PlotKey location hint key - */ - public static final String KEY_PLOTKEY_LOCATION = "PlotKeyLocation"; - - /** - * Layer Placement hint key - */ - public static final String KEY_LAYER_PLACEMENT = "LayerPlacement"; - /** - * Layer Placement hint values -- overlay - */ - public static final String VALUE_LAYER_PLACEMENT_OVERLAY = "Overlay"; - - /** - * AspectRatio hint key - */ - public static final String KEY_ASPECT_RATIO = "AspectRatio"; - /** - * AspecRatio hint values -- lock X and Y scales - */ - public static final String VALUE_ASPECT_RATIO_LOCK = "Lock"; - /** - * AspecRatio hint values -- dont lock X and Y scales (during resize) - */ - public static final String VALUE_ASPECT_RATIO_NO_LOCK = "NoLock"; - - /** - * Axis location should actually go through a series of steps - * - * X Axis Location - * 1) bottom of plot region - * 2) top of plot region - * 3) below bottom axis (increase border if needed) - * 4) above top axis (increase border if needed) - * - * Y Axis Locations - * 1) left of plot region - * 2) right of plot region - * 3) outside left axis (increase border if needed) - * 4) outside right axis (increase border if needed) - * - * - * X Axis Location hint key - */ - public static final String KEY_X_AXIS_LOCATION = "XAxisLocation"; - /** - * X Axis Location hint values -- default - * First try bottom, top, below bottom, then above top - */ - public static final String VALUE_X_AXIS_LOCATION_DEFAULT = "Default"; - /** - * X Axis Location hint values -- bottom - */ - public static final String VALUE_X_AXIS_LOCATION_BOTTOM = "Bottom"; - /** - * X Axis Location hint values -- top - */ - public static final String VALUE_X_AXIS_LOCATION_TOP = "Top"; - - /** - * Y Axis Location hint key - */ - public static final String KEY_Y_AXIS_LOCATION = "YAxis Location"; - /** - * Y Axis Location hint values -- default - * First try left, right, outside right, then outside left - */ - public static final String VALUE_Y_AXIS_LOCATION_DEFAULT = "Default"; - /** - * Y Axis Location hint values -- left - */ - public static final String VALUE_Y_AXIS_LOCATION_LEFT = "Left"; - /** - * Y Axis Location hint values -- right - */ - public static final String VALUE_Y_AXIS_LOCATION_RIGHT = "Right"; - - /** - * Decision to create a new transform or re-use an existing - * transform should follow the following steps - * - * 1) Use transform from same LayerStack - * 2) Use transform from same JPlotPane - * 3) Create a new transform - * - * to use existing transform - * 1) both must be space or both time (test cant be defeated) - * 2) must have units that are convertable to existing transform - * 3) must have identical units - * - * - * X Transform hint key - */ - public static final String KEY_X_TRANSFORM = "XTransform"; - /** - * X Transform hint values -- default - * First try LayerStack, JPlotPane, then create new transform - */ - public static final String VALUE_X_TRANSFORM_DEFAULT = "Default"; - /** - * X Transform hint values -- new - */ - public static final String VALUE_X_TRANSFORM_NEW = "New"; - /** - * X Transform hint values -- use JPlotPane - */ - public static final String VALUE_X_TRANSFORM_USEPLOTPANE = "UsePlotPane"; - - /** - * Y Transform hint key - */ - public static final String KEY_Y_TRANSFORM = "YTransform"; - /** - * Y Transform hint values -- default - * First try LayerStack, JPlotPane, then create new transform - */ - public static final String VALUE_Y_TRANSFORM_DEFAULT = "Default"; - /** - * Y Transform hint values -- new - */ - public static final String VALUE_Y_TRANSFORM_NEW = "New"; - /** - * Y Transform hint values -- use JPlotPane - */ - public static final String VALUE_Y_TRANSFORM_USEPLOTPANE = "UsePlotPane"; - - public PlotLayerHints(Map init) { - if(init != null) { - hintmap.putAll(init); - } - } - - public PlotLayerHints(String key, String value) { - hintmap.put(key, value); - } - - public int size() { - return hintmap.size(); - } - - public boolean isEmpty() { - return hintmap.isEmpty(); - } - - public boolean containsKey(Object key) { - return hintmap.containsKey((String)key); - } - - public boolean containsValue(Object value) { - return hintmap.containsValue((String)value); - } - - public Object get(Object key) { - return hintmap.get((String)key); - } - - public Object put(Object key, Object value) { - return hintmap.put((String) key, (String)value); - } - - public void add(PlotLayerHints hints) { - hintmap.putAll(hints.hintmap); - } - - public void clear() { - hintmap.clear(); - } - - public Object remove(Object key) { - return hintmap.remove((String)key); - } - - public void putAll(Map m) { - if(m instanceof PlotLayerHints) { - hintmap.putAll(((PlotLayerHints)m).hintmap); - } else { - // Funnel each key/value pair though our method - Iterator iter = m.entrySet().iterator(); - while(iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - put(entry.getKey(), entry.getValue()); - } - } - } - - public Set keySet() { - return hintmap.keySet(); - } - - public Collection values() { - return hintmap.values(); - } - - public Set entrySet() { - return Collections.unmodifiableMap(hintmap).entrySet(); - } - - public boolean equals(Object o) { - if(o instanceof PlotLayerHints) { - return hintmap.equals(((PlotLayerHints)o).hintmap); - } else if(o instanceof Map) { - return hintmap.equals(o); - } - return false; - } - - public int hashCode() { - return hintmap.hashCode(); - } - - public Object clone() { - PlotLayerHints plh; - try { - plh = (PlotLayerHints) super.clone(); - if(hintmap != null) { - plh.hintmap = (HashMap) hintmap.clone(); - } - } catch (CloneNotSupportedException e) { - // this shouldnt happend since we are Cloneable - throw new InternalError(); - } - return plh; - } - - public String toString() { - if(hintmap == null) { - return getClass().getName() + - "@" + - Integer.toHexString(hashCode()) + - " (0 hints)"; - } - return hintmap.toString(); - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayerManager.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayerManager.java deleted file mode 100755 index a00aa4fd..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotLayerManager.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * $Id: PlotLayerManager.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.plot; - -import gov.noaa.pmel.sgt.AxisTransform; -import gov.noaa.pmel.sgt.LayerStack; -import gov.noaa.pmel.sgt.LayerNotFoundException; -/** - * @since 2.x - */ -public class PlotLayerManager { - public PlotLayerManager(JPlotPane plotPane) { - plotPane_ = plotPane; - } - - /** - * - */ - public void addLayer(PlotLayer layer) { - } - - public void removeLayer(int index) throws LayerNotFoundException { - } - - public void removeLayer(PlotLayer layer) throws LayerNotFoundException { - } - - public void update() { - } - - /** @link dependency */ - /*#LayerStack lnkLayerStack;*/ - - /** @link dependency */ - /*#PlotLayer lnkPlotLayer;*/ - - /** @link dependency */ - /*#AxisTransform lnkAxisTransform;*/ - - /** @link dependency */ - /*#PlotLayerHints lnkPlotLayerHints;*/ - - /** - * @label plotPane - */ - private JPlotPane plotPane_; -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotPaneMode.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotPaneMode.java deleted file mode 100755 index 8e566edb..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PlotPaneMode.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * $Id: PlotPaneMode.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.plot; - -/** - * @since 2.x - */ -final public class PlotPaneMode { - /** - * @supplierCardinality - */ - private static PlotPaneMode[] values_ = new PlotPaneMode[4]; - private int value_; - public final static int _ZOOM_DOMAIN = 0; - public final static PlotPaneMode ZOOM_DOMAIN = new PlotPaneMode(_ZOOM_DOMAIN); - public final static int _SELECT_OBJECT = 1; - public final static PlotPaneMode SELECT_OBJECT = new PlotPaneMode(_SELECT_OBJECT); - public final static int _SELECT_DATA = 2; - public final static PlotPaneMode SELECT_DATA = new PlotPaneMode(_SELECT_DATA); - public final static int _DRAG_AND_DROP = 3; - public final static PlotPaneMode DRAG_AND_DROP = new PlotPaneMode(_DRAG_AND_DROP); - - protected PlotPaneMode(int value) { - values_[value] = this; - value_ = value; - } - public int getValue() { - return value_; - } - public PlotPaneMode from_int(int value) { - return values_[value]; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PrintManager.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PrintManager.java deleted file mode 100755 index 61d45ffd..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/PrintManager.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * $Id: PrintManager.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.plot; - -/** - * @since 2.x - */ -public class PrintManager { -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/package.html deleted file mode 100755 index 5068b357..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plot/package.html +++ /dev/null @@ -1,23 +0,0 @@ - - -Classes for the automatic layout of multiple Layers. - -

The classes in this package are designed to work together to create -an automated system for plot layout. Eventually, I hope to include -managers for printing, Drag-and-Drop, and plot layout. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- -@see gov.noaa.pmel.sgt.JPane -@see gov.noaa.pmel.sgt.Layer -@see gov.noaa.pmel.sgt.Graph - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plotmarkcodes.gif b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plotmarkcodes.gif deleted file mode 100755 index 6b2fbce5..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/plotmarkcodes.gif and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ColorSwatchIcon.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ColorSwatchIcon.java deleted file mode 100755 index 638c59e1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ColorSwatchIcon.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * $Id: ColorSwatchIcon.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import gov.noaa.pmel.sgt.IndexedColor; -import gov.noaa.pmel.sgt.ColorMap; -import gov.noaa.pmel.util.Debug; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; -import javax.swing.Icon; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Color; -/** - * ColorSwatchIcon implements Icon to create a - * icon that displays a small square of - * color. ColorSwatchIcon is used with property dialogs - * to display/edit colors from an IndexedColor map. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see Icon - */ -public class ColorSwatchIcon implements Icon, PropertyChangeListener { - private int width_; - private int height_; -// private int size_; - private IndexedColor cmap_; - private int index_; - private Color color_ = null; - /** - * Construct a ColorSwatchIcon. - * - * @param cmap indexed color map - * @param index color index - * @param size swatch size in pixels - */ - public ColorSwatchIcon(IndexedColor cmap, int index, int size) { - setSize(size); - cmap_ = cmap; - index_ = index; - ((ColorMap)cmap_).addPropertyChangeListener(this); - color_ = cmap_.getColorByIndex(index_); - } - - /** - * @since version 1.3 - * @param color - * @param size - */ - public ColorSwatchIcon(Color color, int width, int height) { - index_ = -1; - cmap_ = null; - color_ = color; - width_ = width; - height_ = height; - } - /** - * Get color index. - */ - public int getIndex() { - return index_; - } - /** - * Get icon color. - */ - public Color getColor() { - return color_; - } - /** - * Change the size of the swatch. - */ - public void setSize(int size) { - width_ = size; - height_ = size; - } - /** - * Get the size of the icon. - */ -// public int getSize() { -// return size_; -// } - /** - * Paint the icon at the specified location - */ - public void paintIcon(Component c, Graphics g, int x, int y) { - g.setColor(color_); - g.fillRect(x, y, width_, height_); - } - /** - * Get the icon width. - */ - public int getIconWidth() { - return width_; - } - /** - * Get the icon heigth. - */ - public int getIconHeight() { - return height_; - } - - public String toString() { - return "ColorSwatchIcon: "; - } - /** - * ColorSwatchIcon listens for changes to the - * IndexedColor color map. If changes occur the swatch - * is updated. - */ - public void propertyChange(PropertyChangeEvent event) { - if(Debug.EVENT) { - System.out.println("ColorSwatchIcon: " + event); - System.out.println(" " + event.getPropertyName()); - } - if(event.getPropertyName().equals("color")) { - // - // color has changed - // - Color ncolor = cmap_.getColorByIndex(index_); - if(!ncolor.equals(color_)) { - color_ = ncolor; - // notify here? - } - } - } -} - - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/Draggable.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/Draggable.java deleted file mode 100755 index 8a58ea87..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/Draggable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * $Id: Draggable.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import java.awt.Point; -/** - * Draggable defines an interface to allow classes to be - * imaged separately in a Layer from other classes. - * The interface is sufficient to allow dragging in a - * JLayeredPane (JPane). - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - */ -public interface Draggable { - /** - * Set the location of the Draggable object. Change in - * location will not be vetoed. - */ - public void setLocationNoVeto(int x, int y); - /** - * Set the location of the Draggable object. - */ - public void setLocation(Point loc); - /** - * Set the location of the Draggable object and optionally don't - * fire a PropertyChangeEvent - * - * @since 3.0 - */ - public void setLocation(Point loc, boolean fireEvent); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JClassTree.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JClassTree.java deleted file mode 100755 index 7d44f419..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JClassTree.java +++ /dev/null @@ -1,619 +0,0 @@ -/* - * $Id: JClassTree.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import javax.swing.*; -import javax.swing.tree.*; -import java.awt.*; -import java.awt.event.MouseListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.InputEvent; -import java.util.Enumeration; -import java.util.List; - -import gov.noaa.pmel.util.Debug; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.LayerChild; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.CartesianRenderer; -import gov.noaa.pmel.sgt.PointCartesianRenderer; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.GridCartesianRenderer; -import gov.noaa.pmel.sgt.VectorCartesianRenderer; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.SpaceAxis; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.Transform; -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.VectorAttribute; -import gov.noaa.pmel.sgt.Logo; - -import gov.noaa.pmel.sgt.beans.Panel; -import gov.noaa.pmel.sgt.beans.DataGroupLayer; - -import gov.noaa.pmel.sgt.swing.prop.LineAttributeDialog; -import gov.noaa.pmel.sgt.swing.prop.GridAttributeDialog; -import gov.noaa.pmel.sgt.swing.prop.SGLabelDialog; -import gov.noaa.pmel.sgt.swing.prop.TimeAxisDialog; -import gov.noaa.pmel.sgt.swing.prop.SpaceAxisDialog; -import gov.noaa.pmel.sgt.swing.prop.PointAttributeDialog; -import gov.noaa.pmel.sgt.swing.prop.LogoDialog; -import gov.noaa.pmel.sgt.swing.prop.VectorAttributeDialog; - -/** - * JClassTree displays the sgt object tree - * in a JDialog using a JTree. Many - * sgt classes can be selected from the - * JTree to edit their properties. They include: - * {@link gov.noaa.pmel.sgt.SGLabel SGLabel}, - * {@link gov.noaa.pmel.sgt.LineAttribute LineAttribute}, - * {@link gov.noaa.pmel.sgt.GridAttribute GridAttribute}, - * {@link gov.noaa.pmel.sgt.CartesianGraph CartesianGraph}, - * {@link gov.noaa.pmel.sgt.TimeAxis TimeAxis}, - * {@link gov.noaa.pmel.sgt.SpaceAxis SpaceAxis}, - * {@link gov.noaa.pmel.sgt.PointAttribute PointAttribute}, and - * {@link gov.noaa.pmel.sgt.Logo Logo}. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see SGLabelDialog - * @see LineAttributeDialog - * @see GridAttributeDialog - * @see TimeAxisDialog - * @see SpaceAxisDialog - * @see PointAttributeDialog - * @see LogoDialog - */ -public class JClassTree extends javax.swing.JDialog { - private JPane pane_; - - private static SGLabelDialog sg_; - private static LineAttributeDialog la_; - private static GridAttributeDialog ga_; - private static VectorAttributeDialog va_; - private static TimeAxisDialog ta_; - private static SpaceAxisDialog pa_; - private static PointAttributeDialog pta_; - private static LogoDialog lg_; - /** - * Default constructor. - */ - public JClassTree() { - getContentPane().setLayout(new BorderLayout(0,0)); - setVisible(false); - setSize(405,362); - jScrollPane1 = new javax.swing.JScrollPane(); - jScrollPane1.setOpaque(true); - getContentPane().add(BorderLayout.CENTER, jScrollPane1); - treeView_ = new javax.swing.JTree(); - treeView_.setBounds(0,0,402,324); - treeView_.setFont(new Font("Dialog", Font.PLAIN, 12)); - treeView_.setBackground(java.awt.Color.white); - jScrollPane1.getViewport().add(treeView_); - treeControlsPanel = new javax.swing.JPanel(); - treeControlsPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - treeControlsPanel.setFont(new Font("Dialog", Font.PLAIN, 12)); - treeControlsPanel.setForeground(java.awt.Color.black); - treeControlsPanel.setBackground(new java.awt.Color(204,204,204)); - getContentPane().add(BorderLayout.SOUTH, treeControlsPanel); - expandButton = new javax.swing.JButton(); - expandButton.setText("Expand All"); - expandButton.setActionCommand("Expand All"); - expandButton.setFont(new Font("Dialog", Font.BOLD, 12)); - expandButton.setBackground(new java.awt.Color(204,204,204)); - treeControlsPanel.add(expandButton); - collapseButton = new javax.swing.JButton(); - collapseButton.setText("Collapse All"); - collapseButton.setActionCommand("Collapse All"); - collapseButton.setFont(new Font("Dialog", Font.BOLD, 12)); - collapseButton.setBackground(new java.awt.Color(204,204,204)); - treeControlsPanel.add(collapseButton); - editButton = new javax.swing.JButton(); - editButton.setText("Edit Selected"); - editButton.setActionCommand("Edit Selected"); - editButton.setFont(new Font("Dialog", Font.BOLD, 12)); - editButton.setBackground(new java.awt.Color(204,204,204)); - treeControlsPanel.add(editButton); - cancelButton = new javax.swing.JButton(); - cancelButton.setText("Close"); - cancelButton.setActionCommand("Close"); - cancelButton.setFont(new Font("Dialog", Font.BOLD, 12)); - cancelButton.setBackground(new java.awt.Color(204,204,204)); - treeControlsPanel.add(cancelButton); - setTitle("Class View"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - expandButton.addActionListener(lSymAction); - collapseButton.addActionListener(lSymAction); - editButton.addActionListener(lSymAction); - cancelButton.addActionListener(lSymAction); - - MouseListener ml = new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - int selRow = treeView_.getRowForLocation(e.getX(), - e.getY()); - TreePath selPath = treeView_.getPathForLocation(e.getX(), - e.getY()); - if(selRow != -1) { - if((e.getClickCount() == 2) || - ((e.getModifiers()&InputEvent.BUTTON3_MASK) != 0)) { - doubleClick(selRow, selPath); - } - } - } - }; - treeView_.addMouseListener(ml); - // - - if(System.getProperty("mrj.version") == null || - !UIManager.getSystemLookAndFeelClassName().equals(UIManager.getLookAndFeel().getClass().getName())) { - Insets inset = new Insets(0,5,0,5); - expandButton.setMargin(inset); - collapseButton.setMargin(inset); - editButton.setMargin(inset); - cancelButton.setMargin(inset); - } - } - - void doubleClick(int selRow, TreePath selPath) { - if(Debug.DEBUG) System.out.println("row " + selRow + " selected"); - Object[] objs = selPath.getPath(); - Object thing = ((DefaultMutableTreeNode)objs[objs.length-1]).getUserObject(); - showProperties(thing); - } - - public JClassTree(String sTitle) { - this(); - setTitle(sTitle); - } - /** - * Make the dialog visible. - */ - public void setVisible(boolean b) { - if (b) - setLocation(50, 50); - super.setVisible(b); - } - - static public void main(String[] args) { - (new JClassTree()).setVisible(true); - } - - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - Insets in = getInsets(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - // Adjust components according to the insets - setSize(in.left + in.right + d.width, in.top + in.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) - { - Point p = components[i].getLocation(); - p.translate(in.left, in.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - private boolean fComponentsAdjusted = false; - - javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); - javax.swing.JTree treeView_ = new javax.swing.JTree(); - javax.swing.JPanel treeControlsPanel = new javax.swing.JPanel(); - javax.swing.JButton expandButton = new javax.swing.JButton(); - javax.swing.JButton collapseButton = new javax.swing.JButton(); - javax.swing.JButton editButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == JClassTree.this) - JClassTree_WindowClosing(event); - } - } - - void JClassTree_WindowClosing(java.awt.event.WindowEvent event) { - setVisible(false); // hide the Frame - // dispose(); // free the system resources - // System.exit(0); // close the application - } - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == expandButton) - expandButton_actionPerformed(event); - else if (object == collapseButton) - collapseButton_actionPerformed(event); - else if (object == editButton) - editButton_actionPerformed(event); - else if (object == cancelButton) - cancelButton_actionPerformed(event); - } - } - - void expandButton_actionPerformed(java.awt.event.ActionEvent event) { - expandTree(); - } - /** - * Expand the tree to show all nodes. - */ - public void expandTree() { - int row=0; - while(row < treeView_.getRowCount()) { - if(treeView_.isCollapsed(row)) { - treeView_.expandRow(row); - } - row++; - } - } - - void collapseButton_actionPerformed(java.awt.event.ActionEvent event) { - treeView_.collapseRow(0); - } - - void editButton_actionPerformed(java.awt.event.ActionEvent event) { - Object[] objs = treeView_.getSelectionPath().getPath(); - showProperties(((DefaultMutableTreeNode)objs[objs.length-1]).getUserObject()); - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - setVisible(false); - } - /** - * Set the JPane for which the JTree is to - * be built. - */ - public void setJPane(JPane pane) { - Layer ly; - // - DefaultTreeModel treeModel; - DefaultMutableTreeNode paneNode; - DefaultMutableTreeNode panelNode; - DefaultMutableTreeNode layerNode; - DefaultMutableTreeNode dataGroupNode; - - pane_ = pane; - paneNode = new DefaultMutableTreeNode(pane_); - treeModel = new DefaultTreeModel(paneNode); - treeView_.setModel(treeModel); - // - Component[] comps = pane_.getComponents(); - for(int il=0; il < comps.length; il++) { - if(comps[il] instanceof DataGroupLayer) { - ly = (Layer)comps[il]; - dataGroupNode = new DefaultMutableTreeNode(ly); - treeModel.insertNodeInto(dataGroupNode, - paneNode, - treeModel.getChildCount(paneNode)); - List lyList = ((DataGroupLayer)ly).getLayerList(); - for(int i=1; i < lyList.size(); i++) { - ly = (Layer)lyList.get(i); - layerNode = new DefaultMutableTreeNode(ly); - treeModel.insertNodeInto(layerNode, - dataGroupNode, - treeModel.getChildCount(dataGroupNode)); - expandLayer(ly, dataGroupNode, treeModel); - } - } else if(comps[il] instanceof Layer) { - ly = (Layer)comps[il]; - layerNode = new DefaultMutableTreeNode(ly); - treeModel.insertNodeInto(layerNode, - paneNode, - treeModel.getChildCount(paneNode)); - expandLayer(ly, layerNode, treeModel); - } else if(comps[il] instanceof Panel) { - panelNode = new DefaultMutableTreeNode(comps[il]); - treeModel.insertNodeInto(panelNode, - paneNode, - treeModel.getChildCount(paneNode)); - Component[] pcomps = ((Panel)comps[il]).getComponents(); - for(int pl=0; pl < pcomps.length; pl++) { - if(pcomps[pl] instanceof DataGroupLayer) { - ly = (Layer)pcomps[pl]; - dataGroupNode = new DefaultMutableTreeNode(ly); - treeModel.insertNodeInto(dataGroupNode, - paneNode, - treeModel.getChildCount(paneNode)); - expandLayer(ly, dataGroupNode, treeModel); - List lyList = ((DataGroupLayer)ly).getLayerList(); - for(int i=1; i < lyList.size(); i++) { - ly = (Layer)lyList.get(i); - layerNode = new DefaultMutableTreeNode(ly); - treeModel.insertNodeInto(layerNode, - dataGroupNode, - treeModel.getChildCount(dataGroupNode)); - expandLayer(ly, layerNode, treeModel); - } - } else if(pcomps[pl] instanceof Layer) { - ly = (Layer)pcomps[pl]; - layerNode = new DefaultMutableTreeNode(ly); - treeModel.insertNodeInto(layerNode, - panelNode, - treeModel.getChildCount(panelNode)); - expandLayer(ly, layerNode, treeModel); - } - } - } else { - continue; - } - - int row=0; - while(row < treeView_.getRowCount()) { - if(treeView_.isCollapsed(row)) { - treeView_.expandRow(row); - } - row++; - } - } - } - - private void expandLayer(Layer ly, - DefaultMutableTreeNode layerNode, - DefaultTreeModel treeModel) { - LayerChild child; - Graph graph; - Axis axis; - CartesianRenderer rend; - LineAttribute attr; - GridAttribute gattr; - PointAttribute pattr; - VectorAttribute vattr; - // - DefaultMutableTreeNode node; - DefaultMutableTreeNode paneNode; - DefaultMutableTreeNode childNode; - DefaultMutableTreeNode graphNode; - DefaultMutableTreeNode attrNode; - DefaultMutableTreeNode gattrNode; - DefaultMutableTreeNode pattrNode; - DefaultMutableTreeNode axisNode; - DefaultMutableTreeNode titleNode; - - String name, className; - for(Enumeration childs = ly.childElements(); childs.hasMoreElements();) { - child = (LayerChild)childs.nextElement(); - className = child.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - childNode = new DefaultMutableTreeNode(child); - treeModel.insertNodeInto(childNode, - layerNode, - treeModel.getChildCount(layerNode)); - } - graph = ly.getGraph(); - if(graph == null) return; - className = graph.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - if(graph instanceof CartesianGraph) { - graphNode = new DefaultMutableTreeNode(graph); - treeModel.insertNodeInto(graphNode, - layerNode, - treeModel.getChildCount(layerNode)); - rend = ((CartesianGraph)graph).getRenderer(); - if(rend instanceof LineCartesianRenderer) { - attr = (LineAttribute)((LineCartesianRenderer)rend).getAttribute(); - if(attr != null) { - className = attr.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - attrNode = new DefaultMutableTreeNode(attr); - treeModel.insertNodeInto(attrNode, - graphNode, - treeModel.getChildCount(graphNode)); - } - } else if(rend instanceof VectorCartesianRenderer) { - vattr = (VectorAttribute)((VectorCartesianRenderer)rend).getAttribute(); - if(vattr != null) { - className = vattr.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - attrNode = new DefaultMutableTreeNode(vattr); - treeModel.insertNodeInto(attrNode, - graphNode, - treeModel.getChildCount(graphNode)); - } - } else if(rend instanceof GridCartesianRenderer) { - gattr = (GridAttribute)((GridCartesianRenderer)rend).getAttribute(); - if(gattr != null) { - className = gattr.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - gattrNode = new DefaultMutableTreeNode(gattr); - treeModel.insertNodeInto(gattrNode, - graphNode, - treeModel.getChildCount(graphNode)); - } - } else if(rend instanceof PointCartesianRenderer) { - pattr = (PointAttribute)((PointCartesianRenderer)rend).getAttribute(); - if(pattr != null) { - className = pattr.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - pattrNode = new DefaultMutableTreeNode(pattr); - treeModel.insertNodeInto(pattrNode, - graphNode, - treeModel.getChildCount(graphNode)); - } - } - for(Enumeration axes = ((CartesianGraph)graph).xAxisElements(); - axes.hasMoreElements();) { - axis = (Axis)axes.nextElement(); - className = axis.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - if(axis instanceof SpaceAxis) { - axisNode = new DefaultMutableTreeNode(axis); - treeModel.insertNodeInto(axisNode, - graphNode, - treeModel.getChildCount(graphNode)); - SGLabel title = axis.getTitle(); - if(title != null) { - titleNode = new DefaultMutableTreeNode(title); - treeModel.insertNodeInto(titleNode, - axisNode, - treeModel.getChildCount(axisNode)); - } - } else { // not a SpaceAxis - axisNode = new DefaultMutableTreeNode(axis); - treeModel.insertNodeInto(axisNode, - graphNode, - treeModel.getChildCount(graphNode)); - } - } - for(Enumeration axes = ((CartesianGraph)graph).yAxisElements(); - axes.hasMoreElements();) { - axis = (Axis)axes.nextElement(); - className = axis.getClass().getName(); - name = className.substring(className.lastIndexOf(".")+1); - if(axis instanceof SpaceAxis) { - axisNode = new DefaultMutableTreeNode(axis); - treeModel.insertNodeInto(axisNode, - graphNode, - treeModel.getChildCount(graphNode)); - SGLabel title = axis.getTitle(); - if(title != null) { - titleNode = new DefaultMutableTreeNode(title); - treeModel.insertNodeInto(titleNode, - axisNode, - treeModel.getChildCount(axisNode)); - } - } else { // not a SpaceAxis - axisNode = new DefaultMutableTreeNode(axis); - treeModel.insertNodeInto(axisNode, - graphNode, - treeModel.getChildCount(graphNode)); - } - } - } else { // not a CartesianGraph - graphNode = new DefaultMutableTreeNode(graph); - treeModel.insertNodeInto(graphNode, - layerNode, - treeModel.getChildCount(layerNode)); - } - } - - void showProperties(Object obj) { - if(obj instanceof SGLabel) { - if(sg_ == (SGLabelDialog) null) { - // - // create the SGLabel dialog - // - sg_ = new SGLabelDialog(); - } - sg_.setSGLabel((SGLabel) obj, pane_); - if(!sg_.isShowing()) - sg_.setVisible(true); - } else if(obj instanceof Logo) { - if(lg_ == null) { - // - // create logo dialog - // - lg_ = new LogoDialog(); - } - lg_.setLogo((Logo) obj, pane_); - if(!lg_.isShowing()) - lg_.setVisible(true); - } else if(obj instanceof PlainAxis) { - if(pa_ == (SpaceAxisDialog) null) { - // - // create the PlainAxis dialog - // - pa_ = new SpaceAxisDialog(); - } - pa_.setSpaceAxis((PlainAxis) obj, pane_); - if(!pa_.isShowing()) - pa_.show(); - } else if(obj instanceof TimeAxis) { - if(ta_ == (TimeAxisDialog) null) { - // - // create the TimeAxis dialog - // - ta_ = new TimeAxisDialog(); - } - ta_.setTimeAxis((TimeAxis) obj, pane_); - if(!ta_.isShowing()) - ta_.show(); - } else if(obj instanceof LineAttribute) { - if(la_ == (LineAttributeDialog) null) { - // - // create the LineAttr dialog - // - la_ = new LineAttributeDialog(); - la_.setJPane(pane_); - } - la_.setLineAttribute((LineAttribute)obj); - if(!la_.isShowing()) - la_.setVisible(true); - } else if(obj instanceof VectorAttribute) { - if(va_ == (VectorAttributeDialog) null) { - // - // create the LineAttr dialog - // - va_ = new VectorAttributeDialog(); - va_.setJPane(pane_); - } - va_.setVectorAttribute((VectorAttribute)obj); - if(!va_.isShowing()) - va_.setVisible(true); - } else if (obj instanceof GridAttribute) { - if(ga_ == null) { - // - // create a new dialog - // - ga_ = new GridAttributeDialog(); - } - ga_.setGridAttribute((GridAttribute)obj); - if(!ga_.isShowing()) - ga_.setVisible(true); - } else if (obj instanceof CartesianGraph) { - CartesianRenderer rend = ((CartesianGraph)obj).getRenderer(); - if( rend instanceof GridCartesianRenderer) { - if(ga_ == null) { - ga_ = new GridAttributeDialog(); - } - ga_.setGridCartesianRenderer((GridCartesianRenderer)rend); - if(!ga_.isShowing()) - ga_.setVisible(true); - } - } else if (obj instanceof PointAttribute) { - if(pta_ == (PointAttributeDialog) null) { - pta_ = new PointAttributeDialog(); - } - pta_.setPointAttribute((PointAttribute) obj, pane_); - if(!pta_.isShowing()) - pta_.show(); - } - } - private Frame getFrame() { - Container theFrame = this; - do { - theFrame = theFrame.getParent(); - } while ((theFrame != null) && !(theFrame instanceof Frame)); - if (theFrame == null) - theFrame = new Frame(); - return (Frame)theFrame; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JGraphicLayout.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JGraphicLayout.java deleted file mode 100755 index ccb1cc58..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JGraphicLayout.java +++ /dev/null @@ -1,1131 +0,0 @@ -/* - * $Id: JGraphicLayout.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.Pane; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.AxisTransform; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.Attribute; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.Logo; -import gov.noaa.pmel.sgt.DataNotFoundException; - -import gov.noaa.pmel.util.Domain; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Units; -import gov.noaa.pmel.util.SoTRange; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTPoint; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.dm.SGTVector; - -import gov.noaa.pmel.sgt.swing.prop.SGLabelDialog; -import gov.noaa.pmel.sgt.swing.prop.TimeAxisDialog; -import gov.noaa.pmel.sgt.swing.prop.SpaceAxisDialog; -import gov.noaa.pmel.sgt.swing.prop.LogoDialog; - -import java.util.Vector; -import java.util.Enumeration; -import java.util.Hashtable; -import java.net.URL; -import java.awt.Image; -import java.awt.Color; -import java.awt.Rectangle; -import java.awt.Component; -import java.awt.Frame; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.event.InputEvent; -import java.text.DecimalFormat; - -import java.beans.PropertyVetoException; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; -import java.beans.VetoableChangeSupport; -import java.beans.VetoableChangeListener; - -/** - * JGraphicLayout is a abstract class that provides - * the basis for pre-defined layouts using the - * CartesianGraph class. JGraphicLayout - * extends JPane. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see CartesianGraph - * @see JPlotLayout -**/ -public abstract class JGraphicLayout extends JPane { - /** - * Use X array from SGTData. - */ - public static final int X_AXIS = 1; - /** - * Use Y array from SGTData. - */ - public static final int Y_AXIS = 2; - /** - * Use Z array from SGTData. - */ - public static final int Z_AXIS = 3; - /** Width of graph in physical units */ - protected static double XSIZE_ = 6.00; - /** Start of X axis in physical units */ - protected static double XMIN_ = 0.60; - /** End of X axis in physical units */ - protected static double XMAX_ = 5.40; - /** Height of graph in physical units */ - protected static double YSIZE_ = 4.50; - /** Start of Y axis in physical units */ - protected static double YMIN_ = 0.75; - /** End of Y axis in physical units */ - protected static double YMAX_ = 3.30; - // - /** Height of main title in physical units */ - protected static double MAIN_TITLE_HEIGHT_ = 0.25; - /** Height of axis title in physical units */ - protected static double TITLE_HEIGHT_ = 0.22; - /** Height of axis labels in physical units */ - protected static double LABEL_HEIGHT_ = 0.18; - /** Height of 2nd and 3rd main titles */ - protected static double WARN_HEIGHT_ = 0.15; - /** Height of line or color key labels */ - protected static double KEY_HEIGHT_ = 0.16; - // protected static double KEY_HEIGHT_ = 0.20; - // - /** Width of key if in separate pane */ - protected static double XKEYSIZE_ = 6.00; - /** Height of key if in separate pane */ - protected static double YKEYSIZE_ = 12.00; - // - /** Main pane color */ - protected static Color PANE_COLOR = Color.white; - /** Key pane color */ - protected static Color KEYPANE_COLOR = Color.white; - // - /** Base units of data */ - protected int base_units_ = Units.NONE; - private JGraphicLayout me_; - /** Key pane reference */ - protected JPane keyPane_; - /** SGTData storage */ - protected Vector data_; - /** Mapping of data to attributes */ - protected Hashtable dataAttrMap_ = new Hashtable(); - /** Identification of graph */ - protected String ident_; - /** Layers are overlayed */ - protected boolean overlayed_; - /** Data is clipped to axes */ - protected boolean clipping_ = false; - /** Optional image */ - protected Image iconImage_ = null; - - /** - * Titles for graph - * @link aggregation - * @undirected - * @label titles - */ - protected SGLabel mainTitle_, title2_, title3_; - /** Reference to Mouse event handler */ - protected SymMouse aSymMouse_; - // - /** Allow editing of sgt object properties */ - protected boolean editClasses_ = true; - /** Reference to SGLabelDialog */ - protected SGLabelDialog sg_props_; - /** Reference to SpaceAxisDialog */ - protected SpaceAxisDialog pa_props_; - /** Reference to TimeAxisDialog */ - protected TimeAxisDialog ta_props_; - /** Reference to LogoDialog */ - protected LogoDialog lo_props_; - // - /** Reference to PropertyChangeSupport */ - protected PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - /** Reference to VetoableChangeSupport */ - protected VetoableChangeSupport vetos_ = new VetoableChangeSupport(this); - /** - * Default constructor - */ - public JGraphicLayout() { - this("", null, new Dimension(50,50)); - } - /** - * JGraphicLayout constructor. - * - * @param id identifier - * @param img icon image - * @see JPlotLayout - */ - public JGraphicLayout(String id, Image img) { - this(id, img, new Dimension(50,50)); - } - /** - * JGraphicLayout constructor. - * - * @param id identifier - * @param img icon image - * @param size graph size in device units - * @see JPlotLayout - */ - public JGraphicLayout(String id, Image img, Dimension size) { - super(id, size); - ident_ = id; - overlayed_ = true; - data_ = new Vector(10); - iconImage_ = img; - mainTitle_ = null; - title2_ = null; - title3_ = null; - me_ = this; - if(aSymMouse_ == null) aSymMouse_ = new SymMouse(); - addMouseListener(aSymMouse_); - } - /** - * Set the identifier - * - * @param id layout identifier - */ - public void setId(String id) { - ident_ = id; - } - /** - * Get the identifier - * - * @return layout identifier - */ - public String getId() { - return ident_; - } - /** - * Set the plot titles. - * - * @param title main plot title - * @param title2 secondary plot title - * @param title3 tertiary plot title - */ - public void setTitles(String title, String title2, String title3) { - if(mainTitle_ != null) mainTitle_.setText(title); - if(title2_ != null) title2_.setText(title2); - if(title3_ != null) title3_.setText(title3); - } - /** - * Set the base units. The base units are set automatically based - * on the first SGTData added to the list. Other - * SGTData objects added - * thereafter will be converted to the standard display units for each - * base unit type. (TEMPERATURE, default units are "degC"; VELOCITY, - * default units are "m/s"; DISTANCE, default unis are "m"). NOTE: Presently - * the units supported are very limited. - * - * @see gov.noaa.pmel.util.Units#NONE - * @see gov.noaa.pmel.util.Units#TEMPERATURE - * @see gov.noaa.pmel.util.Units#VELOCITY - * @see gov.noaa.pmel.util.Units#DISTANCE - */ - public void setBaseUnit(int base) { - base_units_ = base; - } - /** - * Get the base units - * - * @return the current base units for the layout - */ - public int getBaseUnit() { - return base_units_; - } - /** - * Set flag to overlay the layers. - * - * @param over if true overlay layers if false stack - */ - public void setOverlayed(boolean over) { - overlayed_ = over; - } - /** - * Layer overlay flag. - * - * @return true if layers will be overlayed - */ - public boolean isOverlayed() { - return overlayed_; - } - /** - * Get icon image - * - * @return icon image - */ - public Image getIconImage() { - return iconImage_; - } - /** - * Get KeyPane object - * - * @return pane - */ - public JPane getKeyPane() { - return keyPane_; - } - /** - * Is there a key pane? - */ - public boolean isKeyPane() { - return (keyPane_ != null); - } - /** - * Add data to the layout. Where data is added is dependent on the - * specific layout. Additional layers will be created as required. - * - * @param data data to be added - */ - public void addData(SGTData data) { - data_.addElement(data); - } - /** - * Associate SGTData with an - * Attribute. The associations are managed by a - * Hashtable object. - */ - public void addAttribute(SGTData data, Attribute attr) { - dataAttrMap_.put(data, attr); - } - /** - * Find an Attribute given a SGTData - * object. - */ - public Attribute getAttribute(SGTData data) - throws DataNotFoundException { - Attribute attr = (Attribute)dataAttrMap_.get(data); - if(attr == null) { - throw new DataNotFoundException(); - } - return attr; - } - /** - * Find an Attribute given an id. - * - * @since 3.0 - */ - public Attribute findAttribute(String id) { - Attribute attr = null; - Enumeration e = dataAttrMap_.elements(); - while(e.hasMoreElements()) { - attr = (Attribute)e.nextElement(); - if(attr.getId().equals(id)) return attr; - } - return attr; - } - /** - * Add data to the plot - */ - public abstract void addData(SGTData data, String label); - /** - * Construct a string that summarizes the location of the data. - */ - public abstract String getLocationSummary(SGTData grid); - /** - * Find the range of the SGTLine object in the specific - * direction. - * - * @param data SGTLine object - * @param dir direction - * @see CartesianGraph - */ - public Range2D findRange(SGTLine data, int dir) { - int num, i, first=0; - double amin=0.0, amax=0.0; - double[] values; - boolean good = false; - - switch(dir) { - case X_AXIS: - values = data.getXArray(); - num = values.length; - break; - default: - case Y_AXIS: - values = data.getYArray(); - num = values.length; - } - for(i=0; i < num; i++) { - if(!Double.isNaN(values[i])) { - amin = (double)values[i]; - amax = (double)values[i]; - good = true; - first = i+1; - break; - } - } - if(!good) { - return new Range2D(Double.NaN, Double.NaN); - } else { - for(i=first; i < num; i++) { - if(!Double.isNaN(values[i])) { - amin = Math.min(amin, (double)values[i]); - amax = Math.max(amax, (double)values[i]); - } - } - } - return new Range2D(amin, amax); - } - /** - * Find the range of the SGTLine object in the specific - * direction. - * - * @param data SGTLine object - * @param dir direction - * @return range as an SoTRange object - * @see CartesianGraph - */ - public SoTRange findSoTRange(SGTLine line, int dir) { - switch(dir) { - case X_AXIS: - return line.getXRange(); - case Y_AXIS: - return line.getYRange(); - default: - return null; - } - } - /** - * Find the range of the SGTVector object in the - * specified direction. Uses the U component to find X, Y ranges. - * - * @param data the data vector - * @param dir the direction - * @return range as an SoTRange object - */ - public SoTRange findSoTRange(SGTVector data, int dir) { - double[] veclen; - int num, i, first = 0; - double amin = 0.0, amax = 0.0; - boolean good = false; - - switch(dir) { - case X_AXIS: - return data.getU().getXRange(); - case Y_AXIS: - return data.getU().getYRange(); - default: - case Z_AXIS: - double[] ucomp = data.getU().getZArray(); - double[] vcomp = data.getV().getZArray(); - veclen = new double[ucomp.length]; - for(i=0; i < veclen.length; i++) { - veclen[i] = Math.sqrt(ucomp[i]*ucomp[i] + vcomp[i]*vcomp[i]); - } - num = veclen.length; - } - for(i=0; i < num; i++) { - if(!Double.isNaN(veclen[i])) { - amin = (double)veclen[i]; - amax = (double)veclen[i]; - good = true; - first = i+1; - break; - } - } - if(!good) { - return new SoTRange.Double(Double.NaN, Double.NaN); - } else { - for(i=first; i < num; i++) { - if(!Double.isNaN(veclen[i])) { - amin = Math.min(amin, (double)veclen[i]); - amax = Math.max(amax, (double)veclen[i]); - } - } - } - return new SoTRange.Double(amin, amax); - } - /** - * Find the range of the SGTGrid object in the - * specified direction. - * - * @param data the data grid - * @param attr the grid attribute - * @param dir the direction - * @return range as an SoTRange object - */ - public SoTRange findSoTRange(SGTGrid data, GridAttribute attr, int dir) { - int num, onum, i, first=0; - double amin=0.0, amax=0.0; - GeoDate tmin, tmax; - double[] values, orig; - GeoDate[] taxis, torig; - boolean good = false; - - if(attr.isRaster() && - ((data.isXTime() && (dir == X_AXIS) && !data.hasXEdges()) || - (data.isYTime() && (dir == Y_AXIS) && !data.hasYEdges()))) { - torig = data.getTimeArray(); - onum = torig.length; - taxis = new GeoDate[onum+1]; - taxis[0] = torig[0].subtract( - (torig[1].subtract(torig[0])).divide(2.0)); - for(i=1; i < onum; i++) { - taxis[i] = (torig[i-1].add(torig[i])).divide(2.0); - } - taxis[onum] = torig[onum-1].add( - (torig[onum-1].subtract(torig[onum-2])).divide(2.0)); - num = taxis.length; - return new SoTRange.Time(taxis[0].getTime(), - taxis[num-1].getTime()); - } - - switch(dir) { - case X_AXIS: - if(attr.isRaster()) { - if(data.hasXEdges()) { - return data.getXEdgesRange(); - } else { - orig = data.getXArray(); - onum = orig.length; - values = new double[onum+1]; - values[0] = orig[0]-(orig[1]-orig[0])*0.5; - for(i=1; i < onum; i++) { - values[i] = (orig[i-1]+orig[i])*0.5; - } - values[onum] = orig[onum-1]+(orig[onum-1]-orig[onum-2])*0.5; - num = values.length; - } - } else { - return data.getXRange(); - } - break; - case Y_AXIS: - if(attr.isRaster()) { - if(data.hasYEdges()) { - return data.getYEdgesRange(); - } else { - orig = data.getYArray(); - onum = orig.length; - values = new double[onum+1]; - values[0] = orig[0]-(orig[1]-orig[0])*0.5; - for(i=1; i < onum; i++) { - values[i] = (orig[i-1]+orig[i])*0.5; - } - values[onum] = orig[onum-1]+(orig[onum-1]-orig[onum-2])*0.5; - num = values.length; - } - } else { - return data.getYRange(); - } - break; - default: - case Z_AXIS: - values = data.getZArray(); - num = values.length; - } - for(i=0; i < num; i++) { - if(!Double.isNaN(values[i])) { - amin = (double)values[i]; - amax = (double)values[i]; - good = true; - first = i+1; - break; - } - } - if(!good) { - return new SoTRange.Double(Double.NaN, Double.NaN); - } else { - for(i=first; i < num; i++) { - if(!Double.isNaN(values[i])) { - amin = Math.min(amin, (double)values[i]); - amax = Math.max(amax, (double)values[i]); - } - } - } - return new SoTRange.Double(amin, amax); - } - /** - * Find the range of the SGTGrid object in the - * specified direction. - * - * @param data the data grid - * @param attr the grid attribute - * @param dir the direction - */ - public Range2D findRange(SGTGrid data, GridAttribute attr, int dir) { - int num, onum, i, first=0; - double amin=0.0, amax=0.0; - double[] values, orig; - boolean good = false; - - switch(dir) { - case X_AXIS: - if(attr.isRaster()) { - if(data.hasXEdges()) { - values = data.getXEdges(); - num = values.length; - } else { - orig = data.getXArray(); - onum = orig.length; - values = new double[onum+1]; - values[0] = orig[0]-(orig[1]-orig[0])*0.5; - for(i=1; i < onum; i++) { - values[i] = (orig[i-1]+orig[i])*0.5; - } - values[onum] = orig[onum-1]+(orig[onum-1]-orig[onum-2])*0.5; - num = values.length; - } - } else { - values = data.getXArray(); - num = values.length; - } - break; - case Y_AXIS: - if(attr.isRaster()) { - if(data.hasYEdges()) { - values = data.getYEdges(); - num = values.length; - } else { - orig = data.getYArray(); - onum = orig.length; - values = new double[onum+1]; - values[0] = orig[0]-(orig[1]-orig[0])*0.5; - for(i=1; i < onum; i++) { - values[i] = (orig[i-1]+orig[i])*0.5; - } - values[onum] = orig[onum-1]+(orig[onum-1]-orig[onum-2])*0.5; - num = values.length; - } - } else { - values = data.getYArray(); - num = values.length; - } - break; - default: - case Z_AXIS: - values = data.getZArray(); - num = values.length; - } - for(i=0; i < num; i++) { - if(!Double.isNaN(values[i])) { - amin = (double)values[i]; - amax = (double)values[i]; - good = true; - first = i+1; - break; - } - } - if(!good) { - return new Range2D(Double.NaN, Double.NaN); - } else { - for(i=first; i < num; i++) { - if(!Double.isNaN(values[i])) { - amin = Math.min(amin, (double)values[i]); - amax = Math.max(amax, (double)values[i]); - } - } - } - return new Range2D(amin, amax); - } - /** - * Find the time range of the SGTLine object. - * - * @param data SGTLine object - * @see CartesianGraph - */ - public TimeRange findTimeRange(SGTLine data) { - long taxis[]; - int num; - - taxis = data.getGeoDateArray().getTime(); - num = taxis.length; - return new TimeRange(taxis[0], taxis[num-1]); - } - /** - * Find the TimeRange of the SGTGrid object. - * - * @param data the data grid - * @param attr the grid attribute - * @param dir the direction - */ - public TimeRange findTimeRange(SGTGrid data, GridAttribute attr) { - long tmin, tmax; - long taxis[], orig[]; - int num, onum, i; - - if(attr.isRaster() && (data.isXTime() || data.isYTime())) { - if(data.hasXEdges() || data.hasYEdges()) { - taxis = data.getGeoDateArrayEdges().getTime(); - } else { - orig = data.getGeoDateArray().getTime(); - onum = orig.length; - taxis = new long[onum+1]; - taxis[0] = orig[0] - (orig[1]-orig[0])/2; - for(i=1; i < onum; i++) { - taxis[i] = (orig[i-1] + orig[i])/2; - } - taxis[onum] = orig[onum-1] + (orig[onum-1] - orig[onum-2])/2; - } - } else { - taxis = data.getGeoDateArray().getTime(); - } - num = taxis.length; - return new TimeRange(taxis[0], taxis[num-1]); - } - /** - * Set clipping on or off. If clipping is on, clip to the - * axes range. - * - * @param clip true if clipping is on - */ - public void setClipping(boolean clip) { - clipping_ = clip; - } - /** - * Returns true if clipping is on. - * - * @return true if clipping is on - */ - public boolean isClipping() { - return clipping_; - } - /** - * Set the axes to the range of the SGTData objects. - */ - abstract public void resetZoom(); - /** - * Set the axes to to range specified by the Domain - * object. - */ - abstract public void setRange(Domain domain) throws PropertyVetoException; - /** - * Get the current Domain - */ - public Domain getRange() { - Domain domain = new Domain(); - Range2D xr = new Range2D(); - Range2D yr = new Range2D(); -// TimeRange tr = new TimeRange(); - Layer layer = getFirstLayer(); - Graph graph = layer.getGraph(); - if(graph instanceof CartesianGraph) { - CartesianGraph cg = (CartesianGraph)graph; - AxisTransform xt = cg.getXTransform(); - AxisTransform yt = cg.getYTransform(); - if(xt.isTime()) { - domain.setXRange(xt.getTimeRangeU()); - } else { - domain.setXRange(xt.getRangeU()); - } - if(yt.isTime()) { - domain.setYRange(yt.getTimeRangeU()); - } else { - domain.setYRange(yt.getRangeU()); - } - } - return domain; - } - /** - * Get the zoom bounds in user units - */ - public Domain getZoomBoundsU() { - Domain domain = new Domain(); - Range2D xr = new Range2D(); - Range2D yr = new Range2D(); - long start, end; - - Rectangle zoom = getZoomBounds(); - Layer layer = getFirstLayer(); - Graph graph = layer.getGraph(); - - if(graph instanceof CartesianGraph) { - CartesianGraph cg = (CartesianGraph)graph; - AxisTransform xt = cg.getXTransform(); - AxisTransform yt = cg.getYTransform(); - if(xt.isSpace()) { - xr.start = cg.getXPtoU(layer.getXDtoP(zoom.x)); - xr.end = cg.getXPtoU(layer.getXDtoP(zoom.x + zoom.width)); - if(xr.start > xr.end) { - double temp = xr.start; - xr.start = xr.end; - xr.end = temp; - } - domain.setXRange(xr); - } else { - start = cg.getXPtoLongTime(layer.getXDtoP(zoom.x)); - end = cg.getXPtoLongTime(layer.getXDtoP(zoom.x + zoom.width)); - if(start > end) { - long tmp = start; - start = end; - end = tmp; - } - domain.setXRange(new TimeRange(new GeoDate(start), new GeoDate(end))); - } - if(yt.isSpace()) { - yr.start = cg.getYPtoU(layer.getYDtoP(zoom.y)); - yr.end = cg.getYPtoU(layer.getYDtoP(zoom.y + zoom.height)); - if(yr.start > yr.end) { - double temp = yr.start; - yr.start = yr.end; - yr.end = temp; - } - domain.setYRange(yr); - } else { - start = cg.getYPtoLongTime(layer.getYDtoP(zoom.y)); - end = cg.getYPtoLongTime(layer.getYDtoP(zoom.y + zoom.height)); - if(start > end) { - long tmp = start; - start = end; - end = tmp; - } - domain.setYRange(new TimeRange(new GeoDate(start), new GeoDate(end))); - } - } - return domain; - } - /** - * return a formated string summarizing the latitude - */ - protected String getLatString(double lat) { - if(lat == 0.0) return "Eq"; - DecimalFormat dfLat = new DecimalFormat("##.##N;##.##S"); - return dfLat.format(lat); - } - /** - * return a formated string summarizing the longitude - */ - protected String getLonString(double lond) { - /* positive west */ - String str; - DecimalFormat dfLon = new DecimalFormat("###.##W;###.##"); - double lon = (lond + 360.0) % 360.0; - dfLon.setNegativeSuffix("E"); - if(lon > 180.0) { - lon = 360.0 - lon; - } - return dfLon.format(lon); - } - /** - * Return data associated with the plot. - * - * @return data in a Collection - */ - public Collection getData() { - Collection col = new Collection(ident_ + " Data Collection", - data_.size()); - for(Enumeration e = data_.elements(); e.hasMoreElements(); ) { - col.addElement(e.nextElement()); - } - return col; - } - - class SymMouse extends java.awt.event.MouseAdapter { - public void mousePressed(java.awt.event.MouseEvent event) { - if(!isMouseEventsEnabled()) return; - Object object = event.getSource(); - if (object == me_) - Layout_MousePress(event); - else if (object == keyPane_) - KeyPane_MousePress(event); - } - - public void mouseClicked(java.awt.event.MouseEvent event) { - if(!isMouseEventsEnabled()) return; - Object object = event.getSource(); - if (object == me_) - Layout_MouseClicked(event); - else if (object == keyPane_) - KeyPane_MouseClicked(event); - } - - public void mouseReleased(java.awt.event.MouseEvent event) { - if(!isMouseEventsEnabled()) return; - Object object = event.getSource(); - if (object == me_) - Layout_MouseRelease(event); - } - } - - void Layout_MouseRelease(java.awt.event.MouseEvent event) { - // - // continue only if button1 is pressed - // - if((event.getModifiers()&InputEvent.BUTTON1_MASK) == 0) return; - - Rectangle zm = getZoomBounds(); - if(zm.width <= 1 || zm.height <= 1) return; - - Domain zoom = getZoomBoundsU(); - - setClipping(true); - - if(getFirstLayer().getGraph() instanceof CartesianGraph) { - try { - setRange(zoom); - } catch (PropertyVetoException e) { - System.out.println("Zoom denied! " + e); - } - } - // draw(); - } - - void Layout_MousePress(java.awt.event.MouseEvent event) { - if(event.isControlDown()) { - resetZoom(); - setClipping(false); - // draw(); - } - } - - void Layout_MouseClicked(java.awt.event.MouseEvent event) { - if(event.isControlDown()) return; - Object obj = getSelectedObject(); - if(obj instanceof LineCartesianRenderer) { - LineCartesianRenderer line = (LineCartesianRenderer)obj; - LineAttribute attr = line.getLineAttribute(); - if(attr.getStyle() == LineAttribute.SOLID) { - attr.setStyle(LineAttribute.HIGHLIGHT); - } else if(attr.getStyle() == LineAttribute.HIGHLIGHT) { - attr.setStyle(LineAttribute.SOLID); - } - // draw(); - } - - if(((event.getModifiers()&InputEvent.BUTTON3_MASK) != 0) && - editClasses_) { - showProperties(obj); - } - } - - void KeyPane_MousePress(java.awt.event.MouseEvent event) { - } - - void KeyPane_MouseClicked(java.awt.event.MouseEvent event) { - if(keyPane_ == null) return; - Object obj = keyPane_.getSelectedObject(); - if(obj instanceof LineCartesianRenderer) { - LineCartesianRenderer line = (LineCartesianRenderer)obj; - LineAttribute attr = line.getLineAttribute(); - if(attr.getStyle() == LineAttribute.SOLID) { - attr.setStyle(LineAttribute.HIGHLIGHT); - } else if(attr.getStyle() == LineAttribute.HIGHLIGHT) { - attr.setStyle(LineAttribute.SOLID); - } - // draw(); - // keyPane_.draw(); - } - if(editClasses_) { - showProperties(obj); - } - } - /** - * Enable sgt object property editing - */ - public void setEditClasses(boolean b) { - editClasses_ = b; - } - /** - * Are sgt objects editable? - */ - public boolean isEditClasses() { - return editClasses_; - } - /** - * Determine if the object selected is an SGLabel, PlainAxis, or - * TimeAxis. Depending on the answer create the appropriate dialog. - */ - void showProperties(Object obj) { - if(obj instanceof SGLabel) { - if(sg_props_ == (SGLabelDialog) null) { - // - // create the SGLabelDialog - // - sg_props_ = new SGLabelDialog(); - } - sg_props_.setSGLabel((SGLabel) obj, this); - if(!sg_props_.isShowing()) - sg_props_.show(); - } else if(obj instanceof PlainAxis) { - if(pa_props_ == (SpaceAxisDialog) null) { - // - // create the PlainAxis dialog - // - pa_props_ = new SpaceAxisDialog(); - } - pa_props_.setSpaceAxis((PlainAxis) obj, this); - if(!pa_props_.isShowing()) - pa_props_.show(); - } else if(obj instanceof TimeAxis) { - if(ta_props_ == (TimeAxisDialog) null) { - // - // create the TimeAxis Dialog - // - ta_props_ = new TimeAxisDialog(); - } - ta_props_.setTimeAxis((TimeAxis) obj, this); - if(!ta_props_.isShowing()) - ta_props_.show(); - } else if (obj instanceof Logo) { - if(lo_props_ == (LogoDialog) null) { - // - // create the LogoProperties dialog - // - lo_props_ = new LogoDialog(); - } - lo_props_.setLogo((Logo) obj, this); - if(!lo_props_.isShowing()) - lo_props_.show(); - } - } - - private Frame getFrame() { - Container theFrame = this; - do { - theFrame = theFrame.getParent(); - } while ((theFrame != null) && !(theFrame instanceof Frame)); - if (theFrame == null) - theFrame = new Frame(); - return (Frame) theFrame; - } - /** - * Set the clip range for all Layers. - */ - protected void setAllClip(SoTRange xr, SoTRange yr) { - if(yr.isTime()) { - setAllClip(yr.getStart().getLongTime(), - yr.getEnd().getLongTime(), - ((SoTRange.Double)xr).start, - ((SoTRange.Double)xr).end); - } else { - if(xr.isTime()) { - setAllClip(xr.getStart().getLongTime(), - xr.getEnd().getLongTime(), - ((SoTRange.Double)yr).start, - ((SoTRange.Double)yr).end); - } else { - setAllClip(((SoTRange.Double)xr).start, - ((SoTRange.Double)xr).end, - ((SoTRange.Double)yr).start, - ((SoTRange.Double)yr).end); - } - } - } - - /** - * Set the clip range for all Layers. - */ - protected void setAllClip(double xmin, double xmax, double ymin, double ymax) { - Layer ly; - Component[] comps = getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ly = (Layer)comps[i]; - ((CartesianGraph)ly.getGraph()).setClip(xmin, xmax, ymin, ymax); - } - } - } - /** - * Set the clip range for all Layers. - */ - protected void setAllClip(GeoDate tmin, GeoDate tmax, double min, double max) { -// System.out.println("setAllClip(" + tmin + ", " + tmax + ", " + min + ", " + max + ")"); - setAllClip(tmin.getTime(), tmax.getTime(), min, max); -/* Layer ly; - Component[] comps = getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ly = (Layer)comps[i]; - ((CartesianGraph)ly.getGraph()).setClip(tmin, tmax, min, max); - } - } */ - } - /** - * @since 3.0 - */ - protected void setAllClip(long tmin, long tmax, double min, double max) { -// System.out.println("setAllClip(" + tmin + ", " + tmax + ", " + min + ", " + max + ")"); - Layer ly; - Component[] comps = getComponents(); - for(int i=0; i < comps.length; i++) { - ly = (Layer)comps[i]; - ((CartesianGraph)ly.getGraph()).setClip(tmin, tmax, min, max); - } - } - /** - * Turn on clipping for all Layers. - */ - protected void setAllClipping(boolean clip) { - Layer ly; - Component[] comps = getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ly = (Layer)comps[i]; - ((CartesianGraph)ly.getGraph()).setClipping(clip); - } - } - } - /** - * Get the bounds for the line or color key. - */ - public abstract Rectangle2D.Double getKeyBoundsP(); - /** - * Set the bounds for the line or color key. - */ - public abstract void setKeyBoundsP(Rectangle2D.Double r); - /** - * Get the size of the key layer in physical coordinates. - */ - public Dimension2D getKeyLayerSizeP() { - if(keyPane_ != null) { - return keyPane_.getFirstLayer().getSizeP(); - } - return null; - } - /** - * Set the size of the key layer in physical coordinates. - */ - public void setKeyLayerSizeP(Dimension2D d) { - if(keyPane_ != null) { - keyPane_.getFirstLayer().setSizeP(d); - } - } - public void addVetoableChangeListener(VetoableChangeListener l) { - vetos_.addVetoableChangeListener(l); - } - public void removeVetoableChangeListener(VetoableChangeListener l) { - vetos_.removeVetoableChangeListener(l); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - public void finalize(){ - changes_ = null; - vetos_ = null; - data_ = null; - dataAttrMap_ = null; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JLineProfileLayout.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JLineProfileLayout.java deleted file mode 100755 index 49199a41..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JLineProfileLayout.java +++ /dev/null @@ -1,884 +0,0 @@ -/* - * $Id: JLineProfileLayout.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import gov.noaa.pmel.sgt.LineKey; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.Logo; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.LayerNotFoundException; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.AxisNotFoundException; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.SGException; -import gov.noaa.pmel.sgt.StackedLayout; - -import gov.noaa.pmel.util.Domain; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Range2D; -//import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.Units; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SimpleLine; -import gov.noaa.pmel.sgt.dm.SGTMetaData; -import gov.noaa.pmel.sgt.dm.Collection; - - -import java.util.Enumeration; -import java.util.Vector; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Color; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.Component; - -import java.beans.PropertyVetoException; - -/** - * JLineProfileLayout creates a pre-defined graphics layout for - * profile data using LineCartesianGraph. This layout is application specific. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @see LineCartesianRenderer - * @deprecated As of v2.0, replaced by {@link gov.noaa.pmel.sgt.swing.JPlotLayout} -**/ -/*oodE***********************************************/ -public class JLineProfileLayout extends JGraphicLayout { - // - // save handles to unique components - // - Logo logo_; - LineKey lineKey_; - int layerCount_; - boolean zUp_ = true; - Layer firstLayer_; - boolean inZoom_ = false; - // - // constants - // - double xSize_ = XSIZE_; - double xMin_ = XMIN_; - double xMax_ = XMAX_; - double ySize_ = YSIZE_; - double yMin_ = YMIN_; - double yMax_ = YMAX_; - // - double mainTitleHeight_ = MAIN_TITLE_HEIGHT_; - double titleHeight_ = TITLE_HEIGHT_; - double labelHeight_ = LABEL_HEIGHT_; - double warnHeight_ = WARN_HEIGHT_; - double keyHeight_ = KEY_HEIGHT_; - // - double xKeySize_ = XKEYSIZE_; - double yKeySize_ = YKEYSIZE_; - // - Color paneColor_ = PANE_COLOR; - Color keyPaneColor_ = KEYPANE_COLOR; - - // - private static final Color[] colorList_ = - { Color.blue, Color.cyan, Color.green, Color.orange.darker(), - Color.red, Color.magenta, Color.black, Color.gray}; - // {Color.red, Color.green, Color.blue, Color.cyan, - // Color.magenta, Color.yellow, Color.orange, Color.pink}; - private static final int[] markList_ = - {1, 2, 9, 15, 10, 24, 11, 44}; - /** - * Default constructor. No Logo image is used and the LineKey - * will be in the same Pane. - */ - public JLineProfileLayout() { - this("", null, false); - } - /** - * JLineProfileLayout constructor. - * - * @param id identifier - * @param img Logo image - * @param is_key_pane if true LineKey is in separate pane - */ - public JLineProfileLayout(String id, Image img, boolean is_key_pane) { - super(id, img, new Dimension(400,300)); - Layer layer, key_layer; - CartesianGraph graph; - LinearTransform xt, yt; - PlainAxis xbot, yleft; - double xpos, ypos; - int halign; - // - // create Pane and descendants for the LineProfile layout - // - setOpaque(true); - setLayout(new StackedLayout()); - setBackground(paneColor_); - layer = new Layer("Layer 1", new Dimension2D(xSize_, ySize_)); - firstLayer_ = layer; - add(layer,0); - // - lineKey_ = new LineKey(); - lineKey_.setSelectable(false); - lineKey_.setId("Line Key"); - lineKey_.setVAlign(LineKey.TOP); - if(is_key_pane) { - lineKey_.setHAlign(LineKey.LEFT); - lineKey_.setBorderStyle(LineKey.NO_BORDER); - lineKey_.setLocationP(new Point2D.Double(0.0, yKeySize_)); - int xdim = 400; - int ydim = (int)((double)xdim/xKeySize_*yKeySize_); - keyPane_ = new JPane("KeyPane", new Dimension(xdim,ydim)); - keyPane_.setOpaque(true); - keyPane_.setLayout(new StackedLayout()); - keyPane_.setBackground(keyPaneColor_); - key_layer = new Layer("Key Layer", new Dimension2D(xKeySize_, yKeySize_)); - keyPane_.add(key_layer); - key_layer.addChild(lineKey_); - } else { - lineKey_.setHAlign(LineKey.RIGHT); - lineKey_.setLocationP(new Point2D.Double(xSize_ - 0.01, ySize_)); - layer.addChild(lineKey_); - } - // - // add Icon - // - if(iconImage_ != null) { - logo_ = new Logo(new Point2D.Double(0.0, ySize_), Logo.TOP, Logo.LEFT); - logo_.setImage(iconImage_); - layer.addChild(logo_); - Rectangle bnds = logo_.getBounds(); - xpos = layer.getXDtoP(bnds.x + bnds.width) + 0.05; - halign = SGLabel.LEFT; - } else { - xpos = (xMin_ + xMax_)*0.5; - halign = SGLabel.CENTER; - } - // - // title - // - ypos = ySize_ - 1.2f*mainTitleHeight_; - Font titleFont = new Font("Helvetica", Font.BOLD, 14); - mainTitle_ = new SGLabel("Line Profile Title", - "Profile Plot", - mainTitleHeight_, - new Point2D.Double(xpos, ypos), - SGLabel.BOTTOM, - halign); - mainTitle_.setFont(titleFont); - layer.addChild(mainTitle_); - ypos = ypos - 1.2f*warnHeight_; - Font title2Font = new Font("Helvetica", Font.PLAIN, 10); - title2_ = new SGLabel("Warning", - "Warning: Browse image only", - warnHeight_, - new Point2D.Double(xpos, ypos), - SGLabel.BOTTOM, - halign); - title2_.setFont(title2Font); - layer.addChild(title2_); - ypos = ypos - 1.1f*warnHeight_; - title3_ = new SGLabel("Warning 2", - "Verify accuracy of plot before research use", - warnHeight_, - new Point2D.Double(xpos, ypos), - SGLabel.BOTTOM, - halign); - title3_.setFont(title2Font); - layer.addChild(title3_); - // - title3_.setSelectable(false); - - layerCount_ = 0; - // - // create LineCartesianGraph and transforms - // - graph = new CartesianGraph("Profile Graph 1"); - xt = new LinearTransform(xMin_, xMax_, 10.0, 20.0); - yt = new LinearTransform(yMin_, yMax_, 400.0, 0.0); - graph.setXTransform(xt); - graph.setYTransform(yt); - // - // create axes - // - Font axfont = new Font("Helvetica", Font.ITALIC, 14); - xbot = new PlainAxis("Bottom Axis"); - xbot.setRangeU(new Range2D(10.0, 20.0)); - xbot.setDeltaU(2.0); - xbot.setNumberSmallTics(0); - xbot.setLabelHeightP(labelHeight_); - xbot.setLocationU(new Point2D.Double(10.0, 400.0)); - xbot.setLabelFont(axfont); - graph.addXAxis(xbot); - // - yleft = new PlainAxis("Left Axis"); - yleft.setRangeU(new Range2D(400.0, 0.0)); - yleft.setDeltaU(-50.0); - yleft.setNumberSmallTics(0); - yleft.setLabelHeightP(labelHeight_); - yleft.setLocationU(new Point2D.Double(10.0, 400.0)); - yleft.setLabelFont(axfont); - graph.addYAxis(yleft); - // - layer.setGraph(graph); - } - public String getLocationSummary(SGTData grid) { - return ""; - } - public void addData(Collection lines) { - addData(lines, null); - } - public void addData(Collection lines, String descrip) { - // System.out.println("addData(Collection) called"); - for(int i=0; i < lines.size(); i++) { - SGTLine line = (SGTLine)lines.elementAt(i); - addData(line, line.getTitle()); - } - } - /** - * Add data to the layout. LineKey descriptor will be - * taken from the dependent variable name. - * - * @param data datum data to be added - */ - public void addData(SGTData datum) { - addData(datum, null); - } - /** - * Add data to the layout. Data will be added to X axis and Z_AXIS will be - * assigned to Y axis. If this is not the first invocation of addData a new Layer - * will be created. If overlayed, the transforms from the first layer will be - * attached and no axes will be created. If not overlayed, new transforms - * and axes will be created and adjusted so that the data is horizontally stacked. - * - * @param datum data to be added - * @param descrip LineKey description for datum - */ - public void addData(SGTData datum, String descrip) { - // - Layer layer, newLayer; - CartesianGraph graph, newGraph; - PlainAxis xbot = null; - PlainAxis yleft = null; - LinearTransform xt, yt; - SGLabel xtitle, ytitle, lineTitle; - SGTData data; - LineAttribute lineAttr; - String xLabel, yLabel; - Range2D xRange, yRange; - Range2D xnRange = null, ynRange = null; - Point2D.Double origin = null; - boolean data_good = true; - double save; - // - if(data_.size() == 0) setBaseUnit(Units.getBaseUnit(((SGTLine)datum).getXMetaData())); - datum = Units.convertToBaseUnit(datum, getBaseUnit(), Units.X_AXIS); - // - if(data_.size() == 0) { - super.addData(datum); - // - // only one data set... - // determine range and titles from data - // - data = (SGTData)data_.firstElement(); - xRange = findRange((SGTLine)data, X_AXIS); - yRange = findRange((SGTLine)data, Y_AXIS); - zUp_ = ((SGTLine)data).getYMetaData().isReversed(); - - if(Double.isNaN(xRange.start) || Double.isNaN(yRange.start)) data_good = false; - - if(data_good) { - if(!zUp_) { - save = yRange.end; - yRange.end = yRange.start; - yRange.start = save; - } - // - xnRange = Graph.computeRange(xRange, 6); - ynRange = Graph.computeRange(yRange, 6); - // - origin = new Point2D.Double(xnRange.start, ynRange.start); - } - // - xLabel = " (" + ((SGTLine)data).getXMetaData().getUnits() + ")"; - yLabel = " (" + ((SGTLine)data).getYMetaData().getUnits() + ")"; - // - // attach information to pane and descendents - // - try { - layer = getLayer("Layer 1"); - } catch (LayerNotFoundException e) { - return; - } - graph = (CartesianGraph)layer.getGraph(); - // - // axes - // - try { - Font tfont = new Font("Helvetica", Font.PLAIN, 14); - xbot = (PlainAxis)graph.getXAxis("Bottom Axis"); - if(data_good) { - xbot.setRangeU(xnRange); - xbot.setDeltaU(xnRange.delta); - xbot.setLocationU(origin); - } - xtitle = new SGLabel("xaxis title", xLabel, new Point2D.Double(0.0, 0.0)); - xtitle.setFont(tfont); - xtitle.setHeightP(titleHeight_); - xbot.setTitle(xtitle); - // - yleft = (PlainAxis)graph.getYAxis("Left Axis"); - if(data_good) { - yleft.setRangeU(ynRange); - yleft.setDeltaU(ynRange.delta); - yleft.setLocationU(origin); - } - ytitle = new SGLabel("yaxis title", yLabel, new Point2D.Double(0.0, 0.0)); - ytitle.setFont(tfont); - ytitle.setHeightP(titleHeight_); - yleft.setTitle(ytitle); - } catch (AxisNotFoundException e) {} - if(data_good) { - // - // transforms - // - xt = (LinearTransform)graph.getXTransform(); - xt.setRangeU(xnRange); - // - yt = (LinearTransform)graph.getYTransform(); - yt.setRangeU(ynRange); - } - // - // attach data - // - if(((SGTLine)data).getYArray().length >= 2) { - lineAttr = new LineAttribute(LineAttribute.SOLID, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } else { - lineAttr = new LineAttribute(LineAttribute.MARK, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } - graph.setData(data, lineAttr); - // - // add to lineKey - // - if(descrip == null) { - lineTitle = new SGLabel("line title", xLabel, new Point2D.Double(0.0, 0.0)); - } else { - lineTitle = new SGLabel("line title", descrip, new Point2D.Double(0.0, 0.0)); - } - lineTitle.setHeightP(keyHeight_); - lineKey_.addLineGraph((LineCartesianRenderer)graph.getRenderer(), lineTitle); - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - int nrow = vRect.height/lineKey_.getRowHeight(); - keyPane_.setScrollableUnitIncrement(1, lineKey_.getRowHeight()); - keyPane_.setScrollableBlockIncrement(vRect.width, - lineKey_.getRowHeight()*nrow); - } - } else { - // - // more than one data set... - // add new layer - // - if(((SGTLine)datum).getYMetaData().isReversed() != zUp_) { - // System.out.println("New datum has reversed ZUp!"); - SGTData modified = flipZ(datum); - datum = modified; - } - super.addData(datum); - - data_good = false; - layerCount_++; - if(isOverlayed()) { - try { - layer = getLayer("Layer 1"); - } catch (LayerNotFoundException e) { - return; - } - graph = (CartesianGraph)layer.getGraph(); - // - // transforms - // - xt = (LinearTransform)graph.getXTransform(); - yt = (LinearTransform)graph.getYTransform(); - try { - xbot = (PlainAxis)graph.getXAxis("Bottom Axis"); - yleft = (PlainAxis)graph.getYAxis("Left Axis"); - } catch (AxisNotFoundException e) {} - - if(!inZoom_) { - // - // loop over data sets, getting ranges - // - Range2D xTotalRange = new Range2D(); - Range2D yTotalRange = new Range2D(); - - boolean first = true; - for (Enumeration e = data_.elements() ; e.hasMoreElements() ;) { - data = (SGTData)e.nextElement(); - xRange = findRange((SGTLine)data, X_AXIS); - yRange = findRange((SGTLine)data, Y_AXIS); - if(!((SGTLine)data).getYMetaData().isReversed()) { - save = yRange.start; - yRange.start = yRange.end; - yRange.end = save; - } - if(first) { - if(Double.isNaN(xRange.start) || Double.isNaN(yRange.start)) { - first = true; - } else { - first = false; - data_good = true; - xTotalRange = new Range2D(xRange.start, xRange.end); - yTotalRange = new Range2D(yRange.start, yRange.end); - } - } else { - if(!Double.isNaN(xRange.start) && !Double.isNaN(yRange.start)) { - data_good = true; - xTotalRange.start = Math.min(xTotalRange.start, xRange.start); - xTotalRange.end = Math.max(xTotalRange.end, xRange.end); - if(!((SGTLine)data).getYMetaData().isReversed()) { - yTotalRange.start = Math.max(yTotalRange.start, yRange.start); - yTotalRange.end = Math.min(yTotalRange.end, yRange.end); - } else { - yTotalRange.start = Math.min(yTotalRange.start, yRange.start); - yTotalRange.end = Math.max(yTotalRange.end, yRange.end); - } - } - } - } - if(data_good) { - xnRange = Graph.computeRange(xTotalRange, 6); - ynRange = Graph.computeRange(yTotalRange, 6); - origin = new Point2D.Double(xnRange.start, ynRange.start); - // - // axes - // - xbot.setRangeU(xnRange); - xbot.setDeltaU(xnRange.delta); - xbot.setLocationU(origin); - // - yleft.setRangeU(ynRange); - yleft.setDeltaU(ynRange.delta); - yleft.setLocationU(origin); - } - // - if(data_good) { - xt.setRangeU(xnRange); - yt.setRangeU(ynRange); - } - } - // - // create new layer and graph - // - newLayer = new Layer("Layer " + (layerCount_+1), new Dimension2D(xSize_, ySize_)); - newGraph = new CartesianGraph("Graph " + (layerCount_+1), xt, yt); - if(inZoom_) { - Range2D xr, yr; - xr = xbot.getRangeU(); - yr = yleft.getRangeU(); - newGraph.setClip(xr.start, xr.end, yr.start, yr.end); - newGraph.setClipping(true); - } - add(newLayer,0); - newLayer.setGraph(newGraph); - newLayer.invalidate(); - validate(); - // - // attach data - // - if(((SGTLine)datum).getXArray().length >= 2) { - lineAttr = new LineAttribute(LineAttribute.SOLID, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } else { - lineAttr = new LineAttribute(LineAttribute.MARK, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } - newGraph.setData(datum, lineAttr); - // - // add to lineKey - // - if(descrip == null) { - xLabel = ((SGTLine)datum).getXMetaData().getName(); - lineTitle = new SGLabel("line title", xLabel, new Point2D.Double(0.0, 0.0)); - } else { - lineTitle = new SGLabel("line title", descrip, new Point2D.Double(0.0, 0.0)); - } - lineTitle.setHeightP(keyHeight_); - lineKey_.addLineGraph((LineCartesianRenderer)newGraph.getRenderer(), lineTitle); - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - int nrow = vRect.height/lineKey_.getRowHeight(); - keyPane_.setScrollableUnitIncrement(1, lineKey_.getRowHeight()); - keyPane_.setScrollableBlockIncrement(vRect.width, - lineKey_.getRowHeight()*nrow); - } - } - } - } - /** - * Flip the zaxis. Reverse the direction of the z axis by changing the sign - * of the axis values and isBackward flag. - */ - private SGTData flipZ(SGTData in) { - SGTMetaData zmetaout; - SGTMetaData zmetain; - SimpleLine out = null; - SGTLine line = (SGTLine) in; - double[] values; - double[] newValues; - values = line.getYArray(); - newValues = new double[values.length]; - for(int i=0; i < values.length; i++) { - newValues[i] = -values[i]; - } - out = new SimpleLine(line.getXArray(), newValues, line.getTitle()); - zmetain = line.getYMetaData(); - zmetaout = new SGTMetaData(zmetain.getName(), zmetain.getUnits(), - !zmetain.isReversed(), zmetain.isModulo()); - zmetaout.setModuloValue(zmetain.getModuloValue()); - zmetaout.setModuloTime(zmetain.getModuloTime()); - out.setXMetaData(line.getXMetaData()); - out.setYMetaData(zmetaout); - return (SGTData)out; - } - /** - * Clear the current zoom. - */ - public void resetZoom() { - SGTData data; - Range2D xRange, yRange; - boolean data_good = false; - double save; - - inZoom_ = false; - // - // loop over data sets, getting ranges - // - Range2D xTotalRange = new Range2D(); - Range2D yTotalRange = new Range2D(); - - boolean first = true; - - for (Enumeration e = data_.elements() ; e.hasMoreElements() ;) { - data = (SGTData)e.nextElement(); - xRange = findRange((SGTLine)data, X_AXIS); - yRange = findRange((SGTLine)data, Y_AXIS); - if(!((SGTLine)data).getYMetaData().isReversed()) { - save = yRange.start; - yRange.start = yRange.end; - yRange.end = save; - } - if(first) { - if(Double.isNaN(xRange.start) || Double.isNaN(yRange.start)) { - first = true; - } else { - first = false; - data_good = true; - xTotalRange = new Range2D(xRange.start, xRange.end); - yTotalRange = new Range2D(yRange.start, yRange.end); - } - } else { - if(!Double.isNaN(xRange.start) && !Double.isNaN(yRange.start)) { - data_good = true; - xTotalRange.start = Math.min(xTotalRange.start, xRange.start); - xTotalRange.end = Math.max(xTotalRange.end, xRange.end); - if(!((SGTLine)data).getYMetaData().isReversed()) { - yTotalRange.start = Math.max(yTotalRange.start, yRange.start); - yTotalRange.end = Math.min(yTotalRange.end, yRange.end); - } else { - yTotalRange.start = Math.min(yTotalRange.start, yRange.start); - yTotalRange.end = Math.max(yTotalRange.end, yRange.end); - } - } - } - } - if(data_good) { - try { - setRange(new Domain(xTotalRange, yTotalRange), false); - } catch (PropertyVetoException e) { - System.out.println("zoom reset denied! " + e); - } - } - } - /** - * Set the x and y range of the domain. - * - * @param range new domain - */ - public void setRange(Domain domain) throws PropertyVetoException { - setRange(domain, true); - } - public void setRange(Domain domain, boolean testZUp) - throws PropertyVetoException { - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - Domain oldRange = new Domain(xt.getRangeU(), - yt.getRangeU()); - if(!domain.equals(oldRange)) { - setBatch(true, "JLineProfileLayout: setRange"); - vetos_.fireVetoableChange("domainRange", oldRange, domain); - - inZoom_ = true; - - if(!domain.isXTime()) { - setXRange(domain.getXRange()); - } - if(!domain.isYTime()) { - setYRange(domain.getYRange(), testZUp); - } - changes_.firePropertyChange("domainRange", oldRange, domain); - setBatch(false, "JLineProfileLayout: setRange"); - } - } - public void setRangeNoVeto(Domain domain) { - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - Domain oldRange = new Domain(xt.getRangeU(), - yt.getRangeU()); - // - // clipping? hack fix. how should clipping be done for - // external range sets? - // - setBatch(true, "JLineProfileLayout: setRangeNoVeto"); - inZoom_ = true; - setClipping(true); - - if(!domain.isXTime()) { - setXRange(domain.getXRange()); - } - if(!domain.isYTime()) { - setYRange(domain.getYRange(),false); - } - setBatch(false, "JLineProfileLayout: setRangeNoVeto"); - // changes_.firePropertyChange("domainRange", oldRange, domain); - } - /** - * Reset the x range. This method is designed to provide - * zooming functionality. - * - * @param rnge new x range - */ - void setXRange(Range2D rnge) { - Point2D.Double origin; - PlainAxis xbot, yleft; - Range2D xr, yr, xnRange; - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - xnRange = Graph.computeRange(rnge, 6); - xt.setRangeU(xnRange); - try { - xbot = (PlainAxis)graph.getXAxis("Bottom Axis"); - yleft = (PlainAxis)graph.getYAxis("Left Axis"); - - xbot.setRangeU(xnRange); - xbot.setDeltaU(xnRange.delta); - - xr = xbot.getRangeU(); - yr = yleft.getRangeU(); - origin = new Point2D.Double(xr.start, yr.start); - xbot.setLocationU(origin); - - yleft.setLocationU(origin); - // - // set clipping - // - if(clipping_) { - setAllClip(xr.start, xr.end, yr.start, yr.end); - } else { - setAllClipping(false); - } - } catch (AxisNotFoundException e) {} - } - /** - * Reset the y range. This method is designed to provide - * zooming functionality. - * - * @param rnge new y range - */ - void setYRange(Range2D rnge) { - setYRange(rnge, true); - } - - /** - * Reset the y range. This method is designed to provide - * zooming functionality. - * - * @param rnge new y range - * @param testZUp test to see if Z is Up - */ - void setYRange(Range2D rnge, boolean testZUp) { - SGTData grid; - Point2D.Double origin; - PlainAxis xbot, yleft; - Range2D xr, yr, ynRange; - double save; - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - if(testZUp && data_.size() > 0) { - grid = (SGTData)data_.elements().nextElement(); - if(!((SGTLine)grid).getYMetaData().isReversed()) { - save = rnge.end; - rnge.end = rnge.start; - rnge.start = save; - } - } - ynRange = Graph.computeRange(rnge, 6); - yt.setRangeU(ynRange); - try { - xbot = (PlainAxis)graph.getXAxis("Bottom Axis"); - yleft = (PlainAxis)graph.getYAxis("Left Axis"); - - yleft.setRangeU(ynRange); - yleft.setDeltaU(ynRange.delta); - - xr = xbot.getRangeU(); - yr = yleft.getRangeU(); - origin = new Point2D.Double(xr.start, yr.start); - yleft.setLocationU(origin); - - xbot.setLocationU(origin); - // - // set clipping - // - if(clipping_) { - setAllClip(xr.start, xr.end, yr.start, yr.end); - } else { - setAllClipping(false); - } - } catch (AxisNotFoundException e) {} - } - private void setAllClip(JPane pane, double xmin, double xmax, double ymin, double ymax) { - Layer ly; - Component[] comps = pane.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ly = (Layer)comps[i]; - ((CartesianGraph)ly.getGraph()).setClip(xmin, xmax, ymin, ymax); - } - } - } - private void setAllClipping(JPane pane, boolean clip) { - Layer ly; - Component[] comps = pane.getComponents(); - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ly = (Layer)comps[i]; - ((CartesianGraph)ly.getGraph()).setClipping(clip); - } - } - } - public void clear() { - data_.removeAllElements(); - ((CartesianGraph)firstLayer_.getGraph()).setRenderer(null); - removeAll(); - add(firstLayer_,0); // restore first layer - lineKey_.clearAll(); - // draw(); - // if(keyPane_ != null)keyPane_.draw(); - inZoom_ = false; - } - - public void clear(String data_id) { - Layer ly = null; - SGTData dat; - try { - ly = getLayerFromDataId(data_id); - remove(ly); - } catch (LayerNotFoundException e) {} - for(Enumeration it=data_.elements(); it.hasMoreElements();) { - dat = (SGTData)it.nextElement(); - if(dat.getId().equals(data_id)) { - data_.removeElement(dat); - } - } - lineKey_.clear(data_id); - if(getComponentCount() <= 0 || ly.equals(firstLayer_)) { - ((CartesianGraph)firstLayer_.getGraph()).setRenderer(null); - add(firstLayer_,0); // restore first layer - } - // draw(); - // if(keyPane_ != null)keyPane_.draw(); - } - - public void setKeyBoundsP(Rectangle2D.Double bounds){ - if(lineKey_ != null) { - lineKey_.setBoundsP(bounds); - } - } - public Rectangle2D.Double getKeyBoundsP() { - if(lineKey_ == null) { - return null; - } else { - return lineKey_.getBoundsP(); - } - } - - public Dimension2D getLayerSizeP() { - return new Dimension2D(xSize_, ySize_); - } - public Layer getFirstLayer() { - return firstLayer_; - } - public void setLayerSizeP(Dimension2D d) { - Component[] comps = getComponents(); - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - xMax_ = d.width - (xSize_ - xMax_); - yMax_ = d.height - (ySize_ - yMax_); - xSize_ = d.width; - ySize_ = d.height; - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ((Layer)comps[i]).setSizeP(d); - } - } - yt.setRangeP(new Range2D(yMin_, yMax_)); - xt.setRangeP(new Range2D(xMin_, xMax_)); - // - double xpos; - if(iconImage_ != null) { - Rectangle bnds = logo_.getBounds(); - xpos = firstLayer_.getXDtoP(bnds.x + bnds.width) + 0.05; - } else { - xpos = (xMin_ + xMax_)*0.5; - } - double ypos = ySize_ - 1.2f*mainTitleHeight_; - mainTitle_.setLocationP(new Point2D.Double(xpos, ypos)); - ypos = ypos - 1.2f*warnHeight_; - title2_.setLocationP(new Point2D.Double(xpos, ypos)); - ypos = ypos - 1.1f*warnHeight_; - title3_.setLocationP(new Point2D.Double(xpos, ypos)); - if(keyPane_ == null) { - lineKey_.setLocationP(new Point2D.Double(xSize_ - 0.01, ySize_)); - } - - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JPlotLayout.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JPlotLayout.java deleted file mode 100755 index 488afcd0..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/JPlotLayout.java +++ /dev/null @@ -1,2293 +0,0 @@ -/* - * $Id: JPlotLayout.java,v 1.1.1.2 2008/12/19 13:29:38 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import gov.noaa.pmel.sgt.LineKey; -import gov.noaa.pmel.sgt.PointCollectionKey; -import gov.noaa.pmel.sgt.ColorKey; -import gov.noaa.pmel.sgt.VectorKey; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.CartesianRenderer; -import gov.noaa.pmel.sgt.LineCartesianRenderer; -import gov.noaa.pmel.sgt.PointCartesianRenderer; -import gov.noaa.pmel.sgt.GridCartesianRenderer; -import gov.noaa.pmel.sgt.VectorCartesianRenderer; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.PlainAxis; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.Logo; -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.LayerNotFoundException; -import gov.noaa.pmel.sgt.Attribute; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.VectorAttribute; -import gov.noaa.pmel.sgt.Graph; -import gov.noaa.pmel.sgt.AxisNotFoundException; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.SGException; -import gov.noaa.pmel.sgt.StackedLayout; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.ColorMap; -import gov.noaa.pmel.sgt.IndexedColorMap; -import gov.noaa.pmel.sgt.TransformAccess; -import gov.noaa.pmel.sgt.DataNotFoundException; -import gov.noaa.pmel.sgt.AttributeChangeEvent; - -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.util.SoTValue; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTRange; -import gov.noaa.pmel.util.SoTDomain; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.Domain; -import gov.noaa.pmel.util.Dimension2D; -import gov.noaa.pmel.util.Rectangle2D; -import gov.noaa.pmel.util.Units; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.TimeRange; - -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.SimpleLine; -import gov.noaa.pmel.sgt.dm.SGTMetaData; -import gov.noaa.pmel.sgt.dm.Collection; -import gov.noaa.pmel.sgt.dm.PointCollection; -import gov.noaa.pmel.sgt.dm.SGTVector; - -import java.util.Enumeration; -import java.util.Vector; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Color; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.Component; -import java.awt.geom.AffineTransform; - -import java.awt.Point; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.print.*; - -import java.beans.PropertyVetoException; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -/** - * JPlotLayout creates a pre-defined graphics layout for - * SGTLine, SGTGrid, - * Collection, SGTVector, - * and PointCollection data. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.2 $, $Date: 2008/12/19 13:29:38 $ - * @since 2.0 - * @see LineCartesianRenderer - * @see PointCartesianRenderer - * @see GridCartesianRenderer - * @see VectorCartesianRenderer -**/ -public class JPlotLayout extends JGraphicLayout - implements PropertyChangeListener { - // - // save handles to unique components - // - - - /** - * @label coastline - * @link aggregation - * @undirected - */ - CartesianGraph coastLine_ = null; - Layer coastLayer_ = null; - Logo logo_; - - /** - * @label lineKey - * @link aggregation - * @undirected - */ - LineKey lineKey_; - - /** - * @label colorKey - * @link aggregation - * @undirected - */ - ColorKey colorKey_; - - /** - * @label pointKey - * @link aggregation - * @undirected - */ - PointCollectionKey pointKey_; - - VectorKey vectorKey_; - - private boolean computeScroll_ = false; - int layerCount_; - boolean revXAxis_ = false; - boolean revYAxis_ = false; - Layer firstLayer_; - boolean inZoom_ = false; - GridAttribute gAttr_ = null; - // - private boolean isXTime_ = false; - private boolean isYTime_ = false; - // - // constants - // - double xSize_ = XSIZE_; - double xMin_ = XMIN_; - double xMax_ = XMAX_; - double ySize_ = YSIZE_; - double yMin_ = YMIN_; - double yMax_ = YSIZE_ - 1.0*MAIN_TITLE_HEIGHT_ - - 2.0*WARN_HEIGHT_ - - 0.5*WARN_HEIGHT_; - // - double mainTitleHeight_ = MAIN_TITLE_HEIGHT_; - double titleHeight_ = TITLE_HEIGHT_; - double labelHeight_ = LABEL_HEIGHT_; - double warnHeight_ = WARN_HEIGHT_; - double keyHeight_ = KEY_HEIGHT_; - // - double xKeySize_ = XKEYSIZE_; - double yKeySize_ = YKEYSIZE_; - // - Color paneColor_ = PANE_COLOR; - Color keyPaneColor_ = KEYPANE_COLOR; - // - boolean autoRangeX_ = false; - boolean autoRangeY_ = false; - int autoXIntervals_ = 10; - int autoYIntervals_ = 10; - // - public static final int POINTS = 0; - public static final int LINE = 1; - public static final int GRID = 2; - public static final int VECTOR = 3; - // - private int plotType_ = -1; - // - private static final Color[] colorList_ = - { Color.blue, Color.cyan.darker(), Color.green, Color.orange.darker(), - Color.red, Color.magenta, Color.black, Color.gray}; - // {Color.red, Color.green, Color.blue, Color.cyan, - // Color.magenta, Color.yellow, Color.orange, Color.pink}; - private static final int[] markList_ = - {1, 2, 9, 15, 10, 24, 11, 44}; - - private static String LEFT_AXIS = "Left Axis"; - private static String BOTTOM_AXIS = "Bottom Axis"; - - // public JPlotLayout(SGTData dataset, String dataKey) { - // this(dataset, "", null, false); - // } - /** - * Default constructor. No Logo image is used and the LineKey - * will be in the same JPane. - */ - public JPlotLayout(SGTData dataset) { - this(dataset, "", null, false); - } - /** - * JPlotLayout constructor. Whether the data is GRID, - * POINTS, LINE, or VECTOR, isXtime, and isYTime is determined from the dataset. - * - * @param dataset the template data - * @param id identifier - * @param img Logo image - * @param is_key_pane if true LineKey is in separate pane - */ - public JPlotLayout(SGTData dataset, String id, Image img, - boolean is_key_pane) { - this(dataset instanceof SGTGrid? GRID: - (dataset instanceof PointCollection? POINTS: (dataset instanceof SGTVector? VECTOR: LINE)), - dataset.isXTime(), dataset.isYTime(), id, img, is_key_pane); - } - /** - * JPlotLayout constructor. This constructor is - * retained for backward compatability. - * - * @param isGrid if true data is grid - * @param isXtime if true x coordinate is time - * @param isYTime if true y coordinate is time - * @param id identifier - * @param img Logo image - * @param is_key_pane if true LineKey is in separate pane - */ - public JPlotLayout(boolean isGrid, boolean isXTime, - boolean isYTime, String id, Image img, - boolean is_key_pane) { - this(isGrid? GRID: LINE, - isXTime, isYTime, id, img, is_key_pane); - } - /** - * JPlotLayout constructor. All other constructors - * call this one. Data is not plotted during construction of the - * JPlotLayout object and the addData - * method must be called to associated data with this object. - * - * @param isGrid if true data is grid - * @param isPoints if true data is points - * @param isXtime if true x coordinate is time - * @param isYTime if true y coordinate is time - * @param id identifier - * @param img Logo image - * @param is_key_pane if true LineKey is in separate pane - */ - public JPlotLayout(boolean isGrid, - boolean isPoints, - boolean isXTime, - boolean isYTime, - String id, - Image img, - boolean is_key_pane) { - this(isGrid? GRID:(isPoints? POINTS: LINE), - isXTime, isYTime, id, img, is_key_pane); - } - /** - * JPlotLayout constructor. All other constructors - * call this one. Data is not plotted during construction of the - * JPlotLayout object and the addData - * method must be called to associated data with this object. - * - * @param type type of plot , POINT, GRID, LINE, or VECTOR - * @param isXtime if true x coordinate is time - * @param isYTime if true y coordinate is time - * @param id identifier - * @param img Logo image - * @param is_key_pane if true LineKey is in separate pane - */ - public JPlotLayout(int type, - boolean isXTime, - boolean isYTime, - String id, - Image img, - boolean is_key_pane) { - super(id, img, new Dimension(400,300)); - Layer layer, key_layer; - CartesianGraph graph; - LinearTransform xt, yt; - PlainAxis xbot = null; - PlainAxis yleft = null; - TimeAxis tbot = null; - TimeAxis tleft = null; - double xpos, ypos; - int halign; - ColorMap cmap; - // - // - // define default colormap - // - int[] red = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 23, 39, 55, 71, 87,103, - 119,135,151,167,183,199,215,231, - 247,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,246,228,211,193,175,158,140}; - int[] green = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 11, 27, 43, 59, 75, 91,107, - 123,139,155,171,187,203,219,235, - 251,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0}; - int[] blue = - { 0,143,159,175,191,207,223,239, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - // - isXTime_ = isXTime; - isYTime_ = isYTime; - plotType_ = type; - // - // create Pane and descendants for the LineProfile layout - // - setOpaque(true); - setLayout(new StackedLayout()); - setBackground(paneColor_); - layer = new Layer("Layer 1", new Dimension2D(xSize_, ySize_)); - firstLayer_ = layer; - if(coastLine_ == null) { - add(layer,0); - } else { - add(layer,1); - } - // - if(plotType_ == GRID) { - // SGTGrid - colorKey_ = new ColorKey(new Rectangle2D.Double(0.01, 0.01, - xKeySize_ - 0.01, 1.0), - ColorKey.BOTTOM, ColorKey.LEFT); - colorKey_.setId("Color Key"); - colorKey_.setVisible(false); - if(is_key_pane) { - colorKey_.setVAlign(ColorKey.TOP); - colorKey_.setBorderStyle(ColorKey.NO_BORDER); -// colorKey_.setBorderStyle(ColorKey.PLAIN_LINE); - colorKey_.setLocationP(new Point2D.Double(0.0, yKeySize_)); - int xdim = 500; - int ydim = (int)((double)xdim/xKeySize_*yKeySize_); - keyPane_ = new JPane("KeyPane", new Dimension(xdim,ydim)); - keyPane_.setOpaque(true); - keyPane_.setLayout(new StackedLayout()); - keyPane_.setBackground(keyPaneColor_); - key_layer = new Layer("Key Layer", new Dimension2D(xKeySize_, yKeySize_)); - keyPane_.add(key_layer); - key_layer.addChild(colorKey_); - } else { - colorKey_.setHAlign(ColorKey.CENTER); - colorKey_.setLocationP(new Point2D.Double(xSize_*0.5, 0.01)); - layer.addChild(colorKey_); - } - } else if(plotType_ == POINTS){ - // SGTPoint - pointKey_ = new PointCollectionKey(); - pointKey_.setSelectable(false); - pointKey_.setId("Point Key"); - pointKey_.setVAlign(LineKey.TOP); - if(is_key_pane) { - pointKey_.setHAlign(PointCollectionKey.LEFT); - pointKey_.setBorderStyle(PointCollectionKey.NO_BORDER); - pointKey_.setLocationP(new Point2D.Double(0.0, yKeySize_)); - int xdim = 500; - int ydim = (int)((double)xdim/xKeySize_*yKeySize_); - keyPane_ = new JPane("KeyPane", new Dimension(xdim,ydim)); - keyPane_.setOpaque(true); - keyPane_.setLayout(new StackedLayout()); - keyPane_.setBackground(keyPaneColor_); - key_layer = new Layer("Key Layer", new Dimension2D(xKeySize_, yKeySize_)); - keyPane_.add(key_layer); - key_layer.addChild(pointKey_); - } else { - pointKey_.setVAlign(PointCollectionKey.TOP); - pointKey_.setHAlign(PointCollectionKey.RIGHT); - pointKey_.setLocationP(new Point2D.Double(xSize_-0.02, ySize_-0.1)); - layer.addChild(pointKey_); - } - } else if(plotType_ == LINE) { - // SGTLine - lineKey_ = new LineKey(); - lineKey_.setSelectable(false); - lineKey_.setId("Line Key"); - lineKey_.setVAlign(LineKey.TOP); - if(is_key_pane) { - lineKey_.setHAlign(LineKey.LEFT); - lineKey_.setBorderStyle(LineKey.NO_BORDER); - lineKey_.setLocationP(new Point2D.Double(0.0, yKeySize_)); - int xdim = 500; - int ydim = (int)((double)xdim/xKeySize_*yKeySize_); - keyPane_ = new JPane("KeyPane", new Dimension(xdim,ydim)); - keyPane_.setOpaque(true); - keyPane_.setLayout(new StackedLayout()); - keyPane_.setBackground(keyPaneColor_); - key_layer = new Layer("Key Layer", new Dimension2D(xKeySize_, yKeySize_)); - keyPane_.add(key_layer); - key_layer.addChild(lineKey_); - } else { - lineKey_.setVAlign(LineKey.TOP); - lineKey_.setHAlign(LineKey.RIGHT); - lineKey_.setLocationP(new Point2D.Double(xSize_-0.02, ySize_-0.1)); - layer.addChild(lineKey_); - } - } else if(plotType_ == VECTOR) { - // SGTVector - vectorKey_ = new VectorKey(); - vectorKey_.setSelectable(false); - vectorKey_.setId("Vector Key"); - vectorKey_.setVAlign(VectorKey.TOP); - if(is_key_pane) { - vectorKey_.setHAlign(VectorKey.LEFT); - vectorKey_.setBorderStyle(VectorKey.NO_BORDER); - vectorKey_.setLocationP(new Point2D.Double(0.0, yKeySize_)); - int xdim = 500; - int ydim = (int)((double)xdim/xKeySize_*yKeySize_); - keyPane_ = new JPane("KeyPane", new Dimension(xdim,ydim)); - keyPane_.setOpaque(true); - keyPane_.setLayout(new StackedLayout()); - keyPane_.setBackground(keyPaneColor_); - key_layer = new Layer("Key Layer", new Dimension2D(xKeySize_, yKeySize_)); - keyPane_.add(key_layer); - key_layer.addChild(vectorKey_); - } else { - vectorKey_.setVAlign(VectorKey.TOP); - vectorKey_.setHAlign(VectorKey.RIGHT); - vectorKey_.setLocationP(new Point2D.Double(xSize_-0.02, ySize_-0.1)); - vectorKey_.setSelectable(true); - layer.addChild(vectorKey_); - } - } - // - // add Icon - // - if(iconImage_ != null) { - logo_ = new Logo(new Point2D.Double(0.0, ySize_), Logo.TOP, Logo.LEFT); - logo_.setImage(iconImage_); - layer.addChild(logo_); - Rectangle bnds = logo_.getBounds(); - xpos = layer.getXDtoP(bnds.x + bnds.width) + 0.05; - halign = SGLabel.LEFT; - } else { - xpos = (xMin_ + xMax_)*0.5; - halign = SGLabel.CENTER; - } - // - // title - // - ypos = ySize_ - 1.0f*mainTitleHeight_; - Font titleFont = new Font("Helvetica", Font.BOLD, 14); - mainTitle_ = new SGLabel("Line Profile Title", - "Profile Plot", - mainTitleHeight_, - new Point2D.Double(xpos, ypos), - SGLabel.BOTTOM, - halign); - mainTitle_.setFont(titleFont); - layer.addChild(mainTitle_); - ypos = ypos - 1.0f*warnHeight_; - Font title2Font = new Font("Helvetica", Font.PLAIN, 10); - title2_ = new SGLabel("Second Title", - "Warning: Browse image only", - warnHeight_, - new Point2D.Double(xpos, ypos), - SGLabel.BOTTOM, - halign); - title2_.setFont(title2Font); - layer.addChild(title2_); - ypos = ypos - 1.0f*warnHeight_; - title3_ = new SGLabel("Warning 2", - "Verify accuracy of plot before research use", - warnHeight_, - new Point2D.Double(xpos, ypos), - SGLabel.BOTTOM, - halign); - title3_.setFont(title2Font); - layer.addChild(title3_); - - layerCount_ = 0; - // - // create LineCartesianGraph and transforms - // - graph = new CartesianGraph("Profile Graph 1"); - GeoDate start = null; - GeoDate end = null; - try { - start = new GeoDate("1992-11-01", "yyyy-MM-dd"); - end = new GeoDate("1993-02-20", "yyyy-MM-dd"); - } catch (IllegalTimeValue e) {} - SoTRange xRange, yRange; - if(isXTime_) { - xRange = new SoTRange.Time(start.getTime(), end.getTime()); - } else { - xRange = new SoTRange.Double(10.0, 20.0, 2.0); - } - if(isYTime_) { - yRange = new SoTRange.Time(start.getTime(), end.getTime()); - } else { - yRange = new SoTRange.Double(400.0, 0.0, -50.0); - } - SoTPoint origin; - - xt = new LinearTransform(new Range2D(xMin_, xMax_), xRange); - yt = new LinearTransform(new Range2D(yMin_, yMax_), yRange); - origin = new SoTPoint(xRange.getStart(), yRange.getStart()); - - graph.setXTransform(xt); - graph.setYTransform(yt); - // - // create axes - // - Font axfont = new Font("Helvetica", Font.ITALIC, 14); - if(isXTime_) { - tbot = new TimeAxis(BOTTOM_AXIS, TimeAxis.AUTO); - tbot.setRangeU(xRange); - tbot.setLabelHeightP(labelHeight_); - tbot.setLocationU(origin); - tbot.setLabelFont(axfont); - graph.addXAxis(tbot); - // graph.addXAxis("Time",tbot); - } else { - xbot = new PlainAxis(BOTTOM_AXIS); - xbot.setRangeU(xRange); - xbot.setNumberSmallTics(0); - xbot.setLocationU(origin); - xbot.setLabelHeightP(labelHeight_); - xbot.setLabelFont(axfont); - graph.addXAxis(xbot); - } - if(isYTime_) { - tleft = new TimeAxis(LEFT_AXIS, TimeAxis.AUTO); - tleft.setRangeU(yRange); - tleft.setLabelHeightP(labelHeight_); - tleft.setLocationU(origin); - tleft.setLabelFont(axfont); - graph.addYAxis(tleft); - } else { - yleft = new PlainAxis(LEFT_AXIS); - yleft.setRangeU(yRange); - yleft.setNumberSmallTics(0); - yleft.setLabelHeightP(labelHeight_); - yleft.setLocationU(origin); - yleft.setLabelFont(axfont); - graph.addYAxis(yleft); - } - if(plotType_ == GRID) { - // - // create default GridAttribute, and ColorMap - // - cmap = new IndexedColorMap(red, green, blue); - LinearTransform ctrans = - new LinearTransform(0.0, (double)red.length, 0.0, 1.0); - ((IndexedColorMap)cmap).setTransform(ctrans); - gAttr_ = new GridAttribute(GridAttribute.RASTER, cmap); - gAttr_.addPropertyChangeListener(this); - colorKey_.setColorMap(cmap); - } - // - layer.setGraph(graph); - } - /** - * @todo implement getLocationSummary - */ - public String getLocationSummary(SGTData grid) { - return ""; - } - /** - * Add a Collection of lines using the default - * attributes and description. The description will be taken from - * the dependent variable name - */ - public void addData(Collection lines) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(Collection)"); - addData(lines, null, null); - } - /** - * Add a Collection of lines using the default - * description. The description will be taken from - * the dependent variable name - */ - public void addData(Collection lines, Attribute attr) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(Collection, Attribute)"); - addData(lines, attr, null); - } - - /** - * Add a PointCollection. - */ - public void addData(PointCollection points, String descrip) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(PointCollection, String)"); - addData((SGTData)points, descrip); - } - - /** - * Add a Collection of lines using the default - * attributes. - */ - public void addData(Collection lines, String descrip) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(Collection, String)"); - addData(lines, null, descrip); - } - /** - * Add a Collecdtion of lines. - */ - public void addData(Collection lines, Attribute attr, String descrip) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(Collection, Attribute, String)"); - // System.out.println("addData(Collection) called"); - for(int i=0; i < lines.size(); i++) { - SGTLine line = (SGTLine)lines.elementAt(i); - addData(line, attr, line.getTitle()); - } - } - /** - * Add data to the layout. LineKey descriptor will be - * taken from the dependent variable name. - * - * @param data datum data to be added - */ - public void addData(SGTData datum) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(SGTData)"); - addData(datum, null, null); - } - /** - * Add data to the layout. LineKey descriptor will be - * taken from the dependent variable name. - * - * @param data datum data to be added - * @param attr attribute for graphics - */ - public void addData(SGTData datum, Attribute attr) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(SGTData, Attribute)"); - addData(datum, attr, null); - } - /** - * Add data to the layout. JPlotLayout will use a - * default attribute. - */ - public void addData(SGTData datum, String descrip) { - if(Debug.DEBUG) System.out.println("JPlotLayout.addData(SGTData, String)"); - addData(datum, null, descrip); - } - /** - * Add data to the layout. Data will be added to X axis and - * Z_AXIS will be assigned to Y axis. If this is - * not the first invocation of addData a new - * Layer will be created. If overlayed, the - * Transforms from the first Layer - * will be attached and no axes will be created. If not - * overlayed, new transforms and axes will be created and - * adjusted so that the data is horizontally stacked. - * - * @param datum data to be added - * @param descrip LineKey description for datum - */ - public void addData(SGTData datum, Attribute attr, String descrip) { - if(Debug.DEBUG) { - System.out.println("JPlotLayout.addData(SGTData, Attribute, String)"); - if(attr != null && attr instanceof LineAttribute) { - System.out.println("attr = LineAttribute"); - } else { - System.out.println("attr = new LineAttribute"); - } - } - // - Layer layer, newLayer; - CartesianGraph graph, newGraph; - Axis bottom = null; - Axis left = null; - LinearTransform xt, yt; - SGLabel xtitle, ytitle, lineTitle; - SGTData data; - SGTGrid grid = null; - SGTLine line = null; - SGTVector vector = null; - PointCollection points = null; - LineAttribute lineAttr = null; - GridAttribute gridAttr = null; - PointAttribute pointAttr = null; - VectorAttribute vectorAttr = null; - String xLabel, yLabel; - SoTRange xRange = null; - SoTRange yRange = null; - SoTRange xnRange = null; - SoTRange ynRange = null; - SoTPoint origin = null; - Range2D vRange = null; - boolean data_good = true; - boolean flipX = false; - boolean flipY = false; - double save; - GeoDate savet; - int len; - boolean showColorKey = false; - // - // if(!isXTime_ && !(plotType_ == GRID)) { - // if(data_.size() == 0) setBaseUnit(Units.getBaseUnit(datum.getXMetaData())); - // datum = Units.convertToBaseUnit(datum, getBaseUnit(), - // Units.X_AXIS); - // } - // - if(data_.size() == 0) { - super.addData(datum); - // - // only one data set... - // determine range and titles from data - // - data = (SGTData)data_.firstElement(); - if(plotType_ == GRID) { - // SGTGrid - grid = (SGTGrid)data; - } else if(plotType_ == POINTS){ - // SGTPoint - points = (PointCollection)data; - } else if(plotType_ == LINE){ - // SGTLine - line = (SGTLine)data; - } else if(plotType_ == VECTOR) { - // SGTVector - vector = (SGTVector)data; - } - // - // find range of datum (grid, points, or line) - // - if(plotType_ == GRID) { - // SGTGrid - if(attr != null && attr instanceof GridAttribute) { - gridAttr = (GridAttribute)attr; - gridAttr.addPropertyChangeListener(this); - } else { - gridAttr = gAttr_; - } - addAttribute(datum, gridAttr); - showColorKey = gridAttr.isRaster(); - vRange = findRange(grid, gridAttr, Z_AXIS); - if(gridAttr.isRaster()) { - ColorMap cmap = gridAttr.getColorMap(); - if(cmap instanceof TransformAccess) { - ((TransformAccess)cmap).setRange(vRange); - } - } - xRange = findSoTRange(grid, gridAttr, X_AXIS); - yRange = findSoTRange(grid, gridAttr, Y_AXIS); - } else if((plotType_ == LINE) || (plotType_ == POINTS)){ - // SGTPoint or SGTLine - xRange = data.getXRange(); - yRange = data.getYRange(); - } else if(plotType_ == VECTOR) { - // SGTVector - xRange = findSoTRange(vector, X_AXIS); - yRange = findSoTRange(vector, Y_AXIS); - } - flipX = data.getXMetaData().isReversed(); - flipY = data.getYMetaData().isReversed(); - // - // check for good points - // - data_good = !(xRange.isStartOrEndMissing() || - yRange.isStartOrEndMissing()); - - revXAxis_ = flipX; - revYAxis_ = flipY; - - if(data_good) { - // - // flip range if data_good and flipped - // - if(flipX) { - xRange.flipStartAndEnd(); - } - if(flipY) { - yRange.flipStartAndEnd(); - } - // - // compute "Nice" range - // - if(isXTime_) { - xnRange = xRange; - } else { - if(autoRangeX_) { - xnRange = Graph.computeRange(xRange, autoXIntervals_); - } else { - xnRange = xRange; - ((SoTRange.Double)xnRange).delta = ((SoTRange.Double)Graph.computeRange(xRange, autoXIntervals_)).delta; - } - } - if(isYTime_) { - ynRange = yRange; - } else { - if(autoRangeY_) { - ynRange = Graph.computeRange(yRange, autoYIntervals_); - } else { - ynRange = yRange; - ((SoTRange.Double)ynRange).delta = ((SoTRange.Double)Graph.computeRange(yRange, autoYIntervals_)).delta; - } - } - // - // test xnRange and ynRange - // - adjustRange(xnRange); - adjustRange(ynRange); - origin = new SoTPoint(xnRange.getStart(), ynRange.getStart()); - } // data_good - // - // create labels - // - xLabel = data.getXMetaData().getName() + - " (" + data.getXMetaData().getUnits() + ")"; - yLabel = data.getYMetaData().getName() + - " (" + data.getYMetaData().getUnits() + ")"; - // - // attach information to pane and descendents - // - try { - layer = getLayer("Layer 1"); - } catch (LayerNotFoundException e) { - return; - } - graph = (CartesianGraph)layer.getGraph(); - // - // create axes - // - try { - Font tfont = new Font("Helvetica", Font.PLAIN, 14); - xtitle = new SGLabel("xaxis title", xLabel, new Point2D.Double(0.0, 0.0)); - xtitle.setFont(tfont); - xtitle.setHeightP(titleHeight_); - - bottom = graph.getXAxis(BOTTOM_AXIS); - bottom.setRangeU(xRange); - bottom.setLocationU(origin); - bottom.setTitle(xtitle); - - ytitle = new SGLabel("yaxis title", yLabel, new Point2D.Double(0.0, 0.0)); - ytitle.setFont(tfont); - ytitle.setHeightP(titleHeight_); - - left = graph.getYAxis(LEFT_AXIS); - left.setRangeU(ynRange); - left.setLocationU(origin); - left.setTitle(ytitle); - } catch (AxisNotFoundException e) {} - if(data_good) { - // - // transforms - // - xt = (LinearTransform)graph.getXTransform(); - xt.setRangeU(xnRange); - // - yt = (LinearTransform)graph.getYTransform(); - yt.setRangeU(ynRange); - } - // - // attach data - // - if(plotType_ == GRID) { - // SGTGrid - graph.setData(grid, gridAttr); - } else if(plotType_ == POINTS) { - // SGTPoint - if(attr != null && attr instanceof PointAttribute) { - pointAttr = (PointAttribute)attr; - } else { - pointAttr = new PointAttribute(markList_[layerCount_%8], - colorList_[layerCount_%8]); - pointAttr.setMarkHeightP(0.15); - pointAttr.setLabelHeightP(0.15); - pointAttr.setDrawLabel(false); - pointAttr.setLabelColor(Color.red); - pointAttr.setLabelPosition(PointAttribute.NE); - } - pointAttr.addPropertyChangeListener(this); - addAttribute(datum, pointAttr); - graph.setData(points, pointAttr); - } else if(plotType_ == LINE) { - // SGTLine - if(isYTime_) { - len = line.getXArray().length; - } else { - len = line.getYArray().length; - } - if(attr != null && attr instanceof LineAttribute) { - lineAttr = (LineAttribute)attr; - } else { - if(len >= 2) { - lineAttr = new LineAttribute(LineAttribute.SOLID, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } else { - lineAttr = new LineAttribute(LineAttribute.MARK, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } - } - lineAttr.addPropertyChangeListener(this); - addAttribute(datum, lineAttr); - graph.setData(line, lineAttr); - } else if(plotType_ == VECTOR) { - // SGTVector - if(attr != null && attr instanceof VectorAttribute) { - vectorAttr = (VectorAttribute)attr; - } else { - vectorAttr = new VectorAttribute(VectorAttribute.SCALED_HEAD, - 0.10, - Color.black, - 0.10); - } - vectorAttr.addPropertyChangeListener(this); - addAttribute(datum, vectorAttr); - graph.setData(vector, vectorAttr); - } - // - // add to lineKey - // - if(descrip == null) { - lineTitle = datum.getKeyTitle(); - if(lineTitle == null) { - lineTitle = new SGLabel("line title", - xLabel, - new Point2D.Double(0.0, 0.0)); - } - } else { - lineTitle = new SGLabel("line title", - descrip, - new Point2D.Double(0.0, 0.0)); - } - lineTitle.setHeightP(keyHeight_); - int rowHeight = 1; - if(!isShowing()) computeScroll_ = true; - if(plotType_ == GRID) { - // SGTGrid - colorKey_.setTitle(lineTitle); - colorKey_.setColorMap(gridAttr.getColorMap()); - colorKey_.setVisible(showColorKey); - } else if(plotType_ == POINTS) { - // SGTPoint - pointKey_.addPointGraph((PointCartesianRenderer)graph.getRenderer(), lineTitle); - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - if(isShowing()) rowHeight = pointKey_.getRowHeight(); - int nrow = vRect.height/rowHeight; - keyPane_.setScrollableUnitIncrement(1, rowHeight); - keyPane_.setScrollableBlockIncrement(vRect.width, rowHeight*nrow); - } - } else if(plotType_ == LINE) { - // SGTLine - lineKey_.addLineGraph((LineCartesianRenderer)graph.getRenderer(), lineTitle); - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - if(isShowing()) rowHeight = lineKey_.getRowHeight(); - int nrow = vRect.height/rowHeight; - keyPane_.setScrollableUnitIncrement(1, rowHeight); - keyPane_.setScrollableBlockIncrement(vRect.width, rowHeight*nrow); - } - } else if(plotType_ == VECTOR) { - // SGTVector - vectorKey_.addVectorGraph((VectorCartesianRenderer)graph.getRenderer(), - lineTitle); - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - if(isShowing()) rowHeight = vectorKey_.getRowHeight(); - int nrow = vRect.height/rowHeight; - keyPane_.setScrollableUnitIncrement(1, rowHeight); - keyPane_.setScrollableBlockIncrement(vRect.width, rowHeight*nrow); - } - } - // - // update coast - // - updateCoastLine(); - } else { // #of datasets - // - // grid can't have more than one data set!!!! - // more than one data set... - // add new layer - // - if(plotType_ == GRID) return; - - if(datum instanceof SGTLine) { - if(datum.getYMetaData().isReversed() != revYAxis_) { - if(Debug.DEBUG) System.out.println("New datum has reversed ZUp!"); - SGTData modified = flipY(datum); - datum = modified; - } - } - super.addData(datum); - - data_good = false; - layerCount_++; - if(isOverlayed()) { - try { - layer = getLayer("Layer 1"); - } catch (LayerNotFoundException e) { - return; - } - graph = (CartesianGraph)layer.getGraph(); - // - // transforms - // - xt = (LinearTransform)graph.getXTransform(); - yt = (LinearTransform)graph.getYTransform(); - try { - bottom = graph.getXAxis(BOTTOM_AXIS); - left = graph.getYAxis(LEFT_AXIS); - } catch (AxisNotFoundException e) {} - - if(!inZoom_) { - // - // loop over data sets, getting ranges - // - SoTRange xTotalRange = null; - SoTRange yTotalRange = null; - - boolean first = true; - - for (Enumeration e = data_.elements() ; e.hasMoreElements() ;) { - data = (SGTData)e.nextElement(); - xRange = data.getXRange(); - yRange = data.getYRange(); - flipX = data.getXMetaData().isReversed(); - flipY = data.getYMetaData().isReversed(); - - revXAxis_ = flipX; - revYAxis_ = flipY; - - if(flipX) { - xRange.flipStartAndEnd(); - } - if(flipY) { - yRange.flipStartAndEnd(); - } - if(first) { - data_good = !(xRange.isStartOrEndMissing() || - yRange.isStartOrEndMissing()); - - if(!data_good) { - first = true; - } else { - first = false; - data_good = true; - xTotalRange = xRange; - yTotalRange = yRange; - } - } else { - // - // not first - // - data_good = !(xRange.isStartOrEndMissing() || - yRange.isStartOrEndMissing()); - if(data_good) { - xTotalRange.add(xRange); - yTotalRange.add(yRange); - } // data_good - } // first - } // loop over data elements - - if(data_good) { - if(isXTime_) { - xnRange = xTotalRange; - } else { - if(autoRangeX_) { - xnRange = Graph.computeRange(xTotalRange, autoXIntervals_); - } else { - xnRange = xTotalRange; - ((SoTRange.Double)xnRange).delta = - ((SoTRange.Double)Graph.computeRange(xTotalRange, autoXIntervals_)).delta; - } - } - if(isYTime_) { - ynRange = yTotalRange; - } else { - if(autoRangeY_) { - ynRange = Graph.computeRange(yTotalRange, autoYIntervals_); - } else { - ynRange = yTotalRange; - ((SoTRange.Double)ynRange).delta = - ((SoTRange.Double)Graph.computeRange(yTotalRange, autoYIntervals_)).delta; - } - } - // - // fix xnRange and ynRange - // - adjustRange(xnRange); - adjustRange(ynRange); - origin = new SoTPoint(xnRange.getStart(), ynRange.getStart()); - // - // axes - // - bottom.setRangeU(xnRange); - bottom.setLocationU(origin); - // - left.setRangeU(ynRange); - left.setLocationU(origin); - // - xt.setRangeU(xnRange); - yt.setRangeU(ynRange); - updateCoastLine(); - } // data_good - } // end of !inZoom_ - // - // create new layer and graph - // - newLayer = new Layer("Layer " + (layerCount_+1), new Dimension2D(xSize_, ySize_)); - newGraph = new CartesianGraph("Graph " + (layerCount_+1), xt, yt); - if(inZoom_) { - SoTRange xr = null; - SoTRange yr = null; - xr = bottom.getSoTRangeU(); - yr = left.getSoTRangeU(); - newGraph.setClip(xr, yr); - newGraph.setClipping(true); - } // inZoom_ - if(coastLine_ == null) { - add(newLayer,0); - } else { - add(newLayer,1); - } - newLayer.setGraph(newGraph); - newLayer.invalidate(); - validate(); - // - // attach data - // - if(plotType_ == POINTS) { - // SGTPoint - if(attr != null && attr instanceof PointAttribute) { - pointAttr = (PointAttribute)attr; - } else { - pointAttr = new PointAttribute(markList_[layerCount_%8], - colorList_[layerCount_%8]); - pointAttr.setMarkHeightP(0.15); - pointAttr.setLabelHeightP(0.15); - pointAttr.setDrawLabel(false); - pointAttr.setLabelColor(Color.red); - pointAttr.setLabelPosition(PointAttribute.NE); - } - pointAttr.addPropertyChangeListener(this); - addAttribute(datum, pointAttr); - newGraph.setData(datum, pointAttr); - } else if(plotType_ == LINE) { - // SGTLine - if(isYTime_) { - len = ((SGTLine)datum).getXArray().length; - } else { - len = ((SGTLine)datum).getYArray().length; - } - if(attr != null && attr instanceof LineAttribute) { - lineAttr = (LineAttribute)attr; - } else { - if(Debug.DEBUG) System.out.println("Create new LineAttribute"); - if(len >= 2) { - lineAttr = new LineAttribute(LineAttribute.SOLID, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } else { - lineAttr = new LineAttribute(LineAttribute.MARK, - markList_[layerCount_%8], - colorList_[layerCount_%8]); - } - } - lineAttr.addPropertyChangeListener(this); - addAttribute(datum, lineAttr); - newGraph.setData(datum, lineAttr); - } else if(plotType_ == VECTOR) { - // SGTVector - /** - * @todo add vector data to graph - */ - } - // - // add to lineKey - // - if(pointKey_ != null) { - if(descrip == null) { - xLabel = datum.getXMetaData().getName(); - lineTitle = new SGLabel("line title", xLabel, new Point2D.Double(0.0, 0.0)); - } else { - lineTitle = new SGLabel("line title", descrip, new Point2D.Double(0.0, 0.0)); - } - lineTitle.setHeightP(keyHeight_); - pointKey_.addPointGraph((PointCartesianRenderer)newGraph.getRenderer(), lineTitle); - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - int nrow = vRect.height/pointKey_.getRowHeight(); - keyPane_.setScrollableUnitIncrement(1, pointKey_.getRowHeight()); - keyPane_.setScrollableBlockIncrement(vRect.width, - pointKey_.getRowHeight()*nrow); - } - } - if(lineKey_ != null) { - if(descrip == null) { - xLabel = datum.getXMetaData().getName(); - lineTitle = new SGLabel("line title", xLabel, new Point2D.Double(0.0, 0.0)); - } else { - lineTitle = new SGLabel("line title", descrip, new Point2D.Double(0.0, 0.0)); - } - lineTitle.setHeightP(keyHeight_); - lineKey_.addLineGraph((LineCartesianRenderer)newGraph.getRenderer(), lineTitle); - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - int nrow = vRect.height/lineKey_.getRowHeight(); - keyPane_.setScrollableUnitIncrement(1, lineKey_.getRowHeight()); - keyPane_.setScrollableBlockIncrement(vRect.width, - lineKey_.getRowHeight()*nrow); - } - } - } // overlayed - } // # of datasets - } - /** - * If start == end fix - */ - private void adjustRange(SoTRange range) { - if(range.isTime()) { - long end = range.getEnd().getLongTime(); - long st = range.getStart().getLongTime(); - if(end == st) { - end += 30*86400000; // add 30 days - st -= 30*86400000; // substract 30 days - if(range instanceof SoTRange.Time) { - ((SoTRange.Time)range).end = end; - ((SoTRange.Time)range).start = st; - } else { - ((SoTRange.GeoDate)range).end = new GeoDate(end); - ((SoTRange.GeoDate)range).start = new GeoDate(st); - } - } - } else { - double end = ((SoTRange.Double)range).end; - double st = ((SoTRange.Double)range).start; - double dlt = ((SoTRange.Double)range).delta; - if(dlt == 0) { // delta computation failed - end = st; - } - if(end == st) { - if(end == 0.0) { - st = -1.0; - end = 1.0; - } else { - if(end > 0.0) { - end = 1.1*end; - } else { - end = 0.9*end; - } - if(st > 0.0) { - st = 0.9*st; - } else { - st = 1.1*st; - } - } - ((SoTRange.Double)range).end = end; - ((SoTRange.Double)range).start = st; - ((SoTRange.Double)range).delta = - ((SoTRange.Double)Graph.computeRange(range, 10)).delta; - } // end == st - } // isTime() - } - /** - * Flip the yaxis. Reverse the direction of the y axis by changing the sign - * of the axis values and isReversed flag. - */ - private SGTData flipY(SGTData in) { - SGTMetaData zmetaout; - SGTMetaData zmetain; - SimpleLine out = null; - SGTLine line = (SGTLine) in; - double[] values; - double[] newValues; - values = line.getYArray(); - newValues = new double[values.length]; - for(int i=0; i < values.length; i++) { - newValues[i] = -values[i]; - } - out = new SimpleLine(line.getXArray(), newValues, line.getTitle()); - zmetain = line.getYMetaData(); - zmetaout = new SGTMetaData(zmetain.getName(), zmetain.getUnits(), - zmetain.isReversed(), zmetain.isModulo()); - zmetaout.setModuloValue(zmetain.getModuloValue()); - zmetaout.setModuloTime(zmetain.getModuloTime()); - out.setXMetaData(line.getXMetaData()); - out.setYMetaData(zmetaout); - return (SGTData)out; - } - - public void resetZoom() { - Attribute attr; - GridAttribute gridAttr = null; - SGTData data; - SoTRange xRange = null; - SoTRange yRange = null; - SoTRange xTotalRange = null; - SoTRange yTotalRange = null; - boolean data_good = false; - boolean flipY = false; - boolean flipX = false; - double save; - GeoDate savet; - boolean batch = isBatch(); - - setBatch(true, "JPlotLayout: resetZoom"); - inZoom_ = false; - setAllClipping(false); - setClipping(false); - // - // loop over data sets, getting ranges - // - boolean first = true; - Enumeration e = data_.elements(); - while (e.hasMoreElements()) { - data = (SGTData)e.nextElement(); - try { - attr = getAttribute(data); - } catch(DataNotFoundException except) { - System.out.println(except); - attr = null; - } - if(plotType_ == GRID) { - // SGTGrid - if(attr != null && attr instanceof GridAttribute) { - gridAttr = (GridAttribute)attr; - } else { - gridAttr = gAttr_; - } - - xRange = findSoTRange((SGTGrid)data, gridAttr, X_AXIS); - yRange = findSoTRange((SGTGrid)data, gridAttr, Y_AXIS); - } else if((plotType_ == POINTS) || (plotType_ == LINE)) { - // SGTPoint or SGTLine - xRange = data.getXRange(); - yRange = data.getYRange(); - } else if(plotType_ == VECTOR) { - // SGTVector - xRange = findSoTRange((SGTVector)data, X_AXIS); - yRange = findSoTRange((SGTVector)data, Y_AXIS); - } - flipX = data.getXMetaData().isReversed(); - flipY = data.getYMetaData().isReversed(); - - revXAxis_ = flipX; - revYAxis_ = flipY; - - if(flipX) { - xRange.flipStartAndEnd(); - } - if(flipY) { - yRange.flipStartAndEnd(); - } - if(first) { - data_good = !(xRange.isStartOrEndMissing() || - yRange.isStartOrEndMissing()); - - if(!data_good) { - first = true; - } else { - first = false; - data_good = true; - xTotalRange = xRange; - yTotalRange = yRange; - } - } else { - data_good = !(xRange.isStartOrEndMissing() || - yRange.isStartOrEndMissing()); - if(data_good) { - xTotalRange.add(xRange); - yTotalRange.add(yRange); - } // data_good - } // first - } // for loop - // - // fix ranges - // - if(xTotalRange != null && yTotalRange != null) { - adjustRange(xTotalRange); - adjustRange(yTotalRange); - if(data_good) { - try { - setRange(new SoTDomain(xTotalRange, yTotalRange, flipX, flipY)); - } catch (PropertyVetoException ve) { - System.out.println("zoom reset denied! " + ve); - } - } - } - // turn off clipping and clip coastline - // - inZoom_ = false; - updateCoastLine(); - if(!batch) setBatch(false, "JPlotLayout: resetZoom"); - } - - public Domain getRange() { - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - Range2D xr = null; - Range2D yr = null; - TimeRange tr = null; - if(xt.isTime()) { - tr = xt.getTimeRangeU(); - } else { - xr = xt.getRangeU(); - } - if(yt.isTime()) { - tr = yt.getTimeRangeU(); - } else { - yr = yt.getRangeU(); - } - if(xt.isTime()) { - return new Domain(tr, yr); - } else if(yt.isTime()) { - return new Domain(xr, tr); - } else { - return new Domain(xr, yr); - } - } - /** - * Set the x and y range of the domain. - * - * @param reversed the y axis data is reversed - */ - public void setRange(SoTDomain std) - throws PropertyVetoException { - Domain domain = new Domain(); - if(std.isXTime()) { - SoTRange range = std.getXRange(); - if(range instanceof SoTRange.Time) { - SoTRange.Time tgeo = (SoTRange.Time)range; - domain.setXRange(new TimeRange(tgeo.start, tgeo.end)); - } else { - SoTRange.GeoDate geo = (SoTRange.GeoDate)range; - domain.setXRange(new TimeRange(geo.start, geo.end)); - } - } else { - SoTRange.Double dbl = (SoTRange.Double)std.getXRange(); - domain.setXRange(new Range2D(dbl.start, dbl.end, dbl.delta)); - } - if(std.isYTime()) { - SoTRange range = std.getYRange(); - if(range instanceof SoTRange.Time) { - SoTRange.Time tgeo = (SoTRange.Time)range; - domain.setYRange(new TimeRange(tgeo.start, tgeo.end)); - } else { - SoTRange.GeoDate geo = (SoTRange.GeoDate)range; - domain.setYRange(new TimeRange(geo.start, geo.end)); - } - } else { - SoTRange.Double dbl = (SoTRange.Double)std.getYRange(); - domain.setYRange(new Range2D(dbl.start, dbl.end, dbl.delta)); - } - domain.setXReversed(std.isXReversed()); - domain.setYReversed(std.isYReversed()); - setRange(domain); - } - - /** - * Set the x and y range of the domain. - *
Property Change: domainRange. - * - * @param reversed y axis data is reversed - */ - public void setRange(Domain domain) throws PropertyVetoException { - Domain oldRange = getRange(); - if(!domain.equals(oldRange)) { - boolean batch = isBatch(); - setBatch(true, "JPlotLayout: setRange"); - vetos_.fireVetoableChange("domainRange", oldRange, domain); - - inZoom_ = true; - - if(!domain.isXTime()) { - setXRange(domain.getXRange()); - } else { - setXRange(domain.getTimeRange()); - } - if(!domain.isYTime()) { - setYRange(domain.getYRange(), domain.isYReversed()); - } else { - setYRange(domain.getTimeRange()); - } - changes_.firePropertyChange("domainRange", oldRange, domain); - if(!batch) setBatch(false, "JPlotLayout: setRange"); - updateCoastLine(); - } - } - - /** - * Set the x and y range of the domain. - */ - public void setRangeNoVeto(Domain domain) { - // - // clipping? hack fix. how should clipping be done for - // external range sets? - // - if(Debug.DEBUG) System.out.println("setRangeNoVeto: " + domain.toString()); - boolean batch = isBatch(); - setBatch(true, "JPlotLayout: setRangeNoVeto"); - inZoom_ = true; - setClipping(true); - - if(!domain.isXTime()) { - setXRange(domain.getXRange()); - } else { - setXRange(domain.getTimeRange()); - } - if(!domain.isYTime()) { - setYRange(domain.getYRange(), domain.isYReversed()); - } else { - setYRange(domain.getTimeRange()); - } - if(!batch) setBatch(false, "JPlotLayout: setRangeNoVeto"); - updateCoastLine(); - // changes_.firePropertyChange("domainRange", oldRange, domain); - } - /** - * Reset the x range. This method is designed to provide - * zooming functionality. - * - * @param trnge new x range - */ - void setXRange(TimeRange trnge) { - Axis bottom; - Axis left; - SoTRange yr; - SoTRange xr = new SoTRange.Time(trnge); - SoTPoint origin; - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - xt.setRangeU(xr); - try { - bottom = graph.getXAxis(BOTTOM_AXIS); - left = graph.getYAxis(LEFT_AXIS); - bottom.setRangeU(xr); - - yr = left.getSoTRangeU(); - origin = new SoTPoint(xr.getStart(), yr.getStart()); - - bottom.setLocationU(origin); - left.setLocationU(origin); - - // - // set clipping - // - if(clipping_) { - setAllClip(xr, yr); - } else { - setAllClipping(false); - } - } catch (AxisNotFoundException e) {} - } - /** - * Reset the x range. This method is designed to provide - * zooming functionality. - * - * @param rnge new x range - */ - void setXRange(Range2D rnge) { - Axis bottom; - Axis left; - SoTRange xr = new SoTRange.Double(rnge); - SoTRange yr; - SoTPoint origin; - SoTRange xnRange; - double save; - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - if(Debug.DEBUG) System.out.println("setXRange start, end, delta = " + - rnge.start + ", " + rnge.end + ", " + rnge.delta); - if(autoRangeX_) { - xnRange = Graph.computeRange(xr, autoXIntervals_); - } else { - xnRange = xr; - ((SoTRange.Double)xnRange).delta = - ((SoTRange.Double)Graph.computeRange(xr, autoXIntervals_)).delta; - } - xt.setRangeU(xnRange); - try { - bottom = graph.getXAxis(BOTTOM_AXIS); - left = graph.getYAxis(LEFT_AXIS); - yr = left.getSoTRangeU(); - - bottom.setRangeU(xnRange); - - xr = bottom.getSoTRangeU(); - origin = new SoTPoint(xr.getStart(), yr.getStart()); - bottom.setLocationU(origin); - left.setLocationU(origin); - // - // set clipping - // - if(clipping_) { - setAllClip(xr, yr); - } else { - setAllClipping(false); - } - } catch (AxisNotFoundException e) {} - } - /** - * Reset the y range. This method is designed to provide - * zooming functionality. - * - * @param trnge new x range - */ - void setYRange(TimeRange trnge) { - Axis bottom; - Axis left; - SoTRange xr; - SoTRange yr = new SoTRange.Time(trnge); - SoTPoint origin; - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - yt.setRangeU(yr); - try { - bottom = graph.getXAxis(BOTTOM_AXIS); - left = graph.getYAxis(LEFT_AXIS); - left.setRangeU(yr); - - xr = bottom.getSoTRangeU(); - origin = new SoTPoint(xr.getStart(), yr.getStart()); - left.setLocationU(origin); - - bottom.setLocationU(origin); - // - // set clipping - // - if(clipping_) { - setAllClip(xr, yr); - } else { - setAllClipping(false); - } - } catch (AxisNotFoundException e) {} - } - /** - * Reset the y range. This method is designed to provide - * zooming functionality. - * - * @param rnge new y range - */ - void setYRange(Range2D rnge) { - setYRange(rnge, true); - } - - /** - * Reset the y range. This method is designed to provide - * zooming functionality. - * - * @param rnge new y range - * @param reversed data is reversed - */ - void setYRange(Range2D rnge, boolean reversed) { - SGTData grid; - Axis bottom; - Axis left; - SoTRange xr; - SoTRange yr = new SoTRange.Double(rnge); - SoTRange ynRange; - SoTPoint origin; - double save; - boolean flip; - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); -/* if(testZUp && data_.size() > 0) { - grid = (SGTData)data_.elements().nextElement(); - if(grid.getYMetaData().isReversed()) { - yr.flipStartAndEnd(); - } - } */ - if(!data_.isEmpty()) { - grid = (SGTData)data_.elements().nextElement(); - if(data_.size() > 0 && (reversed != grid.getYMetaData().isReversed())) { - yr.flipStartAndEnd(); - } - } - if(autoRangeY_) { - ynRange = Graph.computeRange(yr, autoYIntervals_); - } else { - ynRange = yr; - ((SoTRange.Double)ynRange).delta = - ((SoTRange.Double)Graph.computeRange(yr, autoYIntervals_)).delta; - } - // if(revYAxis_) { - // save = ynRange.end; - // ynRange.end = ynRange.start; - // ynRange.start = save; - // ynRange.delta = -ynRange.delta; - // } - yt.setRangeU(ynRange); - try { - bottom = graph.getXAxis(BOTTOM_AXIS); - left = graph.getYAxis(LEFT_AXIS); - xr = bottom.getSoTRangeU(); - left.setRangeU(ynRange); - - yr = left.getSoTRangeU(); - origin = new SoTPoint(xr.getStart(), yr.getStart()); - left.setLocationU(origin); - bottom.setLocationU(origin); - - // - // set clipping - // - if(clipping_) { - setAllClip(xr, yr); - } else { - setAllClipping(false); - } - } catch (AxisNotFoundException e) {} - } - /** - * Find a dataset from the data's id. - * - * @param data_id the id - * @return SGTData - */ - public SGTData getData(String data_id) { - try { - Layer ly = getLayerFromDataId(data_id); - if(ly != null) { - CartesianRenderer rend = ((CartesianGraph)ly.getGraph()).getRenderer(); - if(rend != null) { - if(rend instanceof LineCartesianRenderer) { - return (SGTData)((LineCartesianRenderer)rend).getLine(); - } else if(rend instanceof GridCartesianRenderer) { - return (SGTData)((GridCartesianRenderer)rend).getGrid(); - } - } - } - } catch (LayerNotFoundException e) {} - return null; - } - /** - * Find a dataset from the renderer. - * - * @param rend the renderer - * @return SGTData - */ - public SGTData getData(CartesianRenderer rend) { - if(rend instanceof LineCartesianRenderer) { - return (SGTData)((LineCartesianRenderer)rend).getLine(); - } else if(rend instanceof GridCartesianRenderer) { - return (SGTData)((GridCartesianRenderer)rend).getGrid(); - } - return null; - } - /** - * Remove all data from the JPlotLayout - */ - public void clear() { - data_.removeAllElements(); - ((CartesianGraph)firstLayer_.getGraph()).setRenderer(null); - removeAll(); - add(firstLayer_,0); // restore first layer - if(coastLine_ != null) add(coastLayer_, 0); - if(lineKey_ != null) - lineKey_.clearAll(); - if(pointKey_ != null) - pointKey_.clearAll(); - inZoom_ = false; - } - /** - * Remove a specific dataset from the JPlotLayout - * - * @param data_id the data id - */ - public void clear(String data_id) { - Layer ly = null; - SGTData dat; - try { - ly = getLayerFromDataId(data_id); - remove(ly); - } catch (LayerNotFoundException e) {} - for(Enumeration it=data_.elements(); it.hasMoreElements();) { - dat = (SGTData)it.nextElement(); - if(dat.getId().equals(data_id)) { - data_.removeElement(dat); - } - } - if(lineKey_ != null) - lineKey_.clear(data_id); - if(pointKey_ != null) - pointKey_.clear(data_id); - if(getComponentCount() <= 0 || ly.equals(firstLayer_)) { - ((CartesianGraph)firstLayer_.getGraph()).setRenderer(null); - add(firstLayer_,0); // restore first layer - } - } - /** - * Get the JPlotLayout layer size in physical - * coordinates. - */ - public Dimension2D getLayerSizeP() { - return new Dimension2D(xSize_, ySize_); - } - - public Layer getFirstLayer() { - return firstLayer_; - } - /** - * Set the axes origin in physical units - */ - public void setAxesOriginP(Point2D.Double pt) { - xMin_ = pt.x; - yMin_ = pt.y; - } - /** - * @since 3.0 - */ - public SoTDomain getGraphDomain() { - SoTRange xRange = null; - SoTRange yRange = null; - CartesianGraph graph = null; - try { - Layer layer = getLayer("Layer 1"); - graph = (CartesianGraph)layer.getGraph(); - } catch (LayerNotFoundException e) { - return null; - } - try { - Axis bottom = graph.getXAxis(BOTTOM_AXIS); - Axis left = graph.getYAxis(LEFT_AXIS); - xRange = bottom.getSoTRangeU(); - yRange = left.getSoTRangeU(); - } catch (AxisNotFoundException e) { - return null; - } - return new SoTDomain(xRange, yRange); - } - /** - * Set the layer size in physical units - */ - public void setLayerSizeP(Dimension2D d) { - Component[] comps = getComponents(); - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - xMax_ = d.width - (xSize_ - xMax_); - yMax_ = d.height - (ySize_ - yMax_); - xSize_ = d.width; - ySize_ = d.height; - for(int i=0; i < comps.length; i++) { - if(comps[i] instanceof Layer) { - ((Layer)comps[i]).setSizeP(d); - } - } - yt.setRangeP(new Range2D(yMin_, yMax_)); - xt.setRangeP(new Range2D(xMin_, xMax_)); - // - double xpos; - if(iconImage_ != null) { - Rectangle bnds = logo_.getBounds(); - xpos = firstLayer_.getXDtoP(bnds.x + bnds.width) + 0.05; - } else { - xpos = (xMin_ + xMax_)*0.5; - } - double ypos = ySize_ - 1.0f*mainTitleHeight_; - mainTitle_.setLocationP(new Point2D.Double(xpos, ypos)); - ypos = ypos - 1.0f*warnHeight_; - title2_.setLocationP(new Point2D.Double(xpos, ypos)); - ypos = ypos - 1.0f*warnHeight_; - title3_.setLocationP(new Point2D.Double(xpos, ypos)); - // if(plotType_ == GRID) { - // if(keyPane_ == null) { - // colorKey_.setLocationP(new Point2D.Double(xSize_*0.5, 0.0)); - // } - // } else { - // if(keyPane_ == null) { - // lineKey_.setLocationP(new Point2D.Double(xSize_*0.5, 0.01)); - // } - // } - } - /** - * Set the main and secondary label heights in physical units - * - * @param main main label height - * @param second second and third label height - */ - public void setTitleHeightP(double main, double second) { -// mainTitleHeight_ = main; -// warnHeight_ = second; - // - // title - // - double ypos = ySize_ - 1.0f*main; - double xpos = mainTitle_.getLocationP().x; - boolean batch = isBatch(); - setBatch(true, "JPlotLayout: setTitleHeightP"); - if(main != mainTitleHeight_) { - mainTitleHeight_ = main; - mainTitle_.setHeightP(main); - mainTitle_.setLocationP(new Point2D.Double(xpos, ypos)); - } - if(second != warnHeight_) { - warnHeight_ = second; - ypos = ypos - 1.0f*second; - title2_.setHeightP(second); - title2_.setLocationP(new Point2D.Double(xpos, ypos)); - ypos = ypos - 1.0f*warnHeight_; - title3_.setHeightP(second); - title3_.setLocationP(new Point2D.Double(xpos, ypos)); - } - if(!batch) setBatch(false, "JPlotLayout: setTitleHeightP"); - } - /** - * Get main label height in physical units - */ - public double getMainTitleHeightP() { - return mainTitleHeight_; - } - /** - * Get second and third label heights in physical units - */ - public double getSecondaryTitleHeightP() { - return warnHeight_; - } - /** - * Set the key size in physical units - */ - public void setKeyBoundsP(Rectangle2D.Double bounds){ - if((plotType_ == GRID) && (colorKey_ != null)) { - // SGTGrid - colorKey_.setBoundsP(bounds); - } else if((plotType_ == POINTS) && (pointKey_ != null)) { - // SGTPoint - pointKey_.setBoundsP(bounds); - } else if((plotType_ == LINE) && (lineKey_ != null)) { - // SGTLine - lineKey_.setBoundsP(bounds); - } else if((plotType_ == VECTOR) && (vectorKey_ != null)) { - // SGTVector - vectorKey_.setBoundsP(bounds); - } - } - /** - * Get the key size in physical units - */ - public Rectangle2D.Double getKeyBoundsP() { - if((plotType_ == GRID) && (colorKey_ != null)) { - // SGTGrid - return colorKey_.getBoundsP(); - } else if((plotType_ == POINTS) && (pointKey_ != null)) { - // SGTPoint - return pointKey_.getBoundsP(); - } else if((plotType_ == LINE) && (lineKey_ != null)) { - // SGTLine - return lineKey_.getBoundsP(); - } else if((plotType_ == VECTOR) && (vectorKey_ != null)) { - // SGTVector - return vectorKey_.getBoundsP(); - } - return null; - } - /** - * Set the key alignment - * - * @param vert vertical alignment - * @param horz horizontal alignment - * - * @see ColorKey - * @see LineKey - * @see PointCollectionKey - */ - public void setKeyAlignment(int vert, int horz) { - if((plotType_ == GRID) && (colorKey_ != null)) { - // SGTGrid - colorKey_.setAlign(vert, horz); - } else if((plotType_ == POINTS) && (pointKey_ != null)) { - // SGTPoint - pointKey_.setAlign(vert, horz); - } else if((plotType_ == LINE) && (lineKey_ != null)) { - // SGTLine - lineKey_.setAlign(vert, horz); - } else if((plotType_ == VECTOR) && (vectorKey_ != null)) { - // SGTVector - vectorKey_.setAlign(vert, horz); - } - } - /** - * Get the key position in physical units - */ - public Point2D.Double getKeyPositionP() { - Rectangle2D.Double bnds = getKeyBoundsP(); - double xp = bnds.x; - double yp = bnds.y; - return new Point2D.Double(xp, yp); - } - /** - * Set the key position in physical units - */ - public void setKeyLocationP(Point2D.Double loc) { - if(keyPane_ == null) { - if(plotType_ == GRID) { - // SGTGrid - colorKey_.setLocationP(loc); - } else if(plotType_ == POINTS) { - // SGTPoint - pointKey_.setLocationP(loc); - } else if(plotType_ == LINE) { - // SGTLine - lineKey_.setLocationP(loc); - } else if(plotType_ == VECTOR) { - // SGTVector - vectorKey_.setLocationP(loc); - } - } - } - - /* reversable axes not yet fully implemented */ - // public boolean isXAxisReversed() { - // return revXAxis_; - // } - - // public boolean isYAxisReversed() { - // return revYAxis_; - // } - - // public void setXAxisReversed(boolean rev) { - // revXAxis_ = rev; - // resetAxes(); - // } - - // public void setYAxisReversed(boolean rev) { - // revYAxis_ = rev; - // resetAxes(); - // } - - private void resetAxes() { - Domain domain = getRange(); - if(domain.isXTime()) { - setXRange(domain.getTimeRange()); - } else { - setXRange(domain.getXRange()); - } - if(domain.isYTime()) { - setYRange(domain.getTimeRange()); - } else { - setYRange(domain.getYRange()); - } - // draw(); - } - /** - * Used by JPlotLayout to listen for changes in line, - * grid, vector, and point attributes. - */ - public void propertyChange(PropertyChangeEvent evt) { - if(Debug.EVENT) { - System.out.println("JPlotLayout: " + evt); - System.out.println(" " + evt.getPropertyName()); - } - if(evt.getSource() instanceof GridAttribute && - evt.getPropertyName() == "style" && (plotType_ == GRID)) { - // SGTGrid - SGTGrid grid = (SGTGrid)data_.firstElement(); - try{ - GridAttribute gridAttr = (GridAttribute)getAttribute(grid); - Range2D vRange = findRange(grid, gridAttr, Z_AXIS); - if(gridAttr.isRaster()) { - ColorMap cmap = gridAttr.getColorMap(); - if(cmap instanceof TransformAccess) { - ((TransformAccess)cmap).setRange(vRange); - } - colorKey_.setColorMap(cmap); - colorKey_.setVisible(true); - } else { - colorKey_.setVisible(false); - } - } catch (DataNotFoundException e) { - System.out.println(e); - } - if(keyPane_ != null) { - keyPane_.setModified(true, "JPlotLayout: forced setModified"); - keyPane_.setBatch(false, "JPlotLayout: propertyChange"); - } - } - if(evt.getSource() instanceof Attribute) { - boolean local = true; - if(evt instanceof AttributeChangeEvent) { - local = ((AttributeChangeEvent)evt).isLocal(); - } - if(Debug.EVENT) System.out.println("JPlotLayout: Attribute change: " + evt.getPropertyName()); - changes_.firePropertyChange(new AttributeChangeEvent(this, - "attribute", - null, - evt.getSource(), - local)); - } - } - /** - * Set the coastline. - */ - public void setCoastLine(SGTLine coast) { - if(coastLine_ == null) { - CartesianGraph graph = (CartesianGraph)firstLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - Range2D xrange = xt.getRangeU(); - Range2D yrange = yt.getRangeU(); - coastLayer_ = new Layer("CoastLine", new Dimension2D(xSize_, ySize_)); - add(coastLayer_, 0); - coastLine_ = new CartesianGraph("CoastLine Graph"); - coastLayer_.setGraph(coastLine_); - coastLine_.setXTransform(xt); - coastLine_.setYTransform(yt); - LineAttribute lattr = new LineAttribute(); - lattr.setColor(new Color(244,164, 96)); - lattr.addPropertyChangeListener(this); - coastLine_.setData(coast, lattr); - coastLine_.setClip(xrange.start, xrange.end, yrange.start, yrange.end); - coastLine_.setClipping(true); - // - coastLayer_.invalidate(); - validate(); - } - } - - void updateCoastLine() { - if(coastLine_ != null) { - CartesianGraph graph = (CartesianGraph)coastLayer_.getGraph(); - LinearTransform xt = (LinearTransform)graph.getXTransform(); - LinearTransform yt = (LinearTransform)graph.getYTransform(); - Range2D xrange = xt.getRangeU(); - Range2D yrange = yt.getRangeU(); - coastLine_.setClip(xrange.start, xrange.end, yrange.start, yrange.end); - coastLine_.setClipping(true); - coastLayer_.invalidate(); - validate(); - } - } - /** - * Implements the print method in - * java.awt.print.Printable. Overrides JPane behavior. - */ - public int print(Graphics g, PageFormat pf, int pageIndex) { - if(pageIndex > 0) { - return NO_SUCH_PAGE; - } else { - if(Debug.DEBUG) { - System.out.println("Imageable(X,Y): " + pf.getImageableX() + - ", " + pf.getImageableY()); - System.out.println("Imageable(h,w): " + pf.getImageableHeight() + - ", " + pf.getImageableWidth()); - System.out.println("Paper(h,w): " + pf.getHeight() + - ", " + pf.getWidth()); - } - Graphics2D g2 = (Graphics2D)g; - drawPage(g2, pf); - if(keyPane_ != null) { - g2.setTransform(new AffineTransform()); - Point pt = keyPane_.getLocation(); - double scale = 72.0; - double margin = 0.5; // 0.5 inches - int layoutHeight = (int)((getLayerSizeP().getHeight() + margin)*scale) - - pt.y; - int xoff = -pt.x; - Point offset = new Point(xoff, layoutHeight); - keyPane_.setPageOrigin(offset); - keyPane_.setPageVAlign(SPECIFIED_LOCATION); - keyPane_.setPageHAlign(CENTER); - g2.setClip(-1000, -1000, 5000, 5000); - keyPane_.drawPage(g2, pf, true); - } - return PAGE_EXISTS; - } - } - /** - * Turn on/off the auto range feature for the x axis. Auto range creates a - * "nice" range with a delta of 1., 2., 5. or 10^n of these. The start - * and end of the range is extended to the next full delta. - */ - public void setXAutoRange(boolean xauto) { - autoRangeX_ = xauto; - } - /** - * Turn on/off the auto range feature for the y axis. Auto range creates a - * "nice" range with a delta of 1., 2., 5. or 10^n of these. The start - * and end of the range is extended to the next full delta. - */ - public void setYAutoRange(boolean yauto) { - autoRangeY_ = yauto; - } - /** - * Turn on/off the auto range feature for the x and y axes. Auto range - * creates a "nice" range with a delta of 1., 2., 5. or 10^n of these. - * The start and end of the range is extended to the next full delta. - */ - public void setAutoRange(boolean xauto, boolean yauto) { - autoRangeX_ = xauto; - autoRangeY_ = yauto; - } - /** - * Tests if the auto range feature is enabled for the x axis. - */ - public boolean isXAutoRange() { - return autoRangeX_; - } - /** - * Tests if the auto range feature is enabled for the y axis. - */ - public boolean isYAutoRange() { - return autoRangeY_; - } - /** - * Set the approximate number of x axis intervals for auto range. - */ - public void setXAutoIntervals(int xint) { - autoXIntervals_ = xint; - } - /** - * Set the approximate number of y axis intervals for auto range. - */ - public void setYAutoIntervals(int yint) { - autoYIntervals_ = yint; - } - /** - * Set the approximate number of x and y axes intervals for auto range. - */ - public void setAutoIntervals(int xint, int yint) { - autoXIntervals_ = xint; - autoYIntervals_ = yint; - } - /** - * Return the number of intervals for the x axis. - */ - public int getXAutoIntervals() { - return autoXIntervals_; - } - /** - * Return the number of intervals for the y axis. - */ - public int getYAutoIntervals() { - return autoYIntervals_; - } - /** - * Override JPane init method. The scrolling list parameters are computed - * here if necessary. - */ - public void init() { - if(Debug.DEBUG) System.out.println("JPLotLayout: init()"); - if(computeScroll_) { - computeScroll_ = false; - int rowHeight = 1; - if(plotType_ == GRID) { - // SGTGrid - } else if(plotType_ == POINTS) { - // SGTPoint - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - rowHeight = pointKey_.getRowHeight(); - int nrow = vRect.height/rowHeight; - keyPane_.setScrollableUnitIncrement(1, rowHeight); - keyPane_.setScrollableBlockIncrement(vRect.width, rowHeight*nrow); - } - } else if(plotType_ == LINE) { - // SGTLine - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - rowHeight = lineKey_.getRowHeight(); - int nrow = vRect.height/rowHeight; - keyPane_.setScrollableUnitIncrement(1, rowHeight); - keyPane_.setScrollableBlockIncrement(vRect.width, rowHeight*nrow); - } - } else if(plotType_ == VECTOR) { - // SGTVector - if(keyPane_ != null) { - Rectangle vRect = keyPane_.getVisibleRect(); - rowHeight = vectorKey_.getRowHeight(); - int nrow = vRect.height/rowHeight; - keyPane_.setScrollableUnitIncrement(1, rowHeight); - keyPane_.setScrollableBlockIncrement(vRect.width, rowHeight*nrow); - } - } - } - } - public void finalize(){ - gAttr_ = null; - super.finalize(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/PlotMarkIcon.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/PlotMarkIcon.java deleted file mode 100755 index ca43f2f3..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/PlotMarkIcon.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * $Id: PlotMarkIcon.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import gov.noaa.pmel.sgt.PlotMark; - -import javax.swing.Icon; -import java.awt.Component; -import java.awt.Graphics; - -/** - * PlotMarkIcon extends PlotMark to create a - * icon than displays the sgt plot marks. The - * PlotMarkIcon can be used with buttons, e.g. selecting - * a plot mark for a line, or labels. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see PlotMark - * @see Icon - */ -public class PlotMarkIcon extends PlotMark implements Icon { - private int size_; - private double scale_; - /** - * Construct a PlotMarkIcon. - * - * @param mark the plot mark code - * @param size plot mark size in device units - */ - public PlotMarkIcon(int mark, int size) { - super(mark); - setSize(size); - } - /** - * Construct a PlotMarkIcon. - * - * @param mark the plot mark code - */ - public PlotMarkIcon(int mark) { - this(mark, 16); - } - /** - * Set the size of the plot mark in device units. - */ - public void setSize(int size) { - size_ = size; - scale_ = (double)size_/8.0; - } - /** - * Get the size of the plot mark - */ - public int getSize() { - return size_; - } - /** - * Paint the icon at the specified location - */ - public void paintIcon(Component c, Graphics g, int x, int y) { - int ib; - boolean penf; - int movex, movey; - int xt, yt; - int xtOld, ytOld; - - g.setColor(c.getForeground()); - - if(circle_) { - xt = (int)(scale_*2.0) + x; - yt = (int)(scale_*2.0) + y; - int w = (int)(scale_*4.0); - if(fill_) { - g.fillOval(xt, yt, w, w); - } else { - g.drawOval(xt, yt, w, w); - } - return; - } - - int[] xl = new int[lastPoint_-firstPoint_]; - int[] yl = new int[lastPoint_-firstPoint_]; - - double scale; - - xtOld = x; - ytOld = y; - - penf = false; - int i=0; - for(int count=firstPoint_; count < lastPoint_; count++) { - ib = table[count]; - if(ib == 0) { - penf=false; - } else { - movex = (ib>>3); - movey = 7 - (ib&7); - xt = (int)(scale_*(double)movex) + x; - yt = (int)(scale_*(double)movey) + y; - if(penf) { - if(fill_) { - xl[i] = xt; - yl[i] = yt; - i++; - } else { - g.drawLine(xtOld, ytOld, xt, yt); - } - } - penf = true; - xtOld = xt; - ytOld = yt; - } - } - if(fill_) g.fillPolygon(xl, yl, i); - } - /** - * Get the icon with - */ - public int getIconWidth() { - return size_; - } - /** - * Set the icon height - */ - public int getIconHeight() { - return size_; - } - - public String toString() { - return "PlotMarkIcon: " + mark_; - } -} - - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/UserIcon.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/UserIcon.java deleted file mode 100755 index 9254f290..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/UserIcon.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * $Id: UserIcon.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing; - -import gov.noaa.pmel.sgt.LayerChild; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.AbstractPane; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.util.SoTPoint; - -import javax.swing.ImageIcon; -import java.awt.Rectangle; -import java.awt.Point; -import java.awt.Image; -import java.net.URL; -import java.awt.Graphics; -import java.awt.Component; -import java.awt.Font; -import java.awt.Color; -import java.awt.FontMetrics; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeSupport; -import java.beans.VetoableChangeListener; - -/** - * UserIcon extends ImageIcon to create a - * icon than can be dragged on a sgt plot displaying a - * user defined text string along with the image. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see ValueIcon - */ -public class UserIcon extends ImageIcon implements LayerChild, Draggable { - private boolean selected_ = false; - private boolean selectable_ = true; - protected boolean moved_ = false; - protected Layer layer_ = null; - private String id_ = null; - private boolean visible_ = true; - protected Rectangle bounds_ = new Rectangle(); - protected Point2D.Double loc_ = new Point2D.Double(); - protected SoTPoint uLoc_ = new SoTPoint(0.0, 0.0); - private Font font_ = new Font("Dialog", Font.PLAIN, 10); - private Color textColor_ = Color.black; - protected PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - protected VetoableChangeSupport vetos_ = new VetoableChangeSupport(this); - - /** - * Construct a UserIcon using an image from a - * specified file. - * - * @param filename name of image file - * @param description brief textual description of the image - */ - public UserIcon(String filename, String description) { - super(filename, description); - } - /** - * Construct a UserIcon using an image from a - * specified URL. - * - * @param location URL of image file - * @param description brief textual description of the image - */ - public UserIcon(URL location, String description) { - super(location, description); - } - /** - * Construct a UserIcon using an Image. - * - * @param image the image - * @param description brief textual description of the image - */ - public UserIcon(Image image, String description) { - super(image, description); - } - /** - * Paint the icon at the specified location. - */ - public void paintIcon(Component c, Graphics g, int x, int y) { - computeBounds(g); - bounds_.x = x; - bounds_.y = y; - if(visible_) { - g.drawImage(getImage(), bounds_.x, bounds_.y, layer_.getPane().getComponent()); - int xl = bounds_.x + super.getIconWidth(); - int yl = bounds_.y + super.getIconHeight(); - g.setFont(font_); - g.setColor(textColor_); - g.drawString(getDescription(), xl, yl); - } - } - /** - * Set the font for the value label. - * - * @param font the font - */ - public void setFont(Font font) { - font_ = font; - } - /** - * Get the value label font - */ - public Font getFont() { - return font_; - } - /** - * Get the total width, icon + label. - */ - public int getIconWidth() { - return bounds_.width; - } - /** - * Get the total heigth. - */ - public int getIconHeight() { - return bounds_.height; - } - private void computeBounds(Graphics g) { - int wid = super.getIconWidth(); - int hgt = super.getIconHeight(); - g.setFont(font_); - FontMetrics fmet = g.getFontMetrics(); - bounds_.width = wid + fmet.stringWidth(getDescription()); - bounds_.height = hgt; - } - - public LayerChild copy() { - return null; - } - - public void setVisible(boolean vis) { - if(visible_ != vis) { - visible_ = vis; -// modified("UserIcon: setVisible(" + vis + ")"); - } - } - - public boolean isVisible() { - return visible_; - } - - public void draw(Graphics g) { - int x = ((CartesianGraph)layer_.getGraph()).getXUtoD(uLoc_.getX()); - int y = ((CartesianGraph)layer_.getGraph()).getYUtoD(uLoc_.getY()); - paintIcon(layer_.getPane().getComponent(), g, x, y); - } - - public String getId() { - return id_; - } - - public Layer getLayer() { - return layer_; - } - - public AbstractPane getPane() { - return layer_.getPane(); - } - - public void modified(String mess) { - if(layer_ != null) - layer_.modified(mess); - } - - public void setId(String id) { - id_ = id; - } - - public void setLayer(Layer l) { - layer_ = l; - } - public String toString() { - return "UserIcon: " + id_; - } - - public Rectangle getBounds() { - return bounds_; - } - - public boolean isSelected() { - return selected_; - } - - public void setSelected(boolean sel) { - selected_ = sel; - } - - public boolean isSelectable() { - return selectable_; - } - - public void setSelectable(boolean select) { - selectable_ = select; - } - /** - * Get the icon location in physical units. - */ - public Point2D.Double getLocationP() { - return loc_; - } - /** - * Set the icon location in physical units. - *
Property Change: location. - */ - public void setLocationP(Point2D.Double loc) { - SoTPoint pt; - loc_ = loc; - bounds_.x = layer_.getXPtoD(loc_.x); - bounds_.y = layer_.getYPtoD(loc_.y); - pt = ((CartesianGraph)layer_.getGraph()).getPtoU(loc_); - if(!pt.equals(uLoc_) || moved_) { - changes_.firePropertyChange("location", - uLoc_, - pt); - uLoc_ = pt; - moved_ = false; - } - } - /** - * Get the icon location in user units. - * - * @since 3.0 - */ - public SoTPoint getLocationU() { - return uLoc_; - } - /** - * Set the icon location in user units. Location change can't be - * vetoed. - * - * @since 3.0 - */ - public void setLocationUNoVeto(SoTPoint loc) { - moved_ = moved_ || !loc.equals(uLoc_); - uLoc_ = loc; - loc_.x = ((CartesianGraph)layer_.getGraph()).getXUtoP(uLoc_.getX()); - loc_.y = ((CartesianGraph)layer_.getGraph()).getYUtoP(uLoc_.getY()); - bounds_.x = layer_.getXPtoD(loc_.x); - bounds_.y = layer_.getYPtoD(loc_.y); - } - /** - * Set the icon location in user units. Location change can be - * vetoed. - *
Property Change: location. - * - * @since 3.0 - */ - public void setLocationU(SoTPoint loc) throws PropertyVetoException { - if(!loc.equals(uLoc_) || moved_) { - vetos_.fireVetoableChange("location", uLoc_, loc); - - changes_.firePropertyChange("location", - uLoc_, - loc); - uLoc_ = loc; - moved_ = false; - loc_.x = ((CartesianGraph)layer_.getGraph()).getXUtoP(uLoc_.getX()); - loc_.y = ((CartesianGraph)layer_.getGraph()).getYUtoP(uLoc_.getY()); - bounds_.x = layer_.getXPtoD(loc_.x); - bounds_.y = layer_.getYPtoD(loc_.y); - } - } - /** - * Set icon location in device coordinates. Locatoin change can't be - * vetoed. - */ - public void setLocationNoVeto(int x, int y) { - SoTPoint pt; - bounds_.x = x; - bounds_.y = y; - loc_.x = layer_.getXDtoP(x); - loc_.y = layer_.getYDtoP(y); - pt = ((CartesianGraph)layer_.getGraph()).getPtoU(loc_); - moved_ = moved_ || !pt.equals(uLoc_); - uLoc_ = pt; - } - /** - * Set icon location in device units - */ - public void setLocation(Point loc) { - setLocation(loc, true); - } - /** - * Set icon location in device units and optionally fire a - * PropertyChangeEvent. - */ - public void setLocation(Point loc, boolean fireEvent) { - setBounds(loc.x, loc.y, 0, 0, fireEvent); - } - /** - * Set icon bounds. - *
Property Change: location. - */ - public void setBounds(int x, int y, int width, int height) { - setBounds(x, y, width, height, true); - } - - protected void setBounds(int x, int y, int width, int height, boolean fireEvent) { - SoTPoint pt; - bounds_.x = x; - bounds_.y = y; - loc_.x = layer_.getXDtoP(x); - loc_.y = layer_.getYDtoP(y); - pt = ((CartesianGraph)layer_.getGraph()).getPtoU(loc_); - moved_ = moved_ || !pt.equals(uLoc_); - if(moved_) { - SoTPoint temp = new SoTPoint(pt); - if(fireEvent) { - changes_.firePropertyChange("location", - uLoc_, - temp); - moved_ = false; - } - uLoc_ = temp; - } - } - /** - * Set icon bounds. - */ - public void setBounds(Rectangle bounds) { - setBounds(bounds.x, bounds.y, bounds.width, bounds.height); - } - public void addVetoableChangeListener(VetoableChangeListener l) { - vetos_.addVetoableChangeListener(l); - } - public void removeVetoableChangeListener(VetoableChangeListener l) { - vetos_.removeVetoableChangeListener(l); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ValueIcon.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ValueIcon.java deleted file mode 100755 index 42b93978..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ValueIcon.java +++ /dev/null @@ -1,373 +0,0 @@ -/* - * $Id: ValueIcon.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing; - -import gov.noaa.pmel.sgt.LayerChild; -import gov.noaa.pmel.sgt.Layer; -import gov.noaa.pmel.sgt.CartesianGraph; -import gov.noaa.pmel.sgt.AbstractPane; - -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.Debug; - -import javax.swing.ImageIcon; -import java.awt.Rectangle; -import java.awt.Point; -import java.awt.Image; -import java.net.URL; -import java.awt.Graphics; -import java.awt.Component; -import java.awt.Font; -import java.awt.Color; -import java.awt.FontMetrics; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeSupport; -import java.beans.VetoableChangeListener; -/** - * ValueIcon extends ImageIcon to create a - * icon than can be dragged on a sgt plot displaying the - * local coordinates along with the image. Typically a cross-hairs - * image is used, but others can be substituted. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see UserIcon - * @see ValueIconFormat - */ -public class ValueIcon extends ImageIcon implements LayerChild, Draggable { - private int iWidth_ = 0; - private int iHeight_ = 0; - private boolean selected_ = false; - private boolean selectable_ = true; - private boolean moved_ = false; - private Layer layer_ = null; - private String id_ = null; - private boolean visible_ = true; - private Rectangle bounds_ = new Rectangle(); - private Point2D.Double loc_ = new Point2D.Double(); - private SoTPoint uLoc_ = new SoTPoint(0.0, 0.0); - private Font font_ = new Font("Dialog", Font.PLAIN, 12); - private Color textColor_ = Color.black; - private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); - private VetoableChangeSupport vetos_ = new VetoableChangeSupport(this); - private ValueIconFormat frmt_ = new ValueIconFormat("#####.##", "#.#"); - private final static String defTFrmt = "yyyy-MM-dd"; - /** - * Construct a ValueIcon using an image from a - * specified file. - * - * @param filename name of image file - * @param description brief textual description of the image - */ - public ValueIcon(String filename, String description) { - super(filename, description); - getImageSize(); - frmt_.setTimeFormat(defTFrmt); - } - /** - * Construct a ValueIcon using an image from a - * specified URL. - * - * @param location URL of image file - * @param description brief textual description of the image - */ - public ValueIcon(URL location, String description) { - super(location, description); - getImageSize(); - frmt_.setTimeFormat(defTFrmt); - } - /** - * Construct a ValueIcon using an Image. - * - * @param image the image - * @param description brief textual description of the image - */ - public ValueIcon(Image image, String description) { - super(image, description); - getImageSize(); - frmt_.setTimeFormat(defTFrmt); - } - /** - * Set format to be used to create the value string. Default format - * is new ValueIconFormat("#####.##", "#"). - * - * @param the value format - */ - public void setValueFormat(ValueIconFormat vf) { - frmt_ = vf; - } - /** - * Paint the icon at the specified location. - */ - public void paintIcon(Component c, Graphics g, int x, int y) { - String text; - double xu, yu; - double xt, yt; - // - // compute bounds - // - text = frmt_.format(uLoc_); - FontMetrics fmet = g.getFontMetrics(); - int wid = fmet.stringWidth(text); - int hgt = fmet.getMaxAscent() + fmet.getMaxDescent(); - bounds_.x = x; - bounds_.y = y; - bounds_.width = iWidth_ + wid; - bounds_.height = iHeight_ + fmet.getMaxDescent(); - // - if(visible_) { - g.drawImage(getImage(), bounds_.x, bounds_.y, layer_.getPane().getComponent()); - int xl = bounds_.x + iWidth_; - int yl = bounds_.y + iHeight_; - g.setFont(font_); - g.setColor(layer_.getPane().getComponent().getBackground()); - g.fillRect(xl,yl-fmet.getMaxAscent(),wid,hgt); - g.setColor(textColor_); - g.drawString(text, xl, yl); - } - } - /** - * Set the font for the value label. - * - * @param font the font - */ - public void setFont(Font font) { - font_ = font; - } - /** - * Get the value label font - */ - public Font getFont() { - return font_; - } - private void getImageSize() { - iWidth_ = super.getIconWidth(); - iHeight_ = super.getIconHeight(); - } - /** - * Get the total width, icon + label. - */ - public int getIconWidth() { - return bounds_.width; - } - /** - * Get the total heigth. - */ - public int getIconHeight() { - return bounds_.height; - } - public LayerChild copy() { - return null; - } - public void setVisible(boolean vis) { - if(visible_ != vis) { - visible_ = vis; - } - } - public boolean isVisible() { - return visible_; - } - - public void draw(Graphics g) { - int x = ((CartesianGraph)layer_.getGraph()).getXUtoD(uLoc_.getX()) - - iWidth_/2; - int y = ((CartesianGraph)layer_.getGraph()).getYUtoD(uLoc_.getY()) - - iHeight_/2; - paintIcon(layer_.getPane().getComponent(), g, x, y); - } - public String getId() { - return id_; - } - public Layer getLayer() { - return layer_; - } - public AbstractPane getPane() { - return layer_.getPane(); - } - public void modified(String mess) { - if(layer_ != null) - layer_.modified(mess); - } - public void setId(String id) { - id_ = id; - } - public void setLayer(Layer l) { - layer_ = l; - } - public String toString() { - return "ValueIcon: " + id_; - } - public Rectangle getBounds() { - return bounds_; - } - public boolean isSelected() { - return selected_; - } - public void setSelected(boolean sel) { - selected_ = sel; - } - public boolean isSelectable() { - return selectable_; - } - public void setSelectable(boolean select) { - selectable_ = select; - } - /** - * Get the icon location in physical units. - */ - public Point2D.Double getLocationP() { - return loc_; - } - /** - * Set the icon location in physical units. - *
Property Change: location. - */ - public void setLocationP(Point2D.Double loc) { - SoTPoint pt; - loc_ = loc; - bounds_.x = layer_.getXPtoD(loc_.x) - iWidth_/2; - bounds_.y = layer_.getYPtoD(loc_.y) - iHeight_/2; - pt = ((CartesianGraph)layer_.getGraph()).getPtoU(loc_); - if(!pt.equals(uLoc_) || moved_) { - SoTPoint temp = new SoTPoint(pt); - changes_.firePropertyChange("location", - uLoc_, - temp); - uLoc_ = temp; - moved_ = false; - } - } - /** - * Get the icon location in user units. - * - * @since 3.0 - */ - public SoTPoint getLocationU() { - return uLoc_; - } - /** - * Set the icon location in user units. Location change can't be - * vetoed. - * - * @since 3.0 - */ - public void setLocationUNoVeto(SoTPoint loc) { - moved_ = moved_ || !loc.equals(uLoc_); - uLoc_ = loc; - loc_.x = ((CartesianGraph)layer_.getGraph()).getXUtoP(uLoc_.getX()); - loc_.y = ((CartesianGraph)layer_.getGraph()).getYUtoP(uLoc_.getY()); - bounds_.x = layer_.getXPtoD(loc_.x); - bounds_.y = layer_.getYPtoD(loc_.y); - } - /** - * Set the icon location in user units. Location change can be - * vetoed. - *
Property Change: location. - * @since 3.0 - */ - public void setLocationU(SoTPoint loc) throws PropertyVetoException { - if(!loc.equals(uLoc_) || moved_) { - vetos_.fireVetoableChange("location", uLoc_, loc); - - changes_.firePropertyChange("location", - uLoc_, - loc); - uLoc_ = loc; - moved_ = false; - loc_.x = ((CartesianGraph)layer_.getGraph()).getXUtoP(uLoc_.getX()); - loc_.y = ((CartesianGraph)layer_.getGraph()).getYUtoP(uLoc_.getY()); - bounds_.x = layer_.getXPtoD(loc_.x) - iWidth_/2; - bounds_.y = layer_.getYPtoD(loc_.y) - iHeight_/2; - } - } - /** - * Set icon location in device coordinates. Locatoin change can't be - * vetoed. - */ - public void setLocationNoVeto(int x, int y) { - SoTPoint pt; - bounds_.x = x; - bounds_.y = y; - loc_.x = layer_.getXDtoP(x); - loc_.y = layer_.getYDtoP(y); - pt = ((CartesianGraph)layer_.getGraph()).getPtoU(loc_); - moved_ = moved_ || !pt.equals(uLoc_); - uLoc_ = new SoTPoint(pt); - } - /** - * Set icon location in device units - */ - public void setLocation(Point loc) { - setLocation(loc, true); - } - /** - * Set icon location in device units and optionally fire a - * PropertyChangeEvent. - * - * @since 3.0 - */ - public void setLocation(Point loc, boolean fireEvent) { - setBounds(loc.x, loc.y, 0, 0, fireEvent); - } - /** - * Set icon bounds. - *
Property Change: location. - */ - public void setBounds(int x, int y, int width, int height) { - setBounds(x, y, width, height, true); - } - - private void setBounds(int x, int y, int width, int height, boolean fireEvent) { - SoTPoint pt; - bounds_.x = x; - bounds_.y = y; - loc_.x = layer_.getXDtoP(x + iWidth_/2); - loc_.y = layer_.getYDtoP(y + iHeight_/2); - pt = ((CartesianGraph)layer_.getGraph()).getPtoU(loc_); - moved_ = moved_ || !pt.equals(uLoc_); - if(moved_) { - SoTPoint temp = new SoTPoint(pt); - if(fireEvent) { - changes_.firePropertyChange("location", - uLoc_, - temp); - moved_ = false; - } - uLoc_ = temp; - } - - } - /** - * Set icon bounds. - */ - public void setBounds(Rectangle bounds) { - setBounds(bounds.x, bounds.y, bounds.width, bounds.height); - } - public void addVetoableChangeListener(VetoableChangeListener l) { - vetos_.addVetoableChangeListener(l); - } - public void removeVetoableChangeListener(VetoableChangeListener l) { - vetos_.removeVetoableChangeListener(l); - } - public void addPropertyChangeListener(PropertyChangeListener l) { - changes_.addPropertyChangeListener(l); - } - public void removePropertyChangeListener(PropertyChangeListener l) { - changes_.removePropertyChangeListener(l); - } - -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ValueIconFormat.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ValueIconFormat.java deleted file mode 100755 index 0a4993bf..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/ValueIconFormat.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * $Id: ValueIconFormat.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing; - -import java.text.DecimalFormat; - -import gov.noaa.pmel.util.SoTPoint; -import gov.noaa.pmel.util.SoTValue; - -/** - * ValueIconFormat is used to create the value string for - * ValueIcon. This class can be extended to create more - * sophisticated formatting. For example, handling the modulo 360 of - * longitude coordinates. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @see DecimalFormat - * @see ValueIcon - */ -public class ValueIconFormat { - protected DecimalFormat xfrm_; - protected DecimalFormat yfrm_; - protected String tfrm_ = "yyyy-MM-dd HH:mm:ss z"; - /** - * Construct ValueIconFormat from x and y coordinate - * DeciamalFormats. - */ - public ValueIconFormat(String xfrmt, String yfrmt) { - xfrm_ = new DecimalFormat(xfrmt); - yfrm_ = new DecimalFormat(yfrmt); - } - /** - * Format a string using DecimalFormat for x and y - * coordinates. - */ - public String format(double x, double y) { - return "(" + xfrm_.format(x) + ", " + yfrm_.format(y) + ")"; - } - /** - * Define the time format. - * - * @since 3.0 - */ - public void setTimeFormat(String tfrmt) { - tfrm_ = tfrmt; - } - /** - * Format a string using DecimalFormat for x and y - * coordinates or GeoDate formatting for time. - * - * @since 3.0 - */ - public String format(SoTPoint pt) { - StringBuffer sbuf = new StringBuffer("("); - if(pt.isXTime()) { - sbuf.append(pt.getX().getGeoDate().toString(tfrm_)); - } else { - sbuf.append(xfrm_.format(((SoTValue.Double)pt.getX()).getValue())); - } - sbuf.append(", "); - if(pt.isYTime()) { - sbuf.append(pt.getY().getGeoDate().toString(tfrm_)); - } else { - sbuf.append(yfrm_.format(((SoTValue.Double)pt.getY()).getValue())); - } - sbuf.append(")"); - return sbuf.toString(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/package.html deleted file mode 100755 index ec2d7223..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - -Components that use the package javax.swing. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/plotmarkcodes.png b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/plotmarkcodes.png deleted file mode 100755 index 16d181a4..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/plotmarkcodes.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ArrayEditDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ArrayEditDialog.java deleted file mode 100755 index df9ea579..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ArrayEditDialog.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * $Id: ArrayEditDialog.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.util.Enumeration; -/** - * This dialog accepts an array of float's then via a graphical - * interface allows this array to be modified. For example, this - * dialog is used to edit the dash array of the LineAttribute. - * - *

Example of ArrayEditDialog use: - *

- *
- * public float[] editArray(float[] inArray) {
- *   ArrayEditDialog aed = new ArrayEditDialog();
- *   aed.setTitle("ArrayEdit");
- *   aed.setArray(inArray);
- *   if(aed.showDialog() == ArrayEditDialog.CANCEL_RESPONSE) {
- *     return inArray;
- *   } else {
- *     return aed.getFloatArray();
- *   }
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - * @LineAttribute - */ -public class ArrayEditDialog extends JDialog implements ListSelectionListener { - private DefaultListModel model_; - private int result_; - /** OK button was selected */ - public static int OK_RESPONSE = 1; - /** Cancel button was selected */ - public static int CANCEL_RESPONSE = 2; - /** - * Constructor. - */ - public ArrayEditDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(322,349); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(48,396); - mainPanel.setLayout(new GridBagLayout()); - getContentPane().add(mainPanel, "Center"); - mainPanel.add(JScrollPane1, new GridBagConstraints(0,0,1,3,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,5,5,5),155,0)); - arrayList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - JScrollPane1.getViewport().add(arrayList); - arrayList.setBounds(0,0,173,295); - JPanel2.setBorder(titledBorder2); - JPanel2.setLayout(new GridBagLayout()); - mainPanel.add(JPanel2, new GridBagConstraints(1,0,1,1,0.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,5),0,0)); - JPanel2.add(editTextField,new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,0,5),0,0)); - editButton.setToolTipText("Change value of selected element."); - editButton.setText("Change Value"); - JPanel2.add(editButton,new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,5,5),0,0)); - JPanel3.setBorder(titledBorder3); - JPanel3.setLayout(new GridBagLayout()); - mainPanel.add(JPanel3, new GridBagConstraints(1,2,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); - deleteButton.setToolTipText("Delete selected element."); - deleteButton.setText("Delete"); - JPanel3.add(deleteButton,new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,5,5),0,0)); - JPanel1.setBorder(titledBorder1); - JPanel1.setLayout(new GridBagLayout()); - mainPanel.add(JPanel1, new GridBagConstraints(1,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); - JPanel1.add(insertTextField, new GridBagConstraints(0,0,1,1,1.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,0,5),0,0)); - beforeButton.setToolTipText("Insert new item before selected element."); - beforeButton.setText("Before"); - JPanel1.add(beforeButton, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,0,5),0,0)); - afterButton.setToolTipText("Insert new item after selected element."); - afterButton.setText("After"); - JPanel1.add(afterButton, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - setTitle("Edit Array"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - editButton.addActionListener(lSymAction); - beforeButton.addActionListener(lSymAction); - afterButton.addActionListener(lSymAction); - deleteButton.addActionListener(lSymAction); - - arrayList.addListSelectionListener(this); - } - /** - * Used internally. - */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public ArrayEditDialog(String title) { - this(); - setTitle(title); - } - /** Default constructor */ - public ArrayEditDialog() { - this((Frame)null); - } - /** - * Make the dialog visible. - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == ArrayEditDialog.this) - ArrayEditDialog_WindowClosing(event); - } - } - - void ArrayEditDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JPanel mainPanel = new javax.swing.JPanel(); - javax.swing.JScrollPane JScrollPane1 = new javax.swing.JScrollPane(); - javax.swing.JList arrayList = new javax.swing.JList(); - javax.swing.JPanel JPanel2 = new javax.swing.JPanel(); - javax.swing.JTextField editTextField = new javax.swing.JTextField(); - javax.swing.JButton editButton = new javax.swing.JButton(); - javax.swing.JPanel JPanel3 = new javax.swing.JPanel(); - javax.swing.JButton deleteButton = new javax.swing.JButton(); - javax.swing.JPanel JPanel1 = new javax.swing.JPanel(); - javax.swing.JTextField insertTextField = new javax.swing.JTextField(); - javax.swing.JButton beforeButton = new javax.swing.JButton(); - javax.swing.JButton afterButton = new javax.swing.JButton(); - javax.swing.border.TitledBorder titledBorder1 = new javax.swing.border.TitledBorder("Insert Element"); - javax.swing.border.TitledBorder titledBorder2 = new javax.swing.border.TitledBorder("Edit Element"); - javax.swing.border.TitledBorder titledBorder3 = new javax.swing.border.TitledBorder("Delete Element"); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == editButton) - editButton_actionPerformed(event); - else if (object == beforeButton) - beforeButton_actionPerformed(event); - else if (object == afterButton) - afterButton_actionPerformed(event); - if (object == deleteButton) - deleteButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - result_ = CANCEL_RESPONSE; - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - this.setVisible(false); - } - /** - * Test entry point. - */ - public static void main(String[] args) { - float[] array = {0.0f, 2.0f, 2.5f, 3.0f, 4.5f}; - ArrayEditDialog aed = new ArrayEditDialog(); - aed.setTitle("Test ArrayEdit Dialog"); - aed.setArray(array); - if(aed.showDialog() == CANCEL_RESPONSE) { - System.out.println("Dialog Cancelled"); - } else { - float[] out = aed.getFloatArray(); - for(int i=0; i < out.length; i++) { - System.out.println("x["+i+"] = " + out[i]); - } - } - aed.setVisible(false); - aed.dispose(); - System.exit(0); - } - /** - * Show the dialog and wait for a response. - * - * @return CANCEL_RESPONSE or OK_RESPONSE - */ - public int showDialog() { - result_ = CANCEL_RESPONSE; - setModal(true); - super.setVisible(true); - return result_; - } - /** - * Initialize the array. - */ - public void setArray(float[] array) { - model_ = new DefaultListModel(); - for(int i=0; i < array.length; i++) { - model_.addElement(Float.toString(array[i])); - } - arrayList.setModel(model_); - } - /** - * Get the edited array. - */ - public float[] getFloatArray() { - float[] array = new float[model_.size()]; - Enumeration e = model_.elements(); - int index = 0; - while(e.hasMoreElements()) { - array[index] = new Float((String)e.nextElement()).floatValue(); - index++; - } - return array; - } - - void editButton_actionPerformed(java.awt.event.ActionEvent event) { - for(int i=0; i < model_.size(); i++) { - if(arrayList.isSelectedIndex(i)) { - model_.set(i, editTextField.getText()); - return; - } - } - } - - void beforeButton_actionPerformed(java.awt.event.ActionEvent event) { - for(int i=0; i < model_.size(); i++) { - if(arrayList.isSelectedIndex(i)) { - model_.insertElementAt(insertTextField.getText(), i); - return; - } - } - } - - void afterButton_actionPerformed(java.awt.event.ActionEvent event) { - for(int i=0; i < model_.size(); i++) { - if(arrayList.isSelectedIndex(i)) { - model_.insertElementAt(insertTextField.getText(), i+1); - return; - } - } - } - /** - * Internal event listener - */ - public void valueChanged(ListSelectionEvent e) { - if(e.getValueIsAdjusting()) return; - int first = e.getFirstIndex(); - int last = e.getLastIndex(); - for(int i=first; i <= last; i++) { - if(arrayList.isSelectedIndex(i)) - editTextField.setText((String)model_.get(i)); - } - } - - void deleteButton_actionPerformed(java.awt.event.ActionEvent event) { - for(int i=0; i < model_.size(); i++) { - if(arrayList.isSelectedIndex(i)) { - model_.removeElementAt(i); - return; - } - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ColorDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ColorDialog.java deleted file mode 100755 index 00cb5b89..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ColorDialog.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * $Id: ColorDialog.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing.prop; - -import java.awt.*; -import javax.swing.*; -import java.awt.event.*; -import javax.swing.border.*; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 3.0 - **/ -public class ColorDialog extends JDialog { - private JPanel panel1 = new JPanel(); - private JColorChooser colorChooserPanel = new JColorChooser(); - private JPanel alphaPanel = new JPanel(); - private JPanel buttonPanel = new JPanel(); - private JButton cancelButton = new JButton(); - private JButton okButton = new JButton(); - private TitledBorder titledBorder1; - private JLabel jLabel1 = new JLabel(); - private Border border1; - private GridBagLayout gridBagLayout1 = new GridBagLayout(); - private JTextField alphaTF = new JTextField(); - private GridBagLayout gridBagLayout2 = new GridBagLayout(); - - private Color color_ = null; - - public ColorDialog(Dialog dialog, String title, boolean modal) { - super(dialog, title, modal); - init(dialog); - } - - public ColorDialog(Frame frame, String title, boolean modal) { - super(frame, title, modal); - init(frame); - } - - private void init(Window win) { - try { - jbInit(); - pack(); - } - catch(Exception ex) { - ex.printStackTrace(); - } - if(win != null) { - Rectangle fBounds = win.getBounds(); - Point fLoc = win.getLocationOnScreen(); - Rectangle bounds = getBounds(); - int x = fLoc.x + fBounds.width/2 - bounds.width/2; - int y = fLoc.y + fBounds.height/2 - bounds.height/2; - setLocation(x, y); - } - } - - public ColorDialog() { - this((Frame)null, "", false); - } - - private void jbInit() throws Exception { - titledBorder1 = new TitledBorder(""); - border1 = BorderFactory.createLineBorder(Color.gray,1); - panel1.setLayout(gridBagLayout1); - buttonPanel.setBorder(BorderFactory.createEtchedBorder()); - cancelButton.setText("Cancel"); - cancelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - cancelButton_actionPerformed(e); - } - }); - okButton.setText("OK"); - okButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - okButton_actionPerformed(e); - } - }); - alphaPanel.setBorder(titledBorder1); - alphaPanel.setLayout(gridBagLayout2); - titledBorder1.setTitle("Alpha Channel"); - titledBorder1.setBorder(border1); - jLabel1.setText("Alpha"); - alphaTF.setText("0"); - alphaTF.setColumns(5); - getContentPane().add(panel1); - panel1.add(colorChooserPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - panel1.add(alphaPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0)); - alphaPanel.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0)); - alphaPanel.add(alphaTF, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 15), 0, 0)); - panel1.add(buttonPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0)); - buttonPanel.add(okButton, null); - buttonPanel.add(cancelButton, null); - } - - void cancelButton_actionPerformed(ActionEvent e) { - setVisible(false); - } - - void okButton_actionPerformed(ActionEvent e) { - Color temp = colorChooserPanel.getColor(); - int alpha = Integer.parseInt(alphaTF.getText()); - color_ = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), alpha); - setVisible(false); - } - - public void setColor(Color color) { - color_ = color; - colorChooserPanel.setColor(color_); - alphaTF.setText(Integer.toString(color_.getAlpha())); - } - - public Color getColor() { - return color_; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ColorEntryPanel.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ColorEntryPanel.java deleted file mode 100755 index d2a9f210..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ColorEntryPanel.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * $Id: ColorEntryPanel.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import java.awt.event.*; -import java.awt.*; - -import gov.noaa.pmel.swing.ThreeDotsButton; - - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 3.0 - **/ -public class ColorEntryPanel extends JComponent { -// private ThreeDotsIcon dotsIcon_ = new ThreeDotsIcon(Color.black); - private JLabel redLabel = new JLabel(); - private JLabel greenLabel = new JLabel(); - private JLabel blueLabel = new JLabel(); - private JLabel alphaLabel = new JLabel(); - private JTextField redTF = new JTextField(); - private JTextField greenTF = new JTextField(); - private JTextField blueTF = new JTextField(); - private JTextField alphaTF = new JTextField(); - private ThreeDotsButton button = new ThreeDotsButton(); - private FlowLayout fLayout = new FlowLayout(); - - private Color color_ = Color.black; - private String title_ = "Set Color"; - - public ColorEntryPanel(String title, Color color) { - super(); - setColor(color); - setTitle(title); - } - - public ColorEntryPanel() { - try { - jbInit(); - } - catch(Exception e) { - e.printStackTrace(); - } - } - - private void jbInit() throws Exception { - setLayout(fLayout); - redLabel.setText("red"); - greenLabel.setText("green"); - blueLabel.setText("blue"); - alphaLabel.setText("alpha"); - redTF.setText("0"); - redTF.setColumns(3); - greenTF.setText("0"); - greenTF.setColumns(3); - blueTF.setText("0"); - blueTF.setColumns(3); - alphaTF.setText("0"); - alphaTF.setColumns(3); - button.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - button_actionPerformed(e); - } - }); - button.setToolTipText("Edit color."); - button.setActionCommand("..."); - add(redLabel); - add(redTF); - add(greenLabel); - add(greenTF); - add(blueLabel); - add(blueTF); - add(alphaLabel); - add(alphaTF); - add(button); - boolean enabled = isEnabled(); - redTF.setEnabled(enabled); - greenTF.setEnabled(enabled); - blueTF.setEnabled(enabled); - alphaTF.setEnabled(enabled); - button.setEnabled(enabled); - } - - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - redTF.setEnabled(enabled); - greenTF.setEnabled(enabled); - blueTF.setEnabled(enabled); - alphaTF.setEnabled(enabled); - button.setEnabled(enabled); - } - - void button_actionPerformed(ActionEvent e) { - Window win = javax.swing.SwingUtilities.getWindowAncestor(this); - ColorDialog cd = null; - if(win instanceof Frame) { - cd = new ColorDialog((Frame)win, title_, true); - } else if(win instanceof Dialog) { - cd = new ColorDialog((Dialog)win, title_, true); - } else { - cd = new ColorDialog((Frame)null, title_, true); - } - cd.setColor(getColorFromTF()); - cd.setVisible(true); - setColor(cd.getColor()); - } - - public void setColor(Color color) { - color_ = color; - redTF.setText(Integer.toString(color_.getRed())); - greenTF.setText(Integer.toString(color_.getGreen())); - blueTF.setText(Integer.toString(color_.getBlue())); - alphaTF.setText(Integer.toString(color_.getAlpha())); - } - - public Color getColor() { - return getColorFromTF(); - } - - private Color getColorFromTF() { - int red = Integer.parseInt(redTF.getText()); - int green = Integer.parseInt(greenTF.getText()); - int blue = Integer.parseInt(blueTF.getText()); - int alpha = Integer.parseInt(alphaTF.getText()); - return new Color(red, green, blue, alpha); - } - - public void setTitle(String title) { - title_ = title; - } - public String getTitle() { - return title_; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ContourLevelsDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ContourLevelsDialog.java deleted file mode 100755 index 3027710b..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ContourLevelsDialog.java +++ /dev/null @@ -1,479 +0,0 @@ -/* - * $Id: ContourLevelsDialog.java,v 1.1.1.1 2007/09/07 06:32:04 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.TableColumn; -import javax.swing.table.AbstractTableModel; -import java.awt.*; -import java.util.Vector; -import java.util.Enumeration; - -import gov.noaa.pmel.sgt.ContourLevels; -import gov.noaa.pmel.sgt.ContourLevelNotFoundException; -import gov.noaa.pmel.sgt.ContourLineAttribute; -import gov.noaa.pmel.sgt.DefaultContourLineAttribute; - -/** - * This dialog edits a ContourLevels object. This dialog - * has the standalone functionality found in the - * GridAttributeDialog to edit ContourLevels - * objects. - * - *

Example of ContourLevelsDialog use: - *

- *
- * public ContourLevels editLevels(ContourLevels inLevels) {
- *   ContourLevelsDialog cld = new ContourLevelsDialog(inLevels);
- *   if(cld.showDialog() == ContourLevelsDialog.CANCEL_RESPONSE) {
- *     return inLevels;
- *   } else {
- *     return cld.getContourLevels();
- *   }
- * }
- *
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:04 $ - * @since 2.0 - */ -public class ContourLevelsDialog extends JDialog { - private ContourLevels conLevels_; - private JTable table_; - private ConLevelTableModel model_; - private int result_; - /** OK button was selected */ - public static int OK_RESPONSE = 1; - /** Cancel button was selected */ - public static int CANCEL_RESPONSE = 2; - /** - * Constructor. - */ - public ContourLevelsDialog(Frame parent) { - super(parent); - try { - jbInit(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(529,307); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5,5)); - gridScrollPane.setMinimumSize(new Dimension(350, 283)); - gridScrollPane.setPreferredSize(new Dimension(350, 283)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - controlPanel.setLayout(new GridBagLayout()); - getContentPane().add(controlPanel, "East"); - JPanel1.setBorder(titledBorder1); - JPanel1.setLayout(new GridBagLayout()); - controlPanel.add(JPanel1, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0)); - editButton.setToolTipText("Edit attribute of selected level."); - editButton.setText("Edit Attribute"); - editButton.setActionCommand("Change Value"); - JPanel1.add(editButton, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,0,5),0,0)); - aboveButton.setToolTipText("Insert level above selected level."); - aboveButton.setText("Insert Level Above"); - aboveButton.setActionCommand("Before Item"); - JPanel1.add(aboveButton, new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,0,5),0,0)); - belowButton.setToolTipText("Insert level below selected level."); - belowButton.setText("Insert Level Below"); - belowButton.setActionCommand("After Item"); - JPanel1.add(belowButton, new GridBagConstraints(0,2,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,0,5),0,0)); - deleteButton.setToolTipText("Delete the selected level."); - deleteButton.setText("Delete Level"); - deleteButton.setActionCommand("Delete Item"); - JPanel1.add(deleteButton, new GridBagConstraints(0,3,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,5,5),0,0)); - JPanel4.setBorder(titledBorder4); - JPanel4.setLayout(new GridBagLayout()); - controlPanel.add(JPanel4, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0)); - defaultButton.setToolTipText("Edit default attributes."); - defaultButton.setText("Edit Default Attributes"); - JPanel4.add(defaultButton,new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,5,5,5),0,0)); - sortButton.setToolTipText("Sort levels by value."); - sortButton.setText("Sort Levels"); - sortButton.setActionCommand("Sort"); - controlPanel.add(sortButton, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 10, 5), 0, 0)); - gridScrollPane.setBorder(compoundBorder1); - getContentPane().add(gridScrollPane, "Center"); - setTitle("Edit Contour Levels"); - - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - editButton.addActionListener(lSymAction); - aboveButton.addActionListener(lSymAction); - belowButton.addActionListener(lSymAction); - deleteButton.addActionListener(lSymAction); - sortButton.addActionListener(lSymAction); - defaultButton.addActionListener(lSymAction); - - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public ContourLevelsDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public ContourLevelsDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == ContourLevelsDialog.this) - ContourLevelsDialog_WindowClosing(event); - } - } - - void ContourLevelsDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.JPanel controlPanel = new javax.swing.JPanel(); - javax.swing.JPanel JPanel1 = new javax.swing.JPanel(); - javax.swing.JButton editButton = new javax.swing.JButton(); - javax.swing.JButton aboveButton = new javax.swing.JButton(); - javax.swing.JButton belowButton = new javax.swing.JButton(); - javax.swing.JButton deleteButton = new javax.swing.JButton(); - javax.swing.JPanel JPanel4 = new javax.swing.JPanel(); - javax.swing.JButton defaultButton = new javax.swing.JButton(); - javax.swing.JButton sortButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JScrollPane gridScrollPane = new javax.swing.JScrollPane(); - javax.swing.border.TitledBorder titledBorder1 = new javax.swing.border.TitledBorder("Contour Levels"); - javax.swing.border.EmptyBorder emptyBorder1 = new javax.swing.border.EmptyBorder(5,0,0,0); - javax.swing.border.CompoundBorder compoundBorder1 = new - javax.swing.border.CompoundBorder(emptyBorder1, etchedBorder1); - javax.swing.border.TitledBorder titledBorder4 = new javax.swing.border.TitledBorder("Default Attributes"); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == editButton) - editButton_actionPerformed(event); - else if (object == aboveButton) - aboveButton_actionPerformed(event); - else if (object == belowButton) - belowButton_actionPerformed(event); - if (object == deleteButton) - deleteButton_actionPerformed(event); - else if (object == sortButton) - sortButton_actionPerformed(event); - else if (object == defaultButton) - defaultButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - result_ = CANCEL_RESPONSE; - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - update(); - result_ = OK_RESPONSE; - this.setVisible(false); - } - - private void update() { - ContourLevels cl = new ContourLevels(); - Double val; - ContourLineAttribute attr; - int size = model_.getRowCount(); - for(int i=0; i < size; i++) { - val = (Double)model_.getValueAt(i,0); - attr = (ContourLineAttribute)model_.getValueAt(i,1); - cl.addLevel(val.doubleValue(), attr); - } - cl.setDefaultContourLineAttribute(conLevels_.getDefaultContourLineAttribute()); - conLevels_ = cl; - } - /** - * Dialog test entry point. - */ - public static void main(String[] args) { - ContourLevelsDialog cla = new ContourLevelsDialog(); - cla.setTitle("Test ContourLevels Dialog"); - cla.setVisible(true); - } - /** - * Show the dialog and wait for a response. - * - * @param cl ContourLevels object to be edited - * @return return code - */ - public int showDialog(ContourLevels cl) { - conLevels_ = cl; - result_ = CANCEL_RESPONSE; - createTable(); - setModal(true); - super.setVisible(true); - return result_; - } - - void createTable() { - Double val; - ContourLineAttribute attr; - int size = conLevels_.size(); - model_ = new ConLevelTableModel(); - for(int i=0; i < size; i++) { - try { - val = new Double(conLevels_.getLevel(i)); - attr = conLevels_.getContourLineAttribute(i); - model_.add(val, attr); - } catch (ContourLevelNotFoundException e) { - System.out.println(e); - } - } - table_ = new JTable(model_); - table_.setSize(1000,1000); - ListSelectionModel lsm = table_.getSelectionModel(); - lsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - TableColumn tc; - tc = table_.getColumnModel().getColumn(0); - tc.setPreferredWidth(250); - tc = table_.getColumnModel().getColumn(1); - tc.setPreferredWidth(750); - gridScrollPane.getViewport().add(table_); - } - /** - * Get the edited ContourLevels. - */ - public ContourLevels getContourLevels() { - return conLevels_; - } - - void editButton_actionPerformed(java.awt.event.ActionEvent event) { - ContourLineAttribute attr; - int index = table_.getSelectedRow(); - if(index < 0) return; - ContourLineAttributeDialog clad = new ContourLineAttributeDialog(); - attr = (ContourLineAttribute) - ((ContourLineAttribute)model_.getValueAt(index,1)).copy(); - int result = clad.showDialog(attr); - if(result == ContourLineAttributeDialog.OK_RESPONSE) { - attr = clad.getContourLineAttribute(); - model_.setValueAt(attr, index, 1); - } - } - - void aboveButton_actionPerformed(java.awt.event.ActionEvent event) { - int index = table_.getSelectedRow(); - if(index < 0) return; - model_.insert(index, - new Double(0.0), - new ContourLineAttribute(ContourLineAttribute.SOLID)); - } - - void belowButton_actionPerformed(java.awt.event.ActionEvent event) { - int index = table_.getSelectedRow(); - if(index < 0) return; - model_.insert(index + 1, - new Double(0.0), - new ContourLineAttribute(ContourLineAttribute.SOLID)); - } - - - void deleteButton_actionPerformed(java.awt.event.ActionEvent event) { - int index = table_.getSelectedRow(); - if(index < 0) return; - model_.remove(index); - } - - void sortButton_actionPerformed(java.awt.event.ActionEvent event) { - model_.sort(); - } - - void defaultButton_actionPerformed(java.awt.event.ActionEvent event) { - DefaultContourLineAttribute attr; - DefaultContourLineAttributeDialog dclad = new DefaultContourLineAttributeDialog(); - attr = conLevels_.getDefaultContourLineAttribute(); - int result = dclad.showDialog((DefaultContourLineAttribute)attr.copy()); - if(result == DefaultContourLineAttributeDialog.OK_RESPONSE) { - attr = dclad.getDefaultContourLineAttribute(); - conLevels_.setDefaultContourLineAttribute(attr); - } - } - - class ConLevelTableModel extends AbstractTableModel { - Vector values = new Vector(); - Vector attr = new Vector(); - String[] titles = {"Value", "Attribute"}; - - public void add(Double val, ContourLineAttribute cla) { - values.addElement(val); - attr.addElement(cla); - } - - public void insert(int row, Double val, ContourLineAttribute cla) { - values.insertElementAt(val, row); - attr.insertElementAt(cla, row); - fireTableChanged(new TableModelEvent(this, row, row, - TableModelEvent.ALL_COLUMNS, - TableModelEvent.INSERT)); - } - - public void remove(int row) { - values.removeElementAt(row); - attr.removeElementAt(row); - fireTableChanged(new TableModelEvent(this, row, row, - TableModelEvent.ALL_COLUMNS, - TableModelEvent.DELETE)); - } - - public void sort() { - // - // use brain-dead bubble sort (there will be few lines) - // - int i, temp; - int size = values.size(); - Double a, b; - int[] index = new int[size]; - boolean flipped = true; - for(i=0; i < size; i++) { - index[i] = i; - } - while(flipped) { - flipped = false; - for(i=0; i < size-1; i++) { - a = (Double)values.elementAt(index[i]); - b = (Double)values.elementAt(index[i+1]); - if(a.doubleValue() > b.doubleValue()) { - // if(a.compareTo(b) > 0) { // jdk1.2 - temp = index[i]; - index[i] = index[i+1]; - index[i+1] = temp; - flipped = true; - } - } - } - Vector oldValues = values; - Vector oldAttr = attr; - values = new Vector(size); - attr = new Vector(size); - for(i=0; i < size; i++) { - values.addElement(oldValues.elementAt(index[i])); - attr.addElement(oldAttr.elementAt(index[i])); - } - fireTableChanged(new TableModelEvent(this)); - } - - public Object getValueAt(int row, int col) { - if(col == 0) { - return values.elementAt(row); - } else { - return attr.elementAt(row); - } - } - - public void setValueAt(Object obj, int row, int col) { - if(col == 0) { - if(obj instanceof Double) { - values.setElementAt(obj, row); - } else if(obj instanceof String) { - values.setElementAt(new Double((String)obj), row); - } - } else { - attr.setElementAt(obj, row); - } - fireTableCellUpdated(row, col); - } - - public int getRowCount() { - return values.size(); - } - - public int getColumnCount() { - return 2; - } - - public String getColumnName(int col) { - return titles[col]; - } - - public boolean isCellEditable(int row, int col) { - return col == 0; - } - - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ContourLineAttributeDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ContourLineAttributeDialog.java deleted file mode 100755 index 967a2f9f..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/ContourLineAttributeDialog.java +++ /dev/null @@ -1,923 +0,0 @@ -/* - * $Id: ContourLineAttributeDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import java.awt.*; -import java.util.StringTokenizer; - -import gov.noaa.pmel.sgt.ContourLineAttribute; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.swing.ThreeDotsButton; -import javax.swing.border.*; -import java.awt.event.*; - -/** - * Edits a ContourLineAttribute. This dialog does not - * make a copy of the attribute so changes "Applied" will cause - * sgt to redraw the plot using the new properties unless - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} - * has been turned on. - * - *

Example of ContourLineAttributeDialog use: - *

- * public void editCLAttribute(ContourLineAttribute cla) {
- *   ContourLineAttributeDialog clad = new ContourLineAttributeDialog();
- *   clad.showDialog(cla);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class ContourLineAttributeDialog extends JDialog { - private ContourLineAttribute attr_; - private Font labelFont_; - private int result_; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - /** OK button was selected */ - public static int OK_RESPONSE = 1; - /** Cancel button was selected */ - public static int CANCEL_RESPONSE = 2; - /** - * Constructor. - */ - public ContourLineAttributeDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - { - String[] tempString = new String[7]; - tempString[0] = "SOLID"; - tempString[1] = "DASHED"; - tempString[2] = "HEAVY"; - tempString[3] = "HIGHLIGHT"; - tempString[4] = "MARK"; - tempString[5] = "MARK & SOLID"; - tempString[6] = "STROKE"; - for(int i=0; i < tempString.length; i++) { - lineStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "BUTT"; - tempString[1] = "ROUND"; - tempString[2] = "SQUARE"; - for(int i=0; i < tempString.length; i++) { - capStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "MITER"; - tempString[1] = "ROUND"; - tempString[2] = "BEVEL"; - for(int i=0; i < tempString.length; i++) { - miterStyleCBM.addElement(tempString[i]); - } - } - titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142)),"Stroke Line Attributes"); - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(new Dimension(587, 410)); - setVisible(false); - strokePanel.setBorder(titledBorder1); - strokePanel.setLayout(gridBagLayout1); - dashArrayUseDefault.setActionCommand("dashArray"); - JLabel110.setText(" Width:"); - dashPhaseTextField.setColumns(10); - JLabel27.setText("Dash Phase:"); - JLabel28.setText("Dash Array:"); - widthTextField.setColumns(10); - arrayEditor.setActionCommand("..."); - arrayEditor.setToolTipText("Edit dash array."); - dashArrayPanel.setLayout(new GridBagLayout()); - dashPhaseUseDefault.setActionCommand("dashPhase"); - widthUseDefault.setActionCommand("width"); - jLabel1.setText("Cap Style:"); - jLabel2.setText("Miter Style:"); - jLabel3.setText("Miter Limit:"); - miterLimitTextField.setColumns(10); - capStyleComboBox.setModel(capStyleCBM); - miterStyleComboBox.setModel(miterStyleCBM); - lineStyleComboBox.addActionListener(new ContourLineAttributeDialog_lineStyleComboBox_actionAdapter(this)); - capStyleUseDefault.setActionCommand("capStyle"); - miterStyleUseDefault.setActionCommand("miterStyle"); - miterLimitUseDefault.setActionCommand("miterLimit"); - getContentPane().add(TabbedPane, "Center"); - linePanel.setLayout(new GridBagLayout()); - TabbedPane.add(linePanel, "linePanel"); - labelPanel.setLayout(new GridBagLayout()); - TabbedPane.add(labelPanel, "labelPanel"); - labelPanel.setBounds(2,27,476,260); - labelPanel.setVisible(false); - JLabel23.setText("Property"); - labelPanel.add(JLabel23, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.SOUTH,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - JLabel23.setForeground(java.awt.Color.darkGray); - JPanel3.setLayout(new GridBagLayout()); - labelPanel.add(JPanel3, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.SOUTH,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - JLabel24.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - JLabel24.setText("Use"); - JPanel3.add(JLabel24, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); - JLabel24.setForeground(java.awt.Color.darkGray); - JLabel25.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - JLabel25.setText("Default"); - JPanel3.add(JLabel25, new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0)); - JLabel25.setForeground(java.awt.Color.darkGray); - JLabel26.setText("Value"); - labelPanel.add(JLabel26, new GridBagConstraints(2,0,1,1,0.0,0.0, - GridBagConstraints.SOUTH,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - JLabel26.setForeground(java.awt.Color.darkGray); - JPanel4.setBorder(etchedBorder1); - JPanel4.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(JPanel4, new GridBagConstraints(0,1,3,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(2,5,7,5),0,-12)); - JLabel11.setText("Color:"); - labelPanel.add(JLabel11, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelColorUseDefault.setActionCommand("labelColor"); - labelPanel.add(labelColorUseDefault, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - textColorPanel.setBorder(etchedBorder1); - textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(textColorPanel, new GridBagConstraints(2,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - JLabel15.setText("Font:"); - labelPanel.add(JLabel15, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelFontUseDefault.setActionCommand("labelFont"); - labelPanel.add(labelFontUseDefault, new GridBagConstraints(1,3,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(fontPanel, new GridBagConstraints(2,3,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontLabel.setText("Dialog, 12, Bold"); - fontPanel.add(fontLabel); - fontLabel.setForeground(java.awt.Color.black); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.add(fontEditor); - JLabel16.setText("HeightP:"); - labelPanel.add(JLabel16, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - heightPUseDefault.setActionCommand("heightP"); - labelPanel.add(heightPUseDefault, new GridBagConstraints(1,4,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - heightTextField.setColumns(10); - labelPanel.add(heightTextField, new GridBagConstraints(2,4,1,1,1.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel6.setText("Text:"); - labelPanel.add(JLabel6, new GridBagConstraints(0,6,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelPanel.add(textTextField, new GridBagConstraints(2,6,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,5,2,5),0,0)); - JLabel22.setText("Format:"); - labelPanel.add(JLabel22, new GridBagConstraints(0,7,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelFormatUseDefault.setActionCommand("labelFormat"); - labelPanel.add(labelFormatUseDefault, new GridBagConstraints(1,7,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - labelFormatTextField.setColumns(10); - labelPanel.add(labelFormatTextField, new GridBagConstraints(2,7,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel17.setText("Auto Label:"); - labelPanel.add(JLabel17, new GridBagConstraints(0,5,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelPanel.add(autoLabelCheckBox, new GridBagConstraints(2,5,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - JLabel7.setText("Enabled:"); - labelPanel.add(JLabel7, new GridBagConstraints(0,8,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(5,5,0,5),0,0)); - labelEnabledUseDefault.setActionCommand("labelEnabled"); - labelPanel.add(labelEnabledUseDefault, new GridBagConstraints(1,8,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - labelEnabledCheckBox.setSelected(true); - labelPanel.add(labelEnabledCheckBox, new GridBagConstraints(2,8,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - TabbedPane.setSelectedComponent(linePanel); - TabbedPane.setSelectedIndex(0); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,384); - linePanel.setBounds(2,27,476,260); - linePanel.setVisible(false); - JLabel1.setText("Color:"); - linePanel.add(JLabel1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - colorUseDefault.setActionCommand("color"); - linePanel.add(colorUseDefault, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - lineColorPanel.setBorder(etchedBorder1); - lineColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - linePanel.add(lineColorPanel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel5.setText("Line Style:"); - linePanel.add(JLabel5, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 28, 0, 5), 0, 0)); - styleUseDefault.setActionCommand("style"); - linePanel.add(styleUseDefault, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - lineStyleComboBox.setModel(lineStyleCBM); - linePanel.add(lineStyleComboBox, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel18.setText("Property"); - linePanel.add(JLabel18, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - JLabel18.setForeground(java.awt.Color.darkGray); - JPanel1.setLayout(new GridBagLayout()); - linePanel.add(JPanel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - JLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - JLabel19.setText("Use"); - JPanel1.add(JLabel19, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); - JLabel19.setForeground(java.awt.Color.darkGray); - JLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - JLabel20.setText("Default"); - JPanel1.add(JLabel20, new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0)); - JLabel20.setForeground(java.awt.Color.darkGray); - JLabel21.setText("Value"); - linePanel.add(JLabel21, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - JLabel21.setForeground(java.awt.Color.darkGray); - JPanel2.setBorder(etchedBorder1); - JPanel2.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - linePanel.add(JPanel2, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 7, 0), 0, -12)); - linePanel.add(strokePanel, new GridBagConstraints(0, 5, 3, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(dashArrayUseDefault, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - strokePanel.add(JLabel110, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(dashPhaseTextField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(JLabel27, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(JLabel28, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(widthTextField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(dashArrayPanel, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); - dashArrayPanel.add(dashArrayTextField, new GridBagConstraints(0,0,1,1,1.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); - dashArrayPanel.add(arrayEditor, new GridBagConstraints(1,0,1,1,0.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(0,0,0,0),0,0)); - strokePanel.add(dashPhaseUseDefault, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - strokePanel.add(widthUseDefault, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - strokePanel.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel2, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel3, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(capStyleUseDefault, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - strokePanel.add(miterStyleUseDefault, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - strokePanel.add(miterLimitUseDefault, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); - strokePanel.add(capStyleComboBox, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(miterStyleComboBox, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(miterLimitTextField, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - TabbedPane.setTitleAt(0,"Line"); - TabbedPane.setTitleAt(1,"Label"); - //$$ stringComboBoxModel1.move(24,384); - lineStyleComboBox.setSelectedIndex(0); - setTitle("ContourLineAttribute Properties"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - fontEditor.addActionListener(lSymAction); - autoLabelCheckBox.addActionListener(lSymAction); - labelEnabledCheckBox.addActionListener(lSymAction); - arrayEditor.addActionListener(lSymAction); - - // - // Use Default checkbox's have their own action listener - // - CBAction cbAction = new CBAction(); - colorUseDefault.addActionListener(cbAction); - styleUseDefault.addActionListener(cbAction); - labelColorUseDefault.addActionListener(cbAction); - labelFontUseDefault.addActionListener(cbAction); - heightPUseDefault.addActionListener(cbAction); - labelFormatUseDefault.addActionListener(cbAction); - labelEnabledUseDefault.addActionListener(cbAction); - dashArrayUseDefault.addActionListener(cbAction); - dashPhaseUseDefault.addActionListener(cbAction); - widthUseDefault.addActionListener(cbAction); - capStyleUseDefault.addActionListener(cbAction); - miterStyleUseDefault.addActionListener(cbAction); - miterLimitUseDefault.addActionListener(cbAction); - -// Insets pup = new Insets(0, 0, 0, 0); -// fontEditor.setMargin(pup); -// arrayEditor.setMargin(pup); - } - /** Used internally. */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public ContourLineAttributeDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public ContourLineAttributeDialog() { - this((Frame)null); - } - /** - * Make the dialog visible. - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == ContourLineAttributeDialog.this) - ContourLineAttributeDialog_WindowClosing(event); - } - } - - void ContourLineAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); - javax.swing.JPanel linePanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - javax.swing.JCheckBox colorUseDefault = new javax.swing.JCheckBox(); - ColorEntryPanel lineColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JCheckBox styleUseDefault = new javax.swing.JCheckBox(); - javax.swing.JComboBox lineStyleComboBox = new javax.swing.JComboBox(); - javax.swing.JLabel JLabel18 = new javax.swing.JLabel(); - javax.swing.JPanel JPanel1 = new javax.swing.JPanel(); - javax.swing.JLabel JLabel19 = new javax.swing.JLabel(); - javax.swing.JLabel JLabel20 = new javax.swing.JLabel(); - javax.swing.JLabel JLabel21 = new javax.swing.JLabel(); - javax.swing.JPanel JPanel2 = new javax.swing.JPanel(); - javax.swing.JPanel labelPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel23 = new javax.swing.JLabel(); - javax.swing.JPanel JPanel3 = new javax.swing.JPanel(); - javax.swing.JLabel JLabel24 = new javax.swing.JLabel(); - javax.swing.JLabel JLabel25 = new javax.swing.JLabel(); - javax.swing.JLabel JLabel26 = new javax.swing.JLabel(); - javax.swing.JPanel JPanel4 = new javax.swing.JPanel(); - javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelColorUseDefault = new javax.swing.JCheckBox(); - ColorEntryPanel textColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelFontUseDefault = new javax.swing.JCheckBox(); - javax.swing.JPanel fontPanel = new javax.swing.JPanel(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - ThreeDotsButton fontEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); - javax.swing.JCheckBox heightPUseDefault = new javax.swing.JCheckBox(); - javax.swing.JTextField heightTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JTextField textTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel22 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelFormatUseDefault = new javax.swing.JCheckBox(); - javax.swing.JTextField labelFormatTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); - javax.swing.JCheckBox autoLabelCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelEnabledUseDefault = new javax.swing.JCheckBox(); - javax.swing.JCheckBox labelEnabledCheckBox = new javax.swing.JCheckBox(); - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - DefaultComboBoxModel lineStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel capStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel miterStyleCBM = new DefaultComboBoxModel(); - JPanel strokePanel = new JPanel(); - TitledBorder titledBorder1; - GridBagLayout gridBagLayout1 = new GridBagLayout(); - JCheckBox dashArrayUseDefault = new javax.swing.JCheckBox(); - JLabel JLabel110 = new javax.swing.JLabel(); - JTextField dashPhaseTextField = new javax.swing.JTextField(); - JLabel JLabel27 = new javax.swing.JLabel(); - JLabel JLabel28 = new javax.swing.JLabel(); - JTextField dashArrayTextField = new javax.swing.JTextField(); - JTextField widthTextField = new javax.swing.JTextField(); - ThreeDotsButton arrayEditor = new ThreeDotsButton(); - JPanel dashArrayPanel = new javax.swing.JPanel(); - JCheckBox dashPhaseUseDefault = new javax.swing.JCheckBox(); - JCheckBox widthUseDefault = new javax.swing.JCheckBox(); - JLabel jLabel1 = new JLabel(); - JLabel jLabel2 = new JLabel(); - JLabel jLabel3 = new JLabel(); - JCheckBox capStyleUseDefault = new JCheckBox(); - JCheckBox miterStyleUseDefault = new JCheckBox(); - JCheckBox miterLimitUseDefault = new JCheckBox(); - JComboBox capStyleComboBox = new JComboBox(); - JComboBox miterStyleComboBox = new JComboBox(); - JTextField miterLimitTextField = new JTextField(); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == fontEditor) - fontEditor_actionPerformed(event); - else if (object == autoLabelCheckBox) - autoLabelCheckBox_actionPerformed(event); - else if (object == labelEnabledCheckBox) - labelEnabledCheckBox_actionPerformed(event); - else if (object == arrayEditor) - arrayEditor_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - result_ = CANCEL_RESPONSE; - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - updateContourLineAttribute(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - updateContourLineAttribute(); - } - - class CBAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if(object instanceof JCheckBox) - checkBox_actionPerformed(event); - } - } - - void checkBox_actionPerformed(java.awt.event.ActionEvent event) { - String action = event.getActionCommand(); - useDefault(action); - } - - private void useDefault(String action) { - boolean enable; - boolean stroke = lineStyleComboBox.getSelectedIndex() == LineAttribute.STROKE; - if(action.equals("color")) { - enable = !colorUseDefault.isSelected(); - lineColorPanel.setEnabled(enable); - } else if(action.equals("style")) { - lineStyleComboBox.setEnabled(!styleUseDefault.isSelected()); - } else if(action.equals("width")) { - widthTextField.setEnabled(!widthUseDefault.isSelected() && stroke); - } else if(action.equals("dashArray")) { - enable = !dashArrayUseDefault.isSelected() && stroke; - dashArrayTextField.setEnabled(enable); - arrayEditor.setEnabled(enable); - } else if(action.equals("dashPhase")) { - dashPhaseTextField.setEnabled(!dashPhaseUseDefault.isSelected() && stroke); - } else if(action.equals("capStyle")) { - capStyleComboBox.setEnabled(!capStyleUseDefault.isSelected() && stroke); - } else if(action.equals("miterStyle")) { - miterStyleComboBox.setEnabled(!miterStyleUseDefault.isSelected() && stroke); - } else if(action.equals("miterLimit")) { - miterLimitTextField.setEnabled(!miterLimitUseDefault.isSelected() && stroke); - } else if(action.equals("labelColor")) { - enable = !labelColorUseDefault.isSelected(); - textColorPanel.setEnabled(enable); - } else if(action.equals("labelFont")) { - enable = !labelFontUseDefault.isSelected(); - fontLabel.setEnabled(enable); - fontEditor.setEnabled(enable); - } else if(action.equals("heightP")) { - heightTextField.setEnabled(!heightPUseDefault.isSelected()); - } else if(action.equals("labelFormat")) { - labelFormatTextField.setEnabled(!labelFormatUseDefault.isSelected()); - } else if(action.equals("labelEnabled")) { - labelEnabledCheckBox.setEnabled(!labelEnabledUseDefault.isSelected()); - } else { - System.out.println("Action " + action + " not found."); - } - } - - private void useDefaultAll() { - useDefault("color"); - useDefault("style"); - useDefault("width"); - useDefault("dashArray"); - useDefault("dashPhase"); - useDefault("capStyle"); - useDefault("miterStyle"); - useDefault("miterLimit"); - useDefault("labelColor"); - useDefault("labelFont"); - useDefault("heightP"); - useDefault("labelFormat"); - useDefault("labelEnabled"); - } - /** - * Show the dialog and wait for a response - * - * @return result, either CANCE_RESPONSE or OK_RESPONSE - */ - public int showDialog(ContourLineAttribute attr) { - setContourLineAttribute(attr); - result_ = CANCEL_RESPONSE; - setModal(true); - super.setVisible(true); - return result_; - } - /** - * Set the ContourLineAttribute for editing. - */ - public void setContourLineAttribute(ContourLineAttribute attr) { - attr_ = attr; - // - // Line attributes - // - // Color - // - lineColorPanel.setColor(attr_.getColor()); - colorUseDefault.setSelected(!attr_.isColorOverridden()); - // - // style - // - lineStyleComboBox.setSelectedIndex(attr_.getStyle()); - styleUseDefault.setSelected(!attr_.isStyleOverridden()); - strokePanelEnabled(attr_.getStyle() == LineAttribute.STROKE); - // - // width - // - widthTextField.setText(Float.toString(attr_.getWidth())); - widthUseDefault.setSelected(!attr_.isWidthOverridden()); - // - // dash Array - // - float[] da = attr_.getDashArray(); - dashArrayTextField.setText(dashArrayString(da)); - dashArrayUseDefault.setSelected(!attr_.isDashArrayOverridden()); - // - // dash phase - // - dashPhaseTextField.setText(Float.toString(attr_.getDashPhase())); - dashPhaseUseDefault.setSelected(!attr_.isDashPhaseOverridden()); - // - // cap style - // - capStyleComboBox.setSelectedIndex(attr_.getCapStyle()); - capStyleUseDefault.setSelected(!attr_.isCapStyleOverridden()); - // - // miter style - // - miterStyleComboBox.setSelectedIndex(attr_.getMiterStyle()); - miterStyleUseDefault.setSelected(!attr_.isMiterStyleOverridden()); - // - // miter limit - // - miterLimitTextField.setText(Float.toString(attr_.getMiterLimit())); - miterLimitUseDefault.setSelected(!attr_.isMiterLimitOverridden()); - // - // Label attributes - // - // color - // - textColorPanel.setColor(attr_.getLabelColor()); - labelColorUseDefault.setSelected(!attr_.isLabelColorOverridden()); - // - // font - // - labelFont_ = attr_.getLabelFont(); - if(labelFont_ == null) { - fontLabel.setText("Default Font"); - } else { - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - labelFontUseDefault.setSelected(!attr_.isLabelFontOverridden()); - // - // heightP - // - heightTextField.setText(Double.toString(attr_.getLabelHeightP())); - heightPUseDefault.setSelected(!attr_.isLabelHeightPOverridden()); - // - // autoLabel - // - autoLabelCheckBox.setSelected(attr_.isAutoLabel()); - autoLabel(); - // - // text - // - textTextField.setText(attr_.getLabelText()); - // - // label format - labelFormatTextField.setText(attr_.getLabelFormat()); - labelFormatUseDefault.setSelected(!attr_.isLabelFormatOverridden()); - // - // enabled - // - labelEnabledCheckBox.setSelected(attr_.isLabelEnabled()); - labelEnabledUseDefault.setSelected(!attr_.isLabelEnabledOverridden()); - labelEnabled(); - // - useDefaultAll(); - } - - private void autoLabel() { - textTextField.setEnabled(!autoLabelCheckBox.isSelected()); - } - - private void labelEnabled() { - boolean enabled = labelEnabledCheckBox.isSelected(); - textTextField.setEnabled(enabled); - textColorPanel.setEnabled(enabled); - fontLabel.setEnabled(enabled); - labelFontUseDefault.setEnabled(enabled); - fontEditor.setEnabled(enabled); - heightTextField.setEnabled(enabled); - heightPUseDefault.setEnabled(enabled); - autoLabelCheckBox.setEnabled(enabled); - labelFormatTextField.setEnabled(enabled); - labelFormatUseDefault.setEnabled(enabled); - // - useDefaultAll(); - } - - private String dashArrayString(float[] da) { - if(da == null) { - return "null"; - } - StringBuffer sbuf = new StringBuffer("{"); - for(int i=0; i < da.length; i++) { - sbuf.append(Float.toString(da[i]) + ", "); - } - sbuf.setLength(sbuf.length()-2); - sbuf.append("}"); - return sbuf.toString(); - } - - private float[] dashArray() { - String arrayString = dashArrayTextField.getText(); - int start = arrayString.indexOf("{"); - int stop = arrayString.indexOf("}"); - String sub = arrayString.substring(start+1,stop); - // - // parse array - // - StringTokenizer token = new StringTokenizer(sub, ","); - int index = 0; - float[] array = new float[token.countTokens()]; - while(token.hasMoreTokens()) { - array[index] = new Float(token.nextToken()).floatValue(); - index++; - } - return array; - } - - void updateContourLineAttribute() { - // - // Line attributes - // - // Color - // - attr_.setColor(lineColorPanel.getColor()); - attr_.setColorOverridden(!colorUseDefault.isSelected()); - // - // style - // - attr_.setStyle(lineStyleComboBox.getSelectedIndex()); - attr_.setStyleOverridden(!styleUseDefault.isSelected()); - // - // width - // - attr_.setWidth(new Float(widthTextField.getText()).floatValue()); - attr_.setWidthOverridden(!widthUseDefault.isSelected()); - // - // dash array - // - attr_.setDashArray(dashArray()); - attr_.setDashArrayOverridden(!dashArrayUseDefault.isSelected()); - // - // dash phase - // - attr_.setDashPhase(new Float(dashPhaseTextField.getText()).floatValue()); - attr_.setDashPhaseOverridden(!dashPhaseUseDefault.isSelected()); - // - // cap style - // - attr_.setCapStyle(capStyleComboBox.getSelectedIndex()); - attr_.setCapStyleOverridden(!capStyleUseDefault.isSelected()); - // - // miter style - // - attr_.setMiterStyle(miterStyleComboBox.getSelectedIndex()); - attr_.setMiterStyleOverridden(!miterStyleUseDefault.isSelected()); - // - // miter limit - // - attr_.setMiterLimit(new Float(miterLimitTextField.getText()).floatValue()); - attr_.setMiterLimitOverridden(!miterLimitUseDefault.isSelected()); - // - // Label attributes - // - // color - // - attr_.setLabelColor(textColorPanel.getColor()); - attr_.setLabelColorOverridden(!labelColorUseDefault.isSelected()); - // - // font - // - if(labelFont_ != null) attr_.setLabelFont(labelFont_); - attr_.setLabelFontOverridden(!labelFontUseDefault.isSelected()); - // - // heightP - // - attr_.setLabelHeightP(new Double(heightTextField.getText()).doubleValue()); - attr_.setLabelHeightPOverridden(!heightPUseDefault.isSelected()); - // - // autoLabel - // - attr_.setAutoLabel(autoLabelCheckBox.isSelected()); - // - // text - // - attr_.setLabelText(textTextField.getText()); - // - // label format - // - attr_.setLabelFormat(labelFormatTextField.getText()); - attr_.setLabelFormatOverridden(!labelFormatUseDefault.isSelected()); - // - // enabled - // - attr_.setLabelEnabled(labelEnabledCheckBox.isSelected()); - attr_.setLabelEnabledOverridden(!labelEnabledUseDefault.isSelected()); - } - /** - * Get the modified attribute - */ - public ContourLineAttribute getContourLineAttribute() { - return attr_; - } - /** - * Dialog test. - */ - public static void main(String[] args) { - ContourLineAttribute attr = new ContourLineAttribute(); - ContourLineAttributeDialog la = new ContourLineAttributeDialog(); - la.setContourLineAttribute(attr); - la.setTitle("Test ContourLineAttribute Dialog"); - la.setVisible(true); - } - - void arrayEditor_actionPerformed(java.awt.event.ActionEvent event) { - ArrayEditDialog aed = new ArrayEditDialog(); - Point loc = arrayEditor.getLocationOnScreen(); - aed.setLocation(loc.x, loc.y); - aed.setArray(dashArray()); - int result = aed.showDialog(); - if(result == ArrayEditDialog.OK_RESPONSE) { - dashArrayTextField.setText(dashArrayString(aed.getFloatArray())); - } - } - - void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - - void autoLabelCheckBox_actionPerformed(java.awt.event.ActionEvent event) { - autoLabel(); - } - - void labelEnabledCheckBox_actionPerformed(java.awt.event.ActionEvent event) { - labelEnabled(); - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } - - void lineStyleComboBox_actionPerformed(ActionEvent e) { - int index = lineStyleComboBox.getSelectedIndex(); - strokePanelEnabled(index == LineAttribute.STROKE); - if(index == LineAttribute.MARK || index == LineAttribute.MARK_LINE) { - JOptionPane.showMessageDialog(this, - "Line stytle MARK or MARK & SOLID not valid for ContourLine", - "Illegal Line Style", JOptionPane.ERROR_MESSAGE); - lineStyleComboBox.setSelectedIndex(attr_.getStyle()); - } - } - - public void strokePanelEnabled(boolean enabled) { - widthUseDefault.setEnabled(enabled); - dashArrayUseDefault.setEnabled(enabled); - dashArrayUseDefault.setEnabled(enabled); - dashPhaseUseDefault.setEnabled(enabled); - capStyleUseDefault.setEnabled(enabled); - miterStyleUseDefault.setEnabled(enabled); - miterLimitUseDefault.setEnabled(enabled); - useDefault("width"); - useDefault("dashArray"); - useDefault("dashPhase"); - useDefault("capStyle"); - useDefault("miterStyle"); - useDefault("miterLimit"); - } -} - -class ContourLineAttributeDialog_lineStyleComboBox_actionAdapter implements java.awt.event.ActionListener { - ContourLineAttributeDialog adaptee; - - ContourLineAttributeDialog_lineStyleComboBox_actionAdapter(ContourLineAttributeDialog adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.lineStyleComboBox_actionPerformed(e); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/DefaultContourLineAttributeDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/DefaultContourLineAttributeDialog.java deleted file mode 100755 index 1614a3af..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/DefaultContourLineAttributeDialog.java +++ /dev/null @@ -1,655 +0,0 @@ -/* - * $Id: DefaultContourLineAttributeDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import java.awt.*; -import java.util.StringTokenizer; - -import gov.noaa.pmel.sgt.DefaultContourLineAttribute; -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.swing.ThreeDotsButton; -import javax.swing.border.*; -import java.awt.event.*; - -/** - * Edits a DefaultContourLineAttribute. This dialog does not - * make a copy of the attribute so changes "Applied" will cause - * sgt to redraw the plot using the new properties unless - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} - * has been turned on. - * - *

Example of DefaultContourLineAttributeDialog use: - *

- * public void editCLAttribute(DefaultContourLineAttribute cla) {
- *   DefaultContourLineAttributeDialog clad =
- *                        new DefaultContourLineAttributeDialog();
- *   clad.showDialog(cla);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class DefaultContourLineAttributeDialog extends JDialog { - private DefaultContourLineAttribute attr_; - private Font labelFont_; - private int result_; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - /** OK button was selected */ - public static int OK_RESPONSE = 1; - /** Cancel button was selected */ - public static int CANCEL_RESPONSE = 2; - /** - * Construtor. - */ - public DefaultContourLineAttributeDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - { - String[] tempString = new String[7]; - tempString[0] = "SOLID"; - tempString[1] = "DASHED"; - tempString[2] = "HEAVY"; - tempString[3] = "HIGHLIGHT"; - tempString[4] = "MARK"; - tempString[5] = "MARK & SOLID"; - tempString[6] = "STROKE"; - for(int i=0; i < tempString.length; i++) { - lineStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "BUTT"; - tempString[1] = "ROUND"; - tempString[2] = "SQUARE"; - for(int i=0; i < tempString.length; i++) { - capStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "MITER"; - tempString[1] = "ROUND"; - tempString[2] = "BEVEL"; - for(int i=0; i < tempString.length; i++) { - miterStyleCBM.addElement(tempString[i]); - } - } - titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142)),"Stroke Line Attributes"); - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(new Dimension(526, 362)); - setVisible(false); - miterLimitTextField.setColumns(10); - dashArrayPanel.setLayout(new GridBagLayout()); - strokePanel.setLayout(gridBagLayout1); - arrayEditor.setActionCommand("..."); - arrayEditor.setToolTipText("Edit dash array."); - JLabel28.setText("Dash Array:"); - JLabel27.setText("Dash Phase:"); - dashPhaseTextField.setColumns(10); - jLabel3.setText("Miter Limit:"); - jLabel2.setText("Miter Style:"); - jLabel1.setText("Cap Style:"); - JLabel110.setText(" Width:"); - widthTextField.setColumns(10); - strokePanel.setBorder(titledBorder1); - lineStyleComboBox.addActionListener(new DefaultContourLineAttributeDialog_lineStyleComboBox_actionAdapter(this)); - capStyleComboBox.setModel(capStyleCBM); - miterStyleComboBox.setModel(miterStyleCBM); - getContentPane().add(TabbedPane, "Center"); - linePanel.setLayout(new GridBagLayout()); - TabbedPane.add(linePanel, "linePanel"); - JLabel1.setText("Color:"); - linePanel.add(JLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - lineColorPanel.setBorder(etchedBorder1); - lineColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - linePanel.add(lineColorPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel5.setText("Line Style:"); - linePanel.add(JLabel5, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 25, 0, 5), 0, 0)); - lineStyleComboBox.setModel(lineStyleCBM); - linePanel.add(lineStyleComboBox, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - linePanel.add(strokePanel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - strokePanel.add(JLabel110, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(dashPhaseTextField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(JLabel27, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(JLabel28, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(widthTextField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(dashArrayPanel, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); - dashArrayPanel.add(dashArrayTextField, new GridBagConstraints(0,0,1,1,1.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); - dashArrayPanel.add(arrayEditor, new GridBagConstraints(1,0,1,1,0.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(0,0,0,0),0,0)); - strokePanel.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel2, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel3, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(capStyleComboBox, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(miterStyleComboBox, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(miterLimitTextField, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - labelPanel.setLayout(new GridBagLayout()); - TabbedPane.add(labelPanel, "labelPanel"); - labelPanel.setBounds(2,27,425,258); - labelPanel.setVisible(false); - JLabel7.setText("Enabled:"); - labelPanel.add(JLabel7, new GridBagConstraints(0,6,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelEnabledCheckBox.setSelected(true); - labelPanel.add(labelEnabledCheckBox, new GridBagConstraints(1,6,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - JLabel11.setText("Color:"); - labelPanel.add(JLabel11, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - textColorPanel.setBorder(etchedBorder1); - textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(textColorPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - JLabel15.setText("Font:"); - labelPanel.add(JLabel15, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(fontPanel, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontLabel.setText("Dialog, 12, Bold"); - fontPanel.add(fontLabel); - fontLabel.setForeground(java.awt.Color.black); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.add(fontEditor); - JLabel16.setText("HeightP:"); - labelPanel.add(JLabel16, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - heightTextField.setColumns(10); - labelPanel.add(heightTextField, new GridBagConstraints(1,3,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel6.setText("Significant Digits:"); - labelPanel.add(JLabel6, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - sigDigitsTextField.setColumns(10); - labelPanel.add(sigDigitsTextField, new GridBagConstraints(1,4,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel17.setText("Format:"); - labelPanel.add(JLabel17, new GridBagConstraints(0,5,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelFormatTextField.setColumns(10); - labelPanel.add(labelFormatTextField, new GridBagConstraints(1,5,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - TabbedPane.setSelectedComponent(linePanel); - TabbedPane.setSelectedIndex(0); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,324); - linePanel.setBounds(2,27,425,258); - linePanel.setVisible(false); - TabbedPane.setTitleAt(0,"Line"); - TabbedPane.setTitleAt(1,"Label"); - - lineStyleComboBox.setSelectedIndex(0); - setTitle("DefaultContourLineAttribute Properties"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - fontEditor.addActionListener(lSymAction); - labelEnabledCheckBox.addActionListener(lSymAction); - arrayEditor.addActionListener(lSymAction); - -// Insets pup = new Insets(0, 0, 0, 0); -// fontEditor.setMargin(pup); -// arrayEditor.setMargin(pup); - - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public DefaultContourLineAttributeDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor - */ - public DefaultContourLineAttributeDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == DefaultContourLineAttributeDialog.this) - DefaultContourLineAttributeDialog_WindowClosing(event); - } - } - - void DefaultContourLineAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); - javax.swing.JPanel linePanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - ColorEntryPanel lineColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JComboBox lineStyleComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel labelPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelEnabledCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); - ColorEntryPanel textColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); - javax.swing.JPanel fontPanel = new javax.swing.JPanel(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - ThreeDotsButton fontEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); - javax.swing.JTextField heightTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JTextField sigDigitsTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); - javax.swing.JTextField labelFormatTextField = new javax.swing.JTextField(); - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - DefaultComboBoxModel lineStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel capStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel miterStyleCBM = new DefaultComboBoxModel(); - GridBagLayout gridBagLayout1 = new GridBagLayout(); - JTextField miterLimitTextField = new JTextField(); - JPanel dashArrayPanel = new javax.swing.JPanel(); - JPanel strokePanel = new JPanel(); - ThreeDotsButton arrayEditor = new ThreeDotsButton(); - JLabel JLabel28 = new javax.swing.JLabel(); - JLabel JLabel27 = new javax.swing.JLabel(); - JTextField dashArrayTextField = new javax.swing.JTextField(); - JTextField dashPhaseTextField = new javax.swing.JTextField(); - JComboBox miterStyleComboBox = new JComboBox(); - JLabel jLabel3 = new JLabel(); - JLabel jLabel2 = new JLabel(); - JLabel jLabel1 = new JLabel(); - JLabel JLabel110 = new javax.swing.JLabel(); - JComboBox capStyleComboBox = new JComboBox(); - JTextField widthTextField = new javax.swing.JTextField(); - TitledBorder titledBorder1; - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == arrayEditor) - arrayEditor_actionPerformed(event); - else if (object == fontEditor) - fontEditor_actionPerformed(event); - else if (object == labelEnabledCheckBox) - labelEnabledCheckBox_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - result_ = CANCEL_RESPONSE; - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - updateDefaultContourLineAttribute(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - updateDefaultContourLineAttribute(); - } - /** - * Show the dialog and wait for a response - */ - public int showDialog(DefaultContourLineAttribute attr) { - setDefaultContourLineAttribute(attr); - result_ = CANCEL_RESPONSE; - setModal(true); - super.setVisible(true); - return result_; - } - /** - * Set the DefaultContourLineAttribute to be edited. - */ - public void setDefaultContourLineAttribute(DefaultContourLineAttribute attr) { - attr_ = attr; - attr_.setContourLineAttribute(null); - // - // Line attributes - // - // Color - // - lineColorPanel.setColor(attr_.getColor()); - // - // style - // - lineStyleComboBox.setSelectedIndex(attr_.getStyle()); - // - // width - // - widthTextField.setText(Float.toString(attr_.getWidth())); - // - // dash Array - // - float[] da = attr_.getDashArray(); - dashArrayTextField.setText(dashArrayString(da)); - // - // dash phase - // - dashPhaseTextField.setText(Float.toString(attr_.getDashPhase())); - // - // cap style - // - capStyleComboBox.setSelectedIndex(attr_.getCapStyle()); - // - // miter style - // - miterStyleComboBox.setSelectedIndex(attr_.getMiterStyle()); - // - // miter limit - // - miterLimitTextField.setText(Float.toString(attr_.getMiterLimit())); - // - // Label attributes - // - // color - // - textColorPanel.setColor(attr_.getLabelColor()); - // - // font - // - labelFont_ = attr_.getLabelFont(); - if(labelFont_ == null) { - fontLabel.setText("Default Font"); - } else { - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - // - // heightP - // - heightTextField.setText(Double.toString(attr_.getLabelHeightP())); - // - // Significant Digits - // - sigDigitsTextField.setText(Integer.toString(attr_.getSignificantDigits())); - // - // format - // - labelFormatTextField.setText(attr_.getLabelFormat()); - // - // enabled - // - labelEnabledCheckBox.setSelected(attr_.isLabelEnabled()); - labelEnabled(); - } - - private void labelEnabled() { - boolean enabled = labelEnabledCheckBox.isSelected(); - textColorPanel.setEnabled(enabled); - fontLabel.setEnabled(enabled); - heightTextField.setEnabled(enabled); - labelFormatTextField.setEnabled(enabled); - sigDigitsTextField.setEnabled(enabled); - } - - private String dashArrayString(float[] da) { - if(da == null) { - return "null"; - } - StringBuffer sbuf = new StringBuffer("{"); - for(int i=0; i < da.length; i++) { - sbuf.append(Float.toString(da[i]) + ", "); - } - sbuf.setLength(sbuf.length()-2); - sbuf.append("}"); - return sbuf.toString(); - } - - private float[] dashArray() { - String arrayString = dashArrayTextField.getText(); - int start = arrayString.indexOf("{"); - int stop = arrayString.indexOf("}"); - String sub = arrayString.substring(start+1,stop); - // - // parse array - // - StringTokenizer token = new StringTokenizer(sub, ","); - int index = 0; - float[] array = new float[token.countTokens()]; - while(token.hasMoreTokens()) { - array[index] = new Float(token.nextToken()).floatValue(); - index++; - } - return array; - } - - void updateDefaultContourLineAttribute() { - // - // Line attributes - // - // Color - // - attr_.setColor(lineColorPanel.getColor()); - // - // style - // - attr_.setStyle(lineStyleComboBox.getSelectedIndex()); - // - // width - // - attr_.setWidth(new Float(widthTextField.getText()).floatValue()); - // - // dash array - // - attr_.setDashArray(dashArray()); - // - // dash phase - // - attr_.setDashPhase(new Float(dashPhaseTextField.getText()).floatValue()); - // - // cap style - // - attr_.setCapStyle(capStyleComboBox.getSelectedIndex()); - // - // miter style - // - attr_.setMiterStyle(miterStyleComboBox.getSelectedIndex()); - // - // miter limit - // - attr_.setMiterLimit(new Float(miterLimitTextField.getText()).floatValue()); - // - // Label attributes - // - // enabled - // - attr_.setLabelEnabled(labelEnabledCheckBox.isSelected()); - // - // color - // - attr_.setLabelColor(textColorPanel.getColor()); - // - // font - // - if(labelFont_ != null) attr_.setLabelFont(labelFont_); - // - // heightP - // - attr_.setLabelHeightP(new Double(heightTextField.getText()).doubleValue()); - // - // label format - // - attr_.setLabelFormat(labelFormatTextField.getText()); - // - // significant digits - // - attr_.setSignificantDigits(Integer.valueOf(sigDigitsTextField.getText()).intValue()); - } - /** - * Get the modified attribute. - */ - public DefaultContourLineAttribute getDefaultContourLineAttribute() { - return attr_; - } - /** - * Test entry point - */ - public static void main(String[] args) { - DefaultContourLineAttribute attr = new DefaultContourLineAttribute(); - DefaultContourLineAttributeDialog la = new DefaultContourLineAttributeDialog(); - la.setDefaultContourLineAttribute(attr); - la.setTitle("Test DefaultContourLineAttribute Dialog"); - la.setVisible(true); - } - - void arrayEditor_actionPerformed(java.awt.event.ActionEvent event) { - ArrayEditDialog aed = new ArrayEditDialog(); - Point loc = arrayEditor.getLocationOnScreen(); - aed.setLocation(loc.x, loc.y); - aed.setArray(dashArray()); - int result = aed.showDialog(); - if(result == ArrayEditDialog.OK_RESPONSE) { - dashArrayTextField.setText(dashArrayString(aed.getFloatArray())); - } - } - - void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - void labelEnabledCheckBox_actionPerformed(java.awt.event.ActionEvent event) { - labelEnabled(); - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } - - void lineStyleComboBox_actionPerformed(ActionEvent e) { - int index = lineStyleComboBox.getSelectedIndex(); - strokePanelEnabled(index == LineAttribute.STROKE); - if(index == LineAttribute.MARK || index == LineAttribute.MARK_LINE) { - JOptionPane.showMessageDialog(this, - "Line stytle MARK or MARK & SOLID not valid for ContourLine", - "Illegal Line Style", JOptionPane.ERROR_MESSAGE); - lineStyleComboBox.setSelectedIndex(attr_.getStyle()); - } - } - - public void strokePanelEnabled(boolean enabled) { - widthTextField.setEnabled(enabled); - dashArrayTextField.setEnabled(enabled); - arrayEditor.setEnabled(enabled); - dashPhaseTextField.setEnabled(enabled); - capStyleComboBox.setEnabled(enabled); - miterStyleComboBox.setEnabled(enabled); - miterLimitTextField.setEnabled(enabled); - } -} - -class DefaultContourLineAttributeDialog_lineStyleComboBox_actionAdapter implements java.awt.event.ActionListener { - DefaultContourLineAttributeDialog adaptee; - - DefaultContourLineAttributeDialog_lineStyleComboBox_actionAdapter(DefaultContourLineAttributeDialog adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.lineStyleComboBox_actionPerformed(e); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/FontDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/FontDialog.java deleted file mode 100755 index 5a0c9d9d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/FontDialog.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * $Id: FontDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import java.awt.*; - -/** - * Edits a Font object. This dialog does not - * make a copy of the object so changes "Applied" will cause - * sgt to redraw the plot using the new Font - * properties unless - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} - * has been turned on. - * - *

Example of FontDialog use: - *

- * public void editFont(Font font) {
- *   FontDialog fd = new FontDialog();
- *   fd.showDialog(font);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class FontDialog extends JDialog { - private int result_; - private Font font_; - private String[] fontNames_; - private int[] styles_ = {Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD|Font.ITALIC}; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - /** OK button was selected */ - public static int OK_RESPONSE = 1; - /** Cancel button was selected */ - public static int CANCEL_RESPONSE = 2; - /** - * Constructor. - */ - public FontDialog(Frame parent) { - super(parent); - try { - jbInit(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - //{{INIT_CONTROLS - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(450,141); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - italicButton.setMnemonic('0'); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(okButton); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,228); - mainPanel.setLayout(new GridBagLayout()); - getContentPane().add(mainPanel, "Center"); - mainPanel.add(fontComboBox, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,5,5,1),0,0)); - boldButton.setText("Bold"); - mainPanel.add(boldButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 1, 5, 2), 0, 0)); - italicButton.setText("Italic"); - mainPanel.add(italicButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 5), 0, 0)); - italicButton.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 12)); - fontLabel.setText("Font Name in font."); - mainPanel.add(fontLabel, new GridBagConstraints(0,0,3,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,5,5),0,0)); - this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); - setTitle("Select a Mark"); - //}} - - //{{REGISTER_LISTENERS - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - fontComboBox.addActionListener(lSymAction); - boldButton.addActionListener(lSymAction); - italicButton.addActionListener(lSymAction); - //}} - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public FontDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public FontDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == FontDialog.this) - FontDialog_WindowClosing(event); - } - } - - void FontDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - //{{DECLARE_CONTROLS - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JPanel mainPanel = new javax.swing.JPanel(); - javax.swing.JComboBox fontComboBox = new javax.swing.JComboBox(); - javax.swing.JToggleButton boldButton = new javax.swing.JToggleButton(); - javax.swing.JToggleButton italicButton = new javax.swing.JToggleButton(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - //}} - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == fontComboBox) - fontComboBox_actionPerformed(event); - else if (object == boldButton) - boldButton_actionPerformed(event); - else if (object == italicButton) - italicButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - result_ = CANCEL_RESPONSE; - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - this.setVisible(false); - } - /** - * Test entry point - */ - public static void main(String[] args) { - FontDialog la = new FontDialog(); - la.setFont(null); - la.setTitle("Test Font Dialog"); - la.setVisible(true); - } - /** - * Show the dialog and wait for a response - * - * @param font the font - * @return result, either CANCEL_RESPONSE or OK_RESPONSE - */ - public int showDialog(Font font) { -// fontNames_ = Toolkit.getDefaultToolkit().getFontList(); - fontNames_ = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); - for(int i=0; i < fontNames_.length; i++) { - fontComboBox.addItem(fontNames_[i]); - } - setDefaultFont(font); - result_ = CANCEL_RESPONSE; - setModal(true); - super.setVisible(true); - return result_; - } - /** - * Set the font to be edited - */ - public void setDefaultFont(Font font) { - int index=0; - font_ = font; - if(font_ == null) { - font_ = super.getFont(); - } - // - // setup font combo box - // - for(int i=0; i < fontNames_.length; i++) { - if(font_.getName().equals(fontNames_[i])) { - index = i; - break; - } - } - boldButton.setSelected(font_.isBold()); - italicButton.setSelected(font_.isItalic()); - fontComboBox.setSelectedIndex(index); - fontLabel.setText(fontString()); - fontLabel.setFont(font_); - } - /** - * Create a string representation of the Font - */ - public String fontString() { - int style = (boldButton.isSelected()?1:0) + (italicButton.isSelected()?2:0); - return font_.getName() + " " + styleNames_[style]; - } - /** - * Get the edited font. - */ - public Font getFont() { - return font_; - } - - void fontComboBox_actionPerformed(java.awt.event.ActionEvent event) { - updateFont(); - } - - void boldButton_actionPerformed(java.awt.event.ActionEvent event) { - updateFont(); - } - - void italicButton_actionPerformed(java.awt.event.ActionEvent event) { - updateFont(); - } - - void updateFont() { - int style = (boldButton.isSelected()?1:0) + (italicButton.isSelected()?2:0); - Font font = new Font(fontNames_[fontComboBox.getSelectedIndex()], styles_[style], 12); - font_ = font; - fontLabel.setText(fontString()); - fontLabel.setFont(font_); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GeoDateDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GeoDateDialog.java deleted file mode 100755 index 31887094..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GeoDateDialog.java +++ /dev/null @@ -1,1243 +0,0 @@ -/* - * $Id: GeoDateDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import gov.noaa.pmel.util.GeoDate; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.border.*; -import javax.swing.*; -import java.io.*; -import java.net.*; -import java.util.*; -import java.text.*; -import javax.swing.event.ListSelectionListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyChangeListener; - -/** - * GeoDateDialog is a calendar, plus optionally, time, chooser - * that produces a date. It allows the invoker to set the - * allowable range of dates by specifying an earliest and latest - * allowable date. The user can select a date to within - * 5 minutes. If the hour and minutes aren't needed, a flag - * allows the exclusion of the display of these fields. - * - * @author Chris Windsor - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class GeoDateDialog extends JDialog - implements ItemListener, - PropertyChangeListener, - ActionListener { - // Get-able, Set-able variables - private GeoDate initialDate = new GeoDate(); - private GeoDate earliestDateAllowed = new GeoDate(); - private GeoDate latestDateAllowed = new GeoDate(); - private boolean earliestCheckingEnabled = false; - private boolean latestCheckingEnabled = false; - private Font regularFont, boldFont; - private Color panelBackground, calBackground, selectedButnBackground; - - private final static String[] months = {"Jan","Feb","Mar", - "Apr","May","Jun", - "Jul","Aug","Sep", - "Oct", "Nov","Dec"}; - private final static String[] daysOfMonth = {" 1"," 2"," 3"," 4"," 5", - " 6"," 7"," 8"," 9","10", - "11","12","13","14","15", - "16","17","18","19","20", - "21","22","23","24","25", - "26","27","28","29","30", - "31"}; - private final static String[] hours = {"0","1","2","3","4","5","6","7", - "8","9","10","11","12","13","14", - "15","16","17","18","19","20","21", - "22","23"}; - private final static String[] minutes = {"0","5","10","15","20","25", - "30","35","40","45","50","55"}; - private final static int numWeeks = 6; - - private GregorianCalendar cal; - private SimpleDateFormat dateFormatter; - private SimpleDateFormat sdf; - private SimpleDateFormat tsdf = new SimpleDateFormat("dd MMM yyyy "); - private static TimeZone tz = TimeZone.getTimeZone("GMT"); - - private int result_; - public static int OK_RESPONSE = 1; - public static int CANCEL_RESPONSE = 2; - - private JPanel mainPanel_; - private JPanel calPanel, okPanel, selectionPanel; - private javax.swing.Box box, theBox, timeBox, monthYearBox, okBox, labelBox, - hrMinBox; - private JButton subYearButn, subMonthButn, addMonthButn, addYearButn, - addHourButn, subHourButn, addMinButn, subMinButn; - private JButton cancelButn, okButn; - private JToggleButton calButtons[ ]; - private JLabel yearLabel, hourLabel, minLabel, hourMinLabel; - private JLabel selectionLabel; - private Choice monthChoice, yearChoice; - private JComboBox monthList, minList; - private JTextField hourText, yearText; - private Component caller; - - private ButtonGroup calButtonGroup; - - private GeoDate liquidDate; - private int lastDaySel, lastButnSel = 1; - private int xloc, yloc; - private String title; - private boolean hideTime; - // private JFrame aJFrame = null; - static private CompoundBorder cp = new CompoundBorder( - new BevelBorder( BevelBorder.RAISED ), - new EmptyBorder( 2,2,2,2)); - - public static final int DATE = Calendar.DATE; - public static final int YEAR = Calendar.YEAR; - public static final int MONTH = Calendar.MONTH; - public static final int MINUTE = Calendar.MINUTE; - public static final int HOUR_OF_DAY = Calendar.HOUR_OF_DAY; - - private boolean TRACE = false; - private PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - // Get/Set Routines ------------------------------------------------------ - public void setEarliestDateAllowed( GeoDate earliestDateAllowed ) { - this.earliestDateAllowed = earliestDateAllowed; - earliestCheckingEnabled = true; - System.out.println("Earliest date allowed: " + earliestDateAllowed); - } - public void setLatestDateAllowed( GeoDate latestDateAllowed ) { - this.latestDateAllowed = latestDateAllowed; - latestCheckingEnabled = true; - System.out.println("Latest date allowed: " + latestDateAllowed); - } - public GeoDate getEarliestDateAllowed() { - return( earliestDateAllowed ); - } - public GeoDate getLatestDateAllowed() { - return( latestDateAllowed ); - } - // public void setTimeZone( TimeZone tz ) { - // this.tz = tz; - // setTimeZoneForTimeObjects( tz ); - // } - - // public TimeZone getTimeZone( ) { - // return this.tz; - // } - - public void setOutputDateFormatter( SimpleDateFormat sdf) { - this.sdf = sdf; - } - - public void setInitialDate( GeoDate initialDateIn) { - initialDate = initialDateIn; - liquidDate = new GeoDate( initialDate ); - this.setTitle( composeTimeLabel( liquidDate)); - } - public void setGeoDate( GeoDate dt) { - if (TRACE) System.out.println( "setDate entered"); - liquidDate = new GeoDate( dt ); - if (liquidDateWithinBounds()) { - updateGUIAfterLiquidDateChange(); - this.setTitle( composeTimeLabel( liquidDate)); - } - } - public void setTitle( String title ) { - this.title = title; - } - public String getTitle( ) { - return this.title; - } - public GeoDate getInitialDate() { - return( initialDate ); - } - public void setRegularFont( Font regularFontIn ) { - regularFont = regularFontIn; - } - public Font getRegularFont() { - return( regularFont ); - } - public void setBoldFont( Font boldFontIn ) { - boldFont = boldFontIn; - } - public Font getBoldFont( ) { - return( boldFont ); - } - public void setPanelBackground( Color color ) { - panelBackground = color; - } - public Color getPanelBackground( ) { - return( panelBackground ); - } - public void setCalBackground( Color color ) { - calBackground = color; - } - public Color getCalBackground( ) { - return( calBackground ); - } - public void setSelectedButnBackground( Color color ) { - selectedButnBackground = color; - } - public Color getSelectedButnBackground( ) { - return( selectedButnBackground ); - } - public void setHideTime( boolean ans) { - hideTime = ans; - if (ans) { - removeTime(); - } - } - public boolean getHideTime() { - return hideTime; - } - // public JButton getOkButn() { - // return okButn; - // } - // public JButton getCancelButn() { - // return cancelButn; - // } - //---------------------------------------------------------------- - // Constructor - public GeoDateDialog( GeoDate inDate ) { - - super(); - // tz = TimeZone.getDefault(); - cal = new GregorianCalendar(); - cal.setTimeZone(tz); - createDateFormatter(); - setTimeZoneForTimeObjects( ); - setInitialDate( inDate ); - finishConstruction(); - } - - //---------------------------------------------------------------- - // Constructor - public GeoDateDialog( GeoDate inDate, GeoDate earliestDateAllowedIn, - GeoDate latestDateAllowedIn, int xlocIn, int ylocIn) { - - super(); - // tz = TimeZone.getDefault(); - cal = new GregorianCalendar(); - cal.setTimeZone(tz); - createDateFormatter(); - setTimeZoneForTimeObjects( ); - xloc = xlocIn; - yloc = ylocIn; - setInitialDate( inDate ); - setEarliestDateAllowed( earliestDateAllowedIn ); - setLatestDateAllowed( latestDateAllowedIn ); - finishConstruction(); - } - - //---------------------------------------------------------------- - // Constructor - public GeoDateDialog( ) { - - super(); - // tz = TimeZone.getDefault(); - cal = new GregorianCalendar(); - cal.setTimeZone(tz); - createDateFormatter(); - setTimeZoneForTimeObjects( ); - // Initialize date to current, but round hours and minutes to 0 - GeoDate dt = new GeoDate(); - cal.setTime( dt ); - computeFields( cal ); - cal.set(HOUR_OF_DAY,0); cal.set(MINUTE,0); - cal.set( cal.SECOND,0); - dt = new GeoDate(cal.getTime()); - setInitialDate( dt ); - - finishConstruction(); - } - //---------------------------------------------------------------- - // Finish Construction - // - void finishConstruction( ) { - - mainPanel_ = new JPanel(); - - this.addPropertyChangeListener( this ); - // mainPanel_.setSize(220 ,323); - - regularFont = new Font( "Dialog", Font.PLAIN, 10); - boldFont = new Font( "Dialog", Font.BOLD, 10); - setSelectedButnBackground( new Color(240, 240, 240 )); - setCalBackground( new Color(200,200,200 )); - - createCalendarPanel(); - createMonthYearPanel(); - createTimePanel(); - createOkPanel(); - createSelectionPanel(); - - theBox = box.createVerticalBox(); - theBox.add( monthYearBox ); - theBox.add( calPanel); - theBox.add( timeBox); - theBox.add( box.createVerticalStrut( 1 )); - theBox.add( selectionPanel); - theBox.add( okPanel); - theBox.add( box.createVerticalGlue()); - - theBox.validate(); - theBox.setBackground( panelBackground ); - theBox.setBackground( Color.white ); - theBox.repaint(); - //this.getContentPane().add( theBox ); - mainPanel_.add( theBox ); - theBox.setLocation( 10, 10 ); - mainPanel_.setLocation( xloc, yloc); - this.getContentPane().add(mainPanel_); - validate(); - repaint(); - - cal.setTime( getInitialDate()); - computeFields( cal ); - lastDaySel = cal.get( DATE ); - - resetCalendarPanel( initialDate ); - softwareDayOfMonthClick( initialDate ); - - minList.setSelectedIndex( (cal.get(MINUTE)/5)); - hourText.setText( new String(String.valueOf(cal.get(HOUR_OF_DAY)))); - monthList.setSelectedIndex( cal.get( MONTH)); - - } - //---------------------------------------------------------------- - // showInJFrame - // - // show this DateTimeGetter in a JFrame; handles all window closing - // - public int showDialog(GeoDate date, int x, int y) { - this.setSize(220 ,323); - this.setLocation(x, y); -// aJFrame.addWindowListener( new WindowAdapter() { -// public void windowClosing( WindowEvent e) { -// closeDown(); -// } -// }); - setInitialDate(date); - setGeoDate(date); - result_ = CANCEL_RESPONSE; - this.setModal(true); - this.setVisible( true ); - return result_; - } - - //---------------------------------------------------------------- - // Removes the time-related selectors - // - void removeTime() { - theBox.remove(timeBox); - createDateFormatter(); - updateDateLabel(); - this.setSize( 220 ,260); - } - - //---------------------------------------------------------------- - // - // for all objects that use timezone. - // - void setTimeZoneForTimeObjects() { - if (TRACE) System.out.println( "setTimeZoneForTimeObjects entered"); - if (dateFormatter != null) dateFormatter.setTimeZone( tz ); - if (cal != null) cal.setTimeZone( tz ); - } - - - //---------------------------------------------------------------- - // Create date formatter; need to create this only once for use - // many times. - void createDateFormatter() { - - if (TRACE) System.out.println( "createDateFormatter entered"); - dateFormatter = new SimpleDateFormat(" dd MMM yyyy HH:mm "); - if (hideTime) { - dateFormatter = new SimpleDateFormat("dd MMM yyyy "); - } - dateFormatter.setTimeZone( tz ); - } - - //---------------------------------------------------------------- - // create Calendar panel - //---------------------------------------------------------------- - // The calendar panel has the grid layout of 7 rows, 7 columns, - // (One label row; 6 week rows) - // - - void createCalendarPanel( ) { - - if (TRACE) System.out.println( "createCalendarPanel entered"); - int dayOfWeek, weekOfMonth; - - JLabel jl; - // Create a panel for the calendar - calPanel = new JPanel(); - calPanel.setLayout( new GridLayout( numWeeks+1, 7, 2, 1 )); - jl = new JLabel("Sun", JLabel.CENTER); jl.setFont(boldFont); - calPanel.add( jl); - jl = new JLabel("Mon", JLabel.CENTER); jl.setFont(boldFont); - calPanel.add( jl); - jl = new JLabel("Tue", JLabel.CENTER); jl.setFont(boldFont); - calPanel.add( jl); - jl = new JLabel("Wed", JLabel.CENTER); jl.setFont(boldFont); - calPanel.add( jl); - jl = new JLabel("Thu", JLabel.CENTER); jl.setFont(boldFont); - calPanel.add( jl); - jl = new JLabel("Fri", JLabel.CENTER); jl.setFont(boldFont); - calPanel.add( jl); - jl = new JLabel("Sat", JLabel.CENTER); jl.setFont(boldFont); - calPanel.add( jl); - calPanel.setBorder( new EmptyBorder( 2,2,2,2)); - - calButtonGroup = new ButtonGroup(); - calButtons = new JToggleButton[ numWeeks * 7 ]; - for (int i = 0; i < (7*numWeeks); i++ ) { - calButtons[ i ] = new JToggleButton(" "); - calButtons[ i ].setBorder( cp ); - calButtons[ i ].setContentAreaFilled( true ); - calButtons[ i ].addActionListener( this ); - calButtons[ i ].setFont(regularFont); - calPanel.add( calButtons[ i ] ); - calButtonGroup.add( calButtons[ i ] ); - calButtons[ i ].setMinimumSize( new Dimension( 17, 21 )); - calButtons[ i ].setMaximumSize( new Dimension( 17, 21 )); - calButtons[ i ].setSize( new Dimension( 17, 21 )); - } - - } // createCalendarPanel - - //---------------------------------------------------------------- - // reset Calendar Panel when the date changes to reflect new month. - //---------------------------------------------------------------- - void resetCalendarPanel( GeoDate newDate ) { - - if (TRACE) System.out.println( "resetCalendarPanel entered"); - int dayOfWeek, weekOfMonth; - String[][] gridLabels = new String[7][numWeeks]; - GregorianCalendar cal1 = new GregorianCalendar(); - cal1.setTimeZone( tz ); - - // Set labels in grid to " " - for (dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) { // monday -> sunday - for (weekOfMonth = 0; weekOfMonth < numWeeks; weekOfMonth++) { - gridLabels[ dayOfWeek][ weekOfMonth ] = " "; - } - } - - // Get first day of this month - cal1.setTime( newDate ); - computeFields( cal1 ); - cal1.set( cal1.DATE, 1 ); - Date firstThisMonth = cal1.getTime(); - - //System.out.println(" firstThisMonth: " + tsdf.format( firstThisMonth)); - // Get first of next month's date - cal1.setTime( firstThisMonth ); - computeFields( cal1 ); - dayOfWeek = cal1.get( cal1.DAY_OF_WEEK ) - 1; // added the subtract 12/99 - //System.out.println(" day of week is: " + dayOfWeek); - - // Now set calendar to next month - if ((cal1.get(cal1.MONTH)+1) == 13) { // crossing over to the next year - cal1.set(cal1.MONTH, 0 ); - cal1.set(cal1.YEAR, cal1.get( cal1.YEAR ) +1 ); - } - else - cal1.set(cal1.MONTH, cal1.get( cal1.MONTH )+1 ); - - - Date firstNextMonth = cal1.getTime(); - //System.out.println(" firstNextMonth: " + tsdf.format( firstNextMonth)); - - long curTime = firstThisMonth.getTime(); - long endTime = firstNextMonth.getTime(); - cal1.setTime( firstThisMonth); - computeFields( cal1 ); - - weekOfMonth = 0; - int dayOfMonth = 1; - while (curTime < endTime) { - // Set labels in grid - if (dayOfMonth != 32) // October; daylight savings time causes bug - gridLabels[ dayOfWeek][ weekOfMonth ] = daysOfMonth[ dayOfMonth-1 ]; - - dayOfWeek++; - dayOfMonth++; - if (dayOfWeek > 6) { - dayOfWeek = 0; - weekOfMonth++; - } - curTime+= (24 * 60 * 60 * 1000); // add 24 hours - } - - int ithButn = 0; - for (weekOfMonth = 0; weekOfMonth < numWeeks; weekOfMonth++) { - for (dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {// monday -> sunday - if (gridLabels[ dayOfWeek][weekOfMonth].equals(" ")) { - calButtons[ ithButn ].setText( " "); - calButtons[ ithButn ].setVisible(false); - } - else { - calButtons[ ithButn ].setText( - gridLabels[ dayOfWeek][weekOfMonth]); - calButtons[ ithButn ].setVisible(true); - } - ithButn++; - } - } - } - //---------------------------------------------------------------- - // closeDown - // - void closeDown() { - this.setVisible( false ); - } - - public GeoDate getGeoDate() { - return liquidDate; - } - - //---------------------------------------------------------------- - void softwareDayOfMonthClick( GeoDate dt) { - - if (TRACE) System.out.println( "softwareDayOfMonthClick entered"); - cal.setTime( dt ); - computeFields( cal ); - int date = cal.get( DATE ); - int idx = 0; - for (int i = 0; i < calButtons.length; i++) { - if (calButtons[i].getText().equals( daysOfMonth[ date-1 ])) { - calButtons[i].doClick(); - } - } - } - - //---------------------------------------------------------------- - void selectDay( int date) { - - if (TRACE) System.out.println( "selectDay entered"); - if (calButtons != null) { - for (int i = 0; i < calButtons.length; i++) { - if (calButtons[i].getText().equals( daysOfMonth[ date-1 ])) { - lastButnSel = i; - lastDaySel = date; - break; - } - } - } - } // selectDay - - // -------------------------------------------------------------- - // Compose time label - String composeTimeLabel( GeoDate dt ) { - return( dateFormatter.format( dt )); - } - //---------------------------------------------------------------- - // computeFields - // forces the Calendar object to compute its fields. (Unfortunately, - // the computeFields method of the object is protected, so I can't - // call it.) - //---------------------------------------------------------------- - void computeFields( Calendar caln ) { - {int yrr=caln.get(caln.YEAR);} // FORCE a call to computeFields - } - - //---------------------------------------------------------------- - // update Date Label - //---------------------------------------------------------------- - void updateDateLabel( ) { - - //this.setTitle( composeTimeLabel( liquidDate )); - selectionLabel.setText( composeTimeLabel( liquidDate )); - } - //---------------------------------------------------------------- - // create Month/Year panel - //---------------------------------------------------------------- - // The Month/Year panel has the following grid bag layout structure: - // - // x-0 x-1 x-2 x-3 x-4 x-5 x-6 - // ------ ------ ------ ------ ------ ------ ------ - // y-0: subYea subMon month month year addMon addYea - - void createMonthYearPanel() { - - if (TRACE) System.out.println( "createMonthYearPanel entered"); - subMonthButn = new JButton("<<"); - subMonthButn.setFont( regularFont ); - subMonthButn.setBorder( cp ); - subMonthButn.addActionListener( this ); - subMonthButn.setBackground( calBackground ); - subMonthButn.setAlignmentY( 0.5f ); - - addMonthButn = new JButton(">>"); - addMonthButn.setFont( regularFont ); - addMonthButn.setBorder( cp ); - addMonthButn.addActionListener( this ); - addMonthButn.setBackground( calBackground ); - addMonthButn.setAlignmentY( 0.5f ); - - monthList = new JComboBox( months ); - monthList.setFont( regularFont ); - monthList.addItemListener( this ); - monthList.setAlignmentY( 0.5f ); - - yearText = new JTextField( new String( String.valueOf(cal.get( YEAR)))); - yearText.setBackground(calBackground); - yearText.addActionListener( this ); - yearText.setFont( regularFont ); - int x = subMonthButn.getPreferredSize().width*3; - int y = subMonthButn.getPreferredSize().height; - yearText.setPreferredSize( new Dimension( x,y)); - yearText.setMaximumSize( new Dimension( x,y)); - yearText.setAlignmentY( .5f ); - - subYearButn = new JButton("<<"); - subYearButn.setFont( regularFont ); - subYearButn.setBorder( cp ); - subYearButn.addActionListener( this ); - subYearButn.setBackground( calBackground ); - subYearButn.setAlignmentY( .5f ); - - addYearButn = new JButton(">>"); - addYearButn.setFont( regularFont ); - addYearButn.setBorder( cp ); - addYearButn.addActionListener( this ); - addYearButn.setBackground( calBackground ); - addYearButn.setAlignmentY( .5f ); - - monthYearBox = box.createHorizontalBox(); - - - monthYearBox.add( box.createHorizontalGlue()); - monthYearBox.add( subMonthButn ); - monthYearBox.add( addMonthButn ); - monthYearBox.add( monthList ); - monthYearBox.add( box.createHorizontalStrut(1)); - monthYearBox.add( yearText ); - monthYearBox.add( subYearButn ); - monthYearBox.add( addYearButn ); - monthYearBox.add( box.createHorizontalGlue()); - } - - //---------------------------------------------------------------- - // Reset MonthYear Panel - public void resetMonthYearPanel( GeoDate newDate ) { - if (TRACE) System.out.println( "resetMonthYearPanel entered"); - cal.setTime( newDate ); - computeFields( cal ); - int m = cal.get( MONTH ); - Integer yr = new Integer( cal.get( YEAR)); - - monthList.setVisible(false ); - monthList.setSelectedIndex( m); - monthList.setVisible( true); - - int yr1 = Integer.parseInt( yearText.getText().trim()); - if (yr.intValue() != yr1) { - yearText.setText( yr.toString() ); - } - } - //---------------------------------------------------------------- - // Create Time Panel - - void createTimePanel () { - - if (TRACE) System.out.println( "createTimePanel entered"); - hourLabel = new JLabel("Hour(0-23) "); - hourLabel.setFont( boldFont ); - - minLabel = new JLabel( "Minute "); - minLabel.setFont( boldFont ); - - JLabel colonLabel = new JLabel( ":"); - Font f = new Font( "Dialog", Font.BOLD, 12); - colonLabel.setFont( f ); - - subHourButn = new JButton("<<"); - subHourButn.setFont( regularFont ); - subHourButn.setBorder( cp ); - subHourButn.addActionListener( this ); - subHourButn.setBackground( calBackground ); - subHourButn.setAlignmentY( 0.5f ); - - addHourButn = new JButton(">>"); - addHourButn.setFont( regularFont ); - addHourButn.setBorder( cp ); - addHourButn.addActionListener( this ); - addHourButn.setBackground( calBackground ); - addHourButn.setAlignmentY( 0.5f ); - - hourText = new JTextField(); - hourText.setText(" 00"); - hourText.setFont( regularFont ); - hourText.setBackground(calBackground); - hourText.addActionListener( this ); - hourText.setHorizontalAlignment( JTextField.RIGHT ); - - int x = addHourButn.getPreferredSize().width * 2; - int y = addHourButn.getPreferredSize().height; - hourText.setPreferredSize( new Dimension( x, y) ); - hourText.setMaximumSize( hourText.getPreferredSize()); - hourText.setSize( hourText.getPreferredSize()); - hourText.setAlignmentY( .5f ); - - - minList = new JComboBox( minutes ); - minList.addItemListener( this ); - minList.setFont( regularFont ); - x = addHourButn.getPreferredSize().width * 2; - y = addHourButn.getPreferredSize().height; - minList.setPreferredSize( new Dimension( x,y )); - minList.setMaximumSize( minList.getPreferredSize()); - minList.setSize( minList.getPreferredSize()); - minList.setAlignmentY( .5f ); - - subMinButn = new JButton("<<"); - subMinButn.setFont( regularFont ); - subMinButn.setBorder( cp ); - subMinButn.addActionListener( this ); - subMinButn.setBackground( calBackground ); - subMinButn.setAlignmentY( .5f ); - - addMinButn = new JButton(">>"); - addMinButn.setFont( regularFont ); - addMinButn.setBorder( cp ); - addMinButn.addActionListener( this ); - addMinButn.setBackground( calBackground ); - addMinButn.setAlignmentY( .5f ); - - - labelBox = box.createHorizontalBox(); - labelBox.add( box.createHorizontalGlue()); - labelBox.add( hourLabel ); - labelBox.add( box.createHorizontalStrut(1)); - labelBox.add( minLabel ); - labelBox.add( box.createHorizontalGlue()); - - hrMinBox = box.createHorizontalBox(); - hrMinBox.add( box.createHorizontalGlue()); - hrMinBox.add( subHourButn ); - hrMinBox.add( addHourButn ); - hrMinBox.add( hourText ); - hrMinBox.add( box.createHorizontalStrut(5)); - //hrMinBox.add( colonLabel ); - hrMinBox.add( minList ); - hrMinBox.add( subMinButn ); - hrMinBox.add( addMinButn ); - hrMinBox.add( box.createHorizontalGlue()); - - timeBox = box.createVerticalBox(); - timeBox.add( box.createVerticalGlue()); - timeBox.add( labelBox ); - timeBox.add( hrMinBox ); - timeBox.add( box.createVerticalGlue()); - } - - void createSelectionPanel() { - if (TRACE) System.out.println( "createSelectionPanel entered"); - selectionLabel = new JLabel("ddd mmm dd hh:mm yyyy"); - selectionLabel.setBackground( Color.red ); - selectionLabel.setForeground( Color.black ); - selectionPanel = new JPanel(); - selectionPanel.add( selectionLabel ); - int x = selectionPanel.getPreferredSize().width; - int y = 15; - //selectionPanel.setPreferredSize( new Dimension( x,y)); - //selectionPanel.setMaximumSize( new Dimension( x,y)); - //selectionPanel.setBackground( Color.yellow ); - updateDateLabel(); - } - //---------------------------------------------------------------- - // create the okay/cancel panel - void createOkPanel() { - - if (TRACE) System.out.println( "createOkPanel entered"); - okButn = new JButton( "OK"); - okButn.addActionListener( this ); - okButn.setBackground( calBackground ); - okButn.setMinimumSize( new Dimension( 51, 25 )); - okButn.setMaximumSize( new Dimension( 51, 25 )); - - cancelButn = new JButton("Cancel"); - cancelButn.addActionListener( this ); - cancelButn.setBackground( calBackground ); - cancelButn.setMinimumSize( new Dimension( 73, 25 )); - cancelButn.setMaximumSize( new Dimension( 73, 25 )); - - okPanel = new JPanel(); - okPanel.setLayout( new GridLayout(1,2)); - okPanel.add( okButn); - okPanel.add( cancelButn); - } // create okPanel - - //---------------------------------------------------------------- - // handleHourChange - void handleHourChange(){ - if (TRACE) System.out.println( "handleHourChange entered"); - try { - cal.setTime( liquidDate ); - computeFields( cal ); - int prevHr = cal.get(HOUR_OF_DAY); // hang on to old value - int hr = Integer.parseInt( hourText.getText().trim()); - hr = validateHours( hr ); - hourText.setText( (new Integer(hr)).toString() ); - cal.set( HOUR_OF_DAY, hr ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { // restore old value - cal.set( HOUR_OF_DAY, prevHr ); - liquidDate = new GeoDate(cal.getTime()); - hourText.setText( (new Integer(prevHr)).toString() ); - } - updateDateLabel(); - } catch (NumberFormatException e) { - } - } - //---------------------------------------------------------------- - // handleYearChange - void handleYearChange(){ - if (TRACE) System.out.println( "handleYearChange entered"); - try { - cal.setTime( liquidDate ); - computeFields( cal ); - int prevYr = cal.get(YEAR); // hang on to old value - int yr = Integer.parseInt( yearText.getText().trim()); - //yr = validateYear( yr ); - yearText.setText( (new Integer(yr)).toString() ); - cal.set( YEAR, yr ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { // restore old value - //boundsMsg(); - cal.set( YEAR, prevYr ); - liquidDate = new GeoDate(cal.getTime()); - yearText.setText( (new Integer(prevYr)).toString() ); - } - else { - updateGUIAfterLiquidDateChange(); - } - updateDateLabel(); - } catch (NumberFormatException e) { - } - } - //---------------------------------------------------------------- - // Validate Hours - int validateHours( int hr) { - if (TRACE) System.out.println( "validateHours entered"); - if (hr < 0) return(0); - if (hr > 23) return(23); - return( hr ); - } - //---------------------------------------------------------------- - // check Date within range - boolean liquidDateWithinBounds( ) { - - if (TRACE) System.out.println( "liquidDateWithinBounds entered"); - /* - cal.setTime( earliestDateAllowed ); - computeFields( cal ); - System.out.println(" Floor date is: " + - " year " + cal.get( YEAR) + - " month " + cal.get( MONTH) + - " date " + cal.get( DATE) + - " hour " + cal.get( cal.HOUR) + - " min " + cal.get( MINUTE)); - - cal.setTime( latestDateAllowed ); - computeFields( cal ); - System.out.println(" Latest date is: " + - " year " + cal.get( YEAR) + - " month " + cal.get( MONTH) + - " date " + cal.get( DATE) + - " hour " + cal.get( cal.HOUR) + - " min " + cal.get( MINUTE)); - - cal.setTime( liquidDate ); - computeFields( cal ); - System.out.println(" Liquid date is: " + - " year " + cal.get( YEAR) + - " month " + cal.get( MONTH) + - " date " + cal.get( DATE) + - " hour " + cal.get( cal.HOUR) + - " min " + cal.get( MINUTE)); - */ - - if (earliestCheckingEnabled) { - System.out.println("liquidDate is: " + liquidDate); - System.out.println("earliestDateAllowed is: " + earliestDateAllowed); - if (liquidDate.getTime() < earliestDateAllowed.getTime()) { - lowerBoundMsg(); - return (false); - } - } - if (latestCheckingEnabled) { - if (liquidDate.getTime() > latestDateAllowed.getTime()) { - upperBoundMsg(); - return( false ); - } - } - return( true ); - } - //---------------------------------------------------------------- - // - void lowerBoundMsg() { - if (TRACE) System.out.println( "lowerBoundMsg entered"); - JOptionPane.showMessageDialog(this, - (new String("Lower bound restricted to " + composeTimeLabel( getEarliestDateAllowed()))), - "Calendar Bounds Exception", - JOptionPane.WARNING_MESSAGE); - } - //---------------------------------------------------------------- - // - void upperBoundMsg() { - if (TRACE) System.out.println( "upperBoundMsg entered"); - JOptionPane.showMessageDialog(this, - (new String("Upper bound restricted to " + composeTimeLabel( getLatestDateAllowed()))), - "Calendar Bounds Exception", - JOptionPane.WARNING_MESSAGE); - } - //---------------------------------------------------------------- - // attempt to add or subract a year - void attemptToAddOrSubtractAYear( int numYears ) { - if (TRACE) System.out.println( "attemptToAddOrSubtractAYear entered"); - cal.setTime( liquidDate ); - computeFields( cal ); - int yr = cal.get(YEAR) + numYears; - cal.set( YEAR, yr ); - liquidDate = new GeoDate(cal.getTime()); - if (liquidDateWithinBounds()) { - updateGUIAfterLiquidDateChange(); - } - else { // drops below floor or above ceiling; return to previous value - cal.set( YEAR, (cal.get(YEAR) - numYears) ); - liquidDate = new GeoDate(cal.getTime()); - } - } - //---------------------------------------------------------------- - // update GUI components after liquid Date change - void updateGUIAfterLiquidDateChange() { - if (TRACE) System.out.println( "updateGUIAfterLIquidDateChange entered"); - resetMonthYearPanel( liquidDate ); - resetCalendarPanel( liquidDate ); - softwareDayOfMonthClick( liquidDate ); - updateDateLabel(); - } - //---------------------------------------------------------------- - // item State Changed - public void itemStateChanged( ItemEvent itemEvent) { - if (TRACE) System.out.println( "itemStateChanged entered"); - - if (itemEvent.getSource() == monthList) { - - int mon = monthList.getSelectedIndex(); - cal.setTime( liquidDate ); - computeFields( cal ); - int prevMon = cal.get(MONTH); - - if (prevMon != mon) { - cal.set( MONTH, mon ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - cal.set(MONTH, prevMon ); - liquidDate = new GeoDate(cal.getTime()); - } - updateGUIAfterLiquidDateChange(); - } - } - else if (itemEvent.getSource() == minList) { - int min = Integer.parseInt( (String) minList.getSelectedItem()); - cal.setTime( liquidDate ); - computeFields( cal ); - int oldMin = cal.get(MINUTE); - cal.set(MINUTE, min ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - cal.set(MINUTE, oldMin); - liquidDate = new GeoDate(cal.getTime()); - minList.setVisible(false); - minList.setSelectedIndex( oldMin/5 ); - minList.setVisible(true); - } - updateDateLabel(); - } - } - //---------------------------------------------------------------- - // Action - public void actionPerformed( ActionEvent event ) { - if (TRACE) System.out.println( "actionPerformed entered"); - Object source = event.getSource(); - int mon = 0; - int prevMon = 0; - int yr = 0; - int day = 0; - int inputDayOfMonth; - - if (source == okButn) { - // First, get the hour from the TextField in case user didn't hit - // return - handleHourChange(); - if (sdf != null) { - pcs.firePropertyChange("FormattedDateTime", - sdf.format( getInitialDate()), - sdf.format(liquidDate)); - } - pcs.firePropertyChange("DateTime", - getInitialDate(), - liquidDate); - result_ = OK_RESPONSE; - closeDown(); - } - else if (source == cancelButn) { - result_ = CANCEL_RESPONSE; - closeDown(); - } - else if (source == subYearButn) { - attemptToAddOrSubtractAYear( -1 ); - } - else if (source == addYearButn) { - attemptToAddOrSubtractAYear( 1 ); - } - else if (source == subMonthButn) { - cal.setTime( liquidDate ); - computeFields( cal ); - mon = cal.get(MONTH) - 1; - if (mon == -1) { // Jan --> Dec - mon = 11; - cal.set( MONTH, mon ); - yr = cal.get( YEAR ) - 1; - cal.set( YEAR, yr ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - yr = cal.get( YEAR ) + 1; - cal.set( YEAR, yr); - liquidDate = new GeoDate(cal.getTime()); - } - } - cal.set( MONTH, mon); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - mon = mon + 1; - if (mon == 12) mon = 0; - cal.set( MONTH, mon ); - liquidDate = new GeoDate(cal.getTime()); - } - updateGUIAfterLiquidDateChange(); - } - else if (source == addMonthButn) { - cal.setTime( liquidDate ); - computeFields( cal ); - mon = cal.get(MONTH) + 1; - if (mon == 12) { - mon = 0; - cal.set( MONTH, 0 ); - yr = cal.get(YEAR) + 1; - cal.set( YEAR, yr ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - cal.set( YEAR, cal.get(YEAR) - 1); - liquidDate = new GeoDate(cal.getTime()); - } - } - cal.set(MONTH, mon ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - mon = mon - 1; - if (mon == -1) mon = 11; - cal.set( MONTH, mon ); - liquidDate = new GeoDate(cal.getTime()); - } - updateGUIAfterLiquidDateChange(); - } - else if (source == hourText) { - handleHourChange(); - } - else if (source == yearText) { - handleYearChange(); - } - else if (source == subHourButn) { - try { - // User may have changed the hour text without hitting "return" - // so must synchronize the value in TextField with our variables - handleHourChange(); - // Now, get the value in TextField and decrement - int hr = Integer.parseInt( hourText.getText().trim()); - hr--; - if (hr == -1) { - hr = 23; - } - hourText.setText( (new Integer(hr)).toString() ); - handleHourChange(); - } catch (NumberFormatException e) { - } - } - else if (source == addHourButn) { - try { - // User may have changed the hour text without hitting "return" - // so must synchronize the value in TextField with our variables - handleHourChange(); - // Now, get the value in TextField and decrement - int hr = Integer.parseInt( hourText.getText().trim()); - hr++; - if (hr == 24) { - hr = 0; - } - hourText.setText( (new Integer(hr)).toString() ); - handleHourChange(); - } catch (NumberFormatException e) { - } - } - else if (source == subMinButn) { - try { - int min = Integer.parseInt( (String) minList.getSelectedItem()); - min = min - 5; - if (min == -5) { - min = 55; - } - cal.setTime( liquidDate ); - computeFields( cal ); - int oldMin = cal.get( MINUTE); - cal.set( MINUTE, min ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - cal.set( MINUTE,oldMin); - liquidDate = new GeoDate(cal.getTime()); - min = oldMin; - } - minList.setVisible(false); - minList.setSelectedIndex( min/5 ); - minList.setVisible(true); - updateDateLabel(); - } catch (NumberFormatException e) { - } - } - else if (source == addMinButn) { - try { - int min = Integer.parseInt( (String) minList.getSelectedItem()); - min = min + 5; - if (min == 60) { - min = 0; - } - cal.setTime( liquidDate ); - computeFields( cal ); - int oldMin = cal.get(MINUTE); - cal.set(MINUTE, min ); - liquidDate = new GeoDate(cal.getTime()); - if (!liquidDateWithinBounds()) { - cal.set( MINUTE, oldMin); - liquidDate = new GeoDate(cal.getTime()); - min = oldMin; - } - minList.setVisible(false); - minList.setSelectedIndex( min/5 ); - minList.setVisible(true); - updateDateLabel(); - } catch (NumberFormatException e) { - } - } - else if (source == monthList) { - } - else { // must be from the calendar - try { - inputDayOfMonth = Integer.parseInt( event.getActionCommand().trim()); - cal.setTime( liquidDate ); - computeFields( cal ); - int lastDate = cal.get(DATE); - cal.set(DATE, inputDayOfMonth ); - liquidDate = new GeoDate(cal.getTime()); - if (liquidDateWithinBounds()) { - selectDay( inputDayOfMonth); - updateDateLabel(); - } - else { - cal.set(DATE, lastDate ); - liquidDate = new GeoDate(cal.getTime()); - } - } catch (NumberFormatException e) { - System.out.println(" !!! Trouble with " + event.getActionCommand()); - } - } - } - - public GeoDate getDate() { - return liquidDate; - } - - public void propertyChange( java.beans.PropertyChangeEvent event) { - if (TRACE) System.out.println( "propertyChange entered"); - Object obj = event.getSource(); - this.setTitle( composeTimeLabel( liquidDate)); - if (event.getPropertyName().equals("DateTime")) { - /* - System.out.println(" Property Change, old value: " + - composeTimeLabel( (Date) event.getOldValue()) + " new value: " + - composeTimeLabel( (Date) event.getNewValue())); - */ - } - else if (event.getPropertyName().equals("FormattedDateTime")) { - } - } - public void addPropertyChangeListener( PropertyChangeListener l ) { - pcs.addPropertyChangeListener( l ); - } - public void removePropertyChangeListener( PropertyChangeListener l ) { - pcs.removePropertyChangeListener( l ); - } - - - - // ---------------------------------------------------------------- - // - public static void main(String args[]) { - - GeoDateDialog dtg = new GeoDateDialog(); - dtg.setOutputDateFormatter( new SimpleDateFormat(" dd MMM yyyy HH:mm ")); - - /* - JFrame jf = new JFrame(); - jf.setVisible( true ); - jf.setSize(220 ,323); - jf.getContentPane().add( dtg ); - jf.invalidate(); - jf.validate(); - jf.addWindowListener( new WindowAdapter() { - public void windowClosing( WindowEvent e) { - Window w = e.getWindow(); - w.setVisible( false ); - w.dispose(); - System.exit( 0 ); - } - }); - */ - - int result = dtg.showDialog(new GeoDate(), 200, 200); - - System.out.println("Result = " + result); - System.out.println("Date = " + dtg.getGeoDate().toString()); - - dtg.addPropertyChangeListener( new PropertyChangeListener() { - public void propertyChange( java.beans.PropertyChangeEvent event) { - if (event.getPropertyName().equals("FormattedDateTime")) { - System.out.println(" MAIN Property Change, old value: " + - (String) event.getOldValue() + " new value: " + - (String) event.getNewValue()); - } - } - }); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GridAttributeDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GridAttributeDialog.java deleted file mode 100755 index 40859bb8..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GridAttributeDialog.java +++ /dev/null @@ -1,885 +0,0 @@ -/* - * $Id: GridAttributeDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import java.awt.*; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumn; -import javax.swing.event.TableModelEvent; -import java.util.Vector; -import java.io.File; -import java.io.Reader; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.StreamTokenizer; - -import gov.noaa.pmel.sgt.GridCartesianRenderer; -import gov.noaa.pmel.sgt.GridAttribute; -import gov.noaa.pmel.sgt.ContourLineAttribute; -import gov.noaa.pmel.sgt.DefaultContourLineAttribute; -import gov.noaa.pmel.sgt.ContourLevels; -import gov.noaa.pmel.sgt.ColorMap; -import gov.noaa.pmel.sgt.IndexedColor; -import gov.noaa.pmel.sgt.swing.ColorSwatchIcon; -import gov.noaa.pmel.sgt.IndexedColorMap; -import gov.noaa.pmel.sgt.LinearTransform; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.ContourLevelNotFoundException; -import gov.noaa.pmel.sgt.dm.SGTGrid; - -import gov.noaa.pmel.util.Range2D; -import java.awt.event.*; - -/** - * Edits the GridAttribute. This dialog does not make a - * copy of the attribute so changes "Applied" will cause - * sgt to redraw the plot using the properties - * immediately unless a JPane was supplied. - * - *

Example of GridAttributeDialog use: - *

- *  JPane pane_;
- *  CartesianRenderer rend = ((CartesianGraph)pane_.getFirstLayer().getGraph()).getRenderer();
- *  ...
- *  GridAttributeDialog gad = new GridAttributeDialog();
- *  gad.setJPane(pane_);
- *  gad.setGridCartesianRenderer((GridCartesianRenderer)rend);
- *  gad.setVisible(true);
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - * @see NewLevelsDialog - * @see ContourLineAttributeDialog - * @see DefaultContourLineAttributeDialog - */ -public class GridAttributeDialog extends JDialog { - private GridAttribute attr_; - private ContourLevels conLevels_; - private ColorMap colorMap_; - private JPane[] paneList_ = null; - private int contourLevelIndex_ = 0; - private int colorMapIndex_ = 1; - private JTable conLevelTable_; - private ConLevelTableModel conLevelModel_; - private SGTGrid grid_ = null; - private JToggleButton[] colorButtons_ = new JToggleButton[256]; - /** - * Constructor. - */ - public GridAttributeDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(516,374); - setVisible(false); - mainPanel.setPreferredSize(new Dimension(516, 36)); - getContentPane().add(TabbedPane, "Center"); - ContourLevelsPanel.setLayout(new BorderLayout(0,0)); - TabbedPane.add(ContourLevelsPanel, "ContourLevelsPanel"); - ContourLevelsPanel.setBounds(2,27,511,271); - ContourLevelsPanel.setVisible(false); - ContourLevelsPanel.add(gridScrollPane, "Center"); - controlPanel.setLayout(new GridBagLayout()); - ContourLevelsPanel.add(controlPanel, "East"); - JPanel1.setBorder(titledBorder1); - JPanel1.setLayout(new GridBagLayout()); - controlPanel.add(JPanel1, new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); - editButton.setToolTipText("Edit attribute of selected level."); - editButton.setText("Edit Attribute"); - editButton.setActionCommand("Change Value"); - JPanel1.add(editButton, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,0,5),0,0)); - aboveButton.setToolTipText("Insert level above selected level."); - aboveButton.setText("Insert Level Above"); - aboveButton.setActionCommand("Before Item"); - JPanel1.add(aboveButton, new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(2,5,0,5),0,0)); - belowButton.setToolTipText("Insert level below selected level."); - belowButton.setText("Insert Level Below"); - belowButton.setActionCommand("After Item"); - JPanel1.add(belowButton, new GridBagConstraints(0,2,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(2,5,0,5),0,0)); - deleteButton.setToolTipText("Delete the selected level."); - deleteButton.setText("Delete Level"); - deleteButton.setActionCommand("Delete Item"); - JPanel1.add(deleteButton, new GridBagConstraints(0,3,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(2,5,2,5),0,0)); - JPanel4.setBorder(titledBorder4); - JPanel4.setLayout(new GridBagLayout()); - controlPanel.add(JPanel4, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); - defaultButton.setToolTipText("Edit default attributes."); - defaultButton.setText("Edit Default Attributes"); - defaultButton.setActionCommand("Edit Default Attributes"); - JPanel4.add(defaultButton, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(2,5,2,5),0,0)); - sortButton.setToolTipText("Sort levels by value."); - sortButton.setText("Sort Levels"); - sortButton.setActionCommand("Sort"); - controlPanel.add(sortButton, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,5,5),0,0)); - newConLevelButton.setToolTipText("Create new contour level set."); - newConLevelButton.setText("New..."); - newConLevelButton.setActionCommand("New..."); - controlPanel.add(newConLevelButton, new GridBagConstraints(0,0,1,1,1.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,5,0,5),0,0)); - ColorMapPanel.setLayout(new BorderLayout(0,0)); - TabbedPane.add(ColorMapPanel, "ColorMapPanel"); - ColorMapPanel.setBounds(2,27,511,271); - ColorMapPanel.setVisible(false); - colorControlPanel.setLayout(new GridBagLayout()); - ColorMapPanel.add(colorControlPanel, "East"); - colorMapPanel.setBorder(titledBorder2); - colorMapPanel.setLayout(new GridBagLayout()); - colorControlPanel.add(colorMapPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); - newColorMapButton.setToolTipText("Create new color map."); - newColorMapButton.setText("New..."); - newColorMapButton.setActionCommand("New..."); - colorMapPanel.add(newColorMapButton, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); - loadColorMapButton.setToolTipText("Load color map from disk."); - loadColorMapButton.setText("Load..."); - loadColorMapButton.setActionCommand("Load..."); - colorMapPanel.add(loadColorMapButton, new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); - saveColorMapButton.setToolTipText("Save color map to disk."); - saveColorMapButton.setText("Save..."); - saveColorMapButton.setActionCommand("Save..."); - colorMapPanel.add(saveColorMapButton, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); - colorPanel.setLayout(new CardLayout(0,0)); - ColorMapPanel.add(colorPanel, "Center"); - CLIndexedPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - colorPanel.add("CLIndexed", CLIndexedPanel); - CLTransformPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - colorPanel.add("CLTransform", CLTransformPanel); - CLTransformPanel.setVisible(false); - IndexedPanel.setLayout(new GridBagLayout()); - colorPanel.add("Indexed", IndexedPanel); - IndexedPanel.setVisible(false); - colorButtonsPanel.setLayout(new GridLayout(16,16,1,1)); - IndexedPanel.add(colorButtonsPanel, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - TransformPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - colorPanel.add("Transform", TransformPanel); - TransformPanel.setVisible(false); - TabbedPane.setSelectedComponent(ContourLevelsPanel); - TabbedPane.setSelectedIndex(0); - TabbedPane.setTitleAt(0,"Contour Levels"); - TabbedPane.setTitleAt(1,"Color Map"); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - mainPanel.setLayout(new GridBagLayout()); - getContentPane().add(mainPanel, "North"); - JLabel5.setText("Grid Style:"); - mainPanel.add(JLabel5, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(5,5,0,5),0,0)); - gridStyleComboBox.setModel(stringComboBoxModel1); - mainPanel.add(gridStyleComboBox, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - { - String[] tempString = new String[5]; - tempString[0] = "RASTER"; - tempString[1] = "AREA_FILL"; - tempString[2] = "CONTOUR"; - tempString[3] = "RASTER_CONTOUR"; - tempString[4] = "AREA_FILL_CONTOUR"; - for(int i=0; i < tempString.length; i++) { - stringComboBoxModel1.addElement(tempString[i]); - } - } - gridStyleComboBox.setSelectedIndex(0); - setTitle("GridAttribute Properties"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - gridStyleComboBox.addActionListener(lSymAction); - newConLevelButton.addActionListener(lSymAction); - newColorMapButton.addActionListener(lSymAction); - loadColorMapButton.addActionListener(lSymAction); - editButton.addActionListener(lSymAction); - aboveButton.addActionListener(lSymAction); - belowButton.addActionListener(lSymAction); - deleteButton.addActionListener(lSymAction); - sortButton.addActionListener(lSymAction); - saveColorMapButton.addActionListener(lSymAction); - defaultButton.addActionListener(lSymAction); - - makeColorToggleButtons(); - } - - private void makeColorToggleButtons() { - Insets insets = new Insets(0,0,0,0); - ButtonGroup bg = new ButtonGroup(); - ColorSwatchIcon csi = null; - for(int i=0; i < 256; i++) { - JToggleButton tb = new JToggleButton(""); - if(System.getProperty("mrj.version") == null || - !UIManager.getSystemLookAndFeelClassName().equals(UIManager.getLookAndFeel().getClass().getName())) - tb.setMargin(insets); - csi = new ColorSwatchIcon(Color.white, 8, 8); - tb.setIcon(csi); - colorButtons_[i] = tb; - colorButtonsPanel.add(tb); - bg.add(tb); - } - } - /** Used internally. */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public GridAttributeDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public GridAttributeDialog() { - this((Frame)null); - } - /** - * Make the dialog visible. - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == GridAttributeDialog.this) - GridAttributeDialog_WindowClosing(event); - } - } - - void GridAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - //{{DECLARE_CONTROLS - javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); - javax.swing.JPanel ContourLevelsPanel = new javax.swing.JPanel(); - javax.swing.JScrollPane gridScrollPane = new javax.swing.JScrollPane(); - javax.swing.JPanel controlPanel = new javax.swing.JPanel(); - javax.swing.JPanel JPanel1 = new javax.swing.JPanel(); - javax.swing.JButton editButton = new javax.swing.JButton(); - javax.swing.JButton aboveButton = new javax.swing.JButton(); - javax.swing.JButton belowButton = new javax.swing.JButton(); - javax.swing.JButton deleteButton = new javax.swing.JButton(); - javax.swing.JPanel JPanel4 = new javax.swing.JPanel(); - javax.swing.JButton defaultButton = new javax.swing.JButton(); - javax.swing.JButton sortButton = new javax.swing.JButton(); - javax.swing.JButton newConLevelButton = new javax.swing.JButton(); - javax.swing.JPanel ColorMapPanel = new javax.swing.JPanel(); - javax.swing.JPanel colorControlPanel = new javax.swing.JPanel(); - javax.swing.JPanel colorMapPanel = new javax.swing.JPanel(); - javax.swing.JButton newColorMapButton = new javax.swing.JButton(); - javax.swing.JButton loadColorMapButton = new javax.swing.JButton(); - javax.swing.JButton saveColorMapButton = new javax.swing.JButton(); - javax.swing.JPanel colorPanel = new javax.swing.JPanel(); - javax.swing.JPanel CLIndexedPanel = new javax.swing.JPanel(); - javax.swing.JPanel CLTransformPanel = new javax.swing.JPanel(); - javax.swing.JPanel IndexedPanel = new javax.swing.JPanel(); - javax.swing.JPanel colorButtonsPanel = new javax.swing.JPanel(); - javax.swing.JPanel TransformPanel = new javax.swing.JPanel(); - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.JPanel mainPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JComboBox gridStyleComboBox = new javax.swing.JComboBox(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - DefaultComboBoxModel stringComboBoxModel1 = new DefaultComboBoxModel(); - javax.swing.border.EtchedBorder etchedBorder2 = new javax.swing.border.EtchedBorder(); - javax.swing.border.TitledBorder titledBorder1 = new javax.swing.border.TitledBorder("Contour Level"); - javax.swing.border.EmptyBorder emptyBorder1 = new javax.swing.border.EmptyBorder(5,0,0,0); - javax.swing.border.TitledBorder titledBorder4 = new javax.swing.border.TitledBorder("Default Attributes"); - javax.swing.border.TitledBorder titledBorder2 = new javax.swing.border.TitledBorder("Color Map"); - //}} - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == gridStyleComboBox) - gridStyleComboBox_actionPerformed(event); - if (object == newConLevelButton) - newConLevelButton_actionPerformed(event); - if (object == newColorMapButton) - newColorMapButton_actionPerformed(event); - else if (object == loadColorMapButton) - loadColorMapButton_actionPerformed(event); - else if (object == editButton) - editButton_actionPerformed(event); - else if (object == aboveButton) - aboveButton_actionPerformed(event); - else if (object == belowButton) - belowButton_actionPerformed(event); - else if (object == deleteButton) - deleteButton_actionPerformed(event); - else if (object == sortButton) - sortButton_actionPerformed(event); - else if (object == saveColorMapButton) - saveColorMapButton_actionPerformed(event); - else if (object == defaultButton) - defaultButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - updateGridAttribute(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateGridAttribute(); - } - /** - * Set the parent JPane. This reference to - * JPane is used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. - */ - public void setJPane(JPane pane) { - paneList_ = new JPane[1]; - paneList_[0] = pane; - } - /** - * Get the first parent pane. - */ - public JPane getJPane() { - if(paneList_ != null) { - return paneList_[0]; - } else { - return null; - } - } - /** - * Set the parent JPanes. These references to - * JPane are used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. A second - * JPane is often used for a ColorKey. - */ - public void setJPaneList(JPane[] list) { - paneList_ = list; - } - /** Get an array of parent panes. */ - public JPane[] getJPaneList() { - return paneList_; - } - - /** - * Set the GridCartesianRenderer. Specifying the - * renderer give GridAttributeDialog a reference to the - * data and GridAttribute allowing automated - * computation of ColorMap and - * ContourLevels ranges. - * - * @see #setGridAttribute(GridAttribute) - */ - public void setGridCartesianRenderer(GridCartesianRenderer render) { - grid_ = render.getGrid(); - setGridAttribute((GridAttribute)render.getAttribute()); - } - /** - * Set the GridAttribute. - */ - public void setGridAttribute(GridAttribute attr) { - attr_ = attr; - colorMap_ = attr.getColorMap(); - conLevels_ = attr.getContourLevels(); - // - // style - // - int style = attr_.getStyle(); - gridStyleComboBox.setSelectedIndex(style); - // - // contour ? - // - enableContourLevels(style); - initContourLevels(); - // - // raster ? - // - enableColorMap(style); - initColorMap(); - // - setCurrentTab(); - } - - private void enableContourLevels(int style) { - boolean isContour = (style == GridAttribute.CONTOUR || - style == GridAttribute.RASTER_CONTOUR || - style == GridAttribute.AREA_FILL_CONTOUR); - TabbedPane.setEnabledAt(contourLevelIndex_, isContour); - Component[] list = ContourLevelsPanel.getComponents(); - boolean clExists = conLevels_ != null; - for(int i=0; i < list.length; i++) { - list[i].setEnabled(clExists); - } - newConLevelButton.setEnabled(true); - } - - private void enableColorMap(int style) { - boolean isRaster = style != GridAttribute.CONTOUR; - TabbedPane.setEnabledAt(colorMapIndex_, isRaster); - Component[] list = ColorMapPanel.getComponents(); - boolean cmExists = colorMap_ != null; - for(int i=0; i < list.length; i++) { - list[i].setEnabled(cmExists); - } - newColorMapButton.setEnabled(true); - } - - private void setCurrentTab() { - if(!TabbedPane.isEnabledAt(TabbedPane.getSelectedIndex())) { - // - // change to other tab - // - if(TabbedPane.getSelectedIndex() == colorMapIndex_) { - TabbedPane.setSelectedIndex(contourLevelIndex_); - } else { - TabbedPane.setSelectedIndex(colorMapIndex_); - } - } - } - - private void initContourLevels() { - createConLevelTable(); - } - - private void initColorMap() { - ColorSwatchIcon csi; - int i; - if(colorMap_ instanceof IndexedColor) { - int maxindx = ((IndexedColor)colorMap_).getMaximumIndex(); - for(i=0; i <= maxindx; i++) { - csi = new ColorSwatchIcon((IndexedColor)colorMap_, i, 8); - colorButtons_[i].setIcon(csi); - colorButtons_[i].setEnabled(true); - } - for(i=maxindx+1; i < 256; i++) { - csi = new ColorSwatchIcon(Color.white, 8, 8); - colorButtons_[i].setIcon(csi); - colorButtons_[i].setEnabled(false); - } - ((CardLayout)colorPanel.getLayout()).show(colorPanel, "Indexed"); - } - } - - void updateGridAttribute() { - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(true, "GridAttributeDialog"); - } - } - updateConLevels(); - attr_.setContourLevels(conLevels_); - attr_.setColorMap(colorMap_); - attr_.setStyle(gridStyleComboBox.getSelectedIndex()); - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(false, "GridAttributeDialog"); - } - } - } - /** - * Test entry point. - */ - public static void main(String[] args) { - Range2D range = new Range2D(-20.0f, 45.0f, 5.0f); - ContourLevels clevels = ContourLevels.getDefault(range); - GridAttribute attr = new GridAttribute(clevels); - GridAttributeDialog la = new GridAttributeDialog(); - la.setGridAttribute(attr); - la.setTitle("Test GridAttribute Dialog"); - la.setVisible(true); - } - - void gridStyleComboBox_actionPerformed(java.awt.event.ActionEvent event) { - int style = gridStyleComboBox.getSelectedIndex(); - // - enableContourLevels(style); - enableColorMap(style); - setCurrentTab(); - // - } - - void newConLevelButton_actionPerformed(java.awt.event.ActionEvent event) { - NewLevelsDialog nld = new NewLevelsDialog(); - int result = nld.showDialog(grid_); - if(result == NewLevelsDialog.OK_RESPONSE) { - Range2D range = nld.getRange(); - conLevels_ = ContourLevels.getDefault(range); - initContourLevels(); - } - } - - void newColorMapButton_actionPerformed(java.awt.event.ActionEvent event) { - // - // this will be replaced by a specialized dialog - // - // - // define default colormap (ps.64) - // - int[] red = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 23, 39, 55, 71, 87,103, - 119,135,151,167,183,199,215,231, - 247,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,246,228,211,193,175,158,140}; - int[] green = - { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 11, 27, 43, 59, 75, 91,107, - 123,139,155,171,187,203,219,235, - 251,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0}; - int[] blue = - { 0,143,159,175,191,207,223,239, - 255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255, - 255,247,231,215,199,183,167,151, - 135,119,103, 87, 71, 55, 39, 23, - 7, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - // - colorMap_ = new IndexedColorMap(red, green, blue); - ((IndexedColorMap)colorMap_).setTransform(new LinearTransform(0.0, - (double)red.length, - 0.0, 1.0)); - initColorMap(); - } - - void loadColorMapButton_actionPerformed(ActionEvent event) { - int[] r = new int[256]; - int[] g = new int[256]; - int[] b = new int[256]; - int lastindx = -1; - File file = null; - StreamTokenizer st = null; - JFileChooser chooser = new JFileChooser("C:/local/pal"); - int returnVal = chooser.showOpenDialog(this); - if(returnVal == JFileChooser.APPROVE_OPTION) { - file = chooser.getSelectedFile(); - try { - Reader rdr = new BufferedReader(new FileReader(file)); - st = new StreamTokenizer(rdr); - } catch (java.io.FileNotFoundException e) { - System.out.println(e); - return; - } - try { - st.nextToken(); - while(st.ttype != StreamTokenizer.TT_EOF) { - lastindx++; - if(st.ttype == StreamTokenizer.TT_NUMBER) { - r[lastindx] = (int)st.nval; - st.nextToken(); - g[lastindx] = (int)st.nval; - st.nextToken(); - b[lastindx] = (int)st.nval; - } - if(st.nextToken() == StreamTokenizer.TT_EOL) st.nextToken(); - } - } catch (java.io.IOException e) { - System.out.println(e); - } - int[] red = new int[lastindx+1]; - int[] green = new int[lastindx+1]; - int[] blue = new int[lastindx+1]; - for(int i=0; i <= lastindx; i++) { - red[i] = r[i]; - green[i] = g[i]; - blue[i] = b[i]; - } - colorMap_ = new IndexedColorMap(red, green, blue); - ((IndexedColorMap)colorMap_).setTransform(new LinearTransform(0.0, - (double)red.length, - 0.0, 1.0)); - initColorMap(); - } - } - - void editButton_actionPerformed(java.awt.event.ActionEvent event) { - ContourLineAttribute attr; - int index = conLevelTable_.getSelectedRow(); - if(index < 0) return; - ContourLineAttributeDialog clad = new ContourLineAttributeDialog(); - attr = (ContourLineAttribute) - ((ContourLineAttribute)conLevelModel_.getValueAt(index,1)).copy(); - int result = clad.showDialog(attr); - if(result == ContourLineAttributeDialog.OK_RESPONSE) { - attr = clad.getContourLineAttribute(); - conLevelModel_.setValueAt(attr, index, 1); - } - } - - void aboveButton_actionPerformed(java.awt.event.ActionEvent event) { - int index = conLevelTable_.getSelectedRow(); - if(index < 0) return; - conLevelModel_.insert(index, - new Double(0.0), - new ContourLineAttribute(ContourLineAttribute.SOLID)); - } - - void belowButton_actionPerformed(java.awt.event.ActionEvent event) { - int index = conLevelTable_.getSelectedRow(); - if(index < 0) return; - conLevelModel_.insert(index + 1, - new Double(0.0), - new ContourLineAttribute(ContourLineAttribute.SOLID)); - } - - void deleteButton_actionPerformed(java.awt.event.ActionEvent event) { - int index = conLevelTable_.getSelectedRow(); - if(index < 0) return; - conLevelModel_.remove(index); - } - - void sortButton_actionPerformed(java.awt.event.ActionEvent event) { - conLevelModel_.sort(); - } - - void defaultButton_actionPerformed(java.awt.event.ActionEvent event) { - DefaultContourLineAttribute attr; - DefaultContourLineAttributeDialog dclad = new DefaultContourLineAttributeDialog(); - attr = conLevels_.getDefaultContourLineAttribute(); - int result = dclad.showDialog((DefaultContourLineAttribute)attr.copy()); - if(result == DefaultContourLineAttributeDialog.OK_RESPONSE) { - attr = dclad.getDefaultContourLineAttribute(); - conLevels_.setDefaultContourLineAttribute(attr); - } - } - - void saveColorMapButton_actionPerformed(java.awt.event.ActionEvent event) { - // to do: code goes here. - } - - void createConLevelTable() { - Double val; - ContourLineAttribute attr; - conLevelModel_ = new ConLevelTableModel(); - conLevelTable_ = new JTable(conLevelModel_); - conLevelTable_.setSize(1000,1000); - ListSelectionModel lsm = conLevelTable_.getSelectionModel(); - lsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - TableColumn tc; - tc = conLevelTable_.getColumnModel().getColumn(0); - tc.setPreferredWidth(250); - tc = conLevelTable_.getColumnModel().getColumn(1); - tc.setPreferredWidth(750); - gridScrollPane.getViewport().add(conLevelTable_); - // - if(conLevels_ == null) return; - int size = conLevels_.size(); - for(int i=0; i < size; i++) { - try { - val = new Double(conLevels_.getLevel(i)); - attr = conLevels_.getContourLineAttribute(i); - conLevelModel_.add(val, attr); - } catch (ContourLevelNotFoundException e) { - System.out.println(e); - } - } - } - - private void updateConLevels() { - if(conLevels_ == null) return; - ContourLevels cl = new ContourLevels(); - Double val; - ContourLineAttribute attr; - conLevelModel_.sort(); - int size = conLevelModel_.getRowCount(); - for(int i=0; i < size; i++) { - val = (Double)conLevelModel_.getValueAt(i,0); - attr = (ContourLineAttribute)conLevelModel_.getValueAt(i,1); - cl.addLevel(val.doubleValue(), attr); - } - cl.setDefaultContourLineAttribute(conLevels_.getDefaultContourLineAttribute()); - conLevels_ = cl; - } - - class ConLevelTableModel extends AbstractTableModel { - Vector values = new Vector(); - Vector attr = new Vector(); - String[] titles = {"Value", "Attribute"}; - - public void add(Double val, ContourLineAttribute cla) { - values.addElement(val); - attr.addElement(cla); - } - - public void insert(int row, Double val, ContourLineAttribute cla) { - values.insertElementAt(val, row); - attr.insertElementAt(cla, row); - fireTableChanged(new TableModelEvent(this, row, row, - TableModelEvent.ALL_COLUMNS, - TableModelEvent.INSERT)); - } - - public void remove(int row) { - values.removeElementAt(row); - attr.removeElementAt(row); - fireTableChanged(new TableModelEvent(this, row, row, - TableModelEvent.ALL_COLUMNS, - TableModelEvent.DELETE)); - } - - public void sort() { - // - // use brain-dead bubble sort (there will be few lines) - // - int i, temp; - int size = values.size(); - Double a, b; - int[] index = new int[size]; - boolean flipped = true; - for(i=0; i < size; i++) { - index[i] = i; - } - while(flipped) { - flipped = false; - for(i=0; i < size-1; i++) { - a = (Double)values.elementAt(index[i]); - b = (Double)values.elementAt(index[i+1]); - if(a.doubleValue() > b.doubleValue()) { - // if(a.compareTo(b) > 0) { // jdk1.2 - temp = index[i]; - index[i] = index[i+1]; - index[i+1] = temp; - flipped = true; - } - } - } - Vector oldValues = values; - Vector oldAttr = attr; - values = new Vector(size); - attr = new Vector(size); - for(i=0; i < size; i++) { - values.addElement(oldValues.elementAt(index[i])); - attr.addElement(oldAttr.elementAt(index[i])); - } - fireTableChanged(new TableModelEvent(this)); - } - - public Object getValueAt(int row, int col) { - if(col == 0) { - return values.elementAt(row); - } else { - return attr.elementAt(row); - } - } - - public void setValueAt(Object obj, int row, int col) { - if(col == 0) { - if(obj instanceof Double) { - values.setElementAt(obj, row); - } else if(obj instanceof String) { - values.setElementAt(new Double((String)obj), row); - } - } else { - attr.setElementAt(obj, row); - } - fireTableCellUpdated(row, col); - } - - public int getRowCount() { - return values.size(); - } - - public int getColumnCount() { - return 2; - } - - public String getColumnName(int col) { - return titles[col]; - } - - public boolean isCellEditable(int row, int col) { - return col == 0; - } - - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GridBagConstraints.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GridBagConstraints.java deleted file mode 100755 index 8e2ec503..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/GridBagConstraints.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * $Id: GridBagConstraints.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; -/** - * Creates a GridBagConstraints object from the - * constructor. This class duplicates functionality available in jdk1.2 - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class GridBagConstraints extends java.awt.GridBagConstraints { - -/** - * Creates a GridBagConstraint object. - */ - - public GridBagConstraints(int gridX, - int gridY, - int gridWidth, - int gridHeight, - double weightX, - double weightY, - int anchor, - int fills, - java.awt.Insets inset, - int ipadX, - int ipadY) { - - gridx = gridX; - gridy = gridY; - gridwidth = gridWidth; - gridheight = gridHeight; - weightx = weightX; - weighty = weightY; - this.anchor = anchor; - fill = fills; - insets = inset; - ipadx = ipadX; - ipady = ipadY; - - } -} - - - - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/LineAttributeDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/LineAttributeDialog.java deleted file mode 100755 index c1497531..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/LineAttributeDialog.java +++ /dev/null @@ -1,587 +0,0 @@ -/* - * $Id: LineAttributeDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import gov.noaa.pmel.sgt.JPane; - -import javax.swing.*; -import java.awt.*; -import java.util.StringTokenizer; - -import gov.noaa.pmel.sgt.LineAttribute; -import gov.noaa.pmel.sgt.swing.PlotMarkIcon; -import gov.noaa.pmel.swing.ThreeDotsButton; -import javax.swing.border.*; -import java.awt.event.*; - -/** - * Edits a LineAttribute. This dialog does not - * make a copy of the attribute so changes "Applied" will cause - * sgt to redraw the plot using the new properties unless - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} - * has been turned on. - * - *

Example of LineAttributeDialog use: - *

- * public void editLineAttribute(LineAttribute attr) {
- *   LineAttributeDialog lad = new LineAttributeDialog();
- *   lad.setLineAttribute(attr);
- *   lad.setVisible(true);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - * @see PlotMarkDialog - * @see ArrayEditDialog - */ -public class LineAttributeDialog extends JDialog { - private LineAttribute attr_; - private PlotMarkIcon pmIcon_; - private int mark_; - private JPane[] paneList_ = null; - /** - * Constructor. - */ - public LineAttributeDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - - void jbInit() throws Exception { - { - String[] tempString = new String[7]; - tempString[0] = "SOLID"; - tempString[1] = "DASHED"; - tempString[2] = "HEAVY"; - tempString[3] = "HIGHLIGHT"; - tempString[4] = "MARK"; - tempString[5] = "MARK & SOLID"; - tempString[6] = "STROKE"; - for(int i=0; i < tempString.length; i++) { - lineStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "BUTT"; - tempString[1] = "ROUND"; - tempString[2] = "SQUARE"; - for(int i=0; i < tempString.length; i++) { - capStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "MITER"; - tempString[1] = "ROUND"; - tempString[2] = "BEVEL"; - for(int i=0; i < tempString.length; i++) { - miterStyleCBM.addElement(tempString[i]); - } - } - strokeBorder = new TitledBorder(""); - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(500,490); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - strokePanel.setBorder(strokeBorder); - strokePanel.setLayout(gridBagLayout1); - strokeBorder.setTitle("Stroke Line Attributes"); - JLabel10.setText(" Width:"); - widthTextField.setColumns(10); - JLabel8.setText("Dash Array:"); - dashArrayPanel.setLayout(flowLayout1); - arrayEditor.setActionCommand("..."); - JLabel9.setText("Dash Phase:"); - dashPhaseTextField.setColumns(10); - jLabel1.setText("Cap Style:"); - jLabel2.setText("Miter Style:"); - jLabel3.setText("Miter Limit:"); - miterLimitTextField.setColumns(10); - capStyleComboBox.setModel(capStyleCBM); - miterStyleComboBox.setModel(miterStyleCBM); - lineStyleComboBox.addActionListener(new LineAttributeDialog_lineStyleComboBox_actionAdapter(this)); - dashArrayTextField.setColumns(28); - getContentPane().add(buttonPanel, "South"); - buttonPanel.setBounds(0,263,430,39); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - okButton.setBounds(115,7,51,25); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - applyButton.setBounds(171,7,65,25); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - cancelButton.setBounds(241,7,73,25); - //$$ etchedBorder1.move(0,300); - mainPanel.setLayout(new GridBagLayout()); - getContentPane().add(mainPanel, "Center"); - mainPanel.setBounds(0,0,430,263); - JLabel1.setText("Color:"); - mainPanel.add(JLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(15, 15, 5, 5), 0, 0)); - JLabel1.setBounds(65,43,33,15); - colorPanel.setBorder(etchedBorder1); - mainPanel.add(colorPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 5, 15), 0, 0)); - colorPanel.setBounds(108,29,295,39); - JLabel5.setText("Line Style:"); - mainPanel.add(JLabel5, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 15, 5, 5), 0, 0)); - JLabel5.setBounds(40,80,58,15); - lineStyleComboBox.setModel(lineStyleCBM); - mainPanel.add(lineStyleComboBox, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 15), 0, 0)); - lineStyleComboBox.setBounds(108,73,92,24); - JLabel6.setText("Mark:"); - mainPanel.add(JLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 15, 5, 5), 0, 0)); - JLabel6.setBounds(66,133,32,15); - markPanel.setLayout(flowLayout2); - mainPanel.add(markPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 15), 0, 0)); - markPanel.setBounds(108,126,48,25); - markPanel.add(plotMarkIconLabel, null); - plotMarkIconLabel.setForeground(java.awt.Color.black); - plotMarkIconLabel.setBounds(0,0,0,0); - markEditor.setActionCommand("..."); - markPanel.add(markEditor, null); - JLabel7.setText("MarkHeight:"); - mainPanel.add(JLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 22, 5, 5), 0, 0)); - JLabel7.setBounds(30,160,68,15); - markHeightTextField.setColumns(10); - mainPanel.add(markHeightTextField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 5, 15), 0, 0)); - markHeightTextField.setBounds(108,156,110,19); - mainPanel.add(strokePanel, new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 15, 10), 0, 0)); - strokePanel.add(JLabel10, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(widthTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(JLabel8, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(dashArrayPanel, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - dashArrayPanel.add(dashArrayTextField, null); - dashArrayPanel.add(arrayEditor, null); - strokePanel.add(JLabel9, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(dashPhaseTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel2, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(capStyleComboBox, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(miterStyleComboBox, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel3, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - strokePanel.add(miterLimitTextField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - //$$ stringComboBoxModel1.move(24,300); - lineStyleComboBox.setSelectedIndex(0); - setTitle("LineAttribute Properties"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - markEditor.addActionListener(lSymAction); - arrayEditor.addActionListener(lSymAction); - - // - pmIcon_ = new PlotMarkIcon(1); - plotMarkIconLabel.setIcon(pmIcon_); - // - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public LineAttributeDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public LineAttributeDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == LineAttributeDialog.this) - LineAttributeDialog_WindowClosing(event); - } - } - - void LineAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JPanel mainPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - ColorEntryPanel colorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JComboBox lineStyleComboBox = new javax.swing.JComboBox(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JPanel markPanel = new javax.swing.JPanel(); - javax.swing.JLabel plotMarkIconLabel = new javax.swing.JLabel(); - ThreeDotsButton markEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JTextField markHeightTextField = new javax.swing.JTextField(); - DefaultComboBoxModel lineStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel capStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel miterStyleCBM = new DefaultComboBoxModel(); - JPanel strokePanel = new JPanel(); - TitledBorder strokeBorder; - GridBagLayout gridBagLayout1 = new GridBagLayout(); - JLabel JLabel10 = new javax.swing.JLabel(); - JTextField widthTextField = new javax.swing.JTextField(); - JLabel JLabel8 = new javax.swing.JLabel(); - JTextField dashArrayTextField = new javax.swing.JTextField(); - JPanel dashArrayPanel = new javax.swing.JPanel(); - ThreeDotsButton arrayEditor = new ThreeDotsButton(); - JLabel JLabel9 = new javax.swing.JLabel(); - JTextField dashPhaseTextField = new javax.swing.JTextField(); - JLabel jLabel1 = new JLabel(); - JLabel jLabel2 = new JLabel(); - JComboBox capStyleComboBox = new JComboBox(); - JComboBox miterStyleComboBox = new JComboBox(); - JLabel jLabel3 = new JLabel(); - JTextField miterLimitTextField = new JTextField(); - private FlowLayout flowLayout1 = new FlowLayout(); - private FlowLayout flowLayout2 = new FlowLayout(); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == markEditor) - markEditor_actionPerformed(event); - else if (object == arrayEditor) - arrayEditor_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - updateLineAttribute(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateLineAttribute(); - } - /** - * Set the LineAttribute for the dialog. - */ - public void setLineAttribute(LineAttribute attr) { - attr_ = attr; - // - // Color - // - colorPanel.setColor(attr_.getColor()); - // - // style - // - lineStyleComboBox.setSelectedIndex(attr_.getStyle()); - // - // mark - // - int mark = attr_.getMark(); - changeMark(mark); - // - // mark height - // - markHeightTextField.setText(Double.toString(attr_.getMarkHeightP())); - // - // Stroke line attributes - // - // width - // - widthTextField.setText(Float.toString(attr_.getWidth())); - // - // dash Array - // - float[] da = attr_.getDashArray(); - dashArrayTextField.setText(dashArrayString(da)); - // - // dash phase - // - dashPhaseTextField.setText(Float.toString(attr_.getDashPhase())); - // - // cap style - // - capStyleComboBox.setSelectedIndex(attr_.getCapStyle()); - // - // miter style - // - miterStyleComboBox.setSelectedIndex(attr_.getMiterStyle()); - // - // miter limit - // - miterLimitTextField.setText(Float.toString(attr_.getMiterLimit())); - // - // test for stroke panel enabled - // - strokePanelEnabled(lineStyleComboBox.getSelectedIndex() == LineAttribute.STROKE); - } - - private String dashArrayString(float[] da) { - if(da == null) { - return "null"; - } - StringBuffer sbuf = new StringBuffer("{"); - for(int i=0; i < da.length; i++) { - sbuf.append(Float.toString(da[i]) + ", "); - } - sbuf.setLength(sbuf.length()-2); - sbuf.append("}"); - return sbuf.toString(); - } - private float[] dashArray() { - String arrayString = dashArrayTextField.getText(); - int start = arrayString.indexOf("{"); - int stop = arrayString.indexOf("}"); - String sub = arrayString.substring(start+1,stop); - // - // parse array - // - StringTokenizer token = new StringTokenizer(sub, ","); - int index = 0; - float[] array = new float[token.countTokens()]; - while(token.hasMoreTokens()) { - array[index] = new Float(token.nextToken()).floatValue(); - index++; - } - return array; - } - - void updateLineAttribute() { - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(true, "LineAttributeDialog"); - } - } - attr_.setBatch(true); - // - // Color - // - attr_.setColor(colorPanel.getColor()); - // - // style - // - attr_.setStyle(lineStyleComboBox.getSelectedIndex()); - // - // mark - // - attr_.setMark(mark_); - // - // mark height - // - attr_.setMarkHeightP(new Double(markHeightTextField.getText()).doubleValue()); - // - // stroke attributes - // - // - // width - // - attr_.setWidth(new Float(widthTextField.getText()).floatValue()); - // - // dash array - // - attr_.setDashArray(dashArray()); - // - // dash phase - // - attr_.setDashPhase(new Float(dashPhaseTextField.getText()).floatValue()); - // - // cap style - // - attr_.setCapStyle(capStyleComboBox.getSelectedIndex()); - // - // miter style - // - attr_.setMiterStyle(miterStyleComboBox.getSelectedIndex()); - // - // miter limit - // - attr_.setMiterLimit(new Float(miterLimitTextField.getText()).floatValue()); - - attr_.setBatch(false); - // - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(false, "LineAttributeDialog"); - } - } - } - /** - * Dialog test entry. - */ - public static void main(String[] args) { - LineAttribute attr = new LineAttribute(); - LineAttributeDialog la = new LineAttributeDialog(); - la.setLineAttribute(attr); - la.setTitle("Test LineAttribute Dialog"); - la.setVisible(true); - } - - void markEditor_actionPerformed(java.awt.event.ActionEvent event) { - PlotMarkDialog pmd = new PlotMarkDialog(); - Point loc = markEditor.getLocationOnScreen(); - pmd.setLocation(loc.x, loc.y); - int result = pmd.showDialog(mark_); - if(result == PlotMarkDialog.OK_RESPONSE) { - changeMark(pmd.getMark()); - } - } - private void changeMark(int mark) { - mark_ = mark; - pmIcon_.setMark(mark); - plotMarkIconLabel.repaint(); - } - - void arrayEditor_actionPerformed(java.awt.event.ActionEvent event) { - ArrayEditDialog aed = new ArrayEditDialog(); - Point loc = arrayEditor.getLocationOnScreen(); - aed.setLocation(loc.x, loc.y); - aed.setArray(dashArray()); - int result = aed.showDialog(); - if(result == ArrayEditDialog.OK_RESPONSE) { - dashArrayTextField.setText(dashArrayString(aed.getFloatArray())); - } - } - - void lineStyleComboBox_actionPerformed(ActionEvent e) { - strokePanelEnabled(lineStyleComboBox.getSelectedIndex() == LineAttribute.STROKE); - } - - void strokePanelEnabled(boolean enabled) { - widthTextField.setEnabled(enabled); - dashArrayTextField.setEnabled(enabled); - arrayEditor.setEnabled(enabled); - dashPhaseTextField.setEnabled(enabled); - capStyleComboBox.setEnabled(enabled); - miterStyleComboBox.setEnabled(enabled); - miterLimitTextField.setEnabled(enabled); - } - /** - * Set the parent JPane. This reference to - * JPane is used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. - */ - public void setJPane(JPane pane) { - paneList_ = new JPane[1]; - paneList_[0] = pane; - } - /** Get the first parent pane. */ - public JPane getJPane() { - if(paneList_ != null) { - return paneList_[0]; - } else { - return null; - } - } - /** - * Set the parent JPanes. These references to - * JPane are used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. A second - * JPane is often used for a LineKey. - */ - public void setJPaneList(JPane[] list) { - paneList_ = list; - } - /** Get an array of parent panes. */ - public JPane[] getJPaneList() { - return paneList_; - } -} - -class LineAttributeDialog_lineStyleComboBox_actionAdapter implements java.awt.event.ActionListener { - LineAttributeDialog adaptee; - - LineAttributeDialog_lineStyleComboBox_actionAdapter(LineAttributeDialog adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.lineStyleComboBox_actionPerformed(e); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/LogoDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/LogoDialog.java deleted file mode 100755 index fbba5583..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/LogoDialog.java +++ /dev/null @@ -1,374 +0,0 @@ -/* - * $Id: LogoDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - - -import gov.noaa.pmel.sgt.Logo; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; - -import javax.swing.*; -import java.awt.*; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -/** - * Edits a Logo object. This dialog does not make a copy - * of the object so changes "Applied" will cause sgt to - * redraw the plot using the new Logo properties. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class LogoDialog extends JDialog implements PropertyChangeListener { - private Logo logo_; - private JPane pane_ = null; - private boolean ignoreEvent_ = false; - /** - * Constructor. - */ - public LogoDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(457,294); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,324); - mainPanel.setLayout(new GridBagLayout()); - getContentPane().add(mainPanel, "Center"); - positionPanel.setBorder(positionBorder); - positionPanel.setLayout(new GridBagLayout()); - mainPanel.add(positionPanel, new GridBagConstraints(0,0,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel1.setText("X Position:"); - positionPanel.add(JLabel1, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - xPosTextField.setColumns(20); - positionPanel.add(xPosTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel2.setText("Y Position:"); - positionPanel.add(JLabel2, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - yPosTextField.setColumns(20); - positionPanel.add(yPosTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - alignPanel.setBorder(alignBorder); - alignPanel.setLayout(new GridBagLayout()); - mainPanel.add(alignPanel, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.VERTICAL,new Insets(5,0,5,0),20,15)); - JLabel3.setText("Horizontal:"); - alignPanel.add(JLabel3, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - horizComboBox.setModel(horizCBModel); - alignPanel.add(horizComboBox, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - JLabel4.setText("Vertical:"); - alignPanel.add(JLabel4, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - vertComboBox.setModel(vertCBModel); - alignPanel.add(vertComboBox, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - optionPanel.setBorder(optionBorder); - optionPanel.setLayout(new GridBagLayout()); - mainPanel.add(optionPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(5,10,5,0),20,15)); - JLabel7.setText("Visible:"); - optionPanel.add(JLabel7, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelVisibleCheckBox.setSelected(true); - optionPanel.add(labelVisibleCheckBox, new GridBagConstraints(1,4,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - JLabel6.setText("Selectable:"); - optionPanel.add(JLabel6, new GridBagConstraints(0,5,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelSelectableCheckBox.setSelected(true); - optionPanel.add(labelSelectableCheckBox, new GridBagConstraints(1,5,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - { - String[] tempString = new String[3]; - tempString[0] = "LEFT"; - tempString[1] = "CENTER"; - tempString[2] = "RIGHT"; - for(int i=0; i < tempString.length; i++) { - horizCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "TOP"; - tempString[1] = "MIDDLE"; - tempString[2] = "BOTTOM"; - for(int i=0; i < tempString.length; i++) { - vertCBModel.addElement(tempString[i]); - } - } - vertComboBox.setSelectedIndex(2); - horizComboBox.setSelectedIndex(0); - setTitle("SGLabel"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - - public LogoDialog(String title) { - this(); - setTitle(title); - } - - public LogoDialog() { - this((Frame)null); - } - /** - * Make the dialog visible. - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == LogoDialog.this) - FontDialog_WindowClosing(event); - } - } - - void FontDialog_WindowClosing(java.awt.event.WindowEvent event) { - finish(); - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JPanel mainPanel = new javax.swing.JPanel(); - javax.swing.JPanel positionPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - javax.swing.JTextField xPosTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); - javax.swing.JTextField yPosTextField = new javax.swing.JTextField(); - javax.swing.JPanel alignPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); - javax.swing.JComboBox horizComboBox = new javax.swing.JComboBox(); - javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); - javax.swing.JComboBox vertComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel optionPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelVisibleCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelSelectableCheckBox = new javax.swing.JCheckBox(); - javax.swing.border.TitledBorder alignBorder = new javax.swing.border.TitledBorder("Alignment"); - javax.swing.border.TitledBorder positionBorder = new javax.swing.border.TitledBorder("Position"); - DefaultComboBoxModel horizCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel vertCBModel = new DefaultComboBoxModel(); - javax.swing.border.TitledBorder optionBorder = new javax.swing.border.TitledBorder("Options"); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - if (object == applyButton) - applyButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - finish(); - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - finish(); - updateLogo(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateLogo(); - } - /** - * Test entry point. - */ - public static void main(String[] args) { - LogoDialog la = new LogoDialog(); - la.setTitle("Test Logo Dialog"); - la.setVisible(true); - } - /** - * Set the Logo to be edited and JPane. With - * JPane set the dialog will use - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} when - * updating the Logo properties. - */ - public void setLogo(Logo logo, JPane pane) { - setJPane(pane); - setLogo(logo); - } - /** - * Set the Logo to be edited. - */ - public void setLogo(Logo logo) { - logo_ = logo; - logo_.addPropertyChangeListener(this); - ignoreEvent_ = false; - setLogo(); - } - /** - * Get the edited Logo - */ - public Logo getLogo() { - return logo_; - } - /** - * Set the parent JPane. With - * JPane set the dialog will use - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} when - * updating the Logo properties. - */ - public void setJPane(JPane pane) { - pane_ = pane; - } - /** - * Get the parent JPane. - */ - public JPane getJPane() { - return pane_; - } - - private void setLogo() { - // - // label Id - // - setTitle("Logo - " + logo_.getId()); - // - // options - // - labelVisibleCheckBox.setSelected(logo_.isVisible()); - labelSelectableCheckBox.setSelected(logo_.isSelectable()); - // - // location - // - Point2D.Double locp = logo_.getLocationP(); - xPosTextField.setText(String.valueOf(locp.x)); - yPosTextField.setText(String.valueOf(locp.y)); - // - // alignment - // - horizComboBox.setSelectedIndex(logo_.getHAlign()); - vertComboBox.setSelectedIndex(logo_.getVAlign()); - } - - private void updateLogo() { - ignoreEvent_ = true; - if(pane_ != null) pane_.setBatch(true, "LogoDialog"); - // - // options - // - logo_.setVisible(labelVisibleCheckBox.isSelected()); - logo_.setSelectable(labelSelectableCheckBox.isSelected()); - // - // Location - // - double x = Double.valueOf(xPosTextField.getText()).doubleValue(); - double y = Double.valueOf(yPosTextField.getText()).doubleValue(); - Point2D.Double locp = new Point2D.Double(x, y); - logo_.setLocationP(locp); - // - // alignment - // - logo_.setHAlign(horizComboBox.getSelectedIndex()); - logo_.setVAlign(vertComboBox.getSelectedIndex()); - - if(pane_ != null) pane_.setBatch(false, "LogoDialog"); - ignoreEvent_ = false; - } - private void finish() { - logo_.removePropertyChangeListener(this); - } - /** Used internally for property changes */ - public void propertyChange(PropertyChangeEvent event) { - if(ignoreEvent_) { - if(Debug.EVENT) System.out.println("Logo: ignore event"); - return; - } - if(Debug.EVENT) { - System.out.println("LogoDialog: " + event); - System.out.println(" " + event.getPropertyName()); - } - if(event.getPropertyName().equals("location")) { - Point2D.Double locp = logo_.getLocationP(); - xPosTextField.setText(String.valueOf(locp.x)); - yPosTextField.setText(String.valueOf(locp.y)); - } - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/NewLevelsDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/NewLevelsDialog.java deleted file mode 100755 index c6b99cf3..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/NewLevelsDialog.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * $Id: NewLevelsDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.sgt.Graph; - -import javax.swing.*; -import java.awt.*; - -import gov.noaa.pmel.swing.JSlider2Double; - -/** - * Computes the range for creating a ContourLevels - * object. If a SGTGrid object is provided - * NewLevelsDialog can use the actual data range to help - * in creating the contour levels. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class NewLevelsDialog extends JDialog { - private int result_; - private SGTGrid grid_ = null; - private boolean useSpacing_ = false; - private boolean rangeComputed_ = false; - /** OK button selected */ - public static int OK_RESPONSE = 1; - /** Cancel button selected */ - public static int CANCEL_RESPONSE = 2; - /** - * Constructor. - */ - public NewLevelsDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(282,366); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,444); - mainPanel.setLayout(new GridBagLayout()); - getContentPane().add(mainPanel, "Center"); - mainPanel.setBackground(new java.awt.Color(204,204,204)); - JPanel1.setBorder(titledBorder1); - JPanel1.setLayout(new GridBagLayout()); - mainPanel.add(JPanel1, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(5,5,5,5),0,0)); - JLabel1.setText("Minimum:"); - JPanel1.add(JLabel1,new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,10,5,2),0,0)); - minTextField.setColumns(15); - JPanel1.add(minTextField,new GridBagConstraints(1,0,1,1,1.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,10),0,0)); - JLabel2.setText("Maximum:"); - JPanel1.add(JLabel2,new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,5,5,2),0,0)); - maxTextField.setColumns(15); - JPanel1.add(maxTextField,new GridBagConstraints(1,1,1,1,1.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,10),0,0)); - JPanel3.setBorder(titledBorder3); - JPanel3.setLayout(new GridBagLayout()); - mainPanel.add(JPanel3, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,5,0,5),0,0)); - JLabel3.setText("Number:"); - JPanel3.add(JLabel3,new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,10,0,2),0,0)); - nlevelsTextField.setColumns(5); - JPanel3.add(nlevelsTextField,new GridBagConstraints(1,0,1,1,0.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,0,10),0,0)); - JLabel5.setText("or"); - JPanel3.add(JLabel5,new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0)); - JLabel5.setBackground(new java.awt.Color(204,204,204)); - JLabel5.setForeground(new java.awt.Color(102,102,153)); - JLabel4.setText("Spacing:"); - JPanel3.add(JLabel4,new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,10,5,2),0,0)); - spacingTextField.setColumns(15); - JPanel3.add(spacingTextField,new GridBagConstraints(1,2,1,1,0.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,0,5,10),0,0)); - JPanel4.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - mainPanel.add(JPanel4, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); - computeButton.setText("Compute \"nice\" Range"); - JPanel4.add(computeButton); - JPanel2.setBorder(titledBorder2); - JPanel2.setLayout(new GridBagLayout()); - mainPanel.add(JPanel2, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); - JLabel6.setText("Minimum:"); - JPanel2.add(JLabel6,new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,10,5,2),0,0)); - minCompTextField.setEditable(false); - minCompTextField.setColumns(15); - minCompTextField.setEnabled(false); - JPanel2.add(minCompTextField,new GridBagConstraints(1,0,1,1,1.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,10),0,0)); - JLabel7.setText("Minimum:"); - JPanel2.add(JLabel7,new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(5,5,5,2),0,0)); - maxCompTextField.setEditable(false); - maxCompTextField.setColumns(15); - maxCompTextField.setEnabled(false); - JPanel2.add(maxCompTextField,new GridBagConstraints(1,1,1,1,0.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,10),0,0)); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - minTextField.addActionListener(lSymAction); - maxTextField.addActionListener(lSymAction); - nlevelsTextField.addActionListener(lSymAction); - spacingTextField.addActionListener(lSymAction); - SymPropertyChange lSymPropertyChange = new SymPropertyChange(); - computeButton.addActionListener(lSymAction); - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public NewLevelsDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public NewLevelsDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == NewLevelsDialog.this) - NewLevelsDialog_WindowClosing(event); - } - } - - void NewLevelsDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JPanel mainPanel = new javax.swing.JPanel(); - javax.swing.JPanel JPanel1 = new javax.swing.JPanel(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - javax.swing.JTextField minTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); - javax.swing.JTextField maxTextField = new javax.swing.JTextField(); - javax.swing.JPanel JPanel3 = new javax.swing.JPanel(); - javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); - javax.swing.JTextField nlevelsTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); - javax.swing.JTextField spacingTextField = new javax.swing.JTextField(); - javax.swing.JPanel JPanel4 = new javax.swing.JPanel(); - javax.swing.JButton computeButton = new javax.swing.JButton(); - javax.swing.JPanel JPanel2 = new javax.swing.JPanel(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JTextField minCompTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JTextField maxCompTextField = new javax.swing.JTextField(); - javax.swing.border.TitledBorder titledBorder1 = new javax.swing.border.TitledBorder("Data Range"); - javax.swing.border.TitledBorder titledBorder3 = new javax.swing.border.TitledBorder("Select"); - javax.swing.border.TitledBorder titledBorder2 = new javax.swing.border.TitledBorder("Computed Range"); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == minTextField) - minTextField_actionPerformed(event); - else if (object == maxTextField) - maxTextField_actionPerformed(event); - else if (object == nlevelsTextField) - nlevelsTextField_actionPerformed(event); - else if (object == spacingTextField) - spacingTextField_actionPerformed(event); - else if (object == computeButton) - computeButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - result_ = CANCEL_RESPONSE; - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - this.setVisible(false); - } - /** - * Test entry point - */ - public static void main(String[] args) { - NewLevelsDialog la = new NewLevelsDialog(); - la.setTitle("Test New Levels Dialog"); - la.setVisible(true); - } - /** - * Show the dialog and wait for a response. - * - * @param grid the data grid - * @return result, either CANCEL_RESPONSE or OK_RESPONSE - */ - public int showDialog(SGTGrid grid) { - setGrid(grid); - result_ = CANCEL_RESPONSE; - setModal(true); - super.setVisible(true); - return result_; - } - /** - * Return the computed or entered range. - */ - public Range2D getRange() { - double min; - double max; - if(rangeComputed_) { - min = (new Double(minCompTextField.getText())).doubleValue(); - max = (new Double(maxCompTextField.getText())).doubleValue(); - } else { - min = (new Double(minTextField.getText())).doubleValue(); - max = (new Double(maxTextField.getText())).doubleValue(); - } - double delta = (new Double(spacingTextField.getText())).doubleValue(); - Range2D range = new Range2D(min, max, delta); - return range; - } - /** - * Set the data grid for the computed range. - */ - public void setGrid(SGTGrid grid) { - double zmin, zmax; - grid_ = grid; - if(grid_ == null) { - titledBorder1.setTitle("Enter Range"); - zmin = 0.0; - zmax = 10.0; - } else { - zmin = Double.MAX_VALUE; - zmax = -Double.MAX_VALUE; - double[] z = grid_.getZArray(); - for(int i=0; i < z.length; i++) { - if(Double.isNaN(z[i])) continue; - zmin = Math.min(zmin, z[i]); - zmax = Math.max(zmax, z[i]); - } - } - minTextField.setText(Double.toString(zmin)); - maxTextField.setText(Double.toString(zmax)); - useSpacing_ = false; - nlevelsTextField.setText("10"); - updateLevSpac(); - } - - private void updateLevSpac() { - int levels; - double delta = (new Double(maxTextField.getText())).doubleValue() - - (new Double(minTextField.getText())).doubleValue(); - double spacing; - if(useSpacing_) { - levels = (int)(delta/(new Double(spacingTextField.getText())).doubleValue()); - nlevelsTextField.setText(Integer.toString(levels)); - } else { - spacing = delta/(new Integer(nlevelsTextField.getText())).intValue(); - spacingTextField.setText(Double.toString(spacing)); - } - } - - void minTextField_actionPerformed(java.awt.event.ActionEvent event) { - updateLevSpac(); - } - - void maxTextField_actionPerformed(java.awt.event.ActionEvent event) { - updateLevSpac(); - } - - void nlevelsTextField_actionPerformed(java.awt.event.ActionEvent event) { - useSpacing_ = false; - updateLevSpac(); - } - - void spacingTextField_actionPerformed(java.awt.event.ActionEvent event) { - useSpacing_ = true; - updateLevSpac(); - } - - class SymPropertyChange implements java.beans.PropertyChangeListener { - public void propertyChange(java.beans.PropertyChangeEvent event) { - } - } - - void computeButton_actionPerformed(java.awt.event.ActionEvent event) { - rangeComputed_ = true; - minCompTextField.setEnabled(true); - maxCompTextField.setEnabled(true); - double min = (new Double(minTextField.getText())).doubleValue(); - double max = (new Double(maxTextField.getText())).doubleValue(); - Range2D range = new Range2D(min,max); - int levels = Integer.parseInt(nlevelsTextField.getText()); - Range2D newRange = Graph.computeRange(range, levels); - spacingTextField.setText(Double.toString(newRange.delta)); - minCompTextField.setText(Double.toString(newRange.start)); - maxCompTextField.setText(Double.toString(newRange.end)); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/PlotMarkDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/PlotMarkDialog.java deleted file mode 100755 index 9511b3ea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/PlotMarkDialog.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * $Id: PlotMarkDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import java.awt.*; - -import gov.noaa.pmel.sgt.swing.PlotMarkIcon; - -/** - * Provides a dialog to graphically select a PlotMark - * code. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class PlotMarkDialog extends JDialog { - private static final int numMarks = 51; - private int result_; - private int mark_; - private JToggleButton[] buttons_ = new JToggleButton[numMarks]; - /** OK button selected */ - public static int OK_RESPONSE = 1; - /** Cancel button selected */ - public static int CANCEL_RESPONSE = 2; - /** - * Constructor - */ - public PlotMarkDialog(Frame parent) { - super(parent); - try { - jbInit(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(288,201); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - buttonPanel.setBounds(0,162,288,39); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - okButton.setBounds(79,7,51,25); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - cancelButton.setBounds(135,7,73,25); - //$$ etchedBorder1.move(0,300); - mainPanel.setLayout(new GridLayout(4,11,0,0)); - getContentPane().add(mainPanel, "Center"); - mainPanel.setBounds(0,0,288,162); - setTitle("Select a Mark"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor - */ - public PlotMarkDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor - */ - public PlotMarkDialog() { - this((Frame)null); - } - /** - * Make the dialog visible. - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == PlotMarkDialog.this) - PlotMarkDialog_WindowClosing(event); - } - } - - void PlotMarkDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JPanel mainPanel = new javax.swing.JPanel(); - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - - - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - result_ = CANCEL_RESPONSE; - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - result_ = OK_RESPONSE; - for(int i=0; i < numMarks; i++) { - if(buttons_[i].isSelected()) { - mark_ = i+1; - } - } - this.setVisible(false); - } - /** - * Test entry point - */ - public static void main(String[] args) { - PlotMarkDialog la = new PlotMarkDialog(); - la.setTitle("Test PlotMark Dialog"); - la.setVisible(true); - } - /** - * Show the dialog and wait for a response - * - * @param mark initial PlotMark code - * @return result, either CANCEL_RESPONSE or OK_RESPONSE - */ - public int showDialog(int mark) { - mark_ = mark; - createButtons(); - result_ = CANCEL_RESPONSE; - setModal(true); - super.setVisible(true); - return result_; - } - /** - * Set initial mark. - */ - public void setMark(int mark) { - mark_ = mark; - } - /** - * Get the selected PlotMark code. - */ - public int getMark() { - return mark_; - } - - private void createButtons() { - PlotMarkIcon pmi; - ButtonGroup group = new ButtonGroup(); - for(int i=0; i < numMarks; i++) { - pmi = new PlotMarkIcon(i+1); - buttons_[i] = new JToggleButton(pmi); - buttons_[i].setName(Integer.toString(i+1)); - group.add(buttons_[i]); - mainPanel.add(buttons_[i]); - } - buttons_[mark_-1].setSelected(true); - } - - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/PointAttributeDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/PointAttributeDialog.java deleted file mode 100755 index eb724610..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/PointAttributeDialog.java +++ /dev/null @@ -1,475 +0,0 @@ -/* - * $Id: PointAttributeDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import javax.swing.*; -import java.awt.*; -import java.util.StringTokenizer; - - -import gov.noaa.pmel.sgt.PointAttribute; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.swing.PlotMarkIcon; -import gov.noaa.pmel.swing.ThreeDotsButton; - -/** - * Edits a PointAttribute. This dialog does not - * make a copy of the attribute so changes "Applied" will cause - * sgt to redraw the plot using the new properties unless - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} - * has been turned on. - * - *

Example of PointAttributeDialog use: - *

- * public void editPointAttribute(PointAttribute attr, JPane pane) {
- *   PointAttributeDialog pad = new PointAttributeDialog();
- *   pad.setPointAttribute(attr, pane);
- *   pad.setVisible(true);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class PointAttributeDialog extends JDialog { - private JPane pane_ = null; - private JPane[] paneList_ = null; - private PointAttribute attr_; - private PlotMarkIcon pmIcon_; - private int mark_; - private Font labelFont_; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - /** - * Constructor. - */ - public PointAttributeDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(new Dimension(504, 320)); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,372); - getContentPane().add(JTabbedPane1, "Center"); - markAttrPanel.setLayout(new GridBagLayout()); - JTabbedPane1.add(markAttrPanel, "markAttrPanel"); - JLabel1.setText("Color:"); - markAttrPanel.add(JLabel1, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - colorPanel.setBorder(etchedBorder1); - markAttrPanel.add(colorPanel, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,5,10,5),0,0)); - JLabel6.setText("Mark:"); - markAttrPanel.add(JLabel6, new GridBagConstraints(0,1,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - markPanel.setLayout(new GridBagLayout()); - markAttrPanel.add(markPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,10,5),0,0)); - markPanel.add(plotMarkIconLabel, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0)); - plotMarkIconLabel.setForeground(java.awt.Color.black); - markEditor.setActionCommand("..."); - markPanel.add(markEditor, new GridBagConstraints(2,0,1,1,0.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(0,0,0,0),0,0)); - JLabel7.setText("Height:"); - markAttrPanel.add(JLabel7, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - markHeightTextField.setColumns(10); - markAttrPanel.add(markHeightTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - labelPanel.setLayout(new GridBagLayout()); - JTabbedPane1.add(labelPanel, "labelPanel"); - JLabel5.setText("Position:"); - labelPanel.add(JLabel5, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - positionComboBox.setModel(positionCBModel); - labelPanel.add(positionComboBox, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel8.setText("Font:"); - labelPanel.add(JLabel8, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(fontPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - fontLabel.setText("Dialog, 12, Bold"); - fontPanel.add(fontLabel); - fontLabel.setForeground(java.awt.Color.black); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.add(fontEditor); - JLabel9.setText("Color:"); - labelPanel.add(JLabel9, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelColorPanel.setBorder(etchedBorder1); - labelColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(labelColorPanel, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,5,5,5),0,0)); - JLabel10.setText("Height:"); - labelPanel.add(JLabel10, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelHeightTextField.setColumns(10); - labelPanel.add(labelHeightTextField, new GridBagConstraints(1,3,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel14.setText("Draw Label?"); - labelPanel.add(JLabel14, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelPanel.add(drawLabelCheckBox, new GridBagConstraints(1,4,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JTabbedPane1.setSelectedIndex(0); - JTabbedPane1.setTitleAt(0,"Mark"); - JTabbedPane1.setTitleAt(1,"Label"); - { - String[] tempString = new String[9]; - tempString[0] = "Centered"; - tempString[1] = "North"; - tempString[2] = "NorthEast"; - tempString[3] = "East"; - tempString[4] = "SouthEast"; - tempString[5] = "South"; - tempString[6] = "SouthWest"; - tempString[7] = "West"; - tempString[8] = "NorthWest"; - for(int i=0; i < tempString.length; i++) { - positionCBModel.addElement(tempString[i]); - } - } - markAttrPanel.setBounds(2,27,425,203); - labelPanel.setBounds(2,27,425,203); - positionComboBox.setSelectedIndex(2); - setTitle("PointAttribute Properties"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - markEditor.addActionListener(lSymAction); - fontEditor.addActionListener(lSymAction); - // - pmIcon_ = new PlotMarkIcon(1); - plotMarkIconLabel.setIcon(pmIcon_); - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor - */ - public PointAttributeDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor - */ - public PointAttributeDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == PointAttributeDialog.this) - PointAttributeDialog_WindowClosing(event); - } - } - - void PointAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JTabbedPane JTabbedPane1 = new javax.swing.JTabbedPane(); - javax.swing.JPanel markAttrPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - ColorEntryPanel colorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JPanel markPanel = new javax.swing.JPanel(); - javax.swing.JLabel plotMarkIconLabel = new javax.swing.JLabel(); - ThreeDotsButton markEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JTextField markHeightTextField = new javax.swing.JTextField(); - javax.swing.JPanel labelPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JComboBox positionComboBox = new javax.swing.JComboBox(); - javax.swing.JLabel JLabel8 = new javax.swing.JLabel(); - javax.swing.JPanel fontPanel = new javax.swing.JPanel(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - ThreeDotsButton fontEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); - ColorEntryPanel labelColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel10 = new javax.swing.JLabel(); - javax.swing.JTextField labelHeightTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel14 = new javax.swing.JLabel(); - javax.swing.JCheckBox drawLabelCheckBox = new javax.swing.JCheckBox(); - DefaultComboBoxModel positionCBModel = new DefaultComboBoxModel(); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == markEditor) - markEditor_actionPerformed(event); - else if (object == fontEditor) - fontEditor_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - updatePointAttribute(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updatePointAttribute(); - } - /** - * Set the PointAttribute to be edited and the - * JPane. - */ - public void setPointAttribute(PointAttribute attr, JPane pane) { - pane_ = pane; - attr_ = attr; - // - // Mark attributes - // - // Color - // - colorPanel.setColor(attr_.getColor()); - // - // mark - // - int mark = attr_.getMark(); - changeMark(mark); - // - // mark height - // - markHeightTextField.setText(Double.toString(attr_.getMarkHeightP())); - // - // Label attributes - // - // position - // - positionComboBox.setSelectedIndex(attr_.getLabelPosition()); - // - // font - // - labelFont_ = attr_.getLabelFont(); - if(pane_ != null && labelFont_ == null) labelFont_ = pane_.getComponent().getFont(); - fontLabel.setText(fontString(labelFont_)); - // - // color - // - labelColorPanel.setColor(attr_.getLabelColor()); - // - // width - // - labelHeightTextField.setText(Double.toString(attr_.getLabelHeightP())); - // - // draw label? - // - drawLabelCheckBox.setSelected(attr_.isDrawLabel()); - } - /** - * Set the parent JPane. This reference to - * JPane is used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. - */ - public void setJPane(JPane pane) { - paneList_ = new JPane[1]; - paneList_[0] = pane; - } - /** - * Get the first parent. - */ - public JPane getJPane() { - if(paneList_ != null) { - return paneList_[0]; - } else { - return null; - } - } - /** - * Set the parent JPanes. These references to - * JPane are used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. A second - * JPane is often used for a PointCollectionKey. - */ - public void setJPaneList(JPane[] list) { - paneList_ = list; - } - /** Get an array of parent panes. */ - public JPane[] getJPaneList() { - return paneList_; - } - - void updatePointAttribute() { - if(pane_ != null) pane_.setBatch(true, "PointAttributeDialog"); - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(true, "PointAttributeDialog"); - } - } - attr_.setBatch(true); - // - // mark attributes - // - // Color - // - attr_.setColor(colorPanel.getColor()); - // - // mark - // - attr_.setMark(mark_); - // - // mark height - // - attr_.setMarkHeightP(new Double(markHeightTextField.getText()).doubleValue()); - // - // label attributes - // - // position - // - attr_.setLabelPosition(positionComboBox.getSelectedIndex()); - // - // font - // - attr_.setLabelFont(labelFont_); - // - // color - // - attr_.setLabelColor(labelColorPanel.getColor()); - // - // height - // - attr_.setLabelHeightP(new Double(labelHeightTextField.getText()).doubleValue()); - // - // draw label? - // - attr_.setDrawLabel(drawLabelCheckBox.isSelected()); - - attr_.setBatch(false); - // - if(pane_ != null) pane_.setBatch(false, "PointAttributeDialog"); - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(false, "PointAttributeDialog"); - } - } - } - /** - * Test entry point - */ - public static void main(String[] args) { - PointAttribute attr = new PointAttribute(); - PointAttributeDialog la = new PointAttributeDialog(); - la.setPointAttribute(attr, null); - la.setTitle("Test PointAttribute Dialog"); - la.setVisible(true); - } - - void markEditor_actionPerformed(java.awt.event.ActionEvent event) { - PlotMarkDialog pmd = new PlotMarkDialog(); - Point loc = markEditor.getLocationOnScreen(); - pmd.setLocation(loc.x, loc.y); - int result = pmd.showDialog(mark_); - if(result == PlotMarkDialog.OK_RESPONSE) { - changeMark(pmd.getMark()); - } - } - - private void changeMark(int mark) { - mark_ = mark; - pmIcon_.setMark(mark); - plotMarkIconLabel.repaint(); - } - - void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/RulerDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/RulerDialog.java deleted file mode 100755 index 228929f1..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/RulerDialog.java +++ /dev/null @@ -1,726 +0,0 @@ -/* - * $Id: RulerDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import gov.noaa.pmel.sgt.*; -import gov.noaa.pmel.util.*; -import gov.noaa.pmel.swing.ThreeDotsButton; -import java.awt.*; -import javax.swing.*; - -/** - * Edits a Ruler. This dialog does not - * make a copy of the object so changes "Applied" will cause - * sgt to redraw the plot using the new properties. - * - *

Example of RulerDialog use: - *

- * public void editRuler(Ruler axis, JPane pane) {
- *   RulerDialog sad = new RulerDialog();
- *   sad.setRuler(axis, pane);
- *   sad.setVisible(true);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 3.0 - */ -public class RulerDialog extends JDialog { - private JPane pane_; - private Ruler scale_; - private Font labelFont_; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - /** - * Constructor. - */ - public RulerDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(new Dimension(531, 358)); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - jLabel1.setText("Line Color:"); - physicalBorder.setTitle("Physical Bounds"); - jLabel5.setText("Height:"); - heightPhysicalTextField.setColumns(10); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,348); - getContentPane().add(TabbedPane, "Center"); - labelPanel.setLayout(new GridBagLayout()); - TabbedPane.add(labelPanel, "labelPanel"); - labelPanel.setBounds(2,27,452,275); - labelPanel.setVisible(false); - JLabel3.setText("Interval:"); - labelPanel.add(JLabel3, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - intervalTextField.setColumns(5); - labelPanel.add(intervalTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel4.setText("Sig Digits:"); - labelPanel.add(JLabel4, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - sigDigitsTextField.setColumns(5); - labelPanel.add(sigDigitsTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel5.setText("Format:"); - labelPanel.add(JLabel5, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - formatTextField.setColumns(10); - labelPanel.add(formatTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel11.setText("Color:"); - labelPanel.add(JLabel11, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(textColorPanel, new GridBagConstraints(1,3,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - JLabel15.setText("Font:"); - labelPanel.add(JLabel15, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(fontPanel, new GridBagConstraints(1,4,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontLabel.setText("Dialog, 12, Bold"); - fontPanel.add(fontLabel); - fontLabel.setForeground(java.awt.Color.black); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.add(fontEditor); - JLabel16.setText("Height:"); - labelPanel.add(JLabel16, new GridBagConstraints(0,5,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - heightTextField.setColumns(10); - labelPanel.add(heightTextField, new GridBagConstraints(1,5,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,5,5),0,0)); - JLabel1.setText("Position:"); - labelPanel.add(JLabel1, new GridBagConstraints(0,6,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - positionComboBox.setModel(positionCBModel); - labelPanel.add(positionComboBox, new GridBagConstraints(1,6,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - rangePanel.setLayout(new GridBagLayout()); - TabbedPane.add(rangePanel, "rangePanel"); - rangePanel.setBounds(2,27,452,275); - rangePanel.setVisible(false); - userPanel.setBorder(userBorder); - userPanel.setLayout(new GridBagLayout()); - rangePanel.add(userPanel, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel8.setText("Minimum:"); - userPanel.add(JLabel8, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - minUserTextField.setColumns(25); - userPanel.add(minUserTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel9.setText("Maximum:"); - userPanel.add(JLabel9, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - maxUserTextField.setColumns(25); - userPanel.add(maxUserTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel2.setText("Delta:"); - userPanel.add(JLabel2, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - incUserTextField.setColumns(25); - userPanel.add(incUserTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - physicalPanel.setBorder(physicalBorder); - physicalPanel.setLayout(new GridBagLayout()); - rangePanel.add(physicalPanel, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel10.setText("X:"); - physicalPanel.add(JLabel10, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - xPhysicalTextField.setColumns(10); - physicalPanel.add(xPhysicalTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel17.setText("Y:"); - physicalPanel.add(JLabel17, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - yPhysicalTextField.setColumns(10); - physicalPanel.add(yPhysicalTextField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - originLabel.setText("Width:"); - physicalPanel.add(originLabel, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - widthPhysicalTextField.setColumns(10); - physicalPanel.add(widthPhysicalTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - physicalPanel.add(jLabel5, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - physicalPanel.add(heightPhysicalTextField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - ticsStylePanel.setLayout(new GridBagLayout()); - TabbedPane.add(ticsStylePanel, "ticsStylePanel"); - ticsStylePanel.setBounds(2,27,452,275); - ticsStylePanel.setVisible(false); - ticsPanel.setBorder(ticsBorder); - ticsPanel.setLayout(new GridBagLayout()); - ticsStylePanel.add(ticsPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 10, 10)); - JLabel18.setText("Large Tic Height:"); - ticsPanel.add(JLabel18, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - largeTicTextField.setColumns(15); - ticsPanel.add(largeTicTextField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel19.setText("Small Tic Height:"); - ticsPanel.add(JLabel19, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - smallTicTextField.setColumns(15); - ticsPanel.add(smallTicTextField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel20.setText("Number of Small Tics:"); - ticsPanel.add(JLabel20, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - numSmallTicsTextField.setColumns(5); - ticsPanel.add(numSmallTicsTextField, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel21.setText("Tic Position:"); - ticsPanel.add(JLabel21, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - ticPositionComboBox.setModel(ticPositionCBModel); - ticsPanel.add(ticPositionComboBox, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - ticsPanel.add(lineColorPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - stylePanel.setBorder(styleBorder); - stylePanel.setLayout(new GridBagLayout()); - ticsStylePanel.add(stylePanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 20, 10)); - JLabel7.setText("Visible:"); - stylePanel.add(JLabel7, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - axislVisibleCheckBox.setSelected(true); - stylePanel.add(axislVisibleCheckBox, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - JLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - JLabel6.setText("Selectable:"); - stylePanel.add(JLabel6, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 61, 0)); - axisSelectableCheckBox.setSelected(true); - stylePanel.add(axisSelectableCheckBox, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - ticsPanel.add(jLabel1, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - TabbedPane.setSelectedComponent(labelPanel); - TabbedPane.setSelectedIndex(0); - TabbedPane.setTitleAt(0,"Label"); - TabbedPane.setTitleAt(1,"Range"); - TabbedPane.setTitleAt(2,"Tics/Style"); - TabbedPane.setTitleAt(3,"Attach"); - { - String[] tempString = new String[3]; - tempString[0] = "LEFT"; - tempString[1] = "CENTER"; - tempString[2] = "RIGHT"; - for(int i=0; i < tempString.length; i++) { - horizCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "TOP"; - tempString[1] = "MIDDLE"; - tempString[2] = "BOTTOM"; - for(int i=0; i < tempString.length; i++) { - vertCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "POSITIVE_SIDE"; - tempString[1] = "NEGATIVE_SIDE"; - tempString[2] = "NO_LABEL"; - for(int i=0; i < tempString.length; i++) { - positionCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "POSITIVE_SIDE"; - tempString[1] = "NEGATIVE_SIDE"; - tempString[2] = "BOTH_SIDES"; - for(int i=0; i < tempString.length; i++) { - ticPositionCBModel.addElement(tempString[i]); - } - } - positionComboBox.setSelectedIndex(1); - ticPositionComboBox.setSelectedIndex(1); - setTitle("TimeAxis"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - fontEditor.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - minUserTextField.addActionListener(lSymAction); - maxUserTextField.addActionListener(lSymAction); - widthPhysicalTextField.addActionListener(lSymAction); - -// Insets pup = new Insets(0, 0, 0, 0); -// fontEditor.setMargin(pup); - } - /** Used internally. */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public RulerDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public RulerDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == RulerDialog.this) - FontDialog_WindowClosing(event); - } - } - - void FontDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - //{{DECLARE_CONTROLS - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); - javax.swing.JPanel labelPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); - javax.swing.JTextField intervalTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); - javax.swing.JTextField sigDigitsTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JTextField formatTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); - ColorEntryPanel textColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); - javax.swing.JPanel fontPanel = new javax.swing.JPanel(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - ThreeDotsButton fontEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); - javax.swing.JTextField heightTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - javax.swing.JComboBox positionComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel rangePanel = new javax.swing.JPanel(); - javax.swing.JPanel userPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel8 = new javax.swing.JLabel(); - javax.swing.JTextField minUserTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); - javax.swing.JTextField maxUserTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); - javax.swing.JTextField incUserTextField = new javax.swing.JTextField(); - javax.swing.JPanel physicalPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel10 = new javax.swing.JLabel(); - javax.swing.JTextField xPhysicalTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); - javax.swing.JTextField yPhysicalTextField = new javax.swing.JTextField(); - javax.swing.JLabel originLabel = new javax.swing.JLabel(); - javax.swing.JTextField widthPhysicalTextField = new javax.swing.JTextField(); - javax.swing.JPanel ticsStylePanel = new javax.swing.JPanel(); - javax.swing.JPanel ticsPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel18 = new javax.swing.JLabel(); - javax.swing.JTextField largeTicTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel19 = new javax.swing.JLabel(); - javax.swing.JTextField smallTicTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel20 = new javax.swing.JLabel(); - javax.swing.JTextField numSmallTicsTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel21 = new javax.swing.JLabel(); - javax.swing.JComboBox ticPositionComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel stylePanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JCheckBox axislVisibleCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JCheckBox axisSelectableCheckBox = new javax.swing.JCheckBox(); - DefaultComboBoxModel horizCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel vertCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel positionCBModel = new DefaultComboBoxModel(); - javax.swing.border.TitledBorder userBorder = new javax.swing.border.TitledBorder("User Range"); - javax.swing.border.TitledBorder physicalBorder = new javax.swing.border.TitledBorder("Physical Range"); - javax.swing.border.TitledBorder ticsBorder = new javax.swing.border.TitledBorder("Tics"); - javax.swing.border.TitledBorder styleBorder = new javax.swing.border.TitledBorder("Axis Style"); - DefaultComboBoxModel ticPositionCBModel = new DefaultComboBoxModel(); - private ColorEntryPanel lineColorPanel = new ColorEntryPanel(); - private JLabel jLabel1 = new JLabel(); - private JLabel jLabel5 = new JLabel(); - private JTextField heightPhysicalTextField = new JTextField(); - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == fontEditor) - fontEditor_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - updateRuler(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateRuler(); - } - /** - * Test entry point - */ - public static void main(String[] args) { - RulerDialog la = new RulerDialog(); - la.setFont(null); - la.setTitle("Test Ruler Dialog"); - la.setVisible(true); - } - /** - * Set the Ruler to be edited and the - * JPane - */ - public void setRuler(Ruler scale, JPane pane) { - setJPane(pane); - setRuler(scale); - } - /** - * Set the Ruler to be edited - */ - public void setRuler(Ruler scale) { - scale_ = scale; - setRuler(); - } - /** - * Get the edited Ruler - */ - public Ruler getRuler() { - return scale_; - } - /** - * Set the parent JPane. - */ - public void setJPane(JPane pane) { - pane_ = pane; - } - /** - * Get the parent JPane. - */ - public JPane getJPane() { - return pane_; - } - - private void setRuler() { - // - // time axis ID - // - setTitle("Ruler - " + scale_.getId()); - // - // label - // - intervalTextField.setText(Integer.toString(scale_.getLabelInterval())); - sigDigitsTextField.setText(Integer.toString(scale_.getSignificantDigits())); - formatTextField.setText(scale_.getLabelFormat()); - - Color col = scale_.getLabelColor(); - if(col == null) col = pane_.getComponent().getForeground(); - textColorPanel.setColor(col); - - labelFont_ = scale_.getLabelFont(); - if(labelFont_ == null) labelFont_ = pane_.getComponent().getFont(); - fontLabel.setText(fontString(labelFont_)); - - heightTextField.setText(String.valueOf(scale_.getLabelHeightP())); - // - // range - // - Range2D urange = scale_.getRangeU(); - minUserTextField.setText(String.valueOf(urange.start)); - maxUserTextField.setText(String.valueOf(urange.end)); - incUserTextField.setText(String.valueOf(urange.delta)); - Rectangle2D.Double bounds = scale_.getBoundsP(); -// Range2D range = sa_.getRangeP(); - xPhysicalTextField.setText(String.valueOf(bounds.x)); - yPhysicalTextField.setText(String.valueOf(bounds.y)); - widthPhysicalTextField.setText(String.valueOf(bounds.width)); - heightPhysicalTextField.setText(String.valueOf(bounds.height)); -// Point2D.Double pt = sa_.getLocationU(); -// TimePoint tt = null; -// double point = 0.0; - -// if(pt == null) { -// originIsGeoDate_ = true; -// tt = sa_.getTimeLocationU(); -// tOrigin_ = tt.t; -// } else { -// originIsGeoDate_ = false; -// if(sa_.getOrientation() == Axis.HORIZONTAL) { -// point = pt.y; -// } else { -// point = pt.x; -// } -// } - - if(scale_.getOrientation() == Axis.HORIZONTAL) { - originLabel.setText("Y Origin:"); - } else { - originLabel.setText("X Origin:"); - } -// if(originIsGeoDate_) { -// originDateEditor.setEnabled(true); -// originTextField.setText(tOrigin_.toString()); -// } else { -// originDateEditor.setEnabled(false); -// originTextField.setText(String.valueOf(point)); -// } - // - // tics - // - largeTicTextField.setText(String.valueOf(scale_.getLargeTicHeightP())); - smallTicTextField.setText(String.valueOf(scale_.getSmallTicHeightP())); - numSmallTicsTextField.setText(String.valueOf(scale_.getNumberSmallTics())); - ticPositionComboBox.setSelectedIndex(scale_.getTicPosition()); - - Color lcol = scale_.getLineColor(); - if(lcol == null) col = pane_.getComponent().getForeground(); - lineColorPanel.setColor(col); - - // - // axis style - // - axislVisibleCheckBox.setSelected(scale_.isVisible()); - axisSelectableCheckBox.setSelected(scale_.isSelectable()); - // - // attachments - // -// boolean test = sa_.getNumberRegisteredTransforms() > 0; -// transformCheckBox.setSelected(test); - -// if(sa_.getOrientation() == Axis.HORIZONTAL) { -//// test = sa_.getGraph().getNumberXAxis() >= 2; -// axisLabel.setEnabled(test); -// axisCheckBox.setEnabled(test); -// axisLabel.setText("Attach X Axis to Axis:"); -// test = sa_.getNumberRegisteredAxes() > 0; -// axisCheckBox.setSelected(test); -// } else { -// test = sa_.getGraph().getNumberYAxis() >= 2; -// axisLabel.setEnabled(test); -// axisCheckBox.setEnabled(test); -// axisLabel.setText("Attach Y Axis to Axis:"); -// test = sa_.getNumberRegisteredAxes() > 0; -// axisCheckBox.setSelected(test); -// } - - } - - private void updateRuler() { - pane_.setBatch(true, "RulerDialog"); - // - // label - // - scale_.setLabelInterval(Integer.parseInt(intervalTextField.getText())); - scale_.setSignificantDigits(Integer.parseInt(sigDigitsTextField.getText())); - scale_.setLabelFormat(formatTextField.getText()); - - scale_.setLabelColor(textColorPanel.getColor()); - if(labelFont_ != null) scale_.setLabelFont(labelFont_); - - scale_.setLabelHeightP(Double.valueOf(heightTextField.getText()).doubleValue()); - scale_.setLabelPosition(positionComboBox.getSelectedIndex()); - // - // range - // - double min = Double.valueOf(minUserTextField.getText()).doubleValue(); - double max = Double.valueOf(maxUserTextField.getText()).doubleValue(); - double inc = Double.valueOf(incUserTextField.getText()).doubleValue(); - scale_.setRangeU(new Range2D(min, max, inc)); - double x = Double.valueOf(xPhysicalTextField.getText()).doubleValue(); - double y = Double.valueOf(yPhysicalTextField.getText()).doubleValue(); - double width = Double.valueOf(widthPhysicalTextField.getText()).doubleValue(); - double height = Double.valueOf(heightPhysicalTextField.getText()).doubleValue(); - scale_.setBoundsP(new Rectangle2D.Double(x, y, width, height)); -// sa_.setRangeP(new Range2D(min, max)); -// if(originIsGeoDate_) { -// TimePoint pt = sa_.getTimeLocationU(); -// pt.t = tOrigin_; -// sa_.setLocationU(pt); -// } else { -// Point2D.Double pt = sa_.getLocationU(); -// if(sa_.getOrientation() == Axis.HORIZONTAL) { -// pt.y = Double.valueOf(originTextField.getText()).doubleValue(); -// } else { -// pt.x = Double.valueOf(originTextField.getText()).doubleValue(); -// } -// sa_.setLocationU(pt); -// } - // - // tics - // - scale_.setLargeTicHeightP(Double.valueOf(largeTicTextField.getText()).doubleValue()); - scale_.setSmallTicHeightP(Double.valueOf(smallTicTextField.getText()).doubleValue()); - scale_.setNumberSmallTics(Integer.parseInt(numSmallTicsTextField.getText())); - scale_.setTicPosition(ticPositionComboBox.getSelectedIndex()); - - scale_.setLineColor(lineColorPanel.getColor()); - // - // axis style - // - scale_.setVisible(axislVisibleCheckBox.isSelected()); - scale_.setSelectable(axisSelectableCheckBox.isSelected()); - // - // attach - // -// boolean test; -/* if(transformCheckBox.isSelected() && (sa_.getNumberRegisteredTransforms() < 1)) { - if(sa_.getOrientation() == Axis.HORIZONTAL) { - sa_.register(sa_.getGraph().getXTransform()); - } else { - sa_.register(sa_.getGraph().getYTransform()); - } - } else { - if(sa_.getNumberRegisteredTransforms() > 0) sa_.clearAllRegisteredTransforms(); - } - if(sa_.getOrientation() == Axis.HORIZONTAL) { - test = (sa_.getGraph().getNumberXAxis() >= 2) && - (sa_.getNumberRegisteredAxes() < 1); - if(axisCheckBox.isSelected() && test) { - Axis ax; - for(Enumeration it = sa_.getGraph().xAxisElements(); - it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() != sa_.getId()) sa_.register(ax); - } - } else { - if(sa_.getNumberRegisteredAxes() > 0) sa_.clearAllRegisteredAxes(); - } - } else { // vertical axis - test = (sa_.getGraph().getNumberYAxis() >= 2) && - (sa_.getNumberRegisteredAxes() < 1); - if(axisCheckBox.isSelected() && test) { - Axis ax; - for(Enumeration it = sa_.getGraph().yAxisElements(); - it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() != sa_.getId()) sa_.register(ax); - } - } else { - if(sa_.getNumberRegisteredAxes() > 0) sa_.clearAllRegisteredAxes(); - } - } */ - - pane_.setBatch(false, "RulerDialog"); - } - - void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } - - -// void widthPhysicalTextField_actionPerformed(java.awt.event.ActionEvent event) { -/* if(originIsGeoDate_) { - try { - tOrigin_ = new GeoDate(originTextField.getText(), dateFormat_); - } catch (IllegalTimeValue e) { - originTextField.setText(tOrigin_.toString()); - } - } */ -// } - -// void originDateEditor_actionPerformed(java.awt.event.ActionEvent event) { -/* GeoDateDialog gd = new GeoDateDialog(); - Point loc = originDateEditor.getLocationOnScreen(); - int result = gd.showDialog(tOrigin_, loc.x, loc.y); - if(result == GeoDateDialog.OK_RESPONSE) { - tOrigin_ = gd.getGeoDate(); - originTextField.setText(tOrigin_.toString()); - } */ -// } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/SGLabelDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/SGLabelDialog.java deleted file mode 100755 index 4ee79c04..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/SGLabelDialog.java +++ /dev/null @@ -1,525 +0,0 @@ -/* - * $Id: SGLabelDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - - -import gov.noaa.pmel.sgt.SGLabel; -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.Debug; -import gov.noaa.pmel.swing.ThreeDotsButton; -import gov.noaa.pmel.swing.MRJUtil; - -import javax.swing.*; -import java.awt.*; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -/** - * Edits a SGLabel. This dialog does not - * make a copy of the object so changes "Applied" will cause - * sgt to redraw the plot using the new properties. - * - *

Example of SGLabelDialog use: - *

- * public void editSGLabel(SGLabel label, JPane pane) {
- *   SGLabelDialog sgld = new SGLabelDialog();
- *   sgld.setSGLabel(label, pane);
- *   sgld.setVisible(true);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class SGLabelDialog extends JDialog implements PropertyChangeListener { - private SGLabel label_; - private JPane pane_; - private Font labelFont_; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - private boolean ignoreEvent_ = false; -// private ThreeDotsIcon dotsIcon_ = new ThreeDotsIcon(Color.black); - /** - * Constructor. - */ - public SGLabelDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - //{{INIT_CONTROLS - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(457, 320); -// setSize(457,294); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - fontEditor.setAlignmentY((float) 0.0); -// fontEditor.setIcon(dotsIcon_); - fontLabel.setAlignmentY((float) 0.0); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,300); - getContentPane().add(TabbedPane, "Center"); - textPanel.setLayout(new GridBagLayout()); - TabbedPane.add(textPanel, "textPanel"); - textPanel.setBounds(2,27,452,225); - textPanel.setVisible(false); - JLabel9.setText("Text:"); - textPanel.add(JLabel9, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelTextField.setColumns(20); - textPanel.add(labelTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - JLabel11.setText("Color:"); - textPanel.add(JLabel11, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - textPanel.add(textColorPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - JLabel15.setText("Font:"); - textPanel.add(JLabel15, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontPanel.setLayout(flowLayout1); - textPanel.add(fontPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - fontLabel.setText("Dialog, 12, Bold"); - fontPanel.add(fontLabel, null); - fontLabel.setForeground(java.awt.Color.black); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.add(fontEditor, null); - JLabel16.setText("HeightP:"); - textPanel.add(JLabel16, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - heightTextField.setColumns(10); - textPanel.add(heightTextField, new GridBagConstraints(1,3,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel7.setText("Visible:"); - textPanel.add(JLabel7, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelVisibleCheckBox.setSelected(true); - textPanel.add(labelVisibleCheckBox, new GridBagConstraints(1,4,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - JLabel6.setText("Selectable:"); - textPanel.add(JLabel6, new GridBagConstraints(0,5,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelSelectableCheckBox.setSelected(true); - textPanel.add(labelSelectableCheckBox, new GridBagConstraints(1,5,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - locationPanel.setLayout(new GridBagLayout()); - TabbedPane.add(locationPanel, "locationPanel"); - locationPanel.setBounds(2,27,452,225); - locationPanel.setVisible(false); - positionPanel.setBorder(positionBorder); - positionPanel.setLayout(new GridBagLayout()); - locationPanel.add(positionPanel, new GridBagConstraints(0,0,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel1.setText("X Position:"); - positionPanel.add(JLabel1, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - xPosTextField.setColumns(20); - positionPanel.add(xPosTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel2.setText("Y Position:"); - positionPanel.add(JLabel2, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - yPosTextField.setColumns(20); - positionPanel.add(yPosTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - alignPanel.setBorder(alignBorder); - alignPanel.setLayout(new GridBagLayout()); - locationPanel.add(alignPanel, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.VERTICAL,new Insets(5,0,5,0),20,15)); - JLabel3.setText("Horizontal:"); - alignPanel.add(JLabel3,new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - horizComboBox.setModel(horizCBModel); - alignPanel.add(horizComboBox,new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - JLabel4.setText("Vertical:"); - alignPanel.add(JLabel4,new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - vertComboBox.setModel(vertCBModel); - alignPanel.add(vertComboBox,new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - orientPanel.setBorder(orientBorder); - orientPanel.setLayout(new GridBagLayout()); - locationPanel.add(orientPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(5,10,5,0),20,15)); - orientPanel.setBackground(new java.awt.Color(204,204,204)); - horizRadioButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - horizRadioButton.setText("Horizontal"); - horizRadioButton.setActionCommand("Horizontal"); - orientPanel.add(horizRadioButton, new GridBagConstraints(0,0,1,1,1.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,0),0,0)); - vertRadioButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - vertRadioButton.setText("Vertical"); - vertRadioButton.setActionCommand("Vertical"); - orientPanel.add(vertRadioButton,new GridBagConstraints(0,1,1,1,1.0,1.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,0),0,0)); - TabbedPane.setSelectedComponent(textPanel); - TabbedPane.setSelectedIndex(0); - TabbedPane.setTitleAt(0,"Text"); - TabbedPane.setTitleAt(1,"Position"); - { - String[] tempString = new String[3]; - tempString[0] = "LEFT"; - tempString[1] = "CENTER"; - tempString[2] = "RIGHT"; - for(int i=0; i < tempString.length; i++) { - horizCBModel.addElement(tempString[i]); - } - // horizCBModel.setItems(tempString); - } - //$$ horizCBModel.move(72,300); - { - String[] tempString = new String[3]; - tempString[0] = "TOP"; - tempString[1] = "MIDDLE"; - tempString[2] = "BOTTOM"; - for(int i=0; i < tempString.length; i++) { - vertCBModel.addElement(tempString[i]); - } - // vertCBModel.setItems(tempString); - } - vertComboBox.setSelectedIndex(2); - horizComboBox.setSelectedIndex(0); - setTitle("SGLabel"); - //}} - - //{{REGISTER_LISTENERS - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - fontEditor.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - //}} - - if(!MRJUtil.isAquaLookAndFeel()) { - Insets pup = new Insets(0, 0, 0, 0); - fontEditor.setMargin(pup); - } - - ButtonGroup orientBG = new ButtonGroup(); - orientBG.add(horizRadioButton); - orientBG.add(vertRadioButton); - - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public SGLabelDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public SGLabelDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == SGLabelDialog.this) - SGLabelDialog_WindowClosing(event); - } - } - - void SGLabelDialog_WindowClosing(java.awt.event.WindowEvent event) { - finish(); - dispose(); - } - - //{{DECLARE_CONTROLS - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); - javax.swing.JPanel textPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); - javax.swing.JTextField labelTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); - ColorEntryPanel textColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); - javax.swing.JPanel fontPanel = new javax.swing.JPanel(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - ThreeDotsButton fontEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); - javax.swing.JTextField heightTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelVisibleCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JCheckBox labelSelectableCheckBox = new javax.swing.JCheckBox(); - javax.swing.JPanel locationPanel = new javax.swing.JPanel(); - javax.swing.JPanel positionPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - javax.swing.JTextField xPosTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); - javax.swing.JTextField yPosTextField = new javax.swing.JTextField(); - javax.swing.JPanel alignPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); - javax.swing.JComboBox horizComboBox = new javax.swing.JComboBox(); - javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); - javax.swing.JComboBox vertComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel orientPanel = new javax.swing.JPanel(); - javax.swing.JRadioButton horizRadioButton = new javax.swing.JRadioButton(); - javax.swing.JRadioButton vertRadioButton = new javax.swing.JRadioButton(); - javax.swing.border.TitledBorder alignBorder = new javax.swing.border.TitledBorder("Alignment"); - javax.swing.border.TitledBorder positionBorder = new javax.swing.border.TitledBorder("Position"); - DefaultComboBoxModel horizCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel vertCBModel = new DefaultComboBoxModel(); - javax.swing.border.TitledBorder orientBorder = new javax.swing.border.TitledBorder("Orientation"); - private FlowLayout flowLayout1 = new FlowLayout(); - //}} - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == fontEditor) - fontEditor_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - finish(); - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - finish(); - updateSGLabel(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateSGLabel(); - } - /** - * Test entry point - */ - public static void main(String[] args) { - SGLabelDialog la = new SGLabelDialog(); - la.setFont(null); - la.setTitle("Test SGLabel Dialog"); - la.setVisible(true); - } - /** - * Set the SGLabel to be edited and the - * JPane. - */ - public void setSGLabel(SGLabel label, JPane pane) { - setJPane(pane); - setSGLabel(label); - } - /** - * Set the SGLabel to be edited. - */ - public void setSGLabel(SGLabel label) { - label_ = label; - label_.addPropertyChangeListener(this); - ignoreEvent_ = false; - setSGLabel(); - } - /** - * Get the edited object - */ - public SGLabel getSGLabel() { - return label_; - } - /** - * Set the parent JPane - */ - public void setJPane(JPane pane) { - pane_ = pane; - } - /** - * Get the parent JPane - */ - public JPane getJPane() { - return pane_; - } - - private void setSGLabel() { - // - // label Id - // - setTitle("SGLabel - " + label_.getId()); - // - // text - // - labelTextField.setText(label_.getText()); - - Color col = label_.getColor(); - if(col == null && pane_ != null) col = pane_.getComponent().getForeground(); - textColorPanel.setColor(col); - - labelFont_ = label_.getFont(); - if(labelFont_ == null && pane_ != null) labelFont_ = pane_.getComponent().getFont(); - fontLabel.setText(fontString(labelFont_)); - - heightTextField.setText(String.valueOf(label_.getHeightP())); - labelVisibleCheckBox.setSelected(label_.isVisible()); - labelSelectableCheckBox.setSelected(label_.isSelectable()); - // - // location - // - Point2D.Double locp = label_.getLocationP(); - xPosTextField.setText(String.valueOf(locp.x)); - yPosTextField.setText(String.valueOf(locp.y)); - - horizComboBox.setSelectedIndex(label_.getHAlign()); - vertComboBox.setSelectedIndex(label_.getVAlign()); - - if(label_.getOrientation() == SGLabel.HORIZONTAL) { - horizRadioButton.setSelected(true); - } else { - vertRadioButton.setSelected(true); - } - } - - private void updateSGLabel() { - ignoreEvent_ = true; - if(pane_ != null) pane_.setBatch(true, "SGLabelDialog"); - // - // text - // - label_.setText(labelTextField.getText()); - - label_.setColor(textColorPanel.getColor()); - - if(labelFont_ != null) label_.setFont(labelFont_); - - label_.setHeightP(Double.valueOf(heightTextField.getText()).doubleValue()); - label_.setVisible(labelVisibleCheckBox.isSelected()); - label_.setSelectable(labelSelectableCheckBox.isSelected()); - // - // Location - // - double x = Double.valueOf(xPosTextField.getText()).doubleValue(); - double y = Double.valueOf(yPosTextField.getText()).doubleValue(); - Point2D.Double locp = new Point2D.Double(x, y); - label_.setLocationP(locp); - - label_.setHAlign(horizComboBox.getSelectedIndex()); - label_.setVAlign(vertComboBox.getSelectedIndex()); - - boolean horiz = horizRadioButton.isSelected(); - if(horiz) { - label_.setOrientation(SGLabel.HORIZONTAL); - } else { - label_.setOrientation(SGLabel.VERTICAL); - } - - if(pane_ != null) pane_.setBatch(false, "SGLabelDialog"); - ignoreEvent_ = false; - } - - void fontEditor_actionPerformed(java.awt.event.ActionEvent event) - { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } - - private void finish() { - label_.removePropertyChangeListener(this); - } - /** - * Used internally to track changes to a SGLabel - */ - public void propertyChange(PropertyChangeEvent event) { - if(ignoreEvent_) { - if(Debug.EVENT) System.out.println("SGLabel: ignore event"); - return; - } - if(Debug.EVENT) { - System.out.println("SGLabelDialog: " + event); - System.out.println(" " + event.getPropertyName()); - } - if(event.getPropertyName().equals("location")) { - Point2D.Double locp = label_.getLocationP(); - xPosTextField.setText(String.valueOf(locp.x)); - yPosTextField.setText(String.valueOf(locp.y)); - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/SpaceAxisDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/SpaceAxisDialog.java deleted file mode 100755 index 8ae9907c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/SpaceAxisDialog.java +++ /dev/null @@ -1,750 +0,0 @@ -/* - * $Id: SpaceAxisDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.SpaceAxis; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.Point2D; -import gov.noaa.pmel.util.TimePoint; -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.swing.ThreeDotsButton; - -import java.util.Enumeration; -import javax.swing.*; -import java.awt.*; - -/** - * Edits a SpaceAxis. This dialog does not - * make a copy of the object so changes "Applied" will cause - * sgt to redraw the plot using the new properties. - * - *

Example of SpaceAxisDialog use: - *

- * public void editSpaceAxis(SpaceAxis axis, JPane pane) {
- *   SpaceAxisDialog sad = new SpaceAxisDialog();
- *   sad.setSpaceAxis(axis, pane);
- *   sad.setVisible(true);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class SpaceAxisDialog extends JDialog { - private JPane pane_; - private SpaceAxis sa_; - private Font labelFont_; - private boolean originIsGeoDate_; - private GeoDate tOrigin_ = null; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - private String dateFormat_ = "yyyy-MM-dd HH:mm:ss"; - /** - * Constructor. - */ - public SpaceAxisDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(457,344); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - jLabel1.setText("Line Color:"); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,348); - getContentPane().add(TabbedPane, "Center"); - labelPanel.setLayout(new GridBagLayout()); - TabbedPane.add(labelPanel, "labelPanel"); - labelPanel.setBounds(2,27,452,275); - labelPanel.setVisible(false); - JLabel3.setText("Interval:"); - labelPanel.add(JLabel3, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - intervalTextField.setColumns(5); - labelPanel.add(intervalTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel4.setText("Sig Digits:"); - labelPanel.add(JLabel4, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - sigDigitsTextField.setColumns(5); - labelPanel.add(sigDigitsTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel5.setText("Format:"); - labelPanel.add(JLabel5, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - formatTextField.setColumns(10); - labelPanel.add(formatTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel11.setText("Color:"); - labelPanel.add(JLabel11, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(textColorPanel, new GridBagConstraints(1,3,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - JLabel15.setText("Font:"); - labelPanel.add(JLabel15, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(fontPanel, new GridBagConstraints(1,4,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontLabel.setText("Dialog, 12, Bold"); - fontPanel.add(fontLabel); - fontLabel.setForeground(java.awt.Color.black); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.add(fontEditor); - JLabel16.setText("Height:"); - labelPanel.add(JLabel16, new GridBagConstraints(0,5,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - heightTextField.setColumns(10); - labelPanel.add(heightTextField, new GridBagConstraints(1,5,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,5,5),0,0)); - JLabel1.setText("Position:"); - labelPanel.add(JLabel1, new GridBagConstraints(0,6,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - positionComboBox.setModel(positionCBModel); - labelPanel.add(positionComboBox, new GridBagConstraints(1,6,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - rangePanel.setLayout(new GridBagLayout()); - TabbedPane.add(rangePanel, "rangePanel"); - rangePanel.setBounds(2,27,452,275); - rangePanel.setVisible(false); - userPanel.setBorder(userBorder); - userPanel.setLayout(new GridBagLayout()); - rangePanel.add(userPanel, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel8.setText("Minimum:"); - userPanel.add(JLabel8, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - minUserTextField.setColumns(25); - userPanel.add(minUserTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel9.setText("Maximum:"); - userPanel.add(JLabel9, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - maxUserTextField.setColumns(25); - userPanel.add(maxUserTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel2.setText("Delta:"); - userPanel.add(JLabel2, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - incUserTextField.setColumns(25); - userPanel.add(incUserTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - physicalPanel.setBorder(physicalBorder); - physicalPanel.setLayout(new GridBagLayout()); - rangePanel.add(physicalPanel, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel10.setText("Minimum:"); - physicalPanel.add(JLabel10, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - minPhysicalTextField.setColumns(25); - physicalPanel.add(minPhysicalTextField, new GridBagConstraints(1,0,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel17.setText("Maximum:"); - physicalPanel.add(JLabel17, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - maxPhysicalTextField.setColumns(25); - physicalPanel.add(maxPhysicalTextField, new GridBagConstraints(1,1,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - originLabel.setText("Y Origin:"); - physicalPanel.add(originLabel, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - originTextField.setColumns(20); - physicalPanel.add(originTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - originDateEditor.setToolTipText("Edit origin date."); - originDateEditor.setActionCommand("..."); - originDateEditor.setEnabled(false); - physicalPanel.add(originDateEditor, new GridBagConstraints(2,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - ticsStylePanel.setLayout(new GridBagLayout()); - TabbedPane.add(ticsStylePanel, "ticsStylePanel"); - ticsStylePanel.setBounds(2,27,452,275); - ticsStylePanel.setVisible(false); - ticsPanel.setBorder(ticsBorder); - ticsPanel.setLayout(new GridBagLayout()); - ticsStylePanel.add(ticsPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 10, 10)); - JLabel18.setText("Large Tic Height:"); - ticsPanel.add(JLabel18, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - largeTicTextField.setColumns(15); - ticsPanel.add(largeTicTextField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel19.setText("Small Tic Height:"); - ticsPanel.add(JLabel19, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - smallTicTextField.setColumns(15); - ticsPanel.add(smallTicTextField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel20.setText("Number of Small Tics:"); - ticsPanel.add(JLabel20, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - numSmallTicsTextField.setColumns(5); - ticsPanel.add(numSmallTicsTextField, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel21.setText("Tic Position:"); - ticsPanel.add(JLabel21, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - ticPositionComboBox.setModel(ticPositionCBModel); - ticsPanel.add(ticPositionComboBox, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - ticsPanel.add(lineColorPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - stylePanel.setBorder(styleBorder); - stylePanel.setLayout(new GridBagLayout()); - ticsStylePanel.add(stylePanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 20, 10)); - JLabel7.setText("Visible:"); - stylePanel.add(JLabel7, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - axislVisibleCheckBox.setSelected(true); - stylePanel.add(axislVisibleCheckBox, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - JLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - JLabel6.setText("Selectable:"); - stylePanel.add(JLabel6, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 61, 0)); - axisSelectableCheckBox.setSelected(true); - stylePanel.add(axisSelectableCheckBox, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - attachPanel.setLayout(new GridBagLayout()); - TabbedPane.add(attachPanel, "attachPanel"); - attachPanel.setBounds(2,27,452,275); - attachPanel.setVisible(false); - JLabel23.setText("Attach Transform to Axis:"); - attachPanel.add(JLabel23,new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - attachPanel.add(transformCheckBox,new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - axisLabel.setText("Attach X Axis to Axis:"); - attachPanel.add(axisLabel,new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - attachPanel.add(axisCheckBox,new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - ticsPanel.add(jLabel1, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - TabbedPane.setSelectedComponent(labelPanel); - TabbedPane.setSelectedIndex(0); - TabbedPane.setTitleAt(0,"Label"); - TabbedPane.setTitleAt(1,"Range"); - TabbedPane.setTitleAt(2,"Tics/Style"); - TabbedPane.setTitleAt(3,"Attach"); - { - String[] tempString = new String[3]; - tempString[0] = "LEFT"; - tempString[1] = "CENTER"; - tempString[2] = "RIGHT"; - for(int i=0; i < tempString.length; i++) { - horizCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "TOP"; - tempString[1] = "MIDDLE"; - tempString[2] = "BOTTOM"; - for(int i=0; i < tempString.length; i++) { - vertCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "POSITIVE_SIDE"; - tempString[1] = "NEGATIVE_SIDE"; - tempString[2] = "NO_LABEL"; - for(int i=0; i < tempString.length; i++) { - positionCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "POSITIVE_SIDE"; - tempString[1] = "NEGATIVE_SIDE"; - tempString[2] = "BOTH_SIDES"; - for(int i=0; i < tempString.length; i++) { - ticPositionCBModel.addElement(tempString[i]); - } - } - positionComboBox.setSelectedIndex(1); - ticPositionComboBox.setSelectedIndex(1); - setTitle("TimeAxis"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - fontEditor.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - minUserTextField.addActionListener(lSymAction); - maxUserTextField.addActionListener(lSymAction); - originTextField.addActionListener(lSymAction); - originDateEditor.addActionListener(lSymAction); - } - /** Used internally. */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public SpaceAxisDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public SpaceAxisDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == SpaceAxisDialog.this) - FontDialog_WindowClosing(event); - } - } - - void FontDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - //{{DECLARE_CONTROLS - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); - javax.swing.JPanel labelPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); - javax.swing.JTextField intervalTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); - javax.swing.JTextField sigDigitsTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JTextField formatTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); - ColorEntryPanel textColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); - javax.swing.JPanel fontPanel = new javax.swing.JPanel(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - ThreeDotsButton fontEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); - javax.swing.JTextField heightTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - javax.swing.JComboBox positionComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel rangePanel = new javax.swing.JPanel(); - javax.swing.JPanel userPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel8 = new javax.swing.JLabel(); - javax.swing.JTextField minUserTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); - javax.swing.JTextField maxUserTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); - javax.swing.JTextField incUserTextField = new javax.swing.JTextField(); - javax.swing.JPanel physicalPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel10 = new javax.swing.JLabel(); - javax.swing.JTextField minPhysicalTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); - javax.swing.JTextField maxPhysicalTextField = new javax.swing.JTextField(); - javax.swing.JLabel originLabel = new javax.swing.JLabel(); - javax.swing.JTextField originTextField = new javax.swing.JTextField(); - ThreeDotsButton originDateEditor = new ThreeDotsButton(); - javax.swing.JPanel ticsStylePanel = new javax.swing.JPanel(); - javax.swing.JPanel ticsPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel18 = new javax.swing.JLabel(); - javax.swing.JTextField largeTicTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel19 = new javax.swing.JLabel(); - javax.swing.JTextField smallTicTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel20 = new javax.swing.JLabel(); - javax.swing.JTextField numSmallTicsTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel21 = new javax.swing.JLabel(); - javax.swing.JComboBox ticPositionComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel stylePanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JCheckBox axislVisibleCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JCheckBox axisSelectableCheckBox = new javax.swing.JCheckBox(); - javax.swing.JPanel attachPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel23 = new javax.swing.JLabel(); - javax.swing.JCheckBox transformCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel axisLabel = new javax.swing.JLabel(); - javax.swing.JCheckBox axisCheckBox = new javax.swing.JCheckBox(); - DefaultComboBoxModel horizCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel vertCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel positionCBModel = new DefaultComboBoxModel(); - javax.swing.border.TitledBorder userBorder = new javax.swing.border.TitledBorder("User Range"); - javax.swing.border.TitledBorder physicalBorder = new javax.swing.border.TitledBorder("Physical Range"); - javax.swing.border.TitledBorder ticsBorder = new javax.swing.border.TitledBorder("Tics"); - javax.swing.border.TitledBorder styleBorder = new javax.swing.border.TitledBorder("Axis Style"); - DefaultComboBoxModel ticPositionCBModel = new DefaultComboBoxModel(); - private ColorEntryPanel lineColorPanel = new ColorEntryPanel(); - private JLabel jLabel1 = new JLabel(); - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == fontEditor) - fontEditor_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == originTextField) - originTextField_actionPerformed(event); - else if (object == originDateEditor) - originDateEditor_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - updateSpaceAxis(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateSpaceAxis(); - } - /** - * Test entry point - */ - public static void main(String[] args) { - SpaceAxisDialog la = new SpaceAxisDialog(); - la.setFont(null); - la.setTitle("Test SpaceAxis Dialog"); - la.setVisible(true); - } - /** - * Set the SpaceAxis to be edited and the - * JPane - */ - public void setSpaceAxis(SpaceAxis sa, JPane pane) { - setJPane(pane); - setSpaceAxis(sa); - } - /** - * Set the SpaceAxis to be edited - */ - public void setSpaceAxis(SpaceAxis sa) { - sa_ = sa; - setSpaceAxis(); - } - /** - * Get the edited SpaceAxis - */ - public SpaceAxis getSpaceAxis() { - return sa_; - } - /** - * Set the parent JPane. - */ - public void setJPane(JPane pane) { - pane_ = pane; - } - /** - * Get the parent JPane. - */ - public JPane getJPane() { - return pane_; - } - - private void setSpaceAxis() { - // - // time axis ID - // - setTitle("SpaceAxis - " + sa_.getId()); - // - // label - // - intervalTextField.setText(Integer.toString(sa_.getLabelInterval())); - sigDigitsTextField.setText(Integer.toString(sa_.getSignificantDigits())); - formatTextField.setText(sa_.getLabelFormat()); - - Color col = sa_.getLabelColor(); - if(col == null) col = pane_.getComponent().getForeground(); - textColorPanel.setColor(col); - - labelFont_ = sa_.getLabelFont(); - if(labelFont_ == null) labelFont_ = pane_.getComponent().getFont(); - fontLabel.setText(fontString(labelFont_)); - - heightTextField.setText(String.valueOf(sa_.getLabelHeightP())); - // - // range - // - Range2D urange = sa_.getRangeU(); - minUserTextField.setText(String.valueOf(urange.start)); - maxUserTextField.setText(String.valueOf(urange.end)); - incUserTextField.setText(String.valueOf(urange.delta)); - Range2D range = sa_.getRangeP(); - minPhysicalTextField.setText(String.valueOf(range.start)); - maxPhysicalTextField.setText(String.valueOf(range.end)); - - Point2D.Double pt = sa_.getLocationU(); - TimePoint tt = null; - double point = 0.0; - - if(pt == null) { - originIsGeoDate_ = true; - tt = sa_.getTimeLocationU(); - tOrigin_ = tt.t; - } else { - originIsGeoDate_ = false; - if(sa_.getOrientation() == Axis.HORIZONTAL) { - point = pt.y; - } else { - point = pt.x; - } - } - - if(sa_.getOrientation() == Axis.HORIZONTAL) { - originLabel.setText("Y Origin:"); - } else { - originLabel.setText("X Origin:"); - } - if(originIsGeoDate_) { - originDateEditor.setEnabled(true); - originTextField.setText(tOrigin_.toString()); - } else { - originDateEditor.setEnabled(false); - originTextField.setText(String.valueOf(point)); - } - // - // tics - // - largeTicTextField.setText(String.valueOf(sa_.getLargeTicHeightP())); - smallTicTextField.setText(String.valueOf(sa_.getSmallTicHeightP())); - numSmallTicsTextField.setText(String.valueOf(sa_.getNumberSmallTics())); - ticPositionComboBox.setSelectedIndex(sa_.getTicPosition()); - - Color lcol = sa_.getLineColor(); - if(lcol == null) col = pane_.getComponent().getForeground(); - lineColorPanel.setColor(col); - - // - // axis style - // - axislVisibleCheckBox.setSelected(sa_.isVisible()); - axisSelectableCheckBox.setSelected(sa_.isSelectable()); - // - // attachments - // - boolean test = sa_.getNumberRegisteredTransforms() > 0; - transformCheckBox.setSelected(test); - - if(sa_.getOrientation() == Axis.HORIZONTAL) { - test = sa_.getGraph().getNumberXAxis() >= 2; - axisLabel.setEnabled(test); - axisCheckBox.setEnabled(test); - axisLabel.setText("Attach X Axis to Axis:"); - test = sa_.getNumberRegisteredAxes() > 0; - axisCheckBox.setSelected(test); - } else { - test = sa_.getGraph().getNumberYAxis() >= 2; - axisLabel.setEnabled(test); - axisCheckBox.setEnabled(test); - axisLabel.setText("Attach Y Axis to Axis:"); - test = sa_.getNumberRegisteredAxes() > 0; - axisCheckBox.setSelected(test); - } - - } - - private void updateSpaceAxis() { - pane_.setBatch(true, "SpaceAxisDialog"); - // - // label - // - sa_.setLabelInterval(Integer.parseInt(intervalTextField.getText())); - sa_.setSignificantDigits(Integer.parseInt(sigDigitsTextField.getText())); - sa_.setLabelFormat(formatTextField.getText()); - - sa_.setLabelColor(textColorPanel.getColor()); - if(labelFont_ != null) sa_.setLabelFont(labelFont_); - - sa_.setLabelHeightP(Double.valueOf(heightTextField.getText()).doubleValue()); - sa_.setLabelPosition(positionComboBox.getSelectedIndex()); - // - // range - // - double min = Double.valueOf(minUserTextField.getText()).doubleValue(); - double max = Double.valueOf(maxUserTextField.getText()).doubleValue(); - double inc = Double.valueOf(incUserTextField.getText()).doubleValue(); - sa_.setRangeU(new Range2D(min, max, inc)); - min = Double.valueOf(minPhysicalTextField.getText()).doubleValue(); - max = Double.valueOf(maxPhysicalTextField.getText()).doubleValue(); - sa_.setRangeP(new Range2D(min, max)); - if(originIsGeoDate_) { - TimePoint pt = sa_.getTimeLocationU(); - pt.t = tOrigin_; - sa_.setLocationU(pt); - } else { - Point2D.Double pt = sa_.getLocationU(); - if(sa_.getOrientation() == Axis.HORIZONTAL) { - pt.y = Double.valueOf(originTextField.getText()).doubleValue(); - } else { - pt.x = Double.valueOf(originTextField.getText()).doubleValue(); - } - sa_.setLocationU(pt); - } - // - // tics - // - sa_.setLargeTicHeightP(Double.valueOf(largeTicTextField.getText()).doubleValue()); - sa_.setSmallTicHeightP(Double.valueOf(smallTicTextField.getText()).doubleValue()); - sa_.setNumberSmallTics(Integer.parseInt(numSmallTicsTextField.getText())); - sa_.setTicPosition(ticPositionComboBox.getSelectedIndex()); - - sa_.setLineColor(lineColorPanel.getColor()); - // - // axis style - // - sa_.setVisible(axislVisibleCheckBox.isSelected()); - sa_.setSelectable(axisSelectableCheckBox.isSelected()); - // - // attach - // - boolean test; - if(transformCheckBox.isSelected() && (sa_.getNumberRegisteredTransforms() < 1)) { - if(sa_.getOrientation() == Axis.HORIZONTAL) { - sa_.register(sa_.getGraph().getXTransform()); - } else { - sa_.register(sa_.getGraph().getYTransform()); - } - } else { - if(sa_.getNumberRegisteredTransforms() > 0) sa_.clearAllRegisteredTransforms(); - } - if(sa_.getOrientation() == Axis.HORIZONTAL) { - test = (sa_.getGraph().getNumberXAxis() >= 2) && - (sa_.getNumberRegisteredAxes() < 1); - if(axisCheckBox.isSelected() && test) { - Axis ax; - for(Enumeration it = sa_.getGraph().xAxisElements(); - it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() != sa_.getId()) sa_.register(ax); - } - } else { - if(sa_.getNumberRegisteredAxes() > 0) sa_.clearAllRegisteredAxes(); - } - } else { // vertical axis - test = (sa_.getGraph().getNumberYAxis() >= 2) && - (sa_.getNumberRegisteredAxes() < 1); - if(axisCheckBox.isSelected() && test) { - Axis ax; - for(Enumeration it = sa_.getGraph().yAxisElements(); - it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() != sa_.getId()) sa_.register(ax); - } - } else { - if(sa_.getNumberRegisteredAxes() > 0) sa_.clearAllRegisteredAxes(); - } - } - - pane_.setBatch(false, "SpaceAxisDialog"); - } - - void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } - - - void originTextField_actionPerformed(java.awt.event.ActionEvent event) { - if(originIsGeoDate_) { - try { - tOrigin_ = new GeoDate(originTextField.getText(), dateFormat_); - } catch (IllegalTimeValue e) { - originTextField.setText(tOrigin_.toString()); - } - } - } - - void originDateEditor_actionPerformed(java.awt.event.ActionEvent event) { - GeoDateDialog gd = new GeoDateDialog(); - Point loc = originDateEditor.getLocationOnScreen(); - int result = gd.showDialog(tOrigin_, loc.x, loc.y); - if(result == GeoDateDialog.OK_RESPONSE) { - tOrigin_ = gd.getGeoDate(); - originTextField.setText(tOrigin_.toString()); - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/TimeAxisDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/TimeAxisDialog.java deleted file mode 100755 index 251dab0c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/TimeAxisDialog.java +++ /dev/null @@ -1,768 +0,0 @@ -/* - * $Id: TimeAxisDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import gov.noaa.pmel.sgt.JPane; -import gov.noaa.pmel.sgt.TimeAxis; -import gov.noaa.pmel.sgt.Axis; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.util.TimeRange; -import gov.noaa.pmel.util.TimePoint; - -import gov.noaa.pmel.util.GeoDate; -import gov.noaa.pmel.util.IllegalTimeValue; -import gov.noaa.pmel.swing.ThreeDotsButton; - -import java.util.Enumeration; -import javax.swing.*; -import java.awt.*; - -/** - * Edits a TimeAxis. This dialog does not - * make a copy of the object so changes "Applied" will cause - * sgt to redraw the plot using the new properties. - * - *

Example of TimeAxisDialog use: - *

- * public void editTimeAxis(TimeAxis axis, JPane pane) {
- *   TimeAxisDialog tad = new TimeAxisDialog();
- *   tad.setTimeAxis(axis, pane);
- *   tad.setVisible(true);
- * }
- * 
- * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.0 - */ -public class TimeAxisDialog extends JDialog { - private JPane pane_; - private TimeAxis ta_; - private Font labelFont_; - private GeoDate startDate_; - private GeoDate endDate_; - private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; - private String dateFormat_ = "yyyy-MM-dd HH:mm:ss"; - /** - * Constructor. - */ - public TimeAxisDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - void jbInit() throws Exception { - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(new Dimension(457, 354)); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - jLabel1.setText("Line Color:"); - getContentPane().add(buttonPanel, "South"); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - //$$ etchedBorder1.move(0,348); - getContentPane().add(TabbedPane, "Center"); - labelPanel.setLayout(new GridBagLayout()); - TabbedPane.add(labelPanel, "labelPanel"); - labelPanel.setBounds(2,27,452,275); - labelPanel.setVisible(false); - JLabel4.setText("format"); - labelPanel.add(JLabel4, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - JLabel5.setText("interval"); - labelPanel.add(JLabel5, new GridBagConstraints(2,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); - JLabel2.setText("Minor:"); - labelPanel.add(JLabel2, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - majorFormatTextField.setColumns(5); - labelPanel.add(majorFormatTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - majorIntervalTextField.setColumns(3); - labelPanel.add(majorIntervalTextField, new GridBagConstraints(2,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel3.setText("Major:"); - labelPanel.add(JLabel3, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - labelPanel.add(minorFormatTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,5,5,5),0,0)); - minorIntervalTextField.setColumns(3); - labelPanel.add(minorIntervalTextField, new GridBagConstraints(2,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel11.setText("Color:"); - labelPanel.add(JLabel11, new GridBagConstraints(0,3,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(textColorPanel, new GridBagConstraints(1,3,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - JLabel15.setText("Font:"); - labelPanel.add(JLabel15, new GridBagConstraints(0,4,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - labelPanel.add(fontPanel, new GridBagConstraints(1,4,2,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - fontLabel.setText("Dialog, 12, Bold"); - fontPanel.add(fontLabel); - fontLabel.setForeground(java.awt.Color.black); - fontEditor.setToolTipText("Edit font."); - fontEditor.setActionCommand("..."); - fontPanel.add(fontEditor); - JLabel16.setText("Height:"); - labelPanel.add(JLabel16, new GridBagConstraints(0,5,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); - heightTextField.setColumns(10); - labelPanel.add(heightTextField, new GridBagConstraints(1,5,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,5,5),0,0)); - JLabel1.setText("Position:"); - labelPanel.add(JLabel1, new GridBagConstraints(0,6,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - positionComboBox.setModel(positionCBModel); - labelPanel.add(positionComboBox, new GridBagConstraints(1,6,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - rangePanel.setLayout(new GridBagLayout()); - TabbedPane.add(rangePanel, "rangePanel"); - rangePanel.setBounds(2,27,452,275); - rangePanel.setVisible(false); - userPanel.setBorder(userBorder); - userPanel.setLayout(new GridBagLayout()); - rangePanel.add(userPanel, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel8.setText("Minimum:"); - userPanel.add(JLabel8, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - minUserTextField.setColumns(25); - userPanel.add(minUserTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - minDateEditor.setToolTipText("Edit minimum date."); - minDateEditor.setActionCommand("..."); - userPanel.add(minDateEditor, new GridBagConstraints(2,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel9.setText("Maximum:"); - userPanel.add(JLabel9, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - maxUserTextField.setColumns(25); - userPanel.add(maxUserTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - maxDateEditor.setToolTipText("Edit max date."); - maxDateEditor.setActionCommand("..."); - userPanel.add(maxDateEditor, new GridBagConstraints(2,1,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - physicalPanel.setBorder(physicalBorder); - physicalPanel.setLayout(new GridBagLayout()); - rangePanel.add(physicalPanel, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); - JLabel10.setText("Minimum:"); - physicalPanel.add(JLabel10, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - minPhysicalTextField.setColumns(20); - physicalPanel.add(minPhysicalTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - JLabel17.setText("Maximum:"); - physicalPanel.add(JLabel17, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - maxPhysicalTextField.setColumns(20); - physicalPanel.add(maxPhysicalTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - originLabel.setText("Y Origin:"); - physicalPanel.add(originLabel, new GridBagConstraints(0,2,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - originTextField.setColumns(20); - physicalPanel.add(originTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - ticsStylePanel.setLayout(new GridBagLayout()); - TabbedPane.add(ticsStylePanel, "ticsStylePanel"); - ticsStylePanel.setBounds(2,27,452,275); - ticsStylePanel.setVisible(false); - ticsPanel.setBorder(ticsBorder); - ticsPanel.setLayout(new GridBagLayout()); - ticsStylePanel.add(ticsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 10, 10)); - JLabel18.setText("Large Tic Height:"); - ticsPanel.add(JLabel18, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - largeTicTextField.setColumns(15); - ticsPanel.add(largeTicTextField, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel19.setText("Small Tic Height:"); - ticsPanel.add(JLabel19, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - smallTicTextField.setColumns(15); - ticsPanel.add(smallTicTextField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel20.setText("Number of Small Tics:"); - ticsPanel.add(JLabel20, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - numSmallTicsTextField.setColumns(5); - ticsPanel.add(numSmallTicsTextField, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel21.setText("Tic Position:"); - ticsPanel.add(JLabel21, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - ticPositionComboBox.setModel(ticPositionCBModel); - ticsPanel.add(ticPositionComboBox, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - ticsPanel.add(jLabel1, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - ticsPanel.add(lineColorPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - stylePanel.setBorder(styleBorder); - stylePanel.setLayout(new GridBagLayout()); - ticsStylePanel.add(stylePanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 10, 10)); - JLabel22.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - JLabel22.setText("Time Axis Style:"); - stylePanel.add(JLabel22, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),34,0)); - axisStyleComboBox.setModel(styleCBModel); - axisStyleComboBox.setEnabled(false); - stylePanel.add(axisStyleComboBox, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - JLabel7.setText("Visible:"); - stylePanel.add(JLabel7, new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); - axislVisibleCheckBox.setSelected(true); - stylePanel.add(axislVisibleCheckBox, new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); - JLabel6.setText("Selectable:"); - stylePanel.add(JLabel6, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - axisSelectableCheckBox.setSelected(true); - stylePanel.add(axisSelectableCheckBox, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - attachPanel.setLayout(new GridBagLayout()); - TabbedPane.add(attachPanel, "attachPanel"); - attachPanel.setBounds(2,27,452,275); - attachPanel.setVisible(false); - JLabel23.setText("Attach Transform to Axis:"); - attachPanel.add(JLabel23,new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - attachPanel.add(transformCheckBox,new GridBagConstraints(1,0,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - axisLabel.setText("Attach X Axis to Axis:"); - attachPanel.add(axisLabel,new GridBagConstraints(0,1,1,1,0.0,0.0, - GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - attachPanel.add(axisCheckBox,new GridBagConstraints(1,1,1,1,0.0,0.0, - GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); - - TabbedPane.setTitleAt(0,"Label"); - TabbedPane.setTitleAt(1,"Range"); - TabbedPane.setTitleAt(2,"Tics/Style"); - TabbedPane.setTitleAt(3,"Attach"); - - { - String[] horizString = new String[3]; - horizString[0] = "LEFT"; - horizString[1] = "CENTER"; - horizString[2] = "RIGHT"; - for(int i=0; i < horizString.length; i++) { - horizCBModel.addElement(horizString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "TOP"; - tempString[1] = "MIDDLE"; - tempString[2] = "BOTTOM"; - for(int i=0; i < tempString.length; i++) { - vertCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "POSITIVE_SIDE"; - tempString[1] = "NEGATIVE_SIDE"; - tempString[2] = "NO_LABEL"; - for(int i=0; i < tempString.length; i++) { - positionCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "POSITIVE_SIDE"; - tempString[1] = "NEGATIVE_SIDE"; - tempString[2] = "BOTH_SIDES"; - for(int i=0; i < tempString.length; i++) { - ticPositionCBModel.addElement(tempString[i]); - } - } - { - String[] tempString = new String[6]; - tempString[0] = "Auto"; - tempString[1] = "Year/Decade"; - tempString[2] = "Month/Year"; - tempString[3] = "Day/Month"; - tempString[4] = "Hour/Day"; - tempString[5] = "Minute/Hour"; - for(int i=0; i < tempString.length; i++) { - styleCBModel.addElement(tempString[i]); - } - } - - setTitle("TimeAxis"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - fontEditor.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - minDateEditor.addActionListener(lSymAction); - maxDateEditor.addActionListener(lSymAction); - minUserTextField.addActionListener(lSymAction); - maxUserTextField.addActionListener(lSymAction); - - } - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public TimeAxisDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor - */ - public TimeAxisDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == TimeAxisDialog.this) - FontDialog_WindowClosing(event); - } - } - - void FontDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - //{{DECLARE_CONTROLS - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); - javax.swing.JPanel labelPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); - javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); - javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); - javax.swing.JTextField majorFormatTextField = new javax.swing.JTextField(); - javax.swing.JTextField majorIntervalTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); - javax.swing.JTextField minorFormatTextField = new javax.swing.JTextField(); - javax.swing.JTextField minorIntervalTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); - ColorEntryPanel textColorPanel = new ColorEntryPanel(); - javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); - javax.swing.JPanel fontPanel = new javax.swing.JPanel(); - javax.swing.JLabel fontLabel = new javax.swing.JLabel(); - ThreeDotsButton fontEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); - javax.swing.JTextField heightTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); - javax.swing.JComboBox positionComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel rangePanel = new javax.swing.JPanel(); - javax.swing.JPanel userPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel8 = new javax.swing.JLabel(); - javax.swing.JTextField minUserTextField = new javax.swing.JTextField(); - ThreeDotsButton minDateEditor = new ThreeDotsButton(); - javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); - javax.swing.JTextField maxUserTextField = new javax.swing.JTextField(); - ThreeDotsButton maxDateEditor = new ThreeDotsButton(); - javax.swing.JPanel physicalPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel10 = new javax.swing.JLabel(); - javax.swing.JTextField minPhysicalTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); - javax.swing.JTextField maxPhysicalTextField = new javax.swing.JTextField(); - javax.swing.JLabel originLabel = new javax.swing.JLabel(); - javax.swing.JTextField originTextField = new javax.swing.JTextField(); - javax.swing.JPanel ticsStylePanel = new javax.swing.JPanel(); - javax.swing.JPanel ticsPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel18 = new javax.swing.JLabel(); - javax.swing.JTextField largeTicTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel19 = new javax.swing.JLabel(); - javax.swing.JTextField smallTicTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel20 = new javax.swing.JLabel(); - javax.swing.JTextField numSmallTicsTextField = new javax.swing.JTextField(); - javax.swing.JLabel JLabel21 = new javax.swing.JLabel(); - javax.swing.JComboBox ticPositionComboBox = new javax.swing.JComboBox(); - javax.swing.JPanel stylePanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel22 = new javax.swing.JLabel(); - javax.swing.JComboBox axisStyleComboBox = new javax.swing.JComboBox(); - javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); - javax.swing.JCheckBox axislVisibleCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); - javax.swing.JCheckBox axisSelectableCheckBox = new javax.swing.JCheckBox(); - javax.swing.JPanel attachPanel = new javax.swing.JPanel(); - javax.swing.JLabel JLabel23 = new javax.swing.JLabel(); - javax.swing.JCheckBox transformCheckBox = new javax.swing.JCheckBox(); - javax.swing.JLabel axisLabel = new javax.swing.JLabel(); - javax.swing.JCheckBox axisCheckBox = new javax.swing.JCheckBox(); - DefaultComboBoxModel horizCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel vertCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel positionCBModel = new DefaultComboBoxModel(); - javax.swing.border.TitledBorder userBorder = new javax.swing.border.TitledBorder("User Range"); - javax.swing.border.TitledBorder physicalBorder = new javax.swing.border.TitledBorder("Physical Range"); - javax.swing.border.TitledBorder ticsBorder = new javax.swing.border.TitledBorder("Tics"); - javax.swing.border.TitledBorder styleBorder = new javax.swing.border.TitledBorder("Axis Style"); - DefaultComboBoxModel ticPositionCBModel = new DefaultComboBoxModel(); - DefaultComboBoxModel styleCBModel = new DefaultComboBoxModel(); - private JLabel jLabel1 = new JLabel(); - private ColorEntryPanel lineColorPanel = new ColorEntryPanel(); - //}} - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == fontEditor) - fontEditor_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == minDateEditor) - minDateEditor_actionPerformed(event); - else if (object == maxDateEditor) - maxDateEditor_actionPerformed(event); - else if (object == minUserTextField) - minUserTextField_actionPerformed(event); - else if (object == maxUserTextField) - maxUserTextField_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - updateTimeAxis(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateTimeAxis(); - } - /** - * Test entry point - */ - public static void main(String[] args) { - TimeAxisDialog la = new TimeAxisDialog(); - la.setFont(null); - la.setTitle("Test TimeAxis Dialog"); - la.setVisible(true); - } - /** - * Set the TimeAxis to be edited and the - * JPane - */ - public void setTimeAxis(TimeAxis ta, JPane pane) { - setJPane(pane); - setTimeAxis(ta); - } - /** - * Set the TimeAxis to be edited - */ - public void setTimeAxis(TimeAxis ta) { - ta_ = ta; - setTimeAxis(); - } - /** - * Get the edited TimeAxis - */ - public TimeAxis getTimeAxis() { - return ta_; - } - /** - * Set the parent JPane. - */ - public void setJPane(JPane pane) { - pane_ = pane; - } - /** - * Get the parent JPane. - */ - public JPane getJPane() { - return pane_; - } - - private void setTimeAxis() { - // - // time axis ID - // - setTitle("TimeAxis - " + ta_.getId()); - // - // label - // - majorFormatTextField.setText(ta_.getMajorLabelFormat()); - majorIntervalTextField.setText(Integer.toString(ta_.getMajorLabelInterval())); - minorFormatTextField.setText(ta_.getMinorLabelFormat()); - minorIntervalTextField.setText(Integer.toString(ta_.getMinorLabelInterval())); - - Color col = ta_.getLabelColor(); - if(col == null) col = pane_.getComponent().getForeground(); - textColorPanel.setColor(col); - - labelFont_ = ta_.getLabelFont(); - if(labelFont_ == null) labelFont_ = pane_.getComponent().getFont(); - fontLabel.setText(fontString(labelFont_)); - - heightTextField.setText(String.valueOf(ta_.getLabelHeightP())); - - positionComboBox.setSelectedIndex(ta_.getLabelPosition()); - // - // range - // - TimeRange trange = ta_.getTimeRangeU(); - startDate_ = trange.start; - endDate_ = trange.end; - minUserTextField.setText(startDate_.toString()); - maxUserTextField.setText(endDate_.toString()); - Range2D range = ta_.getRangeP(); - minPhysicalTextField.setText(String.valueOf(range.start)); - maxPhysicalTextField.setText(String.valueOf(range.end)); - - TimePoint pt = ta_.getLocationU(); - - if(ta_.getOrientation() == Axis.HORIZONTAL) { - originLabel.setText("Y Origin:"); - originTextField.setText(String.valueOf(pt.x)); - } else { - originLabel.setText("X Origin:"); - originTextField.setText(String.valueOf(pt.x)); - } - // - // tics - // - largeTicTextField.setText(String.valueOf(ta_.getLargeTicHeightP())); - smallTicTextField.setText(String.valueOf(ta_.getSmallTicHeightP())); - numSmallTicsTextField.setText(String.valueOf(ta_.getNumberSmallTics())); - ticPositionComboBox.setSelectedIndex(ta_.getTicPosition()); - col = ta_.getLineColor(); - if(col == null) col = pane_.getComponent().getForeground(); - lineColorPanel.setColor(col); - // - // axis style - // - axisStyleComboBox.setSelectedIndex(ta_.getStyle()); - axislVisibleCheckBox.setSelected(ta_.isVisible()); - axisSelectableCheckBox.setSelected(ta_.isSelectable()); - // - // attachments - // - boolean test = ta_.getNumberRegisteredTransforms() > 0; - transformCheckBox.setSelected(test); - - if(ta_.getOrientation() == Axis.HORIZONTAL) { - test = ta_.getGraph().getNumberXAxis() >= 2; - axisLabel.setEnabled(test); - axisCheckBox.setEnabled(test); - axisLabel.setText("Attach X Axis to Axis:"); - test = ta_.getNumberRegisteredAxes() > 0; - axisCheckBox.setSelected(test); - } else { - test = ta_.getGraph().getNumberYAxis() >= 2; - axisLabel.setEnabled(test); - axisCheckBox.setEnabled(test); - axisLabel.setText("Attach Y Axis to Axis:"); - test = ta_.getNumberRegisteredAxes() > 0; - axisCheckBox.setSelected(test); - } - - } - - private void updateTimeAxis() { - pane_.setBatch(true, "TimeAxisDialog"); - // - // label - // - ta_.setMajorLabelFormat(majorFormatTextField.getText()); - ta_.setMajorLabelInterval(Integer.parseInt(majorIntervalTextField.getText())); - ta_.setMinorLabelFormat(minorFormatTextField.getText()); - ta_.setMinorLabelInterval(Integer.parseInt(minorIntervalTextField.getText())); - - ta_.setLabelColor(textColorPanel.getColor()); - if(labelFont_ != null) ta_.setLabelFont(labelFont_); - - ta_.setLabelHeightP(Double.valueOf(heightTextField.getText()).doubleValue()); - ta_.setLabelPosition(positionComboBox.getSelectedIndex()); - // - // range - // - ta_.setRangeU(new TimeRange(startDate_, endDate_)); - double min = Double.valueOf(minPhysicalTextField.getText()).doubleValue(); - double max = Double.valueOf(maxPhysicalTextField.getText()).doubleValue(); - ta_.setRangeP(new Range2D(min, max)); - TimePoint pt = ta_.getLocationU(); - pt.x = Double.valueOf(originTextField.getText()).doubleValue(); - ta_.setLocationU(pt); - // - // tics - // - ta_.setLargeTicHeightP(Double.valueOf(largeTicTextField.getText()).doubleValue()); - ta_.setSmallTicHeightP(Double.valueOf(smallTicTextField.getText()).doubleValue()); - ta_.setNumberSmallTics(Integer.parseInt(numSmallTicsTextField.getText())); - ta_.setTicPosition(ticPositionComboBox.getSelectedIndex()); - ta_.setLineColor(lineColorPanel.getColor()); - // - // axis style - // - ta_.setVisible(axislVisibleCheckBox.isSelected()); - ta_.setSelectable(axisSelectableCheckBox.isSelected()); - // - // attach - // - boolean test; - if(transformCheckBox.isSelected() && (ta_.getNumberRegisteredTransforms() < 1)) { - if(ta_.getOrientation() == Axis.HORIZONTAL) { - ta_.register(ta_.getGraph().getXTransform()); - } else { - ta_.register(ta_.getGraph().getYTransform()); - } - } else { - if(ta_.getNumberRegisteredTransforms() > 0) ta_.clearAllRegisteredTransforms(); - } - if(ta_.getOrientation() == Axis.HORIZONTAL) { - test = (ta_.getGraph().getNumberXAxis() >= 2) && - (ta_.getNumberRegisteredAxes() < 1); - if(axisCheckBox.isSelected() && test) { - Axis ax; - for(Enumeration it = ta_.getGraph().xAxisElements(); - it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() != ta_.getId()) ta_.register(ax); - } - } else { - if(ta_.getNumberRegisteredAxes() > 0) ta_.clearAllRegisteredAxes(); - } - } else { // vertical axis - test = (ta_.getGraph().getNumberYAxis() >= 2) && - (ta_.getNumberRegisteredAxes() < 1); - if(axisCheckBox.isSelected() && test) { - Axis ax; - for(Enumeration it = ta_.getGraph().yAxisElements(); - it.hasMoreElements();) { - ax = (Axis)it.nextElement(); - if(ax.getId() != ta_.getId()) ta_.register(ax); - } - } else { - if(ta_.getNumberRegisteredAxes() > 0) ta_.clearAllRegisteredAxes(); - } - } - - pane_.setBatch(false, "TimeAxisDialog"); - } - - void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { - FontDialog fd = new FontDialog(); - int result = fd.showDialog(labelFont_); - if(result == FontDialog.OK_RESPONSE) { - labelFont_ = fd.getFont(); - fontLabel.setText(fontString(labelFont_)); - fontLabel.setFont(labelFont_); - } - } - - String fontString(Font font) { - int style = (font.isBold()?1:0) + (font.isItalic()?2:0); - return font.getName() + " " + styleNames_[style]; - } - - - void minDateEditor_actionPerformed(java.awt.event.ActionEvent event) { - GeoDateDialog gd = new GeoDateDialog(); - Point loc = minDateEditor.getLocationOnScreen(); - int result = gd.showDialog(startDate_, loc.x, loc.y); - if(result == GeoDateDialog.OK_RESPONSE) { - startDate_ = gd.getGeoDate(); - minUserTextField.setText(startDate_.toString()); - } - } - - void maxDateEditor_actionPerformed(java.awt.event.ActionEvent event) { - GeoDateDialog gd = new GeoDateDialog(); - Point loc = maxDateEditor.getLocationOnScreen(); - int result = gd.showDialog(endDate_, loc.x, loc.y); - if(result == GeoDateDialog.OK_RESPONSE) { - endDate_ = gd.getGeoDate(); - maxUserTextField.setText(endDate_.toString()); - } - } - - void minUserTextField_actionPerformed(java.awt.event.ActionEvent event) { - try { - startDate_ = new GeoDate(minUserTextField.getText(), dateFormat_); - } catch (IllegalTimeValue e) { - minUserTextField.setText(startDate_.toString()); - } - } - - void maxUserTextField_actionPerformed(java.awt.event.ActionEvent event) { - try { - endDate_ = new GeoDate(maxUserTextField.getText(), dateFormat_); - } catch (IllegalTimeValue e) { - maxUserTextField.setText(endDate_.toString()); - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/VectorAttributeDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/VectorAttributeDialog.java deleted file mode 100755 index d46d40e0..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/VectorAttributeDialog.java +++ /dev/null @@ -1,687 +0,0 @@ -/* - * $Id: VectorAttributeDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.sgt.swing.prop; - -import gov.noaa.pmel.sgt.JPane; - -import javax.swing.*; -import java.awt.*; -import java.util.StringTokenizer; - -import gov.noaa.pmel.sgt.VectorAttribute; -import gov.noaa.pmel.sgt.swing.PlotMarkIcon; -import gov.noaa.pmel.swing.ThreeDotsButton; -import javax.swing.border.*; -import java.awt.event.*; - -/** - * Edits a VectorAttribute. This dialog does not - * make a copy of the attribute so changes "Applied" will cause - * sgt to redraw the plot using the new properties unless - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} - * has been turned on. - * - *

Example of VectorAttributeDialog use: - *

- * public void editVectorAttribute(VectorAttribute attr) {
- *   VectorAttributeDialog lad = new VectorAttributeDialog();
- *   lad.setVectorAttribute(attr);
- *   lad.setVisible(true);
- * }
- * 
- * * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 2.1 - * @see PlotMarkDialog - * @see ArrayEditDialog - */ -public class VectorAttributeDialog extends JDialog { - private VectorAttribute attr_; - private PlotMarkIcon pmIcon_; - private int mark_; - private JPane[] paneList_ = null; - /** - * Constructor. - */ - public VectorAttributeDialog(Frame parent) { - super(parent); - try { - jbInit(); - pack(); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - - void jbInit() throws Exception { - // - pmIcon_ = new PlotMarkIcon(1); - { - String[] tempString = new String[3]; - tempString[0] = "NO_HEAD"; - tempString[1] = "HEAD"; - tempString[2] = "SCALED_HEAD"; - for(int i=0; i < tempString.length; i++) { - vectorStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[2]; - tempString[0] = "NO_MARK"; - tempString[1] = "MARK"; - for(int i=0; i < tempString.length; i++) { - originStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "BUTT"; - tempString[1] = "ROUND"; - tempString[2] = "SQUARE"; - for(int i=0; i < tempString.length; i++) { - capStyleCBM.addElement(tempString[i]); - } - } - { - String[] tempString = new String[3]; - tempString[0] = "MITER"; - tempString[1] = "ROUND"; - tempString[2] = "BEVEL"; - for(int i=0; i < tempString.length; i++) { - miterStyleCBM.addElement(tempString[i]); - } - } - getContentPane().setLayout(new BorderLayout(0,0)); - setSize(500,490); - setVisible(false); - buttonPanel.setBorder(etchedBorder1); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - vectorMaxSizeTextField.setColumns(8); - vectorScaleTextField.setColumns(8); - JLabel5.setText("Style:"); - colorPanel.setBorder(etchedBorder1); - colorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - JLabel1.setText("Color:"); - offsetAngleTextField.setColumns(8); - vectorStyleComboBox.setModel(vectorStyleCBM); - vectorStyleComboBox.addActionListener(new VectorAttributeDialog_vectorStyleComboBox_actionAdapter(this)); - jLabel7.setText("Offset Angle:"); - jLabel6.setText("Max Size:"); - jLabel5.setText("Scale:"); - vectorPanel.setLayout(gridBagLayout2); - jLabel11.setText("Fixed Size:"); - jLabel10.setText("Max Size:"); - headMinSizeTextField.setColumns(8); - jLabel9.setText("Min Size:"); - jLabel8.setText("Scale:"); - headScaleTextField.setColumns(8); - headMaxSizeTextField.setColumns(8); - headFixedSizeTextField.setColumns(8); - headPanel.setLayout(gridBagLayout4); - markHeightTextField.setColumns(8); - originStyleComboBox.setModel(originStyleCBM); - JLabel12.setText("Color:"); - JLabel7.setText("Mark Height:"); - JLabel6.setText("Mark:"); - markPanel.setLayout(new GridBagLayout()); - markEditor.addActionListener(new VectorAttributeDialog_markEditor_actionAdapter(this)); - markEditor.setActionCommand("..."); -// markEditor.setMargin(new Insets(0, 0, 0, 0)); - markColorPanel.setBorder(etchedBorder1); - Mark.setLayout(gridBagLayout3); - jLabel4.setText("Style:"); - plotMarkIconLabel.setForeground(java.awt.Color.black); - plotMarkIconLabel.setIcon(pmIcon_); - miterLimitTextField.setColumns(8); - JLabel10.setText(" Width:"); - strokePanel.setLayout(gridBagLayout1); - miterStyleComboBox.setModel(miterStyleCBM); - jLabel3.setText("Miter Limit:"); - jLabel2.setText("Miter Style:"); - jLabel1.setText("Cap Style:"); - capStyleComboBox.setModel(capStyleCBM); - widthTextField.setColumns(8); - getContentPane().add(buttonPanel, "South"); - buttonPanel.setBounds(0,263,430,39); - okButton.setText("OK"); - okButton.setActionCommand("OK"); - buttonPanel.add(okButton); - okButton.setBounds(115,7,51,25); - applyButton.setText("Apply"); - applyButton.setActionCommand("Apply"); - buttonPanel.add(applyButton); - applyButton.setBounds(171,7,65,25); - cancelButton.setText("Cancel"); - cancelButton.setActionCommand("Cancel"); - buttonPanel.add(cancelButton); - cancelButton.setBounds(241,7,73,25); - //$$ etchedBorder1.move(0,300); - this.getContentPane().add(jTabbedPane1, BorderLayout.CENTER); - jTabbedPane1.add(vectorPanel, "Vector"); - vectorPanel.add(vectorStyleComboBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 5, 5), 0, 0)); - vectorPanel.add(colorPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 15), 0, 0)); - vectorPanel.add(JLabel1, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - vectorPanel.add(jLabel5, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 6, 0, 6), 0, 0)); - vectorPanel.add(jLabel6, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - vectorPanel.add(jLabel7, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 15, 10, 5), 0, 0)); - vectorPanel.add(vectorScaleTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - vectorPanel.add(vectorMaxSizeTextField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - vectorPanel.add(offsetAngleTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 15, 5), 0, 0)); - vectorPanel.add(JLabel5, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 0, 5), 0, 0)); - jTabbedPane1.add(headPanel, "Head"); - headPanel.add(jLabel8, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - headPanel.add(headScaleTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - headPanel.add(jLabel9, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - headPanel.add(jLabel10, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - headPanel.add(headMinSizeTextField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - headPanel.add(headMaxSizeTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - headPanel.add(jLabel11, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - headPanel.add(headFixedSizeTextField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - jTabbedPane1.add(Mark, "Mark"); - Mark.add(markPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - markPanel.add(plotMarkIconLabel, new GridBagConstraints(0,0,1,1,0.0,0.0, - GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0)); - markPanel.add(markEditor, new GridBagConstraints(2,0,1,1,0.0,1.0, - GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(0,0,0,0),0,0)); - Mark.add(JLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - Mark.add(JLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 15, 10, 5), 0, 0)); - Mark.add(markHeightTextField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 15, 5), 0, 0)); - Mark.add(markColorPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 15), 0, 0)); - Mark.add(JLabel12, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - Mark.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 0, 5), 0, 0)); - Mark.add(originStyleComboBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 5, 5), 0, 0)); - jTabbedPane1.add(strokePanel, "Line Style"); - strokePanel.add(JLabel10, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(widthTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(jLabel1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(jLabel2, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(capStyleComboBox, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(miterStyleComboBox, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - strokePanel.add(jLabel3, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - strokePanel.add(miterLimitTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - //$$ stringComboBoxModel1.move(24,300); - setTitle("VectorAttribute Properties"); - - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - cancelButton.addActionListener(lSymAction); - okButton.addActionListener(lSymAction); - applyButton.addActionListener(lSymAction); - } - - /** Used internally */ - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - Insets ins = getInsets(); - setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); - Component components[] = getContentPane().getComponents(); - for (int i = 0; i < components.length; i++) { - Point p = components[i].getLocation(); - p.translate(ins.left, ins.top); - components[i].setLocation(p); - } - fComponentsAdjusted = true; - } - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - /** - * Constructor. - */ - public VectorAttributeDialog(String title) { - this(); - setTitle(title); - } - /** - * Default constructor. - */ - public VectorAttributeDialog() { - this((Frame)null); - } - /** - * Make the dialog visible - */ - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - class SymWindow extends java.awt.event.WindowAdapter { - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == VectorAttributeDialog.this) - VectorAttributeDialog_WindowClosing(event); - } - } - - void VectorAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { - dispose(); - } - - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton okButton = new javax.swing.JButton(); - javax.swing.JButton applyButton = new javax.swing.JButton(); - javax.swing.JButton cancelButton = new javax.swing.JButton(); - javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); - DefaultComboBoxModel vectorStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel originStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel capStyleCBM = new DefaultComboBoxModel(); - DefaultComboBoxModel miterStyleCBM = new DefaultComboBoxModel(); - JTabbedPane jTabbedPane1 = new JTabbedPane(); - JTextField vectorMaxSizeTextField = new JTextField(); - GridBagLayout gridBagLayout2 = new GridBagLayout(); - JTextField vectorScaleTextField = new JTextField(); - JLabel JLabel5 = new javax.swing.JLabel(); - ColorEntryPanel colorPanel = new ColorEntryPanel(); - JLabel JLabel1 = new javax.swing.JLabel(); - JTextField offsetAngleTextField = new JTextField(); - JComboBox vectorStyleComboBox = new javax.swing.JComboBox(); - JLabel jLabel7 = new JLabel(); - JLabel jLabel6 = new JLabel(); - JLabel jLabel5 = new JLabel(); - JPanel vectorPanel = new JPanel(); - JLabel jLabel11 = new JLabel(); - JLabel jLabel10 = new JLabel(); - GridBagLayout gridBagLayout4 = new GridBagLayout(); - JTextField headMinSizeTextField = new JTextField(); - JLabel jLabel9 = new JLabel(); - JLabel jLabel8 = new JLabel(); - JTextField headScaleTextField = new JTextField(); - JTextField headMaxSizeTextField = new JTextField(); - JTextField headFixedSizeTextField = new JTextField(); - JPanel headPanel = new JPanel(); - JTextField markHeightTextField = new javax.swing.JTextField(); - GridBagLayout gridBagLayout3 = new GridBagLayout(); - JComboBox originStyleComboBox = new JComboBox(); - JLabel JLabel12 = new javax.swing.JLabel(); - JLabel JLabel7 = new javax.swing.JLabel(); - JLabel JLabel6 = new javax.swing.JLabel(); - JPanel markPanel = new javax.swing.JPanel(); - ThreeDotsButton markEditor = new ThreeDotsButton(); - ColorEntryPanel markColorPanel = new ColorEntryPanel(); - JPanel Mark = new JPanel(); - JLabel jLabel4 = new JLabel(); - JLabel plotMarkIconLabel = new javax.swing.JLabel(); - GridBagLayout gridBagLayout1 = new GridBagLayout(); - JTextField miterLimitTextField = new JTextField(); - JLabel JLabel10 = new javax.swing.JLabel(); - JPanel strokePanel = new JPanel(); - JComboBox miterStyleComboBox = new JComboBox(); - JLabel jLabel3 = new JLabel(); - JLabel jLabel2 = new JLabel(); - JLabel jLabel1 = new JLabel(); - JComboBox capStyleComboBox = new JComboBox(); - JTextField widthTextField = new javax.swing.JTextField(); - - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == cancelButton) - cancelButton_actionPerformed(event); - else if (object == okButton) - okButton_actionPerformed(event); - else if (object == applyButton) - applyButton_actionPerformed(event); - else if (object == markEditor) - markEditor_actionPerformed(event); - } - } - - void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { - this.setVisible(false); - } - - void okButton_actionPerformed(java.awt.event.ActionEvent event) { - updateVectorAttribute(); - this.setVisible(false); - } - - void applyButton_actionPerformed(java.awt.event.ActionEvent event) { - updateVectorAttribute(); - } - /** - * Set the VectorAttribute for the dialog. - */ - public void setVectorAttribute(VectorAttribute attr) { - attr_ = attr; - // - // Vector - // - // Color - // - colorPanel.setColor(attr_.getVectorColor()); - // - // style - // - vectorStyleComboBox.setSelectedIndex(attr_.getVectorStyle()); - vectorStyle(attr_.getVectorStyle()); - // - // vectorScale - // - vectorScaleTextField.setText(Double.toString(attr_.getVectorScale())); - // - // vector max size - // - vectorMaxSizeTextField.setText(Double.toString(attr_.getVectorMaxSize())); - // - // offset angle - // - offsetAngleTextField.setText(Double.toString(attr_.getOffsetAngle())); - // - // head - // - // - // scale - // - headScaleTextField.setText(Double.toString(attr_.getHeadScale())); - // - // head max size - // - headMaxSizeTextField.setText(Double.toString(attr_.getHeadMaxSize())); - // - // head min size - // - headMinSizeTextField.setText(Double.toString(attr_.getHeadMinSize())); - // - // head fixed size - // - headFixedSizeTextField.setText(Double.toString(attr_.getHeadFixedSize())); - // - // origin - // - // style - // - originStyleComboBox.setSelectedIndex(attr_.getOriginStyle()); - // - // mark - // - int mark = attr_.getMark(); - changeMark(mark); -// System.out.println(" mark code = " + mark); - // - // Color - // - markColorPanel.setColor(attr_.getMarkColor()); - // - // mark height - // - markHeightTextField.setText(Double.toString(attr_.getMarkHeightP())); - // - // Stroke line attributes - // - // width - // - widthTextField.setText(Float.toString(attr_.getWidth())); - // - // cap style - // - capStyleComboBox.setSelectedIndex(attr_.getCapStyle()); - // - // miter style - // - miterStyleComboBox.setSelectedIndex(attr_.getMiterStyle()); - // - // miter limit - // - miterLimitTextField.setText(Float.toString(attr_.getMiterLimit())); - } - - void updateVectorAttribute() { - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(true, "VectorAttributeDialog"); - } - } - attr_.setBatch(true); - // - // Vector - // - // - // Color - // - attr_.setVectorColor(colorPanel.getColor()); - // - // style - // - attr_.setVectorStyle(vectorStyleComboBox.getSelectedIndex()); - // - // vectorScale - // - attr_.setVectorScale(Double.parseDouble(vectorScaleTextField.getText())); - // - // vector max size - // - attr_.setVectorMaxSize(Double.parseDouble(vectorMaxSizeTextField.getText())); - // - // offset angle - // - attr_.setOffsetAngle(Double.parseDouble(offsetAngleTextField.getText())); - // - // head - // - // - // scale - // - attr_.setHeadScale(Double.parseDouble(headScaleTextField.getText())); - // - // max head size - // - attr_.setHeadMaxSize(Double.parseDouble(headMaxSizeTextField.getText())); - // - // head min size - // - attr_.setHeadMinSize(Double.parseDouble(headMinSizeTextField.getText())); - // - // head fixed size - // - attr_.setHeadFixedSize(Double.parseDouble(headFixedSizeTextField.getText())); - // - // origin - // - // style - // - attr_.setOriginStyle(originStyleComboBox.getSelectedIndex()); - // - // mark - // - attr_.setMark(mark_); - // - // color - // - attr_.setMarkColor(markColorPanel.getColor()); - // - // mark height - // - attr_.setMarkHeightP(new Double(markHeightTextField.getText()).doubleValue()); - // - // stroke attributes - // - // - // width - // - attr_.setWidth(new Float(widthTextField.getText()).floatValue()); - // - // cap style - // - attr_.setCapStyle(capStyleComboBox.getSelectedIndex()); - // - // miter style - // - attr_.setMiterStyle(miterStyleComboBox.getSelectedIndex()); - // - // miter limit - // - attr_.setMiterLimit(new Float(miterLimitTextField.getText()).floatValue()); - - attr_.setBatch(false); - // - if(paneList_ != null) { - for(int i=0; i < paneList_.length; i++) { - paneList_[i].setBatch(false, "VectorAttributeDialog"); - } - } - } - - private void vectorStyle(int style) { - switch(style) { - case VectorAttribute.NO_HEAD: - headScaleTextField.setEnabled(false); - headMinSizeTextField.setEnabled(false); - headMaxSizeTextField.setEnabled(false); - headFixedSizeTextField.setEnabled(false); - break; - case VectorAttribute.HEAD: - headScaleTextField.setEnabled(false); - headMinSizeTextField.setEnabled(false); - headMaxSizeTextField.setEnabled(false); - headFixedSizeTextField.setEnabled(true); - break; - case VectorAttribute.SCALED_HEAD: - headScaleTextField.setEnabled(true); - headMinSizeTextField.setEnabled(true); - headMaxSizeTextField.setEnabled(true); - headFixedSizeTextField.setEnabled(false); - } - } - /** - * Dialog test entry. - */ - public static void main(String[] args) { - VectorAttribute attr = new VectorAttribute(); - VectorAttributeDialog la = new VectorAttributeDialog(); - la.setVectorAttribute(attr); - la.setTitle("Test VectorAttribute Dialog"); - la.setVisible(true); - } - - void markEditor_actionPerformed(java.awt.event.ActionEvent event) { - PlotMarkDialog pmd = new PlotMarkDialog(); - Point loc = markEditor.getLocationOnScreen(); - pmd.setLocation(loc.x, loc.y); - int result = pmd.showDialog(mark_); - if(result == PlotMarkDialog.OK_RESPONSE) { - changeMark(pmd.getMark()); - } - } - - private void changeMark(int mark) { - mark_ = mark; - pmIcon_.setMark(mark); - plotMarkIconLabel.repaint(); - } - /** - * Set the parent JPane. This reference to - * JPane is used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. - */ - public void setJPane(JPane pane) { - paneList_ = new JPane[1]; - paneList_[0] = pane; - } - /** Get the first parent pane. */ - public JPane getJPane() { - if(paneList_ != null) { - return paneList_[0]; - } else { - return null; - } - } - /** - * Set the parent JPanes. These references to - * JPane are used to enable/disable - * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so - * multiple property changes are made at one time. A second - * JPane is often used for a VectorKey. - */ - public void setJPaneList(JPane[] list) { - paneList_ = list; - } - /** Get an array of parent panes. */ - public JPane[] getJPaneList() { - return paneList_; - } - - void vectorStyleComboBox_actionPerformed(ActionEvent e) { - int style = vectorStyleComboBox.getSelectedIndex(); - vectorStyle(style); - } -} - -class VectorAttributeDialog_vectorStyleComboBox_actionAdapter implements java.awt.event.ActionListener { - VectorAttributeDialog adaptee; - - VectorAttributeDialog_vectorStyleComboBox_actionAdapter(VectorAttributeDialog adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.vectorStyleComboBox_actionPerformed(e); - } -} - -class VectorAttributeDialog_markEditor_actionAdapter implements java.awt.event.ActionListener { - VectorAttributeDialog adaptee; - - VectorAttributeDialog_markEditor_actionAdapter(VectorAttributeDialog adaptee) { - this.adaptee = adaptee; - } - public void actionPerformed(ActionEvent e) { - adaptee.markEditor_actionPerformed(e); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/package.html deleted file mode 100755 index 4147f9ea..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/prop/package.html +++ /dev/null @@ -1,22 +0,0 @@ - - -Property dialogs for sgt components using -javax.swing. Dialogs that edit the properties of -attributes and other sgt objects do not, in general, work -on a copy of the object. Because the references to attributes are -one-way if a copy were created the editing would not affect most of -the references. If you want these dialogs to work on copies instead of -the actual object, the creation of the copy and updating of the -original, if the changes are applied, will need to be done in the -users application. - -

This software is provided by NOAA for full, free -and open release. It is understood by the recipient/user that NOAA -assumes no liability for any errors contained in the code. Although -this software is released without conditions or restrictions in its -use, it is expected that appropriate credit be given to its author and -to the National Oceanic and Atmospheric Administration should the -software be included by the recipient as an element in other product -development.

- - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/sgt_logo.png b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/sgt_logo.png deleted file mode 100755 index 0d2f5cd7..00000000 Binary files a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/sgt/swing/sgt_logo.png and /dev/null differ diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/space/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/space/package.html deleted file mode 100755 index 37f92e20..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/space/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - -Collaborative support classes for JavaSpaces and Jini. - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSlider2.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSlider2.java deleted file mode 100755 index c84ec587..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSlider2.java +++ /dev/null @@ -1,555 +0,0 @@ -/* - * $Id: JSlider2.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - */ - -package gov.noaa.pmel.swing; - -import javax.swing.*; -import javax.swing.border.EtchedBorder; -import java.awt.event.*; -import java.beans.*; -import java.awt.Dimension; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.FontMetrics; -import java.awt.BorderLayout; -import java.awt.Rectangle; - -import gov.noaa.pmel.util.Range; -import gov.noaa.pmel.swing.beans.SliderHandle; - -/** - * JSlider2 provides the graphical input and feedback - * for JSlider2Double and JSlider2Date. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @see JSlider2Double - * @see JSlider2Date -**/ -public class JSlider2 extends JComponent - implements java.io.Serializable { - protected Range rawRange_; - protected int handleSize_; - protected Dimension size_; - protected int yval_; - boolean showBorder_; - boolean twoHandles_; - boolean alwaysPost_; - SliderHandle minHandle_, maxHandle_; - int min_, max_; - double scale_; - double minValue_, maxValue_; - double minOld_, maxOld_; - String minLabel_, maxLabel_; - private PropertyChangeSupport changes = new PropertyChangeSupport(this); - boolean indexed_ = false; - double[] values_; - int[] pixels_; - - private EtchedBorder eBorder_ = null; - /** - * Class for the Date and Double JSlider2 classes. This class creates - * the slider portion of the JSlider2Date and JSlider2Double classes. - * - * @see JSlider2Date - * @see JSlider2Double - **/ - public JSlider2() { - this(true); - setSize(40,40); - } - - /** - * Class for the GeoDate and Double JSlider2 classes. This class creates - * the slider portion of the JSlider2Date and JSlider2Double classes. - * - * @param twoHandles if true create two handles - * @see JSlider2Date - * @see JSlider2Double - **/ - public JSlider2(boolean twoHandles) { - super(); - - //{{REGISTER_LISTENERS - SymMouse aSymMouse = new SymMouse(); - this.addMouseListener(aSymMouse); - SymMouseMotion aSymMouseMotion = new SymMouseMotion(); - this.addMouseMotionListener(aSymMouseMotion); - MyComponent aMyComponent = new MyComponent(); - this.addComponentListener(aMyComponent); - //}} - - twoHandles_ = twoHandles; - showBorder_ = true; - eBorder_ = new EtchedBorder(); - setBorder(eBorder_); - handleSize_ = 6; - alwaysPost_ = false; - - size_ = new Dimension(175, 50); - rawRange_ = new Range(handleSize_ + 1, size_.width - handleSize_ - 1); - - reset(); - - minLabel_ = Double.toString(minValue_); - maxLabel_ = Double.toString(maxValue_); - - minHandle_ = new SliderHandle(handleSize_, Color.green, SliderHandle.LEFT); - maxHandle_ = new SliderHandle(handleSize_, Color.red, SliderHandle.RIGHT); - if(!twoHandles_) - minHandle_.setStyle(SliderHandle.SINGLE); - } - /** - * Set the minimum handle value. Valid range 0.0 - 1.0. - * - * @param min minimum handle value - **/ - public void setMinValue(double min) { - minValue_ = Math.max(min, 0.0); - if(minOld_ != minValue_) { - Double tempOld = new Double(minOld_); - minOld_ = minValue_; - changes.firePropertyChange("minValue", tempOld, new Double(minValue_)); - } - repaint(); - } - /** - * Get the minimum handle value. - * - * @return minimum handle value - **/ - public double getMinValue() { - return minValue_; - } - /** - * Set the maximum handle value. Valid range 0.0 - 1.0. - * - * @param max maximum handle value - **/ - public void setMaxValue(double max) { - maxValue_ = Math.min(max, 1.0); - if(maxOld_ != maxValue_) { - Double tempOld = new Double(maxOld_); - maxOld_ = maxValue_; - changes.firePropertyChange("maxValue", tempOld, new Double(maxValue_)); - } - repaint(); - } - /** - * Get the maximum handle value. - * - * @return maximum handle value - **/ - public double getMaxValue() { - return maxValue_; - } - /** - * Reset the max,min values to the range limits - **/ - public void reset() { - maxValue_ = 1.0; - minValue_ = 0.0; - maxOld_ = 1.0; - minOld_ = 0.0; - } - - /** - * Set the minimum label. - * - * @param lab minimum string - **/ - public void setMinLabel(String lab) { - minLabel_ = lab; - repaint(); - } - /** - * Get the minimum label. - * - * @return the minimum label - */ - public String getMinLabel() { - return minLabel_; - } - /** - * Set the maximum label. - * - * @param lab maximum string - **/ - public void setMaxLabel(String lab) { - maxLabel_ = lab; - repaint(); - } - /** - * Get the maximum label. - * - * @return the maximum label - */ - public String getMaxLabel() { - return maxLabel_; - } - /** - * Add a property change listener. The properties that fire a property - * change are "minValue" and "maxValue". The old and new Double objects - * are set. - * - * @param l property change listener - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - changes.addPropertyChangeListener(l); - } - /** - * Remove a property change listener. - * - * @param l property change listener - */ - public void removePropertyChangeListener(PropertyChangeListener l) { - changes.removePropertyChangeListener(l); - } - /** - * Set the two handle mode. - * - * @param th if true set two handles - */ - public void setTwoHandles(boolean th) { - twoHandles_ = th; - if(twoHandles_) { - minHandle_.setStyle(SliderHandle.LEFT); - } else { - minHandle_.setStyle(SliderHandle.SINGLE); - } - repaint(); - } - /** - * Get the two handle flag. - * - * @return true if two handles - */ - public boolean isTwoHandles() { - return twoHandles_; - } - /** - * Get the two handle flag. - * - * @return true if two handles - */ - public boolean getTwoHandles() { - return twoHandles_; - } - /** - * Show a border around the slider. - * - * @param sb if true show the border - */ - public void setShowBorder(boolean sb) { - showBorder_ = sb; - if(!showBorder_) setBorder(null); - repaint(); - } - /** - * Get border status for the slider. - * - * @return true if border is showing - */ - public boolean isShowBorder() { - return showBorder_; - } - /** - * Get border status for the slider. - * - * @return true if border is showing - */ - public boolean getShowBorder() { - return showBorder_; - } - /** - * Set the handle size for the slider. - * - * @param sz handle size in pixels - */ - public void setHandleSize(int sz) { - if(handleSize_ != sz) { - handleSize_ = sz; - minHandle_ = new SliderHandle(handleSize_, Color.green); - maxHandle_ = new SliderHandle(handleSize_, Color.red); - repaint(); - } - } - /** - * Get the current slider handle size. - * - * @return handle size in pixels - */ - public int getHandleSize() { - return handleSize_; - } - /** - * Set the always post flag for the slider. If true any motion of the - * slider will fire a property change, if false a property change is - * only caused when the mouse button is released. - * - * @param ap if true always post - */ - public void setAlwaysPost(boolean ap) { - alwaysPost_ = ap; - } - /** - * Get the always post flag for the slider. - * - * @return true if the slider will always post - */ - public boolean isAlwaysPost() { - return alwaysPost_; - } - /** - * Get the always post flag for the slider. - * - * @return true if the slider will always post - */ - public boolean getAlwaysPost() { - return alwaysPost_; - } - /** - * Get the range of the slider. The range is in pixels and is determined from - * the size of the slider and the sizes of the handles. - * - * @return slider range - **/ - public Range getRawRange() { - return rawRange_; - } - - public void setBounds(Rectangle r) { - super.setBounds(r); - invalidate(); - doCompute(); - } - - public void setBounds(int x, int y, int w, int h) { - super.setBounds(x,y,w,h); - invalidate(); - doCompute(); - } - /** - * Set the size of the slider. - * - * @param size slider size - **/ - public void setSize(Dimension size) { - super.setSize(size); - invalidate(); - doCompute(); - } - - public void setSize(int width, int height) { - super.setSize(width, height); - invalidate(); - doCompute(); - } - - public void setIndexed(boolean ind) { - indexed_ = ind; - } - - public boolean isIndexed() { - return indexed_; - } - - public void paintComponent(Graphics g) { - FontMetrics fmet; - int xs, ys, swidth; - - min_ = rawRange_.start + (int)(minValue_*scale_); - max_ = rawRange_.start + (int)(maxValue_*scale_); - - g.setColor(getBackground()); - g.fillRect(0, 0, size_.width, size_.height); - - g.setColor(Color.black); -// if(showBorder_) { -// g.drawRect(0, 0, size_.width-1, size_.height-1); -// } - g.setColor(Color.black); - g.drawLine(rawRange_.start, yval_ - 3, rawRange_.end, yval_ - 3); - g.setColor(Color.gray); - g.drawLine(rawRange_.start, yval_ - 2, rawRange_.end, yval_ - 2); - // - // draw labels - // - g.setColor(Color.black); - fmet = g.getFontMetrics(); - ys = yval_ - 8; - xs = rawRange_.start; - g.drawString(minLabel_, xs, ys); - swidth = fmet.stringWidth(maxLabel_); - xs = rawRange_.end - swidth; - g.drawString(maxLabel_, xs, ys); - // - // draw handles - // - minHandle_.draw(g, min_, yval_); - if(twoHandles_) maxHandle_.draw(g, max_, yval_); - } - - public Dimension getMinimumSize() { - return new Dimension(96,57); - } - - public Dimension getPreferredSize() { - return new Dimension(200,57); - } - - public Dimension getMaximumSize() { - return new Dimension(Short.MAX_VALUE,Short.MIN_VALUE); - } - - public void setIndexValues(double[] array) { - values_ = array; - indexed_ = true; - pixels_ = new int[values_.length]; - doCompute(); - } - - void doCompute() { - size_ = getSize(); - rawRange_.start = 2*handleSize_ + 1; - rawRange_.end = size_.width - 2*handleSize_ - 1; - yval_ = size_.height - 3*handleSize_ - 10; - scale_ = (double)(rawRange_.end - rawRange_.start); - if(indexed_) { - for(int i=0; i < values_.length; i++) { - pixels_[i] = rawRange_.start + (int)(values_[i]*scale_); - } - } - } - - /** - * - **/ - - void doMove(int xpos, boolean forcePost) { - double value; - if(xpos > rawRange_.end) xpos = rawRange_.end; - if(xpos < rawRange_.start) xpos = rawRange_.start; - - if(indexed_ && forcePost) { - int ind = 0; - if(xpos <= pixels_[0]) { - ind = 0; - } else if(xpos >= pixels_[pixels_.length-1]) { - ind = pixels_.length-1; - } else { - for(int i=0; i < pixels_.length - 1; i++) { - if(xpos >= pixels_[i] && xpos < pixels_[i+1]) { - if(xpos - pixels_[i] < pixels_[i+1] - xpos) { - ind = i; - } else { - ind = i+1; - } - break; - } - } - } - value = values_[ind]; - xpos = pixels_[ind]; - } else { - value = (double)(xpos - rawRange_.start)/scale_; - } - - if(twoHandles_) { - int toMin = xpos - min_; - int toMax = xpos - max_; - if(toMin < 0) { - minValue_ = value; - } else if(toMax > 0) { - maxValue_ = value; - } else if(toMin < -toMax) { - minValue_ = value; - } else { - maxValue_ = value; - } - } else - minValue_ = value; - - if(forcePost || alwaysPost_) { - if(minOld_ != minValue_) { - Double tempOld = new Double(minOld_); - minOld_ = minValue_; - changes.firePropertyChange("minValue", tempOld, new Double(minValue_)); - } - if(maxOld_ != maxValue_) { - Double tempOld = new Double(maxOld_); - maxOld_ = maxValue_; - changes.firePropertyChange("maxValue", tempOld, new Double(maxValue_)); - } - } - paint(getGraphics()); - } - - class SymMouse extends MouseAdapter { - public void mouseReleased(MouseEvent event) { - Object object = event.getSource(); - if (object == JSlider2.this) - JSlider2_MouseRelease(event); - } - - public void mouseClicked(MouseEvent event) { - Object object = event.getSource(); - if (object == JSlider2.this) - JSlider2_MouseClick(event); - } - } - - void JSlider2_MouseClick(MouseEvent event) { - doMove(event.getX(), true); - } - - class MyComponent extends ComponentAdapter { - public void componentResized(ComponentEvent event) { - Object object = event.getSource(); - if(object == JSlider2.this) - JSlider2_resized(event); - } - } - - void JSlider2_resized(ComponentEvent event) { - doCompute(); - } - - class SymMouseMotion extends MouseMotionAdapter { - public void mouseDragged(MouseEvent event) { - Object object = event.getSource(); - if (object == JSlider2.this) - JSlider2_MouseDrag(event); - } - } - - void JSlider2_MouseDrag(MouseEvent event) { - doMove(event.getX(), false); - } - - - void JSlider2_MouseRelease(MouseEvent event) { - doMove(event.getX(), true); - } - - public static void main(String[] args) { - double[] values = {0.0, 0.1, 0.2, 0.3, 0.4, - 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}; - JFrame jf = new JFrame("JSlider2 Test"); - jf.setSize(400,100); - jf.getContentPane().setLayout(new BorderLayout()); - JSlider2 js2 = new JSlider2(); - // - // valid range of slider is 0-1 - // - js2.setDoubleBuffered(true); - js2.setMinValue(0.2); - js2.setMaxValue(0.8); - js2.setIndexValues(values); - js2.setMinLabel("-20 stuff"); - js2.setMaxLabel("20 stuff"); - jf.getContentPane().add(js2, BorderLayout.CENTER); - jf.setVisible(true); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSlider2Double.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSlider2Double.java deleted file mode 100755 index 1f8c73d7..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSlider2Double.java +++ /dev/null @@ -1,580 +0,0 @@ -/* - * $Id: JSlider2Double.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - */ - -package gov.noaa.pmel.swing; - -import javax.swing.*; -import java.awt.event.*; -import java.beans.*; -//import java.awt.Container; -import java.awt.Dimension; -import java.awt.GridBagLayout; -import java.awt.GridBagConstraints; -import java.awt.BorderLayout; -import java.awt.Insets; -import java.text.DecimalFormat; - -import gov.noaa.pmel.util.Range2D; - -/** - * Class provides graphical and textual input of a range. - * Minimum value are required to be less than or equal - * to the maximum value. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @see JSlider2 -**/ -public -//class JSlider2Double extends Container implements java.io.Serializable -class JSlider2Double extends JComponent implements java.io.Serializable -{ - boolean twoHandles_; - Range2D range_; - double minValue_, oldMinValue_; - double maxValue_, oldMaxValue_; - double scale_; - String format_ = ""; - DecimalFormat form_; - boolean indexed_ = false; - double[] values_; - double[] scaled_; -/** - * @link aggregationByValue - * @clientCardinality 1 - * @supplierCardinality 1 - */ - JSlider2 slider_; - JLabel minLabel_; - JTextField minField_; - JLabel maxLabel_; - JTextField maxField_; - JPanel panel_; - GridBagLayout layout_; - - private PropertyChangeSupport changes = new PropertyChangeSupport(this); - - /** - * Default constructor. The default creates two handles. - **/ - public JSlider2Double() { - this(true); - } - /** - * Constructs a one or two handled slider. - * - * @param twoHandles if true create two handles - */ - public JSlider2Double(boolean twoHandles) { - super(); - twoHandles_ = twoHandles; - - setLayout(new BorderLayout(0,0)); - panel_ = new JPanel(); - layout_ = new GridBagLayout(); - panel_.setLayout(layout_); - panel_.setBounds(12,12,384,156); - slider_ = new JSlider2(); - slider_.setBounds(5,20,374,49); - GridBagConstraints gbc; - gbc = new GridBagConstraints(); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.insets = new Insets(10,5,5,5); - layout_.setConstraints(slider_, gbc); - panel_.add(slider_); - minLabel_ = new JLabel("Minimum:",JLabel.RIGHT); - minLabel_.setBounds(6,79,68,23); - gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.NONE; - gbc.insets = new Insets(5,5,5,5); - layout_.setConstraints(minLabel_, gbc); - panel_.add(minLabel_); - minField_ = new JTextField(); - minField_.setBounds(80,79,299,23); - gbc = new GridBagConstraints(); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.insets = new Insets(5,0,5,5); - layout_.setConstraints(minField_, gbc); - panel_.add(minField_); - // second handle information - maxLabel_ = new JLabel("Maximum:",JLabel.RIGHT); - maxLabel_.setBounds(5,112,70,23); - maxField_ = new JTextField(); - maxField_.setBounds(80,112,299,23); - if(twoHandles_) { - gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.NONE; - gbc.insets = new Insets(5,5,10,5); - layout_.setConstraints(maxLabel_, gbc); - panel_.add(maxLabel_); - - gbc = new GridBagConstraints(); - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.insets = new Insets(5,0,10,5); - layout_.setConstraints(maxField_, gbc); - panel_.add(maxField_); - } else { - minLabel_.setText("Value:"); - } - add("Center", panel_); - - SymPropertyChange lSymPropertyChange = new SymPropertyChange(); - slider_.addPropertyChangeListener(lSymPropertyChange); - SymAction lSymAction = new SymAction(); - minField_.addActionListener(lSymAction); - maxField_.addActionListener(lSymAction); - - form_ = new DecimalFormat(format_); - - form_.setGroupingUsed(false); - range_ = new Range2D(0.0f, 1.0f); - setRange(range_); - - } - /** - * Set the range for the slider. The minimum value must be - * less than the maximum value. - * - * @param min minimum value - * @param max maximum value - **/ - public void setRange(double min, double max) { - setRange(new Range2D(min, max)); - } - /** - * Set the range for the slider. - * - * @param range slider total range - **/ - public void setRange(Range2D range) { - double min, max; - range_ = range; - scale_ = (double)(range_.end - range_.start); - slider_.setMinLabel(form_.format(range_.start)); - slider_.setMaxLabel(form_.format(range_.end)); - - minValue_ = range_.start; - oldMinValue_ = minValue_; - min = (minValue_ - range_.start)/scale_; - slider_.setMinValue(min); - minField_.setText(form_.format(minValue_)); - - maxValue_ = range_.end; - oldMaxValue_ = maxValue_; - max = (maxValue_ - range_.start)/scale_; - slider_.setMaxValue(max); - maxField_.setText(form_.format(maxValue_)); - - if(indexed_) { - for(int i=0; i < values_.length; i++) { - scaled_[i] = (values_[i] - range_.start)/scale_; - } - slider_.setIndexValues(scaled_); - } - } - /** - * Get the slider range. - * - * @return slider range - **/ - public Range2D getRange() { - return range_; - } - /** - * Set the minimum for the range. - * - * @param min minimum range value - */ - public void setMinRange(double min) { - range_.start = min; - setRange(range_); - } - /** - * Get the minimum for the range. - * - * @return minimum range value - */ - public double getMinRange() { - return (double)range_.start; - } - /** - * Set the maximum for the range. - * - * @param max maximum range value - */ - public void setMaxRange(double max) { - range_.end = max; - setRange(range_); - } - /** - * Get the maximum for the range. - * - * @return maximum range value - */ - public double getMaxRange() { - return (double)range_.end; - } - /** - * Reset the slider handles - **/ - public void reset() - { - slider_.reset(); - } - - public void setIndexValues(double[] array) { - values_ = array; - indexed_ = true; - scaled_ = new double[values_.length]; - setRange(range_); - } - /** - * Set the two handle mode. - * - * @param th if true set two handles - */ - public void setTwoHandles(boolean th) { - GridBagConstraints gbc; - twoHandles_ = th; - slider_.setTwoHandles(th); - if(twoHandles_) { - if(!panel_.isAncestorOf(maxLabel_)) { - gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.NONE; - gbc.insets = new Insets(5,5,10,5); - layout_.setConstraints(maxLabel_, gbc); - panel_.add(maxLabel_); - } - if(!panel_.isAncestorOf(maxField_)) { - gbc = new GridBagConstraints(); - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.insets = new Insets(5,0,10,5); - layout_.setConstraints(maxField_, gbc); - panel_.add(maxField_); - } - minLabel_.setText("Minimum:"); - panel_.invalidate(); - } else { - minLabel_.setText("Value:"); - if(panel_.isAncestorOf(maxLabel_)) panel_.remove(maxLabel_); - if(panel_.isAncestorOf(maxField_)) panel_.remove(maxField_); - panel_.invalidate(); - } - - slider_.setDoubleBuffered(true); - } - /** - * Get the two handle flag. - * - * @return true if two handles - */ - public boolean getTwoHandles() { - return twoHandles_; - } - /** - * Get the two handle flag. - * - * @return true if two handles - */ - public boolean isTwoHandles() { - return twoHandles_; - } - /** - * Set the format for the slider range label and display. - * - * @param frmt format in Format syntax - */ - public void setFormat(String frmt) { - format_ = frmt; - form_ = new DecimalFormat(format_); - form_.setGroupingUsed(false); - setRange(range_); - } - /** - * Get the format for the slider range label. - * - * @return the format in Format syntax - */ - public String getFormat() { - return format_; - } - public double getStartValue() { - if(range_.start > range_.end) { - minValue_ = - Math.min((Double.valueOf(minField_.getText())).doubleValue(), - range_.start); - } else { - minValue_ = - Math.max((Double.valueOf(minField_.getText())).doubleValue(), - range_.start); - } - return minValue_; - } - public double getEndValue() { - if(range_.start > range_.end) { - maxValue_ = - Math.max((Double.valueOf(maxField_.getText())).doubleValue(), - range_.end); - } else { - maxValue_ = - Math.min((Double.valueOf(maxField_.getText())).doubleValue(), - range_.end); - } - return maxValue_; - } - public void setStartValue(double min) { - if(range_.start > range_.end) { - minValue_ = Math.min(min, range_.start); - } else { - minValue_ = Math.max(min, range_.start); - } - min = (minValue_ - range_.start)/scale_; - slider_.setMinValue(min); - } - public void setEndValue(double max) { - if(range_.start > range_.end) { - maxValue_ = Math.max(max, range_.end); - } else { - maxValue_ = Math.min(max, range_.end); - } - max = (maxValue_ - range_.start)/scale_; - slider_.setMaxValue(max); - } - /** - * Get the minimum handle value. - * - * @return minimum handle value. - **/ - public double getMinValue() { - minValue_ = Math.max((Double.valueOf(minField_.getText())).doubleValue(), range_.start); - minValue_ = Math.min(minValue_, maxValue_); - return minValue_; - } - /** - * Set the minimum handle value. - * - * @param min minimum handle value. - **/ - public void setMinValue(double min) { - minValue_ = min; - minValue_ = Math.min(minValue_, maxValue_); - min = (minValue_ - range_.start)/scale_; - slider_.setMinValue(min); - } - /** - * Get the maximum handle value. - * - * @return maximum handle value - **/ - public double getMaxValue() { - maxValue_ = Math.min((Double.valueOf(maxField_.getText())).doubleValue(), range_.end); - maxValue_ = Math.max(maxValue_, minValue_); - return maxValue_; - } - /** - * Set the maximum handle value. - * - * @param max maximum handle value - **/ - public void setMaxValue(double max) { - maxValue_ = max; - maxValue_ = Math.max(maxValue_, minValue_); - max = (maxValue_ - range_.start)/scale_; - slider_.setMaxValue(max); - } - /** - * Show a border around the slider. - * - * @param sb if true show the border - */ - public void setShowBorder(boolean sb) { - slider_.setShowBorder(sb); - } - /** - * Get border status for the slider. - * - * @return true if border is showing - */ - public boolean getShowBorder() { - return slider_.getShowBorder(); - } - /** - * Set the handle size for the slider. - * - * @param sz handle size in pixels - */ - public void setHandleSize(int sz) { - slider_.setHandleSize(sz); - } - /** - * Get the current slider handle size. - * - * @return handle size in pixels - */ - public int getHandleSize() { - return slider_.getHandleSize(); - } - /** - * Set the always post flag for the slider. If true any motion of the - * slider will fire a property change, if false a property change is - * only caused when the mouse button is released. - * - * @param ap if true always post - */ - public void setAlwaysPost(boolean ap) { - slider_.setAlwaysPost(ap); - } - /** - * Get the always post flag for the slider. - * - * @return true if the slider will always post - */ - public boolean getAlwaysPost() { - return slider_.getAlwaysPost(); - } - /** - * Add a property change listener. The properties that fire a property - * change are "minValue" and "maxValue". The old and new Double objects - * values are set. - * - * @param l property change listener - */ - public void addPropertyChangeListener(PropertyChangeListener l) { - changes.addPropertyChangeListener(l); - } - /** - * Remove a property change listener. - * - * @param l property change listener - */ - public void removePropertyChangeListener(PropertyChangeListener l) { - changes.removePropertyChangeListener(l); - } - class SymPropertyChange implements java.beans.PropertyChangeListener - { - public void propertyChange(java.beans.PropertyChangeEvent event) - { - Object object = event.getSource(); - if (object == slider_) - slider_propertyChange(event); - } - } - - public Dimension getMinimumSize() { - int hgt; - if(twoHandles_) - hgt = 135; - else - hgt = 105; - return new Dimension(180,hgt); - } - - public Dimension getPreferredSize() { - int hgt; - if(twoHandles_) - hgt = 135; - else - hgt = 105; - return new Dimension(384,hgt); - } - - public boolean isIndexed() { - return indexed_; - } - - public void setIndexed(boolean ind) { - indexed_ = ind; - } - - public void setSize(Dimension dim) { - super.setSize(dim); - validate(); - } - public void setSize(int w, int h) { - super.setSize(w, h); - validate(); - } - - public Dimension getMaximumSize() { - return new Dimension(Short.MAX_VALUE,Short.MAX_VALUE); - } - - void slider_propertyChange(java.beans.PropertyChangeEvent event) - { - if(event.getPropertyName().equals("minValue")) { - minValue_ = range_.start + slider_.getMinValue()*scale_; - minField_.setText(form_.format(minValue_)); - testMin(); - } else if(event.getPropertyName().equals("maxValue")) { - maxValue_ = range_.start + slider_.getMaxValue()*scale_; - maxField_.setText(form_.format(maxValue_)); - testMax(); - } - } - - class SymAction implements java.awt.event.ActionListener - { - public void actionPerformed(java.awt.event.ActionEvent event) - { - Object object = event.getSource(); - if (object == minField_) - minField_EnterHit(event); - else if (object == maxField_) - maxField_EnterHit(event); - } - } - - void minField_EnterHit(java.awt.event.ActionEvent event) { - double min; - minValue_ = Math.max((Double.valueOf(minField_.getText())).doubleValue(), range_.start); - minValue_ = Math.min(minValue_, maxValue_); - min = (minValue_ - range_.start)/scale_; - slider_.setMinValue(min); - } - void maxField_EnterHit(java.awt.event.ActionEvent event) { - double max; - maxValue_ = Math.min((Double.valueOf(maxField_.getText())).doubleValue(), range_.end); - maxValue_ = Math.max(maxValue_, minValue_); - max = (maxValue_ - range_.start)/scale_; - slider_.setMaxValue(max); - } - - void testMax() { - if(oldMaxValue_ != maxValue_) { - Double tempOldValue = new Double(oldMaxValue_); - oldMaxValue_ = maxValue_; - changes.firePropertyChange("maxValue", tempOldValue, new Double(maxValue_)); - } - } - void testMin() { - if(oldMinValue_ != minValue_) { - Double tempOldValue = new Double(oldMinValue_); - oldMinValue_ = minValue_; - changes.firePropertyChange("minValue", tempOldValue, new Double(minValue_)); - } - } - - public static void main(String[] args) { - double[] values = {-20.0, -10.0, -5.0, -2.5, 0., 2.5, 5.0, 10., 15., 20.0}; - JFrame jf = new JFrame("JSlider2Double Test"); - jf.setSize(400,200); - jf.getContentPane().setLayout(new BorderLayout()); - JSlider2Double js2db = new JSlider2Double(); - // - js2db.setRange(new Range2D(-20.0, 20.0)); - js2db.setStartValue(-10.0); - js2db.setEndValue(15.0); - js2db.setIndexValues(values); - js2db.setAlwaysPost(true); - jf.getContentPane().add(js2db, BorderLayout.CENTER); - jf.setVisible(true); - } - -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSystemPropertiesDialog.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSystemPropertiesDialog.java deleted file mode 100755 index db61c0af..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/JSystemPropertiesDialog.java +++ /dev/null @@ -1,205 +0,0 @@ -/* -* $Id: JSystemPropertiesDialog.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - */ -package gov.noaa.pmel.swing; - -import java.awt.*; -import javax.swing.*; -import javax.swing.table.TableColumn; -import java.util.Enumeration; -import java.util.Properties; -import java.util.Vector; - -/** - * Displays the system properties in a scrolling JTable. The - * properties that consist of multiple parts, e.g. CLASSPATH, are - * displayed one component per line. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @see javax.swing.JTable - * @see java.lang.System#getProperties() - **/ -public class JSystemPropertiesDialog extends javax.swing.JDialog { - private JTable propTable; - - public JSystemPropertiesDialog(String sTitle) { - this((Frame) null, sTitle, false); - } - - public JSystemPropertiesDialog() { - this((Frame)null, (String) null, false); - } - - public JSystemPropertiesDialog(Frame frame, String title) { - this(frame, title, false); - } - - public JSystemPropertiesDialog(Frame parent, String title, boolean modal) { - super(parent, title, modal); - - if(title == null) { - setTitle("System Properties"); - } - createTable(); - getContentPane().setLayout(new BorderLayout(0,0)); - getContentPane().setBackground(new Color(200, 200, 200)); - setSize(556,305); - setVisible(false); - displayPanel.setLayout(new GridBagLayout()); - getContentPane().add(BorderLayout.CENTER,displayPanel); - displayPanel.setBounds(0, 0, 556, 270); - JScrollPane1.setOpaque(true); - JScrollPane1.setBackground(new Color(200, 200, 200)); - - GridBagConstraints gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.anchor = GridBagConstraints.CENTER; - gbc.fill = GridBagConstraints.BOTH; - gbc.insets = new java.awt.Insets(5,5,5,5); - gbc.ipadx = 0; - gbc.ipady = 0; - displayPanel.add(JScrollPane1, gbc ); - - JScrollPane1.setBounds(5,5,546,260); - JScrollPane1.getViewport().add(propTable); - propTable.setBounds(0,0,543,0); - buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); - getContentPane().add(BorderLayout.SOUTH,buttonPanel); - buttonPanel.setBounds(0,270,556,35); - OKButton.setText("OK"); - OKButton.setActionCommand("OK"); - buttonPanel.add(OKButton); - OKButton.setBounds(252,5,51,25); - - SymAction lSymAction = new SymAction(); - OKButton.addActionListener(lSymAction); - - } - - void createTable() { - Properties prop = System.getProperties(); - // - int size = prop.size() + 50; - Vector names = new Vector(size); - Vector values = new Vector(size); - // - // sniff out the version of sgt! - // - String ver = null; - try { - Class cls = Class.forName("gov.noaa.pmel.sgt.JPane"); - java.lang.reflect.Method meth = cls.getMethod("getVersion", null); - ver = (String)meth.invoke(null, null); - } catch (Exception e) { - } finally { - names.add("gov.noaa.pmel.sgt.version"); - values.add(ver); - } - // - String separator = prop.getProperty("path.separator", ";"); - int row=0; - Enumeration e = prop.propertyNames(); - while(e.hasMoreElements()) { - String name = (String)e.nextElement(); - String value = prop.getProperty(name); - int len = value.length(); - if(value.indexOf(separator) != -1 && !name.equals("path.separator")) { - int lastIndex = 0; - int count = 1; - int ind; - int[] indicies = new int[200]; - indicies[0] = 0; - while((ind = value.indexOf(separator, lastIndex)) != -1) { - indicies[count] = ind + 1; - lastIndex = ind + 1; - count++; - } - indicies[count] = len; - for(int i=1; i <= count; i++) { - names.addElement(name + "[" + i + "]"); - values.addElement(value.substring(indicies[i-1], indicies[i])); - row++; - } - } else { - names.addElement(name); - values.addElement(value); - row++; - } - } - Enumeration enames = names.elements(); - Enumeration evalues = values.elements(); - String[][] data = new String[names.size()][2]; - for(int i=0; i < names.size(); i++) { - data[i][0] = (String)enames.nextElement(); - data[i][1] = (String)evalues.nextElement(); - } - propTable = new JTable(data, new String[] {"Property", "Value"}); - propTable.setSize(1000,1000); - TableColumn tc; - tc = propTable.getColumnModel().getColumn(0); - tc.setPreferredWidth(100); - tc = propTable.getColumnModel().getColumn(1); - tc.setPreferredWidth(300); - } - - - public void setVisible(boolean b) { - if (b) { - setLocation(50, 50); - // init(); - } - super.setVisible(b); - } - - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension size = getSize(); - - super.addNotify(); - - if (frameSizeAdjusted) - return; - frameSizeAdjusted = true; - - // Adjust size of frame according to the insets - Insets insets = getInsets(); - setSize(insets.left + insets.right + size.width, - insets.top + insets.bottom + size.height); - } - - // Used by addNotify - boolean frameSizeAdjusted = false; - - javax.swing.JPanel displayPanel = new javax.swing.JPanel(); - javax.swing.JScrollPane JScrollPane1 = new javax.swing.JScrollPane(); - javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); - javax.swing.JButton OKButton = new javax.swing.JButton(); - - class SymAction implements java.awt.event.ActionListener { - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == OKButton) - OKButton_actionPerformed(event); - } - } - - void OKButton_actionPerformed(java.awt.event.ActionEvent event) { - try { - // JSystemPropertiesDialog Hide the JSystemPropertiesDialog - this.setVisible(false); - } catch (java.lang.Exception e) { - } - } - - public static void main(String[] args) { - JSystemPropertiesDialog js = new JSystemPropertiesDialog(); - js.setTitle("Test System Properties Dialog"); - js.setVisible(true); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/MRJUtil.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/MRJUtil.java deleted file mode 100755 index 7f7f01cd..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/MRJUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * $Id: MRJUtil.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.swing; - -import javax.swing.UIManager; - -/** - * Uility methods for dealing with Aqua interfaces - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 3.0 - **/ -public class MRJUtil { - - public MRJUtil() { - } -/** - * MacOS Look and feel test - * @return true if using Aqua Look n' Feel - */ - public static boolean isAquaLookAndFeel() { - return System.getProperty("mrj.version") != null && - UIManager.getSystemLookAndFeelClassName().equals(UIManager.getLookAndFeel().getClass().getName()); - } - /** - * MacOS Java version test - */ - public static boolean fixFontMetrics() { - String rtVer = System.getProperty("java.runtime.version"); - return System.getProperty("mrj.version") != null && - (rtVer.equals("1.4.1_01-39") || rtVer.equals("1.4.1_01-69.1")); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/ThreeDotsButton.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/ThreeDotsButton.java deleted file mode 100755 index ae2d22a8..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/ThreeDotsButton.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * $Id: ThreeDotsButton.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.swing; - -import javax.swing.JButton; -import java.awt.Color; -import java.awt.Insets; - -/** - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since SGT 3.0 - **/ -public class ThreeDotsButton extends JButton { - private static ThreeDotsIcon dotsIcon_ = new ThreeDotsIcon(Color.black); - - public ThreeDotsButton() { - super(); - setIcon(dotsIcon_); - if(!MRJUtil.isAquaLookAndFeel()) { - setMargin(new Insets(0, 0, 0, 0)); - } - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/ThreeDotsIcon.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/ThreeDotsIcon.java deleted file mode 100755 index ba1a4eb2..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/ThreeDotsIcon.java +++ /dev/null @@ -1,79 +0,0 @@ -package gov.noaa.pmel.swing; - -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Color; -import javax.swing.Icon; - -/** - * Creates icon of three dots to be used with a JButton - * to open a dialog. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $ - * @since 3.0 - */ - -public class ThreeDotsIcon implements Icon { - private Color color_; - private int size_; - private int space_; - private int dot_; - private int y_; - - public ThreeDotsIcon() { - this(Color.black, 14); - } - - public ThreeDotsIcon(Color color) { - this(color, 14); - } - - public ThreeDotsIcon(Color color, int size) { - color_ = color; - if(size <= 14) { - dot_ = 2; - space_ = 2; - size_ = 14; - } else if(size > 14 && size <= 17) { - dot_ = 3; - space_ = 2; - size_ = 17; - } else if(size > 17 && size <= 20) { - dot_ = 4; - space_ = 2; - size_ = 20; - } else { - size_ = size; - dot_ = size_/5; - space_ = dot_/2; - if(space_ <= 1) space_ = 2; - dot_ = (size_ - 4*space_)/3; - } - y_ = (size_ - dot_)/2; - } - - public void paintIcon(Component c, Graphics g, int x, int y) { - int xt, yt; - Color save = g.getColor(); - g.setColor(color_); - - xt = x + space_; - yt = y + y_; - g.fillOval(xt, yt, dot_, dot_); - xt = xt + space_ + dot_; - g.fillOval(xt, yt, dot_, dot_); - xt = xt + space_ + dot_; - g.fillOval(xt, yt, dot_, dot_); - - g.setColor(save); - } - - public int getIconWidth() { - return size_; - } - - public int getIconHeight() { - return size_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/beans/SliderHandle.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/beans/SliderHandle.java deleted file mode 100755 index ac6eccab..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/beans/SliderHandle.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * $Id: SliderHandle.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - */ - -package gov.noaa.pmel.swing.beans; - -import java.awt.Color; -import java.awt.Graphics; - -/** - * Description of Class SliderHandle - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ -**/ -public class SliderHandle implements java.io.Serializable { - static public int LEFT = 0; - static public int RIGHT = 1; - static public int SINGLE = 2; - Color color_; - int size_; - int posx_; - int posy_; - int style_ = SINGLE; - int[] xpts = new int[9]; - int[] ypts = new int[9]; - /** - * Default constructor - **/ - public SliderHandle() { - this(6, Color.red, SINGLE); - } - public SliderHandle(int size, Color color) { - this(size, color, SINGLE); - } - /** - * SliderHandle constructor. - * - * @param xpos horizontal position of handle - * @param ypos vertical position of handle - * @param size size of handle in pixels - * @param color handle color - **/ - public SliderHandle(int size, Color color, int style) { - size_ = size; - color_ = color; - style_ = style; - } - /** - * Get the size of the handle in pixels; - * - * @return handle size - **/ - public int getSize() { - return size_; - } - /** - * Set the size of the handle (in pixels). - * - * @param sz handle size in pixels - **/ - public void setSize(int sz) { - size_ = sz; - } - public void setStyle(int st) { - style_ = st; - } - public int getStyle() { - return style_; - } - /** - * Get the color of the handle - * - * @return the handle color - **/ - public Color getColor() { - return color_; - } - /** - * Set the handle color - * - * @param clr handle color - **/ - public void setColor(Color clr) { - color_ = clr; - } - /** - * Get the current handle position - * - * @return current handle position - **/ - public int getPosition() { - return posx_; - } - public void draw(Graphics g, int posx, int posy) { - g.setColor(color_); - - posx_ = posx; - posy_ = posy; - - int pt = 0; - if(style_ == SINGLE || style_ == LEFT) { - xpts[0] = posx_; - ypts[0] = posy_; - xpts[1] = posx_ - size_; - ypts[1] = posy_ + size_; - xpts[2] = xpts[1]; - ypts[2] = ypts[1] + size_; - xpts[3] = xpts[0]; - ypts[3] = ypts[2]; - xpts[4] = xpts[0]; - ypts[4] = ypts[0]; - pt = 5; - } - if(style_ == SINGLE || style_ == RIGHT) { - if(pt == 0) { - xpts[pt] = posx_; - ypts[pt] = posy_; - pt++; - } else { - pt = 4; - } - xpts[pt] = posx_; - ypts[pt] = posy_ + 2*size_; - xpts[pt+1] = posx_ + size_; - ypts[pt+1] = ypts[pt]; - xpts[pt+2] = xpts[pt+1]; - ypts[pt+2] = posy_ + size_; - xpts[pt+3] = posx_; - ypts[pt+3] = posy_; - pt = pt + 4; - } - - /* xpts[0] = posx_; - ypts[0] = posy_; - xpts[1] = posx_ - size_; - ypts[1] = posy_ + 2*size_; - xpts[2] = posx_ + size_; - ypts[2] = ypts[1]; - xpts[3] = xpts[0]; - ypts[3] = ypts[0]; */ - - g.fillPolygon(xpts, ypts, pt); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/package.html deleted file mode 100755 index f34bc46d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/swing/package.html +++ /dev/null @@ -1,10 +0,0 @@ - - -Classes and beans developed from the javax.swing package. - -

This package contains both gui classes that begin with a "J") -and non-visual support classes.

- - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/text/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/text/package.html deleted file mode 100755 index 3cc47829..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/text/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Provides classes and interfaces for handling text, dates, numbers, and messages. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ColorMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ColorMap.java deleted file mode 100755 index 7542941c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ColorMap.java +++ /dev/null @@ -1,85 +0,0 @@ -package gov.noaa.pmel.util; - -import java.util.*; -import java.awt.*; -import gov.noaa.pmel.sgt.Transform; - -public class ColorMap { - protected String mParamName; - Vector mPieceRanges = new Vector(); // stores the physical ranges (Range2D) for each of the pieces of the colormap - Vector mRedTransforms = new Vector(); // stores the transforms from physical to user coords for the red component - Vector mGreenTransforms = new Vector(); // stores the transforms from physical to user coords for the green component - Vector mBlueTransforms = new Vector(); // stores the transforms from physical to user coords for blue component - - public ColorMap() { - // zero argument ctor - } - - public ColorMap(ColorMap inMap) { - // copy constructor - - } - - // public methods - public Color getColor(double inVal) { - // find the appropriate transform by testing what Range2D it's in - int foundPiece = -99; - int numPieces = mPieceRanges.size(); - - // first test whether it's out of range - double sVal =((Range2D)mPieceRanges.elementAt(0)).start; - double eVal =((Range2D)mPieceRanges.elementAt(numPieces - 1)).end; - if (inVal <= sVal) { - float red = (float)(((Transform)mRedTransforms.elementAt(0)).getTransU(sVal)); - float green = (float)(((Transform)mGreenTransforms.elementAt(0)).getTransU(sVal)); - float blue = (float)(((Transform)mBlueTransforms.elementAt(0)).getTransU(sVal)); - return new Color(red, green, blue); - } - else if (inVal >= eVal) { - float red = (float)(((Transform)mRedTransforms.elementAt(numPieces - 1)).getTransU(eVal)); - float green = (float)(((Transform)mGreenTransforms.elementAt(numPieces - 1)).getTransU(eVal)); - float blue = (float)(((Transform)mBlueTransforms.elementAt(numPieces - 1)).getTransU(eVal)); - System.out.println(red + " " + green + " " + blue); - return new Color(red, green, blue); - } - - // value is in range - for (int i=0; i= sVal && inVal <= eVal) { - foundPiece = i; - break; - } - } - float red = (float)(((Transform)mRedTransforms.elementAt(foundPiece)).getTransU(eVal)); - float green = (float)(((Transform)mGreenTransforms.elementAt(foundPiece)).getTransU(eVal)); - float blue = (float)(((Transform)mBlueTransforms.elementAt(foundPiece)).getTransU(eVal)); - return new Color(red, green, blue); - } - - public void addTransform(Transform inTransRed, Transform inTransGreen, Transform inTransBlue) { - mRedTransforms.addElement(inTransRed); - mGreenTransforms.addElement(inTransGreen); - mBlueTransforms.addElement(inTransBlue); - mPieceRanges.addElement(inTransRed.getRangeP()); - } - - public IndexedColorMap getIndexedColorMap(int numColors) { - return new IndexedColorMap(this, numColors); - } - - public String getParamName() { - return mParamName; - } - - public double getMaxValue() { - return ((Range2D)mPieceRanges.elementAt(mPieceRanges.size()-1)).end; - } - - public double getMinValue() { - return ((Range2D)mPieceRanges.elementAt(0)).start; - - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ColorTransform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ColorTransform.java deleted file mode 100755 index d5379be0..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ColorTransform.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * $Id: ColorTransform.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.beans.PropertyChangeListener; -import gov.noaa.pmel.util.Range2D; -import java.awt.*; -import gov.noaa.pmel.sgt.TransformColor; -import gov.noaa.pmel.sgt.Transform; - -/** - * Transform defines an interface for transformations between - * user and physical coordinates. - * - * @see AxisTransform - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 1.0 - */ -public class ColorTransform implements TransformColor { - Transform mRedTransform; - Transform mGreenTransform; - Transform mBlueTransform;; - - public ColorTransform() { - } - - public ColorTransform(Transform redTransform, Transform greenTransform, Transform blueTransform) { - mRedTransform = redTransform; - mGreenTransform = greenTransform; - mBlueTransform = blueTransform; - } - - public Transform getRedTransform() { - return mRedTransform; - } - - public void setRedTransform(Transform redTransform) { - mRedTransform = redTransform; - } - - public Transform getGreenTransform() { - return mGreenTransform; - } - - public void setGreenTransform(Transform greenTransform) { - mGreenTransform = greenTransform; - } - - public Transform getBlueTransform() { - return mBlueTransform; - } - - public void setBlueTransform(Transform blueTransform) { - mBlueTransform = blueTransform; - } - - public void setColorTransforms(Transform red, Transform green, Transform blue) { - mRedTransform = red; - mGreenTransform = green; - mBlueTransform = blue; - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Debug.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Debug.java deleted file mode 100755 index 6afac105..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Debug.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * $Id: Debug.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - */ - -package gov.noaa.pmel.util -; -/** - * For debugging only - */ -public class Debug { - public static final boolean DEBUG = false; - public static final boolean DRAW_TRACE = false; - public static final boolean TAXIS = false; - /** - * Write debug statements related to internal sgt - * events. - */ - public static final boolean EVENT = false; - /** - * Debug for contouring - */ - public static final boolean CONTOUR = false; -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Dimension2D.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Dimension2D.java deleted file mode 100755 index c6157135..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Dimension2D.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * $Id: Dimension2D.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -/** - * A class to encapsulate a double width and a height. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 1.0 - */ -public class Dimension2D { - public double height; - public double width; - public Dimension2D() { - width = 0.0; - height = 0.0; -} - public Dimension2D(double width, double height) { - this.width = width; - this.height = height; - } - /** - * Returns the width. - * - * @return the width - */ - public double getWidth() { - return width; - } - - /** - * Returns the height. - * - * @return the height - */ - public double getHeight() { - return height; - } - - /** - * Set the size to the specified width - * and height. - * This method is included for completeness, to parallel the - * getSize method of Component. - * @param width the new width - * @param height the new height - */ - public void setSize(double width, double height) { - this.width = width; - this.height = height; - } - - /** - * Set the size to match the specified size. - * This method is included for completeness, to parallel the - * getSize method of Component. - * @param d the new size - */ - public void setSize(Dimension2D d) { - setSize(d.getWidth(), d.getHeight()); - } - /** - * - */ - public String toString() { - return getClass().getName() + "[width=" + width + ",height=" + height + -"]"; - } - /** - * Test for equality. Both width and height must be equal to be - * true. - */ - public boolean equals(Dimension2D d) { - return (width == d.width && height == d.height); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Domain.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Domain.java deleted file mode 100755 index 1f81e18a..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Domain.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * $Id: Domain.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.util; - -/** - * GraphDomain contains the X and Y ranges in user units. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 2.0 - */ -public class Domain implements java.io.Serializable { - Range2D xRange_ = null; - Range2D yRange_ = null; - TimeRange tRange_ = null; - boolean xTime_ = false; - boolean yTime_ = false; - boolean xReversed_ = false; - boolean yReversed_ = false; - /** - * Default constructor. - */ - public Domain() { - } - /** - * Create a copy of a Domain. The references for the - * ranges are copied, not the objects. - */ - public Domain(Domain domain) { - if(domain.isXTime()) { - tRange_ = domain.getTimeRange(); - } else { - xRange_ = domain.getXRange(); - } - if(domain.isYTime()) { - tRange_ = domain.getTimeRange(); - } else { - yRange_ = domain.getYRange(); - } - xReversed_ = domain.isXReversed(); - yReversed_ = domain.isYReversed(); - } - public Domain(Range2D xRange, Range2D yRange) { - xRange_ = xRange; - yRange_ = yRange; - } - public Domain(TimeRange tRange, Range2D yRange) { - tRange_ = tRange; - yRange_ = yRange; - xTime_ = true; - } - public Domain(Range2D xRange, TimeRange tRange) { - xRange_ = xRange; - tRange_ = tRange; - yTime_ = true; - } - /** - * @since sgt 3.0 - */ - public Domain(Range2D xRange, Range2D yRange, - boolean xRev, boolean yRev) { - xRange_ = xRange; - yRange_ = yRange; - xReversed_ = xRev; - yReversed_ = yRev; - } - /** - * @since sgt 3.0 - */ - public Domain(TimeRange tRange, Range2D yRange, - boolean xRev, boolean yRev) { - tRange_ = tRange; - yRange_ = yRange; - xTime_ = true; - xReversed_ = xRev; - yReversed_ = yRev; - } - /** - * @since sgt 3.0 - */ - public Domain(Range2D xRange, TimeRange tRange, - boolean xRev, boolean yRev) { - xRange_ = xRange; - tRange_ = tRange; - yTime_ = true; - xReversed_ = xRev; - yReversed_ = yRev; - } - /** - * Set the x range. - */ - public void setXRange(Range2D xRange) { - xTime_ = false; - xRange_ = xRange; - } - /** - * Set the x range as time. - */ - public void setXRange(TimeRange tRange) { - xTime_ = true; - tRange_ = tRange; - } - /** - * Get the x range. - */ - public Range2D getXRange() { - return xRange_; - } - /** - * Set the y range - */ - public void setYRange(Range2D yRange) { - yTime_ = false; - yRange_ = yRange; - } - /** - * Set the yrange as time. - */ - public void setYRange(TimeRange tRange) { - yTime_ = true; - tRange_ = tRange; - } - /** - * Get the y range. - */ - public Range2D getYRange() { - return yRange_; - } - /** - * Get the time range - */ - public TimeRange getTimeRange() { - return tRange_; - } - /** - * Test if x range is time. - */ - public boolean isXTime() { - return xTime_; - } - /** - * Test if y range is time. - */ - public boolean isYTime() { - return yTime_; - } - /** - * @since sgt 3.0 - */ - public void setYReversed(boolean rev) { - yReversed_ = rev; - } - /** - * @since sgt 3.0 - */ - public boolean isYReversed() { - return yReversed_; - } - /** - * @since sgt 3.0 - */ - public void setXReversed(boolean rev) { - xReversed_ = rev; - } - /** - * @since sgt 3.0 - */ - public boolean isXReversed() { - return xReversed_; - } - - /** - * Tests for equality of Domains. Both ranges must be - * equal. - */ - public boolean equals(Domain d) { - if(xTime_) { - if(!d.isXTime()) return false; - if(!tRange_.equals(d.getTimeRange())) return false; - } else { - if(d.isXTime()) return false; - if(!xRange_.equals(d.getXRange())) return false; - } - if(yTime_) { - if(!d.isYTime()) return false; - if(!tRange_.equals(d.getTimeRange())) return false; - } else { - if(d.isYTime()) return false; - if(!yRange_.equals(d.getYRange())) return false; - } - if(xReversed_ != d.isXReversed()) return false; - if(yReversed_ != d.isYReversed()) return false; - return true; - } - public String toString() { - StringBuffer buf = new StringBuffer(100); - buf.append("x="); - if(xTime_) { - buf.append(tRange_).append(",y="); - } else { - buf.append(xRange_).append(",y="); - } - if(yTime_) { - buf.append(tRange_); - } else { - buf.append(yRange_); - } - buf.append(", xRev=").append(xReversed_); - buf.append(", yRev=").append(yReversed_); - return buf.toString(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/EPICSystem.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/EPICSystem.java deleted file mode 100755 index 36925798..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/EPICSystem.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id: EPICSystem.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.util.StringTokenizer; - -/** - * Uility methods for accessing Java System information. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since 3.0 - **/ -public class EPICSystem { - - public EPICSystem() { - } - - /** - * Get the major java version. If 1.4.2, returns 1. - * @return java version - */ - static public int getJavaMajorVersion() { - StringTokenizer st = new StringTokenizer(System.getProperty("java.version"), - ".", false); - return Integer.parseInt(st.nextToken()); - } - /** - * Get the minor java version. If 1.4.2, returns 2. - * @return java minor version - */ - static public int getJavaMinorVersion() { - StringTokenizer st = new StringTokenizer(System.getProperty("java.version"), - ".", false); - st.nextToken(); - return Integer.parseInt(st.nextToken()); - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ExponentialTransformDown.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ExponentialTransformDown.java deleted file mode 100755 index a70018f8..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ExponentialTransformDown.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * $Id: ExponentialTransformDown.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.beans.PropertyChangeListener; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.sgt.Transform; - -/** - * ExponentialTransformUp defines a exponential transformations between - * user and physical coordinates defined between two end points. - * - * @see AxisTransform - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - */ -public class ExponentialTransformDown implements Transform { - Range2D mPhysRange = null; - Range2D mUserRange = null; - //double a = 0.46487; - //double b = 1.7563; - //double c = -2.8931; - //double d = 2.6001; - - double a = 0.82605; - double b = -2.3006; - double c = 2.4729; - - public ExponentialTransformDown(double p1, double p2, double u1, double u2) { - setRangeP(p1, p2); - setRangeU(u1, u2); - } - - public ExponentialTransformDown(Range2D prange, Range2D urange) { - setRangeP(prange); - setRangeU(urange); - } - - public ExponentialTransformDown() { - } - - /** - * Set physical coordinate range. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @see LinearTransform - **/ - public void setRangeP(double p1,double p2) { - mPhysRange = new Range2D(p1, p2); - } - - /** - * Set physical coordinate range. - * - * @param prange physcial coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeP(Range2D prange) { - mPhysRange = null; - mPhysRange = new Range2D(); - mPhysRange.add(prange); - } - - /** - * Get the physical coordinate range. - * - * @return physcial coordinate range - * @see Range2D - **/ - public Range2D getRangeP() { - return mPhysRange; - } - - /** - * Set the user coordinate range for double values. - * - * @param u1 minimum value, user coordinates - * @param u2 maximum value, user coordinates - * @see LinearTransform - **/ - public void setRangeU(double u1,double u2) { - mUserRange = new Range2D(u1, u2); - } - - /** - * Set the user coordinate range for double values. - * - * @param urange user coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeU(Range2D urange) { - mUserRange = null; - mUserRange = new Range2D(); - mUserRange.add(urange); - } - - /** - * Get the user coordinate range for double values. - * - * @return user range - * @see Range2D - **/ - public Range2D getRangeU() { - return mUserRange; - } - - /** - * Transform from user to physical coordinates. - * - * @param u user value - * @return physical value - */ - public double getTransP(double u) { - double retVal = 0.0; - // first have to find u in the normalized range of the y axis - double y = (u - mUserRange.start)/(mUserRange.end - mUserRange.start); - - // now iterate to find solution - double x = 0.5; - double inc = 0.0001; - double eps = 0.001; - int cnt = 0; - while (true) { - //double tstVal = d * x + c * (x * x) + b * (x * x * x) + a * (x * x * x * x); - double tstVal = c * x + b * (x * x) + a * (x * x * x); - if (Math.abs(tstVal - y) < eps) { - retVal = x; - break; - } - else { - if (tstVal > y) - x -= inc; - else - x += inc; - } - cnt++; - } - //System.out.println("iter count = " + cnt); - - // scale the x value back to the unnormalized range - retVal = mPhysRange.start + x * (mPhysRange.end - mPhysRange.start); - return retVal; - } - - /** - * Transform from physical to user coordinates. - * - * @param p physical value - * @return user value - */ - public double getTransU(double p) { - double retVal = 0.0; - double x = (p - mPhysRange.start)/(mPhysRange.end - mPhysRange.start); - //double y = d * x + c * (x * x) + b * (x * x * x) + a * (x * x * x * x); - double y = c * x + b * (x * x) + a * (x * x * x); - retVal = mUserRange.start + y * (mUserRange.end - mUserRange.start); - return retVal; - } - - /** - * Add listener for changes to transform properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ExponentialTransformUp.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ExponentialTransformUp.java deleted file mode 100755 index 590f6737..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/ExponentialTransformUp.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * $Id: ExponentialTransformUp.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.beans.PropertyChangeListener; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.sgt.Transform; - -/** - * ExponentialTransformUp defines a exponential transformations between - * user and physical coordinates defined between two end points. - * - * @see AxisTransform - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - */ -public class ExponentialTransformUp implements Transform { - Range2D mPhysRange = null; - Range2D mUserRange = null; - double a = 0.82809; - double b = -0.17839; - double c = 0.349; - - public ExponentialTransformUp(double p1, double p2, double u1, double u2) { - setRangeP(p1, p2); - setRangeU(u1, u2); - } - - public ExponentialTransformUp(Range2D prange, Range2D urange) { - setRangeP(prange); - setRangeU(urange); - } - - public ExponentialTransformUp() { - } - - /** - * Set physical coordinate range. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @see LinearTransform - **/ - public void setRangeP(double p1,double p2) { - mPhysRange = new Range2D(p1, p2); - } - - /** - * Set physical coordinate range. - * - * @param prange physcial coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeP(Range2D prange) { - mPhysRange = null; - mPhysRange = new Range2D(); - mPhysRange.add(prange); - } - - /** - * Get the physical coordinate range. - * - * @return physcial coordinate range - * @see Range2D - **/ - public Range2D getRangeP() { - return mPhysRange; - } - - /** - * Set the user coordinate range for double values. - * - * @param u1 minimum value, user coordinates - * @param u2 maximum value, user coordinates - * @see LinearTransform - **/ - public void setRangeU(double u1,double u2) { - mUserRange = new Range2D(u1, u2); - } - - /** - * Set the user coordinate range for double values. - * - * @param urange user coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeU(Range2D urange) { - mUserRange = null; - mUserRange = new Range2D(); - mUserRange.add(urange); - } - - /** - * Get the user coordinate range for double values. - * - * @return user range - * @see Range2D - **/ - public Range2D getRangeU() { - return mUserRange; - } - - /** - * Transform from user to physical coordinates. - * - * @param u user value - * @return physical value - */ - public double getTransP(double u) { - double retVal = 0.0; - // first have to find u in the normalized range of the y axis - double y = (u - mUserRange.start)/(mUserRange.end - mUserRange.start); - - // now iterate to find solution - double x = 0.5; - double inc = 0.0001; - double eps = 0.001; - int cnt = 0; - while (true) { - double tstVal = c * x + b * (x * x) + a * (x * x * x); - if (Math.abs(tstVal - y) < eps) { - retVal = x; - break; - } - else { - if (tstVal > y) - x -= inc; - else - x += inc; - } - cnt++; - } - //System.out.println("iter count = " + cnt); - - // scale the x value back to the unnormalized range - retVal = mPhysRange.start + x * (mPhysRange.end - mPhysRange.start); - return retVal; - } - - /** - * Transform from physical to user coordinates. - * - * @param p physical value - * @return user value - */ - public double getTransU(double p) { - double retVal = 0.0; - double x = (p - mPhysRange.start)/(mPhysRange.end - mPhysRange.start); - double y = c * x + b * (x * x) + a * (x * x * x); - retVal = mUserRange.start + y * (mUserRange.end - mUserRange.start); - return retVal; - } - - /** - * Add listener for changes to transform properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeoDate.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeoDate.java deleted file mode 100755 index 0d526f87..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeoDate.java +++ /dev/null @@ -1,777 +0,0 @@ -/* - * $Id: GeoDate.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.util.Date; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.text.ParsePosition; - -/** - * GeoDate extends the capabilities of Date. - * Additional features of GeoDate include methods for - * incrementing and decrementing, adding and substracting - * GeoDate objects. All GeoDate objects - * share the same GregorianCalendar set to a "GMT" time - * zone. Thus, all GeoDate times are in "GMT". This - * simplifies the conversion to and from String - * representations of time. - * - * @see GregorianCalendar - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 1.0 - */ -public class GeoDate extends java.util.Date implements java.io.Serializable { - private int max_day_[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - private boolean splitDone_; - private int yearday_; - private int dayofweek_; - private int year_; - private int month_; - private int day_; - private int hour_; - private int minute_; - private int second_; - private int msec_; - private int MSec_; - private int JDay_; - private boolean EPICTimeDone_; - private boolean relativeTime_ = false; - private static Calendar cal_ = new GregorianCalendar(TimeZone.getTimeZone("GMT")); - /** Increment or decrement in days. */ - public static final int DAYS = 1; - /** Increment or decrement in months. */ - public static final int MONTHS = 2; - /** Increment or decrement in years. */ - public static final int YEARS = 4; - /** Increment or decrement in hours. */ - public static final int HOURS = 5; - /** Increment or decrement in minutes */ - public static final int MINUTES = 6; - /** Increment or decrement in seonds */ - public static final int SECONDS = 7; - /** Increment or decrement in milliseconds */ - public static final int MSEC = 8; - /** Number of milliseconds in a day. */ - public static final long MSECS_IN_DAY = 86400000; - /** Construct a new GeoDate. */ - public GeoDate() { - super(); - } - /** - * Construct a new GeoDate from a - * String. Formatting is done using - * SimpleDateFormat. The specified time - * is taken to be "GMT". - * - * @param time character representation of time - * @param format codes used to read time - */ - public GeoDate(String time,String format) throws IllegalTimeValue { - super(); - ParsePosition pos = new ParsePosition(0); - DateFormat df = new SimpleDateFormat(format); - df.setCalendar(cal_); - - Date dte = df.parse(time, pos); - if(dte == null) { - throw new IllegalTimeValue("Parse error: " + time + ", " + format); - } - setTime(dte.getTime()); - } - /** - * Constructs a new GeoDate from an - * existing GeoDate. - * - * @param t GeoDate - */ - public GeoDate(GeoDate t) { - super(t.getTime()); - } - /** - * Construct a new GeoDate from values. The - * specified time is taken to be "GMT". - * - * @param mon month - * @param day day of the month - * @param year year (no offset!) - * @param hour hour - * @param min minutes - * @param sec seconds - * @param msec milliseconds - * @exception IllegalTimeValue The constructor was called with a set - * of parameters that does not constitute a legitimate time value. - */ - public GeoDate(int mon,int day,int year,int hour,int min,int sec,int msec) throws IllegalTimeValue { - this.set(mon, day, year, hour, min, sec, msec); - } - /** - * Construct a new GeoDate from a - * Date object. No time zone conversion - * is done. - * - * @param date Date object - */ - public GeoDate(Date date) { - setTime(date.getTime()); - } - /** - * Construct a new GeoDate from EPIC double integers. - * Time zone for conversion is "GMT". - * - * @param jday julian day - * @param msec milliseconds since midnight - */ - public GeoDate(int jday, int msec) { - set(jday, msec); - } - - /** - * Allocates a GeoDate object and initializes it to represent - * the specified number of milliseconds since the standard - * base time know as "the epoch", namely January 1, 1970, 00:00:00 - * GMT. - */ - public GeoDate(long date) { - setTime(date); - } - /** - * Set the relativeTime flag. The relativeTime flag indicates that - * the GeoDate object does not represent an actual - * absolute time, but a temporal duration. - */ - public void setRelativeTime(boolean relative) { - relativeTime_ = relative; - } - /** - * Tests the relativeTime flag. - * - * @return if true, time is a duration - */ - public boolean isRelativeTime() { - return relativeTime_; - } - /** - * Change value of GeoDate from EPIC double - * integers. - * Time zone for conversion is "GMT". - * - * @param jday julian day - * @param msec milliseconds since midnight - */ - public void set(int jday, int msec) { - int ja, jb, jc, jd, je; - double jalpha, second; - int day, month, year, hour, minute, sec; - - if(jday > 2299161) { - jalpha = ((double)(jday - 1867216)-0.25)/36524.25; - ja = jday + 1 + (int)jalpha - (int)(0.25*jalpha); - } else { - ja = jday; - } - jb = ja + 1524; - jc = (int)(6680.0 + ((double)(jb - 2439870) - 122.1)/365.25); - jd = (int)(365*jc + (0.25*jc)); - je = (int)((jb - jd)/30.6001); - - day = (int)(jb - jd) - (int)(30.6001*je); - month = (int)(je - 1); - if(month > 12) month -= 12; - year = (int)(jc - 4715); - if(month > 2) --year; - if(year <= 0) --year; - ja = msec/1000; - hour = (int)(ja/3600); - minute = (int)((ja - hour*3600)/60); - second = (double)(msec - (hour*3600 + minute*60)*1000)/1000.0; - sec = (int)second; - msec = ((int)(second*1000.0))%1000; - try{ - set(month, day, year, hour, minute, sec, msec); - } catch (IllegalTimeValue e) {} - } - /** - * Change value of GeoDate from values. - * Time zone for conversion is "GMT". - * - * @param mon month (1=January, 12=December) - * @param day day of the month - * @param year year (no offset!) - * @param hour hour - * @param min minutes - * @param sec seconds - * @param msec milliseconds - * @exception IllegalTimeValue The parameters passed to this method represent a time - * value that is invalid - * - */ - public void set(int mon,int day,int year,int hour,int min,int sec,int msec) throws IllegalTimeValue { - int jy, jm, ja, jul; - int leap = (year%4 != 0? 0: (year%400 == 0? 1: (year%100==0? 0: 1))); - max_day_[1] = 28 + leap; - - if(mon > 12 || mon < 1) { - this.setTime(0); - throw new IllegalTimeValue("value of month out of range"); - } - if(day > max_day_[mon-1] || day < 1) { - this.setTime(0); - throw new IllegalTimeValue("value of day out of range"); - } - if(hour >= 24 || hour < 0) { - this.setTime(0); - throw new IllegalTimeValue("value of hour out of range"); - } - if(min >= 60 || min < 0) { - this.setTime(0); - throw new IllegalTimeValue("value of minute out of range"); - } - if(sec >= 60 || sec < 0) { - this.setTime(0); - throw new IllegalTimeValue("value of second out of range"); - } - if(msec >= 1000 || msec < 0) { - this.setTime(0); - throw new IllegalTimeValue("value of msec out of range"); - } - - cal_.clear(); - cal_.set(year, mon - 1, day, hour, min, sec); - - // this.setTime(cal.getTimeInMillis() + msec); - this.setTime((cal_.getTime()).getTime() + msec); - splitDone_ = false; - EPICTimeDone_ = false; - } - /** - * Get the number of days in the current month. - * - * @return number of days in current month - **/ - public int getDaysInMonth() { - int leap; - int year = cal_.get(Calendar.YEAR); - leap = (year%4 != 0? 0: (year%400 == 0? 1: (year%100==0? 0: 1))); - max_day_[1] = 28 + leap; - return max_day_[month_-1]; - } - /** - * Set to current time. - */ - public void now() { - Date nw = new Date(); - this.setTime(nw.getTime()); - } - /** - * Add time to current GeoDate. This operation only - * makes since if time is a relative time value, - * i.e. the result of a - * GeoDate subrtraction. - * - * @param time GeoDate - * @return new GeoDate - */ - public GeoDate add(GeoDate time) { - GeoDate time2 = new GeoDate(); - long MSec = getTime() + time.getTime(); - - time2.splitDone_ = false; - time2.EPICTimeDone_ = false; - time2.setTime(MSec); - return time2; - } - /** - * Subtract time2 from current GeoDate. - * - * @param time2 subtracthend - * @return new GeoDate - */ - public GeoDate subtract(GeoDate time2) { - GeoDate delta = new GeoDate(); - long MSec = getTime() - time2.getTime(); - - delta.splitDone_ = false; - delta.EPICTimeDone_ = false; - delta.setTime(MSec); - delta.setRelativeTime(true); - return delta; - } - /** - * Divide by value. Current time should the result of adding two times or - * subtracting two times to be a meaningful calculation. - * - * @param val divisor - * @return new GeoDate - */ - public GeoDate divide(double val) { - GeoDate result = new GeoDate(); - - if(val == 0.0) return null; - - result.setTime((long)(((double)getTime())/val)); - - result.splitDone_ = false; - result.EPICTimeDone_ = false; - result.setRelativeTime(true); - return result; - } - void splitTimeFormat() { - int ja, jb, jc, jd, je; - double jalpha; - GeoDate gt; - - if(splitDone_) return; - - cal_.setTime(this); - day_ = cal_.get(Calendar.DAY_OF_MONTH); - month_ = cal_.get(Calendar.MONTH) + 1; - year_ = cal_.get(Calendar.YEAR); - hour_ = cal_.get(Calendar.HOUR_OF_DAY); - minute_ = cal_.get(Calendar.MINUTE); - second_ = cal_.get(Calendar.SECOND); - msec_ = cal_.get(Calendar.MILLISECOND); - dayofweek_ = cal_.get(Calendar.DAY_OF_WEEK) - 1; - yearday_ = cal_.get(Calendar.DAY_OF_YEAR); - - splitDone_ = true; - } - /** - * Increment current GeoDate - * by SECONDS, MINUTES, HOURS, - * DAYS, MONTHS, or YEARS - * - * @param val amount to increment - * @param tu time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) - * operation. - */ - public GeoDate increment(float val,int tu) { - return increment((double)val, tu); - } - /** - * Increment current GeoDate - * by SECONDS, MINUTES, HOURS, - * DAYS, MONTHS, or YEARS - * - * @param val amount to increment - * @param tu time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) - * operation. - */ - public GeoDate increment(double val,int tu) { - int leap; - int ival = (int)val; - double fract = (val - ival); - long MSec = getTime(); - switch(tu) { - case MSEC: - MSec += (long)val; - setTime(MSec); - break; - case SECONDS: - MSec += (long)(val*1000); - setTime(MSec); - break; - case MINUTES: - MSec += (long)(val*60000); - setTime(MSec); - break; - case HOURS: - MSec += (long)(val*3600000); - setTime(MSec); - break; - case DAYS: // days and fraction days - MSec += (long)(val*MSECS_IN_DAY); - setTime(MSec); - break; - case MONTHS: // nearest day - splitTimeFormat(); - month_ += ival; - year_ += ((month_-1)/12); - month_ -= ((month_-1)/12)*12; - if(month_ == 0) month_ = 1; - leap = (year_%4 != 0? 0: (year_%400 == 0? 1: (year_%100==0? 0: 1))); - max_day_[1] = 28 + leap; - day_ += (int)(fract*max_day_[month_-1]); - if(day_ > max_day_[month_-1]) { - day_ -= max_day_[month_-1]; - month_++; - year_ += ((month_-1)/12); - month_ -= ((month_-1)/12)*12; - if(month_ == 0) month_ =1; - } - try { - this.set(month_, day_, year_, hour_, minute_, second_, msec_); - } catch (IllegalTimeValue e) { - System.err.println(e); - } - break; - case YEARS: // nearest day - splitTimeFormat(); - year_ += ival; - leap = (year_%4 != 0? 0: (year_%400 == 0? 1: (year_%100==0? 0: 1))); - max_day_[1] = 28 + leap; - if(day_ > max_day_[month_-1]) day_ = max_day_[month_-1]; - try { - this.set(month_, day_, year_, hour_, minute_, second_, msec_); - } catch (IllegalTimeValue e) { - System.err.println(e); - } - setTime(getTime() + (long)(fract*365.25)*MSECS_IN_DAY); - break; - } - splitDone_ = false; - EPICTimeDone_ = false; - return this; - } - /** - * Decrement current GeoDate - * by SECONDS, MINUTES, HOURS, - * DAYS, MONTHS, or YEARS - * - * @param val amount to decrement - * @param tu time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) - * operation. - */ - public GeoDate decrement(float val,int tu) { - return decrement((double)val, tu); - } - /** - * Decrement current GeoDate - * by SECONDS, MINUTES, HOURS, - * DAYS, MONTHS, or YEARS - * - * @param val amount to decrement - * @param tu time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) - * operation. - */ - public GeoDate decrement(double val,int tu) { - int leap; - int ival = (int)val; - double fract = (val - ival); - long MSec = getTime(); - - switch(tu) { - case MSEC: - MSec -= (long)val; - setTime(MSec); - break; - case SECONDS: - MSec -= (long)(val*1000); - setTime(MSec); - break; - case MINUTES: - MSec -= (long)(val*60000); - setTime(MSec); - break; - case HOURS: - MSec -= (long)(val*3600000); - setTime(MSec); - break; - case DAYS: - MSec -= (long)(val*MSECS_IN_DAY); - setTime(MSec); - break; - case MONTHS: - splitTimeFormat(); - month_ -= ival; - if(month_ <= 0) { - year_ -= (month_-1)/12 + 1; - month_ += ((month_-1)/12)*12 + 12; - } - if(month_ == 0) month_ = 12; - leap = (year_%4 != 0? 0: (year_%400 == 0? 1: (year_%100==0? 0: 1))); - max_day_[1] = 28 + leap; - day_ -= (int)(fract*max_day_[month_-1]); - if(day_ > max_day_[month_-1]) { - day_ -= max_day_[month_-1]; - month_--; - if(month_ <= 0) { - year_ -= (month_-1)/12 + 1; - month_ += ((month_-1)/12)*12; - } - if(month_ == 0) month_ = 12; - } - try { - this.set(month_, day_, year_, hour_, minute_, second_, msec_); - } catch (IllegalTimeValue e) { - System.err.println(e); - } - break; - case YEARS: - splitTimeFormat(); - year_ -= ival; - leap = (year_%4 != 0? 0: (year_%400 == 0? 1: (year_%100==0? 0: 1))); - max_day_[1] = 28 + leap; - if(day_ > max_day_[month_-1]) day_ = max_day_[month_-1]; - try { - this.set(month_, day_, year_, hour_, minute_, second_, msec_); - } catch (IllegalTimeValue e) { - System.err.println(e); - } - setTime(getTime() - (long)(fract*365.25)*MSECS_IN_DAY); - break; - } - splitDone_ = false; - EPICTimeDone_ = false; - return this; - } - /** - * Time offset from reference GeoDate - * - * @param ref reference GeoDate - * @return offset in days - */ - public double offset(GeoDate ref) { - double val; - val = ((double)(this.getTime() - ref.getTime()))/86400000.0; - return val; - } - /** - * Set a GeoDate from year and year-day. - * - * @param year year - * @param yearday year-day number (Jan 1 = 1) - * parameters that does not constitute a legitimate time value. - */ - public void setYearYearDay(int year,int yearday) { - try { - this.set(1, 1, year, 0, 0, 0, 0); - } catch (IllegalTimeValue e) { - System.err.println(e); - } - setTime(getTime() + (yearday - 1)*MSECS_IN_DAY); - } - /** - * Get a reference to the GregorianCalendar set - * to the current GeoDate time. - * - * @return Calendar - */ - public Calendar getCalendar() { - cal_.setTime(this); - return cal_; - } - /** - * Get year-day number (Jan 1 = 1) - */ - public int getYearday() { - splitTimeFormat(); - return yearday_; - } - /** - * Get year - * - * @deprecated Overrides a deprecated method, replaced by {@link #getGMTYear}. - */ - public int getYear() { - splitTimeFormat(); - return year_; - } - /** - * Get year. - */ - public int getGMTYear() { - splitTimeFormat(); - return year_; - } - /** - * Get month - * - * @deprecated Overrides a deprecated method, replaced by {@link #getGMTMonth}. - */ - public int getMonth() { - splitTimeFormat(); - return month_; - } - /** - * Get month - */ - public int getGMTMonth() { - splitTimeFormat(); - return month_; - } - /** - * Get day - * - * @deprecated Overrides a deprecated method, replaced by {@link #getGMTDay}. - */ - public int getDay() { - splitTimeFormat(); - return day_; - } - /** - * Get day - */ - public int getGMTDay() { - splitTimeFormat(); - return day_; - } - /** - * Get hours - * - * @deprecated Overrides a deprecated method, replaced by {@link #getGMTHours}. - */ - public int getHours() { - splitTimeFormat(); - return hour_; - } - /** - * Get hours - */ - public int getGMTHours() { - splitTimeFormat(); - return hour_; - } - /** - * Get minutes - * - * @deprecated Overrides a deprecated method, replaced by {@link #getGMTMinutes}. - */ - public int getMinutes() { - splitTimeFormat(); - return minute_; - } - /** - * Get minutes - */ - public int getGMTMinutes() { - splitTimeFormat(); - return minute_; - } - /** - * Get secondss - * @deprecated replaced by {@link #getGMTSeconds}. - */ - public double getSecondss() { - splitTimeFormat(); - return second_; - } - /** - * Get seconds and fraction of seconds. - */ - public double getGMTSeconds() { - splitTimeFormat(); - return second_; - } - /** - * get EPIC Julian Day - */ - public int getJDay() { - splitTimeFormat(); - computeEPICTime(); - return JDay_; - } - /** - * get milliseconds since midnight - */ - public int getMSec() { - splitTimeFormat(); - computeEPICTime(); - return MSec_; - } - - private void computeEPICTime() { - if(EPICTimeDone_) return; - int GREGORIAN__ = (15+31*(10+12*1582)); - int jy, jm, ja, jul; - int year = year_; - int mon = month_; - int day = day_; - int hour = hour_; - int min = minute_; - int sec = second_; - int msec = msec_; - - int leap = (year%4 != 0? 0: (year%400 == 0? 1: (year%100==0? 0: 1))); - - if(year < 0) ++year; - if(mon > 2) { - jy = year; - jm = mon + 1; - } else { - jy = year - 1; - jm = mon + 13; - } - jul = (int)(Math.floor(365.25*jy)+Math.floor(30.6001*jm)+day+1720995); - if(day + 31L*(mon+12L*year) >= GREGORIAN__) { - ja = (int)(0.01*jy); - jul += 2 - ja + (int)(0.25*ja); - } - - JDay_ = jul; - MSec_ = (int)((hour*3600L+min*60L)*1000L+sec*1000L+msec); - - EPICTimeDone_ = true; - } - /** - * Convert GeoDate to String - * using standard format "yyyy-MM-dd HH:mm:ss z" - * and "GMT" time zone. - * - * @return date - */ - public String toString() { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); - df.setCalendar(cal_); - return df.format(this); - } - /** - * Convert GeoDate to String - * using provided format. The SimpleDateFormat - * and the GregorianCalendar is used to format - * the GeoDate. A format of "decade" will create - * a string of the form 1990 or 1980. - * - * @see SimpleDateFormat - * - * @param format String containing codes used to write time. - */ - public String toString(String format) { - if(format.equals("decade")) { - splitTimeFormat(); - return Integer.toString((year_/10)*10); - } else { - DateFormat df = new SimpleDateFormat(format); - df.setCalendar(cal_); - return df.format(this); - } - } - /** - * Tests to see if value represents missing data. A value from the - * getTime() method of Long.MIN_VALUE represents a - * missing observation. - * - * @see gov.noaa.pmel.sgt.dm.SGTData#getXRange() - */ - public boolean isMissing() { - return getTime() == Long.MIN_VALUE; - } - /** - * Tests to see if the current GeoDate is less than, equal, or greater than. - * another GeoDate - */ - public int compareTo(GeoDate anotherDate) { - if (this.getTime() < anotherDate.getTime()) - return -1; - else if (this.getTime() == anotherDate.getTime()) - return 0; - else - return 1; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeoDateArray.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeoDateArray.java deleted file mode 100755 index 161b8e06..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeoDateArray.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * $Id: GeoDateArray.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.util.Date; -import java.io.Serializable; - -/** - * GeoDateArray creates an efficient storage of - * GeoDate objects. This is accomplished by using an - * internal storage of long for the number of - * milliseconds since January 1, 1970, 00:00:00 GMT. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 3.0 - */ -public class GeoDateArray implements Serializable { - private long[] date_; - - /** - * Construct a new GeoDateArray from an array of - * GeoDates. - * - * @param dates an array of GeoDates. - */ - public GeoDateArray(GeoDate[] dates) { - date_ = new long[dates.length]; - for(int i=0; i < dates.length; i++) { - if(!(dates[i] == null || dates[i].isMissing())) { - date_[i] = dates[i].getTime(); - } else { - date_[i] = Long.MAX_VALUE; - } - } - } - - /** - * Construct a new GeoDateArray from an array of - * Dates. - * - * @param dates an array of Dates. - */ - public GeoDateArray(Date[] dates) { - date_ = new long[dates.length]; - for(int i=0; i < dates.length; i++) { - if(!(dates[i] == null)) { - date_[i] = dates[i].getTime(); - } else { - date_[i] = Long.MAX_VALUE; - } - } - } - - /** - * Construct a new GeoDateArray from an array of - * longs that represent the number of - * milliseconds since January 1, 1970, 00:00:00 GMT. Missing value - * for date is Long.MAX_VALUE. - * - * @param dates an array of longs. - */ - public GeoDateArray(long[] dates) { - date_ = dates; - } - - public long[] getTime() { - return date_; - } - - public long getTime(int index) { - if(index < 0 || index >= date_.length) return Long.MAX_VALUE; - return date_[index]; - } - - public GeoDate getGeoDate(int index) { - if(index < 0 || index >= date_.length) return null; - return new GeoDate(date_[index]); - } - - public GeoDate[] getGeoDate() { - GeoDate[] gd = new GeoDate[date_.length]; - for(int i=0; i < date_.length; i++) { - gd[i] = new GeoDate(date_[i]); - } - return gd; - } - /** - * Time offset for reference GeoDate. - * - * @param ref reference GeoDate - * @return offset in days - */ - public double getOffset(int index, GeoDate ref) { - if(index < 0 || index >= date_.length) return Double.NaN; - return ((double)(date_[index] - ref.getTime()))/86400000.0; - } - - /** - * Time offset for reference GeoDate. - * - * @param ref reference GeoDate - * @return offset in days - */ - public double[] getOffset(GeoDate ref) { - long refgd = ref.getTime(); - double[] off = new double[date_.length]; - for(int i=0; i < date_.length; i++) { - off[i] = ((double)(date_[i] - refgd))/86400000.0; - } - return off; - } - /** - * Time offset for reference GeoDate. - * - * @param ref reference GeoDate - * @return offset in milliseconds - */ - public long getOffsetTime(int index, GeoDate ref) { - if(index < 0 || index >= date_.length) return Long.MAX_VALUE; - return date_[index] - ref.getTime(); - } - - /** - * Time offset for reference GeoDate. - * - * @param ref reference GeoDate - * @return offset in milliseconds - */ - public long[] getOffsetTime(GeoDate ref) { - long refgd = ref.getTime(); - long[] off = new long[date_.length]; - for(int i=0; i < date_.length; i++) { - off[i] = date_[i] - refgd; - } - return off; - } - /** - * Add offset to all dates. - */ - public void addOffset(long offset) { - for(int i=0; i < date_.length; i++) { - date_[i] += offset; - } - } - /** - * Add offset to single date. - */ - public void addOffset(int index, long offset) { - if(index < 0 || index >= date_.length) return; - date_[index] += offset; - } - /** - * Get length of array. - */ - public int getLength() { - return date_.length; - } -} - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeographicValue.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeographicValue.java deleted file mode 100755 index aefd7751..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/GeographicValue.java +++ /dev/null @@ -1,152 +0,0 @@ - - - package gov.noaa.pmel.util; - -/** -* Base class used by LatitudeValue and LongitudeValue for translating between -* a float and deg/min/sec. -*/ - public class GeographicValue { - - protected int degrees; - protected int minutes; - protected int seconds; - protected int sign; - protected float decimalValue; - - // --------------------------------------------- - // - public GeographicValue( ) { - this.decimalValue = 0; - decimalToDegMinSec(); - } - - // --------------------------------------------- - // - public GeographicValue( float decVal ) { - this.decimalValue = decVal; - decimalToDegMinSec(); - } - - // --------------------------------------------- - // - public void decimalToDegMinSec() { - sign = 1; - if (decimalValue < 0) sign = -1; - - float num1 = Math.abs( decimalValue ); - degrees = (new Double( num1)).intValue(); - float f1 = Math.abs( num1 - degrees); - float f2 = (f1 * 60); - - float num2 = Math.abs( f2 ); - minutes = new Double( Math.floor( (new Double(num2)).doubleValue() )).intValue(); - float f3 = Math.abs( num2 - minutes); - double dd = f3 * 60; - seconds = new Long( Math.round( dd )).intValue(); - if (seconds == 60) { - seconds = 0; - minutes++; - } - /* - System.out.println("======================================================"); - System.out.println(" num1: " + num1 - + " \n degrees: " + degrees - + " \n f1: " + f1 - + " \n f2: " + f2 - + " \n num2: " + num2 - + " \n minutes: " + minutes - + " \n f3: " + f3 - + " \n dd: " + dd - + " \n seconds: " + seconds); - System.out.println(""); - */ - } - - - // --------------------------------------------- - // - public void degMinSecToDecimal() { - float minVal = minutes; - float degVal = degrees; - float secVal = seconds; - if (seconds == 0) secVal = 0.1f; - minVal += (secVal/60f); - degVal += (minVal/60f); - degVal = degVal * sign; - decimalValue = degVal; - } - - // --------------------------------------------- - // - public void setDegrees( int degrees ) { - this.degrees = degrees; - } - // --------------------------------------------- - // - public void setMinutes( int minutes ) { - this.minutes = minutes; - } - // --------------------------------------------- - // - public void setSeconds( int seconds ) { - this.seconds = seconds; - } - // --------------------------------------------- - // - public void setSign( int sign ) { - this.sign = sign; - } - // --------------------------------------------- - // - public void setDecimalValue( float decimalValue ) { - this.decimalValue = decimalValue; - decimalToDegMinSec(); - } - - // --------------------------------------------- - // - public int getDegrees( ) { - return degrees; - } - // --------------------------------------------- - // - public int getMinutes( ) { - return minutes; - } - // --------------------------------------------- - // - public int getSeconds( ) { - return seconds; - } - // --------------------------------------------- - // - public int getSign( ) { - return sign; - } - // --------------------------------------------- - // - public float getDecimalValue( ) { - return decimalValue; - } - - // --------------------------------------------- - // - public String toString( ) { - StringBuffer str = new StringBuffer(); - str.append( " ----------------------------: " - + " \n degrees: " + degrees - + " \n minutes: " + minutes - + " \n seconds: " + seconds - + " \n decimalValue: " + decimalValue); - return str.toString(); - } - - // --------------------------------------------- - // - public static void main( String args[] ) { - GeographicValue l1 = new GeographicValue( -154.7002716064453f); - System.out.println(" toString: " + l1.toString()); - } - - } diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/IllegalTimeValue.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/IllegalTimeValue.java deleted file mode 100755 index 3ba88f84..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/IllegalTimeValue.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * $Id: IllegalTimeValue.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -/** - * The specified time was unreadable or illegal. - * - * @author Don Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - **/ - - public class IllegalTimeValue extends Exception { - public IllegalTimeValue() { - super(); -} - public IllegalTimeValue(String s) { - super(s); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/IndexedColorMap.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/IndexedColorMap.java deleted file mode 100755 index f0dff903..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/IndexedColorMap.java +++ /dev/null @@ -1,65 +0,0 @@ -package gov.noaa.pmel.util; - -import java.util.*; -import java.awt.*; - - -public class IndexedColorMap { - String mParamName; - double mMinVal; - double mMaxVal; - double[] mVals = null; - Color[] mColors = null; - int mNumColors; - ColorMap mColorMap; - - public IndexedColorMap(ColorMap inCM, int numColors) { - mNumColors = numColors; - mColorMap = inCM; - mVals = new double[mNumColors]; - mColors = new Color[mNumColors]; - - // initialize the indexed colormap - mMinVal = mColorMap.getMinValue(); - mMaxVal = mColorMap.getMaxValue(); - mParamName = new String(mColorMap.getParamName()); - - double delta = (mMaxVal - mMinVal)/(double)mNumColors; - - for (int i=0; i= mNumColors) - return mColors[mNumColors-1]; - else - return mColors[index]; - } - - public Color[] getColors() { - return mColors; - } - - public String getParamName() { - return mParamName; - } -} \ No newline at end of file diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Latitude.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Latitude.java deleted file mode 100755 index a41cc495..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Latitude.java +++ /dev/null @@ -1,28 +0,0 @@ - - package gov.noaa.pmel.util; - -/** -* LatitudeValue translates between float and deg/min/sec. -*/ - public class Latitude extends GeographicValue { - - // --------------------------------------------- - // - public Latitude( ) { - super(); - } - - // --------------------------------------------- - // - public Latitude( float latitude ) { - super( latitude ); - } - - // --------------------------------------------- - // - public static void main( String args[] ) { - Latitude l1 = new Latitude( -54.7002716064453f); - System.out.println(" toString: " + l1.toString()); - } - - } diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/LinearTransform.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/LinearTransform.java deleted file mode 100755 index 0f732dac..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/LinearTransform.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * $Id: LinearTransform.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.beans.PropertyChangeListener; -import gov.noaa.pmel.util.Range2D; -import gov.noaa.pmel.sgt.Transform; - -/** - * LinearTransform defines a liniear transformations between - * user and physical coordinates defined between two end points. - * - * @see AxisTransform - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - */ -public class LinearTransform implements Transform { - Range2D mPhysRange = null; - Range2D mUserRange = null; - double mPUSlope, mPUYintercept; - double mUPSlope, mUPYintercept; - - public LinearTransform(double p1, double p2, double u1, double u2) { - setRangeP(p1, p2); - setRangeU(u1, u2); - computeTransforms(); - } - - public LinearTransform(Range2D prange, Range2D urange) { - setRangeP(prange); - setRangeU(urange); - computeTransforms(); - } - - public LinearTransform() { - } - - /** - * Set physical coordinate range. - * - * @param p1 minimum value, physical coordinates - * @param p2 maximum value, physical coordinates - * @see LinearTransform - **/ - public void setRangeP(double p1,double p2) { - mPhysRange = new Range2D(p1, p2); - } - - /** - * Set physical coordinate range. - * - * @param prange physcial coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeP(Range2D prange) { - mPhysRange = null; - mPhysRange = new Range2D(); - mPhysRange.add(prange); - } - - /** - * Get the physical coordinate range. - * - * @return physcial coordinate range - * @see Range2D - **/ - public Range2D getRangeP() { - return mPhysRange; - } - - /** - * Set the user coordinate range for double values. - * - * @param u1 minimum value, user coordinates - * @param u2 maximum value, user coordinates - * @see LinearTransform - **/ - public void setRangeU(double u1,double u2) { - mUserRange = new Range2D(u1, u2); - } - - /** - * Set the user coordinate range for double values. - * - * @param urange user coordinate range - * @see Range2D - * @see LinearTransform - **/ - public void setRangeU(Range2D urange) { - mUserRange = null; - mUserRange = new Range2D(); - mUserRange.add(urange); - computeTransforms(); - } - - /** - * Get the user coordinate range for double values. - * - * @return user range - * @see Range2D - **/ - public Range2D getRangeU() { - return mUserRange; - } - - /** - * Transform from user to physical coordinates. - * - * @param u user value - * @return physical value - */ - public double getTransP(double u) { - return (mUPSlope * u) + mUPYintercept; - } - - /** - * Transform from physical to user coordinates. - * - * @param p physical value - * @return user value - */ - public double getTransU(double p) { - return (mPUSlope *p) + mPUYintercept; - } - - /** - * Add listener for changes to transform properties. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - - } - - public void computeTransforms() { - computePULine(); - computeUPLine(); - } - - private void computePULine() { - double denom = mPhysRange.start - mPhysRange.end; - double num = mUserRange.start - mUserRange.end; - mPUSlope = num/denom; - mPUYintercept = mUserRange.start - (mPUSlope * mPhysRange.start); - } - - private void computeUPLine() { - double num = mPhysRange.start - mPhysRange.end; - double denom = mUserRange.start - mUserRange.end; - mUPSlope = num/denom; - mUPYintercept = mPhysRange.start - (mPUSlope * mUserRange.start); - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Longitude.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Longitude.java deleted file mode 100755 index 370ed777..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Longitude.java +++ /dev/null @@ -1,29 +0,0 @@ - - package gov.noaa.pmel.util; - -/** -* LongitudeValue translates between float and deg/min/sec. -*/ - public class Longitude extends GeographicValue { - - - // --------------------------------------------- - // - public Longitude( ) { - super(); - } - - // --------------------------------------------- - // - public Longitude( float longitude ) { - super( longitude ); - } - - // --------------------------------------------- - // - public static void main( String args[] ) { - Longitude l1 = new Longitude( -154.7002716064453f); - System.out.println(" toString: " + l1.toString()); - } - - } diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Point2D.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Point2D.java deleted file mode 100755 index eb2b6117..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Point2D.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * $Id: Point2D.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.io.Serializable; - -/** - * Point2D will be part of java.java2d. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 1.0 - */ -public abstract class Point2D implements Serializable, Cloneable { - /** - * Inner class for Point2D for type - * double. - * @since sgt 1.0 - */ - public static class Double extends Point2D { - /** x coordinate */ - public double x; - /** y coordinate */ - public double y; - /** - * Default constructor - */ - public Double() { - } - public Double(double x,double y) { - this.x = x; - this.y = y; - } - /** - * Test for equality. Both x and y coordinates must be equal for - * equality. - */ - public boolean equals(Point2D.Double pt) { - return (x == pt.x && y == pt.y) ; - } - /** - * @since sgt 3.0 - */ - public boolean equals(Object pt) { - if(pt instanceof Point2D.Double) { - Point2D.Double pt2 = (Point2D.Double)pt; - return (x == pt2.x) && (y == pt2.y); - } else { - return false; - } - } - public String toString() { - return new String("(" + x + ", " + y + ")"); - } - /** - * Make a copy of the Rectangle2D. - * @since sgt 3.0 - */ - public Point2D copy() { - try { - return (Point2D)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - } - /** - * Inner class for Point2D for type - * float. - * @since sgt 2.0 - */ - public static class Float extends Point2D { - /** x coordinate */ - public float x; - /** y coordinate */ - public float y; - /** - * Default constructor - */ - public Float() { - } - public Float(float x,float y) { - this.x = x; - this.y = y; - } - /** - * Test for equality. Both x and y coordinates must be equal for - * equality. - */ - public boolean equals(Point2D.Float pt) { - return (x == pt.x && y == pt.y) ; - } - /** - * @since sgt 3.0 - */ - public boolean equals(Object pt) { - if(pt instanceof Point2D.Float) { - Point2D.Float pt2 = (Point2D.Float)pt; - return (x == pt2.x) && (y == pt2.y); - } else { - return false; - } - } - public String toString() { - return new String("(" + x + ", " + y + ")"); - } - /** - * Make a copy of the Rectangle2D. - * @since sgt 3.0 - */ - public Point2D copy() { - try { - return (Point2D)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - } - /** - * This is an abstract class that cannot be instantiated directly. - * Type-specific implementation subclasses are available for - * instantiation and provide a number of formats for storing - * the information necessary to satisfy the various accessor - * methods below. - * - */ - protected Point2D() { - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Range.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Range.java deleted file mode 100755 index 2b6f5f69..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Range.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id: Range.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -/** - * Contains minimum and maximum integer values. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 1.0 - */ -public class Range implements java.io.Serializable { - /** The range's first value */ - public int start; - /** The range's last value */ - public int end; - /** - * Default constructor - */ - public Range() { - this(0, 0); - } - /** - * Initializes Range with start and end integral values. - * - * @param start first value - * @param end last value - */ - public Range(int start,int end) { - this.start = start; - this.end = end; - } - /** - * Test Range for equality. Both start and end must be - * equal for equality. - */ - public boolean equals(Range r) { - return (start == r.start && end == r.end); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Range2D.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Range2D.java deleted file mode 100755 index 1f974b5d..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Range2D.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * $Id: Range2D.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -/** - * Contains minimum, maximum, and delta double values. - * - * @author Donald Denbo - * @verstion $Revision: 1.1.1.1 $ $Date: 2007/09/07 06:32:05 $ - * @since sgt 1.0 - */ -public class Range2D implements java.io.Serializable, Cloneable { - /** The range's first value */ - public double start; - /** The range's last value */ - public double end; - /** The value of the increment */ - public double delta; - /** - * Default constructor. - */ - public Range2D() { - this(Double.NaN, Double.NaN, Double.NaN); - } - /** - * Construct Range2D with start and end. Default for - * delta is NaN - * - * @param ustart first value - * @param uend last value - */ - public Range2D(double ustart,double uend) { - this(ustart, uend, Double.NaN); - } - /** - * Range2D constructor. - * - * @param ustart first value - * @param uend last value - * @param udel increment value - */ - public Range2D(double ustart,double uend,double udel) { - start = ustart; - end = uend; - delta = udel; - } - /** - * Adds the Range2D object to this - * Range2D. The resulting Range2D is - * the smallest Range2D that contains both the - * origial Range2D and the specified - * Range2D. - */ - public void add(Range2D range) { - start = Math.min(start, range.start); - end = Math.max(end, range.end); - } - /** - * Test for equality. Both start, end, and delta must be equal for - * equality. - */ - public boolean equals(Range2D r) { - if(!Double.isNaN(start) && !Double.isNaN(r.start)) { - if(Double.isNaN(start) || Double.isNaN(r.start)) return false; - if(start != r.start) return false; - } - if(!Double.isNaN(end) && !Double.isNaN(r.end)) { - if(Double.isNaN(end) || Double.isNaN(r.end)) return false; - if(end != r.end) return false; - } - if(!Double.isNaN(delta) && !Double.isNaN(r.delta)) { - if(Double.isNaN(delta) || Double.isNaN(r.delta)) return false; - if(delta != r.delta) return false; - } - return true; - } - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(Double.isNaN(delta)) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } - /** - * Create a copy of Range2D object. - */ - public Range2D copy() { - try { - return (Range2D)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Rectangle2D.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Rectangle2D.java deleted file mode 100755 index 0d96c240..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Rectangle2D.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * $Id: Rectangle2D.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.io.Serializable; - -/** - * Rectangle2D will be part of java.java2d - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 1.0 - */ -public abstract class Rectangle2D implements Serializable, Cloneable { - /** - * Inner class that implements Rectangle2D for - * type double. - * - * @since sgt 1.0 - */ - public static class Double extends Rectangle2D { - /** height of rectangle */ - public double height; - /** width of rectangle */ - public double width; - /** x coordinate of rectangle */ - public double x; - /** y coordinate of rectangle */ - public double y; - /** - * Default constructor - */ - public Double() { - } - public Double(double x,double y,double width,double height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - public Double(double width,double height) { - this.width = width; - this.height = height; - } - public Double(Rectangle2D.Double r) { - x = r.x; - y = r.y; - width = r.width; - height = r.height; - } - /** - * Test for equality. Height, width, x, and y must be equal for - * equality. - */ - public boolean equals(Rectangle2D.Double r) { - return !(x != r.x || - y != r.y || - width != r.width || - height != r.height); - } - public boolean equals(Object r) { - if(r instanceof Rectangle2D.Double) { - Rectangle2D.Double r2 = (Rectangle2D.Double)r; - return !(x != r2.x || - y != r2.y || - width != r2.width || - height != r2.height); - } else { - return false; - } - } - public String toString() { - String result; - result = "[x=" + x + ",y=" + y + ",width=" + width + ",height=" + height + "]"; - return result; - } - /** - * @since 3.0 - */ - public void setWidth(double w) { - width = w; - } - /** - * @since 3.0 - */ - public double getWidth() { - return width; - } - /** - * @since 3.0 - */ - public void setHeight(double h) { - height = h; - } - /** - * @since 3.0 - */ - public double getHeight() { - return height; - } - /** - * @since 3.0 - */ - public void setX(double x) { - this.x = x; - } - /** - * @since 3.0 - */ - public double getX() { - return x; - } - /** - * @since 3.0 - */ - public void setY(double y) { - this.y = y; - } - /** - * @since 3.0 - */ - public double getY() { - return y; - } - /** - * Make a copy of the Rectangle2D. - */ - public Rectangle2D copy() { - try { - return (Rectangle2D)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - } - /** - * Inner class that implements Rectangle2D for - * type float. - * - * @since sgt 1.0 - */ - public static class Float extends Rectangle2D { - /** height of rectangle */ - public float height; - /** width of rectangle */ - public float width; - /** x coordinate of rectangle */ - public float x; - /** y coordinate of rectangle */ - public float y; - /** - * Default constructor - */ - public Float() { - } - public Float(float x,float y,float width,float height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - public Float(float width,float height) { - this.width = width; - this.height = height; - } - public Float(Rectangle2D.Float r) { - x = r.x; - y = r.y; - width = r.width; - height = r.height; - } - /** - * Test for equality. Height, width, x, and y must be equal for - * equality. - */ - public boolean equals(Rectangle2D.Float r) { - return !(x != r.x || - y != r.y || - width != r.width || - height != r.height); - } - public boolean equals(Object r) { - if(r instanceof Rectangle2D.Float) { - Rectangle2D.Float r2 = (Rectangle2D.Float)r; - return !(x != r2.x || - y != r2.y || - width != r2.width || - height != r2.height); - } else { - return false; - } - } - public String toString() { - String result; - result = "[x=" + x + ",y=" + y + ",width=" + width + ",height=" + height + "]"; - return result; - } - /** - * @since 3.0 - */ - public void setWidth(float w) { - width = w; - } - /** - * @since 3.0 - */ - public float getWidth() { - return width; - } - /** - * @since 3.0 - */ - public void setHeight(float h) { - height = h; - } - /** - * @since 3.0 - */ - public float getHeight() { - return height; - } - /** - * @since 3.0 - */ - public void setX(float x) { - this.x = x; - } - /** - * @since 3.0 - */ - public float getX() { - return x; - } - /** - * @since 3.0 - */ - public void setY(float y) { - this.y = y; - } - /** - * @since 3.0 - */ - public float getY() { - return y; - } - /** - * Make a copy of the Rectangle2D. - */ - public Rectangle2D copy() { - try { - return (Rectangle2D)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - } - /** - * This is an abstract class that cannot be instantiated directly. - * Type-specific implementation subclasses are available for - * instantiation and provide a number of formats for storing - * the information necessary to satisfy the various accessor - * methods below. - * - */ - protected Rectangle2D() { } - public abstract Rectangle2D copy(); -} - - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SimpleFileFilter.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SimpleFileFilter.java deleted file mode 100755 index d130324a..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SimpleFileFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * $Id: SimpleFileFilter.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - */ -package gov.noaa.pmel.util; - -import javax.swing.filechooser.*; -import java.io.File; - -public class SimpleFileFilter extends FileFilter { - private String[] extensions; - private String description; - - public SimpleFileFilter(String ext) { - this(new String[] {ext}, null); - } - public SimpleFileFilter(String[] exts, String descr) { - extensions = new String[exts.length]; - for(int i=exts.length -1; i >=0; i--) { - extensions[i]= exts[i].toLowerCase(); - } - description = (descr ==null? exts[0] + " files" : descr); - } - - public boolean accept(File f) { - if(f.isDirectory()) {return true;} - String name = f.getName().toLowerCase(); - for(int i=extensions.length-1; i>=0; i--) { - if(name.endsWith(extensions[i])) { - return true; - } - } - return false; - } - - public boolean hasExtension(String ext) { - for(int i=0; i < extensions.length; i++) { - if(extensions[i].equals(ext)) return true; - } - return false; - } - - public String getExtension() { - return getExtension(0); - } - - public String getExtension(int index) { - int idx = index; - if(idx < 0 || idx >= extensions.length) idx = 0; - return extensions[idx]; - } - public String getDescription() { - return description; - } -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTDomain.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTDomain.java deleted file mode 100755 index 638a4a1c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTDomain.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * $Id: SoTDomain.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ -package gov.noaa.pmel.util; - -/** - * SoTDomain contains the X and Y ranges of a domain in - * user units. These ranges are SoTRange objects which - * can be either Space or Time. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 2.0 - */ -public class SoTDomain implements java.io.Serializable { - SoTRange xRange_ = null; - SoTRange yRange_ = null; - boolean xReversed_ = false; - boolean yReversed_ = false; - /** - * Default constructor. - */ - public SoTDomain() { - } - /** - * Construct a SoTDomain from a Domain. - */ - public SoTDomain(Domain domain) { - if(domain.isXTime()) { -// xRange_ = new SoTRange.GeoDate(domain.getTimeRange()); - xRange_ = new SoTRange.Time(domain.getTimeRange()); - } else { - xRange_ = new SoTRange.Double(domain.getXRange()); - } - if(domain.isYTime()) { -// yRange_ = new SoTRange.GeoDate(domain.getTimeRange()); - yRange_ = new SoTRange.Time(domain.getTimeRange()); - } else { - yRange_ = new SoTRange.Double(domain.getYRange()); - } - xReversed_ = domain.isXReversed(); - yReversed_ = domain.isYReversed(); - } - /** - * Constract a SoTDomain from a SoTDomain - */ - public SoTDomain(SoTDomain domain) { - xRange_ = domain.getXRange(); - yRange_ = domain.getYRange(); - xReversed_ = domain.isXReversed(); - yReversed_ = domain.isYReversed(); - } - /** - * Construct a SoTDomain from SoTRanges. - */ - public SoTDomain(SoTRange xRange, SoTRange yRange) { - xRange_ = xRange; - yRange_ = yRange; - xReversed_ = false; - yReversed_ = false; - } - /** - * @since sgt 3.0 - */ - public SoTDomain(SoTRange xRange, SoTRange yRange, - boolean xRev, boolean yRev) { - xRange_ = xRange; - yRange_ = yRange; - xReversed_ = xRev; - yReversed_ = yRev; - } - /** - * Set the x range - */ - public void setXRange(SoTRange xRange) { - xRange_ = xRange; - } - /** - * Get the x range - */ - public SoTRange getXRange() { - return xRange_; - } - /** - * Set the y range - */ - public void setYRange(SoTRange yRange) { - yRange_ = yRange; - } - /** - * Get the y range - */ - public SoTRange getYRange() { - return yRange_; - } - /** - * Test if the x range is temporal. - */ - public boolean isXTime() { - return xRange_.isTime(); - } - /** - * Test if the y range is temporal - */ - public boolean isYTime() { - return yRange_.isTime(); - } - /** - * Get the center of the domain. - * @since sgt 3.0 - */ - public SoTPoint getCenter() { - SoTValue xVal = null; - SoTValue yVal = null; - if(isXTime()) { - xVal = new SoTValue.Time((xRange_.getStart().getLongTime()+ - xRange_.getEnd().getLongTime())/2); - } else { - xVal = new SoTValue.Double((((Number)xRange_.getStart().getObjectValue()).doubleValue() + - ((Number)xRange_.getEnd().getObjectValue()).doubleValue())/2.0); - } - if(isYTime()) { - yVal = new SoTValue.Time((yRange_.getStart().getLongTime()+ - yRange_.getEnd().getLongTime())/2); - } else { - yVal = new SoTValue.Double((((Number)yRange_.getStart().getObjectValue()).doubleValue() + - ((Number)yRange_.getEnd().getObjectValue()).doubleValue())/2.0); - } - - return new SoTPoint(xVal, yVal); - } - /** - * Test for equality. Both ranges must be equal for equality. - */ - public boolean equals(SoTDomain d) { - if(!xRange_.equals(d.getXRange())) return false; - if(!yRange_.equals(d.getYRange())) return false; - if(xReversed_ != d.isXReversed()) return false; - if(yReversed_ != d.isYReversed()) return false; - return true; - } - public String toString() { - StringBuffer buf = new StringBuffer(100); - buf.append("x="); - buf.append(xRange_).append(",y="); - buf.append(yRange_); - buf.append(", xRev=").append(xReversed_); - buf.append(", yRev=").append(yReversed_); - return buf.toString(); - } - /** - * @since sgt 3.0 - */ - public void setXReversed(boolean rev) { - xReversed_ = rev; - } - /** - * @since sgt 3.0 - */ - public boolean isXReversed() { - return xReversed_; - } - /** - * @since sgt 3.0 - */ - public void setYReversed(boolean rev) { - yReversed_ = rev; - } - /** - * @since sgt 3.0 - */ - public boolean isYReversed() { - return yReversed_; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTPoint.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTPoint.java deleted file mode 100755 index 0bfa261c..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTPoint.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * $Id: SoTPoint.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.io.Serializable; - -/** - * SoTPoint has two coordinates which are of - * type SoTValue. SoT stands for - * space or time, but being basically lazy I've abbreviated it. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @sgt 2.0 - */ -public class SoTPoint implements Serializable, Cloneable { - /** X coordinate */ - private SoTValue x_; - /** Y coordinate */ - private SoTValue y_; - /** - * Default constructor. - */ - public SoTPoint() { - } - /** - * Construct a SoTPoint from SoTValues. - * - * @param x space or time coordinate - * @param y space or time coordinate - */ - public SoTPoint(SoTValue x, SoTValue y) { - x_ = x; - y_ = y; - } - /** - * Construct a SoTPoint from doubles. - */ - public SoTPoint(double x, double y) { - this(new SoTValue.Double(x), new SoTValue.Double(y)); - } - /** - * Construct a SoTPoint from a double and - * a GeoDate. - */ - public SoTPoint(double x, GeoDate y) { - this(new SoTValue.Double(x), new SoTValue.Time(y)); - } - /** - * @since sgt 3.0 - */ - public SoTPoint(double x, long y) { - this(new SoTValue.Double(x), new SoTValue.Time(y)); - } - /** - * Construct a SoTPoint from a GeoDate and - * a double. - */ - public SoTPoint(GeoDate x, double y) { - this(new SoTValue.Time(x), new SoTValue.Double(y)); - } - /** - * @since sgt 3.0 - */ - public SoTPoint(long x, double y) { - this(new SoTValue.Time(x), new SoTValue.Double(y)); - } - /** - * Construct a SoTPoint from a SoTPoint. - */ - public SoTPoint(SoTPoint pt) { - this(pt.getX(), pt.getY()); - } - /** - * Get x value - */ - public SoTValue getX() { - return x_; - } - /** - * Set x value - * @since sgt 3.0 - */ - public void setX(SoTValue x) { - x_ = x; - } - /** - * Get y value - */ - public SoTValue getY() { - return y_; - } - /** - * Set y value - * @since sgt 3.0 - */ - public void setY(SoTValue y) { - y_ = y; - } - /** - * Test for equality. For equality both x and y values must be - * equal. - */ - public boolean equals(SoTPoint stp) { - return (x_.equals(stp.getX()) && - y_.equals(stp.getY())); - } - /** - * Test if x value is time - */ - public boolean isXTime() { - return x_.isTime(); - } - /** - * Test if y value is time - */ - public boolean isYTime() { - return y_.isTime(); - } - /** - * Add to point. - * - * @since sgt 3.0 - */ - public void add(SoTPoint point) { - x_.add(point.getX()); - y_.add(point.getY()); - } - /** - * Make a copy of the SoTRange. - * @since sgt 3.0 - */ - public SoTPoint copy() { - try { - return (SoTPoint)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - /** - * Convert SoTPoint to a default string - * - * @return string representation of the SoTPoint. - */ - public String toString() { - return new String("(" + x_ + ", " + y_ + ")"); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTRange.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTRange.java deleted file mode 100755 index 190a84be..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTRange.java +++ /dev/null @@ -1,1150 +0,0 @@ -/* - * $Id: SoTRange.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -/** - * SoTRange is an abstract class used to wrap either a - * double or GeoDate. SoT stands for - * space or time, but being basically lazy I've abbreviated it. - * Contains minimum, maximum, and delta SoTRange. - * The SoTRange object represents the range of all - * missing data as Double.NaN - * as the start and end values for data of type Double - * and return GeoDate(Long.MIN_VALUE) for data of type - * GeoDate. - * - * @author Donald Denbo - * @verstion $Revision: 1.1.1.1 $ $Date: 2007/09/07 06:32:05 $ - * @since sgt 2.0 - * @see gov.noaa.pmel.sgt.dm.SGTData - */ -public abstract class SoTRange implements java.io.Serializable, Cloneable { - /** - * Inner class for SoTRange for type - * GeoDate. - * @since sgt 2.0 - * @deprecated As of sgt 3.0, replaced by {@link gov.noaa.pmel.util.SoTRange.Time SoTRange.Time} - */ - public static class GeoDate extends SoTRange { - /** The range's first time */ - public gov.noaa.pmel.util.GeoDate start = null; - /** The range's last time */ - public gov.noaa.pmel.util.GeoDate end = null; - /** The range's time increment */ - public gov.noaa.pmel.util.GeoDate delta = null; - /** - * the Default constructor - */ - public GeoDate() { - } - /** - * Constructor - * - * @param tstart first time - * @param tend last time - */ - public GeoDate(gov.noaa.pmel.util.GeoDate tstart, - gov.noaa.pmel.util.GeoDate tend) { - this(tstart, tend, null); - } - /** - * Constructor - * - * @param tstart first time - * @param tend last time - * @param delta time increment - */ - public GeoDate(gov.noaa.pmel.util.GeoDate tstart, - gov.noaa.pmel.util.GeoDate tend, - gov.noaa.pmel.util.GeoDate tdelta) { - this.start = tstart; - this.end = tend; - this.delta = tdelta; - } - /** - * @deprecated use SoTRange - */ - public GeoDate(TimeRange trange) { - start = new gov.noaa.pmel.util.GeoDate(trange.start.getTime()); - end = new gov.noaa.pmel.util.GeoDate(trange.end.getTime()); - if(trange.delta != null) { - delta = new gov.noaa.pmel.util.GeoDate(trange.delta.getTime()); - } else { - delta = null; - } - } - /** - * Get start value - */ - public SoTValue getStart() { - return new SoTValue.GeoDate(start); - } - public void setStart(SoTValue value) { - start = ((SoTValue.GeoDate)value).getValue(); - } - /** - * Get end value - */ - public SoTValue getEnd() { - return new SoTValue.GeoDate(end); - } - public void setEnd(SoTValue value) { - end = ((SoTValue.GeoDate)value).getValue(); - } - /** - * Get delta value - */ - public SoTValue getDelta() { - return new SoTValue.GeoDate(delta); - } - public void setDelta(SoTValue value) { - delta = ((SoTValue.GeoDate)value).getValue(); - } - public Object getStartObject() { - return start; - } - public Object getEndObject() { - return end; - } - public Object getDeltaObject() { - return delta; - } - /** - * Adds the TimeRange object to this - * TimeRange. The resulting TimeRange is - * the smallest TimeRange that contains both the - * origial TimeRange and the specified - * TimeRange. - */ - public void add(SoTRange tr) { - if(!tr.isTime()) return; - SoTRange.GeoDate tRange = (SoTRange.GeoDate)tr; - - if(tRange.start.before(start)) start = tRange.start; - if(tRange.end.after(end)) end = tRange.end; - } - /** - * Test for equality. For equality start, end, and delta must all - * be equal. - */ - public boolean equals(SoTRange tr) { - if(!tr.isTime()) return false; - - SoTRange.GeoDate tRange = (SoTRange.GeoDate)tr; - if(start != null && tRange.start != null) { - if(!start.equals(tRange.start)) return false; - } else { - return false; - } - if(end != null && tRange.end != null) { - if(!end.equals(tRange.end)) return false; - } else { - return false; - } - if(delta != null && tRange.delta != null) { - if(!delta.equals(tRange.delta)) return false; - } else if(delta == null && tRange.delta == null){ - return true; - } else { - return false; - } - return true; - } - /** - * Test if SoTRange is temporal. - */ - public boolean isTime() { - return true; - } - /** - * Exchange start and end values - */ - public void flipStartAndEnd() { - gov.noaa.pmel.util.GeoDate save = end; - end = start; - start = save; - } - - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(delta == null) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } - /** - * Make a copy of the SoTRange. - */ - public SoTRange copy() { - gov.noaa.pmel.util.GeoDate cStart = null; - gov.noaa.pmel.util.GeoDate cEnd = null; - gov.noaa.pmel.util.GeoDate cDelta = null; - if(start != null) - cStart = new gov.noaa.pmel.util.GeoDate(start.getTime()); - if(end != null) - cEnd = new gov.noaa.pmel.util.GeoDate(end.getTime()); - if(delta != null) - cDelta = new gov.noaa.pmel.util.GeoDate(delta.getTime()); - - SoTRange.GeoDate cRange = new SoTRange.GeoDate(cStart, cEnd, cDelta); - return cRange; - } - /** - * Test if start or end is missing - */ - public boolean isStartOrEndMissing() { - if((start == null) || (end == null)) return true; - if(start.isMissing() || end.isMissing()) return true; - return false; - } - - } - /** - * Inner class for SoTRange for type - * long. Alternative method for storing - * time range. - * @since sgt 3.0 - */ - public static class Time extends SoTRange { - /** The range's first value */ - public long start; - /** The range's last value */ - public long end; - /** The value of the increment */ - public long delta; - /** - * Default constructor. - */ - public Time() { - this(java.lang.Long.MAX_VALUE, - java.lang.Long.MAX_VALUE, - java.lang.Long.MAX_VALUE); - } - /** - * Construct SoTRange with start and end. Default for - * delta is MAX_VALUE - * - * @param ustart first value - * @param uend last value - */ - public Time(long ustart, long uend) { - this(ustart, uend, java.lang.Long.MAX_VALUE); - } - public Time(gov.noaa.pmel.util.GeoDate ustart, - gov.noaa.pmel.util.GeoDate uend) { - this(ustart.getTime(), uend.getTime(), java.lang.Long.MAX_VALUE); - } - /** - * SoTRange constructor. - * - * @param ustart first value - * @param uend last value - * @param udel increment value - */ - public Time(long ustart, long uend, long udel) { - start = ustart; - end = uend; - delta = udel; - } - public Time(gov.noaa.pmel.util.GeoDate ustart, - gov.noaa.pmel.util.GeoDate uend, - gov.noaa.pmel.util.GeoDate udel) { - this(ustart.getTime(), uend.getTime(), udel.getTime()); - } - /** - * @deprecated use SoTRange - */ - public Time(TimeRange trange) { - start = trange.start.getTime(); - end = trange.end.getTime(); - if(trange.delta != null) { - delta = trange.delta.getTime(); - } else { - delta = java.lang.Long.MAX_VALUE; - } - } - /** - * @deprecated use SoTRange.Time - */ - public Time(SoTRange.GeoDate trange) { - this(trange.start, trange.end, trange.delta); - } - public Time(SoTRange.Time trange) { - this(trange.start, trange.end, trange.delta); - } - /** - * Get start value - */ - public SoTValue getStart() { - return new SoTValue.Time(start); - } - public void setStart(SoTValue value) { - start = ((SoTValue.Time)value).getValue(); - } - /** - * Get end value - */ - public SoTValue getEnd() { - return new SoTValue.Time(end); - } - public void setEnd(SoTValue value) { - end = ((SoTValue.Time)value).getValue(); - } - /** - * Get delta value - */ - public SoTValue getDelta() { - return new SoTValue.Time(delta); - } - public void setDelta(SoTValue value) { - delta = ((SoTValue.Time)value).getValue(); - } - public Object getStartObject() { - return new java.lang.Long(start); - } - public Object getEndObject() { - return new java.lang.Long(end); - } - public Object getDeltaObject() { - return new java.lang.Long(delta); - } - /** - * Adds the SoTRange object to this - * SoTRange. The resulting SoTRange is - * the smallest SoTRange that contains both the - * origial SoTRange and the specified - * SoTRange. - */ - public void add(SoTRange range) { - if(!range.isTime()) return; - if((start <= end) && - ((SoTRange.Time)range).start <= ((SoTRange.Time)range).end) { - start = Math.min(start, ((SoTRange.Time)range).start); - end = Math.max(end, ((SoTRange.Time)range).end); - } else { - start = Math.max(start, ((SoTRange.Time)range).start); - end = Math.min(end, ((SoTRange.Time)range).end); - } - } - /** - * Test for equality. For equality start, end, and delta must all - * be equal. - */ - public boolean equals(SoTRange r) { - if(r.isTime()) return false; - - long rstart = ((SoTRange.Time)r).start; - long rend = ((SoTRange.Time)r).end; - long rdelta = ((SoTRange.Time)r).delta; - - if(!(start == java.lang.Long.MAX_VALUE) && - !(rstart == java.lang.Long.MAX_VALUE)) { - if((start == java.lang.Long.MAX_VALUE) || - (rstart == java.lang.Long.MAX_VALUE)) return false; - if(start != rstart) return false; - } - if(!(end == java.lang.Long.MAX_VALUE) && - !(rend == java.lang.Long.MAX_VALUE)) { - if((end == java.lang.Long.MAX_VALUE) || - (rend == java.lang.Long.MAX_VALUE)) return false; - if(end != rend) return false; - } - if(!(delta == java.lang.Long.MAX_VALUE) && - !(rdelta == java.lang.Long.MAX_VALUE)) { - if((delta == java.lang.Long.MAX_VALUE) || - (rdelta == java.lang.Long.MAX_VALUE)) return false; - if(delta != rdelta) return false; - } - return true; - } - /** - * Test if SoTRange is temportal - */ - public boolean isTime() { - return true; - } - /** - * Exchange start and end values - */ - public void flipStartAndEnd() { - long save = end; - end = start; - start = save; - } - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(delta == java.lang.Long.MAX_VALUE) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } - /** - * Make a copy of the SoTRange. - */ - public SoTRange copy() { - try { - return (SoTRange)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - /** - * Test if start or end values are missing - */ - public boolean isStartOrEndMissing() { - return (start == java.lang.Long.MAX_VALUE) || - (end == java.lang.Long.MAX_VALUE); - } - } - /** - * Inner class for SoTRange for type - * integer. - * @since sgt 2.0 - */ - public static class Integer extends SoTRange { - /** The range's first value */ - public int start; - /** The range's last value */ - public int end; - /** The value of the increment */ - public int delta; - /** - * Default constructor. - */ - public Integer() { - this(java.lang.Integer.MAX_VALUE, - java.lang.Integer.MAX_VALUE, - java.lang.Integer.MAX_VALUE); - } - /** - * Construct SoTRange with start and end. Default for - * delta is MAX_VALUE - * - * @param ustart first value - * @param uend last value - */ - public Integer(int ustart,int uend) { - this(ustart, uend, java.lang.Integer.MAX_VALUE); - } - /** - * SoTRange constructor. - * - * @param ustart first value - * @param uend last value - * @param udel increment value - */ - public Integer(int ustart, int uend, int udel) { - start = ustart; - end = uend; - delta = udel; - } - /** - * Construct a SoTRange from a Range. - */ - public Integer(Range range) { - start = range.start; - end = range.end; - delta = java.lang.Integer.MAX_VALUE; - } - /** - * Get start value - */ - public SoTValue getStart() { - return new SoTValue.Integer(start); - } - public void setStart(SoTValue value) { - start = ((SoTValue.Integer)value).getValue(); - } - /** - * Get end value - */ - public SoTValue getEnd() { - return new SoTValue.Integer(end); - } - public void setEnd(SoTValue value) { - end = ((SoTValue.Integer)value).getValue(); - } - /** - * Get delta value - */ - public SoTValue getDelta() { - return new SoTValue.Integer(delta); - } - public void setDelta(SoTValue value) { - delta = ((SoTValue.Integer)value).getValue(); - } - public Object getStartObject() { - return new java.lang.Integer(start); - } - public Object getEndObject() { - return new java.lang.Integer(end); - } - public Object getDeltaObject() { - return new java.lang.Integer(delta); - } - /** - * Adds the SoTRange object to this - * SoTRange. The resulting SoTRange is - * the smallest SoTRange that contains both the - * origial SoTRange and the specified - * SoTRange. - */ - public void add(SoTRange range) { - if(range.isTime()) return; - if((start <= end) && - ((SoTRange.Integer)range).start <= ((SoTRange.Integer)range).end) { - start = Math.min(start, ((SoTRange.Integer)range).start); - end = Math.max(end, ((SoTRange.Integer)range).end); - } else { - start = Math.max(start, ((SoTRange.Integer)range).start); - end = Math.min(end, ((SoTRange.Integer)range).end); - } - } - /** - * Test for equality. For equality start, end, and delta must all - * be equal. - */ - public boolean equals(SoTRange r) { - if(r.isTime()) return false; - - int rstart = ((SoTRange.Integer)r).start; - int rend = ((SoTRange.Integer)r).end; - int rdelta = ((SoTRange.Integer)r).delta; - - if(!(start == java.lang.Integer.MAX_VALUE) && - !(rstart == java.lang.Integer.MAX_VALUE)) { - if((start == java.lang.Integer.MAX_VALUE) || - (rstart == java.lang.Integer.MAX_VALUE)) return false; - if(start != rstart) return false; - } - if(!(end == java.lang.Integer.MAX_VALUE) && - !(rend == java.lang.Integer.MAX_VALUE)) { - if((end == java.lang.Integer.MAX_VALUE) || - (rend == java.lang.Integer.MAX_VALUE)) return false; - if(end != rend) return false; - } - if(!(delta == java.lang.Integer.MAX_VALUE) && - !(rdelta == java.lang.Integer.MAX_VALUE)) { - if((delta == java.lang.Integer.MAX_VALUE) || - (rdelta == java.lang.Integer.MAX_VALUE)) return false; - if(delta != rdelta) return false; - } - return true; - } - /** - * Test if SoTRange is temportal - */ - public boolean isTime() { - return false; - } - /** - * Exchange start and end values - */ - public void flipStartAndEnd() { - int save = end; - end = start; - start = save; - } - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(delta == java.lang.Integer.MAX_VALUE) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } - /** - * Make a copy of the SoTRange. - */ - public SoTRange copy() { - try { - return (SoTRange)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - /** - * Test if start or end values are missing - */ - public boolean isStartOrEndMissing() { - return (start == java.lang.Integer.MAX_VALUE) || - (end == java.lang.Integer.MAX_VALUE); - } - } - /** - * Inner class for SoTRange for type - * short. - * @since sgt 2.0 - */ - public static class Short extends SoTRange { - /** The range's first value */ - public short start; - /** The range's last value */ - public short end; - /** The value of the increment */ - public short delta; - /** - * Default constructor. - */ - public Short() { - this(java.lang.Short.MAX_VALUE, - java.lang.Short.MAX_VALUE, - java.lang.Short.MAX_VALUE); - } - /** - * Construct SoTRange with start and end. Default for - * delta is MAX_VALUE - * - * @param ustart first value - * @param uend last value - */ - public Short(short ustart,short uend) { - this(ustart, uend, java.lang.Short.MAX_VALUE); - } - /** - * SoTRange constructor. - * - * @param ustart first value - * @param uend last value - * @param udel increment value - */ - public Short(short ustart, short uend, short udel) { - start = ustart; - end = uend; - delta = udel; - } -// /** -// * Construct a SoTRange from a Range2D. -// */ -// public Double(Range2D range) { -// start = range.start; -// end = range.end; -// delta = range.delta; -// } - /** - * Get start value - */ - public SoTValue getStart() { - return new SoTValue.Short(start); - } - public void setStart(SoTValue value) { - start = ((SoTValue.Short)value).getValue(); - } - /** - * Get end value - */ - public SoTValue getEnd() { - return new SoTValue.Short(end); - } - public void setEnd(SoTValue value) { - end = ((SoTValue.Short)value).getValue(); - } - /** - * Get delta value - */ - public SoTValue getDelta() { - return new SoTValue.Short(delta); - } - public void setDelta(SoTValue value) { - delta = ((SoTValue.Short)value).getValue(); - } - public Object getStartObject() { - return new java.lang.Short(start); - } - public Object getEndObject() { - return new java.lang.Short(end); - } - public Object getDeltaObject() { - return new java.lang.Short(delta); - } - /** - * Adds the SoTRange object to this - * SoTRange. The resulting SoTRange is - * the smallest SoTRange that contains both the - * origial SoTRange and the specified - * SoTRange. - */ - public void add(SoTRange range) { - if(range.isTime()) return; - if((start <= end) && - ((SoTRange.Short)range).start <= ((SoTRange.Short)range).end) { - start = (short)Math.min(start, ((SoTRange.Short)range).start); - end = (short)Math.max(end, ((SoTRange.Short)range).end); - } else { - start = (short)Math.max(start, ((SoTRange.Short)range).start); - end = (short)Math.min(end, ((SoTRange.Short)range).end); - } - } - /** - * Test for equality. For equality start, end, and delta must all - * be equal. - */ - public boolean equals(SoTRange r) { - if(r.isTime()) return false; - - short rstart = ((SoTRange.Short)r).start; - short rend = ((SoTRange.Short)r).end; - short rdelta = ((SoTRange.Short)r).delta; - - if(!(start == java.lang.Short.MAX_VALUE) && - !(rstart == java.lang.Short.MAX_VALUE)) { - if((start == java.lang.Short.MAX_VALUE) || - (rstart == java.lang.Short.MAX_VALUE)) return false; - if(start != rstart) return false; - } - if(!(end == java.lang.Short.MAX_VALUE) && - !(rend == java.lang.Short.MAX_VALUE)) { - if((end == java.lang.Short.MAX_VALUE) || - (rend == java.lang.Short.MAX_VALUE)) return false; - if(end != rend) return false; - } - if(!(delta == java.lang.Short.MAX_VALUE) && - !(rdelta == java.lang.Short.MAX_VALUE)) { - if((delta == java.lang.Short.MAX_VALUE) || - (rdelta == java.lang.Short.MAX_VALUE)) return false; - if(delta != rdelta) return false; - } - return true; - } - /** - * Test if SoTRange is temportal - */ - public boolean isTime() { - return false; - } - /** - * Exchange start and end values - */ - public void flipStartAndEnd() { - short save = end; - end = start; - start = save; - } - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(delta == java.lang.Short.MAX_VALUE) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } - /** - * Make a copy of the SoTRange. - */ - public SoTRange copy() { - try { - return (SoTRange)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - /** - * Test if start or end values are missing - */ - public boolean isStartOrEndMissing() { - return (start == java.lang.Short.MAX_VALUE) || - (end == java.lang.Short.MAX_VALUE); - } - } - /** - * Inner class for SoTRange for type - * flaot. - * @since sgt 2.0 - */ - public static class Float extends SoTRange { - /** The range's first value */ - public float start; - /** The range's last value */ - public float end; - /** The value of the increment */ - public float delta; - /** - * Default constructor. - */ - public Float() { - this(java.lang.Float.NaN, - java.lang.Float.NaN, - java.lang.Float.NaN); - } - /** - * Construct SoTRange with start and end. Default for - * delta is NaN - * - * @param ustart first value - * @param uend last value - */ - public Float(float ustart,float uend) { - this(ustart, uend, java.lang.Float.NaN); - } - /** - * SoTRange constructor. - * - * @param ustart first value - * @param uend last value - * @param udel increment value - */ - public Float(float ustart,float uend,float udel) { - start = ustart; - end = uend; - delta = udel; - } -// /** -// * Construct a SoTRange from a Range2D. -// */ -// public Float(Range2D range) { -// start = range.start; -// end = range.end; -// delta = range.delta; -// } - /** - * Get start value - */ - public SoTValue getStart() { - return new SoTValue.Float(start); - } - public void setStart(SoTValue value) { - start = ((SoTValue.Float)value).getValue(); - } - /** - * Get end value - */ - public SoTValue getEnd() { - return new SoTValue.Float(end); - } - public void setEnd(SoTValue value) { - end = ((SoTValue.Float)value).getValue(); - } - /** - * Get delta value - */ - public SoTValue getDelta() { - return new SoTValue.Float(delta); - } - public void setDelta(SoTValue value) { - delta = ((SoTValue.Float)value).getValue(); - } - public Object getStartObject() { - return new java.lang.Float(start); - } - public Object getEndObject() { - return new java.lang.Float(end); - } - public Object getDeltaObject() { - return new java.lang.Float(delta); - } - /** - * Adds the SoTRange object to this - * SoTRange. The resulting SoTRange is - * the smallest SoTRange that contains both the - * origial SoTRange and the specified - * SoTRange. - */ - public void add(SoTRange range) { - if(range.isTime()) return; - if((start <= end) && - ((SoTRange.Float)range).start <= ((SoTRange.Float)range).end) { - start = Math.min(start, ((SoTRange.Float)range).start); - end = Math.max(end, ((SoTRange.Float)range).end); - } else { - start = Math.max(start, ((SoTRange.Float)range).start); - end = Math.min(end, ((SoTRange.Float)range).end); - } - } - /** - * Test for equality. For equality start, end, and delta must all - * be equal. - */ - public boolean equals(SoTRange r) { - if(r.isTime()) return false; - - float rstart = ((SoTRange.Float)r).start; - float rend = ((SoTRange.Float)r).end; - float rdelta = ((SoTRange.Float)r).delta; - - if(!java.lang.Float.isNaN(start) && - !java.lang.Float.isNaN(rstart)) { - if(java.lang.Float.isNaN(start) || - java.lang.Float.isNaN(rstart)) return false; - if(start != rstart) return false; - } - if(!java.lang.Float.isNaN(end) && - !java.lang.Float.isNaN(rend)) { - if(java.lang.Float.isNaN(end) || - java.lang.Float.isNaN(rend)) return false; - if(end != rend) return false; - } - if(!java.lang.Float.isNaN(delta) && - !java.lang.Float.isNaN(rdelta)) { - if(java.lang.Float.isNaN(delta) || - java.lang.Float.isNaN(rdelta)) return false; - if(delta != rdelta) return false; - } - return true; - } - /** - * Test if SoTRange is temportal - */ - public boolean isTime() { - return false; - } - /** - * Exchange start and end values - */ - public void flipStartAndEnd() { - float save = end; - end = start; - start = save; - } - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(java.lang.Float.isNaN(delta)) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } - /** - * Make a copy of the SoTRange. - */ - public SoTRange copy() { - try { - return (SoTRange)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - /** - * Test if start or end values are missing - */ - public boolean isStartOrEndMissing() { - return java.lang.Float.isNaN(start) || - java.lang.Float.isNaN(end); - } - } - /** - * Inner class for SoTRange for type - * double. - * @since sgt 2.0 - */ - public static class Double extends SoTRange { - /** The range's first value */ - public double start; - /** The range's last value */ - public double end; - /** The value of the increment */ - public double delta; - /** - * Default constructor. - */ - public Double() { - this(java.lang.Double.NaN, - java.lang.Double.NaN, - java.lang.Double.NaN); - } - /** - * Construct SoTRange with start and end. Default for - * delta is NaN - * - * @param ustart first value - * @param uend last value - */ - public Double(double ustart,double uend) { - this(ustart, uend, java.lang.Double.NaN); - } - /** - * SoTRange constructor. - * - * @param ustart first value - * @param uend last value - * @param udel increment value - */ - public Double(double ustart,double uend,double udel) { - start = ustart; - end = uend; - delta = udel; - } - /** - * Construct a SoTRange from a Range2D. - */ - public Double(Range2D range) { - start = range.start; - end = range.end; - delta = range.delta; - } - /** - * Get start value - */ - public SoTValue getStart() { - return new SoTValue.Double(start); - } - public void setStart(SoTValue value) { - start = ((SoTValue.Double)value).getValue(); - } - /** - * Get end value - */ - public SoTValue getEnd() { - return new SoTValue.Double(end); - } - public void setEnd(SoTValue value) { - end = ((SoTValue.Double)value).getValue(); - } - /** - * Get delta value - */ - public SoTValue getDelta() { - return new SoTValue.Double(delta); - } - public void setDelta(SoTValue value) { - delta = ((SoTValue.Double)value).getValue(); - } - public Object getStartObject() { - return new java.lang.Double(start); - } - public Object getEndObject() { - return new java.lang.Double(end); - } - public Object getDeltaObject() { - return new java.lang.Double(delta); - } - /** - * Adds the SoTRange object to this - * SoTRange. The resulting SoTRange is - * the smallest SoTRange that contains both the - * origial SoTRange and the specified - * SoTRange. - */ - public void add(SoTRange range) { - if(range.isTime()) return; - if((start <= end) && - ((SoTRange.Double)range).start <= ((SoTRange.Double)range).end) { - start = Math.min(start, ((SoTRange.Double)range).start); - end = Math.max(end, ((SoTRange.Double)range).end); - } else { - start = Math.max(start, ((SoTRange.Double)range).start); - end = Math.min(end, ((SoTRange.Double)range).end); - } - } - /** - * Test for equality. For equality start, end, and delta must all - * be equal. - */ - public boolean equals(SoTRange r) { - if(r.isTime()) return false; - - double rstart = ((SoTRange.Double)r).start; - double rend = ((SoTRange.Double)r).end; - double rdelta = ((SoTRange.Double)r).delta; - - if(!java.lang.Double.isNaN(start) && - !java.lang.Double.isNaN(rstart)) { - if(java.lang.Double.isNaN(start) || - java.lang.Double.isNaN(rstart)) return false; - if(start != rstart) return false; - } - if(!java.lang.Double.isNaN(end) && - !java.lang.Double.isNaN(rend)) { - if(java.lang.Double.isNaN(end) || - java.lang.Double.isNaN(rend)) return false; - if(end != rend) return false; - } - if(!java.lang.Double.isNaN(delta) && - !java.lang.Double.isNaN(rdelta)) { - if(java.lang.Double.isNaN(delta) || - java.lang.Double.isNaN(rdelta)) return false; - if(delta != rdelta) return false; - } - return true; - } - /** - * Test if SoTRange is temportal - */ - public boolean isTime() { - return false; - } - /** - * Exchange start and end values - */ - public void flipStartAndEnd() { - double save = end; - end = start; - start = save; - } - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(java.lang.Double.isNaN(delta)) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } - /** - * Make a copy of the SoTRange. - */ - public SoTRange copy() { - try { - return (SoTRange)clone(); - } catch (CloneNotSupportedException e) { - return null; - } - } - /** - * Test if start or end values are missing - */ - public boolean isStartOrEndMissing() { - return java.lang.Double.isNaN(start) || - java.lang.Double.isNaN(end); - } - } - - /** - * This is an abstract class that cannot be instantiated directly. - * Type-specific implementation subclasses are available for - * instantiation and provide a number of formats for storing - * the information necessary to satisfy the various accessor - * methods below. - * - */ - protected SoTRange() {} - - public abstract boolean isTime(); - public abstract String toString(); - public abstract boolean equals(SoTRange range); - public abstract void add(SoTRange range); - public abstract SoTValue getStart(); - public abstract SoTValue getEnd(); - public abstract SoTValue getDelta(); - public abstract Object getStartObject(); - public abstract Object getEndObject(); - public abstract Object getDeltaObject(); - public abstract void setStart(SoTValue value); - public abstract void setEnd(SoTValue value); - public abstract void setDelta(SoTValue value); - public abstract void flipStartAndEnd(); - public abstract boolean isStartOrEndMissing(); - public abstract SoTRange copy(); -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTValue.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTValue.java deleted file mode 100755 index ae330739..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/SoTValue.java +++ /dev/null @@ -1,544 +0,0 @@ -/* - * $Id: SoTValue.java,v 1.1.1.1 2007/09/07 06:32:05 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import java.io.Serializable; - -/** - * SoTValue is an abstract class used to wrap either a - * double or GeoDate. SoT stands for - * space or time, but being basically lazy I've abbreviated it. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:05 $ - * @since sgt 2.0 - */ -public abstract class SoTValue implements Serializable { - /** - * Inner class for SoTRange for type - * GeoDate. - * @since sgt 2.0 - * @deprecated As of sgt 3.0, replaced by {@link gov.noaa.pmel.util.SoTValue.Time SoTValue.Time} - */ - public static class GeoDate extends SoTValue { - gov.noaa.pmel.util.GeoDate date_; - /** - * Default constructor. - */ - public GeoDate() {} - /** - * Construct a SoTValue from a GeoDate. - */ - public GeoDate(gov.noaa.pmel.util.GeoDate date) { - date_ = date; - } - /** - * Construct a SoTValue and initialize it to - * represent the specified number of milliseconds since the - * standard base time known as "the epoch", namely January 1, - * 1970, 00:00:00. - */ - public GeoDate(long time) { - this(new gov.noaa.pmel.util.GeoDate(time)); - } - /** - * Get the value - */ - public gov.noaa.pmel.util.GeoDate getValue() { - return date_; - } - /** - * Set the value from a GeoDate - */ - public void setValue(gov.noaa.pmel.util.GeoDate date) { - date_ = date; - } - /** - * Set the value from the number of milliseconds since the epoch. - */ - public void setValue(long time) { - date_ = new gov.noaa.pmel.util.GeoDate(time); - } - public Object getObjectValue() { - return date_; - } - /** - * Test if SoTValue is time. - */ - public boolean isTime() { - return true; - } - /** - * Test for equality - */ - public boolean equals(SoTValue val) { - if(val.isTime()) { - return date_.equals(((SoTValue.GeoDate)val).getValue()); - } else { - return false; - } - } - /** - * Add to value. - * - * @since 3.0 - */ - public void add(SoTValue val) { - if(!val.isTime()) return; - date_.add(((SoTValue.GeoDate)val).getValue()); - } - /** - * Get time as long since 1970-01-01. - * - * @since 3.0 - */ - public long getLongTime() { - if(date_ == null) return Long.MAX_VALUE; - return date_.getTime(); - } - /** - * Get time as GeoDate. - * - * @since 3.0 - */ - public gov.noaa.pmel.util.GeoDate getGeoDate() { - return new gov.noaa.pmel.util.GeoDate(date_); - } - - public String toString() { - return date_.toString(); - } - } - /** - * Inner class for SoTRange for type - * long. Used for time storage. - * @since sgt 3.0 - */ - public static class Time extends SoTValue { - long value_; - /** - * Default constructor. - */ - public Time() {} - /** - * Construct and initialize value. - */ - public Time(long value) { - value_ = value; - } - public Time(gov.noaa.pmel.util.GeoDate value) { - value_ = value.getTime(); - } - /** - * Get the value - */ - public long getValue() { - return value_; - } - /** - * Set the value - */ - public void setValue(long value) { - value_ = value; - } - public Object getObjectValue() { - return new java.lang.Long(value_); - } - /** - * Test if SoTValue is time - */ - public boolean isTime() { - return true; - } - /** - * Test for equality - */ - public boolean equals(SoTValue val) { - if(val.isTime()) { - return value_ == ((SoTValue.Time)val).getValue(); - } else { - return false; - } - } - /** - * Add to value. - * - * @since 3.0 - */ - public void add(SoTValue val) { - if(!val.isTime()) return; - long dval = val.getLongTime(); - value_ += dval; - } - /** - * Get time as long since 1970-01-01. - * - * @since 3.0 - */ - public long getLongTime() { - return value_; - } - /** - * Get time as GeoDate. - * - * @since 3.0 - */ - public gov.noaa.pmel.util.GeoDate getGeoDate() { - return new gov.noaa.pmel.util.GeoDate(value_); - } - - public String toString() { -// return java.lang.Long.toString(value_); - return getGeoDate().toString(); - } - } - - - /** - * Inner class for SoTRange for type - * int. - * @since sgt 2.0 - */ - public static class Integer extends SoTValue { - int value_; - /** - * Default constructor. - */ - public Integer() {} - /** - * Construct and initialize value. - */ - public Integer(int value) { - value_ = value; - } - /** - * Get the value - */ - public int getValue() { - return value_; - } - /** - * Set the value - */ - public void setValue(int value) { - value_ = value; - } - public Object getObjectValue() { - return new java.lang.Integer(value_); - } - /** - * Test if SoTValue is time - */ - public boolean isTime() { - return false; - } - /** - * Test for equality - */ - public boolean equals(SoTValue val) { - if(val.isTime()) { - return false; - } else { - return value_ == ((SoTValue.Integer)val).getValue(); - } - } - /** - * Add to value. - * - * @since 3.0 - */ - public void add(SoTValue val) { - if(val.isTime()) return; - int dval = ((Number)val.getObjectValue()).intValue(); - value_ += dval; - } - /** - * Get time as long since 1970-01-01. - * - * @since 3.0 - */ - public long getLongTime() { - throw new Error("Method not appropriate for SoTValue.Int"); - } - /** - * Get time as GeoDate. - * - * @since 3.0 - */ - public gov.noaa.pmel.util.GeoDate getGeoDate() { - throw new Error("Method not appropriate for SoTValue.Int"); - } - - public String toString() { - return java.lang.Integer.toString(value_); - } - } - - /** - * Inner class for SoTRange for type - * short. - * @since sgt 2.0 - */ - public static class Short extends SoTValue { - short value_; - /** - * Default constructor. - */ - public Short() {} - /** - * Construct and initialize value. - */ - public Short(short value) { - value_ = value; - } - /** - * Get the value - */ - public short getValue() { - return value_; - } - /** - * Set the value - */ - public void setValue(short value) { - value_ = value; - } - public Object getObjectValue() { - return new java.lang.Short(value_); - } - /** - * Test if SoTValue is time - */ - public boolean isTime() { - return false; - } - /** - * Test for equality - */ - public boolean equals(SoTValue val) { - if(val.isTime()) { - return false; - } else { - return value_ == ((SoTValue.Short)val).getValue(); - } - } - /** - * Add to value. - * - * @since 3.0 - */ - public void add(SoTValue val) { - if(val.isTime()) return; - short dval = ((Number)val.getObjectValue()).shortValue(); - value_ += dval; - } - /** - * Get time as long since 1970-01-01. - * - * @since 3.0 - */ - public long getLongTime() { - throw new Error("Method not appropriate for SoTValue.Short"); - } - /** - * Get time as GeoDate. - * - * @since 3.0 - */ - public gov.noaa.pmel.util.GeoDate getGeoDate() { - throw new Error("Method not appropriate for SoTValue.Short"); - } - - public String toString() { - return java.lang.Short.toString(value_); - } - } - - /** - * Inner class for SoTRange for type - * float. - * @since sgt 2.0 - */ - public static class Float extends SoTValue { - float value_; - /** - * Default constructor. - */ - public Float() {} - /** - * Construct and initialize value. - */ - public Float(float value) { - value_ = value; - } - /** - * Get the value - */ - public float getValue() { - return value_; - } - /** - * Set the value - */ - public void setValue(float value) { - value_ = value; - } - public Object getObjectValue() { - return new java.lang.Float(value_); - } - /** - * Test if SoTValue is time - */ - public boolean isTime() { - return false; - } - /** - * Test for equality - */ - public boolean equals(SoTValue val) { - if(val.isTime()) { - return false; - } else { - return value_ == ((SoTValue.Float)val).getValue(); - } - } - /** - * Add to value. - * - * @since 3.0 - */ - public void add(SoTValue val) { - if(val.isTime()) return; - float dval = ((Number)val.getObjectValue()).floatValue(); - value_ += dval; - } - /** - * Get time as long since 1970-01-01. - * - * @since 3.0 - */ - public long getLongTime() { - throw new Error("Method not appropriate for SoTValue.Float"); - } - /** - * Get time as GeoDate. - * - * @since 3.0 - */ - public gov.noaa.pmel.util.GeoDate getGeoDate() { - throw new Error("Method not appropriate for SoTValue.Float"); - } - - public String toString() { - return java.lang.Float.toString(value_); - } - } - - /** - * Inner class for SoTRange for type - * double. - * @since sgt 2.0 - */ - public static class Double extends SoTValue { - double value_; - /** - * Default constructor. - */ - public Double() {} - /** - * Construct and initialize value. - */ - public Double(double value) { - value_ = value; - } - /** - * Get the value - */ - public double getValue() { - return value_; - } - /** - * Set the value - */ - public void setValue(double value) { - value_ = value; - } - public Object getObjectValue() { - return new java.lang.Double(value_); - } - /** - * Test if SoTValue is time - */ - public boolean isTime() { - return false; - } - /** - * Test for equality - */ - public boolean equals(SoTValue val) { - if(val.isTime()) { - return false; - } else { - return value_ == ((SoTValue.Double)val).getValue(); - } - } - /** - * Add to value. - * - * @since 3.0 - */ - public void add(SoTValue val) { - if(val.isTime()) return; - double dval = ((Number)val.getObjectValue()).doubleValue(); - value_ += dval; - } - /** - * Get time as long since 1970-01-01. - * - * @since 3.0 - */ - public long getLongTime() { - throw new Error("Method not appropriate for SoTValue.Double"); - } - /** - * Get time as GeoDate. - * - * @since 3.0 - */ - public gov.noaa.pmel.util.GeoDate getGeoDate() { - throw new Error("Method not appropriate for SoTValue.Double"); - } - public String toString() { - return java.lang.Double.toString(value_); - } - } - - /** - * This is an abstract class that cannot be instantiated directly. - * Type-specific implementation subclasses are available for - * instantiation and provide a number of formats for storing - * the information necessary to satisfy the various accessor - * methods below. - * - */ - protected SoTValue() {} - - public abstract boolean isTime(); - public abstract String toString(); - public abstract boolean equals(SoTValue val); - public abstract Object getObjectValue(); - public abstract long getLongTime(); - public abstract gov.noaa.pmel.util.GeoDate getGeoDate(); - public abstract void add(SoTValue val); -} - diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/TimePoint.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/TimePoint.java deleted file mode 100755 index 0497d318..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/TimePoint.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * $Id: TimePoint.java,v 1.1.1.1 2007/09/07 06:32:06 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -/** - * TimePoint allows specification of a time-space point. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:06 $ - * @since sgt 1.0 - * - * @deprecated As of sgt 3.0, replaced by {@link gov.noaa.pmel.util.SoTPoint SoTPoint}. - */ -public class TimePoint { - /** Space coordinate */ - public double x; - /** Time coordinate */ - public GeoDate t; - /** - * Default constructor. - */ - public TimePoint() { - } - /** - * Construct a TimePoint. - * - * @param x space coordinate - * @param t time coordinate - */ - public TimePoint(double x,GeoDate t) { - this.x = x; - this.t = t; - } - /** - * Test for equality. Both x and t must be equal for equality. - */ - public boolean equals(TimePoint tp) { - if(t != null && tp.t != null) { - return (x == tp.x && t.equals(tp.t)); - } else { - return false; - } - } - /** - * Convert TimePoint to a default string - * - * @return string representation of the TimePoint. - */ - public String toString() { - return new String("(" + x + ", " + t.toString() + ")"); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/TimeRange.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/TimeRange.java deleted file mode 100755 index 194400e7..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/TimeRange.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * $Id: TimeRange.java,v 1.1.1.1 2007/09/07 06:32:06 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -/** - * Contains minimum and maximum Time values. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:06 $ - * @since sgt 1.0 - * - * @deprecated As of sgt 3.0, use {@link gov.noaa.pmel.util.SoTRange.Time SoTRange.Time} - */ -public class TimeRange implements java.io.Serializable { - /** The range's first time */ - public GeoDate start; - /** The range's last time */ - public GeoDate end; - /** The range's time increment */ - public GeoDate delta; - /** - * the Default constructor - */ - public TimeRange() { - } - /** - * Constructor - * - * @param tstart first time - * @param tend last time - */ - public TimeRange(GeoDate tstart,GeoDate tend) { - this(tstart, tend, null); - } - public TimeRange(long start, long end) { - this(new GeoDate(start), new GeoDate(end)); - } - /** - * Constructor - * - * @param tstart first time - * @param tend last time - * @param delta time increment - */ - public TimeRange(GeoDate tstart,GeoDate tend, GeoDate tdelta) { - this.start = tstart; - this.end = tend; - this.delta = tdelta; - } - public TimeRange(long start, long end, long delta) { - this(new GeoDate(start), new GeoDate(end), new GeoDate(delta)); - } - /** - * Adds the TimeRange object to this - * TimeRange. The resulting TimeRange is - * the smallest TimeRange that contains both the - * origial TimeRange and the specified - * TimeRange. - */ - public void add(TimeRange trange) { - if(trange.start.before(start)) start = trange.start; - if(trange.end.after(end)) end = trange.end; - } - /** - * Test for equality. The start, end, and delta must all be equal - * for equality. - */ - public boolean equals(TimeRange tr) { - if(start != null && tr.start != null) { - if(!start.equals(tr.start)) return false; - } else { - return false; - } - if(end != null && tr.end != null) { - if(!end.equals(tr.end)) return false; - } else { - return false; - } - if(delta != null && tr.delta != null) { - if(!delta.equals(tr.delta)) return false; - } else { - return false; - } - return true; - } - public String toString() { - StringBuffer buf = new StringBuffer(50); - buf.append("[").append(start).append(";").append(end); - if(delta == null) { - buf.append("]"); - } else { - buf.append(";").append(delta).append("]"); - } - return buf.toString(); - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Units.java b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Units.java deleted file mode 100755 index 6e5e1dc2..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/Units.java +++ /dev/null @@ -1,786 +0,0 @@ -/* - * $Id: Units.java,v 1.1.1.1 2007/09/07 06:32:06 koennecke Exp $ - * - * This software is provided by NOAA for full, free and open release. It is - * understood by the recipient/user that NOAA assumes no liability for any - * errors contained in the code. Although this software is released without - * conditions or restrictions in its use, it is expected that appropriate - * credit be given to its author and to the National Oceanic and Atmospheric - * Administration should the software be included by the recipient as an - * element in other product development. - */ - -package gov.noaa.pmel.util; - -import gov.noaa.pmel.sgt.dm.SGTMetaData; -import gov.noaa.pmel.sgt.dm.SGTData; -import gov.noaa.pmel.sgt.dm.SGTLine; -import gov.noaa.pmel.sgt.dm.SGTGrid; -import gov.noaa.pmel.sgt.dm.SimpleLine; -import gov.noaa.pmel.sgt.dm.SimpleGrid; - -import java.lang.reflect.Constructor; - -/** - * Units is a static class for converting the units of DependentVariables. - * - * @author Donald Denbo - * @version $Revision: 1.1.1.1 $, $Date: 2007/09/07 06:32:06 $ - * @since sgt 1.0 -**/ -public class Units implements java.io.Serializable { - /** No base units selected */ - public static final int NONE = 0; - /** base units are temperature */ - public static final int TEMPERATURE = 1; - /** base units are velocity */ - public static final int VELOCITY = 2; - /** base units are distance */ - public static final int DISTANCE = 3; - /** check X MetaData for units */ - public static final int X_AXIS = 0; - /** check Y MetaData for units */ - public static final int Y_AXIS = 1; - /** check Z MetaData for units */ - public static final int Z_AXIS = 2; - /** - * Return the base unit for the meta data. - * - * @return TEMPERATURE, VELOCITY, DISTANCE, or NONE - */ - public static int getBaseUnit(SGTMetaData meta) { - if(Temperature.isBaseUnit(meta)) { - return TEMPERATURE; - } else if(Velocity.isBaseUnit(meta)) { - return VELOCITY; - } else if(Distance.isBaseUnit(meta)) { - return DISTANCE; - } else { - return NONE; - } - } - /** - * Convert data to common units. - * - * @param grid the data - * @param base the base units, TEMPERATURE, VELOCITY, DISTANCE, or NONE - * @param comp grid component, X_AXIS, Y_AXIS, or Z_AXIS - */ - public static SGTData convertToBaseUnit(SGTData grid, int base, int comp) { - switch(base) { - case TEMPERATURE: return Temperature.convertToBaseUnit(grid, comp); - case VELOCITY: return Velocity.convertToBaseUnit(grid, comp); - case DISTANCE: return Distance.convertToBaseUnit(grid, comp); - default: - case NONE: return grid; - } - } -} -/** - * Supports temperature conversions. - */ -class Temperature implements java.io.Serializable { - // - // All conversions are to the default units of degC - // - // degC = scale*origUnits + offset - // - private static final String[] name = - {"C", "degC", "K", "degK", "F", "degF", "k", "deg_c", "deg_k"}; - private static final double[] scale = - {1.0, 1.0, 1.0, 1.0, 5.0/9.0, 5.0/9.0, 1.0, 1.0, 1.0}; - private static final double[] offset = - {0.0, 0.0, -273.15, -273.15, 32.0*5.0/9.0, 32.0*5.0/9.0, -273.15, 0.0, -273.15}; - // - private static final String timeArrayName = "[Lgov.noaa.pmel.util.GeoDate"; - private static final String doubleArrayName = "[D"; - private static final String stringName = "java.lang.String"; - /** - * - */ - static SGTData convertToBaseUnit(SGTData grid, int comp) { - int unit, count; - boolean hand; - // GeoVariable xDim, yDim, zDim; - // TimeVariable tDim; - // DependentVariable variable, new_variable; - // VarDesc new_vardesc; - SGTData new_grid = null; - SGTMetaData meta, newMeta; - int projection; - - String units; - switch(comp) { - default: - case Units.X_AXIS: - meta = ((SGTLine)grid).getXMetaData(); - break; - case Units.Y_AXIS: - meta = ((SGTLine)grid).getYMetaData(); - break; - case Units.Z_AXIS: - meta = ((SGTGrid)grid).getZMetaData(); - } - units = meta.getUnits(); - // - // is it one of the changeable units? - // - for(unit = 0; unit < name.length; unit++) { - if(units.equals(name[unit])) break; - } - - if(unit >= name.length) return grid; - // - // is it already in the base units? - // - if(scale[unit] == 1.0 && offset[unit] == 0.0) return grid; - // - // convert the units - // - double values[], new_values[]; - switch(comp) { - default: - case Units.X_AXIS: - values = ((SGTLine)grid).getXArray(); - break; - case Units.Y_AXIS: - values = ((SGTLine)grid).getYArray(); - break; - case Units.Z_AXIS: - values = ((SGTGrid)grid).getZArray(); - } - new_values = new double[values.length]; - - for(count=0; count < values.length; count++) { - new_values[count] = scale[unit]*values[count] + offset[unit]; - } - // - // build the new dependent variable - // - newMeta = new SGTMetaData(meta.getName(), "degC", meta.isReversed(), meta.isModulo()); - newMeta.setModuloValue(meta.getModuloValue()); - newMeta.setModuloTime(meta.getModuloTime()); - - if(grid instanceof SGTLine) { - boolean simpleLine = grid instanceof SimpleLine; - if(simpleLine) { - new_grid = (SGTLine)grid.copy(); - } - Class[] classArgs = new Class[3]; - Object[] constructArgs = new Object[3]; - Class gridClass = grid.getClass(); - Constructor gridConstruct; - switch(comp) { - default: - case Units.X_AXIS: - if(simpleLine) { - ((SimpleLine)new_grid).setXArray(new_values); - } else { - if(((SGTLine)grid).isYTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(timeArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTLine)grid).getTimeArray(); - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTLine)grid).getYArray(); - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } - ((SimpleLine)new_grid).setYMetaData(((SGTLine)grid).getYMetaData()); - } - ((SimpleLine)new_grid).setXMetaData(newMeta); - break; - case Units.Y_AXIS: - if(simpleLine) { - ((SimpleLine)new_grid).setYArray(new_values); - } else { - if(((SGTLine)grid).isXTime()) { - try { - classArgs[0] = Class.forName(timeArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTLine)grid).getTimeArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTLine)grid).getXArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } - ((SimpleLine)new_grid).setXMetaData(((SGTLine)grid).getXMetaData()); - } - ((SimpleLine)new_grid).setYMetaData(newMeta); - } - } else if(grid instanceof SGTGrid) { - boolean simpleGrid = grid instanceof SimpleGrid; - if(simpleGrid) { - new_grid = (SGTGrid)grid.copy(); - } - Class[] classArgs = new Class[4]; - Object[] constructArgs = new Object[4]; - Class gridClass = grid.getClass(); - Constructor gridConstruct; - switch(comp) { - default: - case Units.X_AXIS: - if(simpleGrid) { - ((SimpleGrid)new_grid).setXArray(new_values); - } else { - if(((SGTGrid)grid).isYTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(timeArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTGrid)grid).getYArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } - ((SimpleGrid)new_grid).setYMetaData(((SGTGrid)grid).getYMetaData()); - ((SimpleGrid)new_grid).setZMetaData(((SGTGrid)grid).getZMetaData()); - } - ((SimpleGrid)new_grid).setXMetaData(newMeta); - break; - case Units.Y_AXIS: - if(simpleGrid) { - ((SimpleGrid)new_grid).setYArray(new_values); - } else { - if(((SGTGrid)grid).isXTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(timeArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = new_values; - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = ((SGTGrid)grid).getXArray(); - constructArgs[2] = new_values; - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } - ((SimpleGrid)new_grid).setXMetaData(((SGTGrid)grid).getXMetaData()); - ((SimpleGrid)new_grid).setZMetaData(((SGTGrid)grid).getZMetaData()); - } - ((SimpleGrid)new_grid).setYMetaData(newMeta); - break; - case Units.Z_AXIS: - if(simpleGrid) { - ((SimpleGrid)new_grid).setZArray(new_values); - } else { - if(((SGTGrid)grid).isXTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(timeArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = ((SGTGrid)grid).getYArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } else if(((SGTGrid)grid).isYTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(timeArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTGrid)grid).getXArray(); - constructArgs[2] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTGrid)grid).getXArray(); - constructArgs[2] = ((SGTGrid)grid).getYArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Temperature conversion: " + e); - } - } - ((SimpleGrid)new_grid).setXMetaData(((SGTGrid)grid).getXMetaData()); - ((SimpleGrid)new_grid).setYMetaData(((SGTGrid)grid).getYMetaData()); - } - ((SimpleGrid)new_grid).setZMetaData(newMeta); - } - } - return new_grid; - } - - static boolean isBaseUnit(SGTMetaData meta) { - int count; - String units = meta.getUnits(); - - for(count=0; count < name.length; count++) { - if(units.equals(name[count])) return true; - } - return false; - } -} - -/** - * Supports distance conversions. - */ -class Distance implements java.io.Serializable { - static SGTData convertToBaseUnit(SGTData grid, int comp) { - return grid; - } - static boolean isBaseUnit(SGTMetaData meta) { - return false; - } -} - -/** - * Supports velocity conversions. - */ -class Velocity implements java.io.Serializable { - // - // All conversions are to the default units of "m s-1" - // - // m s-1 = scale*origUnits + offset - // - private static final String[] name = - {"m s-1", "m/s", "cm s-1", "cm/s"}; - private static final double[] scale = - {1.0, 1.0, 0.01, 0.01}; - private static final double[] offset = - {0.0, 0.0, 0.0, 0.0}; - // - private static final String timeArrayName = "[Lgov.noaa.pmel.util.GeoDate"; - private static final String doubleArrayName = "[D"; - private static final String stringName = "java.lang.String"; - /** - * - */ - static SGTData convertToBaseUnit(SGTData grid, int comp) { - int unit, count; - boolean hand; - // GeoVariable xDim, yDim, zDim; - // TimeVariable tDim; - // DependentVariable variable, new_variable; - // VarDesc new_vardesc; - SGTData new_grid = null; - SGTMetaData meta, newMeta; - int projection; - - String units; - switch(comp) { - default: - case Units.X_AXIS: - meta = ((SGTLine)grid).getXMetaData(); - break; - case Units.Y_AXIS: - meta = ((SGTLine)grid).getYMetaData(); - break; - case Units.Z_AXIS: - meta = ((SGTGrid)grid).getZMetaData(); - } - units = meta.getUnits(); - // - // is it one of the changeable units? - // - for(unit = 0; unit < name.length; unit++) { - if(units.equals(name[unit])) break; - } - - if(unit >= name.length) return grid; - // - // is it already in the base units? - // - if(scale[unit] == 1.0 && offset[unit] == 0.0) return grid; - // - // convert the units - // - double values[], new_values[]; - switch(comp) { - default: - case Units.X_AXIS: - values = ((SGTLine)grid).getXArray(); - break; - case Units.Y_AXIS: - values = ((SGTLine)grid).getYArray(); - break; - case Units.Z_AXIS: - values = ((SGTGrid)grid).getZArray(); - } - new_values = new double[values.length]; - - for(count=0; count < values.length; count++) { - new_values[count] = scale[unit]*values[count] + offset[unit]; - } - // - // build the new dependent variable - // - newMeta = new SGTMetaData(meta.getName(), - "m s-1", - meta.isReversed(), - meta.isModulo()); - newMeta.setModuloValue(meta.getModuloValue()); - newMeta.setModuloTime(meta.getModuloTime()); - - if(grid instanceof SGTLine) { - boolean simpleLine = grid instanceof SimpleLine; - if(simpleLine) { - new_grid = (SGTLine)grid.copy(); - } - Class[] classArgs = new Class[3]; - Object[] constructArgs = new Object[3]; - Class gridClass = grid.getClass(); - Constructor gridConstruct; - switch(comp) { - default: - case Units.X_AXIS: - if(simpleLine) { - ((SimpleLine)new_grid).setXArray(new_values); - } else { - if(((SGTLine)grid).isYTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(timeArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTLine)grid).getTimeArray(); - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } - // new_grid = new SimpleLine(new_values, - // ((SGTLine)grid).getTimeArray(), - // ((SGTLine)grid).getTitle()); - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTLine)grid).getYArray(); - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } - // new_grid = new SimpleLine(new_values, - // ((SGTLine)grid).getYArray(), - // ((SGTLine)grid).getTitle()); - } - ((SimpleLine)new_grid).setYMetaData(((SGTLine)grid).getYMetaData()); - } - ((SimpleLine)new_grid).setXMetaData(newMeta); - break; - case Units.Y_AXIS: - if(simpleLine) { - ((SimpleLine)new_grid).setYArray(new_values); - } else { - if(((SGTLine)grid).isXTime()) { - try { - classArgs[0] = Class.forName(timeArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTLine)grid).getTimeArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } - // new_grid = new SimpleLine(((SGTLine)grid).getTimeArray(), - // new_values, - // ((SGTLine)grid).getTitle()); - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTLine)grid).getXArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTLine)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } - // new_grid = new SimpleLine(((SGTLine)grid).getXArray(), - // new_values, - // ((SGTLine)grid).getTitle()); - } - ((SimpleLine)new_grid).setXMetaData(((SGTLine)grid).getXMetaData()); - } - ((SimpleLine)new_grid).setYMetaData(newMeta); - } - } else if(grid instanceof SGTGrid) { - boolean simpleGrid = grid instanceof SimpleGrid; - if(simpleGrid) { - new_grid = (SGTGrid)grid.copy(); - } - Class[] classArgs = new Class[4]; - Object[] constructArgs = new Object[4]; - Class gridClass = grid.getClass(); - Constructor gridConstruct; - switch(comp) { - default: - case Units.X_AXIS: - if(simpleGrid) { - ((SimpleGrid)new_grid).setXArray(new_values); - } else { - if(((SGTGrid)grid).isYTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(timeArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } -// new_grid = new SimpleGrid(((SGTGrid)grid).getZArray(), -// new_values, -// ((SGTGrid)grid).getTimeArray(), -// ((SGTGrid)grid).getTitle()); - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = new_values; - constructArgs[2] = ((SGTGrid)grid).getYArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } -// new_grid = new SimpleGrid(((SGTGrid)grid).getZArray(), -// new_values, -// ((SGTGrid)grid).getYArray(), -// ((SGTGrid)grid).getTitle()); - } - ((SimpleGrid)new_grid).setYMetaData(((SGTGrid)grid).getYMetaData()); - ((SimpleGrid)new_grid).setZMetaData(((SGTGrid)grid).getZMetaData()); - } - ((SimpleGrid)new_grid).setXMetaData(newMeta); - break; - case Units.Y_AXIS: - if(simpleGrid) { - ((SimpleGrid)new_grid).setYArray(new_values); - } else { - if(((SGTGrid)grid).isXTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(timeArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = new_values; - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } -// new_grid = new SimpleGrid(((SGTGrid)grid).getZArray(), -// ((SGTGrid)grid).getTimeArray(), -// new_values, -// ((SGTGrid)grid).getTitle()); - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = ((SGTGrid)grid).getZArray(); - constructArgs[1] = ((SGTGrid)grid).getXArray(); - constructArgs[2] = new_values; - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } -// new_grid = new SimpleGrid(((SGTGrid)grid).getZArray(), -// ((SGTGrid)grid).getXArray(), -// new_values, -// ((SGTGrid)grid).getTitle()); - } - ((SimpleGrid)new_grid).setXMetaData(((SGTGrid)grid).getXMetaData()); - ((SimpleGrid)new_grid).setZMetaData(((SGTGrid)grid).getZMetaData()); - } - ((SimpleGrid)new_grid).setYMetaData(newMeta); - break; - case Units.Z_AXIS: - if(simpleGrid) { - ((SimpleGrid)new_grid).setZArray(new_values); - } else { - if(((SGTGrid)grid).isXTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(timeArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = ((SGTGrid)grid).getYArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } -// new_grid = new SimpleGrid(new_values, -// ((SGTGrid)grid).getTimeArray(), -// ((SGTGrid)grid).getYArray(), -// ((SGTGrid)grid).getTitle()); - } else if(((SGTGrid)grid).isYTime()) { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(timeArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTGrid)grid).getXArray(); - constructArgs[2] = ((SGTGrid)grid).getTimeArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } -// new_grid = new SimpleGrid(new_values, -// ((SGTGrid)grid).getXArray(), -// ((SGTGrid)grid).getTimeArray(), -// ((SGTGrid)grid).getTitle()); - } else { - try { - classArgs[0] = Class.forName(doubleArrayName); - classArgs[1] = Class.forName(doubleArrayName); - classArgs[2] = Class.forName(doubleArrayName); - classArgs[3] = Class.forName(stringName); - gridConstruct = gridClass.getConstructor(classArgs); - constructArgs[0] = new_values; - constructArgs[1] = ((SGTGrid)grid).getXArray(); - constructArgs[2] = ((SGTGrid)grid).getYArray(); - constructArgs[2] = ((SGTGrid)grid).getTitle(); - new_grid = (SGTData)gridConstruct.newInstance(constructArgs); - } catch (java.lang.Exception e) { - System.out.println("Velocity conversion: " + e); - } -// new_grid = new SimpleGrid(new_values, -// ((SGTGrid)grid).getXArray(), -// ((SGTGrid)grid).getYArray(), -// ((SGTGrid)grid).getTitle()); - } - ((SimpleGrid)new_grid).setXMetaData(((SGTGrid)grid).getXMetaData()); - ((SimpleGrid)new_grid).setYMetaData(((SGTGrid)grid).getYMetaData()); - } - ((SimpleGrid)new_grid).setZMetaData(newMeta); - } - - } - return new_grid; - } - static boolean isBaseUnit(SGTMetaData meta) { - int count; - String units = meta.getUnits(); - - for(count=0; count < name.length; count++) { - if(units.equals(name[count])) return true; - } - return false; - } -} diff --git a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/package.html b/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/package.html deleted file mode 100755 index 1b399125..00000000 --- a/contrib/applications/nxplot/sgtgraphics/src/gov/noaa/pmel/util/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Contains date and time facilities and miscellaneous utility classes. - - - - \ No newline at end of file diff --git a/contrib/applications/nxplot/sharedscientific/.classpath b/contrib/applications/nxplot/sharedscientific/.classpath deleted file mode 100755 index ad32c83a..00000000 --- a/contrib/applications/nxplot/sharedscientific/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/contrib/applications/nxplot/sharedscientific/.project b/contrib/applications/nxplot/sharedscientific/.project deleted file mode 100755 index 31b8ae0c..00000000 --- a/contrib/applications/nxplot/sharedscientific/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - sharedscientific - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/contrib/applications/nxplot/sharedscientific/.settings/org.eclipse.jdt.core.prefs b/contrib/applications/nxplot/sharedscientific/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index f17f926a..00000000 --- a/contrib/applications/nxplot/sharedscientific/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Mon Aug 31 16:27:10 CEST 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/contrib/applications/nxplot/sharedscientific/META-INF/MANIFEST.MF b/contrib/applications/nxplot/sharedscientific/META-INF/MANIFEST.MF deleted file mode 100755 index e318a434..00000000 --- a/contrib/applications/nxplot/sharedscientific/META-INF/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Shared Scientific Toolbox -Bundle-SymbolicName: sharedscientific -Bundle-Version: 1.0.0 -Bundle-Vendor: http://hubris.ucsd.edu/shared/ -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: shared.array diff --git a/contrib/applications/nxplot/sharedscientific/bin/font/Vera.ttf b/contrib/applications/nxplot/sharedscientific/bin/font/Vera.ttf deleted file mode 100755 index 58cd6b5e..00000000 Binary files a/contrib/applications/nxplot/sharedscientific/bin/font/Vera.ttf and /dev/null differ diff --git a/contrib/applications/nxplot/sharedscientific/bin/shared/log4j.xml b/contrib/applications/nxplot/sharedscientific/bin/shared/log4j.xml deleted file mode 100755 index c47d8359..00000000 --- a/contrib/applications/nxplot/sharedscientific/bin/shared/log4j.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/sharedscientific/bin/shared/project.properties b/contrib/applications/nxplot/sharedscientific/bin/shared/project.properties deleted file mode 100755 index 29ceaa46..00000000 --- a/contrib/applications/nxplot/sharedscientific/bin/shared/project.properties +++ /dev/null @@ -1,3 +0,0 @@ -### Properties with values specific to the SST. ### - -build.version = 1.10 diff --git a/contrib/applications/nxplot/sharedscientific/build.properties b/contrib/applications/nxplot/sharedscientific/build.properties deleted file mode 100755 index 34d2e4d2..00000000 --- a/contrib/applications/nxplot/sharedscientific/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/contrib/applications/nxplot/sharedscientific/src/font/Vera.ttf b/contrib/applications/nxplot/sharedscientific/src/font/Vera.ttf deleted file mode 100755 index 58cd6b5e..00000000 Binary files a/contrib/applications/nxplot/sharedscientific/src/font/Vera.ttf and /dev/null differ diff --git a/contrib/applications/nxplot/sharedscientific/src/font/package-info.java b/contrib/applications/nxplot/sharedscientific/src/font/package-info.java deleted file mode 100755 index cf564850..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/font/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * The location, by convention, of fonts. - */ -package font; - diff --git a/contrib/applications/nxplot/sharedscientific/src/lib/package-info.java b/contrib/applications/nxplot/sharedscientific/src/lib/package-info.java deleted file mode 100755 index 99a5c0e2..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/lib/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * The location, by convention, of Jar and native libraries. - */ -package lib; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/Constants.java b/contrib/applications/nxplot/sharedscientific/src/shared/Constants.java deleted file mode 100755 index 92950384..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/Constants.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Properties; - -/** - * Contains SST constant values. - * - * @author Roy Liu - */ -public class Constants { - - /** - * The major version of the software. - */ - final public static int MAJOR_VERSION; - - /** - * The minor version of the software. - */ - final public static int MINOR_VERSION; - - static { - - Properties p = new Properties(); - - try { - - p.load(Constants.class.getClassLoader().getResourceAsStream("shared/project.properties")); - - } catch (IOException e) { - - throw new RuntimeException(e); - } - - BigDecimal version = new BigDecimal(p.getProperty("build.version")); - - int versionAsInt = version.movePointRight(2).intValue(); - - MAJOR_VERSION = versionAsInt / 100; - MINOR_VERSION = versionAsInt % 100; - } - - // Dummy constructor. - Constants() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractArray.java deleted file mode 100755 index 72f24ea7..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractArray.java +++ /dev/null @@ -1,332 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.FFTService; -import static shared.array.ArrayBase.FIELD_PRECISION; -import static shared.array.ArrayBase.FIELD_WIDTH; -import static shared.array.ArrayBase.formatEmptyArray; -import static shared.array.ArrayBase.formatRescale; -import static shared.array.ArrayBase.formatSlice; - -import java.util.Arrays; -import java.util.Formatter; - -import shared.array.kernel.MappingOps; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * An abstract base class for multidimensional arrays of real and complex values. - * - * @apiviz.uses shared.array.ArrayBase - * @param - * the base parameterization. - * @param - * the "up" parameterization representing the forwards FFT type. - * @param - * the "down" parameterization representing the backwards FFT type. - * @param - * the array element type. - * @author Roy Liu - */ -abstract public class AbstractArray, U extends AbstractArray, D extends AbstractArray, E> - extends ProtoArray { - - /** - * An extra bit of information to help {@link #rifft()} correctly size destination arrays. - */ - final protected int parity; - - /** - * A value for {@link #parity} indicating that this array was not the result of {@link #rfft()}. - */ - final protected static int INVALID_PARITY = -1; - - /** - * Default constructor. - */ - protected AbstractArray(double[] values, int parity, IndexingOrder order, int[] dims, int[] strides) { - super(values, order, dims, strides); - - this.parity = parity; - } - - /** - * Creates an instance of the base type. - */ - abstract protected T wrap(int parity, IndexingOrder order, int[] dims, int[] strides); - - /** - * Creates an instance of the "up" type after a forwards FFT. - */ - abstract protected U wrapUp(int parity, IndexingOrder order, int[] dims, int[] strides); - - /** - * Creates an instance of the "down" type after a backwards FFT. - */ - abstract protected D wrapDown(int parity, IndexingOrder order, int[] dims, int[] strides); - - /** - * Gets the value at the given logical index. - */ - public double get(int... s) { - return this.values[physical(s)]; - } - - /** - * Sets the value at the given logical index. - */ - public void set(double value, int... s) { - this.values[physical(s)] = value; - } - - @Override - public double[] values() { - return this.values; - } - - @Override - protected T wrap(IndexingOrder order, int[] dims, int[] strides) { - return wrap(this.parity, order, dims, strides); - } - - @Override - public String toString() { - - double[] values = this.values; - int[] dims = this.dims; - int[] strides = this.strides; - - int ndims = dims.length; - int nrows = (ndims == 1) ? 1 : size(ndims - 2); - int ncols = size(ndims - 1); - int sliceSize = nrows * ncols; - - int exponent = (int) Math.log10(Arithmetic.max( // - Arithmetic.max(values), Math.abs(Arithmetic.min(values)), 1e-128)); - - Formatter f = new Formatter(); - - if (values.length == 0) { - - formatEmptyArray(f, dims); - - return f.toString(); - } - - String format = String.format("%%%d.%df", FIELD_WIDTH, FIELD_PRECISION); - - values = formatRescale(f, exponent, values); - - int[] indices = MappingOps.assignMappingIndices(Arithmetic.product(dims), // - dims, strides); - - strides = IndexingOrder.FAR.strides(dims); - - if (ndims <= 2) { - - f.format("%n"); - - formatSlice(f, format, // - values, indices, 0, nrows, ncols, false); - - return f.toString(); - } - - for (int offset = 0, m = values.length; offset < m; offset += sliceSize) { - - f.format("%n[slice ("); - - for (int i = 0, n = ndims - 2, offsetAcc = offset; i < n; offsetAcc %= strides[i], i++) { - f.format("%d, ", offsetAcc / strides[i]); - } - - f.format(":, :)]%n"); - - formatSlice(f, format, // - values, indices, offset, nrows, ncols, false); - } - - return f.toString(); - } - - /** - * Infers dimensions from the backing array length if the number of declared dimensions is {@code 0}. - * - * @param dims - * the declared dimensions. - * @param len - * the array length. - * @param isComplex - * whether the array contains complex values. - * @return the inferred dimensions. - */ - protected static int[] inferDimensions(int[] dims, int len, boolean isComplex) { - return (dims.length > 0) ? dims.clone() : (isComplex ? new int[] { - Control.checkEquals(len, (len >>> 1) << 1) >>> 1, 2 } : new int[] { len }); - } - - /** - * Computes the reduced FFT of this array. - */ - protected U rfft() { - - int[] newDims = rfftDimensions(); - - // Very important: Derive the original size from the parity. - U dst = wrapUp(this.dims[this.dims.length - 1] % 2, DEFAULT_ORDER, newDims, this.order.strides(newDims)); - - FFTService.rfft(this.dims, values(), dst.values()); - - return dst; - } - - /** - * Computes the reduced IFFT of this array. - */ - protected D rifft() { - - int[] newDims = rifftDimensions(); - - D dst = wrapDown(INVALID_PARITY, DEFAULT_ORDER, newDims, this.order.strides(newDims)); - - FFTService.rifft(dst.dims, values(), dst.values()); - - return dst; - } - - /** - * Computes the full FFT of this array. - */ - protected T fft() { - return transform(+1); - } - - /** - * Computes the full IFFT of this array. - */ - protected T ifft() { - return transform(-1); - } - - /** - * Gets the reduced FFT dimensions. - */ - protected int[] rfftDimensions() { - - int ndims = this.dims.length; - int lastDimSize = (this.dims[ndims - 1] / 2 + 1); - - int[] dimsModified = Arrays.copyOf(this.dims, ndims + 1); - dimsModified[ndims - 1] = lastDimSize; - dimsModified[ndims] = 2; - - return dimsModified; - } - - /** - * Gets the reduced IFFT dimensions. - */ - protected int[] rifftDimensions() { - - Control.checkTrue(this.parity != INVALID_PARITY, // - "Array must have valid parity"); - - int ndims = this.dims.length; - int lastDimSize = (this.dims[ndims - 2] - 1) * 2 + this.parity; - - int[] dimsModified = Arrays.copyOf(this.dims, ndims - 1); - dimsModified[ndims - 2] = lastDimSize; - - return dimsModified; - } - - /** - * Checks that this array has storage order {@link ArrayBase#DEFAULT_ORDER}. - */ - protected void checkMatrixOrder() { - Control.checkTrue(this.order == DEFAULT_ORDER, // - "Array must have row major indexing"); - } - - /** - * Checks that this array's parity is {@link #INVALID_PARITY}. - */ - protected void checkInvalidParity() { - Control.checkTrue(this.parity == INVALID_PARITY, // - "Array must have invalid parity"); - } - - /** - * Checks that two {@link AbstractArray}s have the same size and underlying {@link Array.IndexingOrder}. - * - * @param b - * the {@link AbstractArray} to compare to. - * @return the common {@link #parity} value. - */ - protected int checkShape(T b) { - - AbstractArray a = this; - - final int parity = Control.checkEquals(a.parity, b.parity, // - "Parity mismatch"); - - Control.checkTrue(a.order == b.order, // - "Indexing orders do not match"); - - Control.checkTrue(Arrays.equals(a.dims, b.dims), // - "Dimensions do not match"); - - return parity; - } - - /** - * Transforms this array in the forwards/backwards FFT direction. - * - * @param direction - * the FFT direction. - * @return the transformed array. - */ - @SuppressWarnings("unchecked") - protected T transform(int direction) { - - checkInvalidParity(); - - T a = (T) this; - - T res = wrap(INVALID_PARITY, DEFAULT_ORDER, a.dims, a.strides); - - switch (direction) { - - case +1: - FFTService.fft(Arrays.copyOf(a.dims, a.dims.length - 1), a.values, res.values); - break; - - case -1: - FFTService.ifft(Arrays.copyOf(a.dims, a.dims.length - 1), a.values, res.values); - break; - - default: - throw new IllegalArgumentException("Direction not recognized"); - } - - return res; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractComplexArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractComplexArray.java deleted file mode 100755 index a4cd3dfe..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractComplexArray.java +++ /dev/null @@ -1,585 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.FIELD_PRECISION; -import static shared.array.ArrayBase.FIELD_WIDTH; -import static shared.array.ArrayBase.OpKernel; -import static shared.array.ArrayBase.formatEmptyArray; -import static shared.array.ArrayBase.formatRescale; -import static shared.array.ArrayBase.formatSlice; - -import java.util.Arrays; -import java.util.Formatter; - -import shared.array.kernel.ArrayKernel; -import shared.array.kernel.MappingOps; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * An abstract base class for arrays of complex values. - * - * @apiviz.owns shared.array.AbstractComplexArray.Complex - * @param - * the complex array type. - * @param - * the real array type. - * @author Roy Liu - */ -abstract public class AbstractComplexArray, R extends AbstractRealArray> - extends AbstractArray { - - /** - * Default constructor. - */ - protected AbstractComplexArray(double[] values, int parity, int[] dims, int[] strides) { - super(values, parity, DEFAULT_ORDER, dims, strides); - } - - /** - * Shifts the entries of this array to the zero frequency component. - */ - public C fftShift() { - return fftShift(+1); - } - - /** - * Undoes the effects of {@link #fftShift()}. - */ - public C ifftShift() { - return fftShift(-1); - } - - /** - * Depending on the direction, performs an {@link #fftShift()} or {@link #ifftShift()} of this array. - * - * @param direction - * the shift direction. - * @return the shifted array. - */ - protected C fftShift(int direction) { - - checkInvalidParity(); - - int ndims = this.dims.length; - int[] shift = new int[ndims]; - - for (int i = 0, n = ndims - 1; i < n; i++) { - shift[i] = direction * (this.dims[i] / 2); - } - - return shift(shift); - } - - @Override - public String toString() { - - double[] values = this.values; - int[] dims = this.dims; - int[] strides = this.strides; - - int ndims = dims.length; - int nrows = (ndims == 2) ? 1 : size(ndims - 3); - int ncols = size(ndims - 2); - int sliceSize = nrows * ncols * 2; - - int exponent = (int) Math.log10(Arithmetic.max( // - Arithmetic.max(values), Math.abs(Arithmetic.min(values)), 1e-128)); - - Formatter f = new Formatter(); - - if (values.length == 0) { - - formatEmptyArray(f, dims); - - return f.toString(); - } - - String format = String.format("%%%d.%df +%%%d.%dfi", // - FIELD_WIDTH, FIELD_PRECISION, FIELD_WIDTH, FIELD_PRECISION); - - values = formatRescale(f, exponent, values); - - int[] indices = MappingOps.assignMappingIndices(Arithmetic.product(dims), // - dims, strides); - - strides = IndexingOrder.FAR.strides(dims); - - if (ndims <= 3) { - - f.format("%n"); - - formatSlice(f, format, // - values, indices, 0, nrows, ncols, true); - - return f.toString(); - } - - for (int offset = 0, m = values.length; offset < m; offset += sliceSize) { - - f.format("%n[slice ("); - - for (int i = 0, n = ndims - 3, offsetAcc = offset; i < n; offsetAcc %= strides[i], i++) { - f.format("%d, ", offsetAcc / strides[i]); - } - - f.format(":, :)]%n"); - - formatSlice(f, format, // - values, indices, offset, nrows, ncols, true); - } - - return f.toString(); - } - - @Override - protected C wrap(Complex value, IndexingOrder order, int[] dims, int[] strides) { - return wrap(order, dims, strides).uFill(value.re, value.im); - } - - @Override - protected C wrapUp(int parity, IndexingOrder order, int[] dims, int[] strides) { - throw new UnsupportedOperationException(); - } - - @Override - public int[] dimensions() { - return super.dimensions(); - } - - @Override - public int[] rifftDimensions() { - return super.rifftDimensions(); - } - - @Override - public R rifft() { - return super.rifft(); - } - - @Override - public C fft() { - return super.fft(); - } - - @Override - public C ifft() { - return super.ifft(); - } - - @Override - public C subarray(int... bounds) { - - Control.checkTrue((bounds[bounds.length - 1] - bounds[bounds.length - 2]) == 2, // - "Invalid subarray bounds for complex-valued array"); - - return super.subarray(bounds); - } - - @Override - public C tile(int... repetitions) { - - Control.checkTrue(repetitions[repetitions.length - 1] == 1, // - "Invalid tile repetitions for complex-valued array"); - - return super.tile(repetitions); - } - - @Override - public C transpose(int... permutation) { - - Control.checkTrue(permutation[permutation.length - 1] == permutation.length - 1, // - "Invalid transpose permutation for complex-valued array"); - - return super.transpose(permutation); - } - - @Override - public C reshape(int... dims) { - - Control.checkTrue(dims[dims.length - 1] == 2, // - "Invalid reshape dimensions for complex-valued array"); - - return super.reshape(dims); - } - - @Override - public C reverseOrder() { - throw new UnsupportedOperationException("Cannot reverse storage orders of complex-valued arrays"); - } - - public Class getComponentType() { - return Complex.class; - } - - /** - * Creates an {@link AbstractRealArray} from the complex magnitudes of this array's elements. - */ - public R torAbs() { - return applyKernelComplexToRealOperation(ArrayKernel.CTOR_ABS); - } - - /** - * Creates an {@link AbstractRealArray} from the real parts of this array's elements. - */ - public R torRe() { - return applyKernelComplexToRealOperation(ArrayKernel.CTOR_RE); - } - - /** - * Creates an {@link AbstractRealArray} from the imaginary parts of this array's elements. - */ - public R torIm() { - return applyKernelComplexToRealOperation(ArrayKernel.CTOR_IM); - } - - /** - * Computes the elementwise addition. - */ - public C eAdd(C array) { - return applyKernelElementwiseOperation(array, ArrayKernel.CE_ADD); - } - - /** - * Computes the elementwise subtraction. - */ - public C eSub(C array) { - return applyKernelElementwiseOperation(array, ArrayKernel.CE_SUB); - } - - /** - * Computes the elementwise multiplication. - */ - public C eMul(C array) { - return applyKernelElementwiseOperation(array, ArrayKernel.CE_MUL); - } - - /** - * Computes the elementwise division. - */ - public C eDiv(C array) { - return applyKernelElementwiseOperation(array, ArrayKernel.CE_DIV); - } - - /** - * Computes the left elementwise addition. - */ - public C lAdd(C array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.CE_ADD); - } - - /** - * Computes the left elementwise subtraction. - */ - public C lSub(C array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.CE_SUB); - } - - /** - * Computes the left elementwise multiplication. - */ - public C lMul(C array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.CE_MUL); - } - - /** - * Computes the left elementwise division. - */ - public C lDiv(C array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.CE_DIV); - } - - /** - * Mutatively exponentiates the elements to the base {@link Math#E}. - */ - public C uExp() { - return applyKernelComplexUnaryOperation(Double.NaN, Double.NaN, ArrayKernel.CU_EXP); - } - - /** - * Mutatively randomizes the elements. - */ - public C uRnd(double aRe, double aIm) { - return applyKernelComplexUnaryOperation(aRe, aIm, ArrayKernel.CU_RND); - } - - /** - * Mutatively takes the complex conjugates of the elements. - */ - public C uConj() { - return applyKernelComplexUnaryOperation(Double.NaN, Double.NaN, ArrayKernel.CU_CONJ); - } - - /** - * Mutatively takes the cosine of the elements. - */ - public C uCos() { - return applyKernelComplexUnaryOperation(Double.NaN, Double.NaN, ArrayKernel.CU_COS); - } - - /** - * Mutatively takes the sine of the elements. - */ - public C uSin() { - return applyKernelComplexUnaryOperation(Double.NaN, Double.NaN, ArrayKernel.CU_SIN); - } - - /** - * Mutatively adds the argument to the elements. - */ - public C uAdd(double aRe, double aIm) { - return applyKernelComplexUnaryOperation(aRe, aIm, ArrayKernel.CU_ADD); - } - - /** - * Mutatively multiplies the elements by the argument. - */ - public C uMul(double aRe, double aIm) { - return applyKernelComplexUnaryOperation(aRe, aIm, ArrayKernel.CU_MUL); - } - - /** - * Mutatively fills this array with the argument. - */ - public C uFill(double aRe, double aIm) { - return applyKernelComplexUnaryOperation(aRe, aIm, ArrayKernel.CU_FILL); - } - - /** - * Mutatively shuffles this array. - */ - public C uShuffle() { - return applyKernelComplexUnaryOperation(Double.NaN, Double.NaN, ArrayKernel.CU_SHUFFLE); - } - - /** - * Computes the sum over the elements. - */ - public double[] aSum() { - return applyKernelComplexAccumulatorOperation(ArrayKernel.CA_SUM); - } - - /** - * Computes the product over the elements. - */ - public double[] aProd() { - return applyKernelComplexAccumulatorOperation(ArrayKernel.CA_PROD); - } - - /** - * Computes the mean over the elements. - */ - public double[] aMean() { - - int len = values().length / 2; - - double[] res = aSum(); - res[0] /= len; - res[1] /= len; - - return res; - } - - /** - * Supports the a* series of operations. - */ - protected double[] applyKernelComplexAccumulatorOperation(int type) { - return OpKernel.caOp(type, this.values); - } - - /** - * Supports the tor* series of operations. - */ - @SuppressWarnings("unchecked") - protected R applyKernelComplexToRealOperation(int type) { - - checkInvalidParity(); - - C a = (C) this; - - int[] newDims = Arrays.copyOf(a.dims, a.dims.length - 1); - - R res = wrapDown(INVALID_PARITY, a.order, newDims, a.order.strides(newDims)); - - OpKernel.convert(type, a.values, true, res.values, false); - - return res; - } - - /** - * Supports the e* series of operations. - */ - @SuppressWarnings("unchecked") - protected C applyKernelElementwiseOperation(C b, int type) { - - int parity = checkShape(b); - - C a = (C) this; - - C res = wrap(parity, a.order, a.dims, a.strides); - - OpKernel.eOp(type, a.values, b.values, res.values, true); - - return res; - } - - /** - * Supports the l* series of operations. - */ - @SuppressWarnings("unchecked") - protected C applyKernelLeftElementwiseOperation(C b, int type) { - - checkShape(b); - - C a = (C) this; - - OpKernel.eOp(type, a.values, b.values, a.values, false); - - return a; - } - - /** - * Supports the u* series of operations. - */ - @SuppressWarnings("unchecked") - protected C applyKernelComplexUnaryOperation(double aRe, double aIm, int type) { - - OpKernel.cuOp(type, aRe, aIm, this.values); - - return (C) this; - } - - /** - * A representation of complex numbers. - */ - @SuppressWarnings("serial") - public static class Complex extends Number implements Comparable { - - /** - * The real part. - */ - final public double re; - - /** - * The imaginary part. - */ - final public double im; - - /** - * Default constructor. - * - * @param re - * the real part. - * @param im - * the imaginary part. - */ - public Complex(double re, double im) { - - this.re = re; - this.im = im; - } - - /** - * Calculates the complex magnitude. - * - * @return the magnitude. - */ - public double magnitude() { - return Math.sqrt(this.re * this.re + this.im * this.im); - } - - /** - * Checks if the real and imaginary parts are equal. - */ - @Override - public boolean equals(Object o) { - - if (!(o instanceof Complex)) { - return false; - } - - Complex c = (Complex) o; - return (this.re == c.re) && (this.im == c.im); - } - - /** - * Fulfills the {@link Object#hashCode()} contract. - */ - @Override - public int hashCode() { - return (int) (Double.doubleToRawLongBits(this.re) ^ Double.doubleToRawLongBits(this.im)); - } - - /** - * Does a comparison on the basis of magnitude. - */ - public int compareTo(Complex b) { - return Double.compare(magnitude(), b.magnitude()); - } - - /** - * Gets the {@code double} value. - */ - @Override - public double doubleValue() { - return magnitude(); - } - - /** - * Gets the {@code float} value. - */ - @Override - public float floatValue() { - return new Double(magnitude()).floatValue(); - } - - /** - * Gets the {@code int} value. - */ - @Override - public int intValue() { - return new Double(magnitude()).intValue(); - } - - /** - * Gets the {@code long} value. - */ - @Override - public long longValue() { - return new Double(magnitude()).longValue(); - } - - /** - * Gets the {@code byte} value. - */ - @Override - public byte byteValue() { - return new Double(magnitude()).byteValue(); - } - - /** - * Creates a human-readable representation of this number. - */ - @Override - public String toString() { - return String.format("%f + %fi", this.re, this.im); - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractRealArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractRealArray.java deleted file mode 100755 index 73da56ce..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/AbstractRealArray.java +++ /dev/null @@ -1,686 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.OpKernel; - -import java.util.Arrays; - -import shared.array.kernel.ArrayKernel; - -/** - * An abstract base class for arrays of real values. - * - * @apiviz.has shared.array.AbstractRealArray.RealMap - - - argument - * @apiviz.has shared.array.AbstractRealArray.RealReduce - - - argument - * @param - * the real array type. - * @param - * the complex array type. - * @author Roy Liu - */ -abstract public class AbstractRealArray, C extends AbstractComplexArray> - extends AbstractArray { - - /** - * Default constructor. - */ - protected AbstractRealArray(double[] values, IndexingOrder order, int[] dims, int[] strides) { - super(values, INVALID_PARITY, order, dims, strides); - } - - @Override - protected R wrap(Double value, IndexingOrder order, int[] dims, int[] strides) { - return wrap(order, dims, strides).uFill(value); - } - - @Override - protected R wrapDown(int parity, IndexingOrder order, int[] dims, int[] strides) { - throw new IllegalStateException(); - } - - @Override - public int[] dimensions() { - return super.dimensions(); - } - - @Override - public int[] rfftDimensions() { - return super.rfftDimensions(); - } - - @Override - public C rfft() { - return super.rfft(); - } - - public Class getComponentType() { - return Double.class; - } - - /** - * Creates an {@link AbstractComplexArray} with the real parts set to this array's elements. - */ - public C tocRe() { - return applyKernelRealToComplexOperation(ArrayKernel.RTOC_RE); - } - - /** - * Creates an {@link AbstractComplexArray} with the imaginary parts set to this array's elements. - */ - public C tocIm() { - return applyKernelRealToComplexOperation(ArrayKernel.RTOC_IM); - } - - /** - * Mutatively exponentiates the elements to the base {@link Math#E}. - */ - public R uExp() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_EXP); - } - - /** - * Mutatively takes the cosine of the elements. - */ - public R uCos() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_COS); - } - - /** - * Mutatively takes the sine of the elements. - */ - public R uSin() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_SIN); - } - - /** - * Mutatively takes the arctangent of the elements. - */ - public R uAtan() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_ATAN); - } - - /** - * Mutatively randomizes the elements. - */ - public R uRnd(double a) { - return applyKernelRealUnaryOperation(a, ArrayKernel.RU_RND); - } - - /** - * Mutatively takes the natural logarithm of the elements. - */ - public R uLog() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_LOG); - } - - /** - * Mutatively takes the absolute value of the elements. - */ - public R uAbs() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_ABS); - } - - /** - * Mutatively takes the elements to the power of the argument. - */ - public R uPow(double a) { - return applyKernelRealUnaryOperation(a, ArrayKernel.RU_POW); - } - - /** - * Mutatively adds the argument to the elements. - */ - public R uAdd(double a) { - return applyKernelRealUnaryOperation(a, ArrayKernel.RU_ADD); - } - - /** - * Mutatively multiplies the elements by the argument. - */ - public R uMul(double a) { - return applyKernelRealUnaryOperation(a, ArrayKernel.RU_MUL); - } - - /** - * Mutatively takes the square root of the elements. - */ - public R uSqrt() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_SQRT); - } - - /** - * Mutatively squares the elements. - */ - public R uSqr() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_SQR); - } - - /** - * Mutatively takes the multiplicative inverse of the elements. - */ - public R uInv(double a) { - return applyKernelRealUnaryOperation(a, ArrayKernel.RU_INV); - } - - /** - * Mutatively fills this array with the argument. - */ - public R uFill(double a) { - return applyKernelRealUnaryOperation(a, ArrayKernel.RU_FILL); - } - - /** - * Mutatively shuffles this array. - */ - public R uShuffle() { - return applyKernelRealUnaryOperation(Double.NaN, ArrayKernel.RU_SHUFFLE); - } - - /** - * Computes the elementwise addition. - */ - public R eAdd(R array) { - return applyKernelElementwiseOperation(array, ArrayKernel.RE_ADD); - } - - /** - * Computes the elementwise subtraction. - */ - public R eSub(R array) { - return applyKernelElementwiseOperation(array, ArrayKernel.RE_SUB); - } - - /** - * Computes the elementwise multiplication. - */ - public R eMul(R array) { - return applyKernelElementwiseOperation(array, ArrayKernel.RE_MUL); - } - - /** - * Computes the elementwise division. - */ - public R eDiv(R array) { - return applyKernelElementwiseOperation(array, ArrayKernel.RE_DIV); - } - - /** - * Computes the elementwise maximum. - */ - public R eMax(R array) { - return applyKernelElementwiseOperation(array, ArrayKernel.RE_MAX); - } - - /** - * Computes the elementwise minimum. - */ - public R eMin(R array) { - return applyKernelElementwiseOperation(array, ArrayKernel.RE_MIN); - } - - /** - * Computes the left elementwise addition. - */ - public R lAdd(R array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.RE_ADD); - } - - /** - * Computes the left elementwise subtraction. - */ - public R lSub(R array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.RE_SUB); - } - - /** - * Computes the left elementwise multiplication. - */ - public R lMul(R array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.RE_MUL); - } - - /** - * Computes the left elementwise division. - */ - public R lDiv(R array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.RE_DIV); - } - - /** - * Computes the left elementwise maximum. - */ - public R lMax(R array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.RE_MAX); - } - - /** - * Computes the left elementwise minimum. - */ - public R lMin(R array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.RE_MIN); - } - - /** - * Computes the sum over the elements. - */ - public double aSum() { - return applyKernelRealAccumulatorOperation(ArrayKernel.RA_SUM); - } - - /** - * Computes the product over the elements. - */ - public double aProd() { - return applyKernelRealAccumulatorOperation(ArrayKernel.RA_PROD); - } - - /** - * Computes the maximum over the elements. - */ - public double aMax() { - return applyKernelRealAccumulatorOperation(ArrayKernel.RA_MAX); - } - - /** - * Computes the variance over the elements. - */ - public double aVar() { - return applyKernelRealAccumulatorOperation(ArrayKernel.RA_VAR); - } - - /** - * Computes the entropy over the elements. - */ - public double aEnt() { - return applyKernelRealAccumulatorOperation(ArrayKernel.RA_ENT); - } - - /** - * Computes the minimum over the elements. - */ - public double aMin() { - return applyKernelRealAccumulatorOperation(ArrayKernel.RA_MIN); - } - - /** - * Computes the mean over the elements. - */ - public double aMean() { - return aSum() / values().length; - } - - /** - * Computes the sum along the given dimensions. - */ - public R rSum(int... selectedDims) { - return applyKernelRealReduceOperation(ArrayKernel.RR_SUM, selectedDims); - } - - /** - * Computes the product along the given dimensions. - */ - public R rProd(int... selectedDims) { - return applyKernelRealReduceOperation(ArrayKernel.RR_PROD, selectedDims); - } - - /** - * Computes the maximum along the given dimensions. - */ - public R rMax(int... selectedDims) { - return applyKernelRealReduceOperation(ArrayKernel.RR_MAX, selectedDims); - } - - /** - * Computes the minimum along the given dimensions. - */ - public R rMin(int... selectedDims) { - return applyKernelRealReduceOperation(ArrayKernel.RR_MIN, selectedDims); - } - - /** - * Computes the mean along the given dimensions. - */ - public R rMean(int... selectedDims) { - - int acc = 1; - - for (int dim : selectedDims) { - acc *= size(dim); - } - - return rSum(selectedDims).uMul(1.0 / acc); - } - - /** - * Computes the variance along the given dimensions. - */ - public R rVar(int... selectedDims) { - return applyKernelRealReduceOperation(ArrayKernel.RR_VAR, selectedDims); - } - - /** - * Finds the maximum values along the given dimension. - */ - public IntegerArray iMax(int dim) { - return applyKernelRealIndexOperation(ArrayKernel.RI_MAX, dim); - } - - /** - * Finds the minimum values along the given dimension. - */ - public IntegerArray iMin(int dim) { - return applyKernelRealIndexOperation(ArrayKernel.RI_MIN, dim); - } - - /** - * Finds all zeros along the given dimension. - */ - public IntegerArray iZero(int dim) { - return applyKernelRealIndexOperation(ArrayKernel.RI_ZERO, dim); - } - - /** - * Finds all greater-than-zeros along the given dimension. - */ - public IntegerArray iGZero(int dim) { - return applyKernelRealIndexOperation(ArrayKernel.RI_GZERO, dim); - } - - /** - * Finds all less-than-zeros along the given dimension. - */ - public IntegerArray iLZero(int dim) { - return applyKernelRealIndexOperation(ArrayKernel.RI_LZERO, dim); - } - - /** - * Sorts along the given dimension. - */ - public IntegerArray iSort(int dim) { - return applyKernelRealIndexOperation(ArrayKernel.RI_SORT, dim); - } - - /** - * Equates to calling {@link #iMax(int)} with argument {@code -1}. - */ - public IntegerArray iMax() { - return applyKernelRealIndexOperation(ArrayKernel.RI_MAX, -1); - } - - /** - * Equates to calling {@link #iMin(int)} with argument {@code -1}. - */ - public IntegerArray iMin() { - return applyKernelRealIndexOperation(ArrayKernel.RI_MIN, -1); - } - - /** - * Equates to calling {@link #iZero(int)} with argument {@code -1}. - */ - public IntegerArray iZero() { - return applyKernelRealIndexOperation(ArrayKernel.RI_ZERO, -1); - } - - /** - * Equates to calling {@link #iGZero(int)} with argument {@code -1}. - */ - public IntegerArray iGZero() { - return applyKernelRealIndexOperation(ArrayKernel.RI_GZERO, -1); - } - - /** - * Equates to calling {@link #iLZero(int)} with argument {@code -1}. - */ - public IntegerArray iLZero() { - return applyKernelRealIndexOperation(ArrayKernel.RI_LZERO, -1); - } - - /** - * Equates to calling {@link #iSort(int)} with argument {@code -1}. - */ - public IntegerArray iSort() { - return applyKernelRealIndexOperation(ArrayKernel.RI_SORT, -1); - } - - /** - * Takes the sum along the given dimensions. - */ - public R dSum(int... selectedDims) { - return applyKernelRealDimensionOperation(ArrayKernel.RD_SUM, selectedDims); - } - - /** - * Takes the product along the given dimensions. - */ - public R dProd(int... selectedDims) { - return applyKernelRealDimensionOperation(ArrayKernel.RD_PROD, selectedDims); - } - - /** - * Supports the a* series of operations. - */ - protected double applyKernelRealAccumulatorOperation(int type) { - return OpKernel.raOp(type, this.values); - } - - /** - * Supports the e* series of operations. - */ - @SuppressWarnings("unchecked") - protected R applyKernelElementwiseOperation(R b, int type) { - - checkShape(b); - - R a = (R) this; - - R res = wrap(INVALID_PARITY, a.order, a.dims, a.strides); - - OpKernel.eOp(type, a.values, b.values, res.values, false); - - return res; - } - - /** - * Supports the l* series of operations. - */ - @SuppressWarnings("unchecked") - protected R applyKernelLeftElementwiseOperation(R b, int type) { - - checkShape(b); - - R a = (R) this; - - OpKernel.eOp(type, a.values, b.values, a.values, false); - - return a; - } - - /** - * Supports the toc* series of operations. - */ - @SuppressWarnings("unchecked") - protected C applyKernelRealToComplexOperation(int type) { - - checkMatrixOrder(); - - R a = (R) this; - - int[] newDims = Arrays.copyOf(a.dims, a.dims.length + 1); - newDims[newDims.length - 1] = 2; - - C res = wrapUp(INVALID_PARITY, DEFAULT_ORDER, newDims, a.order.strides(newDims)); - - OpKernel.convert(type, a.values, false, res.values, true); - - return res; - } - - /** - * Supports the u* series of operations. - */ - @SuppressWarnings("unchecked") - protected R applyKernelRealUnaryOperation(double a, int type) { - - OpKernel.ruOp(type, a, this.values); - - return (R) this; - } - - /** - * Supports the r* series of operations. - */ - @SuppressWarnings("unchecked") - protected R applyKernelRealReduceOperation(int type, int[] selectedDims) { - - R a = (R) this; - - int[] newDims = a.dims.clone(); - - for (int dim : selectedDims) { - - // In case the dimension is 0. - newDims[dim] = Math.min(a.dims[dim], 1); - } - - R res = wrap(INVALID_PARITY, a.order, newDims, a.order.strides(newDims)); - - OpKernel.rrOp(type, // - a.values, a.dims, a.strides, // - res.values, res.dims, res.strides, // - selectedDims); - - return res; - } - - /** - * Supports the i* series of operations. - */ - @SuppressWarnings("unchecked") - protected IntegerArray applyKernelRealIndexOperation(int type, int dim) { - - R a = (R) this; - - IntegerArray res = new IntegerArray(a.order, a.dims); - - OpKernel.riOp(type, // - a.values, a.dims, a.strides, res.values, // - dim); - - return res; - } - - /** - * Supports the d* series of operations. - */ - @SuppressWarnings("unchecked") - protected R applyKernelRealDimensionOperation(int type, int[] selectedDims) { - - R a = (R) this; - - R res = wrap(INVALID_PARITY, a.order, a.dims, a.strides); - - OpKernel.rdOp(type, // - a.values, a.dims, a.strides, res.values, // - selectedDims); - - return res; - } - - /** - * Mutatively maps the elements. - * - * @param rm - * the {@link RealMap}. - */ - @SuppressWarnings("unchecked") - public R map(RealMap rm) { - - R a = (R) this; - - int[] logical = new int[a.dims.length]; - - for (int i = 0, n = a.values.length; i < n; i++) { - a.values[i] = rm.apply(a.values[i], ArrayBase.logical(i, a.strides, logical)); - } - - return a; - } - - /** - * Reduces the elements. - * - * @param rr - * the {@link RealReduce}. - * @return the reduction result. - */ - @SuppressWarnings("unchecked") - public double reduce(RealReduce rr) { - - R a = (R) this; - - int[] logical = new int[a.dims.length]; - - for (int i = 0, n = a.values.length; i < n; i++) { - rr.apply(a.values[i], ArrayBase.logical(i, a.strides, logical)); - } - - return rr.get(); - } - - /** - * Defines an elementwise "map" operation over real-valued multidimensional arrays. - */ - public interface RealMap { - - /** - * Applies the mapping. - * - * @param value - * the input value. - * @param logical - * the current array logical index. - * @return the output value. - */ - public double apply(double value, int[] logical); - } - - /** - * Defines an elementwise "reduce" operation over real-valued multidimensional arrays. - */ - public interface RealReduce { - - /** - * Applies the reduction. - * - * @param value - * the input value. - * @param logical - * the current array logical index. - */ - public void apply(double value, int[] logical); - - /** - * Gets the reduction result. - * - * @return the reduction result. - */ - public double get(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/Array.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/Array.java deleted file mode 100755 index 1df05108..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/Array.java +++ /dev/null @@ -1,279 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -/** - * Defines functionality that can be expected from all multidimensional arrays. - * - * @apiviz.owns shared.array.Array.IndexingOrder - * @param - * the parameterization lower bounded by {@link Array} itself. - * @param - * the component type. - * @author Roy Liu - */ -public interface Array, E> extends Cloneable { - - /** - * Gets the storage order of this array. - */ - public IndexingOrder order(); - - /** - * Gets the size along the given dimension. - */ - public int size(int i); - - /** - * Gets the stride along the given dimension. - */ - public int stride(int i); - - /** - * Gets the number of dimensions. - */ - public int ndims(); - - /** - * Gets the dimensions. - */ - public int[] dimensions(); - - /** - * Gets the strides. - */ - public int[] strides(); - - /** - * Maps this array into a destination array. - * - * @param dst - * the destination array. - * @param bounds - * the mapping bounds as an array of three-tuples. Given the ith tuple, the first component - * denotes the source start, the second component denotes the destination start, and the third component - * denotes the mapping size. Is very much the multidimensional analogy to - * {@link System#arraycopy(Object, int, Object, int, int)}. - * @return the destination array. - */ - public T map(T dst, int... bounds); - - /** - * A primitive slicing operation. - * - * @param dst - * the destination array. - * @param slices - * the slicing specifications as an array of three-tuples. Given the ith tuple, the first - * component denotes the source index, the second component denotes the destination index, and the third - * component denotes the dimension of interest. The sliced portion is the Cartesian product subarray - * delineated by these specifications. - * @return the destination array. - */ - public T splice(T dst, int... slices); - - /** - * Slices this array into a destination array. - * - * @param srcSlices - * the source slicing indices along each dimension. - * @param dst - * the destination array. - * @param dstSlices - * the destination slicing indices along each dimension. - * @return the destination array. - */ - public T slice(int[][] srcSlices, T dst, int[][] dstSlices); - - /** - * Slices this entire array into a destination array. - * - * @param dst - * the destination array. - * @param dstSlices - * the destination slicing indices along each dimension. - * @return the destination array. - */ - public T slice(T dst, int[]... dstSlices); - - /** - * Slices a value into this array. - * - * @param value - * the value. - * @param srcSlices - * the source slicing indices along each dimension. - * @return this array. - */ - public T slice(E value, int[]... srcSlices); - - /** - * Gets a subarray specified by the given slicing indices. - * - * @param srcSlices - * the slicing indices. - * @return the subarray. - */ - public T slice(int[]... srcSlices); - - /** - * Gets a subarray delimited by the given bounds. - * - * @param bounds - * the subarray bounds as an array of two-tuples. Given the ith tuple, the first component is - * the (inclusive) lower range and the second component is the (exclusive) upper range. - * @return the subarray. - */ - public T subarray(int... bounds); - - /** - * Tiles this array according to the given number repetitions along each dimension. - * - * @param repetitions - * the number times to repeat along each dimension. - * @return the tiled result. - */ - public T tile(int... repetitions); - - /** - * Transposes (permutes) the dimensions of this array. - * - * @param permutation - * the dimension permutation. - * @return the transposed result. - */ - public T transpose(int... permutation); - - /** - * Circularly shifts this array. - * - * @param shifts - * the shift amounts. - * @return the shifted array. - */ - public T shift(int... shifts); - - /** - * Reshapes this array. - * - * @param dims - * the reshaped dimensions. - * @return the reshaped array. - */ - public T reshape(int... dims); - - /** - * Reverses along the given dimensions. - * - * @param selectedDims - * the dimensions to reverse along. - * @return the reversed array. - */ - public T reverse(int... selectedDims); - - /** - * Creates an array where the storage order is reversed. - */ - public T reverseOrder(); - - /** - * Copies this array. - */ - public T clone(); - - /** - * Gets the component type. - */ - public Class getComponentType(); - - /** - * Creates a human-readable representation of this array. - */ - @Override - public String toString(); - - /** - * An enumeration of internal storage orders for {@link Array}s. - */ - public enum IndexingOrder { - - /** - * An ordering where low indices vary most. - */ - NEAR { - - @Override - public int[] strides(int[] dims) { - - final int numDims = dims.length; - final int[] strides = new int[numDims]; - - strides[0] = 1; - - for (int i = 1; i < numDims; i++) { - strides[i] = strides[i - 1] * dims[i - 1]; - } - - return strides; - } - - @Override - public IndexingOrder reverse() { - return FAR; - } - }, // - - /** - * An ordering where high indices vary most. - */ - FAR { - - @Override - public int[] strides(int[] dims) { - - final int numDims = dims.length; - final int[] strides = new int[numDims]; - - strides[numDims - 1] = 1; - - for (int i = numDims - 2; i >= 0; i--) { - strides[i] = strides[i + 1] * dims[i + 1]; - } - - return strides; - } - - @Override - public IndexingOrder reverse() { - return NEAR; - } - }; - - /** - * Creates strides for the given dimensions. - * - * @return the strides -- a vector such that its dot product with a logical index yields a physical index. - */ - abstract public int[] strides(int[] dims); - - /** - * Gets the reversed value. - */ - abstract public IndexingOrder reverse(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/ArrayBase.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/ArrayBase.java deleted file mode 100755 index 32a221c7..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/ArrayBase.java +++ /dev/null @@ -1,396 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.util.Control.LineSeparator; - -import java.lang.reflect.Array; -import java.util.Formatter; - -import shared.array.Array.IndexingOrder; -import shared.array.kernel.ModalArrayIOKernel; -import shared.array.kernel.ModalArrayKernel; -import shared.fft.ModalFFTService; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A collection of useful static methods and data structures common to all {@link Array} implementations. - * - * @author Roy Liu - */ -public class ArrayBase { - - /** - * The array operations kernel. - */ - final public static ModalArrayKernel OpKernel = new ModalArrayKernel(); - - /** - * The array I/O kernel. - */ - final public static ModalArrayIOKernel IOKernel = new ModalArrayIOKernel(); - - /** - * A global service providing access to FFT operations. - */ - final public static ModalFFTService FFTService = new ModalFFTService(); - - /** - * The default storage order shall be {@link shared.array.Array.IndexingOrder#FAR}. - */ - final public static IndexingOrder DEFAULT_ORDER = IndexingOrder.FAR; - - /** - * The field width to use when printing. - */ - public static int FIELD_WIDTH = 8; - - /** - * The field precision to use when printing. - */ - public static int FIELD_PRECISION = 2; - - /** - * Canonicalizes the alternate slicing specification. - */ - final public static int[] canonicalizeSlices(int[][] srcSlices, int[] srcDims, int[][] dstSlices, int[] dstDims) { - - int ndims = srcSlices.length; - - Control.checkTrue(ndims == dstSlices.length // - && ndims == srcDims.length // - && ndims == dstDims.length, // - "Dimensionality mismatch"); - - int nslices = 0; - - for (int dim = 0; dim < ndims; dim++) { - nslices += Control.checkEquals(srcSlices[dim].length, dstSlices[dim].length, // - "Dimension mismatch"); - } - - int[] slices = new int[3 * nslices]; - - for (int dim = 0, offset = 0; dim < ndims; dim++) { - - int[] srcSlice = srcSlices[dim]; - int[] dstSlice = dstSlices[dim]; - - for (int j = 0, m = srcSlice.length; j < m; j++, offset += 3) { - - slices[offset] = srcSlice[j]; - slices[offset + 1] = dstSlice[j]; - slices[offset + 2] = dim; - } - } - - return slices; - } - - /** - * Canonicalizes the alternate slicing specification. - */ - final public static int[] canonicalizeSlices(int[] srcDims, int[] dstDims, int[][] dstSlices) { - - int ndims = dstSlices.length; - - Control.checkTrue(ndims == srcDims.length // - && ndims == dstDims.length, // - "Dimensionality mismatch"); - - int nslices = 0; - - for (int dim = 0; dim < ndims; dim++) { - nslices += Control.checkEquals(srcDims[dim], dstSlices[dim].length, // - "Dimension mismatch"); - } - - int[] slices = new int[3 * nslices]; - - for (int dim = 0, offset = 0; dim < ndims; dim++) { - - int[] dstSlice = dstSlices[dim]; - - for (int j = 0, m = dstSlice.length; j < m; j++, offset += 3) { - - slices[offset] = j; - slices[offset + 1] = dstSlice[j]; - slices[offset + 2] = dim; - } - } - - return slices; - } - - /** - * Canonicalizes the alternate slicing specification. - */ - final public static int[] canonicalizeSlices(int nslices, int[] srcDims, int[][] srcSlices) { - - int[] slices = new int[3 * nslices]; - - for (int dim = 0, offset = 0, ndims = srcDims.length; dim < ndims; dim++) { - - int[] srcSlice = srcSlices[dim]; - - for (int j = 0, m = srcSlice.length; j < m; j++, offset += 3) { - - slices[offset] = srcSlice[j]; - slices[offset + 1] = j; - slices[offset + 2] = dim; - } - } - - return slices; - } - - /** - * Creates a slicing specification for {@link shared.array.Array#reverse(int...)}. - */ - final public static int[] createReverseSlices(int[] srcDims, int[] selectedDims) { - - int ndims = srcDims.length; - int nindices = selectedDims.length; - - int nslices = Arithmetic.sum(srcDims); - int[] slices = new int[3 * nslices]; - - boolean[] sentinel = new boolean[ndims]; - - for (int i = 0; i < nindices; i++) { - sentinel[selectedDims[i]] = true; - } - - for (int dim = 0, offset = 0; dim < ndims; dim++) { - - int dimSize = srcDims[dim]; - - if (sentinel[dim]) { - - for (int j = 0, k = dimSize - 1; j < dimSize; j++, k--, offset += 3) { - - slices[offset] = j; - slices[offset + 1] = k; - slices[offset + 2] = dim; - } - - } else { - - for (int j = 0; j < dimSize; j++, offset += 3) { - - slices[offset] = j; - slices[offset + 1] = j; - slices[offset + 2] = dim; - } - } - } - - return slices; - } - - /** - * Sets the formatting parameters {@link #FIELD_WIDTH} and {@link #FIELD_PRECISION}. - * - * @param width - * the number width. - * @param precision - * the number precision. - */ - final public static void format(int width, int precision) { - - Control.checkTrue(width >= precision + 4 && precision >= 1, // - "Invalid formatting parameters"); - - FIELD_WIDTH = width; - FIELD_PRECISION = precision; - } - - /** - * Formats a two-dimensional slice of an array for display. - * - * @param f - * the target {@link Formatter}. - * @param format - * the formatting string. - * @param values - * the values. - * @param indices - * the physical indices. - * @param offset - * the physical index offset. - * @param nrows - * the number of rows in the slice. - * @param ncols - * the number of columns in the slice. - * @param isComplex - * whether the values are complex. - */ - final public static void formatSlice(Formatter f, String format, // - Object values, int[] indices, // - int offset, int nrows, int ncols, boolean isComplex) { - - if (!isComplex) { - - for (int j = 0, k = 0; j < nrows; j++) { - - for (int i = 0; i < ncols; i++, k++) { - f.format(format, Array.get(values, indices[offset + k])); - } - - f.format(LineSeparator); - } - - } else { - - for (int j = 0, k = 0; j < nrows; j++) { - - for (int i = 0; i < ncols; i++, k += 2) { - f.format(format, // - Array.get(values, indices[offset + k]), // - Array.get(values, indices[offset + k + 1])); - } - - f.format(LineSeparator); - } - } - } - - /** - * Formats an empty array message. - * - * @param f - * the target {@link Formatter}. - * @param dims - * the dimensions. - */ - final public static void formatEmptyArray(Formatter f, int[] dims) { - - int ndims = dims.length; - - f.format(LineSeparator).format("[empty ("); - - for (int i = 0, n = ndims - 1; i < n; i++) { - f.format("%d, ", dims[i]); - } - - f.format("%d)]", dims[ndims - 1]).format(LineSeparator); - } - - /** - * Formats a potential rescale message if the given exponent is too large or too small. - * - * @param f - * the target {@link Formatter}. - * @param exponent - * the exponent. - * @param values - * the values. - * @return the potentially rescaled values. - */ - final public static double[] formatRescale(Formatter f, int exponent, double[] values) { - - if (FIELD_WIDTH < exponent + FIELD_PRECISION + 4 || exponent < 0) { - - f.format("%s[rescale 10^%d]%s", // - LineSeparator, exponent, LineSeparator); - - double scale = Math.pow(10.0, -exponent); - - double[] res = values.clone(); - - for (int i = 0, n = res.length; i < n; i++) { - res[i] *= scale; - } - - return res; - - } else { - - return values; - } - } - - /** - * Formats a sparse array for display. - * - * @param f - * the target {@link Formatter}. - * @param valueFormat - * the formatting string for values. - * @param indexFormat - * the formatting string for logical indices. - * @param values - * the values. - * @param indices - * the physical indices. - * @param strides - * the strides. - */ - final public static void formatSparseArray(Formatter f, String valueFormat, String indexFormat, // - Object values, int[] indices, int[] strides) { - - int ndims = strides.length; - - for (int i = 0, n = Control.checkEquals(Array.getLength(values), indices.length); i < n; i++) { - - int physical = indices[i]; - - f.format("("); - - for (int j = 0, m = ndims - 1; j < m; j++) { - - f.format(indexFormat, physical / strides[j]); - f.format(","); - - physical %= strides[j]; - } - - f.format(indexFormat, physical / strides[ndims - 1]); - f.format(")"); - f.format(valueFormat, Array.get(values, i)); - f.format(LineSeparator); - } - } - - /** - * Computes the logical index from the given physical index and strides. - * - * @param physical - * the physical index. - * @param strides - * the strides. - * @param logical - * the logical index. - * @return the logical index. - */ - final public static int[] logical(int physical, int[] strides, int[] logical) { - - for (int dim = 0, ndims = Control.checkEquals(strides.length, logical.length); dim < ndims; dim++) { - - logical[dim] = physical / strides[dim]; - physical %= strides[dim]; - } - - return logical; - } - - // Dummy constructor. - ArrayBase() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/ComplexArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/ComplexArray.java deleted file mode 100755 index a072120d..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/ComplexArray.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.IOKernel; -import static shared.array.ArrayBase.OpKernel; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A multidimensional complex array class. - * - * @author Roy Liu - */ -public class ComplexArray extends AbstractComplexArray implements - Matrix { - - /** - * Default constructor. - */ - public ComplexArray(int... dims) { - this(0, dims.clone()); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected ComplexArray(int unused, int[] dims) { - super(new double[Arithmetic.product(dims)], INVALID_PARITY, dims, DEFAULT_ORDER.strides(dims)); - - Control.checkTrue(dims.length >= 2 && dims[dims.length - 1] == 2); - } - - /** - * Alternate constructor. - */ - public ComplexArray(double[] values, int... dims) { - this(0, values, inferDimensions(dims, values.length, true)); - } - - /** - * Alternate constructor. - */ - public ComplexArray(ComplexArray array) { - this(0, array.values.clone(), array.dims); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected ComplexArray(int unused, double[] values, int[] dims) { - super(values, INVALID_PARITY, dims, DEFAULT_ORDER.strides(dims)); - - Control.checkTrue(dims.length >= 2 && dims[dims.length - 1] == 2 // - && values.length == Arithmetic.product(dims)); - } - - /** - * Internal constructor for package use only. - */ - protected ComplexArray(int parity, int[] dims, int[] strides) { - super(new double[Arithmetic.product(dims)], parity, dims, strides); - } - - /** - * Internal constructor for package use only. - */ - protected ComplexArray(double[] values, int parity, int[] dims) { - super(values, parity, dims, DEFAULT_ORDER.strides(dims)); - } - - @Override - protected ComplexArray wrap(int parity, IndexingOrder order, int[] dims, int[] strides) { - return new ComplexArray(parity, dims, strides); - } - - @Override - protected RealArray wrapDown(int parity, IndexingOrder order, int[] dims, int[] strides) { - return new RealArray(order, dims, strides); - } - - public ComplexArray mMul(ComplexArray b) { - - ComplexArray a = this; - - Control.checkTrue(Control.checkEquals(a.dims.length, b.dims.length, // - "Dimensionality mismatch") == 3, // - "Arrays must have exactly three dimensions"); - - // Matrices are already in matrix order. - ComplexArray res = new ComplexArray(a.dims[0], b.dims[1], 2); - - OpKernel.mul(a.values, b.values, a.dims[0], b.dims[1], res.values, true); - - return res; - } - - public ComplexArray mDiag() { - - ComplexArray a = this; - - Control.checkTrue(a.dims.length == 3, // - "Array must have exactly three dimensions"); - - int n = Control.checkEquals(a.dims[0], a.dims[1], // - "Dimensionality mismatch"); - - // Matrices are already in matrix order. - ComplexArray res = new ComplexArray(n, 1, 2); - - OpKernel.diag(a.values, res.values, n, true); - - return res; - } - - public ComplexArray mTranspose() { - - ComplexArray a = this; - - Control.checkTrue(a.dims.length == 3, // - "Array must have exactly three dimensions"); - - return transpose(1, 0, 2); - } - - @Override - public byte[] getBytes() { - return IOKernel.getBytes(this); - } - - /** - * Parses an array from {@code byte}s. - */ - final public static ComplexArray parse(byte[] data) { - return IOKernel.parse(data); - } - - public ComplexArray[] mSVD() { - throw new UnsupportedOperationException( - "Complex matrices currently do not support singular value decompositions"); - } - - public ComplexArray[] mEigs() { - throw new UnsupportedOperationException("Complex matrices currently do not support eigenvalue decompositions"); - } - - public ComplexArray mInvert() { - throw new UnsupportedOperationException("Complex matrices currently do not support inverses"); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/IntegerArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/IntegerArray.java deleted file mode 100755 index dcbfc149..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/IntegerArray.java +++ /dev/null @@ -1,381 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.IOKernel; -import static shared.array.ArrayBase.OpKernel; -import static shared.array.ArrayBase.formatEmptyArray; -import static shared.array.ArrayBase.formatSlice; -import static shared.array.kernel.ArrayKernel.ITOR; - -import java.util.Arrays; -import java.util.Formatter; - -import shared.array.kernel.ArrayKernel; -import shared.array.kernel.MappingOps; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A multidimensional integer array class. - * - * @apiviz.uses shared.array.ArrayBase - * @author Roy Liu - */ -public class IntegerArray extends ProtoArray { - - /** - * Default constructor. - */ - public IntegerArray(IndexingOrder order, int... dims) { - this(0, order, dims.clone()); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected IntegerArray(int unused, IndexingOrder order, int[] dims) { - super(new int[Arithmetic.product(dims)], order, dims, order.strides(dims)); - - Control.checkTrue(dims.length > 0); - } - - /** - * Alternate constructor. - */ - public IntegerArray(int[] values, int... dims) { - this(0, values, IndexingOrder.FAR, dims); - } - - /** - * Alternate constructor. - */ - public IntegerArray(int[] values, IndexingOrder order, int... dims) { - this(0, values, order, dims); - } - - /** - * Alternate constructor. - */ - public IntegerArray(IntegerArray array) { - this(0, array.values.clone(), array.order, array.dims); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected IntegerArray(int unused, int[] values, IndexingOrder order, int[] dims) { - super(values, order, dims, order.strides(dims)); - - Control.checkTrue(dims.length > 0 // - && values.length == Arithmetic.product(dims)); - } - - /** - * Internal constructor for package use only. - */ - protected IntegerArray(IndexingOrder order, int[] dims, int[] strides) { - super(new int[Arithmetic.product(dims)], order, dims, strides); - } - - @Override - protected IntegerArray wrap(IndexingOrder order, int[] dims, int[] strides) { - return new IntegerArray(order, dims, strides); - } - - @Override - protected IntegerArray wrap(Integer value, IndexingOrder order, int[] dims, int[] strides) { - return wrap(order, dims, strides).uFill(value); - } - - /** - * Gets the value at the given logical index. - */ - public int get(int... s) { - return this.values[physical(s)]; - } - - /** - * Sets the value at the given logical index. - */ - public void set(int value, int... s) { - this.values[physical(s)] = value; - } - - @Override - public int[] values() { - return this.values; - } - - @Override - public byte[] getBytes() { - return IOKernel.getBytes(this); - } - - public Class getComponentType() { - return Integer.class; - } - - @Override - public String toString() { - - int[] values = this.values; - int[] dims = this.dims; - int[] strides = this.strides; - - int ndims = dims.length; - int nrows = (ndims == 1) ? 1 : size(ndims - 2); - int ncols = size(ndims - 1); - int sliceSize = nrows * ncols; - - int max = Math.max(Arithmetic.max(values), Math.abs(Arithmetic.min(values))); - int exponent = max > 0 ? (int) Math.log10(max) : 0; - - Formatter f = new Formatter(); - - if (values.length == 0) { - - formatEmptyArray(f, dims); - - return f.toString(); - } - - String format = String.format("%%%dd", exponent + 3); - - int[] indices = MappingOps.assignMappingIndices(Arithmetic.product(dims), // - dims, strides); - - strides = IndexingOrder.FAR.strides(dims); - - if (ndims <= 2) { - - f.format("%n"); - - formatSlice(f, format, // - values, indices, 0, nrows, ncols, false); - - return f.toString(); - } - - for (int offset = 0, m = values.length; offset < m; offset += sliceSize) { - - f.format("%n[slice ("); - - for (int i = 0, n = ndims - 2, offsetAcc = offset; i < n; offsetAcc %= strides[i], i++) { - f.format("%d, ", offsetAcc / strides[i]); - } - - f.format(":, :)]%n"); - - formatSlice(f, format, // - values, indices, offset, nrows, ncols, false); - } - - return f.toString(); - } - - /** - * Assumes that this array results from an indexing operation. Extracts the valid indices along a dimension anchored - * at the given logical index. - * - * @param s - * the logical index, where the dimension of interest is marked with a {@code -1}. - * @return the valid indices along said dimension and at said logical index. - */ - public int[] find(int... s) { - - IntegerArray a = this; - - return OpKernel.find(a.values, a.dims, a.strides, s); - } - - /** - * Converts this array to a {@link RealArray}. - */ - public RealArray tor() { - - IntegerArray a = this; - - RealArray res = new RealArray(a.order, a.dims); - - OpKernel.convert(ITOR, a.values, false, res.values, false); - - return res; - } - - /** - * Mutatively adds the argument to the elements. - */ - public IntegerArray uAdd(int a) { - return applyKernelIntegerUnaryOperation(a, ArrayKernel.IU_ADD); - } - - /** - * Mutatively multiplies the elements by the argument. - */ - public IntegerArray uMul(int a) { - return applyKernelIntegerUnaryOperation(a, ArrayKernel.IU_MUL); - } - - /** - * Mutatively fills this array with the argument. - */ - public IntegerArray uFill(int a) { - return applyKernelIntegerUnaryOperation(a, ArrayKernel.IU_FILL); - } - - /** - * Mutatively shuffles this array. - */ - public IntegerArray uShuffle() { - return applyKernelIntegerUnaryOperation(Integer.MIN_VALUE, ArrayKernel.IU_SHUFFLE); - } - - /** - * Computes the elementwise addition. - */ - public IntegerArray eAdd(IntegerArray array) { - return applyKernelElementwiseOperation(array, ArrayKernel.IE_ADD); - } - - /** - * Computes the elementwise subtraction. - */ - public IntegerArray eSub(IntegerArray array) { - return applyKernelElementwiseOperation(array, ArrayKernel.IE_SUB); - } - - /** - * Computes the elementwise multiplication. - */ - public IntegerArray eMul(IntegerArray array) { - return applyKernelElementwiseOperation(array, ArrayKernel.IE_MUL); - } - - /** - * Computes the elementwise maximum. - */ - public IntegerArray eMax(IntegerArray array) { - return applyKernelElementwiseOperation(array, ArrayKernel.IE_MAX); - } - - /** - * Computes the elementwise minimum. - */ - public IntegerArray eMin(IntegerArray array) { - return applyKernelElementwiseOperation(array, ArrayKernel.IE_MIN); - } - - /** - * Computes the left elementwise addition. - */ - public IntegerArray lAdd(IntegerArray array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.IE_ADD); - } - - /** - * Computes the left elementwise subtraction. - */ - public IntegerArray lSub(IntegerArray array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.IE_SUB); - } - - /** - * Computes the left elementwise multiplication. - */ - public IntegerArray lMul(IntegerArray array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.IE_MUL); - } - - /** - * Computes the left elementwise maximum. - */ - public IntegerArray lMax(IntegerArray array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.IE_MAX); - } - - /** - * Computes the left elementwise minimum. - */ - public IntegerArray lMin(IntegerArray array) { - return applyKernelLeftElementwiseOperation(array, ArrayKernel.IE_MIN); - } - - /** - * Supports the e* series of operations. - */ - protected IntegerArray applyKernelElementwiseOperation(IntegerArray b, int type) { - - checkShape(b); - - IntegerArray a = this; - IntegerArray res = wrap(a.order, a.dims, a.strides); - - OpKernel.eOp(type, a.values, b.values, res.values, false); - - return res; - } - - /** - * Supports the l* series of operations. - */ - protected IntegerArray applyKernelLeftElementwiseOperation(IntegerArray b, int type) { - - checkShape(b); - - IntegerArray a = this; - - OpKernel.eOp(type, a.values, b.values, a.values, false); - - return a; - } - - /** - * Supports the u* series of operations. - */ - protected IntegerArray applyKernelIntegerUnaryOperation(int a, int type) { - - OpKernel.iuOp(type, a, this.values); - - return this; - } - - /** - * Checks that two {@link IntegerArray}s have the same size and underlying {@link Array.IndexingOrder}. - * - * @param b - * the {@link IntegerArray} to compare to. - */ - protected void checkShape(IntegerArray b) { - - IntegerArray a = this; - - Control.checkTrue(a.order == b.order, // - "Indexing orders do not match"); - - Control.checkTrue(Arrays.equals(a.dims, b.dims), // - "Dimensions do not match"); - } - - /** - * Parses an array from {@code byte}s. - */ - final public static IntegerArray parse(byte[] data) { - return IOKernel.parse(data); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/Matrix.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/Matrix.java deleted file mode 100755 index c169e59b..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/Matrix.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -/** - * Defines functionality that can be expected from all matrices. - * - * @param - * the parameterization lower bounded by {@link Matrix} itself. - * @param - * the element type. - * @author Roy Liu - */ -public interface Matrix, E> extends Array { - - /** - * Multiplies two matrices. - * - * @param rhs - * the right hand side. - * @return the multiplication result. - */ - public T mMul(T rhs); - - /** - * Gets the diagonal of this matrix as a column vector. - * - * @return the diagonal. - */ - public T mDiag(); - - /** - * Transposes this matrix. - * - * @return the transposed matrix. - */ - public T mTranspose(); - - /** - * Inverts this matrix. - * - * @return the inverted matrix. - */ - public T mInvert(); - - /** - * Gets the singular value decomposition of this matrix. - * - * @return the matrices "U", "S", and "V". - */ - public T[] mSVD(); - - /** - * Gets the eigenvectors and eigenvalues of this matrix. - * - * @return the eigenvectors and eigenvalues. - */ - public T[] mEigs(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/ObjectArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/ObjectArray.java deleted file mode 100755 index 49a1f02d..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/ObjectArray.java +++ /dev/null @@ -1,242 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.formatEmptyArray; -import static shared.array.ArrayBase.formatSlice; - -import java.lang.reflect.Array; -import java.util.Formatter; - -import shared.array.kernel.DimensionOps; -import shared.array.kernel.MappingOps; -import shared.array.kernel.PermutationEntry; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A multidimensional object array class. - * - * @apiviz.uses shared.array.ArrayBase - * @param - * the storage type. - * @author Roy Liu - */ -public class ObjectArray extends ProtoArray, T[], T> { - - /** - * Default constructor. - */ - public ObjectArray(Class clazz, int... dims) { - this(0, clazz, IndexingOrder.FAR, dims); - } - - /** - * Alternate constructor. - */ - public ObjectArray(Class clazz, IndexingOrder order, int... dims) { - this(0, clazz, order, dims); - } - - /** - * Internal constructor with a distinctive signature. - */ - @SuppressWarnings("unchecked") - protected ObjectArray(int unused, Class clazz, IndexingOrder order, int[] dims) { - super((T[]) Array.newInstance(clazz, Arithmetic.product(dims)), order, dims, order.strides(dims)); - - Control.checkTrue(dims.length > 0); - } - - /** - * Alternate constructor. - */ - public ObjectArray(T[] values, int... dims) { - this(0, values, IndexingOrder.FAR, // - AbstractArray.inferDimensions(dims, values.length, false)); - } - - /** - * Alternate constructor. - */ - public ObjectArray(T[] values, IndexingOrder order, int... dims) { - this(0, values, order, // - AbstractArray.inferDimensions(dims, values.length, false)); - } - - /** - * Alternate constructor. - */ - public ObjectArray(ObjectArray array) { - this(0, array.values.clone(), array.order, array.dims); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected ObjectArray(int unused, T[] values, IndexingOrder order, int[] dims) { - super(values, order, dims, order.strides(dims)); - - Control.checkTrue(dims.length > 0 // - && values.length == Arithmetic.product(dims)); - } - - /** - * Internal constructor for package use only. - */ - @SuppressWarnings("unchecked") - protected ObjectArray(Class clazz, IndexingOrder order, int[] dims, int[] strides) { - super((T[]) Array.newInstance(clazz, Arithmetic.product(dims)), order, dims, strides); - } - - @Override - protected ObjectArray wrap(IndexingOrder order, int[] dims, int[] strides) { - return new ObjectArray(getComponentType(), order, dims, strides); - } - - @Override - protected ObjectArray wrap(T value, IndexingOrder order, int[] dims, int[] strides) { - - ObjectArray tmp = wrap(order, dims, strides); - java.util.Arrays.fill(tmp.values, value); - - return tmp; - } - - @SuppressWarnings("unchecked") - public Class getComponentType() { - return (Class) this.values.getClass().getComponentType(); - } - - /** - * Gets the value at the given logical index. - */ - public T get(int... s) { - return this.values[physical(s)]; - } - - /** - * Sets the value at the given logical index. - */ - public void set(T value, int... s) { - this.values[physical(s)] = value; - } - - @Override - public T[] values() { - return this.values; - } - - @Override - public byte[] getBytes() { - throw new UnsupportedOperationException("Serialization of object arrays is not yet supported"); - } - - @Override - public String toString() { - - T[] values = this.values; - int[] dims = this.dims; - int[] strides = this.strides; - - int ndims = dims.length; - int nrows = (ndims == 1) ? 1 : size(ndims - 2); - int ncols = size(ndims - 1); - int sliceSize = nrows * ncols; - - Formatter f = new Formatter(); - - if (values.length == 0) { - - formatEmptyArray(f, dims); - - return f.toString(); - } - - int[] indices = MappingOps.assignMappingIndices(Arithmetic.product(dims), // - dims, strides); - - strides = IndexingOrder.FAR.strides(dims); - - if (ndims <= 2) { - - f.format("%n"); - - formatSlice(f, " \"%s\"", // - values, indices, 0, nrows, ncols, false); - - return f.toString(); - } - - for (int offset = 0, m = values.length; offset < m; offset += sliceSize) { - - f.format("%n[slice ("); - - for (int i = 0, n = ndims - 2, offsetAcc = offset; i < n; offsetAcc %= strides[i], i++) { - f.format("%d, ", offsetAcc / strides[i]); - } - - f.format(":, :)]%n"); - - formatSlice(f, " \"%s\"", // - values, indices, offset, nrows, ncols, false); - } - - return f.toString(); - } - - /** - * Sorts along the given dimension. - */ - @SuppressWarnings("unchecked") - public IntegerArray iSort(int dim) { - - ObjectArray src = this; - IntegerArray dst = new IntegerArray(src.order, src.dims); - - T[] srcV = src.values; - int[] srcD = src.dims; - int[] srcS = src.strides; - - int[] dstV = dst.values(); - - int srcLen = MappingOps.checkDimensions(srcV.length, srcD, srcS); - - Control.checkTrue(srcLen == dstV.length, // - "Invalid arguments"); - - if (srcLen == 0) { - return dst; - } - - if (dim != -1) { - - PermutationEntry.iSort(((ObjectArray) this).values(), // - DimensionOps.assignBaseIndices(srcLen / srcD[dim], srcD, srcS, dim), // - dstV, // - srcD[dim], srcS[dim]); - - } else { - - PermutationEntry.iSort(((ObjectArray) this).values(), // - null, dstV, -1, -1); - } - - return dst; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/ProtoArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/ProtoArray.java deleted file mode 100755 index fa363822..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/ProtoArray.java +++ /dev/null @@ -1,437 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.IOKernel; -import static shared.array.ArrayBase.OpKernel; -import static shared.array.ArrayBase.canonicalizeSlices; -import static shared.array.ArrayBase.createReverseSlices; - -import java.util.Arrays; - -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * An abstract, primordial base class for all multidimensional arrays. Supports operations like mapping, slicing, - * tiling, shifting, transposition of dimensions, and storage order reversals. - * - * @param - * the parameterization lower bounded by {@link ProtoArray} itself. - * @param - * the storage array type. - * @param - * the element type. - * @author Roy Liu - */ -abstract public class ProtoArray, V, E> implements Array { - - /** - * The backing values. - */ - final protected V values; - - /** - * The storage order. - */ - final protected IndexingOrder order; - - /** - * The dimensions. - */ - final protected int[] dims; - - /** - * The strides. - */ - final protected int[] strides; - - /** - * Default constructor. - */ - protected ProtoArray(V values, IndexingOrder order, int[] dims, int[] strides) { - - this.values = values; - this.order = order; - this.dims = dims; - this.strides = strides; - } - - /** - * Allocates a new array. - * - * @param order - * the storage order. - * @param dims - * the dimensions. - * @param strides - * the strides. - * @return the new array. - */ - abstract protected T wrap(IndexingOrder order, int[] dims, int[] strides); - - /** - * Allocates a new array initialized to the given value. - * - * @param value - * the initial value. - * @param order - * the storage order. - * @param dims - * the dimensions. - * @param strides - * the strides. - * @return the new array. - */ - abstract protected T wrap(E value, IndexingOrder order, int[] dims, int[] strides); - - /** - * Converts this array into {@code byte}s. - * - * @return the {@code byte}s. - */ - @SuppressWarnings("unchecked") - public byte[] getBytes() { - return IOKernel.getBytes((T) this); - } - - /** - * Gets the backing values. - */ - protected V values() { - return this.values; - } - - /** - * Converts a logical index into a physical index. - */ - protected int physical(int[] logical) { - - int index = 0; - - for (int i = 0, n = logical.length; i < n; i++) { - index += this.strides[i] * logical[i]; - } - - return index; - } - - public T map(T dst, int... bounds) { - - ProtoArray src = this; - - Control.checkTrue(src != dst, // - "Source and destination cannot be the same"); - - OpKernel.map(bounds, // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T splice(T dst, int... slices) { - - ProtoArray src = this; - - Control.checkTrue(src != dst, // - "Source and destination cannot be the same"); - - OpKernel.slice(slices, // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T slice(int[][] srcSlices, T dst, int[][] dstSlices) { - - ProtoArray src = this; - - Control.checkTrue(src != dst, // - "Source and destination cannot be the same"); - - int[] slices = ArrayBase.canonicalizeSlices(srcSlices, src.dims, dstSlices, dst.dims); - - OpKernel.slice(slices, // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T slice(T dst, int[]... dstSlices) { - - ProtoArray src = this; - - Control.checkTrue(src != dst, // - "Source and destination cannot be the same"); - - OpKernel.slice(canonicalizeSlices(src.dims, dst.dims, dstSlices), // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - @SuppressWarnings("unchecked") - public T slice(E value, int[]... srcSlices) { - - T src = (T) this; - - int ndims = srcSlices.length; - int[] dstDims = new int[ndims]; - - for (int dim = 0; dim < ndims; dim++) { - dstDims[dim] = srcSlices[dim].length; - } - - return wrap(value, src.order, dstDims, src.order.strides(dstDims)).slice(src, srcSlices); - } - - public T slice(int[]... srcSlices) { - - ProtoArray src = this; - - int ndims = Control.checkEquals(src.dims.length, srcSlices.length, // - "Dimensionality mismatch"); - - int nslices = 0; - int[] dstDims = new int[ndims]; - - for (int dim = 0; dim < ndims; dim++) { - nslices += (dstDims[dim] = srcSlices[dim].length); - } - - T dst = wrap(src.order, dstDims, src.order.strides(dstDims)); - - OpKernel.slice(canonicalizeSlices(nslices, src.dims, srcSlices), // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T tile(int... repetitions) { - - ProtoArray src = this; - - int ndims = Control.checkEquals(src.dims.length, repetitions.length, // - "Dimensionality mismatch"); - - int[] newDims = src.dims.clone(); - - for (int dim = 0; dim < ndims; dim++) { - newDims[dim] *= repetitions[dim]; - } - - T dst = wrap(src.order, newDims, src.order.strides(newDims)); - - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - mappingBounds[offset + 2] = dst.dims[dim]; - } - - OpKernel.map(mappingBounds, // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T transpose(int... permutation) { - - ProtoArray src = this; - - int ndims = Control.checkEquals(src.dims.length, permutation.length, // - "Dimensionality mismatch"); - - int[] newDims = new int[ndims]; - int[] copy = permutation.clone(); - - Arrays.sort(copy); - - for (int dim = 0; dim < ndims; dim++) { - - newDims[permutation[dim]] = src.dims[dim]; - - Control.checkTrue(copy[dim] == dim, // - "Invalid permutation"); - } - - T dst = wrap(src.order, newDims, src.order.strides(newDims)); - - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - mappingBounds[offset + 2] = src.dims[dim]; - } - - for (int dim = 0; dim < ndims; dim++) { - copy[dim] = dst.strides[permutation[dim]]; - } - - OpKernel.map(mappingBounds, // - src.values, src.dims, src.strides, // - dst.values, src.dims, copy); - - return dst; - } - - public T shift(int... shifts) { - - ProtoArray src = this; - - int ndims = Control.checkEquals(src.dims.length, shifts.length, // - "Dimensionality mismatch"); - - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - - mappingBounds[offset + 1] = shifts[dim]; - mappingBounds[offset + 2] = src.dims[dim]; - } - - T dst = wrap(src.order, src.dims, src.strides); - - OpKernel.map(mappingBounds, // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T reverseOrder() { - - ProtoArray src = this; - - IndexingOrder newOrder = src.order.reverse(); - T dst = wrap(newOrder, src.dims, newOrder.strides(src.dims)); - - int ndims = src.dims.length; - - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - mappingBounds[offset + 2] = src.dims[dim]; - } - - OpKernel.map(mappingBounds, // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T subarray(int... bounds) { - - ProtoArray src = this; - - int ndims = src.dims.length; - - Control.checkTrue(ndims * 2 == bounds.length, // - "Invalid subarray bounds"); - - int[] newDims = new int[ndims]; - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0; dim < ndims; dim++) { - - int lower = bounds[2 * dim]; - int upper = bounds[2 * dim + 1]; - - newDims[dim] = upper - lower; - mappingBounds[3 * dim] = lower; - mappingBounds[3 * dim + 2] = newDims[dim]; - } - - T dst = wrap(src.order, newDims, src.order.strides(newDims)); - - OpKernel.map(mappingBounds, // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T reverse(int... selectedDims) { - - ProtoArray src = this; - - T dst = wrap(src.order, src.dims, src.strides); - - OpKernel.slice(createReverseSlices(src.dims, selectedDims), // - src.values, src.dims, src.strides, // - dst.values, dst.dims, dst.strides); - - return dst; - } - - public T reshape(int... dims) { - - ProtoArray src = this; - - int len = Control.checkEquals( // - Arithmetic.product(dims), Arithmetic.product(src.dims), // - "Cardinality mismatch"); - - T dst = wrap(src.order, dims, src.order.strides(dims)); - - System.arraycopy(src.values, 0, dst.values, 0, len); - - return dst; - } - - @Override - public T clone() { - - ProtoArray src = this; - - T dst = wrap(src.order, src.dims, src.strides); - - System.arraycopy(src.values, 0, dst.values, 0, Arithmetic.product(src.dims)); - - return dst; - } - - public IndexingOrder order() { - return this.order; - } - - public int size(int i) { - return this.dims[i]; - } - - public int stride(int i) { - return this.strides[i]; - } - - public int ndims() { - return this.dims.length; - } - - public int[] dimensions() { - return this.dims.clone(); - } - - public int[] strides() { - return this.strides.clone(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/RealArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/RealArray.java deleted file mode 100755 index 54ebcd2c..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/RealArray.java +++ /dev/null @@ -1,294 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.IOKernel; -import static shared.array.ArrayBase.OpKernel; -import shared.util.Arithmetic; -import shared.util.Arrays; -import shared.util.Control; - -/** - * A multidimensional real array class. - * - * @author Roy Liu - */ -public class RealArray extends AbstractRealArray implements Matrix { - - /** - * Default constructor. - */ - public RealArray(int... dims) { - this(0, DEFAULT_ORDER, dims.clone()); - } - - /** - * Alternate constructor. - */ - public RealArray(IndexingOrder order, int... dims) { - this(0, order, dims.clone()); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected RealArray(int unused, IndexingOrder order, int[] dims) { - super(new double[Arithmetic.product(dims)], order, dims, order.strides(dims)); - - Control.checkTrue(dims.length > 0); - } - - /** - * Alternate constructor. - */ - public RealArray(double[] values, int... dims) { - this(0, values, DEFAULT_ORDER, inferDimensions(dims, values.length, false)); - } - - /** - * Alternate constructor. - */ - public RealArray(double[] values, IndexingOrder order, int... dims) { - this(0, values, order, inferDimensions(dims, values.length, false)); - } - - /** - * Alternate constructor. - */ - public RealArray(RealArray array) { - this(0, array.values.clone(), array.order, array.dims); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected RealArray(int unused, double[] values, IndexingOrder order, int[] dims) { - super(values, order, dims, order.strides(dims)); - - Control.checkTrue(dims.length > 0 // - && values.length == Arithmetic.product(dims)); - } - - /** - * Internal constructor for package use only. - */ - protected RealArray(IndexingOrder order, int[] dims, int[] strides) { - super(new double[Arithmetic.product(dims)], order, dims, strides); - } - - @Override - protected RealArray wrap(int parity, IndexingOrder order, int[] dims, int[] strides) { - return new RealArray(order, dims, strides); - } - - @Override - protected ComplexArray wrapUp(int parity, IndexingOrder order, int[] dims, int[] strides) { - return new ComplexArray(parity, dims, strides); - } - - public RealArray mMul(RealArray b) { - - RealArray a = this; - - a.checkMatrixOrder(); - b.checkMatrixOrder(); - - Control.checkTrue(Control.checkEquals(a.dims.length, b.dims.length, // - "Dimensionality mismatch") == 2, // - "Arrays must have exactly two dimensions"); - - RealArray res = new RealArray(DEFAULT_ORDER, a.dims[0], b.dims[1]); - - OpKernel.mul(a.values, b.values, a.dims[0], b.dims[1], res.values, false); - - return res; - } - - public RealArray mDiag() { - - RealArray a = this; - - a.checkMatrixOrder(); - - Control.checkTrue(a.dims.length == 2, // - "Array must have exactly two dimensions"); - - int size = Control.checkEquals(a.dims[0], a.dims[1], // - "Dimensionality mismatch"); - - RealArray res = new RealArray(DEFAULT_ORDER, size, 1); - - OpKernel.diag(a.values, res.values, size, false); - - return res; - } - - public RealArray mTranspose() { - - RealArray a = this; - - a.checkMatrixOrder(); - - Control.checkTrue(a.dims.length == 2, // - "Array must have exactly two dimensions"); - - return transpose(1, 0); - } - - public RealArray[] mSVD() { - - RealArray a = this; - - a.checkMatrixOrder(); - - Control.checkTrue(a.dims.length == 2, // - "Array must have exactly two dimensions"); - - int nrows = a.dims[0]; - int ncols = a.dims[1]; - - final int matStrideRow, matStrideCol, nrowsT, ncolsT; - - boolean transpose = (nrows < ncols); - - if (!transpose) { - - nrowsT = nrows; - ncolsT = ncols; - - matStrideRow = ncolsT; - matStrideCol = 1; - - } else { - - nrowsT = ncols; - ncolsT = nrows; - - matStrideRow = 1; - matStrideCol = nrowsT; - } - - RealArray u = new RealArray(nrowsT, ncolsT); - RealArray s = new RealArray(ncolsT, ncolsT); - RealArray v = new RealArray(ncolsT, ncolsT); - - double[] sV = new double[ncolsT]; - - OpKernel.svd(a.values, matStrideRow, matStrideCol, u.values(), sV, v.values(), nrowsT, ncolsT); - - double[] sValues = s.values(); - - for (int i = 0; i < ncolsT; i++) { - sValues[ncolsT * i + i] = sV[i]; - } - - return !transpose ? new RealArray[] { u, s, v } : new RealArray[] { v, s, u }; - } - - public RealArray[] mEigs() { - - RealArray a = this; - - a.checkMatrixOrder(); - - Control.checkTrue(a.dims.length == 2, // - "Array must have exactly two dimensions"); - - int size = Control.checkEquals(a.dims[0], a.dims[1], // - "Dimensionality mismatch"); - - RealArray eigVectors = new RealArray(size, size); - - double[] eigValues = new double[2 * size]; - - OpKernel.eigs(a.values, eigVectors.values, eigValues, size); - - RealArray eigValueMatrix = new RealArray(size, size); - - for (int i = 0, n = 2 * size; i < n; i += 2) { - - int dim = i >>> 1; - - if (i < n - 2 // - && eigValues[i] == eigValues[i + 2] // - && eigValues[i + 1] > 0 // - && eigValues[i + 3] < 0) { - - eigValueMatrix.set(eigValues[i], dim, dim); - eigValueMatrix.set(eigValues[i + 1], dim, dim + 1); - eigValueMatrix.set(eigValues[i + 2], dim + 1, dim + 1); - eigValueMatrix.set(eigValues[i + 3], dim + 1, dim); - - i += 2; - - } else { - - eigValueMatrix.set(eigValues[i], dim, dim); - } - } - - return new RealArray[] { eigVectors, eigValueMatrix }; - } - - public RealArray mInvert() { - - RealArray a = this; - - a.checkMatrixOrder(); - - Control.checkTrue(a.dims.length == 2, // - "Array must have exactly two dimensions"); - - int size = Control.checkEquals(a.dims[0], a.dims[1], // - "Dimensionality mismatch"); - - RealArray res = new RealArray(DEFAULT_ORDER, size, size); - - OpKernel.invert(a.values, res.values, size); - - return res; - } - - @Override - public byte[] getBytes() { - return IOKernel.getBytes(this); - } - - /** - * Parses an array from {@code byte}s. - */ - final public static RealArray parse(byte[] data) { - return IOKernel.parse(data); - } - - /** - * Creates an array of the given size and number of dimensions, with ones for diagonals. - */ - final public static RealArray eye(int size, int ndims) { - - RealArray res = new RealArray(Arrays.newArray(ndims, size)); - double[] resValues = res.values(); - - for (int i = 0, offset = 0, increment = Arithmetic.sum(res.strides()); i < size; i++, offset += increment) { - resValues[offset] = 1.0; - } - - return res; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/jni/NativeArrayKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/jni/NativeArrayKernel.java deleted file mode 100755 index 0abb50bc..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/jni/NativeArrayKernel.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.jni; - -import shared.array.kernel.ArrayKernel; -import shared.array.sparse.SparseArrayState; -import shared.metaclass.Library; -import shared.util.Control; - -/** - * A native implementation of {@link ArrayKernel}. - * - * @author Roy Liu - */ -public class NativeArrayKernel implements ArrayKernel { - - /** - * Default constructor. Checks the validity of native bindings. - */ - public NativeArrayKernel() { - - Control.checkTrue(Library.isInitialized(), // - "Could not instantiate native bindings -- Linking failed"); - } - - // - - final public native void randomize(); - - final public native void derandomize(); - - // - - final public native void map(int[] bounds, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS); - - final public native void slice( // - int[] slices, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS); - - // - - final public native void rrOp(int type, // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS, // - int... selectedDims); - - final public native void riOp(int type, // - double[] srcV, int[] srcD, int[] srcS, int[] dstV, // - int dim); - - final public native void rdOp(int type, // - double[] srcV, int[] srcD, int[] srcS, double[] dstV, // - int... selectedDims); - - // - - final public native double raOp(int type, double[] srcV); - - final public native double[] caOp(int type, double[] srcV); - - final public native void ruOp(int type, double a, double[] srcV); - - final public native void cuOp(int type, double aRe, double aIm, double[] srcV); - - final public native void iuOp(int type, int a, int[] srcV); - - final public native void eOp(int type, Object lhsV, Object rhsV, Object dstV, boolean isComplex); - - final public native void convert(int type, // - Object srcV, boolean isSrcComplex, // - Object dstV, boolean isDstComplex); - - // - - final public native void mul(double[] lhsV, double[] rhsV, int lr, int rc, double[] dstV, boolean isComplex); - - final public native void diag(double[] srcV, double[] dstV, int size, boolean isComplex); - - // - - final public native void svd(double[] srcV, int srcStrideRow, int srcStrideCol, // - double[] uV, double[] sV, double[] vV, // - int nrows, int ncols); - - final public native void eigs(double[] srcV, double[] vecV, double[] valV, int size); - - final public native void invert(double[] srcV, double[] dstV, int size); - - // - - final public native int[] find(int[] srcV, int[] srcD, int[] srcS, int[] logical); - - // - - final public native SparseArrayState insertSparse( // - V oldV, int[] oldD, int[] oldS, int[] oldDO, int[] oldI, // - V newV, int[] newLI); - - final public native SparseArrayState sliceSparse(int[] slices, // - V srcV, int[] srcD, int[] srcS, int[] srcDO, // - int[] srcI, int[] srcIO, int[] srcII, // - V dstV, int[] dstD, int[] dstS, int[] dstDO, // - int[] dstI, int[] dstIO, int[] dstII); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/jni/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/jni/package-info.java deleted file mode 100755 index 66a170c5..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/jni/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package for providing JNI-backed {@link shared.array.Array} operations. - */ -@shared.metaclass.Policy(recursive = false) -package shared.array.jni; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ArrayIOKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ArrayIOKernel.java deleted file mode 100755 index b9bbed8b..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ArrayIOKernel.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import shared.array.Array; -import shared.util.Service; - -/** - * A provider of {@link Array} I/O operations. - * - * @author Roy Liu - */ -public interface ArrayIOKernel extends Service { - - /** - * Converts an {@link Array} into {@code byte}s. - * - * @param - * the {@link Array} type. - * @param - * the {@link Array} element type. - * @param array - * the {@link Array}. - * @return the {@code byte}s. - */ - public , E> byte[] getBytes(T array); - - /** - * Parses an {@link Array} from {@code byte}s. - * - * @param data - * the {@code byte}s. - * @param - * the inferred {@link Array} type. - * @return the {@link Array}. - */ - public > T parse(byte[] data); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ArrayKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ArrayKernel.java deleted file mode 100755 index bbb80534..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ArrayKernel.java +++ /dev/null @@ -1,664 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import shared.array.Array; -import shared.array.Matrix; -import shared.array.Array.IndexingOrder; -import shared.array.sparse.SparseArrayState; -import shared.util.Service; - -/** - * A provider of operations on {@link Array}s. - * - * @author Roy Liu - */ -public interface ArrayKernel extends Service { - - /** Real reduce sum. */ - final public static int RR_SUM = 0; - - /** Real reduce product. */ - final public static int RR_PROD = 1; - - /** Real reduce maximum. */ - final public static int RR_MAX = 2; - - /** Real reduce minimum. */ - final public static int RR_MIN = 3; - - /** Real reduce variance. */ - final public static int RR_VAR = 4; - - // - - /** Real index maximum. */ - final public static int RI_MAX = 0; - - /** Real index minimum. */ - final public static int RI_MIN = 1; - - /** Real index find zeros. */ - final public static int RI_ZERO = 2; - - /** Real index find greater-than-zeros. */ - final public static int RI_GZERO = 3; - - /** Real index find less-than-zeros. */ - final public static int RI_LZERO = 4; - - /** Real index sort. */ - final public static int RI_SORT = 5; - - // - - /** Real dimension sum. */ - final public static int RD_SUM = 0; - - /** Real dimension product. */ - final public static int RD_PROD = 1; - - // - - /** Real accumulator sum. */ - final public static int RA_SUM = 0; - - /** Real accumulator product. */ - final public static int RA_PROD = 1; - - /** Real accumulator variance. */ - final public static int RA_VAR = 2; - - /** Real accumulator maximum. */ - final public static int RA_MAX = 3; - - /** Real accumulator minimum. */ - final public static int RA_MIN = 4; - - /** Real accumulator entropy. */ - final public static int RA_ENT = 5; - - // - - /** Complex accumulator sum. */ - final public static int CA_SUM = 0; - - /** Complex accumulator product. */ - final public static int CA_PROD = 1; - - // - - /** Real unary addition. */ - final public static int RU_ADD = 0; - - /** Real unary multiplication. */ - final public static int RU_MUL = 1; - - /** Real unary absolute value. */ - final public static int RU_ABS = 2; - - /** Real unary power. */ - final public static int RU_POW = 3; - - /** Real unary exponentiation. */ - final public static int RU_EXP = 4; - - /** Real unary randomization. */ - final public static int RU_RND = 5; - - /** Real unary natural logarithm. */ - final public static int RU_LOG = 6; - - /** Real unary square root. */ - final public static int RU_SQRT = 7; - - /** Real unary square. */ - final public static int RU_SQR = 8; - - /** Real unary inverse. */ - final public static int RU_INV = 9; - - /** Real unary cosine. */ - final public static int RU_COS = 10; - - /** Real unary sine. */ - final public static int RU_SIN = 11; - - /** Real unary arctangent. */ - final public static int RU_ATAN = 12; - - /** Real unary fill. */ - final public static int RU_FILL = 13; - - /** Real unary shuffle. */ - final public static int RU_SHUFFLE = 14; - - // - - /** Complex unary addition. */ - final public static int CU_ADD = 0; - - /** Complex unary multiplication. */ - final public static int CU_MUL = 1; - - /** Complex unary exponentiation. */ - final public static int CU_EXP = 2; - - /** Complex unary randomization. */ - final public static int CU_RND = 3; - - /** Complex unary conjugation. */ - final public static int CU_CONJ = 4; - - /** Complex unary cosine. */ - final public static int CU_COS = 5; - - /** Complex unary sine. */ - final public static int CU_SIN = 6; - - /** Complex unary fill. */ - final public static int CU_FILL = 7; - - /** Complex unary shuffle. */ - final public static int CU_SHUFFLE = 8; - - // - - /** Integer unary addition. */ - final public static int IU_ADD = 0; - - /** Integer unary multiplication. */ - final public static int IU_MUL = 1; - - /** Integer unary fill. */ - final public static int IU_FILL = 2; - - /** Integer unary shuffle. */ - final public static int IU_SHUFFLE = 3; - - // - - /** Real elementwise addition. */ - final public static int RE_ADD = 0; - - /** Real elementwise subtraction. */ - final public static int RE_SUB = 1; - - /** Real elementwise multiplication. */ - final public static int RE_MUL = 2; - - /** Real elementwise division. */ - final public static int RE_DIV = 3; - - /** Real elementwise maximum. */ - final public static int RE_MAX = 4; - - /** Real elementwise minimum. */ - final public static int RE_MIN = 5; - - // - - /** Integer elementwise addition. */ - final public static int IE_ADD = 0; - - /** Integer elementwise subtraction. */ - final public static int IE_SUB = 1; - - /** Integer elementwise multiplication. */ - final public static int IE_MUL = 2; - - /** Integer elementwise maximum. */ - final public static int IE_MAX = 3; - - /** Integer elementwise minimum. */ - final public static int IE_MIN = 4; - - // - - /** Complex elementwise addition. */ - final public static int CE_ADD = 0; - - /** Complex elementwise subtraction. */ - final public static int CE_SUB = 1; - - /** Complex elementwise multiplication. */ - final public static int CE_MUL = 2; - - /** Complex elementwise division. */ - final public static int CE_DIV = 3; - - // - - /** Complex to real conversion by complex magnitudes. */ - final public static int CTOR_ABS = 0; - - /** Complex to real conversion by real part. */ - final public static int CTOR_RE = 1; - - /** Complex to real conversion by imaginary part. */ - final public static int CTOR_IM = 2; - - // - - /** Real to complex conversion by real part. */ - final public static int RTOC_RE = 0; - - /** Real to complex conversion by imaginary part. */ - final public static int RTOC_IM = 1; - - // - - /** Integer to real conversion by up-casting. */ - final public static int ITOR = 0; - - // - - /** - * Seeds the underlying source of randomness with the current time. - */ - public void randomize(); - - /** - * Seeds the underlying source of randomness with a constant. - */ - public void derandomize(); - - /** - * Performs a mapping operation. - * - * @param bounds - * the mapping bounds. - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param dstV - * the destination values. - * @param dstD - * the destination dimensions. - * @param dstS - * the destination strides. - */ - public void map( // - int[] bounds, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS); - - /** - * Performs a slicing operation. - * - * @param slices - * the slicing specification. - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param dstV - * the destination values. - * @param dstD - * the destination dimensions. - * @param dstS - * the destination strides. - */ - public void slice( // - int[] slices, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS); - - // - - /** - * Performs a real reduce operation. - * - * @param type - * the operation type. - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param dstV - * the destination values. - * @param dstD - * the destination dimensions. - * @param dstS - * the destination strides. - * @param selectedDims - * the dimensions of interest. - */ - public void rrOp(int type, // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS, // - int... selectedDims); - - /** - * Performs a real index operation. - * - * @param type - * the operation type. - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param dstV - * the destination values. - * @param dim - * the dimension of interest. - */ - public void riOp(int type, // - double[] srcV, int[] srcD, int[] srcS, // - int[] dstV, // - int dim); - - /** - * Performs a real dimension operation. - * - * @param type - * the operation type. - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param dstV - * the destination values. - * @param selectedDims - * the dimensions of interest. - */ - public void rdOp(int type, // - double[] srcV, int[] srcD, int[] srcS, double[] dstV, // - int... selectedDims); - - // - - /** - * Performs a real accumulator operation. - * - * @param type - * the operation type. - * @param srcV - * the array. - * @return the accumulated result. - */ - public double raOp(int type, double[] srcV); - - /** - * Performs a complex accumulator operation. - * - * @param type - * the operation type. - * @param srcV - * the array. - * @return the accumulated result. - */ - public double[] caOp(int type, double[] srcV); - - /** - * Applies a real unary operation. - * - * @param type - * the operation type. - * @param a - * the argument, if any. - * @param srcV - * the array. - */ - public void ruOp(int type, double a, double[] srcV); - - /** - * Applies a complex unary operation. - * - * @param type - * the operation type. - * @param aRe - * the real part of the argument, if any. - * @param aIm - * the imaginary part of the argument, if any. - * @param srcV - * the array. - */ - public void cuOp(int type, double aRe, double aIm, double[] srcV); - - /** - * Applies an integer unary operation. - * - * @param type - * the operation type. - * @param a - * the argument, if any. - * @param srcV - * the array. - */ - public void iuOp(int type, int a, int[] srcV); - - /** - * Applies a binary operation. - * - * @param type - * the operation type. - * @param lhsV - * the left hand side values. - * @param rhsV - * the right hand side values. - * @param dstV - * the destination values. - * @param isComplex - * whether the operation is complex-valued. - */ - public void eOp(int type, Object lhsV, Object rhsV, Object dstV, boolean isComplex); - - /** - * Performs a conversion operation. - * - * @param type - * the operation type. - * @param srcV - * the source values. - * @param isSrcComplex - * whether the source is complex-valued. - * @param dstV - * the destination values. - * @param isDstComplex - * whether the destination is complex-valued. - */ - public void convert(int type, // - Object srcV, boolean isSrcComplex, // - Object dstV, boolean isDstComplex); - - // - - /** - * Multiplies two {@link Matrix}s. They are assumed to have storage order {@link IndexingOrder#FAR}. - * - * @param lhsV - * the left hand side values. - * @param rhsV - * the right hand side values. - * @param lr - * the row count of the result. - * @param rc - * the column count of the result. - * @param dstV - * the destination values. - * @param isComplex - * whether the operation is complex-valued. - */ - public void mul(double[] lhsV, double[] rhsV, int lr, int rc, double[] dstV, boolean isComplex); - - /** - * Gets the diagonal of a {@link Matrix}. - * - * @param srcV - * source values. - * @param dstV - * destination values. - * @param size - * the matrix size. - * @param isComplex - * whether the operation is complex-valued. - */ - public void diag(double[] srcV, double[] dstV, int size, boolean isComplex); - - // - - /** - * Computes the singular value decomposition of a {@link Matrix}. - * - * @param srcV - * the source values. - * @param srcStrideRow - * the source row stride. - * @param srcStrideCol - * the source column stride. - * @param uV - * the input vectors. - * @param sV - * the gain controls. - * @param vV - * the output vectors. - * @param nrows - * the number of rows. - * @param ncols - * the number of columns. - */ - public void svd(double[] srcV, int srcStrideRow, int srcStrideCol, // - double[] uV, double[] sV, double[] vV, // - int nrows, int ncols); - - /** - * Computes the eigenvectors and eigenvalues of a {@link Matrix}. - * - * @param srcV - * the source values. - * @param vecV - * the eigenvectors. - * @param valV - * the eigenvalues. - * @param size - * the matrix size. - */ - public void eigs(double[] srcV, double[] vecV, double[] valV, int size); - - /** - * Computes the inverse of a {@link Matrix}. - * - * @param srcV - * the source values. - * @param dstV - * the destination values. - * @param size - * the matrix size. - */ - public void invert(double[] srcV, double[] dstV, int size); - - // - - /** - * Extracts the valid indices along a dimension anchored at the given logical index. - * - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param logical - * the logical index. - * @return the valid indices. - */ - public int[] find(int[] srcV, int[] srcD, int[] srcS, int[] logical); - - // - - /** - * Inserts elements into a sparse array. - * - * @param oldV - * the old values. - * @param oldD - * the old dimensions. - * @param oldS - * the old strides. - * @param oldDO - * the old dimension offsets. - * @param oldI - * the old physical indices. Invariant: Sorted in ascending order, and does not contain duplicates. - * @param newV - * the new values. - * @param newI - * the new physical indices, which need not be sorted in ascending order. - * @param - * the storage array type. - * @return the {@link SparseArrayState}. - */ - public SparseArrayState insertSparse( // - V oldV, int[] oldD, int[] oldS, int[] oldDO, int[] oldI, // - V newV, int[] newI); - - /** - * Slices one sparse array into another. - * - * @param slices - * the slicing specification. - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param srcDO - * the source dimension offsets. - * @param srcI - * the source physical indices. Invariant: Sorted in ascending order, and does not contain duplicates. - * @param srcIO - * the source indirection offsets. - * @param srcII - * the source indirections. - * @param dstV - * the destination values. - * @param dstD - * the destination dimensions. - * @param dstS - * the destination strides. - * @param dstDO - * the destination dimension offsets. - * @param dstI - * the destination physical indices. Invariant: Sorted in ascending order, and does not contain - * duplicates. - * @param dstIO - * the destination indirection offsets. - * @param dstII - * the destination indirections. - * @param - * the storage array type. - * @return the {@link SparseArrayState}. - */ - public SparseArrayState sliceSparse(int[] slices, // - V srcV, int[] srcD, int[] srcS, int[] srcDO, // - int[] srcI, int[] srcIO, int[] srcII, // - V dstV, int[] dstD, int[] dstS, int[] dstDO, // - int[] dstI, int[] dstIO, int[] dstII); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/DimensionOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/DimensionOps.java deleted file mode 100755 index caf4f90c..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/DimensionOps.java +++ /dev/null @@ -1,690 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import static shared.array.kernel.ArrayKernel.RD_PROD; -import static shared.array.kernel.ArrayKernel.RD_SUM; -import static shared.array.kernel.ArrayKernel.RI_GZERO; -import static shared.array.kernel.ArrayKernel.RI_LZERO; -import static shared.array.kernel.ArrayKernel.RI_MAX; -import static shared.array.kernel.ArrayKernel.RI_MIN; -import static shared.array.kernel.ArrayKernel.RI_SORT; -import static shared.array.kernel.ArrayKernel.RI_ZERO; -import static shared.array.kernel.ArrayKernel.RR_MAX; -import static shared.array.kernel.ArrayKernel.RR_MIN; -import static shared.array.kernel.ArrayKernel.RR_PROD; -import static shared.array.kernel.ArrayKernel.RR_SUM; -import static shared.array.kernel.ArrayKernel.RR_VAR; - -import java.util.Arrays; - -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A class for dimension operations in pure Java. - * - * @apiviz.has shared.array.kernel.DimensionOps.RealReduceOperation - - - argument - * @apiviz.has shared.array.kernel.DimensionOps.RealIndexOperation - - - argument - * @apiviz.has shared.array.kernel.DimensionOps.RealDimensionOperation - - - argument - * @apiviz.uses shared.array.kernel.PermutationEntry - * @author Roy Liu - */ -public class DimensionOps { - - /** - * Defines real reduce operations. - */ - protected interface RealReduceOperation { - - /** - * Performs a real reduce operation. - */ - public void op(double[] working, int[] workingIndices, int size, int stride); - } - - final static RealReduceOperation RRSumOp = new RealReduceOperation() { - - public void op(double[] working, int[] workingIndices, int size, int stride) { - - for (int workingIndex : workingIndices) { - - for (int j = 1, offset = workingIndex + stride; j < size; j++, offset += stride) { - working[workingIndex] += working[offset]; - } - } - } - }; - - final static RealReduceOperation RRProdOp = new RealReduceOperation() { - - public void op(double[] working, int[] workingIndices, int size, int stride) { - - for (int workingIndex : workingIndices) { - - for (int j = 1, offset = workingIndex + stride; j < size; j++, offset += stride) { - working[workingIndex] *= working[offset]; - } - } - } - }; - - final static RealReduceOperation RRMaxOp = new RealReduceOperation() { - - public void op(double[] working, int[] workingIndices, int size, int stride) { - - for (int workingIndex : workingIndices) { - - for (int j = 1, offset = workingIndex + stride; j < size; j++, offset += stride) { - working[workingIndex] = Math.max(working[offset], working[workingIndex]); - } - } - } - }; - - final static RealReduceOperation RRMinOp = new RealReduceOperation() { - - public void op(double[] working, int[] workingIndices, int size, int stride) { - - for (int workingIndex : workingIndices) { - - for (int j = 1, offset = workingIndex + stride; j < size; j++, offset += stride) { - working[workingIndex] = Math.min(working[offset], working[workingIndex]); - } - } - } - }; - - final static RealReduceOperation RRVarOp = new RealReduceOperation() { - - public void op(double[] working, int[] workingIndices, int size, int stride) { - - for (int workingIndex : workingIndices) { - - double mean = 0.0; - - for (int j = 0, offset = workingIndex; j < size; j++, offset += stride) { - mean += working[offset]; - } - - mean /= size; - - for (int j = 0, offset = workingIndex; j < size; j++, offset += stride) { - - double diff = working[offset] - mean; - working[offset] = diff * diff; - } - - for (int j = 1, offset = workingIndex + stride; j < size; j++, offset += stride) { - working[workingIndex] += working[offset]; - } - - working[workingIndex] /= size; - } - } - }; - - /** - * Defines real index operations. - */ - protected interface RealIndexOperation { - - /** - * Performs a real index operation. - */ - public void op(double[] srcV, int[] srcIndices, int[] dstV, int size, int stride); - } - - final static RealIndexOperation RIMaxOp = new RealIndexOperation() { - - public void op(double[] srcV, int[] srcIndices, int[] dstV, int size, int stride) { - - if (srcIndices != null) { - - int maxStride = stride * size; - - for (int i = 0, nindices = srcIndices.length; i < nindices; i++) { - - double acc = -Double.MAX_VALUE; - - for (int offset = 0; offset < maxStride; offset += stride) { - acc = Math.max(acc, srcV[srcIndices[i] + offset]); - } - - int count = 0; - - for (int offset = 0; offset < maxStride; offset += stride) { - - if (srcV[srcIndices[i] + offset] == acc) { - - dstV[srcIndices[i] + count] = offset / stride; - count += stride; - } - } - - for (int offset = count; offset < maxStride; offset += stride) { - dstV[srcIndices[i] + offset] = -1; - } - } - - } else { - - double maxValue = Arithmetic.max(srcV); - - for (int i = 0, n = srcV.length; i < n; i++) { - dstV[i] = (srcV[i] == maxValue) ? 1 : 0; - } - } - } - }; - - final static RealIndexOperation RIMinOp = new RealIndexOperation() { - - public void op(double[] srcV, int[] srcIndices, int[] dstV, int size, int stride) { - - if (srcIndices != null) { - - int maxStride = stride * size; - - for (int i = 0, nindices = srcIndices.length; i < nindices; i++) { - - double acc = Double.MAX_VALUE; - - for (int offset = 0; offset < maxStride; offset += stride) { - acc = Math.min(acc, srcV[srcIndices[i] + offset]); - } - - int count = 0; - - for (int offset = 0; offset < maxStride; offset += stride) { - - if (srcV[srcIndices[i] + offset] == acc) { - - dstV[srcIndices[i] + count] = offset / stride; - count += stride; - } - } - - for (int offset = count; offset < maxStride; offset += stride) { - dstV[srcIndices[i] + offset] = -1; - } - } - - } else { - - double minValue = Arithmetic.min(srcV); - - for (int i = 0, n = srcV.length; i < n; i++) { - dstV[i] = (srcV[i] == minValue) ? 1 : 0; - } - } - } - }; - - final static RealIndexOperation RIZeroOp = new RealIndexOperation() { - - public void op(double[] srcV, int[] srcIndices, int[] dstV, int size, int stride) { - - if (srcIndices != null) { - - int maxStride = stride * size; - - for (int i = 0, nindices = srcIndices.length; i < nindices; i++) { - - int count = 0; - - for (int offset = 0; offset < maxStride; offset += stride) { - - if (srcV[srcIndices[i] + offset] == 0.0) { - - dstV[srcIndices[i] + count] = offset / stride; - count += stride; - } - } - - for (int offset = count; offset < maxStride; offset += stride) { - dstV[srcIndices[i] + offset] = -1; - } - } - - } else { - - for (int i = 0, n = srcV.length; i < n; i++) { - dstV[i] = (srcV[i] == 0.0) ? 1 : 0; - } - } - } - }; - - final static RealIndexOperation RIGZeroOp = new RealIndexOperation() { - - public void op(double[] srcV, int[] srcIndices, int[] dstV, int size, int stride) { - - if (srcIndices != null) { - - int maxStride = stride * size; - - for (int i = 0, nindices = srcIndices.length; i < nindices; i++) { - - int count = 0; - - for (int offset = 0; offset < maxStride; offset += stride) { - - if (srcV[srcIndices[i] + offset] > 0.0) { - - dstV[srcIndices[i] + count] = offset / stride; - count += stride; - } - } - - for (int offset = count; offset < maxStride; offset += stride) { - dstV[srcIndices[i] + offset] = -1; - } - } - - } else { - - for (int i = 0, n = srcV.length; i < n; i++) { - dstV[i] = (srcV[i] > 0.0) ? 1 : 0; - } - } - } - }; - - final static RealIndexOperation RILZeroOp = new RealIndexOperation() { - - public void op(double[] srcV, int[] srcIndices, int[] dstV, int size, int stride) { - - if (srcIndices != null) { - - int maxStride = stride * size; - - for (int i = 0, nindices = srcIndices.length; i < nindices; i++) { - - int count = 0; - - for (int offset = 0; offset < maxStride; offset += stride) { - - if (srcV[srcIndices[i] + offset] < 0.0) { - - dstV[srcIndices[i] + count] = offset / stride; - count += stride; - } - } - - for (int offset = count; offset < maxStride; offset += stride) { - dstV[srcIndices[i] + offset] = -1; - } - } - - } else { - - for (int i = 0, n = srcV.length; i < n; i++) { - dstV[i] = (srcV[i] < 0.0) ? 1 : 0; - } - } - } - }; - - final static RealIndexOperation RISortOp = new RealIndexOperation() { - - public void op(double[] srcV, int[] srcIndices, int[] dstV, int size, int stride) { - - Double[] srcVBoxed = shared.util.Arrays.box(srcV); - - PermutationEntry.iSort(srcVBoxed, srcIndices, dstV, size, stride); - - for (int i = 0, n = srcV.length; i < n; i++) { - srcV[i] = srcVBoxed[i]; - } - } - }; - - /** - * Defines real dimension operations. - */ - protected interface RealDimensionOperation { - - /** - * Performs a real dimension operation. - */ - public void op(double[] srcV, int[] srcD, int[] srcS, double[] dstV, int[] selectedDims); - } - - final static RealDimensionOperation RDSumOp = new RealDimensionOperation() { - - public void op(double[] srcV, int[] srcD, int[] srcS, double[] dstV, int[] selectedDims) { - - int len = Control.checkEquals(srcV.length, dstV.length); - int ndims = Control.checkEquals(srcD.length, srcS.length); - - boolean[] indicator = new boolean[ndims]; - - for (int dim : selectedDims) { - indicator[dim] = true; - } - - int[] srcIndices = MappingOps.assignMappingIndices(len, srcD, srcS); - - // - - System.arraycopy(srcV, 0, dstV, 0, len); - - for (int dim = 0, indexBlockIncrement = len; dim < ndims; indexBlockIncrement /= srcD[dim++]) { - - if (!indicator[dim]) { - continue; - } - - int size = srcD[dim]; - int stride = srcS[dim]; - - for (int lower = 0, upper = indexBlockIncrement / size; // - lower < len; // - lower += indexBlockIncrement, upper += indexBlockIncrement) { - - for (int indexIndex = lower; indexIndex < upper; indexIndex++) { - - double acc = 0.0; - - for (int k = 0, physical = srcIndices[indexIndex]; k < size; k++, physical += stride) { - - acc += dstV[physical]; - dstV[physical] = acc; - } - } - } - } - } - }; - - final static RealDimensionOperation RDProdOp = new RealDimensionOperation() { - - public void op(double[] srcV, int[] srcD, int[] srcS, double[] dstV, int[] selectedDims) { - - int len = Control.checkEquals(srcV.length, dstV.length); - int ndims = Control.checkEquals(srcD.length, srcS.length); - - boolean[] indicator = new boolean[ndims]; - - for (int dim : selectedDims) { - indicator[dim] = true; - } - - int[] srcIndices = MappingOps.assignMappingIndices(len, srcD, srcS); - - // - - System.arraycopy(srcV, 0, dstV, 0, len); - - for (int dim = 0, indexBlockIncrement = len; dim < ndims; indexBlockIncrement /= srcD[dim++]) { - - if (!indicator[dim]) { - continue; - } - - int size = srcD[dim]; - int stride = srcS[dim]; - - for (int lower = 0, upper = indexBlockIncrement / size; // - lower < len; // - lower += indexBlockIncrement, upper += indexBlockIncrement) { - - for (int indexIndex = lower; indexIndex < upper; indexIndex++) { - - double acc = 1.0; - - for (int k = 0, physical = srcIndices[indexIndex]; k < size; k++, physical += stride) { - - acc *= dstV[physical]; - dstV[physical] = acc; - } - } - } - } - } - }; - - /** - * Assigns base indices when excluding a dimension. - * - * @param nindices - * the number of indices. - * @param srcD - * the dimensions. - * @param srcS - * the strides. - * @param dim - * the dimension to exclude. - * @return the base physical indices. - */ - final public static int[] assignBaseIndices(int nindices, int[] srcD, int[] srcS, int dim) { - - int ndims = Control.checkEquals(srcD.length, srcS.length, // - "Invalid arguments"); - - int[] dModified = new int[ndims - 1]; - int[] sModified = new int[ndims - 1]; - - System.arraycopy(srcD, 0, dModified, 0, dim); - System.arraycopy(srcD, dim + 1, dModified, dim, (ndims - 1) - dim); - - System.arraycopy(srcS, 0, sModified, 0, dim); - System.arraycopy(srcS, dim + 1, sModified, dim, (ndims - 1) - dim); - - return MappingOps.assignMappingIndices(nindices, dModified, sModified); - } - - /** - * Dimension reduce operations in support of - * {@link JavaArrayKernel#rrOp(int, double[], int[], int[], double[], int[], int[], int...)}. - */ - final public static void rrOp(int type, // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS, // - int[] selectedDims) { - - int srcLen = MappingOps.checkDimensions(srcV.length, srcD, srcS); - int dstLen = MappingOps.checkDimensions(dstV.length, dstD, dstS); - - final RealReduceOperation op; - - switch (type) { - - case RR_SUM: - op = RRSumOp; - break; - - case RR_PROD: - op = RRProdOp; - break; - - case RR_MAX: - op = RRMaxOp; - break; - - case RR_MIN: - op = RRMinOp; - break; - - case RR_VAR: - op = RRVarOp; - break; - - default: - throw new IllegalArgumentException(); - } - - Arrays.sort(selectedDims); - - int nselectedDims = selectedDims.length; - int ndims = Control.checkEquals(srcD.length, dstD.length, // - "Dimensionality mismatch"); - - for (int i = 1; i < nselectedDims; i++) { - Control.checkTrue(selectedDims[i - 1] != selectedDims[i], // - "Duplicate selected dimensions not allowed"); - } - - int acc = dstLen; - - for (int i = 0; i < nselectedDims; i++) { - - int dim = selectedDims[i]; - - Control.checkTrue(dim >= 0 && dim < ndims, // - "Invalid dimension"); - - Control.checkTrue(dstD[dim] <= 1, // - "Selected dimension must have singleton or zero length"); - - acc *= srcD[dim]; - } - - Control.checkTrue(acc == srcLen, // - "Invalid arguments"); - - if (srcLen == 0) { - return; - } - - double[] workingV = srcV.clone(); - int[] workingD = srcD.clone(); - - acc = srcLen; - - for (int i = 0; i < nselectedDims; i++) { - - int dim = selectedDims[i]; - - acc /= srcD[dim]; - - op.op(workingV, assignBaseIndices(acc, workingD, srcS, dim), // - workingD[dim], srcS[dim]); - - workingD[dim] = 1; - } - - MappingOps.assign( // - workingV, MappingOps.assignMappingIndices(dstLen, dstD, srcS), // - dstV, MappingOps.assignMappingIndices(dstLen, dstD, dstS)); - } - - /** - * Dimension index operations in support of {@link ArrayKernel#riOp(int, double[], int[], int[], int[], int)}. - */ - final public static void riOp(int type, // - double[] srcV, int[] srcD, int[] srcS, int[] dstV, // - int dim) { - - int srcLen = MappingOps.checkDimensions(srcV.length, srcD, srcS); - - final RealIndexOperation op; - - switch (type) { - - case RI_MAX: - op = RIMaxOp; - break; - - case RI_MIN: - op = RIMinOp; - break; - - case RI_ZERO: - op = RIZeroOp; - break; - - case RI_GZERO: - op = RIGZeroOp; - break; - - case RI_LZERO: - op = RILZeroOp; - break; - - case RI_SORT: - op = RISortOp; - break; - - default: - throw new IllegalArgumentException(); - } - - Control.checkTrue(srcLen == dstV.length, // - "Invalid arguments"); - - if (srcLen == 0) { - return; - } - - if (dim != -1) { - - op.op(srcV, assignBaseIndices(srcLen / srcD[dim], srcD, srcS, dim), // - dstV, srcD[dim], srcS[dim]); - - } else { - - op.op(srcV, null, dstV, -1, -1); - } - } - - /** - * Dimension operations in support of {@link ArrayKernel#rdOp(int, double[], int[], int[], double[], int...)}. - */ - final public static void rdOp(int type, // - double[] srcV, int[] srcD, int[] srcS, double[] dstV, // - int[] selectedDims) { - - int srcLen = MappingOps.checkDimensions(srcV.length, srcD, srcS); - - final RealDimensionOperation op; - - switch (type) { - - case RD_SUM: - op = RDSumOp; - break; - - case RD_PROD: - op = RDProdOp; - break; - - default: - throw new IllegalArgumentException(); - } - - int ndims = Control.checkEquals(srcD.length, srcS.length, // - "Dimensionality mismatch"); - - for (int dim : selectedDims) { - Control.checkTrue(dim >= 0 && dim < ndims, // - "Invalid dimension"); - } - - if (srcLen == 0) { - return; - } - - op.op(srcV, srcD, srcS, dstV, selectedDims); - } - - // Dummy constructor. - DimensionOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ElementOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ElementOps.java deleted file mode 100755 index 01d21156..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ElementOps.java +++ /dev/null @@ -1,1038 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import static shared.array.kernel.ArrayKernel.CA_PROD; -import static shared.array.kernel.ArrayKernel.CA_SUM; -import static shared.array.kernel.ArrayKernel.CE_ADD; -import static shared.array.kernel.ArrayKernel.CE_DIV; -import static shared.array.kernel.ArrayKernel.CE_MUL; -import static shared.array.kernel.ArrayKernel.CE_SUB; -import static shared.array.kernel.ArrayKernel.CTOR_ABS; -import static shared.array.kernel.ArrayKernel.CTOR_IM; -import static shared.array.kernel.ArrayKernel.CTOR_RE; -import static shared.array.kernel.ArrayKernel.CU_ADD; -import static shared.array.kernel.ArrayKernel.CU_CONJ; -import static shared.array.kernel.ArrayKernel.CU_COS; -import static shared.array.kernel.ArrayKernel.CU_EXP; -import static shared.array.kernel.ArrayKernel.CU_FILL; -import static shared.array.kernel.ArrayKernel.CU_MUL; -import static shared.array.kernel.ArrayKernel.CU_RND; -import static shared.array.kernel.ArrayKernel.CU_SHUFFLE; -import static shared.array.kernel.ArrayKernel.CU_SIN; -import static shared.array.kernel.ArrayKernel.IE_ADD; -import static shared.array.kernel.ArrayKernel.IE_MAX; -import static shared.array.kernel.ArrayKernel.IE_MIN; -import static shared.array.kernel.ArrayKernel.IE_MUL; -import static shared.array.kernel.ArrayKernel.IE_SUB; -import static shared.array.kernel.ArrayKernel.IU_ADD; -import static shared.array.kernel.ArrayKernel.IU_FILL; -import static shared.array.kernel.ArrayKernel.IU_MUL; -import static shared.array.kernel.ArrayKernel.IU_SHUFFLE; -import static shared.array.kernel.ArrayKernel.RA_ENT; -import static shared.array.kernel.ArrayKernel.RA_MAX; -import static shared.array.kernel.ArrayKernel.RA_MIN; -import static shared.array.kernel.ArrayKernel.RA_PROD; -import static shared.array.kernel.ArrayKernel.RA_SUM; -import static shared.array.kernel.ArrayKernel.RA_VAR; -import static shared.array.kernel.ArrayKernel.RE_ADD; -import static shared.array.kernel.ArrayKernel.RE_DIV; -import static shared.array.kernel.ArrayKernel.RE_MAX; -import static shared.array.kernel.ArrayKernel.RE_MIN; -import static shared.array.kernel.ArrayKernel.RE_MUL; -import static shared.array.kernel.ArrayKernel.RE_SUB; -import static shared.array.kernel.ArrayKernel.RTOC_IM; -import static shared.array.kernel.ArrayKernel.RTOC_RE; -import static shared.array.kernel.ArrayKernel.RU_ABS; -import static shared.array.kernel.ArrayKernel.RU_ADD; -import static shared.array.kernel.ArrayKernel.RU_ATAN; -import static shared.array.kernel.ArrayKernel.RU_COS; -import static shared.array.kernel.ArrayKernel.RU_EXP; -import static shared.array.kernel.ArrayKernel.RU_FILL; -import static shared.array.kernel.ArrayKernel.RU_INV; -import static shared.array.kernel.ArrayKernel.RU_LOG; -import static shared.array.kernel.ArrayKernel.RU_MUL; -import static shared.array.kernel.ArrayKernel.RU_POW; -import static shared.array.kernel.ArrayKernel.RU_RND; -import static shared.array.kernel.ArrayKernel.RU_SHUFFLE; -import static shared.array.kernel.ArrayKernel.RU_SIN; -import static shared.array.kernel.ArrayKernel.RU_SQR; -import static shared.array.kernel.ArrayKernel.RU_SQRT; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A class for elementwise operations in pure Java. - * - * @apiviz.has shared.array.kernel.ElementOps.RealBinaryOperation - - - argument - * @apiviz.has shared.array.kernel.ElementOps.RealAccumulatorOperation - - - argument - * @apiviz.has shared.array.kernel.ElementOps.RealToComplexOperation - - - argument - * @apiviz.has shared.array.kernel.ElementOps.IntegerBinaryOperation - - - argument - * @apiviz.has shared.array.kernel.ElementOps.ComplexBinaryOperation - - - argument - * @apiviz.has shared.array.kernel.ElementOps.ComplexAccumulatorOperation - - - argument - * @apiviz.has shared.array.kernel.ElementOps.ComplexToRealOperation - - - argument - * @author Roy Liu - */ -public class ElementOps { - - /** - * Defines real binary operations. - */ - protected interface RealBinaryOperation { - - /** - * Performs a real binary operation. - */ - public double op(double a, double b); - } - - final static RealBinaryOperation REAddOp = new RealBinaryOperation() { - - public double op(double a, double b) { - return a + b; - } - }; - - final static RealBinaryOperation RESubOp = new RealBinaryOperation() { - - public double op(double a, double b) { - return a - b; - } - }; - - final static RealBinaryOperation REMulOp = new RealBinaryOperation() { - - public double op(double a, double b) { - return a * b; - } - }; - - final static RealBinaryOperation REDivOp = new RealBinaryOperation() { - - public double op(double a, double b) { - return a / b; - } - }; - - final static RealBinaryOperation REMaxOp = new RealBinaryOperation() { - - public double op(double a, double b) { - return Math.max(a, b); - } - }; - - final static RealBinaryOperation REMinOp = new RealBinaryOperation() { - - public double op(double a, double b) { - return Math.min(a, b); - } - }; - - /** - * Defines complex binary operations. - */ - public interface ComplexBinaryOperation { - - /** - * Performs a complex binary operation. - */ - public void op(double[] res, double aRe, double aIm, double bRe, double bIm); - } - - final static ComplexBinaryOperation CEAddOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double bRe, double bIm) { - - res[0] = aRe + bRe; - res[1] = aIm + bIm; - } - }; - - final static ComplexBinaryOperation CESubOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double bRe, double bIm) { - - res[0] = aRe - bRe; - res[1] = aIm - bIm; - } - }; - - final static ComplexBinaryOperation CEMulOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double bRe, double bIm) { - - res[0] = aRe * bRe - aIm * bIm; - res[1] = aRe * bIm + bRe * aIm; - } - }; - - final static ComplexBinaryOperation CEDivOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double bRe, double bIm) { - - res[0] = (aRe * bRe + aIm * bIm) / (bRe * bRe + bIm * bIm); - res[1] = (aIm * bRe - aRe * bIm) / (bRe * bRe + bIm * bIm); - } - }; - - /** - * Defines integer binary operations. - */ - protected interface IntegerBinaryOperation { - - /** - * Performs an integer binary operation. - */ - public int op(int a, int b); - } - - final static IntegerBinaryOperation IEAddOp = new IntegerBinaryOperation() { - - public int op(int a, int b) { - return a + b; - } - }; - - final static IntegerBinaryOperation IESubOp = new IntegerBinaryOperation() { - - public int op(int a, int b) { - return a - b; - } - }; - - final static IntegerBinaryOperation IEMulOp = new IntegerBinaryOperation() { - - public int op(int a, int b) { - return a * b; - } - }; - - final static IntegerBinaryOperation IEMaxOp = new IntegerBinaryOperation() { - - public int op(int a, int b) { - return Math.max(a, b); - } - }; - - final static IntegerBinaryOperation IEMinOp = new IntegerBinaryOperation() { - - public int op(int a, int b) { - return Math.min(a, b); - } - }; - - /** - * Defines complex-to-real operations. - */ - public interface ComplexToRealOperation { - - /** - * Performs a complex-to-real operation. - */ - public double op(double aRe, double aIm); - } - - final static ComplexToRealOperation CTORAbsOp = new ComplexToRealOperation() { - - public double op(double aRe, double aIm) { - return Math.sqrt(aRe * aRe + aIm * aIm); - } - }; - - final static ComplexToRealOperation CTORReOp = new ComplexToRealOperation() { - - public double op(double aRe, double aIm) { - return aRe; - } - }; - - final static ComplexToRealOperation CTORImOp = new ComplexToRealOperation() { - - public double op(double aRe, double aIm) { - return aIm; - } - }; - - /** - * Defines real-to-complex operations. - */ - protected interface RealToComplexOperation { - - /** - * Performs a real-to-complex operation. - */ - public void op(double[] res, double a); - } - - final static RealToComplexOperation RTOCReOp = new RealToComplexOperation() { - - public void op(double[] res, double a) { - - res[0] = a; - res[1] = 0; - } - }; - - final static RealToComplexOperation RTOCImOp = new RealToComplexOperation() { - - public void op(double[] res, double a) { - - res[0] = 0; - res[1] = a; - } - }; - - final static RealBinaryOperation RUAbsOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.abs(v); - } - }; - - final static RealBinaryOperation RUPowOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.pow(v, a); - } - }; - - final static RealBinaryOperation RUExpOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.exp(v); - } - }; - - final static RealBinaryOperation RURndOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Arithmetic.nextDouble(a); - } - }; - - final static RealBinaryOperation RULogOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.log(v); - } - }; - - final static RealBinaryOperation RUSqrtOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.sqrt(v); - } - }; - - final static RealBinaryOperation RUSqrOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return v * v; - } - }; - - final static RealBinaryOperation RUInvOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return a / v; - } - }; - - final static RealBinaryOperation RUCosOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.cos(v); - } - }; - - final static RealBinaryOperation RUSinOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.sin(v); - } - }; - - final static RealBinaryOperation RUAtanOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return Math.atan(v); - } - }; - - final static RealBinaryOperation RUFillOp = new RealBinaryOperation() { - - public double op(double a, double v) { - return a; - } - }; - - final static ComplexBinaryOperation CUExpOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double vRe, double vIm) { - - res[0] = Math.exp(vRe) * Math.cos(vIm); - res[1] = Math.exp(vRe) * Math.sin(vIm); - } - }; - - final static ComplexBinaryOperation CURndOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double vRe, double vIm) { - - res[0] = Arithmetic.nextDouble(aRe); - res[1] = Arithmetic.nextDouble(aIm); - } - }; - - final static ComplexBinaryOperation CUConjOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double vRe, double vIm) { - - res[0] = vRe; - res[1] = -vIm; - } - }; - - final static ComplexBinaryOperation CUCosOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double vRe, double vIm) { - - CEMulOp.op(res, 0.0, 1.0, vRe, vIm); - CUExpOp.op(res, Double.NaN, Double.NaN, res[0], res[1]); - - double xRe = res[0]; - double xIm = res[1]; - - CEMulOp.op(res, 0.0, -1.0, vRe, vIm); - CUExpOp.op(res, Double.NaN, Double.NaN, res[0], res[1]); - - double yRe = res[0]; - double yIm = res[1]; - - CEAddOp.op(res, xRe, xIm, yRe, yIm); - CEDivOp.op(res, res[0], res[1], 2.0, 0.0); - } - }; - - final static ComplexBinaryOperation CUSinOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double vRe, double vIm) { - - CEMulOp.op(res, 0.0, 1.0, vRe, vIm); - CUExpOp.op(res, Double.NaN, Double.NaN, res[0], res[1]); - - double xRe = res[0]; - double xIm = res[1]; - - CEMulOp.op(res, 0.0, -1.0, vRe, vIm); - CUExpOp.op(res, Double.NaN, Double.NaN, res[0], res[1]); - - double yRe = res[0]; - double yIm = res[1]; - - CESubOp.op(res, xRe, xIm, yRe, yIm); - CEDivOp.op(res, res[0], res[1], 0.0, 2.0); - } - }; - - final static ComplexBinaryOperation CUFillOp = new ComplexBinaryOperation() { - - public void op(double[] res, double aRe, double aIm, double vRe, double vIm) { - - res[0] = aRe; - res[1] = aIm; - } - }; - - final static IntegerBinaryOperation IUFillOp = new IntegerBinaryOperation() { - - public int op(int a, int v) { - return a; - } - }; - - /** - * Defines real accumulator operations. - */ - protected interface RealAccumulatorOperation { - - /** - * Performs a real accumulator operation. - */ - public double op(double[] srcV); - } - - final static RealAccumulatorOperation RASumOp = new RealAccumulatorOperation() { - - public double op(double[] srcV) { - return Arithmetic.sum(srcV); - } - }; - - final static RealAccumulatorOperation RAProdOp = new RealAccumulatorOperation() { - - public double op(double[] srcV) { - return Arithmetic.product(srcV); - } - }; - - final static RealAccumulatorOperation RAMaxOp = new RealAccumulatorOperation() { - - public double op(double[] srcV) { - return Arithmetic.max(srcV); - } - }; - - final static RealAccumulatorOperation RAMinOp = new RealAccumulatorOperation() { - - public double op(double[] srcV) { - return Arithmetic.min(srcV); - } - }; - - final static RealAccumulatorOperation RAVarOp = new RealAccumulatorOperation() { - - public double op(double[] srcV) { - return Arithmetic.variance(srcV); - } - }; - - final static RealAccumulatorOperation RAEntOp = new RealAccumulatorOperation() { - - public double op(double[] srcV) { - return Arithmetic.entropy(srcV); - } - }; - - /** - * Defines complex accumulator operations. - */ - protected interface ComplexAccumulatorOperation { - - /** - * Performs a complex accumulator operation. - */ - public double[] op(double[] srcV); - } - - final static ComplexAccumulatorOperation CASumOp = new ComplexAccumulatorOperation() { - - public double[] op(double[] srcV) { - - double[] res = new double[2]; - - for (int i = 0, n = srcV.length; i < n; i += 2) { - CEAddOp.op(res, res[0], res[1], srcV[i], srcV[i + 1]); - } - - return res; - } - }; - - final static ComplexAccumulatorOperation CAProdOp = new ComplexAccumulatorOperation() { - - public double[] op(double[] srcV) { - - double[] res = new double[] { 1.0, 0.0 }; - - for (int i = 0, n = srcV.length; i < n; i += 2) { - CEMulOp.op(res, res[0], res[1], srcV[i], srcV[i + 1]); - } - - return res; - } - }; - - /** - * A real accumulator operation in support of {@link JavaArrayKernel#raOp(int, double[])}. - */ - final public static double raOp(int type, double[] srcV) { - - final RealAccumulatorOperation op; - - switch (type) { - - case RA_SUM: - op = RASumOp; - break; - - case RA_PROD: - op = RAProdOp; - break; - - case RA_ENT: - op = RAEntOp; - break; - - case RA_VAR: - op = RAVarOp; - break; - - case RA_MAX: - op = RAMaxOp; - break; - - case RA_MIN: - op = RAMinOp; - break; - - default: - throw new IllegalArgumentException(); - } - - return op.op(srcV); - } - - /** - * A complex accumulator operation in support of {@link JavaArrayKernel#caOp(int, double[])}. - */ - final public static double[] caOp(int type, double[] srcV) { - - final ComplexAccumulatorOperation op; - - switch (type) { - - case CA_SUM: - op = CASumOp; - break; - - case CA_PROD: - op = CAProdOp; - break; - - default: - throw new IllegalArgumentException(); - } - - Control.checkTrue(srcV.length % 2 == 0); - - return op.op(srcV); - } - - /** - * A real unary elementwise operation in support of {@link JavaArrayKernel#ruOp(int, double, double[])}. - */ - final public static void ruOp(int type, double a, double[] srcV) { - - final RealBinaryOperation op; - - switch (type) { - - case RU_ADD: - op = REAddOp; - break; - - case RU_MUL: - op = REMulOp; - break; - - case RU_EXP: - op = RUExpOp; - break; - - case RU_LOG: - op = RULogOp; - break; - - case RU_POW: - op = RUPowOp; - break; - - case RU_RND: - op = RURndOp; - break; - - case RU_ABS: - op = RUAbsOp; - break; - - case RU_SQRT: - op = RUSqrtOp; - break; - - case RU_SQR: - op = RUSqrOp; - break; - - case RU_INV: - op = RUInvOp; - break; - - case RU_COS: - op = RUCosOp; - break; - - case RU_SIN: - op = RUSinOp; - break; - - case RU_ATAN: - op = RUAtanOp; - break; - - case RU_FILL: - op = RUFillOp; - break; - - case RU_SHUFFLE: - Arithmetic.shuffle(srcV); - return; - - default: - throw new IllegalArgumentException(); - } - - for (int i = 0, n = srcV.length; i < n; i++) { - srcV[i] = op.op(a, srcV[i]); - } - } - - /** - * A complex unary elementwise operation in support of {@link JavaArrayKernel#cuOp(int, double, double, double[])}. - */ - final public static void cuOp(int type, double aRe, double aIm, double[] srcV) { - - double[] tmp = new double[2]; - - int n = srcV.length; - - final ComplexBinaryOperation op; - - switch (type) { - - case CU_ADD: - op = CEAddOp; - break; - - case CU_MUL: - op = CEMulOp; - break; - - case CU_EXP: - op = CUExpOp; - break; - - case CU_RND: - op = CURndOp; - break; - - case CU_CONJ: - op = CUConjOp; - break; - - case CU_COS: - op = CUCosOp; - break; - - case CU_SIN: - op = CUSinOp; - break; - - case CU_FILL: - op = CUFillOp; - break; - - case CU_SHUFFLE: - - for (int i = n / 2; i > 1; i--) { - - int index = Arithmetic.nextInt(i); - - double tmpRe = srcV[2 * (i - 1)]; - double tmpIm = srcV[2 * (i - 1) + 1]; - - srcV[2 * (i - 1)] = srcV[2 * index]; - srcV[2 * (i - 1) + 1] = srcV[2 * index + 1]; - - srcV[2 * index] = tmpRe; - srcV[2 * index + 1] = tmpIm; - } - - return; - - default: - throw new IllegalArgumentException(); - } - - Control.checkTrue(n % 2 == 0); - - for (int i = 0; i < n; i += 2) { - - op.op(tmp, aRe, aIm, srcV[i], srcV[i + 1]); - - srcV[i] = tmp[0]; - srcV[i + 1] = tmp[1]; - } - } - - /** - * An integer unary elementwise operation in support of {@link JavaArrayKernel#iuOp(int, int, int[])}. - */ - final public static void iuOp(int type, int a, int[] srcV) { - - final IntegerBinaryOperation op; - - switch (type) { - - case IU_ADD: - op = IEAddOp; - break; - - case IU_MUL: - op = IEMulOp; - break; - - case IU_FILL: - op = IUFillOp; - break; - - case IU_SHUFFLE: - Arithmetic.shuffle(srcV); - return; - - default: - throw new IllegalArgumentException(); - } - - for (int i = 0, n = srcV.length; i < n; i++) { - srcV[i] = op.op(a, srcV[i]); - } - } - - /** - * A binary elementwise operation in support of {@link JavaArrayKernel#eOp(int, Object, Object, Object, boolean)}. - */ - final public static void eOp(int type, Object lhs, Object rhs, Object dst, boolean isComplex) { - - if (lhs instanceof double[] && rhs instanceof double[] && dst instanceof double[]) { - - final double[] lhsV = (double[]) lhs; - final double[] rhsV = (double[]) rhs; - final double[] dstV = (double[]) dst; - - if (isComplex) { - - final ComplexBinaryOperation op; - - switch (type) { - - case CE_ADD: - op = CEAddOp; - break; - - case CE_SUB: - op = CESubOp; - break; - - case CE_MUL: - op = CEMulOp; - break; - - case CE_DIV: - op = CEDivOp; - break; - - default: - throw new IllegalArgumentException(); - } - - double[] tmp = new double[2]; - - int n = Control.checkEquals(Control.checkEquals(lhsV.length, rhsV.length), dstV.length); - - Control.checkTrue(n % 2 == 0); - - for (int i = 0; i < n; i += 2) { - - op.op(tmp, lhsV[i], lhsV[i + 1], rhsV[i], rhsV[i + 1]); - - dstV[i] = tmp[0]; - dstV[i + 1] = tmp[1]; - } - - } else { - - final RealBinaryOperation op; - - switch (type) { - - case RE_ADD: - op = REAddOp; - break; - - case RE_SUB: - op = RESubOp; - break; - - case RE_MUL: - op = REMulOp; - break; - - case RE_DIV: - op = REDivOp; - break; - - case RE_MAX: - op = REMaxOp; - break; - - case RE_MIN: - op = REMinOp; - break; - - default: - throw new IllegalArgumentException(); - } - - for (int i = 0, n = Control.checkEquals(Control.checkEquals(lhsV.length, rhsV.length), dstV.length); // - i < n; i++) { - dstV[i] = op.op(lhsV[i], rhsV[i]); - } - } - - } else if (lhs instanceof int[] && rhs instanceof int[] && dst instanceof int[]) { - - final int[] lhsV = (int[]) lhs; - final int[] rhsV = (int[]) rhs; - final int[] dstV = (int[]) dst; - - final IntegerBinaryOperation op; - - switch (type) { - - case IE_ADD: - op = IEAddOp; - break; - - case IE_SUB: - op = IESubOp; - break; - - case IE_MUL: - op = IEMulOp; - break; - - case IE_MAX: - op = IEMaxOp; - break; - - case IE_MIN: - op = IEMinOp; - break; - - default: - throw new IllegalArgumentException(); - } - - for (int i = 0, n = Control.checkEquals(Control.checkEquals(lhsV.length, rhsV.length), dstV.length); // - i < n; i++) { - dstV[i] = op.op(lhsV[i], rhsV[i]); - } - - } else { - - throw new IllegalArgumentException("Invalid array types"); - } - } - - /** - * A type conversion operation in support of {@link JavaArrayKernel#convert(int, Object, boolean, Object, boolean)}. - */ - final public static void convert(int type, Object srcV, boolean isSrcComplex, Object dstV, boolean isDstComplex) { - - if (srcV instanceof double[] && !isSrcComplex && dstV instanceof double[] && isDstComplex) { - - double[] srcV_d = (double[]) srcV; - double[] dstV_d = (double[]) dstV; - - final RealToComplexOperation op; - - switch (type) { - - case RTOC_RE: - op = RTOCReOp; - break; - - case RTOC_IM: - op = RTOCImOp; - break; - - default: - throw new IllegalArgumentException(); - } - - double[] tmp = new double[2]; - - for (int i = 0, j = 0, n = Control.checkEquals(srcV_d.length * 2, dstV_d.length) / 2; // - i < n; i++, j += 2) { - - op.op(tmp, srcV_d[i]); - - dstV_d[j] = tmp[0]; - dstV_d[j + 1] = tmp[1]; - } - - } else if (srcV instanceof double[] && isSrcComplex && dstV instanceof double[] && !isDstComplex) { - - double[] srcV_d = (double[]) srcV; - double[] dstV_d = (double[]) dstV; - - final ComplexToRealOperation op; - - switch (type) { - - case CTOR_ABS: - op = CTORAbsOp; - break; - - case CTOR_RE: - op = CTORReOp; - break; - - case CTOR_IM: - op = CTORImOp; - break; - - default: - throw new IllegalArgumentException(); - } - - for (int i = 0, j = 0, n = Control.checkEquals(srcV_d.length, dstV_d.length * 2); // - i < n; i += 2, j++) { - dstV_d[j] = op.op(srcV_d[i], srcV_d[i + 1]); - } - - } else if (srcV instanceof int[] && !isSrcComplex && dstV instanceof double[] && !isDstComplex) { - - int[] srcV_i = (int[]) srcV; - double[] dstV_d = (double[]) dstV; - - for (int i = 0, n = Control.checkEquals(srcV_i.length, dstV_d.length); i < n; i++) { - dstV_d[i] = srcV_i[i]; - } - - } else { - - throw new IllegalArgumentException("Invalid arguments"); - } - } - - // Dummy constructor. - ElementOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/IndexOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/IndexOps.java deleted file mode 100755 index 2abf2677..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/IndexOps.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A class for indexing operations in pure Java. - * - * @author Roy Liu - */ -public class IndexOps { - - /** - * An operation in support of {@link JavaArrayKernel#find(int[], int[], int[], int[])}. - */ - final public static int[] find(int[] srcV, int[] srcD, int[] srcS, int[] logical) { - - int ndims = srcD.length; - - Control.checkTrue(ndims == srcS.length // - && ndims == logical.length); - - MappingOps.checkDimensions(srcV.length, srcD, srcS); - - int activeDim = Arithmetic.indexOf(logical, -1); - - Control.checkTrue(Arithmetic.count(logical, -1) == 1, // - "The dimension marker must be unique"); - - int offset = 0; - - for (int dim = 0; dim < ndims; dim++) { - - if (dim != activeDim) { - - int index = logical[dim]; - - offset += index * srcS[dim]; - - Control.checkTrue(index >= 0 && index < srcD[dim], // - "Invalid index"); - } - } - - int upper = 0; - int size = srcD[activeDim]; - int stride = srcS[activeDim]; - - for (int i = 0, physical = offset; i < size; i++, physical += stride) { - - if (srcV[physical] >= 0) { - upper++; - } - } - - int[] res = new int[upper]; - - for (int i = 0, physical = offset; i < upper; i++, physical += stride) { - res[i] = srcV[physical]; - } - - return res; - } - - // Dummy constructor. - IndexOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/JavaArrayKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/JavaArrayKernel.java deleted file mode 100755 index 96804b78..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/JavaArrayKernel.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import shared.array.sparse.SparseArrayState; -import shared.util.Arithmetic; - -/** - * A pure Java implementation of {@link ArrayKernel}. - * - * @apiviz.uses shared.array.kernel.DimensionOps - * @apiviz.uses shared.array.kernel.ElementOps - * @apiviz.uses shared.array.kernel.IndexOps - * @apiviz.uses shared.array.kernel.LinearAlgebraOps - * @apiviz.uses shared.array.kernel.MappingOps - * @apiviz.uses shared.array.kernel.MatrixOps - * @apiviz.uses shared.array.kernel.SparseOps - * @author Roy Liu - */ -public class JavaArrayKernel implements ArrayKernel { - - /** - * Default constructor. - */ - public JavaArrayKernel() { - } - - // - - public void randomize() { - Arithmetic.randomize(); - } - - public void derandomize() { - Arithmetic.derandomize(); - } - - // - - public void map(int[] bounds, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS) { - MappingOps.map(bounds, srcV, srcD, srcS, dstV, dstD, dstS); - } - - public void slice( // - int[] slices, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS) { - MappingOps.slice(slices, srcV, srcD, srcS, dstV, dstD, dstS); - } - - // - - public void rrOp(int type, // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS, // - int... selectedDims) { - DimensionOps.rrOp(type, srcV, srcD, srcS, dstV, dstD, dstS, selectedDims); - } - - public void riOp(int type, // - double[] srcV, int[] srcD, int[] srcS, int[] dstV, // - int dim) { - DimensionOps.riOp(type, srcV, srcD, srcS, dstV, dim); - } - - public void rdOp(int type, // - double[] srcV, int[] srcD, int[] srcS, double[] dstV, // - int... selectedDims) { - DimensionOps.rdOp(type, srcV, srcD, srcS, dstV, selectedDims); - } - - // - - public double raOp(int type, double[] srcV) { - return ElementOps.raOp(type, srcV); - } - - public double[] caOp(int type, double[] srcV) { - return ElementOps.caOp(type, srcV); - } - - public void ruOp(int type, double a, double[] srcV) { - ElementOps.ruOp(type, a, srcV); - } - - public void cuOp(int type, double aRe, double aIm, double[] srcV) { - ElementOps.cuOp(type, aRe, aIm, srcV); - } - - public void iuOp(int type, int a, int[] srcV) { - ElementOps.iuOp(type, a, srcV); - } - - public void eOp(int type, Object lhsV, Object rhsV, Object dstV, boolean isComplex) { - ElementOps.eOp(type, lhsV, rhsV, dstV, isComplex); - } - - public void convert(int type, Object srcV, boolean isSrcComplex, Object dstV, boolean isDstComplex) { - ElementOps.convert(type, srcV, isSrcComplex, dstV, isDstComplex); - } - - // - - public void mul(double[] lhsV, double[] rhsV, int lr, int rc, double[] dstV, boolean isComplex) { - MatrixOps.mul(lhsV, rhsV, lr, rc, dstV, isComplex); - } - - public void diag(double[] srcV, double[] dstV, int size, boolean isComplex) { - MatrixOps.diag(srcV, dstV, size, isComplex); - } - - // - - public void svd(double[] srcV, int srcStrideRow, int srcStrideCol, // - double[] uV, double[] sV, double[] vV, // - int nrows, int ncols) { - LinearAlgebraOps.svd(srcV, srcStrideRow, srcStrideCol, uV, sV, vV, nrows, ncols); - } - - public void eigs(double[] srcV, double[] vecV, double[] valV, int size) { - LinearAlgebraOps.eigs(srcV, vecV, valV, size); - } - - public void invert(double[] srcV, double[] dstV, int size) { - LinearAlgebraOps.invert(srcV, dstV, size); - } - - // - - public int[] find(int[] srcV, int[] srcD, int[] srcS, int[] logical) { - return IndexOps.find(srcV, srcD, srcS, logical); - } - - // - - public SparseArrayState insertSparse( // - V oldV, int[] oldD, int[] oldS, int[] oldDO, int[] oldI, // - V newV, int[] newI) { - return SparseOps.insert(oldV, oldD, oldS, oldDO, oldI, newV, newI); - } - - public SparseArrayState sliceSparse(int[] slices, // - V srcV, int[] srcD, int[] srcS, int[] srcDO, // - int[] srcI, int[] srcIO, int[] srcII, // - V dstV, int[] dstD, int[] dstS, int[] dstDO, // - int[] dstI, int[] dstIO, int[] dstII) { - return SparseOps.slice(slices, // - srcV, srcD, srcS, srcDO, // - srcI, srcIO, srcII, // - dstV, dstD, dstS, dstDO, // - dstI, dstIO, dstII); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/LinearAlgebraOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/LinearAlgebraOps.java deleted file mode 100755 index c936a3fd..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/LinearAlgebraOps.java +++ /dev/null @@ -1,1180 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import static shared.array.kernel.ElementOps.CEDivOp; -import static shared.array.kernel.ElementOps.CTORAbsOp; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A class for linear algebra operations in pure Java. - * - * @author Roy Liu - */ -public class LinearAlgebraOps { - - /** - * A singular value decomposition operation in support of - * {@link JavaArrayKernel#svd(double[], int, int, double[], double[], double[], int, int)}. - */ - final public static void svd(double[] srcV, int srcStrideRow, int srcStrideCol, // - double[] uV, double[] sV, double[] vV, // - int nrows, int ncols) { - - Control.checkTrue(nrows >= ncols // - && srcV.length == nrows * ncols // - && uV.length == nrows * ncols // - && sV.length == ncols // - && vV.length == ncols * ncols // - && ((srcStrideRow == ncols && srcStrideCol == 1) // - || (srcStrideRow == 1 && srcStrideCol == nrows)), // - "Invalid arguments"); - - int uStrideRow = ncols; - int vStrideRow = ncols; - - double[] e = new double[ncols]; - double[] work = new double[nrows]; - double[] a = srcV.clone(); - - // Reduce A to bidiagonal form, storing the diagonal elements - // in s and the super-diagonal elements in e. - - int nct = Math.min(nrows - 1, ncols); - int nrt = Math.max(0, Math.min(ncols - 2, nrows)); - for (int k = 0, l = Math.max(nct, nrt); k < l; k++) { - if (k < nct) { - - // Compute the transformation for the k-th column and - // place the k-th diagonal in s[k]. - // Compute 2-norm of k-th column without under/overflow. - sV[k] = 0; - for (int i = k; i < nrows; i++) { - sV[k] = CTORAbsOp.op(sV[k], a[srcStrideRow * (i) + srcStrideCol * (k)]); - } - if (sV[k] != 0.0) { - if (a[srcStrideRow * (k) + srcStrideCol * (k)] < 0.0) { - sV[k] = -sV[k]; - } - for (int i = k; i < nrows; i++) { - a[srcStrideRow * (i) + srcStrideCol * (k)] /= sV[k]; - } - a[srcStrideRow * (k) + srcStrideCol * (k)] += 1.0; - } - sV[k] = -sV[k]; - } - for (int j = k + 1; j < ncols; j++) { - if ((k < nct) & (sV[k] != 0.0)) { - - // Apply the transformation. - - double t = 0; - for (int i = k; i < nrows; i++) { - t += a[srcStrideRow * (i) + srcStrideCol * (k)] * a[srcStrideRow * (i) + srcStrideCol * (j)]; - } - t = -t / a[srcStrideRow * (k) + srcStrideCol * (k)]; - for (int i = k; i < nrows; i++) { - a[srcStrideRow * (i) + srcStrideCol * (j)] += t * a[srcStrideRow * (i) + srcStrideCol * (k)]; - } - } - - // Place the k-th row of A into e for the - // subsequent calculation of the row transformation. - - e[j] = a[srcStrideRow * (k) + srcStrideCol * (j)]; - } - if (k < nct) { - - // Place the transformation in U for subsequent back - // multiplication. - - for (int i = k; i < nrows; i++) { - uV[uStrideRow * (i) + (k)] = a[srcStrideRow * (i) + srcStrideCol * (k)]; - } - } - if (k < nrt) { - - // Compute the k-th row transformation and place the - // k-th super-diagonal in e[k]. - // Compute 2-norm without under/overflow. - e[k] = 0; - for (int i = k + 1; i < ncols; i++) { - e[k] = CTORAbsOp.op(e[k], e[i]); - } - if (e[k] != 0.0) { - if (e[k + 1] < 0.0) { - e[k] = -e[k]; - } - for (int i = k + 1; i < ncols; i++) { - e[i] /= e[k]; - } - e[k + 1] += 1.0; - } - e[k] = -e[k]; - if ((k + 1 < nrows) & (e[k] != 0.0)) { - - // Apply the transformation. - - for (int i = k + 1; i < nrows; i++) { - work[i] = 0.0; - } - for (int j = k + 1; j < ncols; j++) { - for (int i = k + 1; i < nrows; i++) { - work[i] += e[j] * a[srcStrideRow * (i) + srcStrideCol * (j)]; - } - } - for (int j = k + 1; j < ncols; j++) { - double t = -e[j] / e[k + 1]; - for (int i = k + 1; i < nrows; i++) { - a[srcStrideRow * (i) + srcStrideCol * (j)] += t * work[i]; - } - } - } - - // Place the transformation in V for subsequent - // back multiplication. - - for (int i = k + 1; i < ncols; i++) { - vV[vStrideRow * (i) + (k)] = e[i]; - } - } - } - - // Set up the final bidiagonal matrix or order p. - - int p = ncols; - if (nct < ncols) { - sV[nct] = a[srcStrideRow * (nct) + srcStrideCol * (nct)]; - } - if (nrows < p) { - sV[p - 1] = 0.0; - } - if (nrt + 1 < p) { - e[nrt] = a[srcStrideRow * (nrt) + srcStrideCol * (p - 1)]; - } - e[p - 1] = 0.0; - - // If required, generate U. - - for (int j = nct; j < ncols; j++) { - for (int i = 0; i < nrows; i++) { - uV[uStrideRow * (i) + (j)] = 0.0; - } - uV[uStrideRow * (j) + (j)] = 1.0; - } - for (int k = nct - 1; k >= 0; k--) { - if (sV[k] != 0.0) { - for (int j = k + 1; j < ncols; j++) { - double t = 0; - for (int i = k; i < nrows; i++) { - t += uV[uStrideRow * (i) + (k)] * uV[uStrideRow * (i) + (j)]; - } - t = -t / uV[uStrideRow * (k) + (k)]; - for (int i = k; i < nrows; i++) { - uV[uStrideRow * (i) + (j)] += t * uV[uStrideRow * (i) + (k)]; - } - } - for (int i = k; i < nrows; i++) { - uV[uStrideRow * (i) + (k)] = -uV[uStrideRow * (i) + (k)]; - } - uV[uStrideRow * (k) + (k)] = 1.0 + uV[uStrideRow * (k) + (k)]; - for (int i = 0; i < k - 1; i++) { - uV[uStrideRow * (i) + (k)] = 0.0; - } - } else { - for (int i = 0; i < nrows; i++) { - uV[uStrideRow * (i) + (k)] = 0.0; - } - uV[uStrideRow * (k) + (k)] = 1.0; - } - } - - // If required, generate V. - - for (int k = ncols - 1; k >= 0; k--) { - if ((k < nrt) & (e[k] != 0.0)) { - for (int j = k + 1; j < ncols; j++) { - double t = 0; - for (int i = k + 1; i < ncols; i++) { - t += vV[vStrideRow * (i) + (k)] * vV[vStrideRow * (i) + (j)]; - } - t = -t / vV[vStrideRow * (k + 1) + (k)]; - for (int i = k + 1; i < ncols; i++) { - vV[vStrideRow * (i) + (j)] += t * vV[vStrideRow * (i) + (k)]; - } - } - } - for (int i = 0; i < ncols; i++) { - vV[vStrideRow * (i) + (k)] = 0.0; - } - vV[vStrideRow * (k) + (k)] = 1.0; - } - - // Main iteration loop for the singular values. - - int pp = p - 1; - int iter = 0; - double eps = Math.pow(2.0, -52.0); - double tiny = Math.pow(2.0, -966.0); - while (p > 0) { - int k, kase; - - // Here is where a test for too many iterations would go. - - // This section of the program inspects for - // negligible elements in the s and e arrays. On - // completion the variables kase and k are set as follows. - - // kase = 1 if s(p) and e[k-1] are negligible and k

= -1; k--) { - if (k == -1) { - break; - } - if (Math.abs(e[k]) <= tiny + eps * (Math.abs(sV[k]) + Math.abs(sV[k + 1]))) { - e[k] = 0.0; - break; - } - } - if (k == p - 2) { - kase = 4; - } else { - int ks; - for (ks = p - 1; ks >= k; ks--) { - if (ks == k) { - break; - } - double t = (ks != p ? Math.abs(e[ks]) : 0.) + (ks != k + 1 ? Math.abs(e[ks - 1]) : 0.); - if (Math.abs(sV[ks]) <= tiny + eps * t) { - sV[ks] = 0.0; - break; - } - } - if (ks == k) { - kase = 3; - } else if (ks == p - 1) { - kase = 1; - } else { - kase = 2; - k = ks; - } - } - k++; - - // Perform the task indicated by kase. - - switch (kase) { - - // Deflate negligible s(p). - - case 1: { - double f = e[p - 2]; - e[p - 2] = 0.0; - for (int j = p - 2; j >= k; j--) { - double t = CTORAbsOp.op(sV[j], f); - double cs = sV[j] / t; - double sn = f / t; - sV[j] = t; - if (j != k) { - f = -sn * e[j - 1]; - e[j - 1] = cs * e[j - 1]; - } - for (int i = 0; i < ncols; i++) { - t = cs * vV[vStrideRow * (i) + (j)] + sn * vV[vStrideRow * (i) + (p - 1)]; - vV[vStrideRow * (i) + (p - 1)] = -sn * vV[vStrideRow * (i) + (j)] + cs - * vV[vStrideRow * (i) + (p - 1)]; - vV[vStrideRow * (i) + (j)] = t; - } - } - } - break; - - // Split at negligible s(k). - - case 2: { - double f = e[k - 1]; - e[k - 1] = 0.0; - for (int j = k; j < p; j++) { - double t = CTORAbsOp.op(sV[j], f); - double cs = sV[j] / t; - double sn = f / t; - sV[j] = t; - f = -sn * e[j]; - e[j] = cs * e[j]; - for (int i = 0; i < nrows; i++) { - t = cs * uV[uStrideRow * (i) + (j)] + sn * uV[uStrideRow * (i) + (k - 1)]; - uV[uStrideRow * (i) + (k - 1)] = -sn * uV[uStrideRow * (i) + (j)] + cs - * uV[uStrideRow * (i) + (k - 1)]; - uV[uStrideRow * (i) + (j)] = t; - } - } - } - break; - - // Perform one qr step. - - case 3: { - - // Calculate the shift. - - double scale = Math.max(Math.max(Math.max(Math.max(Math.abs(sV[p - 1]), Math.abs(sV[p - 2])), Math - .abs(e[p - 2])), Math.abs(sV[k])), Math.abs(e[k])); - double sp = sV[p - 1] / scale; - double spm1 = sV[p - 2] / scale; - double epm1 = e[p - 2] / scale; - double sk = sV[k] / scale; - double ek = e[k] / scale; - double b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2.0; - double c = (sp * epm1) * (sp * epm1); - double shift = 0.0; - if ((b != 0.0) | (c != 0.0)) { - shift = Math.sqrt(b * b + c); - if (b < 0.0) { - shift = -shift; - } - shift = c / (b + shift); - } - double f = (sk + sp) * (sk - sp) + shift; - double g = sk * ek; - - // Chase zeros. - - for (int j = k; j < p - 1; j++) { - double t = CTORAbsOp.op(f, g); - double cs = f / t; - double sn = g / t; - if (j != k) { - e[j - 1] = t; - } - f = cs * sV[j] + sn * e[j]; - e[j] = cs * e[j] - sn * sV[j]; - g = sn * sV[j + 1]; - sV[j + 1] = cs * sV[j + 1]; - for (int i = 0; i < ncols; i++) { - t = cs * vV[vStrideRow * (i) + (j)] + sn * vV[vStrideRow * (i) + (j + 1)]; - vV[vStrideRow * (i) + (j + 1)] = -sn * vV[vStrideRow * (i) + (j)] + cs - * vV[vStrideRow * (i) + (j + 1)]; - vV[vStrideRow * (i) + (j)] = t; - } - t = CTORAbsOp.op(f, g); - cs = f / t; - sn = g / t; - sV[j] = t; - f = cs * e[j] + sn * sV[j + 1]; - sV[j + 1] = -sn * e[j] + cs * sV[j + 1]; - g = sn * e[j + 1]; - e[j + 1] = cs * e[j + 1]; - if (j < nrows - 1) { - for (int i = 0; i < nrows; i++) { - t = cs * uV[uStrideRow * (i) + (j)] + sn * uV[uStrideRow * (i) + (j + 1)]; - uV[uStrideRow * (i) + (j + 1)] = -sn * uV[uStrideRow * (i) + (j)] + cs - * uV[uStrideRow * (i) + (j + 1)]; - uV[uStrideRow * (i) + (j)] = t; - } - } - } - e[p - 2] = f; - iter = iter + 1; - } - break; - - // Convergence. - - case 4: { - - // Make the singular values positive. - - if (sV[k] <= 0.0) { - sV[k] = (sV[k] < 0.0 ? -sV[k] : 0.0); - for (int i = 0; i <= pp; i++) { - vV[vStrideRow * (i) + (k)] = -vV[vStrideRow * (i) + (k)]; - } - } - - // Order the singular values. - - while (k < pp) { - if (sV[k] >= sV[k + 1]) { - break; - } - double t = sV[k]; - sV[k] = sV[k + 1]; - sV[k + 1] = t; - if (k < ncols - 1) { - for (int i = 0; i < ncols; i++) { - t = vV[vStrideRow * (i) + (k + 1)]; - vV[vStrideRow * (i) + (k + 1)] = vV[vStrideRow * (i) + (k)]; - vV[vStrideRow * (i) + (k)] = t; - } - } - if (k < nrows - 1) { - for (int i = 0; i < nrows; i++) { - t = uV[uStrideRow * (i) + (k + 1)]; - uV[uStrideRow * (i) + (k + 1)] = uV[uStrideRow * (i) + (k)]; - uV[uStrideRow * (i) + (k)] = t; - } - } - k++; - } - iter = 0; - p--; - } - break; - } - } - } - - /** - * An eigenvector and eigenvalue operation in support of - * {@link JavaArrayKernel#eigs(double[], double[], double[], int)}. - */ - final public static void eigs(double[] srcV, double[] vecV, double[] valV, int size) { - - Control.checkTrue(srcV.length == size * size // - && vecV.length == size * size // - && valV.length == 2 * size, // - "Invalid arguments"); - - double[] h = srcV.clone(); - - hessenberg(h, vecV, size); - hessenbergToSchur(h, vecV, valV, size); - } - - /** - * Computes the reduction to Hessenberg form. - * - * @param h - * the working Hessenberg matrix. - * @param vecV - * the eigenvectors. - * @param size - * the matrix size. - */ - final protected static void hessenberg(double[] h, double[] vecV, int size) { - - int hStrideRow = size; - int vStrideRow = size; - - double[] ort = new double[size]; - - // This is derived from the Algol procedures orthes and ortran, - // by Martin and Wilkinson, Handbook for Auto. Comp., - // Vol.ii-Linear Algebra, and the corresponding - // Fortran subroutines in EISPACK. - - int low = 0; - int high = size - 1; - - for (int m = low + 1; m <= high - 1; m++) { - - // Scale column. - - double scale = 0.0; - for (int i = m; i <= high; i++) { - scale = scale + Math.abs(h[hStrideRow * (i) + (m - 1)]); - } - if (scale != 0.0) { - - // Compute Householder transformation. - - double hAcc = 0.0; - for (int i = high; i >= m; i--) { - ort[i] = h[hStrideRow * (i) + (m - 1)] / scale; - hAcc += ort[i] * ort[i]; - } - double g = Math.sqrt(hAcc); - if (ort[m] > 0) { - g = -g; - } - hAcc = hAcc - ort[m] * g; - ort[m] = ort[m] - g; - - // Apply Householder similarity transformation - // H = (I-u*u'/h)*H*(I-u*u')/h) - - for (int j = m; j < size; j++) { - double f = 0.0; - for (int i = high; i >= m; i--) { - f += ort[i] * h[hStrideRow * (i) + (j)]; - } - f = f / hAcc; - for (int i = m; i <= high; i++) { - h[hStrideRow * (i) + (j)] -= f * ort[i]; - } - } - - for (int i = 0; i <= high; i++) { - double f = 0.0; - for (int j = high; j >= m; j--) { - f += ort[j] * h[hStrideRow * (i) + (j)]; - } - f = f / hAcc; - for (int j = m; j <= high; j++) { - h[hStrideRow * (i) + (j)] -= f * ort[j]; - } - } - ort[m] = scale * ort[m]; - h[hStrideRow * (m) + (m - 1)] = scale * g; - } - } - - // Accumulate transformations (Algol's ortran). - - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - vecV[vStrideRow * (i) + (j)] = (i == j ? 1.0 : 0.0); - } - } - - for (int m = high - 1; m >= low + 1; m--) { - if (h[hStrideRow * (m) + (m - 1)] != 0.0) { - for (int i = m + 1; i <= high; i++) { - ort[i] = h[hStrideRow * (i) + (m - 1)]; - } - for (int j = m; j <= high; j++) { - double g = 0.0; - for (int i = m; i <= high; i++) { - g += ort[i] * vecV[vStrideRow * (i) + (j)]; - } - // Double division avoids possible underflow - g = (g / ort[m]) / h[hStrideRow * (m) + (m - 1)]; - for (int i = m; i <= high; i++) { - vecV[vStrideRow * (i) + (j)] += g * ort[i]; - } - } - } - } - } - - /** - * Computes the reduction from Hessenberg form to real Schur form. - * - * @param h - * the working Hessenberg matrix. - * @param vecV - * the eigenvectors. - * @param valV - * the eigenvalues. - * @param size - * the matrix size. - */ - final protected static void hessenbergToSchur(double[] h, double[] vecV, double[] valV, int size) { - - int hStrideRow = size; - int vStrideRow = size; - - double[] cdiv = new double[2]; - - // This is derived from the Algol procedure hqr2, - // by Martin and Wilkinson, Handbook for Auto. Comp., - // Vol.ii-Linear Algebra, and the corresponding - // Fortran subroutine in EISPACK. - - // Initialize - - int nn = size; - int n = nn - 1; - int low = 0; - int high = nn - 1; - double eps = Math.pow(2.0, -52.0); - double exShift = 0.0; - double p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y; - - // Store roots isolated by balanc and compute matrix norm - - double norm = 0.0; - for (int i = 0; i < nn; i++) { - if (i < low || i > high) { - valV[2 * (i)] = h[hStrideRow * (i) + (i)]; - valV[2 * (i) + 1] = 0.0; - } - for (int j = Math.max(i - 1, 0); j < nn; j++) { - norm = norm + Math.abs(h[hStrideRow * (i) + (j)]); - } - } - - // Outer loop over eigenvalue index - - int iter = 0; - while (n >= low) { - - // Look for single small sub-diagonal element - - int l = n; - while (l > low) { - s = Math.abs(h[hStrideRow * (l - 1) + (l - 1)]) + Math.abs(h[hStrideRow * (l) + (l)]); - if (s == 0.0) { - s = norm; - } - if (Math.abs(h[hStrideRow * (l) + (l - 1)]) < eps * s) { - break; - } - l--; - } - - // Check for convergence - // One root found - - if (l == n) { - h[hStrideRow * (n) + (n)] = h[hStrideRow * (n) + (n)] + exShift; - valV[2 * (n)] = h[hStrideRow * (n) + (n)]; - valV[2 * (n) + 1] = 0.0; - n--; - iter = 0; - - // Two roots found - - } else if (l == n - 1) { - w = h[hStrideRow * (n) + (n - 1)] * h[hStrideRow * (n - 1) + (n)]; - p = (h[hStrideRow * (n - 1) + (n - 1)] - h[hStrideRow * (n) + (n)]) / 2.0; - q = p * p + w; - z = Math.sqrt(Math.abs(q)); - h[hStrideRow * (n) + (n)] = h[hStrideRow * (n) + (n)] + exShift; - h[hStrideRow * (n - 1) + (n - 1)] = h[hStrideRow * (n - 1) + (n - 1)] + exShift; - x = h[hStrideRow * (n) + (n)]; - - // Real pair - - if (q >= 0) { - if (p >= 0) { - z = p + z; - } else { - z = p - z; - } - valV[2 * (n - 1)] = x + z; - valV[2 * (n)] = valV[2 * (n - 1)]; - if (z != 0.0) { - valV[2 * (n)] = x - w / z; - } - valV[2 * (n - 1) + 1] = 0.0; - valV[2 * (n) + 1] = 0.0; - x = h[hStrideRow * (n) + (n - 1)]; - s = Math.abs(x) + Math.abs(z); - p = x / s; - q = z / s; - r = Math.sqrt(p * p + q * q); - p = p / r; - q = q / r; - - // Row modification - - for (int j = n - 1; j < nn; j++) { - z = h[hStrideRow * (n - 1) + (j)]; - h[hStrideRow * (n - 1) + (j)] = q * z + p * h[hStrideRow * (n) + (j)]; - h[hStrideRow * (n) + (j)] = q * h[hStrideRow * (n) + (j)] - p * z; - } - - // Column modification - - for (int i = 0; i <= n; i++) { - z = h[hStrideRow * (i) + (n - 1)]; - h[hStrideRow * (i) + (n - 1)] = q * z + p * h[hStrideRow * (i) + (n)]; - h[hStrideRow * (i) + (n)] = q * h[hStrideRow * (i) + (n)] - p * z; - } - - // Accumulate transformations - - for (int i = low; i <= high; i++) { - z = vecV[vStrideRow * (i) + (n - 1)]; - vecV[vStrideRow * (i) + (n - 1)] = q * z + p * vecV[vStrideRow * (i) + (n)]; - vecV[vStrideRow * (i) + (n)] = q * vecV[vStrideRow * (i) + (n)] - p * z; - } - - // Complex pair - - } else { - valV[2 * (n - 1)] = x + p; - valV[2 * (n)] = x + p; - valV[2 * (n - 1) + 1] = z; - valV[2 * (n) + 1] = -z; - } - n = n - 2; - iter = 0; - - // No convergence yet - - } else { - - // Form shift - - x = h[hStrideRow * (n) + (n)]; - y = 0.0; - w = 0.0; - if (l < n) { - y = h[hStrideRow * (n - 1) + (n - 1)]; - w = h[hStrideRow * (n) + (n - 1)] * h[hStrideRow * (n - 1) + (n)]; - } - - // Wilkinson's original ad hoc shift - - if (iter == 10) { - exShift += x; - for (int i = low; i <= n; i++) { - h[hStrideRow * (i) + (i)] -= x; - } - s = Math.abs(h[hStrideRow * (n) + (n - 1)]) + Math.abs(h[hStrideRow * (n - 1) + (n - 2)]); - x = y = 0.75 * s; - w = -0.4375 * s * s; - } - - // MATLAB's new ad hoc shift - - if (iter == 30) { - s = (y - x) / 2.0; - s = s * s + w; - if (s > 0) { - s = Math.sqrt(s); - if (y < x) { - s = -s; - } - s = x - w / ((y - x) / 2.0 + s); - for (int i = low; i <= n; i++) { - h[hStrideRow * (i) + (i)] -= s; - } - exShift += s; - x = y = w = 0.964; - } - } - - iter = iter + 1; // (Could check iteration count here.) - - // Look for two consecutive small sub-diagonal elements - - int m = n - 2; - while (m >= l) { - z = h[hStrideRow * (m) + (m)]; - r = x - z; - s = y - z; - p = (r * s - w) / h[hStrideRow * (m + 1) + (m)] + h[hStrideRow * (m) + (m + 1)]; - q = h[hStrideRow * (m + 1) + (m + 1)] - z - r - s; - r = h[hStrideRow * (m + 2) + (m + 1)]; - s = Math.abs(p) + Math.abs(q) + Math.abs(r); - p = p / s; - q = q / s; - r = r / s; - if (m == l) { - break; - } - if (Math.abs(h[hStrideRow * (m) + (m - 1)]) * (Math.abs(q) + Math.abs(r)) < eps - * (Math.abs(p) * (Math.abs(h[hStrideRow * (m - 1) + (m - 1)]) + Math.abs(z) + Math - .abs(h[hStrideRow * (m + 1) + (m + 1)])))) { - break; - } - m--; - } - - for (int i = m + 2; i <= n; i++) { - h[hStrideRow * (i) + (i - 2)] = 0.0; - if (i > m + 2) { - h[hStrideRow * (i) + (i - 3)] = 0.0; - } - } - - // Double QR step involving rows l:n and columns m:n - - for (int k = m; k <= n - 1; k++) { - boolean notlast = (k != n - 1); - if (k != m) { - p = h[hStrideRow * (k) + (k - 1)]; - q = h[hStrideRow * (k + 1) + (k - 1)]; - r = (notlast ? h[hStrideRow * (k + 2) + (k - 1)] : 0.0); - x = Math.abs(p) + Math.abs(q) + Math.abs(r); - if (x != 0.0) { - p = p / x; - q = q / x; - r = r / x; - } - } - if (x == 0.0) { - break; - } - s = Math.sqrt(p * p + q * q + r * r); - if (p < 0) { - s = -s; - } - if (s != 0) { - if (k != m) { - h[hStrideRow * (k) + (k - 1)] = -s * x; - } else if (l != m) { - h[hStrideRow * (k) + (k - 1)] = -h[hStrideRow * (k) + (k - 1)]; - } - p = p + s; - x = p / s; - y = q / s; - z = r / s; - q = q / p; - r = r / p; - - // Row modification - - for (int j = k; j < nn; j++) { - p = h[hStrideRow * (k) + (j)] + q * h[hStrideRow * (k + 1) + (j)]; - if (notlast) { - p = p + r * h[hStrideRow * (k + 2) + (j)]; - h[hStrideRow * (k + 2) + (j)] = h[hStrideRow * (k + 2) + (j)] - p * z; - } - h[hStrideRow * (k) + (j)] = h[hStrideRow * (k) + (j)] - p * x; - h[hStrideRow * (k + 1) + (j)] = h[hStrideRow * (k + 1) + (j)] - p * y; - } - - // Column modification - - for (int i = 0; i <= Math.min(n, k + 3); i++) { - p = x * h[hStrideRow * (i) + (k)] + y * h[hStrideRow * (i) + (k + 1)]; - if (notlast) { - p = p + z * h[hStrideRow * (i) + (k + 2)]; - h[hStrideRow * (i) + (k + 2)] = h[hStrideRow * (i) + (k + 2)] - p * r; - } - h[hStrideRow * (i) + (k)] = h[hStrideRow * (i) + (k)] - p; - h[hStrideRow * (i) + (k + 1)] = h[hStrideRow * (i) + (k + 1)] - p * q; - } - - // Accumulate transformations - - for (int i = low; i <= high; i++) { - p = x * vecV[vStrideRow * (i) + (k)] + y * vecV[vStrideRow * (i) + (k + 1)]; - if (notlast) { - p = p + z * vecV[vStrideRow * (i) + (k + 2)]; - vecV[vStrideRow * (i) + (k + 2)] = vecV[vStrideRow * (i) + (k + 2)] - p * r; - } - vecV[vStrideRow * (i) + (k)] = vecV[vStrideRow * (i) + (k)] - p; - vecV[vStrideRow * (i) + (k + 1)] = vecV[vStrideRow * (i) + (k + 1)] - p * q; - } - } // (s != 0) - } // k loop - } // check convergence - } // while (n >= low) - - // Backsubstitute to find vectors of upper triangular form - - if (norm == 0.0) { - return; - } - - for (n = nn - 1; n >= 0; n--) { - p = valV[2 * (n)]; - q = valV[2 * (n) + 1]; - - // Real vector - - if (q == 0) { - int l = n; - h[hStrideRow * (n) + (n)] = 1.0; - for (int i = n - 1; i >= 0; i--) { - w = h[hStrideRow * (i) + (i)] - p; - r = 0.0; - for (int j = l; j <= n; j++) { - r = r + h[hStrideRow * (i) + (j)] * h[hStrideRow * (j) + (n)]; - } - if (valV[2 * (i) + 1] < 0.0) { - z = w; - s = r; - } else { - l = i; - if (valV[2 * (i) + 1] == 0.0) { - if (w != 0.0) { - h[hStrideRow * (i) + (n)] = -r / w; - } else { - h[hStrideRow * (i) + (n)] = -r / (eps * norm); - } - - // Solve real equations - - } else { - x = h[hStrideRow * (i) + (i + 1)]; - y = h[hStrideRow * (i + 1) + (i)]; - q = (valV[2 * (i)] - p) * (valV[2 * (i)] - p) + valV[2 * (i) + 1] * valV[2 * (i) + 1]; - t = (x * s - z * r) / q; - h[hStrideRow * (i) + (n)] = t; - if (Math.abs(x) > Math.abs(z)) { - h[hStrideRow * (i + 1) + (n)] = (-r - w * t) / x; - } else { - h[hStrideRow * (i + 1) + (n)] = (-s - y * t) / z; - } - } - - // Overflow control - - t = Math.abs(h[hStrideRow * (i) + (n)]); - if ((eps * t) * t > 1) { - for (int j = i; j <= n; j++) { - h[hStrideRow * (j) + (n)] = h[hStrideRow * (j) + (n)] / t; - } - } - } - } - - // Complex vector - - } else if (q < 0) { - int l = n - 1; - - // Last vector component imaginary so matrix is triangular - - if (Math.abs(h[hStrideRow * (n) + (n - 1)]) > Math.abs(h[hStrideRow * (n - 1) + (n)])) { - h[hStrideRow * (n - 1) + (n - 1)] = q / h[hStrideRow * (n) + (n - 1)]; - h[hStrideRow * (n - 1) + (n)] = -(h[hStrideRow * (n) + (n)] - p) / h[hStrideRow * (n) + (n - 1)]; - } else { - CEDivOp.op(cdiv, // - 0.0, -h[hStrideRow * (n - 1) + (n)], // - h[hStrideRow * (n - 1) + (n - 1)] - p, q); - h[hStrideRow * (n - 1) + (n - 1)] = cdiv[0]; - h[hStrideRow * (n - 1) + (n)] = cdiv[1]; - } - h[hStrideRow * (n) + (n - 1)] = 0.0; - h[hStrideRow * (n) + (n)] = 1.0; - for (int i = n - 2; i >= 0; i--) { - double ra, sa, vr, vi; - ra = 0.0; - sa = 0.0; - for (int j = l; j <= n; j++) { - ra = ra + h[hStrideRow * (i) + (j)] * h[hStrideRow * (j) + (n - 1)]; - sa = sa + h[hStrideRow * (i) + (j)] * h[hStrideRow * (j) + (n)]; - } - w = h[hStrideRow * (i) + (i)] - p; - - if (valV[2 * (i) + 1] < 0.0) { - z = w; - r = ra; - s = sa; - } else { - l = i; - if (valV[2 * (i) + 1] == 0) { - CEDivOp.op(cdiv, // - -ra, -sa, w, q); - h[hStrideRow * (i) + (n - 1)] = cdiv[0]; - h[hStrideRow * (i) + (n)] = cdiv[1]; - } else { - - // Solve complex equations - - x = h[hStrideRow * (i) + (i + 1)]; - y = h[hStrideRow * (i + 1) + (i)]; - vr = (valV[2 * (i)] - p) * (valV[2 * (i)] - p) + valV[2 * (i) + 1] * valV[2 * (i) + 1] - q - * q; - vi = (valV[2 * (i)] - p) * 2.0 * q; - if (vr == 0.0 && vi == 0.0) { - vr = eps * norm * (Math.abs(w) + Math.abs(q) + Math.abs(x) + Math.abs(y) + Math.abs(z)); - } - CEDivOp.op(cdiv, // - x * r - z * ra + q * sa, // - x * s - z * sa - q * ra, // - vr, vi); - h[hStrideRow * (i) + (n - 1)] = cdiv[0]; - h[hStrideRow * (i) + (n)] = cdiv[1]; - if (Math.abs(x) > (Math.abs(z) + Math.abs(q))) { - h[hStrideRow * (i + 1) + (n - 1)] = (-ra - w * h[hStrideRow * (i) + (n - 1)] + q - * h[hStrideRow * (i) + (n)]) - / x; - h[hStrideRow * (i + 1) + (n)] = (-sa - w * h[hStrideRow * (i) + (n)] - q - * h[hStrideRow * (i) + (n - 1)]) - / x; - } else { - CEDivOp.op(cdiv, // - -r - y * h[hStrideRow * (i) + (n - 1)], // - -s - y * h[hStrideRow * (i) + (n)], // - z, q); - h[hStrideRow * (i + 1) + (n - 1)] = cdiv[0]; - h[hStrideRow * (i + 1) + (n)] = cdiv[1]; - } - } - - // Overflow control - - t = Math.max(Math.abs(h[hStrideRow * (i) + (n - 1)]), Math.abs(h[hStrideRow * (i) + (n)])); - if ((eps * t) * t > 1) { - for (int j = i; j <= n; j++) { - h[hStrideRow * (j) + (n - 1)] = h[hStrideRow * (j) + (n - 1)] / t; - h[hStrideRow * (j) + (n)] = h[hStrideRow * (j) + (n)] / t; - } - } - } - } - } - } - - // Vectors of isolated roots - - for (int i = 0; i < nn; i++) { - if (i < low || i > high) { - for (int j = i; j < nn; j++) { - vecV[vStrideRow * (i) + (j)] = h[hStrideRow * (i) + (j)]; - } - } - } - - // Back transformation to get eigenvectors of original matrix - - for (int j = nn - 1; j >= low; j--) { - for (int i = low; i <= high; i++) { - z = 0.0; - for (int k = low; k <= Math.min(j, high); k++) { - z = z + vecV[vStrideRow * (i) + (k)] * h[hStrideRow * (k) + (j)]; - } - vecV[vStrideRow * (i) + (j)] = z; - } - } - } - - /** - * A matrix inversion operation in support of {@link JavaArrayKernel#invert(double[], double[], int)}. - */ - final public static void invert(double[] srcV, double[] dstV, int size) { - - Control.checkTrue(srcV.length == size * size // - && dstV.length == size * size, // - "Invalid arguments"); - - double[] lu = srcV.clone(); - int[] pivots = Arithmetic.range(size); - - lup(lu, pivots, size, size); - - for (int i = 0; i < size; i++) { - - Control.checkTrue(lu[size * i + i] != 0, // - "Matrix is singular"); - - dstV[size * i + pivots[i]] = 1.0; - } - - luSolve(lu, size, dstV, size); - } - - /** - * Computes the LU decomposition along with row pivots. - * - * @param lu - * the LU matrix. - * @param pivots - * the row pivots. - * @param nrows - * the number of rows. - * @param ncols - * the number of columns. - */ - final protected static void lup(double[] lu, int[] pivots, int nrows, int ncols) { - - int luStrideRow = ncols; - - // Use a "left-looking", dot-product, Crout/Doolittle algorithm. - - double[] luColJ = new double[nrows]; - - // Outer loop. - - for (int j = 0; j < ncols; j++) { - - // Make a copy of the j-th column to localize references. - - for (int i = 0; i < nrows; i++) { - luColJ[i] = lu[luStrideRow * (i) + (j)]; - } - - // Apply previous transformations. - - for (int i = 0; i < nrows; i++) { - - // Most of the time is spent in the following dot product. - - int kmax = Math.min(i, j); - double s = 0.0; - for (int k = 0; k < kmax; k++) { - s += lu[luStrideRow * (i) + (k)] * luColJ[k]; - } - - lu[luStrideRow * (i) + (j)] = luColJ[i] -= s; - } - - // Find pivot and exchange if necessary. - - int p = j; - for (int i = j + 1; i < nrows; i++) { - if (Math.abs(luColJ[i]) > Math.abs(luColJ[p])) { - p = i; - } - } - if (p != j) { - for (int k = 0; k < ncols; k++) { - double t = lu[luStrideRow * (p) + (k)]; - lu[luStrideRow * (p) + (k)] = lu[luStrideRow * (j) + (k)]; - lu[luStrideRow * (j) + (k)] = t; - } - int k = pivots[p]; - pivots[p] = pivots[j]; - pivots[j] = k; - } - - // Compute multipliers. - - if (j < nrows && lu[luStrideRow * (j) + (j)] != 0.0) { - for (int i = j + 1; i < nrows; i++) { - lu[luStrideRow * (i) + (j)] /= lu[luStrideRow * (j) + (j)]; - } - } - } - } - - /** - * Uses an existing LU decomposition to solve a system of linear equations. - * - * @param lu - * the LU matrix. - * @param nluCols - * the number of columns in the LU matrix. - * @param dstV - * the destination matrix. - * @param ndstVCols - * the number of columns in the destination matrix. - */ - final protected static void luSolve(double[] lu, int nluCols, double[] dstV, int ndstVCols) { - - int luStrideRow = nluCols; - int vStrideRow = ndstVCols; - - // Solve L*Y = B(piv,:) - for (int k = 0; k < nluCols; k++) { - for (int i = k + 1; i < nluCols; i++) { - for (int j = 0; j < ndstVCols; j++) { - dstV[vStrideRow * (i) + (j)] -= dstV[vStrideRow * (k) + (j)] * lu[luStrideRow * (i) + (k)]; - } - } - } - // Solve U*X = Y; - for (int k = nluCols - 1; k >= 0; k--) { - for (int j = 0; j < nluCols; j++) { - dstV[vStrideRow * (k) + (j)] /= lu[luStrideRow * (k) + (k)]; - } - for (int i = 0; i < k; i++) { - for (int j = 0; j < ndstVCols; j++) { - dstV[vStrideRow * (i) + (j)] -= dstV[vStrideRow * (k) + (j)] * lu[luStrideRow * (i) + (k)]; - } - } - } - } - - // Dummy constructor. - LinearAlgebraOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MappingOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MappingOps.java deleted file mode 100755 index 24641936..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MappingOps.java +++ /dev/null @@ -1,332 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import java.lang.reflect.Array; -import java.util.Arrays; - -import shared.util.Control; - -/** - * A class for mapping operations in pure Java. - * - * @author Roy Liu - */ -public class MappingOps { - - /** - * Creates an array of physical indices. - * - * @param nindices - * the number of indices. - * @param dims - * the mapping dimensions. - * @param strides - * the strides. - * @return the physical indices. - */ - final public static int[] assignMappingIndices(int nindices, int[] dims, int[] strides) { - - int[] indices = new int[nindices]; - - for (int k = dims.length - 1, blockSize = 1, stride, size; k >= 0; blockSize *= size, k--) { - - stride = strides[k]; - size = dims[k]; - - for (int offset = blockSize, m = blockSize * size; offset < m; offset += blockSize) { - - for (int i = offset - blockSize, j = offset; i < offset; i++, j++) { - indices[j] = indices[i] + stride; - } - } - } - - return indices; - } - - /** - * Creates an array of physical slicing indices. - * - * @param nindices - * the number of indices. - * @param strides - * the strides. - * @param sliceIndices - * the indices to slice on arranged by dimension. - * @return the physical indices. - */ - final public static int[] assignSlicingIndices(int nindices, int[] strides, int[][] sliceIndices) { - - int[] indices = new int[nindices]; - - for (int i = 0, n = strides.length; i < n; i++) { - indices[0] += strides[i] * sliceIndices[i][0]; - } - - for (int k = strides.length - 1, blockSize = 1, strideOffset, size; k >= 0; blockSize *= size, k--) { - - int[] arr = sliceIndices[k]; - size = arr.length; - - for (int offset = blockSize, m = blockSize * size, n = 1; offset < m; offset += blockSize, n++) { - - strideOffset = strides[k] * (arr[n] - arr[n - 1]); - - for (int i = offset - blockSize, j = offset; i < offset; i++, j++) { - indices[j] = indices[i] + strideOffset; - } - } - } - - return indices; - } - - /** - * Checks an array's dimensions and strides. - * - * @param len - * the array length. - * @param dims - * the dimensions. - * @param strides - * the strides. - * @return the array length. - */ - final public static int checkDimensions(int len, int[] dims, int[] strides) { - - int acc = 0; - - for (int dim = 0, ndims = dims.length; dim < ndims; dim++) { - - Control.checkTrue(dims[dim] >= 0 && strides[dim] >= 0, // - "Invalid dimensions and/or strides"); - - acc += (dims[dim] - 1) * strides[dim]; - } - - Control.checkTrue(acc == len - 1, // - "Invalid dimensions and/or strides"); - - return len; - } - - /** - * Assigns source values to destination values based on arrays of physical indices. - * - * @param srcV - * the source array. - * @param srcIndices - * the source indices. - * @param dstV - * the destination array. - * @param dstIndices - * the destination indices. - */ - final public static void assign(Object srcV, int[] srcIndices, Object dstV, int[] dstIndices) { - - int nindices = Control.checkEquals(srcIndices.length, dstIndices.length, // - "Invalid arguments"); - - if (srcV instanceof double[] && dstV instanceof double[]) { - - double[] srcVArr = (double[]) srcV; - double[] dstVArr = (double[]) dstV; - - for (int i = 0; i < nindices; i++) { - dstVArr[dstIndices[i]] = srcVArr[srcIndices[i]]; - } - - } else if (srcV instanceof int[] && dstV instanceof int[]) { - - int[] srcVArr = (int[]) srcV; - int[] dstVArr = (int[]) dstV; - - for (int i = 0; i < nindices; i++) { - dstVArr[dstIndices[i]] = srcVArr[srcIndices[i]]; - } - - } else if (srcV instanceof Object[] && dstV instanceof Object[]) { - - Control.checkTrue(dstV.getClass().isAssignableFrom(srcV.getClass()), // - "Invalid array types"); - - Object[] srcVArr = (Object[]) srcV; - Object[] dstVArr = (Object[]) dstV; - - for (int i = 0; i < nindices; i++) { - dstVArr[dstIndices[i]] = srcVArr[srcIndices[i]]; - } - - } else { - - throw new IllegalArgumentException("Invalid arguments"); - } - } - - /** - * A mapping operation in support of {@link JavaArrayKernel#map(int[], Object, int[], int[], Object, int[], int[])}. - */ - final public static void map(int[] bounds, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS) { - - int ndims = srcD.length; - - Control.checkTrue(ndims == srcS.length // - && ndims == dstD.length // - && ndims == dstS.length // - && 3 * ndims == bounds.length, // - "Invalid arguments"); - - int srcLen = checkDimensions(Array.getLength(srcV), srcD, srcS); - int dstLen = checkDimensions(Array.getLength(dstV), dstD, dstS); - - int nslices = 0; - int mapLen = 1; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - - int size = bounds[offset + 2]; - - Control.checkTrue(size >= 0, // - "Invalid mapping parameters"); - - nslices += size; - mapLen *= size; - } - - if (srcLen == 0 || dstLen == 0) { - return; - } - - int[][] ssi = new int[ndims][]; - int[][] dsi = new int[ndims][]; - - for (int dim = 0, acc = 0, offset = 0; dim < ndims; dim++, acc += bounds[offset + 2], offset += 3) { - - int mapSize = bounds[offset + 2]; - - int[] srcSlices = (ssi[dim] = new int[mapSize]); - int[] dstSlices = (dsi[dim] = new int[mapSize]); - - for (int j = 0, // - srcSize = srcD[dim], // - srcOffset = (((bounds[offset]) % srcSize) + srcSize) % srcSize, // - dstSize = dstD[dim], // - dstOffset = (((bounds[offset + 1]) % dstSize) + dstSize) % dstSize; // - j < mapSize; // - j++, // - srcOffset = (srcOffset + 1) % srcSize, // - dstOffset = (dstOffset + 1) % dstSize) { - - srcSlices[j] = srcOffset; - dstSlices[j] = dstOffset; - } - } - - if (mapLen == 0) { - return; - } - - int[] srcIndices = assignSlicingIndices(mapLen, srcS, ssi); - int[] dstIndices = assignSlicingIndices(mapLen, dstS, dsi); - - assign(srcV, srcIndices, dstV, dstIndices); - } - - /** - * A slicing operation in support of - * {@link JavaArrayKernel#slice(int[], Object, int[], int[], Object, int[], int[])}. - */ - final public static void slice( // - int[] slices, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS) { - - Control.checkTrue(slices.length % 3 == 0, // - "Invalid slicing specification"); - - int nslices = slices.length / 3; - int ndims = srcD.length; - - Control.checkTrue(ndims == srcS.length // - && ndims == dstD.length // - && ndims == dstS.length); - - checkDimensions(Array.getLength(srcV), srcD, srcS); - checkDimensions(Array.getLength(dstV), dstD, dstS); - - for (int i = 0, n = 3 * nslices; i < n; i += 3) { - - int srcIndex = slices[i]; - int dstIndex = slices[i + 1]; - int dim = slices[i + 2]; - - Control.checkTrue(dim >= 0 && dim < ndims, // - "Invalid dimension"); - - Control.checkTrue((srcIndex >= 0 && srcIndex < srcD[dim]) // - && (dstIndex >= 0 && dstIndex < dstD[dim]), // - "Invalid index"); - } - - int[] dimCounts = new int[ndims]; - - for (int i = 0, n = 3 * nslices; i < n; i += 3) { - dimCounts[slices[i + 2]]++; - } - - int nindices = 1; - - int[][] ssi = new int[ndims][]; - int[][] dsi = new int[ndims][]; - - for (int dim = 0; dim < ndims; dim++) { - - ssi[dim] = new int[dimCounts[dim]]; - dsi[dim] = new int[dimCounts[dim]]; - - nindices *= dimCounts[dim]; - } - - Arrays.fill(dimCounts, 0); - - for (int i = 0, n = 3 * nslices; i < n; i += 3) { - - int dim = slices[i + 2]; - int idx = dimCounts[dim]++; - - ssi[dim][idx] = slices[i]; - dsi[dim][idx] = slices[i + 1]; - } - - if (nindices == 0) { - return; - } - - int[] srcIndices = assignSlicingIndices(nindices, srcS, ssi); - int[] dstIndices = assignSlicingIndices(nindices, dstS, dsi); - - assign(srcV, srcIndices, dstV, dstIndices); - } - - // Dummy constructor. - MappingOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatlabIO.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatlabIO.java deleted file mode 100755 index c7ff3719..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatlabIO.java +++ /dev/null @@ -1,376 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -/** - * Contains constant values pertaining to the reading and writing of Matlab's "mat" file format. - * - * @apiviz.exclude - * @author Roy Liu - */ -public class MatlabIO { - - /** - * A value such that observation in its reversed form necessitates conversion from Little-Endian values to - * Big-Endian values, and vice versa. - */ - final public static short ENDIANNESS = 0x4D49; - - /** - * Matlab's value for a signed {@code byte}. - */ - final public static int MATLAB_MI_INT8 = 1; - - /** - * Matlab's value for an unsigned {@code byte}. - */ - final public static int MATLAB_MI_UINT8 = 2; - - /** - * Matlab's value for a signed {@code short}. - */ - final public static int MATLAB_MI_INT16 = 3; - - /** - * Matlab's value for an unsigned {@code short}. - */ - final public static int MATLAB_MI_UINT16 = 4; - - /** - * Matlab's value for a signed {@code int}. - */ - final public static int MATLAB_MI_INT32 = 5; - - /** - * Matlab's value for an unsigned {@code int}. - */ - final public static int MATLAB_MI_UINT32 = 6; - - /** - * Matlab's value for a {@code float}. - */ - final public static int MATLAB_MI_SINGLE = 7; - - /** - * Matlab's value for a {@code double}. - */ - final public static int MATLAB_MI_DOUBLE = 9; - - /** - * Matlab's value for an array of {@code double}s. - */ - final public static int MATLAB_MX_DOUBLE_CLASS = 6; - - /** - * Matlab's value for an array of {@code float}s. - */ - final public static int MATLAB_MX_SINGLE_CLASS = 7; - - /** - * Matlab's value for an array of signed {@code byte}s. - */ - final public static int MATLAB_MX_INT8_CLASS = 8; - - /** - * Matlab's value for an array of unsigned {@code byte}s. - */ - final public static int MATLAB_MX_UINT8_CLASS = 9; - - /** - * Matlab's value for an array of signed {@code short}s. - */ - final public static int MATLAB_MX_INT16_CLASS = 10; - - /** - * Matlab's value for an array of unsigned {@code short}s. - */ - final public static int MATLAB_MX_UINT16_CLASS = 11; - - /** - * Matlab's value for an array of signed {@code int}s. - */ - final public static int MATLAB_MX_INT32_CLASS = 12; - - /** - * Matlab's value for an array of unsigned {@code int}s. - */ - final public static int MATLAB_MX_UINT32_CLASS = 13; - - /** - * Matlab's value for a matrix. - */ - final public static int MATLAB_MI_MATRIX = 14; - - /** - * An enumeration of Matlab data types. - */ - public enum DataType { - - /** - * Denotes a signed {@code byte}. - */ - MI_INT8 { - - @Override - public int getMatlabValue() { - return MATLAB_MI_INT8; - } - - @Override - public int sizeOf() { - return 1; - } - }, // - - /** - * Denotes an unsigned {@code byte}. - */ - MI_UINT8 { - - @Override - public int getMatlabValue() { - return MATLAB_MI_UINT8; - } - - @Override - public int sizeOf() { - return 1; - } - }, // - - /** - * Denotes a signed {@code short}. - */ - MI_INT16 { - - @Override - public int getMatlabValue() { - return MATLAB_MI_INT16; - } - - @Override - public int sizeOf() { - return 2; - } - }, // - - /** - * Denotes an unsigned {@code short}. - */ - MI_UINT16 { - - @Override - public int getMatlabValue() { - return MATLAB_MI_UINT16; - } - - @Override - public int sizeOf() { - return 2; - } - }, // - - /** - * Denotes a signed {@code int}. - */ - MI_INT32 { - - @Override - public int getMatlabValue() { - return MATLAB_MI_INT32; - } - - @Override - public int sizeOf() { - return 4; - } - }, // - - /** - * Denotes an unsigned {@code int}. - */ - MI_UINT32 { - - @Override - public int getMatlabValue() { - return MATLAB_MI_UINT32; - } - - @Override - public int sizeOf() { - return 4; - } - }, // - - /** - * Denotes a {@code float}. - */ - MI_SINGLE { - - @Override - public int getMatlabValue() { - return MATLAB_MI_SINGLE; - } - - @Override - public int sizeOf() { - return 4; - } - }, // - - /** - * Denotes a {@code double}. - */ - MI_DOUBLE { - - @Override - public int getMatlabValue() { - return MATLAB_MI_DOUBLE; - } - - @Override - public int sizeOf() { - return 8; - } - }; - - /** - * Gets the physical Matlab value. - */ - abstract public int getMatlabValue(); - - /** - * Gets the size of this type in {@code byte}s. - */ - abstract public int sizeOf(); - } - - /** - * An enumeration of Matlab object types. - */ - public enum ObjectType { - - /** - * Denotes a Matlab array of {@code double}s. - */ - MX_DOUBLE_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_DOUBLE_CLASS; - } - }, // - - /** - * Denotes a Matlab array of {@code float}s. - */ - MX_SINGLE_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_SINGLE_CLASS; - } - }, // - - /** - * Denotes a Matlab array of signed {@code byte}s. - */ - MX_INT8_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_INT8_CLASS; - } - }, // - - /** - * Denotes a Matlab array of unsigned {@code byte}s. - */ - MX_UINT8_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_UINT8_CLASS; - } - }, // - - /** - * Denotes a Matlab array of signed {@code short}s. - */ - MX_INT16_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_INT16_CLASS; - } - }, // - - /** - * Denotes a Matlab array of unsigned {@code short}s. - */ - MX_UINT16_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_UINT16_CLASS; - } - }, // - - /** - * Denotes a Matlab array of signed {@code int}s. - */ - MX_INT32_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_INT32_CLASS; - } - }, // - - /** - * Denotes a Matlab array of unsigned {@code int}s. - */ - MX_UINT32_CLASS { - - @Override - public int getMatlabValue() { - return MATLAB_MX_UINT32_CLASS; - } - }, // - - /** - * Denotes a Matlab matrix. - */ - MI_MATRIX { - - @Override - public int getMatlabValue() { - return MATLAB_MI_MATRIX; - } - }; - - /** - * Gets the physical Matlab value. - */ - abstract public int getMatlabValue(); - } - - // Dummy constructor. - MatlabIO() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatlabIOKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatlabIOKernel.java deleted file mode 100755 index 2baf28ed..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatlabIOKernel.java +++ /dev/null @@ -1,796 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import static shared.Constants.MAJOR_VERSION; -import static shared.Constants.MINOR_VERSION; -import static shared.array.kernel.MatlabIO.ENDIANNESS; -import static shared.array.kernel.MatlabIO.MATLAB_MI_DOUBLE; -import static shared.array.kernel.MatlabIO.MATLAB_MI_INT16; -import static shared.array.kernel.MatlabIO.MATLAB_MI_INT32; -import static shared.array.kernel.MatlabIO.MATLAB_MI_INT8; -import static shared.array.kernel.MatlabIO.MATLAB_MI_MATRIX; -import static shared.array.kernel.MatlabIO.MATLAB_MI_SINGLE; -import static shared.array.kernel.MatlabIO.MATLAB_MI_UINT16; -import static shared.array.kernel.MatlabIO.MATLAB_MI_UINT32; -import static shared.array.kernel.MatlabIO.MATLAB_MI_UINT8; -import static shared.array.kernel.MatlabIO.MATLAB_MX_DOUBLE_CLASS; -import static shared.array.kernel.MatlabIO.MATLAB_MX_INT16_CLASS; -import static shared.array.kernel.MatlabIO.MATLAB_MX_INT32_CLASS; -import static shared.array.kernel.MatlabIO.MATLAB_MX_INT8_CLASS; -import static shared.array.kernel.MatlabIO.MATLAB_MX_SINGLE_CLASS; -import static shared.array.kernel.MatlabIO.MATLAB_MX_UINT16_CLASS; -import static shared.array.kernel.MatlabIO.MATLAB_MX_UINT32_CLASS; -import static shared.array.kernel.MatlabIO.MATLAB_MX_UINT8_CLASS; -import static shared.array.kernel.MatlabIO.DataType.MI_DOUBLE; -import static shared.array.kernel.MatlabIO.DataType.MI_INT32; -import static shared.array.kernel.MatlabIO.DataType.MI_INT8; -import static shared.array.kernel.MatlabIO.DataType.MI_UINT32; -import static shared.array.kernel.MatlabIO.ObjectType.MI_MATRIX; -import static shared.array.kernel.MatlabIO.ObjectType.MX_DOUBLE_CLASS; -import static shared.array.kernel.MatlabIO.ObjectType.MX_INT32_CLASS; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import shared.array.Array; -import shared.array.ComplexArray; -import shared.array.IntegerArray; -import shared.array.RealArray; -import shared.array.Array.IndexingOrder; -import shared.array.kernel.MatlabIO.DataType; -import shared.util.Control; - -/** - * An implementation of {@link ArrayIOKernel} that reads and writes Matlab "mat" files. - * - * @apiviz.composedOf shared.array.kernel.MatlabIOKernel.DoubleArrayDataElement - * @apiviz.composedOf shared.array.kernel.MatlabIOKernel.IntArrayDataElement - * @apiviz.composedOf shared.array.kernel.MatlabIOKernel.MatrixDataElement - * @apiviz.owns shared.array.kernel.MatlabIO.DataType - * @apiviz.owns shared.array.kernel.MatlabIO.ObjectType - * @author Roy Liu - */ -public class MatlabIOKernel implements ArrayIOKernel { - - /** - * A {@link RealArray} counter local to the current thread. - */ - final protected static ThreadLocal RealArrayCountLocal = new ThreadLocal(); - - /** - * A {@link ComplexArray} counter local to the current thread. - */ - final protected static ThreadLocal ComplexArrayCountLocal = new ThreadLocal(); - - /** - * An {@link IntegerArray} counter local to the current thread. - */ - final protected static ThreadLocal IntegerArrayCountLocal = new ThreadLocal(); - - /** - * Default constructor. - */ - public MatlabIOKernel() { - } - - public , E> byte[] getBytes(T array) { - - final Integer count; - final String name; - - final Object arrayObj = array; - - if (arrayObj instanceof RealArray) { - - count = RealArrayCountLocal.get(); - - if (count != null) { - - name = String.format("ra_%d", count); - - RealArrayCountLocal.set(count + 1); - - } else { - - name = "ra"; - } - - return getBytes((RealArray) arrayObj, name); - - } else if (arrayObj instanceof ComplexArray) { - - count = ComplexArrayCountLocal.get(); - - if (count != null) { - - name = String.format("ca_%d", count); - - ComplexArrayCountLocal.set(count + 1); - - } else { - - name = "ca"; - } - - return getBytes((ComplexArray) arrayObj, name); - - } else if (arrayObj instanceof IntegerArray) { - - count = IntegerArrayCountLocal.get(); - - if (count != null) { - - name = String.format("ia_%d", count); - - IntegerArrayCountLocal.set(count + 1); - - } else { - - name = "ia"; - } - - return getBytes((IntegerArray) arrayObj, name); - - } else { - - throw new IllegalArgumentException("Invalid array type"); - } - } - - @SuppressWarnings("unchecked") - public > T parse(byte[] data) { - return (T) new MatrixDataElement(ByteBuffer.wrap(data)).get(); - } - - /** - * Gets the binary representation of the "mat" file header. - */ - final public static byte[] getHeaderBytes(String text) { - - ByteBuffer bb = ByteBuffer.allocate(128); - - int len = text.length(); - - Control.checkTrue(len <= 124, // - "The descriptive text is too long"); - - bb.put(text.getBytes()); - - for (int i = 0, n = 124 - len; i < n; i++) { - bb.put((byte) ' '); - } - - bb.putShort((short) 0x0100); - bb.putShort(ENDIANNESS); - - return bb.array(); - } - - /** - * Converts the given {@link RealArray} into {@code byte}s. - */ - final public static byte[] getBytes(RealArray array, String name) { - - // Force column-major indexing. - if (array.order() == IndexingOrder.FAR) { - array = array.reverseOrder(); - } - - int[] dims = array.dimensions(); - double[] values = array.values(); - - int totalSize = getDataElementSize(MI_UINT32, 2) // - + getDataElementSize(MI_INT32, dims.length) // - + getDataElementSize(MI_INT8, name.length()) // - + getDataElementSize(MI_DOUBLE, values.length); - - ByteBuffer bb = ByteBuffer.allocate(totalSize + 8); - - bb.putInt(MI_MATRIX.getMatlabValue()); - bb.putInt(totalSize); - - writeDataElementHeader(bb, MI_UINT32, 2); - bb.putInt(MX_DOUBLE_CLASS.getMatlabValue()); - bb.putInt(0); - - writeDataElementHeader(bb, MI_INT32, dims.length); - writeDataElementBody(bb, dims); - - writeDataElementHeader(bb, MI_INT8, name.length()); - writeDataElementBody(bb, name.getBytes()); - - writeDataElementHeader(bb, MI_DOUBLE, values.length); - writeDataElementBody(bb, values); - - return bb.array(); - } - - /** - * Converts the given {@link ComplexArray} into {@code byte}s. - */ - final public static byte[] getBytes(ComplexArray complexArray, String name) { - - RealArray array = new RealArray(complexArray.values(), complexArray.order(), complexArray.dimensions()) // - .reverseOrder(); - - int[] dims = array.dimensions(); - double[] values = array.values(); - - int totalSize = getDataElementSize(MI_UINT32, 2) // - + getDataElementSize(MI_INT32, dims.length - 1) // - + getDataElementSize(MI_INT8, name.length()) // - + 2 * getDataElementSize(MI_DOUBLE, values.length >>> 1); - - ByteBuffer bb = ByteBuffer.allocate(totalSize + 8); - - bb.putInt(MI_MATRIX.getMatlabValue()); - bb.putInt(totalSize); - - writeDataElementHeader(bb, MI_UINT32, 2); - bb.putInt(0x00000800 | MX_DOUBLE_CLASS.getMatlabValue()); - bb.putInt(0); - - writeDataElementHeader(bb, MI_INT32, dims.length - 1); - writeDataElementBody(bb, Arrays.copyOf(dims, dims.length - 1)); - - writeDataElementHeader(bb, MI_INT8, name.length()); - writeDataElementBody(bb, name.getBytes()); - - writeDataElementHeader(bb, MI_DOUBLE, values.length >>> 1); - writeDataElementBody(bb, Arrays.copyOfRange(values, 0, values.length >>> 1)); - - writeDataElementHeader(bb, MI_DOUBLE, values.length >>> 1); - writeDataElementBody(bb, Arrays.copyOfRange(values, values.length >>> 1, values.length)); - - return bb.array(); - } - - /** - * Converts the given {@link IntegerArray} into {@code byte}s. - */ - final public static byte[] getBytes(IntegerArray array, String name) { - - // Force column-major indexing. - if (array.order() == IndexingOrder.FAR) { - array = array.reverseOrder(); - } - - int[] dims = array.dimensions(); - int[] values = array.values(); - - int totalSize = getDataElementSize(MI_UINT32, 2) // - + getDataElementSize(MI_INT32, dims.length) // - + getDataElementSize(MI_INT8, name.length()) // - + getDataElementSize(MI_INT32, values.length); - - ByteBuffer bb = ByteBuffer.allocate(totalSize + 8); - - bb.putInt(MI_MATRIX.getMatlabValue()); - bb.putInt(totalSize); - - writeDataElementHeader(bb, MI_UINT32, 2); - bb.putInt(MX_INT32_CLASS.getMatlabValue()); - bb.putInt(0); - - writeDataElementHeader(bb, MI_INT32, dims.length); - writeDataElementBody(bb, dims); - - writeDataElementHeader(bb, MI_INT8, name.length()); - writeDataElementBody(bb, name.getBytes()); - - writeDataElementHeader(bb, MI_INT32, values.length); - writeDataElementBody(bb, values); - - return bb.array(); - } - - /** - * Converts the given {@link Array}s into "mat" format. - * - * @param - * the {@link Array} type. - * @param - * the {@link Array} element type. - */ - public , E> byte[] getMatBytes(T... arrays) { - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - RealArrayCountLocal.set(0); - ComplexArrayCountLocal.set(0); - IntegerArrayCountLocal.set(0); - - try { - - out.write(getHeaderBytes(String.format("MATLAB 5.0 MAT-file, " // - + "Platform: Shared Scientific Toolbox in Java %d.%02d", // - MAJOR_VERSION, MINOR_VERSION))); - - for (T array : arrays) { - out.write(getBytes(array)); - } - - } catch (IOException e) { - - throw new RuntimeException(e); - - } finally { - - RealArrayCountLocal.set(null); - ComplexArrayCountLocal.set(null); - IntegerArrayCountLocal.set(null); - } - - return out.toByteArray(); - } - - /** - * Parses a series of {@link Array}s from "mat" format. - */ - public Array[] parseMat(byte[] data) { - - ByteBuffer bb = ByteBuffer.wrap(data); - bb.position(126); - - if (bb.getShort() == (short) ((ENDIANNESS >>> 8) | (ENDIANNESS << 8))) { - bb.order(bb.order().equals(ByteOrder.BIG_ENDIAN) ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); - } - - bb.position(124); - - Control.checkTrue(bb.getShort() == 0x0100, // - "Invalid version"); - - Control.checkTrue(bb.getShort() == ENDIANNESS, // - "Invalid Endian indicator"); - - List> arrays = new ArrayList>(); - - for (; bb.hasRemaining();) { - arrays.add(new MatrixDataElement(bb).get()); - } - - return arrays.toArray(new Array[] {}); - } - - /** - * Writes the data element header, given the {@link DataType} and the number of elements. - */ - final protected static void writeDataElementHeader(ByteBuffer bb, DataType type, int nelts) { - - int nbytes = type.sizeOf() * nelts; - - if (nbytes > 4 || nbytes == 0) { - - bb.putInt(type.getMatlabValue()); - bb.putInt(nbytes); - - } else { - - bb.putShort((short) nbytes); - bb.putShort((short) type.getMatlabValue()); - } - } - - /** - * Writes the data element body. - */ - final protected static void writeDataElementBody(ByteBuffer bb, byte[] arr) { - - bb.put(arr); - - if (arr.length > 4) { - - for (int i = 0, n = (8 - arr.length % 8) % 8; i < n; i++) { - bb.put((byte) 0); - } - - } else if (arr.length >= 1) { - - for (int i = 0, n = 4 - arr.length; i < n; i++) { - bb.put((byte) 0); - } - } - } - - /** - * Writes the data element body. - */ - final protected static void writeDataElementBody(ByteBuffer bb, int[] arr) { - - for (int i : arr) { - bb.putInt(i); - } - - if (arr.length > 1) { - - for (int i = 0, n = (2 - arr.length % 2) % 2; i < n; i++) { - bb.putInt(0); - } - - } else if (arr.length >= 1) { - - for (int i = 0, n = 1 - arr.length; i < n; i++) { - bb.putInt(0); - } - } - } - - /** - * Writes the data element body. - */ - final protected static void writeDataElementBody(ByteBuffer bb, double[] arr) { - - for (double r : arr) { - bb.putDouble(r); - } - } - - /** - * Gets the data element size, given the {@link DataType} and the number of elements. - */ - final protected static int getDataElementSize(DataType type, int nelts) { - - int nbytes = type.sizeOf() * nelts; - return (nbytes > 4) ? (8 + nbytes + (8 - nbytes % 8) % 8) : 8; - } - - /** - * A Matlab data element. - * - * @param - * the result type. - */ - abstract protected static class DataElement { - - final int initialPosition; - final int type; - final int size; - final ByteBuffer bb; - - /** - * Default constructor. - */ - protected DataElement(ByteBuffer bb) { - - this.initialPosition = bb.position(); - - int tag = bb.getInt(); - bb.position(bb.position() - 4); - - if ((tag & 0xFFFF0000) == 0) { - - this.type = bb.getInt(); - this.size = bb.getInt(); - - } else { - - this.size = bb.getShort(); - this.type = bb.getShort(); - } - - this.bb = bb; - } - - /** - * Reads padding up to an eight {@code byte} alignment. - */ - protected void readPadding() { - - for (int i = 0, n = (8 - (this.bb.position() - this.initialPosition) % 8) % 8; i < n; i++) { - this.bb.get(); - } - } - - /** - * Gets the result. - */ - abstract protected T get(); - } - - /** - * A Matlab data element that is an array of {@code int}s. - */ - protected static class IntArrayDataElement extends DataElement { - - final int[] values; - - /** - * Default constructor. - */ - protected IntArrayDataElement(ByteBuffer bb) { - super(bb); - - switch (this.type) { - - case MATLAB_MI_INT8: - - this.values = new int[this.size]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.get(); - } - - break; - - case MATLAB_MI_UINT8: - - this.values = new int[this.size]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = (bb.get() & 0x000000FF); - } - - break; - - case MATLAB_MI_INT16: - - Control.checkTrue(this.size % 2 == 0, // - "Invalid size"); - - this.values = new int[this.size >>> 1]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.getShort(); - } - - break; - - case MATLAB_MI_UINT16: - - Control.checkTrue(this.size % 2 == 0, // - "Invalid size"); - - this.values = new int[this.size >>> 1]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = (bb.getShort() & 0x0000FFFF); - } - - break; - - case MATLAB_MI_INT32: - case MATLAB_MI_UINT32: - - Control.checkTrue(this.size % 4 == 0, // - "Invalid size"); - - this.values = new int[this.size >>> 2]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.getInt(); - } - - break; - - default: - throw new UnsupportedOperationException("Unknown data type"); - } - - readPadding(); - } - - @Override - protected int[] get() { - return this.values; - } - } - - /** - * A Matlab data element that is an array of {@code double}s. - */ - protected static class DoubleArrayDataElement extends DataElement { - - final double[] values; - - /** - * Default constructor. - */ - protected DoubleArrayDataElement(ByteBuffer bb) { - super(bb); - - switch (this.type) { - - case MATLAB_MI_SINGLE: - - Control.checkTrue(this.size % 4 == 0, // - "Invalid size"); - - this.values = new double[this.size >>> 2]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.getFloat(); - } - - break; - - case MATLAB_MI_DOUBLE: - - Control.checkTrue(this.size % 8 == 0, // - "Invalid size"); - - this.values = new double[this.size >>> 3]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.getDouble(); - } - - break; - - case MATLAB_MI_INT8: - - this.values = new double[this.size]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.get(); - } - - break; - - case MATLAB_MI_UINT8: - - this.values = new double[this.size]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = (bb.get() & 0x000000FF); - } - - break; - - case MATLAB_MI_INT16: - - Control.checkTrue(this.size % 2 == 0, // - "Invalid size"); - - this.values = new double[this.size >>> 1]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.getShort(); - } - - break; - - case MATLAB_MI_UINT16: - - Control.checkTrue(this.size % 2 == 0, // - "Invalid size"); - - this.values = new double[this.size >>> 1]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = (bb.getShort() & 0x0000FFFF); - } - - break; - - case MATLAB_MI_INT32: - case MATLAB_MI_UINT32: - - Control.checkTrue(this.size % 4 == 0, // - "Invalid size"); - - this.values = new double[this.size >>> 2]; - - for (int i = 0, n = this.values.length; i < n; i++) { - this.values[i] = bb.getInt(); - } - - break; - - default: - throw new UnsupportedOperationException("Unknown data type"); - } - - readPadding(); - } - - @Override - protected double[] get() { - return this.values; - } - } - - /** - * A Matlab matrix data element. - */ - protected static class MatrixDataElement extends DataElement> { - - final Array array; - - /** - * Default constructor. - */ - protected MatrixDataElement(ByteBuffer bb) { - super(bb); - - int savePosition = bb.position(); - - Control.checkTrue(this.type == MATLAB_MI_MATRIX, // - "Data element must be a Matlab matrix"); - - int arrayType = new IntArrayDataElement(bb).get()[0]; - int[] dims = new IntArrayDataElement(bb).get(); - - // Read in the array name and forget it. - new IntArrayDataElement(bb); - - switch (arrayType & 0x000000FF) { - - case MATLAB_MX_DOUBLE_CLASS: - case MATLAB_MX_SINGLE_CLASS: - - // The regular case. - if ((arrayType & 0x00000800) != 0x00000800) { - - this.array = new RealArray(new DoubleArrayDataElement(bb).get(), // - IndexingOrder.NEAR, dims).reverseOrder(); - - } - // The complex case. - else { - - double[] reals = new DoubleArrayDataElement(bb).get(); - double[] complexes = new DoubleArrayDataElement(bb).get(); - - int len = Control.checkEquals(reals.length, complexes.length, // - "Number of real values must equal number of complex values"); - - double[] composite = new double[2 * len]; - - System.arraycopy(reals, 0, composite, 0, len); - System.arraycopy(complexes, 0, composite, len, len); - - int[] newDims = Arrays.copyOf(dims, dims.length + 1); - newDims[newDims.length - 1] = 2; - - RealArray tmpArray = new RealArray(composite, IndexingOrder.NEAR, newDims); - this.array = new ComplexArray(tmpArray.reverseOrder().values(), newDims); - } - - break; - - case MATLAB_MX_INT8_CLASS: - case MATLAB_MX_UINT8_CLASS: - case MATLAB_MX_INT16_CLASS: - case MATLAB_MX_UINT16_CLASS: - case MATLAB_MX_INT32_CLASS: - case MATLAB_MX_UINT32_CLASS: - this.array = new IntegerArray(new IntArrayDataElement(bb).get(), // - IndexingOrder.NEAR, dims).reverseOrder(); - break; - - default: - throw new IllegalArgumentException("Invalid Matlab matrix type"); - } - - Control.checkTrue(this.size == bb.position() - savePosition, // - "Actual data element size does not match expected"); - } - - @Override - protected Array get() { - return this.array; - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatrixOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatrixOps.java deleted file mode 100755 index 7f5849ca..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/MatrixOps.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import shared.util.Control; - -/** - * A class for matrix operations in pure Java. - * - * @author Roy Liu - */ -public class MatrixOps { - - /** - * A matrix multiply operation in support of - * {@link JavaArrayKernel#mul(double[], double[], int, int, double[], boolean)}. - */ - final public static void mul(double[] lhsV, double[] rhsV, int lr, int rc, double[] dstV, boolean isComplex) { - - int factor = (isComplex ? 2 : 1); - int lc = (lr != 0) ? lhsV.length / (factor * lr) : 0; - int rr = (rc != 0) ? rhsV.length / (factor * rc) : 0; - int inner = Control.checkEquals(lc, rr); - - Control.checkTrue(lr >= 0 && rc >= 0 // - && (lhsV.length == factor * lr * lc) // - && (rhsV.length == factor * rr * rc) // - && (dstV.length == factor * lr * rc), // - "Invalid array lengths"); - - if (isComplex) { - - for (int i = 0; i < lr; i++) { - - for (int j = 0; j < rc; j++) { - - double sumRe = 0.0; - double sumIm = 0.0; - - for (int k = 0; k < inner; k++) { - - int lIndex = 2 * (i * lc + k); - int rIndex = 2 * (k * rc + j); - - sumRe += lhsV[lIndex] * rhsV[rIndex] // - - lhsV[lIndex + 1] * rhsV[rIndex + 1]; - sumIm += lhsV[lIndex] * rhsV[rIndex + 1] // - + lhsV[lIndex + 1] * rhsV[rIndex]; - } - - int outIndex = 2 * (i * rc + j); - - dstV[outIndex] = sumRe; - dstV[outIndex + 1] = sumIm; - } - } - - } else { - - for (int i = 0; i < lr; i++) { - - for (int j = 0; j < rc; j++) { - - double sum = 0.0; - - for (int k = 0; k < inner; k++) { - sum += lhsV[i * lc + k] * rhsV[k * rc + j]; - } - - dstV[i * rc + j] = sum; - } - } - } - } - - /** - * A matrix diagonal operation in support of {@link JavaArrayKernel#diag(double[], double[], int, boolean)}. - */ - final public static void diag(double[] srcV, double[] dstV, int size, boolean isComplex) { - - int factor = (isComplex ? 2 : 1); - - Control.checkTrue((srcV.length == factor * size * size) && (dstV.length == factor * size), // - "Invalid array lengths"); - - if (isComplex) { - - for (int j = 0, m = 2 * size; j < m; j += 2) { - - dstV[j] = srcV[j * size + j]; - dstV[j + 1] = srcV[j * size + j + 1]; - } - - } else { - - for (int i = 0; i < size; i++) { - dstV[i] = srcV[i * size + i]; - } - } - } - - // Dummy constructor. - MatrixOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ModalArrayIOKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ModalArrayIOKernel.java deleted file mode 100755 index 6d069e63..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ModalArrayIOKernel.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import shared.array.Array; -import shared.util.Services; - -/** - * An implementation of {@link ArrayIOKernel} that is a gateway to multiple I/O schemes. - * - * @apiviz.owns shared.array.kernel.MatlabIOKernel - * @author Roy Liu - */ -public class ModalArrayIOKernel implements ArrayIOKernel { - - volatile ArrayIOKernel opKernel; - - /** - * Default constructor. - */ - public ModalArrayIOKernel() { - - this.opKernel = Services.createService(ArrayIOKernel.class); - - if (this.opKernel == null) { - this.opKernel = new MatlabIOKernel(); - } - } - - /** - * Attempts to use the underlying {@link MatlabIOKernel}. - */ - public void useMatlabIO() { - this.opKernel = new MatlabIOKernel(); - } - - public , E> byte[] getBytes(T array) { - return this.opKernel.getBytes(array); - } - - public > T parse(byte[] data) { - return this.opKernel.parse(data); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ModalArrayKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ModalArrayKernel.java deleted file mode 100755 index b5f7127f..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/ModalArrayKernel.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import shared.array.jni.NativeArrayKernel; -import shared.array.sparse.SparseArrayState; -import shared.util.Services; - -/** - * An implementation of {@link ArrayKernel} that has JNI and pure Java bindings. - * - * @apiviz.owns shared.array.kernel.JavaArrayKernel - * @author Roy Liu - */ -public class ModalArrayKernel implements ArrayKernel { - - volatile ArrayKernel opKernel; - - /** - * Default constructor. Tries to create an underlying {@link NativeArrayKernel}. Failing that, creates an underlying - * {@link JavaArrayKernel}. - */ - public ModalArrayKernel() { - - this.opKernel = Services.createService(ArrayKernel.class); - - if (this.opKernel == null) { - this.opKernel = new JavaArrayKernel(); - } - } - - /** - * Uses the underlying {@link NativeArrayKernel} obtained from {@link Services#createService(Class)}. - */ - public boolean useNative() { - - this.opKernel = Services.createService(ArrayKernel.class); - - if (this.opKernel == null) { - - this.opKernel = new JavaArrayKernel(); - - return false; - - } else { - - return true; - } - } - - /** - * Uses the underlying {@link JavaArrayKernel}. - */ - public void useJava() { - this.opKernel = new JavaArrayKernel(); - } - - // - - public void randomize() { - this.opKernel.randomize(); - } - - public void derandomize() { - this.opKernel.derandomize(); - } - - // - - public void map(int[] bounds, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS) { - this.opKernel.map(bounds, srcV, srcD, srcS, dstV, dstD, dstS); - } - - public void slice( // - int[] slices, // - Object srcV, int[] srcD, int[] srcS, // - Object dstV, int[] dstD, int[] dstS) { - this.opKernel.slice(slices, srcV, srcD, srcS, dstV, dstD, dstS); - } - - // - - public void rrOp(int type, // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS, // - int... selectedDims) { - this.opKernel.rrOp(type, srcV, srcD, srcS, dstV, dstD, dstS, selectedDims); - } - - public void riOp(int type, // - double[] srcV, int[] srcD, int[] srcS, int[] dstV, // - int dim) { - this.opKernel.riOp(type, srcV, srcD, srcS, dstV, dim); - } - - public void rdOp(int type, // - double[] srcV, int[] srcD, int[] srcS, double[] dstV, // - int... selectedDims) { - this.opKernel.rdOp(type, srcV, srcD, srcS, dstV, selectedDims); - } - - public double raOp(int type, double[] srcV) { - return this.opKernel.raOp(type, srcV); - } - - public double[] caOp(int type, double[] srcV) { - return this.opKernel.caOp(type, srcV); - } - - public void ruOp(int type, double a, double[] srcV) { - this.opKernel.ruOp(type, a, srcV); - } - - public void cuOp(int type, double aRe, double aIm, double[] srcV) { - this.opKernel.cuOp(type, aRe, aIm, srcV); - } - - public void iuOp(int type, int a, int[] srcV) { - this.opKernel.iuOp(type, a, srcV); - } - - public void eOp(int type, Object lhsV, Object rhsV, Object dstV, boolean isComplex) { - this.opKernel.eOp(type, lhsV, rhsV, dstV, isComplex); - } - - public void convert(int type, // - Object srcV, boolean isSrcComplex, // - Object dstV, boolean isDstComplex) { - this.opKernel.convert(type, srcV, isSrcComplex, dstV, isDstComplex); - } - - // - - public void mul(double[] lhsV, double[] rhsV, int lr, int rc, double[] dstV, boolean isComplex) { - this.opKernel.mul(lhsV, rhsV, lr, rc, dstV, isComplex); - } - - public void diag(double[] srcV, double[] dstV, int size, boolean isComplex) { - this.opKernel.diag(srcV, dstV, size, isComplex); - } - - // - - public void svd(double[] srcV, int srcStrideRow, int srcStrideCol, // - double[] uV, double[] sV, double[] vV, // - int nrows, int ncols) { - this.opKernel.svd(srcV, srcStrideRow, srcStrideCol, uV, sV, vV, nrows, ncols); - } - - public void eigs(double[] srcV, double[] vecV, double[] valV, int size) { - this.opKernel.eigs(srcV, vecV, valV, size); - } - - public void invert(double[] srcV, double[] dstV, int size) { - this.opKernel.invert(srcV, dstV, size); - } - - // - - public int[] find(int[] srcV, int[] srcD, int[] srcS, int[] logical) { - return this.opKernel.find(srcV, srcD, srcS, logical); - } - - // - - public SparseArrayState insertSparse( // - V oldV, int[] oldD, int[] oldS, int[] oldDO, int[] oldI, // - V newV, int[] newI) { - return this.opKernel.insertSparse(oldV, oldD, oldS, oldDO, oldI, newV, newI); - } - - public SparseArrayState sliceSparse(int[] slices, // - V srcV, int[] srcD, int[] srcS, int[] srcDO, // - int[] srcI, int[] srcIO, int[] srcII, // - V dstV, int[] dstD, int[] dstS, int[] dstDO, // - int[] dstI, int[] dstIO, int[] dstII) { - return this.opKernel.sliceSparse(slices, // - srcV, srcD, srcS, srcDO, // - srcI, srcIO, srcII, // - dstV, dstD, dstS, dstDO, // - dstI, dstIO, dstII); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/PermutationEntry.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/PermutationEntry.java deleted file mode 100755 index 6bc3660a..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/PermutationEntry.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import java.util.Arrays; - -/** - * A bookkeeping class for permutations. - * - * @param - * the {@link Comparable} type. - * @author Roy Liu - */ -public class PermutationEntry> implements Comparable> { - - C value; - - int order; - - /** - * Default constructor. - */ - public PermutationEntry(C value, int order) { - - this.value = value; - this.order = order; - } - - /** - * Compares values. - */ - public int compareTo(PermutationEntry o) { - return this.value.compareTo(o.value); - } - - /** - * Gets the value. - */ - public C getValue() { - return this.value; - } - - /** - * Gets the order. - */ - public int getOrder() { - return this.order; - } - - /** - * Performs an index sort operation in support of {@link DimensionOps}. - * - * @param srcV - * the source values. - * @param srcIndices - * the source indices. - * @param dstV - * the destination values. - * @param size - * the dimension size. - * @param stride - * the dimension stride. - * @param - * the component type. - */ - @SuppressWarnings("unchecked") - final public static > void iSort(T[] srcV, int[] srcIndices, int[] dstV, int size, - int stride) { - - int len = (srcIndices != null) ? size : srcV.length; - - PermutationEntry[] entries = new PermutationEntry[len]; - - for (int i = 0; i < len; i++) { - entries[i] = new PermutationEntry((T) null, -1); - } - - if (srcIndices != null) { - - for (int i = 0, nindices = srcIndices.length; i < nindices; i++) { - - for (int offset = 0, j = 0; j < size; offset += stride, j++) { - - entries[j].value = srcV[srcIndices[i] + offset]; - entries[j].order = j; - } - - Arrays.sort(entries); - - for (int offset = 0, j = 0; j < size; offset += stride, j++) { - - srcV[srcIndices[i] + offset] = entries[j].value; - dstV[srcIndices[i] + offset] = entries[j].order; - } - } - - } else { - - for (int i = 0, n = srcV.length; i < n; i++) { - - entries[i].value = srcV[i]; - entries[i].order = i; - } - - Arrays.sort(entries); - - for (int i = 0, n = srcV.length; i < n; i++) { - - srcV[i] = entries[i].value; - dstV[i] = entries[i].order; - } - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/SparseOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/SparseOps.java deleted file mode 100755 index 4107263e..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/SparseOps.java +++ /dev/null @@ -1,820 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.kernel; - -import java.lang.reflect.Array; -import java.util.Arrays; - -import shared.array.sparse.SparseArrayState; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A class for sparse array operations in pure Java. - * - * @author Roy Liu - */ -public class SparseOps { - - /** - * An insertion operation in support of - * {@link JavaArrayKernel#insertSparse(Object, int[], int[], int[], int[], Object, int[])}. - */ - @SuppressWarnings("unchecked") - final public static SparseArrayState insert( // - V oldV, int[] oldD, int[] oldS, int[] oldDO, int[] oldI, // - V newV, int[] newI) { - - int ndims = oldD.length; - int oldLen = Array.getLength(oldV); - int newLen = Array.getLength(newV); - - Control.checkTrue(ndims == oldS.length // - && oldLen == oldI.length // - && newLen == newI.length, // - "Invalid arguments"); - - MappingOps.checkDimensions(Arithmetic.product(oldD), oldD, oldS); - - for (int dim = 0; dim < ndims; dim++) { - Control.checkTrue(oldDO[dim + 1] - oldDO[dim] - 1 == oldD[dim], // - "Invalid arguments"); - } - - PermutationEntry[] entries = new PermutationEntry[newLen]; - - for (int i = 0; i < newLen; i++) { - entries[i] = new PermutationEntry(newI[i], i); - } - - Arrays.sort(entries); - - int[] perm = new int[newLen]; - - for (int i = 0; i < newLen; i++) { - - newI[i] = entries[i].getValue(); - perm[i] = entries[i].getOrder(); - } - - for (int i = 1; i < newLen; i++) { - Control.checkTrue(entries[i - 1].getValue() != entries[i].getValue(), // - "Duplicate values are not allowed"); - } - - int[][] mergeResult = merge( // - oldI, Arithmetic.range(oldLen), // - newI, Arithmetic.range(newLen), // - oldD, oldS, oldDO); - - int[] newIndirections = mergeResult[3]; - - for (int i = 0; i < newLen; i++) { - perm[i] = newIndirections[perm[i]]; - } - - System.arraycopy(perm, 0, newIndirections, 0, newLen); - - return assign(oldV, newV, mergeResult); - } - - /** - * A slicing operation in support of - * {@link JavaArrayKernel#sliceSparse(int[], Object, int[], int[], int[], int[], int[], int[], Object, int[], int[], int[], int[], int[], int[])} - * . - */ - final public static SparseArrayState slice(int[] slices, // - V srcV, int[] srcD, int[] srcS, int[] srcDO, // - int[] srcI, int[] srcIO, int[] srcII, // - V dstV, int[] dstD, int[] dstS, int[] dstDO, // - int[] dstI, int[] dstIO, int[] dstII) { - - int nslices = slices.length / 3; - int ndims = srcD.length; - int srcLen = Array.getLength(srcV); - int dstLen = Array.getLength(dstV); - - Control.checkTrue(ndims == srcS.length // - && ndims == dstD.length // - && ndims == dstS.length // - && slices.length % 3 == 0 // - && srcLen == srcI.length // - && dstLen == dstI.length // - && srcDO.length == ndims + 1 // - && srcIO.length == Arithmetic.sum(srcD) + ndims // - && srcII.length == ndims * srcLen // - && dstDO.length == ndims + 1 // - && dstIO.length == Arithmetic.sum(dstD) + ndims // - && dstII.length == ndims * dstLen, // - "Invalid arguments"); - - MappingOps.checkDimensions(Arithmetic.product(srcD), srcD, srcS); - MappingOps.checkDimensions(Arithmetic.product(dstD), dstD, dstS); - - for (int i = 0, n = 3 * nslices; i < n; i += 3) { - - int srcIndex = slices[i]; - int dstIndex = slices[i + 1]; - int dim = slices[i + 2]; - - Control.checkTrue(dim >= 0 && dim < ndims, // - "Invalid dimension"); - - Control.checkTrue((srcIndex >= 0 && srcIndex < srcD[dim]) // - && (dstIndex >= 0 && dstIndex < dstD[dim]), // - "Invalid index"); - } - - for (int dim = 0; dim < ndims; dim++) { - Control.checkTrue((srcDO[dim + 1] - srcDO[dim] - 1 == srcD[dim]) // - && (dstDO[dim + 1] - dstDO[dim] - 1 == dstD[dim]), // - "Invalid arguments"); - } - - // - - int offsetArrayLen = srcDO[ndims]; - - int[] srcSliceCounts = new int[ndims]; - int[] lookupCounts = new int[offsetArrayLen]; - - Arrays.fill(srcSliceCounts, 0); - Arrays.fill(lookupCounts, 0); - - for (int i = 0, n = 3 * nslices; i < n; i += 3) { - - int srcIndex = slices[i]; - int dim = slices[i + 2]; - - srcSliceCounts[dim]++; - lookupCounts[srcDO[dim] + srcIndex]++; - } - - // - - int[] sliceOffsets = new int[ndims + 1]; - int[] lookupOffsets = new int[offsetArrayLen]; - - int sliceOffset = 0; - int lookupOffset = 0; - - for (int dim = 0; dim < ndims; dim++) { - - sliceOffsets[dim] = sliceOffset; - sliceOffset += srcSliceCounts[dim]; - - int dimSize = srcD[dim]; - - for (int dimIndex = 0; dimIndex < dimSize; dimIndex++) { - - lookupOffsets[srcDO[dim] + dimIndex] = lookupOffset; - lookupOffset += lookupCounts[srcDO[dim] + dimIndex]; - } - - lookupOffsets[srcDO[dim] + dimSize] = lookupOffset; - } - - sliceOffsets[ndims] = sliceOffset; - - // - - int[] srcSlices = new int[sliceOffset]; - int[] dstSlices = new int[sliceOffset]; - int[] dstSliceCounts = new int[ndims]; - int[] dstLookups = new int[lookupOffset]; - - Arrays.fill(srcSliceCounts, 0); - Arrays.fill(lookupCounts, 0); - - for (int i = 0, n = 3 * nslices; i < n; i += 3) { - - int srcIndex = slices[i]; - int dstIndex = slices[i + 1]; - int dim = slices[i + 2]; - - srcSlices[sliceOffsets[dim] + srcSliceCounts[dim]] = srcIndex; - dstSlices[sliceOffsets[dim] + srcSliceCounts[dim]] = dstIndex; - dstLookups[lookupOffsets[srcDO[dim] + srcIndex] // - + lookupCounts[srcDO[dim] + srcIndex]] = dstIndex; - - srcSliceCounts[dim]++; - lookupCounts[srcDO[dim] + srcIndex]++; - } - - // - - Arrays.fill(srcSliceCounts, 0); - Arrays.fill(lookupCounts, 0); - - for (int dim = 0; dim < ndims; dim++) { - - srcSliceCounts[dim] = normalize(srcSlices, sliceOffsets[dim], sliceOffsets[dim + 1]); - dstSliceCounts[dim] = normalize(dstSlices, sliceOffsets[dim], sliceOffsets[dim + 1]); - - for (int dimIndex = 0, dimSize = srcD[dim]; dimIndex < dimSize; dimIndex++) { - lookupCounts[srcDO[dim] + dimIndex] = normalize(dstLookups, // - lookupOffsets[srcDO[dim] + dimIndex], // - lookupOffsets[srcDO[dim] + dimIndex + 1]); - } - } - - // - - int[] srcIndirections = getSlicedIndirections(sliceOffsets, srcSliceCounts, srcSlices, // - srcDO, srcIO, srcII, srcD); - int nsrcIndirections = srcIndirections.length; - - int[] dstIndirections = getSlicedIndirections(sliceOffsets, dstSliceCounts, dstSlices, // - dstDO, dstIO, dstII, dstD); - int ndstIndirections = dstIndirections.length; - - // - - int[] indirectionOffsets = new int[nsrcIndirections + 1]; - int indirectionOffset = 0; - - for (int i = 0, prodD = Arithmetic.product(srcD); i < nsrcIndirections; i++) { - - int indirection = srcIndirections[i]; - - Control.checkTrue(indirection >= 0 && indirection < srcLen, // - "Invalid indirection index"); - - int physical = srcI[indirection]; - - Control.checkTrue(physical >= 0 && physical < prodD, // - "Invalid physical index"); - - int mapLen = 1; - - for (int dim = 0; dim < ndims; dim++) { - - int logicalIndex = physical / srcS[dim]; - - mapLen *= lookupCounts[srcDO[dim] + logicalIndex]; - - physical %= srcS[dim]; - } - - indirectionOffsets[i] = indirectionOffset; - indirectionOffset += mapLen; - } - - indirectionOffsets[nsrcIndirections] = indirectionOffset; - - // - - int[] newIndirections = new int[indirectionOffset]; - int[] newIndices = new int[indirectionOffset]; - int[] logical = new int[ndims]; - - for (int i = 0; i < nsrcIndirections; i++) { - - int indirection = srcIndirections[i]; - int physical = srcI[indirection]; - - indirectionOffset = indirectionOffsets[i]; - - newIndices[indirectionOffset] = 0; - - for (int dim = 0; dim < ndims; dim++) { - - logical[dim] = physical / srcS[dim]; - - newIndices[indirectionOffset] += dstS[dim] // - * dstLookups[lookupOffsets[srcDO[dim] + logical[dim]]]; - - physical %= srcS[dim]; - } - - Arrays.fill(newIndirections, indirectionOffsets[i], indirectionOffsets[i + 1], indirection); - - for (int dim = ndims - 1, blockSize = 1, size; dim >= 0; blockSize *= size, dim--) { - - int start = lookupOffsets[srcDO[dim] + logical[dim]]; - size = lookupCounts[srcDO[dim] + logical[dim]]; - - for (int offset = indirectionOffset + blockSize, // - offsetEnd = indirectionOffset + blockSize * size, n = start + 1; // - offset < offsetEnd; offset += blockSize, n++) { - - int strideOffset = dstS[dim] * (dstLookups[n] - dstLookups[n - 1]); - - for (int j = offset - blockSize, k = offset; j < offset; j++, k++) { - newIndices[k] = newIndices[j] + strideOffset; - } - } - } - } - - // - - final int[] oldIndices; - final int[] oldIndirections; - - if (ndstIndirections > 0) { - - oldIndices = new int[dstI.length - ndstIndirections]; - oldIndirections = new int[dstI.length - ndstIndirections]; - - int count = 0; - - for (int i = 0, m = dstIndirections[0]; i < m; i++, count++) { - - oldIndices[count] = dstI[i]; - oldIndirections[count] = i; - } - - for (int i = 0, n = ndstIndirections - 1; i < n; i++) { - - for (int j = dstIndirections[i] + 1, m = dstIndirections[i + 1]; j < m; j++, count++) { - - oldIndices[count] = dstI[j]; - oldIndirections[count] = j; - } - } - - for (int i = dstIndirections[ndstIndirections - 1] + 1, m = dstI.length; i < m; i++, count++) { - - oldIndices[count] = dstI[i]; - oldIndirections[count] = i; - } - - } else { - - oldIndices = dstI; - oldIndirections = Arithmetic.range(dstI.length); - } - - // - - int[][] res = merge(newIndices, newIndirections); - newIndices = res[0]; - newIndirections = res[1]; - - return assign(dstV, srcV, merge(oldIndices, oldIndirections, newIndices, newIndirections, // - dstD, dstS, dstDO)); - } - - /** - * Aggregates old values, new values, and their assignments into a {@link SparseArrayState}. - * - * @param oldV - * the old values. - * @param newV - * the new values. - * @param mergeResult - * the result of {@link #merge(int[], int[], int[], int[], int[], int[], int[])}. - * @param - * the storage array type. - * @return the {@link SparseArrayState}. - */ - @SuppressWarnings("unchecked") - final public static SparseArrayState assign(V oldV, V newV, int[][] mergeResult) { - - int[] oldAssignments = mergeResult[0]; - int[] oldIndirections = mergeResult[1]; - int[] newAssignments = mergeResult[2]; - int[] newIndirections = mergeResult[3]; - int[] indices = mergeResult[4]; - int[] indirectionOffsets = mergeResult[5]; - int[] indirections = mergeResult[6]; - - int nindices = indices.length; - - final V values; - - if (oldV instanceof double[] && newV instanceof double[]) { - - double[] oldVArr = (double[]) oldV; - double[] newVArr = (double[]) newV; - double[] dstVArr = new double[nindices]; - - for (int i = 0, n = oldAssignments.length; i < n; i++) { - dstVArr[oldAssignments[i]] = oldVArr[oldIndirections[i]]; - } - - for (int i = 0, n = newAssignments.length; i < n; i++) { - dstVArr[newAssignments[i]] = newVArr[newIndirections[i]]; - } - - values = (V) dstVArr; - - } else if (oldV instanceof int[] && newV instanceof int[]) { - - int[] oldVArr = (int[]) oldV; - int[] newVArr = (int[]) newV; - int[] dstVArr = new int[nindices]; - - for (int i = 0, n = oldAssignments.length; i < n; i++) { - dstVArr[oldAssignments[i]] = oldVArr[oldIndirections[i]]; - } - - for (int i = 0, n = newAssignments.length; i < n; i++) { - dstVArr[newAssignments[i]] = newVArr[newIndirections[i]]; - } - - values = (V) dstVArr; - - } else if (oldV instanceof Object[] && newV instanceof Object[]) { - - Control.checkTrue(oldV.getClass().isAssignableFrom(newV.getClass()), // - "Invalid array types"); - - Object[] oldVArr = (Object[]) oldV; - Object[] newVArr = (Object[]) newV; - Object[] dstVArr = (Object[]) Array.newInstance( // - oldVArr.getClass().getComponentType(), nindices); - - for (int i = 0, n = oldAssignments.length; i < n; i++) { - dstVArr[oldAssignments[i]] = oldVArr[oldIndirections[i]]; - } - - for (int i = 0, n = newAssignments.length; i < n; i++) { - dstVArr[newAssignments[i]] = newVArr[newIndirections[i]]; - } - - values = (V) dstVArr; - - } else { - - throw new IllegalArgumentException("Invalid arguments"); - } - - return new SparseArrayState(values, indices, indirectionOffsets, indirections); - } - - /** - * Merges old and new array metadata. - * - * @param oldIndices - * the old physical indices. Invariant: Sorted in ascending order, and does not contain duplicates. - * @param oldIndirections - * the indirections on old values. - * @param newIndices - * the new physical indices. Invariant: Sorted in ascending order, and does not contain duplicates. - * @param newIndirections - * the indirections on new values. - * @param dims - * the dimensions. - * @param strides - * the strides. - * @param dimOffsets - * the dimension offsets. - * @return the assignments and metadata. - */ - final public static int[][] merge( // - int[] oldIndices, int[] oldIndirections, // - int[] newIndices, int[] newIndirections, // - int[] dims, int[] strides, int[] dimOffsets) { - - int oldLen = oldIndices.length; - int newLen = newIndices.length; - - int[] oldAssignments = new int[oldLen]; - int[] newAssignments = new int[newLen]; - - int count = 0; - int oldCount = 0; - int newCount = 0; - - for (; oldCount < oldLen && newCount < newLen;) { - - if (oldIndices[oldCount] < newIndices[newCount]) { - - oldAssignments[oldCount++] = count++; - - } else if (oldIndices[oldCount] > newIndices[newCount]) { - - newAssignments[newCount++] = count++; - - } else { - - oldAssignments[oldCount++] = count; - newAssignments[newCount++] = count; - count++; - } - } - - for (; oldCount < oldLen; oldCount++, count++) { - oldAssignments[oldCount] = count; - } - - for (; newCount < newLen; newCount++, count++) { - newAssignments[newCount] = count; - } - - // - - int[] indices = new int[count]; - - for (int i = 0; i < oldLen; i++) { - indices[oldAssignments[i]] = oldIndices[i]; - } - - for (int i = 0; i < newLen; i++) { - indices[newAssignments[i]] = newIndices[i]; - } - - // - - int sumD = Arithmetic.sum(dims); - int prodD = Arithmetic.product(dims); - int ndims = Control.checkEquals(dims.length, strides.length); - - // - - int[] dimCounts = new int[sumD + ndims]; - - Arrays.fill(dimCounts, 0); - - for (int i = 0, acc; i < count; i++) { - - acc = indices[i]; - - Control.checkTrue(acc >= 0 && acc < prodD, // - "Invalid physical index"); - - for (int dim = 0; dim < ndims; dim++) { - - int dimOffset = dimOffsets[dim] + acc / strides[dim]; - - dimCounts[dimOffset]++; - acc %= strides[dim]; - } - } - - // - - int[] indirectionOffsets = new int[sumD + ndims]; - - for (int dim = 0, acc; dim < ndims; dim++) { - - acc = 0; - - int dimOffset = dimOffsets[dim]; - int dimSize = dims[dim]; - - for (int dimIndex = 0; dimIndex < dimSize; dimIndex++) { - - indirectionOffsets[dimOffset + dimIndex] = acc; - acc += dimCounts[dimOffsets[dim] + dimIndex]; - } - - indirectionOffsets[dimOffset + dimSize] = count; - } - - // - - Arrays.fill(dimCounts, 0); - - int[] indirections = new int[ndims * count]; - - for (int i = 0, acc; i < count; i++) { - - acc = indices[i]; - - for (int dim = 0; dim < ndims; dim++) { - - int dimOffset = dimOffsets[dim] + acc / strides[dim]; - - indirections[count * dim + indirectionOffsets[dimOffset] + dimCounts[dimOffset]] = i; - dimCounts[dimOffset]++; - acc %= strides[dim]; - } - } - - return new int[][] { - // - oldAssignments, // - oldIndirections, // - newAssignments, // - newIndirections, // - indices, // - indirectionOffsets, // - indirections // - }; - } - - /** - * Normalizes a range of sorted values such that duplicates are removed. - * - * @param values - * the array of values. - * @param start - * the start index. - * @param end - * the end index. - * @return the number of resulting unique values. - */ - final public static int normalize(int[] values, int start, int end) { - - Arrays.sort(values, start, end); - - int propagate = 0; - - for (int i = start, current = -1; i < end; i++) { - - values[i - propagate] = values[i]; - - if (current != values[i]) { - - current = values[i]; - - } else { - - propagate++; - } - } - - return end - start - propagate; - } - - /** - * Gets the sliced indirections. - * - * @param sliceOffsets - * the slice offsets. - * @param sliceCounts - * the slice counts. - * @param slices - * the slices. - * @param dimOffsets - * the dimension offsets. - * @param indirectionOffsets - * the indirection offsets. - * @param indirections - * the indirections. - * @param dims - * the dimensions. - * @return the sliced indirections. - */ - final public static int[] getSlicedIndirections( // - int[] sliceOffsets, int[] sliceCounts, int[] slices, // - int[] dimOffsets, int[] indirectionOffsets, int[] indirections, int[] dims) { - - int ndims = sliceOffsets.length - 1; - int nindirections = indirections.length / ndims; - - int[] intersection = null; - int len = 0; - - for (int dim = 0; dim < ndims; dim++) { - - int dimOffset = dimOffsets[dim]; - - int sliceStart = sliceOffsets[dim]; - int sliceEnd = sliceOffsets[dim] + sliceCounts[dim]; - - int nslices = sliceEnd - sliceStart; - - int nelts = 0; - - for (int i = 0; i < nslices; i++) { - - int index = slices[i + sliceStart]; - - int start = indirectionOffsets[dimOffset + index]; - int end = indirectionOffsets[dimOffset + index + 1]; - - Control.checkTrue(start >= 0 // - && start <= end // - && end >= 0 // - && end <= nindirections, // - "Invalid arguments"); - - nelts += end - start; - } - - int[] res = new int[nelts]; - - for (int i = 0, resCount = 0; i < nslices; i++) { - - int index = slices[i + sliceStart]; - - int start = indirectionOffsets[dimOffset + index]; - int end = indirectionOffsets[dimOffset + index + 1]; - - for (int j = start; j < end; j++) { - res[resCount++] = indirections[nindirections * dim + j]; - } - } - - Arrays.sort(res); - - if (intersection != null) { - - int intersectionLower = 0; - int intersectionUpper = len; - - int resLower = 0; - int resUpper = nelts; - - int propagate = 0; - - for (; intersectionLower < intersectionUpper && resLower < resUpper;) { - - if (intersection[intersectionLower] < res[resLower]) { - - intersection[intersectionLower - propagate] = intersection[intersectionLower]; - propagate++; - - intersectionLower++; - - } else if (intersection[intersectionLower] > res[resLower]) { - - resLower++; - - } else { - - intersection[intersectionLower - propagate] = intersection[intersectionLower]; - - intersectionLower++; - resLower++; - } - } - - len = intersectionLower - propagate; - - } else { - - intersection = res; - len = nelts; - } - } - - return Arrays.copyOf(intersection, len); - } - - /** - * Merges sliced indirections by physical index. - * - * @param indices - * the physical indices. - * @param indirections - * the sliced indirections. - * @return the merged physical indices and indirections. - */ - @SuppressWarnings("unchecked") - final public static int[][] merge(int[] indices, int[] indirections) { - - int nelts = Control.checkEquals(indices.length, indirections.length, // - "Invalid arguments"); - - PermutationEntry[] entries = new PermutationEntry[nelts]; - - for (int i = 0; i < nelts; i++) { - entries[i] = new PermutationEntry(indices[i], indirections[i]); - } - - Arrays.sort(entries); - - int propagate = 0; - - for (int i = 0, current = -1; i < nelts; i++) { - - entries[i - propagate] = entries[i]; - - if (current != entries[i].getValue()) { - - current = entries[i].getValue(); - - } else { - - propagate++; - } - } - - int resLen = nelts - propagate; - - int[] resIndices = new int[resLen]; - int[] resIndirections = new int[resLen]; - - for (int i = 0; i < resLen; i++) { - - resIndices[i] = entries[i].getValue(); - resIndirections[i] = entries[i].getOrder(); - } - - return new int[][] { resIndices, resIndirections }; - } - - // Dummy constructor. - SparseOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/package-info.java deleted file mode 100755 index 3847fc44..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/kernel/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package for basic operations on {@link shared.array.Array}s. - */ -package shared.array.kernel; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/package-info.java deleted file mode 100755 index bf9651ba..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of multidimensional arrays. - */ -package shared.array; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/IntegerSparseArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/IntegerSparseArray.java deleted file mode 100755 index 8c36e283..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/IntegerSparseArray.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.sparse; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.OpKernel; -import static shared.array.ArrayBase.formatSparseArray; - -import java.util.Formatter; - -import shared.array.ArrayBase; -import shared.array.IntegerArray; -import shared.util.Arithmetic; -import shared.util.Arrays; -import shared.util.Control; - -/** - * A sparse integer array class. - * - * @author Roy Liu - */ -public class IntegerSparseArray extends ProtoSparseArray { - - /** - * An empty array. - */ - final protected static int[] Empty = new int[] {}; - - /** - * Default constructor. - */ - public IntegerSparseArray(int... dims) { - this(0, dims.clone()); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected IntegerSparseArray(int unused, int[] dims) { - super(new SparseArrayState(Empty, dims), // - dims, DEFAULT_ORDER.strides(dims), createDimensionOffsets(dims)); - - Control.checkTrue(dims.length > 0); - } - - /** - * Alternate constructor. - */ - public IntegerSparseArray(IntegerSparseArray array) { - this(array.state, array.dims, array.strides, array.dimOffsets); - } - - /** - * Internal constructor for package use only. - */ - protected IntegerSparseArray(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets) { - super(state, dims, strides, dimOffsets); - } - - public Class getComponentType() { - return Integer.class; - } - - @Override - protected IntegerSparseArray wrap(Integer value, int[] dims, int[] strides, int[] dimOffsets) { - - final SparseArrayState state; - - if (value == null) { - - state = new SparseArrayState(Empty, dims); - - } else { - - int[] values = Arrays.newArray(Arithmetic.product(dims), value.intValue()); - - state = OpKernel.insertSparse( // - Empty, dims, strides, dimOffsets, EmptyIndices, // - values, Arithmetic.range(values.length)); - } - - return new IntegerSparseArray(state, dims, strides, dimOffsets); - } - - @Override - protected IntegerSparseArray wrap(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets) { - return new IntegerSparseArray(state, dims, strides, dimOffsets); - } - - @Override - protected int length(int[] values) { - return values.length; - } - - @Override - protected int[] empty() { - return Empty; - } - - @Override - public IntegerArray toDense() { - - IntegerSparseArray src = this; - - IntegerArray dst = new IntegerArray(src.order(), src.dims); - - SparseArrayState srcState = src.state; - - int[] srcValues = srcState.values; - int[] srcIndices = srcState.indices; - - int[] dstValues = dst.values(); - - for (int i = 0, n = srcValues.length; i < n; i++) { - dstValues[srcIndices[i]] = srcValues[i]; - } - - return dst; - } - - @Override - public String toString() { - - SparseArrayState state = this.state; - - int[] values = state.values; - int[] indices = state.indices; - int[] dims = this.dims; - int[] strides = this.strides; - - int max = Math.max(Arithmetic.max(values), Math.abs(Arithmetic.min(values))); - int exponent = max > 0 ? (int) Math.log10(max) : 0; - - int maxIndex = Arithmetic.max(dims); - int exponentIndex = maxIndex > 0 ? (int) Math.log10(maxIndex) : 0; - - Formatter f = new Formatter(); - - if (values.length == 0) { - - ArrayBase.formatEmptyArray(f, dims); - - return f.toString(); - } - - String valueFormat = String.format("%%%dd", exponent + 3); - String indexFormat = String.format("%%%dd", exponentIndex + 2); - - formatSparseArray(f, valueFormat, indexFormat, values, indices, strides); - - return f.toString(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/ObjectSparseArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/ObjectSparseArray.java deleted file mode 100755 index 7ef61ee8..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/ObjectSparseArray.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.sparse; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.OpKernel; -import static shared.array.ArrayBase.formatSparseArray; - -import java.lang.reflect.Array; -import java.util.Formatter; - -import shared.array.ArrayBase; -import shared.array.ObjectArray; -import shared.util.Arithmetic; -import shared.util.Arrays; -import shared.util.Control; - -/** - * A sparse object array class. - * - * @param - * the storage type. - */ -public class ObjectSparseArray extends ProtoSparseArray, T[], T, ObjectArray> { - - /** - * Default constructor. - */ - public ObjectSparseArray(Class clazz, int... dims) { - this(0, clazz, dims.clone()); - } - - /** - * Internal constructor with a distinctive signature. - */ - @SuppressWarnings("unchecked") - protected ObjectSparseArray(int unused, Class clazz, int[] dims) { - super(new SparseArrayState((T[]) Array.newInstance(clazz, 0), dims), // - dims, DEFAULT_ORDER.strides(dims), createDimensionOffsets(dims)); - - Control.checkTrue(dims.length > 0); - } - - /** - * Alternate constructor. - */ - public ObjectSparseArray(ObjectSparseArray array) { - this(array.state, array.dims, array.strides, array.dimOffsets); - } - - /** - * Internal constructor for package use only. - */ - protected ObjectSparseArray(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets) { - super(state, dims, strides, dimOffsets); - } - - @SuppressWarnings("unchecked") - public Class getComponentType() { - return (Class) this.state.values.getClass().getComponentType(); - } - - @Override - protected ObjectSparseArray wrap(T value, int[] dims, int[] strides, int[] dimOffsets) { - - final SparseArrayState state; - - if (value == null) { - - state = new SparseArrayState(empty(), dims); - - } else { - - T[] values = Arrays.newArray(getComponentType(), Arithmetic.product(dims), value); - - state = OpKernel.insertSparse( // - empty(), dims, strides, dimOffsets, EmptyIndices, // - values, Arithmetic.range(values.length)); - } - - return new ObjectSparseArray(state, dims, strides, dimOffsets); - } - - @Override - protected ObjectSparseArray wrap(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets) { - return new ObjectSparseArray(state, dims, strides, dimOffsets); - } - - @Override - protected int length(T[] values) { - return values.length; - } - - @SuppressWarnings("unchecked") - @Override - protected T[] empty() { - return (T[]) Array.newInstance(getComponentType(), 0); - } - - @Override - public ObjectArray toDense() { - - ObjectSparseArray src = this; - - ObjectArray dst = new ObjectArray(getComponentType(), src.order(), src.dims); - - SparseArrayState srcState = src.state; - - T[] srcValues = srcState.values; - int[] srcIndices = srcState.indices; - - T[] dstValues = dst.values(); - - for (int i = 0, n = srcValues.length; i < n; i++) { - dstValues[srcIndices[i]] = srcValues[i]; - } - - return dst; - } - - @Override - public String toString() { - - SparseArrayState state = this.state; - - T[] values = state.values; - int[] indices = state.indices; - int[] dims = this.dims; - int[] strides = this.strides; - - int maxIndex = Arithmetic.max(dims); - int exponentIndex = maxIndex > 0 ? (int) Math.log10(maxIndex) : 0; - - Formatter f = new Formatter(); - - if (values.length == 0) { - - ArrayBase.formatEmptyArray(f, dims); - - return f.toString(); - } - - String valueFormat = String.format(" \"%%s\""); - String indexFormat = String.format("%%%dd", exponentIndex + 2); - - formatSparseArray(f, valueFormat, indexFormat, values, indices, strides); - - return f.toString(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/ProtoSparseArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/ProtoSparseArray.java deleted file mode 100755 index 3cf4a395..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/ProtoSparseArray.java +++ /dev/null @@ -1,555 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.sparse; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.OpKernel; -import static shared.array.ArrayBase.canonicalizeSlices; -import static shared.array.ArrayBase.createReverseSlices; - -import java.util.Arrays; - -import shared.array.Array; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * An abstract, primordial base class for all sparse arrays. - * - * @apiviz.owns shared.array.sparse.SparseArrayState - * @param - * the parameterization lower bounded by {@link ProtoSparseArray} itself. - * @param - * the storage array type. - * @param - * the element type. - * @param - * the dense array type. - * @author Roy Liu - */ -abstract public class ProtoSparseArray, V, E, D extends Array> implements - Array { - - /** - * An empty array of indices. - */ - final protected static int[] EmptyIndices = new int[] {}; - - /** - * The {@link SparseArrayState}. - */ - volatile protected SparseArrayState state; - - /** - * The dimensions. - */ - final protected int[] dims; - - /** - * The strides. - */ - final protected int[] strides; - - /** - * The dimension offsets. - */ - final protected int[] dimOffsets; - - /** - * Default constructor. - */ - protected ProtoSparseArray(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets) { - - this.state = state; - this.dims = dims; - this.strides = strides; - this.dimOffsets = dimOffsets; - } - - /** - * Creates dimension offsets from the given dimensions. - * - * @param dims - * the dimensions. - * @return the dimension offsets. - */ - final protected static int[] createDimensionOffsets(int[] dims) { - - int ndims = dims.length; - int[] dimOffsets = new int[ndims + 1]; - int dimOffset = 0; - - for (int dim = 0; dim < ndims; dim++) { - - dimOffsets[dim] = dimOffset; - dimOffset += dims[dim] + 1; - } - - dimOffsets[ndims] = dimOffset; - - return dimOffsets; - } - - /** - * Allocates a new array. - * - * @param state - * the {@link SparseArrayState}. - * @param dims - * the dimensions. - * @param strides - * the strides. - * @param dimOffsets - * the dimension offsets. - * @return the new array. - */ - abstract protected T wrap(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets); - - /** - * Allocates a new array initialized to the given value. - * - * @param value - * the initial value. - * @param dims - * the dimensions. - * @param strides - * the strides. - * @param dimOffsets - * the dimension offsets. - * @return the new array. - */ - abstract protected T wrap(E value, int[] dims, int[] strides, int[] dimOffsets); - - /** - * Gets the length of the given array. - * - * @param values - * the array. - * @return the length. - */ - abstract protected int length(V values); - - /** - * Gets an empty array of values. - */ - abstract protected V empty(); - - /** - * Converts this array to its dense form. - */ - abstract public D toDense(); - - /** - * Inserts values at the given logical indices, which are given in row major order. - * - * @param values - * the values to be inserted. - * @param logicals - * the logical indices. - * @return this array. - */ - @SuppressWarnings("unchecked") - public T insert(V values, int... logicals) { - - ProtoSparseArray src = this; - - int ndims = src.dims.length; - int newLen = length(values); - - Control.checkTrue(ndims * newLen == logicals.length, // - "Invalid arguments"); - - int[] newI = new int[newLen]; - - for (int i = 0; i < newLen; i++) { - - int physical = 0; - - for (int dim = 0; dim < ndims; dim++) { - physical += src.strides[dim] * logicals[ndims * i + dim]; - } - - newI[i] = physical; - } - - SparseArrayState srcState = src.state; - - src.state = OpKernel.insertSparse( // - srcState.values, src.dims, src.strides, src.dimOffsets, srcState.indices, // - values, newI); - - return (T) src; - } - - /** - * Gets the number of non-zero elements. - */ - public int size() { - return length(this.state.values); - } - - public T map(T dst, int... bounds) { - - ProtoSparseArray src = this; - - int ndims = Control.checkEquals(src.dims.length, dst.dims.length, // - "Dimensionality mismatch"); - - Control.checkTrue(3 * ndims == bounds.length, // - "Invalid arguments"); - - // - - int nslices = 0; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - - int size = bounds[offset + 2]; - - Control.checkTrue(size >= 0, // - "Invalid mapping parameters"); - - nslices += size; - } - - if (Arithmetic.product(src.dims) == 0 || Arithmetic.product(dst.dims) == 0) { - return dst; - } - - // - - int[] slices = new int[3 * nslices]; - - for (int dim = 0, acc = 0, offset = 0, sliceOffset = 0; dim < ndims; dim++, acc += bounds[offset + 2], offset += 3) { - - int size = bounds[offset + 2]; - - for (int j = 0, // - srcSize = src.dims[dim], // - srcOffset = (((bounds[offset]) % srcSize) + srcSize) % srcSize, // - dstSize = dst.dims[dim], // - dstOffset = (((bounds[offset + 1]) % dstSize) + dstSize) % dstSize; // - j < size; // - j++, // - srcOffset = (srcOffset + 1) % srcSize, // - dstOffset = (dstOffset + 1) % dstSize, // - sliceOffset += 3) { - - slices[sliceOffset] = srcOffset; - slices[sliceOffset + 1] = dstOffset; - slices[sliceOffset + 2] = dim; - } - } - - return splice(dst, slices); - } - - public T splice(T dst, int... slices) { - - ProtoSparseArray src = this; - - Control.checkTrue(src != dst, // - "Source and destination cannot be the same"); - - SparseArrayState srcState = src.state; - SparseArrayState dstState = dst.state; - - dst.state = OpKernel.sliceSparse(slices, // - srcState.values, src.dims, src.strides, src.dimOffsets, // - srcState.indices, srcState.indirectionOffsets, srcState.indirections, // - dstState.values, dst.dims, dst.strides, dst.dimOffsets, // - dstState.indices, dstState.indirectionOffsets, dstState.indirections); - - return dst; - } - - public T slice(int[][] srcSlices, T dst, int[][] dstSlices) { - - ProtoSparseArray src = this; - - Control.checkTrue(src != dst, // - "Source and destination cannot be the same"); - - SparseArrayState srcState = src.state; - SparseArrayState dstState = dst.state; - - dst.state = OpKernel.sliceSparse(canonicalizeSlices(srcSlices, src.dims, dstSlices, dst.dims), // - srcState.values, src.dims, src.strides, src.dimOffsets, // - srcState.indices, srcState.indirectionOffsets, srcState.indirections, // - dstState.values, dst.dims, dst.strides, dst.dimOffsets, // - dstState.indices, dstState.indirectionOffsets, dstState.indirections); - - return dst; - } - - public T slice(T dst, int[]... dstSlices) { - - ProtoSparseArray src = this; - - Control.checkTrue(src != dst, // - "Source and destination cannot be the same"); - - SparseArrayState srcState = src.state; - SparseArrayState dstState = dst.state; - - dst.state = OpKernel.sliceSparse(canonicalizeSlices(src.dims, dst.dims, dstSlices), // - srcState.values, src.dims, src.strides, src.dimOffsets, // - srcState.indices, srcState.indirectionOffsets, srcState.indirections, // - dstState.values, dst.dims, dst.strides, dst.dimOffsets, // - dstState.indices, dstState.indirectionOffsets, dstState.indirections); - - return dst; - } - - @SuppressWarnings("unchecked") - public T slice(E value, int[]... srcSlices) { - - T src = (T) this; - - int ndims = srcSlices.length; - int[] dstDims = new int[ndims]; - - for (int dim = 0; dim < ndims; dim++) { - dstDims[dim] = srcSlices[dim].length; - } - - return wrap(value, dstDims, src.order().strides(dstDims), createDimensionOffsets(dstDims)) // - .slice(src, srcSlices); - } - - public T slice(int[]... srcSlices) { - - ProtoSparseArray src = this; - - int ndims = Control.checkEquals(src.dims.length, srcSlices.length, // - "Dimensionality mismatch"); - - int nslices = 0; - int[] dstDims = new int[ndims]; - - for (int dim = 0; dim < ndims; dim++) { - nslices += (dstDims[dim] = srcSlices[dim].length); - } - - T dst = wrap((E) null, dstDims, src.order().strides(dstDims), createDimensionOffsets(dstDims)); - - SparseArrayState srcState = src.state; - SparseArrayState dstState = dst.state; - - dst.state = OpKernel.sliceSparse(canonicalizeSlices(nslices, src.dims, srcSlices), // - srcState.values, src.dims, src.strides, src.dimOffsets, // - srcState.indices, srcState.indirectionOffsets, srcState.indirections, // - dstState.values, dst.dims, dst.strides, dst.dimOffsets, // - dstState.indices, dstState.indirectionOffsets, dstState.indirections); - - return dst; - } - - public T tile(int... repetitions) { - - ProtoSparseArray src = this; - - int ndims = Control.checkEquals(src.dims.length, repetitions.length, // - "Dimensionality mismatch"); - - int[] newDims = src.dims.clone(); - - for (int dim = 0; dim < ndims; dim++) { - newDims[dim] *= repetitions[dim]; - } - - T dst = wrap((E) null, newDims, src.order().strides(newDims), createDimensionOffsets(newDims)); - - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - mappingBounds[offset + 2] = dst.dims[dim]; - } - - return map(dst, mappingBounds); - } - - public T transpose(int... permutation) { - - ProtoSparseArray src = this; - - int ndims = Control.checkEquals(src.dims.length, permutation.length, // - "Dimensionality mismatch"); - - int[] newDims = new int[ndims]; - int[] copy = permutation.clone(); - - Arrays.sort(copy); - - for (int dim = 0; dim < ndims; dim++) { - - newDims[permutation[dim]] = src.dims[dim]; - - Control.checkTrue(copy[dim] == dim, // - "Invalid permutation"); - } - - SparseArrayState srcState = src.state; - - int nindices = srcState.indices.length; - int[] newStrides = src.order().strides(newDims); - int[] newDimOffsets = createDimensionOffsets(newDims); - int[] newIndices = new int[nindices]; - - for (int i = 0; i < nindices; i++) { - - int newPhysical = 0; - int physical = srcState.indices[i]; - - for (int dim = 0; dim < ndims; dim++) { - - newPhysical += newStrides[permutation[dim]] * (physical / src.strides[dim]); - physical %= src.strides[dim]; - } - - newIndices[i] = newPhysical; - } - - return wrap(OpKernel.insertSparse( // - empty(), newDims, newStrides, newDimOffsets, EmptyIndices, // - srcState.values, newIndices), newDims, newStrides, newDimOffsets); - } - - public T shift(int... shifts) { - - ProtoSparseArray src = this; - - int ndims = Control.checkEquals(src.dims.length, shifts.length, // - "Dimensionality mismatch"); - - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 3) { - - mappingBounds[offset + 1] = shifts[dim]; - mappingBounds[offset + 2] = src.dims[dim]; - } - - return map(wrap((E) null, src.dims, src.strides, src.dimOffsets), mappingBounds); - } - - public T subarray(int... bounds) { - - ProtoSparseArray src = this; - - int ndims = src.dims.length; - - Control.checkTrue(ndims * 2 == bounds.length, // - "Invalid subarray bounds"); - - int[] newDims = new int[ndims]; - int[] mappingBounds = new int[3 * ndims]; - - for (int dim = 0; dim < ndims; dim++) { - - int lower = bounds[2 * dim]; - int upper = bounds[2 * dim + 1]; - - newDims[dim] = upper - lower; - mappingBounds[3 * dim] = lower; - mappingBounds[3 * dim + 2] = newDims[dim]; - } - - return map(wrap((E) null, newDims, src.order().strides(newDims), createDimensionOffsets(newDims)), // - mappingBounds); - } - - public T reverse(int... selectedDims) { - - ProtoSparseArray src = this; - - T dst = wrap((E) null, src.dims, src.strides, src.dimOffsets); - - SparseArrayState srcState = src.state; - SparseArrayState dstState = dst.state; - - dst.state = OpKernel.sliceSparse(createReverseSlices(src.dims, selectedDims), // - srcState.values, src.dims, src.strides, src.dimOffsets, // - srcState.indices, srcState.indirectionOffsets, srcState.indirections, // - dstState.values, dst.dims, dst.strides, dst.dimOffsets, // - dstState.indices, dstState.indirectionOffsets, dstState.indirections); - - return dst; - } - - public T reshape(int... dims) { - - ProtoSparseArray src = this; - - Control.checkTrue(Arithmetic.product(dims) == Arithmetic.product(src.dims), // - "Cardinality mismatch"); - - int[] strides = src.order().strides(dims); - int[] dimOffsets = createDimensionOffsets(dims); - - SparseArrayState srcState = src.state; - - T dst = wrap(OpKernel.insertSparse( // - empty(), dims, strides, dimOffsets, EmptyIndices, // - srcState.values, srcState.indices), dims, strides, dimOffsets); - - return dst; - } - - @SuppressWarnings("unchecked") - @Override - public T clone() { - - try { - - return (T) super.clone(); - - } catch (CloneNotSupportedException e) { - - throw new RuntimeException(e); - } - } - - public IndexingOrder order() { - return DEFAULT_ORDER; - } - - public int size(int i) { - return this.dims[i]; - } - - public int stride(int i) { - return this.strides[i]; - } - - public int ndims() { - return this.dims.length; - } - - public int[] dimensions() { - return this.dims.clone(); - } - - public int[] strides() { - return this.strides.clone(); - } - - public T reverseOrder() { - throw new UnsupportedOperationException("Sparse arrays always have row major indexing"); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/RealSparseArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/RealSparseArray.java deleted file mode 100755 index 79d9bf03..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/RealSparseArray.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.sparse; - -import static shared.array.ArrayBase.DEFAULT_ORDER; -import static shared.array.ArrayBase.FIELD_PRECISION; -import static shared.array.ArrayBase.FIELD_WIDTH; -import static shared.array.ArrayBase.OpKernel; -import static shared.array.ArrayBase.formatRescale; -import static shared.array.ArrayBase.formatSparseArray; - -import java.util.Formatter; - -import shared.array.ArrayBase; -import shared.array.RealArray; -import shared.util.Arithmetic; -import shared.util.Arrays; -import shared.util.Control; - -/** - * A sparse real array class. - * - * @author Roy Liu - */ -public class RealSparseArray extends ProtoSparseArray { - - /** - * An empty array. - */ - final protected static double[] Empty = new double[] {}; - - /** - * Default constructor. - */ - public RealSparseArray(int... dims) { - this(0, dims.clone()); - } - - /** - * Internal constructor with a distinctive signature. - */ - protected RealSparseArray(int unused, int[] dims) { - super(new SparseArrayState(Empty, dims), // - dims, DEFAULT_ORDER.strides(dims), createDimensionOffsets(dims)); - - Control.checkTrue(dims.length > 0); - } - - /** - * Alternate constructor. - */ - public RealSparseArray(RealSparseArray array) { - this(array.state, array.dims, array.strides, array.dimOffsets); - } - - /** - * Internal constructor for package use only. - */ - protected RealSparseArray(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets) { - super(state, dims, strides, dimOffsets); - } - - public Class getComponentType() { - return Double.class; - } - - @Override - protected RealSparseArray wrap(Double value, int[] dims, int[] strides, int[] dimOffsets) { - - final SparseArrayState state; - - if (value == null) { - - state = new SparseArrayState(Empty, dims); - - } else { - - double[] values = Arrays.newArray(Arithmetic.product(dims), value.doubleValue()); - - state = OpKernel.insertSparse( // - Empty, dims, strides, dimOffsets, EmptyIndices, // - values, Arithmetic.range(values.length)); - } - - return new RealSparseArray(state, dims, strides, dimOffsets); - } - - @Override - protected RealSparseArray wrap(SparseArrayState state, int[] dims, int[] strides, int[] dimOffsets) { - return new RealSparseArray(state, dims, strides, dimOffsets); - } - - @Override - protected int length(double[] values) { - return values.length; - } - - @Override - protected double[] empty() { - return Empty; - } - - @Override - public RealArray toDense() { - - RealSparseArray src = this; - - RealArray dst = new RealArray(src.order(), src.dims); - - SparseArrayState srcState = src.state; - - double[] srcValues = srcState.values; - int[] srcIndices = srcState.indices; - - double[] dstValues = dst.values(); - - for (int i = 0, n = srcValues.length; i < n; i++) { - dstValues[srcIndices[i]] = srcValues[i]; - } - - return dst; - } - - @Override - public String toString() { - - SparseArrayState state = this.state; - - double[] values = state.values; - int[] indices = state.indices; - int[] dims = this.dims; - int[] strides = this.strides; - - int exponent = (int) Math.log10(Arithmetic.max( // - Arithmetic.max(values), Math.abs(Arithmetic.min(values)), 1e-128)); - - int maxIndex = Arithmetic.max(dims); - int exponentIndex = maxIndex > 0 ? (int) Math.log10(maxIndex) : 0; - - Formatter f = new Formatter(); - - if (values.length == 0) { - - ArrayBase.formatEmptyArray(f, dims); - - return f.toString(); - } - - String valueFormat = String.format("%%%d.%df", FIELD_WIDTH, FIELD_PRECISION); - String indexFormat = String.format("%%%dd", exponentIndex + 2); - - formatSparseArray(f, valueFormat, indexFormat, formatRescale(f, exponent, values), indices, strides); - - return f.toString(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/SparseArrayState.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/SparseArrayState.java deleted file mode 100755 index 96504dbe..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/SparseArrayState.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.array.sparse; - -import shared.util.Arithmetic; - -/** - * A container class for sparse array state. - * - * @param - * the storage array type. - * @author Roy Liu - */ -public class SparseArrayState { - - /** - * An empty array. - */ - final protected static int[] Empty = new int[] {}; - - /** - * The values. - */ - final protected V values; - - /** - * The physical indices. - */ - final protected int[] indices; - - /** - * The offsets into {@link #indirections}. - */ - final protected int[] indirectionOffsets; - - /** - * The indirection indices into {@link #values} and {@link #indices}. - */ - final protected int[] indirections; - - /** - * Default constructor. - */ - public SparseArrayState(V values, int[] indices, int[] indirectionOffsets, int[] indirections) { - - this.values = values; - this.indices = indices; - this.indirectionOffsets = indirectionOffsets; - this.indirections = indirections; - } - - /** - * Alternate constructor. - */ - public SparseArrayState(V emptyValues, int[] dims) { - - this.values = emptyValues; - this.indices = Empty; - this.indirectionOffsets = new int[Arithmetic.sum(dims) + dims.length]; - this.indirections = Empty; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/package-info.java deleted file mode 100755 index 0593334a..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/array/sparse/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of multidimensional sparse arrays. - */ -package shared.array.sparse; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/EnumStatus.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/EnumStatus.java deleted file mode 100755 index a2d0f965..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/EnumStatus.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -/** - * Defines a mutable, enumerated state. - * - * @param - * the enumeration type. - */ -public interface EnumStatus> { - - /** - * Gets the status. - */ - public T getStatus(); - - /** - * Sets the status. - */ - public void setStatus(T status); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/EnumType.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/EnumType.java deleted file mode 100755 index 69036f84..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/EnumType.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -/** - * Defines an enumerated type. - * - * @param - * the enumeration type. - */ -public interface EnumType> { - - /** - * Gets the type. - */ - public T getType(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/Event.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/Event.java deleted file mode 100755 index 2e78de09..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/Event.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2005 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -/** - * Defines functionality that can be expected from all events. - * - * @apiviz.owns shared.event.Source - * @param - * the parameterization lower bounded by {@link Event} itself. - * @param - * the {@link Event} enumeration type. - * @param - * the {@link Source} enumeration type. - * @author Roy Liu - */ -public interface Event, E extends Enum, S extends Enum> extends EnumType { - - /** - * Gets the {@link Source} from which this event originated. - */ - public Source getSource(); - - /** - * Gets the {@link Event} type. - */ - public E getType(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/Handler.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/Handler.java deleted file mode 100755 index 337d7724..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/Handler.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2005 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -/** - * Defines a handler for generic objects. - * - * @param - * the object type. - * @author Roy Liu - */ -public interface Handler { - - /** - * Handles a generic object. - */ - public void handle(T value); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/Processor.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/Processor.java deleted file mode 100755 index 2bb51d64..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/Processor.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2005 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -import java.io.Closeable; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - -import shared.util.Control; -import shared.util.CoreThread; -import shared.util.Finalizable; - -/** - * A base class for a thread repetitively going through the event processing motions {@link BlockingQueue#take()} - * (fetch), {@link Event#getSource()} (see who it's from), {@link Source#getHandler()} (see how the source wishes to - * process events), and {@link Handler#handle(Object)} (process the event). - * - * @apiviz.composedOf shared.event.Processor.ProcessorThread - * @param - * the parameterization lower bounded by {@link Event} itself. - * @author Roy Liu - */ -public class Processor> implements SourceLocal, Finalizable>, Closeable { - - final ProcessorThread thread; - - /** - * Default constructor. - */ - public Processor(String name) { - this.thread = new ProcessorThread(name); - } - - /** - * Shuts down the internal thread. - */ - public void close() { - - this.thread.run = false; - this.thread.interrupt(); - } - - public void onLocal(T evt) { - this.thread.eq.add(evt); - } - - public Processor setFinalizer(Runnable finalizer) { - - Control.checkTrue(finalizer != null, // - "Finalizer must be non-null"); - - this.thread.finalizer = finalizer; - - return this; - } - - /** - * Gets the name of the underlying {@link ProcessorThread}. - */ - @Override - public String toString() { - return this.thread.toString(); - } - - /** - * Checks that {@link Thread#currentThread()} is indeed this processor's internal thread. Helpful for enforcing a - * serial event processing model. - */ - public void checkCurrentThread() { - Control.checkTrue(Thread.currentThread() == this.thread, // - "Expected call from within processor thread"); - } - - /** - * A worker thread class for processing events. - * - * @param - * the parameterization lower bounded by {@link Event} itself. - */ - final protected static class ProcessorThread> extends CoreThread { - - final BlockingQueue eq; - - volatile Runnable finalizer; - volatile boolean run; - - /** - * Default constructor. - */ - protected ProcessorThread(String name) { - super(name); - - this.eq = new LinkedBlockingQueue(); - - this.finalizer = Control.NullRunnable; - this.run = true; - - setDaemon(true); - start(); - } - - /** - * Runs the event processing loop. - */ - @Override - protected void runUnchecked() { - - for (; this.run;) { - - try { - - T evt = this.eq.take(); - evt.getSource().getHandler().handle(evt); - - } catch (InterruptedException e) { - } - } - } - - @Override - protected void runFinalizer() { - this.finalizer.run(); - } - } - - // A finalizer guardian for the processor thread. - final Object threadReaper = new Object() { - - @Override - protected void finalize() { - Control.close(Processor.this); - } - }; -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/Source.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/Source.java deleted file mode 100755 index c5b03804..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/Source.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2005 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -import java.io.Closeable; - -/** - * Defines an originator of {@link Event}s. - * - * @param - * the parameterization lower bounded by {@link Event} itself. - * @param - * the {@link Source} enumeration type. - * @author Roy Liu - */ -public interface Source, S extends Enum> extends SourceLocal, SourceRemote, - EnumType, Closeable { - - /** - * Gets the {@link Handler} that will process incoming {@link Event}s. - */ - public Handler getHandler(); - - /** - * Sets the {@link Handler} that will process incoming {@link Event}s. - */ - public void setHandler(Handler handler); - - /** - * Overrides {@link Closeable#close()} so that it doesn't throw an exception. - */ - public void close(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/SourceLocal.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/SourceLocal.java deleted file mode 100755 index b8850589..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/SourceLocal.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2005 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -/** - * Defines the local manifestation of an originator {@link Event}s. - * - * @param - * the parameterization lower bounded by {@link Event} itself. - * @author Roy Liu - */ -public interface SourceLocal> { - - /** - * Delivers an {@link Event} to the local manifestation. - */ - public void onLocal(T evt); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/SourceRemote.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/SourceRemote.java deleted file mode 100755 index 7f4fc558..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/SourceRemote.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2005 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -/** - * Defines the local manifestation of an originator {@link Event}s. - * - * @param - * the parameterization lower bounded by {@link Event} itself. - * @author Roy Liu - */ -public interface SourceRemote> { - - /** - * Delivers an {@link Event} to the remote manifestation. - */ - public void onRemote(T evt); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/StateProcessor.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/StateProcessor.java deleted file mode 100755 index aab2b0e3..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/StateProcessor.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -/** - * A state-based {@link Processor} subclass that is a {@link Source} in itself. - * - * @apiviz.owns shared.event.StateTable - * @param - * the parameterization lower bounded by {@link Event} itself. - * @param - * the {@link Event} enumeration type. - * @param - * the {@link Source} enumeration type. - * @author Roy Liu - */ -abstract public class StateProcessor, E extends Enum, S extends Enum> extends - Processor implements Source, Handler { - - /** - * Default constructor. - */ - public StateProcessor(String name) { - super(name); - } - - public Handler getHandler() { - return this; - } - - public void onRemote(T evt) { - throw new UnsupportedOperationException(); - } - - public void setHandler(Handler handler) { - throw new UnsupportedOperationException(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/StateTable.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/StateTable.java deleted file mode 100755 index 392fc706..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/StateTable.java +++ /dev/null @@ -1,305 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2005 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import shared.array.ObjectArray; -import shared.event.Transitions.Transition; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A finite state machine class. - * - * @apiviz.composedOf shared.event.StateTable.StateHandler - * @apiviz.has shared.event.Transitions - - - argument - * @apiviz.has shared.event.Event - - - event - * @param - * the state enumeration type. - * @param - * the {@link Event} enumeration type. - * @param - * the parameterization lower bounded by {@link Event} itself. - * @author Roy Liu - */ -public class StateTable, Y extends Enum, Z extends Event> { - - /** - * An array of all four wildcard combinations. - */ - final protected static String[] WildcardCombinations = new String[] { "**", "* ", " *", " " }; - - final ObjectArray backingArray; - - /** - * Default constructor. - */ - @SuppressWarnings("unchecked") - public StateTable(Object target, Class stateClass, Class eventTypeClass, String group) { - - this.backingArray = new ObjectArray( // - StateHandler.class, // - stateClass.getEnumConstants().length, // - eventTypeClass.getEnumConstants().length); - - final Map> handlersMap = // - new HashMap>(); - - for (String str : WildcardCombinations) { - handlersMap.put(str, new ArrayList()); - } - - for (Class clazz = target.getClass(); clazz != null // - && !clazz.getName().startsWith("java.") // - && !clazz.getName().startsWith("javax."); clazz = clazz.getSuperclass()) { - - outerLoop: for (Field field : clazz.getDeclaredFields()) { - - Transitions ts = field.getAnnotation(Transitions.class); - Transition t = field.getAnnotation(Transition.class); - - Control.checkTrue(ts == null || t == null, // - "Transition and Transitions annotations cannot occur simultaneously"); - - final Transition[] transitions; - - if (ts != null) { - - transitions = ts.transitions(); - - } else if (t != null) { - - transitions = new Transition[] { t }; - - } else { - - continue outerLoop; - } - - final Object obj; - - field.setAccessible(true); - - try { - - obj = field.get(target); - - } catch (IllegalAccessException e) { - - throw new RuntimeException(e); - - } finally { - - field.setAccessible(false); - } - - Control.checkTrue(obj instanceof Handler, // - "Field does not reference an event handler"); - - final Handler handler = (Handler) obj; - final String name = field.getName(); - - innerLoop: for (Transition transition : transitions) { - - if (!transition.group().equals(group)) { - continue innerLoop; - } - - X currentState = !transition.currentState().equals("*") ? Enum.valueOf( // - stateClass, transition.currentState()) : null; - Y eventType = !transition.eventType().equals("*") ? Enum.valueOf( // - eventTypeClass, transition.eventType()) : null; - - final StateHandler stateHandler; - - if (!transition.nextState().equals("")) { - - final X nextState = Enum.valueOf(stateClass, transition.nextState()); - - stateHandler = new StateHandler(currentState, eventType) { - - @Override - public void handle(EnumStatus stateObj, Z evt) { - - handler.handle(evt); - stateObj.setStatus(nextState); - } - - @Override - public String toString() { - return String.format("%s -> %s : %s", // - super.toString(), nextState, name); - } - }; - - } else { - - stateHandler = new StateHandler(currentState, eventType) { - - @Override - public void handle(EnumStatus stateObj, Z evt) { - handler.handle(evt); - } - - @Override - public String toString() { - return String.format("%s : %s", // - super.toString(), name); - } - }; - } - - final String key; - - if (currentState == null && eventType == null) { - - key = "**"; - - } else if (currentState == null && eventType != null) { - - key = "* "; - - } else if (currentState != null && eventType == null) { - - key = " *"; - - } else { - - key = " "; - } - - handlersMap.get(key).add(stateHandler); - } - } - } - - int[] rowRange = Arithmetic.range(this.backingArray.size(0)); - int[] colRange = Arithmetic.range(this.backingArray.size(1)); - - for (String key : WildcardCombinations) { - - for (StateHandler stateHandler : handlersMap.get(key)) { - - int[][] slices = new int[][] { - // - (stateHandler.state != null) ? new int[] { stateHandler.state // - .ordinal() } : rowRange, // - (stateHandler.eventType != null) ? new int[] { stateHandler.eventType // - .ordinal() } : colRange // - }; - - this.backingArray.slice(stateHandler, slices); - } - } - } - - /** - * Alternate constructor. - */ - public StateTable(Object target, Class stateClass, Class eventTypeClass) { - this(target, stateClass, eventTypeClass, ""); - } - - /** - * Creates a human-readable representation of this table. - */ - @Override - public String toString() { - - StringBuilder sb = new StringBuilder(); - - int nrows = this.backingArray.size(0); - int ncols = this.backingArray.size(1); - - for (int i = 0; i < nrows; i++) { - - for (int j = 0; j < ncols; j++) { - - StateHandler stateHandler = this.backingArray.get(i, j); - - if (stateHandler != null) { - sb.append(stateHandler).append(Control.LineSeparator); - } - } - } - - return sb.toString(); - } - - /** - * Looks up and handles an {@link Event} based on the current state and the event type. - * - * @param stateObj - * the {@link EnumStatus} object. - * @param evt - * the {@link Event}. - */ - public void lookup(EnumStatus stateObj, Z evt) { - - StateHandler handler = this.backingArray.get(stateObj.getStatus().ordinal(), evt.getType().ordinal()); - - if (handler != null) { - handler.handle(stateObj, evt); - } - } - - /** - * Defines an {@link Event} handler that may mutate {@link EnumStatus} objects. - */ - abstract protected class StateHandler { - - /** - * The state. - */ - final protected X state; - - /** - * The event type. - */ - final protected Y eventType; - - /** - * Default constructor. - */ - protected StateHandler(X state, Y eventType) { - - this.state = state; - this.eventType = eventType; - } - - /** - * Creates a human-readable representation of this handler. - */ - @Override - public String toString() { - return String.format("(%s, %s)", // - (this.state != null) ? this.state : "*", // - (this.eventType != null) ? this.eventType : "*"); - } - - /** - * Handles an {@link Event}. May optionally mutate the given {@link EnumStatus} object. - */ - abstract protected void handle(EnumStatus state, Z evt); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/Transitions.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/Transitions.java deleted file mode 100755 index 11456d03..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/Transitions.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An annotation class for specifying finite state machine transitions. Inspired by Apache MINA's StateMachine construct. - * - * @apiviz.owns shared.event.Transitions.Transition - * @author Roy Liu - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Transitions { - - /** - * Gets the {@link Transition}s. - */ - public Transition[] transitions(); - - /** - * An annotation for a single transition. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - public @interface Transition { - - /** - * The current state. - */ - String currentState(); - - /** - * The {@link Event} type. - */ - String eventType(); - - /** - * The next state. - */ - String nextState() default ""; - - /** - * The group name. - */ - String group() default ""; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/XMLEvent.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/XMLEvent.java deleted file mode 100755 index fade428a..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/XMLEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.event; - -import org.w3c.dom.Element; - -/** - * An abstract base class for all XML-derived events. - * - * @param - * the parameterization lower bounded by {@link XMLEvent} itself. - * @param - * the {@link XMLEvent} enumeration type. - * @param - * the {@link Source} enumeration type. - * @author Roy Liu - */ -abstract public class XMLEvent, E extends Enum, S extends Enum> implements - Event { - - final E type; - - /** - * Default constructor. - */ - protected XMLEvent(E type) { - this.type = type; - } - - public E getType() { - return this.type; - } - - /** - * Transforms this event into an XML DOM {@link Element}. - */ - abstract public Element toDOM(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/event/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/event/package-info.java deleted file mode 100755 index 4acc6dee..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/event/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A framework for event-driven programming. - */ -package shared.event; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/Cacheable.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/Cacheable.java deleted file mode 100755 index 476adbe1..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/Cacheable.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.fft; - -/** - * Marks an array as being suitable for having its FFT cached. - * - * @author Roy Liu - */ -public interface Cacheable { -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/ConvolutionCache.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/ConvolutionCache.java deleted file mode 100755 index bd4b7b18..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/ConvolutionCache.java +++ /dev/null @@ -1,233 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.fft; - -import shared.array.AbstractArray; -import shared.array.ComplexArray; -import shared.array.RealArray; -import shared.util.Control; - -/** - * A specialization of {@link FFTCache} for {@link RealArray}s and {@link ComplexArray}s. - * - * @apiviz.owns shared.fft.Cacheable - * @author Roy Liu - */ -public class ConvolutionCache extends FFTCache { - - /** - * A global instance. - */ - protected static ConvolutionCache Instance = null; - - /** - * Gets the global instance. - */ - final public static ConvolutionCache getInstance() { - - if (Instance == null) { - Instance = new ConvolutionCache(); - } - - return Instance; - } - - /** - * Performs convolution in the complex domain. - * - * @param cIm - * the already transformed image. - * @param ker - * the kernel. - * @return the convolution result. - */ - public ComplexArray convolve(ComplexArray cIm, ComplexArray ker) { - - int[] dimsT = cIm.dimensions(); - ComplexArray res = (cIm.eMul(ker instanceof Cacheable ? get(ker, dimsT) // - : createCacheable(ker, dimsT))).ifft(); - - int[] dims = res.dimensions(); - int ndims = dims.length; - int[] bounds = new int[ndims * 2]; - - for (int i = 0, n = ndims - 1; i < n; i++) { - Control.checkTrue((bounds[2 * i + 1] = dims[i] - ker.size(i) + 1) > 0, // - "Invalid kernel size"); - } - - bounds[bounds.length - 1] = 2; - - return res.subarray(bounds); - } - - /** - * Performs convolution in the real domain. - * - * @param cIm - * the already transformed image. - * @param ker - * the kernel. - * @return the convolution result. - */ - public RealArray convolve(ComplexArray cIm, RealArray ker) { - - int[] dimsT = cIm.rifftDimensions(); - RealArray res = (cIm.eMul(ker instanceof Cacheable ? get(ker, dimsT) // - : createCacheable(ker, dimsT))).rifft(); - - int[] dims = res.dimensions(); - int ndims = dims.length; - int[] bounds = new int[ndims * 2]; - - for (int dim = 0; dim < ndims; dim++) { - bounds[2 * dim + 1] = dims[dim] - ker.size(dim) + 1; - } - - return res.subarray(bounds); - } - - @Override - protected > ComplexArray createCacheable(A array, int[] dims) { - - int ndims = dims.length; - int[] bounds = new int[ndims * 3]; - - for (int dim = 0; dim < ndims; dim++) { - bounds[3 * dim + 2] = array.size(dim); - } - - if (array instanceof RealArray) { - - return ((RealArray) array).map(new RealArray(dims), bounds).rfft().uConj(); - - } else if (array instanceof ComplexArray) { - - return ((ComplexArray) array).map(new ComplexArray(dims), bounds).fft().uConj(); - - } else { - - throw new RuntimeException("Invalid array type"); - } - } - - /** - * Pads an image in an extrapolative way. - * - * @param im - * the intensity image. - * @param margins - * the padding margins. - * @return the padded result. - */ - final public static RealArray pad(RealArray im, int... margins) { - - int ndims = im.ndims(); - int[] dims = im.dimensions(); - int[] newDims = dims.clone(); - - Control.checkTrue(dims.length == margins.length, // - "Dimensionality mismatch"); - - for (int dim = 0; dim < ndims; dim++) { - newDims[dim] += 2 * margins[dim]; - } - - RealArray res = new RealArray(newDims); - - // Slice for all partitions of dimensions into corners and edges. - - Control.checkTrue(ndims <= 16, // - "Too many dimensions"); - - for (int i = 0, n = (1 << ndims), cdi = 0, edi = 0; i < n; i++, cdi = 0, edi = 0) { - - int ncornerDims = Integer.bitCount(i); - int nedgeDims = ndims - ncornerDims; - - int[] cornerDimIndices = new int[ncornerDims]; - int[] edgeDimIndices = new int[nedgeDims]; - - int nedgeSlices = 0; - - for (int dim = 0; dim < ndims; dim++) { - - if (((i >>> dim) & 0x1) == 0x1) { - - cornerDimIndices[cdi++] = dim; - - } else { - - nedgeSlices += dims[edgeDimIndices[edi++] = dim]; - } - } - - // - - int nmarginIndices = 0; - - for (int j = 0; j < ncornerDims; j++) { - nmarginIndices += margins[cornerDimIndices[j]]; - } - - int[] slices = new int[6 * nmarginIndices + 3 * nedgeSlices]; - - for (int j = 0, base = 0, offset = 3 * nmarginIndices; j < ncornerDims; j++) { - - int dim = cornerDimIndices[j]; - int size = dims[dim]; - int margin = margins[dim]; - - for (int k = 0; k < margin; k++, base += 3) { - - slices[base] = k; - slices[base + 1] = margin - 1 - k; - slices[base + 2] = dim; - - slices[offset + base] = size - margin + k; - slices[offset + base + 1] = size + 2 * margin - 1 - k; - slices[offset + base + 2] = dim; - } - } - - for (int j = 0, base = 0, offset = 6 * nmarginIndices; j < nedgeDims; j++) { - - int dim = edgeDimIndices[j]; - int size = dims[dim]; - int margin = margins[dim]; - - for (int k = 0; k < size; k++, base += 3) { - - slices[offset + base] = k; - slices[offset + base + 1] = margin + k; - slices[offset + base + 2] = dim; - } - } - - // - - im.splice(res, slices); - } - - return res; - } - - // Dummy constructor. - ConvolutionCache() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTCache.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTCache.java deleted file mode 100755 index fef3bccc..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTCache.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
http://www.gnu.org/licenses/. - */ - -package shared.fft; - -import java.lang.ref.Reference; -import java.util.Arrays; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import shared.array.AbstractArray; -import shared.util.ReferenceReaper; -import shared.util.ReferenceReaper.ReferenceType; - -/** - * A class for thread-safe caching of padded and FFT'd convolution kernels. - * - * @apiviz.composedOf shared.fft.FFTCache.CacheKey - * @param - * the complex array type. - * @param - * the real array type. - * @author Roy Liu - */ -abstract public class FFTCache, R extends AbstractArray> { - - final ConcurrentMap> kernelMap; - final ReferenceReaper rr; - - /** - * Default constructor. - */ - public FFTCache() { - - this.kernelMap = new ConcurrentHashMap>(); - this.rr = new ReferenceReaper(); - } - - /** - * Delegates to {@link ConcurrentHashMap#toString()}. - */ - @Override - public String toString() { - return this.kernelMap.toString(); - } - - /** - * Attempts to retrieve a cached, padded, and FFT'd companion of the given {@link AbstractArray}. - * - * @param tag - * the query key. - * @param dims - * the size of the cached result. - * @param - * the query array type. - * @return the cached result, or a newly created and inserted one. - */ - public > C get(A tag, int... dims) { - - final CacheKey key = new CacheKey(tag, dims); - - Reference ref = this.kernelMap.get(key); - - C kernel = (ref != null) ? ref.get() : null; - - if (kernel == null) { - - kernel = createCacheable(tag, dims); - this.rr.register(ReferenceType.SOFT, kernel, this.kernelMap, key); - } - - return kernel; - } - - /** - * Creates an instance of the complex array type. - * - * @param array - * the query key. - * @param dims - * the size of the cached result. - * @param - * the query array type. - * @return an instance of the complex array type. - */ - abstract protected > C createCacheable(A array, int[] dims); - - /** - * A lookup key class for cached kernels. - */ - protected class CacheKey { - - final AbstractArray tag; - final int[] dims; - - /** - * Default constructor. - */ - protected CacheKey(AbstractArray tag, int[] dims) { - - this.tag = tag; - this.dims = dims; - } - - /** - * Computes the xor of the hash codes of the array and the padded dimensions. - */ - @Override - public int hashCode() { - return this.tag.hashCode() ^ Arrays.hashCode(this.dims); - } - - /** - * Checks for equality on the array and the padded dimensions. - */ - @Override - public boolean equals(Object o) { - - CacheKey key = (CacheKey) o; - return key.tag.equals(this.tag) && Arrays.equals(key.dims, this.dims); - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTOps.java deleted file mode 100755 index cef96d93..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTOps.java +++ /dev/null @@ -1,260 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
http://www.gnu.org/licenses/.
- *
- * This file is derived from previous work, whose license terms are attached.
- *
- * Copyright (c) 2003-2006 Mark Borgerding
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the - * following conditions are met: - *

    - *
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer.
  • - *
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other materials provided with the distribution.
  • - *
  • Neither the author nor the names of any contributors may be used to endorse or promote products derived from this - * software without specific prior written permission.
  • - *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package shared.fft; - -import java.util.ArrayList; - -import shared.util.Arithmetic; - -/** - * A class of mixed-radix FFT operations in support of {@link JavaFFTService}. - * - * @author Roy Liu - */ -public class FFTOps { - - /** - * An FFT operation in support of {@link JavaFFTService#fft(int[], double[], double[])}. Very slow and unoptimized; - * for demonstration purposes only. - * - * @param direction - * the transform direction. - * @param dims - * the array dimensions. - * @param in - * the in array. - * @param out - * the out array. - */ - final public static void fft(int direction, int[] dims, double[] in, double[] out) { - - int ndims = dims.length; - int len = Arithmetic.product(dims); - - double[] outTmp = new double[len << 1]; - double[] scratch = new double[len << 1]; - - System.arraycopy(in, 0, out, 0, len << 1); - - for (int dim = 0; dim < ndims; dim++) { - - int dimSize = dims[dim]; - int dimStride = len / dimSize; - - int[] factors = createFactors(dimSize); - double[] twiddles = createTwiddles(dimSize, direction); - - int srcOffsetIncr = 2; - int dstOffsetIncr = dimSize << 1; - - for (int j = 0, srcOffset = 0, dstOffset = 0; j < dimStride; // - j++, srcOffset += srcOffsetIncr, dstOffset += dstOffsetIncr) { - fft(out, srcOffset, outTmp, dstOffset, scratch, // - factors, 0, twiddles, dimSize, dimStride, 1); - } - - System.arraycopy(outTmp, 0, out, 0, len << 1); - } - - switch (direction) { - - case +1: - break; - - case -1: - - double factor = 1.0 / len; - - for (int i = 0, offset = 0; i < len; i++, offset += 2) { - - out[offset] *= factor; - out[offset + 1] *= factor; - } - - break; - - default: - throw new IllegalArgumentException("Invalid transform direction"); - } - } - - /** - * Creates a prime factorization and stride modifiers array. - */ - final protected static int[] createFactors(int num) { - - ArrayList factors = new ArrayList(); - - int p = 2; - int upper = (int) Math.floor(Math.sqrt(num)); - - do { - - for (; num % p != 0;) { - - switch (p) { - - case 1: - p = 1; - break; - - default: - p += 2; - break; - } - - p = p > upper ? num : p; - } - - num /= p; - - factors.add(p); - factors.add(num); - - } while (num > 1); - - int[] res = new int[factors.size()]; - - for (int i = 0, n = res.length; i < n; i++) { - res[i] = factors.get(i); - } - - return res; - } - - /** - * Creates an array of twiddle factors. - */ - final protected static double[] createTwiddles(int n, int direction) { - - double[] res = new double[n << 1]; - - for (int i = 0, offset = 0; i < n; i++, offset += 2) { - - double phase = (-2 * direction * Math.PI * i) / n; - - res[offset] = Math.cos(phase); - res[offset + 1] = Math.sin(phase); - } - - return res; - } - - /** - * The main mixed-radix FFT procedure. - */ - final protected static void fft(double[] src, int srcOffset, double[] dst, int dstOffset, double[] scratch, // - int[] factors, int factorIndexCurrent, double[] twiddles, // - int size, int stride, int strideCurrent) { - - int p = factors[factorIndexCurrent]; - int m = factors[factorIndexCurrent + 1]; - - int srcOffsetIncr = (strideCurrent * stride) << 1; - int dstOffsetIncr = m << 1; - int upper = dstOffset + ((p * m) << 1); - - if (m == 1) { - - for (int srcOffsetCurrent = srcOffset, dstOffsetCurrent = dstOffset; dstOffsetCurrent < upper; // - srcOffsetCurrent += srcOffsetIncr, dstOffsetCurrent += 2) { - - dst[dstOffsetCurrent] = src[srcOffsetCurrent]; - dst[dstOffsetCurrent + 1] = src[srcOffsetCurrent + 1]; - } - - } else { - - for (int srcOffsetCurrent = srcOffset, dstOffsetCurrent = dstOffset; dstOffsetCurrent < upper; // - srcOffsetCurrent += srcOffsetIncr, dstOffsetCurrent += dstOffsetIncr) { - fft(src, srcOffsetCurrent, dst, dstOffsetCurrent, scratch, // - factors, factorIndexCurrent + 2, twiddles, // - size, stride, strideCurrent * p); - } - } - - fft(dst, dstOffset, scratch, p, m, twiddles, size, strideCurrent); - } - - /** - * A recursive FFT subroutine for a specific radix. - */ - final protected static void fft(double[] dst, int dstOffsetCurrent, double[] scratch, // - int p, int m, double[] twiddles, int size, int strideCurrent) { - - int dstOffsetIncr = m << 1; - int scratchOffsetIncr = 2; - int twiddleOffsetIncr = (strideCurrent * m) << 1; - - int modulus = size << 1; - - for (int i = 0; i < m; i++) { - - for (int j = 0, dstOffset = (i << 1) + dstOffsetCurrent, scratchOffset = 0; j < p; // - j++, dstOffset += dstOffsetIncr, scratchOffset += scratchOffsetIncr) { - - scratch[scratchOffset] = dst[dstOffset]; - scratch[scratchOffset + 1] = dst[dstOffset + 1]; - } - - for (int j = 0, dstOffset = (i << 1) + dstOffsetCurrent, twiddleOffset = (strideCurrent * i) << 1; j < p; // - j++, dstOffset += dstOffsetIncr, twiddleOffset += twiddleOffsetIncr) { - - dst[dstOffset] = scratch[0]; - dst[dstOffset + 1] = scratch[1]; - - for (int k = 1, scratchOffset = 2, modOffset = twiddleOffset; k < p; // - k++, scratchOffset += scratchOffsetIncr, // - modOffset = (modOffset + twiddleOffset) % modulus) { - - dst[dstOffset] += scratch[scratchOffset] * twiddles[modOffset] // - - scratch[scratchOffset + 1] * twiddles[modOffset + 1]; - dst[dstOffset + 1] += scratch[scratchOffset] * twiddles[modOffset + 1] // - + scratch[scratchOffset + 1] * twiddles[modOffset]; - } - } - } - } - - // Dummy constructor. - FFTOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTService.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTService.java deleted file mode 100755 index 9316e2bd..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/FFTService.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.fft; - -import shared.util.Service; - -/** - * Defines a {@link Service} for FFT operations. - * - * @author Roy Liu - */ -public interface FFTService extends Service { - - /** - * Computes a reduced forwards transform. - * - * @param dims - * the dimensions of the transform. - * @param in - * the input array. - * @param out - * the output array. - */ - public void rfft(int[] dims, double[] in, double[] out); - - /** - * Computes a reduced backwards transform. - * - * @param dims - * the dimensions of the transform. - * @param in - * the input array. - * @param out - * the output array. - */ - public void rifft(int[] dims, double[] in, double[] out); - - /** - * Computes a forwards transform. - * - * @param dims - * the dimensions of the transform. - * @param in - * the input array. - * @param out - * the output array. - */ - public void fft(int[] dims, double[] in, double[] out); - - /** - * Computes a backwards transform. - * - * @param dims - * the dimensions of the transform. - * @param in - * the input array. - * @param out - * the output array. - */ - public void ifft(int[] dims, double[] in, double[] out); - - /** - * Sets the value of the given hint. - * - * @param name - * the hint name. - * @param value - * the value. - */ - public void setHint(String name, String value); - - /** - * Gets the value of the given hint. - * - * @param name - * the hint name. - * @return the hint value. - */ - public String getHint(String name); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/JavaFFTService.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/JavaFFTService.java deleted file mode 100755 index cf558332..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/JavaFFTService.java +++ /dev/null @@ -1,191 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.fft; - -import java.util.Arrays; - -import shared.array.ComplexArray; -import shared.array.RealArray; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * An {@link FFTService} implementation in pure Java. - * - * @apiviz.uses shared.fft.FFTOps - * @author Roy Liu - */ -public class JavaFFTService implements FFTService { - - /** - * Default constructor. - */ - public JavaFFTService() { - } - - public void rfft(int[] dims, double[] in, double[] out) { - - ComplexArray proxyIn = new RealArray(in, dims).tocRe(); - ComplexArray proxyOut = proxyIn.clone(); - - FFTOps.fft(+1, dims, proxyIn.values(), proxyOut.values()); - - proxyOut = fullToReduced(proxyOut); - - System.arraycopy(proxyOut.values(), 0, out, 0, // - Control.checkEquals(proxyOut.values().length, out.length)); - } - - public void rifft(int[] dims, double[] in, double[] out) { - - int ndims = dims.length; - int[] subdims = Arrays.copyOf(dims, ndims + 1); - - subdims[ndims - 1] = (subdims[ndims - 1] >>> 1) + 1; - subdims[ndims] = 2; - - ComplexArray proxyIn = reducedToFull(new ComplexArray(in, subdims), dims); - ComplexArray proxyOut = proxyIn.clone(); - - FFTOps.fft(-1, dims, proxyIn.values(), proxyOut.values()); - - RealArray realProxyOut = proxyOut.torRe(); - - System.arraycopy(realProxyOut.values(), 0, out, 0, // - Control.checkEquals(realProxyOut.values().length, out.length)); - } - - public void fft(int[] dims, double[] in, double[] out) { - FFTOps.fft(+1, dims, in, out); - } - - public void ifft(int[] dims, double[] in, double[] out) { - FFTOps.fft(-1, dims, in, out); - } - - public void setHint(String name, String value) { - throw new IllegalArgumentException("Unknown hint"); - } - - public String getHint(String name) { - throw new IllegalArgumentException("Unknown hint"); - } - - /** - * Derives a full {@link ComplexArray} from a reduced, half-complex {@link ComplexArray}. - * - * @param reduced - * the reduced array. - * @param logicalDims - * the logical {@link RealArray} dimensions. - * @return the full array. - */ - public ComplexArray reducedToFull(ComplexArray reduced, int[] logicalDims) { - - int[] reducedDims = reduced.dimensions(); - int ndims = reducedDims.length; - - int[] fullDims = Arrays.copyOf(logicalDims, ndims); - fullDims[ndims - 1] = 2; - - ComplexArray full = new ComplexArray(fullDims); - - // - - int[] mapBounds = new int[3 * ndims]; - - for (int dim = 0; dim < ndims; dim++) { - - mapBounds[3 * dim] = 0; - mapBounds[3 * dim + 1] = 0; - mapBounds[3 * dim + 2] = reducedDims[dim]; - } - - reduced.map(full, mapBounds); - - // - - int[] slices = new int[3 * Arithmetic.sum(reducedDims)]; - int[] sliceOffsets = new int[ndims]; - - for (int dim = 0, offset = 0; dim < ndims; dim++) { - - sliceOffsets[dim] = offset; - - for (int j = 0, m = reducedDims[dim]; j < m; j++, offset += 3) { - - slices[offset] = j; - slices[offset + 1] = j; - slices[offset + 2] = dim; - } - } - - for (int dim = ndims - 2; dim >= 0; dim--) { - - int sliceOffset = sliceOffsets[dim]; - - for (int j = 1, m = reducedDims[dim], offset = sliceOffset + 3; j < m; j++, offset += 3) { - - slices[offset] = j; - slices[offset + 1] = m - j; - slices[offset + 2] = dim; - } - - reduced = reduced.splice(new ComplexArray(reducedDims), slices); - - for (int j = 1, m = reducedDims[dim], offset = sliceOffset + 3; j < m; j++, offset += 3) { - - slices[offset] = j; - slices[offset + 1] = j; - slices[offset + 2] = dim; - } - } - - // - - mapBounds[3 * (ndims - 2)] = 2 * reducedDims[ndims - 2] - fullDims[ndims - 2]; - mapBounds[3 * (ndims - 2) + 1] = reducedDims[ndims - 2]; - mapBounds[3 * (ndims - 2) + 2] = fullDims[ndims - 2] - reducedDims[ndims - 2]; - - return reduced.uConj().map(full, mapBounds); - } - - /** - * Derives a reduced, half-complex {@link ComplexArray} from a full {@link ComplexArray}. - * - * @param full - * the full array. - * @return the reduced array. - */ - public ComplexArray fullToReduced(ComplexArray full) { - - int[] fullDims = full.dimensions(); - int ndims = fullDims.length; - - int[] subbounds = new int[ndims << 1]; - - for (int dim = 0, offset = 0; dim < ndims; dim++, offset += 2) { - subbounds[offset + 1] = fullDims[dim]; - } - - subbounds[((ndims - 2) << 1) + 1] >>>= 1; - subbounds[((ndims - 2) << 1) + 1]++; - - return full.subarray(subbounds); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/ModalFFTService.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/ModalFFTService.java deleted file mode 100755 index 014cfe41..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/ModalFFTService.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.fft; - -import shared.util.Services; - -/** - * An {@link FFTService} backed by a service provider as well as a pure Java implementation. - * - * @apiviz.owns shared.fft.JavaFFTService - * @author Roy Liu - */ -public class ModalFFTService implements FFTService { - - volatile FFTService service; - - /** - * Default constructor. Tries to obtain a service provider. Failing that, falls back to {@link JavaFFTService}. - */ - public ModalFFTService() { - - this.service = Services.createService(FFTService.class); - - if (this.service == null) { - this.service = new JavaFFTService(); - } - } - - /** - * Uses the service provider obtained from {@link Services#createService(Class)}. - */ - public boolean useProvider() { - - this.service = Services.createService(FFTService.class); - - if (this.service == null) { - - this.service = new JavaFFTService(); - - return false; - - } else { - - return true; - } - } - - /** - * Uses {@link JavaFFTService}. - */ - public void useJava() { - this.service = new JavaFFTService(); - } - - public void rfft(int[] dims, double[] in, double[] out) { - this.service.rfft(dims, in, out); - } - - public void rifft(int[] dims, double[] in, double[] out) { - this.service.rifft(dims, in, out); - } - - public void fft(int[] dims, double[] in, double[] out) { - this.service.fft(dims, in, out); - } - - public void ifft(int[] dims, double[] in, double[] out) { - this.service.ifft(dims, in, out); - } - - public void setHint(String name, String value) { - this.service.setHint(name, value); - } - - public String getHint(String name) { - return this.service.getHint(name); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/fft/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/fft/package-info.java deleted file mode 100755 index 4d7bdf1d..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/fft/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package for FFT's. - */ -package shared.fft; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/IntegralHistogram.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/IntegralHistogram.java deleted file mode 100755 index 1c6260cf..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/IntegralHistogram.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image; - -import shared.array.IntegerArray; -import shared.array.RealArray; -import shared.image.kernel.ImageOps; -import shared.util.Control; - -/** - * A data structure for computing the histogram over any rectangular region quickly. - * - * @author Roy Liu - */ -public class IntegralHistogram extends RealArray { - - final int[] ilut; - - /** - * Default constructor. - * - * @param src - * the {@link RealArray} to integrate over. - * @param membership - * the class membership information. - * @param nbins - * the number of bins. - */ - public IntegralHistogram(RealArray src, IntegerArray membership, int nbins) { - super(getDimensionsPlusOne(src, nbins)); - - RealArray dst = this; - - int[] srcDims = src.dimensions(); - int[] dstDims = dst.dimensions(); - - Control.checkTrue(src.order() == membership.order(), // - "Indexing order mismatch"); - - ImageOps.ImKernel.createIntegralHistogram( // - src.values(), srcDims, src.order().strides(srcDims), membership.values(), // - dst.values(), dstDims, dst.order().strides(dstDims)); - - this.ilut = ImageOps.createILUT(ndims() - 1); - } - - /** - * Queries for the values histogram within a rectangular region, whose bounds are expressed in the same way as - * {@link RealArray#subarray(int...)}. - * - * @see RealArray#subarray(int...) - */ - public double[] query(double[] res, int... bounds) { - - double[] values = values(); - - int ndims = ndims() - 1; - int stride = ndims + 1; - int[] ilut = this.ilut; - - int nbins = size(ndims); - int binStride = stride(ndims); - - for (int binIndex = 0, binOffset = 0; binIndex < nbins; binIndex++, binOffset += binStride) { - - double sum = 0.0; - - for (int i = 0, n = (1 << ndims), offset = 0; i < n; i++, offset += stride) { - - int index = binOffset; - - for (int dim = 0; dim < ndims; dim++) { - index += bounds[ilut[offset + dim]] * stride(dim); - } - - sum += values[index] * ilut[offset + ndims]; - } - - res[binIndex] = sum; - } - - return res; - } - - /** - * Gets the number of bins. - */ - public int nbins() { - return size(ndims() - 1); - } - - /** - * Gets the original dimensions plus one with an additional "bins" dimension at the end. - */ - final protected static int[] getDimensionsPlusOne(RealArray arr, int nbins) { - - int ndims = arr.ndims(); - - int[] res = new int[ndims + 1]; - - for (int dim = 0; dim < ndims; dim++) { - res[dim] = arr.size(dim) + 1; - } - - res[ndims] = nbins; - - return res; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/IntegralImage.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/IntegralImage.java deleted file mode 100755 index 1e98d3c0..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/IntegralImage.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image; - -import shared.array.RealArray; -import shared.image.kernel.ImageOps; - -/** - * A data structure for computing the sum over any rectangular region quickly. - * - * @author Roy Liu - */ -public class IntegralImage extends RealArray { - - final int[] ilut; - - /** - * Default constructor. - * - * @param src - * the {@link RealArray} to integrate over. - */ - public IntegralImage(RealArray src) { - super(getDimensionsPlusOne(src)); - - RealArray dst = this; - - int[] srcDims = src.dimensions(); - int[] dstDims = dst.dimensions(); - - ImageOps.ImKernel.createIntegralImage( // - src.values(), srcDims, src.order().strides(srcDims), // - dst.values(), dstDims, dst.order().strides(dstDims)); - - this.ilut = ImageOps.createILUT(ndims()); - } - - /** - * Queries for the sum of the values within a rectangular region, whose bounds are expressed in the same way as - * {@link RealArray#subarray(int...)}. - * - * @see RealArray#subarray(int...) - */ - public double query(int... bounds) { - - double sum = 0.0; - double[] values = values(); - - int ndims = ndims(); - int stride = ndims + 1; - int[] ilut = this.ilut; - - for (int i = 0, n = (1 << ndims), offset = 0; i < n; i++, offset += stride) { - - int index = 0; - - for (int dim = 0; dim < ndims; dim++) { - index += bounds[ilut[offset + dim]] * stride(dim); - } - - sum += values[index] * ilut[offset + ndims]; - } - - return sum; - } - - /** - * Gets the original dimensions plus one. - */ - final protected static int[] getDimensionsPlusOne(RealArray arr) { - - int ndims = arr.ndims(); - - int[] res = new int[ndims]; - - for (int dim = 0; dim < ndims; dim++) { - res[dim] = arr.size(dim) + 1; - } - - return res; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/IntensityImages.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/IntensityImages.java deleted file mode 100755 index 27cddaaf..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/IntensityImages.java +++ /dev/null @@ -1,262 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.awt.image.Raster; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.imageio.ImageIO; - -import shared.array.RealArray; -import shared.array.Array.IndexingOrder; -import shared.util.Control; - -/** - * A collection of static methods for reading and writing intensity images represented as {@link RealArray}s. - * - * @author Roy Liu - */ -public class IntensityImages { - - /** - * A mapping of color names to interpolating color maps. - */ - final protected static Map ColorMaps; - - static { - - ColorMaps = new HashMap(); - - ColorMaps.put("gray", createInterpolatingColorMap( // - 0, 0xFF000000, // - 255, 0xFFFFFFFF)); - - ColorMaps.put("jet", createInterpolatingColorMap( // - 0, 0xFF000080, // - 31, 0xFF0000FF, // - 95, 0xFF00FFFF, // - 160, 0xFFFFFF00, // - 223, 0xFFFF0000, // - 255, 0xFF800000)); - } - - /** - * Converts a {@link RealArray} to a {@link BufferedImage}. - * - * @param m - * the intensity image. - * @param cmName - * the name of the color map to display with. - * @param rangeMin - * the minimum intensity. - * @param rangeMax - * the maximum intensity. - * @return an image representation. - */ - final public static BufferedImage createImage(RealArray m, String cmName, double rangeMin, double rangeMax) { - - Control.checkTrue(m.ndims() == 2, // - "Number of array dimensions must equal two"); - - Control.checkTrue(rangeMax > rangeMin, // - "Invalid intensity range"); - - int[] colorMap = ColorMaps.get(cmName); - - Control.checkTrue(colorMap != null, // - "Invalid color map name"); - - m = m.transpose(1, 0).reverseOrder().uAdd(-rangeMin) // - .uMul(1.0 / (rangeMax - rangeMin)); - - double[] backing = m.values(); - int[] arr = new int[backing.length]; - - for (int i = 0, n = backing.length; i < n; i++) { - arr[i] = colorMap[(int) (backing[i] * 255)]; - } - - BufferedImage bi = new BufferedImage(m.size(0), m.size(1), BufferedImage.TYPE_INT_RGB); - bi.getRaster().setDataElements(0, 0, m.size(0), m.size(1), arr); - - return bi; - } - - /** - * Converts a {@link BufferedImage} to a {@link RealArray}. - * - * @param image - * the original image. - * @return an intensity image representation. - */ - final public static RealArray createMatrix(BufferedImage image) { - - Raster raster = ensureGrayscale(image).getRaster(); - - RealArray res = new RealArray(IndexingOrder.NEAR, image.getWidth(), image.getHeight()); - - raster.getSamples(0, 0, image.getWidth(), image.getHeight(), 0, res.values()); - - return res.reverseOrder().transpose(1, 0).uMul(1.0d / 256); - } - - /** - * Creates a {@link RealArray} from an image file. - * - * @param file - * the image file. - * @return the intensity image. - * @throws IOException - * when the load operation goes awry. - */ - final public static RealArray createMatrix(File file) throws IOException { - return createMatrix(ImageIO.read(file)); - } - - /** - * Creates a {@link RealArray} from a {@code byte} array. - * - * @param data - * the binary data. - * @return the intensity image. - * @throws IOException - * when the load operation goes awry. - */ - final public static RealArray createMatrix(byte[] data) throws IOException { - return createMatrix(bytesToJpeg(data)); - } - - /** - * Converts a {@link BufferedImage} to a {@code byte} array. - * - * @param bi - * the image. - * @return the binary data. - * @throws IOException - * when the encoding operation goes awry. - */ - final public static byte[] jpegToBytes(BufferedImage bi) throws IOException { - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ImageIO.write(ensureGrayscale(bi), "jpeg", out); - - return out.toByteArray(); - } - - /** - * Converts a {@code byte} array to a {@link BufferedImage}. - * - * @param data - * the binary data. - * @return the image. - * @throws IOException - * when the decoding operation goes awry. - */ - final public static BufferedImage bytesToJpeg(byte[] data) throws IOException { - - ByteArrayInputStream in = new ByteArrayInputStream(data); - BufferedImage bi = ImageIO.read(in); - - return bi; - } - - /** - * Ensures that an image is in grayscale, converting it if necessary. - */ - final protected static BufferedImage ensureGrayscale(BufferedImage src) { - - BufferedImage dst = new BufferedImage(src.getWidth(), src.getHeight(), // - BufferedImage.TYPE_BYTE_GRAY); - - Graphics2D g2 = dst.createGraphics(); - g2.drawImage(src, 0, 0, null); - g2.dispose(); - - return dst; - } - - /** - * Creates a color map by interpolating between start, end, and intermediate colors. - */ - final protected static int[] createInterpolatingColorMap(int... args) { - - Control.checkTrue(args.length < 4 // - || args.length % 2 == 0 // - || args[0] != 0 // - || args[args.length - 2] != 255, // - "Invalid arguments"); - - int[] indices = new int[args.length / 2]; - int[] values = new int[args.length / 2]; - - for (int i = 0, n = indices.length; i < n; i++) { - - indices[i] = args[2 * i]; - values[i] = args[2 * i + 1]; - } - - int[] colorMap = new int[256]; - - for (int i = 1, n = indices.length; i < n; i++) { - - int lower = indices[i - 1]; - int upper = indices[i]; - int diff = upper - lower; - - if (diff <= 0) { - throw new RuntimeException("Invalid arguments"); - } - - int srcARGB = values[i - 1]; - int dstARGB = values[i]; - - int aSrc = (srcARGB >>> 24) & 0xFF; - int rSrc = (srcARGB >>> 16) & 0xFF; - int gSrc = (srcARGB >>> 8) & 0xFF; - int bSrc = srcARGB & 0xFF; - - double aIncr = (((dstARGB >>> 24) & 0xFF) - aSrc) / (double) diff; - double rIncr = (((dstARGB >>> 16) & 0xFF) - rSrc) / (double) diff; - double gIncr = (((dstARGB >>> 8) & 0xFF) - gSrc) / (double) diff; - double bIncr = ((dstARGB & 0xFF) - bSrc) / (double) diff; - - for (int j = lower; j <= upper; j++) { - - int a = ((((int) Math.round(aSrc + (j - lower) * aIncr)) & 0xFF) << 24); - int r = ((((int) Math.round(rSrc + (j - lower) * rIncr)) & 0xFF) << 16); - int g = ((((int) Math.round(gSrc + (j - lower) * gIncr)) & 0xFF) << 8); - int b = (((int) Math.round(bSrc + (j - lower) * bIncr)) & 0xFF); - - colorMap[j] = a | r | g | b; - } - } - - return colorMap; - } - - // Dummy constructor. - IntensityImages() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/DerivativeOfGaussian.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/DerivativeOfGaussian.java deleted file mode 100755 index af1307ab..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/DerivativeOfGaussian.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.filter; - -import shared.array.RealArray; -import shared.fft.Cacheable; - -/** - * An implementation of DooG filters up to {@code 0}th and {@code 1}st derivatives. - * - * @apiviz.uses shared.image.filter.Filters - * @author Roy Liu - */ -public class DerivativeOfGaussian extends RealArray implements Cacheable { - - final double theta, scale; - final int ord, hashCode, supportRadius; - - @Override - public String toString() { - return String.format("DooG[%d, %4.2f, %4.2f, %d]", // - this.supportRadius, this.theta, this.scale, this.ord); - } - - /** - * Fulfills the {@link Object#equals(Object)} contract. - */ - @Override - public boolean equals(Object o) { - - if (!(o instanceof DerivativeOfGaussian)) { - return false; - } - - DerivativeOfGaussian g = (DerivativeOfGaussian) o; - return this.supportRadius == g.supportRadius // - && this.theta == g.theta // - && this.scale == g.scale // - && this.ord == g.ord; - } - - /** - * Fulfills the {@link Object#hashCode()} contract. - */ - @Override - public int hashCode() { - return this.hashCode; - } - - /** - * Default constructor. - * - * @param supportRadius - * the support radius. - * @param theta - * the orientation. - * @param scale - * the scale. - * @param ord - * the order of the derivative. - */ - public DerivativeOfGaussian(int supportRadius, double theta, double scale, int ord) { - super(2 * supportRadius + 1, 2 * supportRadius + 1); - - this.supportRadius = supportRadius; - this.theta = theta; - this.scale = scale; - this.ord = ord; - - this.hashCode = new Integer(supportRadius).hashCode() // - ^ new Double(theta).hashCode() // - ^ new Double(scale).hashCode() // - ^ new Integer(ord).hashCode(); - - double sigma = (scale * supportRadius) / 3.0d; - - RealArray ptsMatrix = Filters.createRotationMatrix(theta) // - .mMul(Filters.createPointSupport(supportRadius)); - - RealArray ptsY = ptsMatrix.subarray(0, 1, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - RealArray ptsX = ptsMatrix.subarray(1, 2, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - - RealArray gX = derivative(sigma, ptsX, ord); - RealArray gY = derivative(sigma, ptsY, 0); - - gX.eMul(gY).map(this, 0, 0, size(0), 0, 0, size(1)); - - switch (ord) { - - case 0: - uMul(1.0 / aSum()); - break; - - case 1: - uAdd(-aMean()); - break; - } - } - - /** - * Calculates a Gaussian derivative to the specified order. - */ - final protected static RealArray derivative(double sigma, RealArray support, int order) { - - double variance = sigma * sigma; - - // Get a working copy. - RealArray g = support.eMul(support) // - .uMul(-1.0 / (2 * variance)).uExp() // - .uMul(1.0 / Math.sqrt(2 * Math.PI * variance)); - - switch (order) { - - case 0: - return g; - - case 1: - return g.eMul(support.clone().uMul(-1.0d / variance)); - - default: - throw new IllegalArgumentException("Order of derivative can only be zero or one"); - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Filters.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Filters.java deleted file mode 100755 index 1adef4fc..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Filters.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.filter; - -import shared.array.AbstractArray; -import shared.array.ComplexArray; -import shared.array.RealArray; - -/** - * A collection of static methods in support of two-dimensional filters. - * - * @author Roy Liu - */ -public class Filters { - - /** - * Mutatively normalizes a {@link RealArray} by its L1 norm or, alternatively, a {@link ComplexArray} by - * its complex magnitudes. - */ - final public static > void normalize(T array) { - - if (array instanceof RealArray) { - - RealArray m = (RealArray) array; - - m = m.uAdd(-m.aMean()); - m.uMul(1.0 / m.clone().uAbs().aSum()); - - } else if (array instanceof ComplexArray) { - - ComplexArray c = (ComplexArray) array; - - double[] mean = c.aMean(); - - c.uAdd(-mean[0], -mean[1]); - c.uMul(1.0 / c.torAbs().aSum(), 0.0); - - } else { - - throw new IllegalArgumentException("Array type not recognized"); - } - } - - /** - * Creates the 2x2 rotation matrix
- * -cos(theta) -sin(theta)
- * -sin(theta) cos(theta).
- * - * @param theta - * the angle of rotation. - * @return the rotation matrix. - */ - final public static RealArray createRotationMatrix(double theta) { - - RealArray res = new RealArray(2, 2); - - res.set(-Math.cos(theta), 0, 0); - res.set(-Math.sin(theta), 0, 1); - res.set(-Math.sin(theta), 1, 0); - res.set(Math.cos(theta), 1, 1); - - return res; - } - - /** - * Creates a pair of x and y axis aligned DooG kernels for gradient calculations. - * - * @param supportRadius - * the kernel support radius. - * @return the pair of kernels. - */ - final public static RealArray[] createGradientKernels(int supportRadius) { - - RealArray[] gk = new RealArray[2]; - - normalize(gk[0] = new DerivativeOfGaussian(supportRadius, 0.0, 1.0, 1)); - normalize(gk[1] = new DerivativeOfGaussian(supportRadius, 3.0 * Math.PI / 2.0, 1.0, 1)); - - return gk; - } - - /** - * Creates a point support matrix. The top row consists of x coordinates, and the bottom row consists of - * y coordinates. The points range in a square where the origin is at the center. - * - * @param supportRadius - * the support radius. - * @return the point support matrix. - */ - final public static RealArray createPointSupport(int supportRadius) { - - int support = supportRadius * 2 + 1; - - RealArray pts = new RealArray(2, support * support); - - for (int i = 0, n = support * support; i < n; i++) { - - pts.set((i / support) - supportRadius, 0, i); - pts.set((i % support) - supportRadius, 1, i); - } - - return pts; - } - - // Dummy constructor. - Filters() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Gabor.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Gabor.java deleted file mode 100755 index bf5c1e7e..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Gabor.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.filter; - -import shared.array.ComplexArray; -import shared.array.RealArray; -import shared.fft.Cacheable; - -/** - * An implementation of oriented, complex-valued Gabor filters. - * - * @apiviz.uses shared.image.filter.Filters - * @author Roy Liu - */ -public class Gabor extends ComplexArray implements Cacheable { - - final double theta, scale, frequency, elongation; - final int hashCode, supportRadius; - - @Override - public String toString() { - return String.format("Gabor[%d, %4.2f, %4.2f, %4.2f, %4.2f]", // - this.supportRadius, this.theta, this.scale, this.frequency, this.elongation); - } - - /** - * Fulfills the {@link Object#equals(Object)} contract. - */ - @Override - public boolean equals(Object o) { - - if (!(o instanceof Gabor)) { - return false; - } - - Gabor g = (Gabor) o; - return this.supportRadius == g.supportRadius // - && this.theta == g.theta // - && this.scale == g.scale // - && this.frequency == g.frequency // - && this.elongation == g.elongation; - } - - /** - * Fulfills the {@link Object#hashCode()} contract. - */ - @Override - public int hashCode() { - return this.hashCode; - } - - /** - * Default constructor. - * - * @param supportRadius - * the support radius. - * @param theta - * the orientation. - * @param scale - * the scale. - * @param frequency - * the frequency. - * @param elongation - * the elongation. - */ - public Gabor(int supportRadius, // - final double theta, double scale, // - double frequency, final double elongation) { - super(2 * supportRadius + 1, 2 * supportRadius + 1, 2); - - this.supportRadius = supportRadius; - this.elongation = elongation; - this.theta = theta; - this.scale = scale; - this.frequency = frequency; - - this.hashCode = new Integer(supportRadius).hashCode() // - ^ new Double(theta).hashCode() // - ^ new Double(scale).hashCode() // - ^ new Double(frequency).hashCode() // - ^ new Double(elongation).hashCode(); - - RealArray ptsMatrix = Filters.createRotationMatrix(theta) // - .mMul(Filters.createPointSupport(supportRadius)); - - RealArray ptsY = ptsMatrix.subarray(0, 1, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - RealArray ptsX = ptsMatrix.subarray(1, 2, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - - final double k = scale * supportRadius / elongation; - - final double a = -4.0d / (k * k); - - RealArray ptsRe = ((ptsX.clone().uPow(2.0).uMul(1.0 / (elongation * elongation))) // - .eAdd(ptsY.clone().uPow(2.0))) // - .uMul(a); - - final double b = 2.0d * Math.PI * frequency / k; - - RealArray ptsIm = ptsY.clone().uMul(b); - - (ptsRe.tocRe()).eAdd(ptsIm.tocIm()).uExp().map(this, 0, 0, size(0), 0, 0, size(1), 0, 0, 2); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/GaborCircular.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/GaborCircular.java deleted file mode 100755 index 4a7e2820..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/GaborCircular.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.filter; - -import shared.array.ComplexArray; -import shared.array.RealArray; -import shared.fft.Cacheable; - -/** - * An implementation of circular, complex-valued Gabor filters. - * - * @apiviz.uses shared.image.filter.Filters - * @author Roy Liu - */ -public class GaborCircular extends ComplexArray implements Cacheable { - - final double scale, frequency; - final int hashCode, supportRadius; - - @Override - public String toString() { - return String.format("GaborCircular[%d, %4.2f, %4.2f]", // - this.supportRadius, this.scale, this.frequency); - } - - /** - * Fulfills the {@link Object#equals(Object)} contract. - */ - @Override - public boolean equals(Object o) { - - if (!(o instanceof GaborCircular)) { - return false; - } - - GaborCircular g = (GaborCircular) o; - return this.supportRadius == g.supportRadius // - && this.scale == g.scale // - && this.frequency == g.frequency; - } - - /** - * Fulfills the {@link Object#hashCode()} contract. - */ - @Override - public int hashCode() { - return this.hashCode; - } - - /** - * Default constructor. - * - * @param supportRadius - * the support radius. - * @param scale - * the scale. - * @param frequency - * the frequency. - */ - public GaborCircular(int supportRadius, double scale, double frequency) { - super(2 * supportRadius + 1, 2 * supportRadius + 1, 2); - - this.supportRadius = supportRadius; - this.scale = scale; - this.frequency = frequency; - - this.hashCode = new Integer(supportRadius).hashCode() // - ^ new Double(scale).hashCode() // - ^ new Double(frequency).hashCode(); - - RealArray ptsMatrix = Filters.createPointSupport(supportRadius); - RealArray ptsY = ptsMatrix.subarray(0, 1, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - RealArray ptsX = ptsMatrix.subarray(1, 2, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - - final double k = scale * supportRadius; - - final double a = -4.0d / (k * k); - - RealArray ptsRe = ((ptsX.clone().uPow(2.0)).eAdd(ptsY.clone().uPow(2.0))).uMul(a); - - final double b = 2.0d * Math.PI * frequency / k; - - RealArray ptsIm = ((ptsX.clone().uPow(2.0)).eAdd(ptsY.clone().uPow(2.0))).uPow(0.5).uMul(b); - - (ptsRe.tocRe()).eAdd(ptsIm.tocIm()).uExp().map(this, 0, 0, size(0), 0, 0, size(1), 0, 0, 2); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/LaplacianOfGaussian.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/LaplacianOfGaussian.java deleted file mode 100755 index 58ec0544..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/LaplacianOfGaussian.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.filter; - -import shared.array.RealArray; -import shared.fft.Cacheable; - -/** - * An implementation of LoG filters. - * - * @apiviz.uses shared.image.filter.Filters - * @author Roy Liu - */ -public class LaplacianOfGaussian extends RealArray implements Cacheable { - - final double scale; - final int hashCode, supportRadius; - - @Override - public String toString() { - return String.format("LoG[%d, %4.2f]", // - this.supportRadius, this.scale); - } - - /** - * Fulfills the {@link Object#equals(Object)} contract. - */ - @Override - public boolean equals(Object o) { - - if (!(o instanceof LaplacianOfGaussian)) { - return false; - } - - LaplacianOfGaussian g = (LaplacianOfGaussian) o; - return this.supportRadius == g.supportRadius && this.scale == g.scale; - } - - /** - * Fulfills the {@link Object#hashCode()} contract. - */ - @Override - public int hashCode() { - return this.hashCode; - } - - /** - * Default constructor. - * - * @param supportRadius - * the support radius. - * @param scale - * the scale. - */ - public LaplacianOfGaussian(int supportRadius, double scale) { - super(2 * supportRadius + 1, 2 * supportRadius + 1); - - this.supportRadius = supportRadius; - this.scale = scale; - - this.hashCode = new Integer(supportRadius).hashCode() ^ new Double(scale).hashCode(); - - double sigma = (scale * supportRadius) / 3.0d; - - RealArray ptsMatrix = Filters.createPointSupport(supportRadius); - - RealArray ptsY = ptsMatrix.subarray(0, 1, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - RealArray ptsX = ptsMatrix.subarray(1, 2, 0, ptsMatrix.size(1)) // - .reshape(2 * supportRadius + 1, 2 * supportRadius + 1); - - ptsX.clone().uSqr().eAdd(ptsY.clone().uSqr()) // - .uAdd(-2.0 * sigma * sigma) // - .uMul(1.0 / (sigma * sigma * sigma * sigma)) // - .eMul(new DerivativeOfGaussian(supportRadius, 0.0, 1.0, 0)) // - .map(this, 0, 0, size(0), 0, 0, size(1)); - - uAdd(-aMean()); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Mean.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Mean.java deleted file mode 100755 index 511a43ba..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/Mean.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.filter; - -import shared.array.RealArray; -import shared.fft.Cacheable; - -/** - * A mean low-pass filter. - * - * @author Roy Liu - */ -public class Mean extends RealArray implements Cacheable { - - final int hashCode; - final int width; - final int height; - - @Override - public String toString() { - return String.format("Mean[%d, %d]", // - this.width, this.height); - } - - /** - * Fulfills the {@link Object#equals(Object)} contract. - */ - @Override - public boolean equals(Object o) { - - if (!(o instanceof Mean)) { - return false; - } - - Mean m = (Mean) o; - return this.width == m.width // - && this.height == m.height; - } - - /** - * Fulfills the {@link Object#hashCode()} contract. - */ - @Override - public int hashCode() { - return this.hashCode; - } - - /** - * Default constructor. - * - * @param width - * the width. - * @param height - * the height. - */ - public Mean(int width, int height) { - super(width, height); - - this.hashCode = new Integer(width).hashCode() // - ^ new Integer(height).hashCode(); - - this.width = width; - this.height = height; - - uFill(1.0 / (width * height)); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/package-info.java deleted file mode 100755 index 3414e323..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/filter/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of two-dimensional filters. - */ -package shared.image.filter; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/jni/NativeImageKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/jni/NativeImageKernel.java deleted file mode 100755 index 7ccd7989..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/jni/NativeImageKernel.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.jni; - -import shared.image.kernel.ImageKernel; -import shared.metaclass.Library; -import shared.util.Control; - -/** - * A native implementation of {@link ImageKernel}. - * - * @author Roy Liu - */ -public class NativeImageKernel implements ImageKernel { - - /** - * Default constructor. - */ - public NativeImageKernel() { - - Control.checkTrue(Library.isInitialized(), // - "Could not instantiate native bindings -- Linking failed"); - } - - final public native void createIntegralImage( // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS); - - final public native void createIntegralHistogram( // - double[] srcV, int[] srcD, int[] srcS, int[] memV, // - double[] dstV, int[] dstD, int[] dstS); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/jni/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/jni/package-info.java deleted file mode 100755 index ddaa4233..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/jni/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package for providing JNI-backed image processing operations. - */ -@shared.metaclass.Policy(recursive = false) -package shared.image.jni; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ImageKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ImageKernel.java deleted file mode 100755 index b51d3b72..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ImageKernel.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.kernel; - -import shared.util.Service; - -/** - * A provider of image processing operations. - * - * @author Roy Liu - */ -public interface ImageKernel extends Service { - - /** - * Creates an integral image. - * - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param dstV - * the destination values. - * @param dstD - * the destination dimensions. - * @param dstS - * the destination strides. - */ - public void createIntegralImage( // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS); - - /** - * Creates an integral histogram. - * - * @param srcV - * the source values. - * @param srcD - * the source dimensions. - * @param srcS - * the source strides. - * @param memV - * the class memberships. - * @param dstV - * the destination values. - * @param dstD - * the destination dimensions. - * @param dstS - * the destination strides. - */ - public void createIntegralHistogram( // - double[] srcV, int[] srcD, int[] srcS, int[] memV, // - double[] dstV, int[] dstD, int[] dstS); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ImageOps.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ImageOps.java deleted file mode 100755 index 76c20c06..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ImageOps.java +++ /dev/null @@ -1,206 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.kernel; - -import java.util.Arrays; - -import shared.array.kernel.MappingOps; -import shared.util.Control; - -/** - * A class for image processing operations in pure Java. - * - * @author Roy Liu - */ -public class ImageOps { - - /** - * The image processing kernel. - */ - public static ModalImageKernel ImKernel = new ModalImageKernel(); - - /** - * Creates an index lookup table for speedy index calculations. - */ - final public static int[] createILUT(int ndims) { - - int stride = ndims + 1; - int[] ilut = new int[(1 << ndims) * stride]; - - for (int i = 0, n = (1 << ndims), offset = 0, parity = ndims % 2; i < n; i++, offset += stride) { - - for (int dim = 0; dim < ndims; dim++) { - ilut[offset + dim] = (dim << 1) + ((i >>> dim) & 0x1); - } - - ilut[offset + ndims] = 1 - (((Integer.bitCount(i) + parity) % 2) << 1); - } - - return ilut; - } - - /** - * Supports {@link JavaImageKernel#createIntegralImage(double[], int[], int[], double[], int[], int[])}. - */ - final public static void createIntegralImage( // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS) { - - int ndims = srcD.length; - - Control.checkTrue(ndims == srcS.length // - && ndims == dstD.length // - && ndims == dstS.length); - - int srcLen = MappingOps.checkDimensions(srcV.length, srcD, srcS); - int dstLen = MappingOps.checkDimensions(dstV.length, dstD, dstS); - - int dstOffset = 0; - - for (int dim = 0; dim < ndims; dim++) { - - Control.checkTrue(srcD[dim] + 1 == dstD[dim], // - "Dimension mismatch"); - - dstOffset += dstS[dim]; - } - - if (srcLen == 0) { - return; - } - - int[] srcIndices = MappingOps.assignMappingIndices(srcLen, srcD, srcS); - int[] dstIndices = MappingOps.assignMappingIndices(srcLen, srcD, dstS); - - for (int i = 0; i < srcLen; i++) { - dstV[dstIndices[i] + dstOffset] = srcV[srcIndices[i]]; - } - - // - - dstIndices = MappingOps.assignMappingIndices(dstLen, dstD, dstS); - - for (int dim = 0, indexBlockIncrement = dstLen; dim < ndims; indexBlockIncrement /= dstD[dim++]) { - - int size = dstD[dim]; - int stride = dstS[dim]; - - for (int lower = 0, upper = indexBlockIncrement / size; // - lower < dstLen; // - lower += indexBlockIncrement, upper += indexBlockIncrement) { - - for (int indexIndex = lower; indexIndex < upper; indexIndex++) { - - double acc = 0.0; - - for (int k = 0, physical = dstIndices[indexIndex]; k < size; k++, physical += stride) { - - acc += dstV[physical]; - dstV[physical] = acc; - } - } - } - } - } - - /** - * Supports {@link JavaImageKernel#createIntegralHistogram(double[], int[], int[], int[], double[], int[], int[])}. - */ - final public static void createIntegralHistogram( // - double[] srcV, int[] srcD, int[] srcS, int[] memV, // - double[] dstV, int[] dstD, int[] dstS) { - - int memLen = memV.length; - int ndims = srcD.length; - - Control.checkTrue(ndims == srcS.length // - && ndims + 1 == dstD.length // - && ndims + 1 == dstS.length // - && memLen == srcV.length); - - int[] dstDModified = Arrays.copyOf(dstD, ndims); - int[] dstSModified = Arrays.copyOf(dstS, ndims); - - int srcLen = MappingOps.checkDimensions(srcV.length, srcD, srcS); - int dstLen = MappingOps.checkDimensions(dstV.length, dstD, dstS); - - int dstOffset = 0; - - for (int dim = 0; dim < ndims; dim++) { - - Control.checkTrue(srcD[dim] + 1 == dstD[dim], // - "Dimension mismatch"); - - dstOffset += dstS[dim]; - } - - if (srcLen == 0) { - return; - } - - int[] srcIndices = MappingOps.assignMappingIndices(srcLen, srcD, srcS); - int[] dstIndices = MappingOps.assignMappingIndices(srcLen, srcD, dstSModified); - - int nbins = dstD[ndims]; - int binStride = dstS[ndims]; - int dstLenModified = dstLen / nbins; - - for (int i = 0; i < srcLen; i++) { - - int index = memV[srcIndices[i]]; - - Control.checkTrue(index >= 0 && index < nbins, // - "Invalid membership index"); - - dstV[dstIndices[i] + dstOffset + index * binStride] = srcV[srcIndices[i]]; - } - - // - - dstIndices = MappingOps.assignMappingIndices(dstLenModified, dstDModified, dstSModified); - - for (int dim = 0, indexBlockIncrement = dstLenModified; dim < ndims; indexBlockIncrement /= dstDModified[dim++]) { - - int size = dstDModified[dim]; - int stride = dstSModified[dim]; - - for (int lower = 0, upper = indexBlockIncrement / size; // - lower < dstLenModified; // - lower += indexBlockIncrement, upper += indexBlockIncrement) { - - for (int indexIndex = lower; indexIndex < upper; indexIndex++) { - - for (int binIndex = 0, binOffset = 0; binIndex < nbins; binIndex++, binOffset += binStride) { - - double acc = 0.0; - - for (int k = 0, physical = dstIndices[indexIndex] + binOffset; k < size; k++, physical += stride) { - - acc += dstV[physical]; - dstV[physical] = acc; - } - } - } - } - } - } - - // Dummy constructor. - ImageOps() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/JavaImageKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/JavaImageKernel.java deleted file mode 100755 index 7922f74f..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/JavaImageKernel.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.kernel; - -/** - * A pure Java implementation of {@link ImageKernel}. - * - * @apiviz.uses shared.image.kernel.ImageOps - * @author Roy Liu - */ -public class JavaImageKernel implements ImageKernel { - - /** - * Default constructor. - */ - public JavaImageKernel() { - } - - public void createIntegralImage( // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS) { - ImageOps.createIntegralImage(srcV, srcD, srcS, dstV, dstD, dstS); - } - - public void createIntegralHistogram( // - double[] srcV, int[] srcD, int[] srcS, int[] memV, // - double[] dstV, int[] dstD, int[] dstS) { - ImageOps.createIntegralHistogram(srcV, srcD, srcS, memV, dstV, dstD, dstS); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ModalImageKernel.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ModalImageKernel.java deleted file mode 100755 index 260e87cf..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/ModalImageKernel.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.image.kernel; - -import shared.image.jni.NativeImageKernel; -import shared.util.Services; - -/** - * An implementation of {@link ImageKernel} that has JNI and pure Java bindings. - * - * @apiviz.owns shared.image.kernel.JavaImageKernel - * @author Roy Liu - */ -public class ModalImageKernel implements ImageKernel { - - volatile ImageKernel imKernel; - - /** - * Default constructor. Tries to create an underlying {@link NativeImageKernel}. Failing that, creates an underlying - * {@link JavaImageKernel}. - */ - public ModalImageKernel() { - - this.imKernel = Services.createService(ImageKernel.class); - - if (this.imKernel == null) { - this.imKernel = new JavaImageKernel(); - } - } - - /** - * Uses the underlying {@link NativeImageKernel} obtained from {@link Services#createService(Class)}. - */ - public boolean useNative() { - - this.imKernel = Services.createService(ImageKernel.class); - - if (this.imKernel == null) { - - this.imKernel = new JavaImageKernel(); - - return false; - - } else { - - return true; - } - } - - /** - * Uses the underlying {@link JavaImageKernel}. - */ - public void useJava() { - this.imKernel = new JavaImageKernel(); - } - - public void createIntegralImage( // - double[] srcV, int[] srcD, int[] srcS, // - double[] dstV, int[] dstD, int[] dstS) { - this.imKernel.createIntegralImage(srcV, srcD, srcS, dstV, dstD, dstS); - } - - public void createIntegralHistogram( // - double[] srcV, int[] srcD, int[] srcS, int[] memV, // - double[] dstV, int[] dstD, int[] dstS) { - this.imKernel.createIntegralHistogram(srcV, srcD, srcS, memV, dstV, dstD, dstS); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/package-info.java deleted file mode 100755 index 402f14cb..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/kernel/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package for image processing operations. - */ -package shared.image.kernel; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/image/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/image/package-info.java deleted file mode 100755 index 7eea2b74..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/image/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package for representing images and image statistics as matrices and arrays. - */ -package shared.image; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/log4j.xml b/contrib/applications/nxplot/sharedscientific/src/shared/log4j.xml deleted file mode 100755 index c47d8359..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/log4j.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/FileSystemRegistry.java b/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/FileSystemRegistry.java deleted file mode 100755 index 8cac0540..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/FileSystemRegistry.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.metaclass; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collections; -import java.util.Enumeration; - -/** - * An implementation of {@link ResourceRegistry} that consults the file system for resources. - * - * @author Roy Liu - */ -public class FileSystemRegistry implements ResourceRegistry { - - final File folder; - - /** - * Default constructor. - */ - public FileSystemRegistry(File folder) { - this.folder = folder; - } - - public URL getResource(String pathname) { - - File resourceFile = new File(this.folder, pathname); - - if (resourceFile.exists()) { - - try { - - return resourceFile.toURI().toURL(); - - } catch (MalformedURLException e) { - - // Ah well. - } - } - - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getResources(String pathname) { - - URL url = getResource(pathname); - return Collections.enumeration((url != null) ? Collections.singleton(url) : Collections.EMPTY_LIST); - } - - public InputStream getResourceAsStream(String pathname) { - - URL url = getResource(pathname); - - if (url != null) { - - try { - - return url.openStream(); - - } catch (IOException e) { - - // Ah well. - } - } - - return null; - } - - /** - * Creates a human-readable representation of this registry. - */ - @Override - public String toString() { - - URL url = null; - - try { - - url = this.folder.toURI().toURL(); - - } catch (MalformedURLException e) { - - // Ah well. - } - - return String.format("FileSystemRegistry[url = \"%s\"]", url); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/JarRegistry.java b/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/JarRegistry.java deleted file mode 100755 index fba93d09..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/JarRegistry.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.metaclass; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarInputStream; - -import shared.util.Control; -import shared.util.TemporaryFiles; - -/** - * An implementation of {@link ResourceRegistry} that consults {@link JarFile}s and {@link JarInputStream}s for - * resources. - * - * @author Roy Liu - */ -public class JarRegistry implements ResourceRegistry { - - final Map dataMap; - final Map fileMap; - - /** - * Default constructor. - * - * @throws IOException - * when something goes awry. - */ - public JarRegistry(JarFile jf) throws IOException { - this(createDataMap(jf)); - } - - /** - * Alternate constructor. - * - * @throws IOException - * when something goes awry. - */ - public JarRegistry(JarInputStream jis) throws IOException { - this(createDataMap(jis)); - } - - /** - * Alternate constructor. - */ - public JarRegistry() { - throw new UnsupportedOperationException(); - } - - /** - * Internal constructor. - */ - protected JarRegistry(Map dataMap) { - - this.dataMap = dataMap; - this.fileMap = new HashMap(); - } - - /** - * Gets the {@link Map} of resource pathnames to {@code byte} arrays. - */ - public Map getDataMap() { - return this.dataMap; - } - - public URL getResource(String pathname) { - - final byte[] data = this.dataMap.get(pathname); - - if (data == null) { - return null; - } - - synchronized (this) { - - File f = this.fileMap.get(pathname); - - try { - - if (f != null) { - return f.toURI().toURL(); - } - - f = File.createTempFile(pathname.replace("/", "_").concat("_"), ""); - - this.fileMap.put(pathname, f); - TemporaryFiles.deleteOnExit(f); - - Control.transfer(data, f); - - return f.toURI().toURL(); - - } catch (IOException e) { - - // Return empty-handed if, for some reason, the temporary file could not be created. - return null; - } - } - } - - @SuppressWarnings("unchecked") - public Enumeration getResources(String pathname) { - - URL url = getResource(pathname); - return Collections.enumeration((url != null) ? Collections.singleton(url) : Collections.EMPTY_LIST); - } - - public InputStream getResourceAsStream(String pathname) { - - byte[] data = this.dataMap.get(pathname); - - if (data == null) { - return null; - } - - return new ByteArrayInputStream(data); - } - - /** - * Gets the string "Jar Registry". - */ - @Override - public String toString() { - return String.format("JarRegistry[size = %d]", this.dataMap.size()); - } - - /** - * Creates a mapping of pathnames to data from a {@link JarInputStream}. - * - * @throws IOException - * when something goes awry. - */ - final protected static Map createDataMap(JarInputStream jis) throws IOException { - - HashMap map = new HashMap(); - - for (JarEntry je = null; (je = jis.getNextJarEntry()) != null;) { - map.put(je.getName(), Control.getBytes(jis)); - } - - return map; - } - - /** - * Creates a mapping of pathnames to data from a {@link JarFile}. - * - * @throws IOException - * when something goes awry. - */ - final protected static Map createDataMap(JarFile jf) throws IOException { - - HashMap map = new HashMap(); - - for (Enumeration jes = jf.entries(); jes.hasMoreElements();) { - - JarEntry je = jes.nextElement(); - map.put(je.getName(), Control.getBytes(jf.getInputStream(je))); - } - - return map; - } - - // A finalizer guardian for deleting outstanding files. - final Object fileReaper = new Object() { - - @Override - protected void finalize() { - - JarRegistry jr = JarRegistry.this; - - synchronized (jr) { - - for (File f : jr.fileMap.values()) { - - Control.delete(f); - TemporaryFiles.undelete(f); - } - } - } - }; -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/Library.java b/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/Library.java deleted file mode 100755 index c0b669e0..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/Library.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.metaclass; - -import java.io.File; - -/** - * A class for interacting with dynamically linked native code. - * - * @author Roy Liu - */ -public class Library { - - /** - * A flag set on load of the native library. - */ - protected static boolean INITIALIZED = false; - - /** - * Checks to see if the native library has been loaded. - */ - final public static boolean isInitialized() { - return INITIALIZED; - } - - /** - * Loads a native library from the given file. - */ - final public static void load(File libFile) { - System.load(libFile.getAbsolutePath()); - } - - /** - * Loads a native library from dynamic linker resolution of the given name. - */ - final public static void loadLibrary(String libName) { - System.loadLibrary(libName); - } - - // Dummy constructor. - Library() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/Policy.java b/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/Policy.java deleted file mode 100755 index c496ca90..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/Policy.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.metaclass; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An annotation class for directing package class loading policy. - * - * @author Roy Liu - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PACKAGE) -public @interface Policy { - - /** - * Whether this policy applies recursively to all subpackages. - */ - boolean recursive() default true; - - /** - * Gets the names of external classes and packages to include. - */ - String[] includes() default {}; -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/RegistryClassLoader.java b/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/RegistryClassLoader.java deleted file mode 100755 index c73bbb13..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/RegistryClassLoader.java +++ /dev/null @@ -1,575 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.metaclass; - -import static shared.util.Control.NullRunnable; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.net.URL; -import java.nio.ByteBuffer; -import java.security.SecureClassLoader; -import java.util.Arrays; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Formatter; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; - -import shared.util.Control; -import shared.util.Finalizable; - -/** - * A subclass of {@link SecureClassLoader} that derives classes and resource {@link URL}s from a registry delegation - * chain. - * - * @apiviz.composedOf shared.metaclass.RegistryClassLoader.PrefixNode - * @apiviz.owns shared.metaclass.JarRegistry - * @apiviz.owns shared.metaclass.FileSystemRegistry - * @apiviz.has shared.metaclass.Policy - - - argument - * @apiviz.uses shared.metaclass.Library - * @author Roy Liu - */ -public class RegistryClassLoader extends SecureClassLoader implements ResourceRegistry, - Finalizable { - - final Set delegates; - final Set classNames; - final PrefixNode root; - final Class policyClass; - final Method recursiveMethod, includesMethod, loadMethod, loadLibraryMethod; - - volatile Runnable finalizer; - - /** - * Default constructor. - */ - public RegistryClassLoader() { - this(Thread.currentThread().getContextClassLoader()); - } - - /** - * Alternate constructor. - */ - @SuppressWarnings("unchecked") - public RegistryClassLoader(ClassLoader parent) { - super(parent); - - this.classNames = new HashSet(); - this.root = new PrefixNode(); - - this.delegates = new LinkedHashSet(); - this.finalizer = NullRunnable; - - try { - - this.policyClass = (Class) loadClass("shared.metaclass.Policy", true); - this.recursiveMethod = this.policyClass.getDeclaredMethod("recursive"); - this.includesMethod = this.policyClass.getDeclaredMethod("includes"); - - // Force loading of shared.metaclass.Library by this class loader to effectively make native - // libraries exclusive to it and not the parent class loader. - Class clazz = findClass("shared.metaclass.Library"); - this.loadMethod = clazz.getDeclaredMethod("load", File.class); - this.loadLibraryMethod = clazz.getDeclaredMethod("loadLibrary", String.class); - - } catch (Exception e) { - - throw new RuntimeException(e); - } - } - - /** - * Attempts to derive a class first from this class loader's parent, and then from its {@link #findClass(String)} - * method. - * - * @throws ClassNotFoundException - * when the class could not be found. - */ - @Override - protected Class loadClass(String className, boolean resolve) throws ClassNotFoundException { - - Class clazz = findLoadedClass(className); - - if (clazz != null) { - return clazz; - } - - final String[] prefixes; - - if (className.contains(".")) { - - String[] split = className.split("\\.", -1); - prefixes = Arrays.copyOf(split, split.length - 1); - - } else { - - prefixes = new String[] {}; - } - - // Check for truncated class name membership to deal with inner classes. - int index = className.indexOf("$"); - String truncatedClassName = (index >= 0) ? className.substring(0, index) : className; - - if (!this.root.containsPrefixes(prefixes, 0, false) && !this.classNames.contains(truncatedClassName)) { - - return super.loadClass(className, resolve); - - } else { - - clazz = findClass(className); - } - - if (resolve) { - resolveClass(clazz); - } - - return clazz; - } - - /** - * Attempts to derive a class from the registry delegation chain. - * - * @throws ClassNotFoundException - * when the class could not be found. - */ - @Override - protected Class findClass(String className) throws ClassNotFoundException { - - byte[] classData = getClassBytes(className); - - if (classData == null) { - throw new ClassNotFoundException(String.format("Class '%s' not found", className)); - } - - return defineClass(className, // - ByteBuffer.wrap(classData), // - RegistryClassLoader.class.getProtectionDomain()); - } - - @Override - public URL getResource(String pathname) { - - ClassLoader parent = getParent(); - URL url = (parent != null) ? parent.getResource(pathname) // - : getSystemResource(pathname); - - if (url != null) { - return url; - } - - for (ResourceRegistry delegate : this.delegates) { - - url = delegate.getResource(pathname); - - if (url != null) { - return url; - } - } - - return null; - } - - @Override - public Enumeration getResources(String pathname) throws IOException { - - ClassLoader parent = getParent(); - List urls = Collections.list((parent != null) ? parent.getResources(pathname) // - : getSystemResources(pathname)); - - for (ResourceRegistry delegate : this.delegates) { - urls.addAll(Collections.list(delegate.getResources(pathname))); - } - - return Collections.enumeration(urls); - } - - @Override - public InputStream getResourceAsStream(String pathname) { - - ClassLoader parent = getParent(); - InputStream in = (parent != null) ? parent.getResourceAsStream(pathname) // - : getSystemResourceAsStream(pathname); - - if (in != null) { - return in; - } - - for (ResourceRegistry delegate : this.delegates) { - - in = delegate.getResourceAsStream(pathname); - - if (in != null) { - return in; - } - } - - return null; - } - - public RegistryClassLoader setFinalizer(Runnable finalizer) { - - Control.checkTrue(finalizer != null, // - "Finalizer must be non-null"); - - this.finalizer = finalizer; - - return this; - } - - /** - * Adds a registry to the delegation chain. - */ - public RegistryClassLoader addRegistry(ResourceRegistry registry) { - - this.delegates.add(registry); - - return this; - } - - /** - * Adds a class which requires, for linking purposes, resources exclusive to this class loader. - */ - public RegistryClassLoader addClass(String className) { - - Class clazz = findLoadedClass(className); - - try { - - if (clazz == null) { - clazz = findClass(className); - } - - } catch (ClassNotFoundException e) { - - throw new RuntimeException(e); - } - - this.classNames.add(className); - - return this; - } - - /** - * Adds a package whose classes require, for linking purposes, resources exclusive to this class loader. - */ - public RegistryClassLoader addPackage(String packageName) { - - Control.checkTrue(packageName != null && !packageName.equals(""), // - "Invalid package name"); - - String className = packageName.concat(".package-info"); - String[] prefixes = packageName.split("\\.", -1); - - Class clazz = findLoadedClass(className); - - try { - - if (clazz == null) { - clazz = findClass(className); - } - - } catch (ClassNotFoundException e) { - - throw new RuntimeException(e); - } - - Annotation policy = clazz.getAnnotation(this.policyClass); - - Control.checkTrue(policy != null, // - "Package is not annotated with a class loading policy"); - - final String[] includes; - - try { - - includes = (String[]) this.includesMethod.invoke(policy); - - } catch (Exception e) { - - throw new RuntimeException(e); - } - - for (String include : includes) { - - String[] split = include.split("#", -1); - - switch (split.length) { - - case 1: - addPackage(split[0]); - break; - - case 2: - addClass(!split[0].equals("") ? String.format("%s.%s", split[0], split[1]) : split[1]); - break; - - default: - throw new IllegalArgumentException("Invalid include syntax"); - } - } - - this.root.addPrefixes(prefixes, 0, policy); - - return this; - } - - /** - * Loads a native library from the given file. - */ - public RegistryClassLoader load(File libFile) { - - try { - - this.loadMethod.invoke(null, libFile); - - } catch (Exception e) { - - throw new RuntimeException(e); - } - - return this; - } - - /** - * Loads a native library from dynamic linker resolution of the given name. - */ - public RegistryClassLoader loadLibrary(String libName) { - - try { - - this.loadLibraryMethod.invoke(null, libName); - - } catch (Exception e) { - - throw new RuntimeException(e); - } - - return this; - } - - /** - * Creates a human-readable representation of this class loader. - */ - @Override - public String toString() { - - Formatter f = new Formatter(); - - f.format("%s(%s)%n%n", // - RegistryClassLoader.class.getName(), getParent()); - - for (ResourceRegistry delegate : this.delegates) { - f.format("%s%n", delegate.toString()); - } - - f.format("%n%s", this.root.toString()); - - return f.toString(); - } - - /** - * Gets bytecodes associated with the given class name. - */ - protected byte[] getClassBytes(String className) { - - String pathname = className.replace(".", "/").concat(".class"); - ClassLoader parent = getParent(); - - byte[] classBytes = getBytes((parent != null) ? parent.getResourceAsStream(pathname) // - : getSystemResourceAsStream(pathname)); - - if (classBytes != null) { - return classBytes; - } - - for (ResourceRegistry delegate : this.delegates) { - - classBytes = getBytes(delegate.getResourceAsStream(pathname)); - - if (classBytes != null) { - return classBytes; - } - } - - return null; - } - - /** - * Gets a {@code byte} array from the given {@link InputStream}. - */ - final protected static byte[] getBytes(InputStream in) { - - if (in == null) { - return null; - } - - final byte[] classBytes; - - try { - - classBytes = Control.getBytes(in); - - } catch (IOException e) { - - throw new RuntimeException(e); - } - - return (classBytes != null && classBytes.length > 0) ? classBytes : null; - } - - /** - * A node class for policy hierarchy lookups. - */ - protected class PrefixNode { - - final Map prefixMap; - - Annotation policy; - - /** - * Default constructor. - */ - protected PrefixNode() { - - this.prefixMap = new HashMap(); - this.policy = null; - } - - /** - * Adds the given series of prefixes to the policy hierarchy. - */ - protected void addPrefixes(String[] prefixes, int index, Annotation policy) { - - if (index < prefixes.length) { - - String currentPrefix = prefixes[index]; - - for (Entry entry : this.prefixMap.entrySet()) { - - String prefix = entry.getKey(); - PrefixNode node = entry.getValue(); - - if (currentPrefix.equals(prefix)) { - - node.addPrefixes(prefixes, index + 1, policy); - - return; - } - } - - PrefixNode node = new PrefixNode(); - node.addPrefixes(prefixes, index + 1, policy); - - this.prefixMap.put(currentPrefix, node); - - } else { - - this.policy = policy; - } - } - - /** - * Checks if the given series of prefixes is contained in the policy hierarchy. - */ - protected boolean containsPrefixes(String[] prefixes, int index, boolean recursive) { - - if (index < prefixes.length) { - - String currentPrefix = prefixes[index]; - - for (Entry entry : this.prefixMap.entrySet()) { - - String prefix = entry.getKey(); - PrefixNode node = entry.getValue(); - - if (currentPrefix.equals(prefix)) { - - if (node.policy != null) { - - try { - - recursive = (Boolean) RegistryClassLoader.this.recursiveMethod // - .invoke(node.policy); - - } catch (Exception e) { - - throw new RuntimeException(e); - } - } - - return node.containsPrefixes(prefixes, index + 1, recursive); - } - } - - return recursive; - - } else { - - // Accept if the prefix search terminates at a policy node. - return (this.policy != null) || recursive; - } - } - - /** - * Delegates to {@link PrefixNode#format(Formatter, String)}. - */ - @Override - public String toString() { - - Formatter f = new Formatter(); - format(f, ""); - - return f.toString(); - } - - /** - * Gets a string representation of this node's descendants. - */ - protected void format(Formatter f, String indent) { - - for (Entry entry : this.prefixMap.entrySet()) { - - String prefix = entry.getKey(); - PrefixNode node = entry.getValue(); - - f.format("%s%s%s%n", indent, prefix, // - (node.policy != null) ? ":".concat(node.policy.toString()) : ""); - - node.format(f, indent.concat("\t")); - } - } - } - - // A finalizer guardian for the class loader. - final Object reaper = new Object() { - - @Override - protected void finalize() { - RegistryClassLoader.this.finalizer.run(); - } - }; -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/ResourceRegistry.java b/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/ResourceRegistry.java deleted file mode 100755 index d1fdd4e6..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/ResourceRegistry.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.metaclass; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Enumeration; - -/** - * Defines a registry for looking up class path resources. - * - * @author Roy Liu - */ -public interface ResourceRegistry { - - /** - * Gets a resource {@link URL} corresponding to the given pathname. - * - * @param pathname - * the resource pathname. - * @return a resource {@link URL} or {@code null} if not found. - */ - public URL getResource(String pathname); - - /** - * Gets all resource {@link URL}s corresponding to the given pathname. - * - * @param pathname - * the resource pathname. - * @return an {@link Enumeration} of resource {@link URL}s. - * @throws IOException - * when something goes awry. - */ - public Enumeration getResources(String pathname) throws IOException; - - /** - * Gets an {@link InputStream} to the resource at the given pathname. - * - * @param pathname - * the resource pathname. - * @return an {@link InputStream} to the resource or {@code null} if not found. - */ - public InputStream getResourceAsStream(String pathname); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/package-info.java deleted file mode 100755 index 3fb1f76e..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/metaclass/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of metaclass utilities. - */ -package shared.metaclass; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/package-info.java deleted file mode 100755 index ff680b91..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package denoting the SST hierarchy root. - */ -package shared; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Calculator.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Calculator.java deleted file mode 100755 index a3915889..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Calculator.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.parallel; - -import java.util.List; - -/** - * Defines an atomic calculation as part of a parallel dataflow graph. - * - * @param - * the input type. - * @param - * the output type. - * @author Roy Liu - */ -public interface Calculator { - - /** - * Performs an atomic calculation. - * - * @param inputs - * the {@link List} of inputs. - * @return the calculation result. - */ - public O calculate(List> inputs); - - /** - * Gets the label for this {@link Calculator} as it would appear in {@link Engine#toString()}. - */ - public String toString(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Edge.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Edge.java deleted file mode 100755 index 6af10896..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Edge.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.parallel; - -/** - * Defines an edge relationship between two nodes. - * - * @param - * the node type. - * @author Roy Liu - */ -public interface Edge { - - /** - * Gets the start node. - */ - public V getU(); - - /** - * Sets the start node. - */ - public void setU(V node); - - /** - * Gets the end node. - */ - public V getV(); - - /** - * Sets the end node. - */ - public void setV(V node); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Engine.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Engine.java deleted file mode 100755 index 58950f21..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Engine.java +++ /dev/null @@ -1,639 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.parallel; - -import java.lang.Thread.UncaughtExceptionHandler; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Formatter; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.PriorityBlockingQueue; -import java.util.concurrent.Semaphore; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -import shared.util.Control; - -/** - * An execution engine class for pushing data through the guts of some parallel computation given as a directed, acyclic - * graph. - * - * @apiviz.composedOf shared.parallel.Engine.ThrowableReferenceHandler - * @apiviz.composedOf shared.parallel.Engine.EngineEdge - * @apiviz.composedOf shared.parallel.Engine.EngineNode - * @apiviz.owns shared.parallel.TraversalPolicy - * @param - * the input type. - * @author Roy Liu - */ -public class Engine { - - final Semaphore guard, notifier; - final ThrowableReferenceHandler exceptionRef; - final Calculator startCalculator; - final Calculator stopCalculator; - final Map, EngineNode> nodeMap; - final TraversalPolicy, EngineEdge> policy; - final ThreadPoolExecutor executor; - - boolean valid; - - T engineInput; - - /** - * Alternate constructor. Creates an engine with the number of threads set to {@link Runtime#availableProcessors()} - * and {@link LimitedMemoryPolicy} for its {@link TraversalPolicy}. - */ - public Engine() { - this(Runtime.getRuntime().availableProcessors()); - } - - /** - * Alternate constructor. Creates an engine with {@link LimitedMemoryPolicy} for its {@link TraversalPolicy}. - * - * @param nthreads - * the number of threads. - */ - public Engine(int nthreads) { - this(nthreads, new LimitedMemoryPolicy, EngineEdge>()); - } - - /** - * Default constructor. - * - * @param nthreads - * the number of threads. - * @param policy - * the {@link TraversalPolicy} to apply when ordering nodes. - */ - public Engine(int nthreads, TraversalPolicy, EngineEdge> policy) { - - this.exceptionRef = new ThrowableReferenceHandler(); - this.executor = Control.createPool(nthreads, nthreads, // - new PriorityBlockingQueue(), // - this.exceptionRef); - - this.policy = policy; - - this.guard = new Semaphore(1); - this.notifier = new Semaphore(0); - - this.nodeMap = new LinkedHashMap, EngineNode>(); - - // The start calculation that merely propagates the engine's input. - this.startCalculator = new Calculator() { - - public T calculate(List> inputVector) { - return Engine.this.engineInput; - } - - @Override - public String toString() { - return "Start ()"; - } - }; - - this.nodeMap.put(this.startCalculator, // - new EngineNode(this.startCalculator, false)); - - // The token stop calculation that releases the semaphore guard. - this.stopCalculator = new Calculator() { - - public T calculate(List> inputVector) { - return null; - } - - @Override - public String toString() { - return "Stop ()"; - } - }; - - this.nodeMap.put(this.stopCalculator, // - - new EngineNode(this.stopCalculator, false) { - - @Override - public void run() { - - try { - - super.run(); - - } finally { - - // Make sure that the notifier semaphore is released no matter - // what. - Engine.this.notifier.release(); - } - } - }); - - this.valid = false; - this.engineInput = null; - } - - /** - * Gets the initial {@link Calculator}, which does nothing aside from repeating input given to it. - */ - public Calculator getInput() { - return this.startCalculator; - } - - /** - * Adds a non-output {@link Calculator} along with its dependencies. - * - * @see #add(Calculator, boolean, Collection) - */ - public void add( // - Calculator calc, // - Calculator... calcDeps // - ) { - add(calc, false, Arrays.asList(calcDeps)); - } - - /** - * Adds an output {@link Calculator} along with its dependencies. - * - * @see #add(Calculator, boolean, Collection) - * @return a {@link Handle} from which potential output can be retrieved. - */ - public Handle addOutput( // - Calculator calc, // - Calculator... calcDeps // - ) { - return add(calc, true, Arrays.asList(calcDeps)); - } - - /** - * Adds a {@link Calculator} along with its dependencies. - * - * @param - * the {@link Calculator} input type. - * @param - * the {@link Calculator} output type. - * @param calc - * the {@link Calculator}. - * @param hasOutput - * whether this node has observable output. - * @param calcDeps - * the dependencies. - * @return a {@link Handle} from which potential output can be retrieved. - */ - @SuppressWarnings("unchecked") - public Handle add( // - Calculator calc, boolean hasOutput, // - Collection> calcDeps // - ) { - - EngineNode node = new EngineNode(calc, hasOutput); - - Control.checkTrue(calcDeps.size() > 0, // - "Please specify some dependencies"); - - try { - - Control.checkTrue(this.guard.tryAcquire(), // - "Operation in progress"); - - // The ordering is no longer valid. - invalidate(); - - // Check everything before inserts. - Control.checkTrue(!this.nodeMap.containsKey(calc), // - "Node already exists"); - - for (Calculator calcDep : calcDeps) { - Control.checkTrue(this.nodeMap.containsKey(calcDep), // - "Node doesn't exist"); - } - - this.nodeMap.put(calc, node); - - for (Calculator calcDep : calcDeps) { - addEdge((EngineNode) this.nodeMap.get(calcDep), node); - } - - } finally { - - this.guard.release(); - } - - return node.hasOutput ? node : null; - } - - /** - * Executes with the given input. - * - * @param engineInput - * the input. - */ - public void execute(final T engineInput) { - - try { - - Control.checkTrue(this.guard.tryAcquire(), // - "Operation in progress"); - - validate(); - - // Reset reference counts in preparation for the new computation. - for (EngineNode node : this.nodeMap.values()) { - - // Invariant: Both reference counts should have reached zero. - Control.assertTrue(node.outRefCount.getAndSet(node.outputs.size()) == 0 // - && node.inRefCount.getAndSet(node.inputs.size()) == 0); - - node.set(null); - } - - // The queue size and the number of permits should be zero. - Control.assertTrue(this.notifier.availablePermits() == 0 // - && this.executor.getQueue().isEmpty()); - - // Prime the priority queue with a single element -- the input calculator. - this.engineInput = engineInput; - this.executor.execute(this.nodeMap.get(this.startCalculator)); - - // Try to acquire a number of permits equal to the number of nodes, thus guaranteeing - // termination of the computation upon return. - this.notifier.acquireUninterruptibly(); - - Throwable t = this.exceptionRef.getAndSet(null); - - // If the calculation internally encountered a problem. - if (t != null) { - Control.rethrow(t); - } - - } finally { - - this.guard.release(); - } - } - - /** - * Outputs human-readable directives for Dot graph generation. - */ - @Override - public String toString() { - - try { - - Control.checkTrue(this.guard.tryAcquire(), // - "Operation in progress"); - - validate(); - - EngineNode root = this.nodeMap.get(this.startCalculator); - EngineNode sink = this.nodeMap.get(this.stopCalculator); - - Formatter f = new Formatter(); - - f.format("%n/* Begin Node Specification */%n%n"); - f.format("\"%s (%d)\" [shape = diamond, color = green];%n", root, root.order); - f.format("\"%s (%d)\" [shape = diamond, color = green];%n", sink, sink.order); - - List> nodes = new ArrayList>(this.nodeMap.values()); - Collections.sort(nodes); - - for (EngineNode node : nodes) { - - if (node.hasOutput) { - - f.format("\"%s (%d)\" [shape = octagon, color = red];%n", node, node.order); - - } else if (!node.equals(root) && !node.equals(sink)) { - - f.format("\"%s (%d)\" [shape = rectangle, color = blue];%n", node, node.order); - } - } - - f.format("%n/* Begin Edge Specification */%n%n"); - - for (EngineNode node : nodes) { - - for (EngineEdge edge : node.outputs) { - - for (int i = 0, n = node.depth; i < n; i++) { - f.format("\t"); - } - - f.format("\"%s (%d)\" -> \"%s (%d)\"%n", // - edge.getU(), edge.getU().order, // - edge.getV(), edge.getV().order); - } - } - - return f.toString(); - - } finally { - - this.guard.release(); - } - } - - /** - * Computes a traversal ordering over the current configuration of {@link EngineNode}s. - */ - @SuppressWarnings("unchecked") - protected void validate() { - - if (!this.valid) { - - Collection> nodes = this.nodeMap.values(); - - EngineNode sink = // - (EngineNode) this.nodeMap.get(this.stopCalculator); - - // Unlink the output node. It had better be the case that a child knows about the output node. - for (EngineEdge edge : sink.inputs) { - Control.assertTrue(edge.getU().outputs.remove(edge)); - } - - sink.inputs.clear(); - - // Attach everything that's a sink to the fake sink. - for (EngineNode node : nodes) { - - if (node.outputs.size() == 0 && node != sink) { - addEdge(node, sink); - } - } - - // Assign priority order according to the traversal policy. - Control.assertTrue(this.policy.assign(sink) == nodes.size()); - - this.valid = true; - } - } - - /** - * Invalidates the current traversal ordering. - */ - protected void invalidate() { - this.valid = false; - } - - /** - * Links two {@link EngineNode}s by an {@link EngineEdge}. - * - * @param - * the output-input type. - */ - protected void addEdge(EngineNode u, EngineNode v) { - - EngineEdge e = new EngineEdge(u, v); - - u.outputs.add(e); - v.inputs.add(e); - } - - /** - * A computation node that is part of some topology of nodes. - * - * @apiviz.owns shared.parallel.Calculator - * @param - * the input type. - * @param - * the output type. - */ - protected class EngineNode implements Handle, Runnable, Traversable, EngineEdge> { - - final Calculator calculator; - final List> inputs; - final List> inputsReadOnly; - final List> outputs; - final List> outputsReadOnly; - - final AtomicInteger outRefCount, inRefCount; - - final boolean hasOutput; - - int order, depth; - - O value; - - /** - * Default constructor. - */ - public EngineNode(Calculator calculator, boolean hasOutput) { - - this.calculator = calculator; - this.hasOutput = hasOutput; - - this.inputs = new ArrayList>(); - this.inputsReadOnly = Collections.unmodifiableList(this.inputs); - this.outputs = new ArrayList>(); - this.outputsReadOnly = Collections.unmodifiableList(this.outputs); - - this.outRefCount = new AtomicInteger(0); - this.inRefCount = new AtomicInteger(0); - - this.order = (this.depth = -1); - - this.value = null; - } - - /** - * Compares traversal orders to determine priority of execution. - */ - public int compareTo(EngineNode node) { - return this.order - node.order; - } - - public O get() { - return this.value; - } - - public void set(O value) { - this.value = value; - } - - public int getOrder() { - return this.order; - } - - public void setOrder(int order) { - this.order = order; - } - - public int getDepth() { - return this.depth; - } - - public void setDepth(int depth) { - this.depth = depth; - } - - public List> getIn() { - return this.inputsReadOnly; - } - - public List> getOut() { - return this.outputsReadOnly; - } - - @Override - public String toString() { - return this.calculator.toString(); - } - - /** - * Executes the {@link Calculator#calculate(List)} method associated with this node. - */ - public void run() { - - try { - - this.value = this.calculator.calculate(this.inputsReadOnly); - - } catch (Throwable t) { - - Engine.this.exceptionRef.compareAndSet(null, t); - - Control.rethrow(t); - - } finally { - - for (int i = 0, n = this.inputs.size(), val; i < n; i++) { - - EngineNode node = this.inputs.get(i).getU(); - - // The node has all of its outputs observed; free its value. - if ((val = node.outRefCount.decrementAndGet()) == 0) { - - if (!node.hasOutput) { - node.set(null); - } - - } else { - - Control.assertTrue(val > 0); - } - } - - for (int i = 0, n = this.outputs.size(), val; i < n; i++) { - - EngineNode node = this.outputs.get(i).getV(); - - // The node in question has all of its inputs accounted for; insert it according - // to its traversal order. - if ((val = node.inRefCount.decrementAndGet()) == 0) { - - Engine.this.executor.execute(node); - - } else { - - Control.assertTrue(val > 0); - } - } - } - } - } - - /** - * An output-input relationship between two {@link Engine.EngineNode}s. - * - * @param - * the output-input type. - */ - protected class EngineEdge implements Handle, Edge> { - - final EngineNode u; - final EngineNode v; - - /** - * Default constructor. - */ - public EngineEdge(EngineNode u, EngineNode v) { - - this.u = u; - this.v = v; - } - - public EngineNode getU() { - return this.u; - } - - public EngineNode getV() { - return this.v; - } - - /** - * Delegates to the start {@link Engine.EngineNode}'s {@link #get()} method. - */ - public O get() { - return this.u.get(); - } - - public void setU(EngineNode node) { - throw new UnsupportedOperationException(); - } - - public void setV(EngineNode node) { - throw new UnsupportedOperationException(); - } - - public void set(O output) { - throw new UnsupportedOperationException(); - } - } - - /** - * A subclass of {@link AtomicReference} that doubles as an {@link UncaughtExceptionHandler}. It is set whenever an - * uncaught {@link Throwable} occurs. - */ - protected static class ThrowableReferenceHandler extends AtomicReference implements - UncaughtExceptionHandler { - - /** - * The UID for serialization purposes. - */ - final protected static long serialVersionUID = 1L; - - /** - * Default constructor. - */ - protected ThrowableReferenceHandler() { - } - - /** - * Sets this reference. - */ - public void uncaughtException(Thread thread, Throwable throwable) { - - // Set the exception only if one hasn't already occurred. - compareAndSet(null, throwable); - } - } - - // A finalizer guardian for the thread pool. - final Object poolReaper = new Object() { - - @Override - protected void finalize() { - Engine.this.executor.shutdownNow(); - } - }; -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Handle.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Handle.java deleted file mode 100755 index 247d1fdb..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Handle.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.parallel; - -/** - * Defines a container for storing the results of {@link Calculator}s. - * - * @param - * the storage type. - * @author Roy Liu - */ -public interface Handle { - - /** - * Gets the output. - */ - public O get(); - - /** - * Sets the output. - */ - public void set(O output); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/LimitedMemoryPolicy.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/LimitedMemoryPolicy.java deleted file mode 100755 index 501fb20f..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/LimitedMemoryPolicy.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.parallel; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import shared.parallel.Engine.EngineNode; -import shared.util.Control; - -/** - * An implementation of {@link TraversalPolicy} that attempts to conserve memory usage during parallel execution. - * - * @apiviz.composedOf shared.parallel.LimitedMemoryPolicy.PolicyNode - * @param - * the node type. - * @param - * the edge type. - * @author Roy Liu - */ -public class LimitedMemoryPolicy, E extends Edge> implements TraversalPolicy { - - /** - * Default constructor. - */ - public LimitedMemoryPolicy() { - } - - public int assign(V root) { - return assignDepthFirst(longestPath( // - root, // - new LinkedHashMap, PolicyNode>()), // - new LinkedHashSet(), // - new LinkedHashSet(), 0 // - ); - } - - /** - * Sorts a {@link PolicyNode}'s children in decreasing order of maximum distance from the source. - */ - final protected PolicyNode longestPath(Traversable curr, Map, PolicyNode> visitedMap) { - - // Visit the current node by adding a map entry. - PolicyNode currNode = new PolicyNode(curr); - - visitedMap.put(curr, currNode); - - for (Edge edge : curr.getIn()) { - - V child = edge.getU(); - - PolicyNode node = visitedMap.get(child); - - if (node == null) { - node = longestPath(child, visitedMap); - } - - currNode.maxDistance = Math.max(currNode.maxDistance, node.maxDistance); - currNode.children.add(node); - } - - // Sort in order of decreasing distance. - Collections.sort(currNode.children); - Collections.reverse(currNode.children); - - curr.setDepth(currNode.maxDistance++); - - return currNode; - } - - /** - * A recursive subroutine for assigning traversal orders while traversing the {@link PolicyNode} graph in a - * depth-first manner. - */ - final protected int assignDepthFirst(PolicyNode node, // - Set partiallyVisited, // - Set completelyVisited, // - int dfsCtr) { - - // Partially visit the current node. - partiallyVisited.add(node); - - for (PolicyNode child : node.children) { - - Control.checkTrue(!partiallyVisited.contains(child), // - "Dependency cycle detected"); - - if (!completelyVisited.contains(child)) { - dfsCtr = assignDepthFirst(child, partiallyVisited, completelyVisited, dfsCtr); - } - } - - // Completely visited the current node. - partiallyVisited.remove(node); - completelyVisited.add(node); - - node.handle.setOrder(dfsCtr); - - return dfsCtr + 1; - } - - /** - * An {@link EngineNode} proxy class that aids in the computation of traversal orderings. - */ - protected class PolicyNode implements Comparable { - - final Traversable handle; - final List children; - - int maxDistance; - - /** - * Default constructor. - */ - protected PolicyNode(Traversable handle) { - - this.handle = handle; - this.children = new ArrayList(); - - this.maxDistance = 0; - } - - /** - * Compares maximum distance from the source. - */ - public int compareTo(PolicyNode rhs) { - return this.maxDistance - rhs.maxDistance; - } - - /** - * Delegates to the {@link Traversable}'s {@link Traversable#toString()} method. - */ - @Override - public String toString() { - return this.handle.toString(); - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Traversable.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Traversable.java deleted file mode 100755 index 77862f4f..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/Traversable.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.parallel; - -import java.util.List; - -/** - * Defines a graph node as part of some total ordering on graph nodes. - * - * @param - * the node type. - * @param - * the edge type. - * @author Roy Liu - */ -public interface Traversable, E extends Edge> extends Comparable { - - /** - * Gets the order. - */ - public int getOrder(); - - /** - * Sets the order. - */ - public void setOrder(int order); - - /** - * Gets the depth. - */ - public int getDepth(); - - /** - * Sets the depth. - */ - public void setDepth(int depth); - - /** - * Gets the incoming edges. - */ - public List getIn(); - - /** - * Gets the outgoing edges. - */ - public List getOut(); - - /** - * Creates a human-readable representation of this node. - */ - @Override - public String toString(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/TraversalPolicy.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/TraversalPolicy.java deleted file mode 100755 index 0e576964..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/TraversalPolicy.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.parallel; - -/** - * Defines a total ordering and depth assignment to a collection of {@link Traversable}s via - * {@link Traversable#setOrder(int)} and {@link Traversable#setDepth(int)}. The modifications serve as a hint to - * {@link Engine} and do not affect the correctness of the calculation. - * - * @apiviz.owns shared.parallel.Traversable - * @param - * the node type. - * @param - * the edge type. - * @author Roy Liu - */ -public interface TraversalPolicy, E extends Edge> { - - /** - * Makes a total ordering and depth assignment to all nodes reachable from the given node. - * - * @param root - * the given node. - * @return the number of nodes visited. - */ - public int assign(V root); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/parallel/package-info.java deleted file mode 100755 index 0235f6be..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/parallel/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A framework for specifying and executing parallel dataflow engines. - */ -package shared.parallel; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/project.properties b/contrib/applications/nxplot/sharedscientific/src/shared/project.properties deleted file mode 100755 index 29ceaa46..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/project.properties +++ /dev/null @@ -1,3 +0,0 @@ -### Properties with values specific to the SST. ### - -build.version = 1.10 diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/AbstractGMModel.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/AbstractGMModel.java deleted file mode 100755 index a1f76ae5..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/AbstractGMModel.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.ml; - -import shared.array.RealArray; - -/** - * An abstract base class for Gaussian mixture models characterized by their initialization and update rules. - * - * @apiviz.owns shared.stat.ml.GMComponents - * @author Roy Liu - */ -abstract public class AbstractGMModel { - - /** - * Default constructor. - */ - protected AbstractGMModel() { - } - - /** - * Trains the model. - * - * @param points - * the input. - * @param ncomps - * the number of components. - * @param regularization - * the regularization hint. - * @param delta - * the change in likelihood required for termination. - * @return the mixture components trained. - */ - public GMComponents train(final RealArray points, int ncomps, double regularization, double delta) { - - // Convert to a list of points. - GMComponents gmc = initialize(points, ncomps, regularization); - - int nrounds = 0; - - for (double currentLL = -Double.MAX_VALUE / 4.0, previousLL = 2.0 * currentLL; // - currentLL - previousLL > delta;) { - - previousLL = currentLL; - update(gmc, computePosterior(gmc, points), points, regularization); - currentLL = gmc.likelihood; - - nrounds++; - - gmc.nrounds = nrounds; - } - - return gmc; - } - - /** - * Computes the posterior distribution and updates the mean likelihood of the points. - * - * @param gmc - * the mixture components. - * @param points - * the input. - * @return the posterior distribution p(components | points). - */ - public RealArray computePosterior(GMComponents gmc, RealArray points) { - - int ncomps = gmc.weights.size(0); - - // The log of the weighted densities has dimensions (ncomps, npoints). - RealArray logWeightedDensities = computeLogWeightedDensities(gmc, points); - RealArray rowMax = logWeightedDensities.rMax(0); - - // Compute the normalized posterior for numerical stability. - RealArray posterior = logWeightedDensities.eSub(rowMax.tile(ncomps, 1)).uExp(); - RealArray rowSum = posterior.rSum(0); - - // Normalize the posterior. - posterior = posterior.lDiv(rowSum.tile(ncomps, 1)); - - // Calculate the total log-likelihood. - gmc.likelihood = (rowSum.clone().uAdd(1e-64).uLog()).lAdd(rowMax).aMean(); - - return posterior; - } - - /** - * Performs the update rule. - * - * @param gmc - * the mixture components. - * @param posterior - * the posterior distribution p(components | points). - * @param points - * the input. - * @param regularization - * the regularization hint. - */ - abstract protected void update(GMComponents gmc, RealArray posterior, RealArray points, double regularization); - - /** - * Initializes the mixture components. - * - * @param points - * the input. - * @param ncomps - * the number of components. - * @param regularization - * the regularization hint. - * @return the initial mixture components. - */ - abstract protected GMComponents initialize(RealArray points, int ncomps, double regularization); - - /** - * Computes the log of the weighted densities. - * - * @param gmc - * the mixture components. - * @param points - * the input. - * @return the log of p(points | components). - */ - abstract protected RealArray computeLogWeightedDensities(GMComponents gmc, RealArray points); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/GMComponents.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/GMComponents.java deleted file mode 100755 index 0d4b5d0f..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/GMComponents.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.ml; - -import shared.array.RealArray; - -/** - * A data structure containing information on Gaussian mixture components. - * - * @author Roy Liu - */ -public class GMComponents { - - /** - * The weights. - */ - final public RealArray weights; - - /** - * The centers. - */ - final public RealArray centers; - - /** - * The (diagonal) covariances. - */ - final public RealArray covariances; - - /** - * The likelihood. Updates every time one obtains a new likelihood from the M step. - */ - public double likelihood; - - /** - * The number of rounds so far. - */ - public int nrounds; - - /** - * Default constructor. - * - * @param ncomponents - * the number of components. - * @param ndims - * the dimensionality expected of the data. - */ - public GMComponents(int ncomponents, int ndims) { - - this.weights = new RealArray(ncomponents, 1); - this.centers = new RealArray(ncomponents, ndims); - this.covariances = new RealArray(ncomponents, ndims); - - this.likelihood = Double.NaN; - this.nrounds = -1; - } - - /** - * Regularizes the covariances by setting a floor on what they can be. - * - * @param regularization - * the regularization hint. - */ - public void regularize(double regularization) { - - double[] values = this.covariances.values(); - - // Apply regularization. - for (int i = 0, n = values.length; i < n; i++) { - values[i] = Math.max(values[i], regularization); - } - } - - /** - * Creates a human-readable representation of the mixture components. - */ - @Override - public String toString() { - return String.format("%n" // - + "centers =%n" // - + "%s%n" // - + "sqrt(covariances) =%n" // - + "%s%n" // - + "weights =%n" // - + "%s%n" // - + "likelihood = %4.4e%n%n" // - + "nrounds = %d%n", // - this.centers, this.covariances.clone().uSqrt(), this.weights, this.likelihood, this.nrounds); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/GMModel.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/GMModel.java deleted file mode 100755 index 985bbc9c..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/GMModel.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.ml; - -import java.util.List; - -import shared.array.RealArray; -import shared.util.Control; - -/** - * An implementation of {@link AbstractGMModel} using EM updates on GMM's with diagonal covariances. Inspired by Lawrence Saul's EM code. - * - * @apiviz.uses shared.stat.ml.KMeans - * @author Roy Liu - */ -public class GMModel extends AbstractGMModel { - - /** - * Default constructor. - */ - public GMModel() { - } - - @Override - public GMComponents initialize(RealArray input, int ncomps, double regularization) { - - int ndims = input.size(1); - - GMComponents gmc = new GMComponents(ncomps, ndims); - - List clusters = KMeans.cluster(ncomps, input); - - // Assign the covariances to be the global covariance. - RealArray globalSum = input.rSum(0); - RealArray globalMean = input.rMean(0); - - (globalSum.clone().uSqr().uMul(1.0 / input.size(0))) // - .lSub(globalMean.eMul(globalMean)).uAdd(regularization) // - .tile(ncomps, 1) // - .map(gmc.covariances, 0, 0, ncomps, 0, 0, ndims); - - // Assign the means to be the cluster means. - for (int i = 0; i < ncomps; i++) { - clusters.get(i).rMean(0).map(gmc.centers, 0, i, 1, 0, 0, ndims); - } - - // Every component starts out as equally likely. - gmc.weights.uFill(1.0 / ncomps); - - return gmc; - } - - @Override - public void update(GMComponents gmc, RealArray posterior, RealArray points, double regularization) { - - int ncomps = gmc.weights.size(0); - int ndims = points.size(1); - int npoints = Control.checkEquals(points.size(0), posterior.size(1)); - - RealArray colSum = posterior.rSum(1); - - // The normalization has dimensions (ncomps, ndims). - RealArray nrmp = colSum.tile(1, ndims).uAdd(1e-64); - - // Update the means. - - posterior.mMul(points).lDiv(nrmp) // - .map(gmc.centers, 0, 0, ncomps, 0, 0, ndims); - - // Update the covariances. - - posterior.mMul(points.clone().uSqr()).lDiv(nrmp) // - .lSub(gmc.centers.clone().uSqr()) // - .map(gmc.covariances, 0, 0, ncomps, 0, 0, ndims); - - gmc.regularize(regularization); - - // Update the weights. - - colSum.map(gmc.weights, 0, 0, ncomps, 0, 0, 1).uMul(1.0 / npoints); - } - - @Override - public RealArray computeLogWeightedDensities(GMComponents gmc, RealArray points) { - - int npoints = points.size(0); - - RealArray iCov = gmc.covariances.clone().uInv(1.0); - - RealArray nrmTiled = // - (gmc.centers.clone().uSqr().lMul(iCov)) // - .lAdd(gmc.covariances.clone().uLog()) // - .rSum(1).tile(1, npoints); - - RealArray pointsT = points.transpose(1, 0); - - RealArray logWeightsTiled = gmc.weights.tile(1, npoints).uAdd(1e-64).uLog(); - - RealArray exponent = (iCov.mMul(pointsT.clone().uSqr())) // - .lAdd(gmc.centers.eMul(iCov).mMul(pointsT).uMul(-2.0)) // - .lAdd(nrmTiled).uMul(-0.5); - - return exponent.lAdd(logWeightsTiled); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/KMeans.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/KMeans.java deleted file mode 100755 index dedaaddc..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/KMeans.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.ml; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Random; - -import shared.array.RealArray; -import shared.util.Arithmetic; -import shared.util.Control; - -/** - * A class for K-Means clustering with subset furthest first initialization. - * - * @author Roy Liu - */ -public class KMeans { - - /** - * Computes point-to-point distances. - * - * @param aPts - * the origin points. - * @param bPts - * the destination points. - * @return a {@link RealArray} of distances. - */ - final public static RealArray distances(RealArray aPts, RealArray bPts) { - - int ndims = Control.checkEquals(aPts.size(1), bPts.size(1)); - int naPts = aPts.size(0), nbPts = bPts.size(0); - - RealArray acc = new RealArray(naPts, nbPts); - - for (int dim = 0; dim < ndims; dim++) { - acc = acc.lAdd(aPts.subarray(0, aPts.size(0), dim, dim + 1).tile(1, nbPts) // - .lSub(bPts.subarray(0, bPts.size(0), dim, dim + 1) // - .transpose(1, 0).tile(naPts, 1)).uSqr()); - } - - return acc.uSqrt(); - } - - /** - * Groups a set of points into the given number of clusters. - * - * @param nclusters - * the number of clusters. - * @param points - * the input. - * @return a {@link List} of clusters. - */ - final public static List cluster(int nclusters, RealArray points) { - - int npoints = points.size(0); - int ndims = points.size(1); - - Control.checkTrue(npoints >= nclusters); - - // Subset furthest first initialization of centers. - RealArray centers = subsetFurthestFirst(nclusters, points); - - int[] memberships = shared.util.Arrays.newArray(npoints, -1), newMemberships; - - for (;;) { - - newMemberships = distances(centers, points).iMin(0).subarray(0, 1, 0, points.size(0)).values(); - - int ncenters = centers.size(0); - - // Create the clusters. - - int[] counts = new int[ncenters]; - - for (int i = 0; i < npoints; i++) { - counts[newMemberships[i]]++; - } - - RealArray[] clusters = new RealArray[ncenters]; - - for (int i = 0; i < ncenters; i++) { - clusters[i] = new RealArray(counts[i], ndims); - } - - // Build clusters and increment counts. - counts = new int[ncenters]; - - for (int i = 0; i < npoints; i++) { - - points.map(clusters[newMemberships[i]], // - i, counts[newMemberships[i]], 1, // - 0, 0, ndims); - - counts[newMemberships[i]]++; - } - - // Compute new centers. - - int nnonzero = 0; - - for (int i = 0; i < ncenters; i++) { - - if (clusters[i].size(0) > 0) { - - clusters[i].rMean(0).map(centers, // - 0, nnonzero, 1, // - 0, 0, ndims); - - nnonzero++; - } - } - - // This should happen VERY rarely. - for (int i = nnonzero; i < ncenters; i++) { - centers.subarray(0, i, 0, centers.size(1)).rMean(0).map(centers, // - 0, i, 1, // - 0, 0, ndims); - } - - // Check for convergence and return if necessary. - - if (Arrays.equals(newMemberships, memberships)) { - - return Arrays.asList(clusters); - - } else { - - memberships = newMemberships; - } - } - } - - /** - * Performs subset furthest first initialization. - * - * @param ncenters - * the number of centers. - * @param points - * the collection of points. - * @return a collection of centers. - */ - final protected static RealArray subsetFurthestFirst(int ncenters, RealArray points) { - - int ndims = points.size(1); - int nsamples = Math.min(points.size(0), 2 * ncenters * (int) (Math.log(ncenters + 1) + 1)); - - // Make the permutation predictable and sample from a subset. - int[] perm = Arithmetic.range(points.size(0)); - Collections.shuffle(Arrays.asList(perm), new Random(Arrays.hashCode(points.values()))); - - RealArray samples = new RealArray(nsamples, ndims); - - for (int i = 0; i < nsamples; i++) { - points.map(samples, // - perm[i], i, 1, // - 0, 0, ndims); - } - - // - - RealArray res = samples.map(new RealArray(ncenters, ndims), // - 0, 0, 1, // - 0, 0, ndims); - - for (int i = 1; i < ncenters; i++) { - - RealArray d = distances(res.subarray(0, i, 0, res.size(1)), samples); - - samples.map(res, // - d.rMin(0).iMax(1).get(0, 0), i, 1, // - 0, 0, ndims); - } - - return res; - } - - // Dummy constructor. - KMeans() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/package-info.java deleted file mode 100755 index 58be9c3b..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/ml/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of machine learning algorithms. - */ -package shared.stat.ml; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/package-info.java deleted file mode 100755 index 229147fd..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of statistical tools for scientists and machine learners. - */ -package shared.stat; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/DataStyle.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/DataStyle.java deleted file mode 100755 index e20c6723..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/DataStyle.java +++ /dev/null @@ -1,215 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.event.EnumType; -import shared.util.Control; - -/** - * A container class for dataset rendering style information. - * - * @apiviz.owns shared.stat.plot.DataStyle.DataStyleType - * @author Roy Liu - */ -public class DataStyle implements EnumType { - - /** - * An enumeration of {@link DataStyle} types. - */ - public enum DataStyleType { - - /** - * Indicates lines. - */ - LINES, // - - /** - * Indicates points. - */ - POINTS, // - - /** - * Indicates lines and points. - */ - LINESPOINTS, // - - /** - * Indicates bars. - */ - BARS, // - - /** - * Indicates that the data induces a surface. - */ - SURFACE; - }; - - /** - * The default style for {@link DataStyleType#LINES}. - */ - final public static DataStyle Lines = new DataStyle(DataStyleType.LINES); - - /** - * The default style for {@link DataStyleType#POINTS}. - */ - final public static DataStyle Points = new DataStyle(DataStyleType.POINTS); - - /** - * The default style for {@link DataStyleType#LINESPOINTS}. - */ - final public static DataStyle LinesPoints = new DataStyle(DataStyleType.LINESPOINTS); - - /** - * The default style for {@link DataStyleType#BARS}. - */ - final public static DataStyle Bars = new DataStyle(DataStyleType.BARS); - - /** - * The default style for {@link DataStyleType#SURFACE}. - */ - final public static DataStyle Surface = new DataStyle(DataStyleType.SURFACE); - - final DataStyleType type; - - String lineStyle; - String lineColor; - - Double lineSize; - - String pointStyle; - String pointColor; - - Double pointSize; - - /** - * Default constructor. - */ - public DataStyle(DataStyleType type) { - - this.type = type; - - Control.checkTrue(type != null, // - "Invalid arguments"); - } - - public DataStyleType getType() { - return this.type; - } - - /** - * Gets the line style. - */ - public String getLineStyle() { - return this.lineStyle; - } - - /** - * Sets the line style. - */ - public DataStyle setLineStyle(String lineStyle) { - - this.lineStyle = lineStyle; - - return this; - } - - /** - * Gets the line color. - */ - public String getLineColor() { - return this.lineColor; - } - - /** - * Sets the line color. - */ - public DataStyle setLineColor(String lineColor) { - - this.lineColor = lineColor; - - return this; - } - - /** - * Gets the line size. - */ - public Double getLineSize() { - return this.lineSize; - } - - /** - * Sets the line size. - */ - public DataStyle setLineSize(Double lineSize) { - - this.lineSize = lineSize; - - return this; - } - - /** - * Gets the point style. - */ - public String getPointStyle() { - return this.pointStyle; - } - - /** - * Sets the point style. - */ - public DataStyle setPointStyle(String pointStyle) { - - this.pointStyle = pointStyle; - - return this; - } - - /** - * Gets the point color. - */ - public String getPointColor() { - return this.pointColor; - } - - /** - * Sets the point color. - */ - public DataStyle setPointColor(String pointColor) { - - this.pointColor = pointColor; - - return this; - } - - /** - * Gets the point size. - */ - public Double getPointSize() { - return this.pointSize; - } - - /** - * Sets the point size. - */ - public DataStyle setPointSize(Double pointSize) { - - this.pointSize = pointSize; - - return this; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ErrorDistribution.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ErrorDistribution.java deleted file mode 100755 index db448fdb..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ErrorDistribution.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.array.RealArray; -import shared.stat.plot.Plot.AxisType; -import shared.util.Arrays; -import shared.util.Control; - -/** - * A base class for {@link PrecisionRecall} and {@link ROC}. - * - * @author Roy Liu - */ -abstract public class ErrorDistribution implements Plottable { - - /** - * The datasets. - */ - final protected RealArray[] datasets; - - /** - * The data titles. - */ - final protected String[] dataTitles; - - /** - * The {@link DataStyle}s. - */ - final protected DataStyle[] dataStyles; - - /** - * Default constructor. - * - * @param confidencesArray - * the array of prediction confidences. - * @param outcomesArray - * the array of prediction outcomes. - */ - public ErrorDistribution(double[][] confidencesArray, boolean[][] outcomesArray) { - - int nclasses = Control.checkEquals(confidencesArray.length, outcomesArray.length); - - this.datasets = new RealArray[nclasses]; - - for (int i = 0; i < nclasses; i++) { - - int nexamples = Control.checkEquals(confidencesArray[i].length, outcomesArray[i].length); - - double[] confidences = new double[nexamples]; - boolean[] outcomes = new boolean[nexamples]; - - RealArray dataset = new RealArray(nexamples, 2); - - int[] perm = new RealArray(confidencesArray[i]).clone().iSort(0).reverse(0).values(); - - for (int j = 0; j < nexamples; j++) { - - confidences[j] = confidencesArray[i][perm[j]]; - outcomes[j] = outcomesArray[i][perm[j]]; - } - - initDataset(dataset, outcomes); - - this.datasets[i] = dataset; - } - - this.dataTitles = PlotBase.createDefaultTitles(nclasses); - this.dataStyles = Arrays.newArray(DataStyle.class, nclasses, DataStyle.Lines); - } - - /** - * Gets the AUC's (area under curves). - */ - public double[] getAUCs() { - - double[] aucs = new double[this.datasets.length]; - - for (int i = 0, n = this.datasets.length; i < n; i++) { - - RealArray dataset = this.datasets[i]; - - RealArray xarr = dataset.subarray(0, dataset.size(0), 0, 1); - RealArray yarr = dataset.subarray(0, dataset.size(0), 1, 2); - - aucs[i] = xarr.eSub(xarr.shift(1, 0)).eMul(yarr.eAdd(yarr.shift(1, 0))).uMul(0.5) // - .subarray(1, dataset.size(0), 0, dataset.size(1)).rSum(0).get(0, 0); - } - - return aucs; - } - - public RealArray[] getDatasets() { - return this.datasets; - } - - public String[] getDataTitles() { - return this.dataTitles; - } - - public DataStyle[] getDataStyles() { - return this.dataStyles; - } - - public boolean getPropertyEnabled(String property) { - return (property.equals("legend") || property.equals("grid")); - } - - public String getAxisTitle(AxisType axisType) { - - switch (axisType) { - - case X: - return getXAxisTitle(); - - case Y: - return getYAxisTitle(); - - default: - throw new IllegalArgumentException("Invalid axis type"); - } - } - - public double[] getAxisRange(AxisType axisType) { - - switch (axisType) { - - case X: - return getXAxisRange(); - - case Y: - return getYAxisRange(); - - default: - throw new IllegalArgumentException("Invalid axis type"); - } - } - - /** - * Initializes the given dataset. - * - * @param dataset - * the dataset. - * @param outcomes - * the prediction outcomes. - */ - abstract protected void initDataset(RealArray dataset, boolean[] outcomes); - - /** - * Gets the x-axis title. - */ - abstract protected String getXAxisTitle(); - - /** - * Gets the y-axis title. - */ - abstract protected String getYAxisTitle(); - - /** - * Gets the x-axis range. - */ - abstract protected double[] getXAxisRange(); - - /** - * Gets the y-axis range. - */ - abstract protected double[] getYAxisRange(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/GnuplotContext.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/GnuplotContext.java deleted file mode 100755 index 836460f4..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/GnuplotContext.java +++ /dev/null @@ -1,600 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Formatter; -import java.util.List; - -import shared.array.RealArray; -import shared.stat.plot.Plot.AxisScaleType; -import shared.stat.plot.Plot.AxisType; -import shared.util.Control; - -/** - * A Gnuplot-backed implementation of {@link PlotContext}. - * - * @apiviz.composedOf shared.stat.plot.GnuplotContext.Gnuplot - * @apiviz.uses shared.stat.plot.PlotBase - * @author Roy Liu - */ -public class GnuplotContext implements PlotContext { - - /** - * An array of operating system dependent arguments to execute Gnuplot. - */ - final protected static String[] GnuplotExecArgs; - - /** - * The property that toggles the legend. - */ - final public static String PROPERTY_LEGEND = "legend"; - - /** - * The property that toggles the grid. - */ - final public static String PROPERTY_GRID = "grid"; - - /** - * The property that toggles the mesh. - */ - final public static String PROPERTY_MESH = "mesh"; - - /** - * The property that toggles the colormap. - */ - final public static String PROPERTY_COLORMAP = "colormap"; - - static { - - boolean isWindows = System.getProperty("os.name").contains("Windows"); - - GnuplotExecArgs = isWindows ? new String[] { "cmd", "/C", "gnuplot.exe" } // - : new String[] { "gnuplot" }; - } - - final List plots; - - String fontName; - - int fontSize; - - String outputFormat; - - int outputWidth; - int outputHeight; - - /** - * Default constructor. - */ - public GnuplotContext() { - - this.plots = new ArrayList(); - - this.fontName = "Helvetica"; - this.fontSize = 8; - this.outputFormat = "svg"; - this.outputWidth = 800; - this.outputHeight = 600; - } - - public Gnuplot addPlot(Plottable plottable) { - - final Gnuplot gp = new Gnuplot(plottable.getDatasets()); - - for (int dim = 0, ndims = gp.ndims; dim < ndims; dim++) { - - AxisType axisType = AxisType.values()[dim]; - - double[] range = plottable.getAxisRange(axisType); - - gp.setAxisRange(axisType, range[0], range[1]) // - .setAxisTitle(axisType, plottable.getAxisTitle(axisType)); - } - - gp.setTitle(plottable.getTitle()) // - .setDataStyles(plottable.getDataStyles()) // - .setDataTitles(plottable.getDataTitles()) // - .setPropertyEnabled(PROPERTY_LEGEND, // - plottable.getPropertyEnabled(PROPERTY_LEGEND)) // - .setPropertyEnabled(PROPERTY_GRID, // - plottable.getPropertyEnabled(PROPERTY_GRID)) // - .setPropertyEnabled(PROPERTY_MESH, // - plottable.getPropertyEnabled(PROPERTY_MESH)) // - .setPropertyEnabled(PROPERTY_COLORMAP, // - plottable.getPropertyEnabled(PROPERTY_COLORMAP)); - - this.plots.add(gp); - - return gp; - } - - public Gnuplot addPlot(RealArray... datasets) { - - final Gnuplot gp = new Gnuplot(datasets); - - this.plots.add(gp); - - return gp; - } - - public void toFile(File file) throws IOException { - - File errFile = new File(file.toString().concat(".log")); - - FileOutputStream out = new FileOutputStream(file); - FileOutputStream errOut = new FileOutputStream(errFile); - - try { - - Control.execAndWaitFor(new ByteArrayInputStream(toString().getBytes()), out, errOut, // - GnuplotExecArgs); - - } catch (IOException e) { - - e.printStackTrace(new PrintStream(errOut)); - - } finally { - - Control.close(out); - Control.close(errOut); - } - - if (errFile.length() == 0) { - Control.delete(errFile); - } - } - - /** - * Creates Gnuplot directives for rendering this context. - */ - @Override - public String toString() { - - final String configStr; - - if (this.outputFormat.equals("eps")) { - - configStr = String.format("postscript eps color font \"%s\" %d", // - this.fontName, this.fontSize); - - } else if (this.outputFormat.equals("png")) { - - configStr = String.format("png truecolor font \"%s\" %d size %d, %d", // - this.fontName, this.fontSize, // - this.outputWidth, this.outputHeight); - - } else if (this.outputFormat.equals("svg")) { - - configStr = String.format("svg fname \"%s\" fsize %d size %d, %d", // - this.fontName, this.fontSize, // - this.outputWidth, this.outputHeight); - - } else { - - throw new IllegalArgumentException( // - String.format("Output format '%s' not recognized", this.outputFormat)); - } - - Formatter f = new Formatter(); - - f.format("set terminal %s%n", configStr); - f.format("set output%n"); - f.format("set size 1.0, 1.0%n"); - // Create a better-looking colormap. - f.format("set palette rgbformulae 22, 13, -31%n"); - f.format("set multiplot%n"); - - int maxWidth = 1; - int maxHeight = 1; - - for (Gnuplot plot : this.plots) { - - maxWidth = Math.max(maxWidth, plot.panelX + plot.panelWidth); - maxHeight = Math.max(maxHeight, plot.panelY + plot.panelHeight); - } - - for (Gnuplot plot : this.plots) { - - int ndims = plot.ndims; - int nclasses = plot.datasets.length; - - f.format("set origin %.4f, %.4f%n", // - plot.panelX / (double) maxWidth, // - (maxHeight - plot.panelY - plot.panelHeight) / (double) maxHeight); - f.format("set size %.4f, %.4f%n", // - plot.panelWidth / (double) maxWidth, // - plot.panelHeight / (double) maxHeight); - f.format("set title \"%s\"%n", plot.title); - f.format("%s%n", plot.isLegendEnabled ? "set key box below right" : "unset key"); - - int meshSize = 0; - - if (plot.isMeshEnabled) { - - for (RealArray data : plot.datasets) { - meshSize = Math.max(data.size(0), meshSize); - } - } - - meshSize = (int) Math.sqrt(meshSize) + 1; - - f.format("%s%n", plot.isGridEnabled ? "set grid" : "unset grid"); - f.format("%s%n", plot.isMeshEnabled ? String.format("set dgrid3d %d, %d", meshSize, meshSize) - : "unset dgrid3d"); - f.format("%s%n", plot.isColormapEnabled ? "set pm3d" : "unset pm3d"); - f.format("%s%n", (plot.viewportParameters != null) ? String.format("set view %.2f, %.2f", // - plot.viewportParameters[0], plot.viewportParameters[1]) : "unset view"); - - for (int dim = 0; dim < ndims; dim++) { - - String axisName = AxisType.values()[dim].toString().toLowerCase(); - - f.format("set %srange [%.4e:%.4e]%n", axisName, // - plot.axisRanges[2 * dim], plot.axisRanges[2 * dim + 1]); - f.format("set %slabel \"%s\"%n", axisName, plot.axisTitles[dim]); - f.format("%s logscale %s%n", // - (plot.axisScaleTypes[dim] == AxisScaleType.LOG) ? "set" : "unset", // - axisName); - } - - for (int i = 0; i < nclasses; i++) { - f.format("set style line %d%s%n", i + 1, createLineStyleDefinition(plot.dataStyles[i])); - } - - final String plotStr; - - switch (plot.ndims) { - - case 2: - plotStr = "plot"; - break; - - case 3: - plotStr = "splot"; - break; - - default: - throw new IllegalArgumentException(); - } - - f.format("%s ", plotStr); - - for (int i = 0; i < nclasses; i++) { - - DataStyle style = plot.dataStyles[i]; - - String styleStr; - - switch (style.getType()) { - - case LINES: - styleStr = "lines"; - break; - - case POINTS: - styleStr = "points"; - break; - - case LINESPOINTS: - styleStr = "linespoints"; - break; - - case BARS: - styleStr = "boxes"; - break; - - case SURFACE: - styleStr = "pm3d"; - break; - - default: - throw new IllegalArgumentException(); - } - - f.format("\"-\" title \"%s\" with %s ls %d", plot.dataTitles[i], styleStr, i + 1); - f.format((i < nclasses - 1) ? ", " : "%n"); - } - - for (int i = 0; i < nclasses; i++) { - - RealArray data = plot.datasets[i]; - - for (int j = 0, m = data.size(0); j < m; j++) { - - for (int dim = 0; dim < ndims; dim++) { - - f.format("%.4e", data.get(j, dim)); - f.format((dim < ndims - 1) ? " " : "%n"); - } - } - - f.format("e%n"); - } - - f.format("unset style line%n"); - } - - f.format("unset multiplot%n"); - - return f.toString(); - } - - public GnuplotContext setFont(String fontName, int fontSize) { - - this.fontName = fontName; - this.fontSize = fontSize; - - return this; - } - - public GnuplotContext setOutputFormat(String outputFormat) { - - this.outputFormat = outputFormat; - - return this; - } - - public GnuplotContext setOutputSize(int outputWidth, int outputHeight) { - - this.outputHeight = outputHeight; - this.outputWidth = outputWidth; - - return this; - } - - /** - * Creates a Gnuplot line style definition from the given {@link DataStyle}. - */ - final protected static String createLineStyleDefinition(DataStyle style) { - - Formatter f = new Formatter(); - - String lt = style.getLineStyle(); - String lc = style.getLineColor(); - Double lw = style.getLineSize(); - String pt = style.getPointStyle(); - Double ps = style.getPointSize(); - - if (lt != null) { - f.format(" lt %s", lt); - } - - if (lc != null) { - f.format(" lc rgb \"%s\"", lc); - } - - if (lw != null) { - f.format(" lw %.2f", lw); - } - - if (pt != null) { - f.format(" pt %s", pt); - } - - if (ps != null) { - f.format(" ps %.2f", ps); - } - - String res = f.toString(); - return !res.equals("") ? f.toString() : " default"; - } - - /** - * An internal implementation of {@link Plot}. - */ - public static class Gnuplot implements Plot { - - final String[] axisTitles; - final AxisScaleType[] axisScaleTypes; - final double[] axisRanges; - - final int ndims; - final RealArray[] datasets; - final String[] dataTitles; - final DataStyle[] dataStyles; - - double[] viewportParameters; - - String title; - - boolean isLegendEnabled; - boolean isGridEnabled; - boolean isMeshEnabled; - boolean isColormapEnabled; - - int panelX; - int panelY; - int panelWidth; - int panelHeight; - - /** - * Default constructor. - */ - public Gnuplot(RealArray[] datasets) { - - int nclasses = datasets.length; - - this.ndims = PlotBase.inferDimensionality(datasets); - - Control.checkTrue(this.ndims >= 2 && this.ndims <= 3, // - "The dimensionality must be either two or three"); - - this.axisTitles = shared.util.Arrays.newArray(String.class, this.ndims, ""); - this.axisScaleTypes = shared.util.Arrays.newArray(AxisScaleType.class, this.ndims, AxisScaleType.NORMAL); - this.axisRanges = new double[2 * this.ndims]; - - this.datasets = datasets; - this.dataTitles = shared.util.Arrays.newArray(String.class, nclasses, ""); - this.dataStyles = shared.util.Arrays.newArray(DataStyle.class, nclasses, DataStyle.Points); - - for (int i = 0, n = 2 * this.ndims; i < n; i += 2) { - - this.axisRanges[i] = 0.0; - this.axisRanges[i + 1] = 1.0; - } - - this.viewportParameters = null; - this.title = ""; - this.isLegendEnabled = false; - this.isGridEnabled = false; - this.isMeshEnabled = false; - this.isColormapEnabled = false; - this.panelX = 0; - this.panelY = 0; - this.panelWidth = 1; - this.panelHeight = 1; - } - - public Gnuplot setTitle(String title) { - - this.title = title; - - return this; - } - - public Gnuplot setAxis(AxisType axisType, String axisTitle, double lower, double upper, - AxisScaleType axisScaleType) { - - int dim = axisType.ordinal(); - - Control.checkTrue(dim < this.ndims, // - "Invalid axis type"); - - this.axisTitles[dim] = axisTitle; - this.axisRanges[2 * dim] = lower; - this.axisRanges[2 * dim + 1] = upper; - this.axisScaleTypes[dim] = axisScaleType; - - return this; - } - - public Gnuplot setAxisTitle(AxisType axisType, String axisTitle) { - - int dim = axisType.ordinal(); - - Control.checkTrue(dim < this.ndims, // - "Invalid axis type"); - - this.axisTitles[dim] = axisTitle; - - return this; - } - - public Gnuplot setAxisRange(AxisType axisType, double lower, double upper) { - - int dim = axisType.ordinal(); - - Control.checkTrue(dim < this.ndims, // - "Invalid axis type"); - - this.axisRanges[2 * dim] = lower; - this.axisRanges[2 * dim + 1] = upper; - - return this; - } - - public Gnuplot setAxisScale(AxisType axisType, AxisScaleType axisScaleType) { - - int dim = axisType.ordinal(); - - Control.checkTrue(dim < this.ndims, // - "Invalid axis type"); - - this.axisScaleTypes[dim] = axisScaleType; - - return this; - } - - public Gnuplot setDataTitles(String... dataTitles) { - - System.arraycopy(dataTitles, 0, this.dataTitles, 0, // - Control.checkEquals(this.dataTitles.length, dataTitles.length)); - - return this; - } - - public Gnuplot setDataStyles(DataStyle... dataStyles) { - - System.arraycopy(dataStyles, 0, this.dataStyles, 0, // - Control.checkEquals(this.dataStyles.length, dataStyles.length)); - - return this; - } - - public Gnuplot setViewport(double... viewportParameters) { - - Control.checkTrue(this.ndims == 3, // - "Only three-dimensional plots may have their viewports specified"); - - Control.checkTrue(viewportParameters.length == 2, // - "Invalid arguments"); - - this.viewportParameters = viewportParameters; - - return this; - } - - public Gnuplot setPropertyEnabled(String property, boolean isPropertyEnabled) { - - if (property.equals(PROPERTY_LEGEND)) { - - this.isLegendEnabled = isPropertyEnabled; - - } else if (property.equals(PROPERTY_GRID)) { - - this.isGridEnabled = isPropertyEnabled; - - } else if (property.equals(PROPERTY_MESH)) { - - this.isMeshEnabled = isPropertyEnabled; - - } else if (property.equals(PROPERTY_COLORMAP)) { - - this.isColormapEnabled = isPropertyEnabled; - - } else { - - throw new IllegalArgumentException("Invalid Gnuplot property"); - } - - return this; - } - - public Gnuplot setPanelLocation(int panelX, int panelY) { - - this.panelX = panelX; - this.panelY = panelY; - - return this; - } - - public Gnuplot setPanelSize(int panelWidth, int panelHeight) { - - this.panelWidth = panelWidth; - this.panelHeight = panelHeight; - - return this; - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Histogram.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Histogram.java deleted file mode 100755 index d4b0d56d..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Histogram.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.array.RealArray; -import shared.stat.plot.Plot.AxisType; - -/** - * A representation of histograms. - * - * @author Roy Liu - */ -public class Histogram implements Plottable { - - /** - * The datasets. - */ - final protected RealArray[] datasets; - - /** - * The data titles. - */ - final protected String[] dataTitles; - - /** - * The {@link DataStyle}s. - */ - final protected DataStyle[] dataStyles; - - /** - * The x range. - */ - final protected double[] xrange; - - /** - * The y range. - */ - final protected double[] yrange; - - /** - * Default constructor. - * - * @param min - * the range minimum. - * @param max - * the range maximum. - * @param nbins - * the number of bins. - * @param valuesArray - * the array of values. - */ - public Histogram(double min, double max, int nbins, double[]... valuesArray) { - - int nclasses = valuesArray.length; - - this.datasets = new RealArray[nclasses]; - - double increment = (max - min) / nbins; - double maxCount = 0.0; - - for (int i = 0, n = valuesArray.length; i < n; i++) { - - RealArray dataset = new RealArray(nbins, 2); - - for (int bin = 0; bin < nbins; bin++) { - dataset.set(increment * (bin + 0.5) + min, bin, 0); - } - - for (double value : valuesArray[i]) { - - int bin = Math.max(0, Math.min(nbins - 1, (int) ((value - min) / increment))); - dataset.set(dataset.get(bin, 1) + 1.0d, bin, 1); - } - - maxCount = Math.max(maxCount, dataset.subarray(0, nbins, 1, 2).aMax()); - - this.datasets[i] = dataset; - } - - this.xrange = new double[] { min, max }; - this.yrange = new double[] { 0, maxCount }; - - this.dataTitles = PlotBase.createDefaultTitles(nclasses); - this.dataStyles = shared.util.Arrays.newArray(DataStyle.class, nclasses, DataStyle.Bars); - } - - public String getTitle() { - return "Histogram"; - } - - public RealArray[] getDatasets() { - return this.datasets; - } - - public String[] getDataTitles() { - return this.dataTitles; - } - - public DataStyle[] getDataStyles() { - return this.dataStyles; - } - - public boolean getPropertyEnabled(String property) { - return false; - } - - public double[] getAxisRange(AxisType axisType) { - - switch (axisType) { - - case X: - return this.xrange; - - case Y: - return this.yrange; - - default: - throw new IllegalArgumentException("Invalid axis type"); - } - } - - public String getAxisTitle(AxisType axisType) { - - switch (axisType) { - - case X: - return "bins"; - - case Y: - return "counts"; - - default: - throw new IllegalArgumentException("Invalid axis type"); - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Plot.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Plot.java deleted file mode 100755 index a9e04073..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Plot.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -/** - * Defines a plotting abstraction. - * - * @apiviz.owns shared.stat.plot.Plottable - * @apiviz.owns shared.stat.plot.Plot.AxisType - * @apiviz.owns shared.stat.plot.Plot.AxisScaleType - * @apiviz.owns shared.stat.plot.DataStyle - * @param - * the parameterization lower bounded by {@link Plot} itself. - */ -public interface Plot> { - - /** - * An enumeration of axis types. - */ - public enum AxisType { - - /** - * Indicates the x-axis. - */ - X, // - - /** - * Indicates the y-axis. - */ - Y, // - - /** - * Indicates the z-axis. - */ - Z; - }; - - /** - * An enumeration of axis scale types. - */ - public enum AxisScaleType { - - /** - * Indicates a normal scale. - */ - NORMAL, // - - /** - * Indicates a logarithmic scale. - */ - LOG; - }; - - /** - * Sets the title. - * - * @param title - * the title. - */ - public T setTitle(String title); - - /** - * Sets the axis information. - * - * @param axisType - * the {@link AxisType}. - * @param axisTitle - * the axis title. - * @param lower - * the lower bound. - * @param upper - * the upper bound. - * @param axisScaleType - * the {@link AxisScaleType}. - */ - public T setAxis(AxisType axisType, String axisTitle, double lower, double upper, AxisScaleType axisScaleType); - - /** - * Sets the axis title. - * - * @param axisType - * the {@link AxisType}. - * @param axisTitle - * the axis title. - */ - public T setAxisTitle(AxisType axisType, String axisTitle); - - /** - * Sets the axis range. - * - * @param axisType - * the {@link AxisType}. - * @param lower - * the lower bound. - * @param upper - * the upper bound. - */ - public T setAxisRange(AxisType axisType, double lower, double upper); - - /** - * Sets the {@link AxisScaleType}. - * - * @param axisType - * the {@link AxisType}. - * @param axisScaleType - * the {@link AxisScaleType}. - */ - public T setAxisScale(AxisType axisType, AxisScaleType axisScaleType); - - /** - * Sets the data titles. - * - * @param dataTitles - * the data titles. - */ - public T setDataTitles(String... dataTitles); - - /** - * Sets the {@link DataStyle}s. - * - * @param dataStyles - * the {@link DataStyle}s. - */ - public T setDataStyles(DataStyle... dataStyles); - - /** - * Sets the viewport. - * - * @param viewportParameters - * the viewport parameters. - */ - public T setViewport(double... viewportParameters); - - /** - * Sets whether the given property is enabled. - * - * @param isPropertyEnabled - * whether the given property is enabled. - */ - public T setPropertyEnabled(String property, boolean isPropertyEnabled); - - /** - * Sets the panel location. - * - * @param panelX - * the panel x-coordinate. - * @param panelY - * the panel y-coordinate. - */ - public T setPanelLocation(int panelX, int panelY); - - /** - * Sets the panel size. - * - * @param panelWidth - * the panel width. - * @param panelHeight - * the panel height. - */ - public T setPanelSize(int panelWidth, int panelHeight); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PlotBase.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PlotBase.java deleted file mode 100755 index 31ad5829..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PlotBase.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.array.RealArray; -import shared.util.Control; - -/** - * A collection of useful static methods for plotting. - */ -public class PlotBase { - - /** - * Infers the dimensionality of the given datasets. - * - * @param datasets - * the datasets. - * @return the dimensionality. - */ - final public static int inferDimensionality(RealArray... datasets) { - - int nclasses = datasets.length; - - Control.checkTrue(nclasses > 0, // - "Please specify some datasets"); - - for (int i = 0; i < nclasses; i++) { - Control.checkTrue(datasets[i].ndims() == 2, // - "Invalid arguments"); - } - - int ndims = datasets[0].size(1); - - for (int i = 1; i < nclasses; i++) { - Control.checkTrue(ndims == datasets[i].size(1), // - "Dimensionality mismatch"); - } - - return ndims; - } - - /** - * Creates a default array of titles. - * - * @param length - * the desired length. - * @return an array consisting of {@code 1}, {@code 2}, ..., {@code length}. - */ - final public static String[] createDefaultTitles(int length) { - - String[] res = new String[length]; - - for (int i = 0; i < length; i++) { - res[i] = String.format("class %d", i + 1); - } - - return res; - } - - // Dummy constructor. - PlotBase() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PlotContext.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PlotContext.java deleted file mode 100755 index 6c83c140..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PlotContext.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import java.io.File; -import java.io.IOException; - -import shared.array.RealArray; - -/** - * Defines a context for creating {@link Plot}s. - * - * @apiviz.owns shared.stat.plot.Plot - * @param - * the parameterization lower bounded by {@link PlotContext} itself. - * @param

- * the {@link Plot} type. - */ -public interface PlotContext, P extends Plot

> { - - /** - * Creates a {@link Plot} at the given coordinates. - * - * @param plottable - * the {@link Plottable}. - */ - public P addPlot(Plottable plottable); - - /** - * Creates a {@link Plot} at the given coordinates. - * - * @param datasets - * the datasets. - */ - public P addPlot(RealArray... datasets); - - /** - * Exports to a file. - * - * @param file - * the file. - * @throws IOException - * when something goes awry. - */ - public void toFile(File file) throws IOException; - - /** - * Sets the font and size. - * - * @param fontName - * the font name. - * @param fontSize - * the font size. - */ - public T setFont(String fontName, int fontSize); - - /** - * Sets the output format. - * - * @param outputFormat - * the output format. - */ - public T setOutputFormat(String outputFormat); - - /** - * Sets the output size. - * - * @param outputWidth - * the output width. - * @param outputHeight - * the output height. - */ - public T setOutputSize(int outputWidth, int outputHeight); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Plottable.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Plottable.java deleted file mode 100755 index ac774afe..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Plottable.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.array.RealArray; -import shared.stat.plot.Plot.AxisType; - -/** - * Defines something as suitable for having its values plotted. - */ -public interface Plottable { - - /** - * Gets the datasets. - */ - public RealArray[] getDatasets(); - - /** - * Gets the title. - */ - public String getTitle(); - - /** - * Gets the axis title. - * - * @param axisType - * the {@link AxisType}. - */ - public String getAxisTitle(AxisType axisType); - - /** - * Gets the axis range. - * - * @param axisType - * the {@link AxisType}. - */ - public double[] getAxisRange(AxisType axisType); - - /** - * Gets the data titles. - */ - public String[] getDataTitles(); - - /** - * Gets the {@link DataStyle}s. - */ - public DataStyle[] getDataStyles(); - - /** - * Gets whether the given property is enabled. - * - * @param property - * the given property. - * @return whether the given property is enabled. - */ - public boolean getPropertyEnabled(String property); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PrecisionRecall.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PrecisionRecall.java deleted file mode 100755 index a22baf77..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/PrecisionRecall.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.array.RealArray; - -/** - * A representation of precision-recall plots. - * - * @author Roy Liu - */ -public class PrecisionRecall extends ErrorDistribution { - - /** - * The x-axis range. - */ - final protected static double[] XRange = new double[] { 1.0, 0.0 }; - - final double[] yrange; - - /** - * Default constructor. - * - * @see ErrorDistribution#ErrorDistribution(double[][], boolean[][]) - */ - public PrecisionRecall(double[][] confidencesArray, boolean[][] outcomesArray) { - super(confidencesArray, outcomesArray); - - double precisionMin = 1.0; - - for (RealArray dataset : this.datasets) { - precisionMin = Math.min(precisionMin, dataset.subarray(0, dataset.size(0), 1, 2).aMin()); - } - - this.yrange = new double[] { precisionMin, 1.0 }; - } - - /** - * Alternate constructor. - */ - public PrecisionRecall(double[] confidences, boolean[] outcomes) { - this(new double[][] { confidences }, new boolean[][] { outcomes }); - } - - public String getTitle() { - return "Precision-Recall"; - } - - @Override - protected void initDataset(RealArray dataset, boolean[] outcomes) { - - int nexamples = dataset.size(0); - - for (int i = 0, ncorrect = 0; i < nexamples; i++) { - - if (outcomes[i]) { - ncorrect++; - } - - dataset.set(i / (double) nexamples, i, 0); - dataset.set((i > 0) ? ncorrect / (double) i : 1.0, i, 1); - } - } - - @Override - protected double[] getXAxisRange() { - return XRange; - } - - @Override - protected double[] getYAxisRange() { - return this.yrange; - } - - @Override - protected String getXAxisTitle() { - return "recall"; - } - - @Override - protected String getYAxisTitle() { - return "precision"; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ProbabilityDistribution.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ProbabilityDistribution.java deleted file mode 100755 index fcd535cf..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ProbabilityDistribution.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import java.util.Arrays; - -import shared.array.RealArray; -import shared.stat.plot.Plot.AxisType; - -/** - * A representation of probability distributions. - * - * @apiviz.owns shared.stat.plot.ProbabilityDistribution.Mode - * @author Roy Liu - */ -public class ProbabilityDistribution extends Histogram { - - /** - * An enumeration of probability distribution modes. - */ - public enum Mode { - - /** - * Indicates a cumulative density function. - */ - CDF { - - @Override - protected void initDistribution(RealArray d) { - d.eDiv(d.rSum(0).tile(d.size(0), 1)).dSum(0) // - .map(d, 0, 0, d.size(0), 1, 1, 1); - } - }, // - - /** - * Indicates a probability density function. - */ - PDF { - - @Override - protected void initDistribution(RealArray d) { - d.eDiv(d.rSum(0).tile(d.size(0), 1)) // - .map(d, 0, 0, d.size(0), 1, 1, 1); - } - }; - - /** - * Initializes the probability distribution. - */ - abstract protected void initDistribution(RealArray distribution); - } - - final Mode mode; - - /** - * Default constructor. - * - * @param mode - * the display mode. - * @param min - * the range minimum. - * @param max - * the range maximum. - * @param nintervals - * the number of sampling intervals. - */ - public ProbabilityDistribution(Mode mode, double min, double max, int nintervals, double[] values) { - super(min, max, nintervals, values); - - double maxDensity = 0.0; - - for (RealArray dataset : this.datasets) { - - mode.initDistribution(dataset); - - maxDensity = Math.max(maxDensity, dataset.subarray(0, dataset.size(0), 1, 2).aMax()); - } - - Arrays.fill(this.dataStyles, DataStyle.Lines); - - this.yrange[0] = 0.0; - this.yrange[1] = (mode == Mode.PDF) ? maxDensity : 1.0; - - this.mode = mode; - } - - /** - * Alternate constructor. - * - * @param min - * the range minimum. - * @param max - * the range maximum. - * @param nintervals - * the number of sampling intervals. - */ - public ProbabilityDistribution(double min, double max, int nintervals, double[] values) { - this(Mode.CDF, min, max, nintervals, values); - } - - @Override - public String getTitle() { - - switch (this.mode) { - - case PDF: - return "Probability Density Function"; - - case CDF: - return "Cumulative Density Function"; - - default: - throw new IllegalArgumentException("Invalid mode"); - } - } - - @Override - public String getAxisTitle(AxisType axisType) { - - switch (axisType) { - - case X: - return axisType.toString(); - - case Y: - - switch (this.mode) { - - case PDF: - return "density"; - - case CDF: - return "cumulative density"; - - default: - throw new IllegalArgumentException("Invalid mode"); - } - - default: - throw new IllegalArgumentException("Invalid axis type"); - } - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ROC.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ROC.java deleted file mode 100755 index ed4f7b2f..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/ROC.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.array.RealArray; - -/** - * A representation of ROC (receiver operating characteristic) plots. - * - * @author Roy Liu - */ -public class ROC extends ErrorDistribution { - - /** - * The x-axis range. - */ - final protected static double[] XRange = new double[] { 0.0, 1.0 }; - - /** - * The y-axis range. - */ - final protected static double[] YRange = new double[] { 0.0, 1.0 }; - - /** - * Default constructor. - * - * @see ErrorDistribution#ErrorDistribution(double[][], boolean[][]) - */ - public ROC(double[][] confidencesArray, boolean[][] outcomesArray) { - super(confidencesArray, outcomesArray); - } - - /** - * Alternate constructor. - */ - public ROC(double[] confidences, boolean[] outcomes) { - this(new double[][] { confidences }, new boolean[][] { outcomes }); - } - - public String getTitle() { - return "ROC"; - } - - @Override - protected void initDataset(RealArray dataset, boolean[] outcomes) { - - int nexamples = dataset.size(0); - - int ntrue = 0; - int nfalse = 0; - - for (int i = 0; i < nexamples; i++) { - - if (outcomes[i]) { - - ntrue++; - - } else { - - nfalse++; - } - - dataset.set(nfalse, i, 0); - dataset.set(ntrue, i, 1); - } - - if (nfalse > 0) { - - for (int i = 0; i < nexamples; i++) { - dataset.set(dataset.get(i, 0) / nfalse, i, 0); - } - - } else { - - for (int i = 0; i < nexamples; i++) { - dataset.set(0.0, i, 0); - } - } - - if (ntrue > 0) { - - for (int i = 0; i < nexamples; i++) { - dataset.set(dataset.get(i, 1) / ntrue, i, 1); - } - - } else { - - for (int i = 0; i < nexamples; i++) { - dataset.set(1.0, i, 1); - } - } - } - - @Override - protected double[] getXAxisRange() { - return XRange; - } - - @Override - protected double[] getYAxisRange() { - return YRange; - } - - @Override - protected String getXAxisTitle() { - return "false rate"; - } - - @Override - protected String getYAxisTitle() { - return "true rate"; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Scatter.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Scatter.java deleted file mode 100755 index b3e0c839..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/Scatter.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.plot; - -import shared.array.RealArray; -import shared.stat.plot.Plot.AxisType; - -/** - * A representation of scatter plots. - * - * @author Roy Liu - */ -public class Scatter implements Plottable { - - /** - * The generic axis range. - */ - final protected static double[] AxisRange = new double[] { 0.0, 1.0 }; - - final RealArray[] datasets; - final String[] dataTitles; - final DataStyle[] dataStyles; - - /** - * Default constructor. - * - * @param datasets - * the datasets. - */ - public Scatter(RealArray... datasets) { - - int nclasses = datasets.length; - - // Check for uniform dimensionality. - PlotBase.inferDimensionality(datasets); - - this.datasets = datasets; - this.dataTitles = PlotBase.createDefaultTitles(nclasses); - this.dataStyles = shared.util.Arrays.newArray(DataStyle.class, nclasses, DataStyle.Points); - } - - public RealArray[] getDatasets() { - return this.datasets; - } - - public String getTitle() { - return "Scatter Plot"; - } - - public boolean getPropertyEnabled(String property) { - return property.equals("legend"); - } - - public double[] getAxisRange(AxisType axisType) { - return AxisRange; - } - - public String getAxisTitle(AxisType axisType) { - return axisType.toString(); - } - - public String[] getDataTitles() { - return this.dataTitles; - } - - public DataStyle[] getDataStyles() { - return this.dataStyles; - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/package-info.java deleted file mode 100755 index 2a5bb3fb..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/plot/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of plotting classes for reporting machine learning metrics. - */ -package shared.stat.plot; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/util/Combinatorics.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/util/Combinatorics.java deleted file mode 100755 index 66e8b60b..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/util/Combinatorics.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.stat.util; - -import shared.util.Control; -import shared.util.DynamicObjectArray; - -/** - * A collection of useful static methods for combinatorics. - * - * @author Roy Liu - */ -public class Combinatorics { - - /** - * A lookup table of coefficients in support of {@link #gammaLn(double)}. - */ - final protected static double[] GammaLnCoefficients = new double[] { - // - 76.18009172947146, -86.50532032941677, // - 24.01409824083091, -1.231739572450155, // - 0.1208650973866179e-2, -0.5395239384953e-5 // - }; - - /** - * A facade for {@link #partition(int, int, int)}. - * - * @param n - * the number of elements. - * @return the partitions. - */ - final public static int[][] partition(int n) { - return partition(n, 1, n + 1); - } - - /** - * Calculates all partitions of an {@code n} element set into at least {@code npartsLower} parts and at most - * (exclusive) {@code npartsUpper} parts. - * - * @param n - * the number of elements. - * @param npartsLower - * the lower bound on the number of parts. - * @param npartsUpper - * the upper bound (exclusive) on the number of parts. - * @return the partitions. - */ - final public static int[][] partition(int n, int npartsLower, int npartsUpper) { - - Control.checkTrue(npartsLower >= 1 && npartsUpper <= n + 1, // - "Invalid arguments"); - - DynamicObjectArray acc = new DynamicObjectArray(int[].class); - - for (int nparts = npartsLower; nparts < npartsUpper; nparts++) { - partition(acc, new int[nparts], 0, 1, n); - } - - return acc.values(); - } - - /** - * A helper method in support of {@link #partition(int, int, int)}. - * - * @param acc - * the partition accumulator. - * @param sizes - * the partition sizes. - * @param nsizes - * the number of parts so far. - * @param currentSize - * the part size so far. - * @param nremaining - * the number of remaining elements. - */ - final protected static void partition(DynamicObjectArray acc, // - int[] sizes, int nsizes, int currentSize, int nremaining) { - - if (nremaining == 0 && sizes.length == nsizes) { - acc.push(sizes.clone()); - } - - if (sizes.length == nsizes) { - return; - } - - for (int size = currentSize, maxSize = nremaining / (sizes.length - nsizes); size <= maxSize; size++) { - - sizes[nsizes] = size; - partition(acc, sizes, nsizes + 1, size, nremaining - size); - } - } - - /** - * A facade for {@link #orderedPartition(int, int, int)}. - * - * @param n - * the number of elements. - * @return the ordered partitions. - */ - final public static int[][] orderedPartition(int n) { - return orderedPartition(n, 1, n + 1); - } - - /** - * Calculates all ordered partitions of an {@code n} element set into at least {@code npartsLower} parts and at most - * (exclusive) {@code npartsUpper} parts. - * - * @param n - * the number of elements. - * @param npartsLower - * the lower bound on the number of parts. - * @param npartsUpper - * the upper bound (exclusive) on the number of parts. - * @return the ordered partitions. - */ - final public static int[][] orderedPartition(int n, int npartsLower, int npartsUpper) { - - Control.checkTrue(npartsLower < npartsUpper, // - "Invalid arguments"); - - DynamicObjectArray acc = new DynamicObjectArray(int[].class); - - for (int nparts = npartsLower; nparts < npartsUpper; nparts++) { - orderedPartition(acc, new int[nparts], 0, n); - } - - return acc.values(); - } - - /** - * A helper method in support of {@link #orderedPartition(int, int, int)}. - * - * @param acc - * the ordered partition accumulator. - * @param sizes - * the ordered partition sizes. - * @param nsizes - * the number of parts so far. - * @param nremaining - * the number of remaining elements. - */ - final protected static void orderedPartition(DynamicObjectArray acc, // - int[] sizes, int nsizes, int nremaining) { - - if (nremaining == 0 && sizes.length == nsizes) { - acc.push(sizes.clone()); - } - - if (sizes.length == nsizes) { - return; - } - - for (int size = 0, maxSize = nremaining; size <= maxSize; size++) { - - sizes[nsizes] = size; - orderedPartition(acc, sizes, nsizes + 1, nremaining - size); - } - } - - /** - * The gamma function. - * - * @param x - * the input value. - * @return the gamma function evaluation. - */ - final public static double gamma(double x) { - return Math.exp(gammaLn(x)); - } - - /** - * The log-gamma function. - * - * @param x - * the input value. - * @return the log-gamma function evaluation. - */ - final public static double gammaLn(double x) { - - double t = x + 4.5 - (x - 0.5) * Math.log(x + 4.5); - double sum = 1.000000000190015; - - for (int j = 0, n = GammaLnCoefficients.length; j < n; j++, x++) { - sum += GammaLnCoefficients[j] / x; - } - - return -t + Math.log(2.5066282746310005 * sum); - } - - // Dummy constructor. - Combinatorics() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/stat/util/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/stat/util/package-info.java deleted file mode 100755 index 450f3ac2..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/stat/util/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of statistical utilities. - */ -package shared.stat.util; - diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/Arithmetic.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/Arithmetic.java deleted file mode 100755 index d0a58126..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/Arithmetic.java +++ /dev/null @@ -1,491 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.util.Random; - -/** - * A collection of very basic arithmetic operations on arrays. - * - * @author Roy Liu - */ -public class Arithmetic { - - /** - * The underlying, shared source of randomness. - */ - final protected static Random RandomKernel = new Random(0xdeadbeefcacabeadL); - - /** - * Computes the maximum. - * - * @param values - * the array. - * @return the maximum. - */ - final public static double max(double... values) { - - double acc = -Double.MAX_VALUE; - - for (double v : values) { - acc = Math.max(acc, v); - } - - return acc; - } - - /** - * Computes the minimum. - * - * @param values - * the array. - * @return the minimum. - */ - final public static double min(double... values) { - - double acc = Double.MAX_VALUE; - - for (double v : values) { - acc = Math.min(acc, v); - } - - return acc; - } - - /** - * Computes the sum. - * - * @param values - * the array. - * @return the sum. - */ - final public static double sum(double... values) { - - double acc = 0.0; - - for (double v : values) { - acc += v; - } - - return acc; - } - - /** - * Computes the product. - * - * @param values - * the array. - * @return the product. - */ - final public static double product(double... values) { - - double acc = 1.0; - - for (double v : values) { - acc *= v; - } - - return acc; - } - - /** - * Computes the variance. - * - * @param values - * the array. - * @return the variance. - */ - final public static double variance(double... values) { - - double len = values.length; - double mean = sum(values) / len; - double ssd = 0.0; - - for (double v : values) { - ssd += ((v - mean) * (v - mean)) / len; - } - - return ssd; - } - - /** - * Computes the entropy. - * - * @param values - * the array. - * @return the entropy. - */ - final public static double entropy(double... values) { - - double sum = Math.max(0.0, sum(values)) + 1e-64; - double en = 0.0; - - for (double v : values) { - - double val = v / sum; - en += (val >= 1e-64) ? (val * Math.log(val)) : 0.0; - } - - return -en; - } - - /** - * Shuffles the given array. - * - * @param values - * the array. - * @return the array. - */ - final public static int[] shuffle(int[] values) { - - for (int i = values.length; i > 1; i--) { - - int index = Arithmetic.nextInt(i); - - int tmp = values[i - 1]; - values[i - 1] = values[index]; - values[index] = tmp; - } - - return values; - } - - /** - * Shuffles the given array. - * - * @param values - * the array. - * @return the array. - */ - final public static double[] shuffle(double[] values) { - - for (int i = values.length; i > 1; i--) { - - int index = Arithmetic.nextInt(i); - - double tmp = values[i - 1]; - values[i - 1] = values[index]; - values[index] = tmp; - } - - return values; - } - - /** - * Computes the product. - * - * @param values - * the array. - * @return the product. - */ - final public static int product(int... values) { - - int acc = 1; - - for (int value : values) { - acc *= value; - } - - return acc; - } - - /** - * Computes the sum. - * - * @param values - * the array. - * @return the sum. - */ - final public static int sum(int... values) { - - int acc = 0; - - for (int value : values) { - acc += value; - } - - return acc; - } - - /** - * Computes the maximum. - * - * @param values - * the array. - * @return the maximum. - */ - final public static int max(int... values) { - - int acc = Integer.MIN_VALUE; - - for (int value : values) { - acc = Math.max(acc, value); - } - - return acc; - } - - /** - * Computes the minimum. - * - * @param values - * the array. - * @return the minimum. - */ - final public static int min(int... values) { - - int acc = Integer.MAX_VALUE; - - for (int value : values) { - acc = Math.min(acc, value); - } - - return acc; - } - - /** - * Creates a [m, n) range of {@code int}s. - * - * @param m - * the (inclusive) lower bound. - * @param n - * the (exclusive) upper bound. - * @return the range. - */ - final public static int[] range(int m, int n) { - - int[] res = new int[n - m]; - - for (int i = m, ii = 0; i < n; i++, ii++) { - res[ii] = i; - } - - return res; - } - - /** - * Creates a [0, n) range of {@code int}s. - * - * @param n - * the size of the range. - * @return the range. - */ - final public static int[] range(int n) { - return range(0, n); - } - - /** - * Creates a [m, n) range of {@code double}s. - * - * @param m - * the (inclusive) lower bound. - * @param n - * the (exclusive) upper bound. - * @return the range. - */ - final public static double[] doubleRange(int m, int n) { - - double[] res = new double[n - m]; - - for (int i = m, ii = 0; i < n; i++, ii++) { - res[ii] = i; - } - - return res; - } - - /** - * Creates a [0, n) range of {@code double}s. - * - * @param n - * the size of the range. - * @return the range. - */ - final public static double[] doubleRange(int n) { - return doubleRange(0, n); - } - - /** - * Creates a [m, n) range of {@code long}s. - * - * @param m - * the (inclusive) lower bound. - * @param n - * the (exclusive) upper bound. - * @return the range. - */ - final public static long[] longRange(int m, int n) { - - long[] res = new long[n - m]; - - for (int i = m, ii = 0; i < n; i++, ii++) { - res[ii] = i; - } - - return res; - } - - /** - * Creates a [0, n) range of {@code long}s. - * - * @param n - * the size of the range. - * @return the range. - */ - final public static long[] longRange(int n) { - return longRange(0, n); - } - - /** - * Finds the index of the given value. - * - * @param values - * the array. - * @param value - * the value to search for. - * @return the index, or the array length if not found. - */ - final public static int indexOf(int[] values, int value) { - - for (int i = 0, n = values.length; i < n; i++) { - - if (values[i] == value) { - return i; - } - } - - return values.length; - } - - /** - * Counts the number of times the given value appears. - * - * @param values - * the array. - * @param value - * the value to count. - * @return the count. - */ - final public static int count(int[] values, int value) { - - int count = 0; - - for (int i = 0, n = values.length; i < n; i++) { - - if (values[i] == value) { - count++; - } - } - - return count; - } - - /** - * Retrieves the source of randomness behind the static methods of {@link Arithmetic}. - * - * @return the random source. - */ - final public static Random getRandomSource() { - return RandomKernel; - } - - /** - * A wrapper for {@link Random#nextInt(int)}. - * - * @param n - * the upper bound. - * @return an integer in [0, n). - */ - final public static int nextInt(int n) { - return RandomKernel.nextInt(n); - } - - /** - * A wrapper for {@link Random#nextInt()}. - * - * @return an integer chosen uniformly at random. - */ - final public static int nextInt() { - return RandomKernel.nextInt(); - } - - /** - * A wrapper for {@link Random#nextLong()}. - * - * @return a long chosen uniformly at random. - */ - final public static long nextLong() { - return RandomKernel.nextLong(); - } - - /** - * A wrapper for {@link Random#nextDouble()}. - * - * @param a - * the upper bound. - * @return a {@code double} in [0, a). - */ - final public static double nextDouble(double a) { - return a * RandomKernel.nextDouble(); - } - - /** - * A wrapper for {@link Random#nextGaussian()}. - * - * @param a - * the standard deviation. - * @return a sample drawn from a Gaussian with mean {@code 0} and standard deviation {@code a}. - */ - final public static double nextGaussian(double a) { - return a * RandomKernel.nextGaussian(); - } - - /** - * A wrapper for {@link Random#nextBytes(byte[])}. - * - * @param n - * the size of the random {@code byte} array. - * @return a randomly generated {@code byte} array of length n. - */ - final public static byte[] nextBytes(int n) { - - byte[] res = new byte[n]; - - RandomKernel.nextBytes(res); - - return res; - } - - /** - * Seeds the underlying source of randomness with {@link System#nanoTime()}. - */ - final public static void randomize() { - RandomKernel.setSeed(System.nanoTime()); - } - - /** - * Seeds the underlying source of randomness with {@code 0}. - */ - final public static void derandomize() { - RandomKernel.setSeed(0); - } - - // Dummy constructor. - Arithmetic() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/Arrays.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/Arrays.java deleted file mode 100755 index 8e58b66d..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/Arrays.java +++ /dev/null @@ -1,772 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.lang.reflect.Array; -import java.math.RoundingMode; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** - * A collection of useful static methods for manipulating arrays. - * - * @author Roy Liu - */ -public class Arrays { - - /** - * Creates a new array initialized to the given value. - */ - final public static int[] newArray(int length, int value) { - - int[] res = new int[length]; - java.util.Arrays.fill(res, value); - - return res; - } - - /** - * Creates a new array initialized to the given value. - */ - final public static double[] newArray(int length, double value) { - - double[] res = new double[length]; - java.util.Arrays.fill(res, value); - - return res; - } - - /** - * Creates a new array initialized to the given value. - */ - final public static Object[] newArray(int length, Object value) { - - Object[] res = new Object[length]; - java.util.Arrays.fill(res, value); - - return res; - } - - /** - * Creates a new array initialized to the given value. - * - * @param - * the component type. - */ - @SuppressWarnings("unchecked") - final public static T[] newArray(Class clazz, int length, T value) { - - T[] res = (T[]) Array.newInstance(clazz, length); - java.util.Arrays.fill(res, value); - - return res; - } - - /** - * A convenience array slicing method. - * - * @param values - * the values. - * @param indices - * the slice indices. - * @return the sliced values. - */ - final public static double[] slice(double[] values, int[] indices) { - - int len = indices.length; - - double[] res = new double[len]; - - for (int i = 0; i < len; i++) { - res[i] = values[indices[i]]; - } - - return res; - } - - /** - * A convenience array slicing method. - * - * @param values - * the values. - * @param indices - * the slice indices. - * @return the sliced values. - */ - final public static int[] slice(int[] values, int[] indices) { - - int len = indices.length; - - int[] res = new int[len]; - - for (int i = 0; i < len; i++) { - res[i] = values[indices[i]]; - } - - return res; - } - - /** - * A convenience array slicing method. - * - * @param values - * the values. - * @param indices - * the slice indices. - * @param clazz - * the component class. - * @param - * the component type. - * @return the sliced values. - */ - @SuppressWarnings("unchecked") - final public static T[] slice(T[] values, int[] indices, Class clazz) { - - int len = indices.length; - - T[] res = (T[]) Array.newInstance(clazz, len); - - for (int i = 0; i < len; i++) { - res[i] = values[indices[i]]; - } - - return res; - } - - /** - * Boxes the given array of {@code double}s. - * - * @param values - * the values. - * @return the boxed values. - */ - final public static Double[] box(double[] values) { - - int len = values.length; - - Double[] res = new Double[len]; - - for (int i = 0; i < len; i++) { - res[i] = values[i]; - } - - return res; - } - - /** - * Boxes the given array of {@code int}s. - * - * @param values - * the values. - * @return the boxed values. - */ - final public static Integer[] box(int[] values) { - - int len = values.length; - - Integer[] res = new Integer[len]; - - for (int i = 0; i < len; i++) { - res[i] = values[i]; - } - - return res; - } - - /** - * Unboxes the given array of {@link Double}s. - * - * @param values - * the values. - * @return the unboxed values. - */ - final public static double[] unbox(Double[] values) { - - int len = values.length; - - double[] res = new double[len]; - - for (int i = 0; i < len; i++) { - res[i] = values[i]; - } - - return res; - } - - /** - * Unboxes the given array of {@link Integer}s. - * - * @param values - * the values. - * @return the unboxed values. - */ - final public static int[] unbox(Integer[] values) { - - int len = values.length; - - int[] res = new int[len]; - - for (int i = 0; i < len; i++) { - res[i] = values[i]; - } - - return res; - } - - /** - * Wraps the given value and trailing values as an array. - * - * @param - * the component type. - * @param value - * the head value. - * @param values - * the trailing values. - * @return the array. - */ - @SuppressWarnings("unchecked") - final public static T[] wrap(Class clazz, T value, T... values) { - - T[] res = (T[]) Array.newInstance(clazz, 1 + values.length); - - res[0] = value; - - System.arraycopy(values, 0, res, 1, values.length); - - return res; - } - - /** - * A facade for {@link #wrap(Class, Object, Object...)}. - */ - @SuppressWarnings("unchecked") - final public static T[] wrap(T value, T... values) { - return wrap((Class) value.getClass(), value, values); - } - - /** - * Compares two arrays of {@code double}s on the basis of lexicographic order. - * - * @param lhs - * the left hand side. - * @param rhs - * the right hand side. - */ - final public static int compare(double[] lhs, double[] rhs) { - - for (int i = 0, n = Math.min(lhs.length, rhs.length); i < n; i++) { - - int cmp = Double.compare(lhs[i], rhs[i]); - - if (cmp != 0) { - return cmp; - } - } - - return lhs.length - rhs.length; - } - - /** - * Compares two arrays of {@code int}s on the basis of lexicographic order. - * - * @param lhs - * the left hand side. - * @param rhs - * the right hand side. - */ - final public static int compare(int[] lhs, int[] rhs) { - - for (int i = 0, n = Math.min(lhs.length, rhs.length); i < n; i++) { - - int cmp = lhs[i] - rhs[i]; - - if (cmp != 0) { - return cmp; - } - } - - return lhs.length - rhs.length; - } - - /** - * Compares two arrays of objects on the basis of lexicographic order. - * - * @param lhs - * the left hand side. - * @param rhs - * the right hand side. - * @param - * the component type. - */ - final public static > int compare(T[] lhs, T[] rhs) { - - for (int i = 0, n = Math.min(lhs.length, rhs.length); i < n; i++) { - - int cmp = lhs[i].compareTo(rhs[i]); - - if (cmp != 0) { - return cmp; - } - } - - return lhs.length - rhs.length; - } - - /** - * Compares two arrays of objects on the basis of lexicographic order. - * - * @param lhs - * the left hand side. - * @param rhs - * the right hand side. - * @param c - * the {@link Comparator} to use. - * @param - * the component type. - */ - final public static int compare(T[] lhs, T[] rhs, Comparator c) { - - for (int i = 0, n = Math.min(lhs.length, rhs.length); i < n; i++) { - - int cmp = c.compare(lhs[i], rhs[i]); - - if (cmp != 0) { - return cmp; - } - } - - return lhs.length - rhs.length; - } - - /** - * A variant of {@link java.util.Arrays#binarySearch(int[], int, int, int)} that finds the array index with value - * nearest to the given key, as determined by the provided {@link RoundingMode}. - * - * @param values - * the values. - * @param from - * the search start index. - * @param to - * the search end index. - * @param key - * the key. - * @param rm - * the {@link RoundingMode}. - * @return the "nearest" index. - */ - final public static int binarySearchNearest(int[] values, int from, int to, int key, RoundingMode rm) { - - Control.checkTrue(values.length > 0, // - "Array size must be positive"); - - int index = java.util.Arrays.binarySearch(values, from, to, key); - - if (index >= 0) { - - return index; - - } else { - - index = -index - 1; - - int lower = Math.max(index - 1, 0); - int upper = Math.min(index, values.length - 1); - - int diffLower = key - values[lower]; - int diffUpper = values[upper] - key; - - switch (rm) { - - case DOWN: - return lower; - - case UP: - return upper; - - case HALF_DOWN: - return diffLower <= diffUpper ? lower : upper; - - case HALF_UP: - return diffUpper <= diffLower ? upper : lower; - - default: - throw new IllegalArgumentException("Invalid rounding mode"); - } - } - } - - /** - * A facade for {@link #binarySearchNearest(int[], int, int, int, RoundingMode)}. - */ - final public static int binarySearchNearest(int[] values, int to, int from, int key) { - return binarySearchNearest(values, to, from, key, RoundingMode.HALF_DOWN); - } - - /** - * A facade for {@link #binarySearchNearest(int[], int, int, int, RoundingMode)}. - */ - final public static int binarySearchNearest(int[] values, int key, RoundingMode rm) { - return binarySearchNearest(values, 0, values.length, key, rm); - } - - /** - * A facade for {@link #binarySearchNearest(int[], int, int, int, RoundingMode)}. - */ - final public static int binarySearchNearest(int[] values, int key) { - return binarySearchNearest(values, 0, values.length, key, RoundingMode.HALF_DOWN); - } - - /** - * A variant of {@link java.util.Arrays#binarySearch(double[], int, int, double)} that finds the array index with - * value nearest to the given key, as determined by the provided {@link RoundingMode}. - * - * @param values - * the values. - * @param from - * the search start index. - * @param to - * the search end index. - * @param key - * the key. - * @param rm - * the {@link RoundingMode}. - * @return the "nearest" index. - */ - final public static int binarySearchNearest(double[] values, int from, int to, double key, RoundingMode rm) { - - Control.checkTrue(values.length > 0, // - "Array size must be positive"); - - int index = java.util.Arrays.binarySearch(values, from, to, key); - - if (index >= 0) { - - return index; - - } else { - - index = -index - 1; - - int lower = Math.max(index - 1, 0); - int upper = Math.min(index, values.length - 1); - - double diffLower = key - values[lower]; - double diffUpper = values[upper] - key; - - switch (rm) { - - case DOWN: - return lower; - - case UP: - return upper; - - case HALF_DOWN: - return diffLower <= diffUpper ? lower : upper; - - case HALF_UP: - return diffUpper <= diffLower ? upper : lower; - - default: - throw new IllegalArgumentException("Invalid rounding mode"); - } - } - } - - /** - * A facade for {@link #binarySearchNearest(double[], int, int, double, RoundingMode)}. - */ - final public static int binarySearchNearest(double[] values, int to, int from, double key) { - return binarySearchNearest(values, to, from, key, RoundingMode.HALF_DOWN); - } - - /** - * A facade for {@link #binarySearchNearest(double[], int, int, double, RoundingMode)}. - */ - final public static int binarySearchNearest(double[] values, double key, RoundingMode rm) { - return binarySearchNearest(values, 0, values.length, key, rm); - } - - /** - * A facade for {@link #binarySearchNearest(double[], int, int, double, RoundingMode)}. - */ - final public static int binarySearchNearest(double[] values, double key) { - return binarySearchNearest(values, 0, values.length, key, RoundingMode.HALF_DOWN); - } - - /** - * A variant of {@link java.util.Arrays#binarySearch(Object[], int, int, Object)} that finds the array index with - * value nearest to the given key, as determined by the provided {@link RoundingMode}. - * - * @param values - * the values. - * @param from - * the search start index. - * @param to - * the search end index. - * @param key - * the key. - * @param rm - * the {@link RoundingMode}. - * @param - * the component type. - * @return the "nearest" index. - */ - final public static > int binarySearchNearest(T[] values, int from, int to, // - T key, RoundingMode rm) { - - Control.checkTrue(values.length > 0, // - "Array size must be positive"); - - int index = java.util.Arrays.binarySearch(values, from, to, key); - - if (index >= 0) { - - return index; - - } else { - - index = -index - 1; - - int lower = Math.max(index - 1, 0); - int upper = Math.min(index, values.length - 1); - - switch (rm) { - - case DOWN: - return lower; - - case UP: - return upper; - - default: - throw new IllegalArgumentException("Invalid rounding mode"); - } - } - } - - /** - * A facade for {@link #binarySearchNearest(Comparable[], int, int, Comparable, RoundingMode)}. - * - * @param - * the component type. - */ - final public static > int binarySearchNearest(T[] values, int to, int from, // - T key) { - return binarySearchNearest(values, to, from, key, RoundingMode.DOWN); - } - - /** - * A facade for {@link #binarySearchNearest(Comparable[], int, int, Comparable, RoundingMode)}. - * - * @param - * the component type. - */ - final public static > int binarySearchNearest(T[] values, T key, RoundingMode rm) { - return binarySearchNearest(values, 0, values.length, key, rm); - } - - /** - * A facade for {@link #binarySearchNearest(Comparable[], int, int, Comparable, RoundingMode)}. - * - * @param - * the component type. - */ - final public static > int binarySearchNearest(T[] values, T key) { - return binarySearchNearest(values, 0, values.length, key, RoundingMode.DOWN); - } - - /** - * A variant of {@link java.util.Arrays#binarySearch(Object[], Object, Comparator)} that finds the array index with - * value nearest to the given key, as determined by the provided {@link RoundingMode}. - * - * @param values - * the values. - * @param key - * the key. - * @param rm - * the {@link RoundingMode}. - * @param c - * the {@link Comparator} to use. - * @param - * the component type. - * @return the "nearest" index. - */ - final public static int binarySearchNearest(T[] values, T key, Comparator c, RoundingMode rm) { - - Control.checkTrue(values.length > 0, // - "Array size must be positive"); - - int index = java.util.Arrays.binarySearch(values, key, c); - - if (index >= 0) { - - return index; - - } else { - - index = -index - 1; - - int lower = Math.max(index - 1, 0); - int upper = Math.min(index, values.length - 1); - - switch (rm) { - - case DOWN: - return lower; - - case UP: - return upper; - - default: - throw new IllegalArgumentException("Invalid rounding mode"); - } - } - } - - /** - * A facade for {@link #binarySearchNearest(Object[], Object, Comparator)}. - * - * @param - * the component type. - */ - final public static int binarySearchNearest(T[] values, T key, Comparator c) { - return binarySearchNearest(values, key, c, RoundingMode.DOWN); - } - - /** - * A variant of {@link Collections#binarySearch(List, Object)} that finds the array index with value nearest to the - * given key, as determined by the provided {@link RoundingMode}. - * - * @param values - * the values. - * @param key - * the key. - * @param rm - * the {@link RoundingMode}. - * @param - * the component type. - * @return the "nearest" index. - */ - final public static > int binarySearchNearest(List values, T key, // - RoundingMode rm) { - - Control.checkTrue(values.size() > 0, // - "List size must be positive"); - - int index = Collections.binarySearch(values, key); - - if (index >= 0) { - - return index; - - } else { - - index = -index - 1; - - int lower = Math.max(index - 1, 0); - int upper = Math.min(index, values.size() - 1); - - switch (rm) { - - case DOWN: - return lower; - - case UP: - return upper; - - default: - throw new IllegalArgumentException("Invalid rounding mode"); - } - } - } - - /** - * A facade for {@link #binarySearchNearest(List, Comparable, RoundingMode)}. - * - * @param - * the component type. - */ - final public static > int binarySearchNearest(List values, T key) { - return binarySearchNearest(values, key, RoundingMode.DOWN); - } - - /** - * A variant of {@link Collections#binarySearch(List, Object, Comparator)} that finds the array index with value - * nearest to the given key, as determined by the provided {@link RoundingMode}. - * - * @param values - * the values. - * @param key - * the key. - * @param rm - * the {@link RoundingMode}. - * @param c - * the {@link Comparator} to use. - * @param - * the component type. - * @return the "nearest" index. - */ - final public static int binarySearchNearest(List values, T key, Comparator c, // - RoundingMode rm) { - - Control.checkTrue(values.size() > 0, // - "List size must be positive"); - - int index = Collections.binarySearch(values, key, c); - - if (index >= 0) { - - return index; - - } else { - - index = -index - 1; - - int lower = Math.max(index - 1, 0); - int upper = Math.min(index, values.size() - 1); - - switch (rm) { - - case DOWN: - return lower; - - case UP: - return upper; - - default: - throw new IllegalArgumentException("Invalid rounding mode"); - } - } - } - - /** - * A facade for {@link #binarySearchNearest(List, Object, Comparator, RoundingMode)}. - * - * @param - * the component type. - */ - final public static int binarySearchNearest(List values, T key, Comparator c) { - return binarySearchNearest(values, key, c, RoundingMode.DOWN); - } - - // Dummy constructor. - Arrays() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/Control.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/Control.java deleted file mode 100755 index cf44b3d4..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/Control.java +++ /dev/null @@ -1,1053 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.StringWriter; -import java.lang.Thread.UncaughtExceptionHandler; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -/** - * A collection of useful static methods for control flow. - * - * @author Roy Liu - */ -public class Control { - - /** - * The bulk transfer size for {@link InputStream}s and {@link OutputStream}s. - */ - final protected static int BULK_TRANSFER_SIZE = 1 << 16; - - /** - * A null {@link OutputStream} to which writes have no effect. - */ - final public static OutputStream NullOutputStream = new OutputStream() { - - @Override - public void write(int b) throws IOException { - } - }; - - /** - * A null {@link InputStream} that has nothing to read. - */ - final public static InputStream NullInputStream = new InputStream() { - - @Override - public int read() throws IOException { - return -1; - } - }; - - /** - * A null {@link Runnable} that has an empty {@link Runnable#run()} method. - */ - final public static Runnable NullRunnable = new Runnable() { - - public void run() { - } - }; - - /** - * A timestamp local to the current thread in support of {@link #tick()} and {@link #tock()}. - */ - final protected static ThreadLocal TimeStampLocal = new ThreadLocal(); - - /** - * A mapping of environment variables local to the current thread in support of {@link #beginEnvironment()} and - * {@link #endEnvironment()}. - */ - final protected static ThreadLocal> EnvironmentLocal = new ThreadLocal>(); - - /** - * An implementation of {@link EntityResolver} that finds external entities on the class path of the current - * thread's context class loader. - */ - final public static EntityResolver ClasspathResolver = new EntityResolver() { - - public InputSource resolveEntity(String publicId, String systemId) { - - String classpathStr = "classpath://"; - - if (!systemId.startsWith(classpathStr)) { - return null; - } - - InputStream in = Thread.currentThread().getContextClassLoader() // - .getResourceAsStream(systemId.substring(classpathStr.length())); - return (in != null) ? new InputSource(in) : null; - } - }; - - /** - * An implementation of {@link ErrorHandler} that immediately throws any {@link SAXException} passed to it, - * regardless of severity. - */ - final public static ErrorHandler DefaultErrorHandler = new ErrorHandler() { - - public void error(SAXParseException exception) throws SAXException { - throw exception; - } - - public void fatalError(SAXParseException exception) throws SAXException { - throw exception; - } - - public void warning(SAXParseException exception) throws SAXException { - throw exception; - } - }; - - /** - * A {@link DocumentBuilder} local to the current thread. - */ - final protected static ThreadLocal BuilderLocal = new ThreadLocal() { - - @Override - protected DocumentBuilder initialValue() { - - final DocumentBuilder db; - - try { - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - - dbf.setValidating(true); - dbf.setIgnoringElementContentWhitespace(true); - - dbf.setFeature("http://apache.org/xml/features/validation/dynamic", true); - - db = dbf.newDocumentBuilder(); - db.setEntityResolver(ClasspathResolver); - db.setErrorHandler(DefaultErrorHandler); - - } catch (ParserConfigurationException e) { - - throw new RuntimeException(e); - } - - return db; - } - }; - - /** - * A {@link Transformer} local to the current thread. - */ - final protected static ThreadLocal TransformerLocal = new ThreadLocal() { - - @Override - protected Transformer initialValue() { - - try { - - return TransformerFactory.newInstance().newTransformer(); - - } catch (TransformerConfigurationException e) { - - throw new RuntimeException(e); - } - } - }; - - /** - * The system-dependent line separator. - */ - final public static String LineSeparator = System.getProperty("line.separator"); - - /** - * A {@link Closeable#close()} convenience wrapper. - */ - final public static void close(Closeable closeable) { - - if (closeable != null) { - - try { - - closeable.close(); - - } catch (IOException e) { - } - } - } - - /** - * Sleeps for the given number of milliseconds. - */ - final public static void sleep(long millis) { - - try { - - Thread.sleep(millis); - - } catch (InterruptedException e) { - } - } - - /** - * Creates an unmodifiable {@link Iterator} from a possibly modifiable one. - * - * @param - * the parameterization. - * @param itr - * the original {@link Iterator}. - * @return an unmodifiable {@link Iterator} view. - */ - final public static Iterator unmodifiableIterator(final Iterator itr) { - - return new Iterator() { - - public boolean hasNext() { - return itr.hasNext(); - } - - public T next() { - return itr.next(); - } - - public void remove() { - throw new UnsupportedOperationException("Iterator is unmodifiable"); - } - }; - } - - /** - * Starts the timer for {@link Thread#currentThread()}. - */ - final public static void tick() { - - Control.checkTrue(TimeStampLocal.get() == null, // - "Must call tock() before tick()"); - - TimeStampLocal.set(System.currentTimeMillis()); - } - - /** - * Stops the timer for {@link Thread#currentThread()}. - * - * @return the (wall clock) time elapsed. - */ - final public static long tock() { - - Long timeStamp = TimeStampLocal.get(); - - Control.checkTrue(timeStamp != null, // - "Must call tick() before tock()"); - - TimeStampLocal.set(null); - - return System.currentTimeMillis() - timeStamp; - } - - /** - * Deletes a file or directory. If a directory, then recursively deletes the contents while not following symbolic - * links. - * - * @param f - * the file or directory. - * @return whether the file or directory was deleted. - */ - final public static boolean delete(File f) { - - if (f.isDirectory()) { - - try { - - File absoluteFile = f.getAbsoluteFile(); - File canonicalFile = f.getCanonicalFile(); - File absoluteParent = absoluteFile.getParentFile().getCanonicalFile(); - File canonicalParent = canonicalFile.getParentFile(); - - // The file is a symbolic link if and only if the names don't match and/or the parent - // directories don't match. - if (!absoluteParent.equals(canonicalParent) // - || !absoluteFile.getName().equals(canonicalFile.getName())) { - return false; - } - - for (File file : f.listFiles()) { - delete(file); - } - - } catch (IOException e) { - - return false; - } - } - - return f.delete(); - } - - /** - * Transfers the contents of one stream into another. - * - * @param in - * the {@link InputStream}. - * @param out - * the {@link OutputStream}. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(InputStream in, OutputStream out) throws IOException { - - byte[] transferBuf = new byte[BULK_TRANSFER_SIZE]; - - for (int size; (size = in.read(transferBuf)) >= 0;) { - out.write(transferBuf, 0, size); - } - - out.flush(); - } - - /** - * Transfers the contents of a file into a stream. - * - * @param inFile - * the input {@link File}. - * @param out - * the {@link OutputStream}. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(File inFile, OutputStream out) throws IOException { - - InputStream in = new FileInputStream(inFile); - - transfer(in, out); - - close(in); - } - - /** - * Transfers the contents of a stream into a file. - * - * @param in - * the {@link InputStream}. - * @param outFile - * the output {@link File}. - * @param append - * whether this operation overwrites the file, or merely appends onto the end. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(InputStream in, File outFile, boolean append) throws IOException { - - OutputStream out = new FileOutputStream(outFile, append); - - transfer(in, out); - - close(out); - } - - /** - * Transfers the contents of a file into a file. - * - * @param inFile - * the input {@link File}. - * @param outFile - * the output {@link File}. - * @param append - * whether this operation overwrites the file, or merely appends onto the end. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(File inFile, File outFile, boolean append) throws IOException { - - InputStream in = new FileInputStream(inFile); - - transfer(in, outFile, append); - - close(in); - } - - /** - * Transfers the contents of a stream into a file without appending. - * - * @param in - * the {@link InputStream}. - * @param outFile - * the output {@link File}. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(InputStream in, File outFile) throws IOException { - transfer(in, outFile, false); - } - - /** - * Transfers the contents of a file into a file without appending. - * - * @param inFile - * the input {@link File}. - * @param outFile - * the output {@link File}. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(File inFile, File outFile) throws IOException { - - InputStream in = new FileInputStream(inFile); - - transfer(in, outFile, false); - - close(in); - } - - /** - * Transfers the contents of a {@code byte} array into a stream. - * - * @param bytes - * the {@code byte} array. - * @param out - * the {@link OutputStream}. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(byte[] bytes, OutputStream out) throws IOException { - - InputStream in = new ByteArrayInputStream(bytes); - - transfer(in, out); - - close(in); - } - - /** - * Transfers the contents of a {@code byte} array into a file. - * - * @param bytes - * the {@code byte} array. - * @param outFile - * the output {@link File}. - * @param append - * whether this operation overwrites the file, or merely appends onto the end. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(byte[] bytes, File outFile, boolean append) throws IOException { - - InputStream in = new ByteArrayInputStream(bytes); - - transfer(in, outFile, append); - - close(in); - } - - /** - * Transfers the contents of a {@code byte} array into a file without appending. - * - * @param bytes - * the {@code byte} array. - * @param outFile - * the output {@link File}. - * @throws IOException - * when something goes awry. - */ - final public static void transfer(byte[] bytes, File outFile) throws IOException { - - InputStream in = new ByteArrayInputStream(bytes); - - transfer(in, outFile, false); - - close(in); - } - - /** - * Gets a {@code byte} array from the given stream. - * - * @param in - * the {@link InputStream}. - * @return the {@code byte} array. - * @throws IOException - * when something goes awry. - */ - final public static byte[] getBytes(InputStream in) throws IOException { - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - transfer(in, out); - - return out.toByteArray(); - } - - /** - * Gets a {@code byte} array from the given file. - * - * @param inFile - * the input {@link File}. - * @return the {@code byte} array. - * @throws IOException - * when something goes awry. - */ - final public static byte[] getBytes(File inFile) throws IOException { - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - transfer(inFile, out); - - return out.toByteArray(); - } - - /** - * Checks if a condition is {@code true}. - */ - final public static void checkTrue(boolean value) { - ensureTrue(value, false, "Check failed"); - } - - /** - * Asserts that a condition is {@code true}. - */ - final public static void assertTrue(boolean value) { - ensureTrue(value, true, "Assertion failed"); - } - - /** - * Checks if two {@code int}s are equal. - * - * @param a - * the first argument. - * @param b - * the second argument. - * @return the equality value, if success. - */ - final public static int checkEquals(int a, int b) { - return checkEquals(a, b, "Check failed"); - } - - /** - * Checks if two objects are equal. - * - * @param - * the object parameterization. - * @param a - * the first argument. - * @param b - * the second argument. - * @return the equality value, if success. - */ - final public static T checkEquals(T a, T b) { - return checkEquals(a, b, "Check failed"); - } - - /** - * Checks if a condition is {@code true}. - * - * @param value - * the truth value to check. - * @param message - * the failure message. - */ - final public static void checkTrue(boolean value, String message) { - ensureTrue(value, false, message); - } - - /** - * Checks if two {@code int}s are equal. - * - * @param a - * the first argument. - * @param b - * the second argument. - * @param message - * the failure message. - * @return the equality value, if success. - */ - final public static int checkEquals(int a, int b, String message) { - - final int n; - - ensureTrue((n = a) == b, false, message); - - return n; - } - - /** - * Checks if two objects are equal. - * - * @param - * the object parameterization. - * @param a - * the first argument. - * @param b - * the second argument. - * @param message - * the failure message. - * @return the equality value, if success. - */ - final public static T checkEquals(T a, T b, String message) { - - final T val; - - ensureTrue(((val = a) != null) ? a.equals(b) : (b == null), false, message); - - return val; - } - - /** - * An internal check/assert method that backs the likes of {@link #checkTrue(boolean)} and - * {@link #assertTrue(boolean)}. - * - * @param value - * the truth value. - * @param isAssertion - * if a failed check results in an {@link AssertionError}. - * @param message - * the failure message. - * @throws RuntimeException - * when a check fails. - * @throws AssertionError - * when an assertion fails. - */ - final protected static void ensureTrue(boolean value, boolean isAssertion, String message) // - throws RuntimeException, AssertionError { - - if (!value) { - - if (isAssertion) { - - throw new AssertionError(message); - - } else { - - throw new RuntimeException(message); - } - } - } - - /** - * Rethrows the given exception. Checked exceptions are wrapped with a {@link RuntimeException}. - * - * @param t - * the exception. - * @throws RuntimeException - * when a {@link RuntimeException} has occurred. - * @throws Error - * when an {@link Error} has occurred. - */ - final public static void rethrow(Throwable t) throws RuntimeException, Error { - - if (t instanceof RuntimeException) { - - throw (RuntimeException) t; - - } else if (t instanceof Error) { - - throw (Error) t; - - } else { - - throw new RuntimeException(t); - } - } - - /** - * Forks and waits on a new {@link Process}. - * - * @param parentIn - * the {@link InputStream} that contains the child's input. - * @param parentOut - * the {@link OutputStream} that receives the child's output. - * @param parentError - * the {@link OutputStream} that receives the child's error output. - * @param execArgs - * the command and arguments to execute. - * @return the return code of the child process. - * @throws IOException - * when something goes awry. - */ - final public static int execAndWaitFor(final InputStream parentIn, // - final OutputStream parentOut, final OutputStream parentError, String... execArgs) throws IOException { - - ProcessBuilder pb = new ProcessBuilder(execArgs); - - Process p = null; - - final AtomicReference childThreadException = new AtomicReference(null); - - try { - - Map env = EnvironmentLocal.get(); - - if (env != null) { - pb.environment().putAll(env); - } - - p = pb.start(); - - final OutputStream out = p.getOutputStream(); - final InputStream in = p.getInputStream(); - final InputStream error = p.getErrorStream(); - - Thread t1 = new Thread("Process Writer") { - - @Override - public void run() { - - try { - - transfer(parentIn, out); - - } catch (IOException e) { - - childThreadException.compareAndSet(null, e); - - } finally { - - // Close the child's input. - Control.close(out); - } - } - }; - - t1.start(); - - Thread t2 = new Thread("Process Reader") { - - @Override - public void run() { - - try { - - transfer(in, parentOut); - - } catch (IOException e) { - - childThreadException.compareAndSet(null, e); - } - } - - }; - - t2.start(); - - Thread t3 = new Thread("Process Error Reader") { - - @Override - public void run() { - - try { - - transfer(error, parentError); - - } catch (IOException e) { - - childThreadException.compareAndSet(null, e); - } - } - - }; - - t3.start(); - - retry: for (;;) { - - try { - - int rc = p.waitFor(); - - // Join with the thread that writes to the child's input. - t1.join(); - - // Join with the thread that reads from the child's output. - t2.join(); - - // Join with the thread that reads from the child's error output. - t3.join(); - - IOException ex = childThreadException.get(); - - if (ex != null) { - throw ex; - } - - return rc; - - } catch (InterruptedException e) { - - continue retry; - } - } - - } finally { - - if (p != null) { - p.destroy(); - } - } - } - - /** - * Forks and waits on a new {@link Process}. - * - * @param execArgs - * the command and arguments to execute. - * @return the return code of the child process. - * @throws IOException - * when something goes awry. - */ - final public static int execAndWaitFor(String... execArgs) throws IOException { - return execAndWaitFor(NullInputStream, NullOutputStream, NullOutputStream, execArgs); - } - - /** - * Forks and waits on a new {@link Process}. - * - * @param parentIn - * the {@link InputStream} that contains the child's input. - * @param execArgs - * the command and arguments to execute. - * @return the return code of the child process. - * @throws IOException - * when something goes awry. - */ - final public static int execAndWaitFor(InputStream parentIn, String... execArgs) throws IOException { - return execAndWaitFor(parentIn, NullOutputStream, NullOutputStream, execArgs); - } - - /** - * Forks and waits on a new {@link Process}. - * - * @param parentOut - * the {@link OutputStream} that receives the child's output. - * @param execArgs - * the command and arguments to execute. - * @return the return code of the child process. - * @throws IOException - * when something goes awry. - */ - final public static int execAndWaitFor(OutputStream parentOut, String... execArgs) throws IOException { - return execAndWaitFor(NullInputStream, parentOut, parentOut, execArgs); - } - - /** - * Forks and waits on a new {@link Process}. - * - * @param parentIn - * the {@link InputStream} that contains the child's input. - * @param parentOut - * the {@link OutputStream} that receives the child's output. - * @param execArgs - * the command and arguments to execute. - * @return the return code of the child process. - * @throws IOException - * when something goes awry. - */ - final public static int execAndWaitFor(InputStream parentIn, OutputStream parentOut, String... execArgs) - throws IOException { - return execAndWaitFor(parentIn, parentOut, parentOut, execArgs); - } - - /** - * Begins building the mapping of environment variables for {@link Thread#currentThread()}. - */ - final public static Map beginEnvironment() { - - Control.checkTrue(EnvironmentLocal.get() == null, // - "Must call endEnvironment() before beginEnvironment()"); - - Map env = new HashMap(); - - EnvironmentLocal.set(env); - - return env; - } - - /** - * Ends building the mapping of environment variables for {@link Thread#currentThread()}. - */ - final public static void endEnvironment() { - - Control.checkTrue(EnvironmentLocal.get() != null, // - "Must call beginEnvironment() before endEnvironment()"); - - EnvironmentLocal.set(null); - } - - /** - * Creates a pool of daemon worker threads. - * - * @param ncoreThreads - * the number of core threads. - * @param nmaxThreads - * the maximum number of threads. - * @param workQueue - * the {@link BlockingQueue} to which work is submitted. - * @param h - * the handler to invoke when a worker thread dies horribly. - * @return the pool. - */ - final public static ThreadPoolExecutor createPool(int ncoreThreads, int nmaxThreads, // - BlockingQueue workQueue, final UncaughtExceptionHandler h) { - - return new ThreadPoolExecutor(ncoreThreads, nmaxThreads, // - (ncoreThreads < nmaxThreads) ? 60000L : 0L, // - TimeUnit.MILLISECONDS, workQueue, // - - new ThreadFactory() { - - volatile int threadCount = 0; - - public Thread newThread(Runnable r) { - - Thread t = new Thread(r, String.format("Thread Pool Worker #%d", this.threadCount++)); - t.setDaemon(true); - t.setUncaughtExceptionHandler(h); - - return t; - } - } // - ); - } - - /** - * Creates a pool of daemon worker threads. - * - * @param ncoreThreads - * the number of core threads. - * @return the pool. - */ - final public static ThreadPoolExecutor createPool(int ncoreThreads) { - return createPool(ncoreThreads, ncoreThreads, // - new LinkedBlockingQueue(), null); - } - - /** - * Creates a pool of daemon worker threads of size {@link Runtime#availableProcessors()}. - * - * @return the pool. - */ - final public static ThreadPoolExecutor createPool() { - - int ncoreThreads = Runtime.getRuntime().availableProcessors(); - return createPool(ncoreThreads, ncoreThreads, // - new LinkedBlockingQueue(), null); - } - - /** - * Creates a {@link Document}. - */ - final public static Document createDocument() { - return BuilderLocal.get().newDocument(); - } - - /** - * Creates a {@link Document} from the given {@code byte} array. - */ - final public static Document createDocument(byte[] array) { - return createDocument(new ByteArrayInputStream(array)); - } - - /** - * Creates a {@link Document} from the given string. - */ - final public static Document createDocument(String data) { - return createDocument(new ByteArrayInputStream(data.getBytes())); - } - - /** - * Creates a {@link Document} from the given file. - */ - final public static Document createDocument(File file) { - - final FileInputStream fin; - - try { - - fin = new FileInputStream(file); - - } catch (IOException e) { - - throw new RuntimeException(e); - } - - return createDocument(fin); - } - - /** - * Creates a {@link Document} from the given {@link InputStream}. - */ - final public static Document createDocument(InputStream in) { - - try { - - return BuilderLocal.get().parse(in); - - } catch (Exception e) { - - throw new RuntimeException(e); - } - } - - /** - * Converts the given {@link Document} to a string. - */ - final public static String toString(Node node) { - - StringWriter sw = new StringWriter(); - - try { - - TransformerLocal.get().transform(new DOMSource(node), new StreamResult(sw)); - - } catch (TransformerException e) { - - throw new RuntimeException(e); - } - - return sw.toString(); - } - - // Dummy constructor. - Control() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/CoreThread.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/CoreThread.java deleted file mode 100755 index 72a008dd..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/CoreThread.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -/** - * A thread convenience class that has a {@code try}-{@code catch}-{@code finally} pattern built into its - * {@link Runnable#run()} method. - * - * @author Roy Liu - */ -abstract public class CoreThread extends Thread { - - /** - * Default constructor. - * - * @param name - * the name of this thread. - */ - public CoreThread(String name) { - super(name); - } - - /** - * Houses the {@code try}-{@code catch}-{@code finally} pattern. - */ - @Override - public void run() { - - try { - - runUnchecked(); - - } catch (Throwable t) { - - runCatch(t); - - } finally { - - runFinalizer(); - } - } - - /** - * Runs the main body of code and passes any uncaught exceptions up to the {@link Runnable#run()} method. - * - * @throws Exception - * the deferred exception. - */ - abstract protected void runUnchecked() throws Exception; - - /** - * Runs the exception handler. The default behavior is wrap the given {@link Throwable} in a - * {@link RuntimeException} and throw that. - */ - protected void runCatch(Throwable t) { - Control.rethrow(t); - } - - /** - * Runs the finalizer. Guaranteed to execute on termination of {@link #runUnchecked()}. The default behavior is to - * do nothing. - */ - protected void runFinalizer() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicArray.java deleted file mode 100755 index 9f4792e2..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicArray.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -/** - * Defines an array that can grow and shrink dynamically. - * - * @param - * the parameterization lower bounded by {@link DynamicArray} itself. - * @param - * the storage array type. - * @param - * the component type. - * @author Roy Liu - */ -public interface DynamicArray, V, E> extends Cloneable { - - /** - * Clears this array. - * - * @return this array. - */ - public T clear(); - - /** - * Ensures that this array has at least the given capacity. - * - * @param capacity - * the desired capacity. - * @return this array. - */ - public T ensureCapacity(int capacity); - - /** - * Gets the number of elements. - * - * @return the number of elements. - */ - public int size(); - - /** - * Gets the capacity. - * - * @return the capacity. - */ - public int capacity(); - - /** - * Gets the storage array truncated to the current size. - * - * @return a truncated copy of the storage array. - */ - public V values(); - - /** - * Gets the component type. - */ - public Class getComponentType(); - - /** - * Creates a human-readable representation of this array. - */ - public String toString(); - - /** - * Clones this array. - */ - public T clone(); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicDoubleArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicDoubleArray.java deleted file mode 100755 index e6920486..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicDoubleArray.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.util.Arrays; - -/** - * An implementation of {@link DynamicArray} for {@code double}s. - * - * @author Roy Liu - */ -public class DynamicDoubleArray implements DynamicArray { - - /** - * The initial capacity. - */ - final public static int INITIAL_CAPACITY = 127; - - double[] values; - - int size; - - /** - * Default constructor. - */ - public DynamicDoubleArray() { - this(INITIAL_CAPACITY); - } - - /** - * Alternate constructor. - */ - public DynamicDoubleArray(int capacity) { - - this.values = new double[capacity]; - this.size = 0; - } - - /** - * Alternate constructor. - */ - protected DynamicDoubleArray(double[] values, int size) { - - this.values = values; - this.size = size; - } - - /** - * Gets the value at the given index. - */ - public double get(int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - return this.values[index]; - } - - /** - * Sets a value at the given index. - */ - public DynamicDoubleArray push(double value, int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - this.values[index] = value; - - return this; - } - - /** - * Pops off the last pushed on value. - */ - public double pop() { - - Control.checkTrue(this.size > 0, // - "No more elements"); - - if (this.size <= (this.values.length + 1) >>> 2) { - this.values = Arrays.copyOf(this.values, this.values.length >>> 1); - } - - return this.values[--this.size]; - } - - /** - * Pushes on a value. - */ - public DynamicDoubleArray push(double value) { - - if (this.size == this.values.length) { - this.values = Arrays.copyOf(this.values, 2 * this.values.length + 1); - } - - this.values[this.size++] = value; - - return this; - } - - public DynamicDoubleArray clear() { - - this.values = new double[INITIAL_CAPACITY]; - this.size = 0; - - return this; - } - - public DynamicDoubleArray ensureCapacity(int capacity) { - - this.values = (this.values.length < capacity) ? Arrays.copyOf(this.values, capacity) : this.values; - - return this; - } - - public int size() { - return this.size; - } - - public int capacity() { - return this.values.length; - } - - public double[] values() { - return Arrays.copyOf(this.values, this.size); - } - - public Class getComponentType() { - return Double.class; - } - - @Override - public String toString() { - return String.format("%s[size = %d, capacity = %d, values = %s]", // - DynamicDoubleArray.class.getSimpleName(), // - size(), capacity(), Arrays.toString(values())); - } - - @Override - public DynamicDoubleArray clone() { - return new DynamicDoubleArray(this.values.clone(), this.size); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicIntArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicIntArray.java deleted file mode 100755 index 610113a6..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicIntArray.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.util.Arrays; - -/** - * An implementation of {@link DynamicArray} for {@code int}s. - * - * @author Roy Liu - */ -public class DynamicIntArray implements DynamicArray { - - /** - * The initial capacity. - */ - final public static int INITIAL_CAPACITY = 255; - - int[] values; - - int size; - - /** - * Default constructor. - */ - public DynamicIntArray() { - this(INITIAL_CAPACITY); - } - - /** - * Alternate constructor. - */ - public DynamicIntArray(int capacity) { - - this.values = new int[capacity]; - this.size = 0; - } - - /** - * Alternate constructor. - */ - protected DynamicIntArray(int[] values, int size) { - - this.values = values; - this.size = size; - } - - /** - * Gets the value at the given index. - */ - public double get(int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - return this.values[index]; - } - - /** - * Sets a value at the given index. - */ - public DynamicIntArray push(int value, int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - this.values[index] = value; - - return this; - } - - /** - * Pops off the last pushed on value. - */ - public int pop() { - - Control.checkTrue(this.size > 0, // - "No more elements"); - - if (this.size <= (this.values.length + 1) >>> 2) { - this.values = Arrays.copyOf(this.values, this.values.length >>> 1); - } - - return this.values[--this.size]; - } - - /** - * Pushes on a value. - */ - public DynamicIntArray push(int value) { - - if (this.size == this.values.length) { - this.values = Arrays.copyOf(this.values, 2 * this.values.length + 1); - } - - this.values[this.size++] = value; - - return this; - } - - public DynamicIntArray clear() { - - this.values = new int[INITIAL_CAPACITY]; - this.size = 0; - - return this; - } - - public DynamicIntArray ensureCapacity(int capacity) { - - this.values = (this.values.length < capacity) ? Arrays.copyOf(this.values, capacity) : this.values; - - return this; - } - - public int size() { - return this.size; - } - - public int capacity() { - return this.values.length; - } - - public int[] values() { - return Arrays.copyOf(this.values, this.size); - } - - public Class getComponentType() { - return Integer.class; - } - - @Override - public String toString() { - return String.format("%s[size = %d, capacity = %d, values = %s]", // - DynamicIntArray.class.getSimpleName(), // - size(), capacity(), Arrays.toString(values())); - } - - @Override - public DynamicIntArray clone() { - return new DynamicIntArray(this.values.clone(), this.size); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicLongArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicLongArray.java deleted file mode 100755 index a78c8178..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicLongArray.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.util.Arrays; - -/** - * An implementation of {@link DynamicArray} for {@code long}s. - * - * @author Roy Liu - */ -public class DynamicLongArray implements DynamicArray { - - /** - * The initial capacity. - */ - final public static int INITIAL_CAPACITY = 127; - - long[] values; - - int size; - - /** - * Default constructor. - */ - public DynamicLongArray() { - this(INITIAL_CAPACITY); - } - - /** - * Alternate constructor. - */ - public DynamicLongArray(int capacity) { - - this.values = new long[capacity]; - this.size = 0; - } - - /** - * Alternate constructor. - */ - protected DynamicLongArray(long[] values, int size) { - - this.values = values; - this.size = size; - } - - /** - * Gets the value at the given index. - */ - public long get(int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - return this.values[index]; - } - - /** - * Sets a value at the given index. - */ - public DynamicLongArray push(long value, int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - this.values[index] = value; - - return this; - } - - /** - * Pops off the last pushed on value. - */ - public long pop() { - - Control.checkTrue(this.size > 0, // - "No more elements"); - - if (this.size <= (this.values.length + 1) >>> 2) { - this.values = Arrays.copyOf(this.values, this.values.length >>> 1); - } - - return this.values[--this.size]; - } - - /** - * Pushes on a value. - */ - public DynamicLongArray push(long value) { - - if (this.size == this.values.length) { - this.values = Arrays.copyOf(this.values, 2 * this.values.length + 1); - } - - this.values[this.size++] = value; - - return this; - } - - public DynamicLongArray clear() { - - this.values = new long[INITIAL_CAPACITY]; - this.size = 0; - - return this; - } - - public DynamicLongArray ensureCapacity(int capacity) { - - this.values = (this.values.length < capacity) ? Arrays.copyOf(this.values, capacity) : this.values; - - return this; - } - - public int size() { - return this.size; - } - - public int capacity() { - return this.values.length; - } - - public long[] values() { - return Arrays.copyOf(this.values, this.size); - } - - public Class getComponentType() { - return Long.class; - } - - @Override - public String toString() { - return String.format("%s[size = %d, capacity = %d, values = %s]", // - DynamicLongArray.class.getSimpleName(), // - size(), capacity(), Arrays.toString(values())); - } - - @Override - public DynamicLongArray clone() { - return new DynamicLongArray(this.values.clone(), this.size); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicObjectArray.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicObjectArray.java deleted file mode 100755 index 7787bffc..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/DynamicObjectArray.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.lang.reflect.Array; -import java.util.Arrays; - -/** - * An implementation of {@link DynamicArray} for objects. - * - * @param - * the component type. - * @author Roy Liu - */ -public class DynamicObjectArray implements DynamicArray, T[], T> { - - /** - * The initial capacity. - */ - final public static int INITIAL_CAPACITY = 127; - - T[] values; - - int size; - - /** - * Default constructor. - */ - public DynamicObjectArray(Class clazz) { - this(clazz, INITIAL_CAPACITY); - } - - /** - * Alternate constructor. - */ - @SuppressWarnings("unchecked") - public DynamicObjectArray(Class clazz, int capacity) { - - this.values = (T[]) Array.newInstance(clazz, capacity); - this.size = 0; - } - - /** - * Alternate constructor. - */ - protected DynamicObjectArray(T[] values, int size) { - - this.values = values; - this.size = size; - } - - /** - * Gets the value at the given index. - */ - public T get(int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - return this.values[index]; - } - - /** - * Sets a value at the given index. - */ - public DynamicObjectArray push(T value, int index) { - - Control.checkTrue(index >= 0 && index < this.size, // - "Invalid index"); - - this.values[index] = value; - - return this; - } - - /** - * Pops off the last pushed on value. - */ - public T pop() { - - Control.checkTrue(this.size > 0, // - "No more elements"); - - if (this.size <= (this.values.length + 1) >>> 2) { - this.values = Arrays.copyOf(this.values, this.values.length >>> 1); - } - - return this.values[--this.size]; - } - - /** - * Pushes on a value. - */ - public DynamicObjectArray push(T value) { - - if (this.size == this.values.length) { - this.values = Arrays.copyOf(this.values, 2 * this.values.length + 1); - } - - this.values[this.size++] = value; - - return this; - } - - @SuppressWarnings("unchecked") - public DynamicObjectArray clear() { - - this.values = (T[]) Array.newInstance(getComponentType(), INITIAL_CAPACITY); - this.size = 0; - - return this; - } - - public DynamicObjectArray ensureCapacity(int capacity) { - - this.values = (this.values.length < capacity) ? Arrays.copyOf(this.values, capacity) : this.values; - - return this; - } - - public int size() { - return this.size; - } - - public int capacity() { - return this.values.length; - } - - public T[] values() { - return Arrays.copyOf(this.values, this.size); - } - - @SuppressWarnings("unchecked") - public Class getComponentType() { - return (Class) this.values.getClass().getComponentType(); - } - - @Override - public String toString() { - return String.format("%s[size = %d, capacity = %d, values = %s]", // - DynamicObjectArray.class.getSimpleName(), // - size(), capacity(), Arrays.toString(values())); - } - - @Override - public DynamicObjectArray clone() { - return new DynamicObjectArray(this.values.clone(), this.size); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/Finalizable.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/Finalizable.java deleted file mode 100755 index 79df76a9..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/Finalizable.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -/** - * Defines something that requires special processing during the finalization stage of the object life cycle. - * - * @param - * the parameterization lower bounded by {@link Finalizable} itself. - * @author Roy Liu - */ -public interface Finalizable> { - - /** - * Sets the finalizer. - * - * @param finalizer - * the finalizer. - * @return this object. - */ - public T setFinalizer(Runnable finalizer); -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/LoadableResources.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/LoadableResources.java deleted file mode 100755 index 2c3e8e45..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/LoadableResources.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An annotation in support of {@link Loader} resource loading. - * - * @apiviz.owns shared.util.LoadableResources.Resource - * @author Roy Liu - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface LoadableResources { - - /** - * An enumeration of the types of loadable resources. - */ - public enum ResourceType { - - /** - * Denotes a native library. - */ - NATIVE, // - - /** - * Denotes a Jar file. - */ - JAR, // - - /** - * Denotes a file system folder. - */ - FILE_SYSTEM; - } - - /** - * Gets the resource descriptions. - */ - public Resource[] resources(); - - /** - * Gets the names of packages whose classes require said resources for linking. - */ - public String[] packages(); - - /** - * An annotation describing the whereabouts and type of a resource. - * - * @apiviz.owns shared.util.LoadableResources.ResourceType - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - public @interface Resource { - - /** - * Gets the resource type. - */ - public ResourceType type(); - - /** - * Gets the resource name. - */ - public String name(); - - /** - * Gets the resource path. - */ - public String path(); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/Loader.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/Loader.java deleted file mode 100755 index 01ed192c..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/Loader.java +++ /dev/null @@ -1,325 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Method; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.jar.JarInputStream; - -import shared.metaclass.FileSystemRegistry; -import shared.metaclass.JarRegistry; -import shared.metaclass.RegistryClassLoader; -import shared.util.LoadableResources.Resource; - -/** - * A facility providing a way for programs to take advantage of Jars and native libraries found on the class path. To - * use it, one annotates a target class with {@link LoadableResources.Resource}s specifying the Jars and native - * libraries to be loaded, as well as the {@link Service}s to be registered. - * - * @apiviz.has shared.util.LoadableResources - - - argument - * @apiviz.has shared.util.Loader.EntryPoint - - - argument - * @apiviz.uses shared.util.TemporaryFiles - * @author Roy Liu - */ -public class Loader { - - /** - * A marker annotation for the entry point of a program after {@link Loader} has acquired the required - * resources. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface EntryPoint { - } - - /** - * The entry point for {@link Loader} when invoked as a Java process. - * - * @exception Exception - * when something goes awry. - */ - public static void main(String[] args) throws Exception { - - Control.checkTrue(args.length > 0, // - "Please specify class to load"); - - start(args[0], Arrays.copyOfRange(args, 1, args.length), true); - } - - /** - * Delegates to {@link #start(String, Object, boolean)} with the class loader delegation flag set to {@code true}. - * - * @exception Exception - * when something goes awry. - */ - public static void start(String targetName, Object invocationArg) throws Exception { - start(targetName, invocationArg, true); - } - - /** - * The entry point for {@link Loader} when invoked programmatically. - * - * @param targetName - * the target class. - * @param invocationArg - * the invocation argument. - * @param useDelegation - * whether to use the class loader gotten by {@link Thread#getContextClassLoader()} or {@code null} as - * the underlying {@link RegistryClassLoader}'s parent. - * @throws Exception - * when something goes awry. - */ - @SuppressWarnings("unchecked") - public static void start(String targetName, Object invocationArg, boolean useDelegation) throws Exception { - - List jars = new ArrayList(); - List folders = new ArrayList(); - List libraries = new ArrayList(); - - // - - Thread currentThread = Thread.currentThread(); - ClassLoader cl = currentThread.getContextClassLoader(); - - // Retrieve the annotations WITHOUT initializing the class, which may depend on stuff yet to be loaded. - LoadableResources resources = Class.forName(targetName, false, cl) // - .getAnnotation(LoadableResources.class); - - Control.checkTrue(resources != null, // - "Resource annotations not declared"); - - for (Resource resource : resources.resources()) { - - switch (resource.type()) { - - case NATIVE: - libraries.add(resource); - break; - - case JAR: - jars.add(resource); - break; - - case FILE_SYSTEM: - folders.add(resource); - break; - - default: - throw new AssertionError("Control should never reach here"); - } - } - - // - - final List cleanups = new ArrayList(); - - RegistryClassLoader bootstrapCL = new RegistryClassLoader(useDelegation ? cl : null) // - .setFinalizer(new Runnable() { - - public void run() { - - for (File f : cleanups) { - - Control.delete(f); - TemporaryFiles.undelete(f); - } - } - }); - - for (Resource jar : jars) { - - String pathname = String.format("%s/%s.jar", jar.path(), jar.name()); - - InputStream in = cl.getResourceAsStream(pathname); - - Control.checkTrue(in != null, // - String.format("Resource '%s' not found", pathname)); - - bootstrapCL.addRegistry(new JarRegistry(new JarInputStream(in))); - } - - // - - for (Resource folder : folders) { - - Control.checkTrue(folder.name().equals(""), // - "Folders do not have names"); - - bootstrapCL.addRegistry(new FileSystemRegistry(new File(folder.path()))); - } - - // - - for (String packageName : resources.packages()) { - bootstrapCL.addPackage(packageName); - } - - // - - for (Resource library : libraries) { - - String libName = library.name(); - String pathname = String.format("%s/%s", // - library.path(), System.mapLibraryName(libName)); - - URL url = cl.getResource(pathname); - - // Attempt to load from a file, if found. - if (url != null) { - - final File f; - - if (url.getProtocol().equals("file")) { - - try { - - f = new File(url.toURI()); - - } catch (URISyntaxException e) { - - throw new RuntimeException(e); - } - - } else { - - InputStream in = cl.getResourceAsStream(pathname); - - Control.checkTrue(in != null, // - String.format("Resource '%s' not found", pathname)); - - try { - - f = File.createTempFile(pathname.replace("/", "_").concat("_"), ""); - - cleanups.add(f); - TemporaryFiles.deleteOnExit(f); - - Control.transfer(in, f); - - } catch (IOException e) { - - throw new RuntimeException(e); - - } finally { - - Control.close(in); - } - } - - bootstrapCL.load(f); - } - // Fall back on the dynamic linker for resolution. - else { - - try { - - bootstrapCL.loadLibrary(libName); - - } catch (RuntimeException e) { - - throw new RuntimeException(String.format("The native library resource '%s' was not found " // - + "and dynamic linker resolution of '%s' failed", pathname, libName), e); - } - } - } - - // - - Class entryPointClass = // - (Class) Class.forName(EntryPoint.class.getName(), true, bootstrapCL); - - Class targetClass = Class.forName(targetName, false, bootstrapCL); - - Method method = null; - - // Find any annotated methods. - for (Method m : targetClass.getMethods()) { - - if (m.isAnnotationPresent(entryPointClass)) { - - Control.checkTrue(method == null, // - "Duplicate entry points"); - - method = m; - } - } - - Control.checkTrue(method != null, // - "Annotated entry point method not found"); - - try { - - currentThread.setContextClassLoader(bootstrapCL); - - method.invoke(null, invocationArg); - - } finally { - - currentThread.setContextClassLoader(cl); - } - } - - /** - * Registers a {@link Service}. - * - * @param - * the service type. - * @param serviceSpec - * the service to register. - */ - @SuppressWarnings("unchecked") - public static void registerService(String[] serviceSpec) { - - final Class specClass; - final Class implClass; - - try { - - specClass = (Class) Class.forName(serviceSpec[0]); - implClass = (Class) Class.forName(serviceSpec[1]); - - } catch (ClassNotFoundException e) { - - throw new RuntimeException(e); - } - - Control.checkTrue(Service.class.isAssignableFrom(specClass), // - "Specification class is not marked as a service"); - - Control.checkTrue(specClass.isAssignableFrom(implClass), // - "Specification class is not a superclass of the implementation class"); - - Services.registerService(specClass, implClass); - } - - // Dummy constructor. - Loader() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/ReferenceReaper.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/ReferenceReaper.java deleted file mode 100755 index 53e0f0c1..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/ReferenceReaper.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu, The Regents of the University of California
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.lang.ref.Reference; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.SoftReference; -import java.lang.ref.WeakReference; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * A utility class for reaping {@link SoftReference}s and {@link WeakReference}s. - * - * @apiviz.composedOf shared.util.ReferenceReaper.ReaperThread - * @apiviz.has shared.util.ReferenceReaper.ReferenceType - - - argument - * @param - * the referent type. - * @author Roy Liu - */ -public class ReferenceReaper { - - /** - * An enumeration of {@link Reference} types. - */ - public enum ReferenceType { - - /** - * Indicates a {@link SoftReference}. - */ - SOFT, // - - /** - * Indicates a {@link WeakReference}. - */ - WEAK; - } - - final ReaperThread thread; - - /** - * Default constructor. - */ - public ReferenceReaper() { - this.thread = new ReaperThread(); - } - - /** - * Registers a referent with this reaper. - * - * @param type - * the type of {@link Reference} desired. - * @param referent - * the referent. - * @param cache - * the {@link ConcurrentMap} to register with and clean up from. - * @param cacheKey - * the key used to retrieve the referent. - * @param - * the key type. - * @return a {@link Reference} to the referent. - */ - public Reference register(ReferenceType type, T referent, // - final ConcurrentMap> cache, final K cacheKey) { - - Runnable cleanup = new Runnable() { - - public void run() { - cache.remove(cacheKey); - } - }; - - final Reference ref; - - // Synchronization ensures that insertion happens BEFORE removal. - synchronized (this.thread) { - - switch (type) { - - case SOFT: - - ref = new SoftReference(referent, this.thread.rq) { - - @Override - public String toString() { - return String.valueOf(get()); - } - }; - - break; - - case WEAK: - - ref = new WeakReference(referent, this.thread.rq) { - - @Override - public String toString() { - return String.valueOf(get()); - } - }; - - break; - - default: - throw new IllegalArgumentException("Invalid reference type"); - } - - cache.put(cacheKey, ref); - this.thread.map.put(ref, cleanup); - } - - return ref; - } - - /** - * A worker thread class for reaping {@link Reference}s. - * - * @param - * the referent type. - */ - final protected static class ReaperThread extends CoreThread { - - final ReferenceQueue rq; - final ConcurrentMap, Runnable> map; - - volatile boolean run; - - /** - * Default constructor. - */ - protected ReaperThread() { - super("Reaper"); - - this.rq = new ReferenceQueue(); - this.map = new ConcurrentHashMap, Runnable>(); - - this.run = true; - - setDaemon(true); - start(); - } - - /** - * Runs the reference reaping loop. - */ - @Override - public void runUnchecked() { - - loop: for (; this.run;) { - - final Reference ref; - - try { - - ref = this.rq.remove(); - - } catch (InterruptedException e) { - - continue loop; - } - - // Synchronization ensures that removal happens AFTER insertion. - synchronized (this) { - } - - try { - - this.map.remove(ref).run(); - - } catch (NullPointerException e) { - - // In case the key-value relationship was not successfully added to the map. - - } catch (Throwable t) { - - // In case the cleanup stub acts up. - } - } - } - } - - // A finalizer guardian for the reaper thread. - final Object threadReaper = new Object() { - - @Override - protected void finalize() { - - ReferenceReaper.this.thread.run = false; - ReferenceReaper.this.thread.interrupt(); - } - }; -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/RequestFuture.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/RequestFuture.java deleted file mode 100755 index a2904ffc..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/RequestFuture.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.util.concurrent.FutureTask; - -/** - * A subclass of {@link FutureTask} specially geared toward asynchronous request-response patterns. - * - * @param - * the result type. - * @author Roy Liu - */ -public class RequestFuture extends FutureTask { - - /** - * Default constructor. - */ - public RequestFuture() { - super(Control.NullRunnable, null); - } - - /** - * Gives public visibility to the {@link FutureTask#set(Object)} method. - */ - @Override - public void set(T v) { - super.set(v); - } - - /** - * Gives public visibility to the {@link FutureTask#setException(Throwable)} method. - */ - @Override - public void setException(Throwable t) { - super.setException(t); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/Service.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/Service.java deleted file mode 100755 index 4ef1c870..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/Service.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2008 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -/** - * Defines something as providing a service. - * - * @author Roy Liu - */ -public interface Service { -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/Services.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/Services.java deleted file mode 100755 index 7fb924c9..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/Services.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2007 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.lang.ref.Reference; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import shared.util.ReferenceReaper.ReferenceType; - -/** - * A global registry of various {@link Service}s and their implementing classes. - * - * @apiviz.owns shared.util.Service - * @author Roy Liu - */ -public class Services { - - /** - * A global instance. - */ - final protected static Services Instance = new Services(); - - final ConcurrentMap, Reference>> serviceMap; - final ReferenceReaper> rr; - - /** - * Default constructor. - */ - protected Services() { - - this.serviceMap = new ConcurrentHashMap, Reference>>(); - this.rr = new ReferenceReaper>(); - } - - /** - * Creates an implementing class instance from the given specification superclass. - * - * @param - * the implementing class type, which is a lower bound on the superclass type. - * @param specClass - * the specification superclass. - * @return an instance of the implementing class. - */ - @SuppressWarnings("unchecked") - public static A createService(Class specClass) { - - try { - - Reference> ref = Instance.serviceMap.get(specClass); - - if (ref == null) { - return null; - } - - Class implClass = ref.get(); - - if (implClass == null) { - return null; - } - - return ((Class) implClass).newInstance(); - - } catch (Exception e) { - - throw new RuntimeException(e); - } - } - - /** - * Registers an implementing class with the given specification superclass. - * - * @param - * the superclass type, which is an upper bound on the implementation class type. - * @param specClass - * the specification superclass. - * @param implClass - * the implementing class. - */ - public static void registerService(Class specClass, Class implClass) { - Instance.rr.register(ReferenceType.WEAK, implClass, Instance.serviceMap, specClass); - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/TemporaryFiles.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/TemporaryFiles.java deleted file mode 100755 index 938feb0e..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/TemporaryFiles.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
http://www.gnu.org/licenses/. - */ - -package shared.util; - -import java.io.File; -import java.util.HashSet; -import java.util.Set; - -/** - * A class whose static methods allow (de)registration of files for deletion upon JVM shutdown. - * - * @author Roy Liu - */ -public class TemporaryFiles { - - /** - * The set of temporary files under consideration for deletion. - */ - protected static Set Deletions = new HashSet(); - - static { - - Runtime.getRuntime().addShutdownHook(new CoreThread("Temporary File Deletion Hook") { - - @Override - protected void runUnchecked() { - - synchronized (TemporaryFiles.class) { - - for (File deletion : Deletions) { - Control.delete(deletion); - } - - Deletions = null; - } - } - }); - } - - /** - * Adds the given file for deletion and serves as an alternative to {@link File#deleteOnExit()}. - * - * @param file - * the file. - * @return the file. - */ - final public static File deleteOnExit(File file) { - - synchronized (TemporaryFiles.class) { - - if (Deletions != null) { - - Deletions.add(file); - - return file; - - } else { - - throw new IllegalStateException("Shutdown imminent"); - } - } - } - - /** - * Removes the given file from consideration for deletion. - * - * @param file - * the file. - * @return whether the file was under consideration for deletion. - */ - final public static boolean undelete(File file) { - - synchronized (TemporaryFiles.class) { - - if (Deletions != null) { - - return Deletions.remove(file); - - } else { - - throw new IllegalStateException("Shutdown imminent"); - } - } - } - - // Dummy constructor. - TemporaryFiles() { - } -} diff --git a/contrib/applications/nxplot/sharedscientific/src/shared/util/package-info.java b/contrib/applications/nxplot/sharedscientific/src/shared/util/package-info.java deleted file mode 100755 index 638b9c43..00000000 --- a/contrib/applications/nxplot/sharedscientific/src/shared/util/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file is part of the Shared Scientific Toolbox in Java ("this library").
- *
- * Copyright (C) 2009 Roy Liu
- *
- * This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) - * any later version.
- *
- * This library 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 Lesser General Public License for more - * details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. - */ - -/** - * A package of convenience classes. - */ -package shared.util; - diff --git a/contrib/bindings/README b/contrib/bindings/README index c897ad0d..1c39e4b5 100644 --- a/contrib/bindings/README +++ b/contrib/bindings/README @@ -1,6 +1,5 @@ This directory contains NeXus language bindings contributed by the -neutron community that are not (yet) part of the official NeXus -distribution. +community that are not (yet) part of the official NeXus distribution. See the individual directories for further details. diff --git a/doc/howto/README b/doc/howto/README deleted file mode 100644 index b33b9b4e..00000000 --- a/doc/howto/README +++ /dev/null @@ -1,3 +0,0 @@ -Various bits of NeXus documentation --- -$Id$ diff --git a/doc/tutorial/README b/doc/tutorial/README deleted file mode 100644 index b33b9b4e..00000000 --- a/doc/tutorial/README +++ /dev/null @@ -1,3 +0,0 @@ -Various bits of NeXus documentation --- -$Id$ diff --git a/gnu_license.txt b/gnu_license.txt deleted file mode 100755 index 42d5094f..00000000 --- a/gnu_license.txt +++ /dev/null @@ -1,515 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - - diff --git a/install_nexus_dep_rpm b/install_nexus_dep_rpm deleted file mode 100755 index edda0d85..00000000 --- a/install_nexus_dep_rpm +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# -# $Id$ -# -# Install additional libraries for NeXus -# -rpm -Uvh http://nexus.isis.rl.ac.uk/kits/rpm/szip-2.0-1.i386.rpm -rpm -Uvh http://nexus.isis.rl.ac.uk/kits/rpm/hdf-4.2.1-1.i386.rpm -rpm -Uvh http://nexus.isis.rl.ac.uk/kits/rpm/hdf5-1.6.4-1.i386.rpm -rpm -Uvh http://nexus.isis.rl.ac.uk/kits/rpm/mxml-2.2.2-1.i386.rpm -# diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 803d6228..761f605c 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -27,6 +27,3 @@ #==================================================================== add_subdirectory (tclap) -if(HAVE_XML) -add_subdirectory (mxml-2.6) -endif(HAVE_XML) \ No newline at end of file diff --git a/third_party/README.txt b/third_party/README.txt deleted file mode 100644 index 2ad7bdd9..00000000 --- a/third_party/README.txt +++ /dev/null @@ -1,4 +0,0 @@ -mxml: Mini-XML 2.6 from www.minixml.org -HDF5: HDF5-1.8.7 from www.hdfgroup.org with some bits removed (e.g. examples, applications, fortran, C++, HDF5 high level API) - -$Id: $ \ No newline at end of file