package art.client.GUI.components.devices.window.colors.rtz32.tables.incompatibilities;
|
|
import art.library.gui.flat.FlatButton;
|
import art.library.gui.flat.FlatPanel;
|
import art.library.gui.flat.FlatTableInput;
|
import art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerConfiguration;
|
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Group;
|
import java.awt.BasicStroke;
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Dimension;
|
import java.awt.Font;
|
import java.awt.FontMetrics;
|
import java.awt.Graphics;
|
import java.awt.Graphics2D;
|
import java.awt.RenderingHints;
|
import java.awt.geom.Line2D;
|
import java.awt.geom.Rectangle2D;
|
|
|
|
public class DiagramIncompatibilities extends FlatPanel
|
{
|
|
private RTZ32_ControllerConfiguration configuration = null;
|
private FlatTableInput table1 = null;
|
private Color color = new FlatPanel().getLook().background;
|
|
public DiagramIncompatibilities (RTZ32_ControllerConfiguration configuration)
|
{
|
reload(configuration);
|
}
|
|
|
public void reload(RTZ32_ControllerConfiguration configuration)
|
{
|
this.configuration = configuration;
|
this.removeAll();
|
this.setLayout(new BorderLayout());
|
this.add(new DiagramColumns(), BorderLayout.NORTH);
|
this.add(new DiagramRows(), BorderLayout.WEST);
|
this.add(new Diagram(), BorderLayout.CENTER);
|
|
}
|
|
|
|
|
|
private class DiagramColumns extends FlatButton
|
{
|
private DiagramColumns()
|
{
|
setPreferredSize(new Dimension(0,72));
|
}
|
|
|
public void paint (Graphics g)
|
{
|
try
|
{
|
Graphics2D g2 = (Graphics2D)g;
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
|
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
|
int w = getWidth();
|
int h = getHeight();
|
g2.setBackground(color);
|
g2.clearRect(0, 0, w, h);
|
Font font = new FlatButton().getLook().font;
|
g2.setColor(new FlatButton().getLook().colorForeground);
|
|
double dx = (double)(w - 72) / ((double)configuration.rtz32.groups.length);
|
dx = Math.min(72, dx);
|
|
for (int i=0; i<configuration.rtz32.groups.length; i++)
|
{
|
RTZ32_Configuration_Group group = configuration.rtz32.groups[i];
|
String text = "" + group.number;
|
drawCenteredString(g2, "" + text, new Rectangle2D.Double((dx * i) + 72, 0, dx, h), font);
|
}
|
|
g2.setColor(new FlatButton().getLook().colorBackground.darker());
|
|
for (int i=0; i<=configuration.rtz32.groups.length; i++)
|
{
|
g2.draw(new Line2D.Double((dx * i) + 72, 0, (dx * i) + 72, h));
|
}
|
}
|
catch (Exception e)
|
{
|
}
|
}
|
}
|
|
|
|
|
|
private class DiagramRows extends FlatButton
|
{
|
private DiagramRows()
|
{
|
setPreferredSize(new Dimension(72,0));
|
}
|
|
|
public void paint (Graphics g)
|
{
|
try
|
{
|
Graphics2D g2 = (Graphics2D)g;
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
|
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
|
int w = getWidth();
|
int h = getHeight();
|
g2.setBackground(color);
|
g2.clearRect(0, 0, w, h);
|
Font font = new FlatButton().getLook().font;
|
g2.setColor(new FlatButton().getLook().colorForeground);
|
|
double dy = (double)h / (double)configuration.rtz32.groups.length;
|
dy = Math.min(72, dy);
|
|
for (int i=0; i<configuration.rtz32.groups.length; i++)
|
{
|
RTZ32_Configuration_Group group = configuration.rtz32.groups[i];
|
String text = "" + group.number;
|
drawCenteredString(g2, text, new Rectangle2D.Double(0, dy * i, w, dy), font);
|
}
|
|
g2.setColor(new FlatButton().getLook().colorBackground.darker());
|
|
for (int i=0; i<=configuration.rtz32.groups.length; i++)
|
{
|
g2.draw(new Line2D.Double(0, dy * i, w, dy * i));
|
}
|
|
}
|
catch (Exception e)
|
{
|
}
|
}
|
}
|
|
|
|
|
|
private class Diagram extends FlatButton
|
{
|
public void paint (Graphics g)
|
{
|
try
|
{
|
Graphics2D g2 = (Graphics2D)g;
|
int w = getWidth();
|
int h = getHeight();
|
g2.setBackground(Color.white);
|
|
double dx = (double)w / ((double)configuration.rtz32.groups.length);
|
double dy = (double)h / (double)configuration.rtz32.groups.length;
|
|
dx = Math.min(72, dx);
|
dy = Math.min(36, dy);
|
g2.clearRect(0, 0, (int)(dx * configuration.rtz32.groups.length), (int)(dy * configuration.rtz32.groups.length));
|
|
|
g2.setColor(new FlatButton().getLook().colorBackground);
|
|
for (int i=0; i<configuration.rtz32.groups.length; i++)
|
{
|
g2.fill(new Rectangle2D.Double(dx * i, dy * i, dx, dy));
|
}
|
|
|
g2.setColor(Color.red);
|
|
for (int i=0; i<configuration.rtz32.groups.length; i++)
|
{
|
for (int j=0; j<configuration.rtz32.groups[i].incompatibilities.length; j++)
|
{
|
if (configuration.rtz32.groups[i].incompatibilities[j] == true)
|
{
|
g2.fill(new Rectangle2D.Double(dx * i, dy * j, dx, dy));
|
}
|
}
|
}
|
|
|
g2.setColor(new FlatButton().getLook().colorBackground.darker());
|
|
for (int i=0; i<=configuration.rtz32.groups.length; i++)
|
{
|
g2.draw(new Line2D.Double(dx * i, 0, dx * i, dy * configuration.rtz32.groups.length));
|
g2.draw(new Line2D.Double(0, dy * i, dx * configuration.rtz32.groups.length, dy * i));
|
}
|
|
g2.setStroke(new BasicStroke(1.0f));
|
g2.setColor(new FlatButton().getLook().colorBackground.darker());
|
g2.draw(new Rectangle2D.Double(0,0,dx * configuration.rtz32.groups.length, dy * configuration.rtz32.groups.length));
|
|
}
|
catch (Exception e)
|
{
|
}
|
}
|
}
|
|
|
|
|
private void drawCenteredString(Graphics2D g2, String text, Rectangle2D rect, Font font)
|
{
|
FontMetrics metrics = g2.getFontMetrics(font);
|
double x = rect.getX() + (rect.getWidth() - metrics.stringWidth(text)) / 2;
|
double y = rect.getY() + ((rect.getHeight() - metrics.getHeight()) / 2) + metrics.getAscent();
|
g2.setFont(font);
|
g2.drawString(text, (float)x, (float)y);
|
}
|
|
|
|
}
|