[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...

Norman Richards norman.richards at jboss.com
Wed Jul 4 16:05:20 EDT 2007


  User: nrichards
  Date: 07/07/04 16:05:20

  Modified:    src/pdf/org/jboss/seam/pdf/ui  UIChart.java
  Log:
  write image height/width
  
  Revision  Changes    Path
  1.14      +21 -12    jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChart.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIChart.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChart.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- UIChart.java	1 Jul 2007 23:19:36 -0000	1.13
  +++ UIChart.java	4 Jul 2007 20:05:20 -0000	1.14
  @@ -35,8 +35,8 @@
       private JFreeChart chart = null;
       private byte[] imageData;
          
  -    private float height = 300;
  -    private float width  = 400;    
  +    private int height = 300;
  +    private int width  = 400;    
       
       private String borderBackgroundPaint;
       private String borderPaint;
  @@ -51,14 +51,22 @@
       
       
       
  -    public void setHeight(float height) {
  +    public void setHeight(int height) {
           this.height = height;
       }
       
  -    public void setWidth(float width) {
  +    public int getHeight() {
  +        return (Integer) valueBinding(FacesContext.getCurrentInstance(), "height", height);
  +    }
  +
  +    public void setWidth(int width) {
           this.width = width;
       }
       
  +    public int getWidth() {
  +        return (Integer) valueBinding(FacesContext.getCurrentInstance(), "width", width);        
  +    }
  +    
       public void setBorderBackgroundPaint(String backgroundPaint) {
           this.borderBackgroundPaint = backgroundPaint;
       }
  @@ -138,8 +146,8 @@
          Object[] values = (Object[]) state;
          super.restoreState(context, values[0]);
          
  -       height                = (Float) values[1];
  -       width                 = (Float) values[2];
  +       height                = (Integer) values[1];
  +       width                 = (Integer) values[2];
          borderBackgroundPaint = (String) values[3];
          borderPaint           = (String) values[4];
          borderStroke          = (String) values[5];
  @@ -229,23 +237,21 @@
           
           configurePlot(chart.getPlot());   
           
  -        height = (Float) valueBinding(context, "height", height);
  -        width =  (Float) valueBinding(context, "width", width);        
           
           try { 
               UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
               if (doc != null) {
                   PdfWriter writer = (PdfWriter) doc.getWriter();
                   PdfContentByte cb = writer.getDirectContent(); 
  -                PdfTemplate tp = cb.createTemplate(width, height); 
  -                Graphics2D g2 = tp.createGraphics(width, height, new DefaultFontMapper());             
  -                chart.draw(g2, new Rectangle2D.Double(0, 0, width, height)); 
  +                PdfTemplate tp = cb.createTemplate(getWidth(), getHeight()); 
  +                Graphics2D g2 = tp.createGraphics(getWidth(), getHeight(), new DefaultFontMapper());             
  +                chart.draw(g2, new Rectangle2D.Double(0, 0, getWidth(), getHeight())); 
                   g2.dispose(); 
   
                   image = new ImgTemplate(tp);
               } else {
                   ByteArrayOutputStream stream = new ByteArrayOutputStream();
  -                ChartUtilities.writeChartAsJPEG(stream, chart, (int)width, (int)height);
  +                ChartUtilities.writeChartAsJPEG(stream, chart, (int)getWidth(), (int)getHeight());
   
                   imageData = stream.toByteArray();
                   stream.close();
  @@ -310,6 +316,9 @@
   
               response.writeAttribute("src", url, null);
   
  +            response.writeAttribute("height", getHeight(), null);
  +            response.writeAttribute("width",  getWidth(),  null);
  +
               response.endElement("img");
   
               Manager.instance().beforeRedirect();           
  
  
  



More information about the jboss-cvs-commits mailing list