1 /* ***************************************************************************** 2 * NightLabs Editor2D - Graphical editor framework * 3 * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org * 4 * * 5 * This library is free software; you can redistribute it and/or * 6 * modify it under the terms of the GNU Lesser General Public * 7 * License as published by the Free Software Foundation; either * 8 * version 2.1 of the License, or (at your option) any later version. * 9 * * 10 * This library is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 * Lesser General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU Lesser General Public * 16 * License along with this library; if not, write to the * 17 * Free Software Foundation, Inc., * 18 * 51 Franklin St, Fifth Floor, * 19 * Boston, MA 02110-1301 USA * 20 * * 21 * Or get it online : * 22 * http://www.gnu.org/copyleft/lesser.html * 23 * * 24 * * 25 ******************************************************************************/ 26 27 package org.nightlabs.editor2d.render; 28 29 import java.awt.Graphics2D; 30 31 import org.nightlabs.editor2d.DrawComponent; 32 33 /** 34 * This is the Base-Interface for all Renderers 35 * 36 * For each RenderMode of a DrawComponent there should 37 * exist a certain Renderer-Implementation, which should display 38 * the content of the DrawComponent corresponding to the context (RenderMode) 39 * 40 * Implementation of Renderers for certain classes must cast the DrawComponent 41 * in order to get access to the specialized content 42 * 43 * a small example for a ShapeDrawComponent-Renderer: 44 * 45 * public void paint(DrawComponent dc, Graphics2D g2d) 46 * { 47 * ShapeDrawComponent sdc = (ShapeDrawComponent) dc; 48 * g2d.setPaint(sdc.getFillColor()); 49 * g2d.fill(sdc.getGeneralShape()); 50 * g2d.setPaint(sdc.getLineColor()); 51 * g2d.setStroke(new BasicStroke()); 52 * g2d.draw(sdc.getGeneralShape()); 53 * } 54 * 55 * @see org.nightlabs.editor2d.DrawComponent.getRenderMode() 56 * @see org.nightlabs.editor2d.render.RenderModeManager 57 * 58 * @author Daniel.Mazurek [AT] NightLabs [DOT] com 59 * 60 */ 61 public interface Renderer 62 { 63 /** 64 * In the Implementation of this Method you 65 * need to display the content of the DrawComponent 66 * on the given Graphics2D. 67 * 68 * Specialized Renderers for certain classes must cast the DrawComponent 69 * in order to get access to the specialized content 70 * 71 * @param dc the DrawComponent to paint 72 * @param g2d the Graphics2D to paint on 73 */ 74 public void paint(DrawComponent dc, Graphics2D g2d); 75 } 76