public BoneJointConfig(Item configItem) { myURI_Fragment = configItem.getIdent().getLocalName(); myJointNum = ItemFuncs.getInteger(configItem, BoneAN.P_jointNum, null); myJointName = ItemFuncs.getString(configItem, BoneAN.P_jointName, null); myNormalDefaultPos = ItemFuncs.getDouble(configItem, BoneAN.P_defaultPosNorm, null); Set<Item> bprItems = ItemFuncs.getLinkedItemSet(configItem, BoneAN.P_projectionRange); for (Item bpri : bprItems) { BoneProjectionRange bpr = BoneProjectionRange.makeOne(this, bpri); myProjectionRanges.add(bpr); } }
public static Integer getInteger(Item parent,String fieldName, Integer defaultVal) { Long defLong = (defaultVal != null) ? new Long(defaultVal) : null; Long lv = getLong(parent, fieldName, defLong); return (lv != null) ? lv.intValue() : null; } public static Double getDouble(Item parent, String fieldName, Double defaultVal) {
public static int getLinkedItemCount(Item parent, String linkName, Item.LinkDirection linkDir) { Ident pid = getNeighborIdent(parent, linkName); return parent.getLinkedItemCount(pid, Item.LinkDirection.FORWARD); } public static Item getSingleLinkedItem(Item parent, String linkName, Item.LinkDirection linkDir) {
public static BoneProjectionRange makeOne(BoneJointConfig bjc, Item configItem) { String boneName = ItemFuncs.getString(configItem, BoneAN.P_boneName, null); String rotAxisName = ItemFuncs.getString(configItem, BoneAN.P_rotationAxis, null); Double minAngDeg = ItemFuncs.getDouble(configItem, BoneAN.P_minAngleDeg, null); Double maxAngDeg = ItemFuncs.getDouble(configItem, BoneAN.P_maxAngleDeg, null); double minAngRad = Math.toRadians(minAngDeg); double maxAngRad = Math.toRadians(maxAngDeg); BoneRotationAxis rax = BoneRotationAxis.valueOf(rotAxisName); BoneProjectionRange bpr = new BoneProjectionRange(bjc, boneName, rax, minAngRad, maxAngRad); return bpr; } public String getBoneName() {
@Override protected void initExtendedFieldsAndLinks(BoneRobotConfig mrc, Item configItem, Assembler assmblr, Mode mode) { getLogger().debug("BoneRobotConfig.initExtendedFieldsAndLinks()-BEGIN"); mrc.myRobotName = ItemFuncs.getString(configItem, BoneAN.P_robotName, null); Set<Item> jointItems = ItemFuncs.getLinkedItemSet(configItem, BoneAN.P_joint); for (Item ji : jointItems) { BoneJointConfig bjc = new BoneJointConfig(ji); mrc.myBJCs.add(bjc); } Collections.sort(mrc.myBJCs, new Comparator() { public int compare(Object o1, Object o2) { int jointNum1 = ((BoneJointConfig) o1).myJointNum; int jointNum2 = ((BoneJointConfig) o2).myJointNum; return jointNum1 - jointNum2; } }); }
@Override protected void initExtendedFieldsAndLinks(ChatConfig mcc, Item configItem, Assembler assmblr, Mode mode) { getLogger().debug("ChatConfig.initExtendedFieldsAndLinks()-BEGIN"); Set<Item> resourceItems = ItemFuncs.getLinkedItemSet(configItem, ChatAN.P_config); for (Item ji : resourceItems) { ChatConfigResource ccr = new ChatConfigResource(ji); getLogger().debug("Adding ChatConfigResource in ChatConfig: {} ", ccr); mcc.myCCRs.add(ccr); } }
public ChatConfigResource(Item configItem) { //myURI_Fragment = configItem.getIdent().getLocalName(); List<Item> entryItems = reader.readLinkedItemSeq(configItem, ChatAN.P_entry); theLogger.info("Number of entries found: {}", entryItems.size()); for (Item ei : entryItems) { String name = ItemFuncs.getString(ei, ChatAN.P_name, null); String url = ItemFuncs.getString(ei, ChatAN.P_url, ""); if (name != null) { entries.put(name, url); } else { theLogger.warn("Found an entry with no listed name key in chat config resource"); } } } }
public LightConfig(Item configItem) { lightName = configItem.getIdent().getLocalName(); lightType = LightType.AMBIENT; // For now, we assume light is ambient (no direction required) if type is not specified String typeString = ItemFuncs.getString(configItem, LightsCameraAN.P_lightType, null); if (typeString.equals("DIRECTIONAL")) { lightType = LightType.DIRECTIONAL; } for (int index = 0; index < lightDirection.length; index++) { lightDirection[index] = ItemFuncs.getDouble(configItem, LightsCameraAN.P_direction[index], 0.0).floatValue(); } for (int index = 0; index < lightColor.length; index++) { lightColor[index] = ItemFuncs.getDouble(configItem, LightsCameraAN.P_color[index], null).floatValue(); } }
@Override protected void initExtendedFieldsAndLinks(ScreenBoxImpl box, Item configItem, Assembler asmblr, Mode mode) { theLogger.info("bonus box init here"); List<Object> linkedTriggers = getReader().findOrMakeLinkedObjects(configItem, BoxAssemblyNames.P_trigger, asmblr, mode, null); for (Object lt : linkedTriggers) { Trigger t = (Trigger) lt; box.attachTrigger(t); } Set<Item> extraItems = ItemFuncs.getLinkedItemSet(configItem, ComponentAssemblyNames.P_extraThing); System.out.println("Found extraItems: " + extraItems); }
public static Ident getNeighborIdent(Item neighborItem, String fieldName) { Ident neighborItemIdent = neighborItem.getIdent(); return getNeighborIdent(neighborItemIdent, fieldName); } public static String getString(Item parent, String fieldName, String defaultVal) {
public static String getString(Item parent, String fieldName, String defaultVal) { Ident pid = getNeighborIdent(parent, fieldName); return parent.getValString(pid, defaultVal); } public static Long getLong(Item parent,String fieldName, Long defaultVal) {
public static Long getLong(Item parent,String fieldName, Long defaultVal) { Ident pid = getNeighborIdent(parent, fieldName); return parent.getValLong(pid, defaultVal); } public static Integer getInteger(Item parent,String fieldName, Integer defaultVal) {
public static Set<Item> getLinkedItemSet(Item parent, String linkName) { Ident pid = getNeighborIdent(parent, linkName); return parent.getLinkedItemSet(pid, Item.LinkDirection.FORWARD); } public static int getLinkedItemCount(Item parent, String linkName, Item.LinkDirection linkDir) {
public static Item getSingleLinkedItem(Item parent, String linkName, Item.LinkDirection linkDir) { Ident pid = getNeighborIdent(parent, linkName); return parent.getSingleLinkedItem(pid, Item.LinkDirection.FORWARD); } }
public static Double getDouble(Item parent, String fieldName, Double defaultVal) { Ident pid = getNeighborIdent(parent, fieldName); return parent.getValDouble(pid, defaultVal); }