src/share/classes/javax/print/ServiceUI.java

Print this page




 211         }
 212         Rectangle dlgBounds = dialog.getBounds();
 213 
 214         // get union of all GC bounds
 215         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 216         GraphicsDevice[] gs = ge.getScreenDevices();
 217         for (int j=0; j<gs.length; j++) {
 218             gcBounds =
 219                 gcBounds.union(gs[j].getDefaultConfiguration().getBounds());
 220         }
 221 
 222         // if portion of dialog is not within the gc boundary
 223         if (!gcBounds.contains(dlgBounds)) {
 224             // put in the center relative to parent frame/dialog
 225             dialog.setLocationRelativeTo(owner);
 226         }
 227         dialog.show();
 228 
 229         if (dialog.getStatus() == ServiceDialog.APPROVE) {
 230             PrintRequestAttributeSet newas = dialog.getAttributes();
 231             Class dstCategory = Destination.class;
 232             Class amCategory = SunAlternateMedia.class;
 233             Class fdCategory = Fidelity.class;
 234 
 235             if (attributes.containsKey(dstCategory) &&
 236                 !newas.containsKey(dstCategory))
 237             {
 238                 attributes.remove(dstCategory);
 239             }
 240 
 241             if (attributes.containsKey(amCategory) &&
 242                 !newas.containsKey(amCategory))
 243             {
 244                 attributes.remove(amCategory);
 245             }
 246 
 247             attributes.addAll(newas);
 248 
 249             Fidelity fd = (Fidelity)attributes.get(fdCategory);
 250             if (fd != null) {
 251                 if (fd == Fidelity.FIDELITY_TRUE) {
 252                     removeUnsupportedAttributes(dialog.getPrintService(),
 253                                                 flavor, attributes);


 298 
 299         dialog.getOwner().dispose();
 300     }
 301     */
 302 
 303     /**
 304      * Removes any attributes from the given AttributeSet that are
 305      * unsupported by the given PrintService/DocFlavor combination.
 306      */
 307     private static void removeUnsupportedAttributes(PrintService ps,
 308                                                     DocFlavor flavor,
 309                                                     AttributeSet aset)
 310     {
 311         AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
 312                                                                  aset);
 313 
 314         if (asUnsupported != null) {
 315             Attribute[] usAttrs = asUnsupported.toArray();
 316 
 317             for (int i=0; i<usAttrs.length; i++) {
 318                 Class category = usAttrs[i].getCategory();
 319 
 320                 if (ps.isAttributeCategorySupported(category)) {
 321                     Attribute attr =
 322                         (Attribute)ps.getDefaultAttributeValue(category);
 323 
 324                     if (attr != null) {
 325                         aset.add(attr);
 326                     } else {
 327                         aset.remove(category);
 328                     }
 329                 } else {
 330                     aset.remove(category);
 331                 }
 332             }
 333         }
 334     }
 335 }


 211         }
 212         Rectangle dlgBounds = dialog.getBounds();
 213 
 214         // get union of all GC bounds
 215         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 216         GraphicsDevice[] gs = ge.getScreenDevices();
 217         for (int j=0; j<gs.length; j++) {
 218             gcBounds =
 219                 gcBounds.union(gs[j].getDefaultConfiguration().getBounds());
 220         }
 221 
 222         // if portion of dialog is not within the gc boundary
 223         if (!gcBounds.contains(dlgBounds)) {
 224             // put in the center relative to parent frame/dialog
 225             dialog.setLocationRelativeTo(owner);
 226         }
 227         dialog.show();
 228 
 229         if (dialog.getStatus() == ServiceDialog.APPROVE) {
 230             PrintRequestAttributeSet newas = dialog.getAttributes();
 231             Class<?> dstCategory = Destination.class;
 232             Class<?> amCategory = SunAlternateMedia.class;
 233             Class<?> fdCategory = Fidelity.class;
 234 
 235             if (attributes.containsKey(dstCategory) &&
 236                 !newas.containsKey(dstCategory))
 237             {
 238                 attributes.remove(dstCategory);
 239             }
 240 
 241             if (attributes.containsKey(amCategory) &&
 242                 !newas.containsKey(amCategory))
 243             {
 244                 attributes.remove(amCategory);
 245             }
 246 
 247             attributes.addAll(newas);
 248 
 249             Fidelity fd = (Fidelity)attributes.get(fdCategory);
 250             if (fd != null) {
 251                 if (fd == Fidelity.FIDELITY_TRUE) {
 252                     removeUnsupportedAttributes(dialog.getPrintService(),
 253                                                 flavor, attributes);


 298 
 299         dialog.getOwner().dispose();
 300     }
 301     */
 302 
 303     /**
 304      * Removes any attributes from the given AttributeSet that are
 305      * unsupported by the given PrintService/DocFlavor combination.
 306      */
 307     private static void removeUnsupportedAttributes(PrintService ps,
 308                                                     DocFlavor flavor,
 309                                                     AttributeSet aset)
 310     {
 311         AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
 312                                                                  aset);
 313 
 314         if (asUnsupported != null) {
 315             Attribute[] usAttrs = asUnsupported.toArray();
 316 
 317             for (int i=0; i<usAttrs.length; i++) {
 318                 Class<? extends Attribute> category = usAttrs[i].getCategory();
 319 
 320                 if (ps.isAttributeCategorySupported(category)) {
 321                     Attribute attr =
 322                         (Attribute)ps.getDefaultAttributeValue(category);
 323 
 324                     if (attr != null) {
 325                         aset.add(attr);
 326                     } else {
 327                         aset.remove(category);
 328                     }
 329                 } else {
 330                     aset.remove(category);
 331                 }
 332             }
 333         }
 334     }
 335 }