ingenias.generator.browser.GraphRelationshipImp Maven / Gradle / Ivy
/**
* Copyright (C) 2010 Jorge J. Gomez-Sanz
*
* This file is part of the INGENME tool. INGENME is an open source meta-editor
* which produces customized editors for user-defined modeling languages
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 3 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
**/
package ingenias.generator.browser;
import java.util.*;
import org.jgraph.graph.*;
import ingenias.editor.IDEState;
import ingenias.editor.ModelJGraph;
import ingenias.editor.entities.*;
public class GraphRelationshipImp extends AttributedElementImp implements GraphRelationship{
private ingenias.editor.entities.NAryEdgeEntity rel;
private ModelJGraph graph;
private org.jgraph.graph.DefaultGraphCell dgc;
IDEState ids;
GraphRelationshipImp(ingenias.editor.entities.NAryEdgeEntity rel,ModelJGraph graph, IDEState ids){
super(rel,graph,ids);
this.rel=rel;
this.graph=graph;
dgc=this.getCell();
this.ids=ids;
if (ids==null)
throw new RuntimeException("The ids parameter cannot be null");
}
public DefaultGraphCell getDGC(){
return dgc;
}
public ingenias.editor.entities.NAryEdgeEntity getNAryEdge(){
return rel;
}
private DefaultGraphCell getCell(){
int max=graph.getModel().getRootCount();
Vector v=new Vector();
boolean found=false;
int k=0;
org.jgraph.graph.DefaultGraphCell dgc=null;
while (k rolesFound=new Vector();
for (GraphRole role:roles){
if (role.getName().equalsIgnoreCase(roleName)){
rolesFound.add(role);
}
}
return rolesFound.toArray(new GraphRole[rolesFound.size()]);
}
}