public final void perform(Command c) throws MyError { int n = c.getArgumentNumber(); GeoElement[] arg; switch (n) { case 1: arg = resArgs(c); if (arg[0].isNumberValue()) { GeoNumeric layerGeo = (GeoNumeric) arg[0]; int layer = (int) layerGeo.getDouble(); Iterator<GeoElement> it = kernelA.getConstruction().getGeoSetLabelOrder().iterator(); while (it.hasNext()) { GeoElement geo = it.next(); if (geo.getLayer() == layer) { geo.setEuclidianVisible(true); geo.updateRepaint(); } } return; } else throw argErr(app, c.getName(), null); default: throw argNumErr(app, c.getName(), n); } }
/* * Michael Borcherds 2008-03-03 return -1 if nothing selected return -2 if * objects from more than one layer selected return layer number if objects * from exactly one layer are selected */ private int getSelectedLayer() { Object[] geos = app.getSelectedGeos().toArray(); if (geos.length == 0) return -1; // return -1 if nothing selected int layer = ((GeoElement) geos[0]).getLayer(); for (int i = 1; i < geos.length; i++) { GeoElement geo = (GeoElement) geos[i]; if (geo.getLayer() != layer) return -2; // return -2 if more than one layer selected } return layer; }
/** * Get the layer of a Geo * * @param geo the geo * @return the geo's layer */ public static int getLayer(GeoElement geo) { return geo.getLayer(); }