Skip to content
Snippets Groups Projects
AvatarPanelDrawer.java 40.6 KiB
Newer Older
			if (attr.getType() == AvatarType.INTEGER) {
				type = 0;
			}
			if (attr.hasInitialValue()) {
				bl.addAttribute(new TAttribute(0, attr.getName(), attr.getInitialValue(), type));
			} else {
				bl.addAttribute(new TAttribute(0, attr.getName(), attr.getType().getDefaultInitialValue(), type));
			}
			if (attr.getName().contains("key_") || attr.getName().contains("privKey_")) {
				hasCrypto = true;
				bl.addCryptoElements();
			}
		}

		for (avatartranslator.AvatarMethod method : ab.getMethods()) {
			String methodId = "";
			if (useOriginalValues) {
				methodId = method.toOriginalString().replaceAll(" = 0", "");
			} else {
				methodId = method.toString().replaceAll(" = 0", "");
			}
			String result = methodId.replaceAll(" = false", "");
			TraceManager.addDev("Adding method:" + result);

			//TraceManager.addDev("Extra types are:" + as.getExtraTypes().toString());
			bl.addMethodIfApplicable(result, as.getExtraTypes());
		}
	}

	public String getLastKeyword(String s) {
		return s.split("__")[s.split("__").length - 1];
	}

	public void makeSafetyPragmas(AvatarSpecification avspec, AvatarDesignPanel adp) {
		AvatarBDPanel abd = adp.abdp;
		int dec = 250;
		int xPos = 100, yPos = 500;
		TGComponent tgcO;

		HashMap<Object, AvatarBDSafetyPragma> setOfNewSafetyPragmaComponent = new HashMap<>();

		for(String pragmaS: avspec.getSafetyPragmas()) {
			Object o = avspec.getReferenceObjectOfSafetyPragma(pragmaS);


			AvatarBDSafetyPragma comp = null;
			if (o != null) {
				//TraceManager.addDev(" - - - - Pragma " + pragmaS + " has reference object " + o.toString());
				// already created?
				comp = setOfNewSafetyPragmaComponent.get(o);
				if ((o instanceof TGComponent) && (comp == null))
					tgcO = (TGComponent)o;
				else tgcO = null;
			} else {
				tgcO = null;
			}
			if (comp == null) {
				// We must create it
				if (tgcO != null) {
					xPos = tgcO.getX();
					yPos = tgcO.getY();
				}
				comp = new AvatarBDSafetyPragma(xPos, yPos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, null, abd);
				xPos = xPos + dec;
				yPos = yPos + dec;
				abd.addComponent(comp, xPos, yPos, false, true);
				if (tgcO != null) {
					comp.resize(tgcO.getWidth(), tgcO.getHeight());
				}
				setOfNewSafetyPragmaComponent.put(o, comp);
			}

			String value = comp.getValue();
			value = value + "\n" + pragmaS;
			comp.setValue(value);
			comp.makeValue();
		}
	}