【JavaSE】深度理解JVM
2026/7/14 18:11:08
这篇我们从函数调用顺序的角度梳理一下。
_stageWidth(第432-434行):计算舞台宽度,根据是否折折叠历史工具栏决定_extendStageWidth(第36-37行):扩展模式下的舞台宽度计算getAnimateConfig()(第522-544行):获取动画配置,根据firstTool判断是扩展模式还是其他模式startAnimate()()`** (第547-568行):启动生成动画isGenerating = truegetAnimateConfig()获取配置scanCoverConfig和scanLineConfigstopAnimate()(第569-76行):停止动画stopAnimate()(第569-76行):停止动画updateRectSize()(第582-596行):更新矩形尺寸显示handleUpdateExtendSizeEnd()(第598-614行):处理扩展矩形拖拽结束handleExtendStageWheel()(第817-867行):扩展模式下的滚轮缩放
Ctrl按下时触发缩放0.2 ~ 5倍stage.position()和stage.scale()调整位置和大小handleDrawStageWheel()(第922-972行):绘制模式下的滚轮缩放
handleExtendStageWheel()类似updateCursorInverseScale(newScale)更新光标比例polygons: 存储所有多边形currentPolygonIndex: 当前正在编辑的多边形索引editingMode: 编辑模式 (idle,creating,halfDone,finalized)currentSegmentIndex: 当前正在编辑的段索引startNewPolygon()(第1360-1372行):开始新多边形getAnimateConfig()(第522-544行):获取动画配置handleAnimateStart(): 启动动画handleAnimateStop(): 停止动画onPenStageClick()(第1489-1571-1629行)saveState()保存当前状态finalizeBezierSegment()()`** (第1530-1569行)saveState()editingMode = "finalized"tempP2添加到polygon.pointspolygon.segmentsshowHandles状态onPenMouseDown()(第1673-1750行)isCtrlPressedisLongPress = truelongPressStartPoslongPressTimercreatePointAndStraightSegment()(第1641-1671行)saveState()pointssegmentsonBrushMouseMove()(第1203-1259行)cursorLayerConfigclickTolerance)currentBrushStroke.pointsonBrushMouseUp()(第1261-1315行)saveState()watch(brushStrokes)(第1318-1358行)brushStrokes变化brushClipFunc(第1788-1825行)Path2D构造路径ctx.clip()进行裁剪cloneFullState()(第1915-1921行):克隆完整状态(多边形和笔触)restoreState()(第1923-1942行):恢复状态saveState()(第1945-1951行):保存当前状态到撤销栈undo()(第1954-1965行):撤销操作redo()(第1968-1974行):重做操作handleTransformEnd()(第1989-1997行):处理变换结束handleImageDrag()(第1999–?):处理图像拖拽handleHeaderToolChange()(第993-1010行):处理头部工具切换handleSizeCommand():处理尺寸命令handleSingleDownload():处理单张下载handleSingleCollect():处理单张收藏文件的运行逻辑:
执行顺序:
核心模块:
startAnimate()/stopAnimate()handleDrawStageWheel()/handleExtendStageWheel()normalAddPointLogic()/createPointAndStraightSegment()/finalizeBezierSegment()onPenMouseDown()/longPressTimeronBrushMouseDown()/onBrushMouseMove()/onBrushMouseUp()brushClipFunc+Path2DcloneFullState()/restoreState()/saveState()/undo()/redo()