Warning: session_start(): open(/var/lib/php/sessions/sess_25e5ledv74fbtkcg8kjcnf6nsc, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass ImageSurfaceSelector extends ImageSurfaceMouseHandler {
ImageSurface is;
Point startingPoint;
bool enabled = true;
static bool verbose = false;
*(ImageSurface is) {
if (containsInstance(is.tools, ImageSurfaceSelector)) ret;
register(is);
}
public void mousePressed(MouseEvent evt) {
if (verbose) print("mousePressed");
if (evt.getButton() != MouseEvent.BUTTON1) return;
if (enabled)
startingPoint = getPoint(evt);
}
public void mouseDragged(MouseEvent e) {
if (verbose) print("mouseDragged");
if (startingPoint != null) {
Point endPoint = getPoint(e);
Rectangle r = new Rectangle(startingPoint, new Dimension(endPoint.x-startingPoint.x+1, endPoint.y-startingPoint.y+1));
normalize(r);
r.width = min(r.width, is.getImage().getWidth()-r.x);
r.height = min(r.height, is.getImage().getHeight()-r.y);
is.setSelection(r);
}
if (verbose) print("mouseDragged done");
}
public static void normalize(Rectangle r) {
if (r.width < 0) {
r.x += r.width;
r.width = -r.width;
}
if (r.height < 0) {
r.y += r.height;
r.height = -r.height;
}
}
public void mouseReleased(MouseEvent e) {
if (verbose) print("mouseReleased");
mouseDragged(e);
if (getPoint(e).equals(startingPoint))
is.setSelection((Rectangle) null);
startingPoint = null;
}
Point getPoint(MouseEvent e) {
return new Point((int) (e.getX()/is.getZoomX()), (int) (e.getY()/is.getZoomY()));
}
}