當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。