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


Java GraphModel类代码示例

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


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

示例1: getOffset

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public int getOffset() {
	JmtCell sourceOfEdge = (JmtCell) ((DefaultPort) this.getSource()).getParent();
	Rectangle boundsSource = GraphConstants.getBounds(sourceOfEdge.getAttributes()).getBounds();
	JmtCell targetOfEdge = (JmtCell) ((DefaultPort) this.getTarget()).getParent();
	Rectangle boundsTarget = GraphConstants.getBounds(targetOfEdge.getAttributes()).getBounds();
	GraphModel graphmodel = mediator.getGraph().getModel();
	Object[] fathers = (DefaultGraphModel.getIncomingEdges(graphmodel, targetOfEdge));
	int max = (int) boundsSource.getMaxX();
	for (Object father : fathers) {
		if (father instanceof JmtEdge) {
			JmtCell sourceOfEdge2 = (JmtCell) ((DefaultPort) ((JmtEdge) father).getSource()).getParent();
			Rectangle boundsSource2 = GraphConstants.getBounds(sourceOfEdge2.getAttributes()).getBounds();
			if (sourceOfEdge != sourceOfEdge2 && boundsSource.getMaxX() < boundsTarget.getMinX() - 5
					&& boundsSource2.getMaxX() < boundsTarget.getMinX() - 5) {
				if (max < boundsSource2.getMaxX() && (int) boundsSource.getMaxX() > (int) boundsSource2.getMinX()) {
					max = (int) boundsSource2.getMaxX();
				}
			}
		}
	}
	return (int) (max - boundsSource.getMaxX());
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:23,代码来源:JmtEdge.java

示例2: getOffset

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public int getOffset() {
	JmtCell sourceOfEdge = (JmtCell) ((DefaultPort) this.getSource()).getParent();
	Rectangle boundsSource = GraphConstants.getBounds(sourceOfEdge.getAttributes()).getBounds();
	JmtCell targetOfEdge = (JmtCell) ((DefaultPort) this.getTarget()).getParent();
	Rectangle boundsTarget = GraphConstants.getBounds(targetOfEdge.getAttributes()).getBounds();
	Object[] listEdges = null;
	GraphModel graphmodel = mediator.getGraph().getModel();
	//		System.out.println("Padre: "+targetOfEdge);
	Object[] fathers = (DefaultGraphModel.getIncomingEdges(graphmodel, targetOfEdge));
	int max = (int) boundsSource.getMaxX();
	for (Object father : fathers) {
		//			System.out.println("Dentro il for");
		if (father instanceof JmtEdge) {
			JmtCell sourceOfEdge2 = (JmtCell) ((DefaultPort) ((JmtEdge) father).getSource()).getParent();
			Rectangle boundsSource2 = GraphConstants.getBounds(sourceOfEdge2.getAttributes()).getBounds();
			if (sourceOfEdge != sourceOfEdge2 && boundsSource.getMaxX() < boundsTarget.getMinX() - 5
					&& boundsSource2.getMaxX() < boundsTarget.getMinX() - 5) {
				if (max < boundsSource2.getMaxX() && (int) boundsSource.getMaxX() > (int) boundsSource2.getMinX()) {
					max = (int) boundsSource2.getMaxX();
				}
			}
		}
	}
	return (int) (max - boundsSource.getMaxX());
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:26,代码来源:JmtEdge.java

示例3: testJGraph

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
@Test
public void testJGraph() throws Exception {
	GraphModel model = new DefaultGraphModel();
	GraphLayoutCache view = new GraphLayoutCache(model, new DefaultCellViewFactory());
	JGraph graph = new JGraph(model, view);

	DefaultGraphCell[] cells = new DefaultGraphCell[3];
	cells[0] = createCell("hello", true);
	cells[1] = createCell("world", false);
	DefaultEdge edge = new DefaultEdge();
	GraphConstants.setLineStyle(edge.getAttributes(), GraphConstants.ARROW_LINE);
	edge.setSource(cells[0].getChildAt(0));
	edge.setTarget(cells[1].getChildAt(0));
	cells[2] = edge;
	graph.getGraphLayoutCache().insert(cells);

	JOptionPane.showMessageDialog(null, new JScrollPane(graph));
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:19,代码来源:JGraphTest.java

示例4: getCellFromData

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public BasicCell getCellFromData(Element data){
	GraphModel model = this.getModel();
	BasicCell cell = null;
	BasicCell current = null;
	for(int i = 0; i < model.getRootCount(); i++){			
		Object currentObject = model.getRootAt(i);
		if (currentObject instanceof ActorCell ||
			currentObject instanceof UseCaseCell ||
			currentObject instanceof ClassCell ||
			currentObject instanceof StateCell ||
			currentObject instanceof ObjectCell ||
			currentObject instanceof PlaceCell ||
			currentObject instanceof TransitionCell ||
			currentObject instanceof GraphLabel){
			
			current = (BasicCell) currentObject;				
			if (current.getData().equals(data)){
				cell = current;
				break;
			}
		}			
	}
	return cell;
}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:25,代码来源:ItGraph.java

示例5: getAssociationFromData

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public BasicAssociation getAssociationFromData(Element data){
	GraphModel model = this.getModel();
	BasicAssociation association = null;
	BasicAssociation current = null;
	for(int i = 0; i < model.getRootCount(); i++){			
		Object currentObject = model.getRootAt(i);
		if (currentObject instanceof ActionAssociation ||
			currentObject instanceof ClassAssociation ||
			currentObject instanceof Dependency ||
			currentObject instanceof Generalization ||
			currentObject instanceof ObjectAssociation ||
			currentObject instanceof UseCaseAssociation){
			
			current = (BasicAssociation) currentObject;				
			if (current.getData().equals(data)){
				association = current;
				break;
			}
		}			
	}
	return association;
}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:23,代码来源:ItGraph.java

示例6: getTopPetriPane

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
/**
 * This method initializes topPetriPanel
 *
 * @return javax.swing.JPanel
 */
private JRootPane getTopPetriPane() {
	if (topPetriPane == null) {
		petriToolBar = new ItToolBar("","PetriNet");
		petriToolBar.setName("PetriToolBar");
		GraphModel model = new DefaultGraphModel();
		GraphLayoutCache view = new GraphLayoutCache(model, new ItCellViewFactory());
		petriDiagramGraph = new ItGraph(view, petriToolBar, null, null, null, commonData, "PetriNet");
		petriToolBar.setGraph(petriDiagramGraph);
		petriDiagramGraph.setVisible(false);
		topPetriScrollPane = new JScrollPane(petriDiagramGraph);
		topPetriPane = new JRootPane();
		topPetriPane.setLayout(new BorderLayout());
		topPetriPane.add(petriToolBar, BorderLayout.NORTH);
		topPetriPane.add(topPetriScrollPane, BorderLayout.CENTER);
		//panel.setContentPane(graphScrollPane);
		petriDiagramGraph.setVisible(true);
	}
	return topPetriPane;
}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:25,代码来源:ItSIMPLE.java

示例7: openEditStateTab

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public void openEditStateTab(Element diagram, Element domain, Element project){
 	ItToolBar toolBar = new ItToolBar(diagram.getName(),"UML");
 	toolBar.addCloseEditButton();
toolBar.setName(diagram.getChildText("name"));
GraphModel model = new DefaultGraphModel();
GraphLayoutCache view = new GraphLayoutCache(model, new ItCellViewFactory());
ItGraph diagramGraph = new ItGraph(view, toolBar, propertiesPane, project, diagram, ItSIMPLE.getCommonData(), "UML");
toolBar.setGraph(diagramGraph);
diagramGraph.setVisible(false);
JScrollPane graphScrollPane = new JScrollPane(diagramGraph);
JRootPane panel = new JRootPane();
panel.setLayout(new BorderLayout());			
panel.add(toolBar, BorderLayout.NORTH);
panel.add(graphScrollPane, BorderLayout.CENTER);

diagramGraph.buildEditStateDiagram(domain);
diagramGraph.setVisible(true);

addTab("Current State", new ImageIcon("resources/images/"+diagram.getName()+".png"), panel);
if (getTabCount() > 1){
	setSelectedIndex(getTabCount()-1);	
}
editStateTabIndex = getTabCount() - 1;

}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:26,代码来源:ItTabbedPane.java

示例8: setupGraph

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
private JGraph setupGraph() {
    // Construct Model and Graph
    GraphModel model = new DefaultGraphModel();
    JGraph graph = new JGraph(model);

    // Control-drag should clone selection
    graph.setCloneable(true);

    // Enable edit without final RETURN keystroke
    graph.setInvokesStopCellEditing(true);

    // When over a cell, jump to its default port (we only have one, anyway)
    graph.setJumpToDefaultPort(true);

    return graph;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:17,代码来源:GraphView.java

示例9: MiddlePanelJGraph

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public MiddlePanelJGraph(GraphModel model)
	{
		super(model);
		// Make Ports Visible by Default
		setPortsVisible(true);
		// Use the Grid (but don't make it Visible)
		setGridEnabled(true);
		// Set the Grid Size to 10 Pixel
		setGridSize(6);
		// Set the Tolerance to 2 Pixel
		setTolerance(2);
		// Accept edits if click on background
		setInvokesStopCellEditing(true);
		// Allows control-drag
		setCloneable(false);
		// Jump to default port on connect
		setJumpToDefaultPort(false);
		setDoubleBuffered(true);
//		this.setOpaque(false);
	}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:21,代码来源:MiddlePanelJGraph.java

示例10: repositionSons

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
private void repositionSons(JmtCell padre, List<Object> sons, int numero, int cont) {
	inRepositionSons = true;
	Object[] listEdges = null;
	GraphModel graphmodel = graph.getModel();

	flag1 = true;

	int j = 0;
	Rectangle boundspadre = GraphConstants.getBounds(padre.getAttributes()).getBounds();
	int w = boundspadre.y + ((heightMax + 35) * (numero + 1)) - 38;

	for (int i = cont; i < sons.size(); i++) {
		if (((JmtCell) sons.get(i)).seen == false) {
			Rectangle bounds = GraphConstants.getBounds(((JmtCell) sons.get(i)).getAttributes()).getBounds();
			bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2),
					w - (int) (bounds.getHeight() / 2) + 80);
			GraphConstants.setBounds(((JmtCell) sons.get(i)).getAttributes(), bounds);

			((JmtCell) sons.get(i)).seen = true;
			listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, sons.get(i));

			if (listEdges.length > 0) {
				flag = true;
				j = searchNext((JmtCell) sons.get(i));
				inRepositionSons = true;
			}

			if (j > 0) {
				j = j - 1;
			}

			listEdges = null;
		}

		w = w + (heightMax + ((heightMax + 15) * j) + 30);
		j = 0;
	}

	inRepositionSons = false;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:41,代码来源:Mediator.java

示例11: setModel

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
@Override
public void setModel(GraphModel model) {
    GraphModel oldModel = getModel();
    if (oldModel != null) {
        oldModel.removeGraphModelListener(getRefreshGraphListener());
    }
    super.setModel(model);
    if (model != null) {
        model.addGraphModelListener(getRefreshGraphListener());
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:12,代码来源:AspectJGraph.java

示例12: setModel

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
/**
 * Overwrites the super implementation to add the following functionality:
 * <ul>
 * <li>The selection is cleared
 * <li>the layout action is stopped for the old model
 * <li>the popup menu is re-initialised
 * <li>the layout action is started for the new model
 * </ul>
 */
@Override
public void setModel(GraphModel model) {
    // Added a check that the new model differs from the current one
    // This should be OK, but if not, please comment here!
    if ((model == null || model instanceof JModel) && model != getModel()) {
        JModel<G> oldJModel = getModel();
        @SuppressWarnings("unchecked")
        JModel<G> newJModel = (JModel<G>) model;
        if (oldJModel != null) {
            // if we don't clear the selection, the old selection
            // gives trouble when setting the model
            clearSelection();
            oldJModel.removeGraphModelListener(getCancelEditListener());
        }
        if (newJModel != null) {
            newJModel.refreshVisuals();
        }
        super.setModel(newJModel);
        if (newJModel != null) {
            setName(newJModel.getName());
        }
        //            if (newJModel != null) {
        //                doLayout(false);
        //            }
        if (newJModel != null) {
            newJModel.addGraphModelListener(getCancelEditListener());
        }
        setEnabled(newJModel != null);
        if (newJModel != null && getActions() != null) {
            // create the popup menu to create and activate the actions therein
            createPopupMenu(null);
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:44,代码来源:JGraph.java

示例13: setModel

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
@Override
public void setModel(GraphModel model) {
    // reset the active state and transition
    this.activeState = null;
    this.activeTransition = null;
    super.setModel(model);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:8,代码来源:LTSJGraph.java

示例14: ERDesignerGraph

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public ERDesignerGraph(Model aDBModel, GraphModel aModel,
                       GraphLayoutCache aLayoutCache) {
    super(aModel, aLayoutCache);
    model = aDBModel;

    setMoveIntoGroups(true);
    setMoveOutOfGroups(true);
}
 
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:9,代码来源:ERDesignerGraph.java

示例15: getAttributes

import org.jgraph.graph.GraphModel; //导入依赖的package包/类
public AttributeMap getAttributes(Object node) {
	// This allows to modify the graph model attributes using the
	// common model edit methods, and suporting undo/redo functions
	if ((node == null) || (node instanceof GraphModel))
		return super.getAttributes(null);

	return super.getAttributes(node);
}
 
开发者ID:ProgettoRadis,项目名称:ArasuiteIta,代码行数:9,代码来源:TBoardModel.java


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