Android Project

Hello sir … iam trying to make an Android Project where user need to put some valid diagram code… then may app will convert the code into Wel format Graph Image … Is it possible through Android? Iam new …But I need for Android Platform. Help me

Thank you for project :heart:

My Work

protected void onCreate(Bundle _savedInstanceState) {
	super.onCreate(_savedInstanceState);
	setContentView(R.layout.main);
	initialize(_savedInstanceState);
	initializeLogic();
}
private void initialize(Bundle _savedInstanceState) {
	webview1 = findViewById(R.id.webview1);
	webview1.getSettings().setJavaScriptEnabled(true);
	webview1.getSettings().setSupportZoom(true);
	
	webview1.setWebViewClient(new WebViewClient() {
		@Override
		public void onPageStarted(WebView _param1, String _param2, Bitmap _param3) {
			final String _url = _param2;
			
			super.onPageStarted(_param1, _param2, _param3);
		}
		
		@Override
		public void onPageFinished(WebView _param1, String _param2) {
			final String _url = _param2;
			final String dotCode = new String ("digraph G { A -> B; B -> C; C -> A; }");
			_param1.evaluateJavascript("renderDotCode('" + dotCode + "');", null);
			super.onPageFinished(_param1, _param2);
		}
	});
}

private void initializeLogic() {
	webview1.loadUrl("file:///android_asset/graphviz.html");
	webview1.setWebChromeClient(new WebChromeClient() {
		    @Override
		    public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
			        Log.d("WebView Console", consoleMessage.message());
			        return true;
			    }
	});
}

In Graphviz.html file

<html>
<head>
    <script type="text/javascript" src="file:///android_asset/viz.js"></script>
    <script type="text/javascript">
        function renderDotCode(dotCode) {
            var svg = Viz(dotCode, { format: "svg" });
            document.getElementById("graph").innerHTML = svg;
        }
    </script>
</head>
<body>
    <div id="graph"></div>
</body>
</html>```


And library viz.js

To my knowledge, none of the Graphviz software has been ported to Android. There is a javascript version, if that helps.

That’s true sir… but iam using a WebView method to draw using java script and html language

I am not sure graph-support whether satisfied your demand, it is write by pure java without any dependency, but you have to implement text measure interface MeasureText under Android platform, otherwise text measure not accurate.