List of usage examples for java.awt.event MouseEvent getX
public int getX()
From source file:com.projity.contrib.calendar.JXXMonthView.java
protected void selectFromEvent(MouseEvent e) { boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK; boolean control = (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK; int x = e.getX(); int y = e.getY(); long selected = getDayAt(x, y); if (selected == -1) { return;/* w ww . j ava 2 s . c om*/ } if (!control && !shift) clearSelection(); DateSpan selection; if (selected <= WEEKDAY_OFFSET) { //hk int weekDayNum = (int) (-selected + WEEKDAY_OFFSET); selectWeekDay(weekDayNum); _asKirkWouldSay_FIRE = true; return; } else { if (_pivotDate == -1 || (!shift)) selection = new DateSpan(selected, selected); else selection = new DateSpan(Math.min(_pivotDate, selected), Math.max(_pivotDate, selected)); } select(selection); _pivotDate = selected; // Arm so we fire action performed on mouse release. _asKirkWouldSay_FIRE = true; }
From source file:com.ivli.roim.controls.ChartControl.java
@Override public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e) && (iMarker instanceof DomainMarker || iSeries instanceof XYSeries)) { JPopupMenu mnu = new JPopupMenu( java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("MNU_MARKER_OPERATIONS")); if (iSeries instanceof XYSeries) { mnu.add(MENUS.ADD.makeItem(this)); mnu.add(MENUS.EXPORT_CSV.makeItem(this)); mnu.add(MENUS.DELETE_ALL.makeItem(this)); } else if (iMarker instanceof DomainMarker) { JMenu mi1 = new JMenu(MENUS.MOVE_TO_MIN.iText); mi1.add(MENUS.MOVE_TO_MIN.makeItem(this)); // mi1.add(MENUS.MOVE_TO_MIN_LEFT.makeItem(this)); // mi1.add(MENUS.MOVE_TO_MIN_RIGHT.makeItem(this)); mnu.add(mi1);/*from www.jav a 2 s. c om*/ JMenu mi2 = new JMenu(MENUS.MOVE_TO_MAX.iText); mi2.add(MENUS.MOVE_TO_MAX.makeItem(this)); // mi2.add(MENUS.MOVE_TO_MAX_LEFT.makeItem(this)); // mi2.add(MENUS.MOVE_TO_MAX_RIGHT.makeItem(this)); mnu.add(mi2); mnu.add(MENUS.MOVE_TO_MEDIAN.makeItem(this)); //if(!getDomainMarkersForSeries()){ JMenu mi3 = new JMenu( java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("MARKER_COMMAND.FIT")); mi3.add(MENUS.FIT_LEFT.makeItem(this)); mi3.add(MENUS.FIT_RIGHT.makeItem(this)); mnu.add(mi3); //} mnu.add(MENUS.DELETE.makeItem(this)); } mnu.show(this, e.getX(), e.getY()); } else { super.mouseReleased(e); dropSelection(); } }
From source file:base.BasePlayer.AminoTable.java
@Override public void mouseDragged(MouseEvent event) { mouseDrag = true;//from w ww .ja v a 2s . c om if (resizeColumn > 0) { resizeTable(resizeColumn, event.getX() - this.dragX); this.dragX = event.getX(); } }
From source file:ded.ui.DiagramController.java
@Override public void mouseMoved(MouseEvent e) { this.eventReceived(e); // Keep the focus display up to date if desired. if (debugFocus && e.getX() < 10) { this.repaint(); }/*from w w w.ja va2 s. c o m*/ }
From source file:cn.pholance.datamanager.common.components.JRViewer.java
void pnlLinksMouseDragged(MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseDragged // Add your handling code here: Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; Point point = viewport.getViewPosition(); int newX = point.x - (evt.getX() - downX); int newY = point.y - (evt.getY() - downY); int maxX = pnlInScroll.getWidth() - viewport.getWidth(); int maxY = pnlInScroll.getHeight() - viewport.getHeight(); if (newX < 0) { newX = 0;// w ww . j av a 2 s . co m } if (newX > maxX) { newX = maxX; } if (newY < 0) { newY = 0; } if (newY > maxY) { newY = maxY; } viewport.setViewPosition(new Point(newX, newY)); } }
From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java
/** * Handles a 'mouse dragged' event./*from w ww . j a v a 2s. c om*/ * * @param e the mouse event. */ public void mouseDragged(MouseEvent e) { // if the popup menu has already been triggered, then ignore dragging... if (this.popup != null && this.popup.isShowing()) { return; } // if no initial zoom point was set, ignore dragging... if (this.zoomPoint == null) { return; } Graphics2D g2 = (Graphics2D) getGraphics(); // Erase the previous zoom rectangle (if any)... drawRectangle(g2); boolean hZoom = false; boolean vZoom = false; if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } Rectangle2D scaledDataArea = getScreenDataArea((int) this.zoomPoint.getX(), (int) this.zoomPoint.getY()); if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); this.zoomRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), this.zoomPoint.getY(), xmax - this.zoomPoint.getX(), ymax - this.zoomPoint.getY()); } else if (hZoom) { double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); this.zoomRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), scaledDataArea.getMinY(), xmax - this.zoomPoint.getX(), scaledDataArea.getHeight()); } else if (vZoom) { double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); this.zoomRectangle = new Rectangle2D.Double(scaledDataArea.getMinX(), this.zoomPoint.getY(), scaledDataArea.getWidth(), ymax - this.zoomPoint.getY()); } // Draw the new zoom rectangle... drawRectangle(g2); g2.dispose(); }
From source file:base.BasePlayer.AminoTable.java
@Override public void mouseMoved(MouseEvent event) { if (!this.isEnabled()) { return;/*from w ww. jav a 2s. co m*/ } mouseY = event.getY(); mouseX = event.getX(); repaint(); }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
private void changeInternalLegend(MouseEvent e) { // TODO Auto-generated method stub Point2D screenPoint = translateScreenToJava2D(e.getPoint()); //TODO: resize the mask Rectangle2D screenArea = getScreenDataArea(); if (screenArea.contains(screenPoint)) { // Point2D chartPoint = translateScreenToChart(screenPoint); // changeSelectedMask(ChartMaskingUtilities.translateScreenX( // screenPoint.getX(), getScreenDataArea(), getChart())); int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); switch (cursorType) { case Cursor.MOVE_CURSOR: moveLegend(e.getPoint());/*from w w w.j a v a2 s .c o m*/ break; case Cursor.W_RESIZE_CURSOR: changeLegendX(e.getPoint()); break; case Cursor.E_RESIZE_CURSOR: changeLegendWidth(e.getPoint()); break; default: break; } repaint(); } }
From source file:Clavis.Windows.WShedule.java
public synchronized void refreshTable(int val) { DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (modelo.getRowCount() > 0) { int tam = modelo.getRowCount(); for (int h = 0; h < tam; h++) { modelo.removeRow(0);//from w w w. ja va 2 s . c o m } } java.util.List<Keys.Request> requisicoes = new java.util.ArrayList<>(); if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); } lista = new java.util.ArrayList<>(); andamento = 0; switch (val) { case 0: estado = lingua.translate("Todos"); for (Keys.Request req : requisicoes) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } break; case 1: estado = lingua.translate("terminado"); for (Keys.Request req : requisicoes) { if (req.isTerminated()) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 2: estado = lingua.translate("no realizado"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && ((req.getEndDate().isBigger(new TimeDate.Date()) > 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) > 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 3: estado = lingua.translate("por realizar"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && (!req.isTerminated()) && ((req.getEndDate().isBigger(new TimeDate.Date()) < 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) < 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; } valores = new String[lista.size()][4]; for (int i = 0; i < lista.size(); i++) { String[] multipla = lista.get(i).getActivity().split(":::"); String saux = multipla[0]; if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getTimeBegin().toString(0) + " - " + lista.get(i).getTimeEnd().toString(0); valores[i][2] = lista.get(i).getBeginDate().toString(); valores[i][3] = saux + " - " + lista.get(i).getSubject().getName(); } else { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getBeginDate().toString(); valores[i][2] = lista.get(i).getEndDate().toString(); valores[i][3] = saux; } } }
From source file:ireport_5_6_0.view.JRViewer.java
void pnlLinksMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseDragged // Add your handling code here: Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; Point point = viewport.getViewPosition(); int newX = point.x - (evt.getX() - downX); int newY = point.y - (evt.getY() - downY); int maxX = pnlInScroll.getWidth() - viewport.getWidth(); int maxY = pnlInScroll.getHeight() - viewport.getHeight(); if (newX < 0) { newX = 0;// w w w. j a v a 2 s . c o m } if (newX > maxX) { newX = maxX; } if (newY < 0) { newY = 0; } if (newY > maxY) { newY = maxY; } viewport.setViewPosition(new Point(newX, newY)); } }