Rectangle gcBounds = (gc == null) ? GraphicsEnvironment.
getLocalGraphicsEnvironment().getDefaultScreenDevice().
getDefaultConfiguration().getBounds() : gc.getBounds();
ServiceDialog dialog;
if (owner instanceof Frame) {
dialog = new ServiceDialog(gc,
x + gcBounds.x,
y + gcBounds.y,
services, defaultIndex,
flavor, attributes,
(Frame)owner);
} else {
dialog = new ServiceDialog(gc,
x + gcBounds.x,
y + gcBounds.y,
services, defaultIndex,
flavor, attributes,
(Dialog)owner);
}
Rectangle dlgBounds = dialog.getBounds();
// get union of all GC bounds
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for (int j=0; j<gs.length; j++) {
gcBounds =
gcBounds.union(gs[j].getDefaultConfiguration().getBounds());
}
// if portion of dialog is not within the gc boundary
if (!gcBounds.contains(dlgBounds)) {
// put in the center relative to parent frame/dialog
dialog.setLocationRelativeTo(owner);
}
dialog.show();
if (dialog.getStatus() == ServiceDialog.APPROVE) {
PrintRequestAttributeSet newas = dialog.getAttributes();
Class dstCategory = Destination.class;
Class amCategory = SunAlternateMedia.class;
Class fdCategory = Fidelity.class;
if (attributes.containsKey(dstCategory) &&
!newas.containsKey(dstCategory))
{
attributes.remove(dstCategory);
}
if (attributes.containsKey(amCategory) &&
!newas.containsKey(amCategory))
{
attributes.remove(amCategory);
}
attributes.addAll(newas);
Fidelity fd = (Fidelity)attributes.get(fdCategory);
if (fd != null) {
if (fd == Fidelity.FIDELITY_TRUE) {
removeUnsupportedAttributes(dialog.getPrintService(),
flavor, attributes);
}
}
}
return dialog.getPrintService();
}