/** * Creates a paper by using the paper size in points found in the int-array. The array must have a length of 2 and the * first value of this array has to contain the width and the second the height parameter. The created Paper has no * ImagableArea defined. * * @param papersize * the definition of the papersize in a 2-element int-array * @return the created paper */ public Paper createPaper( final int[] papersize ) { if ( papersize.length != 2 ) { throw new IllegalArgumentException( "Paper must have a width and a height" ); } return createPaper( (double) papersize[0], (double) papersize[1] ); }
/** * Creates a paper by looking up the given Uppercase name in this classes defined constants. The value if looked up by * introspection, if the value is not defined in this class, null is returned. * * @param name * the name of the constant defining the papersize * @return the defined paper or null, if the name was invalid. */ public Paper createPaper( final String name ) { try { final Field f = PageSize.class.getDeclaredField( name ); final Object o = f.get( null ); if ( o instanceof PageSize == false ) { // Log.debug ("Is no valid pageformat definition"); return null; } final PageSize pageformat = (PageSize) o; return createPaper( pageformat ); } catch ( NoSuchFieldException nfe ) { // Log.debug ("There is no pageformat " + name + " defined."); return null; } catch ( IllegalAccessException aie ) { // Log.debug ("There is no pageformat " + name + " accessible."); return null; } }
/** * Invoked when an action occurs. */ public void actionPerformed( final ActionEvent e ) { final String selectedItem = (String) pageFormatBox.getSelectedItem(); if ( selectedItem == null ) { return; } final Paper paper = PageFormatFactory.getInstance().createPaper( selectedItem ); if ( paper == null ) { return; } pageWidthField.setText( String.valueOf( paper.getWidth() ) ); pageHeightField.setText( String.valueOf( paper.getHeight() ) ); } }
/** * Creates a paper by using the paper size in points found in the int-array. The array must have a length of 2 and the * first value of this array has to contain the width and the second the height parameter. The created Paper has no * ImagableArea defined. * * @param papersize * the definition of the papersize in a 2-element int-array * @return the created paper */ public Paper createPaper( final PageSize papersize ) { return createPaper( papersize.getWidth(), papersize.getHeight() ); }
public static PageFormat create( final PageSize papersize, final int orientation, final Insets margins ) { final PageFormatFactory instance = PageFormatFactory.getInstance(); final PageFormat pageFormat = instance.createPageFormat( instance.createPaper( papersize ), orientation ); instance.setPageMargins( pageFormat, margins ); return pageFormat; }
final Paper p = PageFormatFactory.getInstance().createPaper( pageformatName ); if ( p == null ) { PageDefinitionReadHandler.logger.warn( "Paper size '" + pageformatName + "' is not regognized." ); ParserUtil.parseInt( atts.getValue( getUri(), "height" ), "Specified attribute 'height' is not valid", getLocator() ); final Paper p = PageFormatFactory.getInstance().createPaper( pageformatData ); if ( p == null ) { PageDefinitionReadHandler.logger.warn( "Unable to create the requested Paper size with width "
private SimplePageDefinition createPageDefinition() { final float pageWidth = ParserUtil.parseFloat( pageWidthField.getText(), 0 ); final float pageHeight = ParserUtil.parseFloat( pageHeightField.getText(), 0 ); final int spanHorizontal = ParserUtil.parseInt( spanHorizontalField.getText(), 0 ); final int spanVertical = ParserUtil.parseInt( spanVerticalField.getText(), 0 ); final float marginTop = ParserUtil.parseFloat( marginTopField.getText(), 0 ); final float marginLeft = ParserUtil.parseFloat( marginLeftField.getText(), 0 ); final float marginBottom = ParserUtil.parseFloat( marginBottomField.getText(), 0 ); final float marginRight = ParserUtil.parseFloat( marginRightField.getText(), 0 ); final Paper p = PageFormatFactory.getInstance().createPaper( pageWidth, pageHeight ); final PageFormat pf; if ( portraitModeBox.isSelected() ) { PageFormatFactory.getInstance().setBorders( p, marginTop, marginLeft, marginBottom, marginRight ); pf = PageFormatFactory.getInstance().createPageFormat( p, PageFormat.PORTRAIT ); } else { // noinspection SuspiciousNameCombination PageFormatFactory.getInstance().setBorders( p, marginRight, marginTop, marginLeft, marginBottom ); pf = PageFormatFactory.getInstance().createPageFormat( p, PageFormat.LANDSCAPE ); } return new SimplePageDefinition( pf, spanHorizontal, spanVertical ); } }
final Paper p = PageFormatFactory.getInstance().createPaper( pageformatName ); if ( p == null ) { JFreeReportReadHandler.logger.warn( "Unable to create the requested Paper. " + pageformatName ); ParserUtil.parseInt( atts.getValue( getUri(), JFreeReportReadHandler.HEIGHT_ATT ), "No Height set", getLocator() ); final Paper p = PageFormatFactory.getInstance().createPaper( pageformatData ); if ( p == null ) { JFreeReportReadHandler.logger.warn( "Unable to create the requested Paper. Paper={" + pageformatData[0] + ", "
final Paper p = PageFormatFactory.getInstance().createPaper( pageformatName ); if ( p == null ) { PageReadHandler.logger.warn( "Unable to create the requested Paper. " + pageformatName ); pageformatData[1] = ParserUtil.parseInt( atts.getValue( getUri(), PageReadHandler.HEIGHT_ATT ), "No Height set", getLocator() ); final Paper p = PageFormatFactory.getInstance().createPaper( pageformatData ); if ( p == null ) { PageReadHandler.logger.warn( "Unable to create the requested Paper. Paper={" + pageformatData[0] + ", "
public void testPageSize() throws IOException { final TextFilePrinterDriver pc = new TextFilePrinterDriver( new NullOutputStream(), 12, 12 ); final Paper paper = PageFormatFactory.getInstance().createPaper( PageSize.A4 ); pc.startPage( paper, "ASCII" ); final PlainTextPage page = new PlainTextPage( paper, pc, "ASCII" ); final int width = page.getWidth(); final int height = page.getHeight(); assertEquals( 99, width ); assertEquals( 140, height ); } }
/** * Describes the physical output characteristics like page size, margins, and imaginable area. * * @return */ public PageFormat getPageFormat() { if ( pageDefinition == null ) { return new PageFormat(); } final PageFormat pageFormat = pageDefinition.getPageFormat(); final Paper orgPaper = pageFormat.getPaper(); final PageFormatFactory pff = PageFormatFactory.getInstance(); final double virtualPaperWidth = orgPaper.getImageableWidth() + pff.getLeftBorder( orgPaper ) + pff.getRightBorder( orgPaper ); final double virtualPaperHeight = orgPaper.getImageableHeight() + pff.getTopBorder( orgPaper ) + pff.getBottomBorder( orgPaper ); final Paper p = pff.createPaper( virtualPaperWidth, virtualPaperHeight ); pff.setBorders( p, pff.getTopBorder( orgPaper ), pff.getLeftBorder( orgPaper ), pff.getBottomBorder( orgPaper ), pff.getRightBorder( orgPaper ) ); return pff.createPageFormat( p, pageFormat.getOrientation() ); }