edu.uci.ics.jung.algorithms.layout.FRLayout Java Examples

The following examples show how to use edu.uci.ics.jung.algorithms.layout.FRLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Mpl.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static <O, A> JComponent doTermView2(Graph<MplStrict2.Node<O, A>, Integer> sgv) {
		if (sgv.getVertexCount() == 0) {
			return new JPanel();
		}
		Layout layout = new FRLayout<>(sgv);
		layout.setSize(new Dimension(600, 400));
		VisualizationViewer vv = new VisualizationViewer<>(layout);

		DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
		gm.setMode(Mode.TRANSFORMING);
		vv.setGraphMouse(gm);
		gm.setMode(Mode.PICKING);
		// vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);

//		vv.getRenderContext().setVertexLabelTransformer(ttt);
		vv.getRenderContext().setEdgeLabelTransformer(xx -> "");

		GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
		JPanel ret = new JPanel(new GridLayout(1, 1));
		ret.add(zzz);
		ret.setBorder(BorderFactory.createEtchedBorder());
		return ret;
	}
 
Example #2
Source File: ImageWriter.java    From SciGraph with Apache License 2.0 6 votes vote down vote up
private static AbstractLayout<Vertex, Edge> getLayout(GraphJung<Graph> graph, String layoutName) {
  switch (layoutName) {
    case "KKLayout":
      return new KKLayout<>(graph);
    case "CircleLayout":
      return new CircleLayout<>(graph);
    case "FRLayout":
      return new FRLayout<>(graph);
    case "FRLayout2":
      return new FRLayout2<>(graph);
    case "ISOMLayout":
      return new ISOMLayout<>(graph);
    case "SpringLayout":
      return new SpringLayout<>(graph);
    default:
      return new KKLayout<>(graph);
  }
}
 
Example #3
Source File: DiagramGenerator.java    From incubator-batchee with Apache License 2.0 6 votes vote down vote up
private Layout<Node, Edge> newLayout(final Diagram diagram) {
    final Layout<Node, Edge> diagramLayout;
    if (layout != null && layout.startsWith("spring")) {
        diagramLayout = new SpringLayout<Node, Edge>(diagram, new ConstantTransformer(Integer.parseInt(config("spring", "100"))));
    } else if (layout != null && layout.startsWith("kk")) {
        Distance<Node> distance = new DijkstraDistance<Node, Edge>(diagram);
        if (layout.endsWith("unweight")) {
            distance = new UnweightedShortestPath<Node, Edge>(diagram);
        }
        diagramLayout = new KKLayout<Node, Edge>(diagram, distance);
    } else if (layout != null && layout.equalsIgnoreCase("circle")) {
        diagramLayout = new CircleLayout<Node, Edge>(diagram);
    } else if (layout != null && layout.equalsIgnoreCase("fr")) {
        diagramLayout = new FRLayout<Node, Edge>(diagram);
    } else {
        final LevelLayout levelLayout = new LevelLayout(diagram);
        levelLayout.adjust = adjust;

        diagramLayout = levelLayout;
    }
    return diagramLayout;
}
 
Example #4
Source File: Mpl.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private static <O, A> JComponent doTermView(Color src, Color dst, Graph<Node<O, A>, Integer> sgv) {
	if (sgv.getVertexCount() == 0) {
		return new JPanel();
	}
	Layout layout = new FRLayout<>(sgv);
	layout.setSize(new Dimension(600, 400));
	VisualizationViewer vv = new VisualizationViewer<>(layout);
	Function<Node<O, A>, Color> vertexPaint = x -> {
		if (x.isInput) {
			return src;
		}
		return dst;
	};
	DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
	gm.setMode(Mode.TRANSFORMING);
	vv.setGraphMouse(gm);
	gm.setMode(Mode.PICKING);
	vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);

	Function<Node<O, A>, String> ttt = arg0 -> {
		String w = arg0.isInput ? "in" : "out";
		return arg0.term + " #" + arg0.which + " " + w;
	};
	vv.getRenderContext().setVertexLabelTransformer(ttt);
	vv.getRenderContext().setEdgeLabelTransformer(xx -> "");

	GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
	JPanel ret = new JPanel(new GridLayout(1, 1));
	ret.add(zzz);
	ret.setBorder(BorderFactory.createEtchedBorder());
	return ret;
}
 
Example #5
Source File: AqlViewer.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
private static <N, E> JComponent viewGraph(DMG<N, E> g) {
	Graph<N, E> sgv = new DirectedSparseMultigraph<>();

	for (N n : g.nodes) {
		sgv.addVertex(n);
	}
	for (E e : g.edges.keySet()) {
		sgv.addEdge(e, g.edges.get(e).first, g.edges.get(e).second);
	}

	if (sgv.getVertexCount() == 0) {
		return new JPanel();
	}
	Layout<N, E> layout = new FRLayout<>(sgv);

	layout.setSize(new Dimension(600, 400));
	VisualizationViewer<N, E> vv = new VisualizationViewer<>(layout);
	Function<N, Paint> vertexPaint = x -> Color.black;
	DefaultModalGraphMouse<N, E> gm = new DefaultModalGraphMouse<>();
	gm.setMode(Mode.TRANSFORMING);
	vv.setGraphMouse(gm);
	gm.setMode(Mode.PICKING);
	vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);

	Function<E, String> et = Object::toString;
	Function<N, String> vt = Object::toString;
	vv.getRenderContext().setEdgeLabelTransformer(et);
	vv.getRenderContext().setVertexLabelTransformer(vt);

	GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
	JPanel ret = new JPanel(new GridLayout(1, 1));
	ret.add(zzz);
	ret.setBorder(BorderFactory.createEtchedBorder());

	vv.getRenderContext().setLabelOffset(16);
	vv.setBackground(Color.white);

	return ret;
}
 
Example #6
Source File: JungLayoutPlan.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
protected Layout<GraphNode, GraphEdge> buildJungLayout(
    DirectedGraph<GraphNode, GraphEdge> jungGraph, Dimension layoutSize) {

  FRLayout<GraphNode, GraphEdge> result =
      new FRLayout<GraphNode, GraphEdge>(jungGraph, layoutSize);
  if (attractMultiplier.isSet()) {
    result.setAttractionMultiplier(attractMultiplier.getValue());
  }
  if (repulsionMultiplier.isSet()) {
    result.setAttractionMultiplier(repulsionMultiplier.getValue());
  }
  return result;
}
 
Example #7
Source File: ShowLayouts.java    From yawl with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return
 */
@SuppressWarnings("unchecked")
private static Class<? extends Layout>[] getCombos()
{
    List<Class<? extends Layout>> layouts = new ArrayList<Class<? extends Layout>>();
    layouts.add(KKLayout.class);
    layouts.add(FRLayout.class);
    layouts.add(CircleLayout.class);
    layouts.add(SpringLayout.class);
    layouts.add(SpringLayout2.class);
    layouts.add(ISOMLayout.class);
    return layouts.toArray(new Class[0]);
}