You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by Kevin Meyer <ke...@kmz.co.za> on 2013/02/20 20:52:52 UTC

Extending Locatable to generic 2D canvas?

Hi Dan (I guess you're the best to answer this),

I'm working from memory, so I might have the name of the interface wrong...

How much effort is required to extend the Locatable functionality to generic 2D image-based "maps"? I'm thinking of an application whereby I'd like to render items placed on something like a floor plan (the floor plan would basically be a bitmap image, possibly a vector image. Svg?).

Sticking to the floor plan concept, only certain items are actually on a given floor, so the extension would need a way to specify "on map Z @ location X,Y" (where Z is approximately equivalent to a single floor in a multilevel building). Then have the entities available as interactive Pojo's, just as if they were rendered in a list..

Last time I looked, your wicket "locatable" was backed by google maps?
-- 
Sent from my phone with K-9 Mail.
Please excuse my brevity.

Re: Extending Locatable to generic 2D canvas?

Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
> Nice!
> 
> Could some of this be made open source in github, say, 

Since there is nothing "special" about it, it can actually just be added 
to Isis, probably right into the Wicket viewer (apart from the 
"Locatable" interface... that would need a better home?).  

I suppose that is reason enough to release it seperately.

I can look into creating a github account.

>with some sort of
> API to abstract out the grabbing of the actual image to render?

Indeed. The next step is to support the use of existing images for the 
background. But that should be trivial to add (a simple 
implementation is just an extending the "Locatable" interface to 
include the filename, I guess).

Natural add-ons would be to render the POJO icon (from iconName) 
instead of a circle on the image... etc.

Regards,
Kevin

Re: Extending Locatable to generic 2D canvas?

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Nice!

Could some of this be made open source in github, say, with some sort of
API to abstract out the grabbing of the actual image to render?

Cheers,
Dan

Sorry to be brief, sent from my phone
On Feb 24, 2013 6:40 PM, "Kevin Meyer - KMZ" <ke...@kmz.co.za> wrote:

> Works like a charm! I now have a (generated) image with clickable
> markers that link to the domain object.
>
> A nice-to-have would be to somehow add "pop up" labels to the
> clickable URLs.. using the ExternalLink's "label" parameter does not
> seem to work.
>
> But this is enough for the moment.
>
> > > Given that I am am iterating through the collected adapters, how do I
> > > generate a link URL that can be used to load that entity?
> > >
> > >
> > I haven't had to do this myself (because I've integrated with
> > intermediaries that do this monkeying around already), however from
> > googling about [1] I think the following ought to work:
> >
> >
> >         final Class<? extends Page> pageClass =
> > getPageClassRegistry().getPageClass(PageType.ENTITY);
> >         final PageParameters pageParameters =
> > EntityModel.createPageParameters(adapter);
> >
> >         RequestCycle.get().urlFor(pageClass, parameters)
> >
> > Let me know...
> >
> > Dan
> >
> > [1]
> >
> http://stackoverflow.com/questions/9580071/wicket-1-5-and-obtaining-a-url-to-page-instance
> >
>
>
> --
> Kevin Meyer,      Cell: +386 (0)70 260 321   Ljubljana, Slovenia
>
>
>
>

Re: Extending Locatable to generic 2D canvas?

Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
Works like a charm! I now have a (generated) image with clickable 
markers that link to the domain object.

A nice-to-have would be to somehow add "pop up" labels to the 
clickable URLs.. using the ExternalLink's "label" parameter does not 
seem to work.

But this is enough for the moment.

> > Given that I am am iterating through the collected adapters, how do I
> > generate a link URL that can be used to load that entity?
> >
> >
> I haven't had to do this myself (because I've integrated with
> intermediaries that do this monkeying around already), however from
> googling about [1] I think the following ought to work:
> 
> 
>         final Class<? extends Page> pageClass =
> getPageClassRegistry().getPageClass(PageType.ENTITY);
>         final PageParameters pageParameters =
> EntityModel.createPageParameters(adapter);
> 
>         RequestCycle.get().urlFor(pageClass, parameters)
> 
> Let me know...
> 
> Dan
> 
> [1]
> http://stackoverflow.com/questions/9580071/wicket-1-5-and-obtaining-a-url-to-page-instance
> 


--
Kevin Meyer,      Cell: +386 (0)70 260 321   Ljubljana, Slovenia




Re: Extending Locatable to generic 2D canvas?

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 23 February 2013 21:36, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:

> Great news! :)
>
> I've been able to create a panel that can render a collection of entities
> that implemet my floor plan's locatable interface on a dynamic image
> with an an attached corresponding image map..
>
> Glad you're making progress on this.


> Given that I am am iterating through the collected adapters, how do I
> generate a link URL that can be used to load that entity?
>
>
I haven't had to do this myself (because I've integrated with
intermediaries that do this monkeying around already), however from
googling about [1] I think the following ought to work:


        final Class<? extends Page> pageClass =
getPageClassRegistry().getPageClass(PageType.ENTITY);
        final PageParameters pageParameters =
EntityModel.createPageParameters(adapter);

        RequestCycle.get().urlFor(pageClass, parameters)

Let me know...

Dan

[1]
http://stackoverflow.com/questions/9580071/wicket-1-5-and-obtaining-a-url-to-page-instance

Re: Extending Locatable to generic 2D canvas?

Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
Great news! :)

I've been able to create a panel that can render a collection of entities 
that implemet my floor plan's locatable interface on a dynamic image 
with an an attached corresponding image map..

The first implementation just draws a circle on the location, and the 
image map has a link definition at the same place (i.e. you can click 
on the circle).

viz:
 imageMap.addCircleArea(link, location.getX(), location.getY(), 10);

However! Here's the question:
Given that I am am iterating through the collected adapters, how do I 
generate a link URL that can be used to load that entity?

I'm basically looking for the body of this method:

AbstractLink clickableLinkFor(int i, ObjectAdapter adapter) {
 ...
}
where "i" is just used to increment the link ID, and might not be need.

Any suggestions? I tried looking into how regular Isis wicket 
components do it, and I got a bit lost (it's also late! Maybe I missed 
something obvious).

Thanks,
Kevin

Re: Extending Locatable to generic 2D canvas?

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
You should look at CDI [1], which takes this concept much, much further.


[1]
http://code.google.com/p/jee6-cdi/wiki/DependencyInjectionAnIntroductoryTutorial



On 22 February 2013 18:42, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:

>
> > > I just need to figure out how to add create a new Isis Wicket viewer
> > > panel.. Is it true that all I need to do is create a file in
> > > "META-INF/services" called:
> > > "org.apache.isis.viewer.wicket.ui.ComponentFactory"
> > > that lists the full class name of my
> > > "CollectionOfEntitiesAsLocatablesFactory" implementation?
> >
> >  yup, that's all you need to do.  It uses the little-used (but part of
> the
> > JDK) ServiceLoader API ... see ComponentFactoryRegistrarDefault
>
> It's bits of magic like this that make me go Wow!
>
>
>

Re: Extending Locatable to generic 2D canvas?

Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
> > I just need to figure out how to add create a new Isis Wicket viewer
> > panel.. Is it true that all I need to do is create a file in
> > "META-INF/services" called:
> > "org.apache.isis.viewer.wicket.ui.ComponentFactory"
> > that lists the full class name of my
> > "CollectionOfEntitiesAsLocatablesFactory" implementation?
> 
>  yup, that's all you need to do.  It uses the little-used (but part of the
> JDK) ServiceLoader API ... see ComponentFactoryRegistrarDefault

It's bits of magic like this that make me go Wow!



Re: Extending Locatable to generic 2D canvas?

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 21 February 2013 19:50, Kevin Meyer - KMZ <ke...@kmz.co.za> wrote:

> Hi Dan,
>


> I just need to figure out how to add create a new Isis Wicket viewer
> panel.. Is it true that all I need to do is create a file in
> "META-INF/services" called:
> "org.apache.isis.viewer.wicket.ui.ComponentFactory"
> that lists the full class name of my
> "CollectionOfEntitiesAsLocatablesFactory" implementation?
>
> yup, that's all you need to do.  It uses the little-used (but part of the
JDK) ServiceLoader API ... see ComponentFactoryRegistrarDefault


PS: There is a typo in your isis-wicket-gmap3 page, "... entities that
> have date properties  .." I'm sure should be "... have Locatable
> properties ..."
>

thanks, I'll fix.

Cheers


>
>
> On 20 Feb 2013 at 22:43, Dan Haywood wrote:
>
> > On 20 February 2013 19:52, Kevin Meyer wrote:
> >
> > > Sticking to the floor plan concept, only certain items are actually on
> a
> > > given floor, so the extension would need a way to specify "on map Z @
> > > location X,Y" (where Z is approximately equivalent to a single floor
> in a
> > > multilevel building). Then have the entities available as interactive
> > > Pojo's, just as if they were rendered in a list..
> > >
> >
> > In this case I think you ought to create your own equivalent of
> Locatable,
> > with that z axis.  You'll then want to have your own implementation of
> > "appliesTo" in the ComponentFactory for your component (again, see [1],
> > [2], [3]).  It's just a chain-of-responsibility pattern so all quite
> > straightforward.
> >
> > HTH
> > Dan
> >
> > [1] https://github.com/danhaywood/isis-wicket-gmap3
> > [2] https://github.com/danhaywood/isis-wicket-wickedcharts
> > [3] https://github.com/danhaywood/isis-wicket-fullcalendar
> >
>
>

Re: Extending Locatable to generic 2D canvas?

Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
Hi Dan,

Thanks for the head's up.. I can see that you've been leveraging prior 
development.. so I should look for an existing Wicket component that 
does something similar to what I already want, then extend it..

Looking around, I can't immediately see anything specifically related 
to "load an image and let me draw on it", but I think 
RenderedDynamicImageResource might work for me.. 

Based on the assumption that "all" I want to do initially is load a floor 
plan image and then draw on it, I can start by hooking into the 
"render" method. I think I'll start with "and draw on it" first..

I just need to figure out how to add create a new Isis Wicket viewer 
panel.. Is it true that all I need to do is create a file in 
"META-INF/services" called: 
"org.apache.isis.viewer.wicket.ui.ComponentFactory" 
that lists the full class name of my 
"CollectionOfEntitiesAsLocatablesFactory" implementation?

I'll have a go..

Thanks,
Kevin

PS: There is a typo in your isis-wicket-gmap3 page, "... entities that 
have date properties  .." I'm sure should be "... have Locatable 
properties ..."


On 20 Feb 2013 at 22:43, Dan Haywood wrote:

> On 20 February 2013 19:52, Kevin Meyer wrote:
>
> > Sticking to the floor plan concept, only certain items are actually on a
> > given floor, so the extension would need a way to specify "on map Z @
> > location X,Y" (where Z is approximately equivalent to a single floor in a
> > multilevel building). Then have the entities available as interactive
> > Pojo's, just as if they were rendered in a list..
> >
> 
> In this case I think you ought to create your own equivalent of Locatable,
> with that z axis.  You'll then want to have your own implementation of
> "appliesTo" in the ComponentFactory for your component (again, see [1],
> [2], [3]).  It's just a chain-of-responsibility pattern so all quite
> straightforward.
> 
> HTH
> Dan
> 
> [1] https://github.com/danhaywood/isis-wicket-gmap3
> [2] https://github.com/danhaywood/isis-wicket-wickedcharts
> [3] https://github.com/danhaywood/isis-wicket-fullcalendar
> 


Re: Extending Locatable to generic 2D canvas?

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 20 February 2013 19:52, Kevin Meyer <ke...@kmz.co.za> wrote:

> Hi Dan (I guess you're the best to answer this),
>
> I'm working from memory, so I might have the name of the interface wrong...
>
> How much effort is required to extend the Locatable functionality to
> generic 2D image-based "maps"? I'm thinking of an application whereby I'd
> like to render items placed on something like a floor plan (the floor plan
> would basically be a bitmap image, possibly a vector image. Svg?).
>

You could probably carry on using Locatable (it's just two doubles for
latitude and longitude).  The larger piece of work is in writing the Wicket
Component that will grab the appropriate images and render them.
 Obviously, the googlemaps "gmap3" API makes that easy to do.  Rendering on
top of floorplans sounds like it would require you to write a lot more
custom code.  Having said that, if you have a javascript library then it
(seems to be) pretty easy to make Wicket work with JS.

If you look at the github repos [1], [2], [3] you'll see what's involved in
writing a Wicket Component.  The component automatically registers with
Isis by virtue of a bit of metadata in META-INF.



> Sticking to the floor plan concept, only certain items are actually on a
> given floor, so the extension would need a way to specify "on map Z @
> location X,Y" (where Z is approximately equivalent to a single floor in a
> multilevel building). Then have the entities available as interactive
> Pojo's, just as if they were rendered in a list..
>

In this case I think you ought to create your own equivalent of Locatable,
with that z axis.  You'll then want to have your own implementation of
"appliesTo" in the ComponentFactory for your component (again, see [1],
[2], [3]).  It's just a chain-of-responsibility pattern so all quite
straightforward.

HTH
Dan

[1] https://github.com/danhaywood/isis-wicket-gmap3
[2] https://github.com/danhaywood/isis-wicket-wickedcharts
[3] https://github.com/danhaywood/isis-wicket-fullcalendar



> Last time I looked, your wicket "locatable" was backed by google maps?
> --
> Sent from my phone with K-9 Mail.
> Please excuse my brevity.
>