当前位置: 首页>>代码示例>>Java>>正文


Java MediaPrintableArea类代码示例

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


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

示例1: getDefaultPrintableArea

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page,
        double w, double h) {
    double ix, iw, iy, ih;
        if (w >= 72.0 * 6.0) {
            ix = 72.0;
            iw = w - 2 * 72.0;
        } else {
            ix = w / 6.0;
            iw = w * 0.75;
        }
        if (h >= 72.0 * 6.0) {
            iy = 72.0;
            ih = h - 2 * 72.0;
        } else {
            iy = h / 6.0;
            ih = h * 0.75;
        }

    return new MediaPrintableArea((float) (ix / DPI), (float) (iy / DPI),
            (float) (iw / DPI), (float) (ih / DPI), MediaPrintableArea.INCH);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:RasterPrinterJob.java

示例2: getDefaultPrintableArea

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page,
        double w, double h) {
    double ix, iw, iy, ih;
    if (w >= 72.0 * 6.0) {
        ix = 72.0;
        iw = w - 2 * 72.0;
    } else {
        ix = w / 6.0;
        iw = w * 0.75;
    }
    if (h >= 72.0 * 6.0) {
        iy = 72.0;
        ih = h - 2 * 72.0;
    } else {
        iy = h / 6.0;
        ih = h * 0.75;
    }

    return new MediaPrintableArea((float) (ix / DPI), (float) (iy / DPI),
            (float) (iw / DPI), (float) (ih / DPI), MediaPrintableArea.INCH);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:RasterPrinterJob.java

示例3: getAllPrintableAreas

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
private MediaPrintableArea[] getAllPrintableAreas() {

        if (mpas == null) {
            Media[] media = (Media[])getSupportedAttributeValues(Media.class,
                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
        MediaPrintableArea[] mpasCopy = new MediaPrintableArea[mpas.length];
        System.arraycopy(mpas, 0, mpasCopy, 0, mpas.length);
        return mpasCopy;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:UnixPrintService.java

示例4: isSupportedMediaPrintableArea

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) {

        getMediaPrintables(null);
        int units = MediaPrintableArea.INCH;

        if (mediaPrintables != null) {
            for (int i=0; i<mediaPrintables.length; i++) {
                if ((mpa.getX(units) >= mediaPrintables[i].getX(units)) &&
                    (mpa.getY(units) >= mediaPrintables[i].getY(units)) &&
                    (mpa.getX(units) + mpa.getWidth(units) <=
                            mediaPrintables[i].getX(units) +
                            mediaPrintables[i].getWidth(units)) &&
                    (mpa.getY(units) + mpa.getHeight(units) <=
                            mediaPrintables[i].getY(units) +
                            mediaPrintables[i].getHeight(units))) {
                    return true;
                }
            }
        }
        return false;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Win32PrintService.java

示例5: updateForSelectedService

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
/**
 * Called to update for new selected
 * print service. Tests if currently
 * selected attributes are supported.
 */
void updateForSelectedService()
{
  if (categorySupported(MediaPrintableArea.class))
    {
      left.setEnabled(true);
      right.setEnabled(true);
      top.setEnabled(true);
      bottom.setEnabled(true);
      left_tf.setEnabled(true);
      right_tf.setEnabled(true);
      top_tf.setEnabled(true);
      bottom_tf.setEnabled(true);
    }
  else
    {
      left.setEnabled(false);
      right.setEnabled(false);
      top.setEnabled(false);
      bottom.setEnabled(false);
      left_tf.setEnabled(false);
      right_tf.setEnabled(false);
      top_tf.setEnabled(false);
      bottom_tf.setEnabled(false);
    }
 }
 
开发者ID:vilie,项目名称:javify,代码行数:31,代码来源:PrinterDialog.java

示例6: updateForSelectedService

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
/**
 * Called to update for new selected
 * print service. Tests if currently
 * selected attributes are supported.
 */
void updateForSelectedService()
{
  if (categorySupported(MediaPrintableArea.class))
    {
      left.setEnabled(true);
      right.setEnabled(true);
      top.setEnabled(true);
      bottom.setEnabled(true);
      left_tf.setEnabled(true);
      right_tf.setEnabled(true);
      top_tf.setEnabled(true);
      bottom_tf.setEnabled(true);           
    }
  else
    {
      left.setEnabled(false);
      right.setEnabled(false);
      top.setEnabled(false);
      bottom.setEnabled(false);
      left_tf.setEnabled(false);
      right_tf.setEnabled(false);
      top_tf.setEnabled(false);
      bottom_tf.setEnabled(false); 
    }     
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:31,代码来源:PrinterDialog.java

示例7: toString

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
/**
 * 	Get "nice" String Representation
 *  @param ctx context
 * 	@return info
 */
public String toString (Properties ctx)
{
	StringBuffer sb = new StringBuffer();
	//	Print Media size
	//AA Goodwill : Custom Paper Support
	if (m_mediaSize != null){
		sb.append(m_mediaSize.getMediaSizeName());
		//	Print dimension
		String name = m_mediaSize.getMediaSizeName().toString();
		if (!name.startsWith("iso"))
			sb.append(" - ").append(m_mediaSize.toString(MediaSize.INCH,"\""))
				.append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.INCH,"\""));
		if (!name.startsWith("na"))
			sb.append(" - ").append(m_mediaSize.toString(MediaSize.MM,"mm"))
				.append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.MM,"mm"));
		//	Print Orientation
		sb.append(") - ")
			.append(Msg.getMsg(ctx, m_landscape ? "Landscape" : "Portrait"));
	}		
	else sb.append("Custom - ").append(toString());
	//End Of AA Goodwill
	return sb.toString();
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:29,代码来源:CPaper.java

示例8: updateMediaAndMarginsIfNeeded

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
protected PrintRequestAttributeSet updateMediaAndMarginsIfNeeded(
        PrintRequestAttributeSet newAttrs) {

    /* create copy of this.attrs*/
    PrintRequestAttributeSet sum = 
            new HashPrintRequestAttributeSet(this.attrs);

    /* remove MediaMargins and MediaPrintableArea attributes from the copy
       of job attributes if newAttrs contains  MediaMargins or 
       PrintableArea */
    if (newAttrs.containsKey(MediaPrintableArea.class)
                || attrs.containsKey(MediaMargins.class)) {
        sum.remove(MediaPrintableArea.class);
        sum.remove(MediaMargins.class);
    }

    sum.addAll(newAttrs);
    return sum;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:PSPrinterJob.java

示例9: isSupportedMediaPrintableArea

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) {

        getMediaPrintables(null);

        if (mediaPrintables != null) {
            for (int i=0; i<mediaPrintables.length; i++) {
                if (mpa.equals(mediaPrintables[i])) {
                    return true;
                }
            }
        }
        return false;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:Win32PrintService.java

示例10: getDefaultPrintableArea

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
@Override
protected MediaPrintableArea getDefaultPrintableArea(PageFormat page, double w, double h) {
    final float dpi = 72.0f;
    Paper paper = page.getPaper();
    return new MediaPrintableArea(
            (float) (paper.getImageableX() / dpi),
            (float) (paper.getImageableY() / dpi),
            (float) (paper.getImageableWidth() / dpi),
            (float) (paper.getImageableHeight() / dpi),
            MediaPrintableArea.INCH);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:CPrinterJob.java

示例11: printWithCustomImageareaSize

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
private static void printWithCustomImageareaSize() {
    final JTable table = createAuthorTable(18);
    PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
    printAttributes.add(DialogTypeSelection.NATIVE);
    printAttributes.add(new Copies(1));
    printAttributes.add(new MediaPrintableArea(
            0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
    Printable printable = table.getPrintable(
            JTable.PrintMode.NORMAL,
            new MessageFormat("Author Table"),
            new MessageFormat("Page - {0}")
    );

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(printable);

    boolean printAccepted = job.printDialog(printAttributes);
    if (printAccepted) {
        try {
            job.print(printAttributes);
            closeFrame();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        throw new RuntimeException("User cancels the printer job!");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:ImageableAreaTest.java

示例12: getPrintableXFromASet

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
static double getPrintableXFromASet(PrintRequestAttributeSet aset) {
    try {
        return ((MediaPrintableArea) aset.get(
                MediaPrintableArea.class)).getX(MediaPrintableArea.INCH);
    } catch (Exception e) {
        return -1.0;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:PageDialogMarginTest.java

示例13: getPrintableYFromASet

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
static double getPrintableYFromASet(PrintRequestAttributeSet aset) {
    try {
        return ((MediaPrintableArea) aset.get(
                MediaPrintableArea.class)).getY(MediaPrintableArea.INCH);
    } catch (Exception e) {
        return -1.0;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:PageDialogMarginTest.java

示例14: main

import javax.print.attribute.standard.MediaPrintableArea; //导入依赖的package包/类
public static void main(String args[]) {
    PrinterJob job;

    job = PrinterJob.getPrinterJob();

    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();

    // Here you could see the PageFormat with an empty PrintRequestAttributeSet
    PageFormat pf2 = job.getPageFormat(pras);
    System.out.println((pf2.getImageableX() / 72f) + " "
            + (pf2.getImageableY() / 72f) + " "
            + (pf2.getImageableWidth() / 72f) + " "
            + (pf2.getImageableHeight() / 72f)
    );

    // Set left margin to 2.0
    pras.add(new MediaPrintableArea(2.0f,
            (float)(pf2.getImageableY() / 72f),
            (float) ((pf2.getImageableWidth() / 72f) - 1.0f),
            (float) (pf2.getImageableHeight() / 72f),
            MediaPrintableArea.INCH));

    pf2 = job.getPageFormat(pras);
    System.out.println((pf2.getImageableX() / 72f) + " "
            + (pf2.getImageableY() / 72f) + " "
            + (pf2.getImageableWidth() / 72f) + " "
            + (pf2.getImageableHeight() / 72f)
    );

    // check if returned left margin of imageable area is 2.0 as set earlier
    if (pf2.getImageableX() / 72f != 2.0f) {
        throw new RuntimeException("getPageFormat doesn't apply specified "
                + "MediaPrintableArea attribute");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:TestPgfmtSetMPA.java


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