当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent.getX方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:18,代码来源:Scoring.java

示例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)); }
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:40,代码来源:NestedBarChart.java

示例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();
    }
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:27,代码来源:DragResizerXY.java

示例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
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:28,代码来源:PanHandlerFX.java

示例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);
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:9,代码来源:BoardController.java

示例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();
	}
}
 
开发者ID:lukasbischof,项目名称:Orsum-occulendi,代码行数:10,代码来源:GameController.java

示例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);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:WSRecorder.java

示例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());
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:32,代码来源:TileDragResizer.java

示例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); 
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:8,代码来源:PainterController.java

示例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();
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:8,代码来源:GradientPicker.java

示例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();
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:12,代码来源:SplineEditor.java

示例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);
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:9,代码来源:ColorPickerControl.java

示例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);
    }
 }
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:11,代码来源:DispatchHandlerFX.java

示例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);
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:9,代码来源:ColorPickerControl.java

示例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();
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:16,代码来源:DragBoxWithLine.java


注:本文中的javafx.scene.input.MouseEvent.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。