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 Stefán Freyr Stefánsson <st...@althingi.is> on 2003/08/05 12:37:10 UTC

Dynamic data representation with Batik

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.

I have a bit of a dilemma here and I'm hoping that someone on this list can
help me.

The problem that I'm facing is that I need to create an application that
displays the results of a vote. The vote is performed in a room that has a
fixed seating arrangement and the application will display a floor plan.  The
application will display the chairs in different colors depending on the vote
that was cast from that chair.  The voting system is a third party system
that we'll be able to poll and "ask" for the vote for a specific chair (each
chair has a unique integer ID) and we might even be able to later set up some
sort of an event mechanism that will allow the voting status to be pushed to
our application (but that's another story).

An SVG picture is being created for us where each chair will be a single SVG
element.  As I understand we should be able to add our own attributes to an
element such as the aforementioned ID of each chair. It could look something
like this:

<svg>
  <defs>
    <g id="chair"....
  </defs>

  <use xlink:href="#chair" x="10" y="10" althingi:chair-id="1"/>
  <use xlink:href="#chair" x="20" y="20" althingi:chair-id="2"/>
  ...
</svg>

So, what I'll have to do is create something that will poll the voting status
from the voting system and then in some way create a "layer" on top of the
floor plan image where the appearance of each "chair" is modified according
to the voting status on that chair ID.

We're using Java technology for this application and we've decided to use
Batik (unless anyone here objects?).  But the problem is that we really
haven't got much of an idea on what exactly we can do with it to get the
above behavior.

I've read a bit about Batik but it's a very complicated system and it seems to
be hard to just dive into.  Therefore I decided to send this email to the
list hoping that some kind-hearted genius out there could guide us in the
right direction.

So here are some questions/ideas that I would like to get your opinions on:

1) What would be the best way for us to obtain the previously mentioned
"layer" effect?  As I said the voting status would be displayed in a "layer"
that should be possible to "hide".  Other relevant information such as the
name of the person sitting in that chair, the party he/she is affiliated with
and so on would be examples of other "layers".
This might be an "SVG specific" question but I have a feeling that using a
"programmatical approach" would be better suited.  I've seen that the <g>
element is sometimes used to represent layers so I guess it should be
possible to add such an element to the document in some way but I would much
rather like to modify the image in memory than on file.  By that I mean that
Batik will read the floor plan from the SVG document that we have but that
should be the end of that.  The voting status and any other information
(persons name, party affiliation and so on) should be programmatically added
to the memory representation of the document.  I hope I'm making myself at
least vaguely understandable here.

2) My next question depends a bit on the answer of the first but that is how
it's best to manipulate data in SVG documents in Batik.  This would include
such things as coloring one of the chairs green to signify a "yes" vote.  I
could imagine a solution that would involve polling the voting status and
generating a whole new SVG document and re-rendering the whole floor plan in
the client would solve my problem but that would most definately be very slow
and unefficient.  So if it's possible to make each "layer" a seperate SVG
document or some sort a descriptor file that would be better than
re-generating the whole floor plan all the time.  But the image itself would
probably still have to be re-rendered which might not be very efficient. So
is there any way to update an SVG document in batik (for example to make one
of the "chairs" green) and only re-rendering the part of the image that was
modified to save processing?

In general I'd like to hear any and all comments on what you gurus out there
feel would be the best way to solve my problem.  If you know of anything
similar out there that I could use as a reference (by this I mean solutions
that use Batik... I know of the Adoby examples already) that would be most
appreciated as would any reference to reading material related to what I have
to do.

- -- 
Kind regards, Stefan

"XML is a giant step in no direction at all" (Erik Naggum)
"XML is a giant step in whichever direction you want it to be" (Andrew Hardie)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iQEVAwUBPy+I1r0ge6mq4AL2AQLHVgf7Bcu/uGmprSwCnGzvba5IB6os0vhssx8t
mcS9ym6/VSawiMKPrsyAgE9MbIeGojT0goFO+fQ8OlW/qdY146gUEA5iERiUBu+m
BPp9O9R8HSkd2x14h7IY7BKjiDLygToKcY+Cyg4HE1Zx+h7k+ZtRS4cffuf09j+j
tc1u7Jn+CUIZTRZiO94tM2lgKNsSdsLy8VIWnkGw3FEqnQY1DfcQ4fBgHY499M9j
xjeMukc64xBOkodfhJmWzW9Ihg/6jVc3I0El5GAufHS0svM5Nf7LibYjIVxKwcEh
Utt6AzJqTSVoP/yNHR9iy2hZLYhN2dlXfjAj3EWGwqik+qxO4Y4DwQ==
=rd3P
-----END PGP SIGNATURE-----


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


Re: dominant-baseline attribute

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Matthew,

Matthew L. Avizinis wrote:
> Hello all,
>   When rendering the following part of an fo document through FOP
> 0.20.5, dominant-baseline seems to have no effect.  When I copy the SVG
> portion to its own file and view it with the Adobe viewer it looks as
> expected; in the Batik 1.5 Squiggle viewer it, again, seems to have no
> effect.  The same is true if I use alignment-baseline instead of
> dominant-baseline.
[...]
> According to the Batik website at apache, both attributes are
> implemented, so am I missing something? or does the property work with
> only a particular text content element and not all text content elements?

     Unfortunately the website is wrong.  These attributes are not
currently implemented.  They are not trivial to implement
(given the complexities of SVG text dx/dy etc) and
as of right now I know of no plans to implement them.
Contributions are always welcome!  I could provide a sketch on how
they might be implemented, but it would be a fair amount of work
to come up to speed on how text is layed out in Batik.



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


dominant-baseline attribute

Posted by "Matthew L. Avizinis" <ml...@gleim.com>.
Hello all,
   When rendering the following part of an fo document through FOP
0.20.5, dominant-baseline seems to have no effect.  When I copy the SVG
portion to its own file and view it with the Adobe viewer it looks as
expected; in the Batik 1.5 Squiggle viewer it, again, seems to have no
effect.  The same is true if I use alignment-baseline instead of
dominant-baseline.

            <fo:block>
              <fo:instream-foreign-object>
                <svg xmlns="http://www.w3.org/2000/svg"
height="141.7323" width="283.4646">
                  <g style="fill:none; stroke:#FF0000">
                    <rect height="139.7323" width="281.4646 " y="1" x="1"/>
                  </g>
                  <text stroke="rgb(255,0,0)" font-style="italic"
font-size="12pt" font-family="Arial" y="70.86615" x="141.7323">a</text>
                  <text dominant-baseline="mathematical"
text-anchor="middle" stroke="rgb(0,0,255)" font-style="italic"
font-size="12pt" font-family="Arial" y="70.86615" x="141.7323">a test
                  </text>
                </svg>
              </fo:instream-foreign-object>
            </fo:block>

According to the Batik website at apache, both attributes are
implemented, so am I missing something? or does the property work with
only a particular text content element and not all text content elements?
thanks for help,
Matthew L. Avizinis



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


dominant-baseline attribute

Posted by "Matthew L. Avizinis" <ml...@gleim.com>.
Hello all,
   When rendering the following part of an fo document through FOP 
0.20.5, dominant-baseline seems to have no effect.  When I copy the SVG 
portion to its own file and view it with the Adobe viewer it looks as 
expected; in the Batik 1.5 Squiggle viewer it, again, seems to have no 
effect.  The same is true if I use alignment-baseline instead of 
dominant-baseline.

            <fo:block>
              <fo:instream-foreign-object>
                <svg xmlns="http://www.w3.org/2000/svg" 
height="141.7323" width="283.4646">
                  <g style="fill:none; stroke:#FF0000">
                    <rect height="139.7323" width="281.4646 " y="1" x="1"/>
                  </g>
                  <text stroke="rgb(255,0,0)" font-style="italic" 
font-size="12pt" font-family="Arial" y="70.86615" x="141.7323">a</text>
                  <text dominant-baseline="mathematical" 
text-anchor="middle" stroke="rgb(0,0,255)" font-style="italic" 
font-size="12pt" font-family="Arial" y="70.86615" x="141.7323">a test
                  </text>
                </svg>
              </fo:instream-foreign-object>
            </fo:block>

According to the Batik website at apache, both attributes are 
implemented, so am I missing something? or does the property work with 
only a particular text content element and not all text content elements?
thanks for help,
Matthew L. Avizinis


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


Re: Dynamic data representation with Batik

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi,

   I agree that SVG in general and Batik specifically should be
a good match for this application.  As for doing layers
I think 'g' elements is a pretty good match.  You might
consider using the CSS class attribute to control the
presentation of 'fixed' elements based on state.

    See unlike say the persons name/party the color is
a feature of the seating 'layer' - so it may make more sense
to set the class to 'yea', 'nea', and an appropriate CSS style
sheet. You could also have a layer that just copies the
seat with a new color (so you would have two copies of the
seat graphic in the document one 'unvoted' one 'voted' on top
of each other).

    With Batik if you tell the canvas that the document is dynamic
it will automatically update the display as the XML document is
changed - so no need to reread the document or anything. The screen
update is also optimized so only the changed areas are rerendered.


G. Wade Johnson wrote:
> Building layers using either the <g/> or <svg/> tags is fairly easy. The
> two handle positioning differently so you'll want to experiment with
> them a bit to decide which works best for you.
> 
> I've built a system that dynamically updates elements on a display and
> uses layers which may be hidden. In my case, the "effects" that are
> applied to elements are not on separate layers, but other than that
> the ideas are similar.
> 
> You can programmatically change attributes of elements on the screen to
> change their color. I currently change the "fill" and "stroke"
> attributes but you can change the "style" attribute if you prefer.
> 
> I've changed attributes on dozens to hundreds of elements at one time,
> and the redraw was almost instaneous. (Tested on both 350MHz machine
> and 2.4GHz machine.) It is obviously possible to generate SVG documents
> that take much longer to update.
> 
> In general, I guess I'm saying that what you are asking for is quite
> possible using Batik. Whether or not it works in your case depends
> on specifics that you will need to evaluate.
> 
> G. Wade
> 
> Stefán Freyr Stefánsson wrote:
> 
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: SHA1
>>
>>Hello.
>>
>>I have a bit of a dilemma here and I'm hoping that someone on this list can
>>help me.
>>
>>The problem that I'm facing is that I need to create an application that
>>displays the results of a vote. The vote is performed in a room that has a
>>fixed seating arrangement and the application will display a floor plan.  The
>>application will display the chairs in different colors depending on the vote
>>that was cast from that chair.  The voting system is a third party system
>>that we'll be able to poll and "ask" for the vote for a specific chair (each
>>chair has a unique integer ID) and we might even be able to later set up some
>>sort of an event mechanism that will allow the voting status to be pushed to
>>our application (but that's another story).
>>
>>An SVG picture is being created for us where each chair will be a single SVG
>>element.  As I understand we should be able to add our own attributes to an
>>element such as the aforementioned ID of each chair. It could look something
>>like this:
>>
>><svg>
>>  <defs>
>>    <g id="chair"....
>>  </defs>
>>
>>  <use xlink:href="#chair" x="10" y="10" althingi:chair-id="1"/>
>>  <use xlink:href="#chair" x="20" y="20" althingi:chair-id="2"/>
>>  ...
>></svg>
>>
>>So, what I'll have to do is create something that will poll the voting status
>>from the voting system and then in some way create a "layer" on top of the
>>floor plan image where the appearance of each "chair" is modified according
>>to the voting status on that chair ID.
>>
>>We're using Java technology for this application and we've decided to use
>>Batik (unless anyone here objects?).  But the problem is that we really
>>haven't got much of an idea on what exactly we can do with it to get the
>>above behavior.
>>
>>I've read a bit about Batik but it's a very complicated system and it seems to
>>be hard to just dive into.  Therefore I decided to send this email to the
>>list hoping that some kind-hearted genius out there could guide us in the
>>right direction.
>>
>>So here are some questions/ideas that I would like to get your opinions on:
>>
>>1) What would be the best way for us to obtain the previously mentioned
>>"layer" effect?  As I said the voting status would be displayed in a "layer"
>>that should be possible to "hide".  Other relevant information such as the
>>name of the person sitting in that chair, the party he/she is affiliated with
>>and so on would be examples of other "layers".
>>This might be an "SVG specific" question but I have a feeling that using a
>>"programmatical approach" would be better suited.  I've seen that the <g>
>>element is sometimes used to represent layers so I guess it should be
>>possible to add such an element to the document in some way but I would much
>>rather like to modify the image in memory than on file.  By that I mean that
>>Batik will read the floor plan from the SVG document that we have but that
>>should be the end of that.  The voting status and any other information
>>(persons name, party affiliation and so on) should be programmatically added
>>to the memory representation of the document.  I hope I'm making myself at
>>least vaguely understandable here.
>>
>>2) My next question depends a bit on the answer of the first but that is how
>>it's best to manipulate data in SVG documents in Batik.  This would include
>>such things as coloring one of the chairs green to signify a "yes" vote.  I
>>could imagine a solution that would involve polling the voting status and
>>generating a whole new SVG document and re-rendering the whole floor plan in
>>the client would solve my problem but that would most definately be very slow
>>and unefficient.  So if it's possible to make each "layer" a seperate SVG
>>document or some sort a descriptor file that would be better than
>>re-generating the whole floor plan all the time.  But the image itself would
>>probably still have to be re-rendered which might not be very efficient. So
>>is there any way to update an SVG document in batik (for example to make one
>>of the "chairs" green) and only re-rendering the part of the image that was
>>modified to save processing?
>>
>>In general I'd like to hear any and all comments on what you gurus out there
>>feel would be the best way to solve my problem.  If you know of anything
>>similar out there that I could use as a reference (by this I mean solutions
>>that use Batik... I know of the Adoby examples already) that would be most
>>appreciated as would any reference to reading material related to what I have
>>to do.
>>
>>- --
>>Kind regards, Stefan
>>
>>"XML is a giant step in no direction at all" (Erik Naggum)
>>"XML is a giant step in whichever direction you want it to be" (Andrew Hardie)
>>-----BEGIN PGP SIGNATURE-----
>>Version: GnuPG v1.2.2 (GNU/Linux)
>>
>>iQEVAwUBPy+I1r0ge6mq4AL2AQLHVgf7Bcu/uGmprSwCnGzvba5IB6os0vhssx8t
>>mcS9ym6/VSawiMKPrsyAgE9MbIeGojT0goFO+fQ8OlW/qdY146gUEA5iERiUBu+m
>>BPp9O9R8HSkd2x14h7IY7BKjiDLygToKcY+Cyg4HE1Zx+h7k+ZtRS4cffuf09j+j
>>tc1u7Jn+CUIZTRZiO94tM2lgKNsSdsLy8VIWnkGw3FEqnQY1DfcQ4fBgHY499M9j
>>xjeMukc64xBOkodfhJmWzW9Ihg/6jVc3I0El5GAufHS0svM5Nf7LibYjIVxKwcEh
>>Utt6AzJqTSVoP/yNHR9iy2hZLYhN2dlXfjAj3EWGwqik+qxO4Y4DwQ==
>>=rd3P
>>-----END PGP SIGNATURE-----
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 




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


Re: Dynamic data representation with Batik

Posted by "G. Wade Johnson" <wa...@abbnm.com>.
Building layers using either the <g/> or <svg/> tags is fairly easy. The
two handle positioning differently so you'll want to experiment with
them a bit to decide which works best for you.

I've built a system that dynamically updates elements on a display and
uses layers which may be hidden. In my case, the "effects" that are
applied to elements are not on separate layers, but other than that
the ideas are similar.

You can programmatically change attributes of elements on the screen to
change their color. I currently change the "fill" and "stroke"
attributes but you can change the "style" attribute if you prefer.

I've changed attributes on dozens to hundreds of elements at one time,
and the redraw was almost instaneous. (Tested on both 350MHz machine
and 2.4GHz machine.) It is obviously possible to generate SVG documents
that take much longer to update.

In general, I guess I'm saying that what you are asking for is quite
possible using Batik. Whether or not it works in your case depends
on specifics that you will need to evaluate.

G. Wade

Stefán Freyr Stefánsson wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello.
> 
> I have a bit of a dilemma here and I'm hoping that someone on this list can
> help me.
> 
> The problem that I'm facing is that I need to create an application that
> displays the results of a vote. The vote is performed in a room that has a
> fixed seating arrangement and the application will display a floor plan.  The
> application will display the chairs in different colors depending on the vote
> that was cast from that chair.  The voting system is a third party system
> that we'll be able to poll and "ask" for the vote for a specific chair (each
> chair has a unique integer ID) and we might even be able to later set up some
> sort of an event mechanism that will allow the voting status to be pushed to
> our application (but that's another story).
> 
> An SVG picture is being created for us where each chair will be a single SVG
> element.  As I understand we should be able to add our own attributes to an
> element such as the aforementioned ID of each chair. It could look something
> like this:
> 
> <svg>
>   <defs>
>     <g id="chair"....
>   </defs>
> 
>   <use xlink:href="#chair" x="10" y="10" althingi:chair-id="1"/>
>   <use xlink:href="#chair" x="20" y="20" althingi:chair-id="2"/>
>   ...
> </svg>
> 
> So, what I'll have to do is create something that will poll the voting status
> from the voting system and then in some way create a "layer" on top of the
> floor plan image where the appearance of each "chair" is modified according
> to the voting status on that chair ID.
> 
> We're using Java technology for this application and we've decided to use
> Batik (unless anyone here objects?).  But the problem is that we really
> haven't got much of an idea on what exactly we can do with it to get the
> above behavior.
> 
> I've read a bit about Batik but it's a very complicated system and it seems to
> be hard to just dive into.  Therefore I decided to send this email to the
> list hoping that some kind-hearted genius out there could guide us in the
> right direction.
> 
> So here are some questions/ideas that I would like to get your opinions on:
> 
> 1) What would be the best way for us to obtain the previously mentioned
> "layer" effect?  As I said the voting status would be displayed in a "layer"
> that should be possible to "hide".  Other relevant information such as the
> name of the person sitting in that chair, the party he/she is affiliated with
> and so on would be examples of other "layers".
> This might be an "SVG specific" question but I have a feeling that using a
> "programmatical approach" would be better suited.  I've seen that the <g>
> element is sometimes used to represent layers so I guess it should be
> possible to add such an element to the document in some way but I would much
> rather like to modify the image in memory than on file.  By that I mean that
> Batik will read the floor plan from the SVG document that we have but that
> should be the end of that.  The voting status and any other information
> (persons name, party affiliation and so on) should be programmatically added
> to the memory representation of the document.  I hope I'm making myself at
> least vaguely understandable here.
> 
> 2) My next question depends a bit on the answer of the first but that is how
> it's best to manipulate data in SVG documents in Batik.  This would include
> such things as coloring one of the chairs green to signify a "yes" vote.  I
> could imagine a solution that would involve polling the voting status and
> generating a whole new SVG document and re-rendering the whole floor plan in
> the client would solve my problem but that would most definately be very slow
> and unefficient.  So if it's possible to make each "layer" a seperate SVG
> document or some sort a descriptor file that would be better than
> re-generating the whole floor plan all the time.  But the image itself would
> probably still have to be re-rendered which might not be very efficient. So
> is there any way to update an SVG document in batik (for example to make one
> of the "chairs" green) and only re-rendering the part of the image that was
> modified to save processing?
> 
> In general I'd like to hear any and all comments on what you gurus out there
> feel would be the best way to solve my problem.  If you know of anything
> similar out there that I could use as a reference (by this I mean solutions
> that use Batik... I know of the Adoby examples already) that would be most
> appreciated as would any reference to reading material related to what I have
> to do.
> 
> - --
> Kind regards, Stefan
> 
> "XML is a giant step in no direction at all" (Erik Naggum)
> "XML is a giant step in whichever direction you want it to be" (Andrew Hardie)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.2 (GNU/Linux)
> 
> iQEVAwUBPy+I1r0ge6mq4AL2AQLHVgf7Bcu/uGmprSwCnGzvba5IB6os0vhssx8t
> mcS9ym6/VSawiMKPrsyAgE9MbIeGojT0goFO+fQ8OlW/qdY146gUEA5iERiUBu+m
> BPp9O9R8HSkd2x14h7IY7BKjiDLygToKcY+Cyg4HE1Zx+h7k+ZtRS4cffuf09j+j
> tc1u7Jn+CUIZTRZiO94tM2lgKNsSdsLy8VIWnkGw3FEqnQY1DfcQ4fBgHY499M9j
> xjeMukc64xBOkodfhJmWzW9Ihg/6jVc3I0El5GAufHS0svM5Nf7LibYjIVxKwcEh
> Utt6AzJqTSVoP/yNHR9iy2hZLYhN2dlXfjAj3EWGwqik+qxO4Y4DwQ==
> =rd3P
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

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