public void onResize() { if (application != null) { if (application.getActiveEuclidianView().getEuclidianController() instanceof HasOffsets) ((HasOffsets) application.getActiveEuclidianView().getEuclidianController()) .updateOffsets(); } App.debug("resized"); }
@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); } }
private void applyFontStyle(ArrayList<GeoElement> geos) { int fontStyle = 0; if (btnBold.isSelected()) fontStyle += 1; if (btnItalic.isSelected()) fontStyle += 2; App.printStacktrace(geos.size() + ""); for (int i = 0; i < geos.size(); i++) { GeoElement geo = geos.get(i); App.debug(((GeoCasCell) geo).getGeoText()); if (geo instanceof GeoCasCell && ((GeoCasCell) geo).getGeoText().getFontStyle() != fontStyle) { ((GeoCasCell) geo).getGeoText().setFontStyle(fontStyle); geo.updateRepaint(); needUndo = true; } } }
@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); }
public synchronized void initFileChooser() { if (fileChooser == null) { try { setFileChooser( new GeoGebraFileChooser( ((AppD) app), ((AppD) app).getCurrentImagePath())); // non-restricted fileChooser.addPropertyChangeListener( JFileChooser.FILE_FILTER_CHANGED_PROPERTY, new FileFilterChangedListener()); } catch (Exception e) { // fix for java.io.IOException: Could not get shell folder ID // list // Java bug // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6544857 App.debug("Error creating GeoGebraFileChooser - using fallback option"); setFileChooser( new GeoGebraFileChooser( ((AppD) app), ((AppD) app).getCurrentImagePath(), true)); // restricted // version } updateJavaUILanguage(); } }
public void playFunction( GeoFunction geoFunction, double double1, double double2, int double3, int double4) { App.debug("unimplemented"); }
public void playSequenceFromString(String string, int double1) { App.debug("unimplemented"); }
public void playSequenceNote(int double1, double double2, int i, int j) { App.debug("unimplemented"); }
public void pauseResumeSound(boolean b) { App.debug("unimplemented"); }
/** Handles data import. */ @Override public boolean importData(JComponent comp, Transferable t) { // give the drop target (this EV) the view focus requestViewFocus(); Point mousePos = ev.getMousePosition(); // ------------------------------------------ // Import handling is done in this order: // 1) PlotPanel GeoElement copies // 2) Images // 3) Text // 4) CASTableCells // 5) GGB files // ------------------------------------------ // try to get PlotPanel GeoElement copies if (t.isDataFlavorSupported(PlotPanelEuclidianView.plotPanelFlavor)) { try { AbstractAction act = (AbstractAction) t.getTransferData(PlotPanelEuclidianView.plotPanelFlavor); act.putValue("euclidianViewID", ev.getViewID()); act.actionPerformed(new ActionEvent(act, 0, null)); } catch (UnsupportedFlavorException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } return true; } // try to get an image boolean imageDropped = ((GuiManagerD) ev.getApplication().getGuiManager()).loadImage(t, false); if (imageDropped) return true; // handle CAS table cells as simple latex string (not dynamic!!) // ToDo: make it dynamic (after ticket 2449 is finished) DataFlavor[] df = t.getTransferDataFlavors(); for (DataFlavor d : df) { App.debug(d); } if (t.isDataFlavorSupported(CASTransferHandler.casTableFlavor)) { try { // after it is possible to refer to cas cells with "$1" we can refer dynamically // String tableRef; StringBuilder sb = new StringBuilder("FormulaText[$"); sb.append(1 + (Integer) t.getTransferData(CASTransferHandler.casTableFlavor)); sb.append("]"); // tableRef = "$" + (cellnumber+1); // create a GeoText on the specific mouse position GeoElement[] ret = ev.getApplication() .getKernel() .getAlgebraProcessor() .processAlgebraCommandNoExceptionHandling(sb.toString(), true, false, false); if (ret != null && ret[0].isTextValue()) { GeoText geo = (GeoText) ret[0]; geo.setLaTeX(true, false); // TODO: h should equal the geo height, this is just an // estimate double h = 2 * app.getFontSize(); geo.setRealWorldLoc( ev.toRealWorldCoordX(mousePos.x), ev.toRealWorldCoordY(mousePos.y - h)); geo.updateRepaint(); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } // check for ggb file drop boolean ggbFileDropped = ((GuiManagerD) app.getGuiManager()).handleGGBFileDrop(t); if (ggbFileDropped) return true; // handle all text flavors if (t.isDataFlavorSupported(DataFlavor.stringFlavor) || t.isDataFlavorSupported(AlgebraViewTransferHandler.algebraViewFlavor)) { try { String text = null; // expression to be converted into GeoText boolean isLaTeX = false; // get text from AlgebraView flavor if (t.isDataFlavorSupported(AlgebraViewTransferHandler.algebraViewFlavor)) { isLaTeX = true; // get list of selected geo labels ArrayList<String> list = (ArrayList<String>) t.getTransferData(AlgebraViewTransferHandler.algebraViewFlavor); // exit if empty list if (list.size() == 0) return false; // single geo if (list.size() == 1) { text = "FormulaText[" + list.get(0) + ", true, true]"; } // multiple geos, wrap in TableText else { text = "TableText["; for (int i = 0; i < list.size(); i++) { text += "{FormulaText[" + list.get(i) + ", true, true]}"; if (i < list.size() - 1) { text += ","; } } text += "]"; } } // get text from String flavor else { try { // first try to read text line-by-line Reader r = textReaderFlavor.getReaderForText(t); if (r != null) { StringBuilder sb = new StringBuilder(); String line = null; BufferedReader br = new BufferedReader(r); line = br.readLine(); while (line != null) { sb.append(line + "\n"); line = br.readLine(); } br.close(); text = sb.toString(); } } catch (Exception e) { App.debug("Caught exception decoding text transfer:" + e.getMessage()); } // if the reader didn't work, try to get whatever string is // available if (text == null) text = (String) t.getTransferData(DataFlavor.stringFlavor); // exit if no text found if (text == null) return false; // TODO --- validate the text? e.g. no quotes for a GeoText // wrap text in quotes text = "\"" + text + "\""; } // --------------------------------- // create GeoText GeoElement[] ret = ev.getApplication().getKernel().getAlgebraProcessor().processAlgebraCommand(text, true); if (ret != null && ret[0].isTextValue()) { GeoText geo = (GeoText) ret[0]; geo.setLaTeX(isLaTeX, false); // TODO: h should equal the geo height, this is just an // estimate double h = 2 * app.getFontSize(); geo.setRealWorldLoc( ev.toRealWorldCoordX(mousePos.x), ev.toRealWorldCoordY(mousePos.y - h)); geo.updateRepaint(); } return true; } catch (UnsupportedFlavorException ignored) { // TODO } catch (IOException ignored) { // TODO } } return false; }
@Override protected boolean confirm(String string) { App.debug("Shouldn't ever be called"); return false; }
@Override protected String prompt(String message, String def) { App.debug("Shouldn't ever be called"); return null; }
/** * Adds the given modes to a two-dimensional toolbar. The toolbar definition string looks like "0 * , 1 2 | 3 4 5 || 7 8 9" where the int values are mode numbers, "," adds a separator within a * menu, "|" starts a new menu and "||" adds a separator before starting a new menu. * * @param modes * @param tb * @param bg */ private void addCustomModesToToolbar(ModeToggleButtonGroup bg) { Vector<ToolbarItem> toolbarVec; try { if (dockPanel != null) { toolbarVec = ToolBar.parseToolbarString(dockPanel.getToolbarString()); } else { toolbarVec = ToolBar.parseToolbarString(((GuiManagerD) app.getGuiManager()).getToolbarDefinition()); } } catch (Exception e) { if (dockPanel != null) { App.debug("invalid toolbar string: " + dockPanel.getToolbarString()); } else { App.debug( "invalid toolbar string: " + ((GuiManagerD) app.getGuiManager()).getToolbarDefinition()); } toolbarVec = ToolBar.parseToolbarString(getDefaultToolbarString()); } // set toolbar boolean firstButton = true; // make the loop go backwards for eg Hebrew / Arabic int first = app.isRightToLeftReadingOrder() ? toolbarVec.size() - 1 : 0; int increment = app.isRightToLeftReadingOrder() ? -1 : 1; // for (int i = 0; i < toolbarVec.size(); i++) { for (int i = first; i >= 0 && i < toolbarVec.size(); i += increment) { ToolbarItem ob = toolbarVec.get(i); // separator between menus if (ob.getMode() == ToolBar.SEPARATOR) { addSeparator(); continue; } // new menu Vector<Integer> menu = ob.getMenu(); ModeToggleMenu tm = new ModeToggleMenu(app, this, bg); modeToggleMenus.add(tm); for (int k = 0; k < menu.size(); k++) { // separator int addMode = menu.get(k).intValue(); if (addMode < 0) { // separator within menu: tm.addSeparator(); } else { // standard case: add mode // check mode if (!"".equals(app.getToolName(addMode))) { tm.addMode(addMode); if (i == 0 && firstButton) { tm.getJToggleButton().setSelected(true); firstButton = false; } } } } if (tm.getToolsCount() > 0) add(tm); } }