I'm creating an analog clock in Java and I just want to add some more detail. How can I transform a normal line into an arrow like some clocks have?
For example, here's what my hour hand coding looks like:
private void drawHourHand(Graphics2D g) {
int hLength = (int)(radius * 0.5);
int xHour
= (int)(xCenter
+ hLength
* Math.sin(
(hour % 12 + minute / 60.0)
* (2 * Math.PI / 12)));
int yHour
= (int)(yCenter
- hLength
* Math.cos(
(hour % 12 + minute / 60.0)
* (2 * Math.PI / 12)));
g.setColor(Color.BLACK);
g.drawLine(xCenter, yCenter, xHour, yHour);
}
How would I go about adding to this code and still make it continue to run as normal?