package org.geogebra.common.kernel.scripting; import org.geogebra.common.kernel.Kernel; import org.geogebra.common.kernel.arithmetic.Command; import org.geogebra.common.kernel.commands.CmdScripting; import org.geogebra.common.kernel.geos.GeoElement; import org.geogebra.common.kernel.geos.GeoText; import org.geogebra.common.main.MyError; /** * SetCaption */ public class CmdSetCaption extends CmdScripting { /** * Create new command processor * * @param kernel * kernel */ public CmdSetCaption(Kernel kernel) { super(kernel); } @Override protected final GeoElement[] perform(Command c) throws MyError { int n = c.getArgumentNumber(); switch (n) { case 2: GeoElement[] arg = resArgs(c); if (arg[1].isGeoText()) { GeoElement geo = arg[0]; geo.setCaption(((GeoText) arg[1]).getTextString()); geo.setLabelMode(GeoElement.LABEL_CAPTION); geo.updateRepaint(); return arg; } throw argErr(app, c, arg[1]); default: throw argNumErr(app, c, n); } } }