Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static IRenderTheme load(ThemeFile theme, ThemeCallback themeCallback) throws org.oscim.theme.IRenderTheme_ThemeException
        public static IRenderTheme load(ThemeFile theme, ThemeCallback themeCallback)
        {
            IRenderTheme t;

            if (theme.MapsforgeTheme)
            {
                t = Parameters.TEXTURE_ATLAS ? XmlMapsforgeAtlasThemeBuilder.read(theme, themeCallback) : XmlMapsforgeThemeBuilder.read(theme, themeCallback);
            }
            else
            {
                t = Parameters.TEXTURE_ATLAS ? XmlAtlasThemeBuilder.read(theme, themeCallback) : XmlThemeBuilder.read(theme, themeCallback);
            }
            if (t != null)
            {
                t.scaleTextSize(CanvasAdapter.Scale * CanvasAdapter.textScale);
            }
            return(t);
        }
        /// <param name="theme">         an input theme containing valid render theme XML data. </param>
        /// <param name="themeCallback"> the theme callback. </param>
        /// <returns> a new RenderTheme which is created by parsing the XML data from the input theme. </returns>
        /// <exception cref="ThemeException"> if an error occurs while parsing the render theme XML. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback) throws org.oscim.theme.IRenderTheme.ThemeException
        public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback)
        {
            IDictionary <object, TextureRegion> outputMap    = new Dictionary <object, TextureRegion>();
            IList <TextureAtlas>          atlasList          = new List <TextureAtlas>();
            XmlMapsforgeAtlasThemeBuilder renderThemeHandler = new XmlMapsforgeAtlasThemeBuilder(theme, themeCallback, outputMap, atlasList);

            try
            {
                (new XMLReaderAdapter()).parse(renderThemeHandler, theme.RenderThemeAsStream);
            }
            catch (Exception e)
            {
                throw new ThemeException(e.Message);
            }

            TextureAtlasUtils.createTextureRegions(renderThemeHandler.bitmapMap, outputMap, atlasList, true, CanvasAdapter.platform == Platform.IOS);

            return(replaceThemeSymbols(renderThemeHandler.mRenderTheme, outputMap));
        }