package vg.userInterface.jgraphx;
import com.mxgraph.layout.mxCircleLayout;
import com.mxgraph.layout.hierarchical.mxHierarchicalLayout;
import vg.core.IGraphView;
import vg.userInterface.core.AGraphLayout;
import vg.userInterface.core.IGraphLayoutManager;
public class mxLayoutsRegister {
private class Hierarchical extends AGraphLayout{
static final String FINE_TUNING = "Fine tuning";
static final String INTRA_CELL_SPACING = "Intra cell spacing";
static final String INTER_RANK_CELL_SPACING = "Inter rank cell spacing";
static final String INTER_HIERARCHY_SPACING = "Inter hierarchy spacing";
Hierarchical(String name) {
super(name);
super.settings.put(FINE_TUNING, false);
super.settings.put(INTRA_CELL_SPACING, 60.0);
super.settings.put(INTER_RANK_CELL_SPACING, 60.0);
super.settings.put(INTER_HIERARCHY_SPACING, 40.0);
}
@Override
public Object getLayout(IGraphView view) {
if (view instanceof JGraphView) {
JGraphView jgraphview = (JGraphView) view;
mxHierarchicalLayout layout = new mxHierarchicalLayout(jgraphview.getGraph());
layout.setDisableEdgeStyle(false);
if (super.settings.get(FINE_TUNING) instanceof Boolean) {
layout.setFineTuning((Boolean)super.settings.get(FINE_TUNING));
}
if (super.settings.get(INTRA_CELL_SPACING) instanceof Double) {
layout.setIntraCellSpacing((Double)super.settings.get(INTRA_CELL_SPACING));
}
if (super.settings.get(INTER_RANK_CELL_SPACING) instanceof Double) {
layout.setInterRankCellSpacing((Double)super.settings.get(INTER_RANK_CELL_SPACING));
}
if (super.settings.get(INTER_HIERARCHY_SPACING) instanceof Double) {
layout.setInterHierarchySpacing((Double)super.settings.get(INTER_HIERARCHY_SPACING));
}
return layout;
}
return null;
}
}
private class Circle extends AGraphLayout{
static final String RADIUS = "Radius";
Circle(String name) {
super(name);
super.settings.put(RADIUS, 30.0);
}
@Override
public Object getLayout(IGraphView view) {
if (view instanceof JGraphView) {
JGraphView jgraphview = (JGraphView) view;
mxCircleLayout layout = new mxCircleLayout(jgraphview.getGraph());
layout.setDisableEdgeStyle(false);
if (super.settings.get(RADIUS) instanceof Double) {
layout.setRadius((Double)super.settings.get(RADIUS));
}
return layout;
}
return null;
}
}
private class Orthogonal extends AGraphLayout{
public Orthogonal(String name) {
super(name);
}
@Override
public Object getLayout(IGraphView view) {
if (view instanceof JGraphView) {
JGraphView jgraphview = (JGraphView) view;
OrthogonalLayout layout = new OrthogonalLayout(jgraphview.getGraph());
return layout;
}
return null;
}
}
public mxLayoutsRegister(IGraphLayoutManager layoutManager)
{
layoutManager.registerLayout(new Hierarchical("Hierarchical Layout"));
layoutManager.registerLayout(new Orthogonal("Orthogonal Layout"));
layoutManager.registerLayout(new Circle("Circle Layout"));
}
}