本文整理汇总了Java中org.jgraph.graph.DefaultGraphModel类的典型用法代码示例。如果您正苦于以下问题:Java DefaultGraphModel类的具体用法?Java DefaultGraphModel怎么用?Java DefaultGraphModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultGraphModel类属于org.jgraph.graph包,在下文中一共展示了DefaultGraphModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOffset
import org.jgraph.graph.DefaultGraphModel; //导入依赖的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());
}
示例2: getOffset
import org.jgraph.graph.DefaultGraphModel; //导入依赖的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());
}
示例3: reloadRoots
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
@Override
protected void reloadRoots() {
// Reorder roots
Object[] orderedCells = DefaultGraphModel.getAll(this.graphModel);
List<CellView> newRoots = new ArrayList<>();
for (Object element : orderedCells) {
CellView view = getMapping(element, true);
if (view != null) {
// the following line is commented out wrt the super implementation
// to prevent over-enthousiastic refreshing
// view.refresh(this, this, true);
if (view.getParentView() == null) {
newRoots.add(view);
}
}
}
this.roots = newRoots;
}
示例4: testJGraph
import org.jgraph.graph.DefaultGraphModel; //导入依赖的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));
}
示例5: getTopPetriPane
import org.jgraph.graph.DefaultGraphModel; //导入依赖的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;
}
示例6: openEditStateTab
import org.jgraph.graph.DefaultGraphModel; //导入依赖的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;
}
示例7: setupGraph
import org.jgraph.graph.DefaultGraphModel; //导入依赖的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;
}
示例8: repositionSons
import org.jgraph.graph.DefaultGraphModel; //导入依赖的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;
}
示例9: createGraph
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
public static JGraph createGraph() {
DefaultGraphModel defaultGraphModel = new DefaultGraphModel();
GraphLayoutCache graphLayoutCache = new GraphLayoutCache(defaultGraphModel, new CustomCellViewFactory());
JGraph newGraph = new JGraph(defaultGraphModel, graphLayoutCache);
newGraph.setDisconnectable(false);
newGraph.setAntiAliased(true);
newGraph.setEditable(false);
return newGraph;
}
示例10: initJGraphPanel
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
void initJGraphPanel(){
jgraphPanel = new JPanel();
jgraphPanel.setLayout(new BoxLayout(jgraphPanel, BoxLayout.Y_AXIS));
// This method defines the Graph structure as an empty Graph object
GraphModel model = new DefaultGraphModel();
jgraph= new JGraph(model);
jgraphPanel.add(jgraph);
jgraphPanel.validate();
}
示例11: ItGraph
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
public ItGraph(Element project, Element diagram, String language){
super(new GraphLayoutCache(new DefaultGraphModel(), new ItCellViewFactory()));
this.project = project;
this.diagram = diagram;
this.language = language;
setUI(new ItGraphUI());
setDisconnectable(false);
setEdgeLabelsMovable(true);
}
示例12: handleDeleteAll
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
/**
* Handle the deletion of all graph cells on the middle panel.
*/
public synchronized void handleDeleteAll() {
// clean up
Object[] cells = DefaultGraphModel.getDescendants(
getMiddlePanel().getGraph().getModel(),
getMiddlePanel().getGraph().getRoots()).toArray();
// call to remove all cells
removeCells(cells, false);
setGraphChanged(true);
}
示例13: removeCells
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
private void removeCells(Object[] cells, boolean findAssociatedCells) {
unmapCells(cells);
// repaint the source and target tree panel if a functionBox is deleted
boolean repaintSourceTarget = false;
cells = DefaultGraphModel.getDescendants(
getMiddlePanel().getGraph().getModel(), cells).toArray();
if (!findAssociatedCells) {// no need to find associated cells, so
// directly remove them.
getMiddlePanel().getGraph().getGraphLayoutCache().remove(cells,
true, true);
return;
}
List cellSelectionList = new ArrayList(Arrays.asList(cells));
// reverse back in case some additions are added by calling
// comp.findMatchedCell() above.
cells = cellSelectionList.toArray();
if (cells != null) {
cells = DefaultGraphModel.getDescendants(
getMiddlePanel().getGraph().getModel(), cells).toArray();
// graph.getModel().remove(cells);
getMiddlePanel().getGraph().getGraphLayoutCache().remove(cells,
true, true);
}
// repaint the source and target scrollPanes
if (repaintSourceTarget) {
mappingPanel.getSourceScrollPane().repaint();
mappingPanel.getTargetScrollPane().repaint();
}
}
示例14: searchNext
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
private int searchNext(JmtCell prev) {
Rectangle boundspadre = GraphConstants.getBounds((prev).getAttributes()).getBounds();
Object[] listEdges = null;
GraphModel graphmodel = graph.getModel();
List<Object> next = new ArrayList<Object>();
if (flag1 == false && prev.seen == false) {
if (!flag2) {
boundspadre.setLocation(x, y + ((e + 1) * (42 + heightMax)) - (int) (boundspadre.getHeight() / 2) + 30);
} else {
boundspadre.setLocation(x - (int) (boundspadre.getWidth() / 2), y + ((e + 1) * (42 + heightMax))
- (int) (boundspadre.getHeight() / 2) + 30);
}
GraphConstants.setBounds(prev.getAttributes(), boundspadre);
x = (int) boundspadre.getCenterX() + widthMax + 50;
prev.seen = true;
flag2 = true;
}
listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, prev);
Vector<Object> listEdgestmp = new Vector<Object>();
for (Object listEdge : listEdges) {
JmtCell qq = (JmtCell) (graphmodel.getParent(graphmodel.getTarget(listEdge)));
if (!(qq).seen) {
listEdgestmp.add(listEdge);
}
}
listEdges = listEdgestmp.toArray();
int numTarget = listEdges.length;
if (numTarget == 0) {
return 1;
}
for (int k = 0; k < numTarget; k++) {
next.add((graphmodel.getParent(graphmodel.getTarget(listEdges[k]))));
}
int j = 1;
if (inRepositionSons == false && ((JmtCell) next.get(0)).seen == false) {
j = searchNext((JmtCell) next.get(0));
} else if (inRepositionSons == true && ((JmtCell) next.get(0)).seen == false) {
Rectangle bounds = GraphConstants.getBounds(((JmtCell) next.get(0)).getAttributes()).getBounds();
bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2),
(int) boundspadre.getCenterY() - (int) (bounds.getHeight() / 2));
GraphConstants.setBounds(((JmtCell) next.get(0)).getAttributes(), bounds);
((JmtCell) next.get(0)).seen = true;
j = searchNext((JmtCell) next.get(0));
}
if (numTarget > 0) {
if (!flag) {
repositionSons(prev, next, j - 1, 1);
} else {
repositionSons(prev, next, -1, 0);
}
flag = false;
}
(prev).sons = 0;
for (int w = 0; w < numTarget; w++) {
prev.sons += ((JmtCell) next.get(w)).sons;
}
return prev.sons;
}
示例15: searchNext
import org.jgraph.graph.DefaultGraphModel; //导入依赖的package包/类
private int searchNext(JmtCell prev) {
Rectangle boundspadre = GraphConstants.getBounds((prev).getAttributes()).getBounds();
Object[] listEdges = null;
GraphModel graphmodel = graph.getModel();
List<Object> next = new ArrayList<Object>();
if (flag1 == false && prev.seen == false) {
// Rectangle bounds =
// GraphConstants.getBounds(((JmtCell)prev).getAttributes()).getBounds();
if (!flag2) {
boundspadre.setLocation(x, y + ((e + 1) * (42 + heightMax)) - (int) (boundspadre.getHeight() / 2) + 30);
} else {
boundspadre.setLocation(x - (int) (boundspadre.getWidth() / 2), y + ((e + 1) * (42 + heightMax))
- (int) (boundspadre.getHeight() / 2) + 30);
}
GraphConstants.setBounds(prev.getAttributes(), boundspadre);
x = (int) boundspadre.getCenterX() + widthMax + 50;
prev.seen = true;
flag2 = true;
}
// inserisco tutti gli archi uscenti e entranti di min.get(j) in
// listEdges
listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, prev);
Vector<Object> listEdgestmp = new Vector<Object>();
for (Object listEdge : listEdges) {
JmtCell qq = (JmtCell) (graphmodel.getParent(graphmodel.getTarget(listEdge)));
if (!(qq).seen) {
listEdgestmp.add(listEdge);
}
}
listEdges = listEdgestmp.toArray();
int numTarget = listEdges.length;
if (numTarget == 0) {
return 1;
}
for (int k = 0; k < numTarget; k++) {
next.add((graphmodel.getParent(graphmodel.getTarget(listEdges[k]))));
}
int j = 1;
if (inRepositionSons == false && ((JmtCell) next.get(0)).seen == false) {
j = searchNext((JmtCell) next.get(0));
} else if (inRepositionSons == true && ((JmtCell) next.get(0)).seen == false) {
Rectangle bounds = GraphConstants.getBounds(((JmtCell) next.get(0)).getAttributes()).getBounds();
bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2), (int) boundspadre.getCenterY()
- (int) (bounds.getHeight() / 2));
GraphConstants.setBounds(((JmtCell) next.get(0)).getAttributes(), bounds);
((JmtCell) next.get(0)).seen = true;
j = searchNext((JmtCell) next.get(0));
}
if (numTarget > 0) {
if (!flag) {
repositionSons(prev, next, j - 1, 1);
} else {
repositionSons(prev, next, -1, 0);
}
flag = false;
}
(prev).sons = 0;
for (int w = 0; w < numTarget; w++) {
prev.sons += ((JmtCell) next.get(w)).sons;
}
return prev.sons;
}