/** * Computes all roots of f */ public AlgoRootsPolynomial(Construction cons, String[] labels, GeoFunctionable f2, boolean labelEnabled) { this(cons, labels, labelEnabled && !cons.isSuppressLabelsActive(), f2, null, null); }
/** * @param cons * construction * @param labels * output labels * @param conditional * conditional function * @param polynomial * polynomial function */ public AlgoRootsPolynomialInterval(Construction cons, String[] labels, GeoFunction conditional, GeoFunction polynomial) { super(cons, labels, !cons.isSuppressLabelsActive(), conditional, polynomial, null); }
/** * @param cons * construction * @param labels * output labels * @param f * function * @param g * line */ public AlgoRootsPolynomialInterval(Construction cons, String[] labels, GeoFunction f, GeoLine g) { super(cons, labels, !cons.isSuppressLabelsActive(), f, null, g); }
/** * set setLabels to true * * @param label * use this String as indexed labels. */ public void setIndexLabels(String label) { this.indexLabel = label; // setLabels=true; setLabels = !cons.isSuppressLabelsActive(); updateLabels(); }
/** * @param autoLabel * whether label was set by * @return whether function contains only valid variables */ public boolean validate(boolean autoLabel) { return validate(autoLabel, cons.isSuppressLabelsActive()); }
/** * @param ve * expression to process * @return resulting elements * @throws MyError * e.g. for wrong syntax * @throws Exception * e.g. for circular definition */ public GeoElement[] processValidExpression(ValidExpression ve) throws MyError, Exception { return processValidExpression(ve, new EvalInfo(!cons.isSuppressLabelsActive(), true)); }
/** * The given labels will be used for the resulting points. * * @param labels * output labels */ public void setLabels(String[] labels) { this.labels = labels; setLabels = !cons.isSuppressLabelsActive(); // make sure that there are at least as many // points as labels if (labels != null) { initRootPoints(labels.length); } update(); }
/** * constructor with labels * * @param cons * construction * @param labels * output labels * @param func * function * @param poly * polyline */ public AlgoIntersectPolynomialPolyLine(Construction cons, String[] labels, GeoFunction func, GeoPoly poly, boolean polyClosed) { this(cons, func, poly, polyClosed); if (!cons.isSuppressLabelsActive()) { setLabels(labels); hasLabels = true; } update(); }
/** * set setLabels to true * * @param labels * use this Strings as labels. If labels == null, default * labels are used */ public void setLabels(String[] labels) { this.labels = labels; // setLabels=true; setLabels = !cons.isSuppressLabelsActive(); if (labels != null) { if (labels.length == 1) { setIndexLabels(labels[0]); } adjustOutputSize(labels.length); } else { updateLabels(); } }
/** * @param labels * output labels, only first one is used */ public void defaultLabels(String[] labels) { if (cons.isSuppressLabelsActive()) { // for redefine return; } if (labels == null || labels.length == 0) { setLabel(null); } else { setLabel(labels[0]); } defaultPolygonsLabels(); defaultSegmentLabels(); }
@Override public Path getBoundary() { boolean suppress = this.cons.isSuppressLabelsActive(); kernel.setSilentMode(true); GeoPointND[] pointsForPolyLine = new GeoPointND[getPointsLength() + 1]; System.arraycopy(points, 0, pointsForPolyLine, 0, getPointsLength()); pointsForPolyLine[getPointsLength()] = pointsForPolyLine[0]; GeoPolyLine pl = new GeoPolyLine(this.getConstruction(), pointsForPolyLine); kernel.setSilentMode(false); cons.setSuppressLabelCreation(suppress); return pl; }
/** * Returns the projected point of P on line g (or nearest for a Segment) */ final private GeoPointND closestPoint(GeoPointND P, Path g) { Construction cons = kernel.getConstruction(); boolean oldMacroMode = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); AlgoClosestPoint cp = kernel.getAlgoDispatcher() .getNewAlgoClosestPoint(cons, g, P); cons.setSuppressLabelCreation(oldMacroMode); return cp.getP(); } }
@Override public GeoElement evaluate(StringTemplate tpl) { boolean oldFlag = kernel.getConstruction().isSuppressLabelsActive(); kernel.getConstruction().setSuppressLabelCreation(true); GeoElement ge = kernel.getAlgebraProcessor().processEquation(this, this.wrap(), new EvalInfo(false))[0]; kernel.getConstruction().setSuppressLabelCreation(oldFlag); return ge; }
private void getIntersectsBetween(GeoElement geo, ArrayList<GeoElementND> retList) { Construction cons = kernel.getConstruction(); GeoLine xAxisLine = kernel.getXAxis(); GeoLine yAxisLine = kernel.getYAxis(); if (geo == xAxisLine || geo == yAxisLine) { return; } Command cmd = new Command(kernel, "Intersect", false); CmdIntersect intersect = new CmdIntersect(kernel); boolean wasSuppressLabelActive = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); Set<GeoElement> elements = new TreeSet<>(cons.getGeoSetConstructionOrder()); for (GeoElement element: elements) { if (hasIntersectsBetween(element) && element != geo && element.isEuclidianVisible()) { getSpecialPointsIntersect(geo, element, intersect, cmd, retList); } } cons.setSuppressLabelCreation(wasSuppressLabelActive); }
private void ensureListSize(int n) { // TODO: is suppress labels needed here? boolean oldSuppressLabels = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); if (list.size() < n) { for (int i = list.size(); i < n; i++) { list.add(new GeoNumeric(cons)); } } else if (list.size() > n) { for (int i = n - 1; i < list.size(); i++) { list.remove(i); } } cons.setSuppressLabelCreation(oldSuppressLabels); }
/** Computes "all" Extremums of f in <l,r> */ public AlgoExtremumMulti(Construction cons, String[] labels, GeoFunction function, GeoNumberValue left, GeoNumberValue right, boolean labelEnabled) { super(cons, labels, labelEnabled && !cons.isSuppressLabelsActive()); this.f1 = function; this.left = left; this.right = right; setInputOutput(); compute(); // Show at least one root point in algebra view // Copied from AlgoRootsPolynomial... GeoPoint[] gpt = getPoints(); // Ancestor if (!gpt[0].isDefined()) { gpt[0].setCoords(0, 0, 1); gpt[0].update(); gpt[0].setUndefined(); gpt[0].update(); } // if list not defined }
/** * Sets value of the local loop variable of the sequence and updates all * it's dependencies until we reach the sequence algo. */ private void updateLocalVar(double varVal) { // set local variable to given value var.setValue(varVal); // update var's algorithms until we reach expression if (expressionParentAlgo != null) { // update all dependent algorithms of the local variable var this.setStopUpdateCascade(true); // needed for eg Sequence[If[liste1(i) < a boolean oldLabelStatus = cons.isSuppressLabelsActive(); kernel.getConstruction().setSuppressLabelCreation(true); var.getAlgoUpdateSet().updateAllUntil(expressionParentAlgo); kernel.getConstruction().setSuppressLabelCreation(oldLabelStatus); this.setStopUpdateCascade(false); expressionParentAlgo.update(); } }
private void init1varFunction(int varIndex) { Construction cons = kernel.getConstruction(); boolean supress = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); // funBorder for inequality f(x)>g(x) is function f(x)-g(x) funBorder = new GeoFunction(cons, false); funBorder.setFunction(new Function(normal, fv[varIndex])); zeros = rootMultiple(funBorder); // for (int i = 0; i < zeros.length; i++) { // Log.debug(i + ":" + zeros[i]); // } cons.setSuppressLabelCreation(supress); border = funBorder; if (isStrict()) { border.setLineType(EuclidianStyleConstants.LINE_TYPE_DASHED_SHORT); } else { border.setLineType(EuclidianStyleConstants.LINE_TYPE_FULL); } }
@Override public final void compute() { size = inputList.size(); if (!inputList.isDefined() || size == 0) { outputList.setUndefined(); return; } outputList.setDefined(true); outputList.clear(); boolean suppressLabelCreation = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); for (int i = 0; i < size; i++) { GeoElement geo = inputList.get(i); if (geo.isGeoNumeric()) { GeoNumeric num = (GeoNumeric) geo; outputList.addPoint(num.getDouble(), 0.0, 1.0, this); } } cons.setSuppressLabelCreation(suppressLabelCreation); }
@Override public void finish() { result.clear(); AlgebraProcessor ap = result.getKernel().getAlgebraProcessor(); boolean oldMode = result.getConstruction().isSuppressLabelsActive(); result.getConstruction().setSuppressLabelCreation(true); for (int i = 0; i < sum.size(); i++) { try { result.add(ap.processValidExpression( sum.getListElement(i).wrap())[0]); } catch (MyError e) { result.setUndefined(); e.printStackTrace(); } catch (Exception e) { result.setUndefined(); e.printStackTrace(); } } result.getConstruction().setSuppressLabelCreation(oldMode); }