1 19 20 package taskblocks.modelimpl; 21 22 import java.awt.Color ; 23 import java.awt.FontMetrics ; 24 import java.awt.Graphics2D ; 25 import java.awt.Rectangle ; 26 27 import taskblocks.Colors; 28 import taskblocks.graph.TaskGraphPainter; 29 30 public class TaskPainterImpl implements TaskGraphPainter { 31 32 Color _taskCol = Colors.TASK_COLOR; 33 Color _taskSelCol = _taskCol.brighter(); 34 Color _taskBorderCol = _taskCol.darker(); 35 Color _taskBorderSelCol = Colors.SELECTOIN_COLOR; 36 37 public void paintTask(Object task, Graphics2D g2, Rectangle bounds, boolean selected) { 38 String taskName = ((TaskImpl)task).getName(); 39 40 Color col = ((TaskImpl)task).getColor(); 41 42 if(selected) { 43 col = col.brighter(); 44 } 45 g2.setColor(col); 46 g2.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 5, 5); 47 48 if(selected) { 49 g2.setColor(_taskBorderSelCol); 50 } else { 51 g2.setColor(_taskBorderCol); 52 } 53 g2.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 5, 5); 54 55 Rectangle oldClips = g2.getClipBounds(); 56 g2.setColor(Color.black); 57 g2.clipRect(bounds.x, bounds.y, bounds.width-4, bounds.height-3); 58 59 FontMetrics fm = g2.getFontMetrics(); 60 61 g2.drawString(taskName, bounds.x + 5, bounds.y+ (fm.getHeight() + bounds.height)/2 - fm.getDescent()); 62 g2.setClip(oldClips.x, oldClips.y, oldClips.width, oldClips.height); 63 } 65 66 public void paintRowHeader(Object man, Graphics2D g2, Rectangle bounds, boolean selected) { 67 if(selected) { 68 g2.setColor(Color.LIGHT_GRAY); 69 g2.fillRoundRect(bounds.x+3, bounds.y+6, bounds.width-7, bounds.height-6, 5, 5); 70 g2.setColor(Color.GRAY); 71 g2.drawRoundRect(bounds.x+3, bounds.y+6, bounds.width-7, bounds.height-6, 5, 5); 72 } 73 g2.setColor(Color.black); 74 g2.drawString(((ManImpl)man).getName(), bounds.x + 8, bounds.y + (bounds.height + g2.getFontMetrics().getHeight())/2); 75 } 76 77 } 78 | Popular Tags |