List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:net.sf.jabref.gui.mergeentries.MergeEntries.java
/** * Main function for building the merge entry JPanel *//*from w ww . ja va 2 s .c om*/ private void initialize() { doneBuilding = false; setupFields(); // Fill diff mode combo box for (String diffText : DIFF_MODES) { diffMode.addItem(diffText); } diffMode.setSelectedIndex(Math.min(Globals.prefs.getInt(JabRefPreferences.MERGE_ENTRIES_DIFF_MODE), diffMode.getItemCount() - 1)); diffMode.addActionListener(e -> { updateTextPanes(differentFields); storePreference(); }); // Create main layout String colSpecMain = "left:pref, 5px, center:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, center:3cm:grow"; String colSpecMerge = "left:pref, 5px, fill:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, fill:3cm:grow"; String rowSpec = "pref, pref, 10px, fill:5cm:grow, 10px, pref, 10px, fill:3cm:grow"; StringBuilder rowBuilder = new StringBuilder(""); for (int i = 0; i < allFields.size(); i++) { rowBuilder.append("pref, 2dlu, "); } rowBuilder.append("pref"); JPanel mergePanel = new JPanel(); FormLayout mainLayout = new FormLayout(colSpecMain, rowSpec); FormLayout mergeLayout = new FormLayout(colSpecMerge, rowBuilder.toString()); mainPanel.setLayout(mainLayout); mergePanel.setLayout(mergeLayout); CellConstraints cc = new CellConstraints(); mainPanel.add(boldFontLabel(Localization.lang("Use")), cc.xyw(4, 1, 7, "center, bottom")); mainPanel.add(diffMode, cc.xy(11, 1, "right, bottom")); // Set headings JLabel[] headingLabels = new JLabel[6]; for (int i = 0; i < 6; i++) { headingLabels[i] = boldFontLabel(COLUMN_HEADINGS[i]); mainPanel.add(headingLabels[i], cc.xy(1 + (i * 2), 2)); } mainPanel.add(new JSeparator(), cc.xyw(1, 3, 11)); // Start with entry type mergePanel.add(boldFontLabel(Localization.lang("Entry type")), cc.xy(1, 1)); JTextPane leftTypeDisplay = getStyledTextPane(); leftTypeDisplay.setText(HTML_START + leftEntry.getType() + HTML_END); mergePanel.add(leftTypeDisplay, cc.xy(3, 1)); if (leftEntry.getType().equals(rightEntry.getType())) { identicalTypes = true; } else { identicalTypes = false; ButtonGroup group = new ButtonGroup(); typeRadioButtons = new ArrayList<>(2); for (int k = 0; k < 3; k += 2) { JRadioButton button = new JRadioButton(); typeRadioButtons.add(button); group.add(button); mergePanel.add(button, cc.xy(5 + (k * 2), 1)); button.addChangeListener(e -> updateAll()); } typeRadioButtons.get(0).setSelected(true); } JTextPane rightTypeDisplay = getStyledTextPane(); rightTypeDisplay.setText(HTML_START + rightEntry.getType() + HTML_END); mergePanel.add(rightTypeDisplay, cc.xy(11, 1)); // For all fields in joint add a row and possibly radio buttons int row = 2; int maxLabelWidth = -1; for (String field : allFields) { JLabel label = boldFontLabel(new SentenceCaseFormatter().format(field)); mergePanel.add(label, cc.xy(1, (2 * row) - 1, "left, top")); Optional<String> leftString = leftEntry.getFieldOptional(field); Optional<String> rightString = rightEntry.getFieldOptional(field); if (leftString.equals(rightString)) { identicalFields.add(field); } else { differentFields.add(field); } maxLabelWidth = Math.max(maxLabelWidth, label.getPreferredSize().width); // Left text pane if (leftString.isPresent()) { JTextPane tf = getStyledTextPane(); mergePanel.add(tf, cc.xy(3, (2 * row) - 1, "f, f")); leftTextPanes.put(field, tf); } // Add radio buttons if the two entries do not have identical fields if (identicalFields.contains(field)) { mergedEntry.setField(field, leftString.get()); // Will only happen if both entries have the field and the content is identical } else { ButtonGroup group = new ButtonGroup(); List<JRadioButton> list = new ArrayList<>(3); for (int k = 0; k < 3; k++) { JRadioButton button = new JRadioButton(); group.add(button); mergePanel.add(button, cc.xy(5 + (k * 2), (2 * row) - 1)); button.addChangeListener(e -> updateAll()); list.add(button); } radioButtons.put(field, list); if (leftString.isPresent()) { list.get(0).setSelected(true); if (!rightString.isPresent()) { list.get(2).setEnabled(false); } } else { list.get(0).setEnabled(false); list.get(2).setSelected(true); } } // Right text pane if (rightString.isPresent()) { JTextPane tf = getStyledTextPane(); mergePanel.add(tf, cc.xy(11, (2 * row) - 1, "f, f")); rightTextPanes.put(field, tf); } row++; } scrollPane = new JScrollPane(mergePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(BorderFactory.createEmptyBorder()); updateTextPanes(allFields); mainPanel.add(scrollPane, cc.xyw(1, 4, 11)); mainPanel.add(new JSeparator(), cc.xyw(1, 5, 11)); // Synchronize column widths String[] rbAlign = { "right", "center", "left" }; mainLayout.setColumnSpec(1, ColumnSpec.decode(Integer.toString(maxLabelWidth) + "px")); Integer maxRBWidth = -1; for (int k = 2; k < 5; k++) { maxRBWidth = Math.max(maxRBWidth, headingLabels[k].getPreferredSize().width); } for (int k = 0; k < 3; k++) { mergeLayout.setColumnSpec(5 + (k * 2), ColumnSpec.decode(rbAlign[k] + ":" + maxRBWidth + "px")); } // Setup a PreviewPanel and a Bibtex source box for the merged entry mainPanel.add(boldFontLabel(Localization.lang("Merged entry")), cc.xyw(1, 6, 6)); entryPreview = new PreviewPanel(null, mergedEntry, null, Globals.prefs.get(JabRefPreferences.PREVIEW_0)); mainPanel.add(entryPreview, cc.xyw(1, 8, 6)); mainPanel.add(boldFontLabel(Localization.lang("Merged BibTeX source code")), cc.xyw(8, 6, 4)); sourceView = new JTextArea(); sourceView.setLineWrap(true); sourceView.setFont(new Font("Monospaced", Font.PLAIN, Globals.prefs.getInt(JabRefPreferences.FONT_SIZE))); mainPanel.add(new JScrollPane(sourceView), cc.xyw(8, 8, 4)); sourceView.setEditable(false); // Add some margin around the layout mainLayout.appendRow(RowSpec.decode(MARGIN)); mainLayout.appendColumn(ColumnSpec.decode(MARGIN)); mainLayout.insertRow(1, RowSpec.decode(MARGIN)); mainLayout.insertColumn(1, ColumnSpec.decode(MARGIN)); // Everything done, allow any action to actually update the merged entry doneBuilding = true; updateAll(); // Show what we've got mainPanel.setVisible(true); javax.swing.SwingUtilities.invokeLater(() -> scrollPane.getVerticalScrollBar().setValue(0)); }
From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java
/** * Create the panel.// www .jav a 2s.c o m */ public Hl7V2MessageEditorPanel(final Controller theController) { setBorder(null); myController = theController; ButtonGroup encGrp = new ButtonGroup(); setLayout(new BorderLayout(0, 0)); mysplitPane = new JSplitPane(); mysplitPane.setResizeWeight(0.5); mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(mysplitPane); mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight(); ourLog.debug("Resizing split to ratio: {}", ratio); Prefs.getInstance().setHl7EditorSplit(ratio); } }); EventQueue.invokeLater(new Runnable() { public void run() { mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit()); } }); messageEditorContainerPanel = new JPanel(); messageEditorContainerPanel.setBorder(null); mysplitPane.setRightComponent(messageEditorContainerPanel); messageEditorContainerPanel.setLayout(new BorderLayout(0, 0)); myMessageEditor = new JEditorPane(); Highlighter h = new UnderlineHighlighter(); myMessageEditor.setHighlighter(h); // myMessageEditor.setFont(Prefs.getHl7EditorFont()); myMessageEditor.setSelectedTextColor(Color.black); myMessageEditor.setCaret(new EditorCaret()); myMessageScrollPane = new JScrollPane(myMessageEditor); messageEditorContainerPanel.add(myMessageScrollPane); JToolBar toolBar = new JToolBar(); messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH); toolBar.setFloatable(false); toolBar.setRollover(true); myFollowToggle = new JToggleButton("Follow"); myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync"); myFollowToggle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { theController.setMessageEditorInFollowMode(myFollowToggle.isSelected()); } }); myFollowToggle.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png"))); myFollowToggle.setSelected(theController.isMessageEditorInFollowMode()); toolBar.add(myFollowToggle); myhorizontalStrut = Box.createHorizontalStrut(20); toolBar.add(myhorizontalStrut); mylabel_4 = new JLabel("Encoding"); toolBar.add(mylabel_4); myRdbtnEr7 = new JRadioButton("ER7"); myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1)); toolBar.add(myRdbtnEr7); myRdbtnXml = new JRadioButton("XML"); myRdbtnXml.setMargin(new Insets(1, 5, 0, 1)); toolBar.add(myRdbtnXml); encGrp.add(myRdbtnEr7); encGrp.add(myRdbtnXml); treeContainerPanel = new JPanel(); mysplitPane.setLeftComponent(treeContainerPanel); treeContainerPanel.setLayout(new BorderLayout(0, 0)); mySpinnerIconOn = new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif")); mySpinnerIconOff = new ImageIcon(); myTreePanel = new Hl7V2MessageTree(theController); myTreePanel.setWorkingListener(new IWorkingListener() { public void startedWorking() { mySpinner.setText(""); mySpinner.setIcon(mySpinnerIconOn); mySpinnerIconOn.setImageObserver(mySpinner); } public void finishedWorking(String theStatus) { mySpinner.setText(theStatus); mySpinner.setIcon(mySpinnerIconOff); mySpinnerIconOn.setImageObserver(null); } }); myTreeScrollPane = new JScrollPane(myTreePanel); myTopTabBar = new JTabbedPane(); treeContainerPanel.add(myTopTabBar); myTopTabBar.setBorder(null); JPanel treeContainer = new JPanel(); treeContainer.setLayout(new BorderLayout(0, 0)); treeContainer.add(myTreeScrollPane); myTopTabBar.add("Message Tree", treeContainer); mytoolBar_1 = new JToolBar(); mytoolBar_1.setFloatable(false); treeContainer.add(mytoolBar_1, BorderLayout.NORTH); mylabel_3 = new JLabel("Show"); mytoolBar_1.add(mylabel_3); myShowCombo = new JComboBox(); mytoolBar_1.add(myShowCombo); myShowCombo.setPreferredSize(new Dimension(130, 27)); myShowCombo.setMinimumSize(new Dimension(130, 27)); myShowCombo.setMaximumSize(new Dimension(130, 32767)); collapseAllButton = new JButton(); collapseAllButton.setBorderPainted(false); collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton)); collapseAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.collapseAll(); } }); collapseAllButton.setToolTipText("Collapse All"); collapseAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png"))); mytoolBar_1.add(collapseAllButton); expandAllButton = new JButton(); expandAllButton.setBorderPainted(false); expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton)); expandAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.expandAll(); } }); expandAllButton.setToolTipText("Expand All"); expandAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png"))); mytoolBar_1.add(expandAllButton); myhorizontalGlue = Box.createHorizontalGlue(); mytoolBar_1.add(myhorizontalGlue); mySpinner = new JButton(""); mySpinner.setForeground(Color.DARK_GRAY); mySpinner.setHorizontalAlignment(SwingConstants.RIGHT); mySpinner.setMaximumSize(new Dimension(200, 15)); mySpinner.setPreferredSize(new Dimension(200, 15)); mySpinner.setMinimumSize(new Dimension(200, 15)); mySpinner.setBorderPainted(false); mySpinner.setSize(new Dimension(16, 16)); mytoolBar_1.add(mySpinner); myProfileComboboxModel = new ProfileComboModel(); myTablesComboModel = new TablesComboModel(myController); mytoolBar = new JToolBar(); mytoolBar.setFloatable(false); mytoolBar.setRollover(true); treeContainerPanel.add(mytoolBar, BorderLayout.NORTH); myOutboundInterfaceCombo = new JComboBox(); myOutboundInterfaceComboModel = new DefaultComboBoxModel(); mylabel_1 = new JLabel("Send"); mytoolBar.add(mylabel_1); myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel); myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767)); mytoolBar.add(myOutboundInterfaceCombo); mySendButton = new JButton("Send"); mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton)); mySendButton.setBorderPainted(false); mySendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // int selectedIndex = // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem()); int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex(); OutboundConnection connection = myController.getOutboundConnectionList().getConnections() .get(selectedIndex); activateSendingActivityTabForConnection(connection); myController.sendMessages(connection, myMessage, mySendingActivityTable.provideTransmissionCallback()); } }); myhorizontalStrut_2 = Box.createHorizontalStrut(20); myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_2); mySendOptionsButton = new JButton("Options"); mySendOptionsButton.setBorderPainted(false); final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton); mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor); mySendOptionsButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png"))); mytoolBar.add(mySendOptionsButton); mySendOptionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { if (mySendOptionsPopupDialog != null) { mySendOptionsPopupDialog.doHide(); mySendOptionsPopupDialog = null; return; } mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage, mySendOptionsButton, sendOptionsHoverAdaptor); Point los = mySendOptionsButton.getLocationOnScreen(); mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight()); mySendOptionsPopupDialog.setVisible(true); } }); mySendButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png"))); mytoolBar.add(mySendButton); myhorizontalStrut_1 = Box.createHorizontalStrut(20); mytoolBar.add(myhorizontalStrut_1); mylabel_2 = new JLabel("Validate"); mytoolBar.add(mylabel_2); myProfileCombobox = new JComboBox(); mytoolBar.add(myProfileCombobox); myProfileCombobox.setPreferredSize(new Dimension(200, 27)); myProfileCombobox.setMinimumSize(new Dimension(200, 27)); myProfileCombobox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHandlingProfileComboboxChange) { return; } myHandlingProfileComboboxChange = true; try { if (myProfileCombobox.getSelectedIndex() == 0) { myMessage.setValidationContext(null); } else if (myProfileCombobox.getSelectedIndex() == 1) { myMessage.setValidationContext(new DefaultValidation()); } else if (myProfileCombobox.getSelectedIndex() > 0) { ProfileGroup profile = myProfileComboboxModel.myProfileGroups .get(myProfileCombobox.getSelectedIndex()); myMessage.setRuntimeProfile(profile); // } else if (myProfileCombobox.getSelectedItem() == // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) { // IOkCancelCallback<Void> callback = new // IOkCancelCallback<Void>() { // public void ok(Void theArg) { // myProfileComboboxModel.update(); // } // // public void cancel(Void theArg) { // myProfileCombobox.setSelectedIndex(0); // } // }; // myController.chooseAndLoadConformanceProfileForMessage(myMessage, // callback); } } catch (ProfileException e2) { ourLog.error("Failed to load profile", e2); } finally { myHandlingProfileComboboxChange = false; } } }); myProfileCombobox.setMaximumSize(new Dimension(300, 32767)); myProfileCombobox.setModel(myProfileComboboxModel); myhorizontalStrut_4 = Box.createHorizontalStrut(20); myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_4); // mySendingPanel = new JPanel(); // mySendingPanel.setBorder(null); // myTopTabBar.addTab("Sending", null, mySendingPanel, null); // mySendingPanel.setLayout(new BorderLayout(0, 0)); mySendingActivityTable = new ActivityTable(); mySendingActivityTable.setController(myController); myTopTabBar.addTab("Sending", null, mySendingActivityTable, null); // mySendingPanelScrollPanel = new JScrollPane(); // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable); // // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER); bottomPanel = new JPanel(); bottomPanel.setPreferredSize(new Dimension(10, 20)); bottomPanel.setMinimumSize(new Dimension(10, 20)); add(bottomPanel, BorderLayout.SOUTH); GridBagLayout gbl_bottomPanel = new GridBagLayout(); gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 }; gbl_bottomPanel.rowHeights = new int[] { 16, 0 }; gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; bottomPanel.setLayout(gbl_bottomPanel); mylabel = new JLabel("Terser Path:"); mylabel.setHorizontalTextPosition(SwingConstants.LEFT); mylabel.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.fill = GridBagConstraints.VERTICAL; gbc_label.weighty = 1.0; gbc_label.anchor = GridBagConstraints.NORTHWEST; gbc_label.gridx = 0; gbc_label.gridy = 0; bottomPanel.add(mylabel, gbc_label); myTerserPathTextField = new JLabel(); myTerserPathTextField.setForeground(Color.BLUE); myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13)); myTerserPathTextField.setBorder(null); myTerserPathTextField.setBackground(SystemColor.control); myTerserPathTextField.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) { myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0); } } }); GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints(); gbc_TerserPathTextField.weightx = 1.0; gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL; gbc_TerserPathTextField.gridx = 1; gbc_TerserPathTextField.gridy = 0; bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField); initLocal(); }
From source file:FileChooserDemo.java
public FileChooserDemo() { UIManager.LookAndFeelInfo[] installedLafs = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo lafInfo : installedLafs) { try {// w w w. ja v a 2s .c o m Class lnfClass = Class.forName(lafInfo.getClassName()); LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance()); if (laf.isSupportedLookAndFeel()) { String name = lafInfo.getName(); supportedLaFs.add(new SupportedLaF(name, laf)); } } catch (Exception e) { // If ANYTHING weird happens, don't add it continue; } } setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); chooser = new JFileChooser(); previewer = new FilePreviewer(chooser); // Create Custom FileView fileView = new ExampleFileView(); // fileView.putIcon("jpg", new ImageIcon(getClass().getResource("/resources/images/jpgIcon.jpg"))); // fileView.putIcon("gif", new ImageIcon(getClass().getResource("/resources/images/gifIcon.gif"))); // create a radio listener to listen to option changes OptionListener optionListener = new OptionListener(); // Create options openRadioButton = new JRadioButton("Open"); openRadioButton.setSelected(true); openRadioButton.addActionListener(optionListener); saveRadioButton = new JRadioButton("Save"); saveRadioButton.addActionListener(optionListener); customButton = new JRadioButton("Custom"); customButton.addActionListener(optionListener); customField = new JTextField(8) { public Dimension getMaximumSize() { return new Dimension(getPreferredSize().width, getPreferredSize().height); } }; customField.setText("Doit"); customField.setAlignmentY(JComponent.TOP_ALIGNMENT); customField.setEnabled(false); customField.addActionListener(optionListener); ButtonGroup group1 = new ButtonGroup(); group1.add(openRadioButton); group1.add(saveRadioButton); group1.add(customButton); // filter buttons showAllFilesFilterCheckBox = new JCheckBox("Show \"All Files\" Filter"); showAllFilesFilterCheckBox.addActionListener(optionListener); showAllFilesFilterCheckBox.setSelected(true); showImageFilesFilterCheckBox = new JCheckBox("Show JPG and GIF Filters"); showImageFilesFilterCheckBox.addActionListener(optionListener); showImageFilesFilterCheckBox.setSelected(false); accessoryCheckBox = new JCheckBox("Show Preview"); accessoryCheckBox.addActionListener(optionListener); accessoryCheckBox.setSelected(false); // more options setHiddenCheckBox = new JCheckBox("Show Hidden Files"); setHiddenCheckBox.addActionListener(optionListener); showFullDescriptionCheckBox = new JCheckBox("With File Extensions"); showFullDescriptionCheckBox.addActionListener(optionListener); showFullDescriptionCheckBox.setSelected(true); showFullDescriptionCheckBox.setEnabled(false); useFileViewCheckBox = new JCheckBox("Use FileView"); useFileViewCheckBox.addActionListener(optionListener); useFileViewCheckBox.setSelected(false); useEmbedInWizardCheckBox = new JCheckBox("Embed in Wizard"); useEmbedInWizardCheckBox.addActionListener(optionListener); useEmbedInWizardCheckBox.setSelected(false); useControlsCheckBox = new JCheckBox("Show Control Buttons"); useControlsCheckBox.addActionListener(optionListener); useControlsCheckBox.setSelected(true); enableDragCheckBox = new JCheckBox("Enable Dragging"); enableDragCheckBox.addActionListener(optionListener); // File or Directory chooser options ButtonGroup group3 = new ButtonGroup(); justFilesRadioButton = new JRadioButton("Just Select Files"); justFilesRadioButton.setSelected(true); group3.add(justFilesRadioButton); justFilesRadioButton.addActionListener(optionListener); justDirectoriesRadioButton = new JRadioButton("Just Select Directories"); group3.add(justDirectoriesRadioButton); justDirectoriesRadioButton.addActionListener(optionListener); bothFilesAndDirectoriesRadioButton = new JRadioButton("Select Files or Directories"); group3.add(bothFilesAndDirectoriesRadioButton); bothFilesAndDirectoriesRadioButton.addActionListener(optionListener); singleSelectionRadioButton = new JRadioButton("Single Selection", true); singleSelectionRadioButton.addActionListener(optionListener); multiSelectionRadioButton = new JRadioButton("Multi Selection"); multiSelectionRadioButton.addActionListener(optionListener); ButtonGroup group4 = new ButtonGroup(); group4.add(singleSelectionRadioButton); group4.add(multiSelectionRadioButton); // Create show button showButton = new JButton("Show FileChooser"); showButton.addActionListener(this); showButton.setMnemonic('s'); // Create laf combo box lafComboBox = new JComboBox(supportedLaFs); lafComboBox.setEditable(false); lafComboBox.addActionListener(optionListener); // ******************************************************** // ******************** Dialog Type *********************** // ******************************************************** JPanel control1 = new InsetPanel(insets); control1.setBorder(BorderFactory.createTitledBorder("Dialog Type")); control1.setLayout(new BoxLayout(control1, BoxLayout.Y_AXIS)); control1.add(Box.createRigidArea(vpad20)); control1.add(openRadioButton); control1.add(Box.createRigidArea(vpad7)); control1.add(saveRadioButton); control1.add(Box.createRigidArea(vpad7)); control1.add(customButton); control1.add(Box.createRigidArea(vpad4)); JPanel fieldWrapper = new JPanel(); fieldWrapper.setLayout(new BoxLayout(fieldWrapper, BoxLayout.X_AXIS)); fieldWrapper.setAlignmentX(Component.LEFT_ALIGNMENT); fieldWrapper.add(Box.createRigidArea(hpad10)); fieldWrapper.add(Box.createRigidArea(hpad10)); fieldWrapper.add(customField); control1.add(fieldWrapper); control1.add(Box.createRigidArea(vpad20)); control1.add(Box.createGlue()); // ******************************************************** // ***************** Filter Controls ********************** // ******************************************************** JPanel control2 = new InsetPanel(insets); control2.setBorder(BorderFactory.createTitledBorder("Filter Controls")); control2.setLayout(new BoxLayout(control2, BoxLayout.Y_AXIS)); control2.add(Box.createRigidArea(vpad20)); control2.add(showAllFilesFilterCheckBox); control2.add(Box.createRigidArea(vpad7)); control2.add(showImageFilesFilterCheckBox); control2.add(Box.createRigidArea(vpad4)); JPanel checkWrapper = new JPanel(); checkWrapper.setLayout(new BoxLayout(checkWrapper, BoxLayout.X_AXIS)); checkWrapper.setAlignmentX(Component.LEFT_ALIGNMENT); checkWrapper.add(Box.createRigidArea(hpad10)); checkWrapper.add(Box.createRigidArea(hpad10)); checkWrapper.add(showFullDescriptionCheckBox); control2.add(checkWrapper); control2.add(Box.createRigidArea(vpad20)); control2.add(Box.createGlue()); // ******************************************************** // ****************** Display Options ********************* // ******************************************************** JPanel control3 = new InsetPanel(insets); control3.setBorder(BorderFactory.createTitledBorder("Display Options")); control3.setLayout(new BoxLayout(control3, BoxLayout.Y_AXIS)); control3.add(Box.createRigidArea(vpad20)); control3.add(setHiddenCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useFileViewCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(accessoryCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useEmbedInWizardCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useControlsCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(enableDragCheckBox); control3.add(Box.createRigidArea(vpad20)); control3.add(Box.createGlue()); // ******************************************************** // ************* File & Directory Options ***************** // ******************************************************** JPanel control4 = new InsetPanel(insets); control4.setBorder(BorderFactory.createTitledBorder("File and Directory Options")); control4.setLayout(new BoxLayout(control4, BoxLayout.Y_AXIS)); control4.add(Box.createRigidArea(vpad20)); control4.add(justFilesRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(justDirectoriesRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(bothFilesAndDirectoriesRadioButton); control4.add(Box.createRigidArea(vpad20)); control4.add(singleSelectionRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(multiSelectionRadioButton); control4.add(Box.createRigidArea(vpad20)); control4.add(Box.createGlue()); // ******************************************************** // **************** Look & Feel Switch ******************** // ******************************************************** JPanel panel = new JPanel(); panel.add(new JLabel("Look and Feel: ")); panel.add(lafComboBox); panel.add(showButton); // ******************************************************** // ****************** Wrap 'em all up ********************* // ******************************************************** JPanel wrapper = new JPanel(); wrapper.setLayout(new BoxLayout(wrapper, BoxLayout.X_AXIS)); add(Box.createRigidArea(vpad20)); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control1); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control2); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control3); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control4); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(Box.createRigidArea(hpad10)); add(wrapper); add(Box.createRigidArea(vpad20)); add(panel); add(Box.createRigidArea(vpad20)); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.AngleDirectController.java
/** * Initialize the main view./* ww w . jav a 2s .c om*/ */ private void initAngleDirectPanel() { // initialize the main view angleDirectPanel = new AngleDirectPanel(); // initialize the dataTable dataTable = new JTable(); JScrollPane scrollPane = new JScrollPane(dataTable); //the table will take all the viewport height available dataTable.setFillsViewportHeight(true); scrollPane.getViewport().setBackground(Color.white); dataTable.getTableHeader().setReorderingAllowed(false); //row selection must be false && column selection true to be able to select through columns dataTable.setColumnSelectionAllowed(true); dataTable.setRowSelectionAllowed(false); angleDirectPanel.getDataTablePanel().add(scrollPane); //create a ButtonGroup for the radioButtons used for analysis ButtonGroup radioButtonGroup = new ButtonGroup(); //adding buttons to a ButtonGroup automatically deselect one when another one gets selected radioButtonGroup.add(angleDirectPanel.getInstTurnAngleRadioButton()); radioButtonGroup.add(angleDirectPanel.getTrackTurnAngleRadioButton()); // radioButtonGroup.add(angleDirectPanel.getDynamicDirectRatioRadioButton()); // radioButtonGroup.add(angleDirectPanel.getEndPointDirectRatioRadioButton()); /** * Add action listeners */ // show instantaneous turning angles angleDirectPanel.getInstTurnAngleRadioButton().addActionListener((ActionEvent e) -> { PlateCondition currentCondition = singleCellPreProcessingController.getCurrentCondition(); //check that a condition is selected if (currentCondition != null) { showInstAngleInTable(currentCondition); plotHistTA(currentCondition); plotPolarTA(currentCondition); plotRoseTA(currentCondition); plotCompassTA(currentCondition); } }); // show and plot averaged-track turning angles angleDirectPanel.getTrackTurnAngleRadioButton().addActionListener((ActionEvent e) -> { PlateCondition currentCondition = singleCellPreProcessingController.getCurrentCondition(); //check that a condition is selected if (currentCondition != null) { showTrackAngleInTable(currentCondition); plotHistTrackTA(currentCondition); plotPolarTrackTA(currentCondition); plotRoseTrackTA(currentCondition); plotCompassTrackTA(currentCondition); } }); /** * */ angleDirectPanel.getSaveChartToPdfButton().addActionListener((ActionEvent e) -> { ChartPanel chartPanel = rosePlotChartPanels.get(2); JFreeChart chart = chartPanel.getChart(); if (chart != null) { try { // create the PDF report file createPdf(chart); } catch (IOException ex) { LOG.error(ex.getMessage(), ex); } } }); // // show dynamic directionality ratios // angleDirectPanel.getDynamicDirectRatioRadioButton().addActionListener((ActionEvent e) -> { // PlateCondition currentCondition = singleCellPreProcessingController.getCurrentCondition(); // //check that a condition is selected // if (currentCondition != null) { // // } // }); // // // show end-point directionality ratios // angleDirectPanel.getEndPointDirectRatioRadioButton().addActionListener((ActionEvent e) -> { // PlateCondition currentCondition = singleCellPreProcessingController.getCurrentCondition(); // //check that a condition is selected // if (currentCondition != null) { // // } // }); //select as default first button angleDirectPanel.getInstTurnAngleRadioButton().setSelected(true); // add view to parent panel singleCellPreProcessingController.getSingleCellAnalysisPanel().getAngleDirectParentPanel() .add(angleDirectPanel, gridBagConstraints); angleDirectPanel.getTurningAngleParentPanel().add(turningAnglePanel, gridBagConstraints); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellAnalysisController.java
/** * Initialize plot options panel./*w w w. ja va 2s . c om*/ */ private void initPlotOptionsPanel() { // make new view plotOptionsPanel = new PlotOptionsPanel(); // add radiobuttons to a button group ButtonGroup scaleAxesButtonGroup = new ButtonGroup(); scaleAxesButtonGroup.add(plotOptionsPanel.getDoNotScaleAxesRadioButton()); scaleAxesButtonGroup.add(plotOptionsPanel.getScaleAxesRadioButton()); plotOptionsPanel.getDoNotScaleAxesRadioButton().setSelected(true); // another button group for the shifted/unshifted coordinates ButtonGroup shiftedCoordinatesButtonGroup = new ButtonGroup(); shiftedCoordinatesButtonGroup.add(plotOptionsPanel.getShiftedCoordinatesRadioButton()); shiftedCoordinatesButtonGroup.add(plotOptionsPanel.getUnshiftedCoordinatesRadioButton()); plotOptionsPanel.getUnshiftedCoordinatesRadioButton().setSelected(true); /** * Action listeners */ // do not scale axes plotOptionsPanel.getDoNotScaleAxesRadioButton().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); boolean useRawData = plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected(); resetPlotLogic(); generateDataForTrackPlot(useRawData); // use the data to set the charts setTrackChartsWithCollections(nCols); }); // scale axes to the experiment range plotOptionsPanel.getScaleAxesRadioButton().addActionListener((ActionEvent e) -> { boolean useRawData = plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected(); cellTracksChartPanels.stream().forEach((chartPanel) -> { singleCellMainController.scaleAxesToExperiment(chartPanel.getChart(), useRawData); }); }); // shift the all coordinates to the origin plotOptionsPanel.getShiftedCoordinatesRadioButton().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); resetPlotLogic(); generateDataForTrackPlot(false); // use the data to set the charts setTrackChartsWithCollections(nCols); }); // replot the unshifted coordinates plotOptionsPanel.getUnshiftedCoordinatesRadioButton().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); resetPlotLogic(); generateDataForTrackPlot(true); // use the data to set the charts setTrackChartsWithCollections(nCols); }); // replot with a different number of columns plotOptionsPanel.getnColsComboBox().addActionListener((ActionEvent e) -> { int nCols = Integer.parseInt((String) plotOptionsPanel.getnColsComboBox().getSelectedItem()); boolean useRawData = plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected(); resetPlotLogic(); generateDataForTrackPlot(useRawData); // use the data to set the charts setTrackChartsWithCollections(nCols); }); // add view to parent component analysisPanel.getPlotOptionsParentPanel().add(plotOptionsPanel, gridBagConstraints); }
From source file:com.google.code.facebook.graph.sna.applet.LensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * // w w w. ja va 2 s. co m */ public LensDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:net.lmxm.ute.gui.editors.tasks.SubversionExportTaskEditorPanel.java
/** * Gets the revision pane.//from w w w .j a v a2 s . c o m * * @return the revision pane */ private JPanel getRevisionPane() { if (revisionPane == null) { revisionPane = new JPanel(new MigLayout("gapy 0")); revisionPane.add(getHeadRevisionRadioButton(), "wrap"); revisionPane.add(getNumberedRevisionRadioButton()); revisionPane.add(getRevisionNumberTextField(), "wrap"); revisionPane.add(getDateRevisionRadioButton()); revisionPane.add(getRevisionDateTextField(), "wrap"); final ButtonGroup group = new ButtonGroup(); group.add(getHeadRevisionRadioButton()); group.add(getNumberedRevisionRadioButton()); group.add(getDateRevisionRadioButton()); } return revisionPane; }
From source file:edu.uci.ics.jung.samples.LensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * /* www . j a v a 2 s .c o m*/ */ @SuppressWarnings({ "rawtypes", "unchecked" }) public LensDemo() { // create a simple graph for the demo graph = TestGraphs.getOneComponentGraph(); graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java
/** * Builds the side panel with all the options for this StatViw * //from ww w. ja v a 2 s . c om * @return the formatted side panel */ public JPanel buildSidePanel() { final int VERTICAL_PADDING = 5; final int HORIZONTAL_PADDING = 5; final int FAR = 5; final SpringLayout sidePanelLayout = new SpringLayout(); final JPanel sidePanel = new JPanel(sidePanelLayout); final JLabel lblStatisticType = new JLabel("Statistic Type"); final String[] availableStatisticTypes = { "Status", "Assignees", "Iterations", "Velocity" }; // TODO: Add Estimates, Effort, Tasks charts for future use. comboBoxStatisticType = new JComboBox(availableStatisticTypes); comboBoxStatisticType.addActionListener(this); makePieRadio = new JRadioButton("Pie Chart"); makePieRadio.setMnemonic(KeyEvent.VK_P); makePieRadio.setActionCommand("Pie Chart"); makePieRadio.addActionListener(this); makeBarRadio = new JRadioButton("Bar Chart"); makeBarRadio.setMnemonic(KeyEvent.VK_B); makeBarRadio.setActionCommand("Bar Chart"); makeBarRadio.addActionListener(this); makeLineRadio = new JRadioButton("Line Chart"); makeLineRadio.setMnemonic(KeyEvent.VK_B); makeLineRadio.setActionCommand("Line Chart"); makeLineRadio.addActionListener(this); makeLineRadio.setEnabled(false); final ButtonGroup group = new ButtonGroup(); group.add(makePieRadio); group.add(makeBarRadio); group.add(makeLineRadio); updateSelectedItems(); final JPanel radioPanel = new JPanel(new GridLayout(3, 1)); radioPanel.add(makePieRadio); radioPanel.add(makeBarRadio); radioPanel.add(makeLineRadio); radioPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Chart Type")); sidePanel.add(lblStatisticType); sidePanel.add(comboBoxStatisticType); sidePanel.add(radioPanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, lblStatisticType, VERTICAL_PADDING, SpringLayout.NORTH, sidePanel); sidePanelLayout.putConstraint(SpringLayout.WEST, lblStatisticType, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, comboBoxStatisticType, VERTICAL_PADDING, SpringLayout.SOUTH, lblStatisticType); sidePanelLayout.putConstraint(SpringLayout.WEST, comboBoxStatisticType, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); sidePanelLayout.putConstraint(SpringLayout.NORTH, radioPanel, VERTICAL_PADDING + FAR, SpringLayout.SOUTH, comboBoxStatisticType); sidePanelLayout.putConstraint(SpringLayout.WEST, radioPanel, HORIZONTAL_PADDING, SpringLayout.WEST, sidePanel); return sidePanel; }
From source file:net.sf.jabref.groups.GroupSelector.java
/** * The first element for each group defines which field to use for the quicksearch. The next two define the name and * regexp for the group.//from w w w. j ava 2s.c o m */ public GroupSelector(JabRefFrame frame, SidePaneManager manager) { super(manager, IconTheme.JabRefIcon.TOGGLE_GROUPS.getIcon(), Localization.lang("Groups")); this.groupsRoot = new GroupTreeNode(new AllEntriesGroup()); this.frame = frame; hideNonHits = new JRadioButtonMenuItem(Localization.lang("Hide non-hits"), !Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS)); grayOut = new JRadioButtonMenuItem(Localization.lang("Gray out non-hits"), Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS)); ButtonGroup nonHits = new ButtonGroup(); nonHits.add(hideNonHits); nonHits.add(grayOut); floatCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS, floatCb.isSelected()); } }); andCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, andCb.isSelected()); } }); invCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS, invCb.isSelected()); } }); showOverlappingGroups.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING, showOverlappingGroups.isSelected()); if (!showOverlappingGroups.isSelected()) { groupsTree.setHighlight2Cells(null); } } }); select.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SELECT_MATCHES, select.isSelected()); } }); grayOut.addChangeListener( event -> Globals.prefs.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayOut.isSelected())); JRadioButtonMenuItem highlCb = new JRadioButtonMenuItem(Localization.lang("Highlight"), false); if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS)) { floatCb.setSelected(true); highlCb.setSelected(false); } else { highlCb.setSelected(true); floatCb.setSelected(false); } JRadioButtonMenuItem orCb = new JRadioButtonMenuItem(Localization.lang("Union"), false); if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS)) { andCb.setSelected(true); orCb.setSelected(false); } else { orCb.setSelected(true); andCb.setSelected(false); } showNumberOfElements.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS, showNumberOfElements.isSelected()); if (groupsTree != null) { groupsTree.invalidate(); groupsTree.validate(); groupsTree.repaint(); } } }); autoAssignGroup.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP, autoAssignGroup.isSelected()); } }); invCb.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS)); showOverlappingGroups.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING)); select.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SELECT_MATCHES)); editModeIndicator = Globals.prefs.getBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE); editModeCb.setSelected(editModeIndicator); showNumberOfElements.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS)); autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP)); openset.setMargin(new Insets(0, 0, 0, 0)); settings.add(andCb); settings.add(orCb); settings.addSeparator(); settings.add(invCb); settings.addSeparator(); settings.add(select); settings.addSeparator(); settings.add(editModeCb); settings.addSeparator(); settings.add(grayOut); settings.add(hideNonHits); settings.addSeparator(); settings.add(showOverlappingGroups); settings.addSeparator(); settings.add(showNumberOfElements); settings.add(autoAssignGroup); // settings.add(moreRow); // settings.add(lessRow); openset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!settings.isVisible()) { JButton src = (JButton) e.getSource(); showNumberOfElements .setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS)); autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP)); settings.show(src, 0, openset.getHeight()); } } }); JButton expand = new JButton(IconTheme.JabRefIcon.ADD_ROW.getSmallIcon()); expand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) + 1; groupsTree.setVisibleRowCount(i); groupsTree.revalidate(); groupsTree.repaint(); GroupSelector.this.revalidate(); GroupSelector.this.repaint(); Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i); LOGGER.info("Height: " + GroupSelector.this.getHeight() + "; Preferred height: " + GroupSelector.this.getPreferredSize().getHeight()); } }); JButton reduce = new JButton(IconTheme.JabRefIcon.REMOVE_ROW.getSmallIcon()); reduce.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) - 1; if (i < 1) { i = 1; } groupsTree.setVisibleRowCount(i); groupsTree.revalidate(); groupsTree.repaint(); GroupSelector.this.revalidate(); // _panel.sidePaneManager.revalidate(); GroupSelector.this.repaint(); Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i); } }); editModeCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editModeIndicator = editModeCb.getState(); updateBorder(editModeIndicator); Globals.prefs.putBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE, editModeIndicator); } }); int butSize = newButton.getIcon().getIconHeight() + 5; Dimension butDim = new Dimension(butSize, butSize); //Dimension butDimSmall = new Dimension(20, 20); newButton.setPreferredSize(butDim); newButton.setMinimumSize(butDim); refresh.setPreferredSize(butDim); refresh.setMinimumSize(butDim); JButton helpButton = new HelpAction(Localization.lang("Help on groups"), HelpFiles.groupsHelp) .getHelpButton(); helpButton.setPreferredSize(butDim); helpButton.setMinimumSize(butDim); autoGroup.setPreferredSize(butDim); autoGroup.setMinimumSize(butDim); openset.setPreferredSize(butDim); openset.setMinimumSize(butDim); expand.setPreferredSize(butDim); expand.setMinimumSize(butDim); reduce.setPreferredSize(butDim); reduce.setMinimumSize(butDim); Insets butIns = new Insets(0, 0, 0, 0); helpButton.setMargin(butIns); reduce.setMargin(butIns); expand.setMargin(butIns); openset.setMargin(butIns); newButton.addActionListener(this); refresh.addActionListener(this); andCb.addActionListener(this); orCb.addActionListener(this); invCb.addActionListener(this); showOverlappingGroups.addActionListener(this); autoGroup.addActionListener(this); floatCb.addActionListener(this); highlCb.addActionListener(this); select.addActionListener(this); hideNonHits.addActionListener(this); grayOut.addActionListener(this); newButton.setToolTipText(Localization.lang("New group")); refresh.setToolTipText(Localization.lang("Refresh view")); andCb.setToolTipText(Localization.lang("Display only entries belonging to all selected groups.")); orCb.setToolTipText( Localization.lang("Display all entries belonging to one or more of the selected groups.")); autoGroup.setToolTipText(Localization.lang("Automatically create groups for database.")); invCb.setToolTipText(Localization.lang("Show entries *not* in group selection")); showOverlappingGroups.setToolTipText(Localization .lang("Highlight groups that contain entries contained in any currently selected group")); floatCb.setToolTipText(Localization.lang("Move entries in group selection to the top")); highlCb.setToolTipText(Localization.lang("Gray out entries not in group selection")); select.setToolTipText(Localization.lang("Select entries in group selection")); expand.setToolTipText(Localization.lang("Show one more row")); reduce.setToolTipText(Localization.lang("Show one less rows")); editModeCb.setToolTipText(Localization.lang("Click group to toggle membership of selected entries")); ButtonGroup bgr = new ButtonGroup(); bgr.add(andCb); bgr.add(orCb); ButtonGroup visMode = new ButtonGroup(); visMode.add(floatCb); visMode.add(highlCb); JPanel main = new JPanel(); GridBagLayout gbl = new GridBagLayout(); main.setLayout(gbl); GridBagConstraints con = new GridBagConstraints(); con.fill = GridBagConstraints.BOTH; //con.insets = new Insets(0, 0, 2, 0); con.weightx = 1; con.gridwidth = 1; con.gridx = 0; con.gridy = 0; //con.insets = new Insets(1, 1, 1, 1); gbl.setConstraints(newButton, con); main.add(newButton); con.gridx = 1; gbl.setConstraints(refresh, con); main.add(refresh); con.gridx = 2; gbl.setConstraints(autoGroup, con); main.add(autoGroup); con.gridx = 3; con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(helpButton, con); main.add(helpButton); // header.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); // helpButton.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); groupsTree = new GroupsTree(this); groupsTree.addTreeSelectionListener(this); groupsTree.setModel(groupsTreeModel = new DefaultTreeModel(groupsRoot)); JScrollPane sp = new JScrollPane(groupsTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); revalidateGroups(); con.gridwidth = GridBagConstraints.REMAINDER; con.weighty = 1; con.gridx = 0; con.gridwidth = 4; con.gridy = 1; gbl.setConstraints(sp, con); main.add(sp); JPanel pan = new JPanel(); GridBagLayout gb = new GridBagLayout(); con.weighty = 0; gbl.setConstraints(pan, con); pan.setLayout(gb); con.insets = new Insets(0, 0, 0, 0); con.gridx = 0; con.gridy = 0; con.weightx = 1; con.gridwidth = 4; con.fill = GridBagConstraints.HORIZONTAL; gb.setConstraints(openset, con); pan.add(openset); con.gridwidth = 1; con.gridx = 4; con.gridy = 0; gb.setConstraints(expand, con); pan.add(expand); con.gridx = 5; gb.setConstraints(reduce, con); pan.add(reduce); con.gridwidth = 6; con.gridy = 1; con.gridx = 0; con.fill = GridBagConstraints.HORIZONTAL; con.gridy = 2; con.gridx = 0; con.gridwidth = 4; gbl.setConstraints(pan, con); main.add(pan); main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); add(main, BorderLayout.CENTER); updateBorder(editModeIndicator); definePopup(); NodeAction moveNodeUpAction = new MoveNodeUpAction(); moveNodeUpAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK)); NodeAction moveNodeDownAction = new MoveNodeDownAction(); moveNodeDownAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK)); NodeAction moveNodeLeftAction = new MoveNodeLeftAction(); moveNodeLeftAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK)); NodeAction moveNodeRightAction = new MoveNodeRightAction(); moveNodeRightAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK)); }