MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getFactor

Method getFactor

ij/src/main/java/ij/macro/Interpreter.java:1645–1763  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1643 }
1644
1645 final double getFactor() {
1646 double value = 0.0;
1647 Variable v = null;
1648 getToken();
1649 switch (token) {
1650 case NUMBER:
1651 value = tokenValue;
1652 break;
1653 case STRING_CONSTANT:
1654 value = Tools.parseDouble(tokenString,Double.NaN);
1655 break;
1656 case NUMERIC_FUNCTION:
1657 value = func.getFunctionValue(pgm.table[tokenAddress].type);
1658 break;
1659 case STRING_FUNCTION:
1660 String str = func.getStringFunction(pgm.table[tokenAddress].type);
1661 if (nextToken()=='.') {
1662 getToken(); // '.'
1663 getToken(); // numericFunction
1664 value = getNumericStringFunction(str);
1665 } else
1666 value = Tools.parseDouble(str);
1667 if ("NaN".equals(str))
1668 value = Double.NaN;
1669 else if (Double.isNaN(value))
1670 error("Numeric value expected");
1671 break;
1672 case VARIABLE_FUNCTION:
1673 v = func.getVariableFunction(pgm.table[tokenAddress].type);
1674 if (v==null)
1675 error("No return value");
1676 if (v.getString()!=null) {
1677 error("Numeric return value expected");
1678 } else
1679 value = v.getValue();
1680 break;
1681 case USER_FUNCTION:
1682 v = runUserFunction();
1683 if (v==null)
1684 error("No return value");
1685 if (done)
1686 value = 0;
1687 else {
1688 if (v.getString()!=null)
1689 error("Numeric return value expected");
1690 else
1691 value = v.getValue();
1692 }
1693 break;
1694 case TRUE: value = 1.0; break;
1695 case FALSE: value = 0.0; break;
1696 case PI: value = Math.PI; break;
1697 case NaN: value = Double.NaN; break;
1698 case WORD:
1699 v = lookupVariable();
1700 if (v==null)
1701 return 0.0;
1702 int next = nextToken();

Callers 2

getTermMethod · 0.95

Calls 15

getTokenMethod · 0.95
parseDoubleMethod · 0.95
nextTokenMethod · 0.95
errorMethod · 0.95
getStringMethod · 0.95
getValueMethod · 0.95
runUserFunctionMethod · 0.95
lookupVariableMethod · 0.95
getArrayElementMethod · 0.95
runNumericFunctionMethod · 0.95
getArrayMethod · 0.95

Tested by

no test coverage detected