本文整理汇总了Java中javax.print.attribute.standard.OrientationRequested类的典型用法代码示例。如果您正苦于以下问题:Java OrientationRequested类的具体用法?Java OrientationRequested怎么用?Java OrientationRequested使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OrientationRequested类属于javax.print.attribute.standard包,在下文中一共展示了OrientationRequested类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printWorksheetLevel
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
public void printWorksheetLevel() {
PrinterJob print = PrinterJob.getPrinterJob();
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.LANDSCAPE);
print.setPrintable(oscilloscope);
if(print.printDialog(set))
try { print.print(); }
catch(PrinterException e) {}
}
示例2: actionPerformed
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
final public void actionPerformed(ActionEvent objPactionEvent) {
final Object objLsourceObject = objPactionEvent.getSource();
if (this.objGportraitPrintIconRadioJButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(OrientationRequested.PORTRAIT);
} else if (this.objGlandscapePrintIconRadioJButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(OrientationRequested.LANDSCAPE);
} else if (this.objGreversePortraitPrintIconRadioJButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(OrientationRequested.REVERSE_PORTRAIT);
} else if (this.objGreverseLandscapePrintIconRadioJButton.isSameAs(objLsourceObject)) {
this.objGprintJDialog.getAttributes().add(OrientationRequested.REVERSE_LANDSCAPE);
}
// orientation affects display of margins.
if (this.objGprintMarginsSubJPanel != null) {
this.objGprintMarginsSubJPanel.setValues();
}
}
示例3: actionPerformed
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
try {
if (selectedDriver == null)
return;
PrintService ps = (PrintService)printers.getSelectedItem();
PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
attr.add(new Copies(1));
attr.add((Media)ps.getDefaultAttributeValue(Media.class)); // set to default paper from printer
attr.add(OrientationRequested.LANDSCAPE);
SimpleDoc doc = new SimpleDoc(activeLabel, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
ps.createPrintJob().print(doc, attr);
} catch (PrintException ex) {
log.log(Level.SEVERE, "\bBarcode print failed: " + ex.getMessage(), ex);
}
}
示例4: assignOrientation
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
public OrientationRequested assignOrientation(final String orientation) {
OrientationRequested answer;
if (orientation == null) {
// default to portrait
answer = OrientationRequested.PORTRAIT;
} else if (orientation.equalsIgnoreCase("portrait")) {
answer = OrientationRequested.PORTRAIT;
} else if (orientation.equalsIgnoreCase("landscape")) {
answer = OrientationRequested.LANDSCAPE;
} else if (orientation.equalsIgnoreCase("reverse-portrait")) {
answer = OrientationRequested.REVERSE_PORTRAIT;
} else if (orientation.equalsIgnoreCase("reverse-landscape")) {
answer = OrientationRequested.REVERSE_LANDSCAPE;
} else {
answer = OrientationRequested.PORTRAIT;
}
return answer;
}
示例5: printToMiddleTray
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
@Test
public void printToMiddleTray() throws Exception {
PrinterEndpoint endpoint = new PrinterEndpoint();
PrinterConfiguration configuration = new PrinterConfiguration();
configuration.setHostname("localhost");
configuration.setPort(631);
configuration.setPrintername("DefaultPrinter");
configuration.setMediaSizeName(MediaSizeName.ISO_A4);
configuration.setInternalSides(Sides.ONE_SIDED);
configuration.setInternalOrientation(OrientationRequested.PORTRAIT);
configuration.setMediaTray("middle");
PrinterProducer producer = new PrinterProducer(endpoint, configuration);
producer.start();
PrinterOperations printerOperations = producer.getPrinterOperations();
PrintRequestAttributeSet attributeSet = printerOperations.getPrintRequestAttributeSet();
Attribute attribute = attributeSet.get(javax.print.attribute.standard.Media.class);
assertNotNull(attribute);
assertTrue(attribute instanceof MediaTray);
MediaTray mediaTray = (MediaTray) attribute;
assertEquals("middle", mediaTray.toString());
}
示例6: printsWithLandscapeOrientation
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
@Test
public void printsWithLandscapeOrientation() throws Exception {
PrinterEndpoint endpoint = new PrinterEndpoint();
PrinterConfiguration configuration = new PrinterConfiguration();
configuration.setHostname("localhost");
configuration.setPort(631);
configuration.setPrintername("DefaultPrinter");
configuration.setMediaSizeName(MediaSizeName.ISO_A4);
configuration.setInternalSides(Sides.ONE_SIDED);
configuration.setInternalOrientation(OrientationRequested.REVERSE_LANDSCAPE);
configuration.setMediaTray("middle");
configuration.setSendToPrinter(false);
PrinterProducer producer = new PrinterProducer(endpoint, configuration);
producer.start();
PrinterOperations printerOperations = producer.getPrinterOperations();
PrintRequestAttributeSet attributeSet = printerOperations.getPrintRequestAttributeSet();
Attribute attribute = attributeSet.get(OrientationRequested.class);
assertNotNull(attribute);
assertEquals("reverse-landscape", attribute.toString());
}
示例7: getPrintRequestAttributeSet
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
/**
* Return Print Request Attributes
* @return PrintRequestAttributeSet
*/
public PrintRequestAttributeSet getPrintRequestAttributeSet()
{
PrintRequestAttributeSet pratts = new HashPrintRequestAttributeSet();
// media-printable-area = (25.4,25.4)->(165.1,228.6)mm - class javax.print.attribute.standard.MediaPrintableArea
pratts.add(getMediaPrintableArea());
// orientation-requested = landscape - class javax.print.attribute.standard.OrientationRequested
if (isLandscape())
pratts.add(OrientationRequested.LANDSCAPE);
else
pratts.add(OrientationRequested.PORTRAIT);
// media = na-legal
//Commented Lines By AA Goodwill: Custom Paper Support
//pratts.add(getMediaSizeName());
//End Of AA Goodwill
return pratts;
}
示例8: print
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
/**
* Print (async)
* @param printerName optional printer name
* @param jobName optional printer job name
* @param pageable pageable
* @param copies number of copies
* @param withDialog if true, shows printer dialog
*/
static public void print (Pageable pageable, String printerName, String jobName,
int copies, boolean withDialog)
{
if (pageable == null)
return;
String name = "Adempiere_";
if (jobName != null)
name += jobName;
//
PrinterJob job = CPrinter.getPrinterJob(printerName);
job.setJobName (name);
job.setPageable (pageable);
// Attributes
HashPrintRequestAttributeSet prats = new HashPrintRequestAttributeSet();
prats.add(new Copies(copies));
// Set Orientation
if (pageable.getPageFormat(0).getOrientation() == PageFormat.PORTRAIT)
prats.add(OrientationRequested.PORTRAIT);
else
prats.add(OrientationRequested.LANDSCAPE);
prats.add(new JobName(name, Language.getLoginLanguage().getLocale()));
prats.add(getJobPriority(pageable.getNumberOfPages(), copies, withDialog));
//
print (job, prats, withDialog, false);
}
示例9: printInfoButtonActionPerformed
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
private void printInfoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printInfoButtonActionPerformed
// TODO add your handling code here:
PrinterJob pjob = PrinterJob.getPrinterJob();
PageFormat preformat = pjob.defaultPage();
preformat.setOrientation(PageFormat.PORTRAIT);
PageFormat postformat = pjob.pageDialog(preformat);
//If user does not hit cancel then print.
if (preformat != postformat) {
//Set print component
pjob.setPrintable(new Printer(bottomPanel), postformat);
if (pjob.printDialog()) {
try {
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.PORTRAIT);
//pjob.print();
table.print(JTable.PrintMode.FIT_WIDTH, header, null, false, set, false);
} catch (PrinterException ex) {
Logger.getLogger(EditProjectParticipants.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
示例10: setAttribute
import javax.print.attribute.standard.OrientationRequested; //导入依赖的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);
}
}
示例11: enableOrient
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
private void enableOrient(OrientationRequested[] list) {
portraitBtn.setEnabled(false);
landscapeBtn.setEnabled(false);
rvportraitBtn.setEnabled(false);
rvlandscapeBtn.setEnabled(false);
if (list != null) {
for (int i = 0; i < list.length; i++) {
if (list[i].equals(OrientationRequested.LANDSCAPE)) {
landscapeBtn.setEnabled(true);
} else if (list[i].equals(OrientationRequested.PORTRAIT)) {
portraitBtn.setEnabled(true);
} else if (list[i].equals(OrientationRequested.REVERSE_LANDSCAPE)) {
rvlandscapeBtn.setEnabled(true);
} else if (list[i].equals(OrientationRequested.REVERSE_PORTRAIT)) {
rvportraitBtn.setEnabled(true);
}
}
}
}
示例12: createOrientationCombo
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
private void createOrientationCombo(PrintRequestAttributeSet set) {
OrientationRequested[] orientations = (OrientationRequested[]) mService.getSupportedAttributeValues(OrientationRequested.class, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
if (orientations != null && orientations.length > 0) {
HashSet<OrientationRequested> possible = new HashSet<>();
for (OrientationRequested one : orientations) {
possible.add(one);
}
ArrayList<PageOrientation> choices = new ArrayList<>();
for (PageOrientation orientation : PageOrientation.values()) {
if (possible.contains(orientation.getOrientationRequested())) {
choices.add(orientation);
}
}
mOrientation = new JComboBox<>(choices.toArray(new PageOrientation[0]));
mOrientation.setSelectedItem(PrintUtilities.getPageOrientation(mService, set));
UIUtilities.setOnlySize(mOrientation, mOrientation.getPreferredSize());
LinkedLabel label = new LinkedLabel(ORIENTATION, mOrientation);
add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
add(mOrientation);
} else {
mOrientation = null;
}
}
示例13: printsWithLandscapeOrientation
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
@Test
public void printsWithLandscapeOrientation() throws Exception {
PrinterEndpoint endpoint = new PrinterEndpoint();
PrinterConfiguration configuration = new PrinterConfiguration();
configuration.setHostname("localhost");
configuration.setPort(631);
configuration.setPrintername("DefaultPrinter");
configuration.setMediaSizeName(MediaSizeName.ISO_A4);
configuration.setInternalSides(Sides.ONE_SIDED);
configuration.setInternalOrientation(OrientationRequested.REVERSE_LANDSCAPE);
configuration.setMediaTray("middle");
configuration.setSendToPrinter(false);
PrinterProducer producer = new PrinterProducer(endpoint, configuration);
producer.start();
PrinterOperations printerOperations = producer.getPrinterOperations();
PrintRequestAttributeSet attributeSet = printerOperations.getPrintRequestAttributeSet();
Attribute attribute = attributeSet.get(OrientationRequested.class);
Assert.assertNotNull(attribute);
Assert.assertEquals("reverse-landscape", attribute.toString());
}
示例14: printComponent
import javax.print.attribute.standard.OrientationRequested; //导入依赖的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);
}
示例15: printableJob
import javax.print.attribute.standard.OrientationRequested; //导入依赖的package包/类
public void printableJob(Printable printable,
PrintRequestAttributeSet attributes)
throws PrintException {
try {
synchronized(this) {
if (job != null) { // shouldn't happen
throw new PrintException("already printing");
} else {
job = new PSPrinterJob();
}
}
job.setPrintService(getPrintService());
PageFormat pf = new PageFormat();
if (mediaSize != null) {
Paper p = new Paper();
p.setSize(mediaSize.getX(MediaSize.INCH)*72.0,
mediaSize.getY(MediaSize.INCH)*72.0);
p.setImageableArea(72.0, 72.0, p.getWidth()-144.0,
p.getHeight()-144.0);
pf.setPaper(p);
}
if (orient == OrientationRequested.REVERSE_LANDSCAPE) {
pf.setOrientation(PageFormat.REVERSE_LANDSCAPE);
} else if (orient == OrientationRequested.LANDSCAPE) {
pf.setOrientation(PageFormat.LANDSCAPE);
}
job.setPrintable(printable, pf);
job.print(attributes);
notifyEvent(PrintJobEvent.JOB_COMPLETE);
return;
} catch (PrinterException pe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(pe);
} finally {
printReturned = true;
}
}