Properties of Object being dragged


I am dragging a custom image object from a palette to a view. Images in palette are standard 50x50 in size. When I drag to the view, i want to show the image being dragged in its original size and also drop in the view as original size (i pull the width and height from the tag and store as a variable in the image object)

I have overridden dragEnter, dragOver, dragExit and drop methods on the view.

But the value of originalSize variable is null during the drag. I am able to get correct values for other fields though. This is how i am getting the handle of the object being dragged.

DataFlavor localDataFlavor = JGoDocument.getStandardDataFlavor();

Transferable localTransferable = e.getTransferable();

Object localObject1 = localTransferable.getTransferData(localDataFlavor);

JGoObjectSimpleCollection localJGoObjectSimpleCollection = (JGoObjectSimpleCollection)localObject1;

JGoListPosition pos = localJGoObjectSimpleCollection.getFirstObjectPos();

while (pos != null) {

JGoObject obj = localJGoObjectSimpleCollection.getObjectAtPos(pos);

pos = localJGoObjectSimpleCollection.getNextObjectPosAtTop(pos);


if (obj instanceof RotSVGImage){

RotSVGImage img = (RotSVGImage)obj;

System.out.println(img.getSize()); // return correct value

System.out.println(img.getURL()); // return correct value

System.out.println(img.getOriginalSize()); // returns NULL


}//end while

And yes i have overridden the copyObject to include

newobj.originalSize = originalSize;

Can someone tell me why getOriginalSize() returns null and not the getSize()



I’m assuming that your RotSVGImage class inherits from SVGImage (which inherits from JGoImage).

I'm not seeing a getOriginalSize() method in SVGImage or in JGoImage. JGoImage does have a getNaturalSize() method. This method will return the Dimension myNaturalSize if it has been set by your application. Otherwise it will return the size returned by myImage.getHeight() and myImage.getWidth(). Note that myImage is a member of JGoImage rather than the JGoImage itself.

Oh, ok.

I always thought getNaturalSize() works even if my application did not set it, because I did not see a setNaturalSize() anywhere. Hence I implemented the concept of originalSize.

Now i know “This method will return the Dimension myNaturalSize if it has been set by your application”

I overrid getNaturalSize and get the DOM of the loaded SVG file and get the value from tag <svg width=“x” height=“y”…

since there is no extra user specified attributes/fields the data is preserved during the drag and i can get the NaturalSize in my dragOver method. and it works like a charm.