Here are my last 3 duke dollars.  Can someone please help me draw a line?

I have been BEATING my head on this for well over a week now. I'm new to Java2D and I cannot find even one example of this simple little thing that I am trying to do. Not one.
All I want to do is draw an image, zoom that image, then draw some lines on that image, and then zoom it and have those lines show up where they should.
For example, we have an image which has been zoomed. No lines are yet drawn on it.
A line is added.
The image is then zoomed in or out one more time.
How do we get the line to remap to the newly zoomed image?
What I am doing is:
0) Load up an image from a file.
1) Create a zoomed image by using the Image.getScaledInstance() method.
2) Create a BufferedImage with the width and height of the image AFTER the zoom has taken place.
3) Create a Graphics2D object by the createGraphics from this BufferedImage.
4) Place the image into the BufferedImage by doing a BufferedImage.drawImage
5) Select two points to be the start and end of the line.
6) Draw the line using Graphics2D.drawLine(start.x, start.y, end.x, end.y).
7) Zoom the image again (using the Image.getScaledInstance() method.
8) Create a new ImageIcon using the image from above and override its paintIcon method like this:
ImageIcon newIcon = new ImageIcon(newImage) {                       
public void paintIcon(Component c, Graphics g, int x, int y)
super.paintIcon(c, g, x, y);
zoom(); //<---- ZOOM call
Now in the zoom routine, what do I need to do to get the lines to draw at the proper location and size?
Remember, the points of the lines (stored in a list as home grown line objects) are in screen coordinates, not image coordinates since they are just click points
Note that when I use these points to draw a line, all is well (the line gets drawn where it should), but I have problems when I zoom the image.
Thanks!

Below is the documentation and method signature of
Graphics.drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer);The important thing to note is that it does scaling on the fly if the size dictated by the source co-ordinates is defferent than the size dictated by the destination co-ordinates. The source image is always left un-touched.
So basically your visual data is located in an offscreen image. You can draw a line on that. Then create a new image, get it's graphics and call drawImage(original_image, co-ordinates that cause it to scale how you like).
Then you can draw lines on the 2nd image, create a 3rd, ...etc
     * Draws as much of the specified area of the specified image as is
     * currently available, scaling it on the fly to fit inside the
     * specified area of the destination drawable surface. Transparent pixels
     * do not affect whatever pixels are already there.
     * <p>
     * This method returns immediately in all cases, even if the
     * image area to be drawn has not yet been scaled, dithered, and converted
     * for the current output device.
     * If the current output representation is not yet complete then
     * <code>drawImage</code> returns <code>false</code>. As more of
     * the image becomes available, the process that draws the image notifies
     * the specified image observer.
     * <p>
     * This method always uses the unscaled version of the image
     * to render the scaled rectangle and performs the required
     * scaling on the fly. It does not use a cached, scaled version
     * of the image for this operation. Scaling of the image from source
     * to destination is performed such that the first coordinate
     * of the source rectangle is mapped to the first coordinate of
     * the destination rectangle, and the second source coordinate is
     * mapped to the second destination coordinate. The subimage is
     * scaled and flipped as needed to preserve those mappings.
     * @param       img the specified image to be drawn
     * @param       dx1 the <i>x</i> coordinate of the first corner of the
     *                    destination rectangle.
     * @param       dy1 the <i>y</i> coordinate of the first corner of the
     *                    destination rectangle.
     * @param       dx2 the <i>x</i> coordinate of the second corner of the
     *                    destination rectangle.
     * @param       dy2 the <i>y</i> coordinate of the second corner of the
     *                    destination rectangle.
     * @param       sx1 the <i>x</i> coordinate of the first corner of the
     *                    source rectangle.
     * @param       sy1 the <i>y</i> coordinate of the first corner of the
     *                    source rectangle.
     * @param       sx2 the <i>x</i> coordinate of the second corner of the
     *                    source rectangle.
     * @param       sy2 the <i>y</i> coordinate of the second corner of the
     *                    source rectangle.
     * @param       observer object to be notified as more of the image is
     *                    scaled and converted.
     * @return   <code>true</code> if the current output representation
     *           is complete; <code>false</code> otherwise.
     * @see         java.awt.Image
     * @see         java.awt.image.ImageObserver
     * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
     * @since       JDK1.1
    public abstract boolean drawImage(Image img,
                          int dx1, int dy1, int dx2, int dy2,
                          int sx1, int sy1, int sx2, int sy2,
                          ImageObserver observer);

Similar Messages

Maybe you are looking for

  • Bar Charts with Non-Stacked Subgroups

    I'm trying to create a report in CR2008 for my elementary school principals that will display how many students received a specific grade each of the three marking periods (T1, T2, and T3) per grade level per subject area (Math, PE, etc.).  I was abl

  • User cannot retrieve data in app on local PC

    A certain user cannot retrieve data in one application whilst being able to send data in that application. She can access the 'Finance' application, send data in that application and retrieve data but in another application, 'ICM', she cannot retriev

  • My lumia 720

    My Lumia 720 is giving me headache. Sometimes in the middle of reding or doing something, it freezes and you can't do anything even to switch off. It will freeze for few minutes and end up working when it feels like. Irritating.

  • Cisco Enterprise Attendant Console 8.0 - Second Console Queue

    Hello Guys, We have 1 reception console in the head office and we want to setup 2nd reception console in different location (London). we have 2 operators license on CUEAC, I setup second operator with a seperat queue. We want to redirect the calls to

  • Role problems using RIMLoginModule

    Hi all, we are currently trying to execute an web application using the RIMLoginModule with a blackberry. For this reason, we have to configure the module on: http://servername:port/webdynpro/dispatcher/sap.com/mba~com.sap.mbs.mso.main/MSOMain Unfort