本文整理汇总了Java中javafx.scene.input.ScrollEvent.getDeltaY方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollEvent.getDeltaY方法的具体用法?Java ScrollEvent.getDeltaY怎么用?Java ScrollEvent.getDeltaY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.ScrollEvent
的用法示例。
在下文中一共展示了ScrollEvent.getDeltaY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleZoomable
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* Handle the case where a plot implements the {@link Zoomable} interface.
*
* @param zoomable the zoomable plot.
* @param e the mouse wheel event.
*/
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable,
ScrollEvent e) {
// don't zoom unless the mouse pointer is in the plot's data area
ChartRenderingInfo info = canvas.getRenderingInfo();
PlotRenderingInfo pinfo = info.getPlotInfo();
Point2D p = new Point2D.Double(e.getX(), e.getY());
if (pinfo.getDataArea().contains(p)) {
Plot plot = (Plot) zoomable;
// do not notify while zooming each axis
boolean notifyState = plot.isNotify();
plot.setNotify(false);
int clicks = (int) e.getDeltaY();
double zf = 1.0 + this.zoomFactor;
if (clicks < 0) {
zf = 1.0 / zf;
}
if (canvas.isDomainZoomable()) {
zoomable.zoomDomainAxes(zf, pinfo, p, true);
}
if (canvas.isRangeZoomable()) {
zoomable.zoomRangeAxes(zf, pinfo, p, true);
}
plot.setNotify(notifyState); // this generates the change event too
}
}
示例2: 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();
}
示例3: processScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* The process of scrolling value.
*/
private void processScroll(@NotNull final ScrollEvent event) {
if (!event.isControlDown()) return;
final TextField source = (TextField) event.getSource();
final String text = source.getText();
float value;
try {
value = parseFloat(text);
} catch (final NumberFormatException e) {
return;
}
long longValue = (long) (value * 1000);
longValue += event.getDeltaY() * 1;
final String result = String.valueOf(max(min(longValue / 1000F, 1F), 0F));
source.setText(result);
source.positionCaret(result.length());
processChange((KeyEvent) null);
}
示例4: handleZoomable
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* Handle the case where a plot implements the {@link Zoomable} interface.
*
* @param zoomable the zoomable plot.
* @param e the mouse wheel event.
*/
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable,
ScrollEvent e) {
// don't zoom unless the mouse pointer is in the plot's data area
ChartRenderingInfo info = canvas.getRenderingInfo();
PlotRenderingInfo pinfo = info.getPlotInfo();
Point2D p = new Point2D.Double(e.getX(), e.getY());
if (pinfo.getDataArea().contains(p)) {
Plot plot = (Plot) zoomable;
// do not notify while zooming each axis
boolean notifyState = plot.isNotify();
plot.setNotify(false);
int clicks = (int) e.getDeltaY();
double zf = 1.0 + this.zoomFactor;
if (clicks < 0) {
zf = 1.0 / zf;
}
if (true) { //this.chartPanel.isDomainZoomable()) {
zoomable.zoomDomainAxes(zf, pinfo, p, true);
}
if (true) { //this.chartPanel.isRangeZoomable()) {
zoomable.zoomRangeAxes(zf, pinfo, p, true);
}
plot.setNotify(notifyState); // this generates the change event too
}
}
示例5: handleScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
protected void handleScroll(ScrollEvent ev)
{
if(ev.isShiftDown())
{
// TODO horizontal scroll perhaps?
D.print("horizontal scroll", ev.getDeltaX());
}
else if(ev.isShortcutDown())
{
// page up / page down
if(ev.getDeltaY() >= 0)
{
editor.pageUp();
}
else
{
editor.pageDown();
}
}
else
{
// vertical block scroll
editor.blockScroll(ev.getDeltaY() >= 0);
}
}
示例6: 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));
}
}
示例7: mouseWheelMoved
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
public void mouseWheelMoved(ScrollEvent e) {
double scaledDeltaY = e.getDeltaY() > 0 ? -1 : 1;
double formerZoom = zoom;
zoom -= scaledDeltaY;
zoom = zoom <= 1 ? 1 : zoom;
double deltaX = deltaStart.getX() - delta.getX();
double deltaY = deltaStart.getY() - delta.getY();
double projX = (e.getX() + deltaX) / (formerZoom * zoomFactor);
double projY = (e.getY() + deltaY) / (formerZoom * zoomFactor);
double newPointX = (projX * zoom * zoomFactor) - deltaX;
double newPointY = (projY * zoom * zoomFactor) - deltaY;
setDeltaStart(new Point((int) newPointX, (int) newPointY));
delta = new Point((int) e.getX(), (int) e.getY());
}
示例8: 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();
}
示例9: processScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
/**
* The process of scrolling.
*/
@FXThread
private void processScroll(@NotNull final Spinner<Double> spinner, @NotNull final ScrollEvent event) {
if (!event.isControlDown()) return;
final double deltaY = event.getDeltaY();
if (deltaY > 0) {
spinner.increment(1);
} else {
spinner.decrement(1);
}
}
示例10: handleScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
protected void handleScroll(ScrollEvent ev)
{
if(isOverScrollBar(ev.getX(), ev.getY()))
{
return;
}
if(ev.isShiftDown())
{
// TODO horizontal scroll perhaps?
D.print("horizontal scroll", ev.getDeltaX());
}
else if(ev.isShortcutDown())
{
// page up / page down
if(ev.getDeltaY() >= 0)
{
editor.pageUp();
}
else
{
editor.pageDown();
}
}
else
{
// vertical block scroll
editor.blockScroll(ev.getDeltaY() >= 0);
}
}
示例11: onMouseScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void onMouseScroll(ScrollEvent e) {
if (e.getDeltaY() > 0) {
RendererPlatform.enqueue(app -> setAction(app, ActionType.ScrollIn));
} else {
RendererPlatform.enqueue(app -> setAction(app, ActionType.ScrollOut));
}
}
示例12: calculateScale
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
private double calculateScale(ScrollEvent scrollEvent) {
double scale = m_root.getScaleX() + scrollEvent.getDeltaY() / 500;
if (scale <= MIN_SCALE) {
scale = MIN_SCALE;
} else if (scale >= MAX_SCALE) {
scale = MAX_SCALE;
}
return scale;
}
示例13: calculateScale
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
private double calculateScale(ScrollEvent scrollEvent) {
double scale = nodeToZoom.getScaleX() + scrollEvent.getDeltaY() / 300;
if (scale <= 0.75) {
scale = 0.75;
} else if (scale >= 3) {
scale = 3;
}
return scale;
}
示例14: handleMouseScroll
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handleMouseScroll(ScrollEvent event) {
// Get the current z position and modify it by the amount of
// scrolling
double z = camera.getTranslateZ();
double newZ = z + event.getDeltaY();
camera.setTranslateZ(newZ);
}
示例15: handleUserScrolled
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
private void handleUserScrolled(ScrollEvent scrollEvent) {
// If the user scrolled downwards, we don't want to disable auto-scroll,
// so check and return if so.
if (scrollState.get() == ScrollState.SMART_SCROLL || scrollEvent.getDeltaY() <= 0)
return;
logger.debug("User has scrolled upwards while in SCROLL_TO_BOTTOM mode, disabling SCROLL_TO_BOTTOM...");
// Since the user has now scrolled upwards (manually), disable the
// auto-scroll
scrollState.set(ScrollState.SMART_SCROLL);
}