org.w3c.dom.svg.SVGDocument#createElement ( )源码实例Demo

下面列出了org.w3c.dom.svg.SVGDocument#createElement ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Knowage-Server   文件: InteractiveMapRenderer.java
/**
 * Adds the href elements and click events
 *
 * @param targetMap
 *            the target svg
 * @param featureElement
 *            the svg element to manage
 * @param elementId
 *            the svg element id
 * @param drillId
 *            the drill id
 * @param linkUrl
 *            the link url
 * @param linkType
 *            the link type ('cross' or 'drill')
 *
 */
private void addHRefLinksCross(SVGDocument targetMap, Element featureElement, JSONArray JSONValues, JSONArray JSONCross,
		IDataMartProvider datamatProvider) {
	logger.debug("IN");
	Element linkCrossElement = targetMap.createElement("a");
	linkCrossElement.setAttribute("xlink:href", "javascript:void(0)");

	if (featureElement.hasAttribute("style")) {
		String elementStyle = featureElement.getAttribute("style");
		elementStyle = elementStyle + ";cursor:pointer";
		featureElement.setAttribute("style", elementStyle);
	} else {
		featureElement.setAttribute("style", "cursor:pointer");
	}

	featureElement.setAttribute("onclick", "javascript:clickedElementCrossNavigation('" + JSONValues.toString() + "', '" + JSONCross.toString() + "')");

	logger.debug("OUT");
}
 
源代码2 项目: Knowage-Server   文件: InteractiveMapRenderer.java
private void addHRefLinksDrill(SVGDocument targetMap, Element featureElement, String elementId, String drillId, String linkUrl) {
	logger.debug("IN");
	Element linkCrossElement = targetMap.createElement("a");
	linkCrossElement.setAttribute("xlink:href", linkUrl);

	if (featureElement.hasAttribute("style")) {
		String elementStyle = featureElement.getAttribute("style");
		elementStyle = elementStyle + ";cursor:pointer";
		featureElement.setAttribute("style", elementStyle);
	} else {
		featureElement.setAttribute("style", "cursor:pointer");
	}

	// get document_id
	String documentId = (String) this.getEnv().get("DOCUMENT_ID");

	JSONObject jsonOEnv = new JSONObject();
	String strEnv = "";
	try {
		jsonOEnv = JSONUtils.getJsonFromMap(this.getEnv());
		jsonOEnv.remove("ENV_USER_PROFILE"); // clean profile info for correct url
		jsonOEnv.remove("level");
		jsonOEnv.remove("DOCUMENT_OUTPUT_PARAMETERS");
		strEnv = "&" + JSONUtils.getQueryString(jsonOEnv);
		// strEnv = SpagoBIUtilities.encode(strEnv.substring(0, strEnv.length() - 1)); //2017-29-30 commented because changes the parameter values
	} catch (JSONException je) {
		logger.error("An error occured while convert map [env] to json object: " + je);
	}
	// String strEnv = StringUtils.mapToString(this.getEnv());

	if (drillId == null) {
		// featureElement.setAttribute("onclick", "javascript:clickedElement('" + documentId + "','" + elementId + "')");
		featureElement.setAttribute("onclick", "javascript:clickedElement('" + strEnv + "','" + documentId + "','" + elementId + "')");
	} else {
		// featureElement.setAttribute("onclick", "javascript:clickedElement('" + documentId + "','" + elementId + "','" + drillId + "')");
		featureElement.setAttribute("onclick", "javascript:clickedElement('" + strEnv + "','" + documentId + "','" + elementId + "','" + drillId + "')");
	}

	logger.debug("OUT");
}
 
源代码3 项目: Knowage-Server   文件: InteractiveMapRenderer.java
private void importScipt(SVGDocument map, String scriptName) {
	Element script = map.createElement("script");
	script.setAttribute("type", "text/ecmascript");
	script.setAttribute("xlink:href", (String) getEnv().get(SvgViewerEngineConstants.ENV_CONTEXT_URL) + "/js/lib/svg-widgets/" + scriptName);
	Element importsBlock = map.getElementById("imported_scripts");
	importsBlock.appendChild(script);
	Node lf = map.createTextNode("\n");
	importsBlock.appendChild(lf);
}
 
源代码4 项目: Knowage-Server   文件: InteractiveMapRenderer.java
/**
 * Add label to the centroide
 *
 * @param masterMap
 *            the svg content
 * @param centroide
 *            the centroide svg element
 * @param labelGroup
 *            the svg label group element
 * @param aRecord
 *            the record with values
 * @param labelField
 *            the label field
 */
private void addLabels(SVGDocument masterMap, Element centroide, Element labelGroup, IRecord aRecord, IField labelField) {
	logger.debug("IN");
	labelGroup.setAttribute("transform", "translate(" + centroide.getAttribute("cx") + "," + centroide.getAttribute("cy") + ") scale(1)");
	labelGroup.setAttribute("display", "inherit");

	Element label = masterMap.createElement("text");
	label.setAttribute("x", "0");
	label.setAttribute("y", "0");

	label.setAttribute("font-family", "Arial,Helvetica");
	label.setAttribute("font-size", "12px");
	label.setAttribute("font-style", "normal");
	label.setAttribute("fill", "black");
	// label.setAttribute("text-anchor", "middle");
	// get text-anchor property:
	// 1. throught text-anchor property
	// 2. throught style property
	// 3. if it isn't found force 'middle' as default
	String anchor = "middle";
	String anchorProperty = centroide.getAttribute("text-anchor");
	if (anchorProperty != null && anchorProperty.equals("start") || anchorProperty.equals("middle") || anchorProperty.equals("end")) {
		anchor = anchorProperty;
	} else {
		String styleProperty = centroide.getAttribute("style");
		int anchorPropertyPosStart = styleProperty.indexOf("text-anchor:");
		int anchorPropertyPosEnd = styleProperty.indexOf(";", anchorPropertyPosStart);
		if (null != styleProperty && anchorPropertyPosStart >= 0) {
			anchorProperty = styleProperty.substring(anchorPropertyPosStart + 12, anchorPropertyPosEnd);
			anchor = anchorProperty;
			// clean the style from the anchor information
			styleProperty = styleProperty.replace(styleProperty.substring(anchorPropertyPosStart, anchorPropertyPosEnd + 1), "");
			centroide.setAttribute("style", styleProperty);
		}
	}
	label.setAttribute("text-anchor", anchor);
	Node labelText = masterMap.createTextNode((String) labelField.getValue());
	label.appendChild(labelText);
	labelGroup.appendChild(label);
	if (labelGroup != null) {
		// append labels to default layer "valori"
		Element valuesLayer = masterMap.getElementById("_labels_layer");
		valuesLayer.appendChild(labelGroup);
	}

}