/** Updates the state of the stylebar buttons and the defaultGeo field. */ public void updateStyleBar() { // ----------------------------------------------------- // Create activeGeoList, a list of geos the stylebar can adjust. // These are either the selected geos or the current default geo. // Each button uses this list to update its gui and set visibility // ----------------------------------------------------- activeGeoList = new ArrayList<GeoElement>(); // ----------------------------------------------------- // MODE_MOVE case: load activeGeoList with all selected geos // ----------------------------------------------------- if (mode == EuclidianConstants.MODE_MOVE) { boolean hasGeosInThisView = false; for (GeoElement geo : ((AppD) ev.getApplication()).getSelectedGeos()) { if (isVisibleInThisView(geo) && geo.isEuclidianVisible() && !geo.isAxis()) { hasGeosInThisView = true; break; } } for (GeoElement geo : ec.getJustCreatedGeos()) { if (isVisibleInThisView(geo) && geo.isEuclidianVisible()) { hasGeosInThisView = true; break; } } if (hasGeosInThisView) { activeGeoList = ((AppD) ev.getApplication()).getSelectedGeos(); // we also update stylebars according to just created geos activeGeoList.addAll(ec.getJustCreatedGeos()); } } // ----------------------------------------------------- // display a selection for the drag-delete-tool // can't use a geo element for this // ----------------------------------------------------- else if (mode == EuclidianConstants.MODE_DELETE) { } // ----------------------------------------------------- // All other modes: load activeGeoList with current default geo // ----------------------------------------------------- else if (defaultGeoMap.containsKey(mode)) { // Save the current default geo state in oldDefaultGeo. // Stylebar buttons can temporarily change a default geo, but this // default geo is always restored to its previous state after a mode // change. if (oldDefaultGeo != null && modeChanged) { // add oldDefaultGeo to the default map so that the old default // is restored cons.getConstructionDefaults().addDefaultGeo(oldDefaultMode, oldDefaultGeo); oldDefaultGeo = null; oldDefaultMode = null; } // get the current default geo GeoElement geo = cons.getConstructionDefaults().getDefaultGeo(defaultGeoMap.get(mode)); if (geo != null) activeGeoList.add(geo); // update the defaultGeos field (needed elsewhere for adjusting // default geo state) defaultGeos = activeGeoList; // update oldDefaultGeo if (modeChanged) { if (defaultGeos.size() == 0) { oldDefaultGeo = null; oldDefaultMode = -1; } else { oldDefaultGeo = defaultGeos.get(0); oldDefaultMode = defaultGeoMap.get(mode); } } // we also update stylebars according to just created geos activeGeoList.addAll(ec.getJustCreatedGeos()); } updateButtons(); addButtons(); }
/** @return true if the Geo is visible */ public static boolean isEuclidianVisible(GeoElement geo) { return geo.isEuclidianVisible(); }