22 May 2007

Java Astro Library

Astrology for Dogs Ten years ago I had a little interest in astrology. I studied some books and had the idea for an astro-chart real-time watch, some kind of watch that shows the wheel chart for the actual time just like a simple wristwatch. After releasing my Zodiac Watch applet in 2000 I got a lot of requests for its source. So I created AstroLib as branch from Zodiac Watch applet's source in 2003. I removed all painting and user interface routines to create a library.

This is AstroLib
... a free Java library for astro charting calculations. There are house system and planet position calculation methods together with date/time and location conversion routines. For a given time the positions of the planets in the zodiac are calculated. There is no code for graphical representations or drawing a chart. The library contains just methods for calculating the data needed to build a chart. Some methods were simply ported from Walter 'Cruiser1' Pullen's Astrolog 5.40 (which is written in C) and converted to Java. Part of the code is commented in German, but variables and methods are all named in English.

The library is used as shown in the Demo class' main method:
   // get a horoscop instance
TextHoroscop horoscop = new TextHoroscop();
// set your desired planet position calculation algorithm
horoscop.setPlanet(new PlanetAA0());
// set your desired house system calculation algorithm
// may be anything from the at.kugel.zodiac.house package.
horoscop.setHouse(new HousePlacidus());
// set your user data time value
horoscop.setTime(1, 12, 1953, 20);
// set your user data location value
horoscop.setLocationDegree(-16 - 17.0/60, 48 + 4.0/60);
// calculate the values
horoscop.calcValues();
// do something with the data, e.g. output raw data
System.out.println(horoscop.toString());
In case you want to add or change something, there are the following packages:
  • The main package contains the TextHoroscop class, which uses the house system and planet calculation classes to calculate the astro-chart data.
  • util contains some independent calculation utility functions and classes.
  • planet contains the different planet position calculation algorithms. This package is only dependent on the util package. All planet position algorithms are subclasses of PlanetBasic which itself implements PlanetInt. New and more accurate planet position algorithms must implement PlanetInt and may wish to extend PlanetBasic to inherit common functionality, but are not forced to do so. There is only PlanetAA0 available at the moment, which is not very accurate.
  • house contains the different house systems. All house system calculation algorithms are subclasses of HouseBasic which itself implements HouseInt.
Download and Installation
Download AstroLib 1.13 (70 KB), together with source. Extract the astrolib-*.zip and add astrolib.jar to your classpath. AstroLib is JDK 1.1 compliant and does not depend on any other libraries. AstroLib is Open Source under the GPL license.

The library is not actively developed any more, in fact it never was. The last changes I made were adding the Demo class in 2004 and fixing a bug using time zones in 2005 (thanks to Rastislav Szabo for reporting it). Today I reformatted the code and fixed some warnings. That's it folks.

FAQ
Q: Are there any chart drawing functions as in Zodiac Watch? A: Unfortunately the drawing routines are tightly coupled to the applet code and the browser user interface. I was able to extract the calculation routines and put them into a separate package, but this is not possible for the drawing code itself.

Q: The co-ordinates of the planets are within 1 minute difference from other available chart generation programs. But for the co-ordinates of the moon there is a 10 to 20 degree difference and the positions of the houses are absurd. What is wrong? A: Using a wrong time-zone results in a wrong local time. This affects the moon and the houses, but not the slower moving objects. Also make sure to enter negative longitude in the east zone and negative latitude below equator.

Q: Is there any code for computing the nodes of the moon? A: No, AstroLib can't do that.

Q: What kind of zodiac is calculated: Actual constellation divisions or the classic 30 degree each division? A: Traditional 30 degree per sign.

My First Astrology Computer

Update 24 April 2009

Jastrolog - Astrolog Port

Christian just convinced me to start a new project on SourceForge: Jastrolog, an Astrolog Port. Astrolog is a free astrology software program since 1991. Astrolog can create horoscopes, natal charts, and calculate current planetary positions in sidereal, traditional, and heliocentric formats. We believe it to be a bit of a cultural legacy. It deserves to live into the 21st century. As long as it is in C/C++ it has no chance. We might use AstroLib as a starting in porting the whole Astrolog and/or Astrolog32 to Java.

3 September 2006

What is in Java 5

Tiger, Tiger Floating LightDid you ever wonder when a particular class was introduced into the JDK? Or did you ever want to get a quick overview of all new classes included in a new release of Java? That is why I maintain my personal list of all public classes together with the JRE's version they were introduced. I started the list in 2002 and have been updating it whenever a new version of Java came out. Now, almost two years after the release of Tiger, it is high time to update my list with Java 5.

Source of Truth
There is only one true source of the contents of a JRE, and that is rt.jar. Getting a plain list of all *.class files inside the archive is not enough because some classes are package accessible and cannot be used in Java code directly. I use a series of shell scripts that generate a text file with all Java classes of rt.jar. After unpacking rt.jar a script iterates all class names and calls javap -public %class% >> access.log for each of them. Stripping all public content from access.log reveals the package accessible classes, e.g.
java.awt.MutableBoolean
java.beans.ReflectionUtils
java.util.JumboEnumSet
java.util.XMLUtils
...
The list of new classes is the list of all classes found in rt.jar minus the package accessible classes, minus all classes of all earlier versions of Java.

Java 5
Tiger adds 172 new public types in the java. name-space. The new classes are
java.awt.datatransfer.FlavorEvent
java.awt.datatransfer.FlavorListener
java.awt.MouseInfo
java.awt.peer.KeyboardFocusManagerPeer
java.awt.peer.MouseInfoPeer
java.awt.PointerInfo
java.beans.IndexedPropertyChangeEvent
java.io.Closeable
java.io.Flushable
java.lang.Appendable
java.lang.Deprecated
java.lang.Enum
java.lang.EnumConstantNotPresentException
java.lang.Iterable
java.lang.Override
java.lang.ProcessBuilder
java.lang.Readable
java.lang.reflect.AnnotatedElement
java.lang.reflect.GenericArrayType
java.lang.reflect.GenericDeclaration
java.lang.reflect.GenericSignatureFormatError
java.lang.reflect.MalformedParameterizedTypeException
java.lang.reflect.ParameterizedType
java.lang.reflect.Type
java.lang.reflect.TypeVariable
java.lang.reflect.WildcardType
java.lang.StringBuilder
java.lang.SuppressWarnings
java.lang.TypeNotPresentException
java.math.MathContext
java.math.RoundingMode
java.net.CacheRequest
java.net.CacheResponse
java.net.CookieHandler
java.net.HttpRetryException
java.net.Proxy
java.net.ProxySelector
java.net.ResponseCache
java.net.SecureCacheResponse
java.rmi.server.RemoteObjectInvocationHandler
java.security.AuthProvider
java.security.CodeSigner
java.security.interfaces.ECKey
java.security.interfaces.ECPrivateKey
java.security.interfaces.ECPublicKey
java.security.KeyRep
java.security.spec.ECField
java.security.spec.ECFieldF2m
java.security.spec.ECFieldFp
java.security.spec.ECGenParameterSpec
java.security.spec.ECParameterSpec
java.security.spec.ECPoint
java.security.spec.ECPrivateKeySpec
java.security.spec.ECPublicKeySpec
java.security.spec.EllipticCurve
java.security.spec.MGF1ParameterSpec
java.security.Timestamp
java.security.UnrecoverableEntryException
java.util.AbstractQueue
java.util.DuplicateFormatFlagsException
java.util.EnumMap
java.util.EnumSet
java.util.FormatFlagsConversionMismatchException
java.util.Formattable
java.util.FormattableFlags
java.util.Formatter
java.util.FormatterClosedException
java.util.IllegalFormatCodePointException
java.util.IllegalFormatConversionException
java.util.IllegalFormatException
java.util.IllegalFormatFlagsException
java.util.IllegalFormatPrecisionException
java.util.IllegalFormatWidthException
java.util.InputMismatchException
java.util.InvalidPropertiesFormatException
java.util.jar.Pack200
java.util.logging.LoggingMXBean
java.util.MissingFormatArgumentException
java.util.MissingFormatWidthException
java.util.PriorityQueue
java.util.Queue
java.util.regex.MatchResult
java.util.Scanner
java.util.UnknownFormatConversionException
java.util.UnknownFormatFlagsException
java.util.UUID
as well as 86 classes of the four completely new packages
java.lang.annotation
java.lang.instrument
java.lang.management
java.util.concurrent
Further there are around 300 new types in javax. packages. The JMX Management Extension 1.2, javax.management, adds more than 170 classes and is a major addition. Further there are several smaller new packages, mainly
javax.jnlp
javax.sql.rowset
javax.xml.datatype
javax.xml.namespace
javax.xml.validation
javax.xml.xpath
i.e. JNLP-Client 1.0 for JavaWebStart, SQL RowSet implementations and several XML functions from JAXP 1.3 like schema mapping, name-spaces, schema validation and XPath.

Full Class List
Here is the complete list of all classes from Java 1.0 to 1.5, to be more precise from Sun's JDK 1.02 and 1.1.8_09, J2SE 1.2.2_13, 1.3.1_08 and 1.4.2_03, and the new Java5 1.5.0_07. This list gets more and more valuable because it becomes more and more difficult to get older JDKs.

30 August 2006

Java Bookshelf

On this page you will find what I think are the most valuable resources for Java developers available. First a list of books every Java software developer should know (no excuses). It's amazing how old some of these are and still there are people around not knowing them. Next are my favourite newsletters (electronic journals), which I read regularly. Last I give you a (probably subjective) list of some of the best development tools available, which are all free.

Books
Books on the Java Language
Newsletters and Sites
Tools