From: <doc...@us...> - 2007-07-06 20:27:55
|
Revision: 103 http://openpcl.svn.sourceforge.net/openpcl/?rev=103&view=rev Author: documentsystems Date: 2007-07-06 13:27:56 -0700 (Fri, 06 Jul 2007) Log Message: ----------- Howard Hoagland. Implemented new feature "Shrink all Legal pages to fit on Letter" that scales Legal pages by 11/14 and selectes Letter paper intead of Legal paper. On the print setup dialog, if the user unchecks the "Use Windows Print" then the "Shrink all Legal pages to fit on Letter" is automatically unselected and grayed out, because shrink Legal pages to fit on Letter isn't available for print PCL Direct. Also, when the user puts a check in "Print All Documents on Legal Size", the "Shrink all Legal pages to fit on Letter" is automatically unchecked. And visa-versa if the user puts a check in "Shrink all Legal pages to fit on Letter" then "Print All Documents on Legal Size" is automatically unchecked. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-07-06 20:27:56 UTC (rev 103) @@ -33,20 +33,22 @@ private PosTreeNode mPrintThisTreeNode = null; private AffineTransform mOrigAffineTransform = null; private AffineTransform mScaleAffineTransform = null; + private AffineTransform mShrinkLegalToLetterAffineTransform = null; private ArrayList<PosTreeNode> mPagesToPrintArrayList = null; private PosPrintSetupDialogChoices mPosPrintSetupDialogChoices = null; private JProgressBar mPrintingProgressBar = null; private static final String sProgressBarBaseString = "Generating page: "; private static final String sCantAllocate = "Can't allocate memory for temporary image used for printing."; private double mPrintScale = 72.0d / 300.0d; // making width and height using 72 / 300 scale - private int mNumberOfPrintPasses = 1; - private int mCurrentPrintPassNumber = 1; + private double mShrinkLegalToLetterScale = mPrintScale * (11.0d / 14.0d); // shrink in both directions height 14" to 11" public PosPrintBufferedImage(PosView pPosView) { super(); mPosView = pPosView; mParentFrame = mPosView.getOpenPCLViewer().getAppFrame(); mScaleAffineTransform = AffineTransform.getScaleInstance(mPrintScale, mPrintScale); + mShrinkLegalToLetterAffineTransform = + AffineTransform.getScaleInstance(mShrinkLegalToLetterScale, mShrinkLegalToLetterScale); mBufferedImageToPrintOn = createNewBufferedImageToPrintOn(); // Graphics2D for printing (is 2 color black and white with no rendering hints like anti-aliasing if (mBufferedImageToPrintOn != null) { mGraphics2DToPrintOn = mBufferedImageToPrintOn.createGraphics(); } @@ -57,7 +59,7 @@ } public void setPosPrintSetupDialogChoices(PosPrintSetupDialogChoices pPosPrintSetupDialogChoices) { - mPosPrintSetupDialogChoices = pPosPrintSetupDialogChoices; + mPosPrintSetupDialogChoices = pPosPrintSetupDialogChoices; } public void setPrintingProgressBar(JProgressBar pPrintingProgressBar) { @@ -94,10 +96,17 @@ g2D.setPaint(Color.BLACK); // Save the passed in AffineTransform (to put it back before returning) mOrigAffineTransform = g2D.getTransform(); - // Set the 72/300 = .24 AffineTransform on the current Graphics2D, to scale smaller - // to fit exactly on the printed page - g2D.transform(mScaleAffineTransform); + if (mPosPrintSetupDialogChoices.shouldShrinkLegalToFitOnLetter() && + ( !(mPosView.getOpenPCLViewer().isTreeNodePageLetterSize(mPrintThisTreeNode)) )) { + // The user has a check in the "Shrink All Legal Pages to Fit On Letter" check box so shrink to Legal to fit on Letter + g2D.transform(mShrinkLegalToLetterAffineTransform); + + } else { + // Set the 72/300 = .24 AffineTransform on the current Graphics2D, to scale smaller to fit exactly on the printed page + g2D.transform(mScaleAffineTransform); + } + // Make the BufferedImage from the tree node. // The below uses polymorphism because the method renderImageForPrintingFromTreeNode() is one of the subclassed // methods specified in the interface IPluginHooksOpenPCL Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPageableInterface.java 2007-07-06 20:27:56 UTC (rev 103) @@ -57,12 +57,12 @@ // Letter size portrait with .2 inch margins mLetterPaperPortrait = new Paper(); mLetterPaperPortrait.setSize(8.5d * 72, 11.0d * 72); - mLetterPaperPortrait.setImageableArea(.2d * 72, .2d * 72, 8.1d * 72, 10.6d * 72); + mLetterPaperPortrait.setImageableArea(.18d * 72, .18d * 72, 8.14d * 72, 10.64d * 72); // Legal size portraint with .2 inch margins mLegalPaperPortrait = new Paper(); mLegalPaperPortrait.setSize(8.5d * 72, 14.0d * 72); - mLegalPaperPortrait.setImageableArea(.2d * 72, .2d * 72, 8.1d * 72, 13.6d * 72); + mLegalPaperPortrait.setImageableArea(.18d * 72, .18d * 72, 8.14d * 72, 13.64d * 72); } public int getNumberOfPages() { @@ -80,6 +80,12 @@ // The user has a check in the Print Setup dialog box for "Print all Documents on Legal size" // so FORCE ALL PAGES TO LEGAL SIZE no matter if LTR in the DSP values or no matter if this is a PCL file tBuiltPageFormat.setPaper(mLegalPaperPortrait); + + } else if (mPosPrintSetupDialogChoices != null && mPosPrintSetupDialogChoices.shouldShrinkLegalToFitOnLetter()) { + // The user has a check in the "Shrink All Legal Pages to Fit On Letter" check box + // so force all pages to Letter size + tBuiltPageFormat.setPaper(mLetterPaperPortrait); + } else { try { mPosTreeNode = mPagesToPrintArrayList.get(pForPageNumber); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintPages.java 2007-07-06 20:27:56 UTC (rev 103) @@ -255,13 +255,23 @@ StringBuffer tMsgStringBuffer = new StringBuffer(); tMsgStringBuffer.append(" to printer selected: "); tMsgStringBuffer.append(mPrintService.getName()); - tMsgStringBuffer.append("\n Additional Copies is " + mPosPrintSetupDialogChoices.getNumAdditionalCopies()); + + tMsgStringBuffer.append("\n Shrink All Legal Pages to Fit On Letter is "); + if (mPosPrintSetupDialogChoices.shouldShrinkLegalToFitOnLetter()) { + tMsgStringBuffer.append("\"True\""); + } else { + tMsgStringBuffer.append("\"False\""); + } + tMsgStringBuffer.append("\n Print all Documents on Legal Size is "); if (mPosPrintSetupDialogChoices.shouldPrintAllOnLegalSize()) { tMsgStringBuffer.append("\"True\""); } else { tMsgStringBuffer.append("\"False\""); } + + tMsgStringBuffer.append("\n Additional Copies is " + mPosPrintSetupDialogChoices.getNumAdditionalCopies()); + tMsgStringBuffer.append("\n " + mIndexNumbersStringBuffer); // Console output print type "Use Windows Print" or "Print PCL Direct" Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialog.java 2007-07-06 20:27:56 UTC (rev 103) @@ -147,6 +147,8 @@ // JCheckBoxes private JCheckBox mIsPclPrinterJCheckBox = new JCheckBox("Use Windows Print (recommended)"); + private JCheckBox mShrinkLegalToFitOnLetterJCheckBox = new JCheckBox( + "Shrink All Legal Pages to Fit On Letter"); private JCheckBox mPrintAllOnLegalSizeJCheckBox = new JCheckBox("Print All Documents on Legal Size"); // JLists @@ -204,14 +206,15 @@ // Lay out tab 1 items double tloTab1GridSpec[][] = new double[][] { { mTloFill, mTloHgap, mTloFill}, // columns - { mTloFill, mTloPref, mTloPref, mTloPref}}; // rows + { mTloFill, mTloPref, mTloPref, mTloPref, mTloPref}}; // rows TableLayout tloTab1Layout = new TableLayout(tloTab1GridSpec); mTab1.setLayout(tloTab1Layout); mTab1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mTab1.add(mListOfPrintersJPanel, "0, 0, 2, 0"); mTab1.add(mWindowsPrintOrPclPrintJPanel, "0, 1, 2, 1"); - mTab1.add(mPrintAllOnLegalSizeJCheckBox, "0, 2, 2, 2"); - mTab1.add(mAddlCopiesJPanel, "0, 3, 2, 3"); + mTab1.add(mShrinkLegalToFitOnLetterJCheckBox, "0, 2, 2, 2"); + mTab1.add(mPrintAllOnLegalSizeJCheckBox, "0, 3, 2, 3"); + mTab1.add(mAddlCopiesJPanel, "0, 4, 2, 4"); // mTab1.add(mPrintBarCodesJPanel, "0, 6"); // mTab1.add(mPrintOrderJPanel, "2, 6"); @@ -284,6 +287,33 @@ } }); + mIsPclPrinterJCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (mIsPclPrinterJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(true); + } else { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(false); + } + } + }); + + mShrinkLegalToFitOnLetterJCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (mShrinkLegalToFitOnLetterJCheckBox.isSelected()) { + mPrintAllOnLegalSizeJCheckBox.setSelected(false); + } + } + }); + + mPrintAllOnLegalSizeJCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (mPrintAllOnLegalSizeJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + } + } + }); + mFontSizeDinkyJButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mFontSizeDinkyJButton.setText("*D*"); @@ -388,6 +418,7 @@ putPrintChoicesOnScreen(); setHoverHelpOnItems(); grayOutItemsNotImplemented(); + grayOutShrinkToLetterOrForceLegalCheckBoxes(); // Make dialog box outer frame width and height exactly to be all item's preferred sizes pack(); } @@ -516,6 +547,23 @@ panel.add(tGridLayoutJPanel, "1, 0"); return panel; } + + private void grayOutShrinkToLetterOrForceLegalCheckBoxes() { + if (mIsPclPrinterJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(true); + } else { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + mShrinkLegalToFitOnLetterJCheckBox.setEnabled(false); + } + + if (mShrinkLegalToFitOnLetterJCheckBox.isSelected()) { + mPrintAllOnLegalSizeJCheckBox.setSelected(false); + } + + if (mPrintAllOnLegalSizeJCheckBox.isSelected()) { + mShrinkLegalToFitOnLetterJCheckBox.setSelected(false); + } + } private void putPrintChoicesOnScreen() { mAddlCopiesJTextField.setText(Integer.toString(mPrintChoices.getNumAdditionalCopies())); @@ -529,6 +577,7 @@ mPrintFormNamesNoJRadioButton.setSelected( !(mPrintChoices.shouldPrintFormNames()) ); mDuplexYesJRadioButton.setSelected(mPrintChoices.shouldDuplex()); mDuplexNoJRadioButton.setSelected( !(mPrintChoices.shouldDuplex()) ); + mShrinkLegalToFitOnLetterJCheckBox.setSelected(mPrintChoices.shouldShrinkLegalToFitOnLetter()); mPrintAllOnLegalSizeJCheckBox.setSelected(mPrintChoices.shouldPrintAllOnLegalSize()); } @@ -572,6 +621,9 @@ // Duplex mPrintChoices.setShouldDuplex(mDuplexYesJRadioButton.isSelected()); + // Shrink All Legal Pages to Fit On Letter + mPrintChoices.setShouldShrinkLegalToFitOnLetter(mShrinkLegalToFitOnLetterJCheckBox.isSelected()); + // Print all on legal size mPrintChoices.setShouldPrintAllOnLegalSize(mPrintAllOnLegalSizeJCheckBox.isSelected()); } @@ -579,6 +631,7 @@ private void makeArrayListOfDialogItems() { mItemsOnDialogBox.add(mListOfPrintersJList); mItemsOnDialogBox.add(mIsPclPrinterJCheckBox); + mItemsOnDialogBox.add(mShrinkLegalToFitOnLetterJCheckBox); mItemsOnDialogBox.add(mPrintAllOnLegalSizeJCheckBox); mItemsOnDialogBox.add(mAddlCopiesJLabel); mItemsOnDialogBox.add(mAddlCopiesJTextField); @@ -710,6 +763,8 @@ private void setHoverHelpOnItems() { mIsPclPrinterJCheckBox.setToolTipText(sPrinterModeHoverOverString); + mShrinkLegalToFitOnLetterJCheckBox.setToolTipText( + "Shrink Legal pages to Letter not available if \"Use Windows Print\" is unchecked"); mAddlCopiesJTextField.setToolTipText("Allowed values are 0 to 3 additional copies"); mPrintAllOnLegalSizeJCheckBox.setToolTipText("Make all pages print on Legal paper"); Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-07-04 01:46:40 UTC (rev 102) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintSetupDialogChoices.java 2007-07-06 20:27:56 UTC (rev 103) @@ -23,6 +23,7 @@ private int mPrintOrder = mPrintOrderAsDisplayedOrSelected; private boolean mShouldPrintFormNames = false; private boolean mShouldDuplex = false; + private boolean mShouldShrinkLegalToFitOnLetter = false; private boolean mShouldPrintAllOnLegalSize = false; private boolean mUserHitOk = false; @@ -62,6 +63,9 @@ public boolean shouldDuplex() { return mShouldDuplex; } + public boolean shouldShrinkLegalToFitOnLetter() { + return mShouldShrinkLegalToFitOnLetter; + } public boolean shouldPrintAllOnLegalSize() { return mShouldPrintAllOnLegalSize; } @@ -100,6 +104,9 @@ public void setShouldDuplex(boolean yesOrNo) { mShouldDuplex = yesOrNo; } + public void setShouldShrinkLegalToFitOnLetter(boolean yesOrNo) { + mShouldShrinkLegalToFitOnLetter = yesOrNo; + } public void setShouldPrintAllOnLegalSize(boolean yesOrNo) { mShouldPrintAllOnLegalSize = yesOrNo; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |