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


Java LayoutTool类代码示例

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


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

示例1: recalculatePorts

import y.layout.LayoutTool; //导入依赖的package包/类
public static void recalculatePorts(final CanonicMultiStageLayouter layouter,
    final Graph2D graph) {
  // Effect: Ensures that ports are drawn onto node borders, and not onto the node center. (Only
  // Circular layout!)
  // Justification: Circular layout uses as the standard port the center of the node, this will be
  // corrected by
  // calling the following function.
  // Exclusion: Port of nodes with non rectangle shapes, have to be additionally recalculated.

  if (layouter instanceof CircularLayouter) {
    // Port correction
    LayoutTool.clipEdgesOnBB(graph);

    // Recalculate ports (necessary for circular proximity nodes)
    final PortCalculator pc = new PortCalculator();
    final NodeRealizerIntersectionCalculator nrics =
        new NodeRealizerIntersectionCalculator(graph, true);
    graph.addDataProvider(IntersectionCalculator.SOURCE_INTERSECTION_CALCULATOR_DPKEY, nrics);
    final NodeRealizerIntersectionCalculator nrict =
        new NodeRealizerIntersectionCalculator(graph, false);
    graph.addDataProvider(IntersectionCalculator.TARGET_INTERSECTION_CALCULATOR_DPKEY, nrict);

    pc.doLayout(graph);
  }
}
 
开发者ID:google,项目名称:binnavi,代码行数:26,代码来源:LayoutFunctions.java

示例2: verticalShiftSubgraph

import y.layout.LayoutTool; //导入依赖的package包/类
public void verticalShiftSubgraph(LayoutGraph graph, Node startingNode,
		Node end, boolean isFlipped) {

	NodeList nodeList = getSequenceNodes(startingNode, end, graph, true);
	boolean isPeptide = isPeptidePolymer(startingNode);
	double shiftStep = isPeptide ? getViewMetrics()
			.getShiftForFlippedPeptideSequence() : getViewMetrics()
			.getShiftForFlippedNucleotideSequence();

	LayoutTool.moveSubgraph(graph, nodeList.nodes(), 0,
			isFlipped ? shiftStep : -shiftStep);
}
 
开发者ID:PistoiaHELM,项目名称:HELMEditor,代码行数:13,代码来源:AbstractLayoutPrimitives.java

示例3: openFolder

import y.layout.LayoutTool; //导入依赖的package包/类
/**
 * Opens a folder node.
 * 
 * @param graph The graph the folder node belongs to.
 * @param folderNode The folder node to be opened.
 */
public static void openFolder(final Graph2D graph, final Node folderNode) {
  Preconditions.checkNotNull(graph, "Error: Graph argument can not be null");
  Preconditions.checkNotNull(folderNode, "Error: Folder node argument can not be null");

  final HierarchyManager hierarchy = graph.getHierarchyManager();

  final double w = graph.getWidth(folderNode);
  final double h = graph.getHeight(folderNode);

  final NodeList folderNodes = new NodeList();
  folderNodes.add(folderNode);

  graph.firePreEvent();

  for (final NodeCursor nc = folderNodes.nodes(); nc.ok(); nc.next()) {
    // get original location of folder node
    final Graph2D innerGraph = (Graph2D) hierarchy.getInnerGraph(nc.node());
    final YPoint folderP = graph.getLocation(nc.node());
    final NodeList innerNodes = new NodeList(innerGraph.nodes());

    hierarchy.openFolder(nc.node());

    // get new location of group node
    final Rectangle2D.Double gBox = graph.getRealizer(nc.node()).getBoundingBox();
    // move grouped nodes to former location of folder node
    LayoutTool.moveSubgraph(graph, innerNodes.nodes(), folderP.x - gBox.x, folderP.y - gBox.y);
  }
  graph.firePostEvent();

  graph.unselectAll();
  for (final NodeCursor nc = folderNodes.nodes(); nc.ok(); nc.next()) {
    graph.setSelected(nc.node(), true);
  }

  // if the node size has changed, delete source ports of out-edges
  // and target ports of in-edges to ensure that all edges still connect
  // to the node
  if ((w != graph.getWidth(folderNode)) || (h != graph.getHeight(folderNode))) {
    for (final EdgeCursor ec = folderNode.outEdges(); ec.ok(); ec.next()) {
      graph.setSourcePointRel(ec.edge(), YPoint.ORIGIN);
    }
    for (final EdgeCursor ec = folderNode.inEdges(); ec.ok(); ec.next()) {
      graph.setTargetPointRel(ec.edge(), YPoint.ORIGIN);
    }
  }

  graph.updateViews();
}
 
开发者ID:google,项目名称:binnavi,代码行数:55,代码来源:YHelpers.java

示例4: shiftSubgraph

import y.layout.LayoutTool; //导入依赖的package包/类
/**
 * a helper class that could shift a DNA/RNA sequence to make the pairing
 * layout nicely
 * 
 * @param view
 *            : the display of the current graph
 * @param startingNode
 *            : all node after startingNode (include the startingNode) will
 *            be shifted
 * @param yshift
 *            : the y direction shift distance in pixel
 * @throws org.helm.notation.MonomerException
 * @throws org.jdom.JDOMException
 * @throws java.io.IOException
 */
private static void shiftSubgraph(Graph2DView view, Node startingNode,
		int yshift) throws MonomerException, JDOMException, IOException {

	Graph2D graph = view.getGraph2D();
	NodeList nodeList = SequenceGraphTools.getNucleicAcidSequenceNodes(
			startingNode, graph);
	NodeCursor sequenceNodes = nodeList.nodes();
	MonomerInfo monomerInfo = null;
	Monomer monomer = null;
	Map<String, Map<String, Monomer>> monomerDB = MonomerStoreCache
			.getInstance().getCombinedMonomerStore().getMonomerDB();
	// Map<String, Map<String, Monomer>> monomerDB = MonomerFactory
	// .getInstance().getMonomerDB();
	NodeMap monomerInfoMap = (NodeMap) graph
			.getDataProvider(NodeMapKeys.MONOMER_REF);
	EdgeMap edgeMap = (EdgeMap) graph
			.getDataProvider(EdgeMapKeys.EDGE_INFO);
	EdgeCursor edges = null;
	EditorEdgeInfoData edgeInfo = null;

	for (; sequenceNodes.ok(); sequenceNodes.next()) {
		monomerInfo = (MonomerInfo) monomerInfoMap
				.get(sequenceNodes.node());
		monomer = monomerDB.get(monomerInfo.getPolymerType()).get(
				monomerInfo.getMonomerID());

		// for starting startingNode 5', the monomer is null (5')
		if (monomer != null
				&& monomer.getMonomerType().equalsIgnoreCase(
						Monomer.BRANCH_MOMONER_TYPE)) {
			edges = sequenceNodes.node().edges();
			for (; edges.ok(); edges.next()) {
				edgeInfo = (EditorEdgeInfoData) edgeMap.get(edges.edge());
				if (edgeInfo.isPair()) {
					NodeRealizer sourceNodeRealizer = graph
							.getRealizer(sequenceNodes.node());
					NodeRealizer targetNodeRealizer = null;
					if (sequenceNodes.node() != edges.edge().target()) {
						targetNodeRealizer = graph.getRealizer(edges.edge()
								.target());
					} else {
						targetNodeRealizer = graph.getRealizer(edges.edge()
								.source());
					}
					// if the source startingNode and target startingNode is
					// not on the same vertical line

					if (sourceNodeRealizer.getCenterX() != targetNodeRealizer
							.getCenterX()) {
						LayoutTool.moveSubgraph(graph, nodeList.nodes(),
								targetNodeRealizer.getCenterX()
										- sourceNodeRealizer.getCenterX(),
								yshift);
						break;

					}

				}
			}
		}
	}

}
 
开发者ID:PistoiaHELM,项目名称:HELMEditor,代码行数:79,代码来源:SequenceLayout.java

示例5: shiftSubgraph

import y.layout.LayoutTool; //导入依赖的package包/类
public void shiftSubgraph(LayoutGraph graph, Node startingNode, Node end,
		Node parentHyperNode, boolean isFlipped) {
	DataProvider node2Hipernode = graph
			.getDataProvider(NodeMapKeys.NODE2PARENT_HYPERNODE);
	DataProvider edgeMap = graph.getDataProvider(EdgeMapKeys.EDGE_INFO);
	NodeList nodeList = getSequenceNodes(startingNode, end, graph, true);

	for (NodeCursor sequenceNodes = nodeList.nodes(); sequenceNodes.ok(); sequenceNodes
			.next()) {
		for (EdgeCursor edges = sequenceNodes.node().edges(); edges.ok(); edges
				.next()) {
			EdgeInfo edgeInfo = (EdgeInfo) edgeMap.get(edges.edge());
			if (edgeInfo.isPair() || !edgeInfo.isRegular()
					&& isPeptidePolymer(nodeList.firstNode())) {
				Node sourceNode = sequenceNodes.node();
				Node targetNode = null;
				if (sequenceNodes.node() != edges.edge().target()) {
					targetNode = edges.edge().target();
				} else {
					targetNode = edges.edge().source();
				}

				// we should shift sequence in compliance with appropriate
				// sequence which has already been laid out.
				// If parentHyperNode is null then shifted node and the
				// sequence
				// that is being shifted are the parts of one component
				Node targetHiperNode = (Node) node2Hipernode
						.get(targetNode);
				if (parentHyperNode == null
						|| parentHyperNode.equals(targetHiperNode)) {
					LayoutTool
							.moveSubgraph(
									graph,
									nodeList.nodes(),
									graph.getCenterX(targetNode)
											- graph.getCenterX(sourceNode),
									isFlipped ? isPeptideBranchEdge(edgeInfo) ? getViewMetrics()
											.getShiftForFlippedPeptideSequence()
											: getViewMetrics()
													.getShiftForFlippedNucleotideSequence()
											: 0);
					return;
				}
			}
		}
	}
}
 
开发者ID:PistoiaHELM,项目名称:HELMEditor,代码行数:49,代码来源:AbstractLayoutPrimitives.java


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