Alejandro Acuña
2024-10-25 bf65497ed7abf9c669eb3cc0ba219dfa4494b759
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package art.client.GUI.components.devices.window.colors.rtz32.configuration.components;
 
import art.library.gui.FlatGUI;
import art.library.gui.flat.FlatButton;
import art.library.gui.flat.FlatLabel;
import art.library.gui.flat.combobox.FlatComboBox;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Group;
import art.servers.Shared;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import javax.swing.JPanel;
 
 
 
public class Diagram_Distribution_Bars_Header_Groups extends JPanel
{
    private RTZ32_Configuration configuration = null;
    private int numberBars = 0;
    private boolean editable = false;
    private FlatComboBox[] combos1 = new FlatComboBox[0];
    private FlatButton[] buttons2 = new FlatButton[0];
 
    
    public Diagram_Distribution_Bars_Header_Groups(RTZ32_Configuration configuration)
    {
        this.configuration = configuration;
        this.setLayout(null);
    }
 
    
    
    public void paint (Graphics2D g2, int currentBar)
    {
        try
        {
            int w = getWidth();
            int h = getHeight();
            g2.setStroke(new BasicStroke(1.0f));
            Font font = new FlatLabel().getLook().font;
            g2.setColor(new FlatButton().getLook().colorForeground);
            numberBars = Diagram_Distribution.getNumberBars(configuration);
            double dy = (int)((double)h / (double)numberBars); 
 
            
 
            //////////////////////////////////////////////////////////////////////////////////////////////////
            // Quitar si no se quiere que ocupe toda la altura de pantalla
            //
            // dy = Math.min(dy, 36);
            // h = (int)(dy * configuration.groups.size());
            //
            //////////////////////////////////////////////////////////////////////////////////////////////////
 
            
            g2.setColor(FlatGUI.lookDesign.getColor("label.color.foreground"));
            g2.rotate(-Math.PI/2, 25, h/2);
            Diagram_Distribution.drawCenteredString(g2, Shared.getMessage("Group"), new Rectangle2D.Double(0, 0, 50, h), font);
            g2.rotate((Math.PI/2), 25, h/2);
 
            
            double currenty = 0;
          
            for (int i=0; i<configuration.getNumberValidGroups(); i++)
            {
                RTZ32_Configuration_Group group = configuration.groups[i];
                
                if (group.type != 20)
                {
                    Diagram_Distribution.drawLeftString(g2, Shared.getMessage("G") + group.number, new Rectangle2D.Double(60, currenty, w-150, dy), font);
                    Diagram_Distribution.drawCenteredString(g2, "" + group.getType(), new Rectangle2D.Double(90, currenty, 35, dy), font);
                    Diagram_Distribution.drawLeftString(g2, group.getTypeName(), new Rectangle2D.Double(135, currenty, w, dy), font);                    
                    currenty = currenty + dy;
                }
                else
                {
                    Diagram_Distribution.drawLeftString(g2, Shared.getMessage("G") + group.number, new Rectangle2D.Double(60, currenty, w-150, (dy * 4)), font);
                    Diagram_Distribution.drawCenteredString(g2, "" + group.getType(), new Rectangle2D.Double(90, currenty, 35, (dy * 4)), font);
                    Diagram_Distribution.drawLeftString(g2, group.getTypeName(), new Rectangle2D.Double(135, currenty, w, (dy * 4)), font);
                    currenty = currenty + (4 * dy);
                }
            }
 
            
            g2.setColor(new FlatButton().getLook().colorBackground.darker());
            g2.draw(new Line2D.Double(0, 0, w, 0));
            g2.draw(new Line2D.Double(50, 0, 50, h * 2));
            g2.draw(new Line2D.Double(90, 0, 90, h * 2));
            g2.draw(new Line2D.Double(125, 0, 125, h * 2));
            
            currenty = 0;
            
            for (int i=0; i<configuration.getNumberValidGroups(); i++)
            {
                RTZ32_Configuration_Group group = configuration.groups[i];
                
                if (group.type != 20)
                {
                    currenty = currenty + dy;
                    g2.draw(new Line2D.Double(50, currenty,  w, currenty));
                }
                else
                {
                    currenty = currenty + (4 * dy);
                    g2.draw(new Line2D.Double(50, currenty,  w, currenty));
                }
            }
            
            g2.setColor(Color.blue);
            paintFocus(g2, currentBar);
        }
        catch (Exception e)
        {
        }
    }
    
    
    
    
 
    public void paintFocus (Graphics2D g2, int currentBar)
    {
        try
        {
            int w = getWidth();
            int h = getHeight();
            
            double dy = (int)((double)h / (double)numberBars); 
 
            if ((currentBar >= 1) && (currentBar <= numberBars))
            {
                g2.fill(new Ellipse2D.Double(w - 20, (dy * currentBar) - (dy/2) - (dy/4), dy/2, dy/2));
            }
        }
        catch (Exception e)
        {
        }        
    }
 
 
    
 
    
        
}