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

The following examples show how to use edu.uci.ics.jung.algorithms.layout.Layout. 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: 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 #2
Source File: VisualEdgeRenderer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Uses the render context to create a compact shape for the given vertex
 * 
 * @param rc the render context
 * @param layout the layout
 * @param vertex the vertex
 * @return the vertex shape
 * @see VertexShapeProvider#getFullShape()
 */
public Shape getFullShape(RenderContext<V, E> rc, Layout<V, E> layout, V vertex) {
	Function<? super V, Shape> vertexShaper = rc.getVertexShapeTransformer();
	Shape shape = null;
	if (vertexShaper instanceof VisualGraphVertexShapeTransformer) {
		@SuppressWarnings("unchecked")
		VisualGraphVertexShapeTransformer<V> vgShaper =
			(VisualGraphVertexShapeTransformer<V>) vertexShaper;

		// use the viewable shape here, as it is visually pleasing
		shape = vgShaper.transformToFullShape(vertex);
	}
	else {
		shape = vertexShaper.apply(vertex);
	}

	return transformFromLayoutToView(rc, layout, vertex, shape);
}
 
Example #3
Source File: GroupedFunctionGraphVertex.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private Map<FGVertex, Point2D> getCurrentVertexLocations() {
	FGController fgController = getController();
	FGView view = fgController.getView();
	VisualizationViewer<FGVertex, FGEdge> viewer = view.getPrimaryGraphViewer();
	Layout<FGVertex, FGEdge> graphLayout = viewer.getGraphLayout();
	Graph<FGVertex, FGEdge> graph = graphLayout.getGraph();
	Collection<FGVertex> currentVertices = graph.getVertices();
	Map<FGVertex, Point2D> map = new HashMap<>();
	for (FGVertex vertex : currentVertices) {
		if (vertex == this) {
			// not sure if we need to do this, but, conceptually, we are getting the locations
			// in the graph before this group node is installed
			continue;
		}
		Point2D point2D = graphLayout.apply(vertex);
		map.put(vertex, new Point((int) point2D.getX(), (int) point2D.getY()));
	}
	return map;
}
 
Example #4
Source File: FcgExpandingVertexCollection.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private int compareVerticesByLayoutPosition(FcgVertex v1, FcgVertex v2) {

		Layout<FcgVertex, FcgEdge> layout = viewer.getGraphLayout();

		FcgLevel l1 = v1.getLevel();
		FcgLevel l2 = v2.getLevel();
		int result = l1.compareTo(l2);
		if (result != 0) {

			//  prefer the parent level over all
			if (l1.equals(parentLevel)) {
				return -1;
			}
			else if (l2.equals(parentLevel)) {
				return 1;
			}

			return result;
		}

		Point2D p1 = layout.apply(v1);
		Point2D p2 = layout.apply(v2);
		return (int) (p1.getX() - p2.getX());
	}
 
Example #5
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 #6
Source File: GroupHistoryInfo.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public GroupHistoryInfo(FunctionGraph functionGraph, GroupedFunctionGraphVertex groupVertex) {
	this.groupVertices = new HashSet<>(groupVertex.getVertices());
	if (groupVertices.isEmpty()) {
		throw new IllegalArgumentException(
			"Cannot create a group history entry with no vertices!");
	}

	this.groupDescription = groupVertex.getUserText();

	if (groupDescription == null) {
		throw new IllegalArgumentException("Group description cannot be null");
	}

	Layout<FGVertex, FGEdge> graphLayout = functionGraph.getLayout();
	Point2D location = graphLayout.apply(groupVertex);
	locationInfo = new PointInfo(location);

	addressInfo = new AddressInfo(groupVertex);
}
 
Example #7
Source File: VisualEdgeRenderer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Uses the render context to create a compact shape for the given vertex
 * 
 * @param rc the render context
 * @param layout the layout
 * @param vertex the vertex
 * @return the vertex shape
 * @see VertexShapeProvider#getCompactShape()
 */
protected Shape getCompactShape(RenderContext<V, E> rc, Layout<V, E> layout, V vertex) {

	Function<? super V, Shape> vertexShaper = rc.getVertexShapeTransformer();
	Shape shape = null;
	if (vertexShaper instanceof VisualGraphVertexShapeTransformer) {
		@SuppressWarnings("unchecked")
		VisualGraphVertexShapeTransformer<V> vgShaper =
			(VisualGraphVertexShapeTransformer<V>) vertexShaper;

		// use the viewable shape here, as it is visually pleasing
		shape = vgShaper.transformToCompactShape(vertex);
	}
	else {
		shape = vertexShaper.apply(vertex);
	}

	return transformFromLayoutToView(rc, layout, vertex, shape);
}
 
Example #8
Source File: ProcletModel.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String [] args) {
	ProcletModel pmodel = new ProcletModel("visit");
	pmodel.buildFromDB();
	pmodel.persistProcletModel();
	ProcletBlock block1 = new ProcletBlock("b1",BlockType.PI,false,5);
	ProcletBlock block2 = new ProcletBlock("b2",BlockType.PI,false,5);
	pmodel.addBlock(block1);
	pmodel.addBlock(block2);
	ProcletPort port = new ProcletPort("p1",Direction.OUT,Signature.ONE,Signature.ONE);
	ProcletPort port2 = new ProcletPort("p2",Direction.OUT,Signature.ONE,Signature.ONE);
	pmodel.addProcletPort(port, block1);
	pmodel.addProcletPort(port2, block1);
	pmodel.getBlocks();
	pmodel.getPortsBlock(block1);
	// visualization
	Layout layout = new CircleLayout(pmodel);
	layout.setSize(new Dimension(300,300));
	BasicVisualizationServer vv = new BasicVisualizationServer(layout);
	vv.setPreferredSize(new Dimension(350,350));
	
	JFrame frame = new JFrame("simple");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().add(vv);
	frame.pack();
	frame.setVisible(true);
}
 
Example #9
Source File: ArticulatedEdgeRouter.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private Map<V, Rectangle> getVertexBounds() {
	if (cachedVertexBoundsMap != null) {
		return cachedVertexBoundsMap;
	}

	Layout<V, E> layout = viewer.getGraphLayout();
	Graph<V, E> graph = layout.getGraph();
	Collection<V> vertices = graph.getVertices();

	Map<V, Rectangle> map = new HashMap<>();
	for (V v : vertices) {
		Rectangle vertexBounds = getVertexBoundsInGraphSpace(viewer, v);
		map.put(v, vertexBounds);
	}

	cachedVertexBoundsMap = map;
	return map;
}
 
Example #10
Source File: VisualGraphAbstractGraphMousePlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected boolean checkForEdge(MouseEvent e) {
	if (!checkModifiers(e) || isOverVertex(e)) {
		selectedEdge = null;
		return false;
	}

	VisualizationViewer<V, E> vv = getViewer(e);
	GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
	Layout<V, E> layout = vv.getGraphLayout();
	if (pickSupport == null) {
		return false;
	}

	// p is the screen point for the mouse event
	Point2D p = e.getPoint();
	selectedEdge = pickSupport.getEdge(layout, p.getX(), p.getY());
	if (selectedEdge == null) {
		return false;
	}

	e.consume();
	isHandlingMouseEvents = true;
	return true;
}
 
Example #11
Source File: VisualGraphPickingGraphMousePlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void dragVertices(MouseEvent e, GraphViewer<V, E> viewer) {

		Point p = e.getPoint();
		RenderContext<V, E> context = viewer.getRenderContext();
		MultiLayerTransformer xformer = context.getMultiLayerTransformer();
		Point2D layoutPoint = xformer.inverseTransform(p);
		Point2D layoutDown = xformer.inverseTransform(down);
		Layout<V, E> layout = viewer.getGraphLayout();
		double dx = layoutPoint.getX() - layoutDown.getX();
		double dy = layoutPoint.getY() - layoutDown.getY();
		PickedState<V> ps = viewer.getPickedVertexState();

		for (V v : ps.getPicked()) {
			Point2D vertexPoint = layout.apply(v);
			vertexPoint.setLocation(vertexPoint.getX() + dx, vertexPoint.getY() + dy);
			layout.setLocation(v, vertexPoint);
			updatedArticulatedEdges(viewer, v);
		}

		down = p;
		e.consume();
	}
 
Example #12
Source File: VisualGraphPickingGraphMousePlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void maybeClearPickedState(MouseEvent event) {
	VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) event.getSource();
	PickedState<V> pickedVertexState = vv.getPickedVertexState();
	PickedState<E> pickedEdgeState = vv.getPickedEdgeState();
	if (pickedEdgeState == null || pickedVertexState == null) {
		return;
	}

	GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
	Layout<V, E> layout = vv.getGraphLayout();

	Point2D mousePoint = event.getPoint();
	V v = pickSupport.getVertex(layout, mousePoint.getX(), mousePoint.getY());
	if (v != null) {
		return;
	}

	E e = pickSupport.getEdge(layout, mousePoint.getX(), mousePoint.getY());
	if (e != null) {
		return;
	}

	pickedEdgeState.clear();
	pickedVertexState.clear();
}
 
Example #13
Source File: GraphViewer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private ToolTipInfo<?> getToolTipInfo(MouseEvent event) {
	Layout<V, E> viewerLayout = getGraphLayout();
	Point p = event.getPoint();

	// check for a vertex hit first, otherwise, we get edge hits when we are hovering 
	// over a vertex, due to how edges are interpreted as existing all the way to the 
	// center point of a vertex
	V vertex = getPickSupport().getVertex(viewerLayout, p.getX(), p.getY());
	if (vertex != null) {
		return new VertexToolTipInfo(vertex, event);
	}

	E edge = getPickSupport().getEdge(viewerLayout, p.getX(), p.getY());
	if (edge != null) {
		return new EdgeToolTipInfo(edge, event);
	}

	// no vertex or edge hit; just create a basic info that is essentially a null-object
	// placeholder to prevent NPEs
	return new VertexToolTipInfo(vertex, event);
}
 
Example #14
Source File: AbstractVisualVertexRenderer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Uses the render context to create a compact shape for the given vertex
 * 
 * @param rc the render context
 * @param layout the layout
 * @param vertex the vertex
 * @return the vertex shape
 * @see VertexShapeProvider#getFullShape()
 */
public Shape getFullShape(RenderContext<V, E> rc, Layout<V, E> layout, V vertex) {
	Function<? super V, Shape> vertexShaper = rc.getVertexShapeTransformer();
	Shape shape = null;
	if (vertexShaper instanceof VisualGraphVertexShapeTransformer) {
		@SuppressWarnings("unchecked")
		VisualGraphVertexShapeTransformer<V> vgShaper =
			(VisualGraphVertexShapeTransformer<V>) vertexShaper;

		// use the viewable shape here, as it is visually pleasing
		shape = vgShaper.transformToFullShape(vertex);
	}
	else {
		shape = vertexShaper.apply(vertex);
	}

	return transformFromLayoutToView(rc, layout, vertex, shape);
}
 
Example #15
Source File: JungLayoutPlan.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
protected Layout<GraphNode,GraphEdge> buildJungLayout(
        DirectedGraph<GraphNode, GraphEdge> jungGraph,
        Dimension layoutSize) {
  SpringLayout<GraphNode, GraphEdge> result =
          new SpringLayout<GraphNode, GraphEdge>(jungGraph);
  result.setSize(layoutSize);
  if (force.isSet()) {
    result.setForceMultiplier(force.getValue());
  }
  if (range.isSet()) {
    result.setRepulsionRange(range.getValue());
  }
  if (stretch.isSet()) {
    result.setStretch(stretch.getValue());
  }
  return result;
}
 
Example #16
Source File: BasicEdgeRouter.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected boolean isOccluded(E edge, Shape graphSpaceShape) {

		Layout<V, E> layout = viewer.getGraphLayout();
		Graph<V, E> graph = layout.getGraph();
		Collection<V> vertices = graph.getVertices();

		for (V vertex : vertices) {
			Rectangle vertexBounds = getVertexBoundsInGraphSpace(viewer, vertex);

			Pair<V> endpoints = graph.getEndpoints(edge);
			if (vertex == endpoints.getFirst() || vertex == endpoints.getSecond()) {
				// do we ever care if an edge is occluded by its own vertices?
				continue;
			}

			if (graphSpaceShape.intersects(vertexBounds)) {
				return true;
			}
		}

		return false;
	}
 
Example #17
Source File: VisualGraphAbstractGraphMousePlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected boolean checkForVertex(MouseEvent e) {
	if (!checkModifiers(e)) {
		selectedVertex = null;
		return false;
	}

	VisualizationViewer<V, E> vv = getViewer(e);
	GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
	Layout<V, E> layout = vv.getGraphLayout();
	if (pickSupport == null) {
		return false;
	}

	// p is the screen point for the mouse event
	Point2D p = e.getPoint();
	selectedVertex = pickSupport.getVertex(layout, p.getX(), p.getY());
	if (selectedVertex == null) {
		return false;
	}

	e.consume();
	return true;
}
 
Example #18
Source File: GraphViewerTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected TestLayoutProvider createLayoutProvider() {
	return new TestLayoutProvider() {
		@Override
		protected Layout<AbstractTestVertex, TestEdge> createJungLayout(TestVisualGraph g) {
			return new KKLayout<>(g);
		}
	};
}
 
Example #19
Source File: DiagramGenerator.java    From incubator-batchee with Apache License 2.0 5 votes vote down vote up
public void labelEdge(final RenderContext<Node, Edge> rc, final Layout<Node, Edge> layout, final Edge e, final String label) {
    if (label == null || label.length() == 0) {
        return;
    }

    final Graph<Node, Edge> graph = layout.getGraph();
    // don't draw edge if either incident vertex is not drawn
    final Pair<Node> endpoints = graph.getEndpoints(e);
    final Node v1 = endpoints.getFirst();
    final Node v2 = endpoints.getSecond();
    if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Edge>getInstance(graph, e))) {
        return;
    }

    if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Node>getInstance(graph, v1)) ||
        !rc.getVertexIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Node>getInstance(graph, v2))) {
        return;
    }

    final Point2D p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(v1));
    final Point2D p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(v2));

    final GraphicsDecorator g = rc.getGraphicsContext();
    final Component component = prepareRenderer(rc, rc.getEdgeLabelRenderer(), label, rc.getPickedEdgeState().isPicked(e), e);
    final Dimension d = component.getPreferredSize();

    final AffineTransform old = g.getTransform();
    final AffineTransform xform = new AffineTransform(old);
    final FontMetrics fm = g.getFontMetrics();
    int w = fm.stringWidth(e.text);
    double p = Math.max(0, p1.getX() + p2.getX() - w);
    xform.translate(Math.min(layout.getSize().width - w, p / 2), (p1.getY() + p2.getY() - fm.getHeight()) / 2);
    g.setTransform(xform);
    g.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);

    g.setTransform(old);
}
 
Example #20
Source File: TestLayoutProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public TestGraphLayout getLayout(TestVisualGraph g, TaskMonitor monitor)
		throws CancelledException {
	Layout<AbstractTestVertex, TestEdge> jungLayout = new DAGLayout<>(g);

	Collection<AbstractTestVertex> vertices = g.getVertices();
	for (AbstractTestVertex v : vertices) {
		Point2D p = jungLayout.apply(v);
		v.setLocation(p);
	}

	return new TestGraphLayout(jungLayout);
}
 
Example #21
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected Point2D getLocation(FGVertex vertex) {
	FGController controller = getFunctionGraphController();
	FGView view = controller.getView();
	VisualizationViewer<FGVertex, FGEdge> primaryGraphViewer = view.getPrimaryGraphViewer();
	VisualizationModel<FGVertex, FGEdge> model = primaryGraphViewer.getModel();
	Layout<FGVertex, FGEdge> graphLayout = model.getGraphLayout();
	return graphLayout.apply(vertex);
}
 
Example #22
Source File: JungLayoutRunner.java    From depan with Apache License 2.0 5 votes vote down vote up
protected Counted(
    Rectangle2D region,
    Layout<GraphNode, GraphEdge> jungLayout,
    int layoutCost) {
  super(region, jungLayout, layoutCost);
  stepsRemaining = layoutCost;
}
 
Example #23
Source File: JungWrappingVisualGraphLayoutAdapter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Layout<V, E> cloneJungLayout(VisualGraph<V, E> newGraph) {

	Class<? extends Layout> delegateClass = delegate.getClass();
	try {
		Constructor<? extends Layout> constructor = delegateClass.getConstructor(Graph.class);
		Layout layout = constructor.newInstance(newGraph);
		return layout;
	}
	catch (Exception e) {
		throw new RuntimeException("Unable to clone jung graph: " + delegate.getClass(), e);
	}
}
 
Example #24
Source File: SampleGraphLayout.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected Layout<SampleVertex, SampleEdge> cloneJungLayout(
		VisualGraph<SampleVertex, SampleEdge> newGraph) {

	Layout<SampleVertex, SampleEdge> newJungLayout = cloneJungLayout(newGraph);
	return new SampleGraphLayout(newJungLayout);
}
 
Example #25
Source File: JungWrappingVisualGraphLayoutAdapter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public JungWrappingVisualGraphLayoutAdapter cloneLayout(VisualGraph<V, E> newGraph) {

	Layout<V, E> newJungLayout = cloneJungLayout(newGraph);
	return new JungWrappingVisualGraphLayoutAdapter(newJungLayout);
}
 
Example #26
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 #27
Source File: SampleGraphLayoutProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void initVertexLocations(SampleGraph g, Layout<SampleVertex, SampleEdge> layout) {
	Collection<SampleVertex> vertices = g.getVertices();
	for (SampleVertex v : vertices) {
		Point2D p = layout.apply(v);
		v.setLocation(p);
	}
}
 
Example #28
Source File: SampleGraphJungLayout.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected Layout<SampleVertex, SampleEdge> cloneJungLayout(
		VisualGraph<SampleVertex, SampleEdge> newGraph) {

	Layout<SampleVertex, SampleEdge> newJungLayout = cloneJungLayout(newGraph);
	return new SampleGraphJungLayout(newJungLayout);
}
 
Example #29
Source File: FGVertexRenderer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintVertexOrVertexShape(RenderContext<FGVertex, FGEdge> rc, GraphicsDecorator g,
		Layout<FGVertex, FGEdge> layout, FGVertex vertex, Shape compactShape, Shape fullShape) {

	if (isScaledPastVertexPaintingThreshold(rc)) {
		paintScaledVertex(rc, vertex, g, compactShape);
		return;
	}

	if (vertex instanceof GroupedFunctionGraphVertex) {
		// paint depth images offset from main vertex
		Rectangle originalBounds = fullShape.getBounds();
		Rectangle paintBounds = (Rectangle) originalBounds.clone();
		Set<FGVertex> vertices = ((GroupedFunctionGraphVertex) vertex).getVertices();
		int offset = 5;
		int size = vertices.size();
		if (size > 3) {
			size = size / 3; // don't paint one-for-one, that's a bit much
			size = Math.max(size, 2);  // we want at least 2, to give some depth
		}
		int currentOffset = offset * size;
		for (int i = size - 1; i >= 0; i--) {
			paintBounds.x = originalBounds.x + currentOffset;
			paintBounds.y = originalBounds.y + currentOffset;
			currentOffset -= offset;
			paintVertex(rc, g, vertex, paintBounds, layout);
		}
	}

	// paint one final time
	Rectangle bounds = fullShape.getBounds();
	paintVertex(rc, g, vertex, bounds, layout);
}
 
Example #30
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;
}