X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fsolver%2Fformula%2FSumifFormulaFunction.java;fp=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fformula%2FSumifFormulaFunction.java;h=6ed9f00aca404279c1b4fd953dc7a81b586b75fd;hp=8826a384220b554976ed012e515749841a0fdd55;hb=5c67a96d34fe904b8c4b0375cd08ff1d543bf369;hpb=9a37dabc6c0212ed3e14499c88df3208cd06f9b0 diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/SumifFormulaFunction.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/formula/SumifFormulaFunction.java similarity index 65% rename from bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/SumifFormulaFunction.java rename to bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/formula/SumifFormulaFunction.java index 8826a3842..6ed9f00ac 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/SumifFormulaFunction.java +++ b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/formula/SumifFormulaFunction.java @@ -1,10 +1,8 @@ -package org.simantics.spreadsheet.graph.formula; +package org.simantics.spreadsheet.solver.formula; -import org.simantics.spreadsheet.graph.CellFormulaFunction; -import org.simantics.spreadsheet.graph.CellValueVisitor; -import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils; -import org.simantics.spreadsheet.graph.SpreadsheetMatrix; -import org.simantics.spreadsheet.graph.parser.ast.AstArgList; +import org.simantics.spreadsheet.SpreadsheetMatrix; +import org.simantics.spreadsheet.Spreadsheets; +import org.simantics.spreadsheet.solver.formula.parser.ast.AstArgList; class SumifFormulaFunction implements CellFormulaFunction { @@ -14,26 +12,26 @@ class SumifFormulaFunction implements CellFormulaFunction { Object test = args.values.get(0).accept(visitor); Object criteria = null; try { - criteria = args.values.get(1).accept(visitor); + criteria = args.values.get(1).accept(visitor); } catch (IllegalStateException e){ - return 0; + return 0; } FormulaError2 error = FormulaError2.forObject(criteria); if(error!=null) return error.getString(); - + if (test instanceof SpreadsheetMatrix) { double sum = 0.0; SpreadsheetMatrix tm = (SpreadsheetMatrix) test; for (int i = 0; i < tm.values.length; i++) { - if (SpreadsheetGraphUtils.matchCriteria(tm.values[i], criteria)) { - double d = SpreadsheetGraphUtils.asNumber(tm.values[i]); + if (Spreadsheets.matchCriteria(tm.values[i], criteria)) { + double d = Spreadsheets.asNumber(tm.values[i]); if (Double.isFinite(d)) sum += d; } } return sum; } else { - Double d = SpreadsheetGraphUtils.asNumber(test); + Double d = Spreadsheets.asNumber(test); return d; } } @@ -42,13 +40,13 @@ class SumifFormulaFunction implements CellFormulaFunction { Object test = args.values.get(0).accept(visitor); Object criteria = null; try { - criteria = args.values.get(1).accept(visitor); + criteria = args.values.get(1).accept(visitor); } catch (IllegalStateException e){ - return 0; + return 0; } FormulaError2 error = FormulaError2.forObject(criteria); if(error!=null) return error.getString(); - + Object range = args.values.get(2).accept(visitor); if (test instanceof SpreadsheetMatrix) { @@ -56,15 +54,15 @@ class SumifFormulaFunction implements CellFormulaFunction { SpreadsheetMatrix tm = (SpreadsheetMatrix) test; SpreadsheetMatrix rm = (SpreadsheetMatrix) range; for (int i = 0; i < tm.values.length; i++) { - if (SpreadsheetGraphUtils.matchCriteria(tm.values[i], criteria)) { - double d = SpreadsheetGraphUtils.asNumber(rm.values[i]); + if (Spreadsheets.matchCriteria(tm.values[i], criteria)) { + double d = Spreadsheets.asNumber(rm.values[i]); if (Double.isFinite(d)) sum += d; } } return sum; } else { - Double d = SpreadsheetGraphUtils.asNumber(test); + Double d = Spreadsheets.asNumber(test); return d; }