use of com.scriptographer.adm.layout.HorizontalLayout in project scriptographer by scriptographer.
the class LayoutConverter method convert.
public LayoutManager convert(ArgumentReader reader, Object from) {
if (reader.isArray()) {
String str = reader.readString();
if (str != null) {
// See if it's an available alignment for FlowLayout
if (HorizontalLayout.getAlignment(str) != null) {
// FlowLayout
return new HorizontalLayout(str, reader.readInteger(0), reader.readInteger(0));
} else {
// TableLayout
return new TableLayout(str, reader.readString(""), reader.readInteger(0), reader.readInteger(0));
}
} else {
reader.revert();
// Try if there's an array now:
Object[] array = reader.readObject(Object[].class);
if (array != null) {
// TableLayout
return new TableLayout(array, reader.readObject(Object[].class), reader.readInteger(0), reader.readInteger(0));
} else {
reader.revert();
// BorderLayout
return new BorderLayout(reader.readInteger(0), reader.readInteger(0));
}
}
} else if (reader.isMap()) {
if (reader.has("columns")) {
// TableLayout
String str = reader.readString("columns");
if (str != null) {
return new TableLayout(str, reader.readString("rows", ""), reader.readInteger("", 0), reader.readInteger(0));
} else {
Object[] array = reader.readObject("columns", Object[].class);
if (array != null) {
return new TableLayout(array, reader.readObject("rows", Object[].class), reader.readInteger("hgap", 0), reader.readInteger("vgap", 0));
} else {
throw new RuntimeException("Unsupported format for TableLayout");
}
}
} else if (reader.has("alignment")) {
// FlowLayout
String alignment = reader.readString("alignment");
if (HorizontalLayout.getAlignment(alignment) != null) {
return new HorizontalLayout(alignment, reader.readInteger("hgap", 0), reader.readInteger("vgap", 0));
} else {
throw new RuntimeException("Unsupported alignment for FlowLayout: " + alignment);
}
} else {
return new BorderLayout(reader.readInteger("hgap", 0), reader.readInteger("vgap", 0));
}
}
return null;
}
Aggregations