public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; switch (n) { case 1: // Perimeter[ <GeoPolygon> ] arg = resArgs(c); if ((arg[0].isGeoPolygon())) { GeoElement[] ret = {kernel.Perimeter(c.getLabel(), (GeoPolygon) arg[0])}; return ret; // Perimeter[ <Conic> ] } else if ((arg[0].isGeoConic())) { GeoElement[] ret = {kernel.Circumference(c.getLabel(), (GeoConic) arg[0])}; return ret; } else if ((arg[0].isGeoLocus())) { // Perimeter[locus] GeoElement[] ret = {kernel.Perimeter(c.getLabel(), (GeoLocus) arg[0])}; return ret; } else throw argErr(app, c.getName(), arg[0]); default: throw argNumErr(app, c.getName(), n); } }
public final void perform(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; switch (n) { case 1: arg = resArgs(c); if (arg[0].isNumberValue()) { GeoNumeric layerGeo = (GeoNumeric) arg[0]; int layer = (int) layerGeo.getDouble(); Iterator<GeoElement> it = kernelA.getConstruction().getGeoSetLabelOrder().iterator(); while (it.hasNext()) { GeoElement geo = it.next(); if (geo.getLayer() == layer) { geo.setEuclidianVisible(true); geo.updateRepaint(); } } return; } else throw argErr(app, c.getName(), null); default: throw argNumErr(app, c.getName(), n); } }
public final void perform(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; switch (n) { case 2: arg = resArgs(c); if (arg[1].isGeoText()) { GeoElement geo = (GeoElement) arg[0]; if (RenameInputHandler.checkName(geo, ((GeoText) arg[1]).getTextString())) { geo.rename(((GeoText) arg[1]).getTextString()); geo.updateRepaint(); return; } else { throw argErr(app, c.getName(), arg[1]); } } else throw argErr(app, c.getName(), arg[1]); default: throw argNumErr(app, c.getName(), n); } }
public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; arg = resArgs(c); switch (n) { case 0: throw argNumErr(app, c.getName(), n); case 1: if (arg[0].isGeoList()) { GeoElement[] ret = {doCommand(c.getLabel(), (GeoList) arg[0])}; return ret; } else throw argErr(app, c.getName(), arg[0]); // more than one argument default: if (arg[0].isNumberValue()) { // try to create list of numbers GeoList list = wrapInList(kernel, arg, arg.length, GeoClass.NUMERIC); if (list != null) { GeoElement[] ret = {doCommand(c.getLabel(), list)}; return ret; } } else if (arg[0].isVectorValue()) { // try to create list of points (eg FitExp[]) GeoList list = wrapInList(kernel, arg, arg.length, GeoClass.POINT); if (list != null) { GeoElement[] ret = {doCommand(c.getLabel(), list)}; return ret; } } throw argNumErr(app, c.getName(), n); } }
public final GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; switch (n) { case 3: arg = resArgs(c); if ((ok[0] = (arg[0].isGeoPoint())) && (ok[1] = (arg[1].isGeoPoint())) && (ok[2] = (arg[2].isGeoPoint()))) { GeoElement[] ret = { kernel.CircumcircleArc( c.getLabel(), (GeoPoint2) arg[0], (GeoPoint2) arg[1], (GeoPoint2) arg[2]) }; return ret; } else { if (!ok[0]) throw argErr(app, c.getName(), arg[0]); else if (!ok[1]) throw argErr(app, c.getName(), arg[1]); else throw argErr(app, c.getName(), arg[2]); } default: throw argNumErr(app, c.getName(), n); } }
@Override public final GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); // avoid // "Command Sequence not known eg Sequence[If[Element[list1,i]=="b",0,1]] if (n < 3 || n % 2 == 0) throw argNumErr(app, c.getName(), n); // create local variable at position 1 and resolve arguments GeoElement arg = null; GeoElement[] vars = new GeoElement[n / 2]; GeoList[] over = new GeoList[n / 2]; boolean oldval = cons.isSuppressLabelsActive(); try { cons.setSuppressLabelCreation(true); arg = resArgsForZip(c, vars, over); } finally { for (GeoElement localVar : vars) { if (localVar != null) cons.removeLocalVariable(localVar.getLabel(StringTemplate.defaultTemplate)); } cons.setSuppressLabelCreation(oldval); } AlgoZip algo = new AlgoZip(cons, c.getLabel(), arg, vars, over); return algo.getOutput(); }
@Override public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; switch (n) { case 3: arg = resArgs(c); if ((ok[0] = (arg[0].isGeoPoint())) && (ok[1] = (arg[1].isGeoPoint())) && (ok[2] = (arg[2].isGeoPoint()))) { AlgoIncircle algo = new AlgoIncircle( cons, c.getLabel(), (GeoPoint) arg[0], (GeoPoint) arg[1], (GeoPoint) arg[2]); GeoConic circle = (GeoConic) algo.getCircle(); circle.setToSpecific(); circle.update(); GeoElement[] ret = {circle}; return ret; } throw argErr(app, c.getName(), getBadArg(ok, arg)); default: throw argNumErr(app, c.getName(), n); } }
public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; arg = resArgs(c); switch (n) { case 3: if ((ok[0] = arg[0].isGeoList()) && (ok[1] = arg[1].isGeoNumeric()) && (ok[2] = arg[2].isGeoNumeric())) { GeoElement[] ret = { kernel.Take(c.getLabel(), (GeoList) arg[0], (GeoNumeric) arg[1], (GeoNumeric) arg[2]) }; return ret; } else if ((ok[0] = arg[0].isGeoText()) && (ok[1] = arg[1].isGeoNumeric()) && (ok[2] = arg[2].isGeoNumeric())) { GeoElement[] ret = { kernel.Take(c.getLabel(), (GeoText) arg[0], (GeoNumeric) arg[1], (GeoNumeric) arg[2]) }; return ret; } else throw argErr(app, c.getName(), getBadArg(ok, arg)); default: throw argNumErr(app, c.getName(), n); } }
public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; arg = resArgs(c); boolean cumulative = false; // default for n=3 switch (n) { case 4: if (!arg[2].isGeoFunction() || !((GeoFunction) arg[2]).toString().equals("x")) { throw argErr(app, c.getName(), arg[2]); } if (arg[3].isGeoBoolean()) { cumulative = ((GeoBoolean) arg[3]).getBoolean(); } else throw argErr(app, c.getName(), arg[3]); // fall through case 3: if ((ok[0] = arg[0].isNumberValue()) && (ok[1] = arg[1].isNumberValue())) { if (arg[2].isGeoFunction() && ((GeoFunction) arg[2]).toString().equals("x")) { // needed for eg Normal[1, 0.001, x] kernelA.setTemporaryPrintFigures(15); String x0 = arg[0].getLabel(); String g = arg[1].getLabel(); kernelA.restorePrintAccuracy(); String command; if (cumulative) { command = "1/pi atan((x-(" + x0 + "))/abs(" + g + "))+0.5"; } else { command = "1/pi abs(" + g + ")/((" + g + ")^2+(x-(" + x0 + "))^2)"; } GeoElement[] ret = (GeoElement[]) kernelA.getAlgebraProcessor().processAlgebraCommand(command, true); return ret; } else if (arg[2].isNumberValue()) { GeoElement[] ret = { kernelA.Cauchy( c.getLabel(), (NumberValue) arg[0], (NumberValue) arg[1], (NumberValue) arg[2]) }; return ret; } else throw argErr(app, c.getName(), arg[2]); } else if (!ok[0]) throw argErr(app, c.getName(), arg[0]); else if (!ok[1]) throw argErr(app, c.getName(), arg[1]); default: throw argNumErr(app, c.getName(), n); } }
@Override public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; arg = resArgs(c); switch (n) { case 1: if (arg[0].isGeoFunctionable()) { GeoNumeric var = new GeoNumeric(cons, 0.0); arg[0].setEuclidianVisible(false); arg[0].update(); var.setLabel(null); // set label to next available var.setEuclidianVisible(true); var.setIntervalMin(0.0); var.setIntervalMax(1.0); var.setAnimating(true); var.setAnimationStep(0.01); var.setAnimationType(GeoElement.ANIMATION_INCREASING); var.update(); StringTemplate tpl = StringTemplate.maxPrecision; StringBuilder sb = new StringBuilder(); sb.append("Function["); sb.append(arg[0].getLabel(tpl)); sb.append(",x(Corner[1]), x(Corner[1]) (1-"); sb.append(var.getLabel(tpl)); sb.append(") + x(Corner(2)) "); sb.append(var.getLabel(tpl)); sb.append("]"); kernelA.getAnimatonManager().startAnimation(); try { return kernelA .getAlgebraProcessor() .processAlgebraCommandNoExceptionHandling(sb.toString(), true, false, true); } catch (Exception e) { e.printStackTrace(); throw argErr(app, c.getName(), arg[0]); } catch (MyError e) { e.printStackTrace(); throw argErr(app, c.getName(), arg[0]); } } throw argErr(app, c.getName(), arg[0]); default: throw argNumErr(app, c.getName(), n); } }
public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; arg = resArgs(c); switch (n) { case 1: GeoElement[] ret = {kernelA.Defined(c.getLabel(), arg[0])}; return ret; default: throw argNumErr(app, c.getName(), n); } }
public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; arg = resArgs(c); switch (n) { case 1: arg = resArgs(c); if (arg[0].isGeoList()) { GeoElement[] ret = {doCommand(c.getLabel(), (GeoList) arg[0])}; return ret; } else throw argErr(app, c.getName(), arg[0]); default: throw argNumErr(app, c.getName(), n); } }
@Override public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; arg = resArgs(c); BooleanValue cumulative = null; // default for n=2 (false) switch (n) { case 3: if (!arg[1].isGeoFunction() || !((GeoFunction) arg[1]).toString(StringTemplate.defaultTemplate).equals("x")) { throw argErr(app, c.getName(), arg[1]); } if (arg[2].isGeoBoolean()) { cumulative = (BooleanValue) arg[2]; } else throw argErr(app, c.getName(), arg[2]); // fall through case 2: if (arg[0].isNumberValue()) { if (arg[1].isGeoFunction() && ((GeoFunction) arg[1]).toString(StringTemplate.defaultTemplate).equals("x")) { App.debug("jhgjhgjhg"); AlgoTDistributionDF algo = new AlgoTDistributionDF(cons, c.getLabel(), (NumberValue) arg[0], cumulative); return algo.getGeoElements(); } else if (arg[1].isNumberValue()) { AlgoTDistribution algo = new AlgoTDistribution( cons, c.getLabel(), (NumberValue) arg[0], (NumberValue) arg[1]); GeoElement[] ret = {algo.getResult()}; return ret; } else throw argErr(app, c.getName(), arg[1]); } throw argErr(app, c.getName(), arg[0]); default: throw argNumErr(app, c.getName(), n); } }
public final void perform(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; app.clearSelectedGeos(); if (n > 0) { arg = resArgs(c); for (int i = 0; i < n; i++) { if ((arg[i].isGeoElement())) { GeoElement geo = (GeoElement) arg[i]; app.addSelectedGeo(geo, true); } } } return; }
public final GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; arg = resArgs(c); switch (n) { case 1: if (ok[0] = (arg[0] instanceof CasEvaluableFunction)) { GeoElement[] ret = {kernelA.Factor(c.getLabel(), (CasEvaluableFunction) arg[0])}; return ret; } else throw argErr(app, c.getName(), arg[0]); // more than one argument default: throw argNumErr(app, c.getName(), n); } }
/** * Checks correctness of inputs and runs the command. Last change: correct error messages * (2010-05-17), Zbynek Konecny */ @Override public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; if (n == 1) { arg = resArgs(c); if (arg[0].isRegion()) { GeoElement[] ret = { getAlgoDispatcher().PointIn(c.getLabel(), (Region) arg[0], 0, 0, true, false, true) }; return ret; } throw argErr(app, c.getName(), arg[0]); } throw argNumErr(app, c.getName(), n); }
public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); // boolean[] ok = new boolean[n]; GeoElement[] arg; switch (n) { case 1: arg = resArgs(c); if (arg[0].isGeoElement3D()) { if (arg[0].isGeoVector()) { GeoElement[] ret = {kernel.getManager3D().Length(c.getLabel(), (GeoVector3D) arg[0])}; return ret; } } break; } return super.process(c); }
public final GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; switch (n) { case 1: arg = resArgs(c); if (ok[0] = (arg[0].isGeoLine())) { GeoElement[] ret = {kernel.Direction(c.getLabel(), (GeoLine) arg[0])}; return ret; } else { if (!ok[0]) throw argErr(app, "Direction", arg[0]); } default: throw argNumErr(app, "Direction", n); } }
@Override public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; switch (n) { case 2: arg = resArgs(c); // line through point orthogonal to vector if ((ok[0] = (arg[0].isGeoPoint())) && (ok[1] = (arg[1].isGeoVector()))) { GeoElement[] ret = { getAlgoDispatcher().OrthogonalLine(c.getLabel(), (GeoPoint) arg[0], (GeoVector) arg[1]) }; return ret; } // line through point orthogonal to another line else if ((ok[0] = (arg[0].isGeoPoint())) && (ok[1] = (arg[1].isGeoLine()))) { GeoElement[] ret = { getAlgoDispatcher().OrthogonalLine(c.getLabel(), (GeoPoint) arg[0], (GeoLine) arg[1]) }; return ret; } else if ((ok[0] = (arg[0].isGeoPoint())) && (ok[1] = (arg[1].isGeoConic()))) { AlgoOrthoLinePointConic algo = new AlgoOrthoLinePointConic(cons, c.getLabel(), (GeoPoint) arg[0], (GeoConic) arg[1]); return algo.getOutput(); } // syntax error else { if (!ok[0]) throw argErr(app, c.getName(), arg[0]); throw argErr(app, c.getName(), arg[1]); } default: throw argNumErr(app, c.getName(), n); } }
@Override public GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; arg = resArgs(c); switch (n) { case 1: if (arg[0].isGeoText()) { AlgoLetterToUnicode algo = new AlgoLetterToUnicode(cons, c.getLabel(), (GeoText) arg[0]); GeoElement[] ret = {algo.getResult()}; return ret; } throw argErr(app, c.getName(), arg[0]); default: throw argNumErr(app, c.getName(), n); } }
public final GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean[] ok = new boolean[n]; GeoElement[] arg; arg = resArgs(c); switch (n) { case 1: if (ok[0] = (arg[0].isGeoFunction())) { GeoElement[] ret = {kernel.Factors(c.getLabel(), (GeoFunction) arg[0])}; return ret; } else if (ok[0] = (arg[0].isGeoNumeric())) { GeoElement[] ret = {kernel.PrimeFactorisation(c.getLabel(), (GeoNumeric) arg[0])}; return ret; } else throw argErr(app, c.getName(), arg[0]); // more than one argument default: throw argNumErr(app, c.getName(), n); } }
/** * Resolves arguments, creates local variables and fills the vars and overlists * * @param c * @return list of arguments */ protected final GeoElement[] resArgsForZip(Command c) { // check if there is a local variable in arguments int numArgs = c.getArgumentNumber(); vars = new GeoElement[numArgs / 2]; over = new GeoList[numArgs / 2]; Construction cmdCons = (Construction) c.getKernel().getConstruction(); for (int varPos = 1; varPos < numArgs; varPos += 2) { String localVarName = c.getVariableName(varPos); if (localVarName == null) { throw argErr(app, c.getName(), c.getArgument(varPos)); } // add local variable name to construction GeoElement num = null; // initialize first value of local numeric variable from initPos boolean oldval = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); GeoList gl = (GeoList) resArg(c.getArgument(varPos + 1))[0]; cons.setSuppressLabelCreation(oldval); num = gl.get(0).copyInternal(cons); cmdCons.addLocalVariable(localVarName, num); // set local variable as our varPos argument c.setArgument(varPos, new ExpressionNode(c.getKernel(), num)); vars[varPos / 2] = num.toGeoElement(); over[varPos / 2] = gl; // resolve all command arguments including the local variable just // created // remove local variable name from kernel again } GeoElement[] arg = resArgs(c); for (GeoElement localVar : vars) cmdCons.removeLocalVariable(localVar.getLabel()); return arg; }
@Override protected final void perform(Command c) throws MyError { int n = c.getArgumentNumber(); switch (n) { case 2: arg = resArgs(c); if (arg[1].isGeoNumeric()) { GeoElement geo = arg[0]; geo.setTooltipMode((int) ((GeoNumeric) arg[1]).getDouble()); geo.updateRepaint(); return; } throw argErr(app, c.getName(), arg[1]); default: throw argNumErr(app, c.getName(), n); } }
public final GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); // avoid // "Command Sequence not known eg Sequence[If[Element[list1,i]=="b",0,1]] if (n < 3 || n % 2 == 0) throw argNumErr(app, c.getName(), n); boolean[] ok = new boolean[n]; // create local variable at position 1 and resolve arguments GeoElement[] arg; arg = resArgsForZip(c); if ((ok[0] = arg[0].isGeoElement()) && (ok[2] = arg[2].isGeoList())) { return kernelA.Zip(c.getLabel(), arg[0], vars, over); } else { for (int i = 0; i < n; i++) { if (!ok[i]) throw argErr(app, c.getName(), arg[i]); } } return null; }
@Override public final GeoElement[] process(Command c) throws MyError { int n = c.getArgumentNumber(); boolean ok; GeoElement[] arg; arg = resArgs(c); switch (n) { case 2: if ((ok = arg[0].isGeoFunction()) && (arg[1].isNumberValue())) { AlgoLimitBelow algo = new AlgoLimitBelow(cons, c.getLabel(), (GeoFunction) arg[0], (NumberValue) arg[1]); GeoElement[] ret = {algo.getResult()}; return ret; } throw argErr(app, c.getName(), ok ? arg[1] : arg[0]); // more than one argument default: throw argNumErr(app, c.getName(), n); } }