Java Code Examples for java.awt.print.PageFormat#REVERSE_LANDSCAPE
The following examples show how to use
java.awt.print.PageFormat#REVERSE_LANDSCAPE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintLayout.java From pumpernickel with MIT License | 6 votes |
/** * This describes a <code>PageFormat</code> as a String. This is provided as * a debugging tool, because <code>PageFormat.toString()</code> doesn't * support this itself. */ public static String toString(PageFormat f) { if (f == null) return "null"; String orientation; if (f.getOrientation() == PageFormat.LANDSCAPE) { orientation = "LANDSCAPE"; } else if (f.getOrientation() == PageFormat.PORTRAIT) { orientation = "PORTRAIT"; } else if (f.getOrientation() == PageFormat.REVERSE_LANDSCAPE) { orientation = "REVERSE_LANDSCAPE"; } else { orientation = "UNKNOWN"; } return ("PageFormat[ " + f.getWidth() + "x" + f.getHeight() + " imageable=(" + f.getImageableX() + ", " + f.getImageableY() + ", " + f.getImageableWidth() + ", " + f.getImageableHeight() + ") orientation=" + orientation + "]"); }
Example 2
Source File: Options.java From ramus with GNU General Public License v3.0 | 5 votes |
public static void setPageFormat(String name, PageFormat pageFormat) { Properties properties = getProperties(name); switch (pageFormat.getOrientation()) { case PageFormat.LANDSCAPE: properties.setProperty(ORIENTATION, LANDSCAPE); break; case PageFormat.PORTRAIT: properties.setProperty(ORIENTATION, PORTRAIT); break; case PageFormat.REVERSE_LANDSCAPE: properties.setProperty(ORIENTATION, REVERSE_LANDSCAPE); break; default: properties.setProperty(ORIENTATION, "EMPTY"); } ; final Paper paper = pageFormat.getPaper(); properties.setProperty(PAPER_IMAGEABLE_HEIGHT, Double.toString(paper .getImageableHeight())); properties.setProperty(PAPER_IMAGEABLE_WIDTH, Double.toString(paper .getImageableWidth())); properties.setProperty(PAPER_IMAGEABLE_X, Double.toString(paper .getImageableX())); properties.setProperty(PAPER_IMAGEABLE_Y, Double.toString(paper .getImageableY())); properties .setProperty(PAPER_HEIGHT, Double.toString(paper.getHeight())); properties.setProperty(PAPER_WIDTH, Double.toString(paper.getWidth())); }
Example 3
Source File: Java14PrintUtil.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private static OrientationRequested mapOrientation( final int orientation ) { switch ( orientation ) { case PageFormat.LANDSCAPE: return OrientationRequested.LANDSCAPE; case PageFormat.REVERSE_LANDSCAPE: return OrientationRequested.REVERSE_LANDSCAPE; case PageFormat.PORTRAIT: return OrientationRequested.PORTRAIT; default: throw new IllegalArgumentException( "The given value is no valid PageFormat orientation." ); } }
Example 4
Source File: PageDefinitionReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Handles the page format. * * @param atts * the attributes. * @throws SAXException * if a parser error occurs or the validation failed. * @noinspection SuspiciousNameCombination */ private PageFormat configurePageSizeAndMargins( final Attributes atts, PageFormat format ) throws SAXException { // (1) Grab the existing default ... float defTopMargin = (float) format.getImageableY(); float defBottomMargin = (float) ( format.getHeight() - format.getImageableHeight() - format.getImageableY() ); float defLeftMargin = (float) format.getImageableX(); float defRightMargin = (float) ( format.getWidth() - format.getImageableWidth() - format.getImageableX() ); // (2) Now configure the new paper-size format = configurePageSize( format, atts ); // (3) Reconfigure margins as requested defTopMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-top" ), defTopMargin ); defBottomMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-bottom" ), defBottomMargin ); defLeftMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-left" ), defLeftMargin ); defRightMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-right" ), defRightMargin ); final Paper p = format.getPaper(); switch ( format.getOrientation() ) { case PageFormat.PORTRAIT: PageFormatFactory.getInstance().setBorders( p, defTopMargin, defLeftMargin, defBottomMargin, defRightMargin ); break; case PageFormat.REVERSE_LANDSCAPE: PageFormatFactory.getInstance().setBorders( p, defLeftMargin, defBottomMargin, defRightMargin, defTopMargin ); break; case PageFormat.LANDSCAPE: PageFormatFactory.getInstance().setBorders( p, defRightMargin, defTopMargin, defLeftMargin, defBottomMargin ); break; default: // will not happen.. throw new IllegalArgumentException( "Unexpected paper orientation." ); } format.setPaper( p ); return format; }
Example 5
Source File: PageReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Handles the page format. * * @param atts * the attributes. * @throws SAXException * if a parser error occurs or the validation failed. * @noinspection SuspiciousNameCombination */ private void handlePageFormat( final Attributes atts ) throws SAXException { final MasterReport report = (MasterReport) getRootHandler().getHelperObject( ReportParserUtil.HELPER_OBJ_REPORT_NAME ); // grab the default page definition ... PageFormat format = report.getPageDefinition().getPageFormat( 0 ); float defTopMargin = (float) format.getImageableY(); float defBottomMargin = (float) ( format.getHeight() - format.getImageableHeight() - format.getImageableY() ); float defLeftMargin = (float) format.getImageableX(); float defRightMargin = (float) ( format.getWidth() - format.getImageableWidth() - format.getImageableX() ); format = createPageFormat( format, atts ); defTopMargin = ParserUtil.parseFloat( atts.getValue( getUri(), PageReadHandler.TOPMARGIN_ATT ), defTopMargin ); defBottomMargin = ParserUtil.parseFloat( atts.getValue( getUri(), PageReadHandler.BOTTOMMARGIN_ATT ), defBottomMargin ); defLeftMargin = ParserUtil.parseFloat( atts.getValue( getUri(), PageReadHandler.LEFTMARGIN_ATT ), defLeftMargin ); defRightMargin = ParserUtil.parseFloat( atts.getValue( getUri(), PageReadHandler.RIGHTMARGIN_ATT ), defRightMargin ); final Paper p = format.getPaper(); switch ( format.getOrientation() ) { case PageFormat.PORTRAIT: PageFormatFactory.getInstance().setBorders( p, defTopMargin, defLeftMargin, defBottomMargin, defRightMargin ); break; case PageFormat.LANDSCAPE: // right, top, left, bottom PageFormatFactory.getInstance().setBorders( p, defRightMargin, defTopMargin, defLeftMargin, defBottomMargin ); break; case PageFormat.REVERSE_LANDSCAPE: PageFormatFactory.getInstance().setBorders( p, defLeftMargin, defBottomMargin, defRightMargin, defTopMargin ); break; default: // will not happen.. throw new IllegalArgumentException( "Unexpected paper orientation." ); } format.setPaper( p ); pageFormat = format; }
Example 6
Source File: PrintPreviewComponent.java From ramus with GNU General Public License v3.0 | 4 votes |
private void setSize() { int pageCount = printable.getPageCount(); rowCount = (pageCount - 1) / columnCount + 1; pageWidth = 0; pageHeight = 0; pages = new Page[pageCount]; PageFormat pageFormat = printable.getPageFormat(); for (int i = 0; i < pageCount; i++) { pageFormat = printable.getPageFormat(pageFormat, i); double w = pageFormat.getWidth() + 1; double h = pageFormat.getHeight() + 1; double iW = pageFormat.getImageableWidth(); double iH = pageFormat.getImageableHeight(); double x = pageFormat.getImageableX(); double y = pageFormat.getImageableY(); reverce = (pageFormat.getOrientation() == PageFormat.REVERSE_LANDSCAPE); /* * if (pageFormat.getOrientation() == PageFormat.LANDSCAPE) { double * t; * * t = w; w = h; h = t; * * t = iW; iW = iH; iH = t; * * t = x; x = y; y = t; } */ Page page = new Page(w, h, x, y, iW, iH); if (pageWidth < w) pageWidth = w; if (pageHeight < h) pageHeight = h; pages[i] = page; } width = (columnCount - 1) * (pageWidth + W_SPACE / zoom) + pageWidth; height = rowCount * (pageHeight + W_SPACE / zoom); Dimension size = new Dimension((int) (width * getZoom()), (int) (height * getZoom())); this.setSize(size); this.setPreferredSize(size); }
Example 7
Source File: SizeReadHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { String ident = value.getStringValue(); if ( ident.equalsIgnoreCase( "auto" ) ) { return CSSAutoValue.getInstance(); } final PageSize ps = PageSizeFactory.getInstance().getPageSizeByName( ident ); if ( ps == null ) { return null; } value = value.getNextLexicalUnit(); int pageOrientation = PageFormat.PORTRAIT; if ( value != null ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } if ( value.getStringValue().equalsIgnoreCase( "landscape" ) ) { pageOrientation = PageFormat.LANDSCAPE; } else if ( value.getStringValue().equalsIgnoreCase( "reverse-landscape" ) ) { pageOrientation = PageFormat.REVERSE_LANDSCAPE; } else if ( value.getStringValue().equalsIgnoreCase( "portrait" ) ) { pageOrientation = PageFormat.PORTRAIT; } else { return null; } } if ( pageOrientation == PageFormat.LANDSCAPE || pageOrientation == PageFormat.REVERSE_LANDSCAPE ) { return new CSSValuePair( CSSNumericValue.createPtValue( ps.getHeight() ), CSSNumericValue.createPtValue( ps.getWidth() ) ); } else { return new CSSValuePair( CSSNumericValue.createPtValue( ps.getWidth() ), CSSNumericValue.createPtValue( ps.getHeight() ) ); } } else { final CSSNumericValue horizontalWidth = (CSSNumericValue) parseWidth( value ); if ( horizontalWidth == null ) { return null; } value = value.getNextLexicalUnit(); final CSSNumericValue verticalWidth; if ( value == null ) { verticalWidth = horizontalWidth; } else { verticalWidth = (CSSNumericValue) parseWidth( value ); if ( verticalWidth == null ) { return null; } } return new CSSValuePair( horizontalWidth, verticalWidth ); } }
Example 8
Source File: StyleFileWriter.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * Compiles a collection of page format properties. * * @param fmt * the pageformat * @param retval * the attribute list * @return The properties. */ private static AttributeList buildPageFormatProperties( final PageFormat fmt, final AttributeList retval ) { if ( fmt == null ) { throw new NullPointerException(); } if ( retval == null ) { throw new NullPointerException(); } final Paper paper = fmt.getPaper(); final int w = (int) paper.getWidth(); final int h = (int) paper.getHeight(); final String pageDefinition = PageFormatFactory.getInstance().getPageFormatName( w, h ); if ( pageDefinition != null ) { retval.setAttribute( BundleNamespaces.STYLE, "pageformat", pageDefinition ); } else { retval.setAttribute( BundleNamespaces.STYLE, "width", String.valueOf( w ) ); retval.setAttribute( BundleNamespaces.STYLE, "height", String.valueOf( h ) ); } final Insets borders = getBorders( paper ); if ( fmt.getOrientation() == PageFormat.REVERSE_LANDSCAPE ) { retval.setAttribute( BundleNamespaces.STYLE, "orientation", "reverse-landscape" ); retval.setAttribute( BundleNamespaces.STYLE, "margin-top", String.valueOf( borders.right ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-left", String.valueOf( borders.top ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-bottom", String.valueOf( borders.left ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-right", String.valueOf( borders.bottom ) ); } else if ( fmt.getOrientation() == PageFormat.PORTRAIT ) { retval.setAttribute( BundleNamespaces.STYLE, "orientation", "portrait" ); retval.setAttribute( BundleNamespaces.STYLE, "margin-top", String.valueOf( borders.top ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-left", String.valueOf( borders.left ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-bottom", String.valueOf( borders.bottom ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-right", String.valueOf( borders.right ) ); } else { retval.setAttribute( BundleNamespaces.STYLE, "orientation", "landscape" ); retval.setAttribute( BundleNamespaces.STYLE, "margin-top", String.valueOf( borders.left ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-left", String.valueOf( borders.bottom ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-bottom", String.valueOf( borders.right ) ); retval.setAttribute( BundleNamespaces.STYLE, "margin-right", String.valueOf( borders.top ) ); } return retval; }
Example 9
Source File: PhysicalPageDrawable.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * @param pageDrawable * @param page * @noinspection SuspiciousNameCombination */ public PhysicalPageDrawable( final LogicalPageDrawable pageDrawable, final PhysicalPageBox page ) { if ( pageDrawable == null ) { throw new NullPointerException(); } if ( page == null ) { throw new NullPointerException(); } this.pageDrawable = pageDrawable; this.globalX = page.getGlobalX(); this.globalY = page.getGlobalY(); final Paper p = new Paper(); final float marginLeft = (float) StrictGeomUtility.toExternalValue( page.getImageableX() ); final float marginRight = (float) StrictGeomUtility.toExternalValue( page.getWidth() - page.getImageableWidth() - page.getImageableX() ); final float marginTop = (float) StrictGeomUtility.toExternalValue( page.getImageableY() ); final float marginBottom = (float) StrictGeomUtility.toExternalValue( page.getHeight() - page.getImageableHeight() - page.getImageableY() ); switch ( page.getOrientation() ) { case PageFormat.PORTRAIT: p.setSize( StrictGeomUtility.toExternalValue( page.getWidth() ), StrictGeomUtility.toExternalValue( page .getHeight() ) ); PageFormatFactory.getInstance().setBorders( p, marginTop, marginLeft, marginBottom, marginRight ); break; case PageFormat.LANDSCAPE: // right, top, left, bottom p.setSize( StrictGeomUtility.toExternalValue( page.getHeight() ), StrictGeomUtility.toExternalValue( page .getWidth() ) ); PageFormatFactory.getInstance().setBorders( p, marginRight, marginTop, marginLeft, marginBottom ); break; case PageFormat.REVERSE_LANDSCAPE: p.setSize( StrictGeomUtility.toExternalValue( page.getHeight() ), StrictGeomUtility.toExternalValue( page .getWidth() ) ); PageFormatFactory.getInstance().setBorders( p, marginLeft, marginBottom, marginRight, marginTop ); break; default: // will not happen.. throw new IllegalArgumentException( "Unexpected page-orientation encountered." ); } this.pageFormat = new PageFormat(); this.pageFormat.setPaper( p ); this.pageFormat.setOrientation( page.getOrientation() ); }