📄 faceview.java
字号:
package com.zcsoft.stock;import java.awt.*;import com.zcsoft.graphics.line.ShapePane;import com.zcsoft.image.ImageMaker;import java.awt.image.*;import java.awt.geom.*;import java.util.HashMap;/** * <p>Title: 仓库正视图绘制器 </p> * <p>Description: 不仅要绘制设备的当前运行状态,还需要绘制 * 库位状态信息。只要库位有托盘,就在上面绘制一张固定的图片。 * * </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: Zhicheng Software&Service Co. Ltd.</p> * @author 蒋智湘 * @version 1.0 */public class FaceView extends ShapePane{ /** 排索引 */ private int rowIndx; /** 缓存的各排的正视图 */ transient HashMap faceImageCache = new HashMap(2); public FaceView() { } public void refreshed() { if(this.isShowing() && getMaker().isVisible()) { this.repaint(); //javax.swing.RepaintManager.currentManager(this).addDirtyRegion(this, 0, 0, this.getWidth(), this.getHeight()); } } /** * 获取堆垛机绘制器 * @return */ public StackerMaker getMaker() { return (StackerMaker)super.getShapeMaker(0); } /** * 设置绘制的排 * 根据排索引, * @param rowIndx 排索引 */ public void setRowIndx(int rowIndx) { this.rowIndx = rowIndx; } /** * @return 对应的排索引 */ public int getRowIndx() { return rowIndx; } /** * 重写超类方法,使得背景可以绘制图片 * @param g */ public void paintChildren(Graphics g) { if (this.getMaker() != null) {// DDJMaker ddj = this.getMaker();// Path path = ddj.getPath();// Dimension cd = ddj.getContainerDimension();// g.drawImage(getFaceImage(ddj)// , ddj.getOrigin().x + ddj.getXOffset()// - ((path.getPoint(1).x - path.getPoint(0).x) - cd.width)/2// , 0// , null); } super.paintChildren(g); } /** * * @param g2 * @param horizonalPath * @param verticalPath * @param totalHeight */ static void drawCells(Graphics2D g2 , int[] horizonalPath , int[] verticalPath , int totalHeight) { int xCnt = horizonalPath.length; int yCnt = verticalPath.length; float offsetX = horizonalPath[xCnt - 1] - horizonalPath[xCnt - 2]; float offsetY = verticalPath[yCnt - 1] - verticalPath[yCnt - 2]; float x1 = horizonalPath[0]; float x2 = horizonalPath[xCnt - 1] + offsetX; float y1 = verticalPath[yCnt - 1]; float y2 = verticalPath[0] - offsetY; int i; //绘制列的左边缘垂直线 float next = 0; float baseHeight = offsetY/4; for (i = 0; i < xCnt; i++) { next = horizonalPath[i]; g2.draw(new Line2D.Float(next, y1, next, y2 - baseHeight)); if (i % 2 == 0) { String no = Integer.toString(i); g2.drawString(no, next - offsetY + (offsetY - g2.getFontMetrics().stringWidth(no)) / 2, y2); } } //封最右边 float pre = horizonalPath[i-2]; next += (next - pre); g2.draw(new Line2D.Float(next, y1, next, y2 - baseHeight)); //绘制层的下边缘水平线(从下往上) for (i = 0; i < yCnt; i++) { next = verticalPath[i]; g2.draw(new Line2D.Float(x1, next, x2, next)); } //封底 g2.draw(new Line2D.Float(x1, y2, x2, y2)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -