Finn Bock wrote:

> > The solution that I am leaning toward is to have
> > you subclass AddLMVisitor instead. If we then give you a set accessor in
> > LayoutManagerLS to set the subclass, and we use what is stored
> there, do you
> > have a place in your code where you can conveniently use that
> accessor to
> > set a subclass instead of AddLMVisitor?
> I think that would work for me just as well assuming the accessor is
> somehow available from the Driver instance.

Right now, the Layout Strategy gets set at line 584 in Driver. I will
instantiate it with a null value for the Visitor object that it will use,
then create a regular one before using it if I find the null value. So you
just need to set the value to the subclassed object between those two points
in time.

> The acceptVisitor method in my TextField extension would then look like
> this:
>      public void acceptVisitor(FOTreeVisitor fotv) {
>          ((MyLMVisitor) fotv).serveVisitor(this);
>      }
> and I must add a serveVisitor method to MyLMVisitor
>      public void serveVisitor(TextField node) {
>          ...
>      }
> That is quite elegant (except for the cast in acceptVisitor).

I would like to get rid of the cast as well, as my goal is to maintain the
FOTree as an independent module (especially that it doesn't need any
information about layout). Assuming that "this" is a (direct or indirect)
subclass of FONode, I think the cast should be unnecessary, but I'll test it
on this end to make sure first.

After looking at the code for a bit, I need to stop and tie some of the
pieces of the LM Tree together a bit better. Right now I am creating an
AddLMVisitor for each iterator, which is not what I want. It will take me a
while to get that pushed up to LayoutManagerLS and to tie the LM Tree to
that. I'll post back after I get it done, hopefully before the weekend is

> I'm not sure how a AddLMVisitor subclass would work if two different
> extensions are used in the same document, but that is not an issue in my
> use.

AFAIK, it should just be a matter of setting up a method in the subclass for
each of the extensions. But maybe I am misunderstanding your question.

Victor Mote

Reply via email to