// Path: src/main/java/infovis/util/Objects.java
// public final class Objects {
// 
//   /** No instance. */
//   private Objects() {
//     throw new AssertionError();
//   }
// 
//   /**
//    * Requires a non-null argument. This can be used in constructors to enforce
//    * non-null arguments.
//    * 
//    * @param <T> The type of the argument.
//    * @param obj The argument.
//    * @return The argument.
//    * @throws IllegalArgumentException When the argument is <code>null</code>.
//    */
//   public static <T> T requireNonNull(final T obj) {
//     if(obj == null) throw new IllegalArgumentException("null argument");
//     return obj;
//   }
// 
//   /**
//    * Requires a null argument.
//    * 
//    * @param obj The argument.
//    * @throws IllegalArgumentException When the argument is <code>null</code>.
//    */
//   public static void requireNull(final Object obj) {
//     if(obj != null) throw new IllegalArgumentException("non-null argument: " + obj);
//   }
// 
//   /**
//    * Requires a <code>true</code> statement.
//    * 
//    * @param value The statement that needs to be <code>true</code>.
//    * @throws IllegalStateException When the statement is <code>false</code>.
//    */
//   public static void requireTrue(final boolean value) {
//     if(!value) throw new IllegalStateException("expected true");
//   }
// 
//   /**
//    * Returns the first argument if it is non-null otherwise the second argument
//    * is returned. This is a short-hand for:
//    * <code>(obj != null ? obj : or)</code>
//    * 
//    * @param <T> The type of the arguments.
//    * @param obj The object.
//    * @param or The alternative.
//    * @return The first argument if it is non-null or else the second argument.
//    */
//   public static <T> T nonNull(final T obj, final T or) {
//     return obj != null ? obj : or;
//   }
// 
// }


import infovis.util.Objects;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
package infovis.gui;




/**
 * A simple class adding panning and zooming functionality to a
 * {@link JComponent}.
 * 
 * @author Joschi <josua.krause@googlemail.com>
 */
public class Canvas extends JComponent implements Refreshable {

  /** The underlying zoomable user interface. */
  protected final ZoomableUI zui;

  /** The painter. */
  protected Painter painter;

  /** The focused component. */
  private JComponent focus;

  /**
   * Creates a canvas for the given painter.
   * 
   * @param p The painter.
   * @param width The initial width of the component.
   * @param height The initial height of the component.
   */
  public Canvas(final Painter p, final int width, final int height) {
    setPreferredSize(new Dimension(width, height));
// Path: src/main/java/infovis/util/Objects.java
// public final class Objects {
// 
//   /** No instance. */
//   private Objects() {
//     throw new AssertionError();
//   }
// 
//   /**
//    * Requires a non-null argument. This can be used in constructors to enforce
//    * non-null arguments.
//    * 
//    * @param <T> The type of the argument.
//    * @param obj The argument.
//    * @return The argument.
//    * @throws IllegalArgumentException When the argument is <code>null</code>.
//    */
//   public static <T> T requireNonNull(final T obj) {
//     if(obj == null) throw new IllegalArgumentException("null argument");
//     return obj;
//   }
// 
//   /**
//    * Requires a null argument.
//    * 
//    * @param obj The argument.
//    * @throws IllegalArgumentException When the argument is <code>null</code>.
//    */
//   public static void requireNull(final Object obj) {
//     if(obj != null) throw new IllegalArgumentException("non-null argument: " + obj);
//   }
// 
//   /**
//    * Requires a <code>true</code> statement.
//    * 
//    * @param value The statement that needs to be <code>true</code>.
//    * @throws IllegalStateException When the statement is <code>false</code>.
//    */
//   public static void requireTrue(final boolean value) {
//     if(!value) throw new IllegalStateException("expected true");
//   }
// 
//   /**
//    * Returns the first argument if it is non-null otherwise the second argument
//    * is returned. This is a short-hand for:
//    * <code>(obj != null ? obj : or)</code>
//    * 
//    * @param <T> The type of the arguments.
//    * @param obj The object.
//    * @param or The alternative.
//    * @return The first argument if it is non-null or else the second argument.
//    */
//   public static <T> T nonNull(final T obj, final T or) {
//     return obj != null ? obj : or;
//   }
// 
// }


// Path: src/main/java/infovis/gui/Canvas.java
import infovis.util.Objects;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;

package infovis.gui;




/**
 * A simple class adding panning and zooming functionality to a
 * {@link JComponent}.
 * 
 * @author Joschi <josua.krause@googlemail.com>
 */
public class Canvas extends JComponent implements Refreshable {

  /** The underlying zoomable user interface. */
  protected final ZoomableUI zui;

  /** The painter. */
  protected Painter painter;

  /** The focused component. */
  private JComponent focus;

  /**
   * Creates a canvas for the given painter.
   * 
   * @param p The painter.
   * @param width The initial width of the component.
   * @param height The initial height of the component.
   */
  public Canvas(final Painter p, final int width, final int height) {
    setPreferredSize(new Dimension(width, height));
    painter = Objects.requireNonNull(p);