• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Size2DSyntax类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.print.attribute.Size2DSyntax的典型用法代码示例。如果您正苦于以下问题:Java Size2DSyntax类的具体用法?Java Size2DSyntax怎么用?Java Size2DSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Size2DSyntax类属于javax.print.attribute包,在下文中一共展示了Size2DSyntax类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doTest

import javax.print.attribute.Size2DSyntax; //导入依赖的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);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:WrongPaperPrintingTest.java


示例2: setMediaSize

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
/**
 * Set Media Size
 * @param x the value to which to set this <code>Paper</code> object's width
 * @param y the value to which to set this <code>Paper</code> object's height
 * @param units number of microns (see Size2DSyntax.INCH, Size2DSyntax.MM)
 * @param landscape true if it's landscape format
 * @see Paper#setSize(double, double)
 */
public void setMediaSize (double x, double y, int units, boolean landscape)
{
	if (x == 0 || y == 0)
		throw new IllegalArgumentException("MediaSize is null");
	
	m_landscape = landscape;

	//	Get Sise in Inch * 72
	final double mult = (double)units / (double)Size2DSyntax.INCH * (double)72;
	final double width = x * mult;
	final double height = y * mult;
	//	Set Size
	setSize (width, height);
	log.debug("Width & Height" + ": " + x + "/" + y  + " - Landscape=" + m_landscape);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:24,代码来源:CPaper.java


示例3: getPaper

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
public Paper getPaper() {
    final short size = getDmPaperSize(structPtr);
    Paper p = StdPaper.getPaper(size);

    if (p == null) {
        final long fields = getDmFields();

        if (((fields & DM_PAPERLENGTH) != 0)
                        && ((fields & DM_PAPERWIDTH) != 0)) {
            p = new CustomPaper(size, new MediaSize(
                            getDmPaperWidth(structPtr) / 10,
                            getDmPaperLength(structPtr) / 10,
                            Size2DSyntax.MM));
        }
    }

    return p;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:DevmodeStructWrapper.java


示例4: getSupportedMediaSizeNames

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
public static MediaSizeName[] getSupportedMediaSizeNames(final long handle)
                throws PrintException {
    final MediaSizeName[] names;
    final int[] sizes = getSupportedPaperSizes(handle);
    final Vector<MediaSizeName> v = new Vector<MediaSizeName>(
                    sizes.length / 2);

    for (int i = 0; i < sizes.length; i += 2) {
        if ((sizes[i] > 0) && (sizes[i + 1] > 0)) {
            final MediaSizeName name = MediaSize.findMedia(sizes[i] / 10,
                            sizes[i + 1] / 10, Size2DSyntax.MM);

            if ((name != null) && !v.contains(name)) {
                v.add(name);
            }
        }
    }

    names = new MediaSizeName[v.size()];
    return v.toArray(names);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:WinPrinterFactory.java


示例5: mapMedia

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
public static MediaSizeName mapMedia(MediaType mType) {
    MediaSizeName media = null;

    // JAVAXSIZES.length and SIZES.length must be equal!
    // Attempt to recover by getting the smaller size.
    int length = Math.min(SIZES.length, JAVAXSIZES.length);

    for (int i=0; i < length; i++) {
        if (SIZES[i] == mType) {
            if ((JAVAXSIZES[i] != null) &&
                MediaSize.getMediaSizeForName(JAVAXSIZES[i]) != null) {
                media = JAVAXSIZES[i];
                break;
            } else {
                /* create Custom Media */
                media = new CustomMediaSizeName(SIZES[i].toString());

                float w = (float)Math.rint(WIDTHS[i]  / 72.0);
                float h = (float)Math.rint(LENGTHS[i] / 72.0);
                if (w > 0.0 && h > 0.0) {
                    // add new created MediaSize to our static map
                    // so it will be found when we call findMedia
                    new MediaSize(w, h, Size2DSyntax.INCH, media);
                }

                break;
            }
        }
    }
    return media;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:PrintJob2D.java


示例6: print

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
private void print(final PrintPackageRequest request) throws PrinterException
{
	logger.log(Level.FINE, "Printing request {}", request);

	// Create Print Job
	final PrinterJob pjob = PrinterJob.getPrinterJob();
	pjob.setJobName(request.getPrintJobName());

	final PageFormat pf = pjob.defaultPage();
	final Paper paper = pjob.defaultPage().getPaper();
	final MediaSize size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A4);

	paper.setSize(size.getSize(Size2DSyntax.INCH)[0] * 72, size.getSize(Size2DSyntax.INCH)[1] * 72);
	paper.setImageableArea(0, 0, size.getSize(Size2DSyntax.INCH)[0] * 72, size.getSize(Size2DSyntax.INCH)[1] * 72);
	pf.setPaper(paper);

	final Book book = new Book();// java.awt.print.Book
	book.append(request.getPrintable(), pf, request.getNumPages());
	pjob.setPageable(book);

	pjob.setPrintService(request.getPrintService());
	pjob.print(request.getAttributes());

	// task 09618: allow us to configure the client to return an error even if everything went OK, so we can test
	final String alwaysReturnError = Context.getContext().getProperty(Context.CTX_Testing_AlwaysReturnError, Context.DEFAULT_AlwaysReturnError);
	if (Boolean.parseBoolean(alwaysReturnError))
	{
		logger.log(Level.INFO, "{} is true, so we report an error, despite the print was OK", Context.CTX_Testing_AlwaysReturnError);

		final String errorMsg = Context.getContext().getProperty(Context.CTX_Testing_ErrorMessage, Context.DEFAULT_ErrorMessage);
		throw new PrinterException(errorMsg);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:34,代码来源:PrintingEngine.java


示例7: getUnitsInt

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
/**
 * 	Get Units Int
 *	@return units
 */
public int getUnitsInt()
{
	String du = getDimensionUnits();
	if (du == null || DIMENSIONUNITS_MM.equals(du))
		return Size2DSyntax.MM;
	else if (DIMENSIONUNITS_Inch.equals(du))
		return Size2DSyntax.INCH; 
	else
		throw new AdempiereException("@[email protected] @[email protected] : "+du);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:15,代码来源:MPrintPaper.java


示例8: setPaper

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
public void setPaper(final Paper paper) {
    if (paper != null) {
        if (paper.getDmPaperSize() > 0) {
            setDmPaperSize(structPtr, paper.getDmPaperSize());
        } else {
            setDmPaperWidth(structPtr, (short) (paper.getSize().getX(
                            Size2DSyntax.MM) * 10));
            setDmPaperLength(structPtr, (short) (paper.getSize().getY(
                            Size2DSyntax.MM) * 10));
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:DevmodeStructWrapper.java


示例9: PPDMediaSizeName

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
protected PPDMediaSizeName(int value, float x, float y) {
    super(value);
    if (x > y) {
        float z = x;
        y = x;
        x = z;
    }
    new MediaSize(x / 72, y / 72, Size2DSyntax.INCH, this);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:PPDMediaSizeName.java


示例10: getAttrsForPageFormat

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
protected HashPrintRequestAttributeSet 
        getAttrsForPageFormat(PageFormat page) {

    HashPrintRequestAttributeSet lattrs=new HashPrintRequestAttributeSet();

    /* Add Orientation attribute */
    switch (page.getOrientation()) {
        case PageFormat.LANDSCAPE:
            lattrs.add(OrientationRequested.LANDSCAPE);
            break;
        case PageFormat.PORTRAIT:
            lattrs.add(OrientationRequested.PORTRAIT);
            break;
        case PageFormat.REVERSE_LANDSCAPE:
            lattrs.add(OrientationRequested.REVERSE_LANDSCAPE);
            break;
    }

    /* Add Media attribute */
    MediaSizeName media = MediaSize.findMedia(
            (float) (page.getWidth() / 72.0),
            (float) (page.getHeight() / 72.0), 
            Size2DSyntax.INCH);
    if (media != null) {
        lattrs.add(media);
    }

    /* Add MediaMargins attribute */
    lattrs.add(new MediaMargins((float) (page.getImageableX() / 72.0), 
            (float) (page.getImageableY() / 72.0), 
            (float) ((page.getWidth() - page.getImageableX() -
                    page.getImageableWidth()) / 72.0),
            (float) ((page.getHeight() - page.getImageableHeight() -
                    page.getImageableY()) / 72.0), 
            MediaMargins.INCH));

    return lattrs;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:39,代码来源:PSPrinterJob.java


示例11: formatToAttrs

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
private static PrintRequestAttributeSet formatToAttrs(
                final PageFormat format) {
    final PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();

    if (format != null) {
        attributes.add(new MediaPrintableArea((float) (format
                        .getImageableX() / 72.0), (float) (format
                        .getImageableY() / 72.0), (float) (format
                        .getWidth() / 72.0),
                        (float) (format.getHeight() / 72.0),
                        Size2DSyntax.INCH));

        switch (format.getOrientation()) {
        case PageFormat.PORTRAIT:
            attributes.add(OrientationRequested.PORTRAIT);
            break;
        case PageFormat.LANDSCAPE:
            attributes.add(OrientationRequested.LANDSCAPE);
            break;
        case PageFormat.REVERSE_LANDSCAPE:
            attributes.add(OrientationRequested.REVERSE_LANDSCAPE);
            break;
        }
    }

    return attributes;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:PrinterJobImpl.java


示例12: getMediaDimensions

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
/**
 * @param media The {@link Media} to extract dimensions for.
 * @param units The units to return.
 * @return The dimensions of the specified {@link Media}.
 */
public static double[] getMediaDimensions(Media media, LengthUnits units) {
	MediaSize size = media instanceof MediaSizeName ? MediaSize.getMediaSizeForName((MediaSizeName) media) : null;

	if (size == null) {
		size = MediaSize.NA.LETTER;
	}
	return new double[] { units.convert(LengthUnits.IN, size.getX(Size2DSyntax.INCH)), units.convert(LengthUnits.IN, size.getY(Size2DSyntax.INCH)) };
}
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:14,代码来源:PrintUtilities.java


示例13: setPaperSize

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
/**
 * Sets the paper size.
 *
 * @param service The {@link PrintService} to use.
 * @param set The {@link PrintRequestAttributeSet} to use.
 * @param size The size of the paper.
 * @param units The type of units being used.
 */
public static void setPaperSize(PrintService service, PrintRequestAttributeSet set, double[] size, LengthUnits units) {
	double[] margins = getPaperMargins(service, set, units);
	MediaSizeName mediaSizeName = MediaSize.findMedia((float) LengthUnits.IN.convert(units, size[0]), (float) LengthUnits.IN.convert(units, size[1]), Size2DSyntax.INCH);

	if (mediaSizeName == null) {
		mediaSizeName = MediaSizeName.NA_LETTER;
	}
	set.add(mediaSizeName);
	setPaperMargins(service, set, margins, units);
}
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:19,代码来源:PrintUtilities.java


示例14: getMediaSizeName

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
public static MediaSizeName getMediaSizeName(PDDocument document) throws IOException {
    PDFRenderer renderer = new PDFRenderer(document);
    BufferedImage image = renderer.renderImageWithDPI(0, 72f);
    float w, h, swp;
    w = image.getWidth() / 72f;
    h = image.getHeight() / 72f;
    if (w > h) {
        swp = w;
        w = h;
        h = swp;
    }
    return MediaSize.findMedia(w, h, Size2DSyntax.INCH);
}
 
开发者ID:montsuqi,项目名称:monsiaj,代码行数:14,代码来源:PDFPrint.java


示例15: getPageFormat

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
private PageFormat getPageFormat(final AttributeSet... attrSets) {
    final Paper paper = new Paper();
    final PageFormat format = new PageFormat();
    final DevmodeStructWrapper dm = service.getPrinterProps();
    final OrientationRequested o = dm.getOrientation();
    final MediaPrintableArea area = getAttribute(
                    MediaPrintableArea.class, attrSets);
    DevmodeStructWrapper.Paper p = dm.getPaper();

    if (p == null) {
        p = (DevmodeStructWrapper.Paper) service
                        .getDefaultAttributeValue(DevmodeStructWrapper.Paper.class);
        dm.setPaper(p);
    }

    paper.setSize(p.getSize().getX(Size2DSyntax.INCH) * 72.0, p
                    .getSize().getY(Size2DSyntax.INCH) * 72.0);
    format.setPaper(paper);

    if (OrientationRequested.LANDSCAPE.equals(o)
                    || OrientationRequested.REVERSE_LANDSCAPE.equals(o)) {
        format.setOrientation(PageFormat.LANDSCAPE);
    } else {
        format.setOrientation(PageFormat.PORTRAIT);
    }

    if (area != null) {
        paper.setImageableArea(area.getX(MediaPrintableArea.INCH) * 72,
                        area.getY(MediaPrintableArea.INCH) * 72,
                        area.getWidth(MediaPrintableArea.INCH) * 72,
                        area.getHeight(MediaPrintableArea.INCH) * 72);
    } else {
        final double x = paper.getWidth() / 10;
        final double y = paper.getHeight() / 10;

        paper.setImageableArea(x, y, (paper.getWidth() - 2 * x), (paper
                        .getHeight() - 2 * y));
    }

    return format;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:42,代码来源:WinPrintJob.java


示例16: updateMargins

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
private boolean updateMargins() {
    float x1;
    float y1;
    float x2; 
    float y2;    
    NumberFormatter format = getFloatFormatter();

    if (!leftTxt.isEnabled()) {
        removeAttribute(MediaPrintableArea.class);
        removeAttribute(MediaMargins.class);
        return true;
    }

    try {
        x1 = ((Float) format.stringToValue(leftTxt.getText())).floatValue();
        x2 = ((Float) format.stringToValue(rightTxt.getText())).floatValue();
        y1 = ((Float) format.stringToValue(topTxt.getText())).floatValue();
        y2 = ((Float) format.stringToValue(bottomTxt.getText())).floatValue();
    } catch(ParseException e) {
        return false;
    }

    if (sizeBox.isEnabled() 
         && (sizeBox.getSelectedItem() instanceof MediaSizeName) 
         && myService.isAttributeCategorySupported(MediaPrintableArea.class)) {
        MediaSize mediaSize = MediaSize.getMediaSizeForName(
                (MediaSizeName) sizeBox.getSelectedItem());
        float paperWidth = mediaSize.getX(Size2DSyntax.MM);
        float paperHeight = mediaSize.getY(Size2DSyntax.MM);
        if ((x1 + x2 >= paperWidth) || (y1 + y2 >= paperHeight)) {
            return false;
        }
        newAttrs.add(new MediaPrintableArea(x1, 
                                            y1, 
                                            paperWidth - x1 - x2,
                                            paperHeight - y1 - y2, 
                                            MediaPrintableArea.MM));
    } else {
        removeAttribute(MediaPrintableArea.class);
    }

    if (myService.isAttributeCategorySupported(MediaMargins.class)) {
        newAttrs.add(new MediaMargins(x1, y1, x2, y2, MediaMargins.MM));
    } else {
        removeAttribute(MediaMargins.class);
    }
    return true;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:49,代码来源:ServiceUIDialog.java


示例17: getIppValue

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
public static Object getIppValue(Attribute attr, byte ippvtag) {
    Object o = null;

    switch (ippvtag) {
    // integer values for the "value-tag" field.
    case IppAttribute.TAG_BOOLEAN:
    case IppAttribute.TAG_INTEGER:
    case IppAttribute.TAG_ENUM:
        if (attr instanceof IntegerSyntax) {
            o = new Integer(((IntegerSyntax) attr).getValue());
        } else if (attr instanceof EnumSyntax) {
            o = new Integer(((EnumSyntax) attr).getValue());
        } else if (attr instanceof DateTimeSyntax
                || attr instanceof ResolutionSyntax
                || attr instanceof SetOfIntegerSyntax
                || attr instanceof Size2DSyntax
                || attr instanceof TextSyntax || attr instanceof URISyntax) {
            // TODO - process other attr's types
        }
        break;
    // octetString values for the "value-tag" field.
    case IppAttribute.TAG_DATETIME:
    case IppAttribute.TAG_RESOLUTION:
    case IppAttribute.TAG_RANGEOFINTEGER:
    case IppAttribute.TAG_OCTETSTRINGUNSPECIFIEDFORMAT:
    case IppAttribute.TAG_TEXTWITHLANGUAGE:
    case IppAttribute.TAG_NAMEWITHLANGUAGE:
        if (attr instanceof IntegerSyntax) {
            // TODO - it seems that this needs to be fixed
            o = new Integer(((IntegerSyntax) attr).toString());
        } else if (attr instanceof EnumSyntax) {
            // TODO - it seems that this needs to be fixed
            o = new Integer(((EnumSyntax) attr).toString());
        } else if (attr instanceof DateTimeSyntax
                || attr instanceof ResolutionSyntax
                || attr instanceof SetOfIntegerSyntax
                || attr instanceof Size2DSyntax) {
            // TODO - process other attr's types
        } else if (attr instanceof TextSyntax) {
            // TODO - it seems that this needs to be fixed
            o = new Integer(((TextSyntax) attr).toString());
        } else if (attr instanceof URISyntax) {
            // TODO - it seems that this needs to be fixed
            o = new Integer(((URISyntax) attr).toString());
        }
        break;
    // character-string values for the "value-tag" field
    case IppAttribute.TAG_TEXTWITHOUTLANGUAGE:
    case IppAttribute.TAG_NAMEWITHOUTLANGUAGE:
    case IppAttribute.TAG_KEYWORD:
    case IppAttribute.TAG_URI:
    case IppAttribute.TAG_URISCHEME:
    case IppAttribute.TAG_CHARSET:
    case IppAttribute.TAG_NATURAL_LANGUAGE:
    case IppAttribute.TAG_MIMEMEDIATYPE:
        if (attr instanceof IntegerSyntax) {
            o = ((IntegerSyntax) attr).toString();
        } else if (attr instanceof EnumSyntax) {
            o = ((EnumSyntax) attr).toString();
        } else if (attr instanceof DateTimeSyntax
                || attr instanceof ResolutionSyntax
                || attr instanceof SetOfIntegerSyntax
                || attr instanceof Size2DSyntax) {
            // TODO - process other attr's types
        } else if (attr instanceof TextSyntax) {
            o = ((TextSyntax) attr).toString();
        } else if (attr instanceof URISyntax) {
            o = ((URISyntax) attr).toString();
        }
        break;
    default:
        break;
    }

    return o;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:77,代码来源:IppAttributeUtils.java


示例18: getPageFormatForAttrs

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
protected PageFormat getPageFormatForAttrs(
        PrintRequestAttributeSet newattrs) {
    
    PageFormat pf = new PageFormat();
    
    if (newattrs.containsKey(OrientationRequested.class)) {
        OrientationRequested or = (OrientationRequested)
                newattrs.get(OrientationRequested.class);
        pf.setOrientation(or.equals(OrientationRequested.LANDSCAPE)  
                ? PageFormat.LANDSCAPE
                : (or.equals(OrientationRequested.REVERSE_LANDSCAPE)  
                        ? PageFormat.REVERSE_LANDSCAPE 
                        : PageFormat.PORTRAIT));
    }

    Paper paper = new Paper();
    MediaSize size = MediaSize.getMediaSizeForName(
            newattrs.containsKey(Media.class) 
                    && (newattrs.get(Media.class).getClass().
                            isAssignableFrom(MediaSizeName.class))
            ? (MediaSizeName)newattrs.get(Media.class) 
            : MediaSizeName.ISO_A4);
    paper.setSize(size.getX(Size2DSyntax.INCH) * 72.0, 
                  size.getY(Size2DSyntax.INCH) * 72.0);


    MediaMargins mm;
    if (newattrs.containsKey(MediaMargins.class)) {
        mm = (MediaMargins) newattrs.get(MediaMargins.class);
    } else if(newattrs.containsKey(MediaPrintableArea.class)) {
        mm = new MediaMargins(size, 
             (MediaPrintableArea) attrs.get(MediaPrintableArea.class));
    } else {
        mm = new MediaMargins(25.4F, 25.4F, 25.4F, 25.4F, MediaMargins.MM);
    }
    paper.setImageableArea(mm.getX1(MediaMargins.INCH) * 72.0, 
            mm.getY1(MediaMargins.INCH) * 72.0, 
            (size.getX(Size2DSyntax.INCH) - mm.getX1(MediaMargins.INCH) -
            mm.getX2(MediaMargins.INCH)) * 72.0,
            (size.getY(Size2DSyntax.INCH) - mm.getY1(MediaMargins.INCH) -
            mm.getY2(MediaMargins.INCH)) * 72.0 );
    pf.setPaper(paper);
    return pf;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:45,代码来源:PSPrinterJob.java


示例19: attrsToFormat

import javax.print.attribute.Size2DSyntax; //导入依赖的package包/类
private static PageFormat attrsToFormat(
                final PrintRequestAttributeSet attributes) {
    if (attributes == null) {
        return new PageFormat();
    }

    final PageFormat format = new PageFormat();
    final Paper paper = new Paper();
    final OrientationRequested orient = (OrientationRequested) attributes
                    .get(OrientationRequested.class);
    final MediaSize size = attributes.containsKey(Media.class) ? MediaSize
                    .getMediaSizeForName((MediaSizeName) attributes
                                    .get(Media.class))
                    : (MediaSize) attributes.get(MediaSize.class);
    final MediaPrintableArea area = (MediaPrintableArea) attributes
                    .get(MediaPrintableArea.class);

    if (orient != null) {
        if (orient.equals(OrientationRequested.LANDSCAPE)) {
            format.setOrientation(PageFormat.LANDSCAPE);
        } else if (orient.equals(OrientationRequested.REVERSE_LANDSCAPE)) {
            format.setOrientation(PageFormat.REVERSE_LANDSCAPE);
        }
    }

    if (size != null) {
        paper.setSize(size.getX(Size2DSyntax.INCH) * 72.0, size
                        .getY(Size2DSyntax.INCH) * 72.0);
    }

    if (area != null) {
        paper.setImageableArea(area.getX(Size2DSyntax.INCH) * 72.0, area
                        .getY(Size2DSyntax.INCH) * 72.0, area
                        .getWidth(Size2DSyntax.INCH) * 72.0, area
                        .getHeight(Size2DSyntax.INCH) * 72.0);
    }

    format.setPaper(paper);

    return format;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:42,代码来源:PrinterJobImpl.java



注:本文中的javax.print.attribute.Size2DSyntax类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CapacityScheduler类代码示例发布时间:2022-05-21
下一篇:
Java BcRSAContentSignerBuilder类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap