001 package controller;
002
003 import java.awt.*;
004
005 /**
006 * Adapter to connect the display and the model.
007 *
008 * @author Mathias Ricken
009 */
010 public interface IDisplayAdapter {
011 /**
012 * Draw model in this region. The graphics object has been set up so that (0,0) represents the top left and
013 * (100,100) the bottom right corner.
014 *
015 * @param g graphics object
016 * @param comp the component to drawFish on
017 * @param p1 top left edge of the region
018 * @param p2 bottom right edge of the region
019 */
020 void draw(Graphics2D g, Component comp, Point.Double p1, Point.Double p2);
021
022 /**
023 * Get size of the display.
024 *
025 * @return size of the display in model coordinate units.
026 */
027 Dimension getDisplaySize();
028
029 /**
030 * The action to be executed if the display should return home.
031 *
032 * @param sa scroll adapter
033 */
034 void returnHome(IScrollAdapter sa);
035
036 /**
037 * Ask the model where to scroll, given where the user has scrolled. If the environment just acts like a normal
038 * panal, it should return pos without modification. If the environment recenters, it should return a position in
039 * the middle of the pan area. All coordinates are in model coordinate units.
040 *
041 * @param pos position where the user scrolled to
042 *
043 * @return position where the environment wants the view to be
044 *
045 * @see IDisplayAdapter#getPanDelta
046 */
047 Point.Double getViewPosition(Point.Double pos);
048
049 /**
050 * Ask the model how much to pan, given where the user scrolled. If the environment just acts like a normal panal,
051 * it should return (0,0). If the environment recenters, it should return delta without modification. All
052 * coordinates are in model coordinate units.
053 *
054 * @param delta how far the user scrolled
055 *
056 * @return how far the panel should scroll
057 *
058 * @see IDisplayAdapter#getViewPosition
059 */
060 Point.Double getPanDelta(Point.Double delta);
061 }