Last modified 3 months ago
Last modified on 02/29/12 22:50:10
The GeoGebraPanel is a Java component intended for developers who want to embed GeoGebra into their Java applications.
There is very little documentation about this at the moment, for the moment you should look at the source code of the related classes:
- GeoGebraPanel (the panel itself)
- JavaScriptAPI (the most simple way for communication with GeoGebra)
Example
/**
* Minimalistic example on how to use GeoGebraPanel.
*/
public class GeoGebraPanelTest {
public static void main(String[] args) throws IOException {
// create frame (window)
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(new BorderLayout());
f.setTitle("GeoGebraPanel Test");
// create GeoGebraPanel
GeoGebraPanel ggbPanel = new GeoGebraPanel();
ggbPanel.buildGUI(); // needs to be called
f.add(ggbPanel, BorderLayout.CENTER);
// more frame related stuff
f.setPreferredSize(new Dimension(800, 600));
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
// now do something with the API (evaluate a command)
GgbAPI api = ggbPanel.getGeoGebraAPI();
api.evalCommand("A = (1,1)");
// store the result in a new .ggb file
byte[] data = Base64.decode(api.getBase64(true));
OutputStream out = new FileOutputStream("test.ggb");
out.write(data);
out.close();
}
}
