当前位置: 首页>>代码示例>>Java>>正文


Java Point2D.getX方法代码示例

本文整理汇总了Java中javafx.geometry.Point2D.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Point2D.getX方法的具体用法?Java Point2D.getX怎么用?Java Point2D.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.geometry.Point2D的用法示例。


在下文中一共展示了Point2D.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buttondown

import javafx.geometry.Point2D; //导入方法依赖的package包/类
public void buttondown(JSONObject query, JSONObject uriParams, Session session) {
    int button = 0;
    if (query != null && query.has("button")) {
        button = query.getInt("button");
    }
    IJavaFXElement element = null;
    double xoffset;
    double yoffset;
    if (lastComponenet.element != null) {
        element = lastComponenet.element;
        xoffset = lastComponenet.x;
        yoffset = lastComponenet.y;
    } else {
        element = session.getActiveElement();
        Point2D p = element.getMidpoint();
        xoffset = p.getX();
        yoffset = p.getY();
    }
    element.buttonDown(button, xoffset, yoffset);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:JavaServer.java

示例2: buttonup

import javafx.geometry.Point2D; //导入方法依赖的package包/类
public void buttonup(JSONObject query, JSONObject uriParams, Session session) {
    int button = 0;
    if (query.has("button")) {
        button = query.getInt("button");
    }
    IJavaFXElement element = null;
    double xoffset;
    double yoffset;
    if (lastComponenet.element != null) {
        element = lastComponenet.element;
        xoffset = lastComponenet.x;
        yoffset = lastComponenet.y;
    } else {
        element = session.getActiveElement();
        Point2D p = element.getMidpoint();
        xoffset = p.getX();
        yoffset = p.getY();
    }
    element.buttonUp(button, xoffset, yoffset);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:JavaServer.java

示例3: click

import javafx.geometry.Point2D; //导入方法依赖的package包/类
private void click(Session session, int button, int clickCount) {
    IJavaFXElement element = null;
    double xoffset;
    double yoffset;
    if (lastComponenet.element != null) {
        element = lastComponenet.element;
        xoffset = lastComponenet.x;
        yoffset = lastComponenet.y;
    } else {
        element = session.getActiveElement();
        Point2D p = element.getMidpoint();
        xoffset = p.getX();
        yoffset = p.getY();
    }
    element.click(button, null, null, clickCount, xoffset, yoffset);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:17,代码来源:JavaServer.java

示例4: getPolygon

import javafx.geometry.Point2D; //导入方法依赖的package包/类
/**
 * @return Polygon
 * Create a polygon hull of the given image by deleting the transparent pixels
 * There are two methods: convex_hull and hull
 */
public Polygon getPolygon(){
	ImageTransformation transformation = new ImageTransformation();
	Set<Point2D> set = transformation.getMask(image, backgroundColor);			
	ConvexHull convexHull = new ConvexHull(set);
	//Get the convex hull point of the outline of the image
	List<Point2D> pointList = convexHull.getConvexHull();
	double[] pointsToDraw = new double[2 * pointList.size()];
	int k = 0;
	for(Point2D p : pointList){
		pointsToDraw[k] = p.getX();
		pointsToDraw[k + 1] = p.getY();
		k += 2;
	}
	return new Polygon( pointsToDraw);
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:21,代码来源:ImageToPolygon.java

示例5: targetSetOnDragDropped

import javafx.geometry.Point2D; //导入方法依赖的package包/类
private void targetSetOnDragDropped(ScreenMap target, DragEvent e) {
	Dragboard db = e.getDragboard();
	boolean success = false;
	if (e.getDragboard().hasImage()) {
		String imageName = db.getString();
		Point2D point = target.sceneToLocal(e.getSceneX(), e.getSceneY());
		GamePoint gameCoords = new GamePoint(point.getX()/target.getScreenWidth(), point.getY()/target.getScreenHeight());
		for (Pair<String, Image> p : myScreenObjects.keySet()) {
			String iName = p.getKey();
			if (imageName.equals(iName)) {
				XStreamHandler xstream = new XStreamHandler();
				File tempSpriteFile = new File("data/tempSprites/tempSprite.xml");
				xstream.saveToFile(myScreenObjects.get(p), tempSpriteFile);
				SpriteMakerModel xmlSprite = (SpriteMakerModel) xstream.getAttributeFromFile(tempSpriteFile);
				xmlSprite.addComponent(new Position(gameCoords, 0)); //heading 0 because all sprites default to this
				myModel.addBackgroundTile(xmlSprite);
				break;
			}
		}
		success = true;
	}
	e.setDropCompleted(success);
	e.consume();
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:25,代码来源:ScreenObjectHolder.java

示例6: latLongToPixel

import javafx.geometry.Point2D; //导入方法依赖的package包/类
public static Point2D latLongToPixel(final Dimension2D MAP_DIMENSION,
                                     final Point2D UPPER_LEFT,
                                     final Point2D LOWER_RIGHT,
                                     final Point2D LOCATION) {
    final double LATITUDE   = LOCATION.getX();
    final double LONGITUDE  = LOCATION.getY();
    final double MAP_WIDTH  = MAP_DIMENSION.getWidth();
    final double MAP_HEIGHT = MAP_DIMENSION.getHeight();

    final double WORLD_MAP_WIDTH = ((MAP_WIDTH / (LOWER_RIGHT.getY() - UPPER_LEFT.getY())) * 360) / (2 * Math.PI);
    final double MAP_OFFSET_Y    = (WORLD_MAP_WIDTH / 2 * Math.log10((1 + Math.sin(Math.toRadians(LOWER_RIGHT.getX()))) / (1 - Math.sin(Math.toRadians(LOWER_RIGHT.getX())))));

    final double X = (LONGITUDE - UPPER_LEFT.getY()) * (MAP_WIDTH / (LOWER_RIGHT.getY() - UPPER_LEFT.getY()));
    final double Y = MAP_HEIGHT - ((WORLD_MAP_WIDTH / 2 * Math.log10((1 + Math.sin(Math.toRadians(LATITUDE))) / (1 - Math.sin(Math.toRadians(LATITUDE))))) - MAP_OFFSET_Y);

    return new Point2D(X, Y);
}
 
开发者ID:HanSolo,项目名称:worldheatmap,代码行数:18,代码来源:Helper.java

示例7: addPointLocal

import javafx.geometry.Point2D; //导入方法依赖的package包/类
private void addPointLocal(Point2D point){
    if(point.getX() == Double.NaN)
        throw new RuntimeException("X value must be a number.");
    if(point.getY() == Double.NaN)
        throw new RuntimeException("Y value must be a number.");
    points.add(point);
    isNormalized = false;
}
 
开发者ID:DrMerfy,项目名称:GraphCreator,代码行数:9,代码来源:LineGraph.java

示例8: renderGraph

import javafx.geometry.Point2D; //导入方法依赖的package包/类
public void renderGraph(){
    //Calculate smooth curve
    //see: https://medium.com/@francoisromain/smooth-a-svg-path-with-cubic-bezier-curves-e37b49d46c74
    Point2D controlStart;
    Point2D controlEnd;
    path += "L"+points.get(0).getX()+","+points.get(0).getY();

    controlStart = getControlPoint(null, points.get(0), points.get(1), false);
    controlEnd = getControlPoint(points.get(0), points.get(1), points.get(2), true);

    path += "C"+controlStart.getX()+","+controlStart.getY()+","+controlEnd.getX()+","+controlEnd.getY()+","+
            points.get(1).getX()+","+points.get(1).getY();


    for(int i = 2; i<points.size()-1; i++) {
        controlStart = getControlPoint(points.get(i - 2), points.get(i - 1), points.get(i), false);
        controlEnd = getControlPoint(points.get(i - 1), points.get(i), points.get(i + 1), true);
        path += "C" + controlStart.getX() + "," + controlStart.getY() + "," + controlEnd.getX() + "," + controlEnd.getY() + "," +
                points.get(i).getX() + "," + points.get(i).getY();
    }

    int last = points.size() - 1;
    controlStart = getControlPoint(points.get(last - 1), points.get(last), null, false);
    controlEnd = getControlPoint(points.get(last), null , null, true);
    path += "C" + controlStart.getX() + "," + controlStart.getY() + "," + controlEnd.getX() + "," + controlEnd.getY() + "," +
            points.get(last).getX() + "," + points.get(last).getY();
}
 
开发者ID:DrMerfy,项目名称:GraphCreator,代码行数:28,代码来源:LineGraph.java

示例9: mouseDraggedHandler

import javafx.geometry.Point2D; //导入方法依赖的package包/类
/**
 * Handles drag events on xAxis.
 *
 * @param event mouse event
 */
private void mouseDraggedHandler(MouseEvent event) {
  Point2D point2D = getView().sceneToLocal(event.getSceneX(), event.getScreenY());
  double newXPosition = point2D.getX();
  double delta = newXPosition - dragState.startXPosition;
  double deltaAsAxis = delta * dragState.screenDistanceToAxisRatio;
  if (dragState.startLowerBound - deltaAsAxis < 0) {
    deltaAsAxis = dragState.startLowerBound;
  }
  NumberAxis xaxis = getView().getXaxis();
  xaxis.setLowerBound(Math.max(dragState.startLowerBound - deltaAsAxis, 0));
  xaxis.setUpperBound(Math.max(dragState.startUpperBound - deltaAsAxis, visibleRange.get()));
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:18,代码来源:TimingDiagramCollectionController.java

示例10: line

import javafx.geometry.Point2D; //导入方法依赖的package包/类
private double[] line(Point2D prevPoint, Point2D point){
    double lengthX = point.getX() - prevPoint.getX();
    double lengthY = point.getY() - prevPoint.getY();

    double length = sqrt(pow(lengthX,2) + pow(lengthY,2));
    double angle = atan2(lengthX, lengthY);

    return new double[]{length, angle};
}
 
开发者ID:DrMerfy,项目名称:GraphCreator,代码行数:10,代码来源:LineGraph.java

示例11: getInsertData

import javafx.geometry.Point2D; //导入方法依赖的package包/类
private InsertData getInsertData(Point2D screenPoint) {
    for(TabPane tabPane : tabPanes) {
        Rectangle2D tabAbsolute = getAbsoluteRect(tabPane);
        if(tabAbsolute.contains(screenPoint)) {
            int tabInsertIndex = 0;
            if(!tabPane.getTabs().isEmpty()) {
                Rectangle2D firstTabRect = getAbsoluteRect(tabPane.getTabs().get(0));
                if(firstTabRect.getMaxY()+60 < screenPoint.getY() || firstTabRect.getMinY() > screenPoint.getY()) {
                    return null;
                }
                Rectangle2D lastTabRect = getAbsoluteRect(tabPane.getTabs().get(tabPane.getTabs().size() - 1));
                if(screenPoint.getX() < (firstTabRect.getMinX() + firstTabRect.getWidth() / 2)) {
                    tabInsertIndex = 0;
                }
                else if(screenPoint.getX() > (lastTabRect.getMaxX() - lastTabRect.getWidth() / 2)) {
                    tabInsertIndex = tabPane.getTabs().size();
                }
                else {
                    for(int i = 0; i < tabPane.getTabs().size() - 1; i++) {
                        Tab leftTab = tabPane.getTabs().get(i);
                        Tab rightTab = tabPane.getTabs().get(i + 1);
                        if(leftTab instanceof DraggableTab && rightTab instanceof DraggableTab) {
                            Rectangle2D leftTabRect = getAbsoluteRect(leftTab);
                            Rectangle2D rightTabRect = getAbsoluteRect(rightTab);
                            if(betweenX(leftTabRect, rightTabRect, screenPoint.getX())) {
                                tabInsertIndex = i + 1;
                                break;
                            }
                        }
                    }
                }
            }
            return new InsertData(tabInsertIndex, tabPane);
        }
    }
    return null;
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:38,代码来源:DraggableTab.java

示例12: moveto

import javafx.geometry.Point2D; //导入方法依赖的package包/类
public void moveto(JSONObject query, JSONObject uriParams, Session session) {
    IJavaFXElement element = null;
    if (query.has("element")) {
        element = session.findElement(query.getString("element"));
    }
    boolean hasOffset = query.has("xoffset");
    if (hasOffset != query.has("yoffset")) {
        throw new MissingCommandParametersException("Missing x-offset or y-offset. Provide both x and y offsets.", null);
    }
    if (element == null && !hasOffset) {
        throw new MissingCommandParametersException("One of the element or offset is expected.", null);
    }
    double xoffset;
    double yoffset;
    if (hasOffset) {
        xoffset = query.getInt("xoffset");
        yoffset = query.getInt("yoffset");
    } else {
        Point2D p = element.getMidpoint();
        xoffset = p.getX();
        yoffset = p.getY();
    }
    if (element == null) {
        if (hasOffset && lastComponenet.element != null) {
            element = lastComponenet.element;
            xoffset += lastComponenet.x;
            yoffset += lastComponenet.y;
        } else {
            element = session.getActiveElement();
        }
    }
    element.moveto(xoffset, yoffset);
    lastComponenet.x = xoffset;
    lastComponenet.y = yoffset;
    lastComponenet.element = element;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:37,代码来源:JavaServer.java

示例13: clickElement

import javafx.geometry.Point2D; //导入方法依赖的package包/类
public void clickElement(JSONObject query, JSONObject uriParams, Session session, IJavaFXElement element) {
    if (lastComponenet.element != null && lastComponenet.element.equals(element)) {
        element.click(0, null, null, 1, lastComponenet.x, lastComponenet.y);
    } else {
        Point2D p = element.getMidpoint();
        element.click(0, null, null, 1, p.getX(), p.getY());
        lastComponenet.element = element;
        lastComponenet.x = p.getX();
        lastComponenet.y = p.getY();
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:JavaServer.java

示例14: compare

import javafx.geometry.Point2D; //导入方法依赖的package包/类
private int compare(Point2D point1, Point2D point2) {
	if(Math.round(point1.getX() - point2.getX())== 0){
		return (int) (point1.getY() - point2.getY());
	}else{
		return (int)(point1.getX() - point2.getX());
	}
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:8,代码来源:ConvexHull.java

示例15: rotatorMouseDragged

import javafx.geometry.Point2D; //导入方法依赖的package包/类
@FXML void rotatorMouseDragged(MouseEvent e) {
    final Parent p = rotator_dial.getParent();
    final Bounds b = rotator_dial.getLayoutBounds();
    final Double centerX = b.getMinX() + (b.getWidth() / 2);
    final Double centerY = b.getMinY() + (b.getHeight() / 2);
    final Point2D center = p.localToParent(centerX, centerY);
    final Point2D mouse = p.localToParent(e.getX(), e.getY());
    final Double deltaX = mouse.getX() - center.getX();
    final Double deltaY = mouse.getY() - center.getY();
    final Double radians = Math.atan2(deltaY, deltaX);
    rotate(Math.toDegrees(radians));
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:13,代码来源:RotatorControl.java


注:本文中的javafx.geometry.Point2D.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。