Introduction
A shape placeholder is defined in a diagram to present undefined objects of a model. These objects, which can be considered as parameters of a model, are connected to other objects.
Having a placeholder is the only way to define relationships between objects before defining these objects in a diagram.
Usage
A diagram is needed to graphically display a complex model and to help the end user to understand it. Relationships play a key role in a diagram, not the objects: a diagram is not needed to display a set of objects without relationships.
That’s why a diagram with placeholders is usually defined by an expert or defined programmatically to set the relationships even if some objects are not known yet.
An end user then completes it by dropping an object’s shape into each placeholder. The action corresponds to setting a value to a parameter of the model.
Use a placeholder if:
- You want to show a model through a diagram with predefined connected shapes of which some are unknown.
- You must generate a diagram and don’t want to use a form to choose some objects before generating it.
- You want to provide a shape replacement feature. In that case you can provide a diagram with a filled placeholder.
Don’t use a placeholder if:
- A diagram is not compulsory to understand and use the model. In that case, the interface will be a form with input fields to choose the objects from.
- A dialog box displayed before the diagram is better to select objects. In that case, the objects will be changeable once created. The replacement of an object is done by deleting the object (which also deletes all connections), adding a new object, and connecting it manually.
Anatomy
Note: the construction of the placeholder uses “viewport coordinates” and “world coordinates”.
- Viewport coordinates are the coordinates on the screen (in pixel). They are independent from the zoom and the pan.
- World coordinates are the coordinates in the diagram canvas (in pixel) and are submitted to zooming and panning.
Size and Corners
The placeholder is made of two-segment rounded lines positioned at each corner of the shape that can be inserted in. The placeholder defines an area which follows the size of the shape and the zoom factor, but the corner dimensions are independent from the zoom to be clearly visible.
The shape of the placeholder area is calculated by taking the shape’s dimension and adding a 4px margin in viewport coordinates around it (D). That corresponds to 4px*Z in world coordinates where Z is the zoom factor.
Each corner is a two-segment rounded line with 3px width. Each segment is 16px length viewport coordinates (E). That corresponds to 16px*Z in world coordinates. The radius of a placeholder angle (RA) depends on the radius of the shape angle (SA) and the zoom factor (Z) by:
RA = 4px+ SA/Z (in viewport coordinates)
Example:
- When the shape corner radius is 4px at zoom 1 (A), the placeholder radius is 8px (in viewport coordinates). When the shape corner radius is 0px (B), the placeholder radius is 4px.
- When the shape corner radius is 4px at zoom 0.1 (C), the placeholder radius is 4.1px.
If the shape doesn’t have corners, the 4 limits are positioned in the 4 diagonal directions. If this calculation is too complex or if the exact shape form isn’t predictable, a boxing rectangle is used instead.
States and style
The placeholder has the following interaction states:
- Ghost: During the creation of the placeholder (A)
- Normal: No interaction with the placeholder (B)
- Hover: (C)
- Dragged: (C)
- Selected: (D)
- Targeted: when a shape is ready to be dropped on the placeholder to fill it (C)
The placeholder also has content states:
- Empty: The placeholder has no shape.
- Filled: The placeholder is filled by a shape. If the user doesn’t have the right to add or remove placeholders in the diagram, the only possible interaction state when filled is: “normal”.
Connectors and Ports
The connectors (E) and the ports (D) of the placeholder (C) are displayed at the same location and with the same style and behave similarly as if the shape was there (B) or if there was only the shape without any placeholder (A).
Ports are not displayed when the placeholder is in a ghost state.
Role Name
The name of the placeholder is the role of the object in the diagram.
When the placeholder is not filled, the name is displayed in the center of the placeholder (A).
When the placeholder is filled, the shape normally hides it.
It's possible, when needed, to display the name over the placeholder when it's filled (B).
Behavior and Interaction
There are two ways to set a value to the placeholder’s variable:
- Drag and drop a shape’s object into the placeholder.
- Select the empty placeholder and choose the object in the dialog box.
Once the value is set, the placeholder cannot be selected. Only the shape inside it can be selected. When the shape is moved, the placeholder follows it.
To replace a shape in a filled placeholder, it's possible to:
- Remove it and add another one,
- Drag and drop a new one.
Dragging and Dropping a Shape into a Shape Placeholder
When a user drags a shape (A), the shape is under the mouse cursor, centered under it.
At any moment the use can drop it:
- Onto the canvas,
- Onto another shape,
- Onto the shape placeholder.
When the mouse is over the shape (B), the placeholder is in the targeted state but if the shape is not compatible with the placeholder, the placeholder stays in the normal state.
Once dropped, the shape moves directly to its final position (C), the shape is selected, and the placeholder state is filled. No animation is needed.
Dragging and Dropping a Shape into a Magnetized Shape Placeholder
According to the design of the end-to-end workflow chosen to create a valid diagram, we may want to force the user to drag and drop onto mandatory placeholders before dragging and dropping onto other places.
For that, we defined “magnetized” placeholders. The nearest unfilled magnetized placeholder attracts the shape.
When no shape is dragged over the diagram, all magnetized placeholders are in the normal state (A).
When a shape is dragged over the diagram (B), it's attracted by a placeholder by the center of the nearest placeholder (G). The shape is not cented under the mouse cursor (E), but has moved towards the placeholder (F).
The distance from (F) to (E) depends on the shape dimensions: d = Ka*(Ws+Hs). Ws and Hs are the width and the height of the shape in world coordinate. Ka is an attraction factor set to 0.25. This factor may be tuned after usability tests.
The nearest unfilled, compatible, magnetized shape is the targeted state. During the mouse drag, another magnetized placeholder can become the targeted one (C). In that case, it becomes the targeted placeholder and the position (F) of the dragged shape is recalculated with the new placeholder position (G).
At any time, the user can interrupt the dragging action (as usual with ESC key or move outside the diagram area) or drop it to valid it (D). In that case, the dragged shape moves rapidly (around 0.2 seconds) between F and G to fit onto the placeholder. The user can also move the mouse cursor over the placeholder and drop the shape. In that case, the move is immediate.
Selecting Empty Placeholders and Choosing Objects in the Dialog Box
To pass accessibility standards, this feature should be able to be performed without any dragging and dropping: by simple clicks or with the keyboard only.
When selecting the placeholder, the contextual toolbar of the placeholder (magnetized or not) appears and must contain an “Add” command (B).
When selecting the add command (C), it displays a dialog box to choose an object (not presented here).
Once the object is chosen and the dialog is validated, the object’s shape appears selected in the placeholder. The placeholder is not selected anymore. (D).
Moving Placeholders
When the placeholder is empty it behaves like any other shape. It can be dragged to be moved.
When the placeholder is filled, however, it cannot be selected, but it follows the shape when the shape is being dragged.
Emptying Placeholders
The simplest way to empty a placeholder is to select the shape and then to remove it. After that, the placeholder is automatically selected.
When the diagram’s level of interaction is low, for example, shapes and placeholders cannot be moved, it’s possible to drag the shape out of the placeholder and drop it out of the diagram. The placeholder is then empty.
But in high-level interaction diagrams, for example, when shapes can be moved, it’s not possible to drag the shape out of the placeholder to empty it, because the placeholder will follow the dragged shape.
Replacing a Placeholder’s Shape
The user can replace the shape by another one in two ways:
- In two steps by emptying the placeholder and then filling it again.
- In one step by dragging and dropping a shape onto a filled placeholder.
While the mouse is outside the placeholder (A, B), the dragging of the shape follows the normal behavior of a magnetized placeholder: The nearest empty, compatible, compulsory one is the targeted one. But when the mouse moves over a filled placeholder (C), this placeholder is emptied and becomes the targeted one. Then, if the user releases the mouse (D), the dragged shape fills the placeholder (D).
To make the interaction reversible (from C), if he moves out of the placeholder without releasing (B), the initial shape re-appears, and the targeted placeholder is the nearest magnetized one.
Creating a Placeholder
A placeholder can be created as any other shape: by drag and drop it onto a canvas. If the type of the shape the placeholder can receive is unknown when dragging, the size of the placeholder fits to an imaginary square shape of 60x60px. (A) The style is ghost.
If the object type is known while creating the placeholder, for example if the command is creating a specific object’s placeholder, the placeholder size will be based on the size of that object type (C).
When the placeholder is dropped onto the canvas (B), the placeholder is selected. Then the user can set the characteristics in the property pane
Another way to create a placeholder is to drop it on an existing shape. That’s the way to transform a diagram into a diagram template. When the mouse is over a shape, the shape is highlighted (D) when the placeholder can be dropped and the placeholder changes size and position to embrace the shape (E). This transformation is done by an 0.3 second animation.
If the placeholder cannot be dropped onto the shape, the shape remains unselected.
Once dropped, the placeholder is selected, the name is eventually displayed over the shape and the shape is not selected anymore.
Best Practices
When to Use Placeholders in a Diagram Template
A diagram template is a diagram used as a starting point to create another diagram. There are several methods available.
In the following examples, the model M (with objects “Object A”, “Object B”, “Object 1”) is the model template and the model N (with objects “Object C”, “Object D”, “Object 1”) is the model to create.
Method 1: Create a template from a diagram and then create diagram from the template
The expert creates the template. They will:
- Create the model and test it works (A),
- Generalize the case by defining placeholders on shapes (B),
- Optionally empty the placeholders:
- Empty the placeholder if the objects in the placeholders was there only to test the model (C)
- Keep the shape in the placeholder if the object is the default object to use that can be changed (B)
Then any end-user will use the template. They will:
- Duplicate the template (C),
- Fill the placeholders with objects (D),
- Save the diagram.
Method 2: Create a diagram from a diagram
From an existing diagram, seen as a good example to follow (A), the user will:
- Duplicate it,
- Remove the shape that needs to be replaced (B),
- Add the new shapes “Object C” and “Object D” (C),
- Rebuild the connections (D).
As said above, the main issue here is that the user may not know how to reconnect the objects if the connections are complex.
When to Use Placeholders when Generating Diagrams
Method 3: A diagram generated with placeholders
The user executes a command that generates the diagram with placeholders (A). Then the user fills the placeholders with objects and saves the model (B).
Method 4: A diagram generated after inputs in a dialog box
When the user executes a command to generate the model, a dialog box diagram asks to input the objects. Then the diagram is displayed (B).
Related Links
Support
If you have any questions or feedback about this page, please contact our team. For further information and questions in regards to the Design System, please visit the DNA Design SharePoint.