List of usage examples for javax.swing.event ChangeEvent getSource
public Object getSource()
From source file:blue.components.lines.Line.java
public void stateChanged(ChangeEvent e) { LinePoint lp = (LinePoint) e.getSource(); int index = points.indexOf(lp); if (index >= 0) { fireTableRowsUpdated(index, index); }//from ww w. j a v a 2 s .c o m }
From source file:greenfoot.gui.export.ExportPublishPane.java
/** * Of interest is the state of the keep scenario checkbox as that * determines whether the image panel is enabled or disabled *///from w ww .j a va2s .co m @Override public void stateChanged(ChangeEvent e) { if (e.getSource().equals(keepScenarioScreenshot)) { if (keepScenarioScreenshot.isSelected()) { imagePanel.enableImageEditPanel(false); } else { imagePanel.enableImageEditPanel(true); } } }
From source file:com.github.fritaly.dualcommander.DualCommander.java
@Override public void stateChanged(ChangeEvent e) { // Event fired when the pane's user selection changes if (e.getSource() == this.leftPane) { // Update the buttons based on the current selection refreshButtons(this.leftPane.getActiveBrowser().getSelection()); } else if (e.getSource() == this.rightPane) { // Update the buttons based on the current selection refreshButtons(this.rightPane.getActiveBrowser().getSelection()); }/* w w w. java 2 s . com*/ }
From source file:apidemo.PanScrollZoomDemo.java
/** * Handles a {@link ChangeEvent} (in this case, coming from the scrollbar). * /*from ww w. j a v a 2s. co m*/ * @param event the event. */ public void stateChanged(final ChangeEvent event) { try { final Object src = event.getSource(); final BoundedRangeModel scrollBarModel = this.scrollBar.getModel(); if (src == scrollBarModel) { final int val = scrollBarModel.getValue(); final int ext = scrollBarModel.getExtent(); final Plot plot = this.chartPanel.getChart().getPlot(); if (plot instanceof XYPlot) { final XYPlot hvp = (XYPlot) plot; final ValueAxis axis = hvp.getDomainAxis(); // avoid problems this.chartPanel.getChart().removeChangeListener(this); axis.setRange(val / this.scrollFactor, (val + ext) / this.scrollFactor); // restore chart listener this.chartPanel.getChart().addChangeListener(this); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:de.tor.tribes.ui.algo.AttackTimePanel.java
private void fireValidityStateChangedEvent(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fireValidityStateChangedEvent if (evt.getSource() == jDayButton) { dateTimeField.setEnabled(true);/* w ww . j av a 2 s. c o m*/ dateTimeField.setTimeEnabled(false); jSendTimeFrame.setEnabled(true); } else if (evt.getSource() == jAlwaysButton) { dateTimeField.setEnabled(false); jSendTimeFrame.setEnabled(true); } else if (evt.getSource() == jExactTimeButton) { dateTimeField.setEnabled(true); dateTimeField.setTimeEnabled(true); jSendTimeFrame.setEnabled(false); } updatePreview(); }
From source file:org.ash.detail.DetailPanels.java
/** * Initialize DetailFrame//from w ww . j a v a 2 s . co m */ private void initialize() { this.setLayout(new BorderLayout()); this.setVisible(true); this.cpuSplitPaneMainDetail = new JSplitPane(); this.schedulerSplitPaneMainDetail = new JSplitPane(); this.userIOSplitPaneMainDetail = new JSplitPane(); this.systemIOSplitPaneMainDetail = new JSplitPane(); this.concurrencySplitPaneMainDetail = new JSplitPane(); this.applicationSplitPaneMainDetail = new JSplitPane(); this.commitSplitPaneMainDetail = new JSplitPane(); this.configurationSplitPaneMainDetail = new JSplitPane(); this.administrativeSplitPaneMainDetail = new JSplitPane(); this.networkSplitPaneMainDetail = new JSplitPane(); this.queuningSplitPaneMainDetail = new JSplitPane(); this.clusterSplitPaneMainDetail = new JSplitPane(); this.otherSplitPaneMainDetail = new JSplitPane(); this.cpuChartPanel = this.cpuStackedChartMainObjectDetail.createChartPanel(); this.schedulerChartPanel = this.schedulerStackedChartMainObjectDetail.createChartPanel(); this.userIOChartPanel = this.userIOStackedChartMainObjectDetail.createChartPanel(); this.systemIOChartPanel = this.systemIOStackedChartMainObjectDetail.createChartPanel(); this.concurrencyChartPanel = this.concurrencyStackedChartMainObjectDetail.createChartPanel(); this.applicationChartPanel = this.applicationStackedChartMainObjectDetail.createChartPanel(); this.commitChartPanel = this.commitStackedChartMainObjectDetail.createChartPanel(); this.configurationChartPanel = this.configurationStackedChartMainObjectDetail.createChartPanel(); this.administrativeChartPanel = this.administrativeStackedChartMainObjectDetail.createChartPanel(); this.networkChartPanel = this.networkStackedChartMainObjectDetail.createChartPanel(); this.queuningChartPanel = this.queuningStackedChartMainObjectDetail.createChartPanel(); this.clusterChartPanel = this.clusterStackedChartMainObjectDetail.createChartPanel(); this.otherChartPanel = this.otherStackedChartMainObjectDetail.createChartPanel(); /** Gantt graph */ this.cpuSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("cpuLabel.text")); this.schedulerSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("schedulerLabel.text")); this.userIOSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("userIOLabel.text")); this.systemIOSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("systemIOLabel.text")); this.concurrencySqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("concurrencyLabel.text")); this.applicationSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("applicationsLabel.text")); this.commitSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("commitLabel.text")); this.configurationSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("configurationLabel.text")); this.administrativeSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("administrativeLabel.text")); this.networkSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("networkLabel.text")); this.queuningSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("queueningLabel.text")); this.clusterSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("clusterLabel.text")); this.otherSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("otherLabel.text")); this.cpuSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.cpuSplitPaneMainDetail.add(this.cpuChartPanel, "top"); this.cpuSplitPaneMainDetail.add(this.cpuSqlsAndSessions, "bottom"); this.cpuSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.cpuSplitPaneMainDetail.setOneTouchExpandable(true); this.schedulerSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.schedulerSplitPaneMainDetail.add(this.schedulerChartPanel, "top"); this.schedulerSplitPaneMainDetail.add(this.schedulerSqlsAndSessions, "bottom"); this.schedulerSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.schedulerSplitPaneMainDetail.setOneTouchExpandable(true); this.userIOSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.userIOSplitPaneMainDetail.add(this.userIOChartPanel, "top"); this.userIOSplitPaneMainDetail.add(this.userIOSqlsAndSessions, "bottom"); this.userIOSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.userIOSplitPaneMainDetail.setOneTouchExpandable(true); this.systemIOSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.systemIOSplitPaneMainDetail.add(this.systemIOChartPanel, "top"); this.systemIOSplitPaneMainDetail.add(this.systemIOSqlsAndSessions, "bottom"); this.systemIOSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.systemIOSplitPaneMainDetail.setOneTouchExpandable(true); this.concurrencySplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.concurrencySplitPaneMainDetail.add(this.concurrencyChartPanel, "top"); this.concurrencySplitPaneMainDetail.add(this.concurrencySqlsAndSessions, "bottom"); this.concurrencySplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.concurrencySplitPaneMainDetail.setOneTouchExpandable(true); this.applicationSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.applicationSplitPaneMainDetail.add(this.applicationChartPanel, "top"); this.applicationSplitPaneMainDetail.add(this.applicationSqlsAndSessions, "bottom"); this.applicationSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.applicationSplitPaneMainDetail.setOneTouchExpandable(true); this.commitSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.commitSplitPaneMainDetail.add(this.commitChartPanel, "top"); this.commitSplitPaneMainDetail.add(this.commitSqlsAndSessions, "bottom"); this.commitSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.commitSplitPaneMainDetail.setOneTouchExpandable(true); this.configurationSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.configurationSplitPaneMainDetail.add(this.configurationChartPanel, "top"); this.configurationSplitPaneMainDetail.add(this.configurationSqlsAndSessions, "bottom"); this.configurationSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.configurationSplitPaneMainDetail.setOneTouchExpandable(true); this.administrativeSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.administrativeSplitPaneMainDetail.add(this.administrativeChartPanel, "top"); this.administrativeSplitPaneMainDetail.add(this.administrativeSqlsAndSessions, "bottom"); this.administrativeSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.administrativeSplitPaneMainDetail.setOneTouchExpandable(true); this.networkSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.networkSplitPaneMainDetail.add(this.networkChartPanel, "top"); this.networkSplitPaneMainDetail.add(this.networkSqlsAndSessions, "bottom"); this.networkSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.networkSplitPaneMainDetail.setOneTouchExpandable(true); this.queuningSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.queuningSplitPaneMainDetail.add(this.queuningChartPanel, "top"); this.queuningSplitPaneMainDetail.add(this.queuningSqlsAndSessions, "bottom"); this.queuningSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.queuningSplitPaneMainDetail.setOneTouchExpandable(true); this.clusterSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.clusterSplitPaneMainDetail.add(this.clusterChartPanel, "top"); this.clusterSplitPaneMainDetail.add(this.clusterSqlsAndSessions, "bottom"); this.clusterSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.clusterSplitPaneMainDetail.setOneTouchExpandable(true); this.otherSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.otherSplitPaneMainDetail.add(this.otherChartPanel, "top"); this.otherSplitPaneMainDetail.add(this.otherSqlsAndSessions, "bottom"); this.otherSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.otherSplitPaneMainDetail.setOneTouchExpandable(true); this.tabsDetail.add(this.cpuSplitPaneMainDetail, Options.getInstance().getResource("cpuLabel.text")); this.tabsDetail.add(this.schedulerSplitPaneMainDetail, Options.getInstance().getResource("schedulerLabel.text")); this.tabsDetail.add(this.userIOSplitPaneMainDetail, Options.getInstance().getResource("userIOLabel.text")); this.tabsDetail.add(this.systemIOSplitPaneMainDetail, Options.getInstance().getResource("systemIOLabel.text")); this.tabsDetail.add(this.concurrencySplitPaneMainDetail, Options.getInstance().getResource("concurrencyLabel.text")); this.tabsDetail.add(this.applicationSplitPaneMainDetail, Options.getInstance().getResource("applicationsLabel.text")); this.tabsDetail.add(this.commitSplitPaneMainDetail, Options.getInstance().getResource("commitLabel.text")); this.tabsDetail.add(this.configurationSplitPaneMainDetail, Options.getInstance().getResource("configurationLabel.text")); this.tabsDetail.add(this.administrativeSplitPaneMainDetail, Options.getInstance().getResource("administrativeLabel.text")); this.tabsDetail.add(this.networkSplitPaneMainDetail, Options.getInstance().getResource("networkLabel.text")); this.tabsDetail.add(this.queuningSplitPaneMainDetail, Options.getInstance().getResource("queueningLabel.text")); this.tabsDetail.add(this.clusterSplitPaneMainDetail, Options.getInstance().getResource("clusterLabel.text")); this.tabsDetail.add(this.otherSplitPaneMainDetail, Options.getInstance().getResource("otherLabel.text")); this.cpuChartPanel.addListenerReleaseMouse(this.cpuSqlsAndSessions); this.schedulerChartPanel.addListenerReleaseMouse(this.schedulerSqlsAndSessions); this.userIOChartPanel.addListenerReleaseMouse(this.userIOSqlsAndSessions); this.systemIOChartPanel.addListenerReleaseMouse(this.systemIOSqlsAndSessions); this.concurrencyChartPanel.addListenerReleaseMouse(this.concurrencySqlsAndSessions); this.applicationChartPanel.addListenerReleaseMouse(this.applicationSqlsAndSessions); this.commitChartPanel.addListenerReleaseMouse(this.commitSqlsAndSessions); this.configurationChartPanel.addListenerReleaseMouse(this.configurationSqlsAndSessions); this.administrativeChartPanel.addListenerReleaseMouse(this.administrativeSqlsAndSessions); this.networkChartPanel.addListenerReleaseMouse(this.networkSqlsAndSessions); this.queuningChartPanel.addListenerReleaseMouse(this.queuningSqlsAndSessions); this.clusterChartPanel.addListenerReleaseMouse(this.clusterSqlsAndSessions); this.otherChartPanel.addListenerReleaseMouse(this.otherSqlsAndSessions); this.cpuChartPanel.addListenerReleaseMouse(this.statusBar); this.schedulerChartPanel.addListenerReleaseMouse(this.statusBar); this.userIOChartPanel.addListenerReleaseMouse(this.statusBar); this.systemIOChartPanel.addListenerReleaseMouse(this.statusBar); this.concurrencyChartPanel.addListenerReleaseMouse(this.statusBar); this.applicationChartPanel.addListenerReleaseMouse(this.statusBar); this.commitChartPanel.addListenerReleaseMouse(this.statusBar); this.configurationChartPanel.addListenerReleaseMouse(this.statusBar); this.administrativeChartPanel.addListenerReleaseMouse(this.statusBar); this.networkChartPanel.addListenerReleaseMouse((Object) this.statusBar); this.queuningChartPanel.addListenerReleaseMouse((Object) this.statusBar); this.clusterChartPanel.addListenerReleaseMouse((Object) this.statusBar); this.otherChartPanel.addListenerReleaseMouse((Object) this.statusBar); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); int index = sourceTabbedPane.getSelectedIndex(); statusBar.updateLabelStringDetail(sourceTabbedPane.getTitleAt(index)); } }; tabsDetail.addChangeListener(changeListener); this.add(tabsDetail, BorderLayout.CENTER); }
From source file:com.entertailion.java.fling.FlingFrame.java
public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting() && !playbackValueIsAdjusting) { int position = (int) source.getValue(); if (position == 0) { rampClient.play(0);//from w w w . j ava2 s. c om } else { rampClient.play((int) (position / 100.0f * duration)); } } }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.ClusteringControl.java
public void init() { maxCluster = state.growingLayer.getXSize() * state.growingLayer.getYSize(); spinnerNoCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1)); spinnerNoCluster.addChangeListener(new ChangeListener() { @Override/*from w w w . j a v a 2 s .com*/ public void stateChanged(ChangeEvent e) { numClusters = (Integer) ((JSpinner) e.getSource()).getValue(); SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree() .getAllClusteringElements(); if (m.containsKey(numClusters)) { st = m.get(numClusters).sticky; } else { st = false; } sticky.setSelected(st); redrawClustering(); } }); JPanel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters"); sticky.setToolTipText( "Marks this number of clusters as sticky for a certain leve; the next set of clusters will have a smaller boundary"); sticky.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { st = sticky.isSelected(); SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree() .getAllClusteringElements(); if (m.containsKey(numClusters)) { ClusterElementsStorage c = m.get(numClusters); c.sticky = st; // System.out.println("test"); // ((ClusterElementsStorageNode)m.get(numClusters)).sticky = st; redrawClustering(); } } }); colorCluster = new JCheckBox("colour", state.colorClusters); colorCluster.setToolTipText("Fill the clusters in colours"); colorCluster.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.colorClusters = colorCluster.isSelected(); // TODO: Palette anzeigen (?) redrawClustering(); } }); UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerNoCluster, sticky, colorCluster); getContentPane().add(clusterPanel, c.nextRow()); dendogramPanel = UiUtils.makeBorderedPanel(new GridLayout(0, 1), "Dendogram"); getContentPane().add(dendogramPanel, c.nextRow()); JPanel numLabelPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Labels"); GridBagConstraintsIFS gcLabels = new GridBagConstraintsIFS(); labelSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1)); labelSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { numLabels = (Integer) ((JSpinner) e.getSource()).getValue(); state.clusterWithLabels = numLabels; redrawClustering(); } }); this.showValues = new JCheckBox("values", state.labelsWithValues); this.showValues.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.labelsWithValues = showValues.isSelected(); redrawClustering(); } }); int start = new Double((1 - state.clusterByValue) * 100).intValue(); valueQe = new JSlider(0, 100, start); valueQe.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int byValue = ((JSlider) e.getSource()).getValue(); state.clusterByValue = 1 - byValue / 100; redrawClustering(); } }); numLabelPanel.add(new JLabel("# Labels"), gcLabels); numLabelPanel.add(labelSpinner, gcLabels.nextCol()); numLabelPanel.add(showValues, gcLabels.nextCol()); numLabelPanel.add(valueQe, gcLabels.nextRow().setGridWidth(3).setFill(GridBagConstraints.HORIZONTAL)); getContentPane().add(numLabelPanel, c.nextRow()); Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); labelTable.put(0, new JLabel("by Value")); labelTable.put(100, new JLabel("by Qe")); valueQe.setToolTipText("Method how to select representative labels - by QE, or the attribute values"); valueQe.setLabelTable(labelTable); valueQe.setPaintLabels(true); final JComboBox initialisationBox = new JComboBox(KMeans.InitType.values()); initialisationBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object o = mapPane.getMap().getClusteringTreeBuilder(); if (o instanceof KMeansTreeBuilder) { ((KMeansTreeBuilder) o).reInit((KMeans.InitType) initialisationBox.getSelectedItem()); // FIXME: is this call needed? mapPane.getMap().getCurrentClusteringTree().getAllClusteringElements(); redrawClustering(); } } }); getContentPane().add(UiUtils.fillPanel(kmeansInitialisationPanel, new JLabel("k-Means initialisation"), initialisationBox), c.nextRow()); JPanel borderPanel = new TitledCollapsiblePanel("Border", new GridLayout(1, 4), true); JSpinner borderSpinner = new JSpinner( new SpinnerNumberModel(ClusteringTree.INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR, 0.1, 5, 0.1)); borderSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { state.clusterBorderWidthMagnificationFactor = ((Double) ((JSpinner) e.getSource()).getValue()) .floatValue(); redrawClustering(); } }); borderPanel.add(new JLabel("width")); borderPanel.add(borderSpinner); borderPanel.add(new JLabel("colour")); buttonColour = new JButton(""); buttonColour.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new ClusterBoderColorChooser(state.parentFrame, state.clusterBorderColour, ClusteringControl.this); } }); buttonColour.setBackground(state.clusterBorderColour); borderPanel.add(buttonColour); getContentPane().add(borderPanel, c.nextRow()); JPanel evaluationPanel = new TitledCollapsiblePanel("Cluster Evaluation", new GridLayout(3, 2), true); evaluationPanel.add(new JLabel("quality measure")); qualityMeasureButton = new JButton(); qualityMeasureButton.setText("ent/pur calc"); qualityMeasureButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("doing entropy here"); ClusteringTree clusteringTree = state.mapPNode.getClusteringTree(); if (clusteringTree == null) { // we have not clustered yet return; } // System.out.println(clusteringTree.getChildrenCount()); // FIXME put this in a method and call it on numcluster.change() SOMLibClassInformation classInfo = state.inputDataObjects.getClassInfo(); ArrayList<ClusterNode> clusters = clusteringTree.getNodesAtLevel(numClusters); System.out.println(clusters.size()); // EntropyMeasure.computeEntropy(clusters, classInfo); EntropyAndPurityCalculator eapc = new EntropyAndPurityCalculator(clusters, classInfo); // FIXME round first entropyLabel.setText(String.valueOf(eapc.getEntropy())); purityLabel.setText(String.valueOf(eapc.getPurity())); } }); evaluationPanel.add(qualityMeasureButton); GridBagConstraintsIFS gcEval = new GridBagConstraintsIFS(); evaluationPanel.add(new JLabel("entropy"), gcEval); evaluationPanel.add(new JLabel("purity"), gcEval.nextCol()); entropyLabel = new JLabel("n/a"); purityLabel = new JLabel("n/a"); evaluationPanel.add(entropyLabel, gcEval.nextRow()); evaluationPanel.add(purityLabel, gcEval.nextCol()); getContentPane().add(evaluationPanel, c.nextRow()); JPanel panelButtons = new JPanel(new GridLayout(1, 4)); JButton saveButton = new JButton("Save"); saveButton.setFont(smallFont); saveButton.setMargin(SMALL_INSETS); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser; if (state.fileChooser.getSelectedFile() != null) { fileChooser = new JFileChooser(state.fileChooser.getSelectedFile().getPath()); } else { fileChooser = new JFileChooser(); } fileChooser.addChoosableFileFilter(clusteringFilter); fileChooser.addChoosableFileFilter(xmlFilter); File filePath = ExportUtils.getFilePath(ClusteringControl.this, fileChooser, "Save Clustering and Labels"); if (filePath != null) { if (xmlFilter.accept(filePath)) { LabelXmlUtils.saveLabelsToFile(state.mapPNode, filePath); } else { try { FileOutputStream fos = new FileOutputStream(filePath); GZIPOutputStream gzipOs = new GZIPOutputStream(fos); PObjectOutputStream oos = new PObjectOutputStream(gzipOs); oos.writeObjectTree(mapPane.getMap().getCurrentClusteringTree()); oos.writeObjectTree(mapPane.getMap().getManualLabels()); oos.writeInt(state.clusterWithLabels); oos.writeBoolean(state.labelsWithValues); oos.writeDouble(state.clusterByValue); oos.writeObject(spinnerNoCluster.getValue()); oos.close(); } catch (Exception ex) { ex.printStackTrace(); } } // keep the selected path for future references state.fileChooser.setSelectedFile(filePath.getParentFile()); } } }); panelButtons.add(saveButton); JButton loadButton = new JButton("Load"); loadButton.setFont(smallFont); loadButton.setMargin(SMALL_INSETS); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = getFileChooser(); fileChooser.setName("Open Clustering"); fileChooser.addChoosableFileFilter(xmlFilter); fileChooser.addChoosableFileFilter(clusteringFilter); int returnVal = fileChooser.showDialog(ClusteringControl.this, "Open"); if (returnVal == JFileChooser.APPROVE_OPTION) { File filePath = fileChooser.getSelectedFile(); if (xmlFilter.accept(filePath)) { PNode restoredLabels = null; try { restoredLabels = LabelXmlUtils.restoreLabelsFromFile(fileChooser.getSelectedFile()); PNode manual = state.mapPNode.getManualLabels(); ArrayList<PNode> tmp = new ArrayList<PNode>(); for (ListIterator<?> iter = restoredLabels.getChildrenIterator(); iter.hasNext();) { PNode element = (PNode) iter.next(); tmp.add(element); } manual.addChildren(tmp); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Successfully loaded cluster labels."); } catch (Exception e1) { e1.printStackTrace(); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Error loading cluster labels: " + e1.getMessage()); } } else { try { FileInputStream fis = new FileInputStream(filePath); GZIPInputStream gzipIs = new GZIPInputStream(fis); ObjectInputStream ois = new ObjectInputStream(gzipIs); ClusteringTree tree = (ClusteringTree) ois.readObject(); PNode manual = (PNode) ois.readObject(); PNode all = mapPane.getMap().getManualLabels(); ArrayList<PNode> tmp = new ArrayList<PNode>(); for (ListIterator<?> iter = manual.getChildrenIterator(); iter.hasNext();) { PNode element = (PNode) iter.next(); tmp.add(element); } all.addChildren(tmp); state.clusterWithLabels = ois.readInt(); labelSpinner.setValue(state.clusterWithLabels); state.labelsWithValues = ois.readBoolean(); showValues.setSelected(state.labelsWithValues); state.clusterByValue = ois.readDouble(); valueQe.setValue(new Double((1 - state.clusterByValue) * 100).intValue()); mapPane.getMap().buildTree(tree); spinnerNoCluster.setValue(ois.readObject()); ois.close(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Successfully loaded clustering."); } catch (Exception ex) { ex.printStackTrace(); Logger.getLogger("at.tuwien.ifs.somtoolbox") .info("Error loading clustering: " + ex.getMessage()); } } // keep the selected path for future references state.fileChooser.setSelectedFile(filePath.getParentFile()); } } }); panelButtons.add(loadButton); JButton exportImages = new JButton("Export"); exportImages.setFont(smallFont); exportImages.setMargin(SMALL_INSETS); exportImages.setToolTipText("Export labels as images (not yet working)"); exportImages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); if (CommonSOMViewerStateData.fileNamePrefix != null && !CommonSOMViewerStateData.fileNamePrefix.equals("")) { fileChooser.setCurrentDirectory(new File(CommonSOMViewerStateData.fileNamePrefix)); } else { fileChooser.setCurrentDirectory(state.getFileChooser().getCurrentDirectory()); } fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fileChooser.getSelectedFile() != null) { // reusing the dialog fileChooser.setSelectedFile(null); } fileChooser.setName("Choose path"); int returnVal = fileChooser.showDialog(ClusteringControl.this, "Choose path"); if (returnVal == JFileChooser.APPROVE_OPTION) { // save images String path = fileChooser.getSelectedFile().getAbsolutePath(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Writing label images to " + path); } } }); panelButtons.add(exportImages); JButton deleteManual = new JButton("Delete"); deleteManual.setFont(smallFont); deleteManual.setMargin(SMALL_INSETS); deleteManual.setToolTipText("Delete manually added labels."); deleteManual.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { state.mapPNode.getManualLabels().removeAllChildren(); Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Manual Labels deleted."); } }); panelButtons.add(deleteManual); c.anchor = GridBagConstraints.NORTH; this.getContentPane().add(panelButtons, c.nextRow()); this.setVisible(true); }
From source file:TextureByReference.java
public void stateChanged(ChangeEvent e) { Object o = e.getSource(); // for the frame delay if (o == frameDelay) { animate.setFrameDelay(frameDelay.getValue()); }/*from w w w.j a v a 2 s . c o m*/ }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void lumSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_lumSpinnerStateChanged {//GEN-HEADEREND:event_lumSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setMass((Double) src.getValue()); }