📄 calculaterect.java
字号:
package com.ysu.cwy;
public class CalculateRect {
private MemoryInit memoryInit; //内存初始化对象
private int y; //上一此所画矩形的y坐标
private int hightInit; //整个图形的高度
//构造函数
public CalculateRect(MemoryInit memoryInit,int hightInit) {
super();
this.memoryInit = memoryInit;
y=20;
this.hightInit=hightInit;
}//end method CalculateRect
/**
* @function 计算表示某个内存块的矩形的坐标
* @param memoryBlock 需要计算的内存快
* @return 返回矩形坐标
*/
public Rect calculateRect(MemoryBlock memoryBlock){
Rect rect=null;
int highth=getHight(memoryBlock);
rect=new Rect(y,highth);
y+=(highth+1);
return rect;
}//end method calculateRect
/**
* @function 计算表示某个内存块的矩形的高度
* @param memoryBlock 需要计算的内存快
* @return 返回高度
*/
public int getHight(MemoryBlock memoryBlock){
int blockSize=memoryBlock.getBlockSize();
int hight=(int)((float)blockSize*hightInit/(float)memoryInit.getMemorySize());
return hight;
}//end method getHight
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -