Package com.google.code.appengine.awt

Examples of com.google.code.appengine.awt.Graphics2D


   * @param axisChart
   * @param iAxisChartDataSet
   **************************************************************************************/
  static void render( AxisChart axisChart, IAxisChartDataSet iAxisChartDataSet )
  {
    Graphics2D g2d = axisChart.getGraphics2D();
    BarChartProperties barChartProperties = (BarChartProperties) iAxisChartDataSet.getChartTypeProperties();
    float barWidth;

    //---y axis position on screen to start drawing.
    float startingX;
View Full Code Here


            (int)Math.ceil(bounds.getWidth()) + 1,
            (int)Math.ceil(bounds.getHeight()) + 1,
            BufferedImage.TYPE_INT_ARGB);

        // fill background
        Graphics2D graphics = image.createGraphics();
        graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
        graphics.fill(graphics.getDeviceConfiguration().getBounds());
        graphics.setComposite(AlphaComposite.SrcOver);

        // draw paint
        graphics.setPaint(paint);
        graphics.translate(- bounds.getMinX(), - bounds.getMinY());
        graphics.fill(shape);
        graphics.dispose();

        // draw image
        Shape clip = getClip();
        clip(shape);
        drawImage(image, (int)bounds.getX(), (int)bounds.getY(), null);
View Full Code Here

   * Draws the chart
   *
   ************************************************************************************************/
  protected void renderChart()
  {
    Graphics2D g2d = getGraphics2D();

    // turn anti-aliasing on
    g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );


//todo : render legend, use scale processor classes,...

    FontRenderContext fontRenderContext = super.getGraphics2D().
View Full Code Here

        BufferedImage bufferedImage = new BufferedImage(
            image.getWidth(),
            image.getHeight(),
            BufferedImage.TYPE_INT_RGB);
        Graphics2D g = (Graphics2D)bufferedImage.getGraphics();
        g.setBackground(bkg);
        g.clearRect(0, 0, image.getWidth(), image.getHeight());
        g.drawRenderedImage(image, new AffineTransform());
        return bufferedImage;
    }
View Full Code Here

            throw new IOException("com.google.code.appengine.awt.Image fetch aborted or errored");
        }
        int w = pg.getWidth();
        int h = pg.getHeight();
        PdfTemplate tp = cb.createTemplate(w, h);
        Graphics2D g2d = tp.createGraphics(w, h, true, quality);
        g2d.drawImage(awtImage, 0, 0, null);
        g2d.dispose();
        return getInstance(tp);
    }
View Full Code Here

                }
            }
        }              

        if (isDstIndex) { // Convert image into indexed color
            Graphics2D g2d = dst.createGraphics();
            g2d.drawImage(res, 0, 0, null);
            g2d.dispose();
            return dst;
        }
       
        return res;
    }
View Full Code Here

   * Renders the legend.
   *
   **********************************************************************************************/
  public void render()
  {
    Graphics2D g2d = this.chart.getGraphics2D();

    //---get the bounds of the image
    Rectangle2D.Float rectangle = new Rectangle2D.Float( this.x, this.y, width - 1, this.height - 1 );

    //---fill the background of the Legend with the specified Paint
    if( this.legendProperties.getBackgroundPaint() != null )
    {
      g2d.setPaint( this.legendProperties.getBackgroundPaint() );
      g2d.fill( rectangle );
    }

    //---draw Legend border
    if( this.legendProperties.getBorderStroke() != null )
    {
      this.legendProperties.getBorderStroke().draw( g2d, rectangle );
    }

    //---dont think we want this so text will be clean but leave commented out.
    //g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );

    //---set the font and text color.
    g2d.setFont( this.legendProperties.getChartFont().getFont() );

    //---icon coordinates
    rectangle.y += this.legendProperties.getEdgePadding() + (this.textProcessor.getTallestLabel() / 2) - (this.iconSide / 2);
    rectangle.width = this.iconSide;
    rectangle.height = this.iconSide;


    float posX = this.x + this.legendProperties.getEdgePadding();
    float fontY = rectangle.y + rectangle.height;


    //---pre calculate utility values
    float yIncrement = this.textProcessor.getTallestLabel() + this.legendProperties.getRowPadding();
    float iconAndPaddingWidth = this.iconSide + this.legendProperties.getIconPadding();

    int labelIndex = 0;

    //LOOP
    for( int j = 0; j < this.numRows; j++ )
    {
      //LOOP
      for( int i = 0; i < this.numColumns; i++ )
      {
        rectangle.x = posX;

        //---display icon
        g2d.setPaint( (Paint) this.paints.get( labelIndex ) );

        // only Point and Line Charts will have shapes drawn

        if( this.shapes.size() > 0 && this.shapes.size() > labelIndex )
        {
          //Shape shape = (Shape)this.shapes.get( labelIndex);

          //---get the original transform so can reset it
          AffineTransform affineTransform = g2d.getTransform();

          //---translate the Shape into position
          g2d.translate( rectangle.x, rectangle.y );

          if( this.fillPointsFlags.size() > 0 )
          {
            if( ((Boolean) this.fillPointsFlags.get( labelIndex )).booleanValue() )
            {
              g2d.fill( (Shape) this.shapes.get( labelIndex ) );

              //---if we are filling the points, see if we should outline the Shape
              //---applicable only to POINt charts
              if( this.pointOutlinePaints.get( labelIndex ) != null )
              {
                g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) );
                g2d.draw( (Shape) this.shapes.get( labelIndex ) );
              }
            }
          }
          else
          {
            // for Point Charts, only draw shape
            if( chartType == ChartType.POINT)
            {
              g2d.draw( (Shape) this.shapes.get( labelIndex ) );
            } else
            // chartType == ChartType.LINE
            // for Line Charts, fill the shape
            {
              //---get the bounds of the shape
              Rectangle2D shapeBounds = ( (Shape) this.shapes.get( labelIndex ) ).getBounds2D();
              double XOffset = shapeBounds.getWidth() / 2;
              double YOffset = shapeBounds.getHeight() / 2;

              g2d.setStroke(this.lineChartProperties.getLineStrokes()[ labelIndex]);

              Line2D.Double line = new Line2D.Double(0, YOffset, this.legendProperties.getIconLineStrokeLength(), YOffset);
              g2d.draw( line );
              // move posX to account for the lineStroke before the shape. for example, ---o
              posX += this.legendProperties.getIconLineStrokeLength();
              //---translate the Shape to adjust for the IconLineStrokeLength
              g2d.translate( this.legendProperties.getIconLineStrokeLength() - XOffset , 0 );


              line.x1 = XOffset;
              g2d.draw( line );


              g2d.fill( (Shape) this.shapes.get( labelIndex ) );

              //---border around icon
              if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 )
              {
                if( this.pointOutlinePaints != null ) {
                  g2d.setStroke( this.legendProperties.getIconBorderStroke() );
                  g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) );
                  g2d.draw( (Shape) this.shapes.get( labelIndex ) );
                }
              }


              // move posX to account for the lineStroke after the shape. for example, o---
              posX += this.legendProperties.getIconLineStrokeLength();
            }
          }
          //---reset original transform
          g2d.setTransform( affineTransform );
        }
        // for other charts, just draw a rectangle
        else
        {
          g2d.fill( rectangle );

          //---border around icon
          if( this.legendProperties.getIconBorderStroke() != null )
          {
            g2d.setStroke( this.legendProperties.getIconBorderStroke() );
            g2d.setPaint( this.legendProperties.getIconBorderPaint() );
            g2d.draw( rectangle );
          }
        }


        //---draw the label
        g2d.setPaint( this.legendProperties.getChartFont().getPaint() );
        posX += iconAndPaddingWidth;
        g2d.drawString( (String) this.labels.get( labelIndex ), posX, fontY );


        if( this.legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_AS_MANY_AS_NEEDED
          || this.legendProperties.getNumColumns() >= this.labels.size() )
        {
View Full Code Here

            if(!convertImagesToJPEG){
                image = com.lowagie.text.Image.getInstance(img, bgColor);
            }
            else{
                BufferedImage scaled = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
                Graphics2D g3 = scaled.createGraphics();
                g3.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);
                g3.dispose();
               
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());
                iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
                iwparam.setCompressionQuality(jpegQuality);//Set here your compression rate
View Full Code Here

                int type = BufferedImage.TYPE_4BYTE_ABGR;
                if (paint.getTransparency() == Transparency.OPAQUE) {
                    type = BufferedImage.TYPE_3BYTE_BGR;
                }
                img = new BufferedImage((int)width, (int)height, type);
                Graphics2D g = (Graphics2D)img.getGraphics();
                g.transform(transform);
                AffineTransform inv = transform.createInverse();
                Shape fillRect = new Rectangle2D.Double(0,0,img.getWidth(),img.getHeight());
                fillRect = inv.createTransformedShape(fillRect);
                g.setPaint(paint);
                g.fill(fillRect);
                if (invert) {
                    AffineTransform tx = new AffineTransform();
                    tx.scale(1,-1);
                    tx.translate(-xoffset,-yoffset);
                    g.drawImage(img,tx,null);
                }
                g.dispose();
                g = null;
                com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null);
                PdfPatternPainter pattern = cb.createPattern(width, height);
                image.setAbsolutePosition(0,0);
                pattern.addImage(image);
View Full Code Here

TOP

Related Classes of com.google.code.appengine.awt.Graphics2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.