Normand Briere
2018-07-07 09ddd38fd4a8a7100c834a5e976f4796fae53541
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package timeflow.vis;
 
import timeflow.data.db.*;
 
import java.awt.*;
import java.util.*;
 
public class TagVisualAct extends VisualAct {
   
   Color[] colors;
   private static Color[] nullColors={new Color(230,230,230)};
 
   public TagVisualAct(Act act) {
       super(act);
   }
   
   public void setColors(Color[] colors)
   {
       this.colors=colors;
       this.color=colors.length>0 ? colors[0] : Color.gray;
   }
 
   public void draw(Graphics2D g, int ox, int oy, int r, Rectangle maxFill, boolean showDuration)
   {
       if (colors==null)
       {
           super.draw(g, ox, oy, r, maxFill, showDuration);
           return;
       }
 
       Color[] c= colors==null || colors.length==0 ? nullColors : colors;
       int tx=ox-r;
       int side=2*r;
       for (int i=0; i<c.length; i++)
       {
           g.setColor(c[i]);
           int y0=-5+(oy-r)+(2*side*i)/c.length;
           int y1=-5+(oy-r)+(2*side*(i+1))/c.length;
           if (size>=0)
               g.fillRect(tx,y0,side+2,y1-y0);
           else
               g.drawRect(tx,y0,side+2,y1-y0);
       }
       
       if (end!=null && showDuration)
       {
           int lineY=y+6;
           g.fillRect(getX(), lineY, getEndX()-getX(), 2);
           g.drawLine(getX(), lineY, getX(), lineY-4);
       }
   }
}