GregorianCalendar to read the time of day & then drawing hands on clock

I am currently working on a program that displays an analog clock. The program uses an object of type GregorianCalendar to read the hours, mins, and secs, and then I need to draw hands on a clock accordingly. I can read the time using GregorianCalendar, but once i have the time, I am unsure how to draw the hands that coordinate with the time. i already have the clock face drawn, and I am implementing the Icon interface's paintIcon(....) method for that. Any suggestions would be greatly appreciated.
Thanks.

thats what i was trying to do but something isnt working out right. I've
attached my code.
//splits the clock into sections for seconds
double radians_per_second = ((2 * Math.PI)/3600);Are you sure that's correct...? It should have the same amount of sections as the minute hand, so I think this is incorrect... No biggy, though...
double x_hour = ((Math.cos(hours))*sizeHourHand);
double y_hour = ((Math.sin(hours))*sizeHourHand);
double x_minute = (((Math.cos(minutes))*sizeMinuteHand)); //to correct for rotation
double y_minute = (((Math.sin(minutes))*sizeMinuteHand));
double x_second = (((Math.cos(seconds))*sizeSecondHand));
double y_second = (((Math.sin(seconds))*sizeSecondHand));Here, you're calculating the size of one of the sides of the triangle, not the point itself!! Thus...
//creating the face of the clock
Ellipse2D.Double clockFace= new Ellipse2D.Double(0, 0, clockHeight, clockWidth);
Point2D.Double hourHandPoint= new Point2D.Double(x_hour, y_hour);
Point2D.Double minuteHandPoint= new Point2D.Double(x_minute, y_minute);
Point2D.Double secondHandPoint= new Point2D.Double(x_second, y_second);
Point2D.Double center= new Point2D.Double(radius, radius);
Line2D.Double hourHand= new Line2D.Double(center, hourHandPoint);
Line2D.Double minuteHand= new Line2D.Double(center, minuteHandPoint);
Line2D.Double secondHand= new Line2D.Double(center, secondHandPoint);
What you're drawing here is incorrect...
//drawing the clock
g2.setColor(Color.WHITE);
g2.draw(clockFace);
g2.fill(clockFace);
g2.setColor(Color.BLACK);
g2.draw(hourHand);
g2.draw(minuteHand);
g2.draw(secondHand);I'll explain using degrees instead of radians:
The angle for the hands' apperture should give you something between 0 and 360 degrees (non-inclusive), depending on the value, you should determine wether the hand will sit on one of quadrants 1 through 4...
Substract whatever amount of degrees to reduce the angle to anything from 0 to 90 (non-inclusive), otherwise those calculations I suggested won't work!! We need an angle that fits with a right triangle here...
From there, calculate the size of the triangle's sides (as suggested previously) and add or substract to the center point, the X and Y coords of the newly calculated sides, depending on the quadrant....
This should give you the second point to draw the line with...
I know it's long and boring, but I told you so, didn't I...?
There must be an easier way...

Similar Messages

  • DVR STB will not hold the display of the time of day.

    I am new to FIOS.  I have a DVR Set Top Box for my HD TV.  I prefer to see the time of day displayed.  I set this option in Menu/Settings/Set Top/Display and it works OK UNTIL you change the channel.  Then it displays the new channel and DOES NOT revert back to the time of day as it is supposed to do.
    Called Verizon.  They reset the box.  It worked OK for about 30 minutes then went back to the same problem.  I don't want them to reset it again because when they did it wiped all of my favorites.
    Any solutions will be greatly appreciated.
    Solved!
    Go to Solution.

    Try rebooting the STB and then change the clock setting and change it back. That worked for me when i had this issue. I have seen this reported a couple of times and most of the time if this fix didnt work, the issue resolved itself within a couple of days.
    Also, it should be noted that with the 1.7IMG release they changed the way the front display functioned. It now changes to show the channel number at every program change and then reverts back to showing the clock after about 2 minutes.
    "If your problem has been solved, please mark it as such. Don't forget to hand out your Kudos!"

  • CCX User to edit the Time of Day settings?

    We have CCX Premium 7.0(1) with a few CSQ's for various different incoming calls.
    Each of these CSQ's have defined opening hours using the Time of Day field in the associated script. Because of the bad weather in our area recently I've had to change the time of day field to reflect the office closing early.
    Although not a difficult or particularly time consuming job, it would be nice if I could leave it to someone else to make the changes as and when they need to. I was thinking of giving a user access to a number which they would call, follow some prompts, enter the necessary opening/closing times and then make this live on the necessary CSQ.
    Does anyone know if this is possible and if so is there a "best" way to do it?
    Thanks
    Jeff

    Thanks for reply Gergely.
    I am trying to compare the Current Time with the time in XML doc as suggested in this post.
    Lets assume you're going with your first version, have your users enter start/stop times in 24 hour format. For example, 930 for 9:30 AM, and 1730 for 5:30PM
    Concat your two strings into the format of: startTime + "-" + endTime. I.e: "930-1730"
    Write this value to a document
    In your scripts, you'll need to read the document with the string we created above (into a variable, 'todString' in this example). You'll need a single dimension String Array as a variable.
    String[] ToD
    Assume you stored the ToD string as 'todString'
    Set ToD = todString.split("-")
    If (int.valueOf(ToD[0]) <= int.valueOf(T[now].getHours() + "" + T[now].getMinutes()) && int.valueOf(ToD[1]) >= int.valueOf(T[now].getHours() + "" + T[now].getMinutes()))
         True:
              /* within hours of operation */
         False:
              /* outside hours of operation */
    Essentially what we are doing is this:
    storing the hours of operations as "930-1730", once we split it, ToD[0] will be "930", ToD[1] will be "1730"
    The "" in T[now].getHours() + "" + T[now].getMinutes() is important, without it you would simply get back a integer result of hours plus minutes.
    int.valueOf() turns our Strings into numbers which we can compare. If the startTime is less than or equal to the current time, than we're open. If the endTime is greater than or equal to our current time, we're still open.
    I am also trying to follow the same thing as my customer wants to manually change the Operation Hours.
    Thanks & Regards,
    Arpit

  • Question about reseting the time of day trigger.

    A little while back the college was running a promotion and at the last minuet they decided to stay open later then normal to server the needs of our students.  I reset the time of dayclosing time with the CCX editor and ga 6 the phone shut down when I had change it to 7:00.  I then rebooted our contact center servers so that the new close time would be active but in rebooting the 2 servers all the callers in queue were dropped.  Is there a way to change  the time of day trigger and rest it with out rebooting the servers? 
    Thanks
    Eric

    Hi Eric,
    When you edit the UCCX scripts \ prompts \grammers \ applications, please refresh these pages from the UCCX Admin-> Application path.
    Yes, as the UCCX high Availability works in "Warm standby" modes it is expected that the calls in Queue will be dropped, where as the connected calls will continue at the cost of missing Call details.
    Hope it helps.
    Anand
    Please rate helpful posts by clicking on the stars below the right answers!!

  • How can I print a month calendar without the times of day from the day calendar

    The obvious way to put items into iCal is via the day calendar. But I want to print the calendar as one month to a page and there I do not want the times of day.

    It seems like a simple solution must be at hand. There is an option in the iCal Preferences (General) panel--Show event times. With this command unchecked the screen view of the month view is free of the times of day, but when I print the month view the times of day are printed.

  • For iPhone4 with iOS7, how can i see the time of day for a voice memo instead of the length of time for the recording?

    For iPhone 4S with iOS7 version 7.0.2, how can I see the time of day for a voice memo, as opposed to its length (of time)?

    For iPhone 4S with iOS7 version 7.0.2, how can I see the time of day for a voice memo, as opposed to its length (of time)?

  • How do you change the time of day presets in ical?

    How do you change the time of day presets in ical?  I would like them to be only 1 hour difference, with the preset start times of 10:00 am and end time of 6:00 pm, if I have anything starting after 4:00 pm it also changes the date to the next day.  Incredibly annoying!

    Hi there jenni6,
    It looks like this is possible in the Calender prefernces. Take a look at the article below for more infromation.
    Calendar (Mavericks): General preferences
    http://support.apple.com/kb/PH14994
    -Griff W.

  • When I try to install from App Store, the timer moves and then nothing happens...should I just try again tomorrow?

    When I try to install Mavericks from the App Store, the timer moves and then nothing happens. When I first attempted to download Mavericks onto my 2009 15" macpro the program started to download and then seemingly froze up- my partners started after mine and then finished on her 2010 13" macpro... I have gone back several times to the store, restarted my system and am getting nothing... Perhaps Ill try again tomorrow?

    If you have an iPod with iOS 3.1.3 then it is due to an Apple problem.

  • The time of day doesn't sinc from my iphone to my pc is there a way to set that?

    The time of day on my PC doesn't sync with my iphone 4S in my calender. The PC shows the event 3 hours behind the iphone. Is there a setting I need to change?

    Unfortunately you can't restore an incomplete backup.

  • Is there an app that can control the ringer volume by the time of day?

    Is there an app that can control the ringer volume by the time of day. Like say i had work. Is there an app that can automaticly change the ringer volume on certain days at times you input to lower the ringer volume?

    Can a app like this be made or will apple not allow it?

  • How do I see the time of day a call was received on 4S?

    Can anyone tell me how to see the time of day a phone call was received or sent on the IPhone 4S?

    Phone>Recents...tap the "Blue" chevron.

  • Can the iPhone have settings profiles?  I want the settings of what apps are using the "call home" automatically set based on my location or the time of day.  Is this possible?

    Can the iPhone have settings profiles?  I want the settings of what apps are using the "call home" automatically set based on my location or the time of day.  Is this possible?  Of course the GPS location feature will need to be on in order for this to work.  But the idea here would be to optimize battery life by disabling the 'call home' requests of apps.  The settings profile should also support downloads as I would like to download and allow it when I am on WiFi but not so much when I am using my cellular data.

    No, this is not possible as the sandboxed nature of iOS would not allow any app to modify another app like that. Such a feature would have to be enabled by Apple as a part of iOS itself. You can submit feedback to Apple about the idea if you wish to.
    https://www.apple.com/feedback/

  • I have a Seagate Freeagent 1TB external drive that ejects it's self in the middle of the time machine backup, then disappears and can't be found unless I turn it off and back on again

    I have a Seagate Freeagent 1TB external drive that ejects it's self in the middle of the time machine backup, then disappears and can't be found unless I turn it off and back on again. Any ideas?

    Hmmm.. sorry to jump in but...
    I Wish I had seen this before I got mine.
    Mine has been doing this auto eject stuff too.
    I think I just plugged it in and TM let me select it but is it possible
    I should have reformatted it with DU first, like with all the WD drive problems ?
    Is it too late for that ?
    Or just try to return it or get rid of it ?
    TIA

  • Hello THIS IS RAZA I GOT A MACBOOK PRO I HAVE A PROBLEM. PROBLEM IS how to solve this problem i have uploaded in .... all the time few days later on i face this problem in safari..... anyone can help me please.....thanks Screen Shot 2015-03-21 at 10.

    Hello
    THIS IS RAZA
    I GOT A MACBOOK PRO
    I HAVE A PROBLEM. PROBLEM IS how to solve this problem i have uploaded in .... all the time few days later on i face this problem in safari..... anyone can help me please.....thanks

    This is a scam. Do not phone these people, at best they will charge you for unnecessary 'cleaning' and at worst they will gain access to your Mac and steal your data. You've probably managed to install some 'adware' which is producing this fake warning. 'Adwaremedic' should remove it and is safe to use - please see
    http://www.adwaremedic.com/index.php

  • I have my complete computer using Lion backed up on the time machine. Then I installed Mountain lion. I do not like it at all. Is there a way I can remove ML and put my old Lion system back pin my computer?

    I have my complete computer using Lion backed up on the time machine. Then I installed Mountain lion. I do not like it at all. Is there a way I can remove ML and put my old Lion system back pin my computer?

    If you have got a backup, press Command and R keys in boot and restore an old backup. You can install Snow Leopard and upgrade to Lion if you haven't got the backup

Maybe you are looking for