You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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" />
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).
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.)
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?
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.)
Activity
[-]GPML2021 Writing Default Graphics Values [/-][+]Writing Default Graphics Values for GPML2021 [/+]egonw commentedon Jul 25, 2021
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 commentedon Jul 26, 2021
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 commentedon Jul 28, 2021
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:
egonw commentedon Jul 28, 2021
Yes, I guess we cannot expect JavaScript to parse the XML Schema XML.
ariutta commentedon Jul 28, 2021
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.)