Sorry, I forgot to attach the text files...

---------- Forwarded message ----------
From: Sunburned Surveyor <[EMAIL PROTECTED]>
Date: Dec 6, 2006 11:49 AM
Subject: Pluggable renderers for JUMP...
To: "List for discussion of JPP development and use."
<jump-pilot-devel@lists.sourceforge.net>
Cc: JUMP Developers <[EMAIL PROTECTED]>


I've done a little digging in the code and was able to track down the
changes made by Ole to allow "pluggable" renderers in OpenJUMP. He
basically changed to createRenderer() method of the RenderingMananger
class. It now looks up the appropriate Renderer to create for an
object based on its class name.

I have attached files showing the code for the createRenderer() method
in JUMP and OpenJUMP. I have also attached a text file with 2 new
methods added to the RenderingManager class by Ole to support this
functionality, the getRenderFactoryForLayerable() method and the
putRendererForLayerable() method.

I haven't gone over Ole's additions word by word, but I think I have a
pretty good understanding of what is going on here.

If Vivid Solutions is interested in supporting plugabble renderers I
can create a submission for the JUMP CVS for David or another Vivid
developer to review. I can even make some slight revisions to Ole's
code for Vivid's JUMP if some small changes need to be made.

The Sunburned Surveyor
        protected Renderer createRenderer(Object contentID) {
                if (contentID instanceof Layer) {
                        //[sstein] new
                        LayerRenderer lr = new LayerRenderer((Layer) contentID, 
this.panel);
                        lr.setMaxFeatures(this.maxFeatures); 
                        return  lr;
                        //[sstein] old
                        //return new LayerRenderer((Layer) contentID, panel);
                }
                if (contentID instanceof WMSLayer) {
                        return new WMSLayerRenderer((WMSLayer) contentID, 
panel);
                }
            //[sstein: 20.01.2006] Start: added by Ole
            
if(RenderingManager.getRenderFactoryForLayerable(contentID.getClass())!=null){
                  return 
RenderingManager.getRenderFactoryForLayerable(contentID.getClass()).create(contentID);
 }
        //End: added by Ole*
                if (contentIDToLowRendererFactoryMap.containsKey(contentID)) {
                        return ((Renderer.Factory) 
contentIDToLowRendererFactoryMap
                                        .get(contentID)).create();
                }
                if (contentIDToHighRendererFactoryMap.containsKey(contentID)) {
                        return ((Renderer.Factory) 
contentIDToHighRendererFactoryMap
                                        .get(contentID)).create();
                }
                Assert.shouldNeverReachHere(contentID.toString());
                return null;
        }

protected Renderer createRenderer(Object contentID) {
                if (contentID instanceof Layer) {
                        return new LayerRenderer((Layer) contentID, panel);
                }

                if (contentID instanceof WMSLayer) {
                        return new WMSLayerRenderer((WMSLayer) contentID, 
panel);
                }

                if (contentIDToLowRendererFactoryMap.containsKey(contentID)) {
                        return ((Renderer.Factory) 
contentIDToLowRendererFactoryMap
                                        .get(contentID)).create();
                }
                if (contentIDToHighRendererFactoryMap.containsKey(contentID)) {
                        return ((Renderer.Factory) 
contentIDToHighRendererFactoryMap
                                        .get(contentID)).create();
                }
                Assert.shouldNeverReachHere(contentID.toString());
                return null;
        }
        //[sstein: 20.01.2006]
        // Start: added by Ole
        // everything is static to make it useable before a LayerManager 
instance
        // (containing a RenderingManager) is created
        // which is the case, at the time the PlugIns are initialized and to 
have one map
        // for all RenderingManager
        public static Renderer.ContentDependendFactory 
getRenderFactoryForLayerable(Class clss){
            if (layerableClassToRendererFactoryMap.containsKey(clss)){
                return 
(Renderer.ContentDependendFactory)layerableClassToRendererFactoryMap.get(clss); 
                }
            return null;
          }
        
        public static void putRendererForLayerable(Class clss,
                                                                
Renderer.ContentDependendFactory rendererFactory) {
                if (!layerableClassToRendererFactoryMap.containsKey(clss)) {
                        layerableClassToRendererFactoryMap.put(clss, 
rendererFactory);
                }
        }
        // End: added by Ole*
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to