本文整理汇总了Java中java.awt.print.Paper.setImageableArea方法的典型用法代码示例。如果您正苦于以下问题:Java Paper.setImageableArea方法的具体用法?Java Paper.setImageableArea怎么用?Java Paper.setImageableArea使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.print.Paper
的用法示例。
在下文中一共展示了Paper.setImageableArea方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPageFormat
import java.awt.print.Paper; //导入方法依赖的package包/类
/**
* Get an instance of {@link java.awt.print.PageFormat}.
* @param pj {@link java.awt.print.PrinterJob} which is
* associated with the default printer.
* @return an instance of <code>PageFormat</code> that describes the size and
* orientation of a page to be printed.
*/
public static PageFormat getPageFormat(PrinterJob pj) {
PageFormat pageFormat = null;
pageFormat = pj.defaultPage();
Paper p = pageFormat.getPaper();
int pageOrientation = getPreferences().getInt(PROP_PAGE_ORIENTATION, pageFormat.getOrientation());
double paperWidth = getPreferences().getDouble(PROP_PAGE_WIDTH, p.getWidth());
double paperHeight = getPreferences().getDouble(PROP_PAGE_HEIGHT, p.getHeight());
double iaWidth = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_WIDTH, p.getImageableWidth());
double iaHeight = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_HEIGHT, p.getImageableHeight());
double iaX = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_X, p.getImageableX());
double iaY = getPreferences().getDouble(PROP_PAGE_IMAGEABLEAREA_Y, p.getImageableY());
pageFormat.setOrientation(pageOrientation);
p.setSize(paperWidth, paperHeight);
p.setImageableArea(iaX, iaY, iaWidth, iaHeight);
pageFormat.setPaper(p);
return pageFormat;
}
示例2: actionPerformed
import java.awt.print.Paper; //导入方法依赖的package包/类
/**
*
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof mxGraphComponent) {
mxGraphComponent graphComponent = (mxGraphComponent) e.getSource();
PrinterJob pj = PrinterJob.getPrinterJob();
if (pj.printDialog()) {
PageFormat pf = graphComponent.getPageFormat();
Paper paper = new Paper();
double margin = 36;
paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2,
paper.getHeight() - margin * 2);
pf.setPaper(paper);
pj.setPrintable(graphComponent, pf);
try {
pj.print();
} catch (PrinterException e2) {
System.out.println(e2);
}
}
}
}
示例3: getPageFormat
import java.awt.print.Paper; //导入方法依赖的package包/类
public PageFormat getPageFormat() {
PrinterJob job = PrinterJob.getPrinterJob();
if (myPageFormat == null) {
myPageFormat = job.defaultPage();
// restore
myPageFormat.setOrientation(round(get(PAGE_ORIENTATION, PageFormat.PORTRAIT)));
Paper paper = myPageFormat.getPaper();
if (get(PAPER_WIDTH, null) != null && get(PAPER_HEIGHT, null) != null) {
paper.setSize(get(PAPER_WIDTH, INCH), get(PAPER_HEIGHT, INCH));
}
if (get(AREA_X, null) != null && get(AREA_Y, null) != null && get(AREA_WIDTH, null) != null && get(AREA_HEIGHT, null) != null) {
paper.setImageableArea(get(AREA_X, INCH), get(AREA_Y, INCH), get(AREA_WIDTH, INCH), get(AREA_HEIGHT, INCH));
}
myPageFormat.setPaper(paper);
}
return myPageFormat;
}
示例4: printTest
import java.awt.print.Paper; //导入方法依赖的package包/类
private static void printTest() {
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat pf = pj.defaultPage();
Paper paper = new Paper();
double margin = 36; // half inch
paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2,
paper.getHeight() - margin * 2);
pf.setPaper(paper);
pj.setPrintable(new PrintTestLexmarkIQ(), pf);
if (pj.printDialog()) {
try {
pj.print();
} catch (PrinterException e) {
System.out.println(e);
}
}
}
示例5: testGetPageFormat
import java.awt.print.Paper; //导入方法依赖的package包/类
public void testGetPageFormat() {
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat expResult = PrintPreferences.getPageFormat(pj);
PrintPreferences.setPageFormat(expResult);
PageFormat result = PrintPreferences.getPageFormat(pj);
assertEquals(expResult.getHeight(), result.getHeight());
assertEquals(expResult.getWidth(), result.getWidth());
assertEquals(expResult.getOrientation(), result.getOrientation());
assertEquals(expResult.getPaper().getHeight(), result.getPaper().getHeight());
assertEquals(expResult.getPaper().getWidth(), result.getPaper().getWidth());
assertEquals(expResult.getPaper().getImageableHeight(), result.getPaper().getImageableHeight());
assertEquals(expResult.getPaper().getImageableWidth(), result.getPaper().getImageableWidth());
assertEquals(expResult.getPaper().getImageableX(), result.getPaper().getImageableX());
assertEquals(expResult.getPaper().getImageableY(), result.getPaper().getImageableY());
double w = expResult.getPaper().getWidth() + 10;
double h = expResult.getPaper().getHeight() + 10;
Paper p = expResult.getPaper();
double ix = p.getImageableX() + 10;
double iy = p.getImageableY() + 10;
double iw = p.getImageableWidth() + 10;
double ih = p.getImageableHeight() + 10;
p.setImageableArea(ix, iy, iw, ih);
p.setSize(w, h);
expResult.setPaper(p);
PrintPreferences.setPageFormat(expResult);
assertEquals(h, PrintPreferences.getPageFormat(pj).getHeight());
assertEquals(w, PrintPreferences.getPageFormat(pj).getWidth());
assertEquals(ix, PrintPreferences.getPageFormat(pj).getPaper().getImageableX());
assertEquals(iy, PrintPreferences.getPageFormat(pj).getPaper().getImageableY());
assertEquals(iw, PrintPreferences.getPageFormat(pj).getPaper().getImageableWidth());
assertEquals(ih, PrintPreferences.getPageFormat(pj).getPaper().getImageableHeight());
expResult.setOrientation(PageFormat.REVERSE_LANDSCAPE);
PrintPreferences.setPageFormat(expResult);
assertEquals(PageFormat.REVERSE_LANDSCAPE, PrintPreferences.getPageFormat(pj).getOrientation());
}
示例6: EPSPrinter
import java.awt.print.Paper; //导入方法依赖的package包/类
public EPSPrinter(Printable printable, String title,
PrintStream stream,
int x, int y, int wid, int hgt) {
this.printable = printable;
this.epsTitle = title;
this.stream = stream;
llx = x;
lly = y;
urx = llx+wid;
ury = lly+hgt;
// construct a PageFormat with zero margins representing the
// exact bounds of the applet. ie construct a theoretical
// paper which happens to exactly match applet panel size.
Paper p = new Paper();
p.setSize((double)wid, (double)hgt);
p.setImageableArea(0.0,0.0, (double)wid, (double)hgt);
pf = new PageFormat();
pf.setPaper(p);
}
示例7: actionPerformed
import java.awt.print.Paper; //导入方法依赖的package包/类
/**
*
*/
public void actionPerformed(ActionEvent e)
{
if (e.getSource() instanceof mxGraphComponent)
{
mxGraphComponent graphComponent = (mxGraphComponent) e
.getSource();
PrinterJob pj = PrinterJob.getPrinterJob();
if (pj.printDialog())
{
PageFormat pf = graphComponent.getPageFormat();
Paper paper = new Paper();
double margin = 36;
paper.setImageableArea(margin, margin, paper.getWidth()
- margin * 2, paper.getHeight() - margin * 2);
pf.setPaper(paper);
pj.setPrintable(graphComponent, pf);
try
{
pj.print();
}
catch (PrinterException e2)
{
System.out.println(e2);
}
}
}
}
示例8: doTest
import java.awt.print.Paper; //导入方法依赖的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);
}
}
}
示例9: getPageFormat
import java.awt.print.Paper; //导入方法依赖的package包/类
private PageFormat getPageFormat() {
final double mmToDots = 72 / 2.54;
SettingsModel settings = Controller.get().getConfig();
Paper p = new Paper();
p.setSize(
settings.getValue("PageWidht", 21.0 * mmToDots),
settings.getValue("PageHeight", 29.7 * mmToDots)
);
p.setImageableArea(
settings.getValue("PageImageableX", 2.5 * mmToDots),
settings.getValue("PageImageableY", 1.0 * mmToDots),
settings.getValue("PageImageableWidth", 17.5 * mmToDots),
settings.getValue("PageImageableHeight", 27.7 * mmToDots)
);
PageFormat pf = new PageFormat();
pf.setPaper(p);
pf.setOrientation(settings.getValue("PageOrientation", PageFormat.PORTRAIT));
return pf;
}
示例10: actionPerformed
import java.awt.print.Paper; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e)
{
PrinterJob pj = PrinterJob.getPrinterJob();
if (pj.printDialog())
{
PageFormat pf = frame.getPageFormat();
Paper paper = new Paper();
double margin = 36;
paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2, paper.getHeight() - margin * 2);
pf.setPaper(paper);
pj.setPrintable(textArea, pf);
try
{
// Don't delete the float cast! If done, deriveFont will change the style instead of the font size.
textArea.setFont(textArea.getFont().deriveFont((float)(textArea.getFont().getSize() - 5)));
pj.print();
} catch (PrinterException e2)
{
JOptionPane.showMessageDialog(frame, "Error de impresión", "Error", JOptionPane.ERROR_MESSAGE);
}
textArea.setFont(textArea.getFont().deriveFont((float)(textArea.getFont().getSize() + 5)));
}
}
示例11: getPageFormat
import java.awt.print.Paper; //导入方法依赖的package包/类
/**
* Gets a page format instance that describes this page's geometry in terms
* of the Java print API.
*
* @return A throwaway PageFormat object that describes this page's current
* geometry. Changes to the returned PageFormat object will not
* affect this page in any way.
*/
public PageFormat getPageFormat() {
PageFormat pageFormat = new PageFormat();
pageFormat.setOrientation(getOrientation().getPrintApiCode());
Paper paper = new Paper();
if (getOrientation() == PageOrientation.PORTRAIT) {
paper.setSize(getWidth(), getHeight());
} else {
paper.setSize(getHeight(), getWidth());
}
// the imageable area on the page format we return determines the clipping
// region for the print API, so we always want to set it as big as possible
// regardless of our own margin guides
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
pageFormat.setPaper(paper);
return pageFormat;
}
示例12: setPageFormatFromString
import java.awt.print.Paper; //导入方法依赖的package包/类
/**
* @param pPageFormat
* @param pPageFormatProperty
*/
public static void setPageFormatFromString(Paper pPaper,
String pPageFormatProperty) {
try {
// parse string:
StringTokenizer tokenizer = new StringTokenizer(
pPageFormatProperty, ";");
if (tokenizer.countTokens() != 6) {
logger.warning("Page format property has not the correct format:"
+ pPageFormatProperty);
return;
}
pPaper.setSize(nt(tokenizer), nt(tokenizer));
pPaper.setImageableArea(nt(tokenizer), nt(tokenizer),
nt(tokenizer), nt(tokenizer));
} catch (Exception e) {
freemind.main.Resources.getInstance().logException(e);
}
}
示例13: internalizePageFormat
import java.awt.print.Paper; //导入方法依赖的package包/类
/** Reads a PageFormat instance from ObjectInput
* @param obtis
* @return deserialized PageFormat instance
*/
private static PageFormat internalizePageFormat(ObjectInput obtis)
throws IOException, ClassNotFoundException {
PageFormat pf = new PageFormat();
Paper paper = pf.getPaper();
int etc = obtis.readInt();
if (etc == (PageFormat.LANDSCAPE ^ PageFormat.REVERSE_LANDSCAPE ^ PageFormat.PORTRAIT)) {
return null;
}
pf.setOrientation(etc);
// paper size
paper.setSize(obtis.readDouble(), obtis.readDouble());
// imageable
paper.setImageableArea(obtis.readDouble(),
obtis.readDouble(),
obtis.readDouble(),
obtis.readDouble());
pf.setPaper(paper);
return pf;
}
示例14: createPageFormat
import java.awt.print.Paper; //导入方法依赖的package包/类
/** @return A newly created {@link PageFormat} with the current settings. */
public PageFormat createPageFormat() {
PageFormat format = new PageFormat();
PageOrientation orientation = getPageOrientation();
double[] size = getPaperSize(LengthUnits.PT);
double[] margins = getPaperMargins(LengthUnits.PT);
Paper paper = new Paper();
if (orientation == PageOrientation.PORTRAIT) {
format.setOrientation(PageFormat.PORTRAIT);
} else if (orientation == PageOrientation.LANDSCAPE) {
format.setOrientation(PageFormat.LANDSCAPE);
} else if (orientation == PageOrientation.REVERSE_PORTRAIT) {
// REVERSE_PORTRAIT doesn't exist in the old PageFormat class
format.setOrientation(PageFormat.PORTRAIT);
} else if (orientation == PageOrientation.REVERSE_LANDSCAPE) {
format.setOrientation(PageFormat.REVERSE_LANDSCAPE);
}
paper.setSize(size[0], size[1]);
paper.setImageableArea(margins[1], margins[0], size[0] - (margins[1] + margins[3]), size[1] - (margins[0] + margins[2]));
format.setPaper(paper);
return format;
}
示例15: transSVG
import java.awt.print.Paper; //导入方法依赖的package包/类
protected PdfTemplate transSVG( String svgPath, byte[] svgData, float x,
float y, float height, float width, String helpText )
throws IOException, DocumentException
{
PdfTemplate template = contentByte.createTemplate( width, height );
Graphics2D g2D = template.createGraphics( width, height );
PrintTranscoder transcoder = new PrintTranscoder( );
if ( null != svgData && svgData.length > 0 )
{
transcoder.transcode( new TranscoderInput(
new ByteArrayInputStream( svgData ) ), null );
}
else if ( null != svgPath )
{
transcoder.transcode( new TranscoderInput( svgPath ), null );
}
PageFormat pg = new PageFormat( );
Paper p = new Paper( );
p.setSize( width, height );
p.setImageableArea( 0, 0, width, height );
pg.setPaper( p );
transcoder.print( g2D, pg, 0 );
g2D.dispose( );
return template;
}