![]() |
![]() |
com.ibm.icu_4.4.2.v2011082316:34:27.358 INFO jd.cli.Main - Decompiling com.ibm.icu_4.4.2.v20110823.jar package com.ibm.icu.impl; public class Assert { public static void fail(Exception e) { fail(e.toString()); } public static void fail(String msg) { throw new IllegalStateException("failure '" + msg + "'"); } public static void assrt(boolean val) { if (!val) { throw new IllegalStateException("assert failed"); } } public static void assrt(String msg, boolean val) { if (!val) { throw new IllegalStateException("assert '" + msg + "' failed"); } } } /* Location: * Qualified Name: com.ibm.icu.impl.Assert * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; import com.ibm.icu.text.UnicodeSet.SpanCondition; public final class BMPSet { public static int U16_SURROGATE_OFFSET = 56613888; private boolean[] latin1Contains; private int[] table7FF; private int[] bmpBlockBits; private int[] list4kStarts; private final int[] list; private final int listLength; public BMPSet(int[] parentList, int parentListLength) { list = parentList; listLength = parentListLength; latin1Contains = new boolean['?']; table7FF = new int[64]; bmpBlockBits = new int[64]; list4kStarts = new int[18]; list4kStarts[0] = findCodePoint(2048, 0, listLength - 1); for (int i = 1; i <= 16; i++) { list4kStarts[i] = findCodePoint(i << 12, list4kStarts[(i - 1)], listLength - 1); } list4kStarts[17] = (listLength - 1); initBits(); } public BMPSet(BMPSet otherBMPSet, int[] newParentList, int newParentListLength) { list = newParentList; listLength = newParentListLength; latin1Contains = ((boolean[])latin1Contains.clone()); table7FF = ((int[])table7FF.clone()); bmpBlockBits = ((int[])bmpBlockBits.clone()); list4kStarts = ((int[])list4kStarts.clone()); } public boolean contains(int c) { if (c <= 255) { return latin1Contains[c]; } if (c <= 2047) { return (table7FF[(c & 0x3F)] & 1 << (c >> 6)) != 0; } if ((c < 55296) || ((c >= 57344) && (c <= 65535))) { int lead = c >> 12; int twoBits = bmpBlockBits[(c >> 6 & 0x3F)] >> lead & 0x10001; if (twoBits <= 1) { return twoBits != 0; } return containsSlow(c, list4kStarts[lead], list4kStarts[(lead + 1)]); } if (c <= 1114111) { return containsSlow(c, list4kStarts[13], list4kStarts[17]); } return false; } public final int span(CharSequence s, int start, int end, UnicodeSet.SpanCondition spanCondition) { int i = start; int limit = Math.min(s.length(), end); if (UnicodeSet.SpanCondition.NOT_CONTAINED != spanCondition) { while (i < limit) { c = s.charAt(i); if (c <= '�') { if (latin1Contains[c] == 0) { break; } } else if (c <= '?') { if ((table7FF[(c & 0x3F)] & 1 << (c >> '\006')) == 0) { break; } } else if ((c < 55296) || (c >= 56320) || (i + 1 == limit) || ((c2 = s.charAt(i + 1)) < 56320) || (c2 >= 57344)) { lead = c >> '\f'; twoBits = bmpBlockBits[(c >> '\006' & 0x3F)] >> lead & 0x10001; if (twoBits <= 1) { if (twoBits == 0) { break; } } else if (!containsSlow(c, list4kStarts[lead], list4kStarts[(lead + 1)])) { break; } } else { supplementary = UCharacterProperty.getRawSupplementary(c, c2); if (!containsSlow(supplementary, list4kStarts[16], list4kStarts[17])) { break; } i++; } i++; } } else { while (i < limit) { char c; char c2; int lead; int twoBits; char c2; int supplementary; char c = s.charAt(i); if (c <= '�') { if (latin1Contains[c] != 0) { break; } } else if (c <= '?') { if ((table7FF[(c & 0x3F)] & 1 << (c >> '\006')) != 0) { break; } } else { char c2; if ((c < 55296) || (c >= 56320) || (i + 1 == limit) || ((c2 = s.charAt(i + 1)) < 56320) || (c2 >= 57344)) { int lead = c >> '\f'; int twoBits = bmpBlockBits[(c >> '\006' & 0x3F)] >> lead & 0x10001; if (twoBits <= 1) { if (twoBits != 0) { break; } } else if (containsSlow(c, list4kStarts[lead], list4kStarts[(lead + 1)])) { break; } } else { char c2; int supplementary = UCharacterProperty.getRawSupplementary(c, c2); if (containsSlow(supplementary, list4kStarts[16], list4kStarts[17])) { break; } i++; } } i++; } } return i - start; } public final int spanBack(CharSequence s, int limit, UnicodeSet.SpanCondition spanCondition) { limit = Math.min(s.length(), limit); if (UnicodeSet.SpanCondition.NOT_CONTAINED != spanCondition) { do { char c = s.charAt(--limit); if (c <= '�') { if (latin1Contains[c] == 0) { break; } } else if (c <= '?') { if ((table7FF[(c & 0x3F)] & 1 << (c >> '\006')) == 0) { break; } } else { char c2; if ((c < 55296) || (c < 56320) || (limit == 0) || ((c2 = s.charAt(limit - 1)) < 55296) || (c2 >= 56320)) { int lead = c >> '\f'; int twoBits = bmpBlockBits[(c >> '\006' & 0x3F)] >> lead & 0x10001; if (twoBits <= 1) { if (twoBits == 0) { break; } } else if (!containsSlow(c, list4kStarts[lead], list4kStarts[(lead + 1)])) { break; } } else { char c2; int supplementary = UCharacterProperty.getRawSupplementary(c2, c); if (!containsSlow(supplementary, list4kStarts[16], list4kStarts[17])) { break; } limit--; } } } while (limit != 0); return 0; } do { char c = s.charAt(--limit); if (c <= '�') { if (latin1Contains[c] != 0) { break; } } else if (c <= '?') { if ((table7FF[(c & 0x3F)] & 1 << (c >> '\006')) != 0) { break; } } else { char c2; if ((c < 55296) || (c < 56320) || (limit == 0) || ((c2 = s.charAt(limit - 1)) < 55296) || (c2 >= 56320)) { int lead = c >> '\f'; int twoBits = bmpBlockBits[(c >> '\006' & 0x3F)] >> lead & 0x10001; if (twoBits <= 1) { if (twoBits != 0) { break; } } else if (containsSlow(c, list4kStarts[lead], list4kStarts[(lead + 1)])) { break; } } else { char c2; int supplementary = UCharacterProperty.getRawSupplementary(c2, c); if (containsSlow(supplementary, list4kStarts[16], list4kStarts[17])) { break; } limit--; } } } while (limit != 0); return 0; return limit + 1; } private static void set32x64Bits(int[] table, int start, int limit) { assert (64 == table.length); int lead = start >> 6; int trail = start & 0x3F; int bits = 1 << lead; if (start + 1 == limit) { table[trail] |= bits; return; } int limitLead = limit >> 6; int limitTrail = limit & 0x3F; if (lead == limitLead) { while (trail < limitTrail) { table[(trail++)] |= bits; } } else { if (trail > 0) { do { table[(trail++)] |= bits; } while (trail < 64); lead++; } if (lead < limitLead) { bits = (1 << lead) - 1 ^ 0xFFFFFFFF; if (limitLead < 32) { bits &= (1 << limitLead) - 1; } for (trail = 0; trail < 64; trail++) { table[trail] |= bits; } } bits = 1 << limitLead; for (trail = 0; trail < limitTrail; trail++) { table[trail] |= bits; } } } private void initBits() { int listIndex = 0; int start; int limit; do { start = list[(listIndex++)]; int limit; if (listIndex < listLength) { limit = list[(listIndex++)]; } else { limit = 1114112; } if (start >= 256) { break; } do { latin1Contains[(start++)] = true; } while ((start < limit) && (start < 256)); } while (limit <= 256); while (start < 2048) { set32x64Bits(table7FF, start, limit <= 2048 ? limit : 2048); if (limit > 2048) { start = 2048; break; } start = list[(listIndex++)]; if (listIndex < listLength) { limit = list[(listIndex++)]; } else { limit = 1114112; } } int minStart = 2048; while (start < 65536) { if (limit > 65536) { limit = 65536; } if (start < minStart) { start = minStart; } if (start < limit) { if ((start & 0x3F) != 0) { start >>= 6; bmpBlockBits[(start & 0x3F)] |= 65537 << (start >> 6); start = start + 1 << 6; minStart = start; } if (start < limit) { if (start < (limit & 0xFFFFFFC0)) { set32x64Bits(bmpBlockBits, start >> 6, limit >> 6); } if ((limit & 0x3F) != 0) { limit >>= 6; bmpBlockBits[(limit & 0x3F)] |= 65537 << (limit >> 6); limit = limit + 1 << 6; minStart = limit; } } } if (limit == 65536) { break; } start = list[(listIndex++)]; if (listIndex < listLength) { limit = list[(listIndex++)]; } else { limit = 1114112; } } } private int findCodePoint(int c, int lo, int hi) { if (c < list[lo]) { return lo; } if ((lo >= hi) || (c >= list[(hi - 1)])) { return hi; } for (;;) { int i = lo + hi >> 1; if (i == lo) { break; } if (c < list[i]) { hi = i; } else { lo = i; } } return hi; } private final boolean containsSlow(int c, int lo, int hi) { return (findCodePoint(c, lo, hi) & 0x1) != 0; } } /* Location: * Qualified Name: com.ibm.icu.impl.BMPSet * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; import com.ibm.icu.text.UCharacterIterator; public class BOCU { private static final int SLOPE_MIN_ = 3; private static final int SLOPE_MAX_ = 255; private static final int SLOPE_MIDDLE_ = 129; private static final int SLOPE_TAIL_COUNT_ = 253; private static final int SLOPE_SINGLE_ = 80; private static final int SLOPE_LEAD_2_ = 42; private static final int SLOPE_LEAD_3_ = 3; private static final int SLOPE_REACH_POS_1_ = 80; private static final int SLOPE_REACH_NEG_1_ = -80; private static final int SLOPE_REACH_POS_2_ = 10667; private static final int SLOPE_REACH_NEG_2_ = -10668; private static final int SLOPE_REACH_POS_3_ = 192785; private static final int SLOPE_REACH_NEG_3_ = -192786; private static final int SLOPE_START_POS_2_ = 210; private static final int SLOPE_START_POS_3_ = 252; private static final int SLOPE_START_NEG_2_ = 49; private static final int SLOPE_START_NEG_3_ = 7; public static int compress(String source, byte[] buffer, int offset) { int prev = 0; UCharacterIterator iterator = UCharacterIterator.getInstance(source); int codepoint = iterator.nextCodePoint(); while (codepoint != -1) { if ((prev < 19968) || (prev >= 40960)) { prev = (prev & 0xFFFFFF80) - -80; } else { prev = 30292; } offset = writeDiff(codepoint - prev, buffer, offset); prev = codepoint; codepoint = iterator.nextCodePoint(); } return offset; } public static int getCompressionLength(String source) { int prev = 0; int result = 0; UCharacterIterator iterator = UCharacterIterator.getInstance(source); int codepoint = iterator.nextCodePoint(); while (codepoint != -1) { if ((prev < 19968) || (prev >= 40960)) { prev = (prev & 0xFFFFFF80) - -80; } else { prev = 30292; } codepoint = iterator.nextCodePoint(); result += lengthOfDiff(codepoint - prev); prev = codepoint; } return result; } private static final long getNegDivMod(int number, int factor) { int modulo = number % factor; long result = number / factor; if (modulo < 0) { result -= 1L; modulo += factor; } return result << 32 | modulo; } private static final int writeDiff(int diff, byte[] buffer, int offset) { if (diff >= -80) { if (diff <= 80) { buffer[(offset++)] = ((byte)(129 + diff)); } else if (diff <= 10667) { buffer[(offset++)] = ((byte)(210 + diff / 253)); buffer[(offset++)] = ((byte)(3 + diff % 253)); } else if (diff <= 192785) { buffer[(offset + 2)] = ((byte)(3 + diff % 253)); diff /= 253; buffer[(offset + 1)] = ((byte)(3 + diff % 253)); buffer[offset] = ((byte)(252 + diff / 253)); offset += 3; } else { buffer[(offset + 3)] = ((byte)(3 + diff % 253)); diff /= 253; buffer[offset] = ((byte)(3 + diff % 253)); diff /= 253; buffer[(offset + 1)] = ((byte)(3 + diff % 253)); buffer[offset] = -1; offset += 4; } } else { long division = getNegDivMod(diff, 253); int modulo = (int)division; if (diff >= 54868) { diff = (int)(division >> 32); buffer[(offset++)] = ((byte)(49 + diff)); buffer[(offset++)] = ((byte)(3 + modulo)); } else if (diff >= -192786) { buffer[(offset + 2)] = ((byte)(3 + modulo)); diff = (int)(division >> 32); division = getNegDivMod(diff, 253); modulo = (int)division; diff = (int)(division >> 32); buffer[(offset + 1)] = ((byte)(3 + modulo)); buffer[offset] = ((byte)(7 + diff)); offset += 3; } else { buffer[(offset + 3)] = ((byte)(3 + modulo)); diff = (int)(division >> 32); division = getNegDivMod(diff, 253); modulo = (int)division; diff = (int)(division >> 32); buffer[(offset + 2)] = ((byte)(3 + modulo)); division = getNegDivMod(diff, 253); modulo = (int)division; buffer[(offset + 1)] = ((byte)(3 + modulo)); buffer[offset] = 3; offset += 4; } } return offset; } private static final int lengthOfDiff(int diff) { if (diff >= -80) { if (diff <= 80) { return 1; } if (diff <= 10667) { return 2; } if (diff <= 192785) { return 3; } return 4; } if (diff >= 54868) { return 2; } if (diff >= -192786) { return 3; } return 4; } } /* Location: * Qualified Name: com.ibm.icu.impl.BOCU * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; public abstract class CacheBase<K, V, D> { public abstract V getInstance(K paramK, D paramD); protected abstract V createInstance(K paramK, D paramD); } /* Location: * Qualified Name: com.ibm.icu.impl.CacheBase * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; class CalendarAstronomer$1 implements CalendarAstronomer.AngleFunc { CalendarAstronomer$1(CalendarAstronomer paramCalendarAstronomer) {} public double eval() { return this$0.getSunLongitude(); } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; class CalendarAstronomer$2 implements CalendarAstronomer.CoordFunc { CalendarAstronomer$2(CalendarAstronomer paramCalendarAstronomer) {} public CalendarAstronomer.Equatorial eval() { return this$0.getSunPosition(); } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.2 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; class CalendarAstronomer$3 implements CalendarAstronomer.AngleFunc { CalendarAstronomer$3(CalendarAstronomer paramCalendarAstronomer) {} public double eval() { return this$0.getMoonAge(); } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.3 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; class CalendarAstronomer$4 implements CalendarAstronomer.CoordFunc { CalendarAstronomer$4(CalendarAstronomer paramCalendarAstronomer) {} public CalendarAstronomer.Equatorial eval() { return this$0.getMoonPosition(); } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.4 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; abstract interface CalendarAstronomer$AngleFunc { public abstract double eval(); } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.AngleFunc * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; abstract interface CalendarAstronomer$CoordFunc { public abstract CalendarAstronomer.Equatorial eval(); } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.CoordFunc * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; public final class CalendarAstronomer$Ecliptic { public final double latitude; public final double longitude; public CalendarAstronomer$Ecliptic(double lat, double lon) { latitude = lat; longitude = lon; } public String toString() { return Double.toString(longitude * 57.29577951308232D) + "," + latitude * 57.29577951308232D; } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.Ecliptic * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; public final class CalendarAstronomer$Equatorial { public final double ascension; public final double declination; public CalendarAstronomer$Equatorial(double asc, double dec) { ascension = asc; declination = dec; } public String toString() { return Double.toString(ascension * 57.29577951308232D) + "," + declination * 57.29577951308232D; } public String toHmsString() { return CalendarAstronomer.access$0(ascension) + "," + CalendarAstronomer.access$1(declination); } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.Equatorial * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; public final class CalendarAstronomer$Horizon { public final double altitude; public final double azimuth; public CalendarAstronomer$Horizon(double alt, double azim) { altitude = alt; azimuth = azim; } public String toString() { return Double.toString(altitude * 57.29577951308232D) + "," + azimuth * 57.29577951308232D; } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.Horizon * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; class CalendarAstronomer$MoonAge { double value; CalendarAstronomer$MoonAge(double val) { value = val; } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.MoonAge * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; class CalendarAstronomer$SolarLongitude { double value; CalendarAstronomer$SolarLongitude(double val) { value = val; } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer.SolarLongitude * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; import java.util.Date; import java.util.TimeZone; public class CalendarAstronomer { public static final double SIDEREAL_DAY = 23.93446960027D; public static final double SOLAR_DAY = 24.065709816D; public static final double SYNODIC_MONTH = 29.530588853D; public static final double SIDEREAL_MONTH = 27.32166D; public static final double TROPICAL_YEAR = 365.242191D; public static final double SIDEREAL_YEAR = 365.25636D; public static final int SECOND_MS = 1000; public static final int MINUTE_MS = 60000; public static final int HOUR_MS = 3600000; public static final long DAY_MS = 86400000L; public static final long JULIAN_EPOCH_MS = -210866760000000L; static final long EPOCH_2000_MS = 946598400000L; private static final double PI = 3.141592653589793D; private static final double PI2 = 6.283185307179586D; private static final double RAD_HOUR = 3.819718634205488D; private static final double DEG_RAD = 0.017453292519943295D; private static final double RAD_DEG = 57.29577951308232D; static final double JD_EPOCH = 2447891.5D; static final double SUN_ETA_G = 4.87650757829735D; static final double SUN_OMEGA_G = 4.935239984568769D; static final double SUN_E = 0.016713D; public CalendarAstronomer() { this(System.currentTimeMillis()); } public CalendarAstronomer(Date d) { this(d.getTime()); } public CalendarAstronomer(long aTime) { time = aTime; } public CalendarAstronomer(double longitude, double latitude) { this(); } public void setTime(long aTime) { time = aTime; clearCache(); } public void setDate(Date date) { setTime(date.getTime()); } public void setJulianDay(double jdn) { time = ((jdn * 8.64E7D) + -210866760000000L); clearCache(); julianDay = jdn; } public long getTime() { return time; } public Date getDate() { return new Date(time); } public double getJulianDay() { if (julianDay == Double.MIN_VALUE) { julianDay = ((time - -210866760000000L) / 8.64E7D); } return julianDay; } public double getJulianCentury() { if (julianCentury == Double.MIN_VALUE) { julianCentury = ((getJulianDay() - 2415020.0D) / 36525.0D); } return julianCentury; } public double getGreenwichSidereal() { if (siderealTime == Double.MIN_VALUE) { double UT = normalize(time / 3600000.0D, 24.0D); siderealTime = normalize(getSiderealOffset() + UT * 1.002737909D, 24.0D); } return siderealTime; } private double getSiderealOffset() { if (siderealT0 == Double.MIN_VALUE) { double JD = Math.floor(getJulianDay() - 0.5D) + 0.5D; double S = JD - 2451545.0D; double T = S / 36525.0D; siderealT0 = normalize(6.697374558D + 2400.051336D * T + 2.5862E-5D * T * T, 24.0D); } return siderealT0; } public double getLocalSidereal() { return normalize(getGreenwichSidereal() + fGmtOffset / 3600000.0D, 24.0D); } private long lstToUT(double lst) { double lt = normalize((lst - getSiderealOffset()) * 0.9972695663D, 24.0D); long base = 86400000L * ((time + fGmtOffset) / 86400000L) - fGmtOffset; return base + (lt * 3600000.0D); } public final Equatorial eclipticToEquatorial(Ecliptic ecliptic) { return eclipticToEquatorial(longitude, latitude); } public final Equatorial eclipticToEquatorial(double eclipLong, double eclipLat) { double obliq = eclipticObliquity(); double sinE = Math.sin(obliq); double cosE = Math.cos(obliq); double sinL = Math.sin(eclipLong); double cosL = Math.cos(eclipLong); double sinB = Math.sin(eclipLat); double cosB = Math.cos(eclipLat); double tanB = Math.tan(eclipLat); return new Equatorial(Math.atan2(sinL * cosE - tanB * sinE, cosL), Math.asin(sinB * cosE + cosB * sinE * sinL)); } public final Equatorial eclipticToEquatorial(double eclipLong) { return eclipticToEquatorial(eclipLong, 0.0D); } public Horizon eclipticToHorizon(double eclipLong) { Equatorial equatorial = eclipticToEquatorial(eclipLong); double H = getLocalSidereal() * 3.141592653589793D / 12.0D - ascension; double sinH = Math.sin(H); double cosH = Math.cos(H); double sinD = Math.sin(declination); double cosD = Math.cos(declination); double sinL = Math.sin(fLatitude); double cosL = Math.cos(fLatitude); double altitude = Math.asin(sinD * sinL + cosD * cosL * cosH); double azimuth = Math.atan2(-cosD * cosL * sinH, sinD - sinL * Math.sin(altitude)); return new Horizon(azimuth, altitude); } public double getSunLongitude() { if (sunLongitude == Double.MIN_VALUE) { double[] result = getSunLongitude(getJulianDay()); sunLongitude = result[0]; meanAnomalySun = result[1]; } return sunLongitude; } double[] getSunLongitude(double julian) { double day = julian - 2447891.5D; double epochAngle = norm2PI(0.017202791632524146D * day); double meanAnomaly = norm2PI(epochAngle + 4.87650757829735D - 4.935239984568769D); return new double[] { norm2PI(trueAnomaly(meanAnomaly, 0.016713D) + 4.935239984568769D), meanAnomaly }; } public Equatorial getSunPosition() { return eclipticToEquatorial(getSunLongitude(), 0.0D); } private static class SolarLongitude { double value; SolarLongitude(double val) { value = val; } } public static final SolarLongitude VERNAL_EQUINOX = new SolarLongitude(0.0D); public static final SolarLongitude SUMMER_SOLSTICE = new SolarLongitude(1.5707963267948966D); public static final SolarLongitude AUTUMN_EQUINOX = new SolarLongitude(3.141592653589793D); public static final SolarLongitude WINTER_SOLSTICE = new SolarLongitude(4.71238898038469D); static final double moonL0 = 5.556284436750021D; static final double moonP0 = 0.6342598060246725D; static final double moonN0 = 5.559050068029439D; static final double moonI = 0.08980357792017056D; static final double moonE = 0.0549D; static final double moonA = 384401.0D; static final double moonT0 = 0.009042550854582622D; static final double moonPi = 0.016592845198710092D; public long getSunTime(double desired, boolean next) { timeOfAngle(new AngleFunc() { public double eval() { return getSunLongitude(); } }, desired, 365.242191D, 60000L, next); } public long getSunTime(SolarLongitude desired, boolean next) { return getSunTime(value, next); } public long getSunRiseSet(boolean rise) { long t0 = time; long noon = (time + fGmtOffset) / 86400000L * 86400000L - fGmtOffset + 43200000L; setTime(noon + (rise ? -6 : 6) * 3600000); long t = riseOrSet(new CoordFunc() { public CalendarAstronomer.Equatorial eval() { return getSunPosition(); } }, rise, 0.009302604913129777D, 0.009890199094634533D, 5000L); setTime(t0); return t; } public Equatorial getMoonPosition() { if (moonPosition == null) { double sunLong = getSunLongitude(); double day = getJulianDay() - 2447891.5D; double meanLongitude = norm2PI(0.22997150421858628D * day + 5.556284436750021D); double meanAnomalyMoon = norm2PI(meanLongitude - 0.001944368345221015D * day - 0.6342598060246725D); double evection = 0.022233749341155764D * Math.sin(2.0D * (meanLongitude - sunLong) - meanAnomalyMoon); double annual = 0.003242821750205464D * Math.sin(meanAnomalySun); double a3 = 0.00645771823237902D * Math.sin(meanAnomalySun); meanAnomalyMoon += evection - annual - a3; double center = 0.10975677534091541D * Math.sin(meanAnomalyMoon); double a4 = 0.0037350045992678655D * Math.sin(2.0D * meanAnomalyMoon); moonLongitude = (meanLongitude + evection + center - annual + a4); double variation = 0.011489502465878671D * Math.sin(2.0D * (moonLongitude - sunLong)); moonLongitude += variation; double nodeLongitude = norm2PI(5.559050068029439D - 9.242199067718253E-4D * day); nodeLongitude -= 0.0027925268031909274D * Math.sin(meanAnomalySun); double y = Math.sin(moonLongitude - nodeLongitude); double x = Math.cos(moonLongitude - nodeLongitude); moonEclipLong = (Math.atan2(y * Math.cos(0.08980357792017056D), x) + nodeLongitude); double moonEclipLat = Math.asin(y * Math.sin(0.08980357792017056D)); moonPosition = eclipticToEquatorial(moonEclipLong, moonEclipLat); } return moonPosition; } public double getMoonAge() { getMoonPosition(); return norm2PI(moonEclipLong - sunLongitude); } public double getMoonPhase() { return 0.5D * (1.0D - Math.cos(getMoonAge())); } private static class MoonAge { double value; MoonAge(double val) { value = val; } } public static final MoonAge NEW_MOON = new MoonAge(0.0D); public static final MoonAge FIRST_QUARTER = new MoonAge(1.5707963267948966D); public static final MoonAge FULL_MOON = new MoonAge(3.141592653589793D); public static final MoonAge LAST_QUARTER = new MoonAge(4.71238898038469D); private long time; public long getMoonTime(double desired, boolean next) { timeOfAngle(new AngleFunc() { public double eval() { return getMoonAge(); } }, desired, 29.530588853D, 60000L, next); } public long getMoonTime(MoonAge desired, boolean next) { return getMoonTime(value, next); } public long getMoonRiseSet(boolean rise) { riseOrSet(new CoordFunc() { public CalendarAstronomer.Equatorial eval() { return getMoonPosition(); } }, rise, 0.009302604913129777D, 0.009890199094634533D, 60000L); } private long timeOfAngle(AngleFunc func, double desired, double periodDays, long epsilon, boolean next) { double lastAngle = func.eval(); double deltaAngle = norm2PI(desired - lastAngle); double deltaT = (deltaAngle + (next ? 0.0D : -6.283185307179586D)) * (periodDays * 8.64E7D) / 6.283185307179586D; double lastDeltaT = deltaT; long startTime = time; setTime(time + deltaT); do { double angle = func.eval(); double factor = Math.abs(deltaT / normPI(angle - lastAngle)); deltaT = normPI(desired - angle) * factor; if (Math.abs(deltaT) > Math.abs(lastDeltaT)) { long delta = (periodDays * 8.64E7D / 8.0D); setTime(startTime + (next ? delta : -delta)); return timeOfAngle(func, desired, periodDays, epsilon, next); } lastDeltaT = deltaT; lastAngle = angle; setTime(time + deltaT); } while (Math.abs(deltaT) > epsilon); return time; } private long riseOrSet(CoordFunc func, boolean rise, double diameter, double refraction, long epsilon) { Equatorial pos = null; double tanL = Math.tan(fLatitude); long deltaT = Long.MAX_VALUE; int count = 0; do { pos = func.eval(); double angle = Math.acos(-tanL * Math.tan(declination)); double lst = ((rise ? 6.283185307179586D - angle : angle) + ascension) * 24.0D / 6.283185307179586D; long newTime = lstToUT(lst); deltaT = newTime - time; setTime(newTime); count++; } while ((count < 5) && (Math.abs(deltaT) > epsilon)); double cosD = Math.cos(declination); double psi = Math.acos(Math.sin(fLatitude) / cosD); double x = diameter / 2.0D + refraction; double y = Math.asin(Math.sin(x) / Math.sin(psi)); long delta = (240.0D * y * 57.29577951308232D / cosD * 1000.0D); return time + (rise ? -delta : delta); } private static final double normalize(double value, double range) { return value - range * Math.floor(value / range); } private static final double norm2PI(double angle) { return normalize(angle, 6.283185307179586D); } private static final double normPI(double angle) { return normalize(angle + 3.141592653589793D, 6.283185307179586D) - 3.141592653589793D; } private double trueAnomaly(double meanAnomaly, double eccentricity) { double E = meanAnomaly; double delta; do { delta = E - eccentricity * Math.sin(E) - meanAnomaly; E -= delta / (1.0D - eccentricity * Math.cos(E)); } while (Math.abs(delta) > 1.0E-5D); return 2.0D * Math.atan(Math.tan(E / 2.0D) * Math.sqrt((1.0D + eccentricity) / ( 1.0D - eccentricity))); } private double eclipticObliquity() { if (eclipObliquity == Double.MIN_VALUE) { double T = (getJulianDay() - 2451545.0D) / 36525.0D; eclipObliquity = (23.439292D - 0.013004166666666666D * T - 1.6666666666666665E-7D * T * T + 5.027777777777778E-7D * T * T * T); eclipObliquity *= 0.017453292519943295D; } return eclipObliquity; } private double fLongitude = 0.0D; private double fLatitude = 0.0D; private long fGmtOffset = 0L; private static final double INVALID = Double.MIN_VALUE; private transient double julianDay = Double.MIN_VALUE; private transient double julianCentury = Double.MIN_VALUE; private transient double sunLongitude = Double.MIN_VALUE; private transient double meanAnomalySun = Double.MIN_VALUE; private transient double moonLongitude = Double.MIN_VALUE; private transient double moonEclipLong = Double.MIN_VALUE; private transient double eclipObliquity = Double.MIN_VALUE; private transient double siderealT0 = Double.MIN_VALUE; private transient double siderealTime = Double.MIN_VALUE; private transient Equatorial moonPosition = null; private void clearCache() { julianDay = Double.MIN_VALUE; julianCentury = Double.MIN_VALUE; sunLongitude = Double.MIN_VALUE; meanAnomalySun = Double.MIN_VALUE; moonLongitude = Double.MIN_VALUE; moonEclipLong = Double.MIN_VALUE; eclipObliquity = Double.MIN_VALUE; siderealTime = Double.MIN_VALUE; siderealT0 = Double.MIN_VALUE; moonPosition = null; } public String local(long localMillis) { return new Date(localMillis - TimeZone.getDefault().getRawOffset()).toString(); } public static final class Ecliptic { public final double latitude; public final double longitude; public Ecliptic(double lat, double lon) { latitude = lat; longitude = lon; } public String toString() { return Double.toString(longitude * 57.29577951308232D) + "," + latitude * 57.29577951308232D; } } public static final class Equatorial { public final double ascension; public final double declination; public Equatorial(double asc, double dec) { ascension = asc; declination = dec; } public String toString() { return Double.toString(ascension * 57.29577951308232D) + "," + declination * 57.29577951308232D; } public String toHmsString() { return CalendarAstronomer.radToHms(ascension) + "," + CalendarAstronomer.radToDms(declination); } } public static final class Horizon { public final double altitude; public final double azimuth; public Horizon(double alt, double azim) { altitude = alt; azimuth = azim; } public String toString() { return Double.toString(altitude * 57.29577951308232D) + "," + azimuth * 57.29577951308232D; } } private static String radToHms(double angle) { int hrs = (int)(angle * 3.819718634205488D); int min = (int)((angle * 3.819718634205488D - hrs) * 60.0D); int sec = (int)((angle * 3.819718634205488D - hrs - min / 60.0D) * 3600.0D); return Integer.toString(hrs) + "h" + min + "m" + sec + "s"; } private static String radToDms(double angle) { int deg = (int)(angle * 57.29577951308232D); int min = (int)((angle * 57.29577951308232D - deg) * 60.0D); int sec = (int)((angle * 57.29577951308232D - deg - min / 60.0D) * 3600.0D); return Integer.toString(deg) + "�" + min + "'" + sec + "\""; } private static abstract interface AngleFunc { public abstract double eval(); } private static abstract interface CoordFunc { public abstract CalendarAstronomer.Equatorial eval(); } } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarAstronomer * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package com.ibm.icu.impl; public class CalendarCache { public CalendarCache() { makeArrays(arraySize); } private void makeArrays(int newSize) { keys = new long[newSize]; values = new long[newSize]; for (int i = 0; i < newSize; i++) { values[i] = EMPTY; } arraySize = newSize; threshold = ((int)(arraySize * 0.75D)); size = 0; } public synchronized long get(long key) { return values[findIndex(key)]; } public synchronized void put(long key, long value) { if (size >= threshold) { rehash(); } int index = findIndex(key); keys[index] = key; values[index] = value; size += 1; } private final int findIndex(long key) { int index = hash(key); int delta = 0; while ((values[index] != EMPTY) && (keys[index] != key)) { if (delta == 0) { delta = hash2(key); } index = (index + delta) % arraySize; } return index; } private void rehash() { int oldSize = arraySize; long[] oldKeys = keys; long[] oldValues = values; if (pIndex < primes.length - 1) { arraySize = primes[(++pIndex)]; } else { arraySize = (arraySize * 2 + 1); } size = 0; makeArrays(arraySize); for (int i = 0; i < oldSize; i++) { if (oldValues[i] != EMPTY) { put(oldKeys[i], oldValues[i]); } } oldKeys = oldValues = (long[])null; } private final int hash(long key) { int h = (int)((key * 15821L + 1L) % arraySize); if (h < 0) { h += arraySize; } return h; } private final int hash2(long key) { return arraySize - 2 - (int)(key % (arraySize - 2)); } private static final int[] primes = { 61, 127, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139 }; private int pIndex = 0; private int size = 0; private int arraySize = primes[pIndex]; private int threshold = arraySize * 3 / 4; private long[] keys = new long[arraySize]; private long[] values = new long[arraySize]; public static long EMPTY = Long.MIN_VALUE; } /* Location: * Qualified Name: com.ibm.icu.impl.CalendarCache * Java Class Version: 5 (49.0) * JD-Core Version Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|