⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diamond.java

📁 windows画图板.类似于windows自带的画图程序!
💻 JAVA
字号:
import java.awt.*;

/**
 *
 * @author hysun
 */
public class Diamond extends RectBoundedShape {
    
    private int[] xS;
    private int[] yS;
    
    public Diamond(Color c, Stroke s, int x, int y) {
        super(c, s, x, y);
        xS = new int[4];
        yS = new int[4];
    }
    
    public Diamond() {
        super();
        xS = new int[4];
        yS = new int[4];
    }
        
    public void draw(Graphics2D g) {
        g.setColor(color);
        g.setStroke(stroke);
        int x, y, w, h;
        if (startX > endX) {
            x = endX;
            w = startX - endX;
        } else {
            x = startX;
            w = endX - startX;
        }
        if (startY > endY) {
            y = endY;
            h = startY - endY;
        } else {
            y = startY;
            h = endY - startY;
        }
        xS[0] = x + w/2;
        yS[0] = y;
        xS[1] = x + w;
        yS[1] = y + h/2;
        xS[2] = x + w/2;
        yS[2] = y + h;
        xS[3] = x;
        yS[3] = y + h/2;
        g.drawPolygon(xS, yS, 4);
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -