private void doTextFieldActionPerformed(JTextField source) { if (isUpdating) return; try { String inputText = source.getText().trim(); NumberValue nv; nv = app.getKernel().getAlgebraProcessor().evaluateToNumeric(inputText, false); double value = nv.getDouble(); if (source == fldXMin) { settings.xMin = value; firePropertyChange("settings", true, false); } else if (source == fldXMax) { settings.xMax = value; firePropertyChange("settings", true, false); } else if (source == fldYMax) { settings.yMax = value; firePropertyChange("settings", true, false); } else if (source == fldYMin) { settings.yMin = value; firePropertyChange("settings", true, false); } else if (source == fldXInterval) { settings.xAxesInterval = value; firePropertyChange("settings", true, false); } else if (source == fldYInterval) { settings.yAxesInterval = value; firePropertyChange("settings", true, false); } } catch (NumberFormatException e) { e.printStackTrace(); } }
private double evaluateExpression(String expr) { NumberValue nv; nv = kernel.getAlgebraProcessor().evaluateToNumeric(expr, false); return nv.getDouble(); }
protected final void compute() { if (!(f.isDefined() && ageo.isDefined() && bgeo.isDefined())) g.setUndefined(); // check if f has changed if (!hasEqualExpressions(f, g)) { g.set(f); } double ad = a.getDouble(); double bd = b.getDouble(); if (ad > bd) { g.setUndefined(); } else { boolean defined = g.setInterval(ad, bd); g.setDefined(defined); } }
protected final void compute() { if (updateRunning) return; updateRunning = true; for (int i = 1; i < input.length; i++) { if (!input[i].isDefined()) { list.setUndefined(); updateRunning = false; return; } } list.setDefined(true); // create sequence for expression(var) by changing var according to the given range double from = var_from.getDouble(); double to = var_to.getDouble(); double step = var_step == null ? 1 : var_step.getDouble(); isEmpty = !((to - from) * step > -Kernel.MIN_PRECISION); // an update may be necessary because another variable in expression // has changed. However, the range (from, to, step) may not have changed: // in this case it is much more efficient not to create all objects // for the list again, but just to set their new values boolean setValuesOnly = (from == last_from && to == last_to && step == last_step); // setValues does not work for functions setValuesOnly = setValuesOnly && !expIsFunctionOrCurve; // avoid label creation, might happen e.g. in boolean oldSuppressLabels = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); // update list if (setValuesOnly) updateListItems(from, to, step); else createNewList(from, to, step); // revert label creation setting cons.setSuppressLabelCreation(oldSuppressLabels); updateRunning = false; }
protected final void compute() { // validate size = inputList.size(); if (!inputList.isDefined() || size == 0) { outputList.setUndefined(); return; } // convert geoList to sorted array of double sortedData = new double[size]; for (int i = 0; i < size; i++) { GeoElement geo = inputList.get(i); if (geo.isNumberValue()) { NumberValue num = (NumberValue) geo; sortedData[i] = num.getDouble(); } else { outputList.setUndefined(); return; } } Arrays.sort(sortedData); // create the z values calculateZValues(size); // prepare output list. Pre-existing geos will be recycled, // but extra geos are removed when outputList is too long outputList.setDefined(true); for (int i = outputList.size() - 1; i >= size; i--) { GeoElement extraGeo = outputList.get(i); extraGeo.remove(); outputList.remove(extraGeo); } int oldListSize = outputList.size(); // iterate through the sorted data and create the normal quantile points boolean suppressLabelCreation = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); for (int i = 0; i < sortedData.length; i++) { if (i < oldListSize) ((GeoPoint) outputList.get(i)).setCoords(sortedData[i], zValues[i], 1.0); else outputList.add(new GeoPoint(cons, null, sortedData[i], zValues[i], 1.0)); } // create qq line segment and add it to the list outputList.add(getQQLineSegment()); cons.setSuppressLabelCreation(suppressLabelCreation); }
public AlgoIntegralFunctions copy(){ return new AlgoIntegralFunctions(cons, null, (GeoFunction)f.copy(),(GeoFunction)g.copy(), new MyDouble(kernel,a.getDouble()), new MyDouble(kernel,b.getDouble())); }