You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Mayank <ma...@gmail.com> on 2012/10/31 05:40:26 UTC

Need help for tranforming objects.

Hello All,

I am new to batik. I am able to read the SVG document and display it on
SVGCanvas. It worked fine.

Now, the origin of SVG document and Root element in set to (x=0,y=0). Then I
added a Rectangle element programmatically around the SVG components such
that it include all the SVG components. Now, at  (x=0,y=0) I have root, SVG
document and programmatically added rectangle. 

After this I moved rectangle and SVG components to let’s say
(x=400,y=400).So, now I am able to view the rectangle at desired position on
the canvas.

The rectangle and SVG components are away from origin of root. My question
how can i transform the rectangle such that it shows up in left top corner
of Canvas without shifting it to origin(0,0)?Root should be at (0,0) and
rectangle should be at (400,400) but rectangle renders at let top of canvas.

Which property should be used in this case?

Thanks.
 



--
View this message in context: http://batik.2283329.n4.nabble.com/Need-help-for-tranforming-objects-tp4655320.html
Sent from the Batik - Users mailing list archive at Nabble.com.

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


Re: Need help for tranforming objects.

Posted by Mayank <ma...@gmail.com>.
Thanks for reply. It worked for me.



--
View this message in context: http://batik.2283329.n4.nabble.com/Need-help-for-tranforming-objects-tp4655320p4655376.html
Sent from the Batik - Users mailing list archive at Nabble.com.

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


Re: Need help for tranforming objects.

Posted by DeWeese Thomas <th...@gmail.com>.
Hi Mayank,

    I believe this will do what you want:
	canvas.setRenderingTransform(AffineTranform.getTranslateInstance(h/2, l/2))

    Where h/2, l/2 is the value you show in your PNG (although I would call them width/2
and height/2 where width is width of yellow box and height is height of yellow box).

    If that doesn't do what you want please explain why.

    Good luck,
    Thomas

On Nov 5, 2012, at 12:39 AM, Mayank <ma...@gmail.com> wrote:

> <http://batik.2283329.n4.nabble.com/file/n4655340/Concept.bmp> 
> 
> I will explain what I am trying to achieve. Please refer attached image:
> 1)	Here, the blue box is the bound for the components present in the SVG
> document. The white rectangle is the print area or the area which user can
> update for printer page setup. The Yellow box is the programmatically
> calculated bounds which include union of Blue and white box. Now we have are
> which should be visible to user. Based on the Yellow rectangle  we calculate
> the green rectangle which is in gray area and its twice of the yellow
> rectangle.
> 2)	Then we move the components from (0,0) to calculated (x,y) position so
> that the yellow rectangle is in the center of green rectangle.
> 3)	The purpose of doing this shift is that user can move objects out of the
> yellow rectangle.
> 4)	Now the svg document in shifted to (x,y) position on the JSVGCanvas.Now I
> want to set the view port such that user only view the yellow rectangle on
> (x,y) but it should be present on the left top of canvas and user can move
> the objects in the green rectangle.
> 5)	Currently scroll is set on the canvas but somehow I need it to be set for
> the Yellow rectangle area only.
> 6)	Now, limitations I am facing using view box is that user will not be able
> to move objects freely out of the view box. I want to shift the yellow area
> to the left top with coordinates as (x,y) not (0,0).
> Please let me know in case you need further clarification.
> 
> 
> 
> 
> --
> View this message in context: http://batik.2283329.n4.nabble.com/Need-help-for-tranforming-objects-tp4655320p4655340.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: Need help for tranforming objects.

Posted by Mayank <ma...@gmail.com>.
<http://batik.2283329.n4.nabble.com/file/n4655340/Concept.bmp> 

I will explain what I am trying to achieve. Please refer attached image:
1)	Here, the blue box is the bound for the components present in the SVG
document. The white rectangle is the print area or the area which user can
update for printer page setup. The Yellow box is the programmatically
calculated bounds which include union of Blue and white box. Now we have are
which should be visible to user. Based on the Yellow rectangle  we calculate
the green rectangle which is in gray area and its twice of the yellow
rectangle.
2)	Then we move the components from (0,0) to calculated (x,y) position so
that the yellow rectangle is in the center of green rectangle.
3)	The purpose of doing this shift is that user can move objects out of the
yellow rectangle.
4)	Now the svg document in shifted to (x,y) position on the JSVGCanvas.Now I
want to set the view port such that user only view the yellow rectangle on
(x,y) but it should be present on the left top of canvas and user can move
the objects in the green rectangle.
5)	Currently scroll is set on the canvas but somehow I need it to be set for
the Yellow rectangle area only.
6)	Now, limitations I am facing using view box is that user will not be able
to move objects freely out of the view box. I want to shift the yellow area
to the left top with coordinates as (x,y) not (0,0).
Please let me know in case you need further clarification.




--
View this message in context: http://batik.2283329.n4.nabble.com/Need-help-for-tranforming-objects-tp4655320p4655340.html
Sent from the Batik - Users mailing list archive at Nabble.com.

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


Re: Need help for tranforming objects.

Posted by DeWeese Thomas <th...@gmail.com>.
Hi Mayank,

On Nov 1, 2012, at 12:35 AM, Mayank <ma...@gmail.com> wrote:

> How we can manipulate the viewing transform?

	I actually mis-spoke you probably want to manipulate the rendering transform.
You can adjust that by calling 'setRenderingTransform' on the JSVGCanvas.
I suspect you will find it useful to look at the AffineAction inner class in JSVGCanvas
as well as the subclasses of that, in particular ScrollAction.

> Also, I need more details on View Port and User Port. Can we override the
> canvas view port size?


	I don't know what you mean by User Port, but the view port (and viewBox attribute that I mentioned earlier) are described in the SVG specification.
	Once again I'm not sure what you mean by override the canvas view port size, can you clarify?

     What is not clear to me from your first note was if you wanted to construct an SVG document that had
400,400 at the upper left corner in which case you should use viewBox or if you just wanted to be able to
pan the document around under program control in the JSVGCanvas, in which case you should use the
rendering transform.  I think describing what you are really trying to do with context will be better than asking for explanations of features in Batik.

    Good luck

> 
> Thanks for reply Thomas.
> 
> 
> 
> --
> View this message in context: http://batik.2283329.n4.nabble.com/Need-help-for-tranforming-objects-tp4655320p4655327.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: Need help for tranforming objects.

Posted by Mayank <ma...@gmail.com>.
How we can manipulate the viewing transform?

Also, I need more details on View Port and User Port. Can we override the
canvas view port size?

Thanks for reply Thomas.



--
View this message in context: http://batik.2283329.n4.nabble.com/Need-help-for-tranforming-objects-tp4655320p4655327.html
Sent from the Batik - Users mailing list archive at Nabble.com.

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


Re: Need help for tranforming objects.

Posted by DeWeese Thomas <th...@gmail.com>.
Hi Mayank,
    The simple answer is the viewBox attribute, which allows you to set the rectangle of the infinite canvas that should fill to available JSVGCanvas.

    However I suspect that what may really want to do is simply translate the JSVGCanvas which can be done
by manipulating the viewing transform on the canvas.

    If you need more information on either of these just reply.

   Thomas

On Oct 31, 2012, at 12:40 AM, Mayank <ma...@gmail.com> wrote:

> Hello All,
> 
> I am new to batik. I am able to read the SVG document and display it on
> SVGCanvas. It worked fine.
> 
> Now, the origin of SVG document and Root element in set to (x=0,y=0). Then I
> added a Rectangle element programmatically around the SVG components such
> that it include all the SVG components. Now, at  (x=0,y=0) I have root, SVG
> document and programmatically added rectangle. 
> 
> After this I moved rectangle and SVG components to let’s say
> (x=400,y=400).So, now I am able to view the rectangle at desired position on
> the canvas.
> 
> The rectangle and SVG components are away from origin of root. My question
> how can i transform the rectangle such that it shows up in left top corner
> of Canvas without shifting it to origin(0,0)?Root should be at (0,0) and
> rectangle should be at (400,400) but rectangle renders at let top of canvas.
> 
> Which property should be used in this case?
> 
> Thanks.
> 
> 
> 
> 
> --
> View this message in context: http://batik.2283329.n4.nabble.com/Need-help-for-tranforming-objects-tp4655320.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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