Search in sources :

Example 1 with EsriRendererInterface

use of com.sldeditor.importdata.esri.renderer.EsriRendererInterface in project sldeditor by robward-scisys.

the class ParseLayer method internal_createRenderer.

/**
 * Internal_create renderer.
 *
 * @param renderer the renderer
 * @return the json object
 */
private JsonObject internal_createRenderer(IFeatureRenderer renderer) {
    EsriRendererInterface rendererConverter = data.getRenderer(renderer.getClass());
    JsonObject jsonRenderer = null;
    if (rendererConverter != null) {
        jsonRenderer = rendererConverter.convert(renderer);
    } else {
        System.err.println("Unsupported renderer : " + renderer.getClass().getName());
    }
    return jsonRenderer;
}
Also used : EsriRendererInterface(com.sldeditor.importdata.esri.renderer.EsriRendererInterface) JsonObject(com.google.gson.JsonObject)

Example 2 with EsriRendererInterface

use of com.sldeditor.importdata.esri.renderer.EsriRendererInterface in project sldeditor by robward-scisys.

the class RegisterClasses method registerRenderers.

/**
 * Register renderer converters.
 *
 * @param classLoadersList the class loaders list
 * @param data the data
 */
private static void registerRenderers(List<ClassLoader> classLoadersList, ConversionData data) {
    logger.info("Renderers supported:");
    Reflections reflections = new Reflections(new ConfigurationBuilder().setScanners(new SubTypesScanner(false), new ResourcesScanner()).setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))).filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("com.sldeditor.importdata.esri.renderer"))));
    Set<Class<? extends Object>> allClasses = reflections.getSubTypesOf(Object.class);
    for (Class<? extends Object> claszz : allClasses) {
        try {
            if (validClass(claszz, EsriRendererInterface.class)) {
                EsriRendererInterface rendererObj = (EsriRendererInterface) claszz.newInstance();
                logger.info(rendererObj.getRendererClass().getName());
                data.addRenderer(rendererObj);
            }
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
Also used : ConfigurationBuilder(org.reflections.util.ConfigurationBuilder) SubTypesScanner(org.reflections.scanners.SubTypesScanner) FilterBuilder(org.reflections.util.FilterBuilder) EsriRendererInterface(com.sldeditor.importdata.esri.renderer.EsriRendererInterface) ResourcesScanner(org.reflections.scanners.ResourcesScanner) Reflections(org.reflections.Reflections)

Aggregations

EsriRendererInterface (com.sldeditor.importdata.esri.renderer.EsriRendererInterface)2 JsonObject (com.google.gson.JsonObject)1 Reflections (org.reflections.Reflections)1 ResourcesScanner (org.reflections.scanners.ResourcesScanner)1 SubTypesScanner (org.reflections.scanners.SubTypesScanner)1 ConfigurationBuilder (org.reflections.util.ConfigurationBuilder)1 FilterBuilder (org.reflections.util.FilterBuilder)1