当前位置: 首页 > news >正文

wpsppt网站链接怎么做门户网站制作公司

wpsppt网站链接怎么做,门户网站制作公司,搜索引擎优化的主要策略,邵阳县网站建设公司沙河网站建设公司我最近不得不为FlexGanttFX实现自动滚动功能#xff0c;并认为我的解决方案可能对其他人有用。 您可以在下面的清单中找到它的基本概念。 主要思想是使用后台线程来调整列表视图使用的虚拟流节点的像素位置。 当检测到“靠近”顶部或底部边缘的拖拉时#xff0c;线程开始。 “… 我最近不得不为FlexGanttFX实现自动滚动功能并认为我的解决方案可能对其他人有用。 您可以在下面的清单中找到它的基本概念。 主要思想是使用后台线程来调整列表视图使用的虚拟流节点的像素位置。 当检测到“靠近”顶部或底部边缘的拖拉时线程开始。 “接近”由接近变量定义。 通过为接近值使用属性以及为线程化工作使用类型“任务”和“服务”显然可以改进此代码。 package com.dlsc;import javafx.application.Platform; import javafx.scene.Node; import javafx.scene.control.ListView; import javafx.scene.input.ClipboardContent; import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; import javafx.scene.layout.Region;/** Yes, unfortunately we need to use private API for this.*/ import com.sun.javafx.scene.control.skin.VirtualFlow;public class AutoscrollListViewT extends ListViewT {final double proximity 20;public AutoscrollListView() {addEventFilter(MouseEvent.DRAG_DETECTED,evt - startDrag());addEventFilter(DragEvent.DRAG_OVER,evt - autoscrollIfNeeded(evt));addEventFilter(DragEvent.DRAG_EXITED,evt - stopAutoScrollIfNeeded(evt));addEventFilter(DragEvent.DRAG_DROPPED,evt - stopAutoScrollIfNeeded(evt));addEventFilter(DragEvent.DRAG_DONE,evt - stopAutoScrollIfNeeded(evt));}private void startDrag() {Dragboard db startDragAndDrop(TransferMode.MOVE);ClipboardContent content new ClipboardContent();/** We have to add some content, otherwise drag over* will not be called.*/content.putString(dummy);db.setContent(content);}private void autoscrollIfNeeded(DragEvent evt) {evt.acceptTransferModes(TransferMode.ANY);/** Determine the hot region that will trigger automatic scrolling.* Ideally we use the clipped container of the list view skin but when* the rows are empty the dimensions of the clipped container will be* 0x0. In this case we try to use the virtual flow.*/Region hotRegion getClippedContainer();if (hotRegion.getBoundsInLocal().getWidth() 1) {hotRegion this;if (hotRegion.getBoundsInLocal().getWidth() 1) {stopAutoScrollIfNeeded(evt);return;}}double yOffset 0;// y offsetdouble delta evt.getSceneY() -hotRegion.localToScene(0, 0).getY();if (delta proximity) {yOffset -(proximity - delta);}delta hotRegion.localToScene(0, 0).getY() hotRegion.getHeight() -evt.getSceneY();if (delta proximity) {yOffset proximity - delta;}if (yOffset ! 0) {autoscroll(yOffset);} else {stopAutoScrollIfNeeded(evt);}}private VirtualFlow? getVirtualFlow() {return (VirtualFlow?) lookup(VirtualFlow);}private Region getClippedContainer() {/** Safest way to find the clipped container. lookup() does not work at* all.*/for (Node child :getVirtualFlow().getChildrenUnmodifiable()) {if (child.getStyleClass().contains(clipped-container)) {return (Region) child;}}return null;}class ScrollThread extends Thread {private boolean running true;private double yOffset;public ScrollThread() {super(Autoscrolling List View);setDaemon(true);}Overridepublic void run() {/** Some initial delay, especially useful when* dragging something in from the outside.*/try {Thread.sleep(300);} catch (InterruptedException e1) {e1.printStackTrace();}while (running) {Platform.runLater(() - {scrollY();});try {sleep(15);} catch (InterruptedException e) {e.printStackTrace();}}}private void scrollY() {VirtualFlow? flow getVirtualFlow();flow.adjustPixels(yOffset);}public void stopRunning() {this.running false;}public void setDelta(double yOffset) {this.yOffset yOffset;}}private ScrollThread scrollThread;private void autoscroll(double yOffset) {if (scrollThread null) {scrollThread new ScrollThread();scrollThread.start();}scrollThread.setDelta(yOffset);}private void stopAutoScrollIfNeeded(DragEvent evt) {if (scrollThread ! null) {scrollThread.stopRunning();scrollThread null;}} }翻译自: https://www.javacodegeeks.com/2014/11/javafx-tip-15-listview-autoscrolling.html
http://www.sadfv.cn/news/1144/

相关文章: