Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
DragImageExchange.java
1 
16 package net.squiz.matrix.ui;
17 
18 import java.awt.image.BufferedImage;
19 import java.awt.Point;
20 
29 public class DragImageExchange {
30 
31  private static BufferedImage dragImage;
32  private static Point mouseOffset;
33  private static boolean inExchange = false;
34 
35  // cannot instantiate
36  private DragImageExchange() {}
37 
45  public static void setDragImage(BufferedImage dragImage, Point mouseOffset) {
46  //if (inExchange)
47  // throw new IllegalStateException("There is already an exchange open.");
48  DragImageExchange.dragImage = dragImage;
49  DragImageExchange.mouseOffset = mouseOffset;
50  inExchange = true;
51  }
52 
56  public static BufferedImage getDragImage() {
57  if (!inExchange)
58  throw new IllegalStateException("There is no exchange open.");
59  return dragImage;
60  }
61 
66  public static Point getMouseOffset() {
67  if (!inExchange)
68  throw new IllegalStateException("There is no exchange open.");
69  return mouseOffset;
70  }
71 
75  public static void completeExchange() {
76  if (!inExchange)
77  throw new IllegalStateException("There is no exchange open.");
78  dragImage = null;
79  inExchange = false;
80  }
81 }