本文整理汇总了Java中javafx.scene.input.MouseEvent.getX方法的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.getX方法的具体用法?Java MouseEvent.getX怎么用?Java MouseEvent.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.MouseEvent
的用法示例。
在下文中一共展示了MouseEvent.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canvasClicked
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override
public void canvasClicked(MouseEvent mouseEvent) {
DrawCoords mousePosition = new DrawCoords(mouseEvent.getX(), mouseEvent.getY());
CoordProjector projector = getProjector(boardCanvas);
Coords boardPos = projector.nearestCoords(mousePosition);
if ( !projector.isWithinBounds(mousePosition) )
return;
scorePane.enableButtons();
if ( mouseEvent.getButton() == MouseButton.PRIMARY ) {
if ( !mouseEvent.isShiftDown() )
boardScorer.markGroupDead(boardPos);
else
boardScorer.unmarkGroupDead(boardPos);
}
}
示例2: checkForClick
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void checkForClick(final MouseEvent EVT) {
final double X = EVT.getX();
final double Y = EVT.getY();
popup.setX(EVT.getScreenX());
popup.setY(EVT.getScreenY() - popup.getHeight());
long noOfBars = series.size();
double spacer = width * 0.05;
double mainBarWidth = (width - (spacer * (noOfBars - 1))) / noOfBars;
// Find series with sum of values
double maxSum = -Double.MAX_VALUE;
for (int i = 0 ; i < noOfBars ;i++) {
maxSum = Math.max(maxSum, series.get(i).getItems().stream().mapToDouble(ChartItem::getValue).sum());
}
double stepY = height / maxSum;
ChartItemSeries<ChartItem> selectedSeries = null;
for (int i = 0 ; i < noOfBars ; i++) {
ChartItemSeries<ChartItem> s = series.get(i);
int noOfItems = s.getNoOfItems();
double sumOfItems = s.getItems().stream().mapToDouble(ChartItem::getValue).sum();
double innerBarWidth = mainBarWidth / noOfItems;
double mainBarHeight = sumOfItems * stepY;
double minX = i * mainBarWidth + i * spacer;
if (Helper.isInRectangle(X, Y, minX, height - mainBarHeight, minX + mainBarWidth, height)) {
selectedSeries = s;
}
for (ChartItem item : s.getItems()) {
double innerBarHeight = item.getValue() * stepY;
if (Helper.isInRectangle(X, Y, minX, height - innerBarHeight, minX + innerBarWidth, height)) {
fireSelectionEvent(new SelectionEvent(selectedSeries, item));
return;
}
minX += innerBarWidth;
}
}
if (null != selectedSeries) { fireSelectionEvent(new SelectionEvent(selectedSeries)); }
}
示例3: mousePressed
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
protected void mousePressed(MouseEvent event) {
// ignore clicks outside of the draggable margin
if (!isInDraggableZone(event)) {
return;
}
dragging = true;
// make sure that the minimum height is set to the current height once,
// setting a min height that is smaller than the current height will
// have no effect
if (!initMinHeight) {
region.setMinHeight(region.getHeight());
initMinHeight = true;
}
y = event.getY();
if (!initMinWidth) {
region.setMinWidth(region.getWidth());
initMinWidth = true;
}
x = event.getX();
}
示例4: handleMousePressed
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
/**
* Handles a mouse pressed event by recording the initial mouse pointer
* location.
*
* @param canvas the JavaFX canvas ({@code null} not permitted).
* @param e the mouse event ({@code null} not permitted).
*/
@Override
public void handleMousePressed(ChartCanvas canvas, MouseEvent e) {
Plot plot = canvas.getChart().getPlot();
if (!(plot instanceof Pannable)) {
canvas.clearLiveHandler();
return;
}
Pannable pannable = (Pannable) plot;
if (pannable.isDomainPannable() || pannable.isRangePannable()) {
Point2D point = new Point2D.Double(e.getX(), e.getY());
Rectangle2D dataArea = canvas.findDataArea(point);
if (dataArea != null && dataArea.contains(point)) {
this.panW = dataArea.getWidth();
this.panH = dataArea.getHeight();
this.panLast = point;
canvas.setCursor(javafx.scene.Cursor.MOVE);
}
}
// the actual panning occurs later in the mouseDragged() method
}
示例5: canvasHover
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void canvasHover(MouseEvent mouseEvent) {
double x = mouseEvent.getX();
double y = mouseEvent.getY();
DrawCoords location = new DrawCoords(x, y);
HoverEvent event = new HoverEvent(game, location, game);
game.fireEvent(event);
}
示例6: mouseMoved
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void mouseMoved(MouseEvent e) {
int x = (int)e.getX();
int column = Math.max((int)((x - PADDING_X / 2) / ((2 * RADIUS + MARGIN))), 0);
if (column != mouseOverCol) {
mouseOverCol = column;
draw();
}
}
示例7: recordClick2
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override public void recordClick2(final RFXComponent r, MouseEvent e, boolean withCellInfo) {
final JSONObject event = new JSONObject();
event.put("type", "click");
int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
event.put("button", button);
event.put("clickCount", e.getClickCount());
event.put("modifiersEx", buildModifiersText(e));
double x = e.getX();
double y = e.getY();
Node source = (Node) e.getSource();
Node target = r.getComponent();
Point2D sts = source.localToScreen(new Point2D(0, 0));
Point2D tts = target.localToScreen(new Point2D(0, 0));
x = e.getX() - tts.getX() + sts.getX();
y = e.getY() - tts.getY() + sts.getY();
event.put("x", x);
event.put("y", y);
if (withCellInfo) {
event.put("cellinfo", r.getCellInfo());
}
final JSONObject o = new JSONObject();
o.put("event", event);
fill(r, o);
if (e.getClickCount() == 1) {
clickTimer = new Timer();
clickTimer.schedule(new TimerTask() {
@Override public void run() {
sendRecordMessage(o);
}
}, timerinterval.intValue());
} else if (e.getClickCount() == 2) {
if (clickTimer != null) {
clickTimer.cancel();
clickTimer = null;
}
sendRecordMessage(o);
}
}
示例8: mouseDragged
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void mouseDragged(MouseEvent event) {
if (!dragging) {
return;
}
final double mouseX = event.getX();
final double mouseY = event.getY();
final double newWidth = tile.getMinWidth() + (mouseX - lastX);
final double newHeight = tile.getMinHeight() + (mouseY - lastY);
if (resizeLocation.isHorizontal && newWidth >= tilePane.getTileSize()) {
if (tile.getContent().getView().getMinWidth() < newWidth) {
tile.setMinWidth(newWidth);
}
tile.setMaxWidth(newWidth);
}
if (resizeLocation.isVertical && newHeight >= tilePane.getTileSize()) {
if (tile.getContent().getView().getMinHeight() < newHeight) {
tile.setMinHeight(newHeight);
}
tile.setMaxHeight(newHeight);
}
lastX = mouseX;
lastY = mouseY;
TileLayout layout = tilePane.getTileLayout(tile);
tilePane.setHighlight(true);
tilePane.setHighlightPoint(layout.origin);
tilePane.setHighlightSize(finalSize());
}
示例9: drawingAreaMouseDragged
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML
private void drawingAreaMouseDragged(MouseEvent e)
{
Circle newCircle = new Circle(e.getX(), e.getY(),
radius.getRadius(), brushColor);
drawingAreaAnchorPane.getChildren().add(newCircle);
}
示例10: onSliderPressed
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML
void onSliderPressed(MouseEvent event) {
double percentH = ((100.0 / track_pane.getWidth()) * event.getX()) / 100;
final Color color = paintPicker.getColorPicker().getValue();
addStop(0.0, 1.0, percentH, color);
updateAngle();
}
示例11: setPointCircles
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public void setPointCircles(MouseEvent event, Circle controlPointCircle, DoubleProperty controlPointX,
DoubleProperty controlPointY) {
double x = event.getX() + controlPointCircle.getLayoutX();
double y = event.getY() + controlPointCircle.getLayoutY();
double dataX = getXAxis().getValueForDisplay(x).doubleValue();
double dataY = getYAxis().getValueForDisplay(y).doubleValue();
controlPointX.set(clamp(dataX));
controlPointY.set(clamp(dataY));
requestChartLayout();
}
示例12: onPickerRegionPressed
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML void onPickerRegionPressed(MouseEvent e) {
double mx = e.getX();
double my = e.getY();
// Update UI
final Color color = updateUI_OnPickerChange(mx, my);
// Update model
setPaintProperty(color);
}
示例13: handleMouseMoved
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override
public void handleMouseMoved(ChartCanvas canvas, MouseEvent e) {
double x = e.getX();
double y = e.getY();
ChartEntity entity = canvas.getRenderingInfo().getEntityCollection().getEntity(x, y);
ChartMouseEventFX event = new ChartMouseEventFX(canvas.getChart(), e, entity);
for (ChartMouseListenerFX listener : canvas.getChartMouseListeners()) {
listener.chartMouseMoved(event);
}
}
示例14: onPickerRegionDragged
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML void onPickerRegionDragged(MouseEvent e) {
double mx = e.getX();
double my = e.getY();
// Update UI
final Color color = updateUI_OnPickerChange(mx, my);
// Update model
setPaintProperty(color);
}
示例15: switchPoint
import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void switchPoint(MouseEvent event) {
double tempX = event.getX();
double tempY = event.getY();
if (Math.abs(x1.get() + x.get() - tempX) < 10 && Math.abs(y1.get() + y.get() - tempY) < 10) {
cursor = POINT.L;
setCursor(Cursor.HAND);
} else if (Math.abs(x2.get() + x.get() - tempX) < 10 && Math.abs(y2.get() + y.get() - tempY) < 10) {
setCursor(Cursor.HAND);
cursor = POINT.R;
} else {
cursor = POINT.C;
setCursor(Cursor.CROSSHAIR);
}
event.consume();
}