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();
}
/**
* POSSIBLE FUTURE API: This method may be used down the road if we
* decide to allow developers to explicitly display a "page setup" dialog.
* Currently we use that functionality internally for the AWT print model.
*/
/*
public static void pageDialog(GraphicsConfiguration gc,
int x, int y,
PrintService service,
DocFlavor flavor,
PrintRequestAttributeSet attributes)
throws HeadlessException
{
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
} else if (service == null) {
throw new IllegalArgumentException("service must be non-null");
} else if (attributes == null) {
throw new IllegalArgumentException("attributes must be non-null");
}
ServiceDialog dialog = new ServiceDialog(gc, x, y, service,
flavor, attributes);
dialog.show();
if (dialog.getStatus() == ServiceDialog.APPROVE) {
PrintRequestAttributeSet newas = dialog.getAttributes();
Class amCategory = SunAlternateMedia.class;
if (attributes.containsKey(amCategory) &&
!newas.containsKey(amCategory))
{
attributes.remove(amCategory);
}
attributes.addAll(newas.values());
}
dialog.getOwner().dispose();
}
*/
/**
* Removes any attributes from the given AttributeSet that are
* unsupported by the given PrintService/DocFlavor combination.
*/
private static void removeUnsupportedAttributes(PrintService ps,
DocFlavor flavor,
AttributeSet aset)
{
AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
aset);
if (asUnsupported != null) {
Attribute[] usAttrs = asUnsupported.toArray();
for (int i=0; i<usAttrs.length; i++) {
=3= |