List of usage examples for javax.swing JCheckBox isSelected
public boolean isSelected()
From source file:com.diversityarrays.kdxplore.curate.fieldview.InterceptFieldLayoutView.java
public void openFieldLayoutView(Component trigger, String title, @SuppressWarnings("rawtypes") MutableComboBoxModel comboBoxModel, CurationData curationData, CurationTableModel curationTableModel, SelectedValueStore selectedValueStore, PlotCellChoicesPanel plotCellChoicesPanel, JPopupMenu popuMenu, Font smallFont, Action curationHelpAction, MessagePrinter messages, Closure<String> selectionClosure, CurationContext curationContext, CurationMenuProvider curationMenuProvider, FieldLayoutTableModel fieldLayoutTableModel, CellSelectableTable fieldLayoutTable, FieldViewSelectionModel fieldViewSelectionModel, JButton undockButton) {//from www . j a v a2s. c om if (fieldLayoutFrame != null) { fieldLayoutFrame.toFront(); return; } JCheckBox alwaysOnTopOption = new JCheckBox(Msg.OPTION_KEEP_ON_TOP(), true); viewPanel = new FieldLayoutViewPanel(comboBoxModel, alwaysOnTopOption, curationData, curationTableModel, selectedValueStore, plotCellChoicesPanel, popuMenu, smallFont, curationHelpAction, messages, selectionClosure, curationContext, curationMenuProvider, fieldLayoutTableModel, fieldLayoutTable, fieldViewSelectionModel, undockButton); viewPanel.addRefreshListener(refreshListener); viewPanel.addTraitInstanceSelectionListener(itemListener); viewPanel.addCellSelectionListener(cellSelectionListener); fieldLayoutFrame = new JFrame(title); fieldLayoutFrame.setAlwaysOnTop(alwaysOnTopOption.isSelected()); fieldLayoutFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); fieldLayoutFrame.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { viewPanel.doPostOpenActions(); } @Override public void windowClosed(WindowEvent e) { try { viewPanel.removeCellSelectionListener(cellSelectionListener); } finally { fieldLayoutFrame.removeWindowListener(this); fieldLayoutFrame = null; } } }); fieldLayoutFrame.setContentPane(viewPanel); fieldLayoutFrame.pack(); fieldLayoutFrame.setLocationRelativeTo(trigger); fieldLayoutFrame.setVisible(true); fieldLayoutFrame.toFront(); alwaysOnTopOption.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fieldLayoutFrame.setAlwaysOnTop(alwaysOnTopOption.isSelected()); } }); }
From source file:logdruid.ui.chart.GraphPanel.java
public void load(JPanel panel_2) { startDateJSpinner = (JSpinner) panel_2.getComponent(2); endDateJSPinner = (JSpinner) panel_2.getComponent(3); // scrollPane.setV panel.removeAll();//from w w w.ja v a2 s . c o m Dimension panelSize = this.getSize(); add(scrollPane, BorderLayout.CENTER); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); // scrollPane.set trying to replace scroll where it was JCheckBox relativeCheckBox = (JCheckBox) panel_2.getComponent(5); estimatedTime = System.currentTimeMillis() - startTime; logger.info("gathering time: " + estimatedTime); startTime = System.currentTimeMillis(); // Map<Source, Map<String, MineResult>> Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>( mineResultSet.mineResults); Iterator mineResultSetIterator = treeMap.entrySet().iterator(); int ite = 0; logger.debug("mineResultSet size: " + mineResultSet.mineResults.size()); while (mineResultSetIterator.hasNext()) { final Map.Entry pairs = (Map.Entry) mineResultSetIterator.next(); logger.debug("mineResultSet key/source: " + ((Source) pairs.getKey()).getSourceName()); JCheckBox checkBox = (JCheckBox) panel_1.getComponent(ite++); logger.debug("checkbox: " + checkBox.getText() + ", " + checkBox.isSelected()); if (checkBox.isSelected()) { Map mrArrayList = (Map<String, MineResult>) pairs.getValue(); ArrayList<String> mineResultGroup = new ArrayList<String>(); Set<String> mrss = mrArrayList.keySet(); mineResultGroup.addAll(mrss); Collections.sort(mineResultGroup, new AlphanumComparator()); Iterator mrArrayListIterator = mineResultGroup.iterator(); while (mrArrayListIterator.hasNext()) { String key = (String) mrArrayListIterator.next(); logger.debug(key); final MineResult mr = (MineResult) mrArrayList.get(key); Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap(); Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap(); // logger.info("mineResultSet hash size: " // +mr.getTimeseriesMap().size()); // logger.info("mineResultSet hash content: " + // mr.getStatTimeseriesMap()); logger.debug("mineResultSet mr.getStartDate(): " + mr.getStartDate() + " mineResultSet mr.getEndDate(): " + mr.getEndDate()); logger.debug("mineResultSet (Date)jsp.getValue(): " + (Date) startDateJSpinner.getValue()); logger.debug("mineResultSet (Date)jsp2.getValue(): " + (Date) endDateJSPinner.getValue()); if (mr.getStartDate() != null && mr.getEndDate() != null) { if ((mr.getStartDate().before((Date) endDateJSPinner.getValue())) && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) { ArrayList<String> mineResultGroup2 = new ArrayList<String>(); Set<String> mrss2 = statMap.keySet(); mineResultGroup2.addAll(mrss2); Collections.sort(mineResultGroup2, new AlphanumComparator()); Iterator statMapIterator = mineResultGroup2.iterator(); // Iterator statMapIterator = statMap.entrySet().iterator(); if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) { JPanel checkboxPanel = new JPanel(new WrapLayout()); checkboxPanel.setBackground(Color.white); int count = 1; chart = ChartFactory.createXYAreaChart(// Title mr.getSourceID() + " " + mr.getGroup(), // + null, // X-Axis // label null, // Y-Axis label null, // Dataset PlotOrientation.VERTICAL, false, // Show // legend true, // tooltips false // url ); TextTitle my_Chart_title = new TextTitle(mr.getSourceID() + " " + mr.getGroup(), new Font("Verdana", Font.BOLD, 17)); chart.setTitle(my_Chart_title); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis range = plot.getRangeAxis(); range.setVisible(false); final DateAxis domainAxis1 = new DateAxis(); domainAxis1.setTickLabelsVisible(true); // domainAxis1.setTickMarksVisible(true); logger.debug("getRange: " + domainAxis1.getRange()); if (relativeCheckBox.isSelected()) { domainAxis1.setRange((Date) startDateJSpinner.getValue(), (Date) endDateJSPinner.getValue()); } else { Date startDate = mr.getStartDate(); Date endDate = mr.getEndDate(); if (mr.getStartDate().before((Date) startDateJSpinner.getValue())) { startDate = (Date) startDateJSpinner.getValue(); logger.debug("setMinimumDate: " + (Date) startDateJSpinner.getValue()); } if (mr.getEndDate().after((Date) endDateJSPinner.getValue())) { endDate = (Date) endDateJSPinner.getValue(); logger.debug("setMaximumDate: " + (Date) endDateJSPinner.getValue()); } if (startDate.before(endDate)) { domainAxis1.setRange(startDate, endDate); } } XYToolTipGenerator tt1 = new XYToolTipGenerator() { public String generateToolTip(XYDataset dataset, int series, int item) { StringBuffer sb = new StringBuffer(); String htmlStr = "<html>"; Number x; FastDateFormat sdf = FastDateFormat.getInstance("dd-MMM-yyyy HH:mm:ss"); x = dataset.getX(series, item); sb.append(htmlStr); if (x != null) { sb.append("<p style='color:#000000;'>" + (sdf.format(x)) + "</p>"); sb.append("<p style='color:#000000;'>" + dataset.getSeriesKey(series).toString() + ": " + form.format(dataset.getYValue(0, item)) + "</p>"); if (mr.getFileLineForDate(new Date(x.longValue()), dataset.getSeriesKey(series).toString()) != null) { sb.append( "<p style='color:#0000FF;'>" + cd.sourceFileArrayListMap .get(pairs.getKey()).get(mr .getFileLineForDate( new Date(x.longValue()), dataset.getSeriesKey(series) .toString()) .getFileId()) .getFile().getName() + ":" + mr.getFileLineForDate(new Date(x.longValue()), dataset.getSeriesKey(series).toString()) .getLineNumber() + "</p>"); } } return sb.toString(); } }; while (statMapIterator.hasNext()) { TimeSeriesCollection dataset = new TimeSeriesCollection(); String me = (String) statMapIterator.next(); ExtendedTimeSeries ts = (ExtendedTimeSeries) statMap.get(me); // logger.info(((TimeSeries) // me.getValue()).getMaxY()); if (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY() > 0) dataset.addSeries(ts.getTimeSeries()); logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me + " nb records: " + ((ExtendedTimeSeries) statMap.get(me)) .getTimeSeries().getItemCount()); logger.debug("(((TimeSeries) me.getValue()).getMaxY(): " + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY())); logger.debug("(((TimeSeries) me.getValue()).getMinY(): " + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY())); XYPlot plot1 = chart.getXYPlot(); // LogarithmicAxis axis4 = new LogarithmicAxis(me.toString()); NumberAxis axis4 = new NumberAxis(me.toString()); axis4.setAutoRange(true); axis4.setAxisLineVisible(true); axis4.setAutoRangeIncludesZero(false); plot1.setDomainCrosshairVisible(true); plot1.setRangeCrosshairVisible(true); axis4.setRange(new Range( ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY(), ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY())); axis4.setLabelPaint(colors[count]); axis4.setTickLabelPaint(colors[count]); plot1.setRangeAxis(count, axis4); final ValueAxis domainAxis = domainAxis1; domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot1.setDomainAxis(domainAxis); plot1.setForegroundAlpha(0.5f); plot1.setDataset(count, dataset); plot1.mapDatasetToRangeAxis(count, count); final XYAreaRenderer renderer = new XYAreaRenderer(); // XYAreaRenderer2 // also // nice if ((((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY() - ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries() .getMinY()) > 0) { // renderer.setToolTipGenerator(new // StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,new // FastDateFormat("d-MMM-yyyy HH:mm:ss"), // new DecimalFormat("#,##0.00"))); } renderer.setSeriesPaint(0, colors[count]); renderer.setSeriesVisible(0, true); renderer.setSeriesToolTipGenerator(0, tt1); plot1.setRenderer(count, renderer); int hits = 0; // ts.getStat()[1] int matchs = 0; if (((ExtendedTimeSeries) statMap.get(me)).getStat() != null) { hits = ((ExtendedTimeSeries) statMap.get(me)).getStat()[1]; // matchs= ((ExtendedTimeSeries) statMap.get(me)).getStat()[0]; } JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4, me.toString() + "(" + hits + ")", 0)); Boolean selected = true; jcb.setSelected(true); jcb.setBackground(Color.white); jcb.setBorderPainted(true); jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true)); jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize())); checkboxPanel.add(jcb); count++; } Iterator eventMapIterator = eventMap.entrySet().iterator(); while (eventMapIterator.hasNext()) { // HistogramDataset histoDataSet=new HistogramDataset(); TimeSeriesCollection dataset = new TimeSeriesCollection(); Map.Entry me = (Map.Entry) eventMapIterator.next(); // if (dataset.getEndXValue(series, item)) if (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY() > 0) dataset.addSeries(((ExtendedTimeSeries) me.getValue()).getTimeSeries()); logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me.getKey() + " nb records: " + ((ExtendedTimeSeries) me.getValue()).getTimeSeries().getItemCount()); logger.debug("mineResultSet hash content: " + mr.getEventTimeseriesMap()); logger.debug("(((TimeSeries) me.getValue()).getMaxY(): " + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY())); logger.debug("(((TimeSeries) me.getValue()).getMinY(): " + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMinY())); XYPlot plot2 = chart.getXYPlot(); // LogarithmicAxis axis4 = new LogarithmicAxis(me.toString()); NumberAxis axis4 = new NumberAxis(me.getKey().toString()); axis4.setAutoRange(true); // axis4.setInverted(true); axis4.setAxisLineVisible(true); axis4.setAutoRangeIncludesZero(true); // axis4.setRange(new Range(((TimeSeries) // axis4.setRange(new Range(((TimeSeries) // me.getValue()).getMinY(), ((TimeSeries) // me.getValue()).getMaxY())); axis4.setLabelPaint(colors[count]); axis4.setTickLabelPaint(colors[count]); plot2.setRangeAxis(count, axis4); final ValueAxis domainAxis = domainAxis1; // domainAxis.setLowerMargin(0.001); // domainAxis.setUpperMargin(0.0); plot2.setDomainCrosshairVisible(true); plot2.setRangeCrosshairVisible(true); //plot2.setRangeCrosshairLockedOnData(true); plot2.setDomainAxis(domainAxis); plot2.setForegroundAlpha(0.5f); plot2.setDataset(count, dataset); plot2.mapDatasetToRangeAxis(count, count); XYBarRenderer rend = new XYBarRenderer(); // XYErrorRenderer rend.setShadowVisible(false); rend.setDrawBarOutline(true); Stroke stroke = new BasicStroke(5); rend.setBaseStroke(stroke); final XYItemRenderer renderer = rend; renderer.setSeriesToolTipGenerator(0, tt1); // renderer.setItemLabelsVisible(true); renderer.setSeriesPaint(0, colors[count]); renderer.setSeriesVisible(0, true); plot2.setRenderer(count, renderer); int hits = 0; int matchs = 0; if (((ExtendedTimeSeries) me.getValue()).getStat() != null) { hits = ((ExtendedTimeSeries) me.getValue()).getStat()[1]; // matchs= ((ExtendedTimeSeries) me.getValue()).getStat()[0]; } JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4, me.getKey().toString() + "(" + hits + ")", 0)); jcb.setSelected(true); jcb.setBackground(Color.white); jcb.setBorderPainted(true); jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true)); jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize())); checkboxPanel.add(jcb); count++; } JPanel pan = new JPanel(); pan.setLayout(new BorderLayout()); pan.setPreferredSize(new Dimension(600, Integer.parseInt((String) Preferences.getPreference("chartSize")))); // pan.setPreferredSize(panelSize); panel.add(pan); final ChartPanel cpanel = new ChartPanel(chart); cpanel.setMinimumDrawWidth(0); cpanel.setMinimumDrawHeight(0); cpanel.setMaximumDrawWidth(1920); cpanel.setMaximumDrawHeight(1200); // cpanel.setInitialDelay(0); cpanel.setDismissDelay(9999999); cpanel.setInitialDelay(50); cpanel.setReshowDelay(200); cpanel.setPreferredSize(new Dimension(600, 350)); // cpanel.restoreAutoBounds(); fix the tooltip // missing problem but then relative display is // broken panel.add(new JSeparator(SwingConstants.HORIZONTAL)); pan.add(cpanel, BorderLayout.CENTER); // checkboxPanel.setPreferredSize(new Dimension(600, // 0)); cpanel.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent chartmouseevent) { // chartmouseevent.getEntity(). ChartEntity entity = chartmouseevent.getEntity(); if (entity instanceof XYItemEntity) { XYItemEntity item = ((XYItemEntity) entity); if (item.getDataset() instanceof TimeSeriesCollection) { TimeSeriesCollection data = (TimeSeriesCollection) item .getDataset(); TimeSeries series = data.getSeries(item.getSeriesIndex()); TimeSeriesDataItem dataitem = series.getDataItem(item.getItem()); // logger.info(" Serie: "+series.getKey().toString() // + // " Period : "+dataitem.getPeriod().toString()); // mr.getFileForDate(new Date // (x.longValue()) ; int x = chartmouseevent.getTrigger().getX(); // logger.info(mr.getFileForDate(dataitem.getPeriod().getEnd())); int y = chartmouseevent.getTrigger().getY(); String myString = ""; if (dataitem.getPeriod() != null) { logger.info(dataitem.getPeriod().getEnd()); // myString = mr.getFileForDate(dataitem.getPeriod().getEnd()).toString(); String lineString = "" + mr.getFileLineForDate(dataitem.getPeriod().getEnd(), item.getDataset() .getSeriesKey(item.getSeriesIndex()) .toString()) .getLineNumber(); String fileString = cd.sourceFileArrayListMap .get(pairs.getKey()) .get(mr.getFileLineForDate( dataitem.getPeriod().getEnd(), item.getDataset() .getSeriesKey(item.getSeriesIndex()) .toString()) .getFileId()) .getFile().getAbsolutePath(); String command = Preferences.getPreference("editorCommand"); command = command.replace("$line", lineString); command = command.replace("$file", fileString); logger.info(command); Runtime rt = Runtime.getRuntime(); try { rt.exec(command); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } StringSelection stringSelection = new StringSelection( fileString); Clipboard clpbrd = Toolkit.getDefaultToolkit() .getSystemClipboard(); clpbrd.setContents(stringSelection, null); // cpanel.getGraphics().drawString("file name copied", x - 5, y - 5); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch // block e.printStackTrace(); } } // logger.info(mr.getFileForDate(dataitem.getPeriod().getStart())); } } } public void chartMouseMoved(ChartMouseEvent e) { } }); pan.add(checkboxPanel, BorderLayout.SOUTH); } } } else { logger.debug("mr dates null: " + mr.getGroup() + mr.getSourceID() + mr.getLogFiles()); } } } } // Map=miner.mine(sourceFiles,repo); estimatedTime = System.currentTimeMillis() - startTime; revalidate(); logger.info("display time: " + estimatedTime); }
From source file:com.vgi.mafscaling.ClosedLoop.java
@Override public void actionPerformed(ActionEvent e) { if (checkActionPerformed(e)) return;/*from w w w.ja v a 2s. c o m*/ if ("dvdt".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearNotRunDataCheckboxes(); clearRunDataCheckboxes(); if (plotDvdtData()) checkBox.setSelected(true); } else runData.clear(); setRanges(); } else if ("iat".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearNotRunDataCheckboxes(); clearRunDataCheckboxes(); if (plotIatData()) checkBox.setSelected(true); } else runData.clear(); setRanges(); } else if ("trpm".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearNotRunDataCheckboxes(); clearRunDataCheckboxes(); if (plotTrimRpmData()) checkBox.setSelected(true); } else { runData.clear(); currMafData.clear(); } setRanges(); } else if ("mnmd".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearNotRunDataCheckboxes(); clearRunDataCheckboxes(); if (plotMeanModeData()) checkBox.setSelected(true); } else { currMafData.clear(); corrMafData.clear(); runData.clear(); } setRanges(); } else if ("corrdata".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearRunDataCheckboxes(); if (!plotCorrectionData()) checkBox.setSelected(false); } else runData.clear(); setRanges(); } else if ("current".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearRunDataCheckboxes(); if (!plotCurrentMafData()) checkBox.setSelected(false); } else currMafData.clear(); setRanges(); } else if ("corrected".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearRunDataCheckboxes(); if (!setCorrectedMafData()) checkBox.setSelected(false); } else corrMafData.clear(); setRanges(); } else if ("smoothed".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) { clearRunDataCheckboxes(); if (!setSmoothedMafData()) checkBox.setSelected(false); } else smoothMafData.clear(); setRanges(); } else if ("smoothing".equals(e.getActionCommand())) { JCheckBox checkBox = (JCheckBox) e.getSource(); if (checkBox.isSelected()) enableSmoothingView(true); else enableSmoothingView(false); setRanges(); } }
From source file:configuration.Util.java
public static void boxEventComboBox(workflow_properties properties, javax.swing.JCheckBox b, javax.swing.JComboBox s) { if (b == null) { properties.put(s.getName(), s);//from w w w.j a v a 2 s . c o m } else { if (b.isSelected() == true) { String i = (String) s.getSelectedItem(); if (s == null) { properties.put(b.getName(), b.isSelected()); } else { s.setEnabled(true); properties.put(s.getName(), i); properties.put(b.getName(), i); } } else { properties.remove(b.getName()); if (s != null) { s.setEnabled(false); } } } }
From source file:configuration.Util.java
public static void boxEventSpinner(workflow_properties properties, javax.swing.JCheckBox b, javax.swing.JSpinner s) { if (b == null) { properties.put(s.getName(), s.getValue()); } else {/* w ww . j a va 2s . c om*/ if (b.isSelected() == true) { if (s == null) { properties.put(b.getName(), b.isSelected()); } else { s.setEnabled(true); properties.put(s.getName(), s.getValue()); properties.put(b.getName(), s.getValue()); } } else { properties.remove(b.getName()); if (s != null) { s.setEnabled(false); } } } }
From source file:configuration.Util.java
public static void boxEventText(workflow_properties properties, javax.swing.JCheckBox b, javax.swing.JTextField t) { if (b == null) { properties.put(t.getName(), t.getText()); } else {// w ww . j a v a2 s . c o m if (b.isSelected() == true) { if (t == null) { properties.put(b.getName(), b.isSelected()); } else { t.setEnabled(true); properties.put(t.getName(), t.getText()); properties.put(b.getName(), t.getText()); } } else { properties.remove(b.getName()); if (t != null) { t.setEnabled(false); } } } }
From source file:gov.noaa.ncdc.iosp.avhrr.util.AvhrrLevel1B2Netcdf.java
public void handleOtherCheckbox(JCheckBox cb) { if (!cb.isSelected()) { allVarCheckBox.setSelected(false); } }
From source file:org.esa.snap.rcp.statistics.StatisticsPanel.java
private JPanel createAccuracyPanel() { final JPanel accuracyPanel = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); final JLabel label = new JLabel("Histogram accuracy:"); accuracyModel = new AccuracyModel(); final BindingContext bindingContext = new BindingContext( PropertyContainer.createObjectBacked(accuracyModel)); final SpinnerNumberModel accuracyNumberModel = new SpinnerNumberModel(accuracyModel.accuracy, 0, Util.MAX_ACCURACY, 1); final JSpinner accuracySpinner = new JSpinner(accuracyNumberModel); ((JSpinner.DefaultEditor) accuracySpinner.getEditor()).getTextField().setEditable(false); bindingContext.bind("accuracy", accuracySpinner); final JCheckBox checkBox = new JCheckBox("Auto accuracy"); bindingContext.bind("useAutoAccuracy", checkBox); final IntervalValidator rangeValidator = new IntervalValidator(new ValueRange(0, Util.MAX_ACCURACY)); final PropertyDescriptor accuracyDescriptor = bindingContext.getPropertySet().getDescriptor("accuracy"); accuracyDescriptor.setValidator(rangeValidator); checkBox.setSelected(accuracyModel.useAutoAccuracy); bindingContext.getPropertySet().getProperty("useAutoAccuracy") .addPropertyChangeListener(new PropertyChangeListener() { @Override// w ww . java 2 s .c om public void propertyChange(PropertyChangeEvent evt) { label.setEnabled(!checkBox.isSelected()); accuracySpinner.setEnabled(!checkBox.isSelected()); if (checkBox.isSelected()) { bindingContext.getBinding("accuracy").setPropertyValue(3); } computePanel.updateEnablement(); } }); label.setEnabled(false); accuracySpinner.setEnabled(false); accuracySpinner.setToolTipText("Specify the number of histogram bins (#bins: 10^accuracy)."); accuracySpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { computePanel.updateEnablement(); } }); GridBagUtils.addToPanel(accuracyPanel, new TitledSeparator("Histogram accuracy"), gbc, "fill=HORIZONTAL, weightx=1.0,anchor=NORTH,gridwidth=2"); GridBagUtils.addToPanel(accuracyPanel, checkBox, gbc, "gridy=1,insets.left=5,insets.top=2"); GridBagUtils.addToPanel(accuracyPanel, label, gbc, "gridy=2, insets.left=26,weightx=0.0,fill=NONE,anchor=WEST,gridwidth=1"); GridBagUtils.addToPanel(accuracyPanel, accuracySpinner, gbc, "gridx=1,weightx=1.0,fill=HORIZONTAL,insets.right=5,insets.left=5"); return accuracyPanel; }
From source file:com.xtructure.xevolution.gui.components.CollectArgsDialog.java
/** * Creates a new {@link CollectArgsDialog} * //from w w w. j a v a 2 s .c o m * @param frame * the parent JFrame for the new {@link CollectArgsDialog} * @param statusBar * the {@link StatusBar} to update (can be null) * @param title * the title of the new {@link CollectArgsDialog} * @param xOptions * the {@link Collection} of {@link XOption}s for which to * collect user input */ public CollectArgsDialog(JFrame frame, final StatusBar statusBar, String title, final Collection<XOption<?>> xOptions) { super(frame, title, true); argComponents = new ArrayList<JComponent>(); final CollectArgsDialog dialog = this; JPanel panel = new JPanel(new GridBagLayout()); getContentPane().add(panel); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(3, 3, 3, 3); c.fill = GridBagConstraints.BOTH; int row = 0; for (XOption<?> xOption : xOptions) { if (xOption.getName() == null) { continue; } if (xOption.hasArg()) { JLabel label = new JLabel(xOption.getName()); JTextField textField = new JTextField(); textField.setName(xOption.getOpt()); textField.setToolTipText(xOption.getDescription()); argComponents.add(textField); c.gridx = 0; c.gridy = row; panel.add(label, c); c.gridx = 1; c.gridy = row; panel.add(textField, c); } else { JCheckBox checkBox = new JCheckBox(xOption.getName()); checkBox.setName(xOption.getOpt()); checkBox.setToolTipText(xOption.getDescription()); argComponents.add(checkBox); c.gridx = 0; c.gridy = row; panel.add(checkBox, c); } row++; } JPanel buttonPanel = new JPanel(); c.gridx = 1; c.gridy = row; panel.add(buttonPanel, c); JButton okButton = new JButton(new AbstractAction("OK") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.setMessage("building args..."); } ArrayList<String> args = new ArrayList<String>(); for (JComponent component : argComponents) { if (component instanceof JCheckBox) { JCheckBox checkbox = (JCheckBox) component; String opt = checkbox.getName(); if (checkbox.isSelected()) { args.add("-" + opt); } } if (component instanceof JTextField) { JTextField textField = (JTextField) component; String opt = textField.getName(); String text = textField.getText().trim(); if (!text.isEmpty()) { args.add("-" + opt); args.add("\"" + text + "\""); } } } if (statusBar != null) { statusBar.setMessage("parsing args..."); } try { Options options = new Options(); for (XOption<?> xOpt : xOptions) { options.addOption(xOpt); } XOption.parseArgs(options, args.toArray(new String[0])); dialog.success = true; } catch (ParseException e1) { e1.printStackTrace(); dialog.success = false; } if (statusBar != null) { statusBar.clearMessage(); } } }); buttonPanel.add(okButton); getRootPane().setDefaultButton(okButton); buttonPanel.add(new JButton(new AbstractAction("Cancel") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (statusBar != null) { statusBar.clearMessage(); } } })); pack(); setLocationRelativeTo(frame); setVisible(true); }
From source file:EnvironmentExplorer.java
Box lightPanel() { Box panel = new Box(BoxLayout.Y_AXIS); // add the ambient light checkbox to the panel JCheckBox ambientCheckBox = new JCheckBox("Ambient Light"); ambientCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox checkbox = (JCheckBox) e.getSource(); lightAmbient.setEnable(checkbox.isSelected()); }/*from ww w.ja v a2s . c o m*/ }); ambientCheckBox.setSelected(true); panel.add(new LeftAlignComponent(ambientCheckBox)); String[] lightTypeValues = { "None", "Directional", "Positional", "Spot" }; IntChooser lightTypeChooser = new IntChooser("Light Type:", lightTypeValues); lightTypeChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { int value = event.getValue(); switch (value) { case 0: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 1: lightDirectional.setEnable(true); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 2: lightDirectional.setEnable(false); lightPoint.setEnable(true); lightSpot.setEnable(false); break; case 3: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(true); break; } } }); lightTypeChooser.setValueByName("Directional"); panel.add(lightTypeChooser); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Light attenuation:"))); FloatLabelJSlider constantSlider = new FloatLabelJSlider("Constant ", 0.1f, 0.0f, 3.0f, attenuation.x); constantSlider.setMajorTickSpacing(1.0f); constantSlider.setPaintTicks(true); constantSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.x = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(constantSlider); FloatLabelJSlider linearSlider = new FloatLabelJSlider("Linear ", 0.1f, 0.0f, 3.0f, attenuation.y); linearSlider.setMajorTickSpacing(1.0f); linearSlider.setPaintTicks(true); linearSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.y = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(linearSlider); FloatLabelJSlider quadradicSlider = new FloatLabelJSlider("Quadradic", 0.1f, 0.0f, 3.0f, attenuation.z); quadradicSlider.setMajorTickSpacing(1.0f); quadradicSlider.setPaintTicks(true); quadradicSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.z = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(quadradicSlider); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Spot light:"))); // spread angle is 0-180 degrees, no slider scaling FloatLabelJSlider spotSpreadSlider = new FloatLabelJSlider("Spread Angle ", 1.0f, 0.0f, 180.0f, spotSpreadAngle); spotSpreadSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotSpreadAngle = e.getValue(); lightSpot.setSpreadAngle((float) Math.toRadians(spotSpreadAngle)); } }); panel.add(spotSpreadSlider); // concentration angle is 0-128 degrees FloatLabelJSlider spotConcentrationSlider = new FloatLabelJSlider("Concentration", 1.0f, 0.0f, 128.0f, spotConcentration); spotConcentrationSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotConcentration = e.getValue(); lightSpot.setConcentration(spotConcentration); } }); panel.add(spotConcentrationSlider); return panel; }