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

📄 eschergraphics.java

📁 java 报表 to office文档: 本包由java语言开发
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return result;    }    public void drawPolyline(int xPoints[], int yPoints[],				      int nPoints)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"drawPolyline not supported");    }    public void drawRect(int x, int y, int width, int height)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"drawRect not supported");    }    public void drawRoundRect(int x, int y, int width, int height,				       int arcWidth, int arcHeight)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"drawRoundRect not supported");    }    public void drawString(String str, int x, int y)    {        if (str == null || str.equals(""))            return;        Font excelFont = font;        if ( font.getName().equals( "SansSerif" ) )        {            excelFont = new Font( "Arial", font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ) );        }        else        {            excelFont = new Font( font.getName(), font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ));        }        FontDetails d = StaticFontMetrics.getFontDetails( excelFont );        int width = (int) ( (d.getStringWidth( str ) * 8)  + 12 );        int height = (int) ( ( font.getSize() / verticalPixelsPerPoint ) + 6 ) * 2;        y -= ( font.getSize() / verticalPixelsPerPoint ) + 2 * verticalPixelsPerPoint;    // we want to draw the shape from the top-left        HSSFTextbox textbox = escherGroup.createTextbox( new HSSFChildAnchor( x, y, x + width, y + height ) );        textbox.setNoFill( true );        textbox.setLineStyle( HSSFShape.LINESTYLE_NONE );        HSSFRichTextString s = new HSSFRichTextString( str );        HSSFFont hssfFont = matchFont( excelFont );        s.applyFont( hssfFont );        textbox.setString( s );    }    private HSSFFont matchFont( Font font )    {        HSSFColor hssfColor = workbook.getCustomPalette()                .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());        if (hssfColor == null)            hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());        boolean bold = (font.getStyle() & Font.BOLD) != 0;        boolean italic = (font.getStyle() & Font.ITALIC) != 0;        HSSFFont hssfFont = workbook.findFont(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0,                    hssfColor.getIndex(),                    (short)(font.getSize() * 20),                    font.getName(),                    italic,                    false,                    (short)0,                    (byte)0);        if (hssfFont == null)        {            hssfFont = workbook.createFont();            hssfFont.setBoldweight(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0);            hssfFont.setColor(hssfColor.getIndex());            hssfFont.setFontHeight((short)(font.getSize() * 20));            hssfFont.setFontName(font.getName());            hssfFont.setItalic(italic);            hssfFont.setStrikeout(false);            hssfFont.setTypeOffset((short) 0);            hssfFont.setUnderline((byte) 0);        }        return hssfFont;    }    public void drawString(AttributedCharacterIterator iterator,                                    int x, int y)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"drawString not supported");    }    public void fillArc(int x, int y, int width, int height,				 int startAngle, int arcAngle)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"fillArc not supported");    }    public void fillOval(int x, int y, int width, int height)    {        HSSFSimpleShape shape = escherGroup.createShape(new HSSFChildAnchor( x, y, x + width, y + height ) );        shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL);        shape.setLineStyle(HSSFShape.LINESTYLE_NONE);        shape.setFillColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());        shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());    }    public void fillPolygon(int xPoints[], int yPoints[],				     int nPoints)    {        int right  = findBiggest(xPoints);        int bottom = findBiggest(yPoints);        int left   = findSmallest(xPoints);        int top    = findSmallest(yPoints);        HSSFPolygon shape = escherGroup.createPolygon(new HSSFChildAnchor(left,top,right,bottom) );        shape.setPolygonDrawArea(right - left, bottom - top);        shape.setPoints(addToAll(xPoints, -left), addToAll(yPoints, -top));        shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());        shape.setFillColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());    }    private int findBiggest( int[] values )    {        int result = Integer.MIN_VALUE;        for ( int i = 0; i < values.length; i++ )        {            if (values[i] > result)                result = values[i];        }        return result;    }    private int findSmallest( int[] values )    {        int result = Integer.MAX_VALUE;        for ( int i = 0; i < values.length; i++ )        {            if (values[i] < result)                result = values[i];        }        return result;    }    public void fillRect(int x, int y, int width, int height)    {        HSSFSimpleShape shape = escherGroup.createShape(new HSSFChildAnchor( x, y, x + width, y + height ) );        shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);        shape.setLineStyle(HSSFShape.LINESTYLE_NONE);        shape.setFillColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());        shape.setLineStyleColor(foreground.getRed(), foreground.getGreen(), foreground.getBlue());    }    public void fillRoundRect(int x, int y, int width, int height,				       int arcWidth, int arcHeight)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"fillRoundRect not supported");    }    public Shape getClip()    {        return getClipBounds();    }    public Rectangle getClipBounds()    {        return null;    }    public Rectangle getClipRect()    {        return getClipBounds();    }    public Color getColor()    {        return foreground;    }    public Font getFont()    {        return font;    }    public FontMetrics getFontMetrics(Font f)    {        return Toolkit.getDefaultToolkit().getFontMetrics(f);    }    public void setClip(int x, int y, int width, int height)    {        setClip(((Shape) (new Rectangle(x,y,width,height))));    }    public void setClip(Shape shape)    {        // ignore... not implemented    }    public void setColor(Color color)    {        foreground = color;    }    public void setFont(Font f)    {        font = f;    }    public void setPaintMode()    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"setPaintMode not supported");    }    public void setXORMode(Color color)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"setXORMode not supported");    }    public void translate(int x, int y)    {        if (logger.check( POILogger.WARN ))            logger.log(POILogger.WARN,"translate not supported");    }    public Color getBackground()    {        return background;    }    public void setBackground( Color background )    {        this.background = background;    }}

⌨️ 快捷键说明

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