private static void savePrintSpec() { String settings = jEdit.getSettingsDirectory(); if(settings == null) return; String printSpecPath = MiscUtilities.constructPath( settings, "printspec"); File filePrintSpec = new File(printSpecPath); try { FileOutputStream fileOut=new FileOutputStream(filePrintSpec); ObjectOutputStream obOut=new ObjectOutputStream(fileOut); obOut.writeObject(format); //for backwards compatibility, the color variable is stored also as a property Chromaticity cc=(Chromaticity)format.get(Chromaticity.class); if (cc!=null) jEdit.setBooleanProperty("print.color", cc.getValue()==Chromaticity.COLOR.getValue()); } catch(Exception e) { e.printStackTrace(); } } //}}}
/** * Asks the user for a printer and settings and return the pageformat.<br> * Does not print! Use {@link #printJob(java.awt.print.PrinterJob, javax.print.attribute.PrintRequestAttributeSet, boolean)} to print. * * @param job is the new printerjob * @param jobName is the jobname, null = none * @param aset is an initialized (and possibly empty) attribute set, must not be null, because its returned! * @return the pageformat and possibly updated aset, null if printing aborted */ public static PageFormat print(PrinterJob job, String jobName, PrintRequestAttributeSet aset) { if (aset.get(Media.class) == null) { aset.add(mediaSizeName); } if (aset.get(MediaPrintableArea.class) == null) { aset.add(area); } if (jobName != null) { aset.add(new JobName(jobName, Locale.getDefault())); job.setJobName(jobName); } if (job.printDialog(aset)) { return getPageFormat(aset); } return null; }
/** * Utility that tries to save the state of the currently set MediaSize. * The width height and unit values are written to the the propertiesManager. * When the Viewer RI is exited the properites file is wrtten to disk. * * @param printHelper instance of the open documents print helper. */ private void savePrinterProperties(PrintHelper printHelper) { PrintRequestAttributeSet printRequestAttributeSet = printHelper.getPrintRequestAttributeSet(); Object printAttributeSet = printRequestAttributeSet.get(Media.class); if (propertiesManager != null && printAttributeSet instanceof MediaSizeName) { MediaSizeName paper = (MediaSizeName) printAttributeSet; MediaSize mediaSize = MediaSize.getMediaSizeForName(paper); // write out the new page size property values. int printMediaUnit = MediaSize.MM; propertiesManager.set( PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_UNIT, String.valueOf(printMediaUnit)); double printMediaWidth = mediaSize.getX(printMediaUnit); propertiesManager.set( PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_WIDTH, String.valueOf(printMediaWidth)); double printMediaHeight = mediaSize.getY(printMediaUnit); propertiesManager.set( PropertiesManager.PROPERTY_PRINT_MEDIA_SIZE_HEIGHT, String.valueOf(printMediaHeight)); } }
Attribute attrib = aset.get(MediaPrintableArea.class); if (attrib != null) { MediaPrintableArea mpa = (MediaPrintableArea)attrib; attrib = aset.get(Media.class); if (attrib instanceof MediaSizeName) { MediaSize size = MediaSize.getMediaSizeForName((MediaSizeName)attrib); attrib = aset.get(OrientationRequested.class); if (attrib != null) { OrientationRequested orientation = (OrientationRequested)attrib;
Fidelity fd = (Fidelity) attributes.get(fdCategory); if (fd != null) { if (fd == Fidelity.FIDELITY_TRUE) {
Paper pap=pf.getPaper(); MediaSizeName media=(MediaSizeName)format.get( Media.class); MediaSize ms=MediaSize.getMediaSizeForName(media); MediaPrintableArea mediaarea=(MediaPrintableArea)format.get( MediaPrintableArea.class); if(mediaarea!=null) pf.setPaper(pap); OrientationRequested orientation=(OrientationRequested)format.get( OrientationRequested.class); if(orientation!=null)