Graphviz语言从jsp视图动态

发布于 2024-12-09 06:30:05 字数 1782 浏览 0 评论 0原文

我有一些角色,每个角色都有用户。

所以我的问题是根据没有。角色数量和数量。我必须使用 graphviz 创建一个图表。 Graphviz 语言就像 (A -> B;)(B -> C;)(B -> D;)(C -> E;)(D -> E;)(E -> F )

所以我必须根据我拥有的角色和没有角色来创建一种图形语言。我选择的用户数...

传入的字符串类似于 = (1CS_3Admin_1BOD_2SH_1Others)。 这种语言的图表可能是这样的:-


marapet 这就是我正在做的事情。

我的语言类似于 1CS_3Admin_1BOD_2SH_1Others 其中 1,3,1,2 是所选用户的数量,例如 1CS 表示一个用户担任 CS 角色。现在我用“_”作为分隔符将它们分开。现在我得到一个字符串数组。所以真正的问题是从这个字符串数组值创建一种语言。 这里的“名称”是我得到的字符串:-

Graphviz gv = new Graphviz();
          gv.addln(gv.start_graph());
          gv.addln("Start;");

          if(name.startsWith("_"));
            name=name.substring(1);

          String[] str=null;

          if(name.contains("_"))
              str = name.split("_");

          int sPreviousRepeat=0;
          String sPrevious="";
          int sCurrRepeat=0;
          String sCurr="";

          String finalInst="Start -> ";

        for(int i=0;i<str.length;i++) {
             sCurrRepeat=Integer.parseInt(String.valueOf(str[i].charAt(0)));
             sCurr=str[i].substring(1);
             if(i!=0){
                 sPreviousRepeat = Integer.parseInt(String.valueOf(str[i-1].charAt(0)));
                 sPrevious = str[i-1].substring(1);
             }

             if(sCurrRepeat==1){
                 if(i==0)
                     finalInst=finalInst+sCurr+";";
                 else
                     finalInst=finalInst + sPrevious+" -> "+sCurr+";";
             }
             else{
                 for(int j=0;j<sCurrRepeat;j++){

                    //cant figure out????? 

                 }

             }

         }

I have some roles and each roles have users.

So my problem is according to the no. of roles and no. of users selected i have to create a graph using graphviz.
Graphviz language is like (A -> B;)(B -> C;)(B -> D;)(C -> E;)(D -> E;)(E -> F)

So i have to create a graph language according to no of roles i have and no. of users i selected...

The incoming string is like = (1CS_3Admin_1BOD_2SH_1Others).
And the graph for this language myst be like this:-


marapet This is what i am doing.

My language is like 1CS_3Admin_1BOD_2SH_1Others Where 1,3,1,2 is the no of users selected e.g 1CS means one user for CS role. Now i split them with '_' as delimiter . Now i get a string array . So the real problem is to make a language from this string array values.
Here 'name' is the string i am getting:-

Graphviz gv = new Graphviz();
          gv.addln(gv.start_graph());
          gv.addln("Start;");

          if(name.startsWith("_"));
            name=name.substring(1);

          String[] str=null;

          if(name.contains("_"))
              str = name.split("_");

          int sPreviousRepeat=0;
          String sPrevious="";
          int sCurrRepeat=0;
          String sCurr="";

          String finalInst="Start -> ";

        for(int i=0;i<str.length;i++) {
             sCurrRepeat=Integer.parseInt(String.valueOf(str[i].charAt(0)));
             sCurr=str[i].substring(1);
             if(i!=0){
                 sPreviousRepeat = Integer.parseInt(String.valueOf(str[i-1].charAt(0)));
                 sPrevious = str[i-1].substring(1);
             }

             if(sCurrRepeat==1){
                 if(i==0)
                     finalInst=finalInst+sCurr+";";
                 else
                     finalInst=finalInst + sPrevious+" -> "+sCurr+";";
             }
             else{
                 for(int j=0;j<sCurrRepeat;j++){

                    //cant figure out????? 

                 }

             }

         }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴情 2024-12-16 06:30:05

下面是我分解问题的方法:

  1. 将输入字符串解析为表示 n 个有序对角色用户数量的数据结构
  2. 创建图形的语法(graphviz 您
  3. 将 graphviz 语法转换为实际图像

需要学习以下内容:

  • Graphviz 语法
  • 制作简单的 Java 命令行程序
  • 在 Java 中解析和操作字符串(分割等)
  • 调用可执行文件来自 java (dot.exe)

Here's how I'd break down the problem:

  1. Parse the input string into a data structure representing n ordered pairs of role and number of users
  2. Creating the syntax of the graph (graphviz dot) from the data structure in #1
  3. Transform the graphviz syntax into an actual image

You'll need to learn the following:

  • Graphviz syntax
  • Making a simple Java command line program
  • Parsing and manipulating strings in Java (split etc.)
  • Invoking an executable from java (dot.exe)
杀手六號 2024-12-16 06:30:05

我想我能做到。

          if(name.contains("_"))
          str = name.split("_");

      int sPreviousRepeat=0;
      String sPrevious="";
      int sCurrRepeat=0;
      String sCurr="";

      String finalInst="Start -> ";

    for(int i=0;i<str.length;i++) {
         sCurrRepeat=Integer.parseInt(String.valueOf(str[i].charAt(0)));
         sCurr=str[i].substring(1);
         if(i!=0){
             sPreviousRepeat = Integer.parseInt(String.valueOf(str[i-1].charAt(0)));
             sPrevious = str[i-1].substring(1);
         }

         if(sCurrRepeat==1){
             if(i==0)
                 finalInst=finalInst+sCurr+";";
             else if(sPreviousRepeat>1){
                 for(int j=0;j<sPreviousRepeat;j++)
                     finalInst=finalInst + sPrevious+(j+1)+" -> "+sCurr+";";
             }
             else
                 finalInst=finalInst + sPrevious+" -> "+sCurr+";";
         }
         else{
             for(int j=0;j<sCurrRepeat;j++){
                 finalInst=finalInst + sPrevious+" -> "+sCurr+(j+1)+";";                                     
             }

         }

     }

I think i make it.

          if(name.contains("_"))
          str = name.split("_");

      int sPreviousRepeat=0;
      String sPrevious="";
      int sCurrRepeat=0;
      String sCurr="";

      String finalInst="Start -> ";

    for(int i=0;i<str.length;i++) {
         sCurrRepeat=Integer.parseInt(String.valueOf(str[i].charAt(0)));
         sCurr=str[i].substring(1);
         if(i!=0){
             sPreviousRepeat = Integer.parseInt(String.valueOf(str[i-1].charAt(0)));
             sPrevious = str[i-1].substring(1);
         }

         if(sCurrRepeat==1){
             if(i==0)
                 finalInst=finalInst+sCurr+";";
             else if(sPreviousRepeat>1){
                 for(int j=0;j<sPreviousRepeat;j++)
                     finalInst=finalInst + sPrevious+(j+1)+" -> "+sCurr+";";
             }
             else
                 finalInst=finalInst + sPrevious+" -> "+sCurr+";";
         }
         else{
             for(int j=0;j<sCurrRepeat;j++){
                 finalInst=finalInst + sPrevious+" -> "+sCurr+(j+1)+";";                                     
             }

         }

     }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文