javax.print.attribute.standard.PrinterResolution Java Examples

The following examples show how to use javax.print.attribute.standard.PrinterResolution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrintManager.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
private static PrinterResolution extractFromResolutionString(String buffer) {
    if (buffer != null && !buffer.isEmpty()) {
        int sep = buffer.indexOf('x');
        int x;
        int y;

        if (sep != -1 && sep < buffer.length() - 1) {
            x = Numbers.extractInteger(buffer.substring(0, sep), 0, false);
            y = Numbers.extractInteger(buffer.substring(sep + 1), 0, false);
        } else {
            x = Numbers.extractInteger(buffer, 0, false);
            y = x;
        }
        if (x < 1 || y < 1) {
            return null;
        }
        return new PrinterResolution(x, y, 1);
    }
    return null;
}
 
Example #2
Source File: Win32PrintService.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #3
Source File: Win32PrintService.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #4
Source File: Win32PrintService.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #5
Source File: Win32PrintService.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: WPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: Win32PrintService.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: WPrinterJob.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: Win32PrintService.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: Win32PrintService.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #11
Source File: Win32PrintService.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: PageSetupPanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void createResolutionCombo(PrintRequestAttributeSet set) {
    PrinterResolution[] resolutions = (PrinterResolution[]) mService.getSupportedAttributeValues(PrinterResolution.class, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
    if (resolutions != null) {
        int length = resolutions.length;
        if (length > 0) {
            PrinterResolution          current   = PrintUtilities.getResolution(mService, set, true);
            WrappedPrinterResolution[] wrappers  = new WrappedPrinterResolution[length];
            int                        selection = 0;
            for (int i = 0; i < 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.setToPreferredSizeOnly(mResolution);
            LinkedLabel label = new LinkedLabel(I18n.Text("Resolution"), mResolution);
            add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
            add(mResolution);
        } else {
            mResolution = null;
        }
    } else {
        mResolution = null;
    }
}
 
Example #13
Source File: PageSetupPanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private static String generateResolutionTitle(PrinterResolution res) {
    StringBuilder buffer = new StringBuilder();
    int           x      = res.getCrossFeedResolution(ResolutionSyntax.DPI);
    int           y      = res.getFeedResolution(ResolutionSyntax.DPI);

    buffer.append(Integer.toString(x));
    if (x != y) {
        buffer.append(" x ");
        buffer.append(Integer.toString(y));
    }
    buffer.append(I18n.Text(" dpi"));
    return buffer.toString();
}
 
Example #14
Source File: PrintUtilities.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets the print resolution.
 *
 * @param set        The {@link PrintRequestAttributeSet} to use.
 * @param resolution The new print resolution.
 */
public static void setResolution(PrintRequestAttributeSet set, PrinterResolution resolution) {
    if (resolution != null) {
        set.add(resolution);
    } else {
        set.remove(PrinterResolution.class);
    }
}
 
Example #15
Source File: PrintManager.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private static String createResolutionString(PrinterResolution res) {
    if (res != null) {
        StringBuilder buffer = new StringBuilder();
        int           x      = res.getCrossFeedResolution(1);
        int           y      = res.getFeedResolution(1);
        buffer.append(Integer.toString(x));
        if (x != y) {
            buffer.append("x");
            buffer.append(Integer.toString(y));
        }
        return buffer.toString();
    }
    return null;
}
 
Example #16
Source File: WPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #17
Source File: Win32PrintService.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #18
Source File: WPrinterJob.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #19
Source File: Win32PrintService.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #20
Source File: Win32PrintService.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #21
Source File: WPrinterJob.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #22
Source File: Win32PrintService.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #23
Source File: Win32PrintService.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #24
Source File: WPrinterJob.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #25
Source File: Win32PrintService.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #26
Source File: Win32PrintService.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #27
Source File: Win32PrintService.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #28
Source File: Win32PrintService.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #29
Source File: Win32PrintService.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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()]);
}
 
Example #30
Source File: WPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}