< prev index next >

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

Print this page




 194             getDefaultConfiguration().getBounds() : gc.getBounds();
 195 
 196         ServiceDialog dialog;
 197         if (owner instanceof Frame) {
 198             dialog = new ServiceDialog(gc,
 199                                        x + gcBounds.x,
 200                                        y + gcBounds.y,
 201                                        services, defaultIndex,
 202                                        flavor, attributes,
 203                                        (Frame)owner);
 204         } else {
 205             dialog = new ServiceDialog(gc,
 206                                        x + gcBounds.x,
 207                                        y + gcBounds.y,
 208                                        services, defaultIndex,
 209                                        flavor, attributes,
 210                                        (Dialog)owner);
 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             }




 194             getDefaultConfiguration().getBounds() : gc.getBounds();
 195 
 196         ServiceDialog dialog;
 197         if (owner instanceof Frame) {
 198             dialog = new ServiceDialog(gc,
 199                                        x + gcBounds.x,
 200                                        y + gcBounds.y,
 201                                        services, defaultIndex,
 202                                        flavor, attributes,
 203                                        (Frame)owner);
 204         } else {
 205             dialog = new ServiceDialog(gc,
 206                                        x + gcBounds.x,
 207                                        y + gcBounds.y,
 208                                        services, defaultIndex,
 209                                        flavor, attributes,
 210                                        (Dialog)owner);
 211         }
 212         Rectangle dlgBounds = dialog.getBounds();
 213 








 214         // if portion of dialog is not within the gc boundary
 215         if (!gcBounds.contains(dlgBounds)) {
 216             
 217             int dlgWidth = 0;
 218             int dlgHeight = 0;               
 219             
 220             // if dialog bounds exceed window bounds, check if 
 221             // positioning the dialog by moving it (bounds.x + bounds.width) - dlgBound.width 
 222             // will result in moving it beyond the window bounds, then 
 223             // position it at window top-left
 224             // so that dialog is entirely on-screen
 225             if ((gcBounds.x + gcBounds.width - dlgBounds.width) > gcBounds.x) {
 226                 x = (gcBounds.x + gcBounds.width) - dlgBounds.width;
 227                 dlgWidth = dlgBounds.width;;
 228             } else {
 229                 x = gcBounds.x;
 230                 dlgWidth = gcBounds.width;
 231             }
 232             if ((gcBounds.y + gcBounds.height - dlgBounds.height) > gcBounds.y) {
 233                 y = (gcBounds.y + gcBounds.height) - dlgBounds.height;
 234                 dlgHeight = dlgBounds.height;
 235             } else {
 236                 y = gcBounds.y;
 237                 dlgHeight = gcBounds.height;
 238             }            
 239             dialog.setBounds(x, y, dlgWidth, dlgHeight);
 240         }
 241         dialog.show();
 242 
 243         if (dialog.getStatus() == ServiceDialog.APPROVE) {
 244             PrintRequestAttributeSet newas = dialog.getAttributes();
 245             Class<?> dstCategory = Destination.class;
 246             Class<?> amCategory = SunAlternateMedia.class;
 247             Class<?> fdCategory = Fidelity.class;
 248 
 249             if (attributes.containsKey(dstCategory) &&
 250                 !newas.containsKey(dstCategory))
 251             {
 252                 attributes.remove(dstCategory);
 253             }
 254 
 255             if (attributes.containsKey(amCategory) &&
 256                 !newas.containsKey(amCategory))
 257             {
 258                 attributes.remove(amCategory);
 259             }


< prev index next >