@Override public Point2D getCenter() { return new Point2D.Double(bImage.getWidth() / 2.0 + getInnerBounds().x, bImage.getHeight() / 2.0 + getInnerBounds().y); }
@Override public Point2D getCenter() { return new Point2D.Double(bImage.getWidth() / 2.0 + getInnerBounds().x, bImage.getHeight() / 2.0 + getInnerBounds().y); }
public Clock() { super(); CLOCK_TIMER = new Timer(1000, this); INNER_BOUNDS = new Rectangle(200, 200); init(getInnerBounds().width, getInnerBounds().height); setPointerColor(ColorDef.BLACK); horizontalAlignment = SwingConstants.CENTER; verticalAlignment = SwingConstants.CENTER; //CLOCK_TIMER.start(); } // </editor-fold>
/** * 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()); }
public Clock() { super(); CLOCK_TIMER = new Timer(1000, this); INNER_BOUNDS = new Rectangle(200, 200); init(getInnerBounds().width, getInnerBounds().height); setPointerColor(ColorDef.BLACK); horizontalAlignment = SwingConstants.CENTER; verticalAlignment = SwingConstants.CENTER; //CLOCK_TIMER.start(); } // </editor-fold>
/** * 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 setBorder(Border BORDER) { super.setBorder(BORDER); calcInnerBounds(); init(getInnerBounds().width, getInnerBounds().height); }
@Override public void setBorder(Border BORDER) { super.setBorder(BORDER); calcInnerBounds(); init(getInnerBounds().width, getInnerBounds().height); }
@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 second of the clock * @param SECOND */ public void setSecond(final int SECOND) { second = SECOND % 60; 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 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()); }
init(getInnerBounds().width, getInnerBounds().height);
init(getInnerBounds().width, getInnerBounds().height);