List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java
private void valueLeafActionEdit(final MouseEvent mouseEvent, final TreePath selectedPath, final XmlDomAdapterNode clickedItem, final JTree tree) { final JPopupMenu popup = new JPopupMenu(); // Basic type : edit final JMenuItem menuItem = new JMenuItem(ResourceUtils.getI18n("EDIT")); menuItem.addActionListener(new ActionListener() { @Override//from w ww . j a v a 2 s.co m public void actionPerformed(ActionEvent actionEvent) { final String newValue = JOptionPane.showInputDialog(ResourceUtils.getI18n("EDIT"), clickedItem.node.getNodeValue()); if (newValue != null) { try { if (clickedItem.node instanceof Attr) { ((Attr) clickedItem.node).setValue(newValue); } else { clickedItem.node.setNodeValue(newValue); } //clickedItem.setNewValue(newValue); } catch (NumberFormatException e) { showErrorMessage(newValue, tree); } validationPolicyTreeModel.fireTreeChanged(selectedPath); } } }); popup.add(menuItem); popup.show(tree, mouseEvent.getX(), mouseEvent.getY()); }
From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java
private JTable createTable(final ViewState state) { JTable table;/* w ww.j ava2s . c o m*/ final ModelGraph selected = state.getSelected(); if (selected != null) { final Vector<Vector<String>> rows = new Vector<Vector<String>>(); ConcurrentHashMap<String, String> keyToGroupMap = new ConcurrentHashMap<String, String>(); Metadata staticMet = selected.getModel().getStaticMetadata(); Metadata inheritedMet = selected.getInheritedStaticMetadata(state); Metadata completeMet = new Metadata(); if (staticMet != null) { completeMet.replaceMetadata(staticMet.getSubMetadata(state.getCurrentMetGroup())); } if (selected.getModel().getExtendsConfig() != null) { for (String configGroup : selected.getModel().getExtendsConfig()) { Metadata extendsMetadata = state.getGlobalConfigGroups().get(configGroup).getMetadata() .getSubMetadata(state.getCurrentMetGroup()); for (String key : extendsMetadata.getAllKeys()) { if (!completeMet.containsKey(key)) { keyToGroupMap.put(key, configGroup); completeMet.replaceMetadata(key, extendsMetadata.getAllMetadata(key)); } } } } if (inheritedMet != null) { Metadata inheritedMetadata = inheritedMet.getSubMetadata(state.getCurrentMetGroup()); for (String key : inheritedMetadata.getAllKeys()) { if (!completeMet.containsKey(key)) { keyToGroupMap.put(key, "__inherited__"); completeMet.replaceMetadata(key, inheritedMetadata.getAllMetadata(key)); } } } List<String> keys = completeMet.getAllKeys(); Collections.sort(keys); for (String key : keys) { if (key.endsWith("/envReplace")) { continue; } String values = StringUtils.join(completeMet.getAllMetadata(key), ","); Vector<String> row = new Vector<String>(); row.add(keyToGroupMap.get(key)); row.add(key); row.add(values); row.add(Boolean.toString(Boolean.parseBoolean(completeMet.getMetadata(key + "/envReplace")))); rows.add(row); } table = new JTable();// rows, new Vector<String>(Arrays.asList(new // String[] { "key", "values", "envReplace" }))); table.setModel(new AbstractTableModel() { public String getColumnName(int col) { switch (col) { case 0: return "group"; case 1: return "key"; case 2: return "values"; case 3: return "envReplace"; default: return null; } } public int getRowCount() { return rows.size() + 1; } public int getColumnCount() { return 4; } public Object getValueAt(int row, int col) { if (row >= rows.size()) { return null; } String value = rows.get(row).get(col); if (value == null && col == 3) { return "false"; } if (value == null && col == 0) { return "__local__"; } return value; } public boolean isCellEditable(int row, int col) { if (row >= rows.size()) { return selected.getModel().getStaticMetadata().containsGroup(state.getCurrentMetGroup()); } if (col == 0) { return false; } String key = rows.get(row).get(1); return key == null || (selected.getModel().getStaticMetadata() != null && selected.getModel().getStaticMetadata().containsKey(getKey(key, state))); } public void setValueAt(Object value, int row, int col) { if (row >= rows.size()) { Vector<String> newRow = new Vector<String>( Arrays.asList(new String[] { null, null, null, null })); newRow.add(col, (String) value); rows.add(newRow); } else { Vector<String> rowValues = rows.get(row); rowValues.add(col, (String) value); rowValues.remove(col + 1); } this.fireTableCellUpdated(row, col); } }); MyTableListener tableListener = new MyTableListener(state); table.getModel().addTableModelListener(tableListener); table.getSelectionModel().addListSelectionListener(tableListener); } else { table = new JTable(new Vector<Vector<String>>(), new Vector<String>(Arrays.asList(new String[] { "key", "values", "envReplace" }))); } // table.setFillsViewportHeight(true); table.setSelectionBackground(Color.cyan); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableCellRenderer cellRenderer = new TableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel field = new JLabel((String) value); if (column == 0) { field.setForeground(Color.gray); } else { if (isSelected) { field.setBorder(new EtchedBorder(1)); } if (table.isCellEditable(row, 1)) { field.setForeground(Color.black); } else { field.setForeground(Color.gray); } } return field; } }; TableColumn groupCol = table.getColumnModel().getColumn(0); groupCol.setPreferredWidth(75); groupCol.setCellRenderer(cellRenderer); TableColumn keyCol = table.getColumnModel().getColumn(1); keyCol.setPreferredWidth(200); keyCol.setCellRenderer(cellRenderer); TableColumn valuesCol = table.getColumnModel().getColumn(2); valuesCol.setPreferredWidth(300); valuesCol.setCellRenderer(cellRenderer); TableColumn envReplaceCol = table.getColumnModel().getColumn(3); envReplaceCol.setPreferredWidth(75); envReplaceCol.setCellRenderer(cellRenderer); table.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 && DefaultPropView.this.table.getSelectedRow() != -1) { int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition()); String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state); Metadata staticMet = state.getSelected().getModel().getStaticMetadata(); override.setVisible(staticMet == null || !staticMet.containsKey(key)); delete.setVisible(staticMet != null && staticMet.containsKey(key)); tableMenu.show(DefaultPropView.this.table, e.getX(), e.getY()); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); return table; }
From source file:Filter3dTest.java
public synchronized void mouseMoved(MouseEvent e) { // this event is from re-centering the mouse - ignore it if (isRecentering && centerLocation.x == e.getX() && centerLocation.y == e.getY()) { isRecentering = false;/*w ww.j av a 2 s . c o m*/ } else { int dx = e.getX() - mouseLocation.x; int dy = e.getY() - mouseLocation.y; mouseHelper(MOUSE_MOVE_LEFT, MOUSE_MOVE_RIGHT, dx); mouseHelper(MOUSE_MOVE_UP, MOUSE_MOVE_DOWN, dy); if (isRelativeMouseMode()) { recenterMouse(); } } mouseLocation.x = e.getX(); mouseLocation.y = e.getY(); }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
/** * Handles a 'mouse dragged' event.//from w ww.j a v a2s . c o m * * @param e the mouse event. */ public void mouseDragged(MouseEvent e) { setHorizontalTraceLocation(e.getX()); setVerticalTraceLocation(e.getY()); Insets insets = getInsets(); int x = (int) ((e.getX() - insets.left) / getScaleX()); int y = (int) ((e.getY() - insets.top) / getScaleY()); EntityCollection entities = null; ChartEntity entity = null; if (getChartRenderingInfo() != null) { entities = getChartRenderingInfo().getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } if (entity instanceof XYItemEntity) { IDataset dataset = (IDataset) ((XYItemEntity) entity).getDataset(); int item = ((XYItemEntity) entity).getItem(); setChartX(dataset.getXValue(0, item)); setChartY(dataset.getYValue(0, item)); setChartZ(((XYZDataset) dataset).getZValue(0, item)); } // if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) { if (isMaskingEnabled()) { int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); setCursor(Cursor.getPredefinedCursor(cursorType)); } else if (getCursor() != defaultCursor) { setCursor(defaultCursor); } // we can only generate events if the panel's chart is not null // (see bug report 1556951) Object[] listeners = getListeners(ChartMouseListener.class); if (getChart() != null) { XYZChartMouseEvent event = new XYZChartMouseEvent(getChart(), e, entity); event.setXYZ(getChartX(), getChartY(), getChartZ()); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(event); } } if (getMaskDragIndicator() != Cursor.DEFAULT_CURSOR && getSelectedMask() != null && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { changeSelectedMask(e, entities); } else if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) { makeNewMask(e, entities); } else { super.mouseDragged(e); } }
From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java
/** * Build the popup menu to switch between typeAnimation. * works only when statistic has observations * Called by MouseListener //from ww w. java 2 s . c o m * Event wird nur bearbeitet, wenn die Simulation angehalten ist * Im anderen Fall kann der Viewer (inbes. Applet) ueberlastet sein * @param event MouseEvent */ private void checkPopupMenu(MouseEvent event) { //System.out.println("StatisticGrafic.checkPopupMenu"); ViewerPanel viewer = this.statistic.getModel().getViewer(); if (viewer != null && viewer.getSimulationThread() != null && !viewer.getSimulationThread().isWorking()) { // Event wird nur bearbeitet, wenn die Simulation angehalten ist // Im anderen Fall kann der Viewer (inbes. Applet) ueberlastet sein if (event.isPopupTrigger() && this.statistic.hasValue()) { JPopupMenu popup = new JPopupMenu(); JMenuItem mi = new JMenuItem(StatisticGrafic.TEXT_POPUP_MENU[0]); mi.addActionListener(this); popup.add(mi); mi = new JMenuItem(StatisticGrafic.TEXT_POPUP_MENU[1]); mi.addActionListener(this); popup.add(mi); popup.show(event.getComponent(), event.getX(), event.getY()); } } }
From source file:oct.analysis.application.OCTAnalysisUI.java
private void octAnalysisPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_octAnalysisPanelMouseClicked octAnalysisPanel.requestFocus();/*from w ww. j a va 2s. co m*/ //only perform actions when mouse click occurs over image area if (analysisMngr.getAnalysisMode() != null && octAnalysisPanel.coordinateOverlapsOCT(evt.getX(), evt.getY())) { switch (evt.getButton()) { case MouseEvent.BUTTON1: switch (analysisMngr.getAnalysisMode()) { case SINGLE: switch (toolMode) { case SELECT_SINGLE: //clear out any current analysis selection selectionLRPManager.removeSelections(false); octAnalysisPanel.repaint(); //add new selections and redraw panel selectionLRPManager.addOrUpdateSelection(selectionLRPManager.getSelection( octAnalysisPanel.translatePanelPointToOctPoint(evt.getPoint()).x, "Selection", SelectionType.NONFOVEAL, true)); octAnalysisPanel.repaint(); break; case SCREEN_SELECT: selectSelection(evt.getPoint()); break; } break; case MIRROR: switch (toolMode) { case SELECT_SINGLE: //clear out any current analysis selection selectionLRPManager.removeNonfovealSelections(false); octAnalysisPanel.repaint(); //add new selections and redraw panel int distFromFovea = Math.abs(analysisMngr.getFoveaCenterXPosition() - octAnalysisPanel.translatePanelPointToOctPoint(evt.getPoint()).x); selectionLRPManager.addOrUpdateSelection(selectionLRPManager.getSelection( analysisMngr.getFoveaCenterXPosition() - distFromFovea, "Left", SelectionType.NONFOVEAL, true)); selectionLRPManager.addOrUpdateSelection(selectionLRPManager.getSelection( analysisMngr.getFoveaCenterXPosition() + distFromFovea, "Right", SelectionType.NONFOVEAL, true)); octAnalysisPanel.repaint(); break; case SCREEN_SELECT: selectSelection(evt.getPoint()); break; } break; case EZ: //allow user to select and change position of the EZ edge selections after the fact switch (toolMode) { case SCREEN_SELECT: selectSelection(evt.getPoint()); default: break; } break; case EQUIDISTANT: //allow user to change placement of fovea after the fact if (toolMode == ToolMode.SELECT_FOVEA) { //clear out any current analysis information selectionLRPManager.removeSelections(true); octAnalysisPanel.repaint(); //add new selections and redraw panel selectionLRPManager.addOrUpdateEquidistantSelections(evt.getX(), analysisMngr.getMicronsBetweenSelections()); octAnalysisPanel.repaint(); } break; default: break; } break; case MouseEvent.BUTTON3: selectionLRPManager.removeSelections(true); octAnalysisPanel.repaint(); break; default: break; } } }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
/** * Receives notification of mouse clicks on the panel. These are * translated and passed on to any registered {@link ChartMouseListener}s. * * @param event Information about the mouse event. *//*from w ww . jav a 2s .c o m*/ public void mouseClicked(MouseEvent event) { Insets insets = getInsets(); int x = (int) ((event.getX() - insets.left) / getScaleX()); int y = (int) ((event.getY() - insets.top) / getScaleY()); double chartX = 0; double chartY = 0; double chartZ = 0; setAnchor(new Point2D.Double(x, y)); if (getChart() == null) { return; } // this.chart.setNotify(true); // force a redraw // new entity code... // Object[] listeners = this.chartMouseListeners.getListeners( // ChartMouseListener.class); ChartEntity entity = null; if (getChartRenderingInfo() != null) { EntityCollection entities = getChartRenderingInfo().getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } if (entity instanceof XYItemEntity) { IDataset dataset = (IDataset) ((XYItemEntity) entity).getDataset(); int item = ((XYItemEntity) entity).getItem(); chartX = dataset.getXValue(0, item); chartY = dataset.getYValue(0, item); chartZ = ((XYZDataset) dataset).getZValue(0, item); // System.out.println("px=" + x + ", py=" + y); // System.out.println("x=" + chartX + ", y=" + chartY + ", z=" + chartZ); // Point2D trsPoint = translateChartPoint(new Point2D.Double(chartX, chartY)); // System.out.println("tx=" + trsPoint.getX() + ", y=" + trsPoint.getY()); // if ((event.getModifiers() & maskingSelectionMask) != 0) { // selectMask(chartX, chartY); // repaint(); // } else { // if (getSelectedMask() != null && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 // && !getSelectedMask().getShape().contains(chartX, chartY)) { // selectMask(null); // repaint(); // } // } if ((event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { selectMask(chartX, chartY); repaint(); } } Object[] listeners = getListeners(ChartMouseListener.class); XYZChartMouseEvent chartEvent = new XYZChartMouseEvent(getChart(), event, entity); chartEvent.setXYZ(chartX, chartY, chartZ); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Handles a 'mouse pressed' event.//ww w.j a v a 2 s . c om * <P> * This event is the popup trigger on Unix/Linux. For Windows, the popup * trigger is the 'mouse released' event. * * @param e The mouse event. */ public void mousePressed(MouseEvent e) { if (zoomRectangle == null) { this.zoomPoint = RefineryUtilities.getPointInRectangle(e.getX(), e.getY(), getScaledDataArea()); // check for popup trigger... if (e.isPopupTrigger()) { if (popup != null) { displayPopupMenu(e.getX(), e.getY()); } } } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Receives notification of mouse clicks on the panel. These are * translated and passed on to any registered chart mouse click listeners. * * @param event Information about the mouse event. *//*from www .j ava 2 s .com*/ public void mouseClicked(MouseEvent event) { Insets insets = getInsets(); int x = event.getX() - insets.left; int y = event.getY() - insets.top; //"Custom" mouse click handling code. One may use it for interactive work with the plots //(or follow the original framework). //Manager should be set with setManager(), and handleMouseClicked(), which //is an empty function of AbstractManager, should be overriden in the AbstractManager subclass. if (manager != null) manager.handleMouseClicked(x, y); // old 'handle click' code... chart.handleClick(x, y, this.info); // new entity code... if (this.chartMouseListeners.isEmpty()) { return; } ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity); Iterator iterator = chartMouseListeners.iterator(); while (iterator.hasNext()) { ChartMouseListener listener = (ChartMouseListener) iterator.next(); listener.chartMouseClicked(chartEvent); } }
From source file:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java
/** * On left axis//from w w w .j a va2s. c o m * * @param mouseEvent the event * * @return on left axis */ private boolean isOnLeftRangeAxis(MouseEvent mouseEvent) { Rectangle2D dataArea = chartPanel.getScreenDataArea(); if (mouseEvent.getY() < dataArea.getY()) { return false; } if (mouseEvent.getY() > dataArea.getY() + dataArea.getHeight()) { return false; } // System.err.println("mouse:" + mouseEvent.getX() +" da:" + dataArea); double left = dataArea.getX(); if (mouseEvent.getX() < left) { return true; } if (mouseEvent.getX() > left + 20) { return false; } return true; }