コード例 #1
0
ファイル: ActionSet.java プロジェクト: xskogure/HIS
  public void initializeType3(OntologyBase base, ActionEnum type) {
    Action ca = new Action(type);
    ca.setItem(base.getRootNode());
    ArrayList<Action> stack = new ArrayList<Action>();
    stack.add(ca);

    while (stack.size() > 0) {
      ca = stack.get(0);
      stack.remove(0);
      int flag = 1;
      Info iv;
      for (int i = 0; i < ca.itemArrayList.size(); i++) {
        iv = ca.itemArrayList.get(i);
        if (iv.isItemInfo() || iv.isAtomInfo()) {
          if (iv.isItemInfo()) {
            Action tua = (Action) ca.clone();
            tua.deleteItem(iv);
            tua.targetItem = iv;
            stack.add(tua);
            SubtypeInfo st;
            for (int j = 0; j < iv.getChildArrayList().size(); j++) {
              st = (SubtypeInfo) iv.getChildArrayList().get(j);
              Action ttua = (Action) ca.clone();
              Info it;
              for (int k = 0; k < st.getChildArrayList().size(); k++) {
                it = st.getChildArrayList().get(k);
                Action tttua = (Action) ttua.clone();
                tttua.deleteItem(iv);
                tttua.setItem(st);
                tttua.setItem(it);
                stack.add(tttua);
              }
            }
          } else if (iv.isAtomInfo()) {
            ca.deleteItem(iv);
            ca.targetItem = iv;
            stack.add(ca);
          }
          flag = 0;
        }
      }
      if (flag == 1) {
        setAction(ca);
      }
    }
  }
コード例 #2
0
ファイル: ActionSet.java プロジェクト: xskogure/HIS
  public void initializeType1(OntologyBase base, ActionEnum type) {
    Action ca = new Action(type);
    ca.setItem(base.getRootNode());

    ArrayList<Action> stack = new ArrayList<Action>();
    stack.add(ca);

    int[][][] combinfo = {
      {{}},
      {{}, {1}},
      {{}, {1}, {2}, {1, 2}},
      {{}, {1}, {2}, {1, 2}, {3}, {1, 3}, {2, 3}, {1, 2, 3}},
      {
        {},
        {1},
        {2},
        {1, 2},
        {3},
        {1, 3},
        {2, 3},
        {1, 2, 3},
        {4},
        {1, 4},
        {2, 4},
        {1, 2, 4},
        {3, 4},
        {1, 3, 4},
        {2, 3, 4},
        {1, 2, 3, 4}
      },
      {
        {},
        {1},
        {2},
        {1, 2},
        {3},
        {1, 3},
        {2, 3},
        {1, 2, 3},
        {4},
        {1, 4},
        {2, 4},
        {1, 2, 4},
        {3, 4},
        {1, 3, 4},
        {2, 3, 4},
        {1, 2, 3, 4},
        {5},
        {1, 5},
        {2, 5},
        {1, 2, 5},
        {3, 5},
        {1, 3, 5},
        {2, 3, 5},
        {1, 2, 3, 5},
        {4, 5},
        {1, 4, 5},
        {2, 4, 5},
        {1, 2, 4, 5},
        {3, 4, 5},
        {1, 3, 4, 5},
        {2, 3, 4, 5},
        {1, 2, 3, 4, 5}
      }
    };

    while (stack.size() > 0) {
      ca = stack.get(0);
      stack.remove(0);
      int flag = 1;
      Info iv;
      for (int i = 0; i < ca.itemArrayList.size(); i++) {
        iv = ca.itemArrayList.get(i);
        if (iv.isItemInfo() || iv.isAtomInfo()) {
          if (iv.isItemInfo()) {
            SubtypeInfo st;
            for (int j = 0; j < iv.getChildArrayList().size(); j++) {
              st = (SubtypeInfo) iv.getChildArrayList().get(j);
              Action tua = (Action) ca.clone();
              tua.deleteItem(iv);
              tua.setItem(st);
              int[][] ln = combinfo[st.getChildArrayList().size()];
              int[] ii;
              for (int k = 0; k < ln.length; k++) {
                ii = ln[k];
                Action ttua = (Action) tua.clone();
                ttua.deleteItem(iv);

                for (int l = 0; l < ii.length; l++) {
                  ttua.setItem(st.getChildArrayList().get(ii[l] - 1));
                }
                stack.add(ttua);
              }
            }
          } else if (iv.isAtomInfo()) {
            DataInfo da;
            for (int j = 0; j < iv.getChildArrayList().size(); j++) {
              da = (DataInfo) iv.getChildArrayList().get(j);
              Action tua = (Action) ca.clone();
              tua.deleteItem(iv);
              tua.setItem(da);
              stack.add(tua);
            }
          }
          flag = 0;
        }
      }
      if (flag == 1) {
        setAction(ca);
      }
    }
  }