0or. All rights reserved.
NOT ORREMOVECOPYRIGHT NOTICES THIS HEADER
*
* This code is free softwarestatic String[] = {
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
*alongw notthe ,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please Twopage willappear ' both."java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
*.
*/
/** .rint(.1 *7.)/Size2DSyntax.; * @test * @bug 6360339 * @summary Test for fp error in paper size calculations. * @run main/manual PaperSizeError
*/
import java.awt.print System.out.println("Units = 1/72 Paper paper = new Paper(); import pf.setPaper(paper); import javax import// Test dialog with PF argument
publicreturn; // user cancelled the dialog (and hence the test).
static
aset.add( aset.add(MediaSizeName.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "Two java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 "If the test fails MediaSizeName msn = MediaSize.findMedia(fwMM, fhMM, Size2DSyntax System.out.println("Units = 1/72\" new size=" System.out.println("Units = MM new System.out.println("Media = " + if (a4w != Math.rint(dw1) || a4h != Math.rint(dh1)) { ""thrownew RuntimeException("Size is not close enough to }
};
publicstaticvoid main thrownew RuntimeException("MediaSizeName is not A4: " + msn }
for (int i=0;i<instructions.length;i++) {
System.out.println(instructions[i]);
}
/* First find out if we have a valid test environment: * ie print service exists and supports A4.
*/
PrinterJob job = PrinterJob.getPrinterJob();
PrintService service = job.getPrintService(); if (service == null ||
!service.isAttributeValueSupported(MediaSizeName.ISO_A4, null, null)) { return;
}
// Create A4 sized PageFormat.
MediaSize a4 = MediaSize.ISO.A4; double a4w = Math.rint((a4.getX(1) * 72.0) / Size2DSyntax.INCH); double a4h = Math.rint((a4.getY(1) * 72.0) / Size2DSyntax.INCH);
System.out.println("Units = 1/72\" size=" + a4w + "x" + a4h);
Paper paper = new Paper();
paper.setSize(a4w, a4h);
PageFormat pf = new PageFormat();
pf.setPaper(paper);
// Test dialog with PF argument
PageFormat newPF = job.pageDialog(pf); if (newPF == null) { return; // user cancelled the dialog (and hence the test).
} else {
verifyPaper(newPF, a4w, a4h);
}
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(OrientationRequested.PORTRAIT);
aset.add(MediaSizeName.ISO_A4);
// Test dialog with AttributeSet argument
newPF = job.pageDialog(aset); if (newPF == null) { return; // user cancelled the dialog (and hence the test).
} else {
verifyPaper(newPF, a4w, a4h);
}
}
double dw1 = pf.getWidth(); double dh1 = pf.getHeight(); float fwMM = (float)((dw1 * 25.4) / 72.0); float fhMM = (float)((dh1 * 25.4) / 72.0);
MediaSizeName msn = MediaSize.findMedia(fwMM, fhMM, Size2DSyntax.MM);
System.out.println("Units = 1/72\"new size=" + dw1 + "x" + dh1);
System.out.println("Units = MM new size=" + fwMM + "x" + fhMM);
System.out.println("Media = " + msn); if (a4w != Math.rint(dw1) || a4h != Math.rint(dh1)) {
System.out.println("Got " + Math.rint(dw1) + "x" + Math.rint(dh1) + ". Expected " + a4w + "x" + a4h); thrownew RuntimeException("Size is not close enough to A4 size");
} // So far as I know, there's no other standard size that is A4. // So we should match the right one. if (msn != MediaSizeName.ISO_A4) { thrownew RuntimeException("MediaSizeName is not A4: " + msn);
}
}
}
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.4Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.