use of com.intellij.diagram.components.DiagramNodeContainer in project intellij-plugins by JetBrains.
the class AngularUiRouterDiagramProvider method getExtras.
@NotNull
@Override
public DiagramExtras<DiagramObject> getExtras() {
return new DiagramExtras<DiagramObject>() {
@Override
public List<AnAction> getExtraActions() {
return Collections.singletonList(new MyEditSourceAction());
}
@Nullable
@Override
public Object getData(String dataId, List<DiagramNode<DiagramObject>> list, DiagramBuilder builder) {
if (CommonDataKeys.PSI_ELEMENT.is(dataId) && list.size() == 1) {
final SmartPsiElementPointer target = list.get(0).getIdentifyingElement().getNavigationTarget();
return target == null ? null : target.getElement();
} else if (JSModulesDiagramUtils.DIAGRAM_BUILDER.is(dataId)) {
return builder;
}
return null;
}
@Nullable
@Override
public Layouter getCustomLayouter(Graph2D graph, Project project) {
final GraphSettingsProvider settingsProvider = GraphSettingsProvider.getInstance(project);
final GraphSettings settings = settingsProvider.getSettings(graph);
final SmartOrganicLayouter layouter = settings.getOrganicLayouter();
layouter.setNodeEdgeOverlapAvoided(true);
layouter.setNodeSizeAware(true);
layouter.setMinimalNodeDistance(60);
layouter.setNodeOverlapsAllowed(false);
layouter.setSmartComponentLayoutEnabled(true);
layouter.setConsiderNodeLabelsEnabled(true);
layouter.setDeterministic(true);
final List<CanonicMultiStageLayouter> list = new ArrayList<>();
list.add(layouter);
list.add(settings.getBalloonLayouter());
list.add(settings.getCircularLayouter());
list.add(settings.getDirectedOrthogonalLayouter());
//list.add(settings.getGroupLayouter());
list.add(settings.getHVTreeLayouter());
list.add(settings.getOrthogonalLayouter());
for (CanonicMultiStageLayouter current : list) {
final ParallelEdgeLayouter parallelEdgeLayouter = GraphManager.getGraphManager().createParallelEdgeLayouter();
parallelEdgeLayouter.setLineDistance(40);
parallelEdgeLayouter.setUsingAdaptiveLineDistances(false);
current.appendStage(parallelEdgeLayouter);
current.setParallelEdgeLayouterEnabled(false);
}
return layouter;
}
@NotNull
@Override
public JComponent createNodeComponent(DiagramNode<DiagramObject> node, DiagramBuilder builder, Point basePoint, JPanel wrapper) {
final DiagramNodeContainer container = new DiagramNodeContainer(node, builder, basePoint);
if (!GraphViewUtil.isPrintMode()) {
if (!node.getIdentifyingElement().getErrors().isEmpty()) {
container.setBorder(ERROR_BORDER);
} else if (!node.getIdentifyingElement().getWarnings().isEmpty()) {
container.setBorder(WARNING_BORDER);
} else {
container.setBorder(NORMAL_BORDER);
}
}
if (!node.getIdentifyingElement().getChildrenList().isEmpty())
container.getHeader().setBorder(JBUI.Borders.customLine(Gray._190, 0, 0, 1, 0));
return container;
}
};
}
Aggregations