package art.servers.colorsserver.M.gui;
|
|
import art.library.model.devices.colors.controller.M.M_ControllerConfiguration;
|
import art.library.model.devices.colors.controller.M.M_SubcontrollerConfiguration;
|
import art.library.model.devices.colors.controller.M.configuration.ALUVISA_Plan;
|
import art.servers.colorsserver.M.gui.diagrams.DiagramALUVISAPhases;
|
import art.servers.colorsserver.M.gui.diagrams.DiagramConflicts;
|
import art.servers.colorsserver.M.gui.diagrams.DiagramPlan;
|
import art.servers.colorsserver.M.gui.diagrams.DiagramTimetable;
|
import java.awt.Dimension;
|
import java.awt.image.BufferedImage;
|
import java.util.List;
|
import javax.swing.JComponent;
|
import javax.swing.JWindow;
|
|
public class Diagrams
|
{
|
|
public static BufferedImage getDiagramPlan(int width, int height, M_ControllerConfiguration m_controller, M_SubcontrollerConfiguration m_subcontroller, ALUVISA_Plan plan, boolean isStructure)
|
{
|
DiagramPlan diagram = new DiagramPlan(m_controller, m_subcontroller, plan, isStructure);
|
diagram.setSize(new Dimension(width, height));
|
BufferedImage image = new BufferedImage(diagram.getWidth(),diagram.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
diagram.paint(image.getGraphics());
|
return image;
|
}
|
|
|
public static BufferedImage getDiagramALUVISAPhases(int width, int height, M_ControllerConfiguration m_controller, M_SubcontrollerConfiguration m_subcontroller, ALUVISA_Plan plan, int pathnumber)
|
{
|
List<ALUVISA_Plan> lpath = plan.getPaths();
|
DiagramALUVISAPhases diagram = new DiagramALUVISAPhases(m_controller, m_subcontroller, plan, lpath.get(pathnumber).getPathSequence());
|
return getImage(diagram, width, height, 0);
|
}
|
|
|
|
public static BufferedImage getDiagramConflicts(int width, int height, M_ControllerConfiguration m_controller)
|
{
|
DiagramConflicts diagram = new DiagramConflicts(m_controller);
|
return getImage(diagram, width, height, 0);
|
}
|
|
|
|
public static BufferedImage getDiagramTimetable(int width, int height, M_ControllerConfiguration m_controller, M_SubcontrollerConfiguration m_subcontroller)
|
{
|
DiagramTimetable diagram = new DiagramTimetable(m_controller, m_subcontroller);
|
return getImage(diagram, width, height, 1000);
|
}
|
|
|
|
|
private static BufferedImage getImage(JComponent component, int width, int height, int sleep)
|
{
|
JWindow window = new JWindow();
|
|
try
|
{
|
window.setContentPane(component);
|
window.setSize(new Dimension(width,height));
|
window.setLocation(-99999,-99999);
|
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
window.setVisible(true);
|
if (sleep > 0)
|
{
|
try
|
{
|
Thread.sleep(sleep);
|
}
|
catch (Exception e)
|
{
|
}
|
}
|
component.paint(image.getGraphics());
|
return image;
|
}
|
finally
|
{
|
window.setVisible(false);
|
window.dispose();
|
}
|
}
|
}
|