Search in sources :

Example 1 with PageSize

use of jgnash.report.pdf.PageSize in project jgnash by ccavanaugh.

the class PageFormatDialogController method handlePageSizeChange.

private void handlePageSizeChange() {
    final PageSize pageSize = pageSizeComboBox.getValue();
    final Unit unit = unitsComboBox.getValue();
    // convert points to selected unit of measure
    widthField.setDecimal(new BigDecimal(pageSize.width / unit.scale));
    heightField.setDecimal(new BigDecimal(pageSize.height / unit.scale));
}
Also used : PageSize(jgnash.report.pdf.PageSize) BigDecimal(java.math.BigDecimal)

Example 2 with PageSize

use of jgnash.report.pdf.PageSize in project jgnash by ccavanaugh.

the class PageFormatDialogController method setPageFormat.

void setPageFormat(final PageFormat pageFormat) {
    this.pageFormat = pageFormat;
    if (pageFormat.getOrientation() == PageFormat.LANDSCAPE) {
        landscapeRadioButton.setSelected(true);
    } else {
        portraitRadioButton.setSelected(true);
    }
    // force for correct form orientation
    pageFormat.setOrientation(PageFormat.PORTRAIT);
    final float width = (float) pageFormat.getWidth();
    final float height = (float) pageFormat.getHeight();
    final float imageableX = (float) pageFormat.getImageableX();
    final float imageableY = (float) pageFormat.getImageableY();
    final float rightMargin = width - (float) pageFormat.getImageableWidth() - imageableX;
    final float bottomMargin = height - (float) pageFormat.getImageableHeight() - imageableY;
    final PageSize oldPageSize = matchPageSize(width, height);
    if (oldPageSize != null) {
        pageSizeComboBox.setValue(oldPageSize);
    }
    // load the fields with the new values
    final Unit currentUnit = unitsComboBox.getValue();
    handleUnitChange(widthField, width, currentUnit);
    handleUnitChange(heightField, height, currentUnit);
    handleUnitChange(leftMarginField, imageableX, currentUnit);
    handleUnitChange(topMarginField, imageableY, currentUnit);
    handleUnitChange(rightMarginField, rightMargin, currentUnit);
    handleUnitChange(bottomMarginField, bottomMargin, currentUnit);
}
Also used : PageSize(jgnash.report.pdf.PageSize)

Example 3 with PageSize

use of jgnash.report.pdf.PageSize in project jgnash by ccavanaugh.

the class ReportPrintFactory method getDefaultPage.

/**
 * Returns the default paper size for a report
 *
 * @return page format
 */
public static PageFormat getDefaultPage() {
    /* A4 is the assumed default */
    PageSize defaultPageSize = PageSize.A4;
    /* US and Canada use letter size as the default */
    final Locale[] letterLocales = new Locale[] { Locale.US, Locale.CANADA, Locale.CANADA_FRENCH };
    if (Arrays.asList(letterLocales).contains(Locale.getDefault())) {
        defaultPageSize = PageSize.LETTER;
    }
    /* Create the default paper size with a default margin */
    final Paper paper = new Paper();
    double width = defaultPageSize.width;
    double height = defaultPageSize.height;
    paper.setSize(width, height);
    paper.setImageableArea(DEFAULT_MARGIN, DEFAULT_MARGIN, width - (2 * DEFAULT_MARGIN), height - (2 * DEFAULT_MARGIN));
    final PageFormat format = new PageFormat();
    format.setPaper(paper);
    return format;
}
Also used : Locale(java.util.Locale) PageFormat(java.awt.print.PageFormat) PageSize(jgnash.report.pdf.PageSize) Paper(java.awt.print.Paper)

Aggregations

PageSize (jgnash.report.pdf.PageSize)3 PageFormat (java.awt.print.PageFormat)1 Paper (java.awt.print.Paper)1 BigDecimal (java.math.BigDecimal)1 Locale (java.util.Locale)1