I have a shape, Polygon (javafx.scene.shape.Polygon) and want to test whether a point (javafx.geometry.point2D) is contained within the shape. (contains doesn't work)
I can change the polygon to any type, but I need to be able to create it using the 4 corners points and add it as a child to the Pane.
I'm trying to implement a two finger gesture to move a control for a touch screen. However simply touching the screen with two fingers will generate several events that jump all over the place. This here is the code:
Two finger move pressed First layout: 100.0, 100.0 Move by 94.0, 209.0 event set=4 Move by 1.0, 0.0 event set=5 Move by 95.0, 208.0 event set=6 Move by 1.0, 1.0 event set=8 Move by 96.0, 208.0 event set=11 Move by 219.0, 147.0 event set=11 Move by -121.0, 61.0 event set=13
I know that there is the possibility that I get multiple events with the same event set id. However this is not always the case. I would have expected to get one for each of the finger in the gesture. Why is that? As I understand the difference between changing the layout coordinates and the transformation is, that with the transformation coordinates, the bounds in parent changes, but not the bounds itself.
I'm not entirely clear on what effect this has, especially as I will also have the zoom and rotate gesture on the component. Which one is the better choice to change?To my understanding the coordinates of the touchpoint are relative to the parent component. In this case the layout coordinates of the rectangle. This would mean that I have to calculate the delta of the touch point in the onTouchMoved to the touch point of onTouchPressed.
This would get me the vector the rectangle moved.In the above example I use the main touch point of the two touchpoints of the event. As I understand it this should always be the same one. The correct way would be to calculate the geometric mean of the two points and use that, but that has the same effect. Simplifying the above example to one touch point only shows the same jumping behavior.
We are doing a visualisation tool for point cloud research project. We use 3d sphere to represent each single point and when we have large number of points to display (~40,000), the rotation becomes very lagging.
What we have tried:
set JVM flag -Djavafx.animation.fullspeed=true, this worked a bit, but not significant.set JVM flag -Djavafx.autoproxy.disable=true, this did not work.
set Cache to true and CacheHint to Cache.SPEED, this did not make much difference.create another thread to do the rotation, and sync back after calculation, this did not work neither.
I have a combo box inside a table cell for each row. I have defined a value change listener for each combobox. Whenever the combo box value is changed, the selected item is placed inside a MAPVOBean. The problem i am facing is when the user scrolls Up and down the tableview , the change listener is fired even without clicking on it the explicitly, and this changes the my value in my data structure. How to handle this. The source code is attached.
My Model:
Person class
Has first name, last name and MAPVOBean.
Address is stored in a MAPVOBean. It has a map and key is house number and the value is the state where the house is. It is assumed that the person can have one house in each state.
Columns in table view:
Column 1: First Name Column 2: Last name Column 3: State combo box. This shows the state in which the person owns a house.
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package taleviewtester; import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader;
I was reading the oracle java tutorial under: URL....Here's the code for the Point class:
public class Point { public int x = 0; public int y = 0; //constructor public Point(int a, int b) { x = a; y = b; } }
and in the Rectangle class you have the following constructor:
public Rectangle(Point p, int w, int h) { origin = p; width = w; height = h;
If we create a new Point object like this:
Point originOne = new Point(23, 94);
and then a new Rectangle object like this:
Rectangle rectOne = new Rectangle(originOne, 100, 200);
Will that set originOne to point to the object Point at (23, 94). just want to make that this is the meaning of this statement: Point(Point p)Constructs and initializes a point with the same location as the specified Point object.
I'm working on is to create a program to display an n-sided regular polygon and uses two buttons named +1 and -1 to increase or decrease the size of the polygon. Also enable the the user to increase or decrease the size by clicking the right or left mouse button and by pressing the UP and DOWN arrow keys. So, first off I'm just trying to figure out how to display an n-sided polygon. I have some of the other components started, but I'm just trying to focus on getting this to work.
I have a java program which rotates a rectangular polygon. My program is having a problem. As soon as it starts rotating, it shrinks. The polygon is rotating perfectly though. I am trying but unable to figure out the cause.Main class which has an infinite loop (game loop) to rotate polygon continuously :-Java Code:
I have a method that draws a polygon on the screen:
public void poly(List<Point> points) { //code }
For the usage of the method, it makes no difference whether points is an array or a List. In fact, switching doesn't even change any of the code in the method since I use a for-each loop. So, my question is, is it a better practice to use a List as an argument, or an array when the method itself doesn't care about which to use?
I am making a tile based top-down 2D RPG and am using Box2D for the physics. Since my game is tile-based, there are many tiles on each map that cannot be moved through. This results in many small individual Box2D bodies. This is obviously very inefficient and makes the game lag. Therefore I figured that combining the individual tiles' bodies into larger complex groups would be better.
The way I thought of doing it is to, first, group together tiles into groups of tiles that all share 2 vertices with at least one other tile in the group. Then, for each group I do the following. First I get all of the uncommon vertices (these should be the ones on the outside of the polygon). Then I connect all of those vertices and then remove all of the overlapping lines. This should result in only lines on the outside of the polygon. Then I sort the lines so that the first line in the sorted array shares its end point with the second line's start point, etc. Then I remove the doubled vertices and using those remaining vertices (I called them the "true vertices") I create the polygon. I know that Box2D only supports convex polygons, but with Box2DSeparator I should be able to do this, but I first want this method to actually work.
/** * Attempts to combine the given blocks into larger bodies to improve performance. * @param bs The created wall blocks. * @param w The world. Used for body creation. */ private void makeLargeBodies(Block[][] bs, World w) { Array<Tile> tiles = new Array<Tile>(); for(int i = 0; i < bs.length; i++) {
[Code] .....
However, this is where the first problem arises. This method is extremely slow for large maps (like 200x200 tiles). I have worked at this for very long and right now my head can't figure out how to make the loop more efficient...
Now for the next part. After that I attempt to create the bodies for the TileGroups:
//create all the groups' bodies size = groups.size; System.out.println(size + " groups"); for(int i = 0; i < size; i++) { TileGroup g = groups.get(i); System.out.println("Starting group " + i + "."); long timeCheck = TimeUtils.millis(); g.createBody(w); System.out.println("Group 0 took " + (TimeUtils.millis() - timeCheck) + " millis"); }
*Note that the printing is for debugging purposes*...
This method is probably not a problem; it is what is inside createBody(World) that is the issue...
public void createBody(World w) { Array<Vector2> allVertices = new Array<Vector2>(); Array<Vector2> uncommonVertices = new Array<Vector2>(); System.out.print("Starting search for uncommon vertices. "); long timeCheck = TimeUtils.millis();
[Code] .....
Most of the code is self-explanatory (with comments). My current issue is where I connect the uncommon vertices (see the printed statements). This method does not actually finish (I have let it run for several minutes and it does not complete). This is likely due to a large number of vertices (often around 3000 in a 60x60 map), but I cannot figure out how to make the loop more efficient... Because of this early failure I don't know if the rest of the method works, both physically and in theory.
All relevant classes (Tile, TileGroup, Line) are below:
private class Tile { private Vector2[] vertices; private TileGroup group; public Tile(int x, int y) { vertices = new Vector2[4];
My code is giving me an error at the main method and it says that modifier 'static' is not allowed in constant variable declarations. every program that i searched for had the same code line but none had the problem i do.
I am new to javafx I start using it instead of swing i used the scene builder for my forms the problem i faced i don't know how to have main screen with menu bar at top and depending the select from the menu it will open other windows and those window must be inside my window just like for example netbeans.
I don't need to open new window in separate i need all windows inside my main window and controlling over them minimize maximize perhaps.
I made a blackjack code in java and I need to find a way to replace the place where I added a system.exit with a way to ask the user if they'd like to play again and restart the loop, keep in mind that I don't need the program to restart as I'd like to keep the value of their chips considering if they've won or lost.
Secondly, because it is a blackjack code, when it deals the cards, I would like for it to also print out K, Q or J but still consider it the number 11. Can I make an Ace count as 1 and 11?
One last question, is there anyway to add the suits of the cards such as (clubs, spades etc.) but the actual signs and if the signs aren't possible at all then the letter ('C', 'S', 'H', 'J') will have to do I guess.
import java.util.Scanner; class Blackjack { public static void main(String[] args) { Scanner scan = new Scanner (System.in); Scanner num = new Scanner (System.in); System.out.println("Welcome to Blackjack!");
how the data is stored in float. It seems like the range would be greater because it stores scientific notation rather than plain value, whilst integer arithmetic performance is better. float should be used to store bigger values and integer should be used for speed when values are smaller. As an example, I want to have cubic volumes ranging from about a handful to cargo ship. So float would be necessary for that.
designing a program which allows you to buy stuff from the jframe with 10x items each with different pricing, so once you click the image button the cost of that is displayed in the textfield, ive been trying to set the jtextfield to a decimal point but have not been able to so far,
jTotal.setText(Double.toString(dTotal)); DecimalFormat myFormatter = new DecimalFormat("#####.#"); String output = myFormatter.format(dTotal); a visual aspect of it.
What are the x- and y-coordinates of the Points referred to as p1, p2, and p3 after the following code executes? Give your answer as an x-y pair such as (0, 0). Recall that Points and other objects use reference semantics.
PHP Code:
Point p1 = new Point(); p1.x = 17; p1.y = 9; Point p2 = new Point(); p2.x = 4; p2.y = -1; Point p3 = p2; p1.translate(3, 1); p2.x = 50; p3.translate(-4, 5); mh_sh_highlight_all('php');
I need to fill up 1/10th of the board with mines but i am only able to successfully put 1! also my goal is not showing up on the game even though i put it as an up arrow.
package Homework4; import java.util.Random; import java.util.Scanner; public class HW4 { //Creates a new type to be used to create the board
We have Starting point that is (3,0) and an ending point is (1,3). We can only move up and right to get to the ending point by using recursion. We have to list all possible paths from (3,0) to (1,3)
We have Starting point that is (3,0) and an ending point is (1,3). We can only move up and right to get to the ending point by using recursion. We have to list all possible paths from (3,0) to (1,3)
I was able to get from (3,0) to (1,3) but how to list the other paths. This is my code so far
public class Program7 { public static void main(String[] args){ int size = 5; int x1 = 3; int y1 = 0; int x2 = 1; int y2 = 3; System.out.println(x1+" "+y1); System.out.println(x2+" "+y2);
//Design/write a class named MyPoint to represent a point with x and y coordinates. The class should contain:
//->Two variables, x and y, that represent the coordinates //->A no-arg constructor that creates a point (0,0) //->A constructor that constructs a point with specified coordinates //->Two getter (accessor) methods for the variables x and y //-> A method named distance that returns the distance from a point to another point of the MyPoint type //-> A method named distance that returns the distance from a point to another point with specified x and y coordinates. //Draw the UML Diagram for the class. Implement the class. Write a test program that creates two points (0,0) and (10, 30.5) and displays the distance between them.
I have written the program but not I have to do it with user input ....
class MyPoint { private double x; private double y; public double getx() { return x; } public double gety()