All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.protege.widgetmap.client.drop.DropLocation Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
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