• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

draw data points on existing image

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all.
i have a requirement where i have an image which is off specific size.

i have to superimpose some data points on it for example

i have a front facade of a house. i want to have dots on the front window, front door if someone clicks on it or hovers over it should display some info

can you please suggest some technology how to do it

Thanks

 
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Easily done in Java, especially if you don't need to do anything other than put a dot or X where the mouse clicks.

Load the image and you can write directly to the image if you load it as a BufferedImage. Look at that API and you can see that you can get the Graphics object of a BufferedImage. Java uses the Graphics object to do any graphic functions so look at the API for Graphics.

You can load the image using ImageIO from the javax library. You can do a draw Image onto a JPanel Graphics object by overriding paintComponet of a JPanel. Other than those things you'll just need to use MouseListener to get the click event to show the coordinates to where the mouse position was when it was clicked.

Algo:

load the image into a BufferedImage using ImageIO.
make a custom JPanel (extend JPanel) and override the paintComponent.
use the Graphics object of the JPanel to do paint the image onto the JPanel background (drawImage)
use the MouseListener to get the click event to get where the mouse pointer position was when it was clicked.
draw the "X" or whatever onto the BufferedImage
call repaint on your JPanel so your updated image will be drawn on the background
go get an A on your assignment
reply
    Bookmark Topic Watch Topic
  • New Topic