Alejandro Acuña
2024-07-30 65a64a81d30f00f1fffd5da6866850e1308e1135
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package art.client.GUI.components.devices.window.colors.rtz32.configuration.components;
 
import art.library.gui.FlatGUI;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program;
import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Distribution;
import java.awt.BasicStroke;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import javax.swing.JPanel;
 
public class Diagram_Distribution_Bars_Header_Timeline extends JPanel
{
    private RTZ32_Configuration configuration = null;
    private int programNumber = 0;
    private RTZ32_Distribution distribution = null;
 
    
    public Diagram_Distribution_Bars_Header_Timeline(RTZ32_Configuration configuration, int programNumber)
    {
        this.configuration = configuration;
        this.programNumber = programNumber;
    }
 
       
 
    
 
    public void paintTimeline(Graphics2D g2)
    {
        try
        {
            RTZ32_Configuration_Program program = configuration.getProgram(programNumber);
            
            Diagram_Distribution.format(g2);
            int w = getWidth();
            int h = getHeight();
            
            double h1 = 25;
 
            double dx = (double)w / (double)program.cycle;
 
            int scale = 0;
 
            for (int i=0; i<10; i++)
            {
                int width = g2.getFontMetrics().stringWidth("999");
 
                if (width < (dx + (dx * i * 5)))
                {
                    scale = i * 5;
                    break;
                } 
            }    
            scale = Math.max(scale,5);
 
            
            
            // Seconds lines
            
            g2.setColor(FlatGUI.lookDesign.getColor("label.color.foreground").brighter().brighter().brighter());
            g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[]{1f,3f}, 0.0f));    
            
            for (double i=0; i<=program.cycle; i=i+1)
            {
                g2.draw(new Line2D.Double(dx * i, h1, dx * i, h));
            }    
 
            
            // n seconds (scale) lines
            
            g2.setStroke(new BasicStroke(1.0f));    
            Font font = FlatGUI.lookDesign.getFont("label.font").deriveFont((float)(FlatGUI.lookDesign.getFont("label.font").getSize()-2.5f));
            
            for (double i=0; i<=(double)program.cycle; i=i+scale)
            {
                g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
                g2.draw(new Line2D.Double(dx * i, 0, dx * i, h));
                g2.setColor(FlatGUI.lookDesign.getColor("label.color.foreground"));
                Diagram_Distribution.drawRightString(g2, "" + (int)(i + scale), new Rectangle2D.Double(dx * i, 0, dx * scale, h1), font);
            }    
 
 
            g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
            g2.draw(new Rectangle2D.Double(0,0,w,h1));
            g2.draw(new Rectangle2D.Double(0,0,w,h));
        }
        catch (Exception exception)
        {
        }
    }
        
    
 
    
}