summaryrefslogtreecommitdiff
path: root/sources/client/CalendarTableCellRenderer.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2009-02-18 23:01:21 +0000
committerPaul Buetow <paul@buetow.org>2009-02-18 23:01:21 +0000
commit89c679eb813611a2ede208b4c8e27c7f596b3be7 (patch)
treef44c19435286e78b9e8002990e1b55183a4fbc49 /sources/client/CalendarTableCellRenderer.java
parent177f346a9bbe455dc12fd26dfa2c586585c28c1e (diff)
added copyright to header
Diffstat (limited to 'sources/client/CalendarTableCellRenderer.java')
-rw-r--r--sources/client/CalendarTableCellRenderer.java216
1 files changed, 110 insertions, 106 deletions
diff --git a/sources/client/CalendarTableCellRenderer.java b/sources/client/CalendarTableCellRenderer.java
index 67a9b67..da8d02b 100644
--- a/sources/client/CalendarTableCellRenderer.java
+++ b/sources/client/CalendarTableCellRenderer.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package client;
import java.awt.*;
@@ -14,122 +18,122 @@ import shared.*;
* @author buetow
*/
public class CalendarTableCellRenderer extends DefaultTableCellRenderer {
- private static final long serialVersionUID = 1L;
- private CalendarTableModel tableModel;
- // private NetCalendarClient netCalendarClient;
-
- private static final Color SELECTED_BACKGROUND_COLOR;
- private static final Color SELECTED_FOREGROUND_COLOR;
- private static final Color ALREADY_OVER_BACKGROUND_COLOR;
- private static final Color ALREADY_OVER_FOREGROUND_COLOR;
- private static final Color STANDARD_FOREGROUND_COLOR;
- private static final Color BACKGROUND_COLOR_1_DAY;
- private static final Color BACKGROUND_COLOR_7_DAYS;
- private static final Color BACKGROUND_COLOR_28_DAYS;
- private static final Color BACKGROUND_COLOR_168_DAYS;
- private static final Color BACKGROUND_COLOR_365_DAYS;
- private static final Color BACKGROUND_COLOR_MT_365_DAYS;
- private static final Color YEARLY_BACKGROUND_COLOR;
- private static final Color NOT_YEARLY_BACKGROUND_COLOR;
-
-
- private static final long NANOSECONDS_1_DAY;
- private static final long NANOSECONDS_7_DAYS;
- private static final long NANOSECONDS_28_DAYS;
- private static final long NANOSECONDS_168_DAYS;
- private static final long NANOSECONDS_365_DAYS;
-
- // Initialize once, use often!
- static {
- SELECTED_BACKGROUND_COLOR = new Color(0, 0, 0);
- SELECTED_FOREGROUND_COLOR = new Color(255, 255, 255);
- STANDARD_FOREGROUND_COLOR = new Color(0, 0, 0);
- ALREADY_OVER_FOREGROUND_COLOR = SELECTED_BACKGROUND_COLOR;
- ALREADY_OVER_BACKGROUND_COLOR = SELECTED_FOREGROUND_COLOR;
- BACKGROUND_COLOR_1_DAY = new Color(0xff, 0x00, 0x00);
- BACKGROUND_COLOR_7_DAYS = new Color(0xff, 0x6c, 0x00);
- BACKGROUND_COLOR_28_DAYS = new Color(0xff, 0xa5, 0x00);
- BACKGROUND_COLOR_168_DAYS = new Color(0xe7, 0xa5, 0x5e);
- BACKGROUND_COLOR_365_DAYS = new Color(230, 218, 161);
- BACKGROUND_COLOR_MT_365_DAYS = new Color(0xa2, 0x9c, 0x90); // For more than 365 days
-
- YEARLY_BACKGROUND_COLOR = new Color(0x65, 0xa9, 0xe3);
- NOT_YEARLY_BACKGROUND_COLOR = new Color(0x88, 0xe0, 0x90);
-
-
- NANOSECONDS_1_DAY = 3600 * 24 * 1000;
- NANOSECONDS_7_DAYS = NANOSECONDS_1_DAY * 7;
- NANOSECONDS_28_DAYS = NANOSECONDS_7_DAYS * 4;
- NANOSECONDS_168_DAYS = NANOSECONDS_28_DAYS * 6;
- NANOSECONDS_365_DAYS = NANOSECONDS_1_DAY * 365;
- }
-
- /**
- * This method creates a custom table cell renderer for the calendar client.
- * Its coloring the different cells and sets other special display attributes.
- * @param tableModel Specifies the DefaultTableModel object used by the JTable. This is needed to make decisions about displaying a specific cell.
- */
- public CalendarTableCellRenderer(CalendarTableModel tableModel) {
- // this.netCalendarClient = netCalendarClient;
- this.tableModel = tableModel;
- }
-
- /**
- * This method returns the Component object of a specific table cell.
- * @param jTable Specifies the table object of the calendar client frame.
- * @param object Specifies the object which is inside of the specific table cell.
- * @param isSelected Specifies if the current cell is selected or not.
- * @param hasFocus Specifies if the current cell is focused or not.
- * @param iRow Specifies thr row number of the current cell.
- * @param iCol specifies the column number of the current cell.
- * @return Returns the Component object of a specific table cell.
- */
- public Component getTableCellRendererComponent(JTable jTable, Object object,
- boolean isSelected, boolean hasFocus, int iRow, int iCol) {
- JLabel jLable =(JLabel) super.getTableCellRendererComponent(jTable, object, isSelected, hasFocus, iRow, iCol);
-
- //MyVector vecSelected = netCalendarClient.getSelectedIndexes();
-
- //if (vecSelected.hasLike(new Integer(iRow))) {
- if (isSelected) {
- jLable.setBackground(SELECTED_BACKGROUND_COLOR);
- jLable.setForeground(SELECTED_FOREGROUND_COLOR);
- return jLable;
+ private static final long serialVersionUID = 1L;
+ private CalendarTableModel tableModel;
+ // private NetCalendarClient netCalendarClient;
+
+ private static final Color SELECTED_BACKGROUND_COLOR;
+ private static final Color SELECTED_FOREGROUND_COLOR;
+ private static final Color ALREADY_OVER_BACKGROUND_COLOR;
+ private static final Color ALREADY_OVER_FOREGROUND_COLOR;
+ private static final Color STANDARD_FOREGROUND_COLOR;
+ private static final Color BACKGROUND_COLOR_1_DAY;
+ private static final Color BACKGROUND_COLOR_7_DAYS;
+ private static final Color BACKGROUND_COLOR_28_DAYS;
+ private static final Color BACKGROUND_COLOR_168_DAYS;
+ private static final Color BACKGROUND_COLOR_365_DAYS;
+ private static final Color BACKGROUND_COLOR_MT_365_DAYS;
+ private static final Color YEARLY_BACKGROUND_COLOR;
+ private static final Color NOT_YEARLY_BACKGROUND_COLOR;
+
+
+ private static final long NANOSECONDS_1_DAY;
+ private static final long NANOSECONDS_7_DAYS;
+ private static final long NANOSECONDS_28_DAYS;
+ private static final long NANOSECONDS_168_DAYS;
+ private static final long NANOSECONDS_365_DAYS;
+
+ // Initialize once, use often!
+ static {
+ SELECTED_BACKGROUND_COLOR = new Color(0, 0, 0);
+ SELECTED_FOREGROUND_COLOR = new Color(255, 255, 255);
+ STANDARD_FOREGROUND_COLOR = new Color(0, 0, 0);
+ ALREADY_OVER_FOREGROUND_COLOR = SELECTED_BACKGROUND_COLOR;
+ ALREADY_OVER_BACKGROUND_COLOR = SELECTED_FOREGROUND_COLOR;
+ BACKGROUND_COLOR_1_DAY = new Color(0xff, 0x00, 0x00);
+ BACKGROUND_COLOR_7_DAYS = new Color(0xff, 0x6c, 0x00);
+ BACKGROUND_COLOR_28_DAYS = new Color(0xff, 0xa5, 0x00);
+ BACKGROUND_COLOR_168_DAYS = new Color(0xe7, 0xa5, 0x5e);
+ BACKGROUND_COLOR_365_DAYS = new Color(230, 218, 161);
+ BACKGROUND_COLOR_MT_365_DAYS = new Color(0xa2, 0x9c, 0x90); // For more than 365 days
+
+ YEARLY_BACKGROUND_COLOR = new Color(0x65, 0xa9, 0xe3);
+ NOT_YEARLY_BACKGROUND_COLOR = new Color(0x88, 0xe0, 0x90);
+
+
+ NANOSECONDS_1_DAY = 3600 * 24 * 1000;
+ NANOSECONDS_7_DAYS = NANOSECONDS_1_DAY * 7;
+ NANOSECONDS_28_DAYS = NANOSECONDS_7_DAYS * 4;
+ NANOSECONDS_168_DAYS = NANOSECONDS_28_DAYS * 6;
+ NANOSECONDS_365_DAYS = NANOSECONDS_1_DAY * 365;
}
- CalendarEvent calendarEvent = tableModel.getEvent(iRow);
- jLable.setForeground(STANDARD_FOREGROUND_COLOR);
+ /**
+ * This method creates a custom table cell renderer for the calendar client.
+ * Its coloring the different cells and sets other special display attributes.
+ * @param tableModel Specifies the DefaultTableModel object used by the JTable. This is needed to make decisions about displaying a specific cell.
+ */
+ public CalendarTableCellRenderer(CalendarTableModel tableModel) {
+ // this.netCalendarClient = netCalendarClient;
+ this.tableModel = tableModel;
+ }
- if (iCol <= 1) {
- if (!calendarEvent.isYearly())
- jLable.setBackground(NOT_YEARLY_BACKGROUND_COLOR);
- else
- jLable.setBackground(YEARLY_BACKGROUND_COLOR);
+ /**
+ * This method returns the Component object of a specific table cell.
+ * @param jTable Specifies the table object of the calendar client frame.
+ * @param object Specifies the object which is inside of the specific table cell.
+ * @param isSelected Specifies if the current cell is selected or not.
+ * @param hasFocus Specifies if the current cell is focused or not.
+ * @param iRow Specifies thr row number of the current cell.
+ * @param iCol specifies the column number of the current cell.
+ * @return Returns the Component object of a specific table cell.
+ */
+ public Component getTableCellRendererComponent(JTable jTable, Object object,
+ boolean isSelected, boolean hasFocus, int iRow, int iCol) {
+ JLabel jLable =(JLabel) super.getTableCellRendererComponent(jTable, object, isSelected, hasFocus, iRow, iCol);
- return jLable;
- }
+ //MyVector vecSelected = netCalendarClient.getSelectedIndexes();
+
+ //if (vecSelected.hasLike(new Integer(iRow))) {
+ if (isSelected) {
+ jLable.setBackground(SELECTED_BACKGROUND_COLOR);
+ jLable.setForeground(SELECTED_FOREGROUND_COLOR);
+ return jLable;
+ }
- long lCurrentTime = new Date().getTime();
- long lEventTime = calendarEvent.getDate().getTime();
+ CalendarEvent calendarEvent = tableModel.getEvent(iRow);
+ jLable.setForeground(STANDARD_FOREGROUND_COLOR);
- if (lCurrentTime + NANOSECONDS_1_DAY > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_1_DAY);
+ if (iCol <= 1) {
+ if (!calendarEvent.isYearly())
+ jLable.setBackground(NOT_YEARLY_BACKGROUND_COLOR);
+ else
+ jLable.setBackground(YEARLY_BACKGROUND_COLOR);
- else if (lCurrentTime + NANOSECONDS_7_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_7_DAYS);
+ return jLable;
+ }
- else if (lCurrentTime + NANOSECONDS_28_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_28_DAYS);
+ long lCurrentTime = new Date().getTime();
+ long lEventTime = calendarEvent.getDate().getTime();
- else if (lCurrentTime + NANOSECONDS_168_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_168_DAYS);
+ if (lCurrentTime + NANOSECONDS_1_DAY > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_1_DAY);
- else if (lCurrentTime + NANOSECONDS_365_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_365_DAYS);
+ else if (lCurrentTime + NANOSECONDS_7_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_7_DAYS);
- else
- jLable.setBackground(BACKGROUND_COLOR_MT_365_DAYS);
+ else if (lCurrentTime + NANOSECONDS_28_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_28_DAYS);
- return jLable;
- }
+ else if (lCurrentTime + NANOSECONDS_168_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_168_DAYS);
+
+ else if (lCurrentTime + NANOSECONDS_365_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_365_DAYS);
+
+ else
+ jLable.setBackground(BACKGROUND_COLOR_MT_365_DAYS);
+
+ return jLable;
+ }
}