Last active
July 22, 2020 13:22
-
-
Save shannah/918950f937781616744c9db5fda80b23 to your computer and use it in GitHub Desktop.
Sample output from ComponentImageGenerator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title> | |
Codename One Components</title> | |
</head> | |
<body> | |
<div class="cn-test" data-test-id="Label"> | |
<h2> | |
Label</h2> | |
<div class="cn1-test-preview" data-theme="native" data-skin="GooglePixel.skin"> | |
<img src="GooglePixel.skin/native/Label.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="iPhoneX.skin"> | |
<img src="iPhoneX.skin/native/Label.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="SamsungS7.skin"> | |
<img src="SamsungS7.skin/native/Label.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
</div> | |
<div class="cn-test" data-test-id="Button"> | |
<h2> | |
Button</h2> | |
<div class="cn1-test-preview" data-theme="native" data-skin="GooglePixel.skin"> | |
<img src="GooglePixel.skin/native/Button.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="iPhoneX.skin"> | |
<img src="iPhoneX.skin/native/Button.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="SamsungS7.skin"> | |
<img src="SamsungS7.skin/native/Button.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
</div> | |
<div class="cn-test" data-test-id="CheckBox"> | |
<h2> | |
CheckBox</h2> | |
<div class="cn1-test-preview" data-theme="native" data-skin="GooglePixel.skin"> | |
<img src="GooglePixel.skin/native/CheckBox.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="iPhoneX.skin"> | |
<img src="iPhoneX.skin/native/CheckBox.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="SamsungS7.skin"> | |
<img src="SamsungS7.skin/native/CheckBox.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
</div> | |
<div class="cn-test" data-test-id="RadioButton"> | |
<h2> | |
RadioButton</h2> | |
<div class="cn1-test-preview" data-theme="native" data-skin="GooglePixel.skin"> | |
<img src="GooglePixel.skin/native/RadioButton.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="iPhoneX.skin"> | |
<img src="iPhoneX.skin/native/RadioButton.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="SamsungS7.skin"> | |
<img src="SamsungS7.skin/native/RadioButton.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
</div> | |
<div class="cn-test" data-test-id="ToggleButton"> | |
<h2> | |
ToggleButton</h2> | |
<div class="cn1-test-preview" data-theme="native" data-skin="GooglePixel.skin"> | |
<img src="GooglePixel.skin/native/ToggleButton.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="iPhoneX.skin"> | |
<img src="iPhoneX.skin/native/ToggleButton.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
<div class="cn1-test-preview" data-theme="native" data-skin="SamsungS7.skin"> | |
<img src="SamsungS7.skin/native/ToggleButton.png" style="width:400px; height:200px; border:1px solid gray"> | |
</img> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Excerpt from https://github.com/shannah/ComponentImageGenerator/blob/master/src/com/codename1/compgen/MainTestRunner.java | |
// Project https://github.com/shannah/ComponentImageGenerator | |
public String generateHtml() { | |
HTMLBuilder sb = new HTMLBuilder(); | |
sb.appendRaw("<!doctype html>").newLine() | |
.open("html") | |
.open("head") | |
.open("title").append("Codename One Components").close() | |
.close() | |
.open("body"); | |
for (Test test : getTests()) { | |
sb.open("div") | |
.attr("class", "cn-test") | |
.attr("data-test-id", test.getId()) | |
.open("h2").append(test.getId()).close(); | |
for (File skinDir : baseDir.listFiles()) { | |
if (!skinDir.isDirectory()) { | |
continue; | |
} | |
String skinName = skinDir.getName(); | |
for (File themeDir : skinDir.listFiles()) { | |
if (!themeDir.isDirectory()) { | |
continue; | |
} | |
String themeName = themeDir.getName(); | |
File imgFile = new File(themeDir, getOutputFileName(test.getId())); | |
if (imgFile.exists()) { | |
sb.open("div").attr("class", "cn1-test-preview") | |
.attr("data-theme", themeName) | |
.attr("data-skin", skinName) | |
.open("img").attr("src", skinName+"/"+themeName+"/"+getOutputFileName(test.getId())) | |
.attr("style", "width:"+(imageWidth/2)+"px; height:"+(imageHeight/2)+"px; border:1px solid gray") | |
.close() | |
.close(); | |
} | |
} | |
} | |
sb.close(); //cn-test | |
} | |
sb.close(); //body | |
sb.close(); //html | |
return sb.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment