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


Java DefaultEdge.getSource方法代码示例

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


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

示例1: unmapCells

import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
private void unmapCells(Object[] cells) {
	// System.out.println("middlePanel kind: " + middlePanel.getKind() );
	for (int i = 0; i < cells.length; i++) {
		if (cells[i] == null || !(cells[i] instanceof DefaultEdge))
			continue;
		DefaultEdge linkEdge = (DefaultEdge) cells[i];
		DefaultPort srcPort = (DefaultPort) linkEdge.getSource();
		if (srcPort instanceof FunctionBoxGraphPort)
			((FunctionBoxGraphPort) srcPort).setMapStatus(false);
		else {
			MappableNode sourceNode = (MappableNode) srcPort
					.getUserObject();
			sourceNode.setMapStatus(false);
		}
		DefaultPort trgtPort = (DefaultPort) linkEdge.getTarget();
		if (trgtPort instanceof FunctionBoxGraphPort)
			((FunctionBoxGraphPort) trgtPort).setMapStatus(false);
		else {
			MappableNode targetNode = (MappableNode) trgtPort
					.getUserObject();
			targetNode.setMapStatus(false);
		}
	}
}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:25,代码来源:MiddlePanelJGraphController.java

示例2: valueChanged

import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
/**
 * Called whenever the value of the selection changes.
 *
 * @param e the event that characterizes the change.
 */
public void valueChanged(GraphSelectionEvent e)
{
	MappingMainPanel mappingPanel= graphController.getMappingPanel();
       mappingPanel.getGraphController().setGraphSelected(true);
	//the graph is in selection mode, do not set property pan for Element or Attribute
       if(!isAClearSelectionEvent(e))
	{//ignore if it is a clear selection event
		Object obj = e.getCell();
		if (obj instanceof DefaultEdge)
		{//only handles edge, when graph is NOT in CLEAR selection mode.
			DefaultEdge edge = (DefaultEdge) obj;
			DefaultPort srcPort=(DefaultPort)edge.getSource();
			DefaultPort trgtPort=(DefaultPort)edge.getTarget();
			//manually highlight if and only if it is orignated from graph selection.
			Object sourceUserObject =srcPort.getUserObject();
			highlightTreeNodeInTree(sourceUserObject);
			//manually highlight if and only if it is orignated from graph selection.
			Object targetUserObject =trgtPort.getUserObject();// getUserObject(target);
			highlightTreeNodeInTree(targetUserObject);
		}
	}
	
	if(e.getCell() instanceof DefaultGraphCell)
	{
		DefaultGraphCell newSelection = (DefaultGraphCell)e.getCell();
		DefaultPropertiesSwitchController propertySwitchConroller =(DefaultPropertiesSwitchController)mappingPanel.getMiddlePanel().getGraphController().getPropertiesSwitchController();
		propertySwitchConroller.setSelectedItem(newSelection);
	}
	mappingPanel.getMiddlePanel().getGraphController().getPropertiesSwitchController().getPropertiesPage().updateProptiesDisplay(null);
	mappingPanel.getMiddlePanel().getGraphController().setGraphSelected(false);
}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:37,代码来源:LinkSelectionHighlighter.java

示例3: valueChanged

import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
/**
 * Called whenever the value of the selection changes.
 *
 * @param e the event that characterizes the change.
 */
public void valueChanged(GraphSelectionEvent e)
{
	if (mappingPanel.isInDragDropMode())
		return;
	//clean tree highlight if remove graph highlight
    if (!e.isAddedCell())
    {
		if (mappingPanel.getTargetTree() == null)
		{
			JOptionPane.showMessageDialog(mappingPanel, "You should input the source file name first(2).", "No Source file", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else 
			mappingPanel.getTargetTree().clearSelection();
	  
		if (mappingPanel.getSourceTree() == null)
		{
			JOptionPane.showMessageDialog(mappingPanel, "You should input the target file name first(2).", "No Target file", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else 
			mappingPanel.getSourceTree().clearSelection();
    	return;
    }
	if(graphInSelection)
		return;

	graphInSelection = true;
	Object obj = e.getCell();
	if (obj instanceof DefaultEdge)
	{//only handles edge, when graph is NOT in CLEAR selection mode.
		DefaultEdge edge = (DefaultEdge) obj;
		Object source = edge.getSource();
		Object target = edge.getTarget();
		Object sourceUserObject = getUserObject(source);
		highlightTreeNodeInTree(mappingPanel.getSourceTree(), sourceUserObject);

		Object targetUserObject = getUserObject(target);
		highlightTreeNodeInTree(mappingPanel.getTargetTree(), targetUserObject);
	}
	graphInSelection = false;
}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:48,代码来源:LinkSelectionHighlighter.java

示例4: renderInJGraph

import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
public void renderInJGraph()
{
	/** the real renderer */
	ConnectionSet cs = new ConnectionSet();
	Map<Object, AttributeMap> attributes = new Hashtable<Object, AttributeMap>();
	for(DefaultEdge linkEdge:retrieveLinks())
	{
		DefaultPort srcPort=(DefaultPort)linkEdge.getSource();
		DefaultPort trgtPort=(DefaultPort)linkEdge.getTarget();
		DefaultGraphCell sourceCell =(DefaultGraphCell)srcPort.getParent();
		DefaultGraphCell targetCell =(DefaultGraphCell)trgtPort.getParent();

		AttributeMap lineStyle = linkEdge.getAttributes();
		AttributeMap sourceNodeCellAttribute =null;
		if (sourceCell!=null)
			sourceNodeCellAttribute=sourceCell.getAttributes();
		AttributeMap targetNodeCellAttribute =null;
		if (targetCell!=null)
			targetNodeCellAttribute=targetCell.getAttributes();

		Object sourceNode = srcPort.getUserObject();
		Object targetNode = trgtPort.getUserObject();
		try {
			if ( sourceNode instanceof DefaultMappableTreeNode ) 
			{
				if ( (targetNode instanceof DefaultMappableTreeNode) ) {
					// change target node
					DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) targetNode;
					adjustToNewPosition(treeNode, targetNodeCellAttribute);
				}
				// change source node
				DefaultMutableTreeNode srcNode = (DefaultMutableTreeNode) sourceNode;
				adjustToNewPosition(srcNode, sourceNodeCellAttribute);
			}
			if ( sourceNodeCellAttribute != null
					&&targetNodeCellAttribute!=null) {// put in attribute if and only if it is constructed.
				attributes.put(sourceCell, sourceNodeCellAttribute);
				attributes.put(targetCell, targetNodeCellAttribute);
				attributes.put(linkEdge, lineStyle);
				// cs.connect(linkEdge, sourceCell.getChildAt(0), targetCell.getChildAt(0));
				// Log.logInfo(this, "Drew line for : " + mappingComponent.toString());
			}
		} catch (Throwable e) {
			e.printStackTrace();
			//Log.logInfo(this, "Did not draw line for : " + mappingComponent.toString(true));
		}
	}// end of for
	getGraph().getGraphLayoutCache().edit(attributes, cs, null, null);
	getGraph().getGraphLayoutCache().setSelectsAllInsertedCells(false);
}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:51,代码来源:MappingMiddlePanel.java

示例5: doAction

import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
/**
	 * The abstract function that descendant classes must be overridden to provide customsized handling.
	 *
	 * @param e
	 * @return true if the action is finished successfully; otherwise, return false.
	 */
	protected boolean doAction(ActionEvent e)
	{
//		Log.logInfo(this, "GraphDeleteAction's actionPerformed() is called.");
		JGraph graph = getController().getMiddlePanel().getGraph();
		if (!graph.isSelectionEmpty())
		{
			int userChoice = JOptionPane.showConfirmDialog(getMiddlePanel(),
				"Are you sure you want to delete?", "Question",
				JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
			if (userChoice == JOptionPane.YES_OPTION)
			{
				Object[] cells = graph.getSelectionCells();
				DefaultGraphCell graphCell = (DefaultGraphCell) cells[0];
				if (graphCell instanceof DefaultEdge)
				{
					DefaultEdge linkEdge = (DefaultEdge)graphCell;
					DefaultPort srcPort=(DefaultPort)linkEdge.getSource();
					DefaultPort trgtPort=(DefaultPort)linkEdge.getTarget();
					DefaultGraphCell sourceCell =(DefaultGraphCell)srcPort.getParent();
					DefaultGraphCell targetCell =(DefaultGraphCell)trgtPort.getParent();
					//check if the link has any mapped child/descend node
					boolean hasMappedColumn=false;
					
//					if (!hasMappedColumn)
						getController().deleteGraphLink();
				}
				else if (graphCell instanceof FunctionBoxGraphCell)
				{
					//check if any functionPort is mapped
					String errorMsg="";
					for(Object child:graphCell.getChildren())
					{
						FunctionBoxGraphPort fPort=(FunctionBoxGraphPort)child;
						if (fPort.isMapped())
						{
							FunctionData portData=(FunctionData)fPort.getUserObject();
							errorMsg="Mapped port:\nname="+portData.getName()
								+"\ntype="+portData.getType()
								+"\nvalue="+portData.getValue();
							break;
						}
					}
					if(errorMsg.equals(""))
						getController().deleteGraphLink();
					else						
						JOptionPane.showMessageDialog(getMiddlePanel(), errorMsg, "Port is currently mapped.",  JOptionPane.WARNING_MESSAGE);
				}
			}
		}
		else
		{
			JOptionPane.showMessageDialog(getMiddlePanel(), "No graph is currently selected.", "No selection", JOptionPane.WARNING_MESSAGE);
		}
		setSuccessfullyPerformed(true);
		return isSuccessfullyPerformed();
	}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:63,代码来源:GraphDeleteAction.java


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