/** * Returns the DrawFactory, preferably via a graphics instance. * If graphics is null, the current thread local is checked or * if it is not set, a new factory is created. * * @param graphics the current graphics context or null * @return the draw factory */ public static DrawFactory getInstance(Graphics2D graphics) { // first try to find the factory over the rendering hint DrawFactory factory = null; boolean isHint = false; if (graphics != null) { factory = (DrawFactory)graphics.getRenderingHint(Drawable.DRAW_FACTORY); isHint = (factory != null); } // secondly try the thread local default if (factory == null) { factory = defaultFactory.get(); } // and at last, use the default factory if (factory == null) { factory = new DrawFactory(); } if (graphics != null && !isHint) { graphics.setRenderingHint(Drawable.DRAW_FACTORY, factory); } return factory; }
/** * Returns the DrawFactory, preferably via a graphics instance. * If graphics is null, the current thread local is checked or * if it is not set, a new factory is created. * * @param graphics the current graphics context or null * @return the draw factory */ public static DrawFactory getInstance(Graphics2D graphics) { // first try to find the factory over the rendering hint DrawFactory factory = null; boolean isHint = false; if (graphics != null) { factory = (DrawFactory)graphics.getRenderingHint(Drawable.DRAW_FACTORY); isHint = (factory != null); } // secondly try the thread local default if (factory == null) { factory = defaultFactory.get(); } // and at last, use the default factory if (factory == null) { factory = new DrawFactory(); } if (graphics != null && !isHint) { graphics.setRenderingHint(Drawable.DRAW_FACTORY, factory); } return factory; }