/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6531728
* @summary Test printing of images which need to have src area clipped
*/
private ClippedImageCanvas c;
ClippedImages f = new ClippedImages();
f.setVisible(true);
}
public ClippedImages() {
super("Clipped Src Area Image Printing Test");
c = new ClippedImageCanvas();
add("Center", c);
paintButton.addActionListener(this);
printThisButton.addActionListener(this);
printAllButton.addActionListener(this);
p.add(paintButton);
p.add(printThisButton);
p.add(printAllButton);
add("South", p);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
}
});
pack();
}
("This is a manual test as it requires that you compare "+
"the on-screen rendering with the printed output.\n"+
"Select the 'Print All' button to print out the test\n"+
"It will generate 4 sides of content: as it will print "+
"each of 2 sets of transformed images in portrait, \n"+
"and landscape orientations. \n"+
"The sets of images are in turn made up\n"+
"of two similar sets of pages: one is 'random' images,\n "+
" the other is 16 squares.\n"+
"Use the 'Toggle Contents' button to view the screen rendering\n"+
"For each page compare the printed content to the same\n"+
"on-screen one taking careful note of\n"+
"b) that numerical text on the image is displayed similarly\n"+
"e) that the green quadrilaterals match on-screen\n"+
"f) that the rendering is clipped at the default (typically 1 inch) "+
"margins of the page.\n"+
"The test PASSES if the onscreen and printed rendering match");
return ta;
}
printOne();
printAll();
c.toggleContents();
c.repaint();
}
}
private void printOne() {
c.setPrinterJob(pj, false);
pj.setPrintable(c);
try {
} catch (PrinterException pe) {
throw new RuntimeException("Exception whilst printing.");
} finally {
}
}
}
private void printAll() {
c.setPrinterJob(pj, true);
pj.setPageable(c);
try {
} catch (PrinterException pe) {
throw new RuntimeException("Exception whilst printing.");
} finally {
}
}
}
}
int cnt = 0;
int x = 0;
while (x < sw) {
g2d.drawString(s, x, y);
x+= fm.stringWidth(s);
}
}
}
private boolean paintSquares = true;
void toggleContents() {
}
public int getNumberOfPages() {
if (pageable) {
return 4;
} else {
return 1;
}
}
boolean pageable = false;
this.myPrinterJob = job;
}
throws IndexOutOfBoundsException {
throw new IndexOutOfBoundsException();
}
switch (pageIndex % 2) {
case 0 :
break;
case 1:
break;
}
return pf;
}
return "Portrait Orientation, ";
} else {
return "Landscape Orientation,";
}
}
throws IndexOutOfBoundsException {
throw new IndexOutOfBoundsException();
}
if (pageIndex < 2) {
paintSquares = true;
} else {
paintSquares = false;
}
return this;
}
return Printable.NO_SUCH_PAGE;
}
return Printable.PAGE_EXISTS;
}
int r=5;
}
}
}
}
}
if (paintSquares) {
paintSquares(g);
} else {
paintRandom(g);
}
}
}
/* drawImage is required to handle mapping sx1,sy1 -> dx1,dy1 and
* sx2,sy2 -> dx2,dy2 which may imply flips and scales.
* To test this we need to test all combinations of these parameters
* with drawImage.
* If we have a source rectangle with vertices, sA, sB, sC, sD
* there are 4 combinations : sA+sD, sD+sA, sB+sC, sC+sB.
* Similarly for the destination with vertices, dA, dB, dC, dD
* there are 4 combinations : dA+dD, dD+dA, dB+dC, dC+dB.
* Thus we need 16 calls to test all combinations.
* Note that we set the source area coordinates (x and y -20->80)
* to be beyond the image size (50x50) so clipping is always needed.
*/
int incX = 100;
int incY = 100;
/* sA + sD -> dA + dD - the normal untransformed case */
/* sD + sA -> dA + dD */
/* sB + sC -> dA + dD */
/* sC + sB -> dA + dD */
/******/
/* sA + sD -> dD + dA */
/* sD + sA -> dD + dA */
/* sB + sC -> dD + dA */
/* sC + sB -> dD + dA */
/******/
/* sA + sD -> dB + dC */
/* sD + sA -> dB + dC */
/* sB + sC -> dB + dC */
/* sC + sB -> dB + dC */
/******/
/* sA + sD -> dC + dB */
/* sD + sA -> dC + dB */
/* sB + sC -> dC + dB */
/* sC + sB -> dC + dB */
}
/* Size is chosen to match default imageable width of a NA letter
* page. This means there will be clipping, what is clipped will
* depend on PageFormat orientation.
*/
}
}