1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package de.jaret.util.ui.timebars.swing.renderer;
21
22 import java.awt.AlphaComposite;
23 import java.awt.Color;
24 import java.awt.Graphics;
25 import java.awt.Graphics2D;
26 import java.awt.Rectangle;
27
28 import de.jaret.util.ui.timebars.TimeBarViewerDelegate;
29 import de.jaret.util.ui.timebars.swing.TimeBarViewer;
30
31
32
33
34
35
36
37 public class DefaultMiscRenderer implements IMiscRenderer {
38
39 public static final Color HIGHLIGHT_COLOR = Color.RED;
40
41
42
43
44 public void renderRegionRect(Graphics graphics, TimeBarViewer tbv, TimeBarViewerDelegate delegate) {
45 if (delegate.getRegionRect() != null) {
46 Color color = graphics.getColor();
47 Rectangle rect = delegate.calcRect(delegate.getRegionRect());
48 graphics.setColor(Color.GRAY);
49 Graphics2D g2 = (Graphics2D) graphics;
50 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
51 graphics.fillRect(rect.x, rect.y, rect.width, rect.height);
52 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
53 graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
54 graphics.setColor(color);
55 }
56 }
57
58
59
60
61 public void renderSelectionRect(Graphics graphics, TimeBarViewer tbv, Rectangle selectionRect) {
62 Color old = graphics.getColor();
63 graphics.setColor(Color.GRAY);
64 graphics.drawRect(selectionRect.x, selectionRect.y, selectionRect.width, selectionRect.height);
65 graphics.setColor(old);
66 }
67
68
69
70
71 public void drawRowGridLine(Graphics graphics, int x1, int y1, int x2, int y2) {
72 Color color = graphics.getColor();
73 graphics.setColor(Color.LIGHT_GRAY);
74 graphics.drawLine(x1, y1, x2, y2);
75 graphics.setColor(color);
76 }
77
78
79
80
81 public void drawRowBackground(Graphics graphics, int x, int y, int width, int height, boolean selected,
82 boolean highlighted) {
83
84 Color color = graphics.getColor();
85 if (selected) {
86 graphics.setColor(Color.BLUE);
87 } else {
88 graphics.setColor(HIGHLIGHT_COLOR);
89 }
90 Graphics2D g2 = (Graphics2D) graphics;
91 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
92 graphics.fillRect(x, y, width, height);
93 g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
94 graphics.setColor(color);
95
96 }
97
98 }