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));
}
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);
}
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;
}
Aggregations