xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sudhakar S <yessudha...@hotmail.com>
Subject Getting Selected Area for Print Preview
Date Fri, 01 Sep 2006 10:52:03 GMT

Hi All,

I am trying to give print preview for selected area using Rectangle element.
I can able show only the selected area when SVG Canvas is not Zoomed In.
also I can shrink the selected area within single page.

But this is not happening while Zoom In the SVG Canvas to larger size. It is
scaling the document to smaller size lesser than expected page size. So it
is showing the whole document.

Please see the code below, so that you can find the problem.

.
.
.
Element elt = ((SVGDocument)svgDoc).getRootElement();
AffineTransform usr2dev = ViewBox.getViewTransform(null, elt,
(int)rec.getWidth(), (int)rec.getHeight());

 if (fitPage) {

// width refers paper width
// height refers paper width

xscale = width/_selArea.getWidth() ;
yscale = height/_selArea.getHeight();

double scale = Math.min(xscale, yscale);
usr2dev.setToScale(scale, scale);

//After scaled the document, now I am getting the scaled selected area size

Rectangle r = usr2dev.createTransformedShape(_selArea).getBounds();
usr2dev.translate(-r.getX(), -r.getY());

return getImage(usr2dev,(int)r.getWidth(), (int)r.getHeight());

} else {

Dimension size = getPreferredSize();
xscale = width / (float)size.getWidth();
yscale = height / (float)size.getHeight();
double scale = Math.min(xscale, yscale);
usr2dev.setToScale(scale, scale);
}

Here "usr2dev.createTransformedShape(_selArea).getBounds()" returns proper
width or height of the zoomed out rectangle area.

So please anybody explain how to resolve this problem?


Thanks,
Sudhakar
-- 
View this message in context: http://www.nabble.com/Getting-Selected-Area-for-Print-Preview-tf2201896.html#a6096488
Sent from the Batik - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message