@Override public Class<?>[] getSupportedAttributeCategories(){ ArrayList<Class> categList = new ArrayList<Class>(otherAttrCats.length+3); for (int i=0; i < otherAttrCats.length; i++) { categList.add(otherAttrCats[i]); } if (settings.get_CanDuplex()) { categList.add(Sides.class); } if (settings.get_PrinterResolutions().get_Count() > 0) { categList.add(PrinterResolution.class); } return categList.toArray(new Class[categList.size()]); }
public void setAttribute(final Attribute attr) { final Class<? extends Attribute> category = attr.getCategory(); if (OrientationRequested.class.equals(category)) { setOrientation((OrientationRequested) attr); } else if (MediaSize.class.equals(category)) { setPaper((MediaSize) attr); } else if (Media.class.equals(category)) { setPaper((MediaSizeName) attr); } else if (Paper.class.equals(category)) { setPaper((Paper) attr); } else if (Copies.class.equals(category)) { setCopies((Copies) attr); } else if (PrintQuality.class.equals(category)) { setPrintQuality((PrintQuality) attr); } else if (Sides.class.equals(category)) { setSides((Sides) attr); } else if (SheetCollate.class.equals(category)) { setCollate((SheetCollate) attr); } else if (PrinterResolution.class.equals(category)) { setPrinterResolution((PrinterResolution) attr); } else if (Chromaticity.class.equals(category)) { setChromaticity((Chromaticity) attr); } }
private void createResolutionCombo(PrintRequestAttributeSet set) { PrinterResolution[] resolutions = (PrinterResolution[]) mService.getSupportedAttributeValues(PrinterResolution.class, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null); if (resolutions != null && resolutions.length > 0) { PrinterResolution current = PrintUtilities.getResolution(mService, set, true); WrappedPrinterResolution[] wrappers = new WrappedPrinterResolution[resolutions.length]; int selection = 0; for (int i = 0; i < resolutions.length; i++) { wrappers[i] = new WrappedPrinterResolution(generateResolutionTitle(resolutions[i]), resolutions[i]); if (resolutions[i] == current) { selection = i; } } mResolution = new JComboBox<>(wrappers); mResolution.setSelectedIndex(selection); UIUtilities.setOnlySize(mResolution, mResolution.getPreferredSize()); LinkedLabel label = new LinkedLabel(RESOLUTION, mResolution); add(label, new PrecisionLayoutData().setEndHorizontalAlignment()); add(mResolution); } else { mResolution = null; } }
private static PrinterResolution extractFromResolutionString(String buffer) { if (buffer != null && buffer.length() > 0) { int sep = buffer.indexOf('x'); int x; int y; if (sep != -1 && sep < buffer.length() - 1) { x = Numbers.getInteger(buffer.substring(0, sep), 0); y = Numbers.getInteger(buffer.substring(sep + 1), 0); } else { x = Numbers.getInteger(buffer, 0); y = x; } if (x < 1 || y < 1) { return null; } return new PrinterResolution(x, y, 1); } return null; }
private boolean isSupportedResolution(PrinterResolution res) { PrinterResolution[] supportedRes = getPrintResolutions(); if (supportedRes != null) { for (int i=0; i<supportedRes.length; i++) { if (res.equals(supportedRes[i])) { return true; } } } return false; }
public Class<?>[] getSupportedAttributeCategories() { ArrayList categList = new ArrayList(otherAttrCats.length+3); for (int i=0; i < otherAttrCats.length; i++) { categList.add(otherAttrCats[i]); } int caps = getPrinterCapabilities(); if ((caps & DEVCAP_DUPLEX) != 0) { categList.add(Sides.class); } if ((caps & DEVCAP_QUALITY) != 0) { int[] defaults = getDefaultPrinterSettings(); // Added check: if supported, we should be able to get the default. if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) { categList.add(PrintQuality.class); } } PrinterResolution[] supportedRes = getPrintResolutions(); if ((supportedRes!=null) && (supportedRes.length>0)) { categList.add(PrinterResolution.class); } return (Class[])categList.toArray(new Class[categList.size()]); }
private final void setResolutionDPI(int xres, int yres) { if (attributes != null) { PrinterResolution res = new PrinterResolution(xres, yres, PrinterResolution.DPI); attributes.add(res); } mAttXRes = xres; mAttYRes = yres; }
public Class<?>[] getSupportedAttributeCategories() { ArrayList<Class<?>> categList = new ArrayList<>(otherAttrCats.length+3); for (int i=0; i < otherAttrCats.length; i++) { categList.add(otherAttrCats[i]); } int caps = getPrinterCapabilities(); if ((caps & DEVCAP_DUPLEX) != 0) { categList.add(Sides.class); } if ((caps & DEVCAP_QUALITY) != 0) { int[] defaults = getDefaultPrinterSettings(); // Added check: if supported, we should be able to get the default. if ((defaults[3] >= DMRES_HIGH) && (defaults[3] < 0)) { categList.add(PrintQuality.class); } } PrinterResolution[] supportedRes = getPrintResolutions(); if ((supportedRes!=null) && (supportedRes.length>0)) { categList.add(PrinterResolution.class); } return categList.toArray(new Class<?>[categList.size()]); }
private void setResolutionDPI(int xres, int yres) { if (attributes != null) { PrinterResolution res = new PrinterResolution(xres, yres, PrinterResolution.DPI); attributes.add(res); } mAttXRes = xres; mAttYRes = yres; }
/** * Constructs an array from a set of -supported attributes. * @param set set to process * @return The constructed array. * * @see #getAssociatedAttribute() */ public static PrinterResolution[] getAssociatedAttributeArray(Set<Attribute> set) { PrinterResolution[] result = new PrinterResolution[set.size()]; int j = 0; for (Attribute tmp : set) { result[j] = ((PrinterResolutionSupported) tmp).getAssociatedAttribute(); j++; } return result; }
/** * Constructs an array from a set of -supported attributes. * @param set set to process * @return The constructed array. * * @see #getAssociatedAttribute() */ public static PrinterResolution[] getAssociatedAttributeArray(Set set) { PrinterResolutionSupported tmp; PrinterResolution[] result = new PrinterResolution[set.size()]; Iterator it = set.iterator(); int j = 0; while (it.hasNext()) { tmp = (PrinterResolutionSupported) it.next(); result[j] = tmp.getAssociatedAttribute(); j++; } return result; }