edu.stanford.protege.widgetmap.client.drop.DropLocation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of widgetmap Show documentation
Show all versions of widgetmap Show documentation
widgetmap is a GWT library that provides a treemap-like nesting for Widget
package edu.stanford.protege.widgetmap.client.drop;
import com.google.gwt.dom.client.Element;
import edu.stanford.protege.widgetmap.shared.node.Direction;
/**
* Author: Matthew Horridge
* Stanford University
* Bio-Medical Informatics Research Group
* Date: 06/12/2013
*/
public enum DropLocation {
LEFT(Direction.ROW),
RIGHT(Direction.ROW),
TOP(Direction.COLUMN),
BOTTOM(Direction.COLUMN);
private Direction direction;
private DropLocation(Direction direction) {
this.direction = direction;
}
public Direction getDirection() {
return direction;
}
/**
* Gets the drop location give a point and bound of of a rectangle. All co-ordinates are absolute.
* @param ptX
* @param ptY
* @param top
* @param left
* @param bottom
* @param right
* @return
*/
public static DropLocation getDropLocation(int ptX, int ptY, int top, int left, int bottom, int right) {
int width = right - left;
int height = bottom - top;
if(ptX < left + 0.33 * width) {
return LEFT;
}
else if(ptX > right - 0.33 * width) {
return RIGHT;
}
else if(ptY < top + 0.5 * height) {
return TOP;
}
else {
return BOTTOM;
}
}
public static DropLocation getDropLocation(int ptX, int ptY, Element e) {
return getDropLocation(ptX, ptY, e.getAbsoluteTop(), e.getAbsoluteLeft(), e.getAbsoluteBottom(), e.getAbsoluteRight());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy