/* * (C) 2004 - Geotechnical Software Services * * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ package no.geosoft.cc.graphics; /** * Common interface for all graphics interactions. * <p> * Typical usage: * * <pre> * public class DrawInteraction implements GInteraction * { * private GObject interaction_; * private GSegment line_; * * public void event (GScene scene, int event, int x, int y) * { * switch (event) { * case GWindow.BUTTON1_DOWN : * // Create interaction object and segment and add to scene * break; * * case GWindow.BUTTON1.DRAG : * // extend segment with new x,y * // and refresh graphics * * case ... * } * } * } * </pre> * * The interaction is started by installing it in the GWindow: * * <pre> * GInteraction drawInteraction = new DrawInteraction(); * window.startInteraction (drawInteraction); * </pre> * * The interaction is stopped if another interaction is started or if it * is explicitly stopped by <tt>GWindow.stopInteraction()</tt>. Before * the interaction is stopped a <tt>GWindow.ABORT</tt> event is passed * to the interaction. * * @see GWindow#startInteraction(GInteraction) * @see GWindow#stopInteraction() * @see ZoomInteraction * * @author <a href="mailto:info@geosoft.no">GeoSoft</a> */ public interface GInteraction { /** * Trigged by mouse events within the canvas. * @see no.geosoft.cc.graphics.GWindow * * @param scene The scene of this event. * @param event Event type * @param x X position of cursor. * @param y Y position of cursor. */ public void event (GScene scene, int event, int x, int y); }