@Test public void testExtractPageFormat() { verifyPageFormat( PageFormat.PORTRAIT ); verifyPageFormat( PageFormat.LANDSCAPE ); verifyPageFormat( PageFormat.REVERSE_LANDSCAPE ); }
public static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ) { final Media media = (Media) attributeSet.get( Media.class ); final MediaPrintableArea printableArea = (MediaPrintableArea) attributeSet.get( MediaPrintableArea.class ); final OrientationRequested orientationRequested = (OrientationRequested) attributeSet.get( OrientationRequested.class ); final MediaSize mediaSize = lookupMediaSize( media ); if ( mediaSize == null ) { logger.warn( "Unknown media encountered, unable to compute page sizes." ); } final PageFormat pageFormat = new PageFormat(); pageFormat.setPaper( createPaper( mediaSize, printableArea ) ); if ( OrientationRequested.PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } else if ( OrientationRequested.LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.LANDSCAPE ); } else if ( OrientationRequested.REVERSE_LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.REVERSE_LANDSCAPE ); } else if ( OrientationRequested.REVERSE_PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } return pageFormat; }
Java14PrintUtil { public static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ) { final Media media = (Media) attributeSet.get( Media.class ); final MediaPrintableArea printableArea = (MediaPrintableArea) attributeSet.get( MediaPrintableArea.class ); final OrientationRequested orientationRequested = (OrientationRequested) attributeSet.get( OrientationRequested.class ); final MediaSize mediaSize = lookupMediaSize( media ); if ( mediaSize == null ) { logger.warn( "Unknown media encountered, unable to compute page sizes." ); } final PageFormat pageFormat = new PageFormat(); pageFormat.setPaper( createPaper( mediaSize, printableArea ) ); if ( OrientationRequested.PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } else if ( OrientationRequested.LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.LANDSCAPE ); } else if ( OrientationRequested.REVERSE_LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.REVERSE_LANDSCAPE ); } else if ( OrientationRequested.REVERSE_PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } return pageFormat; } }
Java14PrintUtil { public static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ) { final Media media = (Media) attributeSet.get( Media.class ); final MediaPrintableArea printableArea = (MediaPrintableArea) attributeSet.get( MediaPrintableArea.class ); final OrientationRequested orientationRequested = (OrientationRequested) attributeSet.get( OrientationRequested.class ); final MediaSize mediaSize = lookupMediaSize( media ); if ( mediaSize == null ) { logger.warn( "Unknown media encountered, unable to compute page sizes." ); } final PageFormat pageFormat = new PageFormat(); pageFormat.setPaper( createPaper( mediaSize, printableArea ) ); if ( OrientationRequested.PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } else if ( OrientationRequested.LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.LANDSCAPE ); } else if ( OrientationRequested.REVERSE_LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.REVERSE_LANDSCAPE ); } else if ( OrientationRequested.REVERSE_PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } return pageFormat; } private  Java14PrintUtil(); }
Java14PrintUtil { public static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ) { final Media media = (Media) attributeSet.get( Media.class ); final MediaPrintableArea printableArea = (MediaPrintableArea) attributeSet.get( MediaPrintableArea.class ); final OrientationRequested orientationRequested = (OrientationRequested) attributeSet.get( OrientationRequested.class ); final MediaSize mediaSize = lookupMediaSize( media ); if ( mediaSize == null ) { logger.warn( "Unknown media encountered, unable to compute page sizes." ); } final PageFormat pageFormat = new PageFormat(); pageFormat.setPaper( createPaper( mediaSize, printableArea ) ); if ( OrientationRequested.PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } else if ( OrientationRequested.LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.LANDSCAPE ); } else if ( OrientationRequested.REVERSE_LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.REVERSE_LANDSCAPE ); } else if ( OrientationRequested.REVERSE_PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } return pageFormat; } private  Java14PrintUtil(); static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ); static PrintRequestAttributeSet copyConfiguration( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PrintRequestAttributeSet copyAuxillaryAttributes( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ); static void printDirectly( final MasterReport report, PrintService printService ); static boolean print( final MasterReport report ); static boolean print( final MasterReport report, final ReportProgressListener progressListener ); }
Java14PrintUtil { public static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ) { final Media media = (Media) attributeSet.get( Media.class ); final MediaPrintableArea printableArea = (MediaPrintableArea) attributeSet.get( MediaPrintableArea.class ); final OrientationRequested orientationRequested = (OrientationRequested) attributeSet.get( OrientationRequested.class ); final MediaSize mediaSize = lookupMediaSize( media ); if ( mediaSize == null ) { logger.warn( "Unknown media encountered, unable to compute page sizes." ); } final PageFormat pageFormat = new PageFormat(); pageFormat.setPaper( createPaper( mediaSize, printableArea ) ); if ( OrientationRequested.PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } else if ( OrientationRequested.LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.LANDSCAPE ); } else if ( OrientationRequested.REVERSE_LANDSCAPE.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.REVERSE_LANDSCAPE ); } else if ( OrientationRequested.REVERSE_PORTRAIT.equals( orientationRequested ) ) { pageFormat.setOrientation( PageFormat.PORTRAIT ); } return pageFormat; } private  Java14PrintUtil(); static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ); static PrintRequestAttributeSet copyConfiguration( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PrintRequestAttributeSet copyAuxillaryAttributes( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ); static void printDirectly( final MasterReport report, PrintService printService ); static boolean print( final MasterReport report ); static boolean print( final MasterReport report, final ReportProgressListener progressListener ); static final int CONFIGURATION_VALID; static final int CONFIGURATION_REPAGINATE; static final int CONFIGURATION_SHOW_DIALOG; }