Example: Style Overrides

Style overrides allow us to specify exceptions to the default, layer-wide style properties specified by the Contents - Style panel for drawings and labels.   Before proceeding, please read the Style: Overrides topic.

 

eg_style_override01_01.png

 

We begin with a map that has one layer, called Regions, a drawing that shows the regions of France as areas.   This drawing shows French regions after the recent consolidation of regions in a smaller number of larger regions.   The areas in the drawing use default, black and gray style. We have used the Layers panel to specify a nice shade of blue for the background, to liven up the display despite the drab, default formatting.

 

eg_style_override01_02.png

 

Opening the drawing's table we see it has three fields, an mfd_id field as usual for drawings, a Name text field and a Geom field that contains geom data defining each area.

 

eg_style_override01_03.png

 

With the focus on the map, in the Contents - Style panel we can see default black and gray formatting is used for style properties.   We click the Options tab.   

 

eg_style_override01_04.png

 

We click New Field to create a field to accept style override data for each record.

 

eg_style_override01_04a.png

 

In the New Field dialog we accept the default field name of Style.  We could name the field whatever we want, but most Manifold users get into the habit of using the default name so the purpose of the field is obvious when viewing a table or a table's schema.  Press OK.  

 

 

eg_style_override01_05.png

 

Back in the Style panel, we check the Use style overrides box.   If there is a text field in the table called Style, by default that will be loaded into list of available text fields.   We could use another text field, but, again, most Manifold users will get into the habit of using field named "Style" to store style override data.   Press the Update Options button.

 

eg_style_override01_06.png

 

A new text field called Style appears in the table.  It is filled with NULLs since so far we have not specified any style overrides for any areas in the drawing.

 

eg_style_override01_07.png

 

To specify a style override, we Alt-click an area to choose it as the context object for the Record panel.   The area is marked with small blue boxes at the vertices of the area.   

 

eg_style_override01_08.png

 

The Record panel immediately pops into action, showing field values for that object. We see we have clicked the area for Centre-Val de Loire, a truly fine region of France, the historical heart of the country.  We click on the Style tab.

 

eg_style_override01_09.png

The Style tab shows the style properties applied to the area.  By default, these are the same style properties set in Contents - Style for the entire layer.   We click the Fill Color button to change fill color from the default gray to green.

 

Important:  If the Use style overrides box has not been checked in Contents - Style - Options, we will not be able to change the style used by this object.  We can only change these style properties if we have checked the Use style overrides box.

 

eg_style_override01_10.png

When we change the fill color to green a square icon appears on the button to indicate we have specified a style override.  We press Update Record to apply the change.

 

eg_style_override01_11.png

Immediately, our area is rendered using the green fill color we specified.    In the illustration above we have cleaned up the display by alt-clicking an empty spot on the map to clear the context status of the area, so it is not highlighted with a necklace of blue dots.

 

eg_style_override01_12.png

 

If we look in the drawing's table we see that the Style field for the Centre-Val de Loire record has acquired a JSON text string for the style override we specified.  All the other areas have NULLs in their Style field because we only specified a style override for one area.

 

One of the great things about saving style overrides in text fields is that we can uncheck and then re-check the Use style overrides box without losing the style overrides we have specified.

 

eg_style_override01_14.png

eg_style_override01_15.png

 

If we uncheck the Use style overrides box and press the Update Options button the system stops using style overrides.   It applies to all objects whatever style has been specified in the Contents - Style panel.

 

eg_style_override01_13.png

eg_style_override01_11.png

 

If we check the Use style overrides box and press the Update Options button again, the system once more starts using style overrides.  Any style overrides in the Style field are applied.  

 

 

eg_style_override01_14.png

eg_style_override01_15.png

 

We uncheck Use style overrides and press the Update Options button, and then we click the Contents - Style panel to change style properties for the layer.

 

eg_style_override01_16.png

 

In the Style panel we set a thematic format that colors regions of France using their names as unique values.

 

 eg_style_override01_17.png

 

In the map we see the effect as each region is colored by the thematic format based on region name.  

 

eg_style_override01_13.png

 

In the Options tab we check the Use style overrides box and press the Update Options button.

 

eg_style_override01_18.png

 

The style override we specified earlier takes effect.  We see that the style override for the Centre Val de Loire region is still there.

Finding all Objects with Style Overrides

If we look at a map where objects are styled in a variety of ways we may want to know which are styled using the layer style properties specified by Contents - Style and which are styled using a style override.

 

That is easy to do using the Select panel.

 

eg_style_override01_19.png

 

We open the drawing's table, and then with the focus on the opened table in the Select panel we choose the Is not Null template using the Style field.  Press Replace Selection.

 

eg_style_override01_20.png

 

That immediately selects all records where the Style field value is not NULL.  In this case, only one record is selected, shown above using red selection color.

 

eg_style_override01_21.png

 

The corresponding area automatically also is selected in the map and also shown in red selection color.

Clearing a Style Override

Suppose we have some style overrides set for various objects in our drawing, and we would like to clear those, that is not have them any more.   That is easy to do, by simply setting the values of the Style field for those objects to NULL.   We can do that using the Transform panel, a useful approach if we want to set the value to NULL in many records, or we can use an Alt-click on each object to remove the style override using the Record pane.

 

Using the Transform panel:

 

We select all records for which Style is not NULL, as shown in the steps just above.    With the focus on the table, we click on the Transform panel.

 

eg_style_override01_22.png

 

In the Transform panel we choose the Style field, the Copy template and we enter the value NULL.   

 

Important: we check the Restrict to selection box, since we only want to put NULLs into the targeted Style field for selected records.

 

eg_style_override01_23.png

 

Right away, the panel previews for us in blue preview color what it will do.   We can see in the illustration above that it will put a NULL into the Style value for the selected record.  We click the Update Field button.

 

eg_style_override01_24.png

 

A NULL appears in the Style field.    We choose Edit - Select None to clear the selection and thus to clean up the display.

 

eg_style_override01_25.png

 

In the map we see that there is no longer any style override applied to the Centre-Val de Loire area.    In the example above there was only one record that was selected, but if we had thousands of objects using a style override and we had selected them all, we could have instantly cleared the style override for all of those thousands of objects at once in a single step using the same procedure.

 

Using the Transform panel:

 

Another way to clear a style override is to manually Alt-click each object for which we would like to clear the style override and then use the Record panel.

 

eg_style_override01_26.png

 

We Alt-click the Centre-Val de Loire area to choose it for use in the Record panel.

 

eg_style_override01_27.png

 

In the Record panel's Style tab we click on the Fill Color property and we choose Default.  

 

eg_style_override01_28.png

 

That clears the style override.  The square icon indicating a style override disappears from that style property's button, and the style property button shows the brown color assigned to that area by the thematic format which is specified for the entire layer.   We press the Update Record button to apply the changes.

 

eg_style_override01_29.png

 

Back in the map, we see that there is no longer any style override applied for the Centre-Val de Loire area.

Copying and Pasting Style Overrides between Objects

Because style overrides are simply non-NULL strings in the Style field we can copy and paste them between records if we want to apply the same style overrides to other objects.

 

eg_style_override01_30.png

 

Consider our example with a style override in use for the Centre-Val de Loire area, as seen above.

 

eg_style_override01_31.png

 

The style override is simply a string value in the Style field for the Centre-Val de Loire record.   We can copy and paste it just like any other string.

 

eg_style_override01_32.png

For example, we can right-click onto the Style cell for the Centre-Val de Loire record and choose Copy.  

 

eg_style_override01_33.png

We can then right-click onto the Style cell for the Hauts-de-France record and choose Paste.

 

eg_style_override01_34.png

 

That copies the style override string from the Centre-Val de Loire record and pastes it into the Hauts-de-France record.

 

eg_style_override01_35.png

 

Like magic, when we refresh the map view (choose View - Refresh or pan or zoom the view) the Hauts-de-France area is also colored with the same style override as used by the Centre-Val de Loire area.

 

eg_style_override01_36.png

We can right-click onto the Style cell for the Normadie record and Paste again.

 

eg_style_override01_37.png

 

That pastes the style override into the Normandie record.

 

eg_style_override01_38.png

 

Refreshing the map shows that the Normandie area now also uses the same style override.

Multiple Style Override Fields

We can have style override strings in more than one field in a table.   Whatever style override field we tell the system to use in the Contents - Style - Options tab will be used.

 

eg_style_override01_39.png

 

For example, suppose we use Edit - Schema to add an nvarchar field called Style 2 to the Regions Table.

 

eg_style_override01_40.png

 

In the Contents - Style - Options tab we check the Use style overrides box and in the pull-down list of available text fields we choose Style 2.    That will now be the field the system will use as a source of style overrides for each object.   We press the Update Options button.

 

eg_style_override01_41.png

 

The map shows default formatting for all areas, because all of the areas have NULLs, that is no style overrides, in their Style 2 field.

 

Let us add some style overrides:

 

eg_style_override01_42.png

 

We Alt-click on the Pays de la Loire area.  

 

eg_style_override01_43.png

 

In the Record panel's Style tab we change the fill color to yellow and we press Update Record.   That creates a style override for that object.

 

eg_style_override01_44.png

 

The Pays de la Loire area appears in yellow.   We Alt-click the Centre-Val de Loire area.

 

eg_style_override01_45.png

 

We specify a magenta fill color and press Update Record.

 

eg_style_override01_46.png

 

We alt-click into an empty part of the map to clear up the display.   We now have two areas that use style overrides.

 

eg_style_override01_47.png

 

If we open the Regions Table we see that style override strings have been added to the Style 2 field for two records.

 

If we like, we can switch back and forth between using the two different style override fields.

 

eg_style_override01_48.png

eg_style_override01_49.png

 

In the Contents - Style - Options tab we choose Style as the field to use with style overrides.  We press the Update Options button.   Right away, the map uses the style overrides from that field.

 

eg_style_override01_50.png

eg_style_override01_51.png

 

In the Contents - Style - Options tab we choose Style 2 as the field to use with style overrides.   We press the Update Options button.   Right away, the map uses the style overrides from that field.

 

Style Overrides in Properties and the mfd_meta Table

We may want to use SQL or scripts to manipulate the use of style overrides.   How can we see if style overrides are in use, and, if they are, which field do they use?

 

eg_style_override01_52.png

 

Right-clicking a drawing in the Project panel and choosing Properties will show the properties for that drawing.  If Use style overrides has been checked for that drawing, it will contain a StyleOverrides property, the value of which will be the name of the field from which style overrides are used.   In the illustration above we see that style overrides are in use and that the Style field provides those overrides.

 

eg_style_override01_53.png

 

In the illustration above we see that style overrides are in use and that the Style 2 field provides those overrides.

 

eg_style_override01_54.png

 

In the illustration above there is no StyleOverrides property for the drawing, so we know that style overrides are not in use.

 

eg_style_override01_55.png

 

If we would like to access or to manipulate style overrides with SQL or programmatically, we can see in the mfd_meta System Data table if a layer has style overrides in use.  From the illustration above we can see that the Regions drawing uses style overrides, using the Style 2 field.

 

Notes

Is the field named 'Style' special?   - Yes and no.  The Use style overrides facility will look for a text field called Style in the drawing's table and, if a field named Style exists, that field will be used by default to store any style overrides.  We can choose a different text field if we like.   If a field named Style does not exist, the (new field) choice will create an nvarchar text field called Style.   If we already have a field called Style and we choose (new field), that will create a field called Style 2 and so on.   But there is nothing special about the name 'Style' other than it is short, easy to remember, and more self-documenting than using the name 'Ringo' or 'Beatrice' for a field that will store style override text.

 

Why nvarchar?  Can it be a varchar?  - Yes, if you prefer.  Manifold uses nvarchar text type by default because supporting Unicode is good karma in an application that is used in many different countries.

 

Are style overrides a replacement for thematic formatting?  - No.  Style overrides generally are intended for special case needs, to be applied in an ad hoc manner.   For example, suppose we have thematically formatted a map for cartographic reasons but when it comes time to print there is one area that just does not look right, for which a slightly lighter color would look better.   If we are in a hurry, instead of spending more time tinkering with thematic formats we could simply take a brute force approach and use a style override to color that one area exactly the color which looks good in the layout.

 

Another good use for style overrides is when creating labels manually to annotate a map.   Style overrides allow us to manually specify the style of each label, such as size, font and color that we create.   When the numbers of labels are limited it is often easier to simply use style overrides than to organize a limited number of labels into several different layers that can all be formatted in the usual way.  

 

See Also

Maps

 

Drawings

 

Labels

 

Style

 

Style: Drawings

 

Style: Labels

 

Style: Overrides

 

Contents Pane

 

Contents - Record

 

Contents - Select

 

Contents - Transform

 

Example: Style Panel Quickstart - A tutorial introduction to using the Style panel in the Contents pane to apply color, symbology, size and rotation to areas, lines and points in drawings.