1 /* 2 * Copyright (c) 2003-2008 by Cosylab d. d. 3 * 4 * This file is part of CosyBeans-Common. 5 * 6 * CosyBeans-Common is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * CosyBeans-Common is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with CosyBeans-Common. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package com.cosylab.gui.components.gauger; 21 22 import java.awt.Graphics2D; 23 import java.awt.Rectangle; 24 25 26 /** 27 * Interface specifies a graphical element, that needs is relatively small in 28 * size and needs to be drawn very often over the prerendered scale. The 29 * methods specified are sufficied for the Gauger to perform optimized 30 * rendering when the location of the element changes. 31 * 32 * @author <a href="mailto:ales.pucelj@cosylab.com">Ales Pucelj</a> 33 * @version $id$ 34 */ 35 public interface ActiveElement 36 { 37 /** 38 * Returns the extents of this object. This method must return the bounding 39 * box of the element. The area can be larger, but it must not be smaller, 40 * or visual appearance of the gauger will be corrupted. 41 * 42 * @return Bounding rectangle. 43 */ 44 Rectangle getBounds(); 45 46 /** 47 * Performs the rendering of the element. The element should perform the 48 * neccesary space transform to obtain the coordinates to draw to. 49 * 50 * @param g Graphics object to draw to. 51 * @param transform transformation defining the scale. 52 */ 53 void render(Graphics2D g); 54 55 /** 56 * Returns whether the element has changed significantly since it was last 57 * redrawn. If this element has the same position as the last time it was 58 * redrawn and its visual appearance has not changed, then this method 59 * should return false. If the result is true, the component will be 60 * redrawn. This method is used to minimize the number of redraws. 61 * 62 * @return True if change is signifficant. 63 */ 64 boolean isChangeSignificant(); 65 66 /** 67 * Notifies the element that the transformation used to draw this scale has 68 * changed. The element must recalculate its position and bounds as it 69 * will be redrawn. 70 */ 71 public void setTransform(ScaleTransform transform); 72 } 73 74 /* __oOo__ */