Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.47 KB | None | 0 0
  1. import javax.swing.*;
  2. import javax.swing.table.AbstractTableModel;
  3.  
  4. import org.cloudbus.cloudsim.Cloudlet;
  5. import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
  6. import org.cloudbus.cloudsim.DatacenterCharacteristics;
  7. import org.cloudbus.cloudsim.HarddriveStorage;
  8. import org.cloudbus.cloudsim.Host;
  9. import org.cloudbus.cloudsim.Log;
  10. import org.cloudbus.cloudsim.Pe;
  11. import org.cloudbus.cloudsim.Storage;
  12. import org.cloudbus.cloudsim.VmAllocationPolicySimple;
  13. import org.cloudbus.cloudsim.VmSchedulerTimeShared;
  14. import org.cloudbus.cloudsim.core.CloudSim;
  15. import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
  16. import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
  17. import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
  18. import org.workflowsim.CondorVM;
  19. import org.workflowsim.Job;
  20. import org.workflowsim.WorkflowDatacenter;
  21. import org.workflowsim.WorkflowEngine;
  22. import org.workflowsim.WorkflowPlanner;
  23. import org.workflowsim.utils.ClusteringParameters;
  24. import org.workflowsim.utils.OverheadParameters;
  25. import org.workflowsim.utils.Parameters;
  26. import org.workflowsim.utils.ReplicaCatalog;
  27.  
  28. import javax.swing.filechooser.*;
  29.  
  30.  
  31.  
  32.  
  33. import java.awt.*;
  34. import java.awt.event.*;
  35. import java.awt.image.BufferedImage;
  36. import java.io.BufferedReader;
  37. import java.io.BufferedWriter;
  38. import java.io.File;
  39. import java.io.FileInputStream;
  40. import java.io.FileWriter;
  41. import java.io.IOException;
  42. import java.io.InputStream;
  43. import java.io.InputStreamReader;
  44. import java.io.PrintWriter;
  45. import java.text.DecimalFormat;
  46. import java.util.ArrayList;
  47. import java.util.Calendar;
  48. import java.util.LinkedList;
  49. import java.util.List;
  50.  
  51. public class test extends WindowAdapter
  52.                         implements ActionListener {
  53.     private Point lastLocation = null;
  54.     private int maxX = 500;
  55.     private int maxY = 500;
  56.     private boolean DEBUG = false;
  57.     static private final String newline = "\n";
  58.  
  59.     private static JButton defaultButton = null;
  60.  
  61.     protected static String VM = "";
  62.     protected static int vm1 = 10;
  63.     protected final static String LF_DECORATIONS = "laf_dec";
  64.     protected final static String WS_DECORATIONS = "ws_dec";
  65.     protected final static String CREATE_WINDOW = "new_win";
  66.     protected final static String TEST_FILE = "test";
  67.     protected final static String NASTAV = "test";
  68.     protected final static String ROUND_ROBIN = "round_robin";
  69.     protected final static String MAX_MIN = "max_min";
  70.     protected final static String MIN_MIN = "min_min";
  71.    
  72.     protected static String CESTA = "E:/Documents and Settings/zais/Dokumenty/WorkflowSim-1.0-master/config/dax/Montage_100.xml";
  73.  
  74.     protected boolean roundrobin = true;
  75.     protected boolean maxmin = false;
  76.     protected boolean minmin = false;
  77.    
  78.     JFileChooser fc;
  79.     JTextArea log;
  80.     JTextField vm;
  81.  
  82.    
  83.     //static JTextField textField;
  84.  
  85.     public test() {
  86.         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  87.         maxX = screenSize.width - 50;
  88.         maxY = screenSize.height - 50;
  89.     }
  90.    
  91.     // FUNKCIA KTORA SA VYKONA PO KLIKNUTI
  92.     public void simulate() throws IOException {    
  93.         if(roundrobin==true)
  94.         {
  95.             RoundRobin();
  96.             vysledok1();
  97.         }
  98.         if(maxmin==true)
  99.         {
  100.             maxmin();
  101.             vysledok1();
  102.         }
  103.         if(minmin==true)
  104.         {
  105.             minmin();
  106.             vysledok1();
  107.         }
  108.     }
  109.    
  110.     // RoundRobin
  111.     private void RoundRobin() {
  112.         try {
  113.             // Prvý krok. Inicializácia workflow.
  114.             int vmNum = 10;//počet Virtuálnych strojov
  115.            
  116.             String daxPath = CESTA;
  117.  
  118.             File daxFile = new File(daxPath);
  119.             if (!daxFile.exists()) {
  120.                 Log.printLine("Nastavte adresu k súboru, ktorý obsahuje testovacie úlohy.");
  121.                 return;
  122.             }
  123.            
  124.             Parameters.SchedulingAlgorithm sch_method = Parameters.SchedulingAlgorithm.ROUNDROBIN;    
  125.             Parameters.PlanningAlgorithm pln_method = Parameters.PlanningAlgorithm.INVALID;
  126.             ReplicaCatalog.FileSystem file_system = ReplicaCatalog.FileSystem.LOCAL;
  127.            
  128.             OverheadParameters op = new OverheadParameters(0, null, null, null, null, 0);
  129.             ClusteringParameters.ClusteringMethod method = ClusteringParameters.ClusteringMethod.NONE;
  130.             ClusteringParameters cp = new ClusteringParameters(0, 0, method, null);
  131.  
  132.             Parameters.init(vmNum, daxPath, null,
  133.                     null, op, cp, sch_method, pln_method,
  134.                     null, 0);
  135.             ReplicaCatalog.init(file_system);
  136.  
  137.             int num_user = 1;  
  138.             Calendar calendar = Calendar.getInstance();
  139.             boolean trace_flag = false;
  140.  
  141.             CloudSim.init(num_user, calendar, trace_flag);
  142.             WorkflowDatacenter datacenter0 = createDatacenter("Datacenter_0");
  143.             WorkflowPlanner wfPlanner = new WorkflowPlanner("planner_0", 1);
  144.             WorkflowEngine wfEngine = wfPlanner.getWorkflowEngine();
  145.             List<CondorVM> vmlist0 = createVM(wfEngine.getSchedulerId(0), Parameters.getVmNum());
  146.             wfEngine.submitVmList(vmlist0, 0);
  147.             wfEngine.bindSchedulerDatacenter(datacenter0.getId(), 0);
  148.  
  149.             CloudSim.startSimulation();
  150.             List<Job> outputList0 = wfEngine.getJobsReceivedList();
  151.             CloudSim.stopSimulation();
  152.             printJobList(outputList0);
  153.         } catch (Exception e) {
  154.             Log.printLine("Simulácia skončila nečakanou chybou.");
  155.         }
  156.        
  157.        
  158.     }
  159.    
  160.     //MinMin
  161.     private void minmin() {
  162.         try {
  163.             // Prvý krok. Inicializácia workflow.
  164.             int vmNum = 10;//počet Virtuálnych strojov
  165.            
  166.             String daxPath = CESTA;
  167.  
  168.             File daxFile = new File(daxPath);
  169.             if (!daxFile.exists()) {
  170.                 Log.printLine("Nastavte adresu k súboru, ktorý obsahuje testovacie úlohy.");
  171.                 return;
  172.             }
  173.             Parameters.SchedulingAlgorithm sch_method = Parameters.SchedulingAlgorithm.MINMIN;    
  174.             Parameters.PlanningAlgorithm pln_method = Parameters.PlanningAlgorithm.INVALID;
  175.             ReplicaCatalog.FileSystem file_system = ReplicaCatalog.FileSystem.LOCAL;
  176.  
  177.             OverheadParameters op = new OverheadParameters(0, null, null, null, null, 0);
  178.             ClusteringParameters.ClusteringMethod method = ClusteringParameters.ClusteringMethod.NONE;
  179.             ClusteringParameters cp = new ClusteringParameters(0, 0, method, null);
  180.  
  181.             Parameters.init(vmNum, daxPath, null,
  182.                     null, op, cp, sch_method, pln_method,
  183.                     null, 0);
  184.             ReplicaCatalog.init(file_system);
  185.  
  186.             int num_user = 1;
  187.             Calendar calendar = Calendar.getInstance();
  188.             boolean trace_flag = false;
  189.  
  190.             CloudSim.init(num_user, calendar, trace_flag);
  191.             WorkflowDatacenter datacenter0 = createDatacenter("Datacenter_0");
  192.             WorkflowPlanner wfPlanner = new WorkflowPlanner("planner_0", 1);
  193.             WorkflowEngine wfEngine = wfPlanner.getWorkflowEngine();
  194.             List<CondorVM> vmlist0 = createVM(wfEngine.getSchedulerId(0), Parameters.getVmNum());
  195.             wfEngine.submitVmList(vmlist0, 0);
  196.             wfEngine.bindSchedulerDatacenter(datacenter0.getId(), 0);
  197.  
  198.             CloudSim.startSimulation();
  199.             List<Job> outputList0 = wfEngine.getJobsReceivedList();
  200.             CloudSim.stopSimulation();
  201.             printJobList(outputList0);
  202.         } catch (Exception e) {
  203.             Log.printLine("Simulácia skončila nečakanou chybou.");
  204.         }
  205.        
  206.        
  207.     }
  208.    
  209.     //MaxMin
  210.     private void maxmin() {
  211.         try {
  212.             // Prvý krok. Inicializácia workflow.
  213.             int vmNum = 10;//počet Virtuálnych strojov
  214.            
  215.             String daxPath = CESTA;
  216.  
  217.             File daxFile = new File(daxPath);
  218.             if (!daxFile.exists()) {
  219.                 Log.printLine("Nastavte adresu k súboru, ktorý obsahuje testovacie úlohy.");
  220.                 return;
  221.             }
  222.                 Parameters.SchedulingAlgorithm sch_method = Parameters.SchedulingAlgorithm.MAXMIN;
  223.                
  224.             Parameters.PlanningAlgorithm pln_method = Parameters.PlanningAlgorithm.INVALID;
  225.             ReplicaCatalog.FileSystem file_system = ReplicaCatalog.FileSystem.LOCAL;
  226.  
  227.             OverheadParameters op = new OverheadParameters(0, null, null, null, null, 0);
  228.  
  229.             ClusteringParameters.ClusteringMethod method = ClusteringParameters.ClusteringMethod.NONE;
  230.             ClusteringParameters cp = new ClusteringParameters(0, 0, method, null);
  231.  
  232.             Parameters.init(vmNum, daxPath, null,
  233.                     null, op, cp, sch_method, pln_method,
  234.                     null, 0);
  235.             ReplicaCatalog.init(file_system);
  236.             int num_user = 1;
  237.             Calendar calendar = Calendar.getInstance();
  238.             boolean trace_flag = false;
  239.  
  240.             CloudSim.init(num_user, calendar, trace_flag);
  241.             WorkflowDatacenter datacenter0 = createDatacenter("Datacenter_0");
  242.             WorkflowPlanner wfPlanner = new WorkflowPlanner("planner_0", 1);
  243.             WorkflowEngine wfEngine = wfPlanner.getWorkflowEngine();
  244.             List<CondorVM> vmlist0 = createVM(wfEngine.getSchedulerId(0), Parameters.getVmNum());
  245.             wfEngine.submitVmList(vmlist0, 0);
  246.             wfEngine.bindSchedulerDatacenter(datacenter0.getId(), 0);
  247.             CloudSim.startSimulation();
  248.             List<Job> outputList0 = wfEngine.getJobsReceivedList();
  249.             CloudSim.stopSimulation();
  250.             printJobList(outputList0);
  251.         } catch (Exception e) {
  252.             Log.printLine("Simulácia skončila nečakanou chybou.");
  253.         }
  254.        
  255.        
  256.     }
  257.    
  258.     // VYPIS
  259.     protected static void printJobList(List<Job> list) throws IOException {
  260.  
  261.         int size = list.size();
  262.         Job job;
  263.        
  264.         String file ="E:/priebeh.txt";
  265.         FileWriter fw = new FileWriter (file);
  266.         BufferedWriter bw = new BufferedWriter (fw);
  267.         PrintWriter priebeh = new PrintWriter (bw);
  268.  
  269.         DecimalFormat dft = new DecimalFormat("###.##");
  270.         for (int i = 0; i < size; i++) {
  271.             job = list.get(i);
  272.              priebeh.println(job.getCloudletId());
  273.              
  274.             if (job.getCloudletStatus() == Cloudlet.SUCCESS) {
  275.                 priebeh.println("SPLNENA");
  276.                 priebeh.println(job.getResourceId());
  277.                 priebeh.println(job.getVmId());
  278.                 priebeh.println(dft.format(job.getActualCPUTime()));
  279.                 priebeh.println(dft.format(job.getExecStartTime()));
  280.                 priebeh.println(dft.format(job.getFinishTime()));
  281.                 priebeh.println(job.getDepth());
  282.            
  283.             } else if (job.getCloudletStatus() == Cloudlet.FAILED) {
  284.                 priebeh.println("NEUSPECH");
  285.                 priebeh.println(job.getResourceId());
  286.                 priebeh.println(job.getVmId());
  287.                 priebeh.println(dft.format(job.getActualCPUTime()));
  288.                 priebeh.println(dft.format(job.getExecStartTime()));
  289.                 priebeh.println(dft.format(job.getFinishTime()));
  290.                 priebeh.println(job.getDepth());
  291.             }
  292.           }
  293.                 priebeh.close();
  294.     }
  295.    
  296.     // VYTVORENIE DATACENTRA
  297.     protected static WorkflowDatacenter createDatacenter(String name) {
  298.  
  299.         List<Host> hostList = new ArrayList<>();
  300.  
  301.         for (int i = 1; i <= 20; i++) {
  302.             List<Pe> peList1 = new ArrayList<>();
  303.             int mips = 2000;
  304.             peList1.add(new Pe(0, new PeProvisionerSimple(mips)));
  305.             peList1.add(new Pe(1, new PeProvisionerSimple(mips)));
  306.  
  307.             int hostId = 0;
  308.             int ram = 2048;
  309.             long storage = 1000000;
  310.             int bw = 10000;
  311.             hostList.add(
  312.                     new Host(
  313.                             hostId,
  314.                             new RamProvisionerSimple(ram),
  315.                             new BwProvisionerSimple(bw),
  316.                             storage,
  317.                             peList1,
  318.                             new VmSchedulerTimeShared(peList1)));
  319.             hostId++;
  320.         }
  321.  
  322.         String arch = "x86";      
  323.         String os = "Linux";        
  324.         String vmm = "Xen";
  325.         double time_zone = 10.0;        
  326.         double cost = 3.0;            
  327.         double costPerMem = 0.05;      
  328.         double costPerStorage = 0.1;   
  329.         double costPerBw = 0.1;        
  330.         LinkedList<Storage> storageList = new LinkedList<>();  
  331.         WorkflowDatacenter datacenter = null;
  332.  
  333.         DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
  334.                 arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw);
  335.  
  336.         int maxTransferRate = 15;
  337.  
  338.         try {
  339.             HarddriveStorage s1 = new HarddriveStorage(name, 1e12);
  340.             s1.setMaxTransferRate(maxTransferRate);
  341.             storageList.add(s1);
  342.             datacenter = new WorkflowDatacenter(name, characteristics, new VmAllocationPolicySimple(hostList), storageList, 0);
  343.         } catch (Exception e) {
  344.             e.printStackTrace();
  345.         }
  346.         return datacenter;
  347.     }
  348.    
  349.     // VYTVORENIE VIRTUALNEHO STROJA
  350.     protected static List<CondorVM> createVM(int userId, int vms) {
  351.         LinkedList<CondorVM> list = new LinkedList<>();
  352.  
  353.         long size = 10000;
  354.         int ram = 512;
  355.         int mips = 1000;
  356.         long bw = 1000;
  357.         int pesNumber = 1;
  358.         String vmm = "Xen";
  359.  
  360.         CondorVM[] vm = new CondorVM[vms];
  361.         for (int i = 0; i < vms; i++) {
  362.             double ratio = 1.0;
  363.             vm[i] = new CondorVM(i, userId, mips * ratio, pesNumber, ram, bw, size, vmm, new CloudletSchedulerSpaceShared());
  364.             list.add(vm[i]);
  365.         }
  366.         return list;
  367.     }
  368.  
  369.     // VYTVORENIE TLACITIEK
  370.     protected JComponent createOptionControls() {
  371.        
  372.        
  373.         fc = new JFileChooser();
  374.         log = new JTextArea(5, 20);
  375.         log.setMargin(new Insets(5,5,5,5));
  376.         log.setEditable(false);
  377.         JScrollPane logScrollPane = new JScrollPane(log);
  378.         JLabel label = new JLabel("Počet Virtuálnych Strojov:");
  379.         JLabel label1 = new JLabel("Testovací súbor:");
  380.         JLabel label2 = new JLabel("Algoritmus:");
  381.        
  382.         JTextField vm = new JTextField(6);
  383.  
  384.         vm = new JTextField();
  385.         vm.setActionCommand(VM);
  386.         vm.addActionListener(this);
  387.        
  388.          JButton nastav = new JButton("Test ...");
  389.             nastav.setActionCommand(NASTAV);
  390.             nastav.addActionListener(this);
  391.        
  392.         JButton otvor = new JButton("Test ...");
  393.         otvor.setActionCommand(TEST_FILE);
  394.         otvor.addActionListener(this);
  395.        
  396.         ButtonGroup bg2 = new ButtonGroup();
  397.         //
  398.         //
  399.         JRadioButton rb4 = new JRadioButton();
  400.         rb4.setText("RoundRobin");
  401.         rb4.setActionCommand(ROUND_ROBIN);
  402.         rb4.addActionListener(this);
  403.         rb4.setSelected(true);
  404.         bg2.add(rb4);
  405.         //
  406.         JRadioButton rb5 = new JRadioButton();
  407.         rb5.setText("MinMax");
  408.         rb5.setActionCommand(MAX_MIN);
  409.         rb5.addActionListener(this);
  410.         bg2.add(rb5);
  411.         //
  412.         JRadioButton rb6 = new JRadioButton();
  413.         rb6.setText("MaxMin");
  414.         rb6.setActionCommand(MIN_MIN);
  415.         rb6.addActionListener(this);
  416.         bg2.add(rb6);
  417.  
  418.         //Pridanie všetkého do kontajnera
  419.         Box box = Box.createVerticalBox();
  420.         box.add(Box.createVerticalStrut(15));
  421.         box.add(Box.createVerticalStrut(15));
  422.         box.add(label);
  423.         box.add(Box.createVerticalStrut(15));
  424.         box.add(vm);
  425.         box.add(Box.createVerticalStrut(15));
  426.         box.add(label1);
  427.         box.add(Box.createVerticalStrut(15));
  428.         box.add(otvor);
  429.         box.add(Box.createVerticalStrut(15));
  430.         box.add(label2);
  431.         box.add(Box.createVerticalStrut(5));
  432.         box.add(rb4);
  433.         box.add(rb5);
  434.         box.add(rb6);
  435.         box.add(Box.createVerticalStrut(15));
  436.         box.add(logScrollPane);
  437.  
  438.  
  439.         return box;
  440.     }
  441.    
  442.     // CITANIE SUBORU
  443.     protected JComponent vypis() {
  444.         JLabel label1 = new JLabel("Priebeh");
  445.        
  446.      
  447.         JTable table = new JTable(new MyTableModel());
  448.         table.setPreferredScrollableViewportSize(new Dimension(500, 500));
  449.         table.setFillsViewportHeight(true);
  450.  
  451.         JScrollPane scrollPane = new JScrollPane(table);
  452.        
  453.        
  454.         table.setFillsViewportHeight(true);
  455.      
  456.         //Pridanie všetkého do kontajnera
  457.         Box box = Box.createVerticalBox();
  458.         box.add(label1);
  459.         String file ="E:/priebeh.txt";
  460.        
  461.         //Citanie
  462.         try{
  463.             InputStream ips=new FileInputStream(file);
  464.             InputStreamReader ipsr=new InputStreamReader(ips);
  465.             BufferedReader br=new BufferedReader(ipsr);
  466.             String line;
  467.             Integer i=2;
  468.             while ((line=br.readLine())!=null){
  469.                 JLabel label2 = new JLabel(line);
  470.                 box.add(label2);
  471.                 i++;
  472.             }
  473.             br.close();
  474.         }      
  475.         catch (Exception e){
  476.             System.out.println(e.toString());
  477.         }
  478.        
  479.         //
  480.         box.add(Box.createVerticalStrut(15));
  481.  
  482.         return box;
  483.     }
  484.      
  485.     // TABULKA
  486.     class MyTableModel extends AbstractTableModel {    
  487.        
  488.             private String[] columnNames = {"ID úlohy",
  489.                                             "STAV",
  490.                                             "ID Dátového centra",
  491.                                             "ID Virtuálneho stroja",
  492.                                             "Čas",
  493.                                             "Čas spustenia",
  494.                                             "Čas dokončenia",
  495.                                             "Hĺbka"
  496.                                             };
  497.          
  498.             private Object[][] data = {{"", "", "", "", "", "", "", ""}};
  499.            
  500.             public int getColumnCount() {
  501.                 return columnNames.length;
  502.             }
  503.      
  504.             public int getRowCount() {
  505.                 return data.length;
  506.             }
  507.      
  508.             public String getColumnName(int col) {
  509.                 return columnNames[col];
  510.             }
  511.      
  512.             public Object getValueAt(int row, int col) {
  513.                 return data[row][col];
  514.             }
  515.      
  516.             public Class getColumnClass(int c) {
  517.                 return getValueAt(0, c).getClass();
  518.             }
  519.      
  520.             public boolean isCellEditable(int row, int col) {
  521.                 if (col < 2) {
  522.                     return false;
  523.                 } else {
  524.                     return true;
  525.                 }
  526.             }
  527.      
  528.             public void setValueAt(Object value, int row, int col) {
  529.                 if (DEBUG) {
  530.                     System.out.println("Setting value at " + row + "," + col
  531.                                        + " to " + value
  532.                                        + " (an instance of "
  533.                                        + value.getClass() + ")");
  534.                 }
  535.      
  536.                 data[row][col] = value;
  537.                 fireTableCellUpdated(row, col);
  538.      
  539.                 if (DEBUG) {
  540.                     System.out.println("New value of data:");
  541.                     printDebugData();
  542.                 }
  543.             }
  544.      
  545.             private void printDebugData() {
  546.                 int numRows = getRowCount();
  547.                 int numCols = getColumnCount();
  548.      
  549.                 for (int i=0; i < numRows; i++) {
  550.                     System.out.print("    row " + i + ":");
  551.                     for (int j=0; j < numCols; j++) {
  552.                         System.out.print("  " + data[i][j]);
  553.                     }
  554.                     System.out.println();
  555.                 }
  556.                 System.out.println("--------------------------");
  557.             }
  558.         }
  559.    
  560.     // TLACITKO
  561.     protected JComponent createButtonPane() {
  562.         JButton button = new JButton("Simuluj");
  563.         button.setActionCommand(CREATE_WINDOW);
  564.         button.addActionListener(this);
  565.         defaultButton = button;
  566.  
  567.         JPanel pane = new JPanel();
  568.         pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
  569.         pane.add(button);
  570.  
  571.         return pane;
  572.     }
  573.    
  574.     // ODCHITAVANIE AKCIE
  575.     public void actionPerformed(ActionEvent e) {
  576.         String command = e.getActionCommand();
  577.        
  578.         if (TEST_FILE.equals(command)) {
  579.            
  580.             int returnVal = fc.showDialog(defaultButton, command);
  581.             if (returnVal == JFileChooser.APPROVE_OPTION) {
  582.                 File file = fc.getSelectedFile();
  583.                 log.append("Nastavený testovací súbor: " + file.getPath() + "." + newline);
  584.                 CESTA = file.getPath();
  585.             } else {
  586.                 log.append("Nastavenie súboru na testovenie bolo prerušené uživatelom.");
  587.             }
  588.             log.setCaretPosition(log.getDocument().getLength());
  589.         }
  590.         else if (CREATE_WINDOW.equals(command)) {
  591.             try {
  592.                 simulate();
  593.             } catch (IOException e1) {
  594.                 e1.printStackTrace();
  595.                
  596.             }
  597.         }
  598.         else if (ROUND_ROBIN.equals(command)) {
  599.             roundrobin = true;
  600.             maxmin = false;
  601.             minmin = false;
  602.             log.append("Algoritmus :  RoundRobin"+ newline);
  603.             String VO = vm.getText();
  604.            
  605.         } else if (MAX_MIN.equals(command)) {
  606.             roundrobin = false;
  607.             maxmin = true;
  608.             minmin = false;
  609.             log.append("Algoritmus :  MaxMin" + newline);
  610.            
  611.         } else if (MIN_MIN.equals(command)) {
  612.             roundrobin = false;
  613.             maxmin = false;
  614.             minmin = true;
  615.             log.append("Algoritmus :  MinMin" + newline);
  616.         }
  617.         }
  618.    
  619.     // VYTVORENIE A ZOBRAZENIE PROSTREDIA
  620.     private static void createAndShowGUI() {
  621.         try {
  622.             UIManager.setLookAndFeel(
  623.                 UIManager.getCrossPlatformLookAndFeelClassName());
  624.         } catch (Exception e) { }
  625.  
  626.         JFrame.setDefaultLookAndFeelDecorated(true);
  627.         JDialog.setDefaultLookAndFeelDecorated(true);
  628.  
  629.         JFrame frame = new JFrame("Simulátor");
  630.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  631.  
  632.         //Vytvorenie a nastavenie
  633.         test demo = new test();
  634.  
  635.         //Pridanie komponentov.
  636.         Container contentPane = frame.getContentPane();
  637.         contentPane.add(demo.createOptionControls(),
  638.                         BorderLayout.CENTER);
  639.         contentPane.add(demo.createButtonPane(),
  640.                         BorderLayout.PAGE_END);
  641.         frame.getRootPane().setDefaultButton(defaultButton);
  642.  
  643.         //Zobrazenie okna
  644.         frame.pack();
  645.         frame.setLocationRelativeTo(null); // Centrovanie
  646.         frame.setVisible(true);
  647.     }
  648.    
  649.     // OKNO VYPISANIE
  650.     private static void vysledok1() {
  651.         try {
  652.             UIManager.setLookAndFeel(
  653.                 UIManager.getCrossPlatformLookAndFeelClassName());
  654.         } catch (Exception e) { }
  655.  
  656.         test demo = new test();
  657.        
  658.         JFrame frame = new JFrame("Výsledok");
  659.         Container contentPane2 = frame.getContentPane();
  660.         contentPane2.add(demo.vypis(),
  661.                 BorderLayout.CENTER);
  662.         frame.pack();
  663.         frame.setLocationRelativeTo(null); // Centrovanie
  664.         frame.setVisible(true);
  665.     }
  666.  
  667.     // MAIN
  668.     public static void main(String[] args) {
  669.         javax.swing.SwingUtilities.invokeLater(new Runnable() {
  670.             public void run() {
  671.                 createAndShowGUI();
  672.             }
  673.         });
  674.     }
  675.  
  676. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement