869 pageDialog.setBounds(x, y, dlgBounds.width, dlgBounds.height); 870 } 871 pageDialog.show(); 872 873 if (pageDialog.getStatus() == ServiceDialog.APPROVE) { 874 PrintRequestAttributeSet newas = 875 pageDialog.getAttributes(); 876 Class<?> amCategory = SunAlternateMedia.class; 877 878 if (attributes.containsKey(amCategory) && 879 !newas.containsKey(amCategory)) { 880 attributes.remove(amCategory); 881 } 882 attributes.addAll(newas); 883 return attributeToPageFormat(service, attributes); 884 } else { 885 return null; 886 } 887 } 888 889 protected PageFormat getPageFormatFromAttributes() { 890 if (attributes == null || attributes.isEmpty()) { 891 return null; 892 } 893 return attributeToPageFormat(getPrintService(), this.attributes); 894 } 895 896 897 /** 898 * Presents the user a dialog for changing properties of the 899 * print job interactively. 900 * The services browsable here are determined by the type of 901 * service currently installed. 902 * If the application installed a StreamPrintService on this 903 * PrinterJob, only the available StreamPrintService (factories) are 904 * browsable. 905 * 906 * @param attributes to store changed properties. 907 * @return false if the user cancels the dialog and true otherwise. 908 * @exception HeadlessException if GraphicsEnvironment.isHeadless() 909 * returns true. 910 * @see java.awt.GraphicsEnvironment#isHeadless 911 */ 912 public boolean printDialog(final PrintRequestAttributeSet attributes) 913 throws HeadlessException { 914 if (GraphicsEnvironment.isHeadless()) { | 869 pageDialog.setBounds(x, y, dlgBounds.width, dlgBounds.height); 870 } 871 pageDialog.show(); 872 873 if (pageDialog.getStatus() == ServiceDialog.APPROVE) { 874 PrintRequestAttributeSet newas = 875 pageDialog.getAttributes(); 876 Class<?> amCategory = SunAlternateMedia.class; 877 878 if (attributes.containsKey(amCategory) && 879 !newas.containsKey(amCategory)) { 880 attributes.remove(amCategory); 881 } 882 attributes.addAll(newas); 883 return attributeToPageFormat(service, attributes); 884 } else { 885 return null; 886 } 887 } 888 889 protected PageFormat getPageFormatFromAttributes() { 890 if (attributes == null || attributes.isEmpty()) { 891 return null; 892 } 893 894 PageFormat newPf = attributeToPageFormat( 895 getPrintService(), attributes); 896 PageFormat oldPf = null; 897 Pageable pageable = getPageable(); 898 if ((pageable != null) && 899 (pageable instanceof OpenBook) && 900 ((oldPf = pageable.getPageFormat(0)) != null) && 901 (newPf != null)) { 902 // If the attribute set 'attributes' does not contain either 903 // orientation, or media, or imageable area attributes, then use 904 // in the new 'PageFormat' corresponding values of the existing 905 // 'PageFormat'. 906 if (attributes.get(OrientationRequested.class) == null) { 907 newPf.setOrientation(oldPf.getOrientation()); 908 } 909 910 Paper newPaper = newPf.getPaper(); 911 Paper oldPaper = oldPf.getPaper(); 912 boolean oldPaperValWasSet = false; 913 if (attributes.get(MediaSizeName.class) == null) { 914 newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight()); 915 oldPaperValWasSet = true; 916 } 917 if (attributes.get(MediaPrintableArea.class) == null) { 918 newPaper.setImageableArea( 919 oldPaper.getImageableX(), oldPaper.getImageableY(), 920 oldPaper.getImageableWidth(), 921 oldPaper.getImageableHeight()); 922 oldPaperValWasSet = true; 923 } 924 if (oldPaperValWasSet) { 925 newPf.setPaper(newPaper); 926 } 927 } 928 return newPf; 929 } 930 931 932 /** 933 * Presents the user a dialog for changing properties of the 934 * print job interactively. 935 * The services browsable here are determined by the type of 936 * service currently installed. 937 * If the application installed a StreamPrintService on this 938 * PrinterJob, only the available StreamPrintService (factories) are 939 * browsable. 940 * 941 * @param attributes to store changed properties. 942 * @return false if the user cancels the dialog and true otherwise. 943 * @exception HeadlessException if GraphicsEnvironment.isHeadless() 944 * returns true. 945 * @see java.awt.GraphicsEnvironment#isHeadless 946 */ 947 public boolean printDialog(final PrintRequestAttributeSet attributes) 948 throws HeadlessException { 949 if (GraphicsEnvironment.isHeadless()) { |