// Path: ios-moe/src/svg/SVGRenderer.java
// @Generated
// @Library("SVGgh")
// @Runtime(ObjCRuntime.class)
// @ObjCClassBinding
// public class SVGRenderer extends SVGParser {
//     static {
//         NatJ.register();
//     }
// 
//     @Generated
//     public SVGRenderer(Pointer peer) {
//         super(peer);
//     }
// 
// 
//     @Generated
//     @Owned
//     @Selector("alloc")
//     public static native SVGRenderer alloc();
// 
// 
//     @Generated
//     @Selector("asImageWithSize:andScale:")
//     public native UIImage asImageWithSizeAndScale(@ByValue CGSize maximumSize,
//                                                   @NFloat double scale);
// 
// 
//     @Generated
//     @Selector("viewRect")
//     @ByValue
//     public native CGRect viewRect();
// }


import org.oscim.backend.CanvasAdapter;
import org.oscim.utils.IOUtils;
import org.robovm.apple.coregraphics.CGRect;
import org.robovm.apple.coregraphics.CGSize;
import org.robovm.apple.uikit.UIImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import svg.SVGRenderer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/*
 * Copyright 2016 Longri
 * Copyright 2016 devemux86
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.oscim.ios.backend;



public class IosSvgBitmap extends IosBitmap {
    private static final Logger log = LoggerFactory.getLogger(IosSvgBitmap.class);

    /**
     * Default size is 20x20px (400px) at 160dpi.
     */
    public static float DEFAULT_SIZE = 400f;

    private static String getStringFromInputStream(InputStream is) {
        StringBuilder sb = new StringBuilder();
        BufferedReader br = null;
        String line;
        try {
            br = new BufferedReader(new InputStreamReader(is));
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(br);
        }
        return sb.toString();
    }

    public static UIImage getResourceBitmap(InputStream inputStream, float scaleFactor, float defaultSize, int width, int height, int percent) {
        String svg = getStringFromInputStream(inputStream);
// Path: ios-moe/src/svg/SVGRenderer.java
// @Generated
// @Library("SVGgh")
// @Runtime(ObjCRuntime.class)
// @ObjCClassBinding
// public class SVGRenderer extends SVGParser {
//     static {
//         NatJ.register();
//     }
// 
//     @Generated
//     public SVGRenderer(Pointer peer) {
//         super(peer);
//     }
// 
// 
//     @Generated
//     @Owned
//     @Selector("alloc")
//     public static native SVGRenderer alloc();
// 
// 
//     @Generated
//     @Selector("asImageWithSize:andScale:")
//     public native UIImage asImageWithSizeAndScale(@ByValue CGSize maximumSize,
//                                                   @NFloat double scale);
// 
// 
//     @Generated
//     @Selector("viewRect")
//     @ByValue
//     public native CGRect viewRect();
// }


// Path: ios/src/org/oscim/ios/backend/IosSvgBitmap.java
import org.oscim.backend.CanvasAdapter;
import org.oscim.utils.IOUtils;
import org.robovm.apple.coregraphics.CGRect;
import org.robovm.apple.coregraphics.CGSize;
import org.robovm.apple.uikit.UIImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import svg.SVGRenderer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/*
 * Copyright 2016 Longri
 * Copyright 2016 devemux86
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.oscim.ios.backend;



public class IosSvgBitmap extends IosBitmap {
    private static final Logger log = LoggerFactory.getLogger(IosSvgBitmap.class);

    /**
     * Default size is 20x20px (400px) at 160dpi.
     */
    public static float DEFAULT_SIZE = 400f;

    private static String getStringFromInputStream(InputStream is) {
        StringBuilder sb = new StringBuilder();
        BufferedReader br = null;
        String line;
        try {
            br = new BufferedReader(new InputStreamReader(is));
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(br);
        }
        return sb.toString();
    }

    public static UIImage getResourceBitmap(InputStream inputStream, float scaleFactor, float defaultSize, int width, int height, int percent) {
        String svg = getStringFromInputStream(inputStream);
        SVGRenderer renderer = new SVGRenderer(svg);