/** * Enables / disables the visibility of the second pointer of the clock * @param SECOND_POINTER_VISIBLE */ public void setSecondPointerVisible(final boolean SECOND_POINTER_VISIBLE) { secondPointerVisible = SECOND_POINTER_VISIBLE; repaint(getInnerBounds()); }
/** * Enables / disables the visibility of the second pointer of the clock * @param SECOND_POINTER_VISIBLE */ public void setSecondPointerVisible(final boolean SECOND_POINTER_VISIBLE) { secondPointerVisible = SECOND_POINTER_VISIBLE; repaint(getInnerBounds()); }
@Override public void actionPerformed(java.awt.event.ActionEvent event) { if (event.getSource().equals(CLOCK_TIMER)) { // Seconds secondPointerAngle = java.util.Calendar.getInstance().get(java.util.Calendar.SECOND) * ANGLE_STEP + java.util.Calendar.getInstance().get(java.util.Calendar.MILLISECOND) * ANGLE_STEP / 1000; // Hours hour = java.util.Calendar.getInstance().get(java.util.Calendar.HOUR) - this.timeZoneOffsetHour; if (hour > 12) { hour -= 12; } if (hour < 0) { hour += 12; } // Minutes minute = java.util.Calendar.getInstance().get(java.util.Calendar.MINUTE) + this.timeZoneOffsetMinute; if (minute > 60) { minute -= 60; hour++; } if (minute < 0) { minute += 60; hour--; } // Calculate angles from current hour and minute values hourPointerAngle = hour * ANGLE_STEP * 5 + (0.5) * minute; minutePointerAngle = minute * ANGLE_STEP; repaint(getInnerBounds()); } } // </editor-fold>
@Override public void actionPerformed(java.awt.event.ActionEvent event) { if (event.getSource().equals(CLOCK_TIMER)) { // Seconds secondPointerAngle = java.util.Calendar.getInstance().get(java.util.Calendar.SECOND) * ANGLE_STEP + java.util.Calendar.getInstance().get(java.util.Calendar.MILLISECOND) * ANGLE_STEP / 1000; // Hours hour = java.util.Calendar.getInstance().get(java.util.Calendar.HOUR) - this.timeZoneOffsetHour; if (hour > 12) { hour -= 12; } if (hour < 0) { hour += 12; } // Minutes minute = java.util.Calendar.getInstance().get(java.util.Calendar.MINUTE) + this.timeZoneOffsetMinute; if (minute > 60) { minute -= 60; hour++; } if (minute < 0) { minute += 60; hour--; } // Calculate angles from current hour and minute values hourPointerAngle = hour * ANGLE_STEP * 5 + (0.5) * minute; minutePointerAngle = minute * ANGLE_STEP; repaint(getInnerBounds()); } } // </editor-fold>
/** * Sets the current minute of the clock * @param MINUTE */ public void setMinute(final int MINUTE) { minute = MINUTE % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
/** * Sets the current second of the clock * @param SECOND */ public void setSecond(final int SECOND) { second = SECOND % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
/** * Sets the current hour of the clock * @param HOUR */ public void setHour(final int HOUR) { hour = HOUR % 12; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
/** * Sets the current hour of the clock * @param HOUR */ public void setHour(final int HOUR) { hour = HOUR % 12; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
/** * Sets the current minute of the clock * @param MINUTE */ public void setMinute(final int MINUTE) { minute = MINUTE % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
/** * Sets the current second of the clock * @param SECOND */ public void setSecond(final int SECOND) { second = SECOND % 60; calculateAngles(hour, minute, second); repaint(getInnerBounds()); }
/** * Enables / disables the visualization of the clock by using the current time * @param AUTOMATIC */ public void setAutomatic(final boolean AUTOMATIC) { automatic = AUTOMATIC; if (AUTOMATIC) { if (!CLOCK_TIMER.isRunning()) { CLOCK_TIMER.start(); } } else { if (CLOCK_TIMER.isRunning()) { CLOCK_TIMER.stop(); } } repaint(getInnerBounds()); }
/** * Enables / disables the visualization of the clock by using the current time * @param AUTOMATIC */ public void setAutomatic(final boolean AUTOMATIC) { automatic = AUTOMATIC; if (AUTOMATIC) { if (!CLOCK_TIMER.isRunning()) { CLOCK_TIMER.start(); } } else { if (CLOCK_TIMER.isRunning()) { CLOCK_TIMER.stop(); } } repaint(getInnerBounds()); }
@Override public void setMinimumSize(final Dimension DIM) { int width = DIM.width < 50 ? 50 : DIM.width; int height = DIM.height < 50 ? 50 : DIM.height; final int SIZE = width <= height ? width : height; super.setMinimumSize(new Dimension(SIZE, SIZE)); calcInnerBounds(); init(getGaugeBounds().width, getGaugeBounds().height); setInitialized(true); invalidate(); repaint(); }
@Override public void setMinimumSize(final Dimension DIM) { int width = DIM.width < 50 ? 50 : DIM.width; int height = DIM.height < 50 ? 50 : DIM.height; final int SIZE = width <= height ? width : height; super.setMinimumSize(new Dimension(SIZE, SIZE)); calcInnerBounds(); init(getGaugeBounds().width, getGaugeBounds().height); setInitialized(true); invalidate(); repaint(); }
@Override public void setMaximumSize(final Dimension DIM) { int width = DIM.width > 1080 ? 1080 : DIM.width; int height = DIM.height > 1080 ? 1080 : DIM.height; final int SIZE = width <= height ? width : height; super.setMaximumSize(new Dimension(SIZE, SIZE)); calcInnerBounds(); init(getGaugeBounds().width, getGaugeBounds().height); setInitialized(true); invalidate(); repaint(); }
@Override public void setMaximumSize(final Dimension DIM) { int width = DIM.width > 1080 ? 1080 : DIM.width; int height = DIM.height > 1080 ? 1080 : DIM.height; final int SIZE = width <= height ? width : height; super.setMaximumSize(new Dimension(SIZE, SIZE)); calcInnerBounds(); init(getGaugeBounds().width, getGaugeBounds().height); setInitialized(true); invalidate(); repaint(); }