use of com.scriptographer.adm.ImagePane in project scriptographer by scriptographer.
the class AdmPaletteProxy method createLayout.
protected static TableLayout createLayout(Dialog dialog, Component[] components, boolean hasLogo, int extraRows, int gap) {
// First collect all content in a LinkedHashMap, then create the layout
// at the end, and add the items to it. This allows flexibility
// regarding amount of rows, as needed by the ruler element that uses
// two rows when it has a title.
LinkedHashMap<String, com.scriptographer.adm.Component> content = new LinkedHashMap<String, com.scriptographer.adm.Component>();
int column = hasLogo ? 1 : 0, row = 0;
for (int i = 0; i < components.length; i++) {
Component item = components[i];
if (item != null) {
AdmComponentProxy proxy = new AdmComponentProxy(item);
row = proxy.addToContent(dialog, content, column, row);
}
}
if (hasLogo) {
ImagePane logo = new ImagePane(dialog);
logo.setImage(AdmUiFactory.getImage("logo.png"));
logo.setMargin(-4, 4, -4, -4);
// Logo uses all rows of components + filler row
content.put("0, 0, 0, " + row + ", left, top", logo);
row++;
}
double[] rows = new double[row + extraRows];
for (int i = 0; i < rows.length; i++) rows[i] = TableLayout.PREFERRED;
// Define the filler row, 2nd last
if (hasLogo)
rows[rows.length - extraRows - 1] = TableLayout.FILL;
else if (rows.length > 0)
rows[rows.length - 1] = TableLayout.FILL;
double[][] sizes = { hasLogo ? new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL } : new double[] { TableLayout.PREFERRED, TableLayout.FILL }, rows };
TableLayout layout = new TableLayout(sizes, 0, gap);
dialog.setLayout(layout);
dialog.setContent(content);
return layout;
}
Aggregations