Package core

Examples of core.Cell


    int unit = konaneCanvas.getUnit();
    pressedX /= unit;
    pressedY /= unit;
    int releasedX = event.getX() / unit;
    int releasedY = event.getY() / unit;
    if(konaneGame.makeMove(new Cell(pressedX, pressedY),
        new Cell(releasedX, releasedY)))
    {
      konaneEventRegistry.fireEvent(KonaneEvent.MOVE_MADE);
      if(konaneGame.isOver())
      {
        konaneEventRegistry.fireEvent(KonaneEvent.GAME_OVER);
View Full Code Here


        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(1);//(a)
        standOper = new StandarizationOperator(caf, input);
        resultFormulas = standOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "IF(ISNA($A1),0,1)");
        expectedResult.put(new Cell('C',1), "MATCH(ROW(),$B:$B,0)");
        expectedResult.put(new Cell('D',1), "INDEX(A:A,$C1)");
        expectedResult.put(new Cell('B',2), "IF(ISNA($A2),B1,B1+1)");
        expectedResult.put(new Cell('C',2), "MATCH(ROW(),$B:$B,0)");
        expectedResult.put(new Cell('D',2), "INDEX(A:A,$C2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = standOper.getResultRelation();
        assertEquals(new Column('D'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(2);//(a,b)
        standOper = new StandarizationOperator(caf, input);
        resultFormulas = standOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),0,1)");
        expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
        expectedResult.put(new Cell('F',1), "INDEX(B:B,$D1)");
        expectedResult.put(new Cell('C',2), "IF(ISNA($A2),C1,C1+1)");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
        expectedResult.put(new Cell('F',2), "INDEX(B:B,$D2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = standOper.getResultRelation();
        assertEquals(new Column('E'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(2);//zaczynamy od B
        input = caf.getSpaceForNewRelation(3);//(b,c,d)
        standOper = new StandarizationOperator(caf, input);
        resultFormulas = standOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('E',1), "IF(ISNA($B1),0,1)");
        expectedResult.put(new Cell('F',1), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$F1)");
        expectedResult.put(new Cell('H',1), "INDEX(C:C,$F1)");
        expectedResult.put(new Cell('I',1), "INDEX(D:D,$F1)");
        expectedResult.put(new Cell('E',2), "IF(ISNA($B2),E1,E1+1)");
        expectedResult.put(new Cell('F',2), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$F2)");
        expectedResult.put(new Cell('H',2), "INDEX(C:C,$F2)");
        expectedResult.put(new Cell('I',2), "INDEX(D:D,$F2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(1);//(a)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 1);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),$B$1+1,IF(ISERR($A1),1+$B$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\"<\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
        expectedResult.put(new Cell('C',2), "IF(ISNA($A2),$B$1+1,IF(ISERR($A2),1+$B$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\"<\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = sortAscOper.getResultRelation();
        assertEquals(new Column('E'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(1);//(a)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 1);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),$B$1+1,IF(ISERR($A1),1+$B$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\">\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
        expectedResult.put(new Cell('C',2), "IF(ISNA($A2),$B$1+1,IF(ISERR($A2),1+$B$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\">\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 1);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($A1),$C$1+1,IF(ISERR($A1),1+$C$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\"<\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        expectedResult.put(new Cell('E',1), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',1), "INDEX(A:A,$E1)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$E1)");
        expectedResult.put(new Cell('D',2), "IF(ISNA($A2),$C$1+1,IF(ISERR($A2),1+$C$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\"<\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('E',2), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',2), "INDEX(A:A,$E2)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$E2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = sortAscOper.getResultRelation();
        assertEquals(new Column('F'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 1);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($A1),$C$1+1,IF(ISERR($A1),1+$C$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\">\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        expectedResult.put(new Cell('E',1), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',1), "INDEX(A:A,$E1)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$E1)");
        expectedResult.put(new Cell('D',2), "IF(ISNA($A2),$C$1+1,IF(ISERR($A2),1+$C$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\">\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('E',2), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',2), "INDEX(A:A,$E2)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$E2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 2);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($B:$B)-COUNTIF($B:$B,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($B1),$C$1+1,IF(ISERR($B1),1+$C$1-COUNTIF($B:$B,$B1),COUNTIF($B:$B,\"<\"&$B1)+COUNTIF($B$1:$B1,$B1)))");
        expectedResult.put(new Cell('E',1), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',1), "INDEX(A:A,$E1)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$E1)");
        expectedResult.put(new Cell('D',2), "IF(ISNA($B2),$C$1+1,IF(ISERR($B2),1+$C$1-COUNTIF($B:$B,$B2),COUNTIF($B:$B,\"<\"&$B2)+COUNTIF($B$1:$B2,$B2)))");
        expectedResult.put(new Cell('E',2), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',2), "INDEX(A:A,$E2)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$E2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = sortAscOper.getResultRelation();
        assertEquals(new Column('F'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 2);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($B:$B)-COUNTIF($B:$B,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($B1),$C$1+1,IF(ISERR($B1),1+$C$1-COUNTIF($B:$B,$B1),COUNTIF($B:$B,\">\"&$B1)+COUNTIF($B$1:$B1,$B1)))");
        expectedResult.put(new Cell('E',1), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',1), "INDEX(A:A,$E1)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$E1)");
        expectedResult.put(new Cell('D',2), "IF(ISNA($B2),$C$1+1,IF(ISERR($B2),1+$C$1-COUNTIF($B:$B,$B2),COUNTIF($B:$B,\">\"&$B2)+COUNTIF($B$1:$B2,$B2)))");
        expectedResult.put(new Cell('E',2), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',2), "INDEX(A:A,$E2)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$E2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        caf = new CellAddressFactory(2);
        inputRelation = caf.getSpaceForNewRelation(2);//(b,c)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 1);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('D',1), "COUNTA($B:$B)-COUNTIF($B:$B,NA())");
        expectedResult.put(new Cell('E',1), "IF(ISNA($B1),$D$1+1,IF(ISERR($B1),1+$D$1-COUNTIF($B:$B,$B1),COUNTIF($B:$B,\"<\"&$B1)+COUNTIF($B$1:$B1,$B1)))");
        expectedResult.put(new Cell('F',1), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$F1)");
        expectedResult.put(new Cell('H',1), "INDEX(C:C,$F1)");
        expectedResult.put(new Cell('E',2), "IF(ISNA($B2),$D$1+1,IF(ISERR($B2),1+$D$1-COUNTIF($B:$B,$B2),COUNTIF($B:$B,\"<\"&$B2)+COUNTIF($B$1:$B2,$B2)))");
        expectedResult.put(new Cell('F',2), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$F2)");
        expectedResult.put(new Cell('H',2), "INDEX(C:C,$F2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = sortAscOper.getResultRelation();
        assertEquals(new Column('G'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(2);
        inputRelation = caf.getSpaceForNewRelation(2);//(b,c)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 1);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('D',1), "COUNTA($B:$B)-COUNTIF($B:$B,NA())");
        expectedResult.put(new Cell('E',1), "IF(ISNA($B1),$D$1+1,IF(ISERR($B1),1+$D$1-COUNTIF($B:$B,$B1),COUNTIF($B:$B,\">\"&$B1)+COUNTIF($B$1:$B1,$B1)))");
        expectedResult.put(new Cell('F',1), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$F1)");
        expectedResult.put(new Cell('H',1), "INDEX(C:C,$F1)");
        expectedResult.put(new Cell('E',2), "IF(ISNA($B2),$D$1+1,IF(ISERR($B2),1+$D$1-COUNTIF($B:$B,$B2),COUNTIF($B:$B,\">\"&$B2)+COUNTIF($B$1:$B2,$B2)))");
        expectedResult.put(new Cell('F',2), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$F2)");
        expectedResult.put(new Cell('H',2), "INDEX(C:C,$F2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        input1 = caf.getSpaceForNewRelation(1);//(a)
        input2 = caf.getSpaceForNewRelation(1);//(b)
        unionOper = new UnionOperator(caf, input1, input2);
        resultFormulas = unionOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($A:$A)");
        expectedResult.put(new Cell('D',1), "IF(ROW()<=$C$1,A1,INDEX(B:B,ROW()-$C$1))");
        expectedResult.put(new Cell('D',2), "IF(ROW()<=$C$1,A2,INDEX(B:B,ROW()-$C$1))");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = unionOper.getResultRelation();
        assertEquals(new Column('D'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        input1 = caf.getSpaceForNewRelation(2);//(a,b)
        input2 = caf.getSpaceForNewRelation(2);//(c,d)
        unionOper = new UnionOperator(caf, input1, input2);
        resultFormulas = unionOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('E',1), "COUNTA($A:$A)");
        expectedResult.put(new Cell('F',1), "IF(ROW()<=$E$1,A1,INDEX(C:C,ROW()-$E$1))");
        expectedResult.put(new Cell('G',1), "IF(ROW()<=$E$1,B1,INDEX(D:D,ROW()-$E$1))");
        expectedResult.put(new Cell('F',2), "IF(ROW()<=$E$1,A2,INDEX(C:C,ROW()-$E$1))");
        expectedResult.put(new Cell('G',2), "IF(ROW()<=$E$1,B2,INDEX(D:D,ROW()-$E$1))");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(1);//(a)
        dupRemOper = new DuplicateRemovalOperator(caf, input);
        resultFormulas = dupRemOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "IF(ISNA(A1),0,1)");
        expectedResult.put(new Cell('C',1), "MATCH(ROW(),$B:$B,0)");
        expectedResult.put(new Cell('D',1), "INDEX(A:A,$C1)");
        expectedResult.put(new Cell('B',2), "IF(OR(ISNA($A2),COUNTIFS($A$1:$A2,$A2)>1),B1,1+B1)");
        expectedResult.put(new Cell('C',2), "MATCH(ROW(),$B:$B,0)");
        expectedResult.put(new Cell('D',2), "INDEX(A:A,$C2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = dupRemOper.getResultRelation();
        assertEquals(new Column('D'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());


        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(2);//(a,b)
        dupRemOper = new DuplicateRemovalOperator(caf, input);
        resultFormulas = dupRemOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "IF(ISNA(A1),0,1)");
        expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
        expectedResult.put(new Cell('F',1), "INDEX(B:B,$D1)");
        expectedResult.put(new Cell('C',2), "IF(OR(ISNA($A2),COUNTIFS($A$1:$A2,$A2,$B$1:$B2,$B2)>1),C1,1+C1)");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
        expectedResult.put(new Cell('F',2), "INDEX(B:B,$D2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = dupRemOper.getResultRelation();
        assertEquals(new Column('E'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(2);//zaczynamy od B i wypełniamy wiersze 3,4,5
        input = caf.getSpaceForNewRelation(3);//(b,c,d)
        dupRemOper = new DuplicateRemovalOperator(caf, input);
        resultFormulas = dupRemOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('E',1), "IF(ISNA(B1),0,1)");
        expectedResult.put(new Cell('F',1), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$F1)");
        expectedResult.put(new Cell('H',1), "INDEX(C:C,$F1)");
        expectedResult.put(new Cell('I',1), "INDEX(D:D,$F1)");
        expectedResult.put(new Cell('E',2), "IF(OR(ISNA($B2),COUNTIFS($B$1:$B2,$B2,$C$1:$C2,$C2,$D$1:$D2,$D2)>1),E1,1+E1)");
        expectedResult.put(new Cell('F',2), "MATCH(ROW(),$E:$E,0)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$F2)");
        expectedResult.put(new Cell('H',2), "INDEX(C:C,$F2)");
        expectedResult.put(new Cell('I',2), "INDEX(D:D,$F2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        in1 = caf.getSpaceForNewRelation(1);//(a)
        in2 = caf.getSpaceForNewRelation(1);//(b)
        diffOper = new DifferenceBagOperator(caf, in1, in2);
        resultFormulas = diffOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "IF(COUNTIFS($B:$B,$A1)<COUNTIFS($A$1:$A1,$A1),A1,NA())");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = diffOper.getResultRelation();
        assertEquals(new Column('C'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        in1 = caf.getSpaceForNewRelation(2);//(a,b)
        in2 = caf.getSpaceForNewRelation(2);//(c,d)
        diffOper = new DifferenceBagOperator(caf, in1, in2);
        resultFormulas = diffOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('E',1), "IF(COUNTIFS($C:$C,$A1,$D:$D,$B1)<COUNTIFS($A$1:$A1,$A1,$B$1:$B1,$B1),A1,NA())");
        expectedResult.put(new Cell('F',1), "IF(ISNA($E1),NA(),B1)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = diffOper.getResultRelation();
        assertEquals(new Column('E'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        in1 = caf.getSpaceForNewRelation(3);//(a,b,c)
        in2 = caf.getSpaceForNewRelation(3);//(d,e,f)
        diffOper = new DifferenceBagOperator(caf, in1, in2);
        resultFormulas = diffOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('G',1), "IF(COUNTIFS($D:$D,$A1,$E:$E,$B1,$F:$F,$C1)<COUNTIFS($A$1:$A1,$A1,$B$1:$B1,$B1,$C$1:$C1,$C1),A1,NA())");
        expectedResult.put(new Cell('H',1), "IF(ISNA($G1),NA(),B1)");
        expectedResult.put(new Cell('I',1), "IF(ISNA($G1),NA(),C1)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = diffOper.getResultRelation();
        assertEquals(new Column('G'), resRelation.getFirstCol());
        assertEquals(3, resRelation.getCardinality());

        caf = new CellAddressFactory(2);//kolumny A jest poza naszym zakresem
        caf.getSpaceForNewRelation(1);//i jeszcze mamy na początku jedną kolumne z innymi danymi
        in1 = caf.getSpaceForNewRelation(2);//(c,d)
        caf.getSpaceForNewRelation(1);//oraz dane pomiędzy wejściami
        in2 = caf.getSpaceForNewRelation(2);//(f,g)
        caf.getSpaceForNewRelation(1);//i dane po wejściach
        diffOper = new DifferenceBagOperator(caf, in1, in2);
        resultFormulas = diffOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('I',1), "IF(COUNTIFS($F:$F,$C1,$G:$G,$D1)<COUNTIFS($C$1:$C1,$C1,$D$1:$D1,$D1),C1,NA())");
        expectedResult.put(new Cell('J',1), "IF(ISNA($I1),NA(),D1)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
View Full Code Here

        dummyRelation = caf.getSpaceForNewRelation(2);
        labelDummy(dummyRelation, "Standarization of "+inputRelation.toString(caf));
        resultRelation = caf.getSpaceForNewRelation(inputRelation.getCardinality());
        labelResult(resultRelation, "Standarization of "+inputRelation.toString(caf));

        Cell a1 = caf.getLeftTopCellInRelation(inputRelation);
        Cell c1 = caf.getLeftTopCellInRelation(dummyRelation);
        Cell d1 = c1.nextInRow();
        Column c = dummyRelation.getFirstCol();
        formulas.put(c1, fillFR_IF(a1));
        formulas.put(d1, fillMatch(c));

        Cell ef1 = caf.getLeftTopCellInRelation(resultRelation);
        for (Column ab : inputRelation) {
            formulas.put(ef1, fillIndex(ab, d1));
            ef1 = ef1.nextInRow();
        }

        Cell a2 = a1.nextInColumn();
        Cell c2 = c1.nextInColumn();
        Cell d2 = d1.nextInColumn();
        String strC1 = c1.toString(caf);
        formulas.put(c2, String.format(SR_IF, a2.toString(caf), strC1, strC1));
        formulas.put(d2, fillMatch(c));

        Cell ef2 = d1.nextInRow().nextInColumn();
        for (Column ab : inputRelation) {
            formulas.put(ef2, fillSR_IF(ab, d2));
            ef2 = ef2.nextInRow();
        }
    }
View Full Code Here

TOP

Related Classes of core.Cell

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.