• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Drawing program: have to calculate lines?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

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!

 
Steven D'Addario
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just realized the video I linked above isn't very clear in showing the dotted lines. This one is better. Sorry.

 
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Steven D'Addario
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Knute Snortum
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is a simple drawing program that doesn't leave dotted lines when you draw.  Does this help?  
 
Steven D'Addario
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic