List of usage examples for java.awt.event ItemEvent SELECTED
int SELECTED
To view the source code for java.awt.event ItemEvent SELECTED.
Click Source Link
From source file:ventanas.Reportes.java
private void jComboGraficaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboGraficaItemStateChanged int ind1 = jComboGrafica.getSelectedIndex(); int ind2 = jComboTipo.getSelectedIndex(); double por = 0, angulo = 0, sum = 0; String titulo, titulox, tituloy; DefaultCategoryDataset data = new DefaultCategoryDataset(); DefaultPieDataset pData = new DefaultPieDataset(); if (evt.getStateChange() == ItemEvent.SELECTED) { switch (ind1) { case 1:// w ww.j av a 2s.c o m if (ind2 == 1) { List<VistaCategorias> vista1 = new ArrayList<>(); ObtenerVistaCategorias ob = new ObtenerVistaCategorias(); vista1 = ob.obtenerVista(r); for (int i = 0; i < vista1.size(); i++) { data.setValue(vista1.get(i).getCantidad(), "Categoria", vista1.get(i).getCategoria()); } titulo = "Productos por Categoria"; titulox = "Categorias"; tituloy = "Numero de Productos"; crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy); } else { if (ind2 == 2) { List<VistaCategorias> vista1 = new ArrayList<>(); ObtenerVistaCategorias ob = new ObtenerVistaCategorias(); vista1 = ob.obtenerVista(r); for (int i = 0; i < vista1.size(); i++) { sum = vista1.get(i).getCantidad(); } for (int i = 0; i < vista1.size(); i++) { por = vista1.get(i).getCantidad() / sum; angulo = por * 360; pData.setValue(vista1.get(i).getCategoria(), angulo); } titulo = "Productos por Categoria"; crearPieChart(pData, jPanelGrafica, titulo); } } break; case 2: if (ind2 == 1) { List<GananciaCategoria> ganancia = new ArrayList<>(); ObtenerGananciaXCategoria ob = new ObtenerGananciaXCategoria(); ganancia = ob.obtenerGanancia(r); for (int i = 0; i < ganancia.size(); i++) { data.setValue(ganancia.get(i).getGanacia(), "Categoria", ganancia.get(i).getCategoria()); } titulo = "Ganancias por Categoria"; titulox = "Categorias"; tituloy = "Ganancias"; crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy); } else { if (ind2 == 2) { List<GananciaCategoria> ganancia = new ArrayList<>(); ObtenerGananciaXCategoria ob = new ObtenerGananciaXCategoria(); ganancia = ob.obtenerGanancia(r); System.out.println(ganancia.size()); for (int i = 0; i < ganancia.size(); i++) { data.setValue(ganancia.get(i).getGanacia(), "Categoria", ganancia.get(i).getCategoria()); } for (int i = 0; i < ganancia.size(); i++) { sum = ganancia.get(i).getGanacia(); } for (int i = 0; i < ganancia.size(); i++) { por = ganancia.get(i).getGanacia() / sum; angulo = por * 360; pData.setValue(ganancia.get(i).getCategoria(), angulo); } titulo = "Ganancia por Categoria"; crearPieChart(pData, jPanelGrafica, titulo); } } break; case 3: if (ind2 == 1) { List<ProveedorProductosEntregados> lista = new ArrayList<>(); ObtenerVistaProveedor op = new ObtenerVistaProveedor(); lista = op.obtenerLista(r); for (int i = 0; i < lista.size(); i++) { data.setValue(lista.get(i).getNum_productos_entregados(), "Proveedor", lista.get(i).getProveedor()); } titulo = "Cantidad de productos Entregados"; titulox = "Proveedor"; tituloy = "Cantidad"; crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy); } else { if (ind2 == 2) { List<ProveedorProductosEntregados> lista = new ArrayList<>(); ObtenerVistaProveedor op = new ObtenerVistaProveedor(); lista = op.obtenerLista(r); for (int i = 0; i < lista.size(); i++) { data.setValue(lista.get(i).getNum_productos_entregados(), "Proveedor", lista.get(i).getProveedor()); } for (int i = 0; i < lista.size(); i++) { sum = lista.get(i).getNum_productos_entregados(); } for (int i = 0; i < lista.size(); i++) { por = lista.get(i).getNum_productos_entregados() / sum; angulo = por * 360; pData.setValue(lista.get(i).getProveedor(), angulo); } titulo = "Cantidad de productos Entregados"; crearPieChart(pData, jPanelGrafica, titulo); } } break; case 4: if (ind2 == 1) { List<VistaInversioPedido> vista = new ArrayList<>(); ObtenerVistaInversion obt = new ObtenerVistaInversion(); vista = obt.obtenerVista(r); for (int i = 0; i < vista.size(); i++) { data.setValue(vista.get(i).getInversion(), "Proveedor", vista.get(i).getProveedores()); } titulo = "Cantidad de inversion"; titulox = "Proveedor"; tituloy = "Inversion"; crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy); } else { if (ind2 == 2) { List<VistaInversioPedido> vista = new ArrayList<>(); ObtenerVistaInversion obt = new ObtenerVistaInversion(); vista = obt.obtenerVista(r); for (int i = 0; i < vista.size(); i++) { data.setValue(vista.get(i).getInversion(), "Proveedor", vista.get(i).getProveedores()); } for (int i = 0; i < vista.size(); i++) { sum = vista.get(i).getInversion(); } for (int i = 0; i < vista.size(); i++) { por = vista.get(i).getInversion() / sum; angulo = por * 360; pData.setValue(vista.get(i).getProveedores(), angulo); } titulo = "Cantidad de inversion"; crearPieChart(pData, jPanelGrafica, titulo); } } break; } } }
From source file:edu.uci.ics.jung.samples.RadialTreeLensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * //w ww. j ava2s . c om */ @SuppressWarnings({ "unchecked", "rawtypes" }) public RadialTreeLensDemo() { // create a simple graph for the demo // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); Dimension preferredSize = new Dimension(600, 600); final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>( radialLayout, preferredSize); vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Integer> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<String>()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); rings = new Rings(); vv.addPreRenderPaintable(rings); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); 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()); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); JPanel modeControls = new JPanel(new BorderLayout()); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); hyperControls.add(hyperView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modeControls); content.add(controls, BorderLayout.SOUTH); }
From source file:de.fhbingen.wbs.wpOverview.tabs.AvailabilityGraphAction.java
/** * Add the action listener to the graph. */// w w w . j a va 2 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: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.j ava 2s. c o 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: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 www. ja va 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: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);/*from w ww . j ava 2s. c om*/ 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.generic.GenericDRNormalizedController.java
/** * Initialize view.//from w w w.j a v a 2 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:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRNormalizedController.java
/** * Initialize view/* ww w .ja va 2s. com*/ */ @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:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
/** * Creates the component./*w w w . j ava 2 s . c o m*/ */ public RenderedResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; Component component = renderedResultPanel.getComponent(0); if (component instanceof DialogTextArea) { nodeToWrapSelection.put(path, e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:de.fhbingen.wbs.wpOverview.tabs.AvailabilityGraphAction.java
/** * ActionListener.//from w ww.ja v a2s.com * @param buttonId The id of the button. */ private void addButtonListener(final int buttonId) { gui.buttons[buttonId].addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { deselectOthers(buttonId); gui.function.changeView(buttonId); } } }); }