Monday, 31 March 2014

Re-visiting the Maestro layer style editor

Consider the current layer style editor in Maestro

Now, despite being serviceable for our needs it does suffer from several shortcomings:

  • A lot of controls are being created to produce this UI. This is really sluggish when you're editing a style with lots of rules and you need to scroll a lot. We also run the risk of running out of handles if we're editing a really big style.
  • The style previews are Maestro-drawn approximations. Composite styles are blank because we simply have no idea how to draw them in pure .net. Using GETLEGENDIMAGE solves our style preview accuracy problems, but the way this UI has been set up makes it hard to use GETLEGENDIMAGE on say a 100 rule layer (arguments about why you have a layer with 100 theme rules aside) without clogging up your application.
The UI as whole looks like a data grid of sorts. Shouldn't this whole UI be more easier and streamlined if it was grid based?

Yes indeed, so that's what we've done. Meet the new grid-based style editor.

The benefits of the grid-based editor is that because we are using a DataGridView component, we have the ability to not only leverage data-binding against rule objects with very little code plumbing, but also to be able to determine what rules are actually in view on the grid.

As a result, we can issue GETLEGENDIMAGE-based previews only for what you currently see. These requests are also done asynchronously on a background thread, ensuring maximum application responsiveness while not making the MapGuide Server cry since we are only asking for previews for what we can currently see.

Clicking on the Filter cell brings up the Expression Editor. Clicking the LegendLabel cell lets you edit the cell contents. Clicking the Style cell brings up the matching point/line/area style editor and clicking the Label cell brings up the label style editor. Any edits you make are immediately visible on the grid when you close the editor dialog.

When you scroll through the grid, you can see rules that haven't had a preview generated for them yet.

To see the previews for these rules, you can click the Refresh Previews button to refresh the style previews for the rules currently in view.

So now that we have a means for having accurate style previews without obsessively hammering a MapGuide Server, it means that we can also show previews for composite styles. Something that was not possible with the old editor.

Clicking the Style cell for a composite rule in this case still brings up the mega-verbose Symbol Instances dialog for editing composite symbolizations, but at least there's no longer a need to delve into this particular dialog just to get a style preview for a composite rule, because like the other style types, previews for composite rules are also shown in the grid as well.

Moving to a grid-based UI opens up other avenues that were not possible before, like being able to filter the current list of rules by some criteria (handy if you want to focus on some specific rules in a layer with 50+ rules). Not that we have done this already, but these are things that a grid-based UI gives us the ability to explore.

Another improvement that's only available for this grid-based style editor is support for theming composite styles. There are some caveats with this support:
  • The theming algorithm is very naive and basic due to the complexity of Advanced Stylization and the thousands of different possible permutations that a given composite rule could be in. However if you stick to a basic prototype of an un-styled point/line/area the theming algorithm should be able to pick up the relevant color property and apply the theme color ramp to it.
  • On that subject, theming a composite style requires a rule to already exist in the style as a prototype. While this is optional for basic styles, this is required for composite styles.
Now that's not to say we have replaced the old style editor. A new feature like this needs some time to be blooded in as a proper replacement. The old editor is still available if you un-tick the new editor option we've added to the options dialog.

The next release of Maestro will use the grid-based editor by default.

No comments: