List of usage examples for javax.swing JSplitPane setRightComponent
@BeanProperty(bound = false, preferred = true, description = "The component to the right (or below) the divider.") public void setRightComponent(Component comp)
From source file:com.intuit.tank.tools.debugger.PanelBuilder.java
/** * @param debuggerActions//from ww w .j av a2s . c o m * @return */ static Component createContentPanel(final AgentDebuggerFrame frame) { JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); final RSyntaxTextArea scriptEditorTA = new RSyntaxTextArea(); frame.setScriptEditorTA(scriptEditorTA); scriptEditorTA.setSelectionColor(scriptEditorTA.getCurrentLineHighlightColor()); scriptEditorTA.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE); scriptEditorTA.setHyperlinksEnabled(false); scriptEditorTA.setEditable(false); scriptEditorTA.setEnabled(false); scriptEditorTA.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { scriptEditorTA.grabFocus(); try { int offs = scriptEditorTA.viewToModel(e.getPoint()); if (offs > -1) { int line = scriptEditorTA.getLineOfOffset(offs); if (frame.getSteps().size() > line) { frame.fireStepChanged(line); if (e.getClickCount() == 2 && !e.isPopupTrigger()) { // show step xml try { DebugStep debugStep = frame.getSteps().get(line); String text = JaxbUtil.marshall(debugStep.getStepRun()); StepDialog dlg = new StepDialog(frame, text, SyntaxConstants.SYNTAX_STYLE_XML); dlg.setVisible(true); } catch (JAXBException e1) { frame.showError("Error showing step xml: " + e); } } } } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } }); RTextScrollPane scriptEditorScrollPane = new RTextScrollPane(scriptEditorTA); frame.setScriptEditorScrollPane(scriptEditorScrollPane); scriptEditorScrollPane.setIconRowHeaderEnabled(true); scriptEditorScrollPane.getGutter() .setBookmarkIcon(ActionProducer.getIcon("bullet_blue.png", IconSize.SMALL)); scriptEditorScrollPane.getGutter() .setCurrentLineIcon(ActionProducer.getIcon("current_line.png", IconSize.SMALL)); scriptEditorScrollPane.getGutter().setBookmarkingEnabled(true); pane.setLeftComponent(scriptEditorScrollPane); pane.setRightComponent(createRightPanel(frame)); pane.setDividerLocation(300); pane.setResizeWeight(0.4D); return pane; }
From source file:cool.pandora.modeller.ui.jpanel.base.BagView.java
/** * createBagPanel./*from w w w.j ava 2 s . c o m*/ * * @return splitPane */ private JSplitPane createBagPanel() { final LineBorder border = new LineBorder(Color.GRAY, 1); bagButtonPanel = createBagButtonPanel(); final JPanel bagTagButtonPanel = createBagTagButtonPanel(); bagPayloadTree = new BagTree(this, AbstractBagConstants.DATA_DIRECTORY); bagPayloadTree.setEnabled(false); bagPayloadTreePanel = new BagTreePanel(bagPayloadTree); bagPayloadTreePanel.setEnabled(false); bagPayloadTreePanel.setBorder(border); bagPayloadTreePanel.setToolTipText(getMessage("bagTree.help")); bagTagFileTree = new BagTree(this, getMessage("bag.label.noname")); bagTagFileTree.setEnabled(false); bagTagFileTreePanel = new BagTreePanel(bagTagFileTree); bagTagFileTreePanel.setEnabled(false); bagTagFileTreePanel.setBorder(border); bagTagFileTreePanel.setToolTipText(getMessage("bagTree.help")); tagManifestPane = new TagManifestPane(this); tagManifestPane.setToolTipText(getMessage("compositePane.tab.help")); final JSplitPane splitPane = new JSplitPane(); splitPane.setResizeWeight(0.5); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); final JPanel payloadPannel = new JPanel(); splitPane.setLeftComponent(payloadPannel); payloadPannel.setLayout(new BorderLayout(0, 0)); final JPanel payLoadToolBarPanel = new JPanel(); payloadPannel.add(payLoadToolBarPanel, BorderLayout.NORTH); payLoadToolBarPanel.setLayout(new GridLayout(1, 0, 0, 0)); final JPanel payloadLabelPanel = new JPanel(); final FlowLayout flowLayout = (FlowLayout) payloadLabelPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); payLoadToolBarPanel.add(payloadLabelPanel); final JLabel lblPayloadTree = new JLabel(getMessage("bagView.payloadTree.name")); payloadLabelPanel.add(lblPayloadTree); payLoadToolBarPanel.add(bagButtonPanel); payloadPannel.add(bagPayloadTreePanel, BorderLayout.CENTER); final JPanel tagFilePanel = new JPanel(); splitPane.setRightComponent(tagFilePanel); tagFilePanel.setLayout(new BorderLayout(0, 0)); final JPanel tagFileToolBarPannel = new JPanel(); tagFilePanel.add(tagFileToolBarPannel, BorderLayout.NORTH); tagFileToolBarPannel.setLayout(new GridLayout(0, 2, 0, 0)); final JPanel TagFileLabelPanel = new JPanel(); final FlowLayout tagFileToolbarFlowLayout = (FlowLayout) TagFileLabelPanel.getLayout(); tagFileToolbarFlowLayout.setAlignment(FlowLayout.LEFT); tagFileToolBarPannel.add(TagFileLabelPanel); final JLabel tagFileTreeLabel = new JLabel(getMessage("bagView.TagFilesTree.name")); TagFileLabelPanel.add(tagFileTreeLabel); tagFileToolBarPannel.add(bagTagButtonPanel); tagFilePanel.add(bagTagFileTreePanel, BorderLayout.CENTER); return splitPane; }
From source file:Output.SplitChart.java
public void createAndShowGUI() { //Create and set up the window. this.chartPanel = new ChartPanel(this.chart); int[] indexNull = new int[0]; this.drawGeneratorCommitmentWithTrueCostData("", 0, 0, 0, indexNull); SelectPanel selectPanel = new SelectPanel(this.amesFrame, false, null, this); //Provide minimum sizes for the two components in the split pane selectPanel.setMinimumSize(new Dimension(100, 50)); this.chartPanel.setMinimumSize(new Dimension(100, 30)); JSplitPane splitPane = new JSplitPane(); splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(selectPanel); splitPane.setRightComponent(this.chartPanel); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(430);/*from ww w .j a va 2 s . c o m*/ //Add the split pane to this frame this.getContentPane().add(splitPane); //Display the window. this.pack(); this.setVisible(true); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public Jmetrik() { super("jMetrik"); setPreferredSize(new Dimension(1024, 650)); setDefaultCloseOperation(EXIT_ON_CLOSE); //properly close database if user closes window this.addWindowListener(new WindowAdapter() { @Override//from ww w.ja v a 2 s . c o m public void windowClosing(WindowEvent we) { if (workspace != null) { workspace.closeDatabase(); } System.exit(0); } }); //add statusbar statusBar = new StatusBar(1024, 30); statusBar.setBorder(new EmptyBorder(2, 2, 2, 2)); getContentPane().add(statusBar, BorderLayout.SOUTH); //start logging startLog(); //left-right splitpane JSplitPane splitPane1 = new JSplitPane(); splitPane1.setDividerLocation(200); //setup workspace list workspaceList = new JList(); workspaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); workspaceList.setModel(new SortedListModel<DataTableName>()); workspaceList.addKeyListener(new DeleteKeyListener()); // workspaceList.getInsets().set(5, 5, 5, 5); //add icon to list cell renderer String urlString = "/images/spreadsheet.png"; URL url = this.getClass().getResource(urlString); final ImageIcon tableIcon = new ImageIcon(url, "Table"); workspaceList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); label.setIcon(tableIcon); return label; } }); JScrollPane scrollPane1 = new JScrollPane(workspaceList); scrollPane1.setPreferredSize(new Dimension(200, 698)); splitPane1.setLeftComponent(scrollPane1); //tabbed pane for top pane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); //setup data table dataTable = new DataTable(); dataTable.setRowHeight(18); //change size of table header and center text JTableHeader header = dataTable.getTableHeader(); header.setDefaultRenderer(new TableHeaderCellRenderer()); JScrollPane dataScrollPane = new JScrollPane(dataTable); tabbedPane.addTab("Data", dataScrollPane); //setup variable table variableTable = new DataTable(); variableTable.setRowHeight(18); variableTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int col = target.getSelectedColumn(); if (col == 0) { if (target.getModel() instanceof VariableModel) { VariableModel vModel = (VariableModel) target.getModel(); String s = (String) vModel.getValueAt(row, col); DatabaseName db = workspace.getDatabaseName(); DataTableName table = workspace.getCurrentDataTable(); RenameVariableDialog renameVariableDialog = new RenameVariableDialog(Jmetrik.this, db, table, s); renameVariableDialog.setVisible(true); if (renameVariableDialog.canRun()) { RenameVariableCommand command = renameVariableDialog.getCommand(); workspace.runProcess(command); } } //end instanceof } //end if col==0 } //end if click count==2 }//end mouse clicked }); //change size of table header and center text JTableHeader variableHeader = variableTable.getTableHeader(); variableHeader.setDefaultRenderer(new TableHeaderCellRenderer()); variableHeader.setPreferredSize(new Dimension(30, 21)); JScrollPane variableScrollPane = new JScrollPane(variableTable); tabbedPane.addTab("Variables", variableScrollPane); splitPane1.setRightComponent(tabbedPane); getContentPane().add(splitPane1, BorderLayout.CENTER); //add status bar listener - needed to display status message that are generated within this class this.addPropertyChangeListener(statusBar.getStatusListener()); //add listener for displaying error messages - needed to display errors and exceptions this.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); //instantiate file utilities fileUtils = new JmetrikFileUtils(); fileUtils.addPropertyChangeListener(statusBar.getStatusListener()); //set import and export path to user's documents folder JFileChooser chooser = new JFileChooser(); FileSystemView fw = chooser.getFileSystemView(); importExportPath = fw.getDefaultDirectory().toString().replaceAll("\\\\", "/"); //create and start a workspace startWorkspace(); //create menu bar and tool bar this.setJMenuBar(createMenuBar()); JToolBar toolBar = createToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); getContentPane().add(toolBar, BorderLayout.PAGE_START); pack(); }
From source file:ca.uhn.hl7v2.testpanel.ui.TestPanelWindow.java
/** * Initialize the contents of the frame. *//*from w w w .j a va 2 s . c o m*/ private void initialize() { myframe = new JFrame(); myframe.setVisible(false); List<Image> l = new ArrayList<Image>(); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_64.png"))); myframe.setIconImages(l); myframe.setTitle("HAPI TestPanel"); myframe.setBounds(100, 100, 796, 603); myframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); myframe.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent theE) { myController.close(); } }); JMenuBar menuBar = new JMenuBar(); myframe.setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('f'); menuBar.add(mnFile); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { myController.close(); } }); JMenuItem mntmNewMessage = new JMenuItem("New Message..."); mntmNewMessage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); mntmNewMessage.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/message_hl7.png"))); mnFile.add(mntmNewMessage); mySaveMenuItem = new JMenuItem("Save"); mySaveMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mySaveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); mnFile.add(mySaveMenuItem); mySaveAsMenuItem = new JMenuItem("Save As..."); mySaveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessagesAs(); } }); mnFile.add(mySaveAsMenuItem); mymenuItem_3 = new JMenuItem("Open"); mymenuItem_3.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mymenuItem_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myRevertToSavedMenuItem = new JMenuItem("Revert to Saved"); myRevertToSavedMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.revertMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); mnFile.add(myRevertToSavedMenuItem); mnFile.add(mymenuItem_3); myRecentFilesMenu = new JMenu("Open Recent"); mnFile.add(myRecentFilesMenu); JSeparator separator = new JSeparator(); mnFile.add(separator); mnFile.add(mntmExit); JMenu mnNewMenu = new JMenu("View"); mnNewMenu.setMnemonic('v'); menuBar.add(mnNewMenu); myShowLogConsoleMenuItem = new JMenuItem("Show Log Console"); myShowLogConsoleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Prefs.getInstance().setShowLogConsole(!Prefs.getInstance().getShowLogConsole()); updateLogScrollPaneVisibility(); myframe.validate(); } }); mnNewMenu.add(myShowLogConsoleMenuItem); mymenu_1 = new JMenu("Test"); menuBar.add(mymenu_1); mymenuItem_1 = new JMenuItem("Populate TestPanel with Sample Message and Connections..."); mymenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.populateWithSampleMessageAndConnections(); } }); mymenu_1.add(mymenuItem_1); mymenu_3 = new JMenu("Tools"); menuBar.add(mymenu_3); mnHl7V2FileDiff = new JMenuItem("HL7 v2 File Diff..."); mnHl7V2FileDiff.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileDiff == null) { myHl7V2FileDiff = new Hl7V2FileDiffController(myController); } myHl7V2FileDiff.show(); } }); mymenu_3.add(mnHl7V2FileDiff); mymenuItem_5 = new JMenuItem("HL7 v2 File Sort..."); mymenuItem_5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileSort == null) { myHl7V2FileSort = new Hl7V2FileSortController(myController); } myHl7V2FileSort.show(); } }); mymenu_3.add(mymenuItem_5); mymenu_2 = new JMenu("Conformance"); menuBar.add(mymenu_2); mymenuItem_2 = new JMenuItem("Profiles and Tables..."); mymenuItem_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.showProfilesAndTablesEditor(); } }); mymenu_2.add(mymenuItem_2); mymenu = new JMenu("Help"); mymenu.setMnemonic('H'); menuBar.add(mymenu); mymenuItem = new JMenuItem("About HAPI TestPanel..."); mymenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAboutDialog(); } }); mymenuItem.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); mymenu.add(mymenuItem); mymenuItem_4 = new JMenuItem("Licenses..."); mymenuItem_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new LicensesDialog().setVisible(true); } }); mymenu.add(mymenuItem_4); myframe.getContentPane().setLayout(new BorderLayout(0, 0)); JSplitPane outerSplitPane = new JSplitPane(); outerSplitPane.setBorder(null); myframe.getContentPane().add(outerSplitPane); JSplitPane leftSplitPane = new JSplitPane(); leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); outerSplitPane.setLeftComponent(leftSplitPane); JPanel messagesPanel = new JPanel(); leftSplitPane.setLeftComponent(messagesPanel); GridBagLayout gbl_messagesPanel = new GridBagLayout(); gbl_messagesPanel.columnWidths = new int[] { 110, 0 }; gbl_messagesPanel.rowHeights = new int[] { 20, 30, 118, 0, 0 }; gbl_messagesPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_messagesPanel.rowWeights = new double[] { 0.0, 0.0, 100.0, 1.0, Double.MIN_VALUE }; messagesPanel.setLayout(gbl_messagesPanel); JLabel lblMessages = new JLabel("Messages"); GridBagConstraints gbc_lblMessages = new GridBagConstraints(); gbc_lblMessages.insets = new Insets(0, 0, 5, 0); gbc_lblMessages.gridx = 0; gbc_lblMessages.gridy = 0; messagesPanel.add(lblMessages, gbc_lblMessages); JToolBar messagesToolBar = new JToolBar(); messagesToolBar.setFloatable(false); messagesToolBar.setRollover(true); messagesToolBar.setAlignmentX(Component.LEFT_ALIGNMENT); GridBagConstraints gbc_messagesToolBar = new GridBagConstraints(); gbc_messagesToolBar.insets = new Insets(0, 0, 5, 0); gbc_messagesToolBar.weightx = 1.0; gbc_messagesToolBar.anchor = GridBagConstraints.NORTHWEST; gbc_messagesToolBar.gridx = 0; gbc_messagesToolBar.gridy = 1; messagesPanel.add(messagesToolBar, gbc_messagesToolBar); JButton msgOpenButton = new JButton(""); msgOpenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myAddMessageButton = new JButton(""); myAddMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); myAddMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddMessageButton.setToolTipText("New Message"); myAddMessageButton.setBorderPainted(false); myAddMessageButton.addMouseListener(new HoverButtonMouseAdapter(myAddMessageButton)); messagesToolBar.add(myAddMessageButton); myDeleteMessageButton = new JButton(""); myDeleteMessageButton.setToolTipText("Close Selected Message"); myDeleteMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.closeMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); myDeleteMessageButton.setBorderPainted(false); myDeleteMessageButton.addMouseListener(new HoverButtonMouseAdapter(myDeleteMessageButton)); myDeleteMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/close.png"))); messagesToolBar.add(myDeleteMessageButton); msgOpenButton.setBorderPainted(false); msgOpenButton.setToolTipText("Open Messages from File"); msgOpenButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png"))); msgOpenButton.addMouseListener(new HoverButtonMouseAdapter(msgOpenButton)); messagesToolBar.add(msgOpenButton); myMsgSaveButton = new JButton(""); myMsgSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); myMsgSaveButton.setBorderPainted(false); myMsgSaveButton.setToolTipText("Save Selected Messages to File"); myMsgSaveButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/save.png"))); myMsgSaveButton.addMouseListener(new HoverButtonMouseAdapter(myMsgSaveButton)); messagesToolBar.add(myMsgSaveButton); myMessagesList = new JList(); myMessagesList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myMessagesList.getSelectedIndex() >= 0) { ourLog.debug("New messages selection " + myMessagesList.getSelectedIndex()); myController.setLeftSelectedItem(myMessagesList.getSelectedValue()); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); GridBagConstraints gbc_MessagesList = new GridBagConstraints(); gbc_MessagesList.gridheight = 2; gbc_MessagesList.weightx = 1.0; gbc_MessagesList.weighty = 1.0; gbc_MessagesList.fill = GridBagConstraints.BOTH; gbc_MessagesList.gridx = 0; gbc_MessagesList.gridy = 2; messagesPanel.add(myMessagesList, gbc_MessagesList); JPanel connectionsPanel = new JPanel(); leftSplitPane.setRightComponent(connectionsPanel); GridBagLayout gbl_connectionsPanel = new GridBagLayout(); gbl_connectionsPanel.columnWidths = new int[] { 194, 0 }; gbl_connectionsPanel.rowHeights = new int[] { 0, 30, 0, 0, 0, 0, 0 }; gbl_connectionsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_connectionsPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; connectionsPanel.setLayout(gbl_connectionsPanel); JLabel lblConnections = new JLabel("Sending Connections"); lblConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblConnections = new GridBagConstraints(); gbc_lblConnections.insets = new Insets(0, 0, 5, 0); gbc_lblConnections.anchor = GridBagConstraints.NORTH; gbc_lblConnections.fill = GridBagConstraints.HORIZONTAL; gbc_lblConnections.gridx = 0; gbc_lblConnections.gridy = 0; connectionsPanel.add(lblConnections, gbc_lblConnections); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); GridBagConstraints gbc_toolBar = new GridBagConstraints(); gbc_toolBar.insets = new Insets(0, 0, 5, 0); gbc_toolBar.anchor = GridBagConstraints.NORTH; gbc_toolBar.fill = GridBagConstraints.HORIZONTAL; gbc_toolBar.gridx = 0; gbc_toolBar.gridy = 1; connectionsPanel.add(toolBar, gbc_toolBar); myAddConnectionButton = new JButton(""); myAddConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addOutboundConnection(); } }); myAddConnectionButton.setBorderPainted(false); myAddConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddConnectionButton)); myAddConnectionButton.setBorder(null); myAddConnectionButton.setToolTipText("New Connection"); myAddConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); toolBar.add(myAddConnectionButton); myDeleteOutboundConnectionButton = new JButton(""); myDeleteOutboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteOutboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.removeOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteOutboundConnectionButton.setBorderPainted(false); myDeleteOutboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteOutboundConnectionButton)); myDeleteOutboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar.add(myDeleteOutboundConnectionButton); myStartOneOutboundButton = new JButton(""); myStartOneOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.startOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneOutboundButton.setBorderPainted(false); myStartOneOutboundButton.setToolTipText("Start selected connection"); myStartOneOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneOutboundButton)); toolBar.add(myStartOneOutboundButton); myStartAllOutboundButton = new JButton(""); myStartAllOutboundButton.setBorderPainted(false); myStartAllOutboundButton.setToolTipText("Start all sending connections"); myStartAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllOutboundButton)); myStartAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllOutboundConnections(); } }); toolBar.add(myStartAllOutboundButton); myStopAllOutboundButton = new JButton(""); myStopAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllOutboundConnections(); } }); myStopAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllOutboundButton.setToolTipText("Stop all sending connections"); myStopAllOutboundButton.setBorderPainted(false); myStopAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllOutboundButton)); toolBar.add(myStopAllOutboundButton); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 2; connectionsPanel.add(scrollPane, gbc_scrollPane); myOutboundConnectionsList = new JList(); myOutboundConnectionsList.setBorder(null); myOutboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myOutboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug( "New outbound connection selection " + myOutboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myOutboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane.setViewportView(myOutboundConnectionsList); JLabel lblReceivingConnections = new JLabel("Receiving Connections"); lblReceivingConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblReceivingConnections = new GridBagConstraints(); gbc_lblReceivingConnections.insets = new Insets(0, 0, 5, 0); gbc_lblReceivingConnections.gridx = 0; gbc_lblReceivingConnections.gridy = 3; connectionsPanel.add(lblReceivingConnections, gbc_lblReceivingConnections); JToolBar toolBar_1 = new JToolBar(); toolBar_1.setFloatable(false); GridBagConstraints gbc_toolBar_1 = new GridBagConstraints(); gbc_toolBar_1.anchor = GridBagConstraints.WEST; gbc_toolBar_1.insets = new Insets(0, 0, 5, 0); gbc_toolBar_1.gridx = 0; gbc_toolBar_1.gridy = 4; connectionsPanel.add(toolBar_1, gbc_toolBar_1); myAddInboundConnectionButton = new JButton(""); myAddInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addInboundConnection(); } }); myAddInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddInboundConnectionButton.setToolTipText("New Connection"); myAddInboundConnectionButton.setBorderPainted(false); myAddInboundConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddInboundConnectionButton)); toolBar_1.add(myAddInboundConnectionButton); myDeleteInboundConnectionButton = new JButton(""); myDeleteInboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.removeInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteInboundConnectionButton.setBorderPainted(false); myDeleteInboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteInboundConnectionButton)); myDeleteInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar_1.add(myDeleteInboundConnectionButton); myStartOneInboundButton = new JButton(""); myStartOneInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.startInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneInboundButton.setBorderPainted(false); myStartOneInboundButton.setToolTipText("Start selected connection"); myStartOneInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneInboundButton)); toolBar_1.add(myStartOneInboundButton); myStartAllInboundButton = new JButton(""); myStartAllInboundButton.setBorderPainted(false); myStartAllInboundButton.setToolTipText("Start all receiving connections"); myStartAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllInboundButton)); myStartAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllInboundConnections(); } }); toolBar_1.add(myStartAllInboundButton); myStopAllInboundButton = new JButton(""); myStopAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllInboundConnections(); } }); myStopAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllInboundButton.setToolTipText("Stop all receiving connections"); myStopAllInboundButton.setBorderPainted(false); myStopAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllInboundButton)); toolBar_1.add(myStopAllInboundButton); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBorder(null); GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints(); gbc_scrollPane_1.fill = GridBagConstraints.BOTH; gbc_scrollPane_1.gridx = 0; gbc_scrollPane_1.gridy = 5; connectionsPanel.add(scrollPane_1, gbc_scrollPane_1); myInboundConnectionsList = new JList(); myInboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myInboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug("New inbound connection selection " + myInboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myInboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane_1.setViewportView(myInboundConnectionsList); leftSplitPane.setDividerLocation(200); myWorkspacePanel = new JPanel(); myWorkspacePanel.setBorder(null); outerSplitPane.setRightComponent(myWorkspacePanel); myWorkspacePanel.setLayout(new BorderLayout(0, 0)); outerSplitPane.setDividerLocation(200); myLogScrollPane = new LogTable(); myLogScrollPane.setPreferredSize(new Dimension(454, 120)); myLogScrollPane.setMaximumSize(new Dimension(32767, 120)); myframe.getContentPane().add(myLogScrollPane, BorderLayout.SOUTH); updateLogScrollPaneVisibility(); updateLeftToolbarButtons(); }
From source file:sim.util.media.chart.ChartGenerator.java
/** Generates a new ChartGenerator with a blank chart. Before anything else, buildChart() is called. */ public ChartGenerator() { // create the chart buildChart();/*from w w w .j a va 2 s .co m*/ chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); split.setBorder(new EmptyBorder(0, 0, 0, 0)); JScrollPane scroll = new JScrollPane(); JPanel b = new JPanel(); b.setLayout(new BorderLayout()); b.add(seriesAttributes, BorderLayout.NORTH); b.add(new JPanel(), BorderLayout.CENTER); scroll.getViewport().setView(b); scroll.setBackground(getBackground()); scroll.getViewport().setBackground(getBackground()); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); LabelledList list = new LabelledList("Chart Properties"); DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list); globalAttributes.add(pan1); JLabel j = new JLabel("Right-Click or Control-Click"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); j = new JLabel("on Chart for More Options"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); titleField = new PropertyField() { public String newValue(String newValue) { setTitle(newValue); getChartPanel().repaint(); return newValue; } }; titleField.setValue(chart.getTitle().getText()); list.add(new JLabel("Title"), titleField); buildGlobalAttributes(list); final JCheckBox legendCheck = new JCheckBox(); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LegendTitle title = new LegendTitle(chart.getPlot()); title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4)); chart.addLegend(title); } else { chart.removeLegend(); } } }; legendCheck.addItemListener(il); list.add(new JLabel("Legend"), legendCheck); legendCheck.setSelected(true); /* final JCheckBox aliasCheck = new JCheckBox(); aliasCheck.setSelected(chart.getAntiAlias()); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED ); } }; aliasCheck.addItemListener(il); list.add(new JLabel("Antialias"), aliasCheck); */ JPanel pdfButtonPanel = new JPanel(); pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output")); DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel); pdfButtonPanel.setLayout(new BorderLayout()); Box pdfbox = new Box(BoxLayout.Y_AXIS); pdfButtonPanel.add(pdfbox, BorderLayout.WEST); JButton pdfButton = new JButton("Save as PDF"); pdfbox.add(pdfButton); pdfButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE); fd.setFile(chart.getTitle().getText() + ".pdf"); fd.setVisible(true); String fileName = fd.getFile(); if (fileName != null) { Dimension dim = chartPanel.getPreferredSize(); PDFEncoder.generatePDF(chart, dim.width, dim.height, new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf"))); } } }); movieButton = new JButton("Create a Movie"); pdfbox.add(movieButton); pdfbox.add(Box.createGlue()); movieButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (movieMaker == null) startMovie(); else stopMovie(); } }); globalAttributes.add(pan2); // we add into an outer box so we can later on add more global seriesAttributes // as the user instructs and still have glue be last Box outerAttributes = Box.createVerticalBox(); outerAttributes.add(globalAttributes); outerAttributes.add(Box.createGlue()); p.add(outerAttributes, BorderLayout.NORTH); p.add(scroll, BorderLayout.CENTER); p.setMinimumSize(new Dimension(0, 0)); p.setPreferredSize(new Dimension(200, 0)); split.setLeftComponent(p); // Add scale and proportion fields Box header = Box.createHorizontalBox(); final double MAXIMUM_SCALE = 8; fixBox = new JCheckBox("Fill"); fixBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFixed(fixBox.isSelected()); } }); header.add(fixBox); fixBox.setSelected(true); // add the scale field scaleField = new NumberTextField(" Scale: ", 1.0, true) { public double newValue(double newValue) { if (newValue <= 0.0) newValue = currentValue; if (newValue > MAXIMUM_SCALE) newValue = currentValue; scale = newValue; resizeChart(); return newValue; } }; scaleField.setToolTipText("Zoom in and out"); scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); scaleField.setEnabled(false); scaleField.setText(""); header.add(scaleField); // add the proportion field proportionField = new NumberTextField(" Proportion: ", 1.5, true) { public double newValue(double newValue) { if (newValue <= 0.0) newValue = currentValue; proportion = newValue; resizeChart(); return newValue; } }; proportionField.setToolTipText("Change the chart proportions (ratio of width to height)"); proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); header.add(proportionField); chartHolder.setMinimumSize(new Dimension(0, 0)); chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); chartHolder.getViewport().setBackground(Color.gray); JPanel p2 = new JPanel(); p2.setLayout(new BorderLayout()); p2.add(chartHolder, BorderLayout.CENTER); p2.add(header, BorderLayout.NORTH); split.setRightComponent(p2); setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); // set the default to be white, which looks good when printed chart.setBackgroundPaint(Color.WHITE); // JFreeChart has a hillariously broken way of handling font scaling. // It allows fonts to scale independently in X and Y. We hack a workaround here. chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION), (int) (DEFAULT_CHART_HEIGHT))); }
From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java
/** Generates a new ChartGenerator with a blank chart. Before anything else, buildChart() is called. */ public ChartGenerator() { // create the chart buildChart();/* ww w .ja va 2s.co m*/ chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); split.setBorder(new EmptyBorder(0, 0, 0, 0)); JScrollPane scroll = new JScrollPane(); JPanel b = new JPanel(); b.setLayout(new BorderLayout()); b.add(seriesAttributes, BorderLayout.NORTH); b.add(new JPanel(), BorderLayout.CENTER); scroll.getViewport().setView(b); scroll.setBackground(getBackground()); scroll.getViewport().setBackground(getBackground()); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); LabelledList list = new LabelledList("Chart Properties"); DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list); globalAttributes.add(pan1); JLabel j = new JLabel("Right-Click or Control-Click"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); j = new JLabel("on Chart for More Options"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); titleField = new PropertyField() { public String newValue(String newValue) { setTitle(newValue); getChartPanel().repaint(); return newValue; } }; titleField.setValue(chart.getTitle().getText()); list.add(new JLabel("Title"), titleField); buildGlobalAttributes(list); final JCheckBox legendCheck = new JCheckBox(); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LegendTitle title = new LegendTitle(chart.getPlot()); title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4)); chart.addLegend(title); } else { chart.removeLegend(); } } }; legendCheck.addItemListener(il); list.add(new JLabel("Legend"), legendCheck); legendCheck.setSelected(true); /* final JCheckBox aliasCheck = new JCheckBox(); aliasCheck.setSelected(chart.getAntiAlias()); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED ); } }; aliasCheck.addItemListener(il); list.add(new JLabel("Antialias"), aliasCheck); */ JPanel pdfButtonPanel = new JPanel(); pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output")); DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel); pdfButtonPanel.setLayout(new BorderLayout()); Box pdfbox = new Box(BoxLayout.Y_AXIS); pdfButtonPanel.add(pdfbox, BorderLayout.WEST); JButton pdfButton = new JButton("Save as PDF"); pdfbox.add(pdfButton); pdfButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE); fd.setFile(chart.getTitle().getText() + ".pdf"); fd.setVisible(true); String fileName = fd.getFile(); if (fileName != null) { Dimension dim = chartPanel.getPreferredSize(); PDFEncoder.generatePDF(chart, dim.width, dim.height, new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf"))); } } }); movieButton = new JButton("Create a Movie"); pdfbox.add(movieButton); pdfbox.add(Box.createGlue()); movieButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (movieMaker == null) { startMovie(); } else { stopMovie(); } } }); globalAttributes.add(pan2); // we add into an outer box so we can later on add more global seriesAttributes // as the user instructs and still have glue be last Box outerAttributes = Box.createVerticalBox(); outerAttributes.add(globalAttributes); outerAttributes.add(Box.createGlue()); p.add(outerAttributes, BorderLayout.NORTH); p.add(scroll, BorderLayout.CENTER); p.setMinimumSize(new Dimension(0, 0)); p.setPreferredSize(new Dimension(200, 0)); split.setLeftComponent(p); // Add scale and proportion fields Box header = Box.createHorizontalBox(); final double MAXIMUM_SCALE = 8; fixBox = new JCheckBox("Fill"); fixBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFixed(fixBox.isSelected()); } }); header.add(fixBox); fixBox.setSelected(true); // add the scale field scaleField = new NumberTextField(" Scale: ", 1.0, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } if (newValue > MAXIMUM_SCALE) { newValue = currentValue; } scale = newValue; resizeChart(); return newValue; } }; scaleField.setToolTipText("Zoom in and out"); scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); scaleField.setEnabled(false); scaleField.setText(""); header.add(scaleField); // add the proportion field proportionField = new NumberTextField(" Proportion: ", 1.5, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } proportion = newValue; resizeChart(); return newValue; } }; proportionField.setToolTipText("Change the chart proportions (ratio of width to height)"); proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); header.add(proportionField); chartHolder.setMinimumSize(new Dimension(0, 0)); chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); chartHolder.getViewport().setBackground(Color.gray); JPanel p2 = new JPanel(); p2.setLayout(new BorderLayout()); p2.add(chartHolder, BorderLayout.CENTER); p2.add(header, BorderLayout.NORTH); split.setRightComponent(p2); setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); // set the default to be white, which looks good when printed chart.setBackgroundPaint(Color.WHITE); // JFreeChart has a hillariously broken way of handling font scaling. // It allows fonts to scale independently in X and Y. We hack a workaround here. chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION), (int) (DEFAULT_CHART_HEIGHT))); }
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Initialize GUI components./*from w w w . ja v a2s. c o m*/ */ @SuppressWarnings({ "rawtypes", "unchecked" }) private void initGUI() { App.init(); // setBounds(100, 100, 972, 439); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setIconImage(Builder.getApplicationIcon()); setTitle("Sample Size Analysis"); getContentPane().setLayout(new MigLayout("", "[1136px,grow,fill]", "[30px][405px,grow]")); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); getContentPane().add(toolBar, "cell 0 0,growx,aligny top"); JToolBarButton btnOpen = new JToolBarButton(actionBrowse); btnOpen.setIcon(Builder.getImageIcon("fileopen.png")); toolBar.add(btnOpen); JToolBarButton btnSave = new JToolBarButton(actionSaveTable); btnSave.setIcon(Builder.getImageIcon("save.png")); toolBar.add(btnSave); JToolBarButton btnExportPDF = new JToolBarButton(actionExportPDF); btnExportPDF.setIcon(Builder.getImageIcon("pdf.png")); toolBar.add(btnExportPDF); JToolBarButton btnExportPNG = new JToolBarButton(actionExportPNG); btnExportPNG.setIcon(Builder.getImageIcon("formatpng.png")); toolBar.add(btnExportPNG); toolBar.addSeparator(); JToolBarButton btnRun = new JToolBarButton(actionRun); btnRun.setIcon(Builder.getImageIcon("run.png")); toolBar.add(btnRun); JPanel panelMain = new JPanel(); getContentPane().add(panelMain, "cell 0 1,grow"); panelMain.setLayout(new BorderLayout(0, 0)); JSplitPane splitPaneMain = new JSplitPane(); splitPaneMain.setOneTouchExpandable(true); panelMain.add(splitPaneMain); JPanel panelParameters = new JPanel(); splitPaneMain.setLeftComponent(panelParameters); panelParameters.setLayout(new MigLayout("", "[grow,right]", "[][][][193.00,grow,fill][]")); JPanel panelInput = new JPanel(); panelInput.setBorder(new TitledBorder(null, "Input", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelParameters.add(panelInput, "cell 0 0,grow"); panelInput.setLayout(new MigLayout("", "[100px:100px:180px,right][grow,fill][]", "[]")); JLabel lblInputFile = new JLabel("Input file:"); panelInput.add(lblInputFile, "cell 0 0"); txtInputFile = new JTextField(); panelInput.add(txtInputFile, "cell 1 0,growx"); txtInputFile.setActionCommand("NewFileTyped"); txtInputFile.addActionListener(this); txtInputFile.setColumns(10); JButton btnBrowse = new JButton(""); panelInput.add(btnBrowse, "cell 2 0"); btnBrowse.setAction(actionBrowse); btnBrowse.setText(""); btnBrowse.setIcon(Builder.getImageIcon("fileopen16.png")); btnBrowse.setPreferredSize(new Dimension(25, 25)); btnBrowse.setMaximumSize(new Dimension(25, 25)); btnBrowse.putClientProperty("JButton.buttonType", "segmentedTextured"); btnBrowse.putClientProperty("JButton.segmentPosition", "middle"); JPanel panelAnalysisOptions = new JPanel(); panelAnalysisOptions.setBorder(new TitledBorder(null, "Analysis and filtering options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelParameters.add(panelAnalysisOptions, "cell 0 1,grow"); panelAnalysisOptions.setLayout(new MigLayout("", "[100px:100px:180px,right][grow][][]", "[][][][][]")); JLabel lblEventTypes = new JLabel("Event type:"); panelAnalysisOptions.add(lblEventTypes, "cell 0 0"); cboEventType = new JComboBox(); panelAnalysisOptions.add(cboEventType, "cell 1 0 3 1"); cboEventType.setModel(new DefaultComboBoxModel(EventTypeToProcess.values())); new EventTypeWrapper(cboEventType, PrefKey.EVENT_TYPE_TO_PROCESS, EventTypeToProcess.FIRE_EVENT); chkCommonYears = new JCheckBox("<html>Only analyze years all series have in common"); chkCommonYears.setEnabled(false); new CheckBoxWrapper(chkCommonYears, PrefKey.SSIZ_CHK_COMMON_YEARS, false); panelAnalysisOptions.add(chkCommonYears, "cell 1 1 3 1"); chkExcludeSeriesWithNoEvents = new JCheckBox("<html>Exclude series/segments with no events"); chkExcludeSeriesWithNoEvents.setEnabled(false); new CheckBoxWrapper(chkExcludeSeriesWithNoEvents, PrefKey.SSIZ_CHK_EXCLUDE_SERIES_WITH_NO_EVENTS, false); panelAnalysisOptions.add(chkExcludeSeriesWithNoEvents, "cell 1 2 3 1"); JLabel lblThresholdType = new JLabel("Threshold:"); panelAnalysisOptions.add(lblThresholdType, "cell 0 3"); cboThresholdType = new JComboBox(); panelAnalysisOptions.add(cboThresholdType, "cell 1 3"); cboThresholdType.setModel(new DefaultComboBoxModel(FireFilterType.values())); new FireFilterTypeWrapper(cboThresholdType, PrefKey.COMPOSITE_FILTER_TYPE_WITH_ALL_TREES, FireFilterType.NUMBER_OF_EVENTS); JLabel label = new JLabel(">="); panelAnalysisOptions.add(label, "flowx,cell 2 3"); spnThresholdValueGT = new JSpinner(); panelAnalysisOptions.add(spnThresholdValueGT, "cell 3 3"); spnThresholdValueGT.setModel(new SpinnerNumberModel(1, 1, 999, 1)); new SpinnerWrapper(spnThresholdValueGT, PrefKey.COMPOSITE_FILTER_VALUE, 1); chkEnableLessThan = new JCheckBox(""); chkEnableLessThan.setActionCommand("LessThanThresholdStatus"); chkEnableLessThan.addActionListener(this); panelAnalysisOptions.add(chkEnableLessThan, "flowx,cell 1 4,alignx right"); lblLessThan = new JLabel("<="); lblLessThan.setEnabled(false); panelAnalysisOptions.add(lblLessThan, "cell 2 4"); spnThresholdValueLT = new JSpinner(); spnThresholdValueLT.setEnabled(false); spnThresholdValueLT.setModel(new SpinnerNumberModel(1, 1, 999, 1)); panelAnalysisOptions.add(spnThresholdValueLT, "cell 3 4"); lblAnd = new JLabel("and"); panelAnalysisOptions.add(lblAnd, "cell 1 4"); JPanel panelSimulations = new JPanel(); panelSimulations.setBorder( new TitledBorder(null, "Simulations", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelParameters.add(panelSimulations, "cell 0 2,grow"); panelSimulations.setLayout(new MigLayout("", "[100px:100px:180px,right][fill]", "[][][]")); JLabel lblSimulations = new JLabel("Simulations:"); panelSimulations.add(lblSimulations, "cell 0 0"); spnSimulations = new JSpinner(); panelSimulations.add(spnSimulations, "cell 1 0"); spnSimulations.setModel(new SpinnerNumberModel(new Integer(1000), new Integer(1), null, new Integer(1))); new SpinnerWrapper(spnSimulations, PrefKey.SSIZ_SIMULATION_COUNT, 1000); JLabel lblSeedNumber = new JLabel("Seed number:"); panelSimulations.add(lblSeedNumber, "cell 0 1"); spnSeed = new JSpinner(); panelSimulations.add(spnSeed, "cell 1 1"); spnSeed.setModel(new SpinnerNumberModel(new Integer(30188), null, null, new Integer(1))); new SpinnerWrapper(spnSeed, PrefKey.SSIZ_SEED_NUMBER, 30188); JLabel lblResampling = new JLabel("Resampling:"); panelSimulations.add(lblResampling, "cell 0 2"); cboResampling = new JComboBox(); panelSimulations.add(cboResampling, "cell 1 2"); cboResampling .setModel(new DefaultComboBoxModel(new String[] { "With replacement", "Without replacement" })); new ResamplingTypeWrapper(cboResampling, PrefKey.SSIZ_RESAMPLING_TYPE, ResamplingType.WITH_REPLACEMENT); segmentationPanel = new SegmentationPanel(); segmentationPanel.chkSegmentation.setText("Process subset or segments of dataset?"); segmentationPanel.chkSegmentation.setEnabled(false); panelParameters.add(segmentationPanel, "cell 0 3,growx"); JPanel panel_3 = new JPanel(); panelParameters.add(panel_3, "cell 0 4,grow"); panel_3.setLayout(new MigLayout("", "[left][grow][right]", "[]")); JButton btnReset = new JButton("Reset"); btnReset.setActionCommand("Reset"); btnReset.addActionListener(this); panel_3.add(btnReset, "cell 0 0,grow"); JButton btnRunAnalysis = new JButton("Run Analysis"); btnRunAnalysis.setAction(actionRun); panel_3.add(btnRunAnalysis, "cell 2 0,grow"); JPanel panelResults = new JPanel(); splitPaneMain.setRightComponent(panelResults); panelResults.setLayout(new BorderLayout(0, 0)); splitPaneResults = new JSplitPane(); splitPaneResults.setResizeWeight(0.5); splitPaneResults.setOneTouchExpandable(true); splitPaneResults.setDividerLocation(0.5d); panelResults.add(splitPaneResults, BorderLayout.CENTER); splitPaneResults.setOrientation(JSplitPane.VERTICAL_SPLIT); JPanel panelResultsTop = new JPanel(); splitPaneResults.setLeftComponent(panelResultsTop); panelResultsTop.setLayout(new BorderLayout(0, 0)); JPanel panelChartOptions = new JPanel(); panelChartOptions.setBackground(Color.WHITE); panelResultsTop.add(panelChartOptions, BorderLayout.SOUTH); panelChartOptions.setLayout(new MigLayout("", "[][][][][][grow][grow]", "[15px,center]")); JLabel lblNewLabel = new JLabel("Plot:"); panelChartOptions.add(lblNewLabel, "cell 0 0,alignx trailing,aligny center"); cboChartMetric = new JComboBox(); cboChartMetric.setEnabled(false); cboChartMetric.setModel(new DefaultComboBoxModel(MiddleMetric.values())); panelChartOptions.add(cboChartMetric, "cell 1 0,growx"); cboChartMetric.setBackground(Color.WHITE); JLabel lblOfSegment = new JLabel("of segment:"); panelChartOptions.add(lblOfSegment, "cell 2 0,alignx trailing"); cboSegment = new JComboBox(); cboSegment.setBackground(Color.WHITE); cboSegment.setActionCommand("UpdateChart"); cboSegment.addActionListener(this); panelChartOptions.add(cboSegment, "cell 3 0,growx"); cboChartMetric.setActionCommand("UpdateChart"); JLabel lblWithAsymptoteType = new JLabel("with asymptote type:"); panelChartOptions.add(lblWithAsymptoteType, "cell 4 0,alignx trailing"); JComboBox comboBox = new JComboBox(); comboBox.setEnabled(false); comboBox.setModel(new DefaultComboBoxModel(new String[] { "none", "Weibull", "Michaelis-Menten", "Modified Michaelis-Menten", "Logistic", "Modified exponential" })); comboBox.setBackground(Color.WHITE); panelChartOptions.add(comboBox, "cell 5 0,growx"); cboChartMetric.addActionListener(this); panelChart = new JPanel(); panelChart.setMinimumSize(new Dimension(200, 200)); panelResultsTop.add(panelChart, BorderLayout.CENTER); panelChart.setLayout(new BorderLayout(0, 0)); panelChart.setBackground(Color.WHITE); JTabbedPane panelResultsBottom = new JTabbedPane(JTabbedPane.BOTTOM); splitPaneResults.setRightComponent(panelResultsBottom); simulationsTable = new SSIZResultsTable(); simulationsTable.setEnabled(false); simulationsTable.addMouseListener(new TablePopClickListener()); simulationsTable.setVisibleRowCount(10); adapter = new JTableSpreadsheetByRowAdapter(simulationsTable); scrollPaneSimulations = new JScrollPane(); panelResultsBottom.addTab("Simulations", null, scrollPaneSimulations, null); scrollPaneSimulations.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPaneSimulations.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneSimulations.setViewportView(simulationsTable); JPanel panelAsymptote = new JPanel(); asymptoteTable = new AsymptoteTable(); asymptoteTable.setEnabled(false); // asymptoteTable.addMouseListener(new TablePopClickListener()); asymptoteTable.setVisibleRowCount(10); scrollPaneAsymptote = new JScrollPane(); scrollPaneAsymptote.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPaneAsymptote.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneAsymptote.setViewportView(asymptoteTable); panelAsymptote.setLayout(new BorderLayout()); panelAsymptote.add(scrollPaneAsymptote, BorderLayout.CENTER); panelResultsBottom.addTab("Asymptote", null, panelAsymptote, null); // Disable asymptote tab until it is implemented panelResultsBottom.setEnabledAt(1, false); panelProgressBar = new JPanel(); panelProgressBar.setLayout(new BorderLayout()); btnCancelAnalysis = new JButton("Cancel"); btnCancelAnalysis.setIcon(Builder.getImageIcon("delete.png")); btnCancelAnalysis.setVisible(false); btnCancelAnalysis.setActionCommand("CancelAnalysis"); btnCancelAnalysis.addActionListener(this); progressBar = new JProgressBar(); panelProgressBar.add(progressBar, BorderLayout.CENTER); panelProgressBar.add(btnCancelAnalysis, BorderLayout.EAST); progressBar.setStringPainted(true); fileDialogWasUsed = false; mouseListenersActive = false; this.setGUIForFHFileReader(); this.setGUIForThresholdStatus(); pack(); this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); setVisible(true); }
From source file:src.gui.ItSIMPLE.java
/** * @return Returns the planAnalysisFramePanel. *//*from ww w . j a v a 2s .c o m*/ private ItFramePanel getPlanAnalysisFramePanel() { if (planAnalysisFramePanel == null) { planAnalysisFramePanel = new ItFramePanel(":: Plan Analysis", ItFramePanel.NO_MINIMIZE_MAXIMIZE); // tool bar JToolBar chartsToolBar = new JToolBar(); chartsToolBar.add(new JButton(drawChartAction)); // charts panel chartsPanel = new JPanel(); chartsPanel.setLayout(new BoxLayout(chartsPanel, BoxLayout.Y_AXIS)); ItFramePanel variableSelectionPanel = new ItFramePanel(".: Select variables to be tracked", ItFramePanel.NO_MINIMIZE_MAXIMIZE); //variableSelectionPanel.setBackground(new Color(151,151,157)); JSplitPane split = new JSplitPane(); split.setContinuousLayout(true); split.setOrientation(JSplitPane.HORIZONTAL_SPLIT); split.setDividerLocation(2 * screenSize.height / 3); split.setDividerSize(8); //split.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50)); //split.setPreferredSize(new Dimension(screenSize.width/4-20, 120)); split.setLeftComponent(new JScrollPane(variablesPlanTree)); split.setRightComponent(new JScrollPane(selectedVariablesPlanTree)); variableSelectionPanel.setContent(split, false); //variableSelectionPanel.setParentSplitPane() //JPanel variableSelectionPanel = new JPanel(new BorderLayout()); //variableSelectionPanel.add(new JScrollPane(variablesPlanTree), BorderLayout.CENTER); //variableSelectionPanel.add(new JScrollPane(selectedVariablesPlanTree), BorderLayout.EAST); ItFramePanel variableGraphPanel = new ItFramePanel(".: Chart", ItFramePanel.NO_MINIMIZE_MAXIMIZE); variableGraphPanel.setContent(chartsPanel, true); JSplitPane mainvariablesplit = new JSplitPane(); mainvariablesplit.setContinuousLayout(true); mainvariablesplit.setOrientation(JSplitPane.VERTICAL_SPLIT); mainvariablesplit.setDividerLocation(150); mainvariablesplit.setDividerSize(8); //mainvariablesplit.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50)); mainvariablesplit.setTopComponent(variableSelectionPanel); mainvariablesplit.setBottomComponent(variableGraphPanel); // main charts panel - used to locate the tool bar above the charts panel JPanel mainChartsPanel = new JPanel(new BorderLayout()); mainChartsPanel.add(chartsToolBar, BorderLayout.NORTH); //mainChartsPanel.add(new JScrollPane(chartsPanel), BorderLayout.CENTER); mainChartsPanel.add(mainvariablesplit, BorderLayout.CENTER); //Results planInfoEditorPane = new JEditorPane(); planInfoEditorPane.setContentType("text/html"); planInfoEditorPane.setEditable(false); planInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR)); planInfoEditorPane.setBackground(Color.WHITE); JPanel resultsPanel = new JPanel(new BorderLayout()); JToolBar resultsToolBar = new JToolBar(); resultsToolBar.setRollover(true); JButton planReportButton = new JButton("View Full Report", new ImageIcon("resources/images/viewreport.png")); planReportButton.setToolTipText("<html>View full plan report.<br> For multiple plans you will need " + "access to the Internet.<br> The components used in the report require such access (no data is " + "sent through the Internet).</html>"); planReportButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Opens html with defaut browser String path = "resources/report/Report.html"; File report = new File(path); path = report.getAbsolutePath(); try { BrowserLauncher launcher = new BrowserLauncher(); launcher.openURLinBrowser("file://" + path); } catch (BrowserLaunchingInitializingException ex) { Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex); appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n"); } catch (UnsupportedOperatingSystemException ex) { Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex); appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n"); } } }); resultsToolBar.add(planReportButton); resultsToolBar.addSeparator(); JButton planReportDataButton = new JButton("Save Report Data", new ImageIcon("resources/images/savePDDL.png")); planReportDataButton.setToolTipText("<html>Save report data to file</html>"); planReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Save report data if (solveResult != null) { Element lastOpenFolderElement = itSettings.getChild("generalSettings") .getChild("lastOpenFolder"); JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText()); fc.setDialogTitle("Save Report Data"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new XMLFileFilter()); int returnVal = fc.showSaveDialog(ItSIMPLE.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File selectedFile = fc.getSelectedFile(); String path = selectedFile.getPath(); if (!path.toLowerCase().endsWith(".xml")) { path += ".xml"; } //save file (xml) try { FileWriter file = new FileWriter(path); file.write(XMLUtilities.toString(solveResult)); file.close(); } catch (IOException e1) { e1.printStackTrace(); } //Save as a last open folder String folder = selectedFile.getParent(); //Element lastOpenFolderElement = itSettings.getChild("generalSettings").getChild("lastOpenFolder"); lastOpenFolderElement.setText(folder); XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument()); //Ask if the user wants to save plans individually too. boolean needToSavePlans = false; int option = JOptionPane.showOptionDialog(instance, "<html><center>Do you also want to save the plans" + "<br>in individual files?</center></html>", "Save plans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); switch (option) { case JOptionPane.YES_OPTION: { needToSavePlans = true; } break; case JOptionPane.NO_OPTION: { needToSavePlans = false; } break; } if (needToSavePlans) { //Close Open tabs List<?> problems = null; try { XPath ppath = new JDOMXPath("project/domains/domain/problems/problem"); problems = ppath.selectNodes(solveResult); } catch (JaxenException e2) { e2.printStackTrace(); } for (int i = 0; i < problems.size(); i++) { Element problem = (Element) problems.get(i); //create a folder for each problem and put all plans inside as xml files String folderName = problem.getChildText("name"); String folderPath = selectedFile.getAbsolutePath() .replace(selectedFile.getName(), folderName); //System.out.println(folderPath); File planfolder = new File(folderPath); boolean canSavePlan = false; try { if (planfolder.mkdir()) { System.out.println("Directory '" + folderPath + "' created."); canSavePlan = true; } else { System.out.println("Directory '" + folderPath + "' was not created."); } } catch (Exception ep) { ep.printStackTrace(); } if (canSavePlan) { Element plans = problem.getChild("plans"); for (Iterator<Element> it = plans.getChildren("xmlPlan").iterator(); it .hasNext();) { Element eaplan = it.next(); Element theplanner = eaplan.getChild("planner"); //save file (xml) String planFileName = "solution" + theplanner.getChildText("name") + "-" + theplanner.getChildText("version") + "-" + Integer.toString(plans.getChildren().indexOf(eaplan)) + ".xml"; String planPath = folderPath + File.separator + planFileName; /* try { FileWriter planfile = new FileWriter(planPath); planfile.write(XMLUtilities.toString(eaplan)); planfile.close(); System.out.println("File '" + planPath + "' created."); } catch (IOException e1) { e1.printStackTrace(); } * */ if (eaplan.getChild("plan").getChildren().size() > 0) { //TODO: save the plan in PDDL too. It should be done through the XPDDL/PDDL classes String pddlplan = ToXPDDL.XMLtoXPDDLPlan(eaplan); String planFileNamePDDL = "solution" + theplanner.getChildText("name") + "-" + theplanner.getChildText("version") + "-" + Integer.toString(plans.getChildren().indexOf(eaplan)) + ".pddl"; String planPathPDDL = folderPath + File.separator + planFileNamePDDL; //String cfolderPath = selectedFile.getAbsolutePath().replace(selectedFile.getName(), ""); //String planFileNamePDDL = theplanner.getChildText("name")+"-"+theplanner.getChildText("version") + "-" + folderName+"-solution.pddl"; //String planPathPDDL = cfolderPath + File.separator + planFileNamePDDL; //if (!theplanner.getChildText("name").contains("MIPS")){ try { FileWriter planfile = new FileWriter(planPathPDDL); planfile.write(pddlplan); planfile.close(); System.out.println("File '" + planPathPDDL + "' created."); } catch (IOException e1) { e1.printStackTrace(); } } //} } } } } } } else { appendOutputPanelText(">> No report data available to save! \n"); } } }); resultsToolBar.add(planReportDataButton); JButton openPlanReportDataButton = new JButton("Open Report Data", new ImageIcon("resources/images/openreport.png")); openPlanReportDataButton.setToolTipText("<html>Open report data to file</html>"); openPlanReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { planSimStatusBar.setText("Status: Opening File..."); appendOutputPanelText(">> Opening File... \n"); //Open report data Element lastOpenFolderElement = itSettings.getChild("generalSettings") .getChild("lastOpenFolder"); JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText()); fc.setDialogTitle("Open Report Data"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(new XMLFileFilter()); int returnVal = fc.showOpenDialog(ItSIMPLE.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // Get itSIMPLE itSettings from itSettings.xml org.jdom.Document resultsDoc = null; try { resultsDoc = XMLUtilities.readFromFile(file.getPath()); solveResult = resultsDoc.getRootElement(); //XMLUtilities.printXML(solveResult); if (solveResult.getName().equals("projects")) { String report = PlanAnalyzer.generatePlannersComparisonReport(solveResult); String comparisonReport = PlanAnalyzer .generateFullPlannersComparisonReport(solveResult); //Save Comparison Report file saveFile("resources/report/Report.html", comparisonReport); setPlanInfoPanelText(report); setPlanEvaluationInfoPanelText(""); appendOutputPanelText(">> Report data read! \n"); //My experiments PlanAnalyzer.myAnalysis(itPlanners.getChild("planners"), solveResult); } } catch (Exception e1) { e1.printStackTrace(); } //Save as a last open folder String folder = fc.getSelectedFile().getParent(); lastOpenFolderElement.setText(folder); XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument()); } else { planSimStatusBar.setText("Status:"); appendOutputPanelText(">> Canceled \n"); } } }); resultsToolBar.add(openPlanReportDataButton); JButton compareProjectReportDataButton = new JButton("Compare Project Data", new ImageIcon("resources/images/compare.png")); compareProjectReportDataButton.setToolTipText( "<html>Compare different project report data <br> This is commonly use to compare diferent domain models with different adjustments.<br>" + "One project data must be chosen as a reference; others will be compared to this referencial one.</html>"); compareProjectReportDataButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ProjectComparisonDialog dialog = new ProjectComparisonDialog(); dialog.setVisible(true); final List<String> files = dialog.getFiles(); if (files.size() > 1) { new Thread() { public void run() { appendOutputPanelText(">> Project comparison report requested. Processing... \n"); planSimStatusBar.setText("Status: Reading files ..."); appendOutputPanelText(">> Reading files ... \n"); //base project file String baseFileName = files.get(0); appendOutputPanelText(">> Reading file '" + baseFileName + "' \n"); org.jdom.Document baseProjectDoc = null; try { baseProjectDoc = XMLUtilities.readFromFile(baseFileName); } catch (Exception ec) { ec.printStackTrace(); } Element baseProject = null; if (baseProjectDoc != null) { baseProject = baseProjectDoc.getRootElement().getChild("project"); } //The comparible projects List<Element> comparableProjects = new ArrayList<Element>(); for (int i = 1; i < files.size(); i++) { String eafile = files.get(i); appendOutputPanelText(">> Reading file '" + eafile + "' \n"); org.jdom.Document eaProjectDoc = null; try { eaProjectDoc = XMLUtilities.readFromFile(eafile); } catch (Exception ec) { ec.printStackTrace(); } if (eaProjectDoc != null) { comparableProjects.add(eaProjectDoc.getRootElement().getChild("project")); } } appendOutputPanelText(">> Files read. Building report... \n"); String comparisonReport = PlanAnalyzer.generateProjectComparisonReport(baseProject, comparableProjects); saveFile("resources/report/Report.html", comparisonReport); appendOutputPanelText( ">> Project comparison report generated. Press 'View Full Report'\n"); appendOutputPanelText(" \n"); } }.start(); } } }); resultsToolBar.add(compareProjectReportDataButton); resultsPanel.add(resultsToolBar, BorderLayout.NORTH); resultsPanel.add(new JScrollPane(planInfoEditorPane), BorderLayout.CENTER); JTabbedPane planAnalysisTabbedPane = new JTabbedPane(); planAnalysisTabbedPane.addTab("Results", resultsPanel); planAnalysisTabbedPane.addTab("Variable Tracking", mainChartsPanel); planAnalysisTabbedPane.addTab("Movie Maker", getMovieMakerPanel()); planAnalysisTabbedPane.addTab("Plan Evaluation", getPlanEvaluationPanel()); planAnalysisTabbedPane.addTab("Plan Database", getPlanDatabasePanel()); planAnalysisTabbedPane.addTab("Rationale Database", getRationaleDatabasePanel()); JPanel planAnalysisPanel = new JPanel(new BorderLayout()); //planAnalysisPanel.add(chartsToolBar, BorderLayout.NORTH); planAnalysisPanel.add(planAnalysisTabbedPane, BorderLayout.CENTER); planAnalysisFramePanel.setContent(planAnalysisPanel, false); } return planAnalysisFramePanel; }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
private void jbInit() throws Throwable { if (LPMain.getInstance().getDesktop() .darfAnwenderAufZusatzfunktionZugreifen(MandantFac.ZUSATZFUNKTION_DOKUMENTENABLAGE)) { if (!(new HeliumDocPath()).equals(fullDocPath)) { bHatDokumentenablage = true; }// w ww. j a va 2s .c o m } if (bShowExitButton) { String[] aWhichButtonIUse = new String[] { PanelBasis.ACTION_NEW, PanelBasis.ACTION_UPDATE, PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD }; enableToolsPanelButtons(aWhichButtonIUse); createAndSaveAndShowButton("/com/lp/client/res/scanner.png", "TWAIN-Import", BUTTON_SCAN, null); } dropArea.setCenterText(LPMain.getTextRespectUISPr("lp.datei.draganddrop.ablegen")); dropArea.setBackground(Color.LIGHT_GRAY); dropArea.setSupportFiles(true); dropArea.addDropListener(this); dropArea.setMinimumSize(new Dimension(200, 100)); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); JPanel leftPane = new JPanel(); JPanel rightPane = new JPanel(); JLayeredPane rightLayered = new JLayeredPane(); rightLayered.setLayout(new GridBagLayout()); rightLayered.add(rightPane, new GridBagConstraints(1, 1, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // rightLayered.setLayer(rightPane, 0, 1); if (bShowExitButton && bHatDokumentenablage) rightLayered.add(dropArea, new GridBagConstraints(1, 2, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // rightLayered.setLayer(dropArea, 1, 1); rightPane.setLayout(new GridBagLayout()); tree = new WrapperJTree(treeModel); tree.setEditable(false); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setShowsRootHandles(true); tree.setRowHeight(0); tree.setCellRenderer(new ToolTipCellRenderer()); ToolTipManager.sharedInstance().registerComponent(tree); tree.addTreeSelectionListener(this); refresh(); personalDto = DelegateFactory.getInstance().getPersonalDelegate() .personalFindByPrimaryKey(LPMain.getTheClient().getIDPersonal()); dokumentbelegartDto = DelegateFactory.getInstance().getJCRDocDelegate() .dokumentbelegartfindbyMandant(LPMain.getTheClient().getMandant()); for (int i = 0; i < dokumentbelegartDto.length; i++) { if (!JCRDocFac.DEFAULT_ARCHIV_BELEGART.equals(dokumentbelegartDto[i].getCNr())) wcbBelegart.addItem(dokumentbelegartDto[i].getCNr()); } dokumentgruppierungDto = DelegateFactory.getInstance().getJCRDocDelegate() .dokumentgruppierungfindbyMandant(LPMain.getTheClient().getMandant()); for (int i = 0; i < dokumentgruppierungDto.length; i++) { if (!JCRDocFac.DEFAULT_ARCHIV_GRUPPE.equals(dokumentgruppierungDto[i].getCNr()) || !JCRDocFac.DEFAULT_KOPIE_GRUPPE.equals(dokumentgruppierungDto[i].getCNr()) || !JCRDocFac.DEFAULT_VERSANDAUFTRAG_GRUPPE.equals(dokumentgruppierungDto[i].getCNr())) { wcbGruppierung.addItem(dokumentgruppierungDto[i].getCNr()); } } // Listen for when the selection changes. tree.addTreeExpansionListener(this); wcbVersteckteAnzeigen.setEnabled(true); wcbVersteckteAnzeigen.addActionListener(actionListener); wtfSuche.setEditable(true); wbuSuche.setEnabled(true); wbuSuche.addActionListener(actionListener); wbuPartner = new WrapperButton(); wbuPartner.setText(LPMain.getTextRespectUISPr("button.partner")); wbuPartner.setToolTipText(LPMain.getTextRespectUISPr("button.partner.tooltip")); wbuPartner.setActionCommand(ACTION_SPECIAL_PARTNER); wbuPartner.addActionListener(this); wbuChooseDoc.setActionCommand(ACTION_SPECIAL_CHOOSE); wbuChooseDoc.addActionListener(this); wbuShowDoc.setActionCommand(ACTION_SPECIAL_SHOW); wbuShowDoc.addActionListener(this); wbuSaveDoc.setActionCommand(ACTION_SPECIAL_SAVE); wbuSaveDoc.addActionListener(this); wtfPartner = new WrapperTextField(); wtfPartner.setColumnsMax(Facade.MAX_UNBESCHRAENKT); wtfPartner.setActivatable(false); wtfAnleger.setActivatable(false); wdfZeitpunkt.setActivatable(false); wtfBelegnummer.setActivatable(false); wtfTable.setActivatable(false); wtfRow.setActivatable(false); wtfFilename.setActivatable(false); wtfFilename.setColumnsMax(100); wtfMIME.setActivatable(false); wcbVersteckt.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { wtfSchlagworte.setMandatoryField(!wcbVersteckt.isSelected()); } }); if (bHatStufe0) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_NONE); } if (bHatStufe1) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_LOW); } if (bHatStufe2) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_MEDIUM); } if (bHatStufe3) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_HIGH); } if (bHatStufe99) { wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_ARCHIV); } wtfTable.setMandatoryField(true); wtfName.setMandatoryField(true); wtfName.setColumnsMax(200); wtfBelegnummer.setMandatoryField(true); wtfRow.setMandatoryField(true); wtfFilename.setMandatoryField(true); wtfMIME.setMandatoryField(true); wtfAnleger.setMandatoryField(true); wtfSchlagworte.setMandatoryField(true); wtfSchlagworte.setColumnsMax(300); wdfZeitpunkt.setMandatoryField(true); wtfPartner.setMandatoryField(true); treeView = new JScrollPane(tree); treeView.setMinimumSize(new Dimension(200, 10)); treeView.setPreferredSize(new Dimension(200, 10)); iZeile = 0; if (!bShowExitButton) { jpaWorkingOn.add(wtfSuche, new GridBagConstraints(0, iZeile, 1, 1, 0.2, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); jpaWorkingOn.add(wbuSuche, new GridBagConstraints(1, iZeile, 1, 1, 0.1, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; } jpaWorkingOn.add(wcbVersteckteAnzeigen, new GridBagConstraints(0, iZeile, 1, 1, 1, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; leftPane.add(treeView); jpaWorkingOn.add(splitPane, new GridBagConstraints(0, iZeile, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile = 0; rightPane.add(wlaName, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfName, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaTable, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfTable, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaSchlagworte, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfSchlagworte, new GridBagConstraints(1, iZeile, 6, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaZeitpunkt, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wdfZeitpunkt, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaSicherheitsstufe, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbSicherheitsstufe, new GridBagConstraints(5, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbVersteckt, new GridBagConstraints(6, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaBelegnummer, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfBelegnummer, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaRow, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfRow, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaFilename, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfFilename, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaMIME, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfMIME, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaBelegart, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbBelegart, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaGruppierung, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wcbGruppierung, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wbuPartner, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfPartner, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wlaAnleger, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wtfAnleger, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wbuChooseDoc, new GridBagConstraints(0, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wbuShowDoc, new GridBagConstraints(3, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); rightPane.add(wbuSaveDoc, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wlaVorschau, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); iZeile++; rightPane.add(wmcMedia, new GridBagConstraints(0, iZeile, 7, 4, 1.0, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); splitPane.setLeftComponent(treeView); splitPane.setRightComponent(rightLayered); }