Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Plotting dots on Canvas and adding/removing them

Posted on 2006-06-14
5
Medium Priority
?
450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

670 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