diamond.java

来自「JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流」· Java 代码 · 共 62 行

JAVA
62
字号
/* * Diamond.java * * Created on April 29, 2005, 5:37 PM */package flow.graph.gui.graph.item.unit;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 + =
减小字号Ctrl + -
显示快捷键?