Back to project page unknown-pleasures.
The source code is released under:
Creative Commons Attribution NonCommercial NoDerivs (CC-NC-ND) THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTE...
If you think the Android project unknown-pleasures listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * LineRendererFactory.java//www . ja v a 2 s . c o m * Author: marek.brodziak@gmail.com * Created: May 6, 2014 * Copyright 2014 by miniti */ package pl.miniti.android.pleasures.line; import android.util.Log; /** * Factory of the {@see LineRenderer} implementations */ public class LineRendererFactory { /** * Tag name for the logger */ private static final String T = LineRendererFactory.class.getSimpleName(); /** * Enumeration of available implementations */ private enum Impl { /** * Default implementation for this factory */ DEFAULT(SimpleLineRenderer.class), /** * Simple renderer */ SIMPLE(SimpleLineRenderer.class); private Class<? extends LineRenderer> lineRendererClass; private Impl(Class<? extends LineRenderer> ac) { if (ac == null) { throw new IllegalArgumentException( "null is not a valid LineRenderer implementation"); } lineRendererClass = ac; } } /** * Construct a new instance based on the configuration * * @param value * configuration value * @return object instance */ public static LineRenderer newInstance(String value) { Log.d(T, String.format("Searching for LineRenderer %s", value)); try { if (value == null) { Log.d(T, String.format( "Constructing a default LineRenderer implementation %s", Impl.DEFAULT.lineRendererClass.getSimpleName())); return Impl.DEFAULT.lineRendererClass.newInstance(); } for (Impl a : Impl.values()) { if (a.lineRendererClass.getName().equals(value)) { Log.d(T, "Match found"); return a.lineRendererClass.newInstance(); } } Log.w(T, String.format("%s is not a registered LineRenderer", value)); Log.d(T, String.format( "Constructing a default LineRenderer implementation %s", Impl.DEFAULT.lineRendererClass.getSimpleName())); return Impl.DEFAULT.lineRendererClass.newInstance(); } catch (InstantiationException e) { Log.e(T, "Error while creating an LineRenderer", e); } catch (IllegalAccessException e) { Log.e(T, "Error raised while creating an LineRenderer", e); } Log.d(T, "Fall back to constructing from code"); return new SimpleLineRenderer(); } /** * Construct a new default instance * * @return object instance */ public static LineRenderer newInstance() { return newInstance(null); } }