Skip to content

Instantly share code, notes, and snippets.

@codenameone
codenameone / MergeCode.js
Created July 16, 2018 19:05
Small Script used to merge code in PDF from asciidoc in Sketch
log('Merge text layers starting');
const sketch = require('sketch');
var Rectangle = require('sketch/dom').Rectangle;
var Text = require('sketch/dom').Text;
const document = sketch.fromNative(context.document);
var fullText = "";
var x = 10000000;
var y = -1000;
val.addConstraint(phone, new Constraint() {
public boolean isValid(Object value) {
String v = (String)value;
for(int i = 0 ; i < v.length() ; i++) {
char c = v.charAt(i);
if(c >= '0' && c <= '9' || c == '+' || c == '-') {
continue;
}
return false;
}
<xsl:template name="front.cover">
<xsl:call-template name="page.sequence">
<xsl:with-param name="master-reference">titlepage-cover-image</xsl:with-param>
<xsl:with-param name="content">
<fo:block text-align="center">
<fo:external-graphic src="developer-guide-cover-image.jpg" content-height="297mm" content-width="210mm"/>
</fo:block>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
public class DevGuideIndexGenerator {
/**
* Argument 0 should be the output asciidoc file
* Argument 1 should be the index file in the website
* Argument 2 onwards should be the files in the manual in the correct order
*/
public static void main(String[] args) throws Exception {
String version = args[0];
FileOutputStream asciidocFile = new FileOutputStream(args[1]);
FileWriter indexFile = new FileWriter(args[2]);
// HTML_ONLY_START
You can learn more about multi-images in the https://www.codenameone.com/manual/advanced-theming.html#_understanding_images_multi_images[advanced theming] section.
// HTML_ONLY_END
////
//PDF_ONLY
You can learn more about multi-images in the <<understanding-images-and-multi-images>> section.
////
echo "title=About The Codename One Developer Guide - Build Cross Platform Apps Using Java
type=manual
tags=docs
status=published
previousPage=gui-builder
nextPage=introduction
~~~~~~
:icons: font
" | cat - ~/dev/CodenameOne.wiki/About-This-Guide.asciidoc | sed "s/image::/image::\//g" | sed "s/image:img/image:\/img/g" > ~/dev/CodenameOne/newWebsite/templates/content/manual/about.adoc
TextModeLayout tl = new TextModeLayout(3, 2);
Form f = new Form("Pixel Perfect", tl);
TextComponent title = new TextComponent().label("Title");
TextComponent price = new TextComponent().label("Price");
TextComponent location = new TextComponent().label("Location");
PickerComponent date = PickerComponent.createDate(new Date()).label("Date");
TextComponent description = new TextComponent().label("Description").multiline(true);
Validator val = new Validator();
@codenameone
codenameone / RoundRect.java
Created July 23, 2017 09:23
Sample code for the new round rect class based on the RoundBorder sample
Form hi = new Form("RoundRect", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER));
Button ok = new Button("OK");
Button cancel = new Button("Cancel");
Label loginLabel = new Label("Login", "Container");
loginLabel.getAllStyles().setAlignment(Component.CENTER);
Label passwordLabel = new Label("Password", "Container");
passwordLabel.getAllStyles().setAlignment(Component.CENTER);
public final DoubleProperty<Length> metre = new DoubleProperty<>("metre");
public final DoubleProperty<Length> km = new DoubleProperty<>("km") {
public Double get() {
return meter.get() / 0.001;
}
public Length set(Double d) {
return meter.set(d * 1000);
}
};
open class MyApplication {
private var current: Form? = null
private var theme: Resources? = null
fun init(context: Any?) {
theme = UIManager.initFirstTheme("/theme")
Toolbar.setGlobalToolbar(true)
Log.bindCrashProtection(true)
}
fun start() {