Do mouse down makes objects rescale

I’ve been struggling with this for a few days now and I really don’t know what to do anymore. I’m using JGo for Java, version 5.30.
I have created a JGoIconincNode and a JGoBasicNode, and to each of them I added an extra JGoPort that has as port object a JGoImage. Here is a piece of code:

    JGoPort port = new JGoPort();
    port.setFromSpot(JGoPort.NoSpot);
    port.setToSpot(JGoPort.NoSpot);
    port.setValidSource(false);
    port.setValidDestination(false);
    port.setSelectable(false);
    port.setDraggable(false);
    Point boxLocation = iBox.getLocation(JGoObject.TopLeft);
    port.setLocation(boxLocation.x - 3, boxLocation.y - 3);
    port.setSize(16, 16);
    // port.setAutoRescale(false);
    port.setPortObject(hasInfoPortObject);
    port.setStyle(JGoPort.StyleObject);
    iBox.addObjectAtTail(port);

The problem appears when I click+hold on the port or on the JGoBasicNode.

If autoRescale is true, the port starts to become huge and it grows each time I click and hold on the node or on the port. If I set it to false, dragging the node doesn’t drag the port, too, clicking on the port will make the node move further from the port, dragging the port won’t work. This happens even if I set explicitly port.setDraggable(true) and/or port.setDragsNode(true).
This doesn’t happen for the JGoIconicNode, even if I’m using exactly the same approach for adding that JGoPort. I don’t know if this is a bug or if I did something wrong.
Could anyone please help me? Thank you!

Alexandra.

I’m not seeing the problem you describe. I’ve added 7 new lines to the start of your sample code to create the JGoBasicNode and the JGoImage to use as the port object. The rest of the code is yours, although I changed:

iBox.getLocation(JGoObject.TopLeft)
to
iBox.getSpotLocation(JGoObject.TopLeft)
because I think that's what you intended.
// Create the BasicNode
JGoBasicNode iBox = new JGoBasicNode("AAA");
iBox.setLocation(100, 100);
iBox.setLabelSpot(JGoObject.BottomCenter);
goView.getDocument().add(iBox);
// Create an image to use as a new port icon (porticon is declared static)
porticon = new JGoImage(new Rectangle(0,0,16,16));
porticon.loadImage(TestApp.class.getResource("doc.gif"), true);
Point imagelocation = iBox.getSpotLocation(JGoObject.BottomRight);
// Add your code to create new port with specified image
JGoPort port = new JGoPort();
port.setFromSpot(JGoPort.NoSpot);
port.setToSpot(JGoPort.NoSpot);
port.setValidSource(false);
port.setValidDestination(false);
port.setSelectable(false);
port.setDraggable(false);
Point boxLocation = iBox.getSpotLocation(JGoObject.TopLeft);
port.setLocation(boxLocation.x - 3, boxLocation.y - 3);
port.setSize(16, 16);
port.setAutoRescale(true);
port.setPortObject(porticon);
port.setStyle(JGoPort.StyleObject);
iBox.addObjectAtTail(port);
It seems to run OK for me. I can't get the port to grow as you describe.
FYI, if you want to add new components to an existing node class and you want intellegent resizing behavior, you probably want to create a new subclass of the node and override methods like layoutChildren. Take a look at "General Concepts When Defining Nodes", in chapter 5 "Nodes" of JGo User Guide.

Hi

Thank you for answering. In fact, the nodes are subclassed, but I didn’t override the modify children method. I actually don’t want the port or the node to grow and I don’t know what could cause this behavior. The nodes we’re talking about are subclasses of JGoBasicNode and JGoIconicNode. The problem is that I didn’t intend to make anything grow but for the subclass of JGoBasicNode this happens. For the JGoIconicNode I’m adding this port in the same way and it works.
Then it must be something in the code of the subclass that’s making it happen, I just can’t figure out what.

[Edit, after some time]: I finally figured it out. I was overriding getBoundingRectangle and I was actually modifying the returning rectangle in my overriding method in the attempt to make the bounding rectangle take the pen width into consideration(which I found not to be necessary because the jgo library provides the method expandRectByPenWidth). What a relief!

Alexandra.