Listing 1: Plug-in manifest file

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
   <extension
         id="rotatedLabel"
         name="Rotated Label Extension"
         point="org.eclipse.birt.report.designer.ui.reportitemUI">
      <reportItemLabelUI class="org.eclipse.birt.sample.
	  reportitem.rotatedlabel.RotatedLabelUI"/>
      <model extensionName="RotatedLabel"/>
      <palette icon="icons/rotatedlabel.jpg"/>
      <editor
            canResize="true"
            showInDesigner="true"
            showInMasterPage="true"/>
      <outline icon="icons/rotatedlabel.jpg"/>
      <propertyPage class="org.eclipse.birt.sample.reportitem.rotatedlabel.RotatedLabelPropertyEditUIImpl"/>
   </extension>
   <extension
         id="rotatedLabel"
         name="Rotated Label Extension"
         point="org.eclipse.birt.report.model.reportItemModel">
      <reportItem
            class="org.eclipse.birt.sample.reportitem.rotated
			label.RotatedLabelItemFactoryImpl"
            extensionName="RotatedLabel">
         <property
               defaultDisplayName="Rotation Angle"
               defaultValue="-45"
               name="rotationAngle"
               type="integer"/>
         <property
               defaultDisplayName="Display Text"
               defaultValue="Rotated Label"
               name="displayText"
               type="string"/>
      </reportItem>
   </extension>
   <extension
         id="rotatedLabel"
         name="Rotated Label Extension"
         point="org.eclipse.birt.report.engine.reportitem
		 Presentation">
      <reportItem
            class="org.eclipse.birt.sample.reportitem.rotated
			label.RotatedLabelPresentationImpl"
            name="RotatedLabel"/>
   </extension>
</plugin>


Listing 2: The newReportItem( ) method

public class RotatedLabelItemFactoryImpl extends ReportItemFactory implements IMessages
{
public IReportItem newReportItem( DesignElementHandle deh ) {
		return new RotatedLabelReportItemImpl( deh );


Listing 3: The getLabel( ) method

public class RotatedLabelUI extends ReportItemLabelProvider
{
	public String getLabel( ExtendedItemHandle handle )
	{
		if ( handle.getProperty( "displayText" ) != null ) {
			return ( String ) handle.getProperty( "displayText" );
		} else {
			return "Rotated Label";
		}
	}


Listing 4: The onRowSets( ) method

public Object onRowSets( IRowSet[] rowSets ) throws BirtException
	{

		if ( modelHandle == null )
		{
			return null;
		}

		
			// Generate the rotated text image
			graphicsUtil = new GraphicsUtil( );
			org.eclipse.swt.graphics.Image rotatedImage = 
						graphicsUtil.createRotatedText( modelHandle );

			// Save the image to a byte array stream, via an ImageLoader
			ImageLoader imageLoader = new ImageLoader( );
			imageLoader.data = new ImageData[ ] 
			{ rotatedImage.getImageData( ) };
			ByteArrayOutputStream baos = new ByteArrayOutputStream( );
			imageLoader.save( baos, SWT.IMAGE_JPEG );

			return baos.toByteArray( );
	}


Listing 5: The getPropertyDefinitions( ) method

public IPropertyDefinition[ ] getPropertyDefinitions( )
{
	if ( rt == null )
	{
		return null;
	}
	return new IPropertyDefinition[ ]{
			new RotatedLabelPropertyDefinitionImpl ( null,
					"displayText", "property.label.displayText", 
					false, 
					PropertyType.STRING_TYPE,
					null,null,null,true),
			new RotatedLabelPropertyDefinitionImpl ( null,
					"rotationAngle",
					"property.label.rotationAngle", 
					false, 
					PropertyType.INTEGER_TYPE,
					null,null,null,true),
	}
}


Listing 6: The getCateoryTabs( ) method

public class RotatedLabelPropertyEditUIImpl implements IReportItemPropertyEditUI {
	public IPropertyTabUI[ ] getCategoryTabs( ) {
		return new IPropertyTabUI[ ]{
				new RotatedLabelGeneralTabUIImpl( ),
		};
	}
}


Listing 7: The GeneralCategoryWrapper class

static class GeneralCategoryWrapper 
extends AttributesUtil.PageWrapper {
	static String CATEGORY_NAME = "General";

	public void buildContent( Composite parent, 
		Map propertyMap ) {
		parent.setLayout( createGridLayout( 2 ) );
		buildGridControl( parent,
				propertyMap,
				ReportDesignConstants.EXTENDED_ITEM,
				ReportItemHandle.NAME_PROP,
				1,
				false,
				new TextPropertyDescriptor
					( new PropertyProcessor
					( ReportDesignConstants.EXTENDED_ITEM,
						ReportItemHandle.NAME_PROP ) ),
				true,
				150);
				...


Listing 8: The createRotatedText( ) method

public Image createRotatedText( ExtendedItemHandle
modelHandle )
{
	Image stringImage;
	Image image;
	GC gc;
		String text = "";
	if ( modelHandle.getProperty( "displayText" ) != null ) {
		text = ( String ) modelHandle.getProperty
			( "displayText" );
	}
		Integer angle = null;
	if ( modelHandle.getProperty( "rotationAngle" ) != null ) {
		angle = ( Integer ) modelHandle.getProperty
			( "rotationAngle" );
	}
		String fontFamily = "Arial";
	if ( modelHandle.getProperty(Style.FONT_FAMILY_PROP ) != 
		null ) {
		fontFamily = ( String ) modelHandle.getProperty
			( Style.FONT_FAMILY_PROP );
	}
		if ( display == null ) SWT.error
			( SWT.ERROR_THREAD_INVALID_ACCESS ); 

	FontData fontData = new FontData( fontFamily, 14, 0 );
	Font font = new Font( display, fontData );
	try
	{
		gc = new GC( display );
		gc.setFont( font );
		gc.getFontMetrics( ); 
		Point pt = gc.textExtent( text );
		gc.dispose( );
		stringImage = new Image( display, pt.x, pt.y );
		gc = new GC( stringImage );
		gc.setFont( font );
		gc.drawText( text, 0, 0 );
		image = rotateImage( stringImage, angle.doubleValue( ) );
		gc.dispose( ); 
		stringImage.dispose( ); 
		return image;
	}
	catch( Exception e )
	{
		e.printStackTrace( );
	}
	return null;
}