use of org.netxms.ui.eclipse.networkmaps.algorithms.ExpansionAlgorithm in project netxms by netxms.
the class AbstractNetworkMapView method setLayoutAlgorithm.
/**
* Set layout algorithm for map
*
* @param alg Layout algorithm
* @param forceChange
*/
protected void setLayoutAlgorithm(MapLayoutAlgorithm alg, boolean forceChange) {
if (alg == MapLayoutAlgorithm.MANUAL) {
if (!automaticLayoutEnabled)
// manual layout already
return;
automaticLayoutEnabled = false;
// TODO: rewrite, enum value should not be used as index
actionSetAlgorithm[layoutAlgorithm.getValue()].setChecked(false);
actionEnableAutomaticLayout.setChecked(false);
return;
}
if (automaticLayoutEnabled && (alg == layoutAlgorithm) && !forceChange)
// nothing to change
return;
if (!automaticLayoutEnabled) {
actionEnableAutomaticLayout.setChecked(true);
automaticLayoutEnabled = true;
}
LayoutAlgorithm algorithm;
switch(alg) {
case SPRING:
algorithm = new SpringLayoutAlgorithm();
break;
case RADIAL:
algorithm = new RadialLayoutAlgorithm();
break;
case HTREE:
algorithm = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.LEFT_RIGHT);
break;
case VTREE:
algorithm = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.TOP_DOWN);
break;
case SPARSE_VTREE:
algorithm = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.TOP_DOWN);
((TreeLayoutAlgorithm) algorithm).setNodeSpace(new Dimension(100, 100));
break;
default:
algorithm = new GridLayoutAlgorithm();
break;
}
viewer.setLayoutAlgorithm(alwaysFitLayout ? algorithm : new CompositeLayoutAlgorithm(new LayoutAlgorithm[] { algorithm, new ExpansionAlgorithm() }));
actionSetAlgorithm[layoutAlgorithm.getValue()].setChecked(false);
layoutAlgorithm = alg;
actionSetAlgorithm[layoutAlgorithm.getValue()].setChecked(true);
}
Aggregations