Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Grid in pageheader

  1. #1
    Join Date
    Apr 2003
    Posts
    11

    Default Grid in pageheader

    Hi !

    I am using the API only.

    I want to put a grid with 3 columns and one row in the pageheader. The columns are divided into 20%, 60%, 20%.

    I created a new ItemBand and added to the band a rectangle and a label. The following code should produce the first column.

    Code:
    Element recElement = ItemFactory.createRectangleShapeElement(
                "background", Color.black, new BasicStroke(0.0F),
                new java.awt.geom.Rectangle2D.Float(0, y, -20, rowHeight), 
                true, false);
    
    itemband.addElement(recElement);
    
    Element labelElement = ItemFactory.createLabelElement(
                "Code Element", new java.awt.geom.Rectangle2D.Float(0, y, -20,
                 rowHeight), null, Element.CENTER, Element.MIDDLE, null, 
                 null, "text");
    
    itemband.addElement(recElement);
    But on this way i have some problems. The result does not look like a grid. Does anybody knows a better way, to produce a grid with percent values ?

  2. #2
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    I guess the grid should be printed without any space between the ItemBands, right? Then your rectangle element should have an "y"-value of '0', so that the cell border starts at the top of the row. Additionally, you should define a non-null stroke, or you wont see nothing at all.

    The stroke defines the linewidth of your rectangle. A stroke of '0' will draw nothing.

    Have more fun,
    said Thomas

  3. #3
    Join Date
    Mar 2003
    Posts
    4,947

    Default

    Hi Taqua !

    Thank you for your quick reply. I have still a problem with my grid. The following code does not show a right grid.

    Code:
          PageHeader pageheader = (PageHeader)    ItemFactory.createPageHeader(
                headerHeight, headerFont, null, true, true);
    
         ItemBand itemband = (ItemBand) ItemFactory.createItemBand(
                      rowHeight, itemBandFont, Color.black);
                
         // cell border
         Element recElement = ItemFactory.createRectangleShapeElement(
                "background", Color.black, new BasicStroke(1.0F),
                new java.awt.geom.Rectangle2D.Float(0, 0, -30, rowHeight), true, false);
    
          itemband.addElement(recElement);
    
          // Text in cell
          Element element = null;
          element = ItemFactory.createLabelElement(
                "Code Element", new java.awt.geom.Rectangle2D.Float(0, 0, -30, rowHeight),
                null, Element.LEFT, Element.MIDDLE, null, "Left Text");
    
          itemband.addElement(element);
          
          // Cell border
         recElement = ItemFactory.createRectangleShapeElement(
                "background", Color.black, new BasicStroke(1.0F),
                new java.awt.geom.Rectangle2D.Float(-50, 0, -50, rowHeight), true, false);
    
         itemband.addElement(recElement);
          
          // Text in cell
          element = null;
          element = ItemFactory.createLabelElement(
                "Code Element",
                new java.awt.geom.Rectangle2D.Float(
                   -50, 0, -50, rowHeight), null, Element.LEFT,
                Element.MIDDLE, null, "middle Text");
    
          itemband.addElement(element);
          
          // cell border
          recElement = ItemFactory.createRectangleShapeElement(
                "background", Color.black, new BasicStroke(1.0F),
                new java.awt.geom.Rectangle2D.Float(-20, 0, -20, rowHeight), true,
                false);
    
          itemband.addElement(recElement);
    
          // text in cell
          SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy hh:mm");
    
          element = ItemFactory.createLabelElement(
                "Code Element",
                new java.awt.geom.Rectangle2D.Float(
                   -20, 0, -20, rowHeight), null,
                Element.LEFT, Element.MIDDLE, null, formatter.format(new Date()));
    
          itemband.addElement(element);
          
          header.addElement(itemband);
    Can you see the mistake ?

    tanx, Joerg

  4. #4
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    Your bounds are wrong:

    The first element start at 0 and has a width of 20%.
    So the second element has to start at 20% and has a width of 50%. The last cell starts at 70% and has a width of 30%.

    Correct the x-coordinates and everything will be fine.

    Have more fun,
    said Thomas

  5. #5
    Join Date
    Apr 2003
    Posts
    11

    Default

    you did it !!!

    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.