1 package org.netbeans.modules.tasklist.usertasks.renderers; 2 3 import java.awt.Color ; 4 import java.awt.Component ; 5 import java.awt.Font ; 6 import org.netbeans.modules.tasklist.usertasks.options.Settings; 7 import org.netbeans.modules.tasklist.usertasks.model.Duration; 8 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 9 10 13 public class EffortTableCellRenderer extends DurationTableCellRenderer { 14 private Font boldFont, normalFont; 15 16 19 public EffortTableCellRenderer() { 20 } 21 22 public Component getTableCellRendererComponent(javax.swing.JTable table, 23 Object value, boolean isSelected, boolean hasFocus, 24 int row, int column) { 25 if (normalFont == null || !normalFont.equals(table.getFont())) { 26 normalFont = table.getFont(); 27 boldFont = normalFont.deriveFont(Font.BOLD); 28 } 29 setForeground(null); 30 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, 31 row, column); 32 UserTask ut = (UserTask) value; 33 if (ut != null) { 34 boolean b = ut.getEffort() >= ut.getSpentTime() + 35 ut.getRemainingEffort(); 36 setFont(b ? normalFont : boldFont); 37 if (!isSelected && !b) 38 setForeground(Color.RED); 39 } 40 return this; 41 } 42 43 protected Duration getDuration(Object obj) { 44 UserTask ut = (UserTask) obj; 45 if (ut == null) { 46 return null; 47 } else { 48 return new Duration(ut.getEffort(), 49 Settings.getDefault().getMinutesPerDay(), 50 Settings.getDefault().getDaysPerWeek(), true); 51 } 52 } 53 } 54 | Popular Tags |