Package com.mxgraph.swing

Examples of com.mxgraph.swing.mxGraphComponent


        }finally
        {
          graph.getModel().endUpdate();
        }
       
    final mxGraphComponent graphComponent = new mxGraphComponent(graph);
    getContentPane().add(graphComponent);
   
    graphComponent.getGraphControl().addMouseListener(new MouseAdapter()
    {
   
      public void mouseReleased(MouseEvent e)
      {
        Object cell = graphComponent.getCellAt(e.getX(), e.getY());
       
        if (cell != null)
        {
          System.out.println("cell="+graph.getLabel(cell));
        }
View Full Code Here


    m_graph.setAutoOrigin(true);
    m_graph.setAutoSizeCells(true);
    m_graph.setCellsLocked(false);
    m_graph.setAllowDanglingEdges(false);
    m_graph.setCellsCloneable(false);
    m_graphComponent = new mxGraphComponent(m_graph);
    m_graphComponent.setAutoExtend(true);
    m_graphComponent.setExportEnabled(true);
    m_graphComponent.setCenterZoom(true);

   
View Full Code Here

    }finally
    {
      m_graph.getModel().endUpdate();
    }
    m_graph.setCellsDeletable(false);
    m_graphComponent = new mxGraphComponent(m_graph);
   
    layout = new mxOrganicLayout (m_graph);
    layout.execute(m_graph.getDefaultParent());
    m_graph = layout.getGraph();
   
View Full Code Here

    finally {
      graph.getModel().endUpdate();
    }

   
    mxGraphComponent graphComponent = new mxGraphComponent(graph);
    getContentPane().add(graphComponent);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter () {

      @Override
View Full Code Here

    map = new Hashtable<Long, Long>();
    graph = new mxGraph();
    parent = graph.getDefaultParent();

    JScrollPane scroller = new JScrollPane(new mxGraphComponent(graph))
    getContentPane().add(scroller);
    setSize(400, 300);
  }
View Full Code Here

    
       private mxGraphComponent getRolegraph(){
        
          LoggerManager.info(Constants.EDITOR_LOGGER, Messages.getString("PetriNet.Resources.DrawRoleGraph"));
           mxGraph graph;
           mxGraphComponent graphComponent;
          
            graph = new mxGraph();
            Object parentVertex = graph.getDefaultParent();
            graph.getModel().beginUpdate();
            //Colors
            String[] colors = {"00DB26" ,
                               "8DF200" ,
                               "F2B705" ,
                               "F29A2E" ,
                               "F37542" ,
                               "F25456" ,
                               "A73ADB" ,
                               "5549F2" ,
                               "40ADDB" ,
                               "04F9BE" ,
                               "938466" ,
                               "C6B38F" ,
                               "F99249" ,
                               "E26537" ,
                               "FC553D" ,
                               "E52C3B"};
            int alreadyPaintedFlag = 0;
           
            try {
              LogicalModel lm = new LogicalModel(objectsAssignedListModel,objectsUnassignedListModel,RolesTreeModel,RolesTopNode,GroupsTreeModel,GroupsTopNode,superRolesTreeModel,superGroupsTreeModel,superRolesTopNode, superGroupsTopNode);
            LayoutAlgorithm layoutAlgorithm = new LayoutAlgorithm();
            layoutAlgorithm.createLayout(lm);
            Set<Layout> RoleLayoutSet = layoutAlgorithm.RoleLayoutSet;
             
            //Assign color associations to the single Roles
            String[] RoleColorAssociation = new String[lm.allRoles.size()];
            int index = 0;
            Iterator<?> colorIt = lm.allRoles.iterator();
            while (colorIt.hasNext()) {
              Role currentRole = (Role) colorIt.next();
              RoleColorAssociation[index] = currentRole.name;
              index+=1;
            }
           
              Iterator<Layout> it = RoleLayoutSet.iterator();
             
              while (it.hasNext()) {
                Layout currentLayout = it.next();
               
                //Compound
                int dimensionX = 140;
                int dimensionY = 30;
               
                // Width== Number of Roles * dimensionX
                int compound_dimensionX = currentLayout.grid.length*dimensionX+20;
                int compoundDimensionY = 0;
               
                // maxRow= Longest Colum(with maximum of Rows)
                        int maxRow = 0;  
                       
                        // for each Role-Column -> do search the longest column, and remeber the Y
                        for (int i=0;i<currentLayout.grid.length;i++) {
                            if (currentLayout.grid[i] != null) {
                                for (int y=currentLayout.grid[i].length-1;y>=0;y--) {
                                    if (currentLayout.grid[i][y] != null) {
                                        if (y>maxRow) {
                                            maxRow = y;
                                        }
                                        break;
                                    }
                                }
                            }
                        }

                        // Search for the deepest Place
                Integer maxDepth[] = new Integer[currentLayout.grid.length];
                        Integer firstKill[] = new Integer[currentLayout.grid.length];
                Iterator<RoleLocator> deepBlue = currentLayout.Roles.iterator();
               
                while (deepBlue.hasNext()) {
                  RoleLocator currentRole = deepBlue.next();
                 
                  if(maxDepth[currentRole.column]==null){
                    maxDepth[currentRole.column]=1;
                  }else {
                    maxDepth[currentRole.column]++;
                  }
                }
               
                int deepestSubset = 0;
                for(int i=0;i<maxDepth.length;i++){
                 
                  if(maxDepth[i]>deepestSubset){
                    deepestSubset=maxDepth[i];
                  }
                }

                if(deepestSubset==1){
                 
                  // so finally -> compound_dim_Y = LongestColumn * dimensionY
                          compoundDimensionY = (maxRow+1)*dimensionY+60;
                 
                          // now draw compound                                                       x  y                 x-length              y-length
                  graph.insertVertex(parentVertex, null, currentLayout.name, 5, 5+alreadyPaintedFlag, compound_dimensionX + 40, compoundDimensionY, "rounded=1;strokeColor=black;fillColor=#CCCCCC;verticalAlign=top;fontStyle=1;fontColor=black" );
                 
                  // So now we build an Iterator to travel trough all Roles of the compound Role
                  //Roles
                  Iterator<RoleLocator>  subIt = currentLayout.Roles.iterator();
                  while (subIt.hasNext()) {
                    RoleLocator currentRole = subIt.next();
                   
                    //Find the related color
                    int colorRelation = 0;
                    for (int i=0; i<RoleColorAssociation.length;i++) {
                      if (RoleColorAssociation[i] == currentRole.name) {
                        colorRelation = i;
                        if (colorRelation>=colors.length) {
                          colorRelation = colorRelation - colors.length;
                        }
                        break;
                      }
                    }
                    graph.insertVertex(parentVertex, null, currentRole.name, 15+dimensionX*currentRole.column, 20+dimensionY*currentRole.ystart+alreadyPaintedFlag, dimensionX, dimensionY*(currentRole.yend-currentRole.ystart+1)+30, "rounded=1;strokeColor=black;fillColor="+colors[colorRelation]+";verticalAlign=top;fontStyle=1;fontColor=black"); //kursiv ;fontStyle=1;fontColor=black
                  }
                 
                  //Components
                  String containsString = new String();
                 
                  // for each column
                  for (int x1=0; x1<currentLayout.grid.length;x1++) {
                    // for each row/ Component
                    for (int y1=0;y1<currentLayout.grid[x1].length;y1++) {
                      int xMultiplicator = 0;
                      // is the object availible ?
                        if (currentLayout.grid[x1][y1] != null) {
                        if(containsString.contains(currentLayout.grid[x1][y1].name)){}
                          //do nothing -> cause it is already included
                        else if(!containsString.contains(currentLayout.grid[x1][y1].name)){
                          // Add current user
                          containsString = containsString +" "+ currentLayout.grid[x1][y1].name;
                          //for each column
                          for(int x2 = x1 + 1; x2 < currentLayout.grid.length; x2++){
                            // for each row
                            for(int y2 = 0; y2 < currentLayout.grid[x2].length; y2++){
                              // is the object availible ?
                              if(currentLayout.grid[x2][y2] != null){
                                if(currentLayout.grid[x1][y1].name == currentLayout.grid[x2][y2].name){
                                  if((x2 - x1) > xMultiplicator)
                                    // if the multiplicator has to be augmented by more than one column, it will not be done, cause in this case there ist a gap
                                    if((x2-x1)==(xMultiplicator+1)){
                                      xMultiplicator = x2 - x1;
                                    }else {
                                      containsString = containsString.replaceFirst(currentLayout.grid[x1][y1].name,"");
                                      xMultiplicator = 0;
                                    }
                                }
                              }
                            } 
                          }
                          if(xMultiplicator==0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 45+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-10), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                          if(xMultiplicator>0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 45+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-5), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                        }
                      }
                      }
                  }
                }else{
                          compoundDimensionY = (maxRow+1)*dimensionY+70;
                  graph.insertVertex(parentVertex, null, currentLayout.name, 5, 5+alreadyPaintedFlag, compound_dimensionX, compoundDimensionY, "rounded=1;strokeColor=black;fillColor=#CCCCCC;verticalAlign=top;fontStyle=1;fontColor=black" );
               
                  //Roles
                  Iterator<RoleLocator>  subIt = currentLayout.Roles.iterator();
                  while (subIt.hasNext()) {
                    RoleLocator currentRole = subIt.next();
                 
                    if(firstKill[currentRole.column]==null){
                      firstKill[currentRole.column]=0;
                    }else{
                      firstKill[currentRole.column]=1;
                    }
                   
                    //Find the related color
                    int colorRelation = 0;
                    for (int i=0; i<RoleColorAssociation.length;i++) {
                      if (RoleColorAssociation[i] == currentRole.name) {
                        colorRelation = i;
                        if (colorRelation>=colors.length) {
                          colorRelation = colorRelation - colors.length;
                        }
                        break;
                      }
                    }
                    graph.insertVertex(parentVertex, null, currentRole.name, 15+dimensionX*currentRole.column, 20+(dimensionY*currentRole.ystart*2)+alreadyPaintedFlag+(firstKill[currentRole.column]*20), dimensionX, dimensionY*(currentRole.yend-currentRole.ystart+1)-(firstKill[currentRole.column]*dimensionY)+44, "rounded=1;strokeColor=black;fillColor="+colors[colorRelation]+";verticalAlign=top;fontStyle=1;fontColor=black");
                  }
                 
                  //Components
                  String containsString = new String();
                  for (int x1=0; x1<currentLayout.grid.length;x1++) {
                    for (int y1=0;y1<currentLayout.grid[x1].length;y1++) {
                      int xMultiplicator = 0;
                        if (currentLayout.grid[x1][y1] != null) {
                        if(containsString.contains(currentLayout.grid[x1][y1].name)){}
                        else if(!containsString.contains(currentLayout.grid[x1][y1].name)){
                          containsString = containsString +" "+ currentLayout.grid[x1][y1].name;
                          for(int x2 = x1 + 1; x2 < currentLayout.grid.length; x2++){
                            for(int y2 = 0; y2 < currentLayout.grid[x2].length; y2++){
                              if(currentLayout.grid[x2][y2] != null){
                                if(currentLayout.grid[x1][y1].name == currentLayout.grid[x2][y2].name){
                                  if((x2 - x1) > xMultiplicator)
                                    if((x2-x1)==(xMultiplicator+1)){
                                      xMultiplicator = x2 - x1;
                                    }else {
                                      containsString = containsString.replaceFirst(currentLayout.grid[x1][y1].name,"");
                                      xMultiplicator = 0;
 
                                    }
                                }
                              }
                            } 
                          }
                          //                                                                                           x                 y                                x-length                                                                y-length
                          if(xMultiplicator==0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 55+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-10), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                          if(xMultiplicator>0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 55+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-5), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                        }
                      }
                      }
                  }
                }
                alreadyPaintedFlag = alreadyPaintedFlag + compoundDimensionY + 10;
              }
            } finally {
              graph.getModel().endUpdate();
            }
           
            if(alreadyPaintedFlag==0){
              graph.insertVertex(parentVertex, null,Messages.getString("PetriNet.Resources.NoRolesDefined"),10,10,150,30, "rounded=1;opacity=0;fontStyle=1;fontColor=black");           
            }
           
            // Create Listener, first parameter in constructor is the observed graph
            mxIEventListener mySelectListener = new selectListener(graph);
            // add Listener as CHANGE-Listener
            graph.getSelectionModel().addListener(mxEvent.CHANGE, mySelectListener);
            graphComponent = new mxGraphComponent(graph);

            temp_Role_graph = graph;
            temp_Role_graphComponent= graphComponent;

            return graphComponent;
View Full Code Here

     }
    
     private mxGraphComponent getGroupgraph(){
           LoggerManager.info(Constants.EDITOR_LOGGER, Messages.getString("PetriNet.Resources.DrawGroupGraph"));
           mxGraph graph;
           mxGraphComponent graphComponent;
           graph = new mxGraph();
            Object parentVertex = graph.getDefaultParent();
            graph.getModel().beginUpdate();
           
            //Colors
            String[] colors = {"00DB26" ,
                               "8DF200" ,
                               "F2B705" ,
                               "F29A2E" ,
                               "F37542" ,
                               "F25456" ,
                               "A73ADB" ,
                               "5549F2" ,
                               "40ADDB" ,
                               "04F9BE" ,
                               "938466" ,
                               "C6B38F" ,
                               "F99249" ,
                               "E26537" ,
                               "FC553D" ,
                               "E52C3B"};
            int alreadyPaintedFlag = 0;
            try {
              LogicalModel lm = new LogicalModel(objectsAssignedListModel,objectsUnassignedListModel,RolesTreeModel,RolesTopNode,GroupsTreeModel,GroupsTopNode,superRolesTreeModel,superGroupsTreeModel,superRolesTopNode, superGroupsTopNode);
            LayoutAlgorithm layoutAlgorithm = new LayoutAlgorithm();

            layoutAlgorithm.createLayout(lm);
            Set<Layout> GroupLayoutSet = layoutAlgorithm.GroupLayoutSet;
             
            //Assign color associations to the single Roles
            String[] RoleColorAssociation = new String[lm.allRoles.size()];
            int index = 0;
            Iterator<?> colorIt = lm.allGroups.iterator();
            while (colorIt.hasNext()) {
              Group currentGroup = (Group) colorIt.next();
              RoleColorAssociation[index] = currentGroup.name;
              index+=1;
            }
           
              Iterator<Layout> it = GroupLayoutSet.iterator();
             
              while (it.hasNext()) {
                Layout currentLayout = it.next();
               
                //Compound
                int dimensionX = 140;
                int dimensionY = 30;
                int compound_dimensionX = currentLayout.grid.length * dimensionX + 20;
                int compoundDimensionY = 0;
                int maxRow = 0;  
                  
                     for (int i=0;i<currentLayout.grid.length;i++) {
                         if (currentLayout.grid[i] != null) {
                             for (int y=currentLayout.grid[i].length-1; y>=0; y--) {
                                 if (currentLayout.grid[i][y] != null) {
                                     if (y>maxRow) {
                                         maxRow = y;
                                     }
                                     break;
                                 }
                             }
                         }
                      }
                       

                // Search for the deepest Place
               
                     Integer maxDepth[] = new Integer[currentLayout.grid.length];
                     Integer firstKill[] = new Integer[currentLayout.grid.length];
                 Iterator<GroupLocator> deepBlue = currentLayout.Groups.iterator();
               
                while (deepBlue.hasNext()) {
                  GroupLocator currentGroup = deepBlue.next();
                 
                  if(maxDepth[currentGroup.column]==null){
                    maxDepth[currentGroup.column]=1;
                  }else {
                    maxDepth[currentGroup.column]++;
                  }
                }
               
                int deepestSubset = 0;
                for(int i=0;i<maxDepth.length;i++){
                  if(maxDepth[i]>deepestSubset){
                    deepestSubset=maxDepth[i];
                  }
                }
               
                if(deepestSubset==1){
                  //dimensionY = 30;
                  compoundDimensionY = (maxRow+1) * dimensionY + 60;
                  graph.insertVertex(parentVertex, null, currentLayout.name, 5, 5+alreadyPaintedFlag, compound_dimensionX, compoundDimensionY, "rounded=1;strokeColor=black;fillColor=#CCCCCC;verticalAlign=top;fontStyle=1;fontColor=black" );

                  // So now we build an Iterator to travel trough all Roles of the compound Role
                  //Roles
                  Iterator<GroupLocator>  subIt = currentLayout.Groups.iterator();
                  while (subIt.hasNext()) {
                    GroupLocator currentGroup = subIt.next();
                   
                    //Find the related color
                    int colorRelation = 0;
                    for (int i=0; i<RoleColorAssociation.length;i++) {
                      if (RoleColorAssociation[i] == currentGroup.name) {
                        colorRelation = i;
                        if (colorRelation>=colors.length) {
                          colorRelation = colorRelation - colors.length;
                        }
                        break;
                      }
                    }
                    graph.insertVertex(parentVertex, null, currentGroup.name, 15+dimensionX*currentGroup.column, 20+dimensionY*currentGroup.ystart+alreadyPaintedFlag, dimensionX, dimensionY*(currentGroup.yend-currentGroup.ystart+1)+30, "rounded=1;strokeColor=black;fillColor="+colors[colorRelation]+";verticalAlign=top;fontStyle=1;fontColor=black");
                  }
                 
                  //Components
                  String containsString = new String();
                 
                  for (int x1=0; x1<currentLayout.grid.length;x1++) {
                    for (int y1=0;y1<currentLayout.grid[x1].length;y1++) {
                      int xMultiplicator = 0;
                        if (currentLayout.grid[x1][y1] != null) {
                        if(containsString.contains(currentLayout.grid[x1][y1].name)){
                        } else if(!containsString.contains(currentLayout.grid[x1][y1].name)){
                          containsString = containsString +" "+ currentLayout.grid[x1][y1].name;
                          for(int x2 = x1 + 1; x2 < currentLayout.grid.length; x2++){
                            for(int y2 = 0; y2 < currentLayout.grid[x2].length; y2++){
                              if(currentLayout.grid[x2][y2] != null){
                                if(currentLayout.grid[x1][y1].name == currentLayout.grid[x2][y2].name){
                                  if((x2 - x1) > xMultiplicator)
                                    if((x2-x1)==(xMultiplicator+1)){
                                      xMultiplicator = x2 - x1;
                                    }else {
                                      containsString = containsString.replaceFirst(currentLayout.grid[x1][y1].name,"");
                                      xMultiplicator = 0;
                                    }
                                }
                              }
                            } 
                          }
                          if(xMultiplicator==0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 45+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-10), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                          if(xMultiplicator>0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 45+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-5), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                        }
                      }
                      }
                  }
                }else{
                         compoundDimensionY = (maxRow+1)*dimensionY+70;
                  graph.insertVertex(parentVertex, null, currentLayout.name, 5, 5+alreadyPaintedFlag, compound_dimensionX, compoundDimensionY, "rounded=1;strokeColor=black;fillColor=#CCCCCC;verticalAlign=top;fontStyle=1;fontColor=black" );
               
                  //Roles
                  Iterator<GroupLocator>  subIt = currentLayout.Groups.iterator();
                  while (subIt.hasNext()) {
                    GroupLocator currentGroup = subIt.next();
                 
                    if(firstKill[currentGroup.column]==null){
                      firstKill[currentGroup.column]=0;
                    }else{
                      firstKill[currentGroup.column]=1;
                    }
                   
                    //Find the related color
                    int colorRelation = 0;
                    for (int i=0; i<RoleColorAssociation.length;i++) {
                      if (RoleColorAssociation[i] == currentGroup.name) {
                        colorRelation = i;
                        if (colorRelation>=colors.length) {
                          colorRelation = colorRelation - colors.length;
                        }
                        break;
                      }
                    }
                    graph.insertVertex(parentVertex, null, currentGroup.name, 15+dimensionX*currentGroup.column, 20+(dimensionY*currentGroup.ystart*2)+alreadyPaintedFlag+(firstKill[currentGroup.column]*20), dimensionX, dimensionY*(currentGroup.yend-currentGroup.ystart+1)-(firstKill[currentGroup.column]*dimensionY)+44, "rounded=1;strokeColor=black;fillColor="+colors[colorRelation]+";verticalAlign=top;fontStyle=1;fontColor=black");
                  }
                 
                  //Components
                  String containsString = new String();
                  for (int x1=0; x1<currentLayout.grid.length;x1++) {
                    for (int y1=0;y1<currentLayout.grid[x1].length;y1++) {
                      int xMultiplicator = 0;
                        if (currentLayout.grid[x1][y1] != null) {
                        if(containsString.contains(currentLayout.grid[x1][y1].name)){
                        } else if(!containsString.contains(currentLayout.grid[x1][y1].name)){
                          containsString = containsString +" "+ currentLayout.grid[x1][y1].name;
                          for(int x2 = x1 + 1; x2 < currentLayout.grid.length; x2++){
                            for(int y2 = 0; y2 < currentLayout.grid[x2].length; y2++){
                              if(currentLayout.grid[x2][y2] != null){
                                if(currentLayout.grid[x1][y1].name == currentLayout.grid[x2][y2].name){
                                  if((x2 - x1) > xMultiplicator)
                                    if((x2-x1)==(xMultiplicator+1)){
                                      xMultiplicator = x2 - x1;
                                    }else {
                                      containsString = containsString.replaceFirst(currentLayout.grid[x1][y1].name,"");
                                      xMultiplicator = 0;
                                    }
                                }
                              }
                            } 
                          }
                          if(xMultiplicator==0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 55+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-10), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                          if(xMultiplicator>0){
                            graph.insertVertex(parentVertex, null, currentLayout.grid[x1][y1].name, 20+x1*dimensionX, 55+y1*dimensionY+alreadyPaintedFlag, xMultiplicator * 5 + xMultiplicator * (dimensionX-10+ (dimensionX-5), dimensionY-4, "rounded=1;strokeColor=black;fillColor=white;opacity=65;fontStyle=1;fontColor=black");
                          }
                        }
                      }
                      }
                  }
                }
                alreadyPaintedFlag = alreadyPaintedFlag + compoundDimensionY + 10;
              }
            } finally {
                graph.getModel().endUpdate();
            }
           
            if(alreadyPaintedFlag==0){
              graph.insertVertex(parentVertex, null,Messages.getString("PetriNet.Resources.NoGroupsDefined"),10,10,150,30, "rounded=1;opacity=0;fontStyle=1;fontColor=black");
            }
           
            // Create Listener, first parameter in constructor is the observed graph
            mxIEventListener mySelectListener = new selectListener(graph);
            // add Listener as CHANGE-Listener
            graph.getSelectionModel().addListener(mxEvent.CHANGE, mySelectListener);
            graphComponent = new mxGraphComponent(graph);
 
            tempGroupGraph = graph;
            tempGroupGraphComponent= graphComponent;

            return graphComponent;
View Full Code Here

            graph.insertEdge(parent, null, null, v1, v1);
        } finally {
            graph.getModel().endUpdate();
        }

        mxGraphComponent graphComponent = new mxGraphComponent(graph);
        this.getContentPane().add(graphComponent);
        this.setSize(800, 600);
        this.setVisible(true);
    }
View Full Code Here

            }
        } finally {
            graph.getModel().endUpdate();
        }

        mxGraphComponent graphComponent = new mxGraphComponent(graph);
        this.getContentPane().add(graphComponent);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(800, 600);
        this.setVisible(true);
    }
View Full Code Here

      /**
       *
       */
      public void actionPerformed(ActionEvent e)
      {
        mxGraphComponent graphComponent = editor.getGraphComponent();

        // Zoomcombo is changed when the scale is changed in the diagram
        // but the change is ignored here
        if (!ignoreZoomChange)
        {
          String zoom = zoomCombo.getSelectedItem().toString();

          if (zoom.equals(mxResources.get("page")))
          {
            graphComponent.setPageVisible(true);
            graphComponent
                .setZoomPolicy(mxGraphComponent.ZOOM_POLICY_PAGE);
          }
          else if (zoom.equals(mxResources.get("width")))
          {
            graphComponent.setPageVisible(true);
            graphComponent
                .setZoomPolicy(mxGraphComponent.ZOOM_POLICY_WIDTH);
          }
          else if (zoom.equals(mxResources.get("actualSize")))
          {
            graphComponent.zoomActual();
          }
          else
          {
            try
            {
              zoom = zoom.replace("%", "");
              double scale = Math.min(16, Math.max(0.01,
                  Double.parseDouble(zoom) / 100));
              graphComponent.zoomTo(scale, graphComponent
                  .isCenterZoom());
            }
            catch (Exception ex)
            {
              JOptionPane.showMessageDialog(editor, ex
View Full Code Here

TOP

Related Classes of com.mxgraph.swing.mxGraphComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.