本文整理汇总了Java中javafx.scene.input.ScrollEvent.consume方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollEvent.consume方法的具体用法?Java ScrollEvent.consume怎么用?Java ScrollEvent.consume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.ScrollEvent
的用法示例。
在下文中一共展示了ScrollEvent.consume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* Zooms the canvas to the mouse pointer
* @param event
*/
@Override
public void handle(ScrollEvent event) {
double delta = 1.2;
double scale = canvas.getScale(); // currently we only use Y, same value is used for X
double oldScale = scale;
if (event.getDeltaY() < 0) {
scale /= delta;
} else {
scale *= delta;
}
scale = clamp(scale, MIN_SCALE, MAX_SCALE);
double f = (scale / oldScale) - 1;
double dx = (event.getSceneX() - (canvas.getBoundsInParent().getWidth() / 2 + canvas.getBoundsInParent().getMinX()));
double dy = (event.getSceneY() - (canvas.getBoundsInParent().getHeight() / 2 + canvas.getBoundsInParent().getMinY()));
canvas.setScale(scale);
canvas.setPivot(f * dx, f * dy);
canvas.setTranslateX(clamp(canvas.getTranslateX(), minX(), maxX()));
canvas.setTranslateY(clamp(canvas.getTranslateX(), minY(), maxY()));
event.consume();
}
示例2: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent event) {
event.consume();
double deltaY = event.getDeltaY();
double deltaX = event.getDeltaX();
if (deltaY < 0) {
scrollPane.setHvalue(Math.min(1, scrollPane.getHvalue() + 0.0007));
} else if (deltaY > 0) {
scrollPane.setHvalue(Math.max(0, scrollPane.getHvalue() - 0.0007));
}
if (deltaX < 0) {
scrollPane.setVvalue(Math.min(1, scrollPane.getVvalue() + 0.05));
} else if (deltaX > 0) {
scrollPane.setVvalue(Math.max(0, scrollPane.getVvalue() - 0.05));
}
}
示例3: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent scrollEvent) {
if (scrollEvent.isControlDown()) {
Point2D mousePos = new Point2D(scrollEvent.getSceneX(), scrollEvent.getSceneY());
Point2D scenePositionToCentreZoomAround = m_root.sceneToLocal(new Point2D(scrollEvent.getSceneX(), scrollEvent.getSceneY()));
final double scale = calculateScale(scrollEvent);
m_root.setScaleX(scale);
m_root.setScaleY(scale);
scrollTo(mousePos, scenePositionToCentreZoomAround);
scrollEvent.consume();
}
}
示例4: wheelZoom
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/** Zoom in/out triggered by mouse wheel
* @param event Scroll event
*/
protected void wheelZoom(final ScrollEvent event)
{
// Invoked by mouse scroll wheel.
// Only allow zoom (with control), not pan.
if (! event.isControlDown())
return;
if (event.getDeltaY() > 0)
zoomInOut(event.getX(), event.getY(), 1.0/ZOOM_FACTOR);
else if (event.getDeltaY() < 0)
zoomInOut(event.getX(), event.getY(), ZOOM_FACTOR);
else
return;
event.consume();
}
示例5: onScrollStarted
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* When the user starts scrolling on the graph.
*
* @param scrollEvent {@link ScrollEvent} associated with the event
*/
@FXML
void onScrollStarted(final ScrollEvent scrollEvent) {
((Node) scrollEvent.getSource()).getScene().setCursor(Cursor.CROSSHAIR);
scrollEvent.consume();
}
示例6: onScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* When the user scroll on the graph.
*
* @param scrollEvent {@link ScrollEvent} associated with the event
*/
@FXML
void onScroll(final ScrollEvent scrollEvent) {
graphMovementCalculator.onScroll(-scrollEvent.getDeltaY());
scrollEvent.consume();
}
示例7: onScrollFinished
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* When the user finished scrolling.
*
* @param scrollEvent {@link ScrollEvent} associated with the event
*/
@FXML
void onScrollFinished(final ScrollEvent scrollEvent) {
((Node) scrollEvent.getSource()).getScene().setCursor(Cursor.DEFAULT);
scrollEvent.consume();
}
示例8: handleScrollGesture
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
private void handleScrollGesture(ScrollEvent e) {
// only react to proper panning gestures that not on the touch screen itself
if ((!e.isDirect()) && !e.isInertia()) {
if (this.panningAction != null) {
if (preferences.getBoolean("invertScroll", false)) {
this.panningAction.accept(-e.getDeltaX(), -e.getDeltaY());
} else {
this.panningAction.accept(e.getDeltaX(), e.getDeltaY());
}
}
}
e.consume();
}
示例9: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent scrollEvent) {
if (scrollEvent.isControlDown()) {
final double scale = calculateScale(scrollEvent);
nodeToZoom.setScaleX(scale);
nodeToZoom.setScaleY(scale);
scrollEvent.consume();
}
}
示例10: onScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* Invoked if the mouse wheel is rotated.
* <p>
* Increments and decrements the value according to the mouse wheel.
*
* @param pScrollEvent the event.
*/
private void onScroll(ScrollEvent pScrollEvent)
{
if (pScrollEvent.getDeltaY() >= 0)
{
getControl().getValueFactory().increment((int)(pScrollEvent.getDeltaY() / pScrollEvent.getMultiplierY()));
}
else
{
// Minus is needed because the decrement step count needs to be positive.
getControl().getValueFactory().decrement((int)(-pScrollEvent.getDeltaY() / pScrollEvent.getMultiplierY()));
}
pScrollEvent.consume();
}
示例11: onScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* Invoked if the mouse wheel scrolls.
*
* @param pScrollEvent the event.
*/
private void onScroll(ScrollEvent pScrollEvent)
{
if (pScrollEvent.isControlDown())
{
pScrollEvent.consume();
double turns = pScrollEvent.getDeltaY() / pScrollEvent.getMultiplierY();
Point2D mousePoint = sceneToLocal(pScrollEvent.getSceneX(), pScrollEvent.getSceneY());
zoom((int)turns, mousePoint.getX(), mousePoint.getY());
}
}
示例12: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent event) {
event.consume();
if (event.getDeltaY() != 0) {
double scaleFactor = (event.getDeltaY() > 0) ? SCALE_DELTA : 1 / SCALE_DELTA;
node.adjustStaticTransform(new TransformMatrix(scaleFactor));
}
}
示例13: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent scrollEvent) {
if (scrollEvent.isControlDown()) {
final double scale = calculateScale(scrollEvent);
nodeToZoom.setScaleX(scale);
nodeToZoom.setScaleY(scale);
scrollEvent.consume();
}
}
示例14: compositeTokenPane_OnScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@FXML
void compositeTokenPane_OnScroll(ScrollEvent event) {
// if event is touch enabled, skip this as it will be handled by onZoom & onRotate handlers
if (event.isDirect())
return;
if (event.isShiftDown()) {
// Note: OK, this is stupid but on Windows shift + mousewheel returns X delta but on Ubuntu it returns Y delta...
double delta = event.getDeltaY();
if (delta == 0)
delta = event.getDeltaX();
Double r = portraitImageView.getRotate() + delta / 20;
if (r < -360d || r > 360d)
r = 0d;
portraitImageView.setRotate(r);
} else {
Double scale = portraitImageView.getScaleY() * Math.pow(1.001, event.getDeltaY());
portraitImageView.setScaleX(scale);
portraitImageView.setScaleY(scale);
}
event.consume();
updateTokenPreviewImageView();
}
示例15: mouseScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@FXML
void mouseScroll(ScrollEvent event) {
event.consume();
final double diff = 0.1;
//scroll pane locations
final double h = scrollPaneLeft.getHvalue();
final double v = scrollPaneLeft.getVvalue();
final double min = 400;
if(event.getDeltaY()>0&&((imageLeft.getBoundsInParent().getWidth()<min)||
imageLeft.getBoundsInParent().getHeight()<min)) {
return;
}
if(event.getDeltaY()<0) {
imageLeft.setScaleX(imageLeft.getScaleX()+diff);
imageLeft.setScaleY(imageLeft.getScaleY()+diff);
} else {
imageLeft.setScaleX(imageLeft.getScaleX()-diff);
imageLeft.setScaleY(imageLeft.getScaleY()-diff);
}
imageRight.setScaleX(imageLeft.getScaleX());
imageRight.setScaleY(imageLeft.getScaleY());
//just set the same ratio of scroll - this should work out mostly ok
scrollPaneLeft.setHvalue(h);
scrollPaneLeft.setVvalue(v);
}