/** * Turns silent mode on (true) or off (false). In silent mode, commands can * be used to create objects without any side effects, i.e. no labels are * created, algorithms are not added to the construction list and the views * are not notified about new objects. * * @param silentMode * silent mode */ public final void setSilentMode(boolean silentMode) { this.silentMode = silentMode; // no new labels, no adding to construction list getConstruction().setSuppressLabelCreation(silentMode); }
/** * 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 void callback(Boolean ok) { cons.setSuppressLabelCreation(oldVal); if (ok) { DialogManager.doSegmentFixed(kernel, point, inputHandler.getNum()); } callback.callback(ok); } });
private GeoElementND createGeoFromString(String text, boolean suppressLabelCreation) { try { // create the geo // ================================ boolean oldSuppressLabelMode = cons.isSuppressLabelsActive(); if (suppressLabelCreation) { cons.setSuppressLabelCreation(true); } // workaround for eg CmdNormal -> always creates undo point boolean oldEnableUndo = cons.isUndoEnabled(); cons.setUndoEnabled(false); GeoElementND[] geos = kernel.getAlgebraProcessor() .processAlgebraCommandNoExceptions(text, false); cons.setUndoEnabled(oldEnableUndo); if (suppressLabelCreation) { cons.setSuppressLabelCreation(oldSuppressLabelMode); } return geos[0]; } catch (Exception e) { e.printStackTrace(); return null; } }
@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; }
/** * @param c * command * @param pos * argument position * @param info * evaluation info * @return single arg * @throws MyError * when argument is invalid */ protected final GeoElement resArgSilent(Command c, int pos, EvalInfo info) throws MyError { boolean oldMacroMode = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); // resolve arguments to get GeoElements // resolve variables in argument expression c.getArgument(pos).resolveVariables(info.withLabels(false)); // resolve i-th argument and get GeoElements // use only first resolved argument object for result GeoElement result = resArg(c.getArgument(pos), info)[0]; cons.setSuppressLabelCreation(oldMacroMode); return result; }
/** Point3D on a 1D path with cartesian coordinates (x,y,z) */ @Override final public GeoPoint3D point3D(String label, Path path, double x, double y, double z, boolean addToConstruction, boolean coords2D) { boolean oldMacroMode = false; if (!addToConstruction) { oldMacroMode = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); } AlgoPoint3DOnPath algo = new AlgoPoint3DOnPath(cons, path, x, y, z); GeoPoint3D p = (GeoPoint3D) algo.getP(); if (coords2D) { p.setCartesian(); } else { p.setCartesian3D(); } p.setLabel(label); if (!addToConstruction) { cons.setSuppressLabelCreation(oldMacroMode); } return p; }
/** Point in region with cartesian coordinates (x,y) */ final public GeoPoint pointIn(String label, Region region, double x, double y, boolean addToConstruction, boolean complex, boolean coords2D) { boolean oldMacroMode = false; if (!addToConstruction) { oldMacroMode = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); } AlgoPointInRegion algo = new AlgoPointInRegion(cons, label, region, x, y); // Application.debug("PointIn - \n x="+x+"\n y="+y); GeoPoint p = algo.getP(); if (complex) { p.setMode(Kernel.COORD_COMPLEX); } else if (!coords2D) { p.setCartesian3D(); p.update(); } if (!addToConstruction) { cons.setSuppressLabelCreation(oldMacroMode); } return p; }
/** Point in region with cartesian coordinates (x,y,z) */ @Override final public GeoPoint3D point3DIn(String label, Region region, Coords coords, boolean addToConstruction, boolean coords2D) { boolean oldMacroMode = false; if (!addToConstruction) { oldMacroMode = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); } // Application.debug("Point3DIn - \n x="+x+"\n y="+y+"\n z="+z); AlgoPoint3DInRegion algo = new AlgoPoint3DInRegion(cons, label, region, coords); GeoPoint3D p = algo.getP(); if (coords2D) { p.setCartesian(); } else { p.setCartesian3D(); } p.update(); if (!addToConstruction) { cons.setSuppressLabelCreation(oldMacroMode); } return p; }
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); }
private void getEquationSpecialPoints(GeoElement geo, boolean xAxis, boolean yAxis, 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); if (xAxis) { getSpecialPointsIntersect(geo, xAxisLine, intersect, cmd, retList); } if (yAxis) { getSpecialPointsIntersect(geo, yAxisLine, intersect, cmd, retList); } cons.setSuppressLabelCreation(wasSuppressLabelActive); }
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 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); } }
/** * 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(); } }
@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; }
@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 callback(GeoElementND[] result) { cons.setSuppressLabelCreation(oldVal); boolean success = result != null && result[0] instanceof GeoNumberValue; if (!success) { handler.showError(app.getLocalization() .getError("NumberExpected")); if (callback != null) { callback.callback(false); } return; } creator.callback((GeoNumberValue) result[0]); if (callback != null) { callback.callback(success); } } });
@Override public void callback(GeoElementND[] result) { cons.setSuppressLabelCreation(oldVal); boolean success = result != null && result[0] instanceof GeoNumberValue; if (!success) { handler.showError(kernel.getLocalization() .getError("NumberExpected")); if (callback != null) { callback.callback(false); } return; } DialogManager.doAngleFixed(kernel, segments, points, (GeoNumberValue) result[0], clockwise, ec); if (callback != null) { callback.callback(true); } } });
@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); }
@Override public void callback(GeoElementND[] result) { boolean success = result != null && result[0] instanceof GeoNumberValue; Construction cons = algebraProcessor.getKernel() .getConstruction(); if (success) { setNum((GeoNumberValue) result[0]); if (callback != null) { cons.setSuppressLabelCreation(oldVal); callback.callback(num); } } else { handler.showError(app.getLocalization() .getError("NumberExpected")); } if (callback0 != null) { callback0.callback(success); } } });