本文整理汇总了Java中java.awt.Point.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Point.getX方法的具体用法?Java Point.getX怎么用?Java Point.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Point
的用法示例。
在下文中一共展示了Point.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeVisibleSpan
import java.awt.Point; //导入方法依赖的package包/类
private int[] computeVisibleSpan() {
Component parent = pane.getParent();
if (parent instanceof JLayeredPane) {
parent = parent.getParent();
}
if (parent instanceof JViewport) {
JViewport vp = (JViewport) parent;
Point start = vp.getViewPosition();
Dimension size = vp.getExtentSize();
Point end = new Point((int) (start.getX() + size.getWidth()), (int) (start.getY() + size.getHeight()));
int startPosition = pane.viewToModel(start);
int endPosition = pane.viewToModel(end);
if (parentWithListener != vp) {
vp.addChangeListener(WeakListeners.change(this, vp));
parentWithListener = vp;
}
return new int[] {startPosition, endPosition};
}
return new int[] {0, pane.getDocument().getLength()};
}
示例2: applyTextRecovery
import java.awt.Point; //导入方法依赖的package包/类
/**
* Applies text recovery to the gray image. See section IV.B
* @param map The gray image after global thresholding.
* @param postLocalThresholdMap The gray image after local thresholding.
* @return The gray image after text recovery.
*/
public static GrayImage applyTextRecovery(GrayImage map,
GrayImage postLocalThresholdMap) {
GrayImage res = textLabeling(map, postLocalThresholdMap);
TreeSet<Pixel> newTextPixels = new TreeSet<>();
for (int j = 0; j < map.getHeight(); ++j) {
for (int i = 0; i < map.getWidth(); ++i) {
newTextPixels.clear();
if (res.getValue(i, j) > 0) {
int x = i, y = j;
do {
if (!newTextPixels.isEmpty()) {
Point p = newTextPixels.pollFirst();
x = (int) p.getX();
y = (int) p.getY();
}
applyHysteresisMask(map, res, x, y, newTextPixels);
} while (!newTextPixels.isEmpty());
}
}
}
return res;
}
示例3: equals
import java.awt.Point; //导入方法依赖的package包/类
public boolean equals(Object o)
{
double u, v;
if (o instanceof Coordinates)
{
Coordinates c = (Coordinates)o;
u = c.getX();
v = c.getY();
}
else if (o instanceof Point)
{
Point p = (Point)o;
u = p.getX();
v = p.getY();
}
else
return false;
return ((Math.abs(u - getX()) < Float.MIN_VALUE) &&
(Math.abs(v - getY()) < Float.MIN_VALUE));
}
示例4: refresh
import java.awt.Point; //导入方法依赖的package包/类
/**Refreshes appearence of the image to be rendered. In facts, recalculates all of the jobs'
* new positions.*/
public void refresh() {
for (int i = 0; i < jobAnimations.size(); i++) {
JobAnimation ja = jobAnimations.get(i);
//update position as time*speed
ja.setPosition((System.currentTimeMillis() - ja.getTimeOfEntrance()) * ja.getSpeed());
Point p = convertPositionToCoord(ja.getPosition());
//tests if this job should be painted outside bounding box of this edge
if (p != null) {
boolean exceedsWidth = (p.getX() >= bounds.x + bounds.width), exceedsHeight = (p.getY() >= bounds.y + bounds.height);
if (exceedsWidth || exceedsHeight) {
routeJob(ja);
}
//set bounds of the job in order to be centered to the coords.
Rectangle r = ja.getBounds();
p.setLocation(p.getX() - r.getWidth() / 2, p.getY() - r.getHeight() / 2);
r.setLocation(p);
} else {
routeJob(ja);
}
}
}
示例5: getCenterPoint
import java.awt.Point; //导入方法依赖的package包/类
/**
* Returns the center point of a shape.
*/
public Point getCenterPoint(final List<Point> points) {
int centerX = 0;
int centerY = 0;
for (Point p : points) {
centerX += p.getX();
centerY += p.getY();
}
return new Point(centerX / points.size(), centerY / points.size());
}
示例6: mouseDragged
import java.awt.Point; //导入方法依赖的package包/类
@Override
public void mouseDragged(Canvas canvas, Graphics g, MouseEvent e) {
if (pokeCaret != null) {
pokeCaret.mouseDragged(e);
canvas.getProject().repaintCanvas();
} else {
// move scrollpane dragging hand
Point m = canvas.getMousePosition();
if (m == null) {
// if mouse exited and continue dragging
this.x0 = -1;
this.y0 = -1;
this.ScrollBarX = -1;
this.ScrollBarY = -1;
return;
} else if (this.x0 == -1 || this.y0 == -1 || this.ScrollBarX == -1 || this.ScrollBarY == -1) {
// if mouse re-entered after it exited without releasing the button
this.x0 = (int) m.getX();
this.y0 = (int) m.getY();
this.ScrollBarX = canvas.getHorizzontalScrollBar();
this.ScrollBarY = canvas.getVerticalScrollBar();
}
int x = (int) (this.x0 - m.getX());
int y = (int) (this.y0 - m.getY());
canvas.setCursor(move);
canvas.setScrollBar(this.ScrollBarX + x, this.ScrollBarY + y);
canvas.setArrows();
}
}
示例7: getTimeAtPoint
import java.awt.Point; //导入方法依赖的package包/类
public Integer getTimeAtPoint( Point p ) {
if( cruise == null ) return null;
double x = p.getX() / zoomX;
double y = p.getY() / zoomY;
int i=0;
while( i<cruise.xPosition.length
&& cruise.xPosition[i]+cruise.panelSize[i][0] < x ) {
// ((SCSPanel2)panels.get(i)).image = null;
i++;
}
if( i==cruise.xPosition.length || cruise.xPosition[i]>x )
return null;
return cruise.start[i] + (int)(30*(x-cruise.xPosition[i]));
}
示例8: scrollNow
import java.awt.Point; //导入方法依赖的package包/类
/**
* Start scrolling.
*/
private void scrollNow() {
if (mouseOnScreenPoint != null && target.isShowing()) {
Point origin = target.getLocationOnScreen();
Point relative = new Point(mouseOnScreenPoint.x - origin.x, mouseOnScreenPoint.y - origin.y);
Rectangle visibleRect = target.getVisibleRect();
if (!visibleRect.contains(relative)) {
int destX = relative.x;
if (relative.getX() < visibleRect.getMinX()) {
destX = (int) visibleRect.getMinX() - PAN_STEP_SIZE;
}
if (relative.getX() > visibleRect.getMaxX()) {
destX = (int) visibleRect.getMaxX() + PAN_STEP_SIZE;
}
int destY = relative.y;
if (relative.getY() < visibleRect.getMinY()) {
destY = (int) visibleRect.getMinY() - PAN_STEP_SIZE;
}
if (relative.getY() > visibleRect.getMaxY()) {
destY = (int) visibleRect.getMaxY() + PAN_STEP_SIZE;
}
target.scrollRectToVisible(new Rectangle(new Point(destX, destY)));
}
}
}
示例9: toProcessSpace
import java.awt.Point; //导入方法依赖的package包/类
/**
* Converts a {@link Point} to a point relative to the specified process.
*
* @param p
* the original point
* @param processIndex
* the index of the process
* @return the relative point or {@code null} if no process exists for the specified index
*/
public Point toProcessSpace(final Point p, final int processIndex) {
int xOffset = 0;
for (int i = 0; i < model.getProcesses().size(); i++) {
xOffset += ProcessDrawer.WALL_WIDTH;
if (i == processIndex) {
return new Point((int) p.getX() - xOffset, (int) p.getY() - ProcessDrawer.PADDING);
}
xOffset += ProcessDrawer.WALL_WIDTH + model.getProcessWidth(model.getProcess(i));
}
return null;
}
示例10: dropNow
import java.awt.Point; //导入方法依赖的package包/类
@Override
protected boolean dropNow(WorkflowAnnotation anno, Point loc) {
if (anno == null) {
return false;
}
AnnotationsModel annoModel = RapidMinerGUI.getMainFrame().getProcessPanel().getAnnotationsHandler().getModel();
// pasting an operator anno will always create a process anno
if (loc == null) {
loc = model.getMousePositionRelativeToProcess();
}
int index = model.getHoveringProcessIndex();
ExecutionUnit targetProcess;
if (index != -1) {
targetProcess = model.getProcess(index);
} else {
targetProcess = anno.getProcess();
}
ProcessAnnotation proAnno = anno.createProcessAnnotation(targetProcess);
// move to drop location
Rectangle2D frame = proAnno.getLocation();
Rectangle2D newFrame = new Rectangle2D.Double(loc.getX(), loc.getY(), frame.getWidth(), frame.getHeight());
proAnno.setLocation(newFrame);
annoModel.addProcessAnnotation(proAnno);
return true;
}
示例11: convertToAbsoluteProcessPoint
import java.awt.Point; //导入方法依赖的package包/类
/**
* Returns the absolute point for a given point in a process.
*
* @param p
* the relative point which is relative to the displayed process
* @param processIndex
* the index of the process in question
* @param model
* the model required to calculate the absolute location
* @return the absolute point (relative to the process renderer view) or {@code null} if the
* process index is invalid
*/
public static Point convertToAbsoluteProcessPoint(final Point p, final int processIndex,
final ProcessRendererModel model) {
double xOffset = 0;
for (int i = 0; i < model.getProcesses().size(); i++) {
xOffset += ProcessDrawer.WALL_WIDTH;
if (i == processIndex) {
return new Point((int) (p.getX() + xOffset), (int) (p.getY() + ProcessDrawer.PADDING));
}
xOffset += ProcessDrawer.WALL_WIDTH + model.getProcessWidth(model.getProcess(i));
}
return null;
}
示例12: getObjectLocation
import java.awt.Point; //导入方法依赖的package包/类
@Override
protected Point getObjectLocation() {
// get all necessary parameters
if (!getDockable().getComponent().isShowing()) {
return new Point(0, 0);
}
Point rendererLoc = renderer.getVisibleRect().getLocation();
Rectangle2D targetRect = renderer.getModel().getOperatorRect(operator);
if (targetRect == null) {
return rendererLoc;
}
Point loc = new Point((int) targetRect.getX(), (int) targetRect.getY());
loc = ProcessDrawUtils.convertToAbsoluteProcessPoint(loc,
renderer.getModel().getProcessIndex(operator.getExecutionUnit()), renderer.getModel());
if (loc == null) {
return rendererLoc;
}
// calculate actual on screen loc of the operator and return it
Point absoluteLoc = new Point((int) (viewport.getLocationOnScreen().x + (loc.getX() - rendererLoc.getX())),
(int) (viewport.getLocationOnScreen().y + (loc.getY() - rendererLoc.getY())));
// return validated Point
return this.validatePointForBubbleInViewport(absoluteLoc);
}
示例13: getEuclideanDistance
import java.awt.Point; //导入方法依赖的package包/类
private double getEuclideanDistance(Point p0, Point p1) {
//if x or y are equal in both the given points, calculate distance more rapidly
if (p0.getX() == p1.getX()) {
return Math.abs(p0.getY() - p1.getY());
}
if (p0.getY() == p1.getY()) {
return Math.abs(p0.getX() - p1.getX());
}
//if points are on different x and y coords
return Math.sqrt(Math.pow(p0.getX() - p1.getX(), 2) + Math.pow(p0.getY() - p1.getY(), 2));
}
示例14: getScreenMouseX
import java.awt.Point; //导入方法依赖的package包/类
/**
* Returns the mouse x position in the entire screen
* @return
*/
public static int getScreenMouseX()
{
PointerInfo p = MouseInfo.getPointerInfo();
Point b = p.getLocation();
return (int)b.getX();
}
示例15: handleDragEvent
import java.awt.Point; //导入方法依赖的package包/类
/**
* Handles a drag event based on the given {@link Point}.
*
* @param point
* the new point
*/
public void handleDragEvent(final Point point) {
WorkflowAnnotation draggedAnno = getDraggedAnnotation();
double xOffset = point.getX() - getOrigin().getX();
double yOffset = point.getY() - getOrigin().getY();
// we set the drag flag even if not yet unsnapped
if (xOffset != 0 || yOffset != 0) {
dragStarted = true;
}
// operator annotations need to be dragged a certain amount before they come "loose"
if (dragged instanceof OperatorAnnotation) {
if (!unsnapped && Math.abs(xOffset) < OPERATOR_ANNOTATION_UNSNAP_DISTANCE
&& Math.abs(yOffset) < OPERATOR_ANNOTATION_UNSNAP_DISTANCE) {
return;
} else {
unsnapped = true;
}
}
double newX = draggedAnno.getLocation().getX() + xOffset;
double newY = draggedAnno.getLocation().getY() + yOffset;
double width = draggedAnno.getLocation().getWidth();
double height = draggedAnno.getLocation().getHeight();
// make sure dragging out of process is not allowed
if (newX < WorkflowAnnotation.MIN_X) {
newX = WorkflowAnnotation.MIN_X;
}
if (newY < WorkflowAnnotation.MIN_Y) {
newY = WorkflowAnnotation.MIN_Y;
}
// check if we are hovering over an operator which does NOT have an annotation
if (model.getHoveringProcessIndex() != -1) {
ExecutionUnit process = model.getProcess(model.getHoveringProcessIndex());
if (process != null) {
hoveredOperator = null;
for (Operator op : process.getOperators()) {
if (model.getOperatorRect(op) != null
&& model.getOperatorRect(op).contains(model.getMousePositionRelativeToProcess())) {
if (model.getOperatorAnnotations(op) == null || model.getOperatorAnnotations(op).isEmpty()) {
hoveredOperator = op;
break;
} else if (model.getOperatorAnnotations(op).getAnnotationsDrawOrder().contains(draggedAnno)) {
// our own origin is a valid target as well
hoveredOperator = op;
break;
}
}
}
}
}
Rectangle2D newLoc = new Rectangle2D.Double(newX, newY, width, height);
draggedAnno.setLocation(newLoc);
setOrigin(point);
}