本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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();
}
示例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()));
}
示例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};
}
示例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;
}
示例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;
}
示例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();
}
}
示例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());
}
}
示例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));
}