List of usage examples for java.awt.event ItemListener ItemListener
ItemListener
From source file:de.fhbingen.wbs.wpOverview.tabs.AvailabilityGraphAction.java
/** * Add the action listener to the graph. *///from ww w . jav a2 s . c om private void setAction() { gui.pnlGraph.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(final ChartMouseEvent e) { if (e.getEntity() instanceof PlotEntity) { Point2D p = gui.pnlGraph.translateScreenToJava2D(e.getTrigger().getPoint()); CategoryPlot plot = (CategoryPlot) gui.pnlGraph.getChart().getPlot(); Rectangle2D plotArea = gui.pnlGraph.getScreenDataArea(); DateAxis rangeAxis = (DateAxis) plot.getRangeAxis(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); CategoryAxis catAxis = plot.getDomainAxis(); RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); double chartY = rangeAxis.java2DToValue(p.getX(), plotArea, rangeAxisEdge); CategoryDataset categories = (CategoryDataset) plot.getDataset(0); int categoryCount = categories.getColumnCount(); for (int i = 0; i < categoryCount; i++) { double catStart = catAxis.getCategoryStart(i, categoryCount, plotArea, domainAxisEdge); double catEnd = catAxis.getCategoryEnd(i, categoryCount, plotArea, domainAxisEdge); if (e.getTrigger().getY() >= catStart && e.getTrigger().getY() < catEnd) { new EditAvailabilityController(gui.function, gui.function.getWorkers().get(i), new Day(new Date((long) chartY)), parent); } } } else { CategoryItemEntity item = (CategoryItemEntity) e.getEntity(); CategoryPlot plot = (CategoryPlot) gui.pnlGraph.getChart().getPlot(); Rectangle2D plotArea = gui.pnlGraph.getScreenDataArea(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); DateAxis dateAxis = (DateAxis) plot.getRangeAxis(); double d = dateAxis.java2DToValue(e.getEntity().getArea().getBounds2D().getX(), plotArea, rangeAxisEdge); double d2 = dateAxis.java2DToValue(e.getEntity().getArea().getBounds2D().getX() + e.getEntity().getArea().getBounds2D().getWidth(), plotArea, rangeAxisEdge); Date startDate = new Date((long) d); Date endDate = new Date((long) d2); CategoryDataset categories = (CategoryDataset) plot.getDataset(0); int workerIndex = categories.getColumnIndex(item.getColumnKey()); Worker worker = gui.function.getWorkers().get(workerIndex); Set<Availability> found = CalendarService.getAllWorkerAvailability(worker.getId(), startDate, endDate); Availability foundAv = found.toArray(new Availability[1])[0]; if (foundAv != null) { new EditAvailabilityController(gui.function, foundAv, parent); } else { found = CalendarService.getProjectAvailability(startDate, endDate); foundAv = found.toArray(new Availability[1])[0]; if (foundAv != null) { new EditAvailabilityController(gui.function, foundAv, parent); } else { JOptionPane.showMessageDialog( new JFrame(LocalizedStrings.getGeneralStrings().warning()), LocalizedStrings.getErrorMessages().availabilityCanNotBeChanged()); } } } } @Override public void chartMouseMoved(final ChartMouseEvent arg0) { } }); /** * ActionListener */ gui.btnNext.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { gui.function.increment(); } }); /** * ActionListener */ gui.btnPrev.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { gui.function.decrement(); } }); for (int i = 0; i < gui.buttons.length; i++) { addButtonListener(i); } /** * ActionListener */ gui.btnManualAv.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { gui.function.setManualAv(true); } else { gui.function.setManualAv(false); } } }); }
From source file:richtercloud.reflection.form.builder.components.AmountMoneyPanel.java
/** * Creates a new AmountMoneyPanel with {@link #DEFAULT_CURRENCIES} and * {@code additionalCurrencies}./* w ww . j av a 2 s . c om*/ * @param amountMoneyCurrencyStorage * @param amountMoneyUsageStatisticsStorage * @param amountMoneyExchangeRateRetriever * @param messageHandler * @throws richtercloud.reflection.form.builder.components.AmountMoneyCurrencyStorageException */ public AmountMoneyPanel(AmountMoneyCurrencyStorage amountMoneyCurrencyStorage, AmountMoneyUsageStatisticsStorage amountMoneyUsageStatisticsStorage, AmountMoneyExchangeRateRetriever amountMoneyExchangeRateRetriever, MessageHandler messageHandler) throws AmountMoneyCurrencyStorageException { this.messageHandler = messageHandler; Set<Currency> exchangeRateRetrieverSupportedCurrencies = amountMoneyExchangeRateRetriever .getSupportedCurrencies(); for (Currency currency : amountMoneyCurrencyStorage.getCurrencies()) { if (!exchangeRateRetrieverSupportedCurrencies.contains(currency)) { try { currency.getExchangeRate(); } catch (ConversionException ex) { throw new IllegalArgumentException(String.format( "Currency %s isn't supported by exchange rate retriever and doesn't have an exchange rate set", currency)); } } currencyComboBoxModel.addElement(currency); } initComponents(); ((SpinnerNumberModel) amountIntegerSpinner.getModel()) .setMaximum(((long) (Double.MAX_VALUE * MINIMAL_STEP))); //cast to long is necessary to make ChangeListener of //amountIntegerSpinner be notified this.amountIntegerSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { for (AmountMoneyPanelUpdateListener updateListener : AmountMoneyPanel.this.updateListeners) { updateListener.onUpdate(new AmountMoneyPanelUpdateEvent(getValue())); } } }); this.amountDecimalSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { for (AmountMoneyPanelUpdateListener updateListener : AmountMoneyPanel.this.updateListeners) { updateListener.onUpdate(new AmountMoneyPanelUpdateEvent(getValue())); } } }); this.currencyComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { //convert after currency change (not necessary, but useful) Currency oldCurrency = (Currency) itemEvent.getItem(); Currency newCurrency = (Currency) itemEvent.getItemSelectable().getSelectedObjects()[0]; double newAmount; try { newAmount = oldCurrency.getConverterTo(newCurrency).convert(getAmount()); } catch (ConversionException ex) { try { //if the exchange rate isn't set AmountMoneyPanel.this.amountMoneyExchangeRateRetriever.retrieveExchangeRate(newCurrency); AmountMoneyPanel.this.amountMoneyExchangeRateRetriever.retrieveExchangeRate(oldCurrency); newAmount = oldCurrency.getConverterTo(newCurrency).convert(getAmount()); } catch (AmountMoneyCurrencyStorageException amountMoneyCurrencyStorageException) { throw new RuntimeException(amountMoneyCurrencyStorageException); } } AmountMoneyPanel.this.amountIntegerSpinner.setValue((int) newAmount); BigDecimal bd = new BigDecimal(newAmount * 100); bd = bd.setScale(0, //newScale RoundingMode.HALF_UP //the rounding mode "taught in school" ); AmountMoneyPanel.this.amountDecimalSpinner.setValue(bd.intValue() % 100); //notify registered update listeners for (AmountMoneyPanelUpdateListener updateListener : AmountMoneyPanel.this.updateListeners) { updateListener.onUpdate(new AmountMoneyPanelUpdateEvent(getValue())); } } }); this.amountMoneyCurrencyStorage = amountMoneyCurrencyStorage; this.amountMoneyUsageStatisticsStorage = amountMoneyUsageStatisticsStorage; this.amountMoneyExchangeRateRetriever = amountMoneyExchangeRateRetriever; }
From source file:graphView.JungTreeViewer.java
public JungTreeViewer(ArrayList<String> versions) { // Added by Minh Nguyen for CS550 Term Project, KAIST, 2014 Transformer<String, Shape> vertexSize = new Transformer<String, Shape>() { public Shape transform(String str) { Ellipse2D circle = new Ellipse2D.Double(-15, -15, 30, 30); // in this case, the vertex is twice as large return AffineTransform.getScaleInstance(1.5, 1.5).createTransformedShape(circle); }/*from w w w.ja va 2 s . co m*/ }; Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() { @Override public Paint transform(String str) { Color green = new Color(0, 1, 0, 0.1f); String[] chars = str.split("\\."); if (chars.length == 1) { return Color.blue; } else { return green; } } }; // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(versions); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(700, 700)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(700, 700)); //jy: size vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); //vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.BLACK)); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); //vv.getRenderContext().setVertexShapeTransformer(vertexSize); rings = new Rings(); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox<String> modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); content.add(controls, BorderLayout.SOUTH); }
From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java
@Override public void initialize(Viewable viewableArg) { super.initialize(viewableArg); GetSetValueIFace parentField = (GetSetValueIFace) formViewObj.getControlByName("parent"); Component comp = formViewObj.getControlByName("definitionItem"); if (comp instanceof ValComboBox) { final ValComboBox rankComboBox = (ValComboBox) comp; final JCheckBox acceptedCheckBox = (JCheckBox) formViewObj.getControlByName("isAccepted"); Component apComp = formViewObj.getControlByName("acceptedParent"); final ValComboBoxFromQuery acceptedParentWidget = apComp instanceof ValComboBoxFromQuery ? (ValComboBoxFromQuery) apComp : null;/* w w w . j av a2 s .c om*/ if (parentField instanceof ValComboBoxFromQuery) { final ValComboBoxFromQuery parentCBX = (ValComboBoxFromQuery) parentField; if (parentCBX != null && rankComboBox != null) { parentCBX.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e == null || !e.getValueIsAdjusting()) { parentChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox, acceptedParentWidget); } } }); rankComboBox.getComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rankChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox, acceptedParentWidget); } }); } } if (acceptedCheckBox != null && acceptedParentWidget != null) { acceptedCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (acceptedCheckBox.isSelected()) { acceptedParentWidget.setValue(null, null); acceptedParentWidget.setChanged(true); // This should be done automatically acceptedParentWidget.setEnabled(false); } else { acceptedParentWidget.setEnabled(true); } } }); } } }
From source file:com.declarativa.interprolog.gui.Testo1.java
private void updateGUI(Forest<String, Integer> grapho) { layout = new TreeLayout<String, Integer>(grapho); radialLayout = new BalloonLayout<String, Integer>(grapho); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(radialLayout); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel);/*from w w w.j a v a 2 s . co m*/ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(jButton1); content.add(controls, BorderLayout.SOUTH); this.revalidate(); this.repaint(); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRNormalizedController.java
/** * Initialize view./*from w w w . j a v a2 s . c om*/ */ @Override protected void initDRNormalizedPanel() { dRNormalizedPlotPanel = new DRNormalizedPlotPanel(); //init chart panel normalizedChartPanel = new ChartPanel(null); normalizedChartPanel.setOpaque(false); /** * Action listeners for buttons */ /** * The combo box determines how the normalization is done. Bottom combo * box defines what the value for 0% response is. */ dRNormalizedPlotPanel.getBottomComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String value = (String) dRNormalizedPlotPanel.getBottomComboBox().getSelectedItem(); switch (value) { case "Smallest Mean Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMeans(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Smallest Median Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMedians(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getBottomTextField().setText(""); dRNormalizedPlotPanel.getBottomTextField().setEditable(true); break; } } }); /** * The combo box determines how the normalization is done. Top combo box * defines what the value for 100% response is. */ dRNormalizedPlotPanel.getTopComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String choice = (String) dRNormalizedPlotPanel.getTopComboBox().getSelectedItem(); switch (choice) { case "Largest Mean Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMeans(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Largest Median Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMedians(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getTopTextField().setText(""); dRNormalizedPlotPanel.getTopTextField().setEditable(true); break; } } }); /** * If selected, the curve fit 'bottom' parameter will be constrained to * zero. This zero is defined by the text field value during * normalization. * */ dRNormalizedPlotPanel.getBottomConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { bottomConstrainValue = 0.0; } else { bottomConstrainValue = null; } } }); /** * If selected, the curve fit 'top' parameter will be constrained to * 100. This is defined by the text field value during normalization. * */ dRNormalizedPlotPanel.getTopConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { topConstrainValue = 100.0; } else { topConstrainValue = null; } } }); /** * Re-normalize and plot new dose-response graph, taking into account * any choices made by the user. */ dRNormalizedPlotPanel.getPlotGraphButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dataToFit = prepareFittingData(doseResponseController.getdRAnalysisGroup().getDoseResponseData(), doseResponseController.getLogTransform()); setTableModel(doseResponseController.updateTableModel(createTableModel(dataToFit))); doseResponseController.updateModelInTable(tableModel); doseResponseController .performFitting( dataToFit, doseResponseController.getdRAnalysisGroup() .getDoseResponseAnalysisResults().getFittingResults(true), bottomConstrainValue, topConstrainValue); doseResponseController.plotDoseResponse(normalizedChartPanel, dRNormalizedPlotPanel.getDoseResponseChartParentPanel(), dataToFit, doseResponseController.getdRAnalysisGroup(), true); //Calculate new statistics doseResponseController.calculateStatistics(); } }); }
From source file:Sampler.java
private void createUI() { setFont(new Font("Serif", Font.PLAIN, 12)); setLayout(new BorderLayout()); // Set our location to the left of the image frame. setSize(200, 350);//www . j av a 2 s .com Point pt = mImageFrame.getLocation(); setLocation(pt.x - getSize().width, pt.y); final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false); final Label statusLabel = new Label(""); // Make a sorted list of the operators. Enumeration e = mOps.keys(); Vector names = new Vector(); while (e.hasMoreElements()) names.addElement(e.nextElement()); Collections.sort(names); final java.awt.List list = new java.awt.List(); for (int i = 0; i < names.size(); i++) list.add((String) names.elementAt(i)); add(list, BorderLayout.CENTER); // When an item is selected, do the corresponding transformation. list.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { if (ie.getStateChange() != ItemEvent.SELECTED) return; String key = list.getSelectedItem(); BufferedImageOp op = (BufferedImageOp) mOps.get(key); BufferedImage source = mSplitImageComponent.getSecondImage(); boolean accumulate = accumulateCheckbox.getState(); if (source == null || accumulate == false) source = mSplitImageComponent.getImage(); String previous = mImageFrame.getTitle() + " + "; if (accumulate == false) previous = ""; mImageFrame.setTitle(previous + key); statusLabel.setText("Performing " + key + "..."); list.setEnabled(false); accumulateCheckbox.setEnabled(false); BufferedImage destination = op.filter(source, null); mSplitImageComponent.setSecondImage(destination); mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize()); mImageFrame.setSize(mImageFrame.getPreferredSize()); list.setEnabled(true); accumulateCheckbox.setEnabled(true); statusLabel.setText("Performing " + key + "...done."); } }); Button loadButton = new Button("Load..."); loadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { FileDialog fd = new FileDialog(Sampler.this); fd.show(); if (fd.getFile() == null) return; String path = fd.getDirectory() + fd.getFile(); mSplitImageComponent.setImage(path); mSplitImageComponent.setSecondImage(null); // Utilities.sizeContainerToComponent(mImageFrame, // mSplitImageComponent); mImageFrame.validate(); mImageFrame.repaint(); } }); Panel bottom = new Panel(new GridLayout(2, 1)); Panel topBottom = new Panel(); topBottom.add(accumulateCheckbox); topBottom.add(loadButton); bottom.add(topBottom); bottom.add(statusLabel); add(bottom, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { mImageFrame.dispose(); dispose(); System.exit(0); } }); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRNormalizedController.java
/** * Initialize view/*from w ww. j a v a 2s . co m*/ */ @Override protected void initDRNormalizedPanel() { dRNormalizedPlotPanel = new DRNormalizedPlotPanel(); //init chart panel normalizedChartPanel = new ChartPanel(null); normalizedChartPanel.setOpaque(false); /** * Action listeners for buttons */ /** * The combo box determines how the normalization is done. Bottom combo * box defines what the value for 0% response is. */ dRNormalizedPlotPanel.getBottomComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String value = (String) dRNormalizedPlotPanel.getBottomComboBox().getSelectedItem(); switch (value) { case "Smallest Mean Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMeans( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Smallest Median Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMedians( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getBottomTextField().setText(""); dRNormalizedPlotPanel.getBottomTextField().setEditable(true); break; } } }); /** * The combo box determines how the normalization is done. Top combo box * defines what the value for 100% response is. */ dRNormalizedPlotPanel.getTopComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String choice = (String) dRNormalizedPlotPanel.getTopComboBox().getSelectedItem(); switch (choice) { case "Largest Mean Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMeans( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Largest Median Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMedians( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getTopTextField().setText(""); dRNormalizedPlotPanel.getTopTextField().setEditable(true); break; } } }); /** * If selected, the curve fit 'bottom' parameter will be constrained to * zero. This zero is defined by the text field value during * normalization. * */ dRNormalizedPlotPanel.getBottomConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { bottomConstrainValue = 0.0; } else { bottomConstrainValue = null; } } }); /** * If selected, the curve fit 'top' parameter will be constrained to * 100. This is defined by the text field value during normalization. * */ dRNormalizedPlotPanel.getTopConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { topConstrainValue = 100.0; } else { topConstrainValue = null; } } }); /** * Re-normalize and plot new dose-response graph, taking into account * any choices made by the user. */ dRNormalizedPlotPanel.getPlotGraphButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dataToFit = prepareFittingData(doseResponseController.getdRAnalysisGroup()); setTableModel(createTableModel(dataToFit)); doseResponseController.updateModelInTable(tableModel); doseResponseController .performFitting( dataToFit, doseResponseController.getdRAnalysisGroup() .getDoseResponseAnalysisResults().getFittingResults(true), bottomConstrainValue, topConstrainValue); doseResponseController.plotDoseResponse(normalizedChartPanel, dRNormalizedPlotPanel.getDoseResponseChartParentPanel(), dataToFit, doseResponseController.getdRAnalysisGroup(), true); //Calculate new statistics doseResponseController.calculateStatistics(); } }); }
From source file:org.imos.abos.plot.JfreeChartDemo.java
public void createAndShowGUI() { JButton autoZoom = new JButton("Auto Scale"); autoZoom.addActionListener(new ActionListener() { @Override/*from w ww. j a va 2s. c o m*/ public void actionPerformed(ActionEvent e) { System.out.println("Auto Zoom"); chart.getXYPlot().getDomainAxis().setAutoRange(true); chart.getXYPlot().getRangeAxis().setAutoRange(true); } }); JButton pdfButton = new JButton("PDF"); pdfButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("PDF"); createPDF(pdfName); } }); yMax = new JTextField(10); yMax.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("yMax Set " + yMax.getText()); double max = new Double(yMax.getText()); double min = chart.getXYPlot().getRangeAxis().getRange().getLowerBound(); chart.getXYPlot().getRangeAxis().setRange(min, max); } }); yMin = new JTextField(10); yMin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("yMin Set " + yMin.getText()); double min = new Double(yMin.getText()); double max = chart.getXYPlot().getRangeAxis().getRange().getUpperBound(); chart.getXYPlot().getRangeAxis().setRange(min, max); } }); JCheckBox showPoints = new JCheckBox("Show Points"); showPoints.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.DESELECTED) { XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); } } else if (e.getStateChange() == ItemEvent.SELECTED) { XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); } } } }); final JPanel jpanel = new JPanel(); jpanel.setLayout(new BorderLayout()); jpanel.add(chartPanel, BorderLayout.CENTER); JPanel right = new JPanel(); JPanel ypmax = new JPanel(); ypmax.add(yMax); JPanel ypmin = new JPanel(); ypmin.add(yMin); right.setLayout(new BoxLayout(right, BoxLayout.PAGE_AXIS)); right.add(ypmax); right.add(ypmin); right.add(autoZoom); right.add(pdfButton); right.add(showPoints); jpanel.add(right, BorderLayout.LINE_END); setContentPane(jpanel); pack(); setLocationRelativeTo(null); setVisible(true); }
From source file:com.midas.classify.gui.DecisionTreeViewer.java
public DecisionTreeViewer(DelegateTree<TreeNode, TreeEdge> tr, String[] cls) { setLayout(new BorderLayout()); // ---------------------------------------------- // // INICIALIZACION DE COMPONENTES DE VISUALIZACION // // ---------------------------------------------- // tree = tr;//www. j a v a2s .co m classNames = cls; classColors = new TreeMap(); nodeColor = Color.BLUE; for (int i = 0; i < cls.length; ++i) { classColors.put(cls[i], Color.RED); } leafNodes = new TreeSet(); for (TreeNode n : tr.getVertices()) { if (tr.isLeaf(n)) { for (String s : cls) { if (n.toString().startsWith(s)) { leafNodes.add(s); break; } } } } TreeLayout<TreeNode, TreeEdge> layout = new TreeLayout(tr); vv = new VisualizationViewer(layout); vv.setBackground(Color.white); vv.getRenderContext().setEdgeFontTransformer(new EdgeFontTransformer()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<TreeNode, TreeEdge>()); PickedState<TreeNode> picked_state = vv.getPickedVertexState(); vv.getRenderContext().setVertexFillPaintTransformer(new VertexFillColorTransformer<TreeNode>(picked_state)); vv.getRenderContext().setVertexDrawPaintTransformer(new VertexDrawColorTransformer<TreeNode>(picked_state)); vv.getRenderContext().setVertexFontTransformer(new VertexFontTransformer()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv); gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final ScalingControl scaler = new CrossoverScalingControl(); // ---------------------------------------- // // INICIALIZACION DE COMPONENTES DE CONTROL // // ---------------------------------------- // fontChooser = new JFontChooser(); JPanel pControl = new JPanel(new GridLayout(7, 1, 4, 2)); JPanel pZoom = new JPanel(new GridLayout(1, 2, 2, 2)); pZoom.setBorder(new TitledBorder("Zoom")); bZoomIn = new JButton("+"); bZoomIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); bZoomOut = new JButton("-"); bZoomOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); pZoom.add(bZoomIn); pZoom.add(bZoomOut); JPanel pFont = new JPanel(new GridLayout(1, 2, 2, 2)); pFont.setBorder(new TitledBorder("Fonts")); bNodeFont = new JButton("Node Font"); bNodeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fontChooser.showDialog(null); if (r == JFontChooser.OK_OPTION) { nodeFont = fontChooser.getSelectedFont(); vv.repaint(); } } }); bEdgeFont = new JButton("Edge Font"); bEdgeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fontChooser.showDialog(null); if (r == JFontChooser.OK_OPTION) { edgeFont = fontChooser.getSelectedFont(); vv.repaint(); } } }); pFont.add(bNodeFont); pFont.add(bEdgeFont); bNodeColor = new JButton("Node Color"); bNodeColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { nodeColor = JColorChooser.showDialog(null, "Select color for intern nodes", Color.RED); vv.repaint(); } }); JPanel pMode = new JPanel(); pMode.setBorder(new TitledBorder("Mode")); cbMode = new JComboBox(); cbMode.addItem(ModalGraphMouse.Mode.TRANSFORMING); cbMode.addItem(ModalGraphMouse.Mode.PICKING); cbMode.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { gm.setMode((ModalGraphMouse.Mode) e.getItem()); } }); pMode.add(cbMode); JPanel pColors = new JPanel(new GridLayout(1, 2, 2, 2)); pColors.setBorder(new TitledBorder("Node Colors")); cbClasses = new JComboBox(classNames); cbClasses.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(null, "Select class color for " + cbClasses.getSelectedItem(), Color.RED); classColors.put(cbClasses.getSelectedItem().toString(), c); vv.repaint(); } }); pColors.add(cbClasses); pColors.add(bNodeColor); JPanel pLabelPosition = new JPanel(); pLabelPosition.setBorder(new TitledBorder("Label Position")); cbLabelPosition = new JComboBox(); cbLabelPosition.addItem(Renderer.VertexLabel.Position.N); cbLabelPosition.addItem(Renderer.VertexLabel.Position.NE); cbLabelPosition.addItem(Renderer.VertexLabel.Position.E); cbLabelPosition.addItem(Renderer.VertexLabel.Position.SE); cbLabelPosition.addItem(Renderer.VertexLabel.Position.S); cbLabelPosition.addItem(Renderer.VertexLabel.Position.SW); cbLabelPosition.addItem(Renderer.VertexLabel.Position.W); cbLabelPosition.addItem(Renderer.VertexLabel.Position.NW); cbLabelPosition.addItem(Renderer.VertexLabel.Position.N); cbLabelPosition.addItem(Renderer.VertexLabel.Position.CNTR); cbLabelPosition.addItem(Renderer.VertexLabel.Position.AUTO); cbLabelPosition.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cbLabelPosition.setSelectedItem(Renderer.VertexLabel.Position.SE); pLabelPosition.add(cbLabelPosition); chkShowEdgeNames = new JCheckBox("Show Edge Name"); chkShowEdgeNames.addActionListener(new ActionListener() { ToStringLabeller strLabeller = new ToStringLabeller(); ConstantTransformer none = new ConstantTransformer(null); @Override public void actionPerformed(ActionEvent e) { AbstractButton src = (AbstractButton) e.getSource(); if (src.isSelected()) { vv.getRenderContext().setEdgeLabelTransformer(strLabeller); } else { vv.getRenderContext().setEdgeLabelTransformer(none); } vv.repaint(); } }); chkShowEdgeNames.setSelected(true); chkShowNodeNames = new JCheckBox("Show Node Name"); chkShowNodeNames.addActionListener(new ActionListener() { ToStringLabeller strLabeller = new ToStringLabeller(); ConstantTransformer none = new ConstantTransformer(null); @Override public void actionPerformed(ActionEvent e) { AbstractButton src = (AbstractButton) e.getSource(); if (src.isSelected()) { vv.getRenderContext().setVertexLabelTransformer(strLabeller); } else { vv.getRenderContext().setVertexLabelTransformer(none); } vv.repaint(); } }); chkShowNodeNames.setSelected(true); pControl.add(pZoom); pControl.add(pFont); pControl.add(pMode); pControl.add(pLabelPosition); pControl.add(pColors); pControl.add(chkShowNodeNames); pControl.add(chkShowEdgeNames); // Agregar componentes al panel add(scrollPane); JPanel p = new JPanel(new FlowLayout()); p.add(pControl); add(p, BorderLayout.EAST); }