Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Plotting dots on Canvas and adding/removing them

Posted on 2006-06-14
5
Medium Priority
?
453 Views
Last Modified: 2010-03-31
I was able to create an applet with a canvas and an Image display over the canvas. I also created an interactive feature that lets me mark red dots over the canvas (on top of image). Now, I want to create a feature that also lets me remove an existing dot.. like how they do it in Flash editor, removing a vector graphics by highlighting or clicking it and pressing delete. Can anyone give me some techniques on how to do it?
0
Comment
Question by:ibo
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16909035
You need to keep a list of dots to be painted. Add a MouseListener and if one of the dots, say, is right-clicked, remove it from the list and call repaint
0
 
LVL 3

Author Comment

by:ibo
ID: 16909125
I already have a list of locations of the dots. The part missing is how to implement the "right-click to remove" feature. How do I go about that? Do I just read the location for a red pixel? I know it wont work because underneath is an image which can have any kind of picture/color. Also, the dot is not a 1x1 pixel, but can vary in size, ie. a filled circle with a radius of 5 pixels. Is there an exisiting technique how to implement this kind of problem? Im concerned with overlapping dots too.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 320 total points
ID: 16909138
What's underneath is immaterial. If the dots are not 1 pixel in diameter then you need to keep a record of their bounds. I suggest the following:

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Shape.html

See the contains method
0
 
LVL 3

Author Comment

by:ibo
ID: 16909226
I think thats what im looking for.. to be able to determine that a marked point is inside the boundary of the dot.
hmm what if a location hits two (or more) intersecting dots? I guess Ill have to choose the latest dot plotted right?. Thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16909272
:-)

>>I guess Ill have to choose the latest dot plotted right?. Thanks.

Possibly
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question