List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:com.emental.mindraider.ui.outline.OutlineJPanel.java
/** * Creates notebook outline.//ww w . java 2s. co m */ private OutlineJPanel() { setDoubleBuffered(true); setLayout(new BorderLayout()); /* * toolbar */ JToolBar toolbar = createToolbar(); /* * tree */ // tree table itself outlineTableTree = OutlineTreeInstance.getInstance(); outlineTableTreeModel = new NotebookOutlineModel(outlineTableTree.getOutlineRoot()); treeTable = new JTreeTable(outlineTableTreeModel); treeTable.tree.addTreeSelectionListener(new TreeSelectionListenerImplementation()); // add key listener treeTable.addKeyListener(new KeyListenerImplementation()); // label column TableColumn tableColumn = treeTable .getColumn(NotebookOutlineModel.columnNames[NotebookOutlineModel.COLUMN_LABEL]); tableColumn.setMaxWidth(LABEL_COLUMN_MAX_WIDTH); tableColumn.setMinWidth(0); tableColumn.setPreferredWidth(LABEL_COLUMN_PREFERRED_WIDTH); // date column tableColumn = treeTable.getColumn(NotebookOutlineModel.columnNames[NotebookOutlineModel.COLUMN_CREATED]); tableColumn.setMaxWidth(DATE_COLUMN_MAX_WIDTH); tableColumn.setMinWidth(0); tableColumn.setPreferredWidth(DATE_COLUMN_PREFERRED_WIDTH); // and the rest will be annotation JScrollPane treeTableScrollPane = new JScrollPane(treeTable); // outline treetabble + toolbar panel JPanel treeAndToolbarPanel = new JPanel(new BorderLayout()); treeAndToolbarPanel.add(toolbar, BorderLayout.NORTH); treeAndToolbarPanel.add(treeTableScrollPane, BorderLayout.CENTER); /* * outline / list tabbed pane */ outlineAndTreeTabbedPane = new JTabbedPane(JTabbedPane.BOTTOM); outlineAndTreeTabbedPane.add(treeAndToolbarPanel, "Outline"); outlineSorterJPanel = new OutlineSorterJPanel(); outlineAndTreeTabbedPane.add(outlineSorterJPanel, "Sorter"); outlineArchiveJPanel = new OutlineArchiveJPanel(); outlineAndTreeTabbedPane.add(outlineArchiveJPanel, "Archive"); /* * concept sidebar */ conceptJPanel = (ConceptJPanel) MindRaiderSpringContext.getCtx().getBean("conceptPanel"); /* * vertical split of notebook outline and RDF graph */ treeAndSpidersSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); treeAndSpidersSplit.setContinuousLayout(true); treeAndSpidersSplit.setOneTouchExpandable(true); treeAndSpidersSplit.setDividerLocation(200); treeAndSpidersSplit.setLastDividerLocation(150); treeAndSpidersSplit.setDividerSize(6); treeAndSpidersSplit.add(outlineAndTreeTabbedPane); // spiders & tags visual navigation spidersAndTagsTabs = new JTabbedPane(JTabbedPane.BOTTOM); if (MindRaider.profile.isEnableSpiders()) { // notebook mind map spidersAndTagsTabs.addTab("Mind Map", MindRaider.spidersGraph.getPanel()); // TODO bundle } // global tags spidersAndTagsTabs.addTab("Tag Cloud", MindRaider.tagCustodian.getPanel()); // TODO bundle // global mind map //spidersAndTagsTabs.addTab("Global Mind Map",new JPanel()); // TODO bundle // lazy spiders rendering spidersAndTagsTabs.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); if (sourceTabbedPane.getSelectedIndex() == 0) { MindRaider.spidersGraph.renderModel(); } } }); if (!new ConfigurationBean().isDefaultTabMindMap()) { spidersAndTagsTabs.setSelectedIndex(1); } MindRaider.tagCustodian.redraw(); // add spiders panel treeAndSpidersSplit.add(spidersAndTagsTabs); /* * horizontal split of outline/graph slit and concept sidebar */ rightSiderbarSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeAndSpidersSplit, conceptJPanel); rightSiderbarSplitPane.setOneTouchExpandable(true); rightSiderbarSplitPane.setContinuousLayout(true); rightSiderbarSplitPane.setDividerLocation(500); rightSiderbarSplitPane.setLastDividerLocation(500); rightSiderbarSplitPane.setDividerSize(6); add(rightSiderbarSplitPane); }
From source file:de.tbuchloh.kiskis.gui.SecuredElementView.java
private void initDateField() { _dateField = new JCalendarComboBox(_element.getPwd().getExpires()); _dateField.setBorder(BorderFactory.createEmptyBorder()); _dateField.addChangeListener(new ChangeListener() { @Override//w w w . ja v a 2 s .c om public void stateChanged(final ChangeEvent e) { fireContentChangedEvent(true); } }); createNeverBox(); }
From source file:org.cds06.speleograph.graph.SeriesMenu.java
private JPopupMenu createPopupMenuForSeries(final Series series) { if (series == null) return new JPopupMenu(); final JPopupMenu menu = new JPopupMenu(series.getName()); menu.removeAll();/* w w w . j av a2 s .c o m*/ menu.add(new AbstractAction() { { putValue(NAME, "Renommer la srie"); } @Override public void actionPerformed(ActionEvent e) { menu.setVisible(false); String newName = ""; while (newName == null || newName.equals("")) { newName = (String) JOptionPane.showInputDialog(application, "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null, series.getName()); } series.setName(newName); } }); if (series.hasOwnAxis()) { menu.add(new AbstractAction() { { putValue(NAME, "Supprimer l'axe spcifique"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { series.setAxis(null); } } }); } else { menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, "Crer un axe spcifique pour la srie"); } @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?", series.getAxis().getLabel()); if (name == null || "".equals(name)) return; // User has canceled series.setAxis(new NumberAxis(name)); } })); } menu.add(new SetTypeMenu(series)); if (series.isWater()) { menu.addSeparator(); menu.add(new SumOnPeriodAction(series)); menu.add(new CreateCumulAction(series)); } if (series.isWaterCumul()) { menu.addSeparator(); menu.add(new SamplingAction(series)); } if (series.isPressure()) { menu.addSeparator(); menu.add(new CorrelateAction(series)); menu.add(new WaterHeightAction(series)); } menu.addSeparator(); menu.add(new AbstractAction() { { String name; if (series.canUndo()) name = "Annuler " + series.getItemsName(); else name = series.getLastUndoName(); putValue(NAME, name); if (series.canUndo()) setEnabled(true); else { setEnabled(false); } } @Override public void actionPerformed(ActionEvent e) { series.undo(); } }); menu.add(new AbstractAction() { { String name; if (series.canRedo()) { name = "Refaire " + series.getNextRedoName(); setEnabled(true); } else { name = series.getNextRedoName(); setEnabled(false); } putValue(NAME, name); } @Override public void actionPerformed(ActionEvent e) { series.redo(); } }); menu.add(new AbstractAction() { { putValue(NAME, I18nSupport.translate("menus.serie.resetSerie")); if (series.canUndo()) setEnabled(true); else setEnabled(false); } @Override public void actionPerformed(ActionEvent e) { series.reset(); } }); menu.add(new LimitDateRangeAction(series)); menu.add(new HourSettingAction(series)); menu.addSeparator(); { JMenuItem deleteItem = new JMenuItem("Supprimer la srie"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir supprimer cette srie ?\n" + "Cette action est dfinitive.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { series.delete(); } } }); menu.add(deleteItem); } menu.addSeparator(); { final JMenuItem up = new JMenuItem("Remonter dans la liste"), down = new JMenuItem("Descendre dans la liste"); ActionListener listener = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(up)) { series.upSeriesInList(); } else { series.downSeriesInList(); } } }; up.addActionListener(listener); down.addActionListener(listener); if (series.isFirst()) { menu.add(down); } else if (series.isLast()) { menu.add(up); } else { menu.add(up); menu.add(down); } } menu.addSeparator(); { menu.add(new SeriesInfoAction(series)); } { JMenuItem colorItem = new JMenuItem("Couleur de la srie"); colorItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { series.setColor(JColorChooser.showDialog(application, I18nSupport.translate("actions.selectColorForSeries"), series.getColor())); } }); menu.add(colorItem); } { JMenu plotRenderer = new JMenu("Affichage de la srie"); final ButtonGroup modes = new ButtonGroup(); java.util.List<DrawStyle> availableStyles; if (series.isMinMax()) { availableStyles = DrawStyles.getDrawableStylesForHighLow(); } else { availableStyles = DrawStyles.getDrawableStyles(); } for (final DrawStyle s : availableStyles) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s)); item.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (item.isSelected()) series.setStyle(s); } }); modes.add(item); if (s.equals(series.getStyle())) { modes.setSelected(item.getModel(), true); } plotRenderer.add(item); } menu.add(plotRenderer); } menu.addSeparator(); menu.add(new AbstractAction() { { putValue(Action.NAME, "Fermer le fichier"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { final File f = series.getOrigin(); for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) { if (s.getOrigin().equals(f)) s.delete(); } } } }); return menu; }
From source file:com.diversityarrays.kdxplore.scatterplot.ScatterPlotPanel.java
public ScatterPlotPanel(PlotInfoProvider infoProvider, VisualisationToolId<?> vtoolId, SelectedValueStore svs, String title, VisToolData data, Supplier<TraitColorProvider> colorProviderFactory, SuppressionHandler sh) {/*from w ww . j a v a 2s . com*/ super(title, vtoolId, svs, nextId++, data.traitInstances, data.context.getTrial(), sh); this.plotInfoProvider = infoProvider; if (data.plotSpecimensToGraph == null) { plotSpecimens = new ArrayList<>(); VisToolUtil.collectPlotSpecimens(plotInfoProvider.getPlots(), new Consumer<PlotOrSpecimen>() { @Override public void accept(PlotOrSpecimen pos) { plotSpecimens.add(pos); } }); } else { plotSpecimens = data.plotSpecimensToGraph; } List<List<Comparable<?>>> instanceValuesList = new ArrayList<>(); this.colorProviderFactory = colorProviderFactory; Function<TraitInstance, List<KdxSample>> sampleProvider = new Function<TraitInstance, List<KdxSample>>() { @Override public List<KdxSample> apply(TraitInstance ti) { return infoProvider.getSampleMeasurements(ti); } }; tivrByTi = VisToolUtil.buildTraitInstanceValueRetrieverMap(trial, traitInstances, sampleProvider); int plotLength = instanceValuesList.size(); if (plotLength < 3) { plotLength = 3; } xInstance = traitInstances.get(0); TraitInstance firstValueInstance = null; for (int i = 1; i < traitInstances.size(); i++) { TraitInstance ti = traitInstances.get(i); if (firstValueInstance == null) { firstValueInstance = ti; } valueInstances.add(ti); valueInstanceByTraitIdAndNumber.put(InstanceIdentifierUtil.getInstanceIdentifier(ti), ti); } xAxisName = traitNameStyle.makeTraitInstanceName(xInstance); if (traitInstances.size() == 2) { yAxisName = traitNameStyle.makeTraitInstanceName(firstValueInstance); } else { yAxisName = "Sample Measurement Value"; } chartPanel.addChartMouseListener(chartMouseListener); Bag<String> missingOrBad = new TreeBag<String>(); Bag<String> suppressed = new TreeBag<String>(); generateChart(true, missingOrBad, suppressed); ChangeListener listener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (!stillChanging) { clearExternallySelectedPlots(); setXYValues(); drawRectangle(); if (mouseDownPoint != null && mouseUpPoint != null) { buildMinMaxPoints(); setSelectedTraitAndMeasurements(); } } } }; minxSpinner.addChangeListener(listener); minySpinner.addChangeListener(listener); maxxSpinner.addChangeListener(listener); maxySpinner.addChangeListener(listener); stillChanging = true; minxModel.setValue(dataxMin); maxxModel.setValue(dataxMax); minyModel.setValue(datayMin); maxyModel.setValue(datayMax); minxModel.setMinimum(dataxMin); minxModel.setMaximum(dataxMax); minyModel.setMinimum(datayMin); minyModel.setMaximum(datayMax); maxxModel.setMinimum(dataxMin); maxxModel.setMaximum(dataxMax); maxyModel.setMinimum(datayMin); maxyModel.setMaximum(datayMax); stillChanging = false; Box hbox = Box.createHorizontalBox(); hbox.add(syncedOption); addSpinners(hbox, minxSpinner, minySpinner); hbox.add(new JLabel(" " + Msg.LABEL_MIN_TO_MAX_SEPARATOR() + " ")); //$NON-NLS-1$ //$NON-NLS-2$ addSpinners(hbox, maxxSpinner, maxySpinner); List<TraitInstance> curationControlInstances = traitInstances; curationControlInstances.remove(xInstance); curationControls = new CurationControls(true, // askAboutValueForUnscored suppressionHandler, selectedValueStore, // plotInfoProvider, toolPanelId, null, traitNameStyle, curationControlInstances); reportTextArea = new JTextArea(); reportTextArea.setEditable(false); tabMessages = Msg.TAB_MESSAGES(); tabCuration = Msg.TAB_CURATION(); tabbedPane.addTab(tabMessages, new JScrollPane(reportTextArea)); tabbedPane.addTab(tabCuration, curationControls); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabbedPane, chartPanel); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.0); add(splitPane, BorderLayout.CENTER); add(hbox, BorderLayout.SOUTH); splitPane.repaint(); // TODO why is this here? String msg = VisToolData.createReportText(missingOrBad, suppressed); if (Check.isEmpty(msg)) { tabbedPane.setSelectedIndex(tabbedPane.indexOfTab(tabCuration)); } else { reportTextArea.setText(msg); tabbedPane.setSelectedIndex(tabbedPane.indexOfTab(tabMessages)); } setPreferredSize(new Dimension(600, 500)); }
From source file:com.rapidminer.gui.properties.OperatorPropertyPanel.java
public OperatorPropertyPanel(final MainFrame mainFrame) { super();// w w w .j a va2 s . co m this.mainFrame = mainFrame; breakpointButton = new BreakpointButton(); headerLabel.setHorizontalAlignment(SwingConstants.CENTER); expertModeHintLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); expertModeHintLabel.setIcon(WARNING_ICON); expertModeHintLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { mainFrame.TOGGLE_EXPERT_MODE_ACTION.actionPerformed(null); } }); expertModeHintLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); expertModeHintLabel.setHorizontalAlignment(SwingConstants.LEFT); setupComponents(); compatibilityLevelSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { // compatibility level OperatorVersion[] versionChanges = operator.getIncompatibleVersionChanges(); // sort to have an ascending order Arrays.sort(versionChanges); if (versionChanges.length != 0) { OperatorVersion latestChange = versionChanges[versionChanges.length - 1]; if (latestChange.isAtLeast(operator.getCompatibilityLevel())) { compatibilityLabel.setIcon(WARNING_ICON); } else { compatibilityLabel.setIcon(SwingTools.createIcon("16/ok.png")); } } } }); showHelpAction = new ToggleAction(true, "show_parameter_help") { private static final long serialVersionUID = 1L; @Override public void actionToggled(ActionEvent e) { setShowParameterHelp(isSelected()); mainFrame.getPropertyPanel().setupComponents(); } }; }
From source file:jboost.visualization.HistogramFrame.java
private JSplitPane getJSplitPane1() { if (jSplitPane1 == null) { jSplitPane1 = new JSplitPane(); jSplitPane1.setPreferredSize(new Dimension(546, 400)); jSplitPane1.setDividerLocation(400); jSplitPane1.setDoubleBuffered(true); jSplitPane1.setLastDividerLocation(100); {/* w w w . j a va 2s. c o m*/ jPanel1 = new JPanel(); jSplitPane1.add(jPanel1, JSplitPane.RIGHT); jPanel1.setPreferredSize(new Dimension(10, 406)); BoxLayout jPanel1Layout = new BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS); jPanel1.setLayout(jPanel1Layout); { histogramDataset = new XYIntervalSeriesCollection(); fluctDataset = new XYIntervalSeriesCollection(); weightDataset = new XYSeriesCollection(); potentialDataset = new XYSeriesCollection(); updateHistogramDatasets(); histogramChart = createHistogramChart(); histogramPanel = new ChartPanel(histogramChart); jPanel1.add(histogramPanel); histogramPanel.setPopupMenu(null); histogramPanel.setPreferredSize(new Dimension(433, 374)); } } { jPanel2 = new JPanel(); jSplitPane1.add(jPanel2, JSplitPane.LEFT); jPanel2.setPreferredSize(new Dimension(10, 393)); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS); jPanel2.setLayout(jPanel2Layout); jPanel2.setOpaque(false); rocDataset = new XYSeriesCollection(); XYSeries rocSeries = rawData.generateRoC(negLabel, posLabel); rocDataset.addSeries(rocSeries); rocChart = createRocChart(rocDataset); rocPanel = new ChartPanel(rocChart); jPanel2.add(rocPanel); rocPanel.setPopupMenu(null); rocPanel.setPreferredSize(new Dimension(10, 406)); } { jSlider1 = new JSlider(); jPanel1.add(jSlider1); jSlider1.setLayout(null); jSlider1.setPreferredSize(new Dimension(10, 16)); jSlider1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { updateUpperMarker(); } }); } { jSlider2 = new JSlider(); jPanel1.add(jSlider2); jSlider2.setLayout(null); jSlider2.setPreferredSize(new Dimension(10, 16)); jSlider2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { updateLowerMarker(); } }); } } return jSplitPane1; }
From source file:com.diversityarrays.dal.server.ServerGui.java
public ServerGui(Image serverIconImage, IDalServer svr, DalServerFactory factory, File wwwRoot, DalServerPreferences prefs) {/*ww w. ja v a 2s .c om*/ this.serverIconImage = serverIconImage; this.dalServerFactory = factory; this.wwwRoot = wwwRoot; this.preferences = prefs; JMenuBar menuBar = new JMenuBar(); JMenu serverMenu = new JMenu("Server"); menuBar.add(serverMenu); serverMenu.add(serverStartAction); serverMenu.add(serverStopAction); serverMenu.add(exitAction); JMenu commandMenu = new JMenu("Command"); menuBar.add(commandMenu); commandMenu.add(doSql); JMenu urlMenu = new JMenu("URL"); menuBar.add(urlMenu); urlMenu.add(new JMenuItem(copyDalUrlAction)); urlMenu.add(new JMenuItem(showDalUrlQRcodeAction)); setJMenuBar(menuBar); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); messages.setFont(GuiUtil.createMonospacedFont(12)); messages.setEditable(false); setServer(svr); quietOption.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean q = quietOption.isSelected(); if (server != null) { server.setQuiet(q); } } }); JScrollPane scrollPane = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JButton clear = new JButton(new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { messages.setText(""); } }); final boolean[] follow = new boolean[] { true }; final JCheckBox followTail = new JCheckBox("Follow", follow[0]); followTail.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { follow[0] = followTail.isSelected(); } }); final OutputStream os = new OutputStream() { @Override public void write(int b) throws IOException { char ch = (char) b; messages.append(new Character(ch).toString()); if (ch == '\n' && follow[0]) { verticalScrollBar.setValue(verticalScrollBar.getMaximum()); } } }; TeePrintStream pso = new TeePrintStream(System.out, os); TeePrintStream pse = new TeePrintStream(System.err, os); System.setErr(pse); System.setOut(pso); Box box = Box.createHorizontalBox(); box.add(clear); box.add(followTail); box.add(quietOption); box.add(Box.createHorizontalGlue()); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(BorderLayout.NORTH, box); bottom.add(BorderLayout.SOUTH, statusInfoLine); Container cp = getContentPane(); cp.add(BorderLayout.CENTER, scrollPane); cp.add(BorderLayout.SOUTH, bottom); pack(); setSize(640, 480); final MemoryUsageMonitor mum = new MemoryUsageMonitor(); mum.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { statusInfoLine.setMessage(mum.getMemoryUsage()); } }); if (server == null) { // If initial server is null, allow user to specify addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); serverStartAction.actionPerformed(null); } }); } else { addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); ensureDatabaseInitialisedThenStartServer(); } }); } }
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/*from ww w .ja v a 2s. 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.diversityarrays.kdxplore.heatmap.HeatMapPanel.java
public HeatMapPanel(VisualisationTool vtool, int unique, SelectedValueStore svs, PlotInfoProvider pip, String title,//from w w w . j a va2 s . c o m HeatMapModelData<T> heatMapModelData, SuppressionHandler suppressionHandler) { super(title, svs, vtool.getVisualisationToolId(), unique, Arrays.asList(heatMapModelData.zTraitInstance), suppressionHandler); context = heatMapModelData.context; xValueRetriever = heatMapModelData.xValueRetriever; yValueRetriever = heatMapModelData.yValueRetriever; askAboutValueForUnscored = !ValueRetriever.isEitherOneXorY(xValueRetriever, yValueRetriever); traitInstanceValueRetriever = heatMapModelData.traitInstanceValueRetriever; this.zTraitInstance = heatMapModelData.zTraitInstance; // this.plotSpecimensByPoint = heatMapModelData.model.getCellLegend(); this.plotInfoProvider = pip; this.title = title; if (heatMapModelData.plotPointsByMark.isEmpty()) { markInfo = null; } else { markInfo = new MarkInfo(Msg.LABEL_MARK_INFO_PLOT_TYPE(), heatMapModelData.plotPointsByMark); } this.heatMap = createHeatMap(heatMapModelData); this.heatMap.addPropertyChangeListener(HeatMapPane.PROPERTY_SELECTION_CHANGE, heatMapPaneSelectionChangeListener); messagesTextArea.setEditable(false); tabbedPane.addTab(TAB_MESSAGES, new JScrollPane(messagesTextArea)); tabbedPane.addTab(TAB_CURATION, createCurationControls()); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabbedPane, heatMap); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.0); add(splitPane, BorderLayout.CENTER); int cellValueCount = heatMap.getValueModel().getUniqueCellValueCount(); Gradient[] gradients = Gradient.createBuiltins(cellValueCount); Gradient initial = null; for (Gradient g : gradients) { if (Gradient.RAINBOW_NAME.equals(g.getName())) { initial = g; break; } } gradientComboBox = new JComboBox<Gradient>(gradients); gradientComboBox.setRenderer(new GradientComboBoxRenderer()); gradientComboBox.addItemListener(gradientItemListener); // gradientItemListener will to model.setGradient() gradientComboBox.setSelectedItem(initial); Box box = Box.createHorizontalBox(); box.add(syncedOption); box.add(gradientComboBox); box.add(Box.createHorizontalGlue()); // if (RunMode.getRunMode().isDeveloper()) { // box.add(useBlankTilesOption); // } box.add(new JSeparator(JSeparator.VERTICAL)); box.add(opacityLabel); box.add(unselectedOpacitySpinner); add(box, BorderLayout.SOUTH); opacityLabel.setToolTipText("Sets the opacity of unselected cells"); unselectedOpacitySpinner.setToolTipText("Sets the opacity of unselected cells"); // useBlankTilesOption.setSelected(heatMap.getUseBlankTiles()); unselectedOpacityModel.setValue(heatMap.getUnselectedOpacity()); // useBlankTilesOption.addActionListener(new ActionListener() { // @Override // public void actionPerformed(ActionEvent e) { // handleUseBlankTilesChanged(); // } // }); unselectedOpacityModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { handleOpacityChange(); } }); updateMessagesWithMissingOrBad(null, heatMapModelData); applyDecoratorsToHeatMap(heatMapModelData); }
From source file:projects.wdlf47tuc.ProcessAllSwathcal.java
/** * Main entry point.//from w ww .jav a 2 s.com * * @param args * * @throws IOException * */ public ProcessAllSwathcal() { // Path to AllSwathcal.dat file File allSwathcal = new File( "/home/nrowell/Astronomy/Data/47_Tuc/Kalirai_2012/UVIS/www.stsci.edu/~jkalirai/47Tuc/AllSwathcal.dat"); // Read file contents into the List try (BufferedReader in = new BufferedReader(new FileReader(allSwathcal))) { String sourceStr; while ((sourceStr = in.readLine()) != null) { Source source = Source.parseSource(sourceStr); if (source != null) { allSources.add(source); } } } catch (IOException e) { } logger.info("Parsed " + allSources.size() + " Sources from AllSwathcal.dat"); // Initialise chart cmdPanel = new ChartPanel(updateDataAndPlotCmd(allSources)); cmdPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { // Capture mouse click location, transform to graph coordinates and add // a point to the polygonal selection box. Point2D p = cmdPanel.translateScreenToJava2D(e.getTrigger().getPoint()); Rectangle2D plotArea = cmdPanel.getScreenDataArea(); XYPlot plot = (XYPlot) cmdPanel.getChart().getPlot(); double chartX = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge()); double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge()); points.add(new double[] { chartX, chartY }); cmdPanel.setChart(plotCmd()); } @Override public void chartMouseMoved(ChartMouseEvent arg0) { } }); // Create colour combo boxes final JComboBox<Filter> magComboBox = new JComboBox<Filter>(filters); final JComboBox<Filter> col1ComboBox = new JComboBox<Filter>(filters); final JComboBox<Filter> col2ComboBox = new JComboBox<Filter>(filters); // Set initial values magComboBox.setSelectedItem(magFilter); col1ComboBox.setSelectedItem(col1Filter); col2ComboBox.setSelectedItem(col2Filter); // Create an action listener for these ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (evt.getSource() == magComboBox) { magFilter = (Filter) magComboBox.getSelectedItem(); } if (evt.getSource() == col1ComboBox) { col1Filter = (Filter) col1ComboBox.getSelectedItem(); } if (evt.getSource() == col2ComboBox) { col2Filter = (Filter) col2ComboBox.getSelectedItem(); } // Changed colour(s), so reset selection box coordinates points.clear(); cmdPanel.setChart(updateDataAndPlotCmd(allSources)); } }; magComboBox.addActionListener(al); col1ComboBox.addActionListener(al); col2ComboBox.addActionListener(al); // Add a bit of padding to space things out magComboBox.setBorder(new EmptyBorder(5, 5, 5, 5)); col1ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5)); col2ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5)); // Set up statistic sliders final JSlider magErrMaxSlider = GuiUtil.buildSlider(magErrorRangeMin, magErrorRangeMax, 3, "%3.3f"); final JSlider chi2MaxSlider = GuiUtil.buildSlider(chi2RangeMin, chi2RangeMax, 3, "%3.3f"); final JSlider sharpMinSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f"); final JSlider sharpMaxSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f"); // Set intial values magErrMaxSlider.setValue( (int) Math.rint(100.0 * (magErrMax - magErrorRangeMin) / (magErrorRangeMax - magErrorRangeMin))); chi2MaxSlider.setValue((int) Math.rint(100.0 * (chi2Max - chi2RangeMin) / (chi2RangeMax - chi2RangeMin))); sharpMinSlider .setValue((int) Math.rint(100.0 * (sharpMin - sharpRangeMin) / (sharpRangeMax - sharpRangeMin))); sharpMaxSlider .setValue((int) Math.rint(100.0 * (sharpMax - sharpRangeMin) / (sharpRangeMax - sharpRangeMin))); // Set labels & initial values final JLabel magErrMaxLabel = new JLabel(getMagErrMaxLabel()); final JLabel chi2MaxLabel = new JLabel(getChi2MaxLabel()); final JLabel sharpMinLabel = new JLabel(getSharpMinLabel()); final JLabel sharpMaxLabel = new JLabel(getSharpMaxLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == magErrMaxSlider) { // Compute max mag error from slider position double newMagErrMax = magErrorRangeMin + (magErrorRangeMax - magErrorRangeMin) * (source.getValue() / 100.0); magErrMax = newMagErrMax; magErrMaxLabel.setText(getMagErrMaxLabel()); } if (source == chi2MaxSlider) { // Compute Chi2 max from slider position double newChi2Max = chi2RangeMin + (chi2RangeMax - chi2RangeMin) * (source.getValue() / 100.0); chi2Max = newChi2Max; chi2MaxLabel.setText(getChi2MaxLabel()); } if (source == sharpMinSlider) { // Compute sharp min from slider position double newSharpMin = sharpRangeMin + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0); sharpMin = newSharpMin; sharpMinLabel.setText(getSharpMinLabel()); } if (source == sharpMaxSlider) { // Compute sharp max from slider position double newSharpMax = sharpRangeMin + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0); sharpMax = newSharpMax; sharpMaxLabel.setText(getSharpMaxLabel()); } cmdPanel.setChart(updateDataAndPlotCmd(allSources)); } }; magErrMaxSlider.addChangeListener(cl); chi2MaxSlider.addChangeListener(cl); sharpMinSlider.addChangeListener(cl); sharpMaxSlider.addChangeListener(cl); // Add a bit of padding to space things out magErrMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); chi2MaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); sharpMinSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); sharpMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Text field to store distance modulus final JTextField distanceModulusField = new JTextField(Double.toString(mu)); distanceModulusField.setBorder(new EmptyBorder(5, 5, 5, 5)); Border compound = BorderFactory.createCompoundBorder(new LineBorder(this.getBackground(), 5), BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); final JButton lfButton = new JButton("Luminosity function for selection"); lfButton.setBorder(compound); lfButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Read distance modulus field try { double mu_new = Double.parseDouble(distanceModulusField.getText()); mu = mu_new; } catch (NullPointerException | NumberFormatException ex) { JOptionPane.showMessageDialog(lfButton, "Error parsing the distance modulus: " + ex.getMessage(), "Distance Modulus Error", JOptionPane.ERROR_MESSAGE); return; } if (boxedSources.isEmpty()) { JOptionPane.showMessageDialog(lfButton, "No sources are currently selected!", "Selection Error", JOptionPane.ERROR_MESSAGE); } else { computeAndPlotLuminosityFunction(boxedSources); } } }); final JButton clearSelectionButton = new JButton("Clear selection"); clearSelectionButton.setBorder(compound); clearSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { points.clear(); cmdPanel.setChart(plotCmd()); } }); JPanel controls = new JPanel(new GridLayout(9, 2)); controls.setBorder(new EmptyBorder(10, 10, 10, 10)); controls.add(new JLabel("Magnitude = ")); controls.add(magComboBox); controls.add(new JLabel("Colour 1 = ")); controls.add(col1ComboBox); controls.add(new JLabel("Colour 2 = ")); controls.add(col2ComboBox); controls.add(magErrMaxLabel); controls.add(magErrMaxSlider); controls.add(chi2MaxLabel); controls.add(chi2MaxSlider); controls.add(sharpMinLabel); controls.add(sharpMinSlider); controls.add(sharpMaxLabel); controls.add(sharpMaxSlider); controls.add(new JLabel("Adopted distance modulus = ")); controls.add(distanceModulusField); controls.add(lfButton); controls.add(clearSelectionButton); this.setLayout(new BorderLayout()); this.add(cmdPanel, BorderLayout.CENTER); this.add(controls, BorderLayout.SOUTH); this.validate(); }