当前位置: 首页>>代码示例>>Java>>正文


Java MutableTransformer.transform方法代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.transform.MutableTransformer.transform方法的典型用法代码示例。如果您正苦于以下问题:Java MutableTransformer.transform方法的具体用法?Java MutableTransformer.transform怎么用?Java MutableTransformer.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uci.ics.jung.visualization.transform.MutableTransformer的用法示例。


在下文中一共展示了MutableTransformer.transform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getScaleFactor

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的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

示例2: transform

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
public Point2D transform(Point2D p) {
    MutableTransformer transformer = GraphVisualizationPanel.this.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
    return (transformer.transform(p));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:5,代码来源:GraphVisualizationPanel.java

示例3: centerGraph

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的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.visualization.transform.MutableTransformer.transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。