本文整理汇总了Java中javax.print.attribute.standard.Chromaticity类的典型用法代码示例。如果您正苦于以下问题:Java Chromaticity类的具体用法?Java Chromaticity怎么用?Java Chromaticity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Chromaticity类属于javax.print.attribute.standard包,在下文中一共展示了Chromaticity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
private static void doTest() {
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(Chromaticity.MONOCHROME);
MediaSize isoA5Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A5);
float[] size = isoA5Size.getSize(Size2DSyntax.INCH);
Paper paper = new Paper();
paper.setSize(size[0] * 72.0, size[1] * 72.0);
paper.setImageableArea(0.0, 0.0, size[0] * 72.0, size[1] * 72.0);
PageFormat pf = new PageFormat();
pf.setPaper(paper);
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(new WrongPaperPrintingTest(), job.validatePage(pf));
if (job.printDialog()) {
try {
job.print(aset);
} catch (PrinterException pe) {
throw new RuntimeException(pe);
}
}
}
示例2: setAttribute
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
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);
}
}
示例3: fillColorFields
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
void fillColorFields() {
boolean lastIsMonochrome = getLastColor();
monoBtn.setEnabled(false);
colorBtn.setEnabled(false);
if (myService.isAttributeCategorySupported(Chromaticity.class)) {
Chromaticity [] supported = (Chromaticity []) (myService
.getSupportedAttributeValues(Chromaticity.class, flavor, attrs));
if (supported != null) {
if (supported.length == 1) {
lastIsMonochrome = setMonochrome(
(supported[0]).equals(Chromaticity.MONOCHROME));
} else if (supported.length > 1) {
monoBtn.setEnabled(true);
colorBtn.setEnabled(true);
}
}
}
if (lastIsMonochrome) {
monoBtn.setSelected(true);
} else {
colorBtn.setSelected(true);
}
}
示例4: getLastColor
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
private boolean getLastColor() {
if (firstUse) {
if (attrs.containsKey(Chromaticity.class)) {
Attribute value = attrs.get(Chromaticity.class);
return value.equals(Chromaticity.MONOCHROME);
}
Object defaul = myService.getDefaultAttributeValue(Chromaticity.class);
return (myService.isAttributeCategorySupported(Chromaticity.class)
&& (defaul != null))
? defaul.equals(Chromaticity.MONOCHROME)
: true;
}
return monoBtn.isSelected();
}
示例5: createChromaticityCombo
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
private void createChromaticityCombo(PrintRequestAttributeSet set) {
Chromaticity[] chromacities = (Chromaticity[]) mService.getSupportedAttributeValues(Chromaticity.class, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
if (chromacities != null && chromacities.length > 0) {
HashSet<Chromaticity> possible = new HashSet<>();
for (Chromaticity one : chromacities) {
possible.add(one);
}
ArrayList<InkChromaticity> choices = new ArrayList<>();
for (InkChromaticity chromaticity : InkChromaticity.values()) {
if (possible.contains(chromaticity.getChromaticity())) {
choices.add(chromaticity);
}
}
mChromaticity = new JComboBox<>(choices.toArray(new InkChromaticity[0]));
mChromaticity.setSelectedItem(PrintUtilities.getChromaticity(mService, set, true));
UIUtilities.setOnlySize(mChromaticity, mChromaticity.getPreferredSize());
LinkedLabel label = new LinkedLabel(CHROMATICITY, mChromaticity);
add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
add(mChromaticity);
} else {
mChromaticity = null;
}
}
示例6: printComponent
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
public static void printComponent(Component c) {
// Get a list of all printers that can handle Printable objects.
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null);
// Set some define printing attributes
PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
//printAttributes.add(OrientationRequested.LANDSCAPE); // landscape mode
printAttributes.add(OrientationRequested.PORTRAIT); // PORTRAIT mode
printAttributes.add(Chromaticity.MONOCHROME); // print in mono
printAttributes.add(javax.print.attribute.standard.PrintQuality.HIGH); // highest resolution
// Display a dialog that allows the user to select one of the
// available printers and to edit the default attributes
PrintService service = ServiceUI.printDialog(null, 100, 100, services, null, null, printAttributes);
// If the user canceled, don't do anything
if(service==null) {
return;
}
// Now call a method defined below to finish the printing
printToService(c, service, printAttributes);
}
示例7: setColorAttrib
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
private void setColorAttrib(Attribute attr) {
if (attr == Chromaticity.COLOR) {
mAttChromaticity = 2; // DMCOLOR_COLOR
} else {
mAttChromaticity = 1; // DMCOLOR_MONOCHROME
}
}
示例8: actionPerformed
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
@Override final public void actionPerformed(ActionEvent objPactionEvent) {
final Object objLsourceObject = objPactionEvent.getSource();
if (this.objGmonochromePrintIconJRadioButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(Chromaticity.MONOCHROME);
} else if (this.objGcolorPrintIconJRadioButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(Chromaticity.COLOR);
}
}
示例9: actionPerformed
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == bw)
atts.add(Chromaticity.MONOCHROME);
else
atts.add(Chromaticity.COLOR);
}
示例10: updateForSelectedService
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
/**
* Called to update for new selected
* print service. Tests if currently
* selected attributes are supported.
*/
void updateForSelectedService()
{
if (categorySupported(Chromaticity.class))
{
bw.setEnabled(true);
color.setEnabled(true);
Object defaultValue = defaultValue(Chromaticity.class);
Attribute chromaticity = attribute(Chromaticity.class);
if (chromaticity != null)
{
if (chromaticity.equals(Chromaticity.MONOCHROME))
bw.setSelected(true);
else
color.setSelected(true);
}
else
{
if (defaultValue.equals(Chromaticity.MONOCHROME))
bw.setSelected(true);
else
color.setSelected(true);
}
}
else
{
bw.setEnabled(false);
color.setEnabled(false);
}
}
示例11: actionPerformed
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == bw)
atts.add(Chromaticity.MONOCHROME);
else
atts.add(Chromaticity.COLOR);
}
示例12: updateForSelectedService
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
/**
* Called to update for new selected
* print service. Tests if currently
* selected attributes are supported.
*/
void updateForSelectedService()
{
if (categorySupported(Chromaticity.class))
{
bw.setEnabled(true);
color.setEnabled(true);
Object defaultValue = defaultValue(Chromaticity.class);
Attribute chromaticity = attribute(Chromaticity.class);
if (chromaticity != null)
{
if (chromaticity.equals(Chromaticity.MONOCHROME))
bw.setSelected(true);
else
color.setSelected(true);
}
else
{
if (defaultValue.equals(Chromaticity.MONOCHROME))
bw.setSelected(true);
else
color.setSelected(true);
}
}
else
{
bw.setEnabled(false);
color.setEnabled(false);
}
}
示例13: getDefaultAttributeValue
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
public Object getDefaultAttributeValue(
final Class<? extends Attribute> category) {
checkArgs(category, null);
final DevmodeStructWrapper dm = getDefaultPrinterProps();
if (JobName.class.equals(category)) {
return DEFAULT_JOB_NAME;
} else if (RequestingUserName.class.equals(category)) {
return new RequestingUserName(getSystemProperty("user.name"), //$NON-NLS-1$
null);
} else if (Destination.class.equals(category)) {
File file = new File(getSystemProperty("user.dir") //$NON-NLS-1$
+ File.separator + "output.prn"); //$NON-NLS-1$
return new Destination(file.toURI());
} else if (OrientationRequested.class.equals(category)) {
return dm.getOrientation();
} else if (Paper.class.equals(category)) {
return getDefaultPaper();
} else if (Media.class.equals(category)) {
return getDefaultPaper().getSize().getMediaSizeName();
} else if (MediaSize.class.equals(category)) {
return getDefaultPaper().getSize();
} else if (PrintQuality.class.equals(category)) {
return dm.getPrintQuality();
} else if (Sides.class.equals(category)) {
return dm.getSides();
} else if (Copies.class.equals(category)) {
return dm.getCopies();
} else if (SheetCollate.class.equals(category)) {
return dm.getCollate();
} else if (PrinterResolution.class.equals(category)) {
return dm.getPrinterResolution();
} else if (Chromaticity.class.equals(category)) {
return dm.getChromaticity();
}
return null;
}
示例14: setChromaticity
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
public void setChromaticity(final Chromaticity chromaticity) {
if (Chromaticity.COLOR.equals(chromaticity)) {
setDmColor(structPtr, DMCOLOR_COLOR);
} else if (Chromaticity.MONOCHROME.equals(chromaticity)) {
setDmColor(structPtr, DMCOLOR_MONOCHROME);
}
}
示例15: getSupportedAttributeCategories
import javax.print.attribute.standard.Chromaticity; //导入依赖的package包/类
public Class[] getSupportedAttributeCategories() {
ArrayList supportedCategories = new ArrayList();
if (getCopiesSupported(serviceName) >= 1) {
supportedCategories.add(Copies.class);
}
if (getSidesSupported(serviceName)) {
supportedCategories.add(Sides.class);
}
if (getSupportedMediaSizeNames() != null) {
supportedCategories.add(Media.class);
}
if (getResolutionsSupported(serviceName) != null) {
supportedCategories.add(PrinterResolution.class);
}
if (getOrientationSupported(serviceName)) {
supportedCategories.add(OrientationRequested.class);
}
if (getCollateSupported(serviceName)) {
supportedCategories.add(SheetCollate.class);
}
supportedCategories.add(Chromaticity.class);
supportedCategories.add(JobName.class);
supportedCategories.add(RequestingUserName.class);
supportedCategories.add(Destination.class);
Class[] categories = new Class[supportedCategories.size()];
supportedCategories.toArray(categories);
return categories;
}