List of usage examples for javax.swing JCheckBox JCheckBox
public JCheckBox(Action a)
From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
/** * Creates the component.//from w w w . j a va 2 s .c o m */ public RenderedResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; Component component = renderedResultPanel.getComponent(0); if (component instanceof DialogTextArea) { nodeToWrapSelection.put(path, e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:net.pandoragames.far.ui.swing.FindFilePanel.java
private void initBaseDirPanel(SwingConfig config, ComponentRepository componentRepository) { this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JLabel labelBaseDir = new JLabel(config.getLocalizer().localize("label.base-directory")); labelBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(labelBaseDir); baseDirPathTextField/* ww w .jav a 2s .c o m*/ .setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH, config.getStandardComponentHight())); baseDirPathTextField .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); // baseDirPathTextField.setText( dataModel.getBaseDirectory().getPath() ); baseDirPathTextField.addItem(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setSelectedItem(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setToolTipText(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setEditable(false); baseDirPathTextField.addItemListener(new BaseDirectoryComboBoxListener(config, dataModel)); JButton openBaseDirFileChooserButton = new JButton(localizer.localize("button.browse")); openBaseDirFileChooserButton.requestFocusInWindow(); class BaseDirectoryRepository extends AbstractFileRepository { public BaseDirectoryRepository(FARConfig cfg, ComponentRepository repository) { super(cfg, repository.getFindForm(), repository.getReplaceForm(), repository.getMessageBox()); } public File getFile() { return farconfig.getBaseDirectory(); } public boolean setFile(File file) { if (isSubdirectory(replaceForm.getBackupDirectory(), file)) { messageBox.error(localizer.localize("message.nested-base-child")); return false; } else if (isSubdirectory(file, replaceForm.getBackupDirectory())) { messageBox.error(localizer.localize("message.nested-base-parent")); return false; } else { baseDirPathTextField.addItem(file.getPath()); baseDirPathTextField.setSelectedItem(file.getPath()); baseDirPathTextField.setToolTipText(file.getPath()); farconfig.setBaseDirectory(file); findForm.setBaseDirectory(file); return true; } } } browseButtonListener = new FindFilePanelBrowseButtonListener(baseDirPathTextField, new BaseDirectoryRepository(config, componentRepository), localizer.localize("label.choose-base-directory"), componentRepository.getFindCommand(), componentRepository.getResetDispatcher()); browseButtonListener.addActionListener(componentRepository.getSearchBaseListener()); openBaseDirFileChooserButton.addActionListener(browseButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(baseDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(lineBaseDir); subdirFlag = new JCheckBox(localizer.localize("label.include-subdir") + ":"); subdirFlag.setSelected(dataModel.isIncludeSubDirs()); subdirFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setIncludeSubDirs((ItemEvent.SELECTED == event.getStateChange())); if (ItemEvent.SELECTED != event.getStateChange()) subdirButton.reset(); } }); subdirFlag.addItemListener(componentRepository.getSearchBaseListener()); componentRepository.getResetDispatcher().addToBeSelected(subdirFlag); browseButtonListener.setSubdirCheckBox(subdirFlag); subdirButton = new SubdirPatternLink(dataModel, localizer, componentRepository.getSearchBaseListener(), componentRepository.getRootWindow()); componentRepository.getResetDispatcher().addResetable(subdirButton); TwoComponentsPanel subdirpanel = new TwoComponentsPanel(subdirFlag, subdirButton); subdirpanel.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(subdirpanel); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); this.add(Box.createVerticalGlue()); }
From source file:FileChooserDemo.java
public FileChooserDemo() { UIManager.LookAndFeelInfo[] installedLafs = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo lafInfo : installedLafs) { try {//from w w w . j av a 2 s . c om 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:lu.lippmann.cdb.ext.hydviga.ui.GapFillingFrame.java
/** * Constructor.//from ww w.j a v a2 s .co m */ public GapFillingFrame(final AbstractTabView atv, final Instances dataSet, final Attribute attr, final int dateIdx, final int valuesBeforeAndAfter, final int position, final int gapsize, final StationsDataProvider gcp, final boolean inBatchMode) { super(); setTitle("Gap filling for " + attr.name() + " (" + dataSet.attribute(dateIdx).formatDate(dataSet.instance(position).value(dateIdx)) + " -> " + dataSet.attribute(dateIdx).formatDate(dataSet.instance(position + gapsize).value(dateIdx)) + ")"); LogoHelper.setLogo(this); this.atv = atv; this.dataSet = dataSet; this.attr = attr; this.dateIdx = dateIdx; this.valuesBeforeAndAfter = valuesBeforeAndAfter; this.position = position; this.gapsize = gapsize; this.gcp = gcp; final Instances testds = WekaDataProcessingUtil.buildFilteredDataSet(dataSet, 0, dataSet.numAttributes() - 1, Math.max(0, position - valuesBeforeAndAfter), Math.min(position + gapsize + valuesBeforeAndAfter, dataSet.numInstances() - 1)); this.attrNames = WekaTimeSeriesUtil.getNamesOfAttributesWithoutGap(testds); this.isGapSimulated = (this.attrNames.contains(attr.name())); this.originaldataSet = new Instances(dataSet); if (this.isGapSimulated) { setTitle(getTitle() + " [SIMULATED GAP]"); /*final JXLabel fictiveGapLabel=new JXLabel(" FICTIVE GAP"); fictiveGapLabel.setForeground(Color.RED); fictiveGapLabel.setFont(new Font(fictiveGapLabel.getFont().getName(), Font.PLAIN,fictiveGapLabel.getFont().getSize()*2)); final JXPanel fictiveGapPanel=new JXPanel(); fictiveGapPanel.setLayout(new BorderLayout()); fictiveGapPanel.add(fictiveGapLabel,BorderLayout.CENTER); getContentPane().add(fictiveGapPanel,BorderLayout.NORTH);*/ this.attrNames.remove(attr.name()); this.originalDataBeforeGapSimulation = dataSet.attributeToDoubleArray(attr.index()); for (int i = position; i < position + gapsize; i++) dataSet.instance(i).setMissing(attr); } final Object[] attrNamesObj = this.attrNames.toArray(); this.centerPanel = new JXPanel(); this.centerPanel.setLayout(new BorderLayout()); getContentPane().add(this.centerPanel, BorderLayout.CENTER); //final JXPanel algoPanel=new JXPanel(); //getContentPane().add(algoPanel,BorderLayout.NORTH); final JXPanel filterPanel = new JXPanel(); //filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.Y_AXIS)); filterPanel.setLayout(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(10, 10, 10, 10); getContentPane().add(filterPanel, BorderLayout.WEST); final JXComboBox algoCombo = new JXComboBox(Algo.values()); algoCombo.setBorder(new TitledBorder("Algorithm")); filterPanel.add(algoCombo, gbc); gbc.gridy++; final JXLabel infoLabel = new JXLabel("Usable = with no missing values on the period"); //infoLabel.setBorder(new TitledBorder("")); filterPanel.add(infoLabel, gbc); gbc.gridy++; final JList<Object> timeSeriesList = new JList<Object>(attrNamesObj); timeSeriesList.setBorder(new TitledBorder("Usable time series")); timeSeriesList.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); final JScrollPane jcpMap = new JScrollPane(timeSeriesList); jcpMap.setPreferredSize(new Dimension(225, 150)); jcpMap.setMinimumSize(new Dimension(225, 150)); filterPanel.add(jcpMap, gbc); gbc.gridy++; final JXPanel mapPanel = new JXPanel(); mapPanel.setBorder(new TitledBorder("")); mapPanel.setLayout(new BorderLayout()); mapPanel.add(gcp.getMapPanel(Arrays.asList(attr.name()), this.attrNames, true), BorderLayout.CENTER); filterPanel.add(mapPanel, gbc); gbc.gridy++; final JXLabel mssLabel = new JXLabel( "<html>Most similar usable serie: <i>[... computation ...]</i></html>"); mssLabel.setBorder(new TitledBorder("")); filterPanel.add(mssLabel, gbc); gbc.gridy++; final JXLabel nsLabel = new JXLabel("<html>Nearest usable serie: <i>[... computation ...]</i></html>"); nsLabel.setBorder(new TitledBorder("")); filterPanel.add(nsLabel, gbc); gbc.gridy++; final JXLabel ussLabel = new JXLabel("<html>Upstream serie: <i>[... computation ...]</i></html>"); ussLabel.setBorder(new TitledBorder("")); filterPanel.add(ussLabel, gbc); gbc.gridy++; final JXLabel dssLabel = new JXLabel("<html>Downstream serie: <i>[... computation ...]</i></html>"); dssLabel.setBorder(new TitledBorder("")); filterPanel.add(dssLabel, gbc); gbc.gridy++; final JCheckBox hideOtherSeriesCB = new JCheckBox("Hide the others series"); hideOtherSeriesCB.setSelected(DEFAULT_HIDE_OTHER_SERIES_OPTION); filterPanel.add(hideOtherSeriesCB, gbc); gbc.gridy++; final JCheckBox showErrorCB = new JCheckBox("Show error on plot"); filterPanel.add(showErrorCB, gbc); gbc.gridy++; final JCheckBox zoomCB = new JCheckBox("Auto-adjusted size"); zoomCB.setSelected(DEFAULT_ZOOM_OPTION); filterPanel.add(zoomCB, gbc); gbc.gridy++; final JCheckBox multAxisCB = new JCheckBox("Multiple axis"); filterPanel.add(multAxisCB, gbc); gbc.gridy++; final JCheckBox showEnvelopeCB = new JCheckBox("Show envelope (all algorithms, SLOW)"); filterPanel.add(showEnvelopeCB, gbc); gbc.gridy++; final JXButton showModelButton = new JXButton("Show the model"); filterPanel.add(showModelButton, gbc); gbc.gridy++; showModelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final JXFrame dialog = new JXFrame(); dialog.setTitle("Model"); LogoHelper.setLogo(dialog); dialog.getContentPane().removeAll(); dialog.getContentPane().setLayout(new BorderLayout()); final JTextPane modelTxtPane = new JTextPane(); modelTxtPane.setText(gapFiller.getModel()); modelTxtPane.setBackground(Color.WHITE); modelTxtPane.setEditable(false); final JScrollPane jsp = new JScrollPane(modelTxtPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jsp.setSize(new Dimension(400 - 20, 400 - 20)); dialog.getContentPane().add(jsp, BorderLayout.CENTER); dialog.setSize(new Dimension(400, 400)); dialog.setLocationRelativeTo(centerPanel); dialog.pack(); dialog.setVisible(true); } }); algoCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(), showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(), multAxisCB.isSelected()); showModelButton.setEnabled(gapFiller.hasExplicitModel()); } catch (final Exception e1) { e1.printStackTrace(); } } }); timeSeriesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(), showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(), multAxisCB.isSelected()); mapPanel.removeAll(); final List<String> currentlySelected = new ArrayList<String>(); currentlySelected.add(attr.name()); for (final Object sel : timeSeriesList.getSelectedValues()) currentlySelected.add(sel.toString()); mapPanel.add(gcp.getMapPanel(currentlySelected, attrNames, true), BorderLayout.CENTER); } catch (final Exception e1) { e1.printStackTrace(); } } }); hideOtherSeriesCB.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(), showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(), multAxisCB.isSelected()); } catch (final Exception e1) { e1.printStackTrace(); } } }); showErrorCB.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(), showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(), multAxisCB.isSelected()); } catch (Exception e1) { e1.printStackTrace(); } } }); zoomCB.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(), showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(), multAxisCB.isSelected()); } catch (Exception e1) { e1.printStackTrace(); } } }); showEnvelopeCB.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(), showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(), multAxisCB.isSelected()); } catch (Exception e1) { e1.printStackTrace(); } } }); multAxisCB.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(), showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(), multAxisCB.isSelected()); } catch (Exception e1) { e1.printStackTrace(); } } }); this.inBatchMode = inBatchMode; if (!inBatchMode) { try { refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), new int[0], DEFAULT_HIDE_OTHER_SERIES_OPTION, false, DEFAULT_ZOOM_OPTION, false, false); showModelButton.setEnabled(gapFiller.hasExplicitModel()); } catch (Exception e1) { e1.printStackTrace(); } } if (!inBatchMode) { /* automatically select computed series */ new AbstractSimpleAsync<Void>(true) { @Override public Void execute() throws Exception { mostSimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(testds, attr, attrNames, false); mssLabel.setText("<html>Most similar usable serie: <b>" + mostSimilar + "</b></html>"); nearest = gcp.findNearestStation(attr.name(), attrNames); nsLabel.setText("<html>Nearest usable serie: <b>" + nearest + "</b></html>"); upstream = gcp.findUpstreamStation(attr.name(), attrNames); if (upstream != null) { ussLabel.setText("<html>Upstream usable serie: <b>" + upstream + "</b></html>"); } else { ussLabel.setText("<html>Upstream usable serie: <b>N/A</b></html>"); } downstream = gcp.findDownstreamStation(attr.name(), attrNames); if (downstream != null) { dssLabel.setText("<html>Downstream usable serie: <b>" + downstream + "</b></html>"); } else { dssLabel.setText("<html>Downstream usable serie: <b>N/A</b></html>"); } timeSeriesList.setSelectedIndices( new int[] { attrNames.indexOf(mostSimilar), attrNames.indexOf(nearest), attrNames.indexOf(upstream), attrNames.indexOf(downstream) }); return null; } @Override public void onSuccess(final Void result) { } @Override public void onFailure(final Throwable caught) { caught.printStackTrace(); } }.start(); } else { try { mostSimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(testds, attr, attrNames, false); } catch (Exception e1) { e1.printStackTrace(); } nearest = gcp.findNearestStation(attr.name(), attrNames); upstream = gcp.findUpstreamStation(attr.name(), attrNames); downstream = gcp.findDownstreamStation(attr.name(), attrNames); } }
From source file:net.sf.taverna.t2.workbench.views.results.processor.RenderedProcessorResultComponent.java
/** * Creates the component.//ww w . j a va 2 s . co m */ public RenderedProcessorResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); setBorder(new EtchedBorder()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; if (renderedResultPanel.getComponent(0) instanceof DialogTextArea) { nodeToWrapSelection.put(node.hashCode(), e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); renderedResultPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:com.sec.ose.osi.ui.frm.main.identification.autoidentify.JPanImportSPDX.java
private JCheckBox getJCheckSamePath() { if (jCheckSamePath == null) { jCheckSamePath = new JCheckBox("Use the exactly same path file info if duplicated hash files exist."); jCheckSamePath.setSelected(true); }//w w w . j av a 2 s. co m return jCheckSamePath; }
From source file:net.sourceforge.doddle_owl.ui.InputDocumentSelectionPanel.java
public InputDocumentSelectionPanel(InputTermSelectionPanel iwsPanel, DODDLEProject p) { project = p;/*from ww w .j a va 2s . co m*/ inputTermSelectionPanel = iwsPanel; termInfoMap = new HashMap<String, TermInfo>(); stopWordSet = new HashSet<String>(); docList = new JList(new DefaultListModel()); docList.addListSelectionListener(this); JScrollPane docListScroll = new JScrollPane(docList); inputDocList = new JList(new DefaultListModel()); inputDocList.addListSelectionListener(this); JScrollPane inputDocListScroll = new JScrollPane(inputDocList); DefaultComboBoxModel docLangBoxModel = new DefaultComboBoxModel(new Object[] { "en", "ja" }); docLangBox = new JComboBox(docLangBoxModel); docLangBox.addActionListener(this); addDocButton = new JButton(new AddDocAction(Translator.getTerm("AddDocumentButton"))); removeDocButton = new JButton(new RemoveDocAction(Translator.getTerm("RemoveDocumentButton"))); DefaultComboBoxModel inputDocLangBoxModel = new DefaultComboBoxModel(new Object[] { "en", "ja" }); inputDocLangBox = new JComboBox(inputDocLangBoxModel); inputDocLangBox.addActionListener(this); addInputDocButton = new JButton(new AddInputDocAction(Translator.getTerm("AddInputDocumentButton"))); removeInputDocButton = new JButton( new RemoveInputDocAction(Translator.getTerm("RemoveInputDocumentButton"))); inputDocArea = new JTextArea(); inputDocArea.setLineWrap(true); JScrollPane inputDocAreaScroll = new JScrollPane(inputDocArea); JPanel docButtonPanel = new JPanel(); docButtonPanel.setLayout(new BorderLayout()); docButtonPanel.setLayout(new GridLayout(1, 3)); docButtonPanel.add(docLangBox); docButtonPanel.add(addDocButton); docButtonPanel.add(removeDocButton); JPanel docPanel = new JPanel(); docPanel.setLayout(new BorderLayout()); docPanel.add(docListScroll, BorderLayout.CENTER); docPanel.add(docButtonPanel, BorderLayout.SOUTH); punctuationField = new JTextField(10); punctuationField.setText(PUNCTUATION_CHARS); setPunctuationButton = new JButton(Translator.getTerm("SetPunctuationCharacterButton")); setPunctuationButton.addActionListener(this); JPanel punctuationPanel = new JPanel(); punctuationPanel.add(punctuationField); punctuationPanel.add(setPunctuationButton); JPanel inputDocButtonPanel = new JPanel(); inputDocButtonPanel.setLayout(new GridLayout(1, 3)); inputDocButtonPanel.add(inputDocLangBox); inputDocButtonPanel.add(addInputDocButton); inputDocButtonPanel.add(removeInputDocButton); JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); southPanel.add(inputDocButtonPanel, BorderLayout.WEST); southPanel.add(punctuationPanel, BorderLayout.EAST); JPanel inputDocPanel = new JPanel(); inputDocPanel.setLayout(new BorderLayout()); inputDocPanel.add(inputDocListScroll, BorderLayout.CENTER); inputDocPanel.add(southPanel, BorderLayout.SOUTH); termExtractionButton = new JButton(Translator.getTerm("InputTermExtractionButton"), Utils.getImageIcon("input_term_selection.png")); termExtractionButton.addActionListener(this); genSenCheckBox = new JCheckBox(Translator.getTerm("GensenCheckBox")); genSenCheckBox.setSelected(false); cabochaCheckBox = new JCheckBox(Translator.getTerm("CabochaCheckBox")); cabochaCheckBox.setSelected(true); showImportanceCheckBox = new JCheckBox("??"); nounCheckBox = new JCheckBox(Translator.getTerm("NounCheckBox")); nounCheckBox.setSelected(true); verbCheckBox = new JCheckBox(Translator.getTerm("VerbCheckBox")); verbCheckBox.setSelected(false); otherCheckBox = new JCheckBox(Translator.getTerm("OtherPOSCheckBox")); oneWordCheckBox = new JCheckBox(Translator.getTerm("OneCharacterCheckBox")); JPanel morphemeAnalysisPanel = new JPanel(); morphemeAnalysisPanel.add(genSenCheckBox); morphemeAnalysisPanel.add(cabochaCheckBox); morphemeAnalysisPanel.add(nounCheckBox); morphemeAnalysisPanel.add(verbCheckBox); morphemeAnalysisPanel.add(otherCheckBox); morphemeAnalysisPanel.add(oneWordCheckBox); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(morphemeAnalysisPanel, BorderLayout.WEST); buttonPanel.add(termExtractionButton, BorderLayout.EAST); mainViews = new View[2]; ViewMap viewMap = new ViewMap(); // mainViews[0] = new View(Translator.getTerm("DocumentList"), null, // docPanel); mainViews[0] = new View(Translator.getTerm("InputDocumentList"), null, inputDocPanel); mainViews[1] = new View(Translator.getTerm("InputDocumentArea"), null, inputDocAreaScroll); for (int i = 0; i < mainViews.length; i++) { viewMap.addView(i, mainViews[i]); } rootWindow = Utils.createDODDLERootWindow(viewMap); setLayout(new BorderLayout()); add(rootWindow, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
From source file:grisu.frontend.view.swing.files.preview.fileViewers.JobStatusGridFileViewer.java
private JCheckBox getChckbxShowMinutes() { if (chckbxShowMinutes == null) { chckbxShowMinutes = new JCheckBox("Display minutes"); chckbxShowMinutes.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (chckbxShowMinutes.isSelected()) { showMinutes = true;/*from ww w . jav a2 s .c o m*/ } else { showMinutes = false; } new Thread() { @Override public void run() { chckbxShowMinutes.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); generateGraph(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); chckbxShowMinutes.setEnabled(true); } }.start(); } }); } return chckbxShowMinutes; }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.MIResultPanel.java
public MIResultPanel(IgbService service, String summary, List<MIResult> results, String label, MIQuery query) { setLayout(new BorderLayout()); this.label = label; igbLogger = IGBLogger.getInstance(label); colorer = TaxonColorer.getColorer(query.getTaxid()); Box menuBox = new Box(BoxLayout.X_AXIS); Box buttonBox = new Box(BoxLayout.Y_AXIS); Box buttonBox1 = new Box(BoxLayout.X_AXIS); Box buttonBox3 = new Box(BoxLayout.X_AXIS); buttonBox.add(buttonBox1);/*w ww .ja va2 s . c om*/ buttonBox.add(buttonBox3); JTextPane querySummary = new JTextPane(); querySummary.setContentType("text/html"); querySummary.setEditable(false); querySummary.setText(summary); menuBox.add(querySummary); menuBox.add(buttonBox); final JFrame logFrame = new JFrame("MI Bundle Log"); logFrame.setVisible(false); Dimension preferredSize = new Dimension(800, 500); logFrame.setPreferredSize(preferredSize); logFrame.setMinimumSize(preferredSize); logFrame.add(new LogPanel(igbLogger)); JButton log = new JButton(); if (igbLogger.hasError()) { log.setBackground(Color.red); } log.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/console.png")); log.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logFrame.setVisible(true); } }); buttonBox1.add(log); JButton networkButton = new JButton(""); networkButton.setIcon(new ImageIcon(getClass().getResource("/network.jpg"))); networkButton.addActionListener(new DisplayNetworkActionListener()); buttonBox1.add(networkButton); buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("Save: ")); JButton exportButton = new JButton("text"); exportButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png")); exportButton.addActionListener(new ExportActionListener()); if (false == MICommons.testVersion) { buttonBox1.add(exportButton); } JButton exportXgmmlButton = new JButton("xgmml"); exportXgmmlButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png")); exportXgmmlButton.addActionListener(new ExportXgmmlActionListener()); if (false == MICommons.testVersion) { buttonBox1.add(exportXgmmlButton); } buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("View structure: ")); structures = new StructuresPanel(service, label); buttonBox1.add(structures.getJmolButton()); buttonBox1.add(structures.getLinkButton()); // Filters ButtonGroup scoreGroup = new ButtonGroup(); JRadioButton scoreButton0 = new JRadioButton("<html>" + HTML_SCORE_0 + "</html>"); JRadioButton scoreButton1 = new JRadioButton("<html>" + HTML_SCORE_1 + "</html>"); JRadioButton scoreButton2 = new JRadioButton("<html>" + HTML_SCORE_2 + "</html>"); JRadioButton scoreButton3 = new JRadioButton("<html>" + HTML_SCORE_3 + "</html>"); scoreButton0.setSelected(true); ScoreListener scoreListener = new ScoreListener(); scoreButton0.addActionListener(scoreListener); scoreButton1.addActionListener(scoreListener); scoreButton2.addActionListener(scoreListener); scoreButton3.addActionListener(scoreListener); scoreGroup.add(scoreButton0); scoreGroup.add(scoreButton1); scoreGroup.add(scoreButton2); scoreGroup.add(scoreButton3); buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("Score: ")); buttonBox1.add(scoreButton0); buttonBox1.add(scoreButton1); buttonBox1.add(scoreButton2); buttonBox1.add(scoreButton3); buttonBox3.add(new JLabel("Interaction type: ")); JCheckBox EvidencePhysicalButton = new JCheckBox(HTML_CHECKBOX_PHYSICAL); JCheckBox EvidenceAssociationButton = new JCheckBox(HTML_CHECKBOX_ASSOCIATION); JCheckBox EvidenceEnzymaticButton = new JCheckBox(HTML_CHECKBOX_ENZYMATIC); JCheckBox EvidenceOtherButton = new JCheckBox(HTML_CHECKBOX_OTHER); JCheckBox EvidenceUnspecifiedButton = new JCheckBox(HTML_CHECKBOX_UNSPECIFIED); JCheckBox EvidenceStructureButton = new JCheckBox(HTML_CHECKBOX_STRUCTURE); EvidencePhysicalButton.setSelected(true); EvidenceAssociationButton.setSelected(true); EvidenceEnzymaticButton.setSelected(true); EvidenceOtherButton.setSelected(true); EvidenceUnspecifiedButton.setSelected(true); EvidenceStructureButton.setSelected(true); buttonBox3.add(EvidencePhysicalButton); buttonBox3.add(EvidenceAssociationButton); buttonBox3.add(EvidenceEnzymaticButton); buttonBox3.add(EvidenceOtherButton); buttonBox3.add(EvidenceUnspecifiedButton); buttonBox3.add(EvidenceStructureButton); EvidenceTypeListener evidenceListener = new EvidenceTypeListener(); EvidencePhysicalButton.addActionListener(evidenceListener); EvidenceAssociationButton.addActionListener(evidenceListener); EvidenceEnzymaticButton.addActionListener(evidenceListener); EvidenceOtherButton.addActionListener(evidenceListener); EvidenceUnspecifiedButton.addActionListener(evidenceListener); EvidenceStructureButton.addActionListener(evidenceListener); Box tableBox = new Box(BoxLayout.Y_AXIS); MITableModel model = new MITableModel(results); miTable = new MITable(model, service, query); miTable.setFillsViewportHeight(true); miTable.setStructuresPanel(structures); tableBox.add(miTable.getTableHeader()); tableBox.add(miTable); JScrollPane tableScroll = new JScrollPane(tableBox); tableScroll.setMinimumSize(new Dimension(800, 50)); tableScroll.setPreferredSize(new Dimension(800, 50)); tableScroll.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); structures.setMinimumSize(new Dimension(200, 500)); structures.setPreferredSize(new Dimension(200, 500)); structures.setMaximumSize(new Dimension(200, Short.MAX_VALUE)); resultBox = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScroll, structures); resultBox.setOneTouchExpandable(true); add(menuBox, BorderLayout.NORTH); add(resultBox, BorderLayout.CENTER); }
From source file:com.sec.ose.osi.ui.frm.main.identification.autoidentify.JPanImportSPDX.java
private JCheckBox getJCheckRecentInfo() { if (jCheckRecentInfo == null) { jCheckRecentInfo = new JCheckBox("Use SPDX document recently created if project already exists."); jCheckRecentInfo.setSelected(true); }// w w w . j a va2 s .c om return jCheckRecentInfo; }