List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:SciTK.PlotXYZBlock.java
private void init(String x_label, String y_label, String window_title) { chart = ChartFactory.createScatterPlot("", x_label, y_label, data, PlotOrientation.VERTICAL, false, true, false);//from www. j ava 2s . com // turn off borders of the plot: XYPlot p = chart.getXYPlot(); p.getDomainAxis().setLowerMargin(0.0); p.getDomainAxis().setUpperMargin(0.0); p.getRangeAxis().setLowerMargin(0.0); p.getRangeAxis().setUpperMargin(0.0); // -------------------------------------------- // set up a lookup table // -------------------------------------------- // this is how we render the block plots: XYBlockRenderer renderer = new XYBlockRenderer(); // need to find max and min z of the data set: double min = 0; double max = 0; for (int i = 0; i < data.getSeriesCount(); i++) // iterate over data sets { for (int j = 0; j < data.getItemCount(i); j++) // iterate over points in dataset { if (data.getZValue(i, j) < min) min = data.getZValue(i, j); else if (data.getZValue(i, j) > max) max = data.getZValue(i, j); } } // create paint scale using min and max values, default color black: LookupPaintScale paintScale = new LookupPaintScale(min, max, Color.black); // set up the LUT: double step_size = (max - min) / 255.; // step size for LUT for (int i = 0; i < 256; i++) { paintScale.add(min + i * step_size, new Color(i, i, i, 255)); } renderer.setPaintScale(paintScale); // set this renderer to the plot: p.setRenderer(renderer); // -------------------------------------------- // set up a color bar // -------------------------------------------- // create an array of display labels: num_labels = 10; // default to 10 labels on color bar double display_step_size = (max - min) / ((double) num_labels); String[] scale_bar_labels = new String[num_labels + 1]; // to format numbers in scientific notation: DecimalFormat formater = new DecimalFormat("0.#E0"); // create list of labesl: for (int i = 0; i <= num_labels; i++) { scale_bar_labels[i] = formater.format(min + i * display_step_size); } // create axis: SymbolAxis scaleAxis = new SymbolAxis(null, scale_bar_labels); scaleAxis.setRange(min, max); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); // set up the paint scale: psl = new PaintScaleLegend(paintScale, scaleAxis); psl.setBackgroundPaint(new Color(255, 255, 255, 0)); // clear background // set up frame with buffer region to allow text display psl.setFrame(new LineBorder((Paint) Color.BLACK, new BasicStroke((float) 1.0), new RectangleInsets(15, 10, 15, 10))); psl.setAxisOffset(5.0); // display on right side: psl.setPosition(RectangleEdge.RIGHT); // margin around color scale: psl.setMargin(new RectangleInsets(20, 15, 20, 15)); // add to the chart so it will be displayed by default: chart.addSubtitle(psl); // -------------------------------------------- // WINDOW-RELATED UI // -------------------------------------------- // set up the generic plot UI: super.window_title = window_title; super.initUI(); // add another menu item JMenuBar mb = super.getJMenuBar(); // get the menu bar // find menu named "Plot" JMenu menu_plot = null; for (int i = 0; i < mb.getMenuCount(); i++) { if (mb.getMenu(i).getText() == "Plot") menu_plot = mb.getMenu(i); } // Add a new checkbox for the color scale bar JCheckBoxMenuItem menu_plot_scalebar = new JCheckBoxMenuItem("Color Scale"); menu_plot_scalebar.setToolTipText("Show color scale bar?"); menu_plot_scalebar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setScaleBar(selected); } }); // set appropirate checkbox state: menu_plot_scalebar.setState(true); if (menu_plot != null) // sanity check menu_plot.add(menu_plot_scalebar); }
From source file:com.projity.reports.view.ReportView.java
public void init(CoordinatesConverter coord) { initializing = true;// ww w . j av a 2s . co m this.coord = coord; setLayout(layout); reportLabel = new JLabel(Messages.getString("ReportView.Report")); //$NON-NLS-1$ reportChoice = new JComboBox(ReportUtil.getReportDefinitions()); reportChoice.setSelectedIndex(0); reportDefinition = (ReportDefinition) reportChoice.getSelectedItem(); fieldArray = reportDefinition.getMainFieldArray(); reportChoice.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { reportDefinition = (ReportDefinition) ((JComboBox) arg0.getSource()).getSelectedItem(); fieldArray = reportDefinition.getMainFieldArray(); dirty = true; showReport(); initColumns(); } }); columnsLabel = new JLabel(Messages.getString("ReportView.Columns")); //$NON-NLS-1$ columnsChoice = new JComboBox(); initColumns(); columnsChoice.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { fieldArray = (SpreadSheetFieldArray) ((JComboBox) arg0.getSource()).getSelectedItem(); dirty = true; showReport(); } }); add(header(), BorderLayout.PAGE_START); showReport(); initializing = false; }
From source file:com.unicornlabs.kabouter.gui.power.PowerPanel.java
private void liveCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_liveCheckBoxActionPerformed JCheckBox source = (JCheckBox) evt.getSource(); endTimeSpinner.setEnabled(!source.isSelected()); endDateChooser.setEnabled(!source.isSelected()); startTimeSpinner.setEnabled(!source.isSelected()); startDateChooser.setEnabled(!source.isSelected()); }
From source file:com.game.ui.views.PlayerEditor.java
@Override public void actionPerformed(ActionEvent ae) { validationMess.setText(""); validationMess.setVisible(false);/* w ww. j a va 2s . c om*/ if (ae.getActionCommand().equalsIgnoreCase("dropDown")) { JComboBox comboBox = (JComboBox) ae.getSource(); String type = comboBox.getSelectedItem().toString(); for (GameCharacter user : GameBean.playerDetails) { Player player = (Player) user; if (player.getType().equalsIgnoreCase(type)) { ((JTextField) leftPanel.getComponent(2)).setText(player.getName()); ((JTextField) leftPanel.getComponent(4)).setText(player.getImagePath()); ((JTextField) leftPanel.getComponent(6)).setText(new Integer(player.getHealth()).toString()); ((JTextField) leftPanel.getComponent(8)).setText(new Integer(player.getAttackPts()).toString()); ((JTextField) leftPanel.getComponent(10)).setText(new Integer(player.getArmor()).toString()); ((JTextField) leftPanel.getComponent(12)) .setText(new Integer(player.getAttackRange()).toString()); ((JTextField) leftPanel.getComponent(14)).setText(new Integer(player.getMovement()).toString()); ((JTextField) leftPanel.getComponent(16)).setText(player.getType()); JComboBox cBox = (JComboBox) leftPanel.getComponent(18); cBox.setSelectedItem(player.getInventory().getEquippedWeapon().getName()); lvlPanel.txtFields[0].setText("" + player.getLevel()); lvlPanel.txtFields[1].setText("" + player.getExp()); lvlPanel.txtFields[2].setText("" + player.getStrength()); lvlPanel.txtFields[3].setText("" + player.getVitality()); lvlPanel.txtFields[4].setText("" + player.getDexterity()); lvlPanel.txtFields[5].setText("" + player.getWisdom()); break; // return; } } } else { String name = ((JTextField) leftPanel.getComponent(2)).getText(); String image = ((JTextField) leftPanel.getComponent(4)).getText(); String health = ((JTextField) leftPanel.getComponent(6)).getText(); String attackPts = ((JTextField) leftPanel.getComponent(8)).getText(); String armourPts = ((JTextField) leftPanel.getComponent(10)).getText(); String attackRnge = ((JTextField) leftPanel.getComponent(12)).getText(); String movement = ((JTextField) leftPanel.getComponent(14)).getText(); String type = ((JTextField) leftPanel.getComponent(16)).getText(); String weapon = ((JComboBox) leftPanel.getComponent(18)).getSelectedItem().toString(); int attr[] = new int[6]; attr[0] = Integer.parseInt(lvlPanel.txtFields[0].getText()); attr[1] = Integer.parseInt(lvlPanel.txtFields[1].getText()); attr[2] = Integer.parseInt(lvlPanel.txtFields[2].getText()); attr[3] = Integer.parseInt(lvlPanel.txtFields[3].getText()); attr[4] = Integer.parseInt(lvlPanel.txtFields[4].getText()); attr[5] = Integer.parseInt(lvlPanel.txtFields[5].getText()); // validationMess.setText(""); // validationMess.setVisible(false); if (StringUtils.isNotBlank(image) && StringUtils.isNotBlank(health) && StringUtils.isNotBlank(attackPts) && StringUtils.isNotBlank(armourPts) && StringUtils.isNotBlank(attackRnge) && StringUtils.isNotBlank(movement) && StringUtils.isNotBlank(type) && StringUtils.isNotBlank(weapon)) { validationMess.setVisible(false); Player player = new Player(); //have to remove the following statement later.. player.setName(name); player.setAttackPts(Integer.parseInt(attackPts)); player.setAttackRange(Integer.parseInt(attackRnge)); player.setHealth(Integer.parseInt(health)); player.setImagePath(image); player.setMovement(Integer.parseInt(movement)); player.setArmor(Integer.parseInt(armourPts)); player.setType(type); Inventory inventory = new Inventory(); int position = GameUtils.getPositionOfWeaponItem(weapon); Weapon weaponObj = (Weapon) GameBean.weaponDetails.get(position); inventory.setEquippedWeapon(weaponObj); player.setInventory(inventory); player.setLevel(attr[0]); player.setExp(attr[1]); player.setStrength(attr[2]); player.setVitality(attr[3]); player.setDexterity(attr[4]); player.setWisdom(attr[5]); boolean characterAlrdyPresent = false; for (int i = 0; i < GameBean.playerDetails.size(); i++) { Player charFromList = (Player) GameBean.playerDetails.get(i); if (charFromList.getType().equalsIgnoreCase(type)) { GameBean.playerDetails.remove(i); characterAlrdyPresent = true; } } GameBean.playerDetails.add(player); try { GameUtils.writeCharactersToXML(GameBean.playerDetails, Configuration.PATH_FOR_USER_CHARACTERS); validationMess.setText("Saved Successfully.."); validationMess.setVisible(true); if (!characterAlrdyPresent) { comboBox.addItem(type); comboBox.removeActionListener(this); comboBox.setSelectedItem(type); comboBox.addActionListener(this); } } catch (Exception e) { System.out.println("PlayerEditor : actionPerformed() : Some error occured " + e); validationMess.setText("Some error occured.."); validationMess.setVisible(true); e.printStackTrace(); } } else { validationMess.setText("Pls enter all the fields or pls choose a character from the drop down"); validationMess.setVisible(true); } } this.revalidate(); // JFrame frame = (JFrame)SwingUtilities.getAncestorNamed("Frame", this); // frame.revalidate(); }
From source file:GeometryByReferenceTest.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); GeometryArray geo;/*from w w w. ja va 2 s.c o m*/ boolean setColor = false, setVertex = false; if (target == geomType) { geo = geoArrays[geomType.getSelectedIndex()]; // Set everything to null, and set it later .. geo.setColorRefFloat(null); geo.setColorRef3f(null); geo.setCoordRefFloat(null); geo.setCoordRef3f(null); shape.setGeometry(geoArrays[geomType.getSelectedIndex()]); setColor = true; setVertex = true; } else if (target == transparency) { if (transparency.isSelected()) { transp.setTransparencyMode(TransparencyAttributes.BLENDED); } else { transp.setTransparencyMode(TransparencyAttributes.NONE); } } else if (target == updates) { updateIndex = updates.getSelectedIndex(); if (updateIndex == 1) { System.out.println("Doing coordinate update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } else if (updateIndex == 2) { System.out.println("Doing color update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } } else if (target == vertexType) { geo = ((GeometryArray) shape.getGeometry()); if (vertexIndex == 0) { geo.setCoordRefFloat(null); } else if (vertexIndex == 1) { geo.setCoordRef3f(null); } vertexIndex = vertexType.getSelectedIndex(); setVertex = true; } else if (target == colorType) { geo = (GeometryArray) shape.getGeometry(); if (colorIndex == 0) { geo.setColorRefFloat(null); } else if (colorIndex == 1) { geo.setColorRef3f(null); } colorIndex = colorType.getSelectedIndex(); setColor = true; } if (setVertex) { geo = (GeometryArray) shape.getGeometry(); if (vertexIndex == 0) { if (geo instanceof IndexedGeometryArray) geo.setCoordRefFloat(indexedFloatVerts); else geo.setCoordRefFloat(floatVerts); } else if (vertexIndex == 1) { if (geo instanceof IndexedGeometryArray) geo.setCoordRef3f(indexedP3fVerts); else geo.setCoordRef3f(p3fVerts); } } if (setColor) { geo = (GeometryArray) shape.getGeometry(); if (colorIndex == 0) { if (geo instanceof IndexedGeometryArray) geo.setColorRefFloat(indexedFloatClrs); else geo.setColorRefFloat(floatClrs); } else if (colorIndex == 1) { if (geo instanceof IndexedGeometryArray) geo.setColorRef3f(indexedC3fClrs); else geo.setColorRef3f(c3fClrs); } } }
From source file:jgnash.ui.commodity.SecuritiesHistoryDialog.java
@Override public void actionPerformed(final ActionEvent e) { if (e.getSource() == applyButton) { addNode();/*from w w w . j av a2s . c o m*/ } else if (e.getSource() == clearButton) { clearForm(); } else if (e.getSource() == deleteButton) { removeNode(); } else if (e.getSource() == updateButton) { netAddNode(); } else if (e.getSource() == securityCombo) { changeNode(); } else if (e.getSource() == closeButton) { dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); } }
From source file:com.lfv.lanzius.server.WorkspacePanel.java
public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); //if(button==buttonServer) { // JOptionPane.showMessageDialog(server.getFrame(),"Use the menu to stop the server!","Info!",JOptionPane.INFORMATION_MESSAGE); //}//from ww w . j av a2 s .c o m //else if (button == buttonLoad) { server.menuChoiceLoadExercise(); deselectAll(); } else if (button == buttonLink) { try { if (isTerminalSelection) { if (server.menuChoiceTerminalLink(selectionList.get(0).intValue())) deselectAll(); } else deselectAll(); } catch (ArrayIndexOutOfBoundsException ex) { log.warn("Invalid selection list when linking from workspace panel"); } } else if (button == buttonUnlink) { if (isTerminalSelection) { if (server.menuChoiceTerminalUnlink(selectionList)) deselectAll(); } else { boolean deselectAll = false; Iterator<Integer> iteri = selectionList.iterator(); while (iteri.hasNext()) { boolean b = server.menuChoiceTerminalUnlinkGroup(iteri.next().intValue()); deselectAll = deselectAll || b; } if (deselectAll) deselectAll(); } } else if (button == buttonSwap) { try { if (isTerminalSelection) server.menuChoiceTerminalSwap(selectionList.get(0).intValue(), selectionList.get(1).intValue()); deselectAll(); } catch (ArrayIndexOutOfBoundsException ex) { log.warn("Invalid selection list when swapping from workspace panel"); } } else if (button == buttonMonitor) { server.menuChoiceTerminalMonitor(selectionList.get(0).intValue()); deselectAll(); } else if (button == buttonStart) { boolean deselectAll = false; Iterator<Integer> iteri = selectionList.iterator(); while (iteri.hasNext()) { boolean b = server.menuChoiceGroupStart(iteri.next().intValue()); deselectAll = deselectAll || b; } if (deselectAll) deselectAll(); } else if (button == buttonStop) { boolean deselectAll = false; Iterator<Integer> iteri = selectionList.iterator(); while (iteri.hasNext()) { boolean b = server.menuChoiceGroupStop(iteri.next().intValue()); deselectAll = deselectAll || b; } if (deselectAll) deselectAll(); } else if (button == buttonIsaStart) { view.initIsaChart(); if (selectionList != null) { Iterator<Integer> i = selectionList.iterator(); int tid; while (i.hasNext()) { tid = i.next().intValue(); if (server.isaClient(tid)) { //view.removeIsaTrace(tid); server.isaStartStop(tid); } else if (server.isaStartStop(tid)) { view.addIsaTrace(tid); } } updateButtons(false, null); repaint(); } } }
From source file:javaresturentdesktopclient.AddFoodItemPage.java
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed // TODO add your handling code here: int index;/*from ww w .ja v a 2 s .c o m*/ index = ((JComboBox) evt.getSource()).getSelectedIndex(); item = catagoryId[index]; if (item == 1) { CategoryId = Constant.CHINEESE; } else if (item == 2) { CategoryId = Constant.BANGLA; } else { CategoryId = Constant.INDIAN; } ShowFoodTable(CategoryId); }
From source file:ImageComponentByReferenceTest.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); if (target == rasterType) { if (rasterType.getSelectedIndex() < 4) { raster.setSize(w1, h1);//from w ww . j a v a 2 s .c om } else { raster.setSize(checkw, checkh); } raster.setImage(image[rasterType.getSelectedIndex()]); } else if (target == texType) { boxShape.setAppearance(dummyApp); if (texType.getSelectedIndex() < 4) { texOne.setImage(0, image[texType.getSelectedIndex()]); app.setTexture(texOne); } else { texCheckBoard.setImage(0, image[texType.getSelectedIndex()]); app.setTexture(texCheckBoard); } boxShape.setAppearance(app); } }
From source file:edu.mit.fss.examples.visual.gui.WorldWindVisualization.java
/** * Instantiates a new world wind visualization. * * @throws OrekitException the orekit exception *//*from w w w . j a v a2s . c om*/ public WorldWindVisualization() throws OrekitException { logger.trace("Creating Orekit reference frames."); eme = ReferenceFrame.EME2000.getOrekitFrame(); itrf = ReferenceFrame.ITRF2008.getOrekitFrame(); // world wind frame is a fixed rotation from Earth inertial frame wwj = new Frame(itrf, new Transform(date, new Rotation(RotationOrder.ZXZ, 0, -Math.PI / 2, -Math.PI / 2)), "World Wind"); logger.trace("Creating World Window GL canvas and adding to panel."); wwd = new WorldWindowGLCanvas(); wwd.setModel(new BasicModel()); wwd.setPreferredSize(new Dimension(800, 600)); setLayout(new BorderLayout()); add(wwd, BorderLayout.CENTER); logger.trace("Creating and adding a renderable layer."); displayLayer = new RenderableLayer(); wwd.getModel().getLayers().add(displayLayer); logger.trace("Creating and adding a marker layer."); markerLayer = new MarkerLayer(); // allow markers above/below surface markerLayer.setOverrideMarkerElevation(false); wwd.getModel().getLayers().add(markerLayer); logger.trace("Creating and adding a sun renderable."); Vector3D position = sun.getPVCoordinates(date, wwj).getPosition(); sunShape = new Ellipsoid(wwd.getModel().getGlobe().computePositionFromPoint(convert(position)), 696000000., 696000000., 696000000.); ShapeAttributes sunAttributes = new BasicShapeAttributes(); sunAttributes.setInteriorMaterial(Material.YELLOW); sunAttributes.setInteriorOpacity(1.0); sunShape.setAttributes(sunAttributes); displayLayer.addRenderable(sunShape); logger.trace("Creating and adding a terminator."); LatLon antiSun = LatLon.fromRadians(-sunShape.getCenterPosition().getLatitude().radians, FastMath.PI + sunShape.getCenterPosition().getLongitude().radians); // set radius to a quarter Earth chord at the anti-sun position less // a small amount (100 m) to avoid graphics problems terminatorShape = new SurfaceCircle(antiSun, wwd.getModel().getGlobe().getRadiusAt(antiSun) * FastMath.PI / 2 - 100); ShapeAttributes nightAttributes = new BasicShapeAttributes(); nightAttributes.setInteriorMaterial(Material.BLACK); nightAttributes.setInteriorOpacity(0.5); terminatorShape.setAttributes(nightAttributes); displayLayer.addRenderable(terminatorShape); logger.trace("Creating and adding a panel for buttons."); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); buttonPanel.add(new JCheckBox(new AbstractAction("Inertial Frame") { private static final long serialVersionUID = 2287109397693524964L; @Override public void actionPerformed(ActionEvent e) { setInertialFrame(((JCheckBox) e.getSource()).isSelected()); } })); buttonPanel.add(new JButton(editOptionsAction)); add(buttonPanel, BorderLayout.SOUTH); logger.trace( "Creating a timer to rotate the sun renderable, " + "terminator surface circle, and stars layer."); Timer rotationTimer = new Timer(15, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { wwd.redraw(); try { BasicOrbitView wwdView; if (wwd.getView() instanceof BasicOrbitView) { wwdView = (BasicOrbitView) wwd.getView(); } else { return; } // rotate camera to simulate inertial frame if (wwd.getView().isAnimating() || !inertialFrame.get()) { // update eme datum rotationDatum = wwj.getTransformTo(eme, date) .transformPosition(convert(wwdView.getCenterPoint())); } else if (inertialFrame.get()) { Position newCenter = wwd.getModel().getGlobe().computePositionFromPoint( convert(eme.getTransformTo(wwj, date).transformPosition(rotationDatum))); // move to eme datum wwdView.setCenterPosition(newCenter); } // rotate stars layer for (Layer layer : wwd.getModel().getLayers()) { if (layer instanceof StarsLayer) { StarsLayer stars = (StarsLayer) layer; // find the EME coordinates of (0,0) Vector3D emeDatum = wwj.getTransformTo(eme, date).transformPosition(convert( wwd.getModel().getGlobe().computePointFromLocation(LatLon.fromDegrees(0, 0)))); // find the WWJ coordinates the equivalent point in ITRF Vector3D wwjDatum = itrf.getTransformTo(wwj, date).transformPosition(emeDatum); // set the longitude offset to the opposite of // the difference in longitude (i.e. from 0) stars.setLongitudeOffset(wwd.getModel().getGlobe() .computePositionFromPoint(convert(wwjDatum)).getLongitude().multiply(-1)); } } } catch (OrekitException ex) { logger.error(ex); } } }); // set initial 2-second delay for initialization rotationTimer.setInitialDelay(2000); rotationTimer.start(); }