/** * Create a collection of layer lists and their included layers described by an array of XML * layer-list description elements. * * <p>Any exceptions occurring during creation of the layer lists or their included layers are * logged and not re-thrown. The layers associated with the exceptions are not included in the * returned layer list. * * @param elements the XML elements describing the layer lists to create. * @param params any parameters to apply when creating the included layers. * @return an array containing the specified layer lists. */ protected LayerList[] createLayerLists(Element[] elements, AVList params) { ArrayList<LayerList> layerLists = new ArrayList<LayerList>(); for (Element element : elements) { try { String href = WWXML.getText(element, "@href"); if (href != null && href.length() > 0) { Object o = this.createFromConfigSource(href, params); if (o == null) continue; if (o instanceof Layer) { LayerList ll = new LayerList(); ll.add((Layer) o); o = ll; } if (o instanceof LayerList) { LayerList list = (LayerList) o; if (list != null && list.size() > 0) layerLists.add(list); } else if (o instanceof LayerList[]) { LayerList[] lists = (LayerList[]) o; if (lists != null && lists.length > 0) layerLists.addAll(Arrays.asList(lists)); } else { String msg = Logging.getMessage("LayerFactory.UnexpectedTypeForLayer", o.getClass().getName()); Logging.logger().log(java.util.logging.Level.WARNING, msg); } continue; } String title = WWXML.getText(element, "@title"); Element[] children = WWXML.getElements(element, "./Layer", null); if (children != null && children.length > 0) { LayerList list = this.createLayerList(children, params); if (list != null && list.size() > 0) { layerLists.add(list); if (title != null && title.length() > 0) list.setValue(AVKey.DISPLAY_NAME, title); } } } catch (Exception e) { Logging.logger().log(java.util.logging.Level.WARNING, e.getMessage(), e); // keep going to create other layers } } return layerLists.toArray(new LayerList[layerLists.size()]); }
public List<NavigationTile> navTilesVisible( DrawContext dc, double minDistSquared, double maxDistSquared) { ArrayList<NavigationTile> navList = new ArrayList<NavigationTile>(); if (this.isNavSectorVisible(dc, minDistSquared, maxDistSquared)) { if (this.level > 0 && !this.hasSubTiles()) this.buildSubNavTiles(); if (this.hasSubTiles()) { for (NavigationTile nav : subNavTiles) { navList.addAll(nav.navTilesVisible(dc, minDistSquared, maxDistSquared)); } } else // at bottom level navigation tile { navList.add(this); } } return navList; }
@Override protected void doRender(DrawContext dc) { this.referencePoint = this.computeReferencePoint(dc); int serviceCount = this.placeNameServiceSet.getServiceCount(); for (int i = 0; i < serviceCount; i++) { PlaceNameService placeNameService = this.placeNameServiceSet.getService(i); if (!isServiceVisible(dc, placeNameService)) continue; double minDistSquared = placeNameService.getMinDisplayDistance() * placeNameService.getMinDisplayDistance(); double maxDistSquared = placeNameService.getMaxDisplayDistance() * placeNameService.getMaxDisplayDistance(); if (isSectorVisible( dc, placeNameService.getMaskingSector(), minDistSquared, maxDistSquared)) { ArrayList<Tile> baseTiles = new ArrayList<Tile>(); NavigationTile navTile = this.navTiles.get(i); // drill down into tiles to find bottom level navTiles visible List<NavigationTile> list = navTile.navTilesVisible(dc, minDistSquared, maxDistSquared); for (NavigationTile nt : list) { baseTiles.addAll(nt.getTiles()); } for (Tile tile : baseTiles) { try { drawOrRequestTile(dc, tile, minDistSquared, maxDistSquared); } catch (Exception e) { Logging.logger() .log( Level.FINE, Logging.getMessage("layers.PlaceNameLayer.ExceptionRenderingTile"), e); } } } } this.sendRequests(); this.requestQ.clear(); }