• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AbstractLayout类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中edu.uci.ics.jung.algorithms.layout.AbstractLayout的典型用法代码示例。如果您正苦于以下问题:Java AbstractLayout类的具体用法?Java AbstractLayout怎么用?Java AbstractLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AbstractLayout类属于edu.uci.ics.jung.algorithms.layout包,在下文中一共展示了AbstractLayout类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: startLink

import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
/**
 * Called when the drawing of a new link/edge is started
 *
 * @param startVertex
 */
public void startLink(final VertexContext startVertex) {
    if (startVertex == null) {
        return;
    }

    final AbstractLayout<Object, JobGraphLink> graphLayout = _graphContext.getGraphLayout();
    final int x = (int) graphLayout.getX(startVertex.getVertex());
    final int y = (int) graphLayout.getY(startVertex.getVertex());

    logger.debug("startLink({})", startVertex);

    _startVertex = startVertex;
    _startPoint = new Point(x, y);

    transformEdgeShape(_startPoint, _startPoint);
    _graphContext.getVisualizationViewer().addPostRenderPaintable(_edgePaintable);
    transformArrowShape(_startPoint, _startPoint);
    _graphContext.getVisualizationViewer().addPostRenderPaintable(_arrowPaintable);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:25,代码来源:JobGraphLinkPainter.java


示例2: getLayout

import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
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);
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:19,代码来源:ImageWriter.java


示例3: writeTo

import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
@Override
public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations,
    MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException {
  Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH));
  Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT));
  String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT);

  GraphJung<Graph> graph = new GraphJung<Graph>(data);
  AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName);
  layout.setSize(new Dimension(width, height));

  BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout);
  viz.setPreferredSize(new Dimension(width, height));
  viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer);
  viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer);
  viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer);

  BufferedImage bi = renderImage(viz);
  String imageType = null;
  if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) {
    imageType = "jpg";
  } else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) {
    imageType = "png";
  }
  ImageIO.write(bi, imageType, out);
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:27,代码来源:ImageWriter.java


示例4: getScaleFactor

import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
private float getScaleFactor(int imgWidth, int imgHeight) {

		MutableTransformer layout2 = vv.getRenderContext()
				.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
		double top = Double.MAX_VALUE;
		double bottom = Double.MAX_VALUE;
		double left = Double.MAX_VALUE;
		double right = Double.MAX_VALUE;
		double maxSize = 0;

		for (Vertex v : network.getVertices()) {
			Point2D p;
			if (layout instanceof AbstractLayout)
				p = ((AbstractLayout<Vertex, Edge>) layout).transform(v);
			else
				p = ((TreeLayout<Vertex, Edge>) layout).transform(v);
			Point2D invP = layout2.transform(p);
			if (top < invP.getY() || top == Double.MAX_VALUE)
				top = invP.getY();
			if (bottom > invP.getY() || bottom == Double.MAX_VALUE)
				bottom = invP.getY();
			if (left > invP.getX() || left == Double.MAX_VALUE)
				left = invP.getX();
			if (right < invP.getX() || right == Double.MAX_VALUE)
				right = invP.getX();

			if (v.getSize() > maxSize)
				maxSize = v.getSize();
		}

		double width = Math.abs(left - right);
		double height = Math.abs(top - bottom);

		if (width > height)
			return (float) ((imgWidth - maxSize * 0.5) / width);
		else
			return (float) ((imgHeight - maxSize * 0.5) / height);
	}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:39,代码来源:JpegExporter.java


示例5: getGraphLayout

import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
public AbstractLayout<Object, JobGraphLink> getGraphLayout() {
    Layout<Object, JobGraphLink> layout = getVisualizationViewer().getGraphLayout();
    while (layout instanceof LayoutDecorator) {
        layout = ((LayoutDecorator<Object, JobGraphLink>) layout).getDelegate();
    }
    return (AbstractLayout<Object, JobGraphLink>) layout;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:8,代码来源:JobGraphContext.java


示例6: centerGraph

import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
/**
 * This method finds the location of the graph relative to the viewer and
 * shifts is so that it appears in the center of JUNG's VisualizationViewer.
 */
public static Point2D centerGraph(VisualizationViewer<Vertex, Edge> vv, BrowsableNetwork network, Layout<Vertex, Edge> layout,
		EditingModalGraphMouse<Vertex, Edge> mouse) {

	MutableTransformer layout2 = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
	double top = Double.MAX_VALUE;
	double bottom = Double.MAX_VALUE;
	double left = Double.MAX_VALUE;
	double right = Double.MAX_VALUE;

	for (Vertex v : network.getVertices()) {
		Point2D p;
		if (layout instanceof AbstractLayout)
			p = ((AbstractLayout<Vertex, Edge>) layout).transform(v);
		else
			p = ((TreeLayout<Vertex, Edge>) layout).transform(v);
		Point2D invP = layout2.transform(p);
		if (top < invP.getY() || top == Double.MAX_VALUE)
			top = invP.getY();
		if (bottom > invP.getY() || bottom == Double.MAX_VALUE)
			bottom = invP.getY();
		if (left > invP.getX() || left == Double.MAX_VALUE)
			left = invP.getX();
		if (right < invP.getX() || right == Double.MAX_VALUE)
			right = invP.getX();
	}
	if (mouse != null) {
		double scale = 0;
		do {
			scale = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).getScale();
			mouse.mouseWheelMoved(new MouseWheelEvent(vv, 0, 0, 0, vv.getWidth() / 2, vv.getHeight() / 2, 1, false, 1, -1, -1));
		} while (scale >= 1);
	}
	vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)
			.setScale(1, 1, new Point((int) (vv.getCenter().getX() - (right + left) / 2), (int) (vv.getCenter().getY() - (top + bottom) / 2)));

	double deltaX = vv.getCenter().getX() - (right + left) / 2;
	double deltaY = vv.getCenter().getY() - (top + bottom) / 2;
	if (!Double.isInfinite(deltaX) && !Double.isInfinite(deltaY) && !Double.isNaN(deltaX) && !Double.isNaN(deltaY)) {
		layout2.translate(deltaX, deltaY);
	}

	return vv.getCenter();
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:48,代码来源:NetworkPanel.java



注:本文中的edu.uci.ics.jung.algorithms.layout.AbstractLayout类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JRDesignExpression类代码示例发布时间:2022-05-21
下一篇:
Java LogAxis类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap