public PageDefinition performSetup( final PageDefinition original ) { if ( original instanceof SimplePageDefinition ) { final SimplePageDefinition simplePageDefinition = (SimplePageDefinition) original; spanHorizontalField.setText( String.valueOf( simplePageDefinition.getPageCountHorizontal() ) ); spanVerticalField.setText( String.valueOf( simplePageDefinition.getPageCountVertical() ) );
private static void writePageDefinition( final XmlWriter writer, final PageDefinition definition ) throws BundleWriterException, IOException { if ( writer == null ) { throw new NullPointerException(); } if ( definition == null ) { throw new NullPointerException(); } if ( definition instanceof SimplePageDefinition ) { final SimplePageDefinition sdef = (SimplePageDefinition) definition; final int pageCountHorizontal = sdef.getPageCountHorizontal(); final int pageCountVertical = sdef.getPageCountVertical(); final PageFormat pageFormat = sdef.getPageFormat(); final AttributeList attr = new AttributeList(); attr.setAttribute( BundleNamespaces.STYLE, "horizontal-span", String.valueOf( pageCountHorizontal ) ); attr.setAttribute( BundleNamespaces.STYLE, "vertical-span", String.valueOf( pageCountVertical ) ); buildPageFormatProperties( pageFormat, attr ); writer.writeTag( BundleNamespaces.STYLE, "page-definition", attr, XmlWriterSupport.CLOSE ); } else if ( definition instanceof CustomPageDefinition ) { throw new BundleWriterException( "Cannot handle 'CustomPageDefinition' objects." ); } else { throw new BundleWriterException( "Cannot handle generic page-definition objects." ); } }
public void draw( final Graphics2D graphics, final Rectangle2D bounds ) { final PageFormat gpf = getPageFormat(); final Rectangle2D.Double imageableArea = new Rectangle2D.Double( gpf.getImageableX(), gpf.getImageableY(), gpf.getImageableWidth(), gpf .getImageableHeight() ); graphics.setPaint( new Color( 225, 225, 225 ) ); graphics.fill( imageableArea ); graphics.setPaint( Color.gray ); graphics.draw( imageableArea ); final int pcH = pageDefinition.getPageCountHorizontal(); final int pcW = pageDefinition.getPageCountVertical(); final Line2D line = new Line2D.Double(); for ( int splitH = 1; splitH < pcH; splitH += 1 ) { final double xPos = gpf.getImageableX() + ( splitH * gpf.getImageableWidth() ); line.setLine( xPos, gpf.getImageableY(), xPos, gpf.getImageableY() + gpf.getImageableHeight() ); graphics.draw( line ); } for ( int splitW = 1; splitW < pcW; splitW += 1 ) { final double yPos = gpf.getImageableY() + ( splitW * gpf.getImageableHeight() ); line.setLine( gpf.getImageableX(), yPos, gpf.getImageableX() + gpf.getImageableWidth(), yPos ); graphics.draw( line ); } }
private void writePageDefinition() throws IOException { final XmlWriter xmlWriter = getXmlWriter(); final PageDefinition pageDefinition = getReport().getPageDefinition(); if ( pageDefinition instanceof SimplePageDefinition ) { final SimplePageDefinition spdef = (SimplePageDefinition) pageDefinition; final AttributeList attr = new AttributeList(); attr.setAttribute( ExtParserModule.NAMESPACE, "width", String.valueOf( spdef.getPageCountHorizontal() ) ); attr.setAttribute( ExtParserModule.NAMESPACE, "height", String.valueOf( spdef.getPageCountVertical() ) ); xmlWriter.writeTag( ExtParserModule.NAMESPACE, ReportConfigWriter.SIMPLE_PAGE_DEFINITION_TAG, attr, XmlWriterSupport.OPEN ); final AttributeList attributes = buildPageFormatProperties( spdef.getPageFormat( 0 ) ); xmlWriter.writeTag( ExtParserModule.NAMESPACE, ReportConfigWriter.PAGE_TAG, attributes, XmlWriterSupport.CLOSE ); xmlWriter.writeCloseTag(); } else { xmlWriter.writeTag( ExtParserModule.NAMESPACE, ReportConfigWriter.PAGE_DEFINITION_TAG, XmlWriterSupport.OPEN ); final int max = pageDefinition.getPageCount(); for ( int i = 0; i < max; i++ ) { final PageFormat fmt = pageDefinition.getPageFormat( i ); final AttributeList attributes = buildPageFormatProperties( fmt ); xmlWriter.writeTag( ExtParserModule.NAMESPACE, ReportConfigWriter.PAGE_TAG, attributes, XmlWriterSupport.CLOSE ); } xmlWriter.writeCloseTag(); } }
if ( pageDefinition instanceof SimplePageDefinition ) { final SimplePageDefinition spd = (SimplePageDefinition) pageDefinition; report.setPageDefinition( new SimplePageDefinition( pf, spd.getPageCountHorizontal(), spd .getPageCountVertical() ) ); } else {