Search in sources :

Example 1 with ImagePane

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;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) ImagePane(com.scriptographer.adm.ImagePane) Component(com.scriptographer.ui.Component) TableLayout(com.scriptographer.adm.layout.TableLayout)

Aggregations

ImagePane (com.scriptographer.adm.ImagePane)1 TableLayout (com.scriptographer.adm.layout.TableLayout)1 Component (com.scriptographer.ui.Component)1 LinkedHashMap (java.util.LinkedHashMap)1