Drawing Interactive Paths In JavaFx 8?
Aug 6, 2014
I am trying to make a GUI that allows the user to input the NumberLink puzzle (through mouse action events), and then, displays the puzzle in a grid with features to draw a path, and undo it. This is almost exactly the same functionality as in Numberlink on Nikoli
1. In my project, I have a Stage in which a setup scene prompts user for rows and columns (to take size of puzzle),
2. Then, it generates an empty grid (I'm thinking of using a GridPane here), and the user clicks the squares to enter the numbers into the square. this phase isnt a problem if I use text fields and mouse listeners and store info in a grid... the next phase is what I'm stuck at... unless I know exactly how to do that, I cant make progress...
3. In the third stage, I have to display the numbers to the user just like on the Nikoli site (the highlighting number pairs on mouse hover is a necessary feature too, which I think I can handle with CSS).. and the user should draw paths between the numbers, just as on that site ( I thought VLineTo and HLineTo classes would be suitable.. but I'm not sure, and cant find any alternatives) .....
So with this in mind, I made FXML based dummy gui layouts to test if my ideas work... And I cant get the GridPane to have lines drawing atop it (meaning, I cant place Line objects like HLine on top of the grid panes).... is there any other way to do what I need to do ? I also thought of making canvases in a grid (each square is its own canvas)
How I can implement a user inputted path drawing ??
View Replies
ADVERTISEMENT
Apr 28, 2015
Is there some way to create compound shapes/paths in JavaFX?
For the record I'm not implying the use of the methods intersect, subtract, or union. These produce other shapes. A compound shape/path is one that has a knockout of some sort. For instance, a circle within a circle, such as in a 2d donut shape. Alternatives do not include a circle with a thick stroke nor an overlayed circle with the background color. Specifically, JavaFX supports the FillRule, in the case of the Path object. However, there doesn't appear to be an "add" method as there was in the Area shape in Swing.
View Replies
View Related
Jul 15, 2014
I am subclassing a Pane to be able to use my custom NGRegion:
public class MyPane extends Pane {
@Override
public NGNode impl_createPeer() {
return new MyNGRegion();
}
}
in MyNGRegion i override renderContent(Graphics g) for custom drawing
@Override
protected void renderContent(Graphics g) {
/* custom drawing */
}
The custom NGRegion gets drawn one time, but i want to continuously draw on every pulse.
i already tried a lot of things, but don't see how to do it properly:
using -Dprism.forcerepaint=true did not work.
overriding clearDirty() and set it
View Replies
View Related
Nov 16, 2014
I'm trying to write a program the simulates the time delay of an elevator door and I want to know how I can add an interactive time in delay in Java.
I know that this is how you delay a Java program:
try {
Thread.sleep(60000);
}
catch(InterruptedException ex) {
}
But how can I make it so that the user can make the timer last longer or end faster through user input.
View Replies
View Related
Feb 24, 2014
How can i make interactive chat like GMAIL, FACEBOOK.
Can it possible .. using ajax that frequently updating a portion/part/ chat box.
If we do in this way, I am sure our server will be overloaded.
View Replies
View Related
Nov 20, 2014
I know what the tree data structure is, how it works, etc., but I need to design a method that will sequentially print out all the paths in the tree (i.e. for each node).
The method as provided is
private static String getAllPaths(final BinaryNodeInterface<Character> root) { }
Now the string that must be returned needs to be of the format:
root.getData() + " " + path + "
"
root.getData()[1] + " " + path[1] + "
"
etc.
The pseudocode I was thinking of doing was something along the lines of:
paths
if(root.getData() = null) return paths;
path = ?; // absolutely no clue what to do here
paths += root.getData() + " " + path + "
";
if(root.hasLeftChild()) {
newPath += "0";
paths += begin recursion;
}
if(root.hasRightChild()) {
newPath += "1";
paths += begin recursion;
}
return paths;
Problems:
(1) I don't know how to determine "path" before the left and right children check (the root node's path is "", the first left node's path is "0", the first right node's path is "1", pattern continues with left being "0" and right being "1").
(2) I don't know where to put newlines precisely.
(3) I'm not sure how to get the print layout precisely as it is supposed to be. At most I've been able to just get the last number in the sequence (i.e. if it was supposed to be "1000", I could get "0".
I am working with the pseudocode formulation, especially in regards to the logic and formatting. I think once I have an understanding of what is going on, I can solve it. And yes, I've gone through a couple pseudocode rewrites (a few hours worth) and haven't gotten anywhere which is slightly unnerving.
View Replies
View Related
Apr 25, 2014
I can't get Relative paths to work. I have created the class.dat file and I can't get java to recognize it. I am using Eclipse as an IDE. Was wondering if I could get Eclipse to recognize it. I tried with a .txt file as well and couldn't get that to work.
import java.io.*;
public class ReadBytes
{
public static void main(String[] args)
{
try
{
FileInputStream file = new FileInputStream("class.dat");
[Code] .....
View Replies
View Related
Sep 14, 2014
I print a path like below with iteration. It is redundant as you see. How can I remove the redundant path? im using arrayList .
1. [0, 1]
2. [0, 1, 2]
3. [0, 1, 3]
4. [0, 1, 3, 4]
View Replies
View Related
May 1, 2014
So I downloaded jgrasp and eclipse on a new computer and am trying to figure out how their filing/path system works.In eclipse I created a new project under which I've imported all my files for my comp sci class, so they're all under this one project which is my only project. I attached a pic of what my eclipse workspace looks like. In this project folder is a file I'm trying to run.
I keep getting an error saying "editor" does not contain a main type.When I change my class name to the project folder I end up getting an option to run the program as an applet or an application, but either one I choose I get the same error message. In the bottom it gives me a warning saying
DescriptionResourcePathLocationType
Build path specifies execution environment CDC-1.1/Foundation-1.1. There are no JREs installed in the workspace that are strictly compatible with this environment. CS1050AssignmentsBuild pathJRE System Library Problem
I tried running the program in jgrasp and got this error
----jGRASP wedge2 error: command "javac" not found.
---- This command must be in the current working directory or
---- on the current system PATH or jGRASP PATH to use this function.
---- System + jGRASP PATH is "C:UsersQudrat.MommandiDocuments;C:Windowssystem32;C:Program Files (x86)InteliCLS Client;C:Progra
[code]...
I have the JDK installed in program files, I have the correct versions of eclipse and Jgrasp, and have uninstalled / reinstalled the JDK/Jgrasp/Eclipse so I don't know what the problem is?
View Replies
View Related
May 5, 2015
Is it possible to find the number of paths between two nodes in a directed graph using an adjacency matrix? I know how to find all said paths of a given length by using matrix exponentiation, but I don't know how to find all the paths. The professor didn't note it in the assignment but I assume she meant all simple paths because this is a cyclic graph, so there's a potentially infinite number of paths.
I'm thinking I should use matrix exponentiation to find the number of paths of lengths 1 to n-1, where n is the number of nodes in the graph. Then add the number of paths for each length together. Would this work?
View Replies
View Related
Oct 18, 2014
I've been pondering about this algorithm for about a week but I'm still not able to write a "fast" working method/algorithm to solve the Number-of-paths-exercise we were given in my class />
So here's the task:
Write an efficient java program "Paths" which solves the following task:
- Read input n ∈ N and give output a(n) which is the number of paths from (0,0) to (n,0)
it is not allowed to go over the diagonal (m,m) and also not below the x-axis (m,0)
Here are the allowed steps:
u = (1,1), U = (1,4), d = (1,−1), D = (1,−4) and H = (1,0)
steps are performed in a two-dimensional-coordinate-system!
View Replies
View Related
Apr 12, 2014
From a two-dimensional grid 5x5 that looks like this:
(0,0)(0,1)(0,2)(0,3)(0,4)
(1,0)(1,1)(1,2)(1,3)(1,4)
(2,0)(2,1)(2,2)(2,3)(2,4)
(3,0)(3,1)(3,2)(3,3)(3,4)
(4,0)(4,1)(4,2)(4,3)(4,4)
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)
Example: paths:(3,0)(2,0)(1,0)(1,1)(1,2)(1,3)
(3,0)(2,0)(2,1)(1,1)(1,2)(1,3)
etc...
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);
int [][] path = new int[size][size];
grid(path,x1,y1,x2,y2);
[code].....
View Replies
View Related
Apr 12, 2014
From a two-dimensional grid 5x5 that looks like this:
(0,0)(0,1)(0,2)(0,3)(0,4)
(1,0)(1,1)(1,2)(1,3)(1,4)
(2,0)(2,1)(2,2)(2,3)(2,4)
(3,0)(3,1)(3,2)(3,3)(3,4)
(4,0)(4,1)(4,2)(4,3)(4,4)
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)
Example: paths:(3,0)(2,0)(1,0)(1,1)(1,2)(1,3)
(3,0)(2,0)(2,1)(1,1)(1,2)(1,3)
etc...
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);
[Code] ....
View Replies
View Related
Jun 4, 2014
I am using Oracle Java 8 in Eclipse working on both Ubuntu and OSX. I have this code:
Java Code:
private static String getConfigDir(){
Path configDir = Paths.get(homeDir(), homeConfig(), appName());
return configDir.toString();
[code]...
But for the method get() of Paths, I get this error in eclipse.The method get(String, String[]) in the type Paths is not applicable for the argument..Yet on the Oracle documentation site, it uses a similar example:
Path p5 = Paths.get(System.getProperty("user.home"),"logs", "foo.log");
View Replies
View Related
Jun 5, 2014
I use git as my SCM and I use both Ubuntu and Mac OSX. The home directory of the two operating systems are different and there lies the problem. When I commit the .classpath to version control, it looks something like this:
Java Code:
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/Users/MyUser/Documents/github/Gateway/GDGateway/java-json.jar"/>
<classpathentry kind="lib" path="/Users/MyUser/Documents/github/Gateway/GDGateway/postgresql-9.3-1101.jdbc41.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath> mh_sh_highlight_all('java');
Now when I update my project on Ubuntu. I have to change the build path again because it is referencing paths on OSX. And this goes back and forth. Rather than remove this file from git with .gitignore, I'd prefer to use a global environment variable like as follows:
Java Code:
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="$HOME/Documents/github/Gateway/GDGateway/java-json.jar"/>
<classpathentry kind="lib" path="$HOME/Documents/github/Gateway/GDGateway/postgresql-9.3-1101.jdbc41.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath> mh_sh_highlight_all('java');
Is this possible?
View Replies
View Related
Nov 16, 2012
I am developing an web application with servlets and jsp. I have an issue to store images. I am storing images in folder and their relative path's in mysql database.
When I retrieve path from database then using <IMG> tag i have displayed image like:
out.println("<td><img src="+user.getPlaceImage()+" width='70' height='50' /></td>");
It is working fine with internet explorer but not working (that is Not displaying image) in chrome/mozilla.
How to display that image in all browsers....
View Replies
View Related
Jul 14, 2014
I'm trying to draw an image in grayscale. This is my code:
Java Code:
public void paintComponent(Graphics g) {
super.paintComponent(g);
setOpaque(true);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
Graphics g1 = image.getGraphics();
g1.drawImage(CardData.CARD_ART[cardID], 0, 0, null);
g1.dispose();
setOpaque(false);
} mh_sh_highlight_all('java');
For some reason, nothing displays.
View Replies
View Related
May 28, 2014
I have to write a program for class that basically uses Paint Component to draw a bunch of rectangles to look like a building then have them change color randomly. I am stuck I can't figure out how to make it draw the rectangles in rows and columns to look like the building i can make it display multiple squares randomly however but thats not the assignment.. here is my code
package labBuilding;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class Building extends JPanel {
[code]....
View Replies
View Related
May 1, 2014
import java.awt.*;
public class Program5 {
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(300,500);
panel.setBackground(Color.white);
Graphics g = panel.getGraphics();
g.setFont(new Font("Helvetica", Font.PLAIN, 12));
double ball = 10;
[code]....
I'm fairly new to Java and am having a hard time with this particular assignment. The program runs and shows up on the drawing panel fine but I can't get the lines quite right.Capture.jpg
View Replies
View Related
Apr 21, 2014
I've got a question about drawing animations in Java (SWT). I try to draw an animation of some process.
When i use canvas.redraw() it seems like program firstly erases everything that has been drawn and then draws again.
My program draws about 1000 of rectangles per time step so animation doesn't looks smooth - it blinks all the time and I can't avoid drawing that many rectangles.
Is there a way to make it look smoother (for example to paint new objects over old ones, without erasing them)?
I won't paste code, it's rather large.
View Replies
View Related
Feb 17, 2014
I have a problem which can't solve it for 2 days search. I need to draw 3d shapes , i downloaded all packages and set an example code and run it ...
Exception in thread "main" java.lang.UnsatisfiedLinkError: no J3D in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
[Code] ....
View Replies
View Related
Apr 23, 2015
solve my problems regarding drawings on my JPanel(Transparent panel).My Jframe & other components are created by netbeans GUI builder & the transparent panel is created manually but one problem is that i can't impose this Transparent panel into JFrame like it is attached to the JFrame.Another problem is that,i want that transparent panel size should be counted in inch like my attached picture(TOTAL SIze 36 inch) & also when i clicked on that panel those mouse points highest distance should be measured in Inch.How can i do all of these three task??
View Replies
View Related
Jun 17, 2014
I have a question about the execution of code to draw images relative to code that comes after that. I don't normally do this sort of thinghere's the problematic code:
int stn = 0;
while (stn < 10)
{
glb1.xOfText += 20;
glb1.yOfText += 20;
gc1.drawImage(glb1.img1 , glb1.xOfText , glb1.yOfText);
TimeKeeper.pause(500);
stn++;
}
Where glb1 is a final reference to an object that holds common data for the game.while its x and y values say they are for text, they are also used for image placement (at least during this testing phase.)
gc1 is the "graphics context" of the canvas that the images are being drawn on.
The person who wrote this said, "When the attached code is run, the calls to TimeKeeper.pause(500), which in turn call Thread.sleep(500), are all executed in row, and then the results of drawing the image 10 times is displayed. (I know because some of the previous image pastes left some visual data behind.)"
I recall from reading about drawing graphics (a long time ago) that drawImage() could take time, but I don't know why the thread does not indeed sleep between calls to drawImage().
View Replies
View Related
Dec 20, 2014
how to phrase the question. I created a small applet in java.. it allows me to move a toon around a blank applet window. I am using four gif files that have a walking animation in them. The issue i am having is after moving around the gif just flashes in and out really quickly.. when i start the program, moving up and down seems to be working perfectly fine, but the moment i move left or right it starts messing up for all directions. here is my code.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CharactorMove extends JApplet implements KeyListener
[code]....
View Replies
View Related
Feb 7, 2014
I am trying to draw an image unto the screen, however, nothing appears...
Java Code:
private ImageIcon i = new ImageIcon("image.png");
private Image image;
...
image = i.getImage();
...
g.drawImage(image, (int)(x - r), (int)(y - r), null); mh_sh_highlight_all('java');
Am I doing it right? The program gives me no error, it's just that when I try to draw it, I see nothing.
View Replies
View Related
Mar 17, 2014
I am having issues with drawing shapes from bottom right to top left.
Issue:
- g.drawRect() will show like I am calling g.fillRect()
- other shapes will not even show the shape in that area
Needs:
- g.drawSHAPE needs to show and not be filled unless I have my fill checkbox selected
The Program:
- Create a JFrame with a draw panel and a component panel
- have a combobox with shapes that, when selected, will draw that shape in the draw panel
- have a button that, when clicked, will launch JColorChooser to change the color of the drawn shape (draw panel is set to black)
- have a checkbox that, when checked, fills the shape
- have mouse listeners to adjust X and Y and will instantly update the shapes size to where you drag/click/press/release
Code for my drawRect():
Java Code:
// if statement to check if mouse drag X is less than starting X
if(x2 <= x){
if(emptyORfill.isSelected()) // emptyORfill is my JCheckBox
g.fillRect(x2, y, x-x2, y2-y); // x-x2 is the same as Math.abs(x2-x)
else
g.drawRect(x2, y, x-x2, y2-y);
[Code] .....
This is just for my Rectangle. This will show a filled rectangle when both mouse drag X and Y are less then the starting X and Y. If I take this fully functional code and adapt it to drawRoundRect(), the round rectangle wont even show the shape when mouse drag X and Y are less than the starting X and Y but will be fine if one or the other is less than the starting X or Y. NOTE: This same exact code worked on my classmates laptop in her program, but in my program on her laptop it did not. She took out the "else" in the else if's and just made them if statements all the way down and it worked on her laptop in my program, but the same "fix" did not work on my pc.
My mouse listener just sets X and Y values in my Shape class that updates my shape methods. I have an item listener for my comboBox that sets default values when a new selection is made and enables/disables editable on my fill checkbox for certain shapes. My action listener looks for the button click and the checkBox click.
View Replies
View Related