Java Code Examples for java.awt.event.MouseEvent.getY()

The following are Jave code examples for showing how to use getY() of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: myster   File: FileProgressWindow.java   View Source Code Vote up 6 votes
public synchronized void mouseReleased(MouseEvent e) {
    if ((e.getX() > 0 && e.getX() < X_SIZE) && (e.getY() > 0 && e.getY() < AD_HEIGHT)) {
        if ((System.currentTimeMillis() - lastMouseReleaseTime > 500) && url != null
                && (!url.equals(""))) {
            try {
                WebLinkManager.openURL(new URL(url));
            } catch (MalformedURLException ex) {
                ex.printStackTrace();
            }
        }

        lastMouseReleaseTime = System.currentTimeMillis(); //so that
        // double -
        // triple
        // clicks by
        // spastic
        // people
        // don't
        // generate
        // multipe
        // browsers
    }
}
 
Example 2
Project: VASSAL-src   File: PolygonEditor.java   View Source Code Vote up 6 votes
public void mousePressed(MouseEvent e) {
  selected = -1;
  double minDist = Float.MAX_VALUE;
  for (int i = 0; i < polygon.npoints; ++i) {
    double dist = Point2D.distance(polygon.xpoints[i], polygon.ypoints[i], e.getX(), e.getY());
    if (dist < minDist) {
      minDist = dist;
      selected = i;
    }
  }
  if (e.isMetaDown()) {
    polygon.addPoint(e.getX(), e.getY());
    if (selected >= 0) {
      for (int i = polygon.npoints - 1; i > selected; --i) {
        polygon.xpoints[i] = polygon.xpoints[i - 1];
        polygon.ypoints[i] = polygon.ypoints[i - 1];
      }
      polygon.xpoints[selected] = e.getX();
      polygon.ypoints[selected] = e.getY();
    }
  }
}
 
Example 3
Project: jtk   File: PickContext.java   View Source Code Vote up 6 votes
/**
 * Constructs a pick context for the specified mouse event.
 * @param event the mouse event.
 */
public PickContext(MouseEvent event) {
  super((ViewCanvas)event.getSource());
  _event = event;
  int xp = event.getX();
  int yp = event.getY();

  // The near endpoint.
  Point3 near = new Point3(xp,yp,0.0);

  // The far endpoint.
  Point3 far = new Point3(xp,yp,1.0);

  // The pick segment, transformed to world coordinates.
  _pickSegment = new Segment(near,far);
  _pickSegment.transform(getPixelToWorld());
  _nearPoint = _pickSegment.getA();
  _farPoint = _pickSegment.getB();
}
 
Example 4
Project: incubator-netbeans   File: BaseCaret.java   View Source Code Vote up 6 votes
/**
 * Determines if the following are true:
 * <ul>
 * <li>the press event is located over a selection
 * <li>the dragEnabled property is true
 * <li>A TranferHandler is installed
 * </ul>
 * <p>
 * This is implemented to check for a TransferHandler.
 * Subclasses should perform the remaining conditions.
 */
protected boolean isDragPossible(MouseEvent e) {
    JComponent comp = getEventComponent(e);
    boolean possible =  (comp == null) ? false : (comp.getTransferHandler() != null);
    if (possible) {
        JTextComponent c = (JTextComponent) getEventComponent(e);
        if (c.getDragEnabled()) {
            Caret caret = c.getCaret();
            int dot = caret.getDot();
            int mark = caret.getMark();
            if (dot != mark) {
                Point p = new Point(e.getX(), e.getY());
                int pos = c.viewToModel(p);

                int p0 = Math.min(dot, mark);
                int p1 = Math.max(dot, mark);
                if ((pos >= p0) && (pos < p1)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 5
Project: openjdk-jdk10   File: DrawTest.java   View Source Code Vote up 6 votes
@Override
public void mousePressed(MouseEvent e) {
    e.consume();
    switch (mode) {
        case LINES:
            x1 = e.getX();
            y1 = e.getY();
            x2 = -1;
            break;
        case POINTS:
        default:
            colors.add(getForeground());
            lines.add(new Rectangle(e.getX(), e.getY(), -1, -1));
            x1 = e.getX();
            y1 = e.getY();
            repaint();
            break;
    }
}
 
Example 6
Project: BEAST   File: ErrorDisplayer.java   View Source Code Vote up 6 votes
/**
 * checks if the mouse position is over a part of the code which contains an error.
 * if so, it displays a popupmenu with the error message
 * @param e
 */
@Override
public void mouseMoved(MouseEvent e) {
    Point pt = new Point(e.getX(), e.getY());
    int pos = pane.viewToModel(pt);
    if(pos == JTextPaneToolbox.getText(pane).length()) {
        pane.setToolTipText(null);
        //errorPopupMenu.setVisible(false);
        return;
    }
    if(Math.abs(errorPopupMenu.getLocation().x - pt.getX()) < 10 &&
            Math.abs(errorPopupMenu.getLocation().x - pt.getX()) < 10 && errorPopupMenu.isVisible()) return;
    for(int i = 0; i < absPosToMsg.size(); ++i) {
        if(absPosToMsg.get(i).x <= pos && absPosToMsg.get(i).y >= pos) {
            pane.setToolTipText(msges.get(i));
            //errorPopupMenu.getErrorItem().setText(msges.get(i));
            //errorPopupMenu.show(pane, e.getX(), e.getY() + 20);
            return;
        }
    }
    pane.setToolTipText(null);
    /*if(errorPopupMenu.isVisible()) {            
        errorPopupMenu.setVisible(false);
    }*/
}
 
Example 7
Project: The-Mysterious-Mind-Of-Jack   File: Mouse.java   View Source Code Vote up 5 votes
public void mouseMoved(MouseEvent e) {
	mouseX = e.getX();
	mouseY = e.getY();

	MouseMovedEvent event = new MouseMovedEvent(e.getX(), e.getY());
	try {
		eventListener.onEvent(event);
	} catch (Exception ex) {}
}
 
Example 8
Project: Cognizant-Intelligent-Test-Scripter   File: Cropper.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent e) {
    if (SwingUtilities.isLeftMouseButton(e)) {
        setOffsetMarker(e);
        drag = false;
        click.x = e.getX();
        click.y = e.getY();
    } else if (SwingUtilities.isRightMouseButton(e) && rcDisArm) {
        hideCropper();
    }

}
 
Example 9
Project: jtk   File: DragContext.java   View Source Code Vote up 5 votes
/**
 * Updates this drag context for the specified mouse event. Updates the 
 * current mouse event and the current point's local, world, and pixel 
 * coordinates. Mouse motion listeners call this method as the mouse is 
 * dragged.
 * @param event the mouse event.
 */
public void update(MouseEvent event) {
  _event = event;
  _pointPixel.x = event.getX();
  _pointPixel.y = event.getY();
  _pointLocal = _pixelToLocal.times(_pointPixel);
  _pointWorld = _pixelToWorld.times(_pointPixel);
}
 
Example 10
Project: apcs_final   File: Mouse.java   View Source Code Vote up 5 votes
public void mouseDragged(MouseEvent e)
{
	int x = e.getX();
	int y = e.getY();
	int button = e.getButton();
	l.mouseDragged(x, y, button);
}
 
Example 11
Project: parabuild-ci   File: ChartPanel.java   View Source Code Vote up 5 votes
/**
 * Implementation of the MouseMotionListener's method.
 *
 * @param e  the event.
 */
public void mouseMoved(MouseEvent e) {
    Graphics2D g2 = (Graphics2D) getGraphics();
    if (this.horizontalAxisTrace) {
        drawHorizontalAxisTrace(g2, e.getX());
    }
    if (this.verticalAxisTrace) {
        drawVerticalAxisTrace(g2, e.getY());
    }
    g2.dispose();
    
    Object[] listeners = this.chartMouseListeners.getListeners(
            ChartMouseListener.class);
    if (listeners.length == 0) {
        return;
    }
    Insets insets = getInsets();
    int x = (int) ((e.getX() - insets.left) / this.scaleX);
    int y = (int) ((e.getY() - insets.top) / this.scaleY);

    ChartEntity entity = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
        }
    }
    
    // we can only generate events if the panel's chart is not null
    // (see bug report 1556951)
    if (this.chart != null) {
        ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);
        for (int i = listeners.length - 1; i >= 0; i -= 1) {
            ((ChartMouseListener) listeners[i]).chartMouseMoved(event);
        }
    }

}
 
Example 12
Project: QN-ACTR-Release   File: FuzzyKSingleClusterScatter.java   View Source Code Vote up 5 votes
public void mouseDragged(MouseEvent e) {
	if ((e.getX() - UpperLeftGraph.x) >= 0 && (e.getY() - UpperLeftGraph.y) >= 0
			&& (e.getX() - UpperLeftGraph.x) < FuzzyKSingleClusterScatter.this.WIDTH
			&& (e.getY() - UpperLeftGraph.y) < FuzzyKSingleClusterScatter.this.HEIGHT && zoomming) {
		xEnd = e.getX();
		yEnd = e.getY();
		p.repaint();
	}
}
 
Example 13
Project: DreamBlocks   File: AwtEventsHandler.java   View Source Code Vote up 4 votes
@Override
public void mouseMoved(MouseEvent arg0) {
	game.screenMousePos.x = arg0.getX();
	game.screenMousePos.y = arg0.getY();
}
 
Example 14
Project: Logisim   File: DipSwitch.java   View Source Code Vote up 4 votes
@Override
public void mouseReleased(InstanceState state, MouseEvent e) {
	pinValues obj = (pinValues) state.getData();
	Location loc = state.getInstance().getLocation();
	int cx = loc.getX();
	int cy = loc.getY();
	Direction dir = state.getAttributeValue(StdAttr.FACING);
	int gx = e.getX();
	int gy = e.getY();
	int x = gx - cx;
	int y = gy - cy;
	if ((y < -5 && y > -25) && (dir == Direction.SOUTH)) {
		x -= 5;
		x = x / 10;
		if (x % 2 == 0) {
			x = x / 2;
			obj.setValue(state, obj.getValue(x).not(), x);// opposite value
		}
	} else if ((x < -5 && x > -25) && (dir == Direction.EAST)) {
		y -= 5;
		y = y / 10;
		if (y % 2 == 0) {
			y = y / 2;
			obj.setValue(state, obj.getValue(y).not(), y);// opposite value
		}
	} else if ((y > 5 && y < 25) && (dir == Direction.NORTH)) {
		x -= 5;
		x = x / 10;
		if (x % 2 == 0) {
			x = x / 2;
			obj.setValue(state, obj.getValue(x).not(), x);// opposite value
		}
	} else if ((x > 5 && x < 25) && (dir == Direction.WEST)) {
		y -= 5;
		y /= 10;
		if (y % 2 == 0) {
			y /= 2;
			obj.setValue(state, obj.getValue(y).not(), y);// opposite value
		}
	}
}
 
Example 15
Project: rapidminer   File: ImprovedNeuralNetVisualizer.java   View Source Code Vote up 4 votes
@Override
public void mouseReleased(MouseEvent e) {
	int xPos = e.getX();
	int yPos = e.getY();
	checkMousePos(xPos, yPos);
}
 
Example 16
Project: jmt   File: FuzzyKSingleClusterScatter.java   View Source Code Vote up 4 votes
public void mouseReleased(MouseEvent e) {
	if (xStart == e.getX() && yStart == e.getY()) {
		zoomming = false;
		return;
	}
	// Controllo che il mouse venga rilasciato all'interno del grafico
	if ((e.getX() - UpperLeftGraph.x) >= 0 && (e.getY() - UpperLeftGraph.y) >= 0
			&& (e.getX() - UpperLeftGraph.x) < FuzzyKSingleClusterScatter.this.WIDTH
			&& (e.getY() - UpperLeftGraph.y) < FuzzyKSingleClusterScatter.this.HEIGHT && zoomming && e.getButton() == MouseEvent.BUTTON1) {
		xEnd = e.getX();
		yEnd = e.getY();
		zoomming = false;
		double rangeX = xMax - xMin;
		double rangeY = yMax - yMin;
		if (xStart < xEnd && yStart < yEnd) {
			xMin = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xStart - UpperLeftGraph.x);
			yMax = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yStart - UpperLeftGraph.y);
			xMax = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xEnd - xStart);
			yMin = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yEnd - yStart);
		}
		if (xStart < xEnd && yStart > yEnd) {
			xMin = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xStart - UpperLeftGraph.x);
			yMax = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yEnd - UpperLeftGraph.y);
			xMax = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xEnd - xStart);
			yMin = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yStart - yEnd);
		}
		if (xStart > xEnd && yStart < yEnd) {
			xMin = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xEnd - UpperLeftGraph.x);
			yMax = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yStart - UpperLeftGraph.y);
			xMax = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xStart - xEnd);
			yMin = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yEnd - yStart);
		}
		if (xStart > xEnd && yStart > yEnd) {
			xMin = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xEnd - UpperLeftGraph.x);
			yMax = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yEnd - UpperLeftGraph.y);
			xMax = xMin + rangeX / FuzzyKSingleClusterScatter.this.WIDTH * (xStart - xEnd);
			yMin = yMax - rangeY / FuzzyKSingleClusterScatter.this.WIDTH * (yStart - yEnd);
		}

		first = true;
		FuzzyKSingleClusterScatter.this.repaint();
		this.repaint();
		return;
	} else {
		// Annullo lo zoom
		zoomming = false;
		this.repaint();
	}
}
 
Example 17
Project: PekaED   File: TilePanel.java   View Source Code Vote up 4 votes
@Override
public void mousePressed(MouseEvent e) {
	if (e.getY() <= 480) {
		x = (e.getX() / 32);
		y = (e.getY() / 32);
	
		w = 32;
		h = 32;
		
		dx = x;
		dy = y;
		
		Data.multiSelectionForeground.clear();
		Data.multiSelectionBackground.clear();
		Data.multiSelectTiles = false;
		
		Data.sx = x;
		Data.sy = y;
		Data.sw = 0;
		Data.sh = 0;
		
		if (Data.currentLayer == Constants.LAYER_FOREGROUND) {
			Data.selectedTileBackground = 255;
			Data.selectedTileForeground = y * (320 / 32) + x;
		} else if (Data.currentLayer == Constants.LAYER_BACKGROUND) {
			Data.selectedTileForeground = 255;
			Data.selectedTileBackground = y * (320 / 32) + x;
		} else {
			Data.selectedTileForeground = y * (320 / 32) + x;
			Data.selectedTileBackground = y * (320 / 32) + x;
		}
		
		Data.selectedSprite = 255;
		Data.selectedTool = Data.TOOL_BRUSH;
		pk.setToolButton();
		
		x *= 32;
		y *= 32;
		
		repaint();
	}
}
 
Example 18
Project: GUI   File: MainFrame.java   View Source Code Vote up 4 votes
@Override
public void mousePressed(MouseEvent me) {
    mouseX = me.getX();
    mouseY = me.getY();
}
 
Example 19
Project: Mafia   File: MouseInput.java   View Source Code Vote up 4 votes
@Override
public void mouseMoved(MouseEvent event) {
	mouseX = event.getX();
	mouseY = event.getY();
}
 
Example 20
Project: SimpleRecurrentNetwork   File: InputHandler.java   View Source Code Vote up 4 votes
public void mouseMoved(MouseEvent e) {
    mouseX = e.getX() / 3;
    mouseY = e.getY() / 3;
}