Announcement

Collapse
No announcement yet.

Loading WW layersets structure into WWJ

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading WW layersets structure into WWJ

    Here is another step toward a layer manager with a World Wind configuration loader that can read whole layersets structure from existing WW XML config files. Selection, deselection and reordering of layers is not done yet



    Not supported : single image layers, permanent local directory quadtilesets and remote configuration files. Still some issues with quadtilesets cache path and pathlists/terrain fightings though... all this is a work in progress
    My World Wind Java Blog & WW.net Plugins page

  • #2
    That's great!

    Comment


    • #3
      Hello dear patmurris,why your website http://patmurris.blogspot.com/2007/0...-into-wwj.html cannot be opened? I am very appreciated your achivement and want to learn from you. Would you please give me some suggestions to change the layers bar of the wwj?Thank you very much! My email is yangzhaozhao2008@163.com

      Comment


      • #4
        if you lived in china, maybe you cannot visit patmurris's blog.

        but you can visit through http://www.pkblogs.com/patmurris

        Comment


        • #5
          Not supported : single image layers, permanent local directory quadtilesets and remote configuration files. Still some issues with quadtilesets cache path and pathlists/terrain fightings though... all this is a work in progress
          Pat, how's this all going? I'm about to try and work it through myself from your WWXMLLayer, and add an PermanentDirectory to use with imageTileService or wmsAccessor...
          Machine. Unexpectedly, I’d invented a time
          - Alan Moore

          Comment


          • #6
            Originally posted by Chade View Post
            Pat, how's this all going? I'm about to try and work it through myself from your WWXMLLayer, and add an PermanentDirectory to use with imageTileService or wmsAccessor...
            I didnt do much on that matter since my first post - except for single image layers for which i made a SurfaceImage renderable object.

            I wish someone would post code for a checkbox driven layer manager using the above objects and structure.

            With the coming WWJ applet code, and with remote config file support, it would be rather easy to build a limited WW.net clone, using the same config files and layers... as a crossplateforme applet. That would be rather nice

            So much to do...
            My World Wind Java Blog & WW.net Plugins page

            Comment


            • #7
              Hi,
              I'm currently trying to write such a piece of code (checkbox layermanager), but i lack time and competence, so it may take quite long to get finished properly...

              Comment


              • #8
                jp09, if you're willing to post code, I'd be willing to assist...
                Machine. Unexpectedly, I’d invented a time
                - Alan Moore

                Comment


                • #9
                  OK. Right now, it's really a mess, i've got to make it a bit cleaner before i can post it.
                  Patmurris, have you updated WWConfigLoader to WWJ0.2.1 ? I saw new classes appeared for WMS support, in wwj0.2.1, but i'm not sure what to do with it...

                  Comment


                  • #10
                    No newer code for 0.2.1... the above one is for 0.2, so there may be some refactoring needed.
                    My World Wind Java Blog & WW.net Plugins page

                    Comment


                    • #11
                      So, about this check tree layer thing. He's some code you might want. Switch the for loop in Basic Demo or whatever you're using for this:
                      Code:
                                             for (NextImage.LayerAction action : layers) {
                                              	layerList.add(action.layer);
                                                  layerSet.add(action.layer);
                                              }
                                              JTree layerTree = new JTree(layerSet.makeCheckTreeNode());
                                              layerTree.setCellRenderer(new CheckRenderer());
                                              layerTree.getSelectionModel().setSelectionMode(
                                              		TreeSelectionModel.SINGLE_TREE_SELECTION);
                                              layerTree.putClientProperty("JTree.lineStyle", "Angled");
                                              layerTree.addMouseListener(new NodeSelectionListener(layerTree));
                                              layersPanel.add(layerTree);
                      You can also build up a LayerSet of LayerSets, this is also quite happy to convert into a bunch of CheckNodes, with the tree structure intact. You can also set the name of the LayerSet to whatever you want (handy, that)...
                      The code for the check boxes in trees I found here: http://www.codeguru.com/java/articles/185.shtml - if you want to get fancy, get the nasa icon from WW.NET and adjust line 55 in CheckRenderer to (or whatever location the icon is at):
                      Code:
                      label.setIcon(new ImageIcon("images/16x16-icon-nasa.png"));
                      I adjusted Pat Murris' LayerSet class:
                      Code:
                          
                          public CheckNode makeCheckTreeNode() {
                          	CheckNode root = new CheckNode(this);
                          	for (Object layer : this.getLayerList()) {
                          		if (layer instanceof LayerSet) {
                          			CheckNode node = new CheckNode(layer);
                          			node.setSelected(((LayerSet)layer).isEnabled());
                          			root.add(((LayerSet)layer).makeCheckTreeNode());;
                          		} else {
                          			CheckNode node = new CheckNode(layer);
                          			node.setSelected(((Layer)layer).isEnabled());
                          			root.add(node);
                          		}
                          	}
                          	return root;
                          }
                      Finally, in the NodeSelectionListener (and I don't really like this bit, but it'll do for now), add this line in the if statement:
                      Code:
                      			if (node.getUserObject() instanceof Layer)
                      				((Layer)node.getUserObject()).setEnabled(isSelected);
                      			else if (node.getUserObject() instanceof LayerSet)
                      				((LayerSet)node.getUserObject()).setEnabled(isSelected)
                      I do have to say, I'm a bit keen on being able to create layers from XML, so starting with Pat's code I added this to WWXMLLayer to have imagery from XML, and stored in the Cache. At line 118 I added:
                      Code:
                      permDirectory = findChildByName(child, "PermanentDirectory");
                      and at line 146:
                      Code:
                      else if (permDirectory != null) {
                                		n = permDirectory;
                                		service = "http://localhost";
                                		datasetName = n.getTextContent();
                      Last edited by Chade; 08-22-2007, 03:18 AM.
                      Machine. Unexpectedly, I’d invented a time
                      - Alan Moore

                      Comment


                      • #12
                        Loading XML files in a checktree

                        Hi Chade,
                        It looks like you've been quicker than i am !
                        I didn't forget your proposal, either : i've tried to make my code a bit cleaner, a bit more consequent (i had many things in it "just for trial"), and here it is !

                        I refactored a bit patmurris XML loading's stuff, i hope you'll not get angry, pat.
                        Maybe it is not really complete. I may have a look at your latest code additions, Chade, but it works quite well.
                        I have loading of QTS, icons, polygons and polylines. It gets stored in a JTree with checknodes.

                        I hope the structure will be self-explanatory. You've got a ready-to-start applet in ige.apps.BasicAppletWithUI.java

                        If you make some helpful improvement, thanks to share !

                        Jean
                        Attached Files

                        Comment


                        • #13
                          What version of the wwj sdk are you using? I've added it to both 0.2.1 and 0.2.0, and it fails to compile with both, as well as imports not pointing to correct locations...

                          Anyway. Have a look through the code I've posted, there's a couple of added features there that might be interesting - like custom icons for each layer:
                          Add an 'iconLocation' string to AbstractLayer and point it at the nasa 16*16 icon, and then at line 57 of CheckRenderer add
                          Code:
                          label.setIcon(new ImageIcon(((AbstractLayer)o).getIconLocation()));
                          When you extend AbstractLayer, set the property to whatever you want - you could parse it from xml just as easily.
                          I haven't played with polygons or polylines yet, I was distracted yesterday...
                          Machine. Unexpectedly, I’d invented a time
                          - Alan Moore

                          Comment


                          • #14
                            Hi Chade,
                            I adapted it for the last version, the wwj-20070817 unofficial release (see http://forum.worldwindcentral.com/sh...?t=9483&page=2 , there are quite a few changes...)
                            In order to have a custom organisation of the LayerSetItems and icons, my xmlloader loads each Icon in a separate IconLayer. It may not be really optimised for large sets of icons, but this way, each icon can be handled in a different way.
                            By the way, you'll have to change the path to the xml file, of course !
                            Tell me if it works

                            Comment


                            • #15
                              Umm, don't hardcode the path to a file. Put it in with the package and have it as a relative path.
                              Why have you extended JPanel twice? Did you use a visual builder to create the user interface? Also, while the layers turn off and on fine, and the USGS layers download, the Landsat ones don't.
                              A StatusBar would be a good idea, too, just to let the user know what's happening.
                              I did notice your tree nodes don't disappear when they get turned off - nice - I should add that to my code... someday... >.<
                              Last edited by Chade; 08-27-2007, 02:27 AM.
                              Machine. Unexpectedly, I’d invented a time
                              - Alan Moore

                              Comment

                              Working...
                              X