
this application show current time & five prayer time for muslim specific for my current city (Bandung, latitude:6.54 & longitude: 107.36), with polar clock as visualization.
to compute prayer time, i use algorithm that described in this site http://tanzil.info/praytime/doc/calculation/.
source code:
import javafx.scene.shape.*;
import javafx.animation.*;
import java.util.*;
import javafx.scene.shape.*;
import javafx.scene.paint.Color;
import javafx.util.Math;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.date.DateTime;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import java.text.SimpleDateFormat;
/**
* @author Muhammad Hakim A
*/
var hours;
var minutes;
var seconds;
var date;
var day;
var month;
var year;
var cal;
var time = Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames: [
KeyFrame {
time: 100ms
action:function(){
cal = createCalendar();
seconds = (cal.get(Calendar.SECOND) + (cal.get(Calendar.MILLISECOND) as Float)/1000)/60;
minutes = (cal.get(Calendar.MINUTE) + seconds)/60;
hours = (cal.get(Calendar.HOUR) + minutes)/12;
}
}
]
}
var sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
var today:String = "{sdf.format(Calendar.getInstance().getTime())}";
function createCalendar() {
var date = new Date();
def calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar
}
// class polarclock
class PolarClock extends CustomNode{
public var cX=10;
public var cY=10;
public var strokeWidth = 5;
public var radius=50;
public var secLength= 180;
public var minLength= 90;
public var hourLength= 30;
public var text = "";
override function create(){
return Group{
opacity: 0.85
content:[
Arc {// second
centerX: cX, centerY: cY
radiusX: radius, radiusY: radius
startAngle: 90, length:bind -secLength+strokeWidth*360.0/(4*Math.PI*radius)
stroke: Color.GREEN
fill: null
strokeWidth: strokeWidth
}
Arc {// minute
centerX: cX, centerY: cY
radiusX: radius-17, radiusY: radius -17
startAngle: 90, length:bind -minLength+strokeWidth*360.0/(4*Math.PI*radius)
stroke: Color.RED
fill: null
strokeWidth: strokeWidth
}
Arc {// hour
centerX: cX, centerY: cY
radiusX: radius-34, radiusY: radius-34
startAngle: 90, length:bind -hourLength+strokeWidth*360.0/(4*Math.PI*radius)
stroke: Color.BLUE
fill: null
strokeWidth: strokeWidth
}
Label {
translateY : cY+radius + 10
translateX : cX - radius/2;
text: text
textFill: Color.GOLD
}
];
};
}
}
// prayer time calculator
def JD1970 = 2440587.5;
def d2r = Math.PI/180;
def r2d = 57.2957795;
var dt:DateTime = DateTime{};
var jd = JD1970 + Math.floor((dt.instant + 0.5)/(1000 * 60 * 60* 24));
var D = jd - 2451545.0; // jd is the given Julian date
var g = 357.529 + 0.98560028* D;
var q = 280.459 + 0.98564736* D;
var L = q + 1.915* sin(g) + 0.020*sin(2*g);
var R = 1.00014 - 0.01671*cos(g) - (1.4e-4)*cos(2*g);
var e = 23.439 - (3.6e-7)* D;
var RA = atan2(cos(e)*sin(L),cos(L))/15;
var d = asin(sin(e)*sin(L)); // declination of the Sun
var EqT = q/15 - RA; // equation of time
// Bandung info
def TZ = 7;
def lat = 6.54;
def lng = 107.36;
var dzuhr = fixhour(12 + TZ - lng/15 - EqT);
var fajr = dzuhr - T(18);
var fajrh = [to12h(Math.floor(fajr)),to60((fajr - Math.floor(fajr))*60)];
var isya = dzuhr + T(17);
var ashr = dzuhr + 1.0/15*acos((sin(acotan(1.0+tan(lat-d)))
-(sin(lat)*sin(d)))/(cos(lat)*cos(d)));
var maghrib = dzuhr + T(0.8333);
function T(a:Double) {
return (1.0/15)*acos(-sin(a)-sin(lat)*sin(d)/cos(lat)*cos(d)) }
function fixhour(a:Float)
{
var b = a - 24.0 * (Math.floor(a / 24.0));
if (b < 0) b= b + 24.0;
return b;
}
function to12h (h:Integer) { if (h>12) h-12 else h }
function to60(m:Integer) { if(m>60) m-60 else m }
function sin (a:Double) { Math.sin(a*d2r)}
function cos (a:Double) { Math.cos(a*d2r)}
function tan (a:Double) { Math.tan(a*d2r)}
function acotan (a:Double){ Math.atan(1.0/a)*r2d }
function acos(a:Double) { Math.acos(a)*r2d}
function asin(a:Double) { Math.asin(a)*r2d}
function atan(a:Double) { Math.atan(a)*r2d}
function atan2 (y:Double,x:Double) { Math.atan2(y, x)*r2d }
public function run () {
time.play();
println("{today}");
var scene:Scene = Scene {
width: 500
height: 500
fill: Color.BLACK
content: [
ImageView {
image: Image {
url: "{__DIR__}Masjid.png"
}
}
PolarClock{
radius:120
cX: 150
cY: 160
strokeWidth:15
secLength:bind 360*seconds
minLength: bind 360*minutes
hourLength:bind 360*hours
text: bind "today: {today}"
}
//fajr
PolarClock{
radius:50
cX: 340
cY: 60
strokeWidth:11
secLength: 360
minLength: fajrh[1]*6
hourLength: fajrh[0]*30
text: "Fajr: {fajrh[0]}:{fajrh[1]} am"
}
//dzuhr
PolarClock{
radius:50
cX: 340
cY: 200
strokeWidth:11
secLength: 360
minLength: to60((dzuhr - Math.floor(dzuhr))*60)*6
hourLength: to12h(Math.floor(dzuhr))*30
text: "Dzuhr"
}
//ashr
PolarClock{
radius:70
cX: 340
cY: 360
strokeWidth:11
secLength: 300
minLength: to60((ashr - Math.floor(ashr))*60)*6
hourLength: to12h(Math.floor(ashr))*30
text: "Ashr"
}
//maghrb
PolarClock{
radius:50
cX: 190
cY: 400
strokeWidth:11
secLength: 350
minLength: to60((maghrib - Math.floor(maghrib))*60)*6
hourLength: to12h(Math.floor(maghrib))*30
text: "Maghrib"
}
//isya
PolarClock{
radius:50
cX: 70
cY: 400
strokeWidth:11
secLength: 360
minLength: to60((isya - Math.floor(isya))*60)*6
hourLength: to12h(Math.floor(isya))*30
text: "Isya"
}]
}
def stage:Stage = Stage {
title: "Five Prayer Time"
scene: scene
}
stage.visible = true;
}





[...] source code: number of characters: 2987 (without white spaces/characters ) number of lines: 195 you can find more readable code at my blog [...]
polar clocknya bagus kim!
yg flash mmg bagus. yg kubuat masih wobbling (javafx-nya sptnya).
btw, palm webos punya IDE web-based nih mas:
http://www.precentral.net/ares-webos-development-browser-drag-n-drop-coming-later-year
sptnya thesis-mu bakal nyaingi nih ;)
nak tnya…nak run dlm ape nie?? kenapa sy run dlm netbean dan jcreator ada error???
plez help me..
javafx, netbeans harus sudah di install javafx http://javafx.com/downloads/windows.jsp
buat M. Hakim tolong kirimin link download-tannya dong yang masih mentah-nya buat saya kembangin… mudah-mudahan bermanfaat buat semua,,
mas, itu kodenya sudah lengkap kok, tinggal di copy-past (dan sedikit edit mungkin) sudah bias digunakan.
mkch bngt infonya mas. . .
I found your weblog site on google and test a couple of of your early posts. Proceed to keep up the superb operate. I just extra up your RSS feed to my MSN Information Reader. Searching for forward to studying more from you in a while!…
I just could not go away your website prior to suggesting that I extremely loved the usual information an individual provide for your guests? Is going to be again ceaselessly to investigate cross-check new posts
Hi there this is kinda of off topic but I was wanting to know if blogs
use WYSIWYG editors or if you have to manually code with HTML.
I’m starting a blog soon but have no coding expertise so I wanted to get advice from someone with experience. Any help would be greatly appreciated!
Your write-up offers verified necessary to me personally.
It’s quite informative and you’re obviously extremely knowledgeable in this field. You have got opened my own face to various thoughts about this kind of matter using intriguing, notable and solid content.