161 * clone to describe a default page size and orientation. 162 * @param page the {@code PageFormat} to be cloned and altered 163 * @return clone of {@code page}, altered to describe a default 164 * {@code PageFormat}. 165 */ 166 @Override 167 public PageFormat defaultPage(PageFormat page) { 168 PageFormat newPage = (PageFormat)page.clone(); 169 getDefaultPage(newPage); 170 return newPage; 171 } 172 173 @Override 174 protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException { 175 super.setAttributes(attributes); 176 177 if (attributes == null) { 178 return; 179 } 180 181 // See if this has an NSPrintInfo in it. 182 NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class); 183 if (nsPrintInfo != null) { 184 fNSPrintInfo = nsPrintInfo.getValue(); 185 } 186 187 PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class); 188 if (isSupportedValue(pageRangesAttr, attributes)) { 189 SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class); 190 // If rangeSelect is not null, we are using AWT's print dialog that has 191 // All, Selection, and Range radio buttons 192 if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) { 193 int[][] range = pageRangesAttr.getMembers(); 194 // setPageRange will set firstPage and lastPage as called in getFirstPage 195 // and getLastPage 196 setPageRange(range[0][0] - 1, range[0][1] - 1); 197 } else { 198 // if rangeSelect is SunPageSelection.ALL 199 // then setPageRange appropriately 200 setPageRange(-1, -1); 201 } 202 } 203 } 204 205 private void setPageRangeAttribute(int from, int to, boolean isRangeSet) { 206 if (attributes != null) { 546 printerDialog.dispose(); 547 return result; 548 } 549 550 /** 551 * Alters the orientation and Paper to match defaults obtained 552 * from a printer. 553 */ 554 private native void getDefaultPage(PageFormat page); 555 556 /** 557 * validate the paper size against the current printer. 558 */ 559 @Override 560 protected native void validatePaper(Paper origPaper, Paper newPaper ); 561 562 // The following methods are CPrinterJob specific. 563 564 @Override 565 protected void finalize() { 566 if (fNSPrintInfo != -1) { 567 dispose(fNSPrintInfo); 568 } 569 } 570 571 private native long createNSPrintInfo(); 572 private native void dispose(long printInfo); 573 574 private long getNSPrintInfo() { 575 // This is called from the native side. 576 synchronized (fNSPrintInfoLock) { 577 if (fNSPrintInfo == -1) { 578 fNSPrintInfo = createNSPrintInfo(); 579 } 580 return fNSPrintInfo; 581 } 582 } 583 584 private native boolean printLoop(boolean waitUntilDone, int firstPage, int lastPage) throws PrinterException; 585 586 private PageFormat getPageFormat(int pageIndex) { 587 // This is called from the native side. 588 PageFormat page; | 161 * clone to describe a default page size and orientation. 162 * @param page the {@code PageFormat} to be cloned and altered 163 * @return clone of {@code page}, altered to describe a default 164 * {@code PageFormat}. 165 */ 166 @Override 167 public PageFormat defaultPage(PageFormat page) { 168 PageFormat newPage = (PageFormat)page.clone(); 169 getDefaultPage(newPage); 170 return newPage; 171 } 172 173 @Override 174 protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException { 175 super.setAttributes(attributes); 176 177 if (attributes == null) { 178 return; 179 } 180 181 PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class); 182 if (isSupportedValue(pageRangesAttr, attributes)) { 183 SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class); 184 // If rangeSelect is not null, we are using AWT's print dialog that has 185 // All, Selection, and Range radio buttons 186 if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) { 187 int[][] range = pageRangesAttr.getMembers(); 188 // setPageRange will set firstPage and lastPage as called in getFirstPage 189 // and getLastPage 190 setPageRange(range[0][0] - 1, range[0][1] - 1); 191 } else { 192 // if rangeSelect is SunPageSelection.ALL 193 // then setPageRange appropriately 194 setPageRange(-1, -1); 195 } 196 } 197 } 198 199 private void setPageRangeAttribute(int from, int to, boolean isRangeSet) { 200 if (attributes != null) { 540 printerDialog.dispose(); 541 return result; 542 } 543 544 /** 545 * Alters the orientation and Paper to match defaults obtained 546 * from a printer. 547 */ 548 private native void getDefaultPage(PageFormat page); 549 550 /** 551 * validate the paper size against the current printer. 552 */ 553 @Override 554 protected native void validatePaper(Paper origPaper, Paper newPaper ); 555 556 // The following methods are CPrinterJob specific. 557 558 @Override 559 protected void finalize() { 560 synchronized (fNSPrintInfoLock) { 561 if (fNSPrintInfo != -1) { 562 dispose(fNSPrintInfo); 563 } 564 fNSPrintInfo = -1; 565 } 566 } 567 568 private native long createNSPrintInfo(); 569 private native void dispose(long printInfo); 570 571 private long getNSPrintInfo() { 572 // This is called from the native side. 573 synchronized (fNSPrintInfoLock) { 574 if (fNSPrintInfo == -1) { 575 fNSPrintInfo = createNSPrintInfo(); 576 } 577 return fNSPrintInfo; 578 } 579 } 580 581 private native boolean printLoop(boolean waitUntilDone, int firstPage, int lastPage) throws PrinterException; 582 583 private PageFormat getPageFormat(int pageIndex) { 584 // This is called from the native side. 585 PageFormat page; |