Package javax.print.attribute

Examples of javax.print.attribute.PrintServiceAttributeSet


    /*
     * @see org.apache.harmony.x.print.PrintClient#getAttributes()
     */
    public PrintServiceAttributeSet getAttributes() {
        PrintServiceAttributeSet attributes =
            new HashPrintServiceAttributeSet();
        attributes.add(new PrinterName(serviceName, Locale.getDefault()));
        if (getColorSupported(serviceName)) {
            attributes.add(ColorSupported.SUPPORTED);
            int colorPPM = getPagesPerMinuteColor(serviceName);
            if (colorPPM > 0) {
                attributes.add(new PagesPerMinuteColor(colorPPM));
            }
        } else {
            attributes.add(ColorSupported.NOT_SUPPORTED);
        }
       
        int pagesPerMinute = getPagesPerMinute(serviceName);
        if (pagesPerMinute > 0) {
            attributes.add(new PagesPerMinute(pagesPerMinute));
        }
       
        String printerLocation = getPrinterLocation(serviceName);
        if (printerLocation != null) {
            attributes.add(new PrinterLocation(printerLocation,
                    Locale.getDefault()));
        }
       
        int acceptingJobs = getPrinterIsAcceptingJobs(serviceName);
        if (acceptingJobs == 0) {
            attributes.add(PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS);
        } else if (acceptingJobs == 1) {
            attributes.add(PrinterIsAcceptingJobs.ACCEPTING_JOBS);
        }
       
        int jobCount = getQueuedJobCount(serviceName);
        if (jobCount >= 0) {
            attributes.add(new QueuedJobCount(jobCount));
        }
        return attributes;
    }
View Full Code Here


        } else {
            services.add(service);
            ArrayList serviceListeners = new ArrayList();
            serviceListeners.add(listener);
            listeners.put(service, serviceListeners);
            PrintServiceAttributeSet serviceAttributes =
                service.getAttributes();
            attributes.put(service, serviceAttributes);
        }

        if (!running) {
View Full Code Here

            while (running) {
                Thread.sleep(1000);
               
                for (int i = 0; i < services.size(); i++) {
                    PrintService service = (PrintService)services.get(i);
                    PrintServiceAttributeSet lastSet =
                        (PrintServiceAttributeSet)attributes.get(service);
                    PrintServiceAttributeSet newSet = service.getAttributes();
                    if (!lastSet.equals(newSet)) {
                        PrintServiceAttributeSet updated =
                            getUpdatedAttributeSet(lastSet, newSet);
                        if (updated.size() > 0) {
                            PrintServiceAttributeEvent event =
                                new PrintServiceAttributeEvent(service,updated);
                            ArrayList serviceListeners =
                                (ArrayList)listeners.get(service);
                            for (int j = 0; j < serviceListeners.size(); j++) {
View Full Code Here

    }
   
    private PrintServiceAttributeSet getUpdatedAttributeSet(
            PrintServiceAttributeSet oldSet, PrintServiceAttributeSet newSet) {
        Attribute[] newAttributes = newSet.toArray();
        PrintServiceAttributeSet updated = new HashPrintServiceAttributeSet();
        for (int i = 0; i < newAttributes.length; i++) {
            if (!oldSet.containsValue(newAttributes[i])) {
                updated.add(newAttributes[i]);
            }
        }
        return updated;
    }
View Full Code Here

    /*
     * @see org.apache.harmony.x.print.PrintClient#getAttributes()
     */
    public PrintServiceAttributeSet getAttributes() {
        PrintServiceAttributeSet attributes =
            new HashPrintServiceAttributeSet();
        attributes.add(new PrinterName(serviceName, Locale.getDefault()));
        if (getColorSupported(serviceName)) {
            attributes.add(ColorSupported.SUPPORTED);
            int colorPPM = getPagesPerMinuteColor(serviceName);
            if (colorPPM > 0) {
                attributes.add(new PagesPerMinuteColor(colorPPM));
            }
        } else {
            attributes.add(ColorSupported.NOT_SUPPORTED);
        }
       
        int pagesPerMinute = getPagesPerMinute(serviceName);
        if (pagesPerMinute > 0) {
            attributes.add(new PagesPerMinute(pagesPerMinute));
        }
       
        String printerLocation = getPrinterLocation(serviceName);
        if (printerLocation != null) {
            attributes.add(new PrinterLocation(printerLocation,
                    Locale.getDefault()));
        }
       
        int acceptingJobs = getPrinterIsAcceptingJobs(serviceName);
        if (acceptingJobs == 0) {
            attributes.add(PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS);
        } else if (acceptingJobs == 1) {
            attributes.add(PrinterIsAcceptingJobs.ACCEPTING_JOBS);
        }
       
        int jobCount = getQueuedJobCount(serviceName);
        if (jobCount >= 0) {
            attributes.add(new QueuedJobCount(jobCount));
        }
        return attributes;
    }
View Full Code Here

        } else {
            services.add(service);
            ArrayList serviceListeners = new ArrayList();
            serviceListeners.add(listener);
            listeners.put(service, serviceListeners);
            PrintServiceAttributeSet serviceAttributes =
                service.getAttributes();
            attributes.put(service, serviceAttributes);
        }

        if (!running) {
View Full Code Here

            while (running) {
                Thread.sleep(1000);
               
                for (int i = 0; i < services.size(); i++) {
                    PrintService service = (PrintService)services.get(i);
                    PrintServiceAttributeSet lastSet =
                        (PrintServiceAttributeSet)attributes.get(service);
                    PrintServiceAttributeSet newSet = service.getAttributes();
                    if (!lastSet.equals(newSet)) {
                        PrintServiceAttributeSet updated =
                            getUpdatedAttributeSet(lastSet, newSet);
                        if (updated.size() > 0) {
                            PrintServiceAttributeEvent event =
                                new PrintServiceAttributeEvent(service,updated);
                            ArrayList serviceListeners =
                                (ArrayList)listeners.get(service);
                            for (int j = 0; j < serviceListeners.size(); j++) {
View Full Code Here

    }
   
    private PrintServiceAttributeSet getUpdatedAttributeSet(
            PrintServiceAttributeSet oldSet, PrintServiceAttributeSet newSet) {
        Attribute[] newAttributes = newSet.toArray();
        PrintServiceAttributeSet updated = new HashPrintServiceAttributeSet();
        for (int i = 0; i < newAttributes.length; i++) {
            if (!oldSet.containsValue(newAttributes[i])) {
                updated.add(newAttributes[i]);
            }
        }
        return updated;
    }
View Full Code Here

    public PrintServiceAttribute getAttribute(Class category) {
        if (!PrintServiceAttribute.class.isAssignableFrom(category)) {
            throw new IllegalArgumentException();
        }
        PrintServiceAttributeSet attributes = getAttributes();
        if (attributes.containsKey(category)) {
            PrintServiceAttribute attribute = (PrintServiceAttribute) attributes
                    .get(category);
            return attribute;
        }
        return null;
    }
View Full Code Here

        SecurityManager security = System.getSecurityManager();
        if (security != null) {
          security.checkPrintJobAccess();
        }
        PrintRequestAttributeSet requestSet = null;
        PrintServiceAttributeSet serviceSet = null;

        if (attributes != null && !attributes.isEmpty()) {

            requestSet = new HashPrintRequestAttributeSet();
            serviceSet = new HashPrintServiceAttributeSet();

            Attribute[] attrs = attributes.toArray();
            for (int i=0; i<attrs.length; i++) {
                if (attrs[i] instanceof PrintRequestAttribute) {
                    requestSet.add(attrs[i]);
                } else if (attrs[i] instanceof PrintServiceAttribute) {
                    serviceSet.add(attrs[i]);
                }
            }
        }

        PrintService[] services = getPrintServices(serviceSet);
View Full Code Here

TOP

Related Classes of javax.print.attribute.PrintServiceAttributeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.