Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Determine size of extended item(Need to determine size of parent cell containing my extended item)
Determine size of extended item [message #764231] Sun, 11 December 2011 18:12 Go to next message
Thomas Weinstein is currently offline Thomas WeinsteinFriend
Messages: 5
Registered: July 2009
Junior Member
I've implemented my first extended item following the "rotated label" tutorial.
For rendering I use the simple image approach described there.
Works well but I have one remaining problem:

I want to use the item in a report table.
At the moment it renders with a fixed size which can be set using a custom property I've implemented. But what I really need is to render it dynamically so it fills the cell of the table. I can't find any api to access the width of the parent container my item is contained in.

Thank you very mutch for any idea.
Re: Determine size of extended item [message #764693 is a reply to message #764231] Mon, 12 December 2011 17:28 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Thomas,

It may be a good idea to log an enhancement request for this. If the
designer does not specifically set the width/height getting the parent
dimensions will just return null. For example assume I have the rotated
text in a cell in a grid and I have set the column width in the report.
I can get the size like:

public Object onRowSets( IBaseResultSet[] results ) throws BirtException
{
if ( textItem == null )
{
return null;
}
Object myParent = content.getParent().getParent().getParent();
CellContent myCell = (CellContent) content.getParent();
int colnumber = myCell.getColumn();
if( myParent instanceof TableContent){

TableContent tc = (TableContent) myParent;
Column mycol = (Column) tc.getColumns().get(colnumber);
ColumnDesign coldes = (ColumnDesign) mycol.getGenerateBy();
DimensionType mywid = coldes.getWidth();

}

But if it is auto-sized the width will return null.

Jason

On 12/11/2011 1:12 PM, Thomas Weinstein wrote:
> I've implemented my first extended item following the "rotated label"
> tutorial.
> For rendering I use the simple image approach described there.
> Works well but I have one remaining problem:
>
> I want to use the item in a report table.
> At the moment it renders with a fixed size which can be set using a
> custom property I've implemented. But what I really need is to render it
> dynamically so it fills the cell of the table. I can't find any api to
> access the width of the parent container my item is contained in.
>
> Thank you very mutch for any idea.
Re: Determine size of extended item [message #764955 is a reply to message #764693] Tue, 13 December 2011 06:54 Go to previous messageGo to next message
Thomas Weinstein is currently offline Thomas WeinsteinFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Jason,

thank you very much for your quick response.
I used your code like that:

    private int getParentLengthInPixels( IRowSet[] rowSets )
    {

        Object myParent = content.getParent().getParent().getParent();
        CellContent myCell = (CellContent)content.getParent();
        int colnumber = myCell.getColumn();

        if ( myParent instanceof TableBandContent )
            myParent = ((TableBandContent)myParent).getParent();
        
        if ( myParent instanceof TableContent )
        {
            TableContent tc = (TableContent)myParent;
            
            Column mycol = (Column)tc.   getColumns().get( colnumber );
            ColumnDesign coldes = (ColumnDesign)mycol.getGenerateBy();
            DimensionType mywid = coldes.getWidth();
            System.out.println( "mywid=" + mywid ); // This gives e.g. 21%
            int res = mywid != null ? (int)mywid.convertTo( DimensionType.UNITS_PX ) : -1;
            System.out.println( "res=" + res );
            return res;
        }
        return -1;
    }


The width is not null but e.g. 21%.
But now I have to convert to pixels to render my image.
But when I use the conversion above I get an exception:

java.lang.IllegalArgumentException: "targetUnits"must be one of the absolute units(CM, IN, MM, PT, PC).

So it seems I cannot convert to pixels using convertTo ??
Do you have any idea how I can get pixels?

Best Regards

Thomas
Re: Determine size of extended item [message #765240 is a reply to message #764955] Tue, 13 December 2011 17:21 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Thomas,

What happens if you set the width of the column in a fixed size instead
of %?

Jason

On 12/13/2011 1:54 AM, Thomas Weinstein wrote:
> Hi Jason,
>
> thank you very much for your quick response.
> I used your code like that:
>
>
> private int getParentLengthInPixels( IRowSet[] rowSets )
> {
>
> Object myParent = content.getParent().getParent().getParent();
> CellContent myCell = (CellContent)content.getParent();
> int colnumber = myCell.getColumn();
>
> if ( myParent instanceof TableBandContent )
> myParent = ((TableBandContent)myParent).getParent();
> if ( myParent instanceof TableContent )
> {
> TableContent tc = (TableContent)myParent;
> Column mycol = (Column)tc. getColumns().get( colnumber );
> ColumnDesign coldes = (ColumnDesign)mycol.getGenerateBy();
> DimensionType mywid = coldes.getWidth();
> System.out.println( "mywid=" + mywid ); // This gives e.g. 21%
> int res = mywid != null ? (int)mywid.convertTo( DimensionType.UNITS_PX )
> : -1;
> System.out.println( "res=" + res );
> return res;
> }
> return -1;
> }
>
>
> The width is not null but e.g. 21%. But now I have to convert to pixels
> to render my image.
> But when I use the conversion above I get an exception:
>
> java.lang.IllegalArgumentException: "targetUnits"must be one of the
> absolute units(CM, IN, MM, PT, PC).
>
> So it seems I cannot convert to pixels using convertTo ??
> Do you have any idea how I can get pixels?
>
> Best Regards
>
> Thomas
>
Re: Determine size of extended item [message #766050 is a reply to message #765240] Thu, 15 December 2011 06:22 Go to previous messageGo to next message
Thomas Weinstein is currently offline Thomas WeinsteinFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Jason,

I was two days away so I could not test.
But even if this works it will not solve my problem, because the rptdesign file is generated based on a template and report description outside of BIRT. This report description allows only relative widths for columns.
Is there a way I can determine the width and resolution of the render target in pixels or in cm?

Quote:
Thomas,

What happens if you set the width of the column in a fixed size instead
of %?

Jason

Re: Determine size of extended item [message #766338 is a reply to message #766050] Thu, 15 December 2011 15:19 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I do not know of a way to do it. If you generate html directly from the
designer (ie not using frameset) you can look at the html generated by
view source. You will see there is no absolute sizes generated unless
you specify an absolute size in the designer.

Jason


On 12/15/2011 1:23 AM, Thomas Weinstein wrote:
> Hi Jason,
>
> I was two days away so I could not test. But even if this works it will
> not solve my problem, because the rptdesign file is generated based on a
> template and report description outside of BIRT. This report description
> allows only relative widths for columns.
> Is there a way I can determine the width and resolution of the render
> target in pixels or in cm?
>
> Quote:
>> Thomas,
>>
>> What happens if you set the width of the column in a fixed size
>> instead of %?
>>
>> Jason
>
>
Previous Topic:Moving Reports into Production
Next Topic:How to embed a link into object?
Goto Forum:
  


Current Time: Thu Apr 25 07:41:47 GMT 2024

Powered by FUDForum. Page generated in 0.02998 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top