List of usage examples for javax.swing GroupLayout GroupLayout
public GroupLayout(Container host)
From source file:eu.cassandra.training.gui.MainGUI.java
/** * Constructor of the Training Module GUI. * //from w w w.java2 s . c o m * @throws UnsupportedLookAndFeelException * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException * @throws FileNotFoundException */ public MainGUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, FileNotFoundException { setForeground(new Color(0, 204, 51)); // Enable the closing of the frame when pressing the x on the upper corner // of the window addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { Utils.cleanFiles(); System.exit(0); } }); // Cleaning temporary files from the temp folder when starting the GUI. // Utils.cleanFiles(); // Change the platforms look and feel to Nimbus LookAndFeel lnf = new javax.swing.plaf.nimbus.NimbusLookAndFeel(); UIManager.put("NimbusLookAndFeel", Color.GREEN); UIManager.setLookAndFeel(lnf); // Setting the basic attributes of the Training Module GUI setTitle("Training Module (BETA)"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 1228, 799); // Creating the menu bar and adding the menu items JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu("File"); menuBar.add(mnNewMenu); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Utils.cleanFiles(); System.exit(0); } }); mnNewMenu.add(mntmExit); JMenu mnExit = new JMenu("Help"); menuBar.add(mnExit); JMenuItem mntmManual = new JMenuItem("Manual"); mnExit.add(mntmManual); JMenuItem mntmAbout = new JMenuItem("About"); mnExit.add(mntmAbout); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); // Adding the tabbed pane to the content pane final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addComponent(tabbedPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 1202, Short.MAX_VALUE)); gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 736, GroupLayout.PREFERRED_SIZE) .addContainerGap(47, Short.MAX_VALUE))); // TABS // final JPanel importTab = new JPanel(); tabbedPane.addTab("Import Data", null, importTab, null); tabbedPane.setDisplayedMnemonicIndexAt(0, 0); tabbedPane.setEnabledAt(0, true); importTab.setLayout(null); final JPanel trainingTab = new JPanel(); tabbedPane.addTab("Train Activity Models", null, trainingTab, null); tabbedPane.setDisplayedMnemonicIndexAt(1, 1); tabbedPane.setEnabledAt(1, false); trainingTab.setLayout(null); final JPanel createResponseTab = new JPanel(); tabbedPane.addTab("Create Response Models", null, createResponseTab, null); tabbedPane.setEnabledAt(2, false); createResponseTab.setLayout(null); // RESPONSE MODEL TAB // final JPanel responseParametersPanel = new JPanel(); responseParametersPanel.setLayout(null); responseParametersPanel.setBorder( new TitledBorder(null, "Response Parameters", TitledBorder.LEADING, TitledBorder.TOP, null, null)); responseParametersPanel.setBounds(6, 6, 394, 271); createResponseTab.add(responseParametersPanel); final JPanel activityModelSelectionPanel = new JPanel(); activityModelSelectionPanel.setLayout(null); activityModelSelectionPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Activity Model Selection", TitledBorder.LEADING, TitledBorder.TOP, null, null)); activityModelSelectionPanel.setBounds(6, 516, 394, 192); createResponseTab.add(activityModelSelectionPanel); final JPanel responsePanel = new JPanel(); responsePanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Activity Model Change Preview", TitledBorder.LEADING, TitledBorder.TOP, null, null)); responsePanel.setBounds(417, 6, 770, 385); createResponseTab.add(responsePanel); responsePanel.setLayout(new BorderLayout(0, 0)); final JPanel pricingPreviewPanel = new JPanel(); pricingPreviewPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Pricing Scheme Preview", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pricingPreviewPanel.setBounds(417, 438, 770, 259); createResponseTab.add(pricingPreviewPanel); pricingPreviewPanel.setLayout(new BorderLayout(0, 0)); final JPanel pricingSchemePanel = new JPanel(); pricingSchemePanel.setLayout(null); pricingSchemePanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Pricing Scheme Selection", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pricingSchemePanel.setBounds(6, 274, 394, 243); createResponseTab.add(pricingSchemePanel); // ///////////////// // RESPONSE TAB // // //////////////// // RESPONSE PARAMETERS // final JLabel lblSensitivity = new JLabel("Sensitivity"); lblSensitivity.setBounds(10, 28, 78, 16); responseParametersPanel.add(lblSensitivity); final JSlider sensitivitySlider = new JSlider(); sensitivitySlider.setPaintLabels(true); sensitivitySlider.setSnapToTicks(true); sensitivitySlider.setPaintTicks(true); sensitivitySlider.setMinorTickSpacing(10); sensitivitySlider.setMajorTickSpacing(10); sensitivitySlider.setBounds(111, 28, 214, 45); responseParametersPanel.add(sensitivitySlider); final JLabel lblAwareness = new JLabel("Awareness"); lblAwareness.setBounds(10, 79, 78, 16); responseParametersPanel.add(lblAwareness); final JSlider awarenessSlider = new JSlider(); awarenessSlider.setPaintLabels(true); awarenessSlider.setPaintTicks(true); awarenessSlider.setMajorTickSpacing(10); awarenessSlider.setMinorTickSpacing(10); awarenessSlider.setSnapToTicks(true); awarenessSlider.setBounds(111, 79, 214, 45); responseParametersPanel.add(awarenessSlider); final JLabel label_7 = new JLabel("Response Model"); label_7.setBounds(10, 153, 103, 16); responseParametersPanel.add(label_7); final JRadioButton optimalCaseRadioButton = new JRadioButton("Optimal Case Scenario"); responseModelButtonGroup.add(optimalCaseRadioButton); optimalCaseRadioButton.setBounds(111, 131, 170, 18); responseParametersPanel.add(optimalCaseRadioButton); final JRadioButton normalCaseRadioButton = new JRadioButton("Normal Case Scenario"); normalCaseRadioButton.setSelected(true); responseModelButtonGroup.add(normalCaseRadioButton); normalCaseRadioButton.setBounds(111, 152, 170, 18); responseParametersPanel.add(normalCaseRadioButton); final JRadioButton discreteCaseRadioButton = new JRadioButton("Discrete Case Scenario"); discreteCaseRadioButton.setSelected(true); responseModelButtonGroup.add(discreteCaseRadioButton); discreteCaseRadioButton.setBounds(111, 173, 170, 18); responseParametersPanel.add(discreteCaseRadioButton); final JButton previewResponseButton = new JButton("Preview Response Model"); previewResponseButton.setEnabled(false); previewResponseButton.setBounds(24, 198, 157, 28); responseParametersPanel.add(previewResponseButton); final JButton createResponseButton = new JButton("Create Response Model"); createResponseButton.setEnabled(false); createResponseButton.setBounds(191, 198, 162, 28); responseParametersPanel.add(createResponseButton); final JButton createResponseAllButton = new JButton("Create Response All"); createResponseAllButton.setEnabled(false); createResponseAllButton.setBounds(111, 232, 157, 28); responseParametersPanel.add(createResponseAllButton); // SELECT ACTIVITY MODEL // final JLabel lblSelectedActivity = new JLabel("Selected Activity"); lblSelectedActivity.setBounds(10, 21, 130, 16); activityModelSelectionPanel.add(lblSelectedActivity); JScrollPane activityListScrollPane = new JScrollPane(); activityListScrollPane.setBounds(20, 39, 355, 143); activityModelSelectionPanel.add(activityListScrollPane); final JList<String> activitySelectList = new JList<String>(); activityListScrollPane.setViewportView(activitySelectList); activitySelectList.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); final JButton commitButton = new JButton("Commit"); commitButton.setEnabled(false); commitButton.setBounds(151, 209, 89, 23); pricingSchemePanel.add(commitButton); JLabel lblBasicSchema = new JLabel("Basic Schema (Start-End-Value)"); lblBasicSchema.setBounds(10, 18, 182, 14); pricingSchemePanel.add(lblBasicSchema); JLabel lblNewSchemastart = new JLabel("New Schema (Start-End-Value)"); lblNewSchemastart.setBounds(197, 18, 177, 14); pricingSchemePanel.add(lblNewSchemastart); JScrollPane basicPricingSchemeScrollPane = new JScrollPane(); basicPricingSchemeScrollPane.setBounds(10, 43, 177, 161); pricingSchemePanel.add(basicPricingSchemeScrollPane); final JTextPane basicPricingSchemePane = new JTextPane(); basicPricingSchemeScrollPane.setViewportView(basicPricingSchemePane); basicPricingSchemePane.setText("00:00-23:59-0.05"); JScrollPane newPricingScrollPane = new JScrollPane(); newPricingScrollPane.setBounds(197, 43, 177, 161); pricingSchemePanel.add(newPricingScrollPane); final JTextPane newPricingSchemePane = new JTextPane(); newPricingScrollPane.setViewportView(newPricingSchemePane); JPanel buttonPanel = new JPanel(); buttonPanel.setBounds(682, 390, 265, 33); createResponseTab.add(buttonPanel); final JButton dailyResponseButton = new JButton("Daily Times"); dailyResponseButton.setEnabled(false); buttonPanel.add(dailyResponseButton); final JButton startResponseButton = new JButton("Start Time"); startResponseButton.setEnabled(false); buttonPanel.add(startResponseButton); final JPanel exportTab = new JPanel(); tabbedPane.addTab("Export Models", null, exportTab, null); tabbedPane.setEnabledAt(3, false); exportTab.setLayout(null); // PANELS // // DATA IMPORT TAB // final JPanel dataFilePanel = new JPanel(); dataFilePanel .setBorder(new TitledBorder(null, "Data File", TitledBorder.LEADING, TitledBorder.TOP, null, null)); dataFilePanel.setBounds(6, 6, 622, 284); importTab.add(dataFilePanel); dataFilePanel.setLayout(null); final JPanel disaggregationPanel = new JPanel(); disaggregationPanel.setLayout(null); disaggregationPanel.setBorder( new TitledBorder(null, "Disaggregation", TitledBorder.LEADING, TitledBorder.TOP, null, null)); disaggregationPanel.setBounds(629, 6, 567, 284); importTab.add(disaggregationPanel); final JPanel dataReviewPanel = new JPanel(); dataReviewPanel.setBorder( new TitledBorder(null, "Data Preview", TitledBorder.LEADING, TitledBorder.TOP, null, null)); dataReviewPanel.setBounds(6, 293, 622, 407); importTab.add(dataReviewPanel); dataReviewPanel.setLayout(new BorderLayout(0, 0)); final JPanel consumptionModelPanel = new JPanel(); consumptionModelPanel.setBounds(629, 293, 567, 407); importTab.add(consumptionModelPanel); consumptionModelPanel.setBorder( new TitledBorder(null, "Consumption Model", TitledBorder.LEADING, TitledBorder.TOP, null, null)); consumptionModelPanel.setLayout(new BorderLayout(0, 0)); // TRAINING ACTIVITY TAB // final JPanel trainingParametersPanel = new JPanel(); trainingParametersPanel.setLayout(null); trainingParametersPanel.setBorder( new TitledBorder(null, "Training Parameters", TitledBorder.LEADING, TitledBorder.TOP, null, null)); trainingParametersPanel.setBounds(6, 6, 621, 256); trainingTab.add(trainingParametersPanel); final JPanel applianceSelectionPanel = new JPanel(); applianceSelectionPanel.setLayout(null); applianceSelectionPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Appliance/Activity Selection", TitledBorder.LEADING, TitledBorder.TOP, null, null)); applianceSelectionPanel.setBounds(630, 6, 557, 256); trainingTab.add(applianceSelectionPanel); final JPanel expectedPowerPanel = new JPanel(); expectedPowerPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Expected Power Preview", TitledBorder.LEADING, TitledBorder.TOP, null, null)); expectedPowerPanel.setBounds(630, 261, 557, 447); trainingTab.add(expectedPowerPanel); expectedPowerPanel.setLayout(new BorderLayout(0, 0)); contentPane.setLayout(gl_contentPane); // EXPORT TAB // JPanel modelExportPanel = new JPanel(); modelExportPanel.setLayout(null); modelExportPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Model Export Selection", TitledBorder.LEADING, TitledBorder.TOP, null, null)); modelExportPanel.setBounds(10, 11, 596, 267); exportTab.add(modelExportPanel); final JPanel exportPreviewPanel = new JPanel(); exportPreviewPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Export Model Preview", TitledBorder.LEADING, TitledBorder.TOP, null, null)); exportPreviewPanel.setBounds(10, 310, 1187, 387); exportTab.add(exportPreviewPanel); exportPreviewPanel.setLayout(new BorderLayout(0, 0)); JPanel exportButtonsPanel = new JPanel(); exportButtonsPanel.setBounds(322, 279, 536, 33); exportTab.add(exportButtonsPanel); JPanel connectionPanel = new JPanel(); connectionPanel.setLayout(null); connectionPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Connection Properties", TitledBorder.LEADING, TitledBorder.TOP, null, null)); connectionPanel.setBounds(606, 11, 581, 267); exportTab.add(connectionPanel); // COMPONENTS // // IMPORT TAB // // DATA IMPORT // final JLabel lblSource = new JLabel("Data Source:"); lblSource.setBounds(23, 47, 71, 16); dataFilePanel.add(lblSource); final JTextField pathField = new JTextField(); pathField.setEditable(false); pathField.setBounds(99, 41, 405, 28); dataFilePanel.add(pathField); pathField.setColumns(10); final JButton dataBrowseButton = new JButton("Browse"); dataBrowseButton.setBounds(516, 41, 87, 28); dataFilePanel.add(dataBrowseButton); final JButton resetButton = new JButton("Reset"); resetButton.setBounds(516, 81, 87, 28); dataFilePanel.add(resetButton); final JLabel lblDataMeasurementsFrom = new JLabel("Data Measurements From:"); lblDataMeasurementsFrom.setBounds(23, 90, 154, 16); dataFilePanel.add(lblDataMeasurementsFrom); final JRadioButton singleApplianceRadioButton = new JRadioButton("Single Appliance"); singleApplianceRadioButton.setEnabled(false); dataMeasurementsButtonGroup.add(singleApplianceRadioButton); singleApplianceRadioButton.setBounds(242, 110, 115, 18); dataFilePanel.add(singleApplianceRadioButton); final JRadioButton installationRadioButton = new JRadioButton("Installation"); installationRadioButton.setSelected(true); installationRadioButton.setEnabled(false); dataMeasurementsButtonGroup.add(installationRadioButton); installationRadioButton.setBounds(242, 89, 115, 18); dataFilePanel.add(installationRadioButton); final JLabel labelConsumptionModel = new JLabel("Consumption Model:"); labelConsumptionModel.setBounds(23, 179, 120, 16); dataFilePanel.add(labelConsumptionModel); final JButton importDataButton = new JButton("Import Data"); importDataButton.setEnabled(false); importDataButton.setBounds(23, 237, 126, 28); dataFilePanel.add(importDataButton); final JButton disaggregateButton = new JButton("Disaggregate"); disaggregateButton.setEnabled(false); disaggregateButton.setBounds(216, 237, 147, 28); dataFilePanel.add(disaggregateButton); final JButton createEventsButton = new JButton("Create Events Dataset"); createEventsButton.setEnabled(false); createEventsButton.setBounds(422, 237, 181, 28); dataFilePanel.add(createEventsButton); final JTextField consumptionPathField = new JTextField(); consumptionPathField.setEnabled(false); consumptionPathField.setEditable(false); consumptionPathField.setColumns(10); consumptionPathField.setBounds(99, 197, 405, 28); dataFilePanel.add(consumptionPathField); final JButton consumptionBrowseButton = new JButton("Browse"); consumptionBrowseButton.setEnabled(false); consumptionBrowseButton.setBounds(516, 197, 87, 28); dataFilePanel.add(consumptionBrowseButton); JLabel lblTypeOfMeasurements = new JLabel("Type of Measurements"); lblTypeOfMeasurements.setBounds(23, 141, 154, 16); dataFilePanel.add(lblTypeOfMeasurements); final JRadioButton activePowerRadioButton = new JRadioButton("Active Power (P)"); powerButtonGroup.add(activePowerRadioButton); activePowerRadioButton.setEnabled(false); activePowerRadioButton.setBounds(242, 140, 115, 18); dataFilePanel.add(activePowerRadioButton); final JRadioButton activeAndReactivePowerRadioButton = new JRadioButton("Active and Reactive Power (P, Q)"); activeAndReactivePowerRadioButton.setSelected(true); powerButtonGroup.add(activeAndReactivePowerRadioButton); activeAndReactivePowerRadioButton.setEnabled(false); activeAndReactivePowerRadioButton.setBounds(242, 161, 262, 18); dataFilePanel.add(activeAndReactivePowerRadioButton); // ////////////////// // DISAGGREGATION // // ///////////////// final JLabel lblAppliancesDetected = new JLabel("Detected Appliances "); lblAppliancesDetected.setBounds(18, 33, 130, 16); disaggregationPanel.add(lblAppliancesDetected); JScrollPane scrollPane_2 = new JScrollPane(); scrollPane_2.setBounds(145, 31, 396, 231); disaggregationPanel.add(scrollPane_2); final JList<String> detectedApplianceList = new JList<String>(); scrollPane_2.setViewportView(detectedApplianceList); detectedApplianceList.setEnabled(false); detectedApplianceList.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); // //////////////// // TRAINING TAB // // //////////////// // TRAINING PARAMETERS // final JLabel label_1 = new JLabel("Times Per Day"); label_1.setBounds(19, 40, 103, 16); trainingParametersPanel.add(label_1); final JRadioButton timesHistogramRadioButton = new JRadioButton("Histogram"); timesHistogramRadioButton.setSelected(true); timesDailyButtonGroup.add(timesHistogramRadioButton); timesHistogramRadioButton.setBounds(160, 38, 87, 18); trainingParametersPanel.add(timesHistogramRadioButton); final JRadioButton timesNormalRadioButton = new JRadioButton("Normal Distribution"); timesNormalRadioButton.setEnabled(false); timesDailyButtonGroup.add(timesNormalRadioButton); timesNormalRadioButton.setBounds(304, 40, 137, 18); trainingParametersPanel.add(timesNormalRadioButton); JRadioButton timesGaussianRadioButton = new JRadioButton("Gaussian Mixture"); timesGaussianRadioButton.setEnabled(false); timesDailyButtonGroup.add(timesGaussianRadioButton); timesGaussianRadioButton.setBounds(478, 38, 137, 18); trainingParametersPanel.add(timesGaussianRadioButton); final JLabel label_2 = new JLabel("Start Time"); label_2.setBounds(19, 133, 103, 16); trainingParametersPanel.add(label_2); final JRadioButton startHistogramRadioButton = new JRadioButton("Histogram"); startHistogramRadioButton.setSelected(true); startTimeButtonGroup.add(startHistogramRadioButton); startHistogramRadioButton.setBounds(160, 131, 87, 18); trainingParametersPanel.add(startHistogramRadioButton); final JRadioButton startNormalRadioButton = new JRadioButton("Normal Distribution"); // startNormalRadioButton.setEnabled(false); startTimeButtonGroup.add(startNormalRadioButton); startNormalRadioButton.setBounds(304, 133, 137, 18); trainingParametersPanel.add(startNormalRadioButton); final JRadioButton startGaussianRadioButton = new JRadioButton("Gaussian Mixture"); startGaussianRadioButton.setSelected(true); startTimeButtonGroup.add(startGaussianRadioButton); startGaussianRadioButton.setBounds(478, 131, 137, 18); trainingParametersPanel.add(startGaussianRadioButton); final JLabel label_3 = new JLabel("Duration"); label_3.setBounds(19, 86, 103, 16); trainingParametersPanel.add(label_3); final JRadioButton durationHistogramRadioButton = new JRadioButton("Histogram"); durationHistogramRadioButton.setSelected(true); durationButtonGroup.add(durationHistogramRadioButton); durationHistogramRadioButton.setBounds(160, 84, 87, 18); trainingParametersPanel.add(durationHistogramRadioButton); final JRadioButton durationNormalRadioButton = new JRadioButton("Normal Distribution"); durationNormalRadioButton.setSelected(true); durationButtonGroup.add(durationNormalRadioButton); durationNormalRadioButton.setBounds(304, 86, 137, 18); trainingParametersPanel.add(durationNormalRadioButton); final JRadioButton durationGaussianRadioButton = new JRadioButton("Gaussian Mixture"); durationButtonGroup.add(durationGaussianRadioButton); durationGaussianRadioButton.setBounds(478, 84, 137, 18); trainingParametersPanel.add(durationGaussianRadioButton); final JButton trainingButton = new JButton("Train"); trainingButton.setBounds(125, 194, 115, 28); trainingParametersPanel.add(trainingButton); final JButton trainAllButton = new JButton("Train All"); trainAllButton.setBounds(366, 194, 115, 28); trainingParametersPanel.add(trainAllButton); // APPLIANCE SELECTION // final JLabel label_4 = new JLabel("Selected Appliance"); label_4.setBounds(18, 33, 130, 16); applianceSelectionPanel.add(label_4); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(128, 29, 419, 216); applianceSelectionPanel.add(scrollPane_1); final JList<String> selectedApplianceList = new JList<String>(); scrollPane_1.setViewportView(selectedApplianceList); selectedApplianceList.setEnabled(false); selectedApplianceList.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); // DISTRIBUTION SELECTION // JPanel distributionSelectionPanel = new JPanel(); distributionSelectionPanel.setBounds(80, 261, 482, 33); trainingTab.add(distributionSelectionPanel); final JButton dailyTimesButton = new JButton("Daily Times"); dailyTimesButton.setEnabled(false); distributionSelectionPanel.add(dailyTimesButton); final JButton durationButton = new JButton("Duration"); durationButton.setEnabled(false); distributionSelectionPanel.add(durationButton); final JButton startTimeButton = new JButton("Start Time"); startTimeButton.setEnabled(false); distributionSelectionPanel.add(startTimeButton); final JButton startTimeBinnedButton = new JButton("Start Time Binned"); startTimeBinnedButton.setEnabled(false); distributionSelectionPanel.add(startTimeBinnedButton); final JPanel distributionPreviewPanel = new JPanel(); distributionPreviewPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Distribution Preview", TitledBorder.LEADING, TitledBorder.TOP, null, null)); distributionPreviewPanel.setBounds(6, 299, 621, 409); trainingTab.add(distributionPreviewPanel); distributionPreviewPanel.setLayout(new BorderLayout(0, 0)); // ////////////////// // EXPORT TAB /////// // ///////////////// JLabel exportModelLabel = new JLabel("Select Model"); exportModelLabel.setBounds(10, 34, 151, 16); modelExportPanel.add(exportModelLabel); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(83, 32, 503, 212); modelExportPanel.add(scrollPane); final JList<String> exportModelList = new JList<String>(); scrollPane.setViewportView(exportModelList); exportModelList.setEnabled(false); exportModelList.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); // EXPORT TAB // final JButton exportDailyButton = new JButton("Daily Times"); exportDailyButton.setEnabled(false); exportButtonsPanel.add(exportDailyButton); final JButton exportDurationButton = new JButton("Duration"); exportDurationButton.setEnabled(false); exportButtonsPanel.add(exportDurationButton); final JButton exportStartButton = new JButton("Start Time"); exportStartButton.setEnabled(false); exportButtonsPanel.add(exportStartButton); final JButton exportStartBinnedButton = new JButton("Start Time Binned"); exportStartBinnedButton.setEnabled(false); exportButtonsPanel.add(exportStartBinnedButton); final JButton exportExpectedPowerButton = new JButton("Expected Power"); exportExpectedPowerButton.setEnabled(false); exportButtonsPanel.add(exportExpectedPowerButton); JLabel usernameLabel = new JLabel("Username:"); usernameLabel.setBounds(46, 27, 71, 16); connectionPanel.add(usernameLabel); final JTextField usernameTextField; usernameTextField = new JTextField(); usernameTextField.setText("user"); usernameTextField.setColumns(10); usernameTextField.setBounds(122, 21, 405, 28); connectionPanel.add(usernameTextField); final JButton exportButton = new JButton("Export Entity"); exportButton.setEnabled(false); exportButton.setBounds(46, 178, 147, 28); connectionPanel.add(exportButton); final JButton exportAllBaseButton = new JButton("Export All Base"); exportAllBaseButton.setEnabled(false); exportAllBaseButton.setBounds(203, 178, 177, 28); connectionPanel.add(exportAllBaseButton); final JButton exportAllResponseButton = new JButton("Export All Response"); exportAllResponseButton.setEnabled(false); exportAllResponseButton.setBounds(390, 178, 181, 28); connectionPanel.add(exportAllResponseButton); JLabel passwordLabel = new JLabel("Password:"); passwordLabel.setBounds(46, 62, 71, 16); connectionPanel.add(passwordLabel); JLabel UrlLabel = new JLabel("URL:"); UrlLabel.setBounds(46, 105, 71, 16); connectionPanel.add(UrlLabel); final JTextField urlTextField; urlTextField = new JTextField(); urlTextField.setText("https://160.40.50.233:8443/cassandra/api"); urlTextField.setColumns(10); urlTextField.setBounds(122, 99, 405, 28); connectionPanel.add(urlTextField); final JButton connectButton = new JButton("Connect"); connectButton.setEnabled(false); connectButton.setBounds(217, 138, 147, 28); connectionPanel.add(connectButton); final JPasswordField passwordField; passwordField = new JPasswordField(); passwordField.setBounds(122, 60, 405, 28); connectionPanel.add(passwordField); final JTextField householdNameTextField; householdNameTextField = new JTextField(); householdNameTextField.setEnabled(false); householdNameTextField.setBounds(166, 225, 405, 31); connectionPanel.add(householdNameTextField); householdNameTextField.setColumns(10); final JLabel householdNameLabel = new JLabel("Export Household Name:"); householdNameLabel.setBounds(24, 233, 147, 14); connectionPanel.add(householdNameLabel); JButton btnOpenPlatform = new JButton("Open Platform"); btnOpenPlatform.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { Desktop.getDesktop() .browse(new URL("https://cassandra.iti.gr:8443/cassandra/app.html").toURI()); } catch (Exception e) { e.printStackTrace(); } } }); btnOpenPlatform.setBounds(401, 138, 147, 28); connectionPanel.add(btnOpenPlatform); // ////////////////// // ACTIONS /////// // ///////////////// // IMPORT TAB // // DATA IMPORT //// dataBrowseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the browse button to * input the data file on the Data File panel of the Import Data tab. * */ @Override public void actionPerformed(ActionEvent e) { // Opens the browse panel to find the data set file JFileChooser fc = new JFileChooser("./"); // Adds a filter to the type of files acceptable for selection fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new MyFilter2()); int returnVal = fc.showOpenDialog(contentPane); // After choosing the file some of the options in the Data File panel // are unlocked if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); pathField.setText(file.getAbsolutePath()); importDataButton.setEnabled(true); activePowerRadioButton.setEnabled(true); activeAndReactivePowerRadioButton.setEnabled(true); installationRadioButton.setEnabled(true); singleApplianceRadioButton.setEnabled(true); } } }); consumptionBrowseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the browse button to * input the consumption model file on the Data File panel of the Import * Data tab. * */ @Override public void actionPerformed(ActionEvent e) { // Opens the browse panel to find the consumption model file JFileChooser fc = new JFileChooser("./"); // Adds a filter to the type of files acceptable for selection fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new MyFilter()); int returnVal = fc.showOpenDialog(contentPane); // After choosing the file some of the options in the Data File panel // are unlocked if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); consumptionPathField.setText(file.getAbsolutePath()); createEventsButton.setEnabled(true); } } }); resetButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the reset button * on the Data File panel of the Import Data tab. All the imported and * created entities are removed and the Training Module goes back to its * initial state. * */ @Override public void actionPerformed(ActionEvent e) { // Cleaning the Import Data tab components pathField.setText(""); consumptionPathField.setText(""); importDataButton.setEnabled(false); disaggregateButton.setEnabled(false); createEventsButton.setEnabled(false); installation = new Installation(); dataBrowseButton.setEnabled(true); consumptionBrowseButton.setEnabled(false); installationRadioButton.setEnabled(false); installationRadioButton.setSelected(true); singleApplianceRadioButton.setEnabled(false); activePowerRadioButton.setEnabled(false); activeAndReactivePowerRadioButton.setEnabled(false); activeAndReactivePowerRadioButton.setSelected(true); dataReviewPanel.removeAll(); dataReviewPanel.updateUI(); consumptionModelPanel.removeAll(); consumptionModelPanel.updateUI(); detectedApplianceList.setSelectedIndex(-1); detectedAppliances.clear(); detectedApplianceList.setListData(new String[0]); detectedApplianceList.repaint(); // Cleaning the Training Activity Models tab components distributionPreviewPanel.removeAll(); distributionPreviewPanel.updateUI(); expectedPowerPanel.removeAll(); expectedPowerPanel.updateUI(); selectedApplianceList.setSelectedIndex(-1); selectedAppliances.clear(); selectedApplianceList.setListData(new String[0]); selectedApplianceList.repaint(); timesHistogramRadioButton.setSelected(true); durationNormalRadioButton.setSelected(true); startGaussianRadioButton.setSelected(true); // Cleaning the Create Response Models tab components sensitivitySlider.setValue(50); awarenessSlider.setValue(50); normalCaseRadioButton.setSelected(true); previewResponseButton.setEnabled(false); createResponseButton.setEnabled(false); createResponseAllButton.setEnabled(false); pricingPreviewPanel.removeAll(); pricingPreviewPanel.updateUI(); responsePanel.removeAll(); responsePanel.updateUI(); activitySelectList.setSelectedIndex(-1); activityModels.clear(); activitySelectList.setListData(new String[0]); activitySelectList.repaint(); basicPricingSchemePane.setText("00:00-23:59-0.05"); newPricingSchemePane.setText(""); commitButton.setEnabled(false); dailyResponseButton.setEnabled(false); startResponseButton.setEnabled(false); // Cleaning the Export Models tab components exportModelList.setSelectedIndex(-1); exportModels.clear(); exportModelList.setListData(new String[0]); exportModelList.repaint(); exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); exportDailyButton.setEnabled(false); exportDurationButton.setEnabled(false); exportStartButton.setEnabled(false); exportStartBinnedButton.setEnabled(false); exportExpectedPowerButton.setEnabled(false); exportButton.setEnabled(false); exportAllBaseButton.setEnabled(false); exportAllResponseButton.setEnabled(false); householdNameTextField.setEnabled(false); // Disabling the necessary tabs tabbedPane.setEnabledAt(1, false); tabbedPane.setEnabledAt(2, false); tabbedPane.setEnabledAt(3, false); // Clearing the arrayList in need tempAppliances.clear(); tempActivities.clear(); // Removing temporary files Utils.cleanFiles(); trained = false; } }); singleApplianceRadioButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Single Appliance * radio button on the Data File panel of the Import Data tab. */ @Override public void actionPerformed(ActionEvent e) { consumptionPathField.setEnabled(false); consumptionBrowseButton.setEnabled(false); consumptionPathField.setText(""); } }); installationRadioButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Installation * radio button on the Data File panel of the Import Data tab. */ @Override public void actionPerformed(ActionEvent e) { consumptionPathField.setEnabled(false); consumptionBrowseButton.setEnabled(false); consumptionPathField.setText(""); } }); importDataButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Import Data * button on the Data File panel of the Import Data tab. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Change the state of some components installationRadioButton.setEnabled(false); singleApplianceRadioButton.setEnabled(false); importDataButton.setEnabled(false); dataBrowseButton.setEnabled(false); activePowerRadioButton.setEnabled(false); activeAndReactivePowerRadioButton.setEnabled(false); // Check if both active and reactive activeOnly data set are available boolean power = activePowerRadioButton.isSelected(); int parse = -1; // Parsing the measurements file try { parse = Utils.parseMeasurementsFile(pathField.getText(), power); } catch (IOException e2) { e2.printStackTrace(); } // If everything is OK if (parse == -1) { try { // Creating new installation installation = new Installation(pathField.getText(), power); } catch (IOException e2) { e2.printStackTrace(); } // Show the measurements in the preview chart ChartPanel chartPanel = null; try { chartPanel = installation.measurementsChart(); } catch (IOException e1) { e1.printStackTrace(); } dataReviewPanel.add(chartPanel, BorderLayout.CENTER); dataReviewPanel.validate(); disaggregateButton.setEnabled(false); createEventsButton.setEnabled(false); // Enable the appropriate buttons given source of measurements if (installationRadioButton.isSelected()) { disaggregateButton.setEnabled(true); } else if (singleApplianceRadioButton.isSelected()) { consumptionPathField.setEnabled(true); consumptionBrowseButton.setEnabled(true); } // Add installation to the export models list exportModels.addElement(installation.toString()); exportModels.addElement(installation.getPerson().getName()); householdNameTextField.setText(installation.getName()); // Enable Export Models tab exportModelList.setEnabled(true); exportModelList.setModel(exportModels); tabbedPane.setEnabledAt(3, true); } // In case of an error during the measurement parsing show the line of // error and reset settings. else { JFrame error = new JFrame(); JOptionPane.showMessageDialog(error, "Parsing measurements file failed. The problem seems to be in line " + parse + ".Check the selected buttons and the file provided and try again.", "Inane error", JOptionPane.ERROR_MESSAGE); resetButton.doClick(); } } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); disaggregateButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Disaggregate * button on the Data File panel of the Import Data tab in order to * automatically analyse the data set and extract the appliances and * activities within. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Get auxiliary files containing appliances and activities which are // the output of the disaggregation process. String filename = pathField.getText(); File file = new File(filename); String folder = file.getParent() + "/"; String fileNameWithExtension = file.getName(); String fileName = file.getName().substring(0, file.getName().length() - 4); filename = pathField.getText().substring(0, pathField.getText().length() - 4); File appliancesFile = new File(Constants.resultFolder + fileName + "ApplianceList.csv"); File activitiesFile = new File(Constants.resultFolder + fileName + "ActivityList.csv"); if ((Constants.USE_FILES == false) || (!appliancesFile.exists() && !activitiesFile.exists())) { try { System.out.println("IN!!!"); Disaggregate dis = new Disaggregate(folder, fileNameWithExtension); appliancesFile = new File(Constants.resultFolder + fileName + "ApplianceList.csv"); activitiesFile = new File(Constants.resultFolder + fileName + "ActivityList.csv"); } catch (Exception e2) { System.out.println("Missing File"); e2.printStackTrace(); } } // If these exist, disaggregation was successful and the procedure can // continue if (appliancesFile.exists() && activitiesFile.exists()) { // Read appliance file and start appliance parsing Scanner input = null; try { input = new Scanner(appliancesFile); } catch (FileNotFoundException e1) { e1.printStackTrace(); } String nextLine; String[] line; while (input.hasNext()) { nextLine = input.nextLine(); line = nextLine.split(","); String name = line[1] + " " + line[0]; // String activity = line[1]; String activity = name; String[] temp = line[0].split(" "); String type = ""; if (temp.length == 1) type = temp[0]; else { for (int i = 0; i < temp.length - 1; i++) type += temp[i] + " "; type = type.trim(); } boolean refFlag = activity.contains("Refrigeration"); boolean wmFlag = name.contains("Washing"); double p = 0, q = 0; int distance = 0, duration = 0; if (refFlag) { p = Double.parseDouble(line[2]); q = Double.parseDouble(line[3]); duration = Integer.parseInt(line[4]); distance = Integer.parseInt(line[5]); // For each appliance found in the file, an temporary Appliance // Entity is created. tempAppliances.add(new ApplianceTemp(name, installation.getName(), type, activity, p, q, duration, distance)); } else if (wmFlag) { double[] pValues = new double[line.length / 2 - 1]; double[] qValues = new double[line.length / 2 - 1]; // For each appliance found in the file, an temporary Appliance // Entity is created. for (int i = 0; i < pValues.length; i++) { pValues[i] = Double.parseDouble(line[2 + 2 * i]); qValues[i] = Double.parseDouble(line[3 + 2 * i]); } tempAppliances.add(new ApplianceTemp(name, installation.getName(), type, activity, pValues, qValues)); } else { p = Double.parseDouble(line[2]); q = Double.parseDouble(line[3]); // For each appliance found in the file, an temporary Appliance // Entity is created. tempAppliances .add(new ApplianceTemp(name, installation.getName(), type, activity, p, q)); } } System.out.println("Appliances:" + tempAppliances.size()); input.close(); // Read activity file and start activity parsing try { input = new Scanner(activitiesFile); } catch (FileNotFoundException e1) { System.out.println("Problem with activity file."); e1.printStackTrace(); } while (input.hasNext()) { nextLine = input.nextLine(); line = nextLine.split(","); // System.out.println(Arrays.toString(line)); // String name = line[0]; // String activity = line[1]; String activity = line[1] + " " + line[0]; String type = line[1]; int start = Integer.parseInt(line[2]); int end = Integer.parseInt(line[3]); // Search for existing activity int activityIndex = findActivity(activity); // if not found, create a new one if (activityIndex == -1) { // System.out.println("In!"); ActivityTemp newActivity = new ActivityTemp(activity, type); newActivity.addEvent(start, end); tempActivities.add(newActivity); // System.out.println(tempActivities.toString()); } // else add data to the found activity else tempActivities.get(activityIndex).addEvent(start, end); } // This is hard copied for now ArrayList<ActivityTemp> activities = findAllActivity("Refrigeration"); for (ActivityTemp activityTemp : activities) { tempActivities.remove(activityTemp); System.out.println("Refrigeration Removed"); } int index = findActivity("Standby"); if (index != -1) { tempActivities.remove(index); System.out.println("Standby Consumption Removed"); } // TODO Add these lines in case we want to remove activities with // small sampling number // System.out.println(tempActivities.size()); // for (int i = tempActivities.size() - 1; i >= 0; i--) // if (tempActivities.get(i).getEvents().size() < threshold) // tempActivities.remove(i); // Create an event file for each activity, in order to be able to // use // it for training the behaviour models if asked from the user for (int i = 0; i < tempActivities.size(); i++) { // tempActivities.get(i).status(); try { tempActivities.get(i).createEventFile(); } catch (IOException e1) { System.out.println("Problem with creating events file."); e1.printStackTrace(); } } input.close(); // Add each found appliance (after converting temporary appliance to // normal appliance) in the installation Entity, to the detected // appliance and export models list for (ApplianceTemp temp : tempAppliances) { Appliance tempAppliance = temp.toAppliance(); installation.addAppliance(tempAppliance); detectedAppliances.addElement(tempAppliance.toString()); exportModels.addElement(tempAppliance.toString()); } // Add appliances corresponding to each activity, remove activities // without appliances and add activities to the selected activities // list. for (int i = tempActivities.size() - 1; i >= 0; i--) { tempActivities.get(i).setAppliances(findAppliances(tempActivities.get(i))); if (tempActivities.get(i).getAppliances().size() == 0) { tempActivities.remove(i); } else selectedAppliances.addElement(tempActivities.get(i).toString()); } } // In case of an error. else { int temp = 8 + ((int) (Math.random() * 2)); for (int i = 0; i < temp; i++) { String name = "Appliance " + i; String powerModel = ""; String reactiveModel = ""; int tempIndex = i % 5; switch (tempIndex) { case 0: powerModel = "{\"n\":1,\"params\":[{\"n\":1,\"values\":[{\"p\":1900,\"d\":1,\"s\":0}]},{\"n\":0,\"values\":[{\"p\":300,\"d\":1,\"s\":0}]}]}"; reactiveModel = "{\"n\":1,\"params\":[{\"n\":1,\"values\":[{\"q\":-40,\"d\":1,\"s\":0}]},{\"n\":0,\"values\":[{\"q\":-10,\"d\":1,\"s\":0}]}]}"; break; case 1: powerModel = "{ \"n\" : 0, \"params\" : [{ \"n\" : 1, \"values\" : [ {\"p\" : 140.0, \"d\" : 20, \"s\": 0.0}]}]}"; reactiveModel = "{ \"n\" : 0, \"params\" : [{ \"n\" : 1, \"values\" : [ {\"q\" : 120.0, \"d\" : 20, \"s\": 0.0}]}]}"; break; case 2: powerModel = "{ \"n\" : 0, \"params\" : [{ \"n\" : 1, \"values\" : [ {\"p\" : 95.0, \"d\" : 20, \"s\": 0.0}, {\"p\" :80.0, \"d\" : 18, \"s\": 0.0}, {\"p\" : 0.0, \"d\" : 73, \"s\": 0.0}]}]}]}"; reactiveModel = "{ \"n\" : 0, \"params\" : [{ \"n\" : 1, \"values\" : [ {\"q\" : 0.0, \"d\" : 20, \"s\": 0.0}, {\"q\" : 0.0, \"d\" : 18, \"s\": 0.0}, {\"q\" : 0.0, \"d\" : 73, \"s\": 0.0}]}]}]}"; break; case 3: powerModel = "{ \"n\" : 0, \"params\" : [{ \"n\" : 1, \"values\" : [ {\"p\" : 30.0, \"d\" : 20, \"s\": 0.0}]}]}"; reactiveModel = "{ \"n\" : 0, \"params\" : [{ \"n\" : 1, \"values\" : [ {\"q\" : -5.0, \"d\" : 20, \"s\": 0.0}]}]}"; break; case 4: powerModel = "{\"n\":1,\"params\":[{\"n\":1,\"values\":[{\"p\":150,\"d\":25,\"s\":0},{\"p\":2000,\"d\":13,\"s\":0},{\"p\":100,\"d\":62,\"s\":0}]}]}"; reactiveModel = "{\"n\":1,\"params\":[{\"n\":1,\"values\":[{\"q\":400,\"d\":25,\"s\":0},{\"q\":200,\"d\":13,\"s\":0},{\"q\":300,\"d\":62,\"s\":0}]}]}"; break; } Appliance tempAppliance = new Appliance(name, installation.getName(), powerModel, reactiveModel, "Demo/eventsAll" + tempIndex + ".csv"); installation.addAppliance(tempAppliance); detectedAppliances.addElement(tempAppliance.toString()); selectedAppliances.addElement(tempAppliance.toString()); exportModels.addElement(tempAppliance.toString()); } } // Enable all appliance/activity lists detectedApplianceList.setEnabled(true); detectedApplianceList.setModel(detectedAppliances); detectedApplianceList.setSelectedIndex(0); tabbedPane.setEnabledAt(1, true); selectedApplianceList.setEnabled(true); selectedApplianceList.setModel(selectedAppliances); // exportModelList.setEnabled(true); // exportModelList.setModel(exportModels); // tabbedPane.setEnabledAt(3, true); // Disable unnecessary buttons. disaggregateButton.setEnabled(false); createEventsButton.setEnabled(false); } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); createEventsButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Create Events * button on the Data File panel of the Import Data tab. This button is * used when there is a single appliance with an known consumption model * so that the events can be extracted automatically from the data set. * Used for presentation purposes only since is depricated by the * disaggregation function. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Parse the consumption model file File file = new File(consumptionPathField.getText()); String temp = file.getName(); temp = temp.replace(".", " "); String name = temp.split(" ")[0]; Appliance appliance = null; try { int rand = (int) (Math.random() * 5); appliance = new Appliance(name, consumptionPathField.getText(), consumptionPathField.getText(), "Demo/eventsAll" + rand + ".csv", installation, activePowerRadioButton.isSelected()); } catch (IOException e1) { e1.printStackTrace(); } // Add appliance to the installation entity installation.addAppliance(appliance); // Enable all appliance/activity lists detectedAppliances.addElement(appliance.toString()); selectedAppliances.addElement(appliance.toString()); exportModels.addElement(appliance.toString()); detectedApplianceList.setEnabled(true); detectedApplianceList.setModel(detectedAppliances); detectedApplianceList.setSelectedIndex(0); tabbedPane.setEnabledAt(1, true); selectedApplianceList.setEnabled(true); selectedApplianceList.setModel(selectedAppliances); // exportModelList.setEnabled(true); // exportModelList.setModel(exportModels); // tabbedPane.setEnabledAt(3, true); // Disable unnecessary buttons. disaggregateButton.setEnabled(false); createEventsButton.setEnabled(false); } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); // APPLIANCE DETECTION // detectedApplianceList.addListSelectionListener(new ListSelectionListener() { /** * This function is called when the user selects an appliance from the * list of Detected Appliances on the Disaggregation panel of the Import * Data tab. Then the corresponding consumption model is presented in the * Consumption Model Preview panel. */ @Override public void valueChanged(ListSelectionEvent e) { consumptionModelPanel.removeAll(); consumptionModelPanel.updateUI(); if (detectedAppliances.size() >= 1) { String selection = detectedApplianceList.getSelectedValue(); Appliance current = installation.findAppliance(selection); ChartPanel chartPanel = current.consumptionGraph(); consumptionModelPanel.add(chartPanel, BorderLayout.CENTER); consumptionModelPanel.validate(); } } }); // // TRAINING TAB // trainingTab.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent arg0) { selectedApplianceList.setSelectedIndex(0); } }); trainingButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Train button on * the Training Parameters panel of the Train Activity Models tab. It * contains the procedure needed to create an activity model based on the * event set of the appliance or activity. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); responsePanel.removeAll(); responsePanel.validate(); pricingPreviewPanel.removeAll(); pricingPreviewPanel.validate(); previewResponseButton.setEnabled(false); createResponseButton.setEnabled(false); createResponseAllButton.setEnabled(false); dailyResponseButton.setEnabled(false); startResponseButton.setEnabled(false); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Searching for existing activity or appliance. String selection = selectedApplianceList.getSelectedValue(); ActivityTemp activity = null; if (tempActivities.size() > 0) activity = tempActivities.get(findActivity(selection)); Appliance current = installation.findAppliance(selection); String startTime, duration, dailyTimes; // Check for the selected distribution methods for training. if (timesHistogramRadioButton.isSelected()) dailyTimes = "Histogram"; else if (timesNormalRadioButton.isSelected()) dailyTimes = "Normal"; else dailyTimes = "GMM"; if (durationHistogramRadioButton.isSelected()) duration = "Histogram"; else if (durationNormalRadioButton.isSelected()) duration = "Normal"; else duration = "GMM"; if (startHistogramRadioButton.isSelected()) startTime = "Histogram"; else if (startNormalRadioButton.isSelected()) startTime = "Normal"; else startTime = "GMM"; String[] distributions = { dailyTimes, duration, startTime, "Histogram" }; // If the selected object from the list is an appliance the training // procedure for the appliance begins. if (activity == null) { try { installation.getPerson().train(current, distributions); } catch (IOException e1) { e1.printStackTrace(); } } // If the selected object from the list is an activity the training // procedure for the activity begins. else { try { installation.getPerson().train(activity, distributions); } catch (IOException e1) { e1.printStackTrace(); } } // System.out.println("Training OK!"); distributionPreviewPanel.removeAll(); distributionPreviewPanel.updateUI(); expectedPowerPanel.removeAll(); expectedPowerPanel.updateUI(); // Show the distribution created on the Distribution Preview Panel ActivityModel activityModel = installation.getPerson().findActivity(selection, true); if (activityModel == null) activityModel = installation.getPerson().findActivity(current); ChartPanel chartPanel = activityModel.createDailyTimesDistributionChart(); distributionPreviewPanel.add(chartPanel, BorderLayout.CENTER); distributionPreviewPanel.validate(); chartPanel = activityModel.createExpectedPowerChart(); expectedPowerPanel.add(chartPanel, BorderLayout.CENTER); expectedPowerPanel.validate(); // Add the Activity model to the list of trained Activity models of // the Create Response Models tab int size = activitySelectList.getModel().getSize(); if (size > 0) { activityModels = (DefaultListModel<String>) activitySelectList.getModel(); if (activityModels.contains(activityModel.getName()) == false) activityModels.addElement(activityModel.getName()); } else { activityModels = new DefaultListModel<String>(); activityModels.addElement(activityModel.getName()); activitySelectList.setEnabled(true); } activitySelectList.setModel(activityModels); // Add the trained model to the export list also. size = exportModelList.getModel().getSize(); if (size > 0) { exportModels = (DefaultListModel<String>) exportModelList.getModel(); if (exportModels.contains(activityModel.getName()) == false) exportModels.addElement(activityModel.getName()); } else { exportModels = new DefaultListModel<String>(); exportModels.addElement(activityModel.getName()); exportModelList.setEnabled(true); } // Enable some buttons necessary to show the results. dailyTimesButton.setEnabled(true); durationButton.setEnabled(true); startTimeButton.setEnabled(true); startTimeBinnedButton.setEnabled(true); exportModelList.setModel(exportModels); exportDailyButton.setEnabled(true); exportDurationButton.setEnabled(true); exportStartButton.setEnabled(true); exportStartBinnedButton.setEnabled(true); tabbedPane.setEnabledAt(2, true); } finally { root.setCursor(Cursor.getDefaultCursor()); trained = true; } } }); trainAllButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Train All button on * the Training Parameters panel of the Train Activity Models tab. It * is iterating the aforementioned training procedure to each of the * objects on the list. */ @Override public void actionPerformed(ActionEvent e) { responsePanel.removeAll(); responsePanel.validate(); pricingPreviewPanel.removeAll(); pricingPreviewPanel.validate(); previewResponseButton.setEnabled(false); createResponseButton.setEnabled(false); createResponseAllButton.setEnabled(false); dailyResponseButton.setEnabled(false); startResponseButton.setEnabled(false); for (int i = 0; i < selectedApplianceList.getModel().getSize(); i++) { selectedApplianceList.setSelectedIndex(i); trainingButton.doClick(); } } }); dailyTimesButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Daily Times button on * the Distribution Preview panel of the Train Activity Models tab. It * shows the Daily Times Distribution for the selected object from the * list if available. */ @Override public void actionPerformed(ActionEvent arg0) { distributionPreviewPanel.removeAll(); distributionPreviewPanel.updateUI(); String selection = selectedApplianceList.getSelectedValue(); Appliance current = installation.findAppliance(selection); ActivityModel activityModel = installation.getPerson().findActivity(selection, true); if (activityModel == null) activityModel = installation.getPerson().findActivity(current); ChartPanel chartPanel = activityModel.createDailyTimesDistributionChart(); distributionPreviewPanel.add(chartPanel, BorderLayout.CENTER); distributionPreviewPanel.validate(); } }); startTimeBinnedButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Start Time Binned * button on the Distribution Preview panel of the Train Activity * Models tab. It shows the Start Time Binned Distribution for the * selected object from the list if available. */ @Override public void actionPerformed(ActionEvent arg0) { distributionPreviewPanel.removeAll(); distributionPreviewPanel.updateUI(); String selection = selectedApplianceList.getSelectedValue(); Appliance current = installation.findAppliance(selection); ActivityModel activityModel = installation.getPerson().findActivity(selection, true); if (activityModel == null) activityModel = installation.getPerson().findActivity(current); ChartPanel chartPanel = activityModel.createStartTimeBinnedDistributionChart(); distributionPreviewPanel.add(chartPanel, BorderLayout.CENTER); distributionPreviewPanel.validate(); } }); startTimeButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Start Time * button on the Distribution Preview panel of the Train Activity * Models tab. It shows the Start Time Distribution for the selected * object from the list if available. */ @Override public void actionPerformed(ActionEvent arg0) { distributionPreviewPanel.removeAll(); distributionPreviewPanel.updateUI(); String selection = selectedApplianceList.getSelectedValue(); Appliance current = installation.findAppliance(selection); ActivityModel activityModel = installation.getPerson().findActivity(selection, true); if (activityModel == null) activityModel = installation.getPerson().findActivity(current); ChartPanel chartPanel = activityModel.createStartTimeDistributionChart(); distributionPreviewPanel.add(chartPanel, BorderLayout.CENTER); distributionPreviewPanel.validate(); } }); durationButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Duration * button on the Distribution Preview panel of the Train Activity * Models tab. It shows the Duration Distribution for the selected * object from the list if available. */ @Override public void actionPerformed(ActionEvent arg0) { distributionPreviewPanel.removeAll(); distributionPreviewPanel.updateUI(); String selection = selectedApplianceList.getSelectedValue(); Appliance current = installation.findAppliance(selection); ActivityModel activityModel = installation.getPerson().findActivity(selection, true); if (activityModel == null) activityModel = installation.getPerson().findActivity(current); ChartPanel chartPanel = activityModel.createDurationDistributionChart(); distributionPreviewPanel.add(chartPanel, BorderLayout.CENTER); distributionPreviewPanel.validate(); } }); selectedApplianceList.addListSelectionListener(new ListSelectionListener() { /** * This function is called when the user selects an appliance or activity * from the list of Selected Appliances on the Appliance / Activity * Selection panel of the Train Activity Models tab. Then an example * corresponding consumption model is presented in the Consumption Model * Preview panel. */ @Override public void valueChanged(ListSelectionEvent arg0) { ChartPanel chartPanel = null, chartPanel2 = null, chartPanel3 = null; expectedPowerPanel.removeAll(); expectedPowerPanel.updateUI(); distributionPreviewPanel.removeAll(); distributionPreviewPanel.updateUI(); // If there are any appliances / activities on the list if (selectedAppliances.size() >= 1) { // Find the corresponding appliance / activity and show its // consumption model String selection = selectedApplianceList.getSelectedValue(); Appliance currentAppliance = installation.findAppliance(selection); ActivityModel activityModel = installation.getPerson().findActivity(selection, true); // If there is also an Activity model trained, show the corresponding // distribution charts on the Distribution Preview panel if (currentAppliance != null) activityModel = installation.getPerson().findActivity(currentAppliance); if (activityModel == null) activityModel = installation.getPerson().findActivity(selection, true); if (activityModel != null) { dailyTimesButton.setEnabled(true); durationButton.setEnabled(true); startTimeButton.setEnabled(true); startTimeBinnedButton.setEnabled(true); chartPanel2 = activityModel.createDailyTimesDistributionChart(); distributionPreviewPanel.add(chartPanel2, BorderLayout.CENTER); distributionPreviewPanel.validate(); distributionPreviewPanel.updateUI(); chartPanel3 = activityModel.createExpectedPowerChart(); expectedPowerPanel.add(chartPanel3, BorderLayout.CENTER); expectedPowerPanel.validate(); expectedPowerPanel.updateUI(); } else { dailyTimesButton.setEnabled(false); durationButton.setEnabled(false); startTimeButton.setEnabled(false); startTimeBinnedButton.setEnabled(false); } } } }); // RESPONSE TAB // createResponseTab.addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent arg0) { activitySelectList.setSelectedIndex(0); } @Override public void componentShown(ComponentEvent arg0) { activitySelectList.setSelectedIndex(0); } }); previewResponseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Preview Response * button on the Response Parameters panel of the Create Response Models * tab. This button is enabled after selecting activity model, response * type and pricing for testing and presents a preview of the response * model that may be extracted. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); responsePanel.removeAll(); // Find the selected activity ActivityModel activity = installation.getPerson() .findActivity(activitySelectList.getSelectedValue(), false); int response = -1; // Check for the selected response type if (optimalCaseRadioButton.isSelected()) response = 0; else if (normalCaseRadioButton.isSelected()) response = 1; else response = 2; // Parse the pricing schemes double[] basicScheme = Utils.parseScheme(basicPricingSchemePane.getText()); double[] newScheme = Utils.parseScheme(newPricingSchemePane.getText()); float awareness = (float) (awarenessSlider.getValue()) / 100; float sensitivity = (float) (sensitivitySlider.getValue()) / 100; System.out.println("Awareness: " + awareness + " Sensitivity: " + sensitivity); // Create a preview chart of the response model ChartPanel chartPanel = installation.getPerson().previewResponse(activity, response, basicScheme, newScheme, awareness, sensitivity); responsePanel.add(chartPanel, BorderLayout.CENTER); responsePanel.validate(); createResponseButton.setEnabled(true); createResponseAllButton.setEnabled(true); dailyResponseButton.setEnabled(true); startResponseButton.setEnabled(true); } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); createResponseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Create Response Model * button on the Response Parameters panel of the Create Response Models * tab. This button is enabled after preview results of the selected * activity model, response type and pricing for testing and creates the * response model for the user. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); int responseType = -1; String responseString = ""; // Check for the selected response type if (optimalCaseRadioButton.isSelected()) { responseType = 0; responseString = "Optimal"; } else if (normalCaseRadioButton.isSelected()) { responseType = 1; responseString = "Normal"; } else if (discreteCaseRadioButton.isSelected()) { responseType = 2; responseString = "Discrete"; } // Parse the pricing schemes double[] basicScheme = Utils.parseScheme(basicPricingSchemePane.getText()); double[] newScheme = Utils.parseScheme(newPricingSchemePane.getText()); // Create the response model ActivityModel activity = installation.getPerson() .findActivity(activitySelectList.getSelectedValue(), false); String response = ""; float awareness = (float) (awarenessSlider.getValue()) / 100; float sensitivity = (float) (sensitivitySlider.getValue()) / 100; System.out.println("Awareness: " + awareness + " Sensitivity: " + sensitivity); try { response = installation.getPerson().createResponse(activity, responseType, basicScheme, newScheme, awareness, sensitivity); } catch (IOException exc) { exc.printStackTrace(); } // Add the response model extracted to the export model list. int size = exportModelList.getModel().getSize(); // System.out.println(size); if (size > 0) { exportModels = (DefaultListModel<String>) exportModelList.getModel(); String response2 = "", response3 = ""; if (responseString.equalsIgnoreCase("Optimal")) { response2 = response.replace(responseString, "Normal"); response3 = response.replace(responseString, "Discrete"); } else if (responseString.equalsIgnoreCase("Normal")) { response2 = response.replace(responseString, "Optimal"); response3 = response.replace(responseString, "Discrete"); } else { response2 = response.replace(responseString, "Optimal"); response3 = response.replace(responseString, "Normal"); } if (exportModels.contains(response2)) exportModels.removeElement(response2); if (exportModels.contains(response3)) exportModels.removeElement(response3); if (exportModels.contains(response) == false) exportModels.addElement(response); } else { exportModels = new DefaultListModel<String>(); exportModels.addElement(response); exportModelList.setEnabled(true); } exportModelList.setModel(exportModels); if (manyFlag == false) { JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The response model " + response + " was created successfully", "Response Model Created", JOptionPane.INFORMATION_MESSAGE); } } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); createResponseAllButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Create Response All * button on the Response Parameters panel of the Create Response Models * tab. This is achieved by iterating the procedure above for all the * available activity models in the list. */ @Override public void actionPerformed(ActionEvent arg0) { manyFlag = true; for (int i = 0; i < activitySelectList.getModel().getSize(); i++) { activitySelectList.setSelectedIndex(i); createResponseButton.doClick(); } JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The response models were created successfully", "Response Models Created", JOptionPane.INFORMATION_MESSAGE); manyFlag = false; } }); newPricingSchemePane.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent arg0) { commitButton.setEnabled(true); } }); basicPricingSchemePane.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent arg0) { commitButton.setEnabled(true); } }); commitButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Commit button on the * Pricing Scheme panel of the Create Response Models tab. This button is * enabled after adding the two pricing schemes that are prerequisites for * the creation of a response model. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean basicScheme = false; boolean newScheme = false; int parseBasic = 0; int parseNew = 0; pricingPreviewPanel.removeAll(); // Check if both pricing schemes are entered if (basicPricingSchemePane.getText().equalsIgnoreCase("") == false) basicScheme = true; if (newPricingSchemePane.getText().equalsIgnoreCase("") == false) newScheme = true; // Parse the pricing schemes for errors if (basicScheme) parseBasic = Utils.parsePricingScheme(basicPricingSchemePane.getText()); if (newScheme) parseNew = Utils.parsePricingScheme(newPricingSchemePane.getText()); // If errors are found then present the line the error may be at if (parseBasic != -1) { JFrame error = new JFrame(); JOptionPane.showMessageDialog(error, "Basic Pricing Scheme is not defined correctly. Please check your input in line " + parseBasic + " and try again.", "Inane error", JOptionPane.ERROR_MESSAGE); } else if (parseNew != -1) { JFrame error = new JFrame(); JOptionPane.showMessageDialog(error, "New Pricing Scheme is not defined correctly. Please check your input in line " + parseNew + " and try again.", "Inane error", JOptionPane.ERROR_MESSAGE); } // If no errors are found make a preview chart of the two pricing // schemes else { if (basicScheme && newScheme) { ChartPanel chartPanel = ChartUtils.parsePricingScheme(basicPricingSchemePane.getText(), newPricingSchemePane.getText()); pricingPreviewPanel.add(chartPanel, BorderLayout.CENTER); pricingPreviewPanel.validate(); previewResponseButton.setEnabled(true); } else { JFrame error = new JFrame(); JOptionPane.showMessageDialog(error, "You have not defined both pricing schemes.Please check your input and try again.", "Inane error", JOptionPane.ERROR_MESSAGE); previewResponseButton.setEnabled(false); } } responsePanel.removeAll(); responsePanel.validate(); createResponseButton.setEnabled(false); createResponseAllButton.setEnabled(false); dailyResponseButton.setEnabled(false); startResponseButton.setEnabled(false); } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); startResponseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the start time button on * the Preview Response panel of the Create Response Models tab. This * button is enabled after the user has pressed the Response Preview * button in order to see the results of his pricing scheme on a activity * model. It shows the changes in the start time distribution. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); responsePanel.removeAll(); // Find the selected activity ActivityModel activity = installation.getPerson() .findActivity(activitySelectList.getSelectedValue(), false); int response = -1; // Check for the selected response type if (optimalCaseRadioButton.isSelected()) response = 0; else if (normalCaseRadioButton.isSelected()) response = 1; else response = 2; // Parse the pricing schemes double[] basicScheme = Utils.parseScheme(basicPricingSchemePane.getText()); double[] newScheme = Utils.parseScheme(newPricingSchemePane.getText()); float awareness = (float) (awarenessSlider.getValue()) / 100; float sensitivity = (float) (sensitivitySlider.getValue()) / 100; System.out.println("Awareness: " + awareness + " Sensitivity: " + sensitivity); // Create a preview chart of the response model ChartPanel chartPanel = installation.getPerson().previewResponse(activity, response, basicScheme, newScheme, awareness, sensitivity); responsePanel.add(chartPanel, BorderLayout.CENTER); responsePanel.validate(); createResponseButton.setEnabled(true); createResponseAllButton.setEnabled(true); dailyResponseButton.setEnabled(true); startResponseButton.setEnabled(true); } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); dailyResponseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the start time button on * the Preview Response panel of the Create Response Models tab. This * button is enabled after the user has pressed the Response Preview * button in order to see the results of his pricing scheme on a activity * model. It shows the changes in the daily times distribution. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); responsePanel.removeAll(); // Find the selected activity ActivityModel activity = installation.getPerson() .findActivity(activitySelectList.getSelectedValue(), false); // Parse the pricing schemes double[] basicScheme = Utils.parseScheme(basicPricingSchemePane.getText()); double[] newScheme = Utils.parseScheme(newPricingSchemePane.getText()); float awareness = (float) (awarenessSlider.getValue()) / 100; float sensitivity = (float) (sensitivitySlider.getValue()) / 100; System.out.println("Awareness: " + awareness + " Sensitivity: " + sensitivity); // Create a preview chart of the response model ChartPanel chartPanel = installation.getPerson().previewDailyResponse(activity, basicScheme, newScheme, awareness, sensitivity); responsePanel.add(chartPanel, BorderLayout.CENTER); responsePanel.validate(); createResponseButton.setEnabled(true); createResponseAllButton.setEnabled(true); dailyResponseButton.setEnabled(true); startResponseButton.setEnabled(true); } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); // EXPORT TAB // exportTab.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent arg0) { exportModelList.setSelectedIndex(0); } }); exportModelList.addListSelectionListener(new ListSelectionListener() { /** * This function is called when the user selects an entity from the * list of models on the Model Export Selection panel of the Export Models * tab. Then the corresponding preview of the entity model is presented in * the * Export Model Preview panel. */ @Override public void valueChanged(ListSelectionEvent arg0) { if (tabbedPane.getSelectedIndex() == 3) { exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); // Checking if the list has any object if (exportModels.size() > 1) { String selection = exportModelList.getSelectedValue(); // Check to see what type of entity is selected (Installation, // Person, Appliance, Activity, Response) Appliance appliance = installation.findAppliance(selection); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); // Create the appropriate chart for the selected entity and show it. ChartPanel chartPanel = null; if (selection.equalsIgnoreCase(installation.getName())) { try { chartPanel = installation.measurementsChart(); exportDailyButton.setEnabled(false); exportDurationButton.setEnabled(false); exportStartButton.setEnabled(false); exportStartBinnedButton.setEnabled(false); if (trained) exportExpectedPowerButton.setEnabled(true); else exportExpectedPowerButton.setEnabled(false); } catch (IOException e1) { e1.printStackTrace(); } } else if (selection.equalsIgnoreCase(installation.getPerson().getName())) { chartPanel = installation.getPerson().statisticGraphs(); exportDailyButton.setEnabled(false); exportDurationButton.setEnabled(false); exportStartButton.setEnabled(false); exportStartBinnedButton.setEnabled(false); exportExpectedPowerButton.setEnabled(false); } else if (appliance != null) { chartPanel = appliance.consumptionGraph(); exportDailyButton.setEnabled(false); exportDurationButton.setEnabled(false); exportStartButton.setEnabled(false); exportStartBinnedButton.setEnabled(false); exportExpectedPowerButton.setEnabled(false); } else if (activity != null) { chartPanel = activity.createDailyTimesDistributionChart(); activity.status(); exportDailyButton.setEnabled(true); exportDurationButton.setEnabled(true); exportStartButton.setEnabled(true); exportStartBinnedButton.setEnabled(true); exportExpectedPowerButton.setEnabled(true); } else if (response != null) { chartPanel = response.createDailyTimesDistributionChart(); exportDailyButton.setEnabled(true); exportDurationButton.setEnabled(true); exportStartButton.setEnabled(true); exportStartBinnedButton.setEnabled(true); exportExpectedPowerButton.setEnabled(true); } exportPreviewPanel.add(chartPanel, BorderLayout.CENTER); exportPreviewPanel.validate(); } } } }); exportDailyButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Daily Times * button on the Entity Preview panel of the Export Models tab. It shows * the Daily Times Distribution for the selected object from the list. */ @Override public void actionPerformed(ActionEvent arg0) { exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); String selection = exportModelList.getSelectedValue(); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); ChartPanel chartPanel = null; if (activity != null) chartPanel = activity.createDailyTimesDistributionChart(); else chartPanel = response.createDailyTimesDistributionChart(); exportPreviewPanel.add(chartPanel, BorderLayout.CENTER); exportPreviewPanel.validate(); } }); exportStartBinnedButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Start Time Binned * button on the Entity Preview panel of the Export Models tab. It shows * the Start Time Binned Distribution for the selected object from the * list. */ @Override public void actionPerformed(ActionEvent arg0) { exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); String selection = exportModelList.getSelectedValue(); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); ChartPanel chartPanel = null; if (activity != null) chartPanel = activity.createStartTimeBinnedDistributionChart(); else chartPanel = response.createStartTimeBinnedDistributionChart(); exportPreviewPanel.add(chartPanel, BorderLayout.CENTER); exportPreviewPanel.validate(); } }); exportStartButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Start Time * button on the Entity Preview panel of the Export Models tab. It shows * the Start Time Distribution for the selected object from the list. */ @Override public void actionPerformed(ActionEvent arg0) { exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); String selection = exportModelList.getSelectedValue(); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); ChartPanel chartPanel = null; if (activity != null) chartPanel = activity.createStartTimeDistributionChart(); else chartPanel = response.createStartTimeDistributionChart(); exportPreviewPanel.add(chartPanel, BorderLayout.CENTER); exportPreviewPanel.validate(); } }); exportDurationButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Duration * button on the Entity Preview panel of the Export Models tab. It shows * the Duration Distribution for the selected object from the list. */ @Override public void actionPerformed(ActionEvent arg0) { exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); String selection = exportModelList.getSelectedValue(); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); ChartPanel chartPanel = null; if (activity != null) chartPanel = activity.createDurationDistributionChart(); else chartPanel = response.createDurationDistributionChart(); exportPreviewPanel.add(chartPanel, BorderLayout.CENTER); exportPreviewPanel.validate(); } }); exportExpectedPowerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { exportPreviewPanel.removeAll(); exportPreviewPanel.updateUI(); String selection = exportModelList.getSelectedValue(); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); ChartPanel chartPanel = null; if (selection.equalsIgnoreCase(installation.getName())) chartPanel = installation.createExpectedPowerChart(); else if (activity != null) chartPanel = activity.createExpectedPowerChart(); else chartPanel = response.createExpectedPowerChart(); exportPreviewPanel.add(chartPanel, BorderLayout.CENTER); exportPreviewPanel.validate(); } }); connectButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Connect button on the * Connection Properties panel of the Export Models tab. It helps the user * to connect to his Cassandra Library and export the models he created * there. */ @Override public void actionPerformed(ActionEvent e) { boolean result = false; // Reads the user credentials and the server to connect to. try { APIUtilities.setUrl(urlTextField.getText()); result = APIUtilities.sendUserCredentials(usernameTextField.getText(), passwordField.getPassword()); } catch (Exception e1) { e1.printStackTrace(); } // If the use credentials are correct if (result) { exportButton.setEnabled(true); exportAllBaseButton.setEnabled(true); exportAllResponseButton.setEnabled(true); householdNameTextField.setEnabled(true); } // Else a error message appears. else { JFrame error = new JFrame(); JOptionPane.showMessageDialog(error, "User Credentials are not correct! Please try again.", "Inane error", JOptionPane.ERROR_MESSAGE); passwordField.setText(""); } } }); passwordField.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent e) { String pass = String.valueOf(passwordField.getPassword()); if (pass.equals("")) { connectButton.setEnabled(false); } else connectButton.setEnabled(true); } }); exportButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Export button on the * Connection Properties panel of the Export Models tab. The entity model * selected from the list is then exported to the User Library in * Cassandra Platform. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Parsing the selected entity and find out what type of entity it is. String selection = exportModelList.getSelectedValue(); Appliance appliance = installation.findAppliance(selection); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); // If it is installation if (selection.equalsIgnoreCase(installation.getName())) { String oldName = installation.getName(); installation.setName(householdNameTextField.getText()); try { installation.setInstallationID(APIUtilities .sendEntity(installation.toJSON(APIUtilities.getUserID()).toString(), "/inst")); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } installation.setName(oldName); JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The installation model " + installation.getName() + " was exported successfully", "Installation Model Exported", JOptionPane.INFORMATION_MESSAGE); } // If it is person else if (selection.equalsIgnoreCase(installation.getPerson().getName())) { try { installation.getPerson().setPersonID(APIUtilities.sendEntity( installation.getPerson().toJSON(APIUtilities.getUserID()).toString(), "/pers")); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The person model " + installation.getPerson().getName() + " was exported successfully", "Person Model Exported", JOptionPane.INFORMATION_MESSAGE); } // If it is appliance else if (appliance != null) { try { appliance.setApplianceID(APIUtilities .sendEntity(appliance.toJSON(APIUtilities.getUserID()).toString(), "/app")); APIUtilities.sendEntity(appliance.powerConsumptionModelToJSON().toString(), "/consmod"); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The appliance model " + appliance.getName() + " was exported successfully", "Appliance Model Exported", JOptionPane.INFORMATION_MESSAGE); } // If it is activity else if (activity != null) { String[] applianceTemp = new String[activity.getAppliancesOf().length]; String activityTemp = ""; String durationTemp = ""; String dailyTemp = ""; String startTemp = ""; // For each appliance that participates in the activity for (int i = 0; i < activity.getAppliancesOf().length; i++) { Appliance activityAppliance = activity.getAppliancesOf()[i]; try { // In case the appliances contained in the Activity model are // not // in the database, we create the object there before sending // the // activity model if (activityAppliance.getApplianceID().equalsIgnoreCase("")) { activityAppliance.setApplianceID(APIUtilities.sendEntity( activityAppliance.toJSON(APIUtilities.getUserID()).toString(), "/app")); APIUtilities.sendEntity( activityAppliance.powerConsumptionModelToJSON().toString(), "/consmod"); } applianceTemp[i] = activityAppliance.getApplianceID(); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } try { String[] appliancesID = applianceTemp; // Creating the JSON of the activity model activity.setActivityModelID(APIUtilities.sendEntity( activity.toJSON(appliancesID, APIUtilities.getUserID()).toString(), "/actmod")); activityTemp = activity.getActivityModelID(); // Creating the JSON of the distributions activity.getDailyTimes().setDistributionID(APIUtilities.sendEntity( activity.getDailyTimes().toJSON(activityTemp).toString(), "/distr")); activity.setDailyID(activity.getDailyTimes().getDistributionID()); dailyTemp = activity.getDailyID(); activity.getDuration().setDistributionID(APIUtilities .sendEntity(activity.getDuration().toJSON(activityTemp).toString(), "/distr")); activity.setDurationID(activity.getDuration().getDistributionID()); durationTemp = activity.getDurationID(); activity.getStartTime().setDistributionID(APIUtilities .sendEntity(activity.getStartTime().toJSON(activityTemp).toString(), "/distr")); activity.setStartID(activity.getStartTime().getDistributionID()); startTemp = activity.getStartID(); // Adding the JSON of the distributions to the activity model APIUtilities.updateEntity( activity.toJSON(appliancesID, APIUtilities.getUserID()).toString(), "/actmod", activityTemp); } catch (AuthenticationException | NoSuchAlgorithmException | IOException e1) { e1.printStackTrace(); } JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The activity model " + activity.getName() + " was exported successfully", "Activity Model Exported", JOptionPane.INFORMATION_MESSAGE); } // If it is response else if (response != null) { String[] applianceTemp = new String[response.getAppliancesOf().length]; String responseTemp = ""; String durationTemp = ""; String dailyTemp = ""; String startTemp = ""; // For each appliance that participates in the activity for (int i = 0; i < response.getAppliancesOf().length; i++) { Appliance responseAppliance = response.getAppliancesOf()[i]; try { // In case the appliances contained in the Activity model are // not // in the database, we create the object there before sending // the // activity model if (responseAppliance.getApplianceID().equalsIgnoreCase("")) { responseAppliance.setApplianceID(APIUtilities.sendEntity( responseAppliance.toJSON(APIUtilities.getUserID()).toString(), "/app")); APIUtilities.sendEntity( responseAppliance.powerConsumptionModelToJSON().toString(), "/consmod"); } applianceTemp[i] = responseAppliance.getApplianceID(); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } try { String[] appliancesID = applianceTemp; // Creating the JSON of the response response.setActivityModelID(APIUtilities.sendEntity( response.toJSON(appliancesID, APIUtilities.getUserID()).toString(), "/actmod")); responseTemp = response.getActivityModelID(); // Creating the JSON of the distributions response.getDailyTimes().setDistributionID(APIUtilities.sendEntity( response.getDailyTimes().toJSON(responseTemp).toString(), "/distr")); response.setDailyID(response.getDailyTimes().getDistributionID()); dailyTemp = response.getDailyID(); response.getDuration().setDistributionID(APIUtilities .sendEntity(response.getDuration().toJSON(responseTemp).toString(), "/distr")); response.setDurationID(response.getDuration().getDistributionID()); durationTemp = response.getDurationID(); response.getStartTime().setDistributionID(APIUtilities .sendEntity(response.getStartTime().toJSON(responseTemp).toString(), "/distr")); response.setStartID(response.getStartTime().getDistributionID()); startTemp = response.getStartID(); // Adding the JSON of the distributions to the activity model APIUtilities.updateEntity( response.toJSON(appliancesID, APIUtilities.getUserID()).toString(), "/actmod", responseTemp); } catch (AuthenticationException | NoSuchAlgorithmException | IOException e1) { e1.printStackTrace(); } JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The response model " + response.getName() + " was exported successfully", "Response Model Exported", JOptionPane.INFORMATION_MESSAGE); } } finally { root.setCursor(Cursor.getDefaultCursor()); } } }); exportAllBaseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Export All Base * button on the Connection Properties panel of the Export Models tab. The * export procedure above is iterated through all the entities available * on the list except for the response models. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (int i = 0; i < exportModelList.getModel().getSize(); i++) { exportModelList.setSelectedIndex(i); String selection = exportModelList.getSelectedValue(); Appliance appliance = installation.findAppliance(selection); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); if (selection.equalsIgnoreCase(installation.getName())) { String oldName = installation.getName(); try { installation.setName(householdNameTextField.getText() + " Base"); installation.setInstallationID(APIUtilities.sendEntity( installation.toJSON(APIUtilities.getUserID()).toString(), "/inst")); installation.setName(oldName); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } else if (selection.equalsIgnoreCase(installation.getPerson().getName())) { try { installation.getPerson().setPersonID(APIUtilities.sendEntity(installation .getPerson().toJSON(installation.getInstallationID()).toString(), "/pers")); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } else if (appliance != null) { try { appliance.setApplianceID(APIUtilities.sendEntity( appliance.toJSON(installation.getInstallationID().toString()).toString(), "/app")); APIUtilities.sendEntity(appliance.powerConsumptionModelToJSON().toString(), "/consmod"); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } else if (activity != null) { String[] applianceTemp = new String[activity.getAppliancesOf().length]; String personTemp = ""; String activityTemp = ""; String durationTemp = ""; String dailyTemp = ""; String startTemp = ""; // For each appliance that participates in the activity for (int j = 0; j < activity.getAppliancesOf().length; j++) { Appliance activityAppliance = activity.getAppliancesOf()[j]; applianceTemp[j] = activityAppliance.getApplianceID(); } personTemp = installation.getPerson().getPersonID(); try { activity.setActivityID(APIUtilities .sendEntity(activity.activityToJSON(personTemp).toString(), "/act")); String[] appliancesID = applianceTemp; activity.setActivityModelID(APIUtilities .sendEntity(activity.toJSON(appliancesID).toString(), "/actmod")); activityTemp = activity.getActivityModelID(); activity.getDailyTimes().setDistributionID(APIUtilities.sendEntity( activity.getDailyTimes().toJSON(activityTemp).toString(), "/distr")); activity.setDailyID(activity.getDailyTimes().getDistributionID()); dailyTemp = activity.getDailyID(); activity.getDuration().setDistributionID(APIUtilities.sendEntity( activity.getDuration().toJSON(activityTemp).toString(), "/distr")); activity.setDurationID(activity.getDuration().getDistributionID()); durationTemp = activity.getDurationID(); activity.getStartTime().setDistributionID(APIUtilities.sendEntity( activity.getStartTime().toJSON(activityTemp).toString(), "/distr")); activity.setStartID(activity.getStartTime().getDistributionID()); startTemp = activity.getStartID(); APIUtilities.updateEntity(activity.toJSON(appliancesID).toString(), "/actmod", activityTemp); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } else if (response != null) { } } } finally { root.setCursor(Cursor.getDefaultCursor()); } JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The installation model " + installation.getName() + " for the base pricing scheme and all the entities contained within were exported successfully", "Installation Model Exported", JOptionPane.INFORMATION_MESSAGE); } }); exportAllResponseButton.addActionListener(new ActionListener() { /** * This function is called when the user presses the Export All Base * button on the Connection Properties panel of the Export Models tab. The * export procedure above is iterated through all the entities available * on the list except for the activity models. */ @Override public void actionPerformed(ActionEvent e) { Component root = SwingUtilities.getRoot((JButton) e.getSource()); try { root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (int i = 0; i < exportModelList.getModel().getSize(); i++) { exportModelList.setSelectedIndex(i); String selection = exportModelList.getSelectedValue(); Appliance appliance = installation.findAppliance(selection); ActivityModel activity = installation.getPerson().findActivity(selection, false); ResponseModel response = installation.getPerson().findResponse(selection); if (selection.equalsIgnoreCase(installation.getName())) { String oldName = installation.getName(); try { installation.setName(householdNameTextField.getText() + " Response"); installation.setInstallationID(APIUtilities.sendEntity( installation.toJSON(APIUtilities.getUserID()).toString(), "/inst")); installation.setName(oldName); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } else if (selection.equalsIgnoreCase(installation.getPerson().getName())) { try { installation.getPerson().setPersonID(APIUtilities.sendEntity(installation .getPerson().toJSON(installation.getInstallationID()).toString(), "/pers")); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } else if (appliance != null) { try { appliance.setApplianceID(APIUtilities.sendEntity( appliance.toJSON(installation.getInstallationID().toString()).toString(), "/app")); APIUtilities.sendEntity(appliance.powerConsumptionModelToJSON().toString(), "/consmod"); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } else if (activity != null) { } else if (response != null) { String[] applianceTemp = new String[response.getAppliancesOf().length]; String personTemp = ""; String responseTemp = ""; String durationTemp = ""; String dailyTemp = ""; String startTemp = ""; // For each appliance that participates in the activity for (int j = 0; j < response.getAppliancesOf().length; j++) { Appliance responseAppliance = response.getAppliancesOf()[j]; applianceTemp[j] = responseAppliance.getApplianceID(); } personTemp = installation.getPerson().getPersonID(); try { response.setActivityID(APIUtilities .sendEntity(response.activityToJSON(personTemp).toString(), "/act")); String[] appliancesID = applianceTemp; response.setActivityModelID(APIUtilities .sendEntity(response.toJSON(appliancesID).toString(), "/actmod")); responseTemp = response.getActivityModelID(); response.getDailyTimes().setDistributionID(APIUtilities.sendEntity( response.getDailyTimes().toJSON(responseTemp).toString(), "/distr")); response.setDailyID(response.getDailyTimes().getDistributionID()); dailyTemp = response.getDailyID(); response.getDuration().setDistributionID(APIUtilities.sendEntity( response.getDuration().toJSON(responseTemp).toString(), "/distr")); response.setDurationID(response.getDuration().getDistributionID()); durationTemp = response.getDurationID(); response.getStartTime().setDistributionID(APIUtilities.sendEntity( response.getStartTime().toJSON(responseTemp).toString(), "/distr")); response.setStartID(response.getStartTime().getDistributionID()); startTemp = response.getStartID(); APIUtilities.updateEntity(response.toJSON(appliancesID).toString(), "/actmod", responseTemp); } catch (IOException | AuthenticationException | NoSuchAlgorithmException e1) { e1.printStackTrace(); } } } } finally { root.setCursor(Cursor.getDefaultCursor()); } JFrame success = new JFrame(); JOptionPane.showMessageDialog(success, "The installation model " + installation.getName() + " for the new pricing scheme and all the entities contained within were exported successfully", "Installation Model Exported", JOptionPane.INFORMATION_MESSAGE); } }); }
From source file:com.juanhg.cicloc.cicloCApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblPhase = new JLabel("Trabajo Ciclo:"); lblPhase.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTrabajoCValue = new JLabel(); lblTrabajoCValue.setText("0"); lblTrabajoCValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblPosicion = new JLabel("Trabajo:"); lblPosicion.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTrabajoValue = new JLabel(); lblTrabajoValue.setText("0"); lblTrabajoValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); hotImage = loadImage(hot);//from w w w . j a v a 2 s. c o m coldImage = loadImage(cold); lblE = new JLabel("Rendimiento:"); lblE.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblEValue = new JLabel(); lblEValue.setText("0"); lblEValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22).addGroup(gl_panelOutputs .createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblE, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE) .addGap(26).addComponent(lblEValue, GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblPhase, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(26)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblPosicion, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addGap(29))) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false) .addComponent(lblTrabajoValue, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblTrabajoCValue, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)))) .addGap(109)) .addGroup(gl_panelOutputs.createSequentialGroup().addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, 262, GroupLayout.PREFERRED_SIZE) .addContainerGap(82, Short.MAX_VALUE))); gl_panelOutputs .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblTrabajoCValue).addComponent(lblPhase)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblPosicion, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblTrabajoValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblE, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblEValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(79))); panelOutputs.setLayout(gl_panelOutputs); panel_1 = new JPanel(); panel_1.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_6 = new JPanel(); panel_6.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addGroup(gl_panel_control.createParallelGroup(Alignment.LEADING, false) .addComponent(panelOutputs, 0, 0, Short.MAX_VALUE) .addComponent(panelInputs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panel_6, 0, 0, Short.MAX_VALUE).addComponent(panel_1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(92, Short.MAX_VALUE))); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 146, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(17))); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); btnCold = new JButton(""); btnCold.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnHot.setEnabled(true); btnCold.setEnabled(false); isHot = false; lblE.setText("Eficiencia"); lblModeValue.setText("Modo Frig"); panelMode.setBackground(Color.BLUE); } }); btnCold.setIcon(new ImageIcon(coldImage)); btnCold.setEnabled(true); panelMode = new JPanel(); panelMode.setBorder(new LineBorder(new Color(0, 0, 0))); panelMode.setBackground(Color.ORANGE); btnHot = new JButton(""); btnHot.setIcon(new ImageIcon(hotImage)); btnHot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnHot.setEnabled(false); btnCold.setEnabled(true); isHot = true; lblE.setText("Rendimiento"); lblModeValue.setText("Modo Motor"); panelMode.setBackground(Color.ORANGE); } }); btnHot.setEnabled(false); GroupLayout gl_panel_6 = new GroupLayout(panel_6); gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_6 .createSequentialGroup().addContainerGap() .addGroup(gl_panel_6.createParallelGroup(Alignment.LEADING, false) .addComponent(panelMode, Alignment.TRAILING, 0, 0, Short.MAX_VALUE) .addComponent(btnHot, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)) .addGap(10) .addGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING, false) .addComponent(btnCold, GroupLayout.PREFERRED_SIZE, 112, GroupLayout.PREFERRED_SIZE) .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6.createSequentialGroup().addGap(10) .addGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addComponent(panelMode, 0, 0, Short.MAX_VALUE).addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING) .addComponent(btnCold, GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE) .addComponent(btnHot, GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)) .addContainerGap())); lblModeValue = new JLabel("Modo Motor"); lblModeValue.setFont(new Font("Tahoma", Font.PLAIN, 17)); GroupLayout gl_panelMode = new GroupLayout(panelMode); gl_panelMode.setHorizontalGroup(gl_panelMode.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelMode.createSequentialGroup().addContainerGap() .addComponent(lblModeValue, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); gl_panelMode .setVerticalGroup(gl_panelMode.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelMode .createSequentialGroup().addContainerGap().addComponent(lblModeValue, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(52))); panelMode.setLayout(gl_panelMode); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panel_1.add(lblNewLabel); JLabel LabelT1 = new JLabel("T1"); LabelT1.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelT2 = new JLabel("T2"); labelT2.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelVmin = new JLabel("Vm\u00EDn"); labelVmin.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblT2Value = new JLabel("300"); lblT2Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVminValue = new JLabel("2"); lblVminValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblT1Value = new JLabel("400"); lblT1Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderT1 = new JSlider(); sliderT1.setMinimum(350); sliderT1.setMaximum(450); sliderT1.setMinorTickSpacing(1); sliderT1.setValue(400); sliderT1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderT1Event(); } }); sliderT2 = new JSlider(); sliderT2.setMinimum(270); sliderT2.setMaximum(330); sliderT2.setMinorTickSpacing(1); sliderT2.setValue(300); sliderT2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderT2Event(); } }); sliderVMin = new JSlider(); sliderVMin.setMaximum(4); sliderVMin.setMinimum(1); sliderVMin.setValue(2); sliderVMin.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderVminEvent(); } }); JLabel lblVmax = new JLabel("Vm\u00E1x"); lblVmax.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVmaxValue = new JLabel("7"); lblVmaxValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderVMax = new JSlider(); sliderVMax.setMaximum(10); sliderVMax.setMinimum(6); sliderVMax.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderVmaxEvent(); } }); sliderVMax.setValue(7); sliderVMax.setMinorTickSpacing(1); JLabel labelN = new JLabel("N"); labelN.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblNValue = new JLabel("10"); lblNValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderN = new JSlider(); sliderN.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderNEvent(); } }); sliderN.setValue(10); sliderN.setMinorTickSpacing(1); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup().addGap(19).addGroup(gl_panelInputs .createParallelGroup(Alignment.LEADING, false) .addComponent(labelN, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblVmax, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelVmin, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelT2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelT1, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false) .addGroup(gl_panelInputs.createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblT1Value, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblT2Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblVminValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addComponent(sliderT1, 0, 0, Short.MAX_VALUE) .addComponent(sliderT2, 0, 0, Short.MAX_VALUE) .addComponent(sliderVMin, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblVmaxValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18).addComponent(sliderVMax, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblNValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(sliderN, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED))) .addContainerGap()) .addComponent(panelTitle, GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup().addComponent(LabelT1).addGap(12) .addComponent(labelT2).addGap(17).addComponent(labelVmin).addGap(17) .addComponent(lblVmax, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addGap(17).addComponent(labelN, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblT1Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderT1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblT2Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderT2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblVminValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderVMin, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblVmaxValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderVMax, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addComponent(lblNValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderN, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) .addGap(8))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); panel_visualizar.setBackground(Color.WHITE); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 286, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(93, Short.MAX_VALUE))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout .createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addComponent(panel_visualizar, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE) .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 568, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); panelPiston = new JPanelGrafica(); panelPiston.setBackground(Color.WHITE); JPanel panel_5 = new JPanel(); panel_5.setBackground(Color.WHITE); JPanel panel = new JPanel(); panel.setBackground(Color.WHITE); GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar); gl_panel_visualizar.setHorizontalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING) .addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 845, Short.MAX_VALUE) .addGroup(gl_panel_visualizar.createSequentialGroup().addContainerGap() .addComponent(panelPiston, GroupLayout.PREFERRED_SIZE, 355, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel, GroupLayout.PREFERRED_SIZE, 183, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_5, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE).addContainerGap())); gl_panel_visualizar.setVerticalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_visualizar.createSequentialGroup() .addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 289, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING) .addComponent(panel, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE) .addComponent(panelPiston, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE) .addComponent(panel_5, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)) .addContainerGap())); panelTermo = new JPanelGrafica(); panelTermo.setBackground(Color.WHITE); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelTermo, GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelTermo, GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)); panel.setLayout(gl_panel); panelPistonInterno = new JPanelGrafica(); panelPistonInterno.setBackground(Color.WHITE); GroupLayout gl_panelPiston = new GroupLayout(panelPiston); gl_panelPiston.setHorizontalGroup(gl_panelPiston.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelPiston.createSequentialGroup() .addComponent(panelPistonInterno, GroupLayout.PREFERRED_SIZE, 354, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); gl_panelPiston.setVerticalGroup(gl_panelPiston.createParallelGroup(Alignment.LEADING) .addComponent(panelPistonInterno, GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)); panelPiston.setLayout(gl_panelPiston); JPanel panelBulb = new JPanel(); panelBulb.setBackground(Color.WHITE); JPanel panelLED = new JPanel(); panelLED.setBackground(Color.WHITE); lblBulbValue = new JLabel("- Horas"); lblLEDValue = new JLabel("- Horas"); GroupLayout gl_panel_5 = new GroupLayout(panel_5); gl_panel_5.setHorizontalGroup(gl_panel_5.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_5.createSequentialGroup() .addGroup(gl_panel_5.createParallelGroup(Alignment.LEADING, false) .addComponent(panelLED, 0, 0, Short.MAX_VALUE) .addComponent(panelBulb, GroupLayout.PREFERRED_SIZE, 132, Short.MAX_VALUE)) .addGap(18).addGroup(gl_panel_5.createParallelGroup(Alignment.LEADING) .addComponent(lblBulbValue).addComponent(lblLEDValue)) .addContainerGap(87, Short.MAX_VALUE))); gl_panel_5.setVerticalGroup(gl_panel_5.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_5.createSequentialGroup() .addComponent(panelBulb, GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(panelLED, GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)) .addGroup(gl_panel_5.createSequentialGroup().addGap(64).addComponent(lblBulbValue) .addPreferredGap(ComponentPlacement.RELATED, 135, Short.MAX_VALUE).addComponent(lblLEDValue) .addGap(64))); LEDOnImage = loadImage(LEDOn); LEDOffImage = loadImage(LEDOff); lblLED = new JLabel(new ImageIcon(LEDOffImage)); lblLED.setBackground(Color.WHITE); GroupLayout gl_panelLED = new GroupLayout(panelLED); gl_panelLED.setHorizontalGroup(gl_panelLED.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelLED.createSequentialGroup() .addComponent(lblLED, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE) .addContainerGap(33, Short.MAX_VALUE))); gl_panelLED.setVerticalGroup(gl_panelLED.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING, gl_panelLED.createSequentialGroup().addContainerGap().addComponent(lblLED, GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE))); panelLED.setLayout(gl_panelLED); bulbOnImage = loadImage(bulbOn); bulbOffImage = loadImage(bulbOff); lblBulb = new JLabel(new ImageIcon(bulbOffImage)); lblBulb.setBackground(Color.WHITE); GroupLayout gl_panelBulb = new GroupLayout(panelBulb); gl_panelBulb.setHorizontalGroup(gl_panelBulb.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelBulb.createSequentialGroup() .addComponent(lblBulb, GroupLayout.PREFERRED_SIZE, 134, GroupLayout.PREFERRED_SIZE) .addContainerGap(30, Short.MAX_VALUE))); gl_panelBulb.setVerticalGroup(gl_panelBulb.createParallelGroup(Alignment.LEADING).addComponent(lblBulb, GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)); panelBulb.setLayout(gl_panelBulb); panel_5.setLayout(gl_panel_5); JPanel panelXV = new JPanel(); panelXV.setBackground(Color.WHITE); tabbedPane.addTab("Grficas V", null, panelXV, null); JPanel panel_2 = new JPanel(); JPanel panel_3 = new JPanel(); JPanel panel_4 = new JPanel(); panelTV = new JPanelGrafica(); GroupLayout gl_panel_4 = new GroupLayout(panel_4); gl_panel_4.setHorizontalGroup( gl_panel_4.createParallelGroup(Alignment.LEADING).addGap(0, 272, Short.MAX_VALUE) .addComponent(panelTV, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)); gl_panel_4 .setVerticalGroup(gl_panel_4.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE) .addGroup(gl_panel_4.createSequentialGroup() .addComponent(panelTV, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE) .addContainerGap(306, Short.MAX_VALUE))); panel_4.setLayout(gl_panel_4); GroupLayout gl_panelXV = new GroupLayout(panelXV); gl_panelXV.setHorizontalGroup(gl_panelXV.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelXV.createSequentialGroup().addContainerGap() .addComponent(panel_2, GroupLayout.PREFERRED_SIZE, 263, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_4, GroupLayout.PREFERRED_SIZE, 272, GroupLayout.PREFERRED_SIZE) .addContainerGap(11, Short.MAX_VALUE))); gl_panelXV.setVerticalGroup(gl_panelXV.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelXV.createSequentialGroup().addContainerGap() .addGroup(gl_panelXV.createParallelGroup(Alignment.LEADING) .addComponent(panel_4, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelXV.createParallelGroup(Alignment.TRAILING, false) .addComponent(panel_3, Alignment.LEADING, 0, 0, Short.MAX_VALUE) .addComponent(panel_2, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE))) .addContainerGap(317, Short.MAX_VALUE))); panelUV = new JPanelGrafica(); GroupLayout gl_panel_3 = new GroupLayout(panel_3); gl_panel_3.setHorizontalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addComponent(panelUV, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)); gl_panel_3.setVerticalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_3.createSequentialGroup() .addComponent(panelUV, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE) .addContainerGap(306, Short.MAX_VALUE))); panel_3.setLayout(gl_panel_3); panelPV = new JPanelGrafica(); GroupLayout gl_panel_2 = new GroupLayout(panel_2); gl_panel_2.setHorizontalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addComponent(panelPV, GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)); gl_panel_2.setVerticalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addComponent(panelPV, GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)); panel_2.setLayout(gl_panel_2); panelXV.setLayout(gl_panelXV); JPanel panelXT = new JPanel(); panelXT.setBackground(Color.WHITE); tabbedPane.addTab("Grficas T", null, panelXT, null); JPanel panel_9 = new JPanel(); panelPT = new JPanelGrafica(); GroupLayout gl_panel_9 = new GroupLayout(panel_9); gl_panel_9.setHorizontalGroup( gl_panel_9.createParallelGroup(Alignment.LEADING).addGap(0, 263, Short.MAX_VALUE) .addComponent(panelPT, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)); gl_panel_9 .setVerticalGroup(gl_panel_9.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE) .addComponent(panelPT, GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)); panel_9.setLayout(gl_panel_9); JPanel panel_10 = new JPanel(); panelST = new JPanelGrafica(); GroupLayout gl_panel_10 = new GroupLayout(panel_10); gl_panel_10.setHorizontalGroup( gl_panel_10.createParallelGroup(Alignment.LEADING).addGap(0, 272, Short.MAX_VALUE) .addComponent(panelST, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)); gl_panel_10 .setVerticalGroup(gl_panel_10.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE) .addGroup(gl_panel_10.createSequentialGroup() .addComponent(panelST, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel_10.setLayout(gl_panel_10); JPanel panel_11 = new JPanel(); panelUT = new JPanelGrafica(); GroupLayout gl_panel_11 = new GroupLayout(panel_11); gl_panel_11.setHorizontalGroup( gl_panel_11.createParallelGroup(Alignment.LEADING).addGap(0, 272, Short.MAX_VALUE) .addComponent(panelUT, GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)); gl_panel_11 .setVerticalGroup(gl_panel_11.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE) .addGroup(gl_panel_11.createSequentialGroup() .addComponent(panelUT, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel_11.setLayout(gl_panel_11); GroupLayout gl_panelXT = new GroupLayout(panelXT); gl_panelXT.setHorizontalGroup(gl_panelXT.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelXT.createSequentialGroup().addContainerGap() .addComponent(panel_9, GroupLayout.PREFERRED_SIZE, 263, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_11, GroupLayout.PREFERRED_SIZE, 272, GroupLayout.PREFERRED_SIZE) .addContainerGap(11, Short.MAX_VALUE))); gl_panelXT.setVerticalGroup(gl_panelXT.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelXT.createSequentialGroup().addContainerGap() .addGroup(gl_panelXT.createParallelGroup(Alignment.LEADING) .addComponent(panel_11, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panelXT.createParallelGroup(Alignment.TRAILING, false) .addComponent(panel_10, Alignment.LEADING, 0, 0, Short.MAX_VALUE) .addComponent(panel_9, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE))) .addContainerGap(317, Short.MAX_VALUE))); panelXT.setLayout(gl_panelXT); panel_visualizar.setLayout(gl_panel_visualizar); getContentPane().setLayout(groupLayout); }
From source file:com.juanhg.icecubes.IceCubesApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblO1 = new JLabel("T:"); lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO1Value = new JLabel(); lblO1Value.setText("0"); lblO1Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblO2 = new JLabel("t:"); lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO2Value = new JLabel(); lblO2Value.setText("0"); lblO2Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblV = new JLabel("V:"); lblV.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVValue = new JLabel(); lblVValue.setText("0"); lblVValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22) .addComponent(lblO1, GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED)) .addGroup(gl_panelOutputs.createSequentialGroup().addContainerGap() .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE) .addGap(37))) .addGroup(//from w w w. j a v a 2 s . co m gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO1Value, GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE) .addGap(3)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO2Value, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED))) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblV, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE) .addContainerGap())); gl_panelOutputs .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblO1).addComponent(lblO1Value) .addComponent(lblV, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblO2Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(40))); panelOutputs.setLayout(gl_panelOutputs); JPanel panelLicense = new JPanel(); panelLicense.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_6 = new JPanel(); panel_6.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control .setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(Alignment.LEADING, gl_panel_control.createSequentialGroup().addContainerGap() .addGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addComponent(panelOutputs, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panel_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelLicense, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)) .addContainerGap())); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 225, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 112, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelLicense, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); GroupLayout gl_panel_6 = new GroupLayout(panel_6); gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6.createSequentialGroup().addContainerGap() .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6 .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addContainerGap(78, Short.MAX_VALUE))); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panelLicense.add(lblNewLabel); JLabel LabelI1 = new JLabel("Volumen"); LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI2 = new JLabel("T"); labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI3 = new JLabel("t"); labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblTValue = new JLabel("15"); lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lbltValue = new JLabel("-15"); lbltValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVolValue = new JLabel("20"); lblVolValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderVol = new JSlider(); sliderVol.setMinimum(1); sliderVol.setMaximum(30); sliderVol.setMinorTickSpacing(1); sliderVol.setValue(20); sliderVol.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderI1Event(); } }); sliderT = new JSlider(); sliderT.setMinimum(5); sliderT.setMaximum(30); sliderT.setMinorTickSpacing(1); sliderT.setValue(15); sliderT.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI2Event(); } }); slidert = new JSlider(); slidert.setMinimum(5); slidert.setMaximum(30); slidert.setValue(15); slidert.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI3Event(); } }); JLabel lblI4 = new JLabel("N\u00BA de Cubitos"); lblI4.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblNValue = new JLabel("1"); lblNValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderN = new JSlider(); sliderN.setMinimum(1); sliderN.setMaximum(4); sliderN.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI4Event(); } }); sliderN.setValue(1); sliderN.setMinorTickSpacing(1); waterImage = loadImage(water); btnWater = new JButton(new ImageIcon(waterImage)); btnWater.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnWater.setEnabled(false); btnMilk.setEnabled(true); btnOrange.setEnabled(true); btnlemonade.setEnabled(true); type = WATER; fluidColor = new Color(100, 180, 255, 70); updateGlass(IceCubesModel.getV(sliderVol.getValue(), sliderN.getValue())); repaint(); } }); milkImage = loadImage(milk); btnMilk = new JButton(new ImageIcon(milkImage)); btnMilk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnWater.setEnabled(true); btnMilk.setEnabled(false); btnOrange.setEnabled(true); btnlemonade.setEnabled(true); type = MILK; fluidColor = new Color(255, 255, 255, 255); updateGlass(IceCubesModel.getV(sliderVol.getValue(), sliderN.getValue())); repaint(); } }); orangeImage = loadImage(orange); btnOrange = new JButton(new ImageIcon(orangeImage)); btnOrange.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnWater.setEnabled(true); btnMilk.setEnabled(true); btnOrange.setEnabled(false); btnlemonade.setEnabled(true); type = ORANGE; fluidColor = new Color(225, 150, 0, 220); updateGlass(IceCubesModel.getV(sliderVol.getValue(), sliderN.getValue())); repaint(); } }); lemonadeImage = loadImage(lemonade); btnlemonade = new JButton(new ImageIcon(lemonadeImage)); btnlemonade.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btnWater.setEnabled(true); btnMilk.setEnabled(true); btnOrange.setEnabled(true); btnlemonade.setEnabled(false); type = LEMONADE; fluidColor = new Color(225, 225, 0, 150); updateGlass(IceCubesModel.getV(sliderVol.getValue(), sliderN.getValue())); repaint(); } }); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE) .addGroup(gl_panelInputs.createSequentialGroup().addContainerGap(23, Short.MAX_VALUE) .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING).addGroup(gl_panelInputs .createSequentialGroup() .addComponent(btnWater, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnMilk, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnOrange, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnlemonade, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addGap(8)) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs .createParallelGroup(Alignment.TRAILING, false) .addComponent(labelI3, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelI1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelI2, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblVolValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lbltValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18).addGroup( gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addComponent(sliderVol, 0, 0, Short.MAX_VALUE) .addComponent(sliderT, 0, 0, Short.MAX_VALUE) .addComponent(slidert, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(lblNValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18).addComponent(sliderN, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)))) .addGap(15))); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(LabelI1).addComponent(lblVolValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderVol, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelI2).addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3) .addComponent(lbltValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(slidert, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblNValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderN, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(7) .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false) .addComponent(btnWater, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnMilk, GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE) .addComponent(btnOrange, GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE) .addComponent(btnlemonade, GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)) .addGap(11))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); panel_visualizar.setBackground(Color.WHITE); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup( Alignment.TRAILING, groupLayout.createSequentialGroup().addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 694, GroupLayout.PREFERRED_SIZE) .addGap(156))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING, groupLayout.createSequentialGroup().addGap(12) .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false) .addComponent(panel_visualizar, Alignment.LEADING, 0, 0, Short.MAX_VALUE) .addComponent(panel_control, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 494, Short.MAX_VALUE)) .addContainerGap(84, Short.MAX_VALUE))); JPanel panel = new JPanel(); panel.setBorder(new LineBorder(new Color(0, 0, 0))); panel.setBounds(0, 0, 368, 494); panel.setBackground(Color.WHITE); JPanel panel_1 = new JPanel(); panel_1.setBounds(1, 1, 366, 31); panel_1.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel lblSimulacin = new JLabel("Simulaci\u00F3n"); lblSimulacin.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_1.add(lblSimulacin); JPanel panel_3 = new JPanel(); panel_3.setBorder(new LineBorder(new Color(0, 0, 0))); panel_3.setBackground(Color.WHITE); panel_3.setBounds(368, 0, 326, 494); panel_visualizar.setLayout(null); panel_visualizar.add(panel); panel.setLayout(null); panel.add(panel_1); panel_7 = new JPanelGrafica(); panel_7.setBackground(Color.WHITE); panel_7.setBounds(1, 31, 366, 463); panel.add(panel_7); panelGlass = new JPanelGrafica(); panelGlass.setBackground(Color.WHITE); GroupLayout gl_panel_7 = new GroupLayout(panel_7); gl_panel_7.setHorizontalGroup(gl_panel_7.createParallelGroup(Alignment.LEADING).addComponent(panelGlass, GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)); gl_panel_7.setVerticalGroup(gl_panel_7.createParallelGroup(Alignment.LEADING).addComponent(panelGlass, GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)); panel_7.setLayout(gl_panel_7); panel_visualizar.add(panel_3); panel_3.setLayout(null); JPanel panel_4 = new JPanel(); panel_4.setBounds(1, 1, 324, 31); panel_4.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel lblGrficaDeEvolucin = new JLabel("Gr\u00E1fica de Evoluci\u00F3n (T frente a Q)"); lblGrficaDeEvolucin.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_4.add(lblGrficaDeEvolucin); panel_3.add(panel_4); JPanel panel7 = new JPanel(); panel7.setBorder(new LineBorder(new Color(0, 0, 0))); panel7.setBackground(Color.WHITE); panel7.setBounds(1, 31, 324, 463); panel_3.add(panel7); panel7.setLayout(null); panelChart = new JPanelGrafica(); panelChart.setBorder(new LineBorder(new Color(0, 0, 0))); panelChart.setBackground(Color.WHITE); panelChart.setBounds(0, 0, 324, 462); panel7.add(panelChart); getContentPane().setLayout(groupLayout); }
From source file:com.juanhg.angularmdisk.AngularMDiskApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTiempo = new JPanel(); panelTiempo.setToolTipText(""); panelTiempo.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); btnPhase1 = new JButton("Lanzar Insecto"); btnPhase1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btnPhase1Event();/*from www. j a v a 2 s .co m*/ } }); btnPhase1.setEnabled(false); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblDiskW = new JLabel("Velocidad Disco:"); lblDiskW.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblDiskWValue = new JLabel(); lblDiskWValue.setText("0"); lblDiskWValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblCriticRadius = new JLabel("Radio Cr\u00EDtico:"); lblCriticRadius.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblCriticRadiusValue = new JLabel(); lblCriticRadiusValue.setText("0"); lblCriticRadiusValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addContainerGap() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblCriticRadius, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE) .addGap(6)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblDiskW, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(26))) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblDiskWValue, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE) .addComponent(lblCriticRadiusValue, GroupLayout.PREFERRED_SIZE, 147, GroupLayout.PREFERRED_SIZE)) .addContainerGap(112, Short.MAX_VALUE))); gl_panelOutputs .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblDiskW).addComponent(lblDiskWValue)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblCriticRadius, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblCriticRadiusValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(121))); panelOutputs.setLayout(gl_panelOutputs); panel_1 = new JPanel(); panel_1.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap().addGroup(gl_panel_control .createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup() .addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 396, GroupLayout.PREFERRED_SIZE) .addComponent(panelOutputs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE) .addComponent(panelTiempo, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)) .addGap(18)) .addGroup(gl_panel_control.createSequentialGroup() .addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 397, GroupLayout.PREFERRED_SIZE) .addContainerGap(17, Short.MAX_VALUE))))); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 202, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelTiempo, GroupLayout.PREFERRED_SIZE, 210, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, 15, Short.MAX_VALUE).addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panel_1.add(lblNewLabel); rdbtnCam1 = new JRadioButton("C\u00E1mara Fija"); rdbtnCam1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { rdbtnCam1Event(); } }); rdbtnCam1.setSelected(true); rdbtnCam2 = new JRadioButton("C\u00E1mara M\u00F3vil"); rdbtnCam2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { rdbtnCam2Event(); } }); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); btnPauseContinue = new JButton("Pausar"); btnPauseContinue.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnPauseContinue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnPauseContinueEvent(event); } }); panel = new JPanel(); panel.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); label = new JLabel("Datos de la Simulaci\u00F3n"); label.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(label); GroupLayout gl_panelTiempo = new GroupLayout(panelTiempo); gl_panelTiempo.setHorizontalGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup().addContainerGap() .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING, false) .addComponent(btnPhase1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING).addGroup(gl_panelTiempo .createSequentialGroup().addGap(52) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addComponent(rdbtnCam2).addComponent(rdbtnCam1, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelTiempo.createSequentialGroup().addGap(21).addComponent( btnPauseContinue, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE))) .addContainerGap(47, Short.MAX_VALUE)) .addComponent(panel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)); gl_panelTiempo.setVerticalGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup() .addComponent(panel, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE).addGap(22) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelTiempo.createSequentialGroup().addComponent(rdbtnCam1) .addPreferredGap(ComponentPlacement.RELATED).addComponent(rdbtnCam2)) .addComponent(btnPhase1, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelTiempo.createParallelGroup(Alignment.LEADING) .addComponent(btnPauseContinue, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE) .addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE)))); panelTiempo.setLayout(gl_panelTiempo); JLabel LabelBugMass = new JLabel("Masa del Insecto"); LabelBugMass.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelFallRadio = new JLabel("Radio de Ca\u00EDda"); labelFallRadio.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelBugVelocity = new JLabel("Velocidad del Insecto"); labelBugVelocity.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelDiskVelocity = new JLabel("Velocidad del Disco"); labelDiskVelocity.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblFallRadiusValue = new JLabel("10"); lblFallRadiusValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblBugVelocityValue = new JLabel("1"); lblBugVelocityValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVelocityValue = new JLabel("0.5"); lblVelocityValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblInitMassValue = new JLabel("30"); lblInitMassValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderBugInitMass = new JSlider(); sliderBugInitMass.setValue(30); sliderBugInitMass.setMinimum(20); sliderBugInitMass.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderBugInitMassEvent(); } }); sliderBugInitMass.setMaximum(70); sliderFallRadius = new JSlider(); sliderFallRadius.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderFallRadiusEvent(); } }); sliderFallRadius.setValue(10); sliderFallRadius.setMinorTickSpacing(1); sliderFallRadius.setMaximum(20); sliderBugVelocity = new JSlider(); sliderBugVelocity.setValue(10); sliderBugVelocity.setMaximum(20); sliderBugVelocity.setMinimum(5); sliderBugVelocity.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderBugVelocityEvent(); } }); sliderBugVelocity.setMinorTickSpacing(1); sliderDiskVelocity = new JSlider(); sliderDiskVelocity.setMaximum(10); sliderDiskVelocity.setMinimum(1); sliderDiskVelocity.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderDiskVelocityEvent(); } }); sliderDiskVelocity.setValue(5); sliderDiskVelocity.setMinorTickSpacing(1); JLabel lblCoeficienteDeRozamiento = new JLabel("Coef de Rozamiento"); lblCoeficienteDeRozamiento.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblFrictionValue = new JLabel("0.25"); lblFrictionValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderFriction = new JSlider(); sliderFriction.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderFrictionEvent(); } }); sliderFriction.setValue(25); sliderFriction.setMinorTickSpacing(1); sliderFriction.setMinimum(1); sliderFriction.setMaximum(90); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelInputs.createSequentialGroup().addContainerGap() .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false) .addComponent(labelBugVelocity, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelBugMass, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelFallRadio, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblInitMassValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblFallRadiusValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblBugVelocityValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(sliderFallRadius, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderBugInitMass, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderBugVelocity, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addComponent(sliderDiskVelocity, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE)) .addGap(26)) .addGroup(gl_panelInputs.createSequentialGroup().addContainerGap() .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addComponent(lblCoeficienteDeRozamiento, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE) .addComponent(labelDiskVelocity, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup() .addComponent(lblVelocityValue, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(204)) .addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup() .addComponent(lblFrictionValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(sliderFriction, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) .addGap(26)))) .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(8) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(LabelBugMass).addComponent(lblInitMassValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderBugInitMass, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelFallRadio).addComponent(lblFallRadiusValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderFallRadius, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup( gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelBugVelocity) .addComponent(lblBugVelocityValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderBugVelocity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelDiskVelocity).addComponent(lblVelocityValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderDiskVelocity, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup().addGap(12) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblCoeficienteDeRozamiento, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblFrictionValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelInputs.createSequentialGroup() .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(sliderFriction, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGap(47))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 432, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 560, GroupLayout.PREFERRED_SIZE) .addContainerGap(32, Short.MAX_VALUE))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addComponent(panel_visualizar, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE) .addComponent(panel_control, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 598, Short.MAX_VALUE)) .addContainerGap())); GridBagLayout gbl_panel_visualizar = new GridBagLayout(); gbl_panel_visualizar.columnWidths = new int[] { 0, 0 }; gbl_panel_visualizar.rowHeights = new int[] { 0, 0, 0 }; gbl_panel_visualizar.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_panel_visualizar.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; panel_visualizar.setLayout(gbl_panel_visualizar); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); gbc_tabbedPane.gridheight = 2; gbc_tabbedPane.fill = GridBagConstraints.BOTH; gbc_tabbedPane.gridx = 0; gbc_tabbedPane.gridy = 0; panel_visualizar.add(tabbedPane, gbc_tabbedPane); panelSimulation = new JPanelGrafica(); tabbedPane.addTab("Simulacin", null, panelSimulation, null); panelSimulation.setBackground(Color.WHITE); getContentPane().setLayout(groupLayout); }
From source file:AST.DesignPatternDetection.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Murat Oruc btPathFinder = new JButton(); label1 = new JLabel(); tfPath = new JTextField(); label2 = new JLabel(); cbSelectionDP = new JComboBox<>(); btRun = new JButton(); label3 = new JLabel(); tfProjectName = new JTextField(); label4 = new JLabel(); tfThreshold = new JTextField(); chbOverlap = new JCheckBox(); btRunSgiso = new JButton(); scrollPane1 = new JScrollPane(); taInfo = new JTextArea(); label5 = new JLabel(); tfProgramPath = new JTextField(); btProgramPath = new JButton(); button1 = new JButton(); button2 = new JButton(); chbInnerClass = new JCheckBox(); //======== this ======== setTitle("DesPaD (Design Pattern Detector)"); setIconImage(((ImageIcon) UIManager.getIcon("FileView.computerIcon")).getImage()); addWindowListener(new WindowAdapter() { @Override//w w w .j av a 2s .c om public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); Container contentPane = getContentPane(); //---- btPathFinder ---- btPathFinder.setText("..."); btPathFinder.setFont(btPathFinder.getFont().deriveFont(btPathFinder.getFont().getSize() + 1f)); btPathFinder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btPathFinderActionPerformed(e); } }); //---- label1 ---- label1.setText("Source Code Directory Path"); //---- tfPath ---- tfPath.setText("..."); tfPath.setEditable(false); tfPath.setForeground(Color.blue); tfPath.setFont(tfPath.getFont().deriveFont(tfPath.getFont().getStyle() | Font.BOLD)); //---- label2 ---- label2.setText("Select Design Pattern"); //---- cbSelectionDP ---- cbSelectionDP.setModel(new DefaultComboBoxModel<>( new String[] { "FACTORY_METHOD", "PROTOTYPE", "ABSTRACT_FACTORY", "BUILDER", "SINGLETON", "COMPOSITE", "FACADE", "DECORATOR", "DECORATOR2", "BRIDGE", "FLYWEIGHT", "ADAPTER", "PROXY", "MEDIATOR", "STATE", "OBSERVER", "TEMPLATE_METHOD", "TEMPLATE_METHOD2", "COMMAND", "CHAIN_OF_RESPONSIBILITY", "INTERPRETER", "MEMENTO", "ITERATOR", "STRATEGY", "VISITOR" })); //---- btRun ---- btRun.setText("1. Build Model Graph"); btRun.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { btRunActionPerformed(e); } catch (IOException | InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); //---- label3 ---- label3.setText("Project Name"); //---- label4 ---- label4.setText("Threshold"); //---- tfThreshold ---- tfThreshold.setText("0.0"); //---- chbOverlap ---- chbOverlap.setText("Overlap"); //---- btRunSgiso ---- btRunSgiso.setText("2. Run Subdue-Sgiso Algorithm"); btRunSgiso.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { btRunSgisoActionPerformed(e); } catch (IOException | InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); //======== scrollPane1 ======== { scrollPane1.setViewportView(taInfo); } //---- label5 ---- label5.setText("Program Directory Path"); //---- tfProgramPath ---- tfProgramPath.setEditable(false); tfProgramPath.setForeground(Color.blue); tfProgramPath.setFont(tfProgramPath.getFont().deriveFont(tfProgramPath.getFont().getStyle() | Font.BOLD)); //---- btProgramPath ---- btProgramPath.setText("..."); btProgramPath.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btProgramPathActionPerformed(e); } }); //---- button1 ---- button1.setText("3. Exclude overlap outputs"); button1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { button1ActionPerformed(e); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); //---- button2 ---- button2.setText("4. Graph Representations"); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { button2ActionPerformed(e); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); //---- chbInnerClass ---- chbInnerClass.setText("Include Inner Classes"); chbInnerClass.setSelected(true); GroupLayout contentPaneLayout = new GroupLayout(contentPane); contentPane.setLayout(contentPaneLayout); contentPaneLayout.setHorizontalGroup( contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout.createSequentialGroup() .addContainerGap().addGroup(contentPaneLayout .createParallelGroup().addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup().addComponent(label1).addGap(21, 433, Short.MAX_VALUE)) .addGroup(contentPaneLayout .createSequentialGroup().addGroup(contentPaneLayout.createParallelGroup() .addComponent(label4).addGroup(contentPaneLayout .createSequentialGroup().addGroup(contentPaneLayout .createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addComponent( button1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE) .addComponent(tfThreshold, GroupLayout.Alignment.LEADING) .addComponent(cbSelectionDP, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE) .addComponent(label2, GroupLayout.Alignment.LEADING) .addComponent( btRun, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)) .addGap(30, 30, 30) .addGroup(contentPaneLayout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(label3) .addComponent(tfProjectName, GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE) .addGroup(contentPaneLayout.createSequentialGroup() .addComponent(chbOverlap) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chbInnerClass)) .addComponent(btRunSgiso, GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE) .addComponent( button2, GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)))) .addGap(0, 56, Short.MAX_VALUE)) .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup().addGroup(contentPaneLayout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 594, Short.MAX_VALUE) .addGroup(contentPaneLayout.createSequentialGroup() .addGroup(contentPaneLayout.createParallelGroup() .addGroup(contentPaneLayout.createSequentialGroup() .addComponent(label5) .addGap(0, 418, Short.MAX_VALUE)) .addComponent(tfProgramPath, GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE) .addComponent( tfPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(contentPaneLayout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(btPathFinder, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btProgramPath, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addContainerGap())))); contentPaneLayout.setVerticalGroup(contentPaneLayout.createParallelGroup().addGroup(contentPaneLayout .createSequentialGroup().addGap(29, 29, 29).addComponent(label1).addGap(5, 5, 5) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(tfPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btPathFinder, GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(label5) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(tfProgramPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btProgramPath)) .addGap(18, 18, 18) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(label2) .addComponent(label3)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(cbSelectionDP, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(tfProjectName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18).addComponent(label4).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(tfThreshold, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(chbOverlap).addComponent(chbInnerClass)) .addGap(18, 18, 18) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(btRun, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE) .addComponent(btRunSgiso, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(button2, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE) .addComponent(button1, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)) .addGap(18, 18, 18).addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE) .addContainerGap())); setSize(630, 625); setLocationRelativeTo(null); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java
/** * Initialisiere das Panel fr die Verbindungen Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * //from w w w . jav a 2 s. c o m * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 22.04.2012 */ private void initPanel() { setLayout(new BorderLayout(0, 0)); setBackground(Color.WHITE); topPanel = new JPanel(); topPanel.setBackground(Color.WHITE); add(topPanel, BorderLayout.NORTH); deviceComboBox = new JComboBox<String>(); deviceComboBox.setBackground(Color.WHITE); deviceComboBox.setMaximumRowCount(26); deviceComboBox.setFont(new Font("Dialog", Font.PLAIN, 12)); deviceComboBox.setActionCommand("change_device_to_display"); diveSelectComboBox = new JComboBox<String>(); diveSelectComboBox.setBackground(Color.WHITE); diveSelectComboBox.setMaximumRowCount(26); diveSelectComboBox.setFont(new Font("Dialog", Font.PLAIN, 12)); diveSelectComboBox.setActionCommand("change_dive_to_display"); computeGraphButton = new JButton(LangStrings.getString("spx42LogGraphPanel.computeGraphButton.text")); //$NON-NLS-1$ computeGraphButton.setMinimumSize(new Dimension(80, 23)); computeGraphButton.setPreferredSize(new Dimension(80, 23)); computeGraphButton.setSize(new Dimension(80, 23)); computeGraphButton.setMaximumSize(new Dimension(80, 23)); computeGraphButton.setActionCommand("show_log_graph"); detailGraphButton = new JButton(LangStrings.getString("spx42LogGraphPanel.detailGraphButton.text")); //$NON-NLS-1$ detailGraphButton.setMinimumSize(new Dimension(80, 23)); detailGraphButton.setSize(new Dimension(80, 23)); detailGraphButton.setPreferredSize(new Dimension(80, 23)); detailGraphButton.setMaximumSize(new Dimension(80, 23)); detailGraphButton.setActionCommand("set_detail_for_show_graph"); GroupLayout gl_topPanel = new GroupLayout(topPanel); gl_topPanel.setHorizontalGroup(gl_topPanel.createParallelGroup(Alignment.TRAILING).addGroup(gl_topPanel .createSequentialGroup().addContainerGap().addComponent(deviceComboBox, 0, 270, Short.MAX_VALUE) .addGap(18) .addComponent(diveSelectComboBox, GroupLayout.PREFERRED_SIZE, 282, GroupLayout.PREFERRED_SIZE) .addGap(32) .addComponent(computeGraphButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(detailGraphButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18))); gl_topPanel.setVerticalGroup(gl_topPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_topPanel.createSequentialGroup() .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(gl_topPanel.createParallelGroup(Alignment.BASELINE) .addComponent(deviceComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(computeGraphButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(detailGraphButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(diveSelectComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))); topPanel.setLayout(gl_topPanel); bottomPanel = new JPanel(); bottomPanel.setBackground(Color.WHITE); add(bottomPanel, BorderLayout.SOUTH); maxDepthValueLabel = new JLabel("0"); coldestTempValueLabel = new JLabel("0"); diveLenValueLabel = new JLabel("0"); notesLabel = new JLabel(LangStrings.getString("spx42LoglistPanel.diveNotesLabel.text")); //$NON-NLS-1$ notesLabel.setForeground(new Color(0, 100, 0)); notesLabel.setFont(new Font("Tahoma", Font.ITALIC, 12)); notesEditButton = new JButton("..."); notesEditButton.setActionCommand("edit_notes_for_dive"); notesEditButton.setIcon( new ImageIcon(spx42LogGraphPanel.class.getResource("/de/dmarcini/submatix/pclogger/res/142.png"))); notesEditButton.setForeground(new Color(0, 100, 0)); diluentLabel = new JLabel(""); //$NON-NLS-1$ diluentLabel.setForeground(new Color(0, 0, 128)); diluentLabel.setFont(new Font("Segoe UI", Font.PLAIN, 12)); GroupLayout gl_bottomPanel = new GroupLayout(bottomPanel); gl_bottomPanel.setHorizontalGroup(gl_bottomPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_bottomPanel.createSequentialGroup().addContainerGap() .addGroup(gl_bottomPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_bottomPanel.createSequentialGroup() .addComponent(maxDepthValueLabel, GroupLayout.PREFERRED_SIZE, 206, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(coldestTempValueLabel, GroupLayout.PREFERRED_SIZE, 211, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(diveLenValueLabel, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE) .addGap(18)) .addGroup(Alignment.TRAILING, gl_bottomPanel.createSequentialGroup() .addGroup(gl_bottomPanel.createParallelGroup(Alignment.TRAILING) .addComponent(diluentLabel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE) .addComponent(notesLabel, GroupLayout.DEFAULT_SIZE, 653, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED))) .addComponent(notesEditButton, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE) .addGap(40))); gl_bottomPanel.setVerticalGroup(gl_bottomPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_bottomPanel.createSequentialGroup().addGap(18).addGroup(gl_bottomPanel .createParallelGroup(Alignment.LEADING) .addGroup(gl_bottomPanel.createSequentialGroup() .addGroup(gl_bottomPanel.createParallelGroup(Alignment.BASELINE) .addComponent(notesEditButton).addComponent(notesLabel)) .addContainerGap()) .addGroup(Alignment.TRAILING, gl_bottomPanel .createParallelGroup(Alignment.BASELINE).addComponent(maxDepthValueLabel) .addComponent(coldestTempValueLabel).addComponent(diveLenValueLabel)))) .addGroup(gl_bottomPanel.createSequentialGroup().addContainerGap().addComponent(diluentLabel))); bottomPanel.setLayout(gl_bottomPanel); chartPanel = null; }
From source file:com.juanhg.pot.PotApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); JLabel lblW = new JLabel("W:"); lblW.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblWValue = new JLabel(); lblWValue.setText("-"); lblWValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblQ = new JLabel("Q:"); lblQ.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblQValue = new JLabel(); lblQValue.setText("-"); lblQValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblT2 = new JLabel("T:"); lblT2.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTOValue = new JLabel(); lblTOValue.setText("-"); lblTOValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblU = new JLabel("U:"); lblU.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblP = new JLabel("P:"); lblP.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVO = new JLabel("V:"); lblVO.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblVOValue = new JLabel(); lblVOValue.setText("-"); lblVOValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblPValue = new JLabel(); lblPValue.setText("-"); lblPValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblUValue = new JLabel(); lblUValue.setText("-"); lblUValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addGap(31).addGroup(gl_panelOutputs .createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false) .addComponent(lblQ, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblWValue, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE) .addComponent(lblQValue, GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))) .addGroup(Alignment.LEADING, gl_panelOutputs.createSequentialGroup() .addComponent(lblT2, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblTOValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))) .addGap(18)/*from w ww . ja va 2 s.c om*/ .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblU, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(6).addComponent(lblUValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblP, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(6).addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblVO, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE) .addGap(6).addComponent(lblVOValue, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))) .addGap(25))); gl_panelOutputs.setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs .createSequentialGroup().addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING).addGroup(gl_panelOutputs .createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblU, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblUValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(6) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblP, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblPValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(6) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblVO, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblVOValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelOutputs.createSequentialGroup().addGroup(gl_panelOutputs .createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblQ, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblWValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblQValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblT2, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblTOValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)))) .addContainerGap())); panelOutputs.setLayout(gl_panelOutputs); JPanel panelLicense = new JPanel(); panelLicense.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_6 = new JPanel(); panel_6.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control .setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.LEADING) .addGroup(Alignment.TRAILING, gl_panel_control.createSequentialGroup().addContainerGap() .addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addComponent(panelInputs, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelOutputs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelLicense, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)) .addContainerGap())); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(24))); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); GroupLayout gl_panel_6 = new GroupLayout(panel_6); gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, gl_panel_6.createSequentialGroup().addContainerGap() .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_6 .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addContainerGap(69, Short.MAX_VALUE))); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panelLicense.add(lblNewLabel); lblT = new JLabel("Temperatura"); lblT.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblV = new JLabel("Volumen"); lblV.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMo = new JLabel("Masa Inicial"); lblMo.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblVValue = new JLabel("15"); lblVValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMoValue = new JLabel("5"); lblMoValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTValue = new JLabel("300"); lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderT = new JSlider(); sliderT.setMinimum(280); sliderT.setMaximum(330); sliderT.setMinorTickSpacing(1); sliderT.setValue(300); sliderT.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderI1Event(); } }); sliderV = new JSlider(); sliderV.setMinimum(3); sliderV.setMaximum(30); sliderV.setMinorTickSpacing(1); sliderV.setValue(15); sliderV.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI2Event(); } }); sliderMo = new JSlider(); sliderMo.setMinimum(1); sliderMo.setMaximum(1000); sliderMo.setValue(5); sliderMo.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI3Event(); } }); lblM = new JLabel("Masa Final"); lblM.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMValue = new JLabel("4"); lblMValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderM = new JSlider(); sliderM.setMinimum(1); sliderM.setMaximum(1000); sliderM.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI4Event(); } }); sliderM.setValue(4); sliderM.setMinorTickSpacing(1); lblType = new JLabel("Combustible"); lblType.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblTypeValue = new JLabel("Madera"); lblTypeValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderType = new JSlider(); sliderType.setMinimum(1); sliderType.setMaximum(4); sliderType.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI5Event(); } }); sliderType.setValue(1); sliderType.setMinorTickSpacing(1); lblMc = new JLabel("Masa Combustible"); lblMc.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblMcValue = new JLabel("10"); lblMcValue.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderMc = new JSlider(); sliderMc.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI6Event(); } }); sliderMc.setMinimum(1); sliderMc.setValue(10); sliderMc.setMinorTickSpacing(1); sliderMc.setMaximum(50); btn1 = new JButton("1"); btn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { btn1function(); } }); btn2 = new JButton("2"); btn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btn1.setEnabled(true); btn2.setEnabled(false); btn3.setEnabled(true); lblT.setEnabled(true); lblTValue.setEnabled(true); sliderT.setEnabled(true); lblV.setEnabled(true); lblVValue.setEnabled(true); sliderV.setEnabled(true); lblMo.setEnabled(false); lblMoValue.setEnabled(false); sliderMo.setEnabled(false); lblM.setEnabled(false); lblMValue.setEnabled(false); sliderM.setEnabled(false); lblType.setEnabled(true); lblTypeValue.setEnabled(true); sliderType.setEnabled(true); lblMc.setEnabled(true); lblMcValue.setEnabled(true); sliderMc.setEnabled(true); model.setCurrentPhase(2); readInputs(); updateFire(); updateScrews(); updatePot(); updatePanels(); repaint(); } }); btn3 = new JButton("3"); btn3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { btn1.setEnabled(true); btn2.setEnabled(true); btn3.setEnabled(false); lblT.setEnabled(true); lblTValue.setEnabled(true); sliderT.setEnabled(true); lblV.setEnabled(false); lblVValue.setEnabled(false); sliderV.setEnabled(false); lblMo.setEnabled(false); lblMoValue.setEnabled(false); sliderMo.setEnabled(false); lblM.setEnabled(true); lblMValue.setEnabled(true); sliderM.setEnabled(true); lblType.setEnabled(true); lblTypeValue.setEnabled(true); sliderType.setEnabled(true); lblMc.setEnabled(true); lblMcValue.setEnabled(true); sliderMc.setEnabled(true); model.setCurrentPhase(3); readInputs(); updateFire(); updateScrews(); updatePot(); updatePanels(); repaint(); } }); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addComponent(panelTitle, GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE) .addGroup(gl_panelInputs.createSequentialGroup().addGap(25) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs .createParallelGroup(Alignment.TRAILING).addGroup(gl_panelInputs .createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblV, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addComponent(lblMo, GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE) .addComponent(lblM, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addComponent(lblType, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addComponent(lblMc, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE)) .addGap(18)) .addComponent(lblT, GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblMoValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblTypeValue, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addComponent(lblMcValue, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)) .addGap(4).addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(sliderMc, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addComponent(sliderType, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addComponent(sliderM, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE) .addComponent(sliderMo, GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE) .addComponent(sliderV, 0, 0, Short.MAX_VALUE) .addComponent(sliderT, 0, 0, Short.MAX_VALUE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(btn3, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE))) .addContainerGap())); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE).addComponent(lblT) .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE).addComponent(lblV) .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderV, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(lblMo) .addComponent(lblMoValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderMo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblM, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderM, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblType, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderType, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblTypeValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblMcValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblMc, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderMc, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(btn1, GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE) .addGap(12)) .addGroup(gl_panelInputs.createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(btn2, GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE) .addComponent(btn3, GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)) .addContainerGap())))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); panel_visualizar.setBackground(UIManager.getColor("Button.background")); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 382, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 741, GroupLayout.PREFERRED_SIZE) .addContainerGap(31, Short.MAX_VALUE))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent( panel_visualizar, GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)) .addGroup(groupLayout.createSequentialGroup().addGap(12).addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 568, Short.MAX_VALUE))) .addContainerGap())); JPanel panel = new JPanel(); panel.setBounds(0, 0, 345, 568); panel.setBackground(Color.WHITE); panel.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_1 = new JPanel(); panel_1.setBounds(351, 0, 390, 568); panel_1.setBackground(Color.WHITE); panel_1.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel33 = new JPanel(); panel33.setBounds(1, 38, 388, 529); panel33.setBackground(Color.WHITE); JPanel panel_5 = new JPanel(); panel_5.setBounds(1, 1, 388, 31); panel_5.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel lblGrficas = new JLabel("Gr\u00E1ficas"); lblGrficas.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_5.add(lblGrficas); panel_visualizar.setLayout(null); JPanel panel32 = new JPanel(); panel32.setBounds(1, 38, 343, 529); panel32.setBackground(Color.WHITE); JPanel panel_4 = new JPanel(); panel_4.setBounds(1, 1, 343, 31); panel_4.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel lblSimulacion = new JLabel("Simulaci\u00F3n"); lblSimulacion.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_4.add(lblSimulacion); panel_visualizar.add(panel); panel.setLayout(null); panel.add(panel_4); panel.add(panel32); panelPot = new JPanelGrafica(); panelPot.setBackground(Color.WHITE); GroupLayout gl_panel32 = new GroupLayout(panel32); gl_panel32.setHorizontalGroup(gl_panel32.createParallelGroup(Alignment.LEADING).addComponent(panelPot, GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)); gl_panel32.setVerticalGroup(gl_panel32.createParallelGroup(Alignment.LEADING).addComponent(panelPot, GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE)); panel32.setLayout(gl_panel32); panel_visualizar.add(panel_1); panel_1.setLayout(null); panel_1.add(panel33); panelGraficas = new JPanelGrafica(); panelGraficas.setBackground(Color.WHITE); GroupLayout gl_panel33 = new GroupLayout(panel33); gl_panel33.setHorizontalGroup(gl_panel33.createParallelGroup(Alignment.LEADING).addComponent(panelGraficas, GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)); gl_panel33.setVerticalGroup(gl_panel33.createParallelGroup(Alignment.LEADING).addComponent(panelGraficas, GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE)); panel33.setLayout(gl_panel33); panel_1.add(panel_5); getContentPane().setLayout(groupLayout); }
From source file:com.floreantpos.ui.model.MenuItemForm.java
/** This method is called from within the constructor to * initialize the form.// w w w .ja v a 2 s .com * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { lblStockCount = new JLabel(Messages.getString("MenuItemForm.17")); //$NON-NLS-1$ tfStockCount = new DoubleTextField(1); cbDisableStockCount = new JCheckBox(Messages.getString("MenuItemForm.18")); //$NON-NLS-1$ lblButtonColor = new JLabel(Messages.getString("MenuItemForm.19")); //$NON-NLS-1$ tabbedPane = new javax.swing.JTabbedPane(); tabGeneral = new javax.swing.JPanel(); lfname = new javax.swing.JLabel(); lfname.setHorizontalAlignment(SwingConstants.TRAILING); tfName = new com.floreantpos.swing.FixedLengthTextField(20); lgroup = new javax.swing.JLabel(); lgroup.setHorizontalAlignment(SwingConstants.TRAILING); cbGroup = new javax.swing.JComboBox(); cbGroup.setPreferredSize(new Dimension(198, 0)); btnNewGroup = new javax.swing.JButton(); lblPrice = new javax.swing.JLabel(); lblPrice.setHorizontalAlignment(SwingConstants.TRAILING); tfPrice = new DoubleTextField(20); tfPrice.setHorizontalAlignment(javax.swing.JTextField.RIGHT); tfDescription = new JTextArea(new FixedLengthDocument(255)); //tfDescription.setDocument(; tfUnitName = new FixedLengthTextField(20); lTax = new javax.swing.JLabel(); lTax.setHorizontalAlignment(SwingConstants.TRAILING); cbTax = new javax.swing.JComboBox(); btnNewTax = new javax.swing.JButton(); lDiscountRate = new javax.swing.JLabel(); lDiscountRate.setHorizontalAlignment(SwingConstants.TRAILING); lPercentage = new javax.swing.JLabel(); tfDiscountRate = new DoubleTextField(18); tfDiscountRate.setHorizontalAlignment(SwingConstants.TRAILING); chkVisible = new javax.swing.JCheckBox(); tabModifier = new javax.swing.JPanel(); btnNewModifierGroup = new javax.swing.JButton(); btnDeleteModifierGroup = new javax.swing.JButton(); btnEditModifierGroup = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); tableTicketItemModifierGroups = new javax.swing.JTable(); tabShift = new javax.swing.JPanel(); tabPrice = new javax.swing.JPanel(); tabButtonStyle = new javax.swing.JPanel(); btnDeleteShift = new javax.swing.JButton(); btnAddShift = new javax.swing.JButton(); btnNewPrice = new javax.swing.JButton(); btnUpdatePrice = new javax.swing.JButton(); btnDeletePrice = new javax.swing.JButton(); btnDeleteAll = new javax.swing.JButton(); btnDefaultValue = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); jScrollPane3 = new javax.swing.JScrollPane(); shiftTable = new javax.swing.JTable(); priceTable = new javax.swing.JTable(); cbPrinterGroup = new JComboBox<PrinterGroup>(new DefaultComboBoxModel<PrinterGroup>( PrinterGroupDAO.getInstance().findAll().toArray(new PrinterGroup[0]))); cbPrinterGroup.setPreferredSize(new Dimension(226, 0)); tfTranslatedName = new FixedLengthTextField(20); tfTranslatedName.setLength(120); lblUnitName = new JLabel(Messages.getString("MenuItemForm.23")); //$NON-NLS-1$ lblKitchenPrinter = new JLabel(Messages.getString("MenuItemForm.27")); //$NON-NLS-1$ lgroup.setText(Messages.getString("LABEL_GROUP")); //$NON-NLS-1$ lfname.setText(Messages.getString("LABEL_NAME")); //$NON-NLS-1$ tfName.setLength(120); lblTranslatedName = new JLabel(Messages.getString("MenuItemForm.lblTranslatedName.text")); //$NON-NLS-1$ tfBarcode = new FixedLengthTextField(20); tfSortOrder = new IntegerTextField(20); lblSortOrder = new JLabel(Messages.getString("MenuItemForm.lblSortOrder.text")); //$NON-NLS-1$ tfSortOrder.setText(""); //$NON-NLS-1$ lblBarcode = new JLabel(Messages.getString("MenuItemForm.lblBarcode.text")); //$NON-NLS-1$ cbTax.setPreferredSize(new Dimension(198, 0)); ///lblButtonColor = new JLabel(Messages.getString("MenuItemForm.lblButtonColor.text")); //$NON-NLS-1$ btnButtonColor = new JButton(); //$NON-NLS-1$ btnButtonColor.setPreferredSize(new Dimension(228, 40)); lblTextColor = new JLabel(Messages.getString("MenuItemForm.lblTextColor.text")); //$NON-NLS-1$ btnTextColor = new JButton(Messages.getString("MenuItemForm.SAMPLE_TEXT")); //$NON-NLS-1$ // btnTextColor.setPreferredSize(new Dimension(228, 40)); cbShowTextWithImage = new JCheckBox(Messages.getString("MenuItemForm.40")); //$NON-NLS-1$ cbShowTextWithImage.setActionCommand(Messages.getString("MenuItemForm.41")); //$NON-NLS-1$ lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); //$NON-NLS-1$ cbFractionalUnit = new JCheckBox(Messages.getString("MenuItemForm.24")); //$NON-NLS-1$ btnNewGroup.setText("..."); //$NON-NLS-1$ btnNewGroup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doCreateNewGroup(evt); } }); if (Application.getInstance().isPriceIncludesTax()) { lblPrice.setText(Messages.getString("LABEL_SALES_PRICE_INCLUDING_TAX")); //$NON-NLS-1$ } else { lblPrice.setText(Messages.getString("LABEL_SALES_PRICE_EXCLUDING_TAX")); //$NON-NLS-1$ } tfPrice.setHorizontalAlignment(javax.swing.JTextField.RIGHT); lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$ btnNewTax.setText("..."); //$NON-NLS-1$ btnNewTax.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNewTaxdoCreateNewTax(evt); } }); lDiscountRate.setText(com.floreantpos.POSConstants.DISCOUNT_RATE + ":"); //$NON-NLS-1$ lPercentage.setText("%"); //$NON-NLS-1$ chkVisible.setText(com.floreantpos.POSConstants.VISIBLE); chkVisible.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); chkVisible.setMargin(new java.awt.Insets(0, 0, 0, 0)); tabbedPane.addTab(com.floreantpos.POSConstants.GENERAL, tabGeneral); tabbedPane.setPreferredSize(new Dimension(750, 470)); btnNewModifierGroup.setText(com.floreantpos.POSConstants.ADD); btnNewModifierGroup.setActionCommand("AddModifierGroup"); //$NON-NLS-1$ btnNewModifierGroup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNewModifierGroupActionPerformed(evt); } }); btnDeleteModifierGroup.setText(com.floreantpos.POSConstants.DELETE); btnDeleteModifierGroup.setActionCommand("DeleteModifierGroup"); //$NON-NLS-1$ btnEditModifierGroup.setText(com.floreantpos.POSConstants.EDIT); btnEditModifierGroup.setActionCommand("EditModifierGroup"); //$NON-NLS-1$ menuItemMGListModel = new MenuItemMGListModel(); tableTicketItemModifierGroups.setModel(menuItemMGListModel); btnNewModifierGroup.addActionListener(this); btnEditModifierGroup.addActionListener(this); btnDeleteModifierGroup.addActionListener(this); btnAddShift.addActionListener(this); btnDeleteShift.addActionListener(this); tfDiscountRate.setDocument(new DoubleDocument()); tabGeneral.setLayout(new MigLayout("insets 20", "[][]20px[][]", "[][][][][][][][][][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ /*JLabel lblImage = new JLabel(Messages.getString("MenuItemForm.28")); //$NON-NLS-1$ lblImage.setHorizontalAlignment(SwingConstants.TRAILING); tabGeneral.add(lblImage, "cell 0 0,right"); //$NON-NLS-1$ lblImagePreview = new JLabel(""); //$NON-NLS-1$ lblImagePreview.setHorizontalAlignment(JLabel.CENTER); lblImagePreview.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); lblImagePreview.setPreferredSize(new Dimension(100, 100)); tabGeneral.add(lblImagePreview, "cell 1 0"); //$NON-NLS-1$ JButton btnSelectImage = new JButton("..."); //$NON-NLS-1$ btnSelectImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSelectImageFile(); } }); tabGeneral.add(btnSelectImage, "cell 1 0"); //$NON-NLS-1$ btnClearImage = new JButton(Messages.getString("MenuItemForm.34")); //$NON-NLS-1$ btnClearImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doClearImage(); } }); tabGeneral.add(btnClearImage, "cell 1 0"); //$NON-NLS-1$ */ tabGeneral.add(lfname, "cell 0 1 ,right"); //$NON-NLS-1$ tabGeneral.add(tfName, "cell 1 1,grow"); //$NON-NLS-1$ tabGeneral.add(lblTranslatedName, "cell 0 2,right"); //$NON-NLS-1$ tabGeneral.add(tfTranslatedName, "cell 1 2,grow"); //$NON-NLS-1$ /*tabGeneral.add(new JLabel("Description"), "cell 0 3,right"); JScrollPane scrlDescription = new JScrollPane(tfDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tabGeneral.add(scrlDescription, "cell 1 3");*/ tabGeneral.add(lblUnitName, "cell 0 3,right"); //$NON-NLS-1$ tabGeneral.add(tfUnitName, "cell 1 3,grow"); //$NON-NLS-1$ JLabel lblBuyPrice = new JLabel(Messages.getString("LABEL_BUY_PRICE")); //$NON-NLS-1$ tabGeneral.add(lblBuyPrice, "cell 0 4,alignx right"); //$NON-NLS-1$ tfBuyPrice = new DoubleTextField(20); tfBuyPrice.setHorizontalAlignment(SwingConstants.TRAILING); tabGeneral.add(tfBuyPrice, "cell 1 4,grow"); //$NON-NLS-1$ tabGeneral.add(lblPrice, "cell 0 5,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfPrice, "cell 1 5,grow"); //$NON-NLS-1$ tabGeneral.add(lgroup, "cell 0 6,alignx right"); //$NON-NLS-1$ tabGeneral.add(cbGroup, "cell 1 6"); //$NON-NLS-1$ tabGeneral.add(btnNewGroup, "cell 1 6"); //$NON-NLS-1$ tabGeneral.add(lblBarcode, "cell 0 7,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfBarcode, "cell 1 7,grow"); //$NON-NLS-1$ tabGeneral.add(lblSortOrder, "cell 0 8,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfSortOrder, "cell 1 8,grow"); //$NON-NLS-1$ tabGeneral.add(lblStockCount, "cell 0 9,alignx right"); //$NON-NLS-1$ tabGeneral.add(tfStockCount, "cell 1 9,grow"); //$NON-NLS-1$ //tabGeneral.add(cbShowTextWithImage, "cell 1 8"); //$NON-NLS-1$ tabGeneral.add(chkVisible, "cell 1 10"); //$NON-NLS-1$ tabGeneral.add(cbFractionalUnit, "cell 1 11"); //$NON-NLS-1$ tabGeneral.add(cbDisableStockCount, "cell 1 12"); //$NON-NLS-1$ // right side tabGeneral.add(lblKitchenPrinter, "cell 2 1,right"); //$NON-NLS-1$ tabGeneral.add(cbPrinterGroup, "cell 3 1,grow"); //$NON-NLS-1$ tabGeneral.add(lTax, "cell 2 2,right"); //$NON-NLS-1$ tabGeneral.add(cbTax, "cell 3 2"); //$NON-NLS-1$ tabGeneral.add(btnNewTax, "cell 3 2,grow"); //$NON-NLS-1$ /*tabGeneral.add(lblButtonColor, "cell 2 3,right"); //$NON-NLS-1$ tabGeneral.add(btnButtonColor, "cell 3 3,grow"); //$NON-NLS-1$ tabGeneral.add(lblTextColor, "cell 2 4,right"); //$NON-NLS-1$ tabGeneral.add(btnTextColor, "cell 3 4 3 5"); //$NON-NLS-1$ btnTextColor.setPreferredSize(new Dimension(228, 50));*/ tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.25")), "cell 2 3,,aligny top,alignx right"); //$NON-NLS-1$ //$NON-NLS-2$ orderList = new CheckBoxList(); List<OrderType> orderTypes = Application.getInstance().getOrderTypes(); orderList.setModel(orderTypes); // List<String> orderListM = new ArrayList(); // orderListM.add(OrderType.DINE_IN.toString()); // orderListM.add(OrderType.BAR_TAB.toString()); // orderListM.add(OrderType.DRIVE_THRU.toString()); // orderListM.add(OrderType.HOME_DELIVERY.toString()); // orderListM.add(OrderType.PICKUP.toString()); // orderListM.add(OrderType.RETAIL.toString()); // orderListM.add(OrderType.TAKE_OUT.toString()); // orderList.setModel(orderListM); JScrollPane orderCheckBoxList = new JScrollPane(orderList); orderCheckBoxList.setPreferredSize(new Dimension(228, 100)); tabGeneral.add(orderCheckBoxList, "cell 3 3 3 4"); //$NON-NLS-1$ tfDescription.setWrapStyleWord(true); tfDescription.setLineWrap(true); tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.29")), "cell 2 7,aligny top,alignx right"); //$NON-NLS-1$ //$NON-NLS-2$ JScrollPane scrlDescription = new JScrollPane(tfDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrlDescription.setPreferredSize(new Dimension(228, 90)); tabGeneral.add(scrlDescription, "cell 3 7 3 4"); //$NON-NLS-1$ add(tabbedPane); //TODO: addRecepieExtension(); /*btnButtonColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.42"), btnButtonColor.getBackground()); //$NON-NLS-1$ btnButtonColor.setBackground(color); btnTextColor.setBackground(color); } }); btnTextColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.43"), btnTextColor.getForeground()); //$NON-NLS-1$ btnTextColor.setForeground(color); } });*/ jScrollPane1.setViewportView(tableTicketItemModifierGroups); GroupLayout jPanel2Layout = new GroupLayout(tabModifier); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(Alignment.TRAILING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(Alignment.BASELINE) .addComponent(btnDeleteModifierGroup).addComponent(btnEditModifierGroup) .addComponent(btnNewModifierGroup)) .addContainerGap())); jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(Alignment.TRAILING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout .createParallelGroup(Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addComponent(btnNewModifierGroup) .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnEditModifierGroup) .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnDeleteModifierGroup)) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)) .addContainerGap())); tabModifier.setLayout(jPanel2Layout); tabbedPane.addTab(com.floreantpos.POSConstants.MODIFIER_GROUPS, tabModifier); btnDeleteShift.setText(com.floreantpos.POSConstants.DELETE_SHIFT); btnAddShift.setText(com.floreantpos.POSConstants.ADD_SHIFT); shiftTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ jScrollPane2.setViewportView(shiftTable); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(tabShift); tabShift.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup().addContainerGap(76, Short.MAX_VALUE) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 670, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup().add(btnAddShift).add(5, 5, 5) .add(btnDeleteShift))) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup() .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 345, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(btnAddShift).add(btnDeleteShift)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); tabbedPane.addTab(com.floreantpos.POSConstants.SHIFTS, tabShift); // btnNewPrice.setText(Messages.getString("MenuItemForm.9")); //$NON-NLS-1$ btnNewPrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addNewPrice(); } }); btnUpdatePrice.setText(Messages.getString("MenuItemForm.13")); //$NON-NLS-1$ btnUpdatePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updatePrice(); } }); btnDeletePrice.setText(Messages.getString("MenuItemForm.14")); //$NON-NLS-1$ btnDeletePrice.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deletePrice(); } }); btnDeleteAll.setText(Messages.getString("MenuItemForm.15")); //$NON-NLS-1$ btnDeleteAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteAll(); } }); btnDefaultValue.setText(Messages.getString("MenuItemForm.7")); //$NON-NLS-1$ /*btnDefaultValue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setDefaultValue(); } });*/ priceTable .setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ jScrollPane3.setViewportView(priceTable); tabPrice.setLayout(new BorderLayout()); tabPrice.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); tabPrice.add(jScrollPane3, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.add(btnNewPrice); buttonPanel.add(btnUpdatePrice); //buttonPanel.add(btnDefaultValue); buttonPanel.add(btnDeletePrice); // buttonPanel.add(btnDeleteAll); tabPrice.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab(Messages.getString("MenuItemForm.16"), tabPrice); //$NON-NLS-1$ // tabbedPane.addChangeListener(this); // tabButtonStyle.setLayout(new MigLayout("insets 10", "[][]100[][][][]", "[][][center][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JLabel lblImage = new JLabel(Messages.getString("MenuItemForm.28")); //$NON-NLS-1$ lblImage.setHorizontalAlignment(SwingConstants.TRAILING); tabButtonStyle.add(lblImage, "cell 0 0,right"); //$NON-NLS-1$ lblImagePreview = new JLabel(""); //$NON-NLS-1$ lblImagePreview.setHorizontalAlignment(JLabel.CENTER); lblImagePreview.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); lblImagePreview.setPreferredSize(new Dimension(100, 100)); tabButtonStyle.add(lblImagePreview, "cell 1 0"); //$NON-NLS-1$ JButton btnSelectImage = new JButton("..."); //$NON-NLS-1$ btnClearImage = new JButton(Messages.getString("MenuItemForm.34")); //$NON-NLS-1$ tabButtonStyle.add(btnClearImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(btnSelectImage, "cell 1 0"); //$NON-NLS-1$ tabButtonStyle.add(lblButtonColor, "cell 0 2,right"); //$NON-NLS-1$ tabButtonStyle.add(btnButtonColor, "cell 1 2,grow"); //$NON-NLS-1$ tabButtonStyle.add(lblTextColor, "cell 0 3,right"); //$NON-NLS-1$ tabButtonStyle.add(btnTextColor, "cell 1 3"); //$NON-NLS-1$ tabButtonStyle.add(cbShowTextWithImage, "cell 1 4"); //$NON-NLS-1$ /* tabButtonStyle.add(lblImagePreview, "cell 3 0 3 4"); //$NON-NLS-1$ tabButtonStyle.add(btnClearImage, "cell 3 0,gaptop 40"); //$NON-NLS-1$ tabButtonStyle.add(btnSelectImage, "cell 3 0,gaptop 40"); //$NON-NLS-1$ tabButtonStyle.add(lblImage, "cell 2 0,gaptop 40"); //$NON-NLS-1$ tabButtonStyle.add(lblButtonColor, "cell 0 0,right"); //$NON-NLS-1$ tabButtonStyle.add(btnButtonColor, "cell 1 0,grow"); //$NON-NLS-1$ tabButtonStyle.add(lblTextColor, "cell 0 1,right"); //$NON-NLS-1$ tabButtonStyle.add(btnTextColor, "cell 1 1"); //$NON-NLS-1$ */ btnTextColor.setPreferredSize(new Dimension(228, 50)); btnSelectImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSelectImageFile(); } }); btnClearImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doClearImage(); } }); btnButtonColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.42"), //$NON-NLS-1$ btnButtonColor.getBackground()); btnButtonColor.setBackground(color); btnTextColor.setBackground(color); } }); btnTextColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color color = JColorChooser.showDialog(MenuItemForm.this, Messages.getString("MenuItemForm.43"), //$NON-NLS-1$ btnTextColor.getForeground()); btnTextColor.setForeground(color); } }); tabbedPane.addTab(Messages.getString("MenuItemForm.26"), tabButtonStyle); //$NON-NLS-1$ }
From source file:SuitaDetails.java
public void initTCOptions() { tcoptions = new JPanel(); tcoptions.setBackground(Color.WHITE); JLabel tcname = new JLabel("TC name:"); ttcname = new JTextField(); JLabel view = new JLabel("TC view: "); tview = new JTextField(); runnable = new JCheckBox("Runnable"); runnable.setBackground(Color.WHITE); optional = new JCheckBox("Optional"); optional.setBackground(Color.WHITE); prerequisites = new JCheckBox("setup file"); teardown = new JCheckBox("teardown file"); prerequisites.setBackground(Color.WHITE); teardown.setBackground(Color.WHITE); prop = new PropPanel(); param = new ParamPanel(); GroupLayout layout = new GroupLayout(tcoptions); tcoptions.setLayout(layout);//from ww w . j a va 2s. c o m layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addComponent(prop, 0, 0, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(param, 0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addComponent(runnable).addGap(18, 18, 18) .addComponent(optional).addGap(18, 18, 18).addComponent(prerequisites) .addGap(18, 18, 18).addComponent(teardown)) .addGroup(layout.createSequentialGroup().addComponent(tcname) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(ttcname, GroupLayout.PREFERRED_SIZE, 300, GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addComponent(view) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(tview, GroupLayout.PREFERRED_SIZE, 300, GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(tcname) .addComponent(ttcname, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(view) .addComponent(tview, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(runnable) .addComponent(optional).addComponent(prerequisites).addComponent(teardown)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(prop, 0, 0, Short.MAX_VALUE) .addComponent(param, 0, 0, Short.MAX_VALUE)) .addContainerGap())); }
From source file:com.nbt.TreeFrame.java
private void initComponents() { setTitle(TITLE);/* w w w. j a va2 s . co m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); JToolBar toolBar = createToolBar(); contentPane = new JPanel(); setContentPane(contentPane); JPanel browsePanel = new JPanel(); Border border = new TitledBorder(null, "Location"); browsePanel.setBorder(border); textFile = new JTextField(); textFile.setEditable(false); btnBrowse = new JButton("Browse"); btnBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browseAction.actionPerformed(e); } }); scrollPane = new JScrollPane(); JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); int unitIncrement = 200; verticalScrollBar.setUnitIncrement(unitIncrement); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane .setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) .addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup().addContainerGap() .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) .addComponent(browsePanel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) .addComponent(scrollPane, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)) .addContainerGap()) .addComponent(toolBar, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addComponent(toolBar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(browsePanel) .addPreferredGap(ComponentPlacement.RELATED).addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) .addContainerGap())); GroupLayout gl_browsePanel = new GroupLayout(browsePanel); gl_browsePanel .setHorizontalGroup(gl_browsePanel.createParallelGroup(Alignment.LEADING) .addGroup(Alignment.TRAILING, gl_browsePanel.createSequentialGroup().addContainerGap() .addComponent(textFile, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnBrowse) .addContainerGap())); gl_browsePanel.setVerticalGroup(gl_browsePanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_browsePanel.createSequentialGroup() // .addContainerGap() .addGroup(gl_browsePanel .createParallelGroup(Alignment.BASELINE).addComponent(textFile, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) .addComponent(btnBrowse)) .addContainerGap())); browsePanel.setLayout(gl_browsePanel); contentPane.setLayout(gl_contentPane); int width = 440, height = 400; setMinimumSize(new Dimension(width, height)); pack(); }