How do I override configuration properties in the applet tag?

I want to dynamically define my color scheme using the ASP.Net page which generates the HTML for the tree map. How can I do this?

Define your color points using PARAM attributes on the APPLET tag.

If you are defining color points in the APPLET tag, your best bet is to not define any color points in the XML file. That way you don't have to worry about accidental merging issues.

So your XML file would look like:

   <colorScheme label="Default" type="discrete"
                absoluteMinimum="0" absoluteMaximum="1" />

With no closing tag, and your APPLET parameters would define all the color point information:

<applet>
  <param name="config.treemap.colorScheme.colorPoint[0]@color"
         value="#FF0000" />
  <param name="config.treemap.colorScheme.colorPoint[0]@position"
         value="0" />

  <param name="config.treemap.colorScheme.colorPoint[1]@color"
         value="#000000" />
  <param name="config.treemap.colorScheme.colorPoint[1]@value"
         value="0" />

  <param name="config.treemap.colorScheme.colorPoint[2]@color"
         value="#00FF00" />
  <param name="config.treemap.colorScheme.colorPoint[2]@position"
         value="#100" />
</applet>

Just FYI, how the configuration system works under the hood is that it has no knowledge of what XML is. It's just asking for name/value pairs and configuring the tree map based on that. Essentially, every XML tag/attribute/content gets converted to a modified XPath syntax (a combination of XPath & Java properties syntax). And the configuration system just pulls the first property it finds with this name.

So for the color schemes, if the XML configuration looks like:

<config>
   <treemap>
      <colorScheme label="Default" type="discrete">
         <colorPoint position="0"   color="#FF0000" />
         <colorPoint value="0"      color="#000000" />
         <colorPoint position="100" color="#00FF00" />
      <colorScheme>
   </treemap>
</config>

Then this gets converted internally into:

config.treemap.colorScheme@label=Default
config.treemap.colorScheme@type=discrete
config.treemap.colorScheme.colorPoint[0]@position=0
config.treemap.colorScheme.colorPoint[0]@color=#FF0000
config.treemap.colorScheme.colorPoint[1]@value=0
config.treemap.colorScheme.colorPoint[1]@color=#000000
config.treemap.colorScheme.colorPoint[2]@position=100
config.treemap.colorScheme.colorPoint[2]@color=#00FF00

Which maps easily into the Java applet parameters. The problem you can have though, is that you can add extra information in the applet parameters that you may not realize you are adding, or you might be adding it to the wrong place. For instance, assuming you wanted to add another color point at position 50 to the XML configuration above, but do it in Java applet parameters. You might think that since you want to add in the third color point, you could do:

   <param name="config.treemap.colorScheme.colorPoint[2]@position"
          value="50" />

   <param name="config.treemap.colorScheme.colorPoint[2]@color"
          value="#FFCC00" />

However, this doesn't add another element (since the config system has no awareness of XML elements), it simply overrides the properties at the given paths.

Likewise, if you wanted to convert the middle color point from a value-based point to a position-based point, you might try:

   <param name="config.treemap.colorScheme.colorPoint[1]@position"
          value="50" />

But this just adds the attribute 'position' without removing the old 'value' attribute.

So, in general, if someone wants to dynamically configure an aspect of the tree map, I recommend they don't define the element at all in the XML configuration, and define everything in the applet parameters. That way they avoid any override issues. Overriding is great, however, if you want to override just a couple properties, such as the dataSource property. If you do choose to override parameters, just be aware of how the XML path will be converted to a configuration path, so you are overriding the correct values.