cytoscape / RCy3

New version of RCy3, redesigned and collaboratively maintained by Cytoscape developer community
MIT License
48 stars 20 forks source link

How does customShape parameter work in addAnnotationBoundedText #170

Closed bdemchak closed 1 year ago

bdemchak commented 2 years ago

The documentation advises that customShape is a string, but there's no explanation of it, and no apparent analog in the Cytoscape UI. Also, if a value is supplied, how can it be tested?

AlexanderPico commented 2 years ago

Good question for @scootermorris. Do you know what the customShape string needs to be? In Java, we send GeneralPath objects. But I'm not sure how those serialize or if the command takes an alt approach.

Screen Shot 2022-02-27 at 12 40 44 PM

bdemchak commented 2 years ago

GeneralPath is described here: https://docs.oracle.com/javase/7/docs/api/java/awt/geom/GeneralPath.html

There does seem to be a serialization format, and it looks conceptually easy, but with lots of details.

Supposing it's passed into this function, how does it interact with the "type" parameter, which specifies a canned shape?

Is there a demonstration of this parameter somewhere?

scootermorris commented 2 years ago

The "type" parameter should be "custom", I think.

bdemchak commented 2 years ago

I don't think I understand. The "type" parameter for this function is a pre-canned type, such as ELLIPSE or RECTANGLE ... something available in the list returned by GetNodeShapes().

As I understand, the custom_shape parameter would be a serialized version of the Java GeneralPath object, which is a connect-the-dots format.

So, they would be completely different concepts. Is that true??

If I have that right, then the next question would be how they interact when both customShape and type are provided in the call. And after that, whether it's possible to have customShape and not type. Certainly, the opposite is true.

Thanks.

scootermorris commented 2 years ago

Hi Barry, No, the "type" parameter has nothing to do with node shapes -- it's a ShapeType, so without looking at the details of the implementation, I would guess that if the "type" is not "CUSTOM" then the customShape argument is ignored.

scootermorris commented 2 years ago

Just checked the code, and that is indeed the case. If type is not "CUSTOM" then the customShape argument is ignored:

// Handle custom shapes
if (type.equalsIgnoreCase(ShapeAnnotation.ShapeType.CUSTOM.toString()))
  putIfNotNull(tm, args, ShapeAnnotation.CUSTOMSHAPE, customShape);
bdemchak commented 2 years ago

OK ... good thanks. I can document that. Would you have an example (even a small one) of a suitable customShape string?