Earlier this year my Java Collections professor gave us some freedom in letting us design our own javafx application for the final. I chose to make a flash card program that lets you both type and draw on the card and saves the cards and decks in text files. A problem I came across was that the program didn't seem able to keep up with mouse unless you draw relatively slow, but instead would skip spots making dotted lines. I decided to program it so that when the mouse was released it calculated and filled in all the empty spots into full lines. Because this was a last minute thing I didn't have enough time to get the program to fill in the lines perfectly, so After the term ended I decided to make a drawing program that did just that. I also made the lines interactive and used basic math to implement line scaling etc. Its very buggy and small at the moment and kind of a sandbox for me to try out stuff , but in the near future I'd like to make some kind of cool drawing program to start building a portfolio, and before I rewrite the program to calculate the points while the user is drawing (instead of leaving a dotted mess until they release the mouse), I wanted to make sure that I'm not missing something as to why Javafx isn't keeping up with the mouse in creating rectangle objects.
Sorry for the long read. I have a video of my dinky drawing program below. Thanks for your time!
Knute Snortum wrote:So is your question that you want to know how to create a line drawing program in JavaFX that doesn't use this dotted line trick?
Thanks for replying Knute. Im more trying to confirm that this calculation is needed and that the reason javafx leaves dotted lines when I set the handler to create rectangle inherited objects as the mouse drags is that it really isn't fast enough to to do that. I believe I did try setting the handler to check the distance from the last made rectangle to make sure it wasn't creating a rectangle for every fraction of a pixel but that didn't help as I recall.
Also sorry for not being clear in my original post as to what I was asking.
Yes, it is very helpful. Thank you Knute! I only learned a little bit of javafx in class so I don't know a number of these classes like Canvas and GraphicsContext. My concern was that I was going to go ahead and spend time making a drawing program and wind up with something that that worked right but was kind of stupid and did things javafx already provided the code to do. Thanks again!
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss