PathVisio / libGPML

Java library for reading / writing GPML files
Apache License 2.0
2 stars 4 forks source link

Writing Default Graphics Values for GPML2021 #8

Open Finterly opened 3 years ago

Finterly commented 3 years ago

@egonw @ariutta @AlexanderPico @mkutmon

Discussion: For GPML2021, do we want default values for Graphics to be always written?

Depending on the length of a gpml file and frequency with which it has default graphics value, the file size may be up to 25% smaller when default values are not repeatedly written. Example below:

All graphics properties written even if default value:
<Graphics centerX="781.1666666666678" centerY="796.0000000000002" width="47.66666666666658" height="25.0" textColor="000000" fontName="Arial" fontWeight="Normal" fontStyle="Normal" fontDecoration="Normal" fontStrikethru="Normal" fontSize="12" hAlign="Center" vAlign="Middle" borderColor="000000" borderStyle="Solid" borderWidth="1.0" fillColor="ffffff" shapeType="Rectangle" zOrder="32768" />

Graphics properties not written when default value: <Graphics centerX="781.1666666666678" centerY="796.0000000000002" width="47.66666666666658" height="25.0" zOrder="32768" />

egonw commented 3 years ago

Assuming the defaults are in the XML Schema, that sounds good to me.

What will the behavior be? The Java model will be populates with all default values, but when you save it will never output default values?

Finterly commented 3 years ago

When writing, attributes with default values will not be written. When reading, java model will populate with default value if an attribute is missing and has default value (attribute is not optional).

ariutta commented 3 years ago

As long as it's easy to get the default values elsewhere, it's probably fine to not explicitly include them.

For deciding which attributes should have defaults, we could take a look at the existing pathways. If 99% of the time, an attribute has just one value, that would be a good candidate for using a default. (I said 99%, but maybe a lower percentage would be more appropriate.)

@AlexanderPico said:

My suggestion would be to provide defaults just for a few critical parameters like fill color, border color and text color, but leave the rest unspecified. Maybe we want (all?) the values used by Cytoscape to be explicitly specified?

egonw commented 3 years ago

As long as it's easy to get the default values elsewhere, it's probably fine to not explicitly include them.

Yes, I guess we cannot expect JavaScript to parse the XML Schema XML.

ariutta commented 3 years ago

It is possible to parse XML using JavaScript (but obviously not as easy as JSON). If the defaults are simple, e.g., "all DataNodes by default use a rectangle shape," that would be fine.

But trying to make JavaScript properly understand an XSD is harder. I'm not sure how to easily extract anything fancier than "DataNodes of Type 'Metabolite' by default use text color blue." (Except Alex suggested text color be explicitly specified.)