本文整理汇总了Java中javax.print.attribute.standard.PageRanges类的典型用法代码示例。如果您正苦于以下问题:Java PageRanges类的具体用法?Java PageRanges怎么用?Java PageRanges使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageRanges类属于javax.print.attribute.standard包,在下文中一共展示了PageRanges类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRangeCopiesAttribute
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
private final void setRangeCopiesAttribute(int from, int to,
boolean isRangeSet,
int copies) {
if (attributes != null) {
if (isRangeSet) {
attributes.add(new PageRanges(from, to));
setPageRange(from, to);
}
defaultCopies = false;
attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies()
* method which is mainly to send the value down to native
*/
super.setCopies(copies);
mAttCopies = copies;
}
}
示例2: setAttributes
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return;
}
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
// If rangeSelect is not null, we are using AWT's print dialog that has
// All, Selection, and Range radio buttons
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
int[][] range = pageRangesAttr.getMembers();
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
}
}
}
示例3: setAttributes
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return;
}
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
// If rangeSelect is not null, we are using AWT's print dialog that has
// All, Selection, and Range radio buttons
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
int[][] range = pageRangesAttr.getMembers();
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
} else {
// if rangeSelect is SunPageSelection.ALL
// then setPageRange appropriately
setPageRange(-1, -1);
}
}
}
示例4: setRangeCopiesAttribute
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
private void setRangeCopiesAttribute(int from, int to, boolean isRangeSet,
int copies) {
if (attributes != null) {
if (isRangeSet) {
attributes.add(new PageRanges(from, to));
setPageRange(from, to);
}
defaultCopies = false;
attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies()
* method which is mainly to send the value down to native
*/
super.setCopies(copies);
mAttCopies = copies;
}
}
示例5: main
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
String[] instructions
= {
"Select Pages Range From instead of All in print dialog. ",
"Then select Print"
};
SwingUtilities.invokeAndWait(() -> {
JOptionPane.showMessageDialog((Component) null,
instructions, "Instructions",
JOptionPane.INFORMATION_MESSAGE);
});
HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
PrinterJob j = PrinterJob.getPrinterJob();
j.setPageable(new PrintAttributeUpdateTest());
as.add(DialogTypeSelection.NATIVE);
j.printDialog(as);
if (as.containsKey(PageRanges.class) == false) {
throw new RuntimeException("Print Dialog did not update "
+ " attribute set with page range");
}
Attribute attrs[] = as.toArray();
for (int i = 0; i < attrs.length; i++) {
System.out.println("attr " + attrs[i]);
}
j.print(as);
}
示例6: printTest
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
/**
* Starts the application.
*/
public static void printTest() {
System.out.println("\nDefault print service: " +
PrintServiceLookup.lookupDefaultPrintService());
System.out.println("is flavor: "+flavor+" supported? "+
services[0].isDocFlavorSupported(flavor));
System.out.println("is Page Ranges category supported? "+
services[0].isAttributeCategorySupported(PageRanges.class));
System.out.println("is PageRanges[2] value supported ? "+
services[0].isAttributeValueSupported(
new PageRanges(2), flavor, null));
HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
//prSet.add(new PageRanges(2));
PrintService selService = ServiceUI.printDialog(null, 200, 200,
services, services[0], flavor, prSet);
System.out.println("\nSelected Values\n");
Attribute attr[] = prSet.toArray();
for (int x = 0; x < attr.length; x ++) {
System.out.println("Attribute: " + attr[x].getName() +
" Value: " + attr[x]);
}
}
示例7: print
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
public void print() {
getPrintJob().setPrintable(this, getPage());
boolean res;
PrintRequestAttributeSet attr_set
= new HashPrintRequestAttributeSet();
if (page_range.x == 0) {
res = getPrintJob().printDialog();
} else {
PrintRequestAttributeSet attr_set2
= new HashPrintRequestAttributeSet();
attr_set2.add(new PageRanges(page_range.x, page_range.y));
res = getPrintJob().printDialog(attr_set2);
}
if (res) {
try {
getPrintJob().print(attr_set);
} catch (PrinterException pe) {
System.out.println("Error printing: " + pe);
}
//page = getPrintJob().getPageFormat(null);
}
}
示例8: actionPerformed
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
// if ALL is selected we must use a full-range object
if (e.getActionCommand().equals("ALL"))
{
from_tf.setEnabled(false);
to.setEnabled(false);
to_tf.setEnabled(false);
atts.add(new PageRanges(1, Integer.MAX_VALUE));
}
else
{
from_tf.setEnabled(true);
to.setEnabled(true);
to_tf.setEnabled(true);
all_rb.setSelected(false);
}
}
示例9: actionPerformed
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
// if ALL is selected we must use a full-range object
if (e.getActionCommand().equals("ALL"))
{
from_tf.setEnabled(false);
to.setEnabled(false);
to_tf.setEnabled(false);
atts.add(new PageRanges(1, Integer.MAX_VALUE));
}
else
{
from_tf.setEnabled(true);
to.setEnabled(true);
to_tf.setEnabled(true);
all_rb.setSelected(false);
}
}
示例10: setRangeCopiesAttribute
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
private final void setRangeCopiesAttribute(int from, int to,
boolean isRangeSet,
int copies) {
if (attributes != null) {
if (isRangeSet) {
attributes.add(new PageRanges(from, to));
setPageRange(from, to);
}
attributes.add(new Copies(copies));
/* Since this is called from native to tell Java to sync
* up with native, we don't call this class's own setCopies()
* method which is mainly to send the value down to native
*/
super.setCopies(copies);
mAttCopies = copies;
}
}
示例11: setAttributes
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
super.setAttributes(attributes);
if (attributes == null) {
return;
}
// See if this has an NSPrintInfo in it.
NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
if (nsPrintInfo != null) {
fNSPrintInfo = nsPrintInfo.getValue();
}
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (isSupportedValue(pageRangesAttr, attributes)) {
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
// If rangeSelect is not null, we are using AWT's print dialog that has
// All, Selection, and Range radio buttons
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
int[][] range = pageRangesAttr.getMembers();
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
}
}
}
示例12: fillPrintRangeFields
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
void fillPrintRangeFields() {
if (firstUse) {
if (attrs.containsKey(PageRanges.class)) {
PageRanges aRange = (PageRanges) (attrs.get(PageRanges.class));
int [][] range = aRange.getMembers();
fromTxt.setText(range.length > 0
? Integer.toString(range[0][0]) : "1");
toTxt.setText(range.length > 0
? Integer.toString(range[0][1]) : "1");
pageRngBtn.setSelected(true);
} else {
allRngBtn.setSelected(true);
fromTxt.setEnabled(false);
toTxt.setEnabled(false);
fromTxt.setText("1");
toTxt.setText("1");
toLabel.setEnabled(false);
}
}
}
示例13: accept
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
@Override
public PrintService accept(PrintRequestAttributeSet set) {
PrintService service = super.accept(set);
if (mCopies != null) {
PrintUtilities.setCopies(set, ((Integer) mCopies.getValue()).intValue());
}
if (mPageRangeAll != null) {
if (mPageRangeAll.isSelected()) {
PrintUtilities.setPageRanges(set, null);
} else {
int start = ((Integer) mPageRangeStart.getValue()).intValue();
int end = ((Integer) mPageRangeEnd.getValue()).intValue();
if (start > end) {
int tmp = start;
start = end;
end = tmp;
}
PrintUtilities.setPageRanges(set, new PageRanges(start, end));
}
}
return service;
}
示例14: setAttributes
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
if (attributes != null) {
PageRanges pageRangesAttr =
(PageRanges)attributes.get(PageRanges.class);
if (pageRangesAttr != null) {
SunPageSelection psel = (SunPageSelection)attributes.get(SunPageSelection.class);
if (psel == null) {
attributes.add(SunPageSelection.RANGE);
}
}
}
super.setAttributes(attributes);
if (attributes == null) {
return;
}
// See if this has an NSPrintInfo in it.
NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
if (nsPrintInfo != null) {
fNSPrintInfo = nsPrintInfo.getValue();
}
}
示例15: getFromPageAttrib
import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
protected final int getFromPageAttrib() {
if (attributes != null) {
PageRanges pageRangesAttr =
(PageRanges)attributes.get(PageRanges.class);
if (pageRangesAttr != null) {
int[][] range = pageRangesAttr.getMembers();
return range[0][0];
}
}
return getMinPageAttrib();
}