package art.client.GUI.components.devices.window.colors.rtz32.realtime.components.distribution;
|
|
import art.library.gui.FlatGUI;
|
import art.library.model.devices.colors.controller.RTZ32.RTZ32_Controller;
|
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration;
|
import art.library.model.devices.colors.controller.RTZ32.configuration.constants.RTZ32_Constants_Colors;
|
import art.library.model.devices.colors.controller.RTZ32.realtime.RTZ32_Realtime;
|
import art.library.model.devices.colors.controller.RTZ32.realtime.RTZ32_Realtime_Cycle_Distribution;
|
import art.library.model.devices.colors.controller.RTZ32.realtime.RTZ32_Realtime_Impulse_Groups;
|
import art.library.model.devices.colors.controller.RTZ32.realtime.RTZ32_Realtime_Impulse_Phase;
|
import art.library.model.devices.colors.controller.RTZ32.realtime.RTZ32_Realtime_Impulse_Saturation;
|
import art.library.model.devices.colors.controller.RTZ32.realtime.RTZ32_Realtime_Impulse_Trolley_Detector;
|
import java.awt.AlphaComposite;
|
import java.awt.BasicStroke;
|
import java.awt.Color;
|
import java.awt.Font;
|
import java.awt.FontMetrics;
|
import java.awt.Graphics2D;
|
import java.awt.Stroke;
|
import java.awt.geom.Line2D;
|
import java.awt.geom.Rectangle2D;
|
import java.util.List;
|
import javax.swing.JPanel;
|
|
|
public class Diagram_Distribution_Realtime_Content extends JPanel
|
{
|
private static final float[] dashFast = {1.5f, 1.5f};
|
private static final float[] dashSlow = {2.25f, 2.25f};
|
private static final Stroke strokeImpulse = new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0f, dashSlow, 0.0f);
|
private static final Color brown = new Color(185, 122, 77);
|
private static final Font font1 = FlatGUI.lookDesign.getFont("label.font").deriveFont(Font.BOLD).deriveFont(11.0f);
|
private static final Font font2 = FlatGUI.lookDesign.getFont("label.font").deriveFont(Font.PLAIN).deriveFont(11.0f);
|
public static final AlphaComposite composite1 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
|
public static final AlphaComposite composite2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
|
|
private RTZ32_Controller rtz32 = null;
|
private int duration = 0;
|
private int currentCycle = 0;
|
|
|
public Diagram_Distribution_Realtime_Content(RTZ32_Controller rtz32, int duration)
|
{
|
this.rtz32 = rtz32;
|
this.duration = duration;
|
this.setLayout(null);
|
}
|
|
|
public void setDuration(int duration)
|
{
|
this.duration = duration;
|
}
|
|
public void updateCycle()
|
{
|
try
|
{
|
RTZ32_Realtime realtime = rtz32.getDeviceRealtime().rtz32;
|
currentCycle = realtime.counters.getCurrentCycleReal();
|
}
|
catch (Exception exception)
|
{
|
}
|
}
|
|
|
// <editor-fold defaultstate="collapsed" desc="Paint">
|
|
|
public void paintSaturation (Graphics2D g2, int h)
|
{
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("button.color.foreground"));
|
|
int w = getWidth();
|
double dy = h;
|
double dx = (double)w / (double)duration;
|
double currenty = 25;
|
double y1 = currenty;
|
double y2 = currenty + dy;
|
double centery = y1 + ((y2 - y1) /2);
|
float height1 = (float)Math.min(7.5, (y2-y1)/2);
|
|
try
|
{
|
RTZ32_Realtime realtime = rtz32.getDeviceRealtime().rtz32;
|
|
g2.setFont(font1);
|
|
// Paint background
|
{
|
g2.setColor(Color.white);
|
g2.fill(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
}
|
|
// Previous cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
|
if (realtime.cycles.size() == 2)
|
{
|
cycle1 = null;
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
else if (realtime.cycles.size() >= 3)
|
{
|
cycle1 = realtime.cycles.get(realtime.cycles.size()-3);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
|
if (cycle2 != null)
|
{
|
paintSaturations(g2, composite2, dx, dy, currenty, cycle1, cycle2);
|
}
|
}
|
|
// Current cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
if (realtime.cycles.size() >= 2) cycle1 = realtime.cycles.get(realtime.cycles.size()-2);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-1);
|
|
paintSaturations(g2, composite1, dx, dy, currenty, cycle1, cycle2);
|
}
|
|
}
|
catch (Exception e)
|
{
|
}
|
|
// Paint border
|
|
g2.setComposite(composite1);
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
|
g2.draw(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
|
}
|
|
|
|
|
|
public void paintPhases (Graphics2D g2, int h)
|
{
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("button.color.foreground"));
|
|
int w = getWidth();
|
double dy = h;
|
double dx = (double)w / (double)duration;
|
double currenty = 25;
|
double y1 = currenty;
|
double y2 = currenty + dy;
|
double centery = y1 + ((y2 - y1) /2);
|
float height1 = (float)Math.min(7.5, (y2-y1)/2);
|
|
try
|
{
|
RTZ32_Realtime realtime = rtz32.getDeviceRealtime().rtz32;
|
|
g2.setFont(font1);
|
|
// Paint background
|
{
|
g2.setColor(Color.white);
|
g2.fill(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
}
|
|
// Previous cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
|
if (realtime.cycles.size() == 2)
|
{
|
cycle1 = null;
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
else if (realtime.cycles.size() >= 3)
|
{
|
cycle1 = realtime.cycles.get(realtime.cycles.size()-3);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
|
if (cycle2 != null)
|
{
|
paintPhases(g2, composite2, dx, dy, currenty, height1, cycle1, cycle2);
|
}
|
}
|
|
// Current cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
if (realtime.cycles.size() >= 2) cycle1 = realtime.cycles.get(realtime.cycles.size()-2);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-1);
|
|
paintPhases(g2, composite1, dx, dy, currenty, height1, cycle1, cycle2);
|
}
|
|
}
|
catch (Exception e)
|
{
|
}
|
|
// Paint border
|
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
|
g2.draw(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
|
}
|
|
|
|
|
public void paintGroups (Graphics2D g2, int h)
|
{
|
int numberBars = 0;
|
|
try
|
{
|
RTZ32_Configuration configuration = rtz32.getDeviceConfiguration().rtz32;
|
RTZ32_Realtime realtime = rtz32.getDeviceRealtime().rtz32;
|
|
numberBars = configuration.getNumberValidGroups();
|
double currenty = 0;
|
double dy = (double)((double)h / (double)numberBars);
|
|
g2.setFont(font1);
|
|
// Paint background
|
{
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(Color.white);
|
|
for (int i=0; i<numberBars; i++)
|
{
|
double y1 = currenty;
|
double y2 = currenty + dy;
|
double centery = y1 + ((y2 - y1) /2);
|
float height2 = (float)Math.min(9, (y2-y1)/4);
|
g2.fill(new Rectangle2D.Double(0, centery - height2, getWidth(), height2 * 2));
|
currenty = currenty + dy;
|
}
|
}
|
|
currenty = 0;
|
|
// Previous cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
|
if (realtime.cycles.size() == 2)
|
{
|
cycle1 = null;
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
else if (realtime.cycles.size() >= 3)
|
{
|
cycle1 = realtime.cycles.get(realtime.cycles.size()-3);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
|
if (cycle2 != null)
|
{
|
paintGroups(g2, composite2, h, cycle1, cycle2);
|
}
|
}
|
|
// Current cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
if (realtime.cycles.size() >= 2) cycle1 = realtime.cycles.get(realtime.cycles.size()-2);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-1);
|
|
paintGroups(g2, composite1, h, cycle1, cycle2);
|
}
|
|
}
|
catch (Exception e)
|
{
|
}
|
|
try
|
{
|
double currenty = 0;
|
double dy = (double)((double)h / (double)numberBars);
|
|
// Paint borders
|
{
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
|
|
for (int i=0; i<numberBars; i++)
|
{
|
double y1 = currenty;
|
double y2 = currenty + dy;
|
double centery = y1 + ((y2 - y1) /2);
|
float height2 = (float)Math.min(9, (y2-y1)/4);
|
g2.draw(new Rectangle2D.Double(0, centery - height2, getWidth(), height2 * 2));
|
currenty = currenty + dy;
|
}
|
}
|
}
|
catch (Exception exception)
|
{
|
}
|
}
|
|
|
|
public void paintCycleReference (Graphics2D g2, int h)
|
{
|
try
|
{
|
int w = getWidth();
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("button.color.foreground"));
|
double dx = (double)w / (double)duration;
|
|
g2.setColor(Color.blue);
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setFont(font1);
|
{
|
g2.draw(new Line2D.Double(currentCycle * dx, -100, currentCycle * dx, getHeight()*2));
|
g2.drawString("" + currentCycle, (float)(currentCycle * dx) + 5, -80);
|
}
|
}
|
catch (Exception exception)
|
{
|
}
|
}
|
|
|
|
|
public void paintACR (Graphics2D g2, int h)
|
{
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("button.color.foreground"));
|
|
int w = getWidth();
|
double dy = h;
|
double dx = (double)w / (double)duration;
|
double currenty = 25;
|
double y1 = currenty;
|
double y2 = currenty + dy;
|
double centery = y1 + ((y2 - y1) /2);
|
float height1 = (float)Math.min(7.5, (y2-y1)/2);
|
|
try
|
{
|
RTZ32_Realtime realtime = rtz32.getDeviceRealtime().rtz32;
|
|
g2.setFont(font1);
|
|
// Paint background
|
{
|
g2.setColor(Color.white);
|
g2.fill(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
}
|
|
// Previous cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
|
if (realtime.cycles.size() == 2)
|
{
|
cycle1 = null;
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
else if (realtime.cycles.size() >= 3)
|
{
|
cycle1 = realtime.cycles.get(realtime.cycles.size()-3);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
|
if (cycle2 != null)
|
{
|
paintACR(g2, composite2, dx, dy, currenty, height1, cycle1, cycle2);
|
}
|
}
|
|
// Current cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
if (realtime.cycles.size() >= 2) cycle1 = realtime.cycles.get(realtime.cycles.size()-2);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-1);
|
|
paintACR(g2, composite1, dx, dy, currenty, height1, cycle1, cycle2);
|
}
|
|
}
|
catch (Exception e)
|
{
|
}
|
|
// Paint border
|
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
|
g2.draw(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
|
}
|
|
|
|
public void paintTrolleyDetectors (Graphics2D g2, int h, int trolley)
|
{
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("button.color.foreground"));
|
|
int w = getWidth();
|
double dy = h;
|
double dx = (double)w / (double)duration;
|
double currenty = 25;
|
double y1 = currenty;
|
double y2 = currenty + dy;
|
double centery = y1 + ((y2 - y1) /2);
|
float height1 = (float)Math.min(7.5, (y2-y1)/2);
|
|
try
|
{
|
RTZ32_Realtime realtime = rtz32.getDeviceRealtime().rtz32;
|
|
g2.setFont(font2);
|
|
// Paint background
|
// {
|
// g2.setColor(Color.white);
|
// g2.fill(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
// }
|
|
// Previous cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
|
if (realtime.cycles.size() == 2)
|
{
|
cycle1 = null;
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
else if (realtime.cycles.size() >= 3)
|
{
|
cycle1 = realtime.cycles.get(realtime.cycles.size()-3);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-2);
|
}
|
|
if (cycle2 != null)
|
{
|
paintTrolleyDetectors(g2, composite2, dx, dy, currenty, height1, cycle1, cycle2, trolley);
|
}
|
}
|
|
// Current cycle
|
{
|
RTZ32_Realtime_Cycle_Distribution cycle1 = null;
|
RTZ32_Realtime_Cycle_Distribution cycle2 = null;
|
if (realtime.cycles.size() >= 2) cycle1 = realtime.cycles.get(realtime.cycles.size()-2);
|
cycle2 = realtime.cycles.get(realtime.cycles.size()-1);
|
|
paintTrolleyDetectors(g2, composite1, dx, dy, currenty, height1, cycle1, cycle2, trolley);
|
}
|
|
}
|
catch (Exception e)
|
{
|
}
|
|
// Paint border
|
|
// g2.setComposite(composite1);
|
// g2.setStroke(new BasicStroke(1.0f));
|
// g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
|
// g2.draw(new Rectangle2D.Double(0, centery - height1/2, getWidth(), height1));
|
|
}
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="Paint private">
|
|
|
|
|
private void paintSaturations(Graphics2D g2, AlphaComposite composite, double dx, double dy, double currenty, RTZ32_Realtime_Cycle_Distribution cycle1, RTZ32_Realtime_Cycle_Distribution cycle2)
|
{
|
g2.setComposite(composite);
|
|
if ((cycle1 != null) && (cycle2 != null))
|
{
|
if (cycle2.impulsesSaturations.size() == 0)
|
{
|
RTZ32_Realtime_Impulse_Saturation impulse1 = cycle1.impulsesSaturations.get(cycle1.impulsesSaturations.size()-1);
|
drawBar(0, currenty, currentCycle * dx, currenty + dy, impulse1.getColor(), g2);
|
}
|
else
|
{
|
RTZ32_Realtime_Impulse_Saturation impulse1 = cycle1.impulsesSaturations.get(cycle1.impulsesSaturations.size()-1);
|
RTZ32_Realtime_Impulse_Saturation impulse2 = cycle2.impulsesSaturations.get(0);
|
drawBar(0, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColor(), g2);
|
}
|
}
|
|
for (int j=0; j<(cycle2.impulsesSaturations.size()-1); j++)
|
{
|
RTZ32_Realtime_Impulse_Saturation impulse1 = cycle2.impulsesSaturations.get(j);
|
RTZ32_Realtime_Impulse_Saturation impulse2 = cycle2.impulsesSaturations.get(j+1);
|
drawBar(impulse1.cycleReal * dx, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColor(), g2);
|
}
|
|
RTZ32_Realtime_Impulse_Saturation impulse = cycle2.impulsesSaturations.get(cycle2.impulsesSaturations.size()-1);
|
drawBar(impulse.cycleReal * dx, currenty, currentCycle * dx, currenty + dy, impulse.getColor(), g2);
|
}
|
|
|
|
private void paintPhases(Graphics2D g2, AlphaComposite composite, double dx, double dy, double currenty, float height1, RTZ32_Realtime_Cycle_Distribution cycle1, RTZ32_Realtime_Cycle_Distribution cycle2)
|
{
|
FontMetrics metrics = g2.getFontMetrics();
|
|
g2.setComposite(composite);
|
|
if ((cycle1 != null) && (cycle2 != null))
|
{
|
if (cycle2.impulsesPhases.size() == 0)
|
{
|
RTZ32_Realtime_Impulse_Phase impulse1 = cycle1.impulsesPhases.get(cycle1.impulsesPhases.size()-1);
|
drawBar(0, currenty, currentCycle * dx, currenty + dy, impulse1.getColorPhase(), g2);
|
}
|
else
|
{
|
RTZ32_Realtime_Impulse_Phase impulse1 = cycle1.impulsesPhases.get(cycle1.impulsesPhases.size()-1);
|
RTZ32_Realtime_Impulse_Phase impulse2 = cycle2.impulsesPhases.get(0);
|
drawBar(0, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColorPhase(), g2);
|
}
|
}
|
|
for (int j=0; j<(cycle2.impulsesPhases.size()-1); j++)
|
{
|
RTZ32_Realtime_Impulse_Phase impulse1 = cycle2.impulsesPhases.get(j);
|
RTZ32_Realtime_Impulse_Phase impulse2 = cycle2.impulsesPhases.get(j+1);
|
drawBar(impulse1.cycleReal * dx, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColorPhase(), g2);
|
|
if (((composite == composite2) && (impulse1.cycleReal >= currentCycle)) || (composite == composite1))
|
{
|
g2.setColor(Color.black);
|
double x = impulse1.cycleReal * dx;
|
double y = currenty + ((height1 - metrics.getHeight()) / 2);
|
Diagram_Distribution_Realtime.drawLeftString(g2, impulse1.getNamePhase(), x, y);
|
|
// Cycle and cycle real
|
int h = getHeight()-150;
|
g2.setFont(font2);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse1.cycle, 2 + (float)(impulse1.cycleReal * dx), h);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse1.cycleReal, 2 + (float)(impulse1.cycleReal * dx), h+25);
|
|
// Vertical line
|
|
g2.setStroke(strokeImpulse);
|
g2.setColor(brown);
|
g2.draw(new Line2D.Double(impulse1.cycleReal * dx, currenty + (dy/2) + (height1), impulse1.cycleReal * dx, getHeight() + 640));
|
|
}
|
}
|
|
RTZ32_Realtime_Impulse_Phase impulse = cycle2.impulsesPhases.get(cycle2.impulsesPhases.size()-1);
|
drawBar(impulse.cycleReal * dx, currenty, currentCycle * dx, currenty + dy, impulse.getColorPhase(), g2);
|
|
if (((composite == composite2) && (impulse.cycleReal >= currentCycle)) || (composite == composite1))
|
{
|
g2.setColor(Color.black);
|
double x = impulse.cycleReal * dx;
|
double y = currenty + ((height1 - metrics.getHeight()) / 2);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse.getNamePhase(), x, y);
|
|
// Cycle and cycle real
|
|
g2.setFont(font2);
|
int h = getHeight()-150;
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse.cycle, 2 + (float)(impulse.cycleReal * dx), h);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse.cycleReal, 2 + (float)(impulse.cycleReal * dx), h+25);
|
|
// Vertical line
|
|
g2.setStroke(strokeImpulse);
|
g2.setColor(brown);
|
g2.draw(new Line2D.Double(impulse.cycleReal * dx, currenty + (dy/2) + (height1), impulse.cycleReal * dx, getHeight() + 640));
|
|
}
|
}
|
|
|
|
|
|
|
private void paintGroups(Graphics2D g2, AlphaComposite composite, int h, RTZ32_Realtime_Cycle_Distribution cycle1, RTZ32_Realtime_Cycle_Distribution cycle2)
|
{
|
RTZ32_Configuration configuration = rtz32.getDeviceConfiguration().rtz32;
|
|
int w = getWidth();
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(FlatGUI.lookDesign.getColor("button.color.foreground"));
|
int numberBars = configuration.getNumberValidGroups();
|
double dy = (double)((double)h / (double)numberBars);
|
double dx = (double)w / (double)duration;
|
double currenty = 0;
|
|
for (int i=0; i<numberBars; i++)
|
{
|
// Draw one bar group
|
{
|
g2.setComposite(composite);
|
|
if ((cycle1 != null) && (cycle2 != null))
|
{
|
if (cycle2.impulsesGroups.size() == 0)
|
{
|
RTZ32_Realtime_Impulse_Groups impulse1 = cycle1.impulsesGroups.get(cycle1.impulsesGroups.size()-1);
|
drawBar(0, currenty, currentCycle * dx, currenty + dy, impulse1.colors[i], g2);
|
}
|
else
|
{
|
RTZ32_Realtime_Impulse_Groups impulse1 = cycle1.impulsesGroups.get(cycle1.impulsesGroups.size()-1);
|
RTZ32_Realtime_Impulse_Groups impulse2 = cycle2.impulsesGroups.get(0);
|
drawBar(0, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.colors[i], g2);
|
}
|
}
|
|
for (int j=0; j<(cycle2.impulsesGroups.size()-1); j++)
|
{
|
RTZ32_Realtime_Impulse_Groups impulse1 = cycle2.impulsesGroups.get(j);
|
RTZ32_Realtime_Impulse_Groups impulse2 = cycle2.impulsesGroups.get(j+1);
|
drawBar(impulse1.cycleReal * dx, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.colors[i], g2);
|
}
|
|
RTZ32_Realtime_Impulse_Groups impulse = cycle2.impulsesGroups.get(cycle2.impulsesGroups.size()-1);
|
drawBar(impulse.cycleReal * dx, currenty, currentCycle * dx, currenty + dy, impulse.colors[i], g2);
|
}
|
|
currenty = currenty + dy;
|
}
|
|
}
|
|
|
|
|
private void paintACR(Graphics2D g2, AlphaComposite composite, double dx, double dy, double currenty, float height1, RTZ32_Realtime_Cycle_Distribution cycle1, RTZ32_Realtime_Cycle_Distribution cycle2)
|
{
|
FontMetrics metrics = g2.getFontMetrics();
|
|
g2.setComposite(composite);
|
|
if ((cycle1 != null) && (cycle2 != null))
|
{
|
if (cycle2.impulsesPhases.size() == 0)
|
{
|
RTZ32_Realtime_Impulse_Phase impulse1 = cycle1.impulsesPhases.get(cycle1.impulsesPhases.size()-1);
|
drawBar(0, currenty, currentCycle * dx, currenty + dy, impulse1.getColorACR(), g2);
|
}
|
else
|
{
|
RTZ32_Realtime_Impulse_Phase impulse1 = cycle1.impulsesPhases.get(cycle1.impulsesPhases.size()-1);
|
RTZ32_Realtime_Impulse_Phase impulse2 = cycle2.impulsesPhases.get(0);
|
drawBar(0, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColorACR(), g2);
|
}
|
}
|
|
for (int j=0; j<(cycle2.impulsesPhases.size()-1); j++)
|
{
|
RTZ32_Realtime_Impulse_Phase impulse1 = cycle2.impulsesPhases.get(j);
|
RTZ32_Realtime_Impulse_Phase impulse2 = cycle2.impulsesPhases.get(j+1);
|
drawBar(impulse1.cycleReal * dx, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColorACR(), g2);
|
|
if (((composite == composite2) && (impulse1.cycleReal >= currentCycle)) || (composite == composite1))
|
{
|
g2.setColor(Color.black);
|
double x = impulse1.cycleReal * dx;
|
double y = currenty + ((height1 - metrics.getHeight()) / 2);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse1.getNameACR(), x, y);
|
}
|
}
|
|
RTZ32_Realtime_Impulse_Phase impulse = cycle2.impulsesPhases.get(cycle2.impulsesPhases.size()-1);
|
drawBar(impulse.cycleReal * dx, currenty, currentCycle * dx, currenty + dy, impulse.getColorACR(), g2);
|
|
if (((composite == composite2) && (impulse.cycleReal >= currentCycle)) || (composite == composite1))
|
{
|
g2.setColor(Color.black);
|
double x = impulse.cycleReal * dx;
|
double y = currenty + ((height1 - metrics.getHeight()) / 2);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse.getNameACR(), x, y);
|
}
|
}
|
|
|
boolean a = true;
|
|
private void paintTrolleyDetectors(Graphics2D g2, AlphaComposite composite, double dx, double dy, double currenty, float height1, RTZ32_Realtime_Cycle_Distribution cycle1, RTZ32_Realtime_Cycle_Distribution cycle2, int trolley)
|
{
|
|
if (a && trolley==1)
|
{
|
RTZ32_Realtime realtime = rtz32.getDeviceRealtime().rtz32;
|
{
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse = new RTZ32_Realtime_Impulse_Trolley_Detector();
|
impulse.cycleReal = 10;
|
impulse.type = RTZ32_Realtime_Impulse_Trolley_Detector.TYPE_DA;
|
realtime.addImpulse(1, impulse);
|
}
|
{
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse = new RTZ32_Realtime_Impulse_Trolley_Detector();
|
impulse.cycleReal = 22;
|
impulse.type = RTZ32_Realtime_Impulse_Trolley_Detector.TYPE_DC;
|
realtime.addImpulse(1, impulse);
|
}
|
a=false;
|
}
|
FontMetrics metrics = g2.getFontMetrics();
|
|
g2.setComposite(composite);
|
|
List<RTZ32_Realtime_Impulse_Trolley_Detector> cycle1_impulsesTrolleyDetectors = null;
|
List<RTZ32_Realtime_Impulse_Trolley_Detector> cycle2_impulsesTrolleyDetectors = null;
|
|
if (cycle1 != null)
|
{
|
switch (trolley)
|
{
|
case 1 : cycle1_impulsesTrolleyDetectors = cycle1.impulsesTrolleyDetectors1; break;
|
case 2 : cycle1_impulsesTrolleyDetectors = cycle1.impulsesTrolleyDetectors2; break;
|
case 3 : cycle1_impulsesTrolleyDetectors = cycle1.impulsesTrolleyDetectors3; break;
|
case 4 : cycle1_impulsesTrolleyDetectors = cycle1.impulsesTrolleyDetectors4; break;
|
}
|
}
|
|
if (cycle2 != null)
|
{
|
switch (trolley)
|
{
|
case 1 : cycle2_impulsesTrolleyDetectors = cycle2.impulsesTrolleyDetectors1; break;
|
case 2 : cycle2_impulsesTrolleyDetectors = cycle2.impulsesTrolleyDetectors2; break;
|
case 3 : cycle2_impulsesTrolleyDetectors = cycle2.impulsesTrolleyDetectors3; break;
|
case 4 : cycle2_impulsesTrolleyDetectors = cycle2.impulsesTrolleyDetectors4; break;
|
}
|
}
|
|
|
|
|
if ((cycle1 != null) && (cycle2 != null))
|
{
|
if (cycle2_impulsesTrolleyDetectors.size() == 0)
|
{
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse1 = cycle1_impulsesTrolleyDetectors.get(cycle1_impulsesTrolleyDetectors.size()-1);
|
drawBar(0, currenty, currentCycle * dx, currenty + dy, impulse1.getColor(), g2);
|
}
|
else
|
{
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse1 = cycle1_impulsesTrolleyDetectors.get(cycle1_impulsesTrolleyDetectors.size()-1);
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse2 = cycle2_impulsesTrolleyDetectors.get(0);
|
drawBar(0, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColor(), g2);
|
}
|
}
|
|
|
|
for (int j=0; j<(cycle2_impulsesTrolleyDetectors.size()-1); j++)
|
{
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse1 = cycle2_impulsesTrolleyDetectors.get(j);
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse2 = cycle2_impulsesTrolleyDetectors.get(j+1);
|
|
if (((composite == composite2) && (impulse1.cycleReal >= currentCycle)) || (composite == composite1))
|
{
|
drawBar(impulse1.cycleReal * dx, currenty, impulse2.cycleReal * dx, currenty + dy, impulse1.getColor(), g2);
|
|
g2.setColor(Color.black);
|
double x = impulse1.cycleReal * dx;
|
double y = currenty + ((height1 - metrics.getHeight()) / 2);
|
|
if (impulse1.type != RTZ32_Realtime_Impulse_Trolley_Detector.TYPE_DC)
|
{
|
g2.setColor(Color.black);
|
Diagram_Distribution_Realtime.drawRightString(g2, impulse1.getName(), x, y);
|
Diagram_Distribution_Realtime.drawRightString(g2, "" + impulse1.cycleReal, x, y + height1*2);
|
}
|
else
|
{
|
g2.setColor(Color.red);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse1.cycleReal, x, y);
|
g2.setColor(Color.black);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse1.cycleReal, x, y + height1*2);
|
}
|
}
|
}
|
|
RTZ32_Realtime_Impulse_Trolley_Detector impulse = cycle2_impulsesTrolleyDetectors.get(cycle2_impulsesTrolleyDetectors.size()-1);
|
if (((composite == composite2) && (impulse.cycleReal >= currentCycle)) || (composite == composite1))
|
{
|
drawBar(impulse.cycleReal * dx, currenty, currentCycle * dx, currenty + dy, impulse.getColor(), g2);
|
|
double x = impulse.cycleReal * dx;
|
double y = currenty + ((height1 - metrics.getHeight()) / 2);
|
if (impulse.type != RTZ32_Realtime_Impulse_Trolley_Detector.TYPE_DC)
|
{
|
g2.setColor(Color.black);
|
Diagram_Distribution_Realtime.drawRightString(g2, impulse.getName(), x, y);
|
Diagram_Distribution_Realtime.drawRightString(g2, "" + impulse.cycleReal, x, y + height1*2);
|
}
|
else
|
{
|
g2.setColor(Color.red);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse.cycleReal, x, y);
|
g2.setColor(Color.black);
|
Diagram_Distribution_Realtime.drawLeftString(g2, "" + impulse.cycleReal, x, y + height1*2);
|
}
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void drawBar(double x1, double y1, double x2, double y2, int color, Graphics2D g2)
|
{
|
try
|
{
|
if (x2 < x1) return;
|
|
double centery = y1 + ((y2 - y1) /2);
|
float height1 = (float)Math.min(18, (y2-y1)/2);
|
float height2 = (float)Math.min(9, (y2-y1)/4);
|
|
Color colorA = null;
|
Color colorB = null;
|
Stroke strokeA = null;
|
Stroke strokeB = null;
|
|
Stroke strokeNone1 = new BasicStroke(height1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
|
Stroke strokeFast1 = new BasicStroke(height1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, dashFast, 0.0f);
|
Stroke strokeSlow1 = new BasicStroke(height1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, dashSlow, 0.0f);
|
|
Stroke strokeNone2 = new BasicStroke(height2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
|
Stroke strokeFast2 = new BasicStroke(height2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, dashFast, 0.0f);
|
Stroke strokeSlow2 = new BasicStroke(height2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, dashSlow, 0.0f);
|
|
switch (color)
|
{
|
case RTZ32_Constants_Colors.COLOR_OFF : colorA = Color.lightGray; strokeA = strokeNone1; break;
|
case RTZ32_Constants_Colors.COLOR_V : colorA = Color.green; strokeA = strokeNone1; break;
|
case RTZ32_Constants_Colors.COLOR_A : colorA = Color.yellow; strokeA = strokeNone1; break;
|
case RTZ32_Constants_Colors.COLOR_R : colorA = Color.red; strokeA = strokeNone1; break;
|
case RTZ32_Constants_Colors.COLOR_VI : colorA = Color.green; strokeA = strokeFast1; break;
|
//case RTZ32_Constants_Colors.COLOR_AI : colorA = Color.yellow; strokeA = strokeSlow1; break;
|
case RTZ32_Constants_Colors.COLOR_AI : colorA = Color.yellow; strokeA = strokeNone2; colorB = Color.white; strokeB = strokeNone2; break;
|
case RTZ32_Constants_Colors.COLOR_RI : colorA = Color.red; strokeA = strokeSlow1; break;
|
|
case RTZ32_Constants_Colors.COLOR_ViAI : colorA = Color.green; strokeA = strokeFast2; colorB = Color.yellow; strokeB = strokeSlow2; break;
|
case RTZ32_Constants_Colors.COLOR_RiAI : colorA = Color.red; strokeA = strokeFast2; colorB = Color.yellow; strokeB = strokeSlow2; break;
|
case RTZ32_Constants_Colors.COLOR_VAI : colorA = Color.green; strokeA = strokeNone2; colorB = Color.yellow; strokeB = strokeSlow2; break;
|
case RTZ32_Constants_Colors.COLOR_RAI : colorA = Color.red; strokeA = strokeNone2; colorB = Color.blue; strokeB = strokeSlow2; break;
|
case RTZ32_Constants_Colors.COLOR_AIVI : colorA = Color.yellow; strokeA = strokeSlow2; colorB = Color.green; strokeB = strokeSlow2; break;
|
case RTZ32_Constants_Colors.COLOR_AIRI : colorA = Color.yellow; strokeA = strokeSlow2; colorB = Color.red; strokeB = strokeSlow2; break;
|
case RTZ32_Constants_Colors.COLOR_RiVi : colorA = Color.red; strokeA = strokeFast2; colorB = Color.green; strokeB = strokeFast2; break;
|
case RTZ32_Constants_Colors.COLOR_AR : colorA = Color.red; strokeA = strokeNone2; colorB = Color.blue; strokeB = strokeNone2; break;
|
case RTZ32_Constants_Colors.COLOR_Vi : colorA = Color.green; strokeA = strokeFast1; break;
|
case RTZ32_Constants_Colors.COLOR_VA : colorA = Color.green; strokeA = strokeNone2; colorB = Color.yellow; strokeB = strokeNone2; break;
|
case RTZ32_Constants_Colors.COLOR_VR : colorA = Color.green; strokeA = strokeNone2; colorB = Color.red; strokeB = strokeNone2; break;
|
case RTZ32_Constants_Colors.COLOR_VAR : break;
|
|
case RTZ32_Constants_Colors.COLOR_Vd : colorA = Color.green.darker(); strokeA = strokeNone1; break;
|
case RTZ32_Constants_Colors.COLOR_VId : colorA = Color.green.darker(); strokeA = strokeSlow1; break;
|
case RTZ32_Constants_Colors.COLOR_Vid : colorA = Color.green.darker(); strokeA = strokeFast1; break;
|
case RTZ32_Constants_Colors.Rd : break;
|
|
case RTZ32_Constants_Colors.COLOR_AIe : colorA = Color.yellow.darker(); strokeA = strokeSlow1; break;
|
case RTZ32_Constants_Colors.COLOR_Ae : colorA = Color.yellow.darker(); strokeA = strokeNone1; break;
|
case RTZ32_Constants_Colors.COLOR_Re : colorA = Color.red.darker(); strokeA = strokeNone1; break;
|
case RTZ32_Constants_Colors.COLOR_OFFe : colorA = Color.darkGray; strokeA = strokeNone1; break;
|
|
default: colorA = Color.magenta; strokeA = strokeNone1; break;
|
}
|
|
|
if ((strokeA == strokeSlow1) || (strokeA == strokeFast1) || (strokeB == strokeSlow1) || (strokeB == strokeFast1) ||
|
(strokeA == strokeSlow2) || (strokeA == strokeFast2) || (strokeB == strokeSlow2) || (strokeB == strokeFast2))
|
{
|
g2.setStroke(strokeNone1);
|
g2.setColor(Color.white);
|
g2.fill(new Rectangle2D.Double(x1, centery-(height1/2), x2-x1, height1));
|
}
|
|
if ((colorA != null) && (colorB == null))
|
{
|
g2.setColor(colorA);
|
g2.setStroke(strokeA);
|
g2.draw(new Line2D.Double(x1, centery, x2, centery));
|
}
|
else if ((colorA != null) && (colorB != null))
|
{
|
g2.setColor(colorA);
|
g2.setStroke(strokeA);
|
g2.draw(new Line2D.Double(x1, centery - height2/2, x2, centery - height2/2));
|
|
g2.setColor(colorB);
|
g2.setStroke(strokeB);
|
g2.draw(new Line2D.Double(x1, centery + height2/2, x2, centery + height2/2));
|
}
|
}
|
catch (Exception exception)
|
{
|
}
|
}
|
|
|
private void drawBar(double x1, double y1, double x2, double y2, Color color, Graphics2D g2)
|
{
|
try
|
{
|
if (x2 < x1) return;
|
if (color == null) return;
|
|
g2.setColor(color);
|
double centery = y1 + ((y2 - y1) /2);
|
float height1 = (float)Math.min(7.5, (y2-y1)/2);
|
Stroke stroke1 = new BasicStroke(height1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
|
g2.setStroke(stroke1);
|
g2.draw(new Line2D.Double(x1, centery, x2, centery));
|
}
|
catch (Exception exception)
|
{
|
}
|
}
|
|
|
|
// </editor-fold>
|
|
|
|
|
}
|