animationpainter.java
来自「用JAVA实现排序等简单算法的演示」· Java 代码 · 共 45 行
JAVA
45 行
package graphicAnimation;
import javax.swing.JComponent;
import animationController.AnimationController;
public abstract class AnimationPainter {
protected JComponent parent = null; // 所有显示空间的父构件,通常是主框架的内容页面
protected JComponent[] toBlock = null;
protected AnimationDriver animationDriver = null; // 当两个区域的动画展示需要同步进行时所使用的演示管理器
protected AnimationController controller = null;
public AnimationPainter(JComponent parent, JComponent[] toBlock, AnimationController controller) {
this.parent = parent;
this.toBlock = toBlock;
this.controller = controller;
}
public void initialize() {
// 清空 parent 中原有的构件
parent.removeAll();
// 使得需要阻塞的GUI构件不可使用
for (int i = 0; i < toBlock.length; i++) toBlock[i].setEnabled(false);
// 创建动画驱动器
animationDriver = new AnimationDriver();
createAnimator();
createAnimationArea();
connectAnimatorAndArea();
useControllerParameter();
// 使得新加入的构件在构件容器 parent 中真正可见
parent.validate();
}
protected abstract void createAnimator();
protected abstract void createAnimationArea();
protected abstract void connectAnimatorAndArea();
protected abstract void useControllerParameter();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?