📄 sortinganimationcontroller.java
字号:
package animationController;
import java.awt.Color;
import testSortAnimator.MainSwingFrame;
import graphicAnimation.AnimationView;
public class SortingAnimationController extends AnimationController {
// 选择在演示时用的一些颜色值
public Color dataColor = AnimationView.midBlue;
public Color compareColor = AnimationView.lightGreen;
public Color swapColor = AnimationView.midRed;
public Color selectColor = AnimationView.midOrange;
// 用于控制演示的一些选项
public int dataSize = 32; // 排序数组的大小
public int maxDataValue = 360;
public int windowWidth = MainSwingFrame.getWidth()-10; // 显示空间的最大宽度
public boolean useDotViewInMainArea = dataSize > 300;
public int windowHeight = Math.max(MainSwingFrame.getHeight()-20, 600);
public int startX = 20;
public int elementWidth = Math.min((windowWidth-2*startX)/dataSize, 39);
public int spacingWidth = elementWidth/3;
public boolean showValue = elementWidth > 20;
public int infoAreaHeight = 25;
public int infoStartY = infoAreaHeight - 8;
public int smallAreaHeight = 95;
public int smallStartY = smallAreaHeight - 12;
public int mainAreaHeight = Math.max(windowHeight-infoAreaHeight-smallAreaHeight, 480);
public int mainStartY = mainAreaHeight-50;
public int mainMiddleY = 50;
public int unitHeight = Math.max((mainAreaHeight-100)/maxDataValue, 1);
public void setDefaultValue() {
windowWidth = MainSwingFrame.getWidth()-10; // 显示空间的最大宽度
useDotViewInMainArea = dataSize > 300;
windowHeight = Math.max(MainSwingFrame.getHeight()-20, 600);
startX = 20;
elementWidth = Math.min((windowWidth-2*startX)/dataSize, 39);
spacingWidth = elementWidth/3;
showValue = elementWidth > 20;
infoAreaHeight = 25;
infoStartY = infoAreaHeight - 8;
smallAreaHeight = 95;
smallStartY = smallAreaHeight - 12;
mainAreaHeight = Math.max(windowHeight-infoAreaHeight-smallAreaHeight, 480);
mainStartY = mainAreaHeight-50;
mainMiddleY = 50;
unitHeight = Math.max((mainAreaHeight-100)/maxDataValue, 1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -