List of usage examples for javax.swing JToggleButton isSelected
public boolean isSelected()
From source file:org.apereo.learninganalytics.snapp.ClusteringDemo.java
private void setUpView(Graph<Integer, Number> grp, Map<Integer, String> name) { /*/* w ww. java 2 s .com*/ Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number,Number> pnr = new PajekNetReader<Graph<Number, Number>, Number,Number>(vertexFactory, edgeFactory); final Graph<Number,Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); */ //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm this.usernames = name; final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>( new FRLayout<Integer, Number>(grp)); layout.setSize(new Dimension(500, 500)); vv = new VisualizationViewer<Integer, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() { public Paint transform(Integer v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); vv.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new ChainedTransformer<Integer, String>( new Transformer[] { new ToStringLabeller<String>(), new Transformer<String, String>() { public String transform(String input) { return usernames.get(Integer.parseInt(input)); } } })); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); /* //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); */ DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(grp.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); // Add a restart button so the graph can be redrawn to fit the size of the frame JFrame jf = new JFrame("SNAPP: Find Clusters"); //jf.getContentPane().add(); //Container content = getContentPane(); //content.add(new GraphZoomScrollPane(vv)); jf.getContentPane().add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); //grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); //content.add(south, BorderLayout.SOUTH); jf.getContentPane().add(south, BorderLayout.SOUTH); //jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }
From source file:org.datavyu.controllers.component.MixerController.java
/** * Handles the event for toggling movement of tracks on and off. * * @param e the event to handle//from w w w . j a va2s . c o m */ private void lockToggleHandler(final ActionEvent e) { JToggleButton toggle = (JToggleButton) e.getSource(); tracksEditorController.setLockedState(toggle.isSelected()); updateGlobalLockToggle(); }
From source file:org.lz1aq.jatu.SimpleRadioPanel.java
private void connectToRadioButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_connectToRadioButtonActionPerformed {//GEN-HEADEREND:event_connectToRadioButtonActionPerformed JToggleButton tBtn = (JToggleButton) evt.getSource(); try {/*w w w . jav a 2 s .co m*/ // Connect // ---------- if (tBtn.isSelected()) { if (radioParser == null) { JOptionPane.showMessageDialog(null, "Choose a radio first!", "Warning...", JOptionPane.INFORMATION_MESSAGE); connectToRadioButton.setSelected(false); return; } // Get comm port name String name = customComportTextfield.getText(); if (name.isEmpty()) name = String.valueOf(comportCombobox.getSelectedItem()); // Create the radio object using the selected Com port radio = new Radio(radioParser, name); radio.addEventListener(new LocalRadioListener()); radio.connect(); // Let's not forget to call connect(). Calling disconnects() later will close the Com Port } // Disconnect // ---------- else { if (radio != null) { radio.disconnect(); radio = null; } } } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); } }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
/** * Create "Start Recording" Button and attach the event handler. * // w ww . j a va 2 s . co m * @return created Button. */ private JToggleButton createRecordingButton() { JToggleButton button = decoratedToSimpleButton(new JToggleButton("Start Recording")); button.setText("Start Recording"); button.setSelected(false); button.setMinimumSize(new Dimension(100, 30)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JToggleButton button = (JToggleButton) e.getSource(); if (button.isSelected()) { button.setText("Stop Recording"); button.setSelected(true); messageBus.getPublisher(Topics.START_RECORDING).propertyChange(new PropertyChangeEvent( RecordingControlPanel.this, "Start Recording", null, getFilteredFileTypes())); } else { if (!stopConfirm()) { button.setSelected(true); return; } messageBus.getPublisher(Topics.STOP_RECORDING) .propertyChange(new PropertyChangeEvent(RecordingControlPanel.this, "Stop Recording", null, Pair.of(getFilteredFileTypes(), getGenerationOption()))); button.setText("Start Recording"); } } }); return button; }
From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertiesPanel.java
/** * This Method shows the Properties of a {@link WYSIWYGSubFormColumn} * @param c//from www.ja va 2 s. co m * @param tableLayoutUtil */ public static void showPropertiesForSubFormColumn(final WYSIWYGSubFormColumn c, TableLayoutUtil tableLayoutUtil) { final JToggleButton button = new JToggleButton(PROPERTIES_DIALOG.LABEL_DEFAULT_VALUES); List<AbstractButton> buttonlist = new ArrayList<AbstractButton>(); buttonlist.add(button); final PropertiesPanel dialog = new PropertiesPanel(c, tableLayoutUtil, buttonlist); if ((Boolean) c.getProperties().getProperty(WYSIWYGSubFormColumn.PROPERTY_DEFAULTVALUES).getValue()) { button.setSelected(true); dialog.properties.setEnabled(false); } button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (button.isSelected()) { if (dialog.properties.isEditing()) { dialog.properties.getCellEditor().stopCellEditing(); } for (String s : c.getPropertyNames()) { if ((PropertyUtils.getPropertyMode(c, s) & WYSIWYGEditorModes.ENABLED) == WYSIWYGEditorModes.ENABLED) { dialog.getModel().setValueAt(c.getDefaultPropertyValue(s), dialog.values.indexOf(s), 1); } } dialog.properties.setEnabled(false); } else { dialog.properties.setEnabled(true); } } }); dialog.setVisible(true); }
From source file:org.paxle.desktop.impl.dialogues.cconsole.CrawlingConsole.java
public void actionPerformed(ActionEvent e) { final String ac = e.getActionCommand(); if (ac == AC_CLEAR) { clear();// w ww .j a v a 2 s . c o m } else if (ac == AC_CRAWL) { updateCpb(cpb.isSelected(), false, true); } else if (ac == AC_SELECT) { updateCpb(false, true, false); } else if (ac == AC_SETTINGS) { final JToggleButton btn = (JToggleButton) e.getSource(); final boolean sel = btn.isSelected(); btn.setText(((sel) ? '\u2191' : '\u2193') + btn.getText().substring(1)); final boolean notInitialized = sel && options.getComponentCount() == 0; if (notInitialized) initOptions(); final Runnable sr = new Runnable() { public void run() { int height = options.getHeight(); frame.setSize(frame.getWidth(), frame.getHeight() + ((sel) ? height : -height)); } }; if (!notInitialized) sr.run(); options.setVisible(sel); if (notInitialized) SwingUtilities.invokeLater(sr); } if (ac == AC_SELECT || ac == AC_ENQUEUED || ac == AC_DESTROYED) { final String compItem = (String) cbox.getSelectedItem(); final boolean enq = cbEnq.isSelected(); final boolean dstr = cbDstr.isSelected(); if (logger.isDebugEnabled()) logger.debug("received ActionEvent, item: '" + compItem + "', enq: " + enq + ", dstr: " + dstr); updateListeners(MWComponents.valueOfHumanReadable(compItem), enq, dstr); /* model.setType((cbDstr.isSelected()) ? TableDisplay.REJECTED : (cbEnq.isSelected()) ? TableDisplay.WORKING_ON : new TableColumns()); */ } }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.DetailedVariantSubInspector.java
@Override public JPanel getInfoPanel() { if (p == null) { p = new KeyValuePairPanel(4); p.addKey(KEY_DNAID);//w w w .j av a2s . c o m p.addKey(KEY_ZYGOSITY); p.addKey(KEY_QUAL); p.addKey(KEY_DBSNP); p.addKey(KEY_INFO); JButton genomeBrowserButton = ViewUtil .getTexturedButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.BROWSER)); genomeBrowserButton.setToolTipText("View region in genome browser"); genomeBrowserButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { LocationController.getInstance().setLocation(selectedVariant.getChrom(), new Range((int) (selectedVariant.getStartPosition() - 20), (int) (selectedVariant.getEndPosition() + 21))); AppDirectory.launchApp(AppDirectory.BuiltInApp.GENOME_BROWSER); } }); JButton bamButton = ViewUtil .getTexturedButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.BAMFILE)); bamButton.setToolTipText("<html>Load read alignments for this<br/> sample in genome browser</html>"); bamButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Set<AppCommHandler> handlers = AppCommRegistry.getInstance() .getHandlersForEvent(BAMFileComm.class); if (handlers.isEmpty()) { return; } String dnaID = selectedVariant.getDnaID(); String bamPath; try { bamPath = MedSavantClient.PatientManager.getReadAlignmentPathForDNAID( LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(), dnaID); if (bamPath != null && !bamPath.equals("")) { AppCommHandler<BAMFileComm> handler = handlers.iterator().next(); handler.handleCommEvent(new BAMFileComm(null, new URL(bamPath))); //BrowserPage.getInstance().addTrackFromURLString(bamPath, DataFormat.ALIGNMENT); //DialogUtils.displayMessage("Read alignments have been loaded into Browser. Click 'Browser' at left to view."); } } catch (Exception ex) { ClientMiscUtils.reportError("Unable to load BAM file: %s", ex); } } }); JButton geneInspectorButton = ViewUtil .getTexturedButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.INSPECTOR)); geneInspectorButton.setToolTipText("Inspect this gene"); geneInspectorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { StaticGeneInspector.getInstance().setGene((Gene) (geneBox).getSelectedItem()); StaticInspectorPanel.getInstance().switchToGeneInspector(); } }); JLabel l = new JLabel("This will eventually show a chart"); //p.setDetailComponent(KEY_QUAL, l); final JToggleButton button = ViewUtil.getTexturedToggleButton("SHOW"); ViewUtil.makeSmall(button); button.setToolTipText("Toggle Info"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { p.toggleDetailVisibility(KEY_INFO); button.setText(button.isSelected() ? "HIDE" : "SHOW"); } }); p.setValue(KEY_INFO, button); int col = 0; p.setAdditionalColumn(KEY_DNAID, col, KeyValuePairPanel.getCopyButton(KEY_DNAID, p)); p.setAdditionalColumn(KEY_DBSNP, col, KeyValuePairPanel.getCopyButton(KEY_DBSNP, p)); //p.setAdditionalColumn(KEY_QUAL, col, getChartButton(KEY_QUAL)); col++; p.setAdditionalColumn(KEY_DBSNP, col, getNCBIButton(KEY_DBSNP)); p.setAdditionalColumn(KEY_DNAID, col, bamButton); } return p; }
From source file:test.visualization.ClusteringDemo.java
private void setUpView(BufferedReader br) throws IOException { Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; }/*from w w w .j ava 2s .c om*/ }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>( vertexFactory, edgeFactory); final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>( new FRLayout<Number, Number>(graph)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() { public Paint transform(Number v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(graph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); //vv.validate(); //vv.repaint(); } } }); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }