/* (non-Javadoc) * @see com.netlight.layout.runner.ILayoutRunnerPhase#execute(com.netlight.layout.runner.LayoutRunner) */ @Override public void execute(ILayoutRunner runner, boolean stopThreadWhenDone) { IHierarchicalNodeLayout layout = runner.getLayout(); IHierarchicalNodeModel model = layout.getModel(); IBreakCriteria criteria = runner.getBreakCriteria(); LayoutRunnerConfiguration settings = runner.getConfiguration(); // int n = 0; if (layout != null) { while (runner.isRunning()) { runner.visit(layout); // fit view if (settings.isAllowAutoFitAtStepEnd()) runner.autoFit(model); // break using criteria? if (criteria != null) if (criteria.shouldBreak(layout)) { criteria.onBreak(); if (stopThreadWhenDone) runner.setRunning(false, true); // no using runner.stop because this destroy our thread :) break; } // break because of ended algorithm if (!layout.canAlgo()) { if (stopThreadWhenDone) runner.setRunning(false, true); break; } } } }
protected IHierarchicalNodeLayout getRootLayout( IHierarchicalNodeModel model, final IHierarchicalEdgeModel tubeModel) { IHierarchicalEdgeLayout tubeLayout = getHierarchicalEdgeLayout(model); IHierarchicalNodeLayout layout = getHierarchicalNodeLayout(model); layout.setTubeModel(tubeModel); layout.setTubeLayout(tubeLayout); return layout; }
@Override public IHierarchicalNodeLayout getNodeLayoutByModelName(IHierarchicalNodeModel model) { if (modelNameToLayoutName != null) { String name = modelNameToLayoutName.get(model.getLabel()); if (name != null) { IHierarchicalNodeLayout layout = getNodeLayoutByName(name); layout.setModel(model); String initInfo = info(model, layout); Logger.getLogger(HierarchicalLayoutFactory.class).info(initInfo); return layout; } else throw new RuntimeException( "layout factory does not have a defined layout for model " + model.getLabel()); } else throw new RuntimeException("layout factory does not have a model<->layout mapping by name"); }
/** recursively handle children models. */ protected void attachChildren(IHierarchicalNodeLayout layout, IHierarchicalNodeModel model) { for (IBoundedItem child : model.getChildren()) { if (child instanceof IHierarchicalNodeModel) { IHierarchicalNodeModel submodel = (IHierarchicalNodeModel) child; IHierarchicalNodeLayout sublayout = getHierarchicalNodeLayout(submodel); if (sublayout != null) layout.addChild(sublayout); } } }
protected String info(IHierarchicalNodeModel model, IHierarchicalNodeLayout layout) { return model.getClass().getSimpleName() + model.getLabel() + layout.getClass().getSimpleName(); }