@Test public void testCreateFromXMLSampleSource() throws Exception { URL sampleFileUrl = getClass().getResource("sampleThemeFile.xml"); URL context = sampleFileUrl; Object source = sampleFileUrl; Theme result = ThemeFactory.createFromXML(source, context); assertNotNull(result); assertEquals("Sample theme", result.getName()); assertEquals("layers.sample.xml", result.getLayerPersistanceFilename()); assertEquals(true, result.isPersistLayers()); assertEquals("places.sample.xml", result.getPlacesPersistanceFilename()); assertEquals(false, result.isPersistPlaces()); assertEquals(true, result.isPlacesPersistanceFilenameSet()); assertEquals(new URL(sampleFileUrl, "./places.xml"), result.getPlacesInitialisationPath()); assertEquals(true, result.hasMenuBar()); assertEquals(false, result.hasToolBar()); assertEquals(true, result.hasStatusBar()); assertEquals(false, result.hasWms()); assertEquals(-12, result.getInitialLatitude(), DELTA); assertEquals(123.4, result.getInitialLongitude(), DELTA); assertEquals(null, result.getFieldOfView()); assertEquals(null, result.getInitialAltitude()); assertEquals(null, result.getInitialHeading()); assertEquals(1, result.getCacheLocations().size()); assertEquals("Cache", result.getCacheLocations().get(0)); assertEquals(6, result.getHUDs().size()); assertThemeHudCorrect(result.getHUDs().get(0), WorldMapHUD.class, "World Map", AVKey.NORTHWEST, false); assertThemeHudCorrect(result.getHUDs().get(1), CompassHUD.class, "Compass", AVKey.NORTHEAST, false); assertThemeHudCorrect(result.getHUDs().get(2), ScalebarHUD.class, "Scalebar", AVKey.SOUTHEAST, false); assertThemeHudCorrect(result.getHUDs().get(3), ControlsHUD.class, "Navigation Controls", AVKey.SOUTHWEST, false); assertThemeHudCorrect(result.getHUDs().get(4), GraticuleHUD.class, "Graticule", null, false); assertThemeHudCorrect(result.getHUDs().get(5), CrosshairHUD.class, "Crosshair", null, false); assertEquals(1, result.getDatasets().size()); assertEquals("Datasets", result.getDatasets().get(0).getName()); assertEquals(5, result.getPanels().size()); assertPanelCorrect(result.getPanels().get(0), GeoNamesSearchPanel.class, "Search", false); assertPanelCorrect(result.getPanels().get(1), PlacesPanel.class, "Places", false); assertPanelCorrect(result.getPanels().get(2), LayersPanel.class, "Layers", true); assertPanelCorrect(result.getPanels().get(3), DatasetPanel.class, "Datasets", true); assertPanelCorrect(result.getPanels().get(4), ExaggerationPanel.class, "Vertical Exaggeration", false); assertTrue(result.hasLayersPanel()); assertFalse(result.hasThemeLayersPanel()); assertNotNull(result.getLayersPanel()); assertEquals(1, result.getLayers().size()); assertLayerCorrect(result.getLayers().get(0), "Sample Layer", "http: }
public static Theme createFromXML(Object source, URL context) { Element element = XMLUtil.getElementFromSource(source); if (element == null) { return null; } BasicTheme theme = new BasicTheme(XMLUtil.getText(element, "ThemeName")); theme.setMenuBar(XMLUtil.getBoolean(element, "MenuBar", false)); theme.setToolBar(XMLUtil.getBoolean(element, "ToolBar", false)); theme.setStatusBar(XMLUtil.getBoolean(element, "StatusBar", false)); theme.setSideBar(XMLUtil.getBoolean(element, "SideBar", true)); theme.setFullscreen(XMLUtil.getBoolean(element, "Fullscreen", false)); theme.setHasWms(XMLUtil.getBoolean(element, "WmsBrowser", true)); theme.setPersistLayers(XMLUtil.getBoolean(element, "PersistLayers", true)); theme.setLayerPersistanceFilename(XMLUtil.getText(element, "LayersFilename")); theme.setCacheLocations(parseCacheLocations(element, "CacheLocation")); theme.setPersistPlaces(XMLUtil.getBoolean(element, "PersistPlaces", true)); theme.setPlacesPersistanceFilename(XMLUtil.getText(element, "PlacesFilename")); try { theme.setPlacesInitialisationPath(XMLUtil.getURL(element, "InitialPlaces", context)); } catch (MalformedURLException e) { } theme.setHUDs(parseHUDs(element, "HUD")); theme.setPanels(parsePanels(element, "Panel")); theme.setDatasets(parseDatasets(element, "Dataset", context)); theme.setLayers(parseLayers(element, "Layer", context)); theme.setInitialLatitude(XMLUtil.getDouble(element, "InitialLatitude", null)); theme.setInitialLongitude(XMLUtil.getDouble(element, "InitialLongitude", null)); theme.setInitialAltitude(XMLUtil.getDouble(element, "InitialAltitude", null)); theme.setInitialHeading(XMLUtil.getDouble(element, "InitialHeading", null)); theme.setInitialPitch(XMLUtil.getDouble(element, "InitialPitch", null)); theme.setVerticalExaggeration(XMLUtil.getDouble(element, "VerticalExaggeration", null)); theme.setFieldOfView(XMLUtil.getDouble(element, "FieldOfView", null)); return theme; }
ThemeFactory { public static Theme createFromXML(Object source, URL context) { Element element = XMLUtil.getElementFromSource(source); if (element == null) { return null; } BasicTheme theme = new BasicTheme(XMLUtil.getText(element, "ThemeName")); theme.setMenuBar(XMLUtil.getBoolean(element, "MenuBar", false)); theme.setToolBar(XMLUtil.getBoolean(element, "ToolBar", false)); theme.setStatusBar(XMLUtil.getBoolean(element, "StatusBar", false)); theme.setSideBar(XMLUtil.getBoolean(element, "SideBar", true)); theme.setFullscreen(XMLUtil.getBoolean(element, "Fullscreen", false)); theme.setHasWms(XMLUtil.getBoolean(element, "WmsBrowser", true)); theme.setPersistLayers(XMLUtil.getBoolean(element, "PersistLayers", true)); theme.setLayerPersistanceFilename(XMLUtil.getText(element, "LayersFilename")); theme.setCacheLocations(parseCacheLocations(element, "CacheLocation")); theme.setPersistPlaces(XMLUtil.getBoolean(element, "PersistPlaces", true)); theme.setPlacesPersistanceFilename(XMLUtil.getText(element, "PlacesFilename")); try { theme.setPlacesInitialisationPath(XMLUtil.getURL(element, "InitialPlaces", context)); } catch (MalformedURLException e) { } theme.setHUDs(parseHUDs(element, "HUD")); theme.setPanels(parsePanels(element, "Panel")); theme.setDatasets(parseDatasets(element, "Dataset", context)); theme.setLayers(parseLayers(element, "Layer", context)); theme.setInitialLatitude(XMLUtil.getDouble(element, "InitialLatitude", null)); theme.setInitialLongitude(XMLUtil.getDouble(element, "InitialLongitude", null)); theme.setInitialAltitude(XMLUtil.getDouble(element, "InitialAltitude", null)); theme.setInitialHeading(XMLUtil.getDouble(element, "InitialHeading", null)); theme.setInitialPitch(XMLUtil.getDouble(element, "InitialPitch", null)); theme.setVerticalExaggeration(XMLUtil.getDouble(element, "VerticalExaggeration", null)); theme.setFieldOfView(XMLUtil.getDouble(element, "FieldOfView", null)); return theme; } }
ThemeFactory { public static Theme createFromXML(Object source, URL context) { Element element = XMLUtil.getElementFromSource(source); if (element == null) { return null; } BasicTheme theme = new BasicTheme(XMLUtil.getText(element, "ThemeName")); theme.setMenuBar(XMLUtil.getBoolean(element, "MenuBar", false)); theme.setToolBar(XMLUtil.getBoolean(element, "ToolBar", false)); theme.setStatusBar(XMLUtil.getBoolean(element, "StatusBar", false)); theme.setSideBar(XMLUtil.getBoolean(element, "SideBar", true)); theme.setFullscreen(XMLUtil.getBoolean(element, "Fullscreen", false)); theme.setHasWms(XMLUtil.getBoolean(element, "WmsBrowser", true)); theme.setPersistLayers(XMLUtil.getBoolean(element, "PersistLayers", true)); theme.setLayerPersistanceFilename(XMLUtil.getText(element, "LayersFilename")); theme.setCacheLocations(parseCacheLocations(element, "CacheLocation")); theme.setPersistPlaces(XMLUtil.getBoolean(element, "PersistPlaces", true)); theme.setPlacesPersistanceFilename(XMLUtil.getText(element, "PlacesFilename")); try { theme.setPlacesInitialisationPath(XMLUtil.getURL(element, "InitialPlaces", context)); } catch (MalformedURLException e) { } theme.setHUDs(parseHUDs(element, "HUD")); theme.setPanels(parsePanels(element, "Panel")); theme.setDatasets(parseDatasets(element, "Dataset", context)); theme.setLayers(parseLayers(element, "Layer", context)); theme.setInitialLatitude(XMLUtil.getDouble(element, "InitialLatitude", null)); theme.setInitialLongitude(XMLUtil.getDouble(element, "InitialLongitude", null)); theme.setInitialAltitude(XMLUtil.getDouble(element, "InitialAltitude", null)); theme.setInitialHeading(XMLUtil.getDouble(element, "InitialHeading", null)); theme.setInitialPitch(XMLUtil.getDouble(element, "InitialPitch", null)); theme.setVerticalExaggeration(XMLUtil.getDouble(element, "VerticalExaggeration", null)); theme.setFieldOfView(XMLUtil.getDouble(element, "FieldOfView", null)); return theme; }  }
ThemeFactory { public static Theme createFromXML(Object source, URL context) { Element element = XMLUtil.getElementFromSource(source); if (element == null) { return null; } BasicTheme theme = new BasicTheme(XMLUtil.getText(element, "ThemeName")); theme.setMenuBar(XMLUtil.getBoolean(element, "MenuBar", false)); theme.setToolBar(XMLUtil.getBoolean(element, "ToolBar", false)); theme.setStatusBar(XMLUtil.getBoolean(element, "StatusBar", false)); theme.setSideBar(XMLUtil.getBoolean(element, "SideBar", true)); theme.setFullscreen(XMLUtil.getBoolean(element, "Fullscreen", false)); theme.setHasWms(XMLUtil.getBoolean(element, "WmsBrowser", true)); theme.setPersistLayers(XMLUtil.getBoolean(element, "PersistLayers", true)); theme.setLayerPersistanceFilename(XMLUtil.getText(element, "LayersFilename")); theme.setCacheLocations(parseCacheLocations(element, "CacheLocation")); theme.setPersistPlaces(XMLUtil.getBoolean(element, "PersistPlaces", true)); theme.setPlacesPersistanceFilename(XMLUtil.getText(element, "PlacesFilename")); try { theme.setPlacesInitialisationPath(XMLUtil.getURL(element, "InitialPlaces", context)); } catch (MalformedURLException e) { } theme.setHUDs(parseHUDs(element, "HUD")); theme.setPanels(parsePanels(element, "Panel")); theme.setDatasets(parseDatasets(element, "Dataset", context)); theme.setLayers(parseLayers(element, "Layer", context)); theme.setInitialLatitude(XMLUtil.getDouble(element, "InitialLatitude", null)); theme.setInitialLongitude(XMLUtil.getDouble(element, "InitialLongitude", null)); theme.setInitialAltitude(XMLUtil.getDouble(element, "InitialAltitude", null)); theme.setInitialHeading(XMLUtil.getDouble(element, "InitialHeading", null)); theme.setInitialPitch(XMLUtil.getDouble(element, "InitialPitch", null)); theme.setVerticalExaggeration(XMLUtil.getDouble(element, "VerticalExaggeration", null)); theme.setFieldOfView(XMLUtil.getDouble(element, "FieldOfView", null)); return theme; }  static Theme createFromXML(Object source, URL context); }
ThemeFactory { public static Theme createFromXML(Object source, URL context) { Element element = XMLUtil.getElementFromSource(source); if (element == null) { return null; } BasicTheme theme = new BasicTheme(XMLUtil.getText(element, "ThemeName")); theme.setMenuBar(XMLUtil.getBoolean(element, "MenuBar", false)); theme.setToolBar(XMLUtil.getBoolean(element, "ToolBar", false)); theme.setStatusBar(XMLUtil.getBoolean(element, "StatusBar", false)); theme.setSideBar(XMLUtil.getBoolean(element, "SideBar", true)); theme.setFullscreen(XMLUtil.getBoolean(element, "Fullscreen", false)); theme.setHasWms(XMLUtil.getBoolean(element, "WmsBrowser", true)); theme.setPersistLayers(XMLUtil.getBoolean(element, "PersistLayers", true)); theme.setLayerPersistanceFilename(XMLUtil.getText(element, "LayersFilename")); theme.setCacheLocations(parseCacheLocations(element, "CacheLocation")); theme.setPersistPlaces(XMLUtil.getBoolean(element, "PersistPlaces", true)); theme.setPlacesPersistanceFilename(XMLUtil.getText(element, "PlacesFilename")); try { theme.setPlacesInitialisationPath(XMLUtil.getURL(element, "InitialPlaces", context)); } catch (MalformedURLException e) { } theme.setHUDs(parseHUDs(element, "HUD")); theme.setPanels(parsePanels(element, "Panel")); theme.setDatasets(parseDatasets(element, "Dataset", context)); theme.setLayers(parseLayers(element, "Layer", context)); theme.setInitialLatitude(XMLUtil.getDouble(element, "InitialLatitude", null)); theme.setInitialLongitude(XMLUtil.getDouble(element, "InitialLongitude", null)); theme.setInitialAltitude(XMLUtil.getDouble(element, "InitialAltitude", null)); theme.setInitialHeading(XMLUtil.getDouble(element, "InitialHeading", null)); theme.setInitialPitch(XMLUtil.getDouble(element, "InitialPitch", null)); theme.setVerticalExaggeration(XMLUtil.getDouble(element, "VerticalExaggeration", null)); theme.setFieldOfView(XMLUtil.getDouble(element, "FieldOfView", null)); return theme; }  static Theme createFromXML(Object source, URL context);  }