Adds custom panels on a dashboard. A custom panel allows you to customize features.
This article takes the customization of a tree control as an example to introduce how to customize a tree control and achieve its feature.
Operating Illustration
1. Develop a tree-control panel
- Inherit the base class DAbstactCustomPanel to build the panel of custom tree control on your dashboard based on the packaged template.
public class DCustomTreePanel extends DAbstractCustomPanel
- Register the tree control to the dropdown list. After registration, you can choose Tree Control from the Custom Type drop-down list on the Properties panel as the following picture shows.
DashboardManger.getInstance().addCustomType(actionTreeType);
- Build the tree according to the text structure on its properties, spiltting each line as a tree node. Spaces before each line determine the level of each tree node. For example, the second line B is indented one space compared with the first line A. Then in the tree structure, the tree node B is the sub node of A. The core codes are shown below.
final DefaultMutableTreeNode currentNode = new ScaleNode(s.trim());
final int nodeLevel = getNodeLevel(s);
if (nodeLevel == -1) {
continue;
}
if (nodeLevel == 0) {
root.add(currentNode);
} else {
getBeforeNode(root, nodes, nodeLevel).add(currentNode);
}
insertChildNode(currentNode, nodes, nodeLevel); - Response the action after selecting a tree node. After selecting a tree node, the dashboard change the display of map according to the scale and map bounds specified in the tree node properties, thereby achieving the positioning of map.
DesktopMapControl mapControl = ((DMapPanel) ((FormDashboard) getFormDashboard()).getPanelGrid().getParameters(DParameterType.MAP).get(0)).getMapControl();
mapControl.getMap().setScale(scaleNode.scale);
mapControl.getMap().setViewBounds(scaleNode.bounds);
mapControl.getMap().refresh();
2. Configure city areas on the dashboard
Adds the custom panel on the dashboard. Set the control type to Tree Control. And set the level and name of each tree control and corresponding map scale and bounds in the Custom Control Properties. The scale and bounds of the map corresponded with each tree node are set with the parameters scale and bounds.
3. Preview the dashboard
When previewing the dashboard, you can switch maps with the custom tree control.