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); } }
void fillQualityFields() { PrintQuality quality = (PrintQuality) attrs.get(PrintQuality.class); if (firstUse) { selectQualityButton(quality); } PrintQuality [] aList = ( myService.isAttributeCategorySupported(PrintQuality.class) ? (PrintQuality []) myService .getSupportedAttributeValues(PrintQuality.class, flavor, attrs) : null); enableQualityButtons(aList); /* enable qualities which are supported */ /* select quality */ if ((aList != null) && (!qualityIsEnabled(getSelectedQuality()))) { selectQualityButton(qualityIsEnabled(quality) ? quality : (PrintQuality) (myService .getDefaultAttributeValue(PrintQuality.class))); } }
private void enableQualityButtons(PrintQuality [] list) { normalBtn.setEnabled(false); draftBtn.setEnabled(false); highBtn.setEnabled(false); if (list != null) { for (int i = 0; i < list.length; i++) { if (list[i].equals(PrintQuality.DRAFT)) { draftBtn.setEnabled(true); } else if (list[i].equals(PrintQuality.NORMAL)) { normalBtn.setEnabled(true); } else if (list[i].equals(PrintQuality.HIGH)) { highBtn.setEnabled(true); } } } }
private void createPrintQualityCombo(PrintRequestAttributeSet set) { PrintQuality[] qualities = (PrintQuality[]) mService.getSupportedAttributeValues(PrintQuality.class, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null); if (qualities != null && qualities.length > 0) { HashSet<PrintQuality> possible = new HashSet<>(); for (PrintQuality one : qualities) { possible.add(one); } ArrayList<Quality> choices = new ArrayList<>(); for (Quality quality : Quality.values()) { if (possible.contains(quality.getPrintQuality())) { choices.add(quality); } } mPrintQuality = new JComboBox<>(choices.toArray(new Quality[0])); mPrintQuality.setSelectedItem(PrintUtilities.getPrintQuality(mService, set, true)); UIUtilities.setOnlySize(mPrintQuality, mPrintQuality.getPreferredSize()); LinkedLabel label = new LinkedLabel(QUALITY, mPrintQuality); add(label, new PrecisionLayoutData().setEndHorizontalAlignment()); add(mPrintQuality); } else { mPrintQuality = null; } }
/** * Show a print setup dialog, to alter the ViewerModel's PageFormat * * @see ViewModel */ public void showPrintSetupDialog() { PrintHelper printHelper = viewModel.getPrintHelper(); // create a new print helper for this document instance if (printHelper == null) { MediaSizeName mediaSizeName = loadDefaultPrinterProperties(); // create the new print help printHelper = new PrintHelper(documentViewController.getViewContainer(), getPageTree(), documentViewController.getRotation(), mediaSizeName, PrintQuality.NORMAL); } // reuse previous print attributes if they exist. else { printHelper = new PrintHelper(documentViewController.getViewContainer(), getPageTree(), documentViewController.getRotation(), printHelper.getDocAttributeSet(), printHelper.getPrintRequestAttributeSet()); } viewModel.setPrintHelper(printHelper); viewModel.getPrintHelper().showPrintSetupDialog(); // save new printer attributes to properties savePrinterProperties(printHelper); }
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 void setQualityAttrib(Attribute attr) { if (attr == PrintQuality.HIGH) { mAttQuality = -4; // DMRES_HIGH } else if (attr == PrintQuality.NORMAL) { mAttQuality = -3; // DMRES_MEDIUM } else { mAttQuality = -2; // DMRES_LOW } }
@Override final public void actionPerformed(ActionEvent objPactionEvent) { final Object objPsourceObject = objPactionEvent.getSource(); if (objPsourceObject == this.objGdraftJRadioButton) { this.objGprintJDialog.getAttributes().add(PrintQuality.DRAFT); } else if (objPsourceObject == this.objGnormalJRadioButton) { this.objGprintJDialog.getAttributes().add(PrintQuality.NORMAL); } else if (objPsourceObject == this.objGhighJRadioButton) { this.objGprintJDialog.getAttributes().add(PrintQuality.HIGH); } }
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()]); }
/** * Constructs an array from a set of -supported attributes. * @param set set to process * @return The constructed array. * * @see #getAssociatedAttribute() */ public static PrintQuality[] getAssociatedAttributeArray(Set<Attribute> set) { PrintQuality[] result = new PrintQuality[set.size()]; int j = 0; for (Attribute tmp : set) { result[j] = ((PrintQualitySupported) tmp).getAssociatedAttribute(); j++; } return result; }
/** * Writes an attribute in EnumSyntax into the stream. * @param attribute the attribute * @throws IOException if thrown by the stream */ private void write(EnumSyntax attribute) throws IOException { // in JPS API enum syntax is used for enums, keyword and boolean types String name = ((Attribute) attribute).getName(); // the enum value types if (attribute instanceof Finishings || attribute instanceof OrientationRequested || attribute instanceof PrintQuality) { out.writeByte(IppValueTag.ENUM); out.writeShort(name.length()); out.write(name.getBytes()); out.writeShort(4); // length, enum is 4 bytes out.writeInt(attribute.getValue()); } // the boolean value type else if (attribute instanceof Fidelity) { out.writeByte(IppValueTag.BOOLEAN); out.writeShort(name.length()); out.write(name.getBytes()); out.writeShort(1); // length, boolean is 1 bytes out.writeByte(attribute.getValue() == 0 ? 0x00 : 0x01); } // the keyword value types else { String keyword = attribute.toString(); out.writeByte(IppValueTag.KEYWORD); out.writeShort(name.length()); out.write(name.getBytes()); out.writeShort(keyword.length()); out.write(keyword.getBytes()); } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == low) atts.add(PrintQuality.DRAFT); else if (e.getSource() == normal) atts.add(PrintQuality.NORMAL); else atts.add(PrintQuality.HIGH); }
/** * Called to update for new selected * print service. Tests if currently * selected attributes are supported. */ void updateForSelectedService() { if (categorySupported(PrintQuality.class)) { low.setEnabled(true); normal.setEnabled(true); high.setEnabled(true); Object defaultValue = defaultValue(PrintQuality.class); Attribute quality = attribute(PrintQuality.class); if (quality != null) { if (quality.equals(PrintQuality.DRAFT)) low.setSelected(true); else if (quality.equals(PrintQuality.NORMAL)) normal.setSelected(true); else high.setSelected(true); } else { if (defaultValue.equals(PrintQuality.DRAFT)) low.setSelected(true); else if (defaultValue.equals(PrintQuality.NORMAL)) normal.setSelected(true); else high.setSelected(true); } } else { low.setEnabled(false); normal.setEnabled(false); high.setEnabled(false); } }
/** * Constructs an array from a set of -supported attributes. * @param set set to process * @return The constructed array. * * @see #getAssociatedAttribute() */ public static PrintQuality[] getAssociatedAttributeArray(Set set) { PrintQualitySupported tmp; PrintQuality[] result = new PrintQuality[set.size()]; Iterator it = set.iterator(); int j = 0; while (it.hasNext()) { tmp = (PrintQualitySupported) it.next(); result[j] = tmp.getAssociatedAttribute(); j++; } return result; }