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

📄 styledpainterimpl.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            g.setColor(c);            int topy = next.myTopY + next.myHeight - 3;            g.fillPolygon(new int[] { next.myLeftX, next.myLeftX + 3,                    next.myLeftX }, new int[] { topy, topy, topy + 3 }, 3);        }    };    private RectanglePainter myProjectTaskEndPainter = new RectanglePainter() {        public void paint(Rectangle next) {            Graphics g = myGraphics;            Color c = Color.BLACK;            // if(((TaskActivity)next.getModelObject()).getTask().isCritical())            // c = Color.RED;            g.setColor(c);            int topy = next.myTopY + next.myHeight - 3;            int rightx = next.myLeftX + next.myWidth;            g.fillPolygon(new int[] { rightx - 3, rightx, rightx }, new int[] {                    topy, topy, topy + 3 }, 3);        }    };    private RectanglePainter myMilestonePanter = new RectanglePainter() {        private int[] myXPoints = new int[4];        private int[] myYPoints = new int[4];        public void paint(Rectangle next) {            Object modelObject = next.getModelObject();            if (modelObject instanceof TaskActivity == false) {                throw new RuntimeException(                        "Model object is expected to be TaskActivity ");            }            Task task = ((TaskActivity) modelObject).getTask();            Color c = task.getColor();            Graphics g = myGraphics;            if (myConfig.isCriticalPathOn()                    && ((TaskActivity) next.getModelObject()).getTask()                            .isCritical())                c = Color.RED;            g.setColor(c);            int middleX = (next.myWidth <= next.myHeight) ? next.getRightX()                    - next.myWidth / 2 : next.myLeftX + next.myHeight / 2;            int middleY = next.getBottomY() - next.myHeight / 2;            myXPoints[0] = next.myLeftX;            myXPoints[1] = middleX;            myXPoints[2] = (next.myWidth <= next.myHeight) ? next.getRightX()                    : next.myLeftX + next.myHeight;            myXPoints[3] = middleX;            myYPoints[0] = middleY;            myYPoints[1] = next.myTopY;            myYPoints[2] = middleY;            myYPoints[3] = next.getBottomY();            g.fillPolygon(myXPoints, myYPoints, 4);        }    };    private RectanglePainter myArrowDownPainter = new RectanglePainter() {        private int[] myXPoints = new int[3];        private int[] myYPoints = new int[3];        public void paint(Rectangle next) {            Graphics g = myGraphics;            g.setColor(Color.BLACK);            myXPoints[0] = next.myLeftX;            myXPoints[1] = next.getRightX();            myXPoints[2] = next.getMiddleX();            myYPoints[0] = next.myTopY;            myYPoints[1] = next.myTopY;            myYPoints[2] = next.getBottomY();            g.fillPolygon(myXPoints, myYPoints, 3);        }    };    private RectanglePainter myArrowUpPainter = new RectanglePainter() {        private int[] myXPoints = new int[3];        private int[] myYPoints = new int[3];        public void paint(Rectangle next) {            Graphics g = myGraphics;            g.setColor(Color.BLACK);            myXPoints[0] = next.myLeftX;            myXPoints[1] = next.getRightX();            myXPoints[2] = next.getMiddleX();            myYPoints[0] = next.getBottomY();            myYPoints[1] = next.getBottomY();            myYPoints[2] = next.myTopY;            g.fillPolygon(myXPoints, myYPoints, 3);        }    };    private RectanglePainter myArrowLeftPainter = new RectanglePainter() {        private int[] myXPoints = new int[3];        private int[] myYPoints = new int[3];        public void paint(Rectangle next) {            Graphics g = myGraphics;            g.setColor(Color.BLACK);            myXPoints[0] = next.myLeftX;            myXPoints[1] = next.getRightX();            myXPoints[2] = next.getRightX();            myYPoints[0] = next.getMiddleY();            myYPoints[1] = next.myTopY;            myYPoints[2] = next.getBottomY();            g.fillPolygon(myXPoints, myYPoints, 3);        }    };    private RectanglePainter myArrowRightPainter = new RectanglePainter() {        private int[] myXPoints = new int[3];        private int[] myYPoints = new int[3];        public void paint(Rectangle next) {            Graphics g = myGraphics;            g.setColor(Color.BLACK);            myXPoints[0] = next.myLeftX;            myXPoints[1] = next.getRightX();            myXPoints[2] = next.myLeftX;            myYPoints[0] = next.myTopY;            myYPoints[1] = next.getMiddleY();            myYPoints[2] = next.getBottomY();            g.fillPolygon(myXPoints, myYPoints, 3);        }    };    private RectanglePainter myDayOffPainter = new RectanglePainter() {        public void paint(Rectangle next) {            Graphics g = myGraphics;            String style = next.getStyle();            int margin = StyledPainterImpl.this.margin - 3;            Color c = myConfig.getDayOffColor();            g.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 100));            g.fillRect(next.myLeftX, next.myTopY + margin, next.myWidth,                    next.myHeight - 2 * margin);            g.setColor(Color.BLACK);            g.drawLine(next.myLeftX, next.myTopY + margin, next.myLeftX, next                    .getBottomY()                    - margin);            g.drawLine(next.myLeftX, next.myTopY + margin, next.getRightX(),                    next.myTopY + margin);            g.drawLine(next.myLeftX, next.getBottomY() - margin, next                    .getRightX(), next.getBottomY() - margin);            g.drawLine(next.getRightX(), next.myTopY + margin,                    next.getRightX(), next.getBottomY() - margin);        }    };    private RectanglePainter myResourceLoadPainter = new RectanglePainter() {        public void paint(Rectangle next) {            Graphics g = myGraphics;            String style = next.getStyle();            g.setFont(myConfig.getChartFont());            Color color;            if (style.indexOf("overload") > 0)                color = myConfig.getResourceOverloadColor();            else if (style.indexOf("underload") > 0)                color = myConfig.getResourceUnderLoadColor();            else                color = myConfig.getResourceNormalLoadColor();            g.setColor(color);            g.fillRect(next.myLeftX, next.myTopY + margin, next.myWidth,                    next.myHeight - 2 * margin);            if (style.indexOf(".first") > 0) {                g.setColor(Color.BLACK);                g.drawLine(next.myLeftX, next.myTopY + margin, next.myLeftX,                        next.getBottomY() - margin);            }            if (style.indexOf(".last") > 0) {                g.setColor(Color.BLACK);                g.drawLine(next.getRightX(), next.myTopY + margin, next                        .getRightX(), next.getBottomY() - margin);            }            g.setColor(Color.BLACK);            ResourceLoadRenderer.ResourceLoad load = (ResourceLoadRenderer.ResourceLoad) next                    .getModelObject();            int l = Math.round(load.getLoad());            String disp = l + "%";            int emsLength = myTextLengthCalculator.getTextLength(disp);            boolean display = emsLength <= next.myWidth;            if (load.getLoad() != 100f && display) {                g.drawString(disp, next.getMiddleX()                        - myTextLengthCalculator.getTextLength(disp) / 2,                        next.myTopY + margin + next.myHeight / 2);                g.drawLine(next.myLeftX, next.myTopY + margin, next.myLeftX,                        next.getBottomY() - margin);            }            g.setColor(Color.BLACK);            g.drawLine(next.myLeftX, next.myTopY + margin, next.getRightX(),                    next.myTopY + margin);            g.drawLine(next.myLeftX, next.getBottomY() - margin, next                    .getRightX(), next.getBottomY() - margin);        }    };    private RectanglePainter myPreviousStateTaskRectanglePainter = new RectanglePainter() {        private int[] myXPoints = new int[4];        private int[] myYPoints = new int[4];        public void paint(GraphicPrimitiveContainer.Rectangle next) {            Object modelObject = next.getModelObject();            Graphics g = myGraphics;            String style = next.getStyle();            Color c;            if (style.indexOf("earlier") > 0)                c = myConfig.getEarlierPreviousTaskColor();            else if (style.indexOf("later") > 0)                c = myConfig.getLaterPreviousTaskColor();            else                c = myConfig.getPreviousTaskColor();            g.setColor(c);            if (style.indexOf("milestone") > 0) {                int middleX = (next.myWidth <= next.myHeight) ? next                        .getRightX()                        - next.myWidth / 2 : next.myLeftX + next.myHeight / 2;                int middleY = next.getBottomY() - next.myHeight / 2;                myXPoints[0] = next.myLeftX + 2;                ;                myXPoints[1] = middleX + 3;                myXPoints[2] = (next.myWidth <= next.myHeight) ? next                        .getRightX() + 4 : next.myLeftX + next.myHeight + 4;                myXPoints[3] = middleX + 3;                myYPoints[0] = middleY;                myYPoints[1] = next.myTopY - 1;                ;                myYPoints[2] = middleY;                myYPoints[3] = next.getBottomY() + 1;                ;                g.fillPolygon(myXPoints, myYPoints, 4);            } else if (style.indexOf("super") > 0) {                g.fillRect(next.myLeftX, next.myTopY + next.myHeight - 6,                        next.myWidth, 3);                int topy = next.myTopY + next.myHeight - 3;                // if the super task is completely displayed                // so whe draw the left triangle                if (style.indexOf("apart") <= 0)                    g.fillPolygon(new int[] { next.myLeftX, next.myLeftX + 3,                            next.myLeftX }, new int[] { topy, topy, topy + 3 },                            3);                int rightx = next.myLeftX + next.myWidth;                g.fillPolygon(new int[] { rightx - 3, rightx, rightx },                        new int[] { topy, topy, topy + 3 }, 3);            } else {                g.fillRect(next.myLeftX, next.myTopY, next.myWidth,                        next.myHeight);                g.setColor(Color.black);                g.drawRect(next.myLeftX, next.myTopY, next.myWidth,                        next.myHeight);            }        }    };    private interface RectanglePainter {        public void paint(GraphicPrimitiveContainer.Rectangle next);    }    private class ColouredRectanglePainter implements RectanglePainter {        private Color myColor;        private ColouredRectanglePainter(Color color) {            myColor = color;        }        public void paint(Rectangle next) {            Graphics g = myGraphics;            g.setColor(myColor);            g.fillRect(next.myLeftX, next.myTopY, next.myWidth, next.myHeight);        }    }    public void paint(Text next) {        Font graphicFont = myGraphics.getFont();        int requestedMaxLength = next.getMaxLength();        Color foreColor = next.getForegroundColor();        if (foreColor == null) {            foreColor = Color.BLACK;        }        myGraphics.setColor(foreColor);        if (next.getFont() != null) {            myGraphics.setFont(next.getFont());        } else {            myGraphics.setFont(myConfig.getChartFont());        }        if (next.getStyle() != null && next.getStyle().equals("text.ganttinfo"))//            myGraphics.setFont(myConfig.getChartFont().deriveFont(10f));            myGraphics.setFont(myConfig.getChartFont());        int actualLength;        String nextTextString = next.getText();        if (next.getModelObject() != null) {            TimeUnitText nextText = (TimeUnitText) next.getModelObject();            nextTextString = nextText.getText(requestedMaxLength,                    myTextLengthCalculator);            actualLength = requestedMaxLength;        } else {            actualLength = TextLengthCalculatorImpl.getTextLength(myGraphics,                    next.getText());            if (requestedMaxLength >= 0 && actualLength > requestedMaxLength) {                return;            }        }        int fontHeight = myGraphics.getFont().getSize();        int xleft = next.getLeftX();        int ybottom = next.getBottomY();        if (HAlignment.CENTER == next.getHAlignment()) {            xleft -= actualLength / 2;        }        if (HAlignment.RIGHT == next.getHAlignment()) {            xleft -= actualLength;        }        if (VAlignment.CENTER == next.getVAlignment()) {            ybottom += fontHeight / 2;        }        if (VAlignment.TOP == next.getVAlignment()) {            ybottom += fontHeight;        }        myGraphics.drawString(nextTextString, xleft, ybottom);        myGraphics.setFont(graphicFont);    }}

⌨️ 快捷键说明

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