private void addNewGeoToConstruction() { if (objectType == TYPE_LISTOFPOINTS || objectType == TYPE_POLYLINE) { app.getKernel().getConstruction().addToConstructionList(newGeo.getParentAlgorithm(), true); } newGeo.setEuclidianVisible(true); if (!newGeo.isGeoText()) newGeo.setAuxiliaryObject(false); if (objectType == TYPE_LISTOFPOINTS) { GeoList gl = (GeoList) newGeo; for (int i = 0; i < gl.size(); i++) { gl.get(i).setEuclidianVisible(true); gl.get(i).setAuxiliaryObject(false); } } if (objectType == TYPE_POLYLINE) { GeoPoint[] pts = ((AlgoPolyLine) newGeo.getParentAlgorithm()).getPoints(); for (int i = 0; i < pts.length; i++) { pts[i].setEuclidianVisible(true); pts[i].setAuxiliaryObject(false); } } newGeo.update(); app.storeUndoInfo(); }
@Override public void compute() { if (!factorList.isDefined() || !Kernel.isInteger(number.getDouble())) { result.setUndefined(); return; } long res = 1; for (int i = 0; i < factorList.size(); i++) { GeoList pair = (GeoList) factorList.get(i); double exp = ((NumberValue) pair.get(1)).getDouble(); if (sum) { double prime = ((NumberValue) pair.get(0)).getDouble(); App.debug(prime); res = res * Math.round((Math.pow(prime, exp + 1) - 1) / (prime - 1.0)); } else { res = res * Math.round(exp + 1); } } result.setValue(res); }
@Override public final void compute() { size = inputList.size(); if (!inputList.isDefined() || !function.toGeoElement().isDefined()) { r2.setUndefined(); return; } GeoFunction funGeo = function.getGeoFunction(); // Calculate errorsum and ssy: double sumyy = 0.0d; double sumy = 0.0d; double syy = 0.0d; double errorsum = 0.0d; GeoElement geo = null; GeoPoint point = null; double x, y, v; for (int i = 0; i < size; i++) { geo = inputList.get(i); if (geo.isGeoPoint()) { point = (GeoPoint) geo; x = point.getX(); y = point.getY(); v = funGeo.evaluate(x); errorsum += (v - y) * (v - y); sumy += y; sumyy += y * y; } else { r2.setUndefined(); return; } // if calculation is possible } // for all points syy = sumyy - sumy * sumy / size; // calculate RSquare r2.setValue(1 - errorsum / syy); } // compute()
private void createNewGeo() { boolean nullGeo = newGeo == null; if (!nullGeo) { if (objectType == TYPE_LISTOFPOINTS) { GeoList gl = (GeoList) newGeo; for (int i = 0; i < gl.size(); i++) gl.get(i).remove(); } if (objectType == TYPE_POLYLINE) { GeoPoint[] pts = ((AlgoPolyLine) newGeo.getParentAlgorithm()).getPoints(); for (int i = 0; i < pts.length; i++) pts[i].remove(); } newGeo.remove(); } int column1 = table.selectedCellRanges.get(0).getMinColumn(); int column2 = table.selectedCellRanges.get(0).getMaxColumn(); int row1 = table.selectedCellRanges.get(0).getMinRow(); int row2 = table.selectedCellRanges.get(0).getMaxRow(); boolean copyByValue = btnValue.isSelected(); boolean scanByColumn = cbScanOrder.getSelectedIndex() == 1; boolean leftToRight = cbLeftRightOrder.getSelectedIndex() == 0; boolean transpose = ckTranspose.isSelected(); boolean doCreateFreePoints = true; boolean doStoreUndo = true; boolean isSorted = false; try { switch (objectType) { case TYPE_LIST: newGeo = cp.createList(selectedCellRanges, scanByColumn, copyByValue); break; case TYPE_LISTOFPOINTS: newGeo = cp.createPointGeoList( selectedCellRanges, copyByValue, leftToRight, isSorted, doStoreUndo, doCreateFreePoints); newGeo.setLabel(null); for (int i = 0; i < ((GeoList) newGeo).size(); i++) { ((GeoList) newGeo).get(i).setAuxiliaryObject(true); ((GeoList) newGeo).get(i).setEuclidianVisible(false); } newGeo.updateRepaint(); break; case TYPE_MATRIX: newGeo = cp.createMatrix(column1, column2, row1, row2, copyByValue, transpose); break; case TYPE_TABLETEXT: newGeo = cp.createTableText(column1, column2, row1, row2, copyByValue, transpose); break; case TYPE_POLYLINE: newGeo = cp.createPolyLine(selectedCellRanges, copyByValue, leftToRight); newGeo.setLabel(null); GeoPoint[] pts = ((AlgoPolyLine) newGeo.getParentAlgorithm()).getPoints(); for (int i = 0; i < pts.length; i++) { pts[i].setAuxiliaryObject(true); pts[i].setEuclidianVisible(false); } newGeo.updateRepaint(); break; } ImageIcon latexIcon = new ImageIcon(); // String latexStr = newGeo.getLaTeXAlgebraDescription(true); String latexStr = newGeo.getFormulaString(StringTemplate.latexTemplate, true); // System.out.println(latexStr); Font latexFont = new Font( app.getPlainFont().getName(), app.getPlainFont().getStyle(), app.getPlainFont().getSize() - 1); if (latexStr != null && newGeo.isLaTeXDrawableGeo()) { app.getDrawEquation() .drawLatexImageIcon(app, latexIcon, latexStr, latexFont, false, Color.black, null); lblPreview.setText(" "); } else { lblPreview.setText(newGeo.getAlgebraDescriptionTextOrHTMLDefault()); } lblPreview.setIcon(latexIcon); if (!nullGeo) { newGeo.setLabel(fldName.getText()); newGeo.setAuxiliaryObject(true); newGeo.setEuclidianVisible(false); } updateGUI(); } catch (Exception e) { e.printStackTrace(); } }
/** * Return the length of a GeoList * * @param list the GeoList * @return the length of the list */ public static int getListLength(GeoList list) { return list.size(); }