|
Re: Determine size of extended item [message #764693 is a reply to message #764231] |
Mon, 12 December 2011 17:28 |
|
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 #765240 is a reply to message #764955] |
Tue, 13 December 2011 17:21 |
|
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 #766338 is a reply to message #766050] |
Thu, 15 December 2011 15:19 |
|
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
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03384 seconds