Search in sources :

Example 6 with AbstractLayout

use of com.intellij.uiDesigner.core.AbstractLayout in project intellij-community by JetBrains.

the class GridBagConverter method getGap.

private static int getGap(LwContainer container, final boolean horizontal) {
    while (container != null) {
        final LayoutManager layout = container.getLayout();
        if (layout instanceof AbstractLayout) {
            AbstractLayout aLayout = (AbstractLayout) layout;
            final int gap = horizontal ? aLayout.getHGap() : aLayout.getVGap();
            if (gap >= 0) {
                return gap;
            }
        }
        container = container.getParent();
    }
    return horizontal ? AbstractLayout.DEFAULT_HGAP : AbstractLayout.DEFAULT_VGAP;
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) AbstractLayout(com.intellij.uiDesigner.core.AbstractLayout)

Example 7 with AbstractLayout

use of com.intellij.uiDesigner.core.AbstractLayout in project intellij-community by JetBrains.

the class VGapProperty method setValueImpl.

protected void setValueImpl(final RadContainer component, final Integer value) throws Exception {
    if (component.getLayout() instanceof BorderLayout) {
        BorderLayout layout = (BorderLayout) component.getLayout();
        layout.setVgap(value.intValue());
    } else if (component.getLayout() instanceof FlowLayout) {
        FlowLayout layout = (FlowLayout) component.getLayout();
        layout.setVgap(value.intValue());
    } else if (component.getLayout() instanceof CardLayout) {
        CardLayout layout = (CardLayout) component.getLayout();
        layout.setVgap(value.intValue());
    } else {
        final AbstractLayout layoutManager = (AbstractLayout) component.getLayout();
        layoutManager.setVGap(value.intValue());
    }
}
Also used : CardLayout(java.awt.CardLayout) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) AbstractLayout(com.intellij.uiDesigner.core.AbstractLayout)

Example 8 with AbstractLayout

use of com.intellij.uiDesigner.core.AbstractLayout in project android by JetBrains.

the class FormScalingUtil method scaleComponent.

private void scaleComponent(Component c) {
    if (c instanceof Container) {
        Container container = (Container) c;
        scaleLayoutManager(container.getLayout());
    }
    if (c instanceof JTable) {
        JTable table = (JTable) c;
        Dimension size = table.getPreferredScrollableViewportSize();
        if (size != null) {
            table.setPreferredScrollableViewportSize(scale(size, "preferredScrollableViewportSize"));
        }
    }
    if (c instanceof JSlider) {
        JSlider slider = (JSlider) c;
        // force the default size to be computed. It will then be scaled in this method below.
        if (!slider.isPreferredSizeSet()) {
            slider.setPreferredSize(slider.getPreferredSize());
        }
    }
    if (c instanceof JBLabel) {
        JBLabel label = (JBLabel) c;
        label.setIconTextGap(scale(label.getIconTextGap(), "IconTextGap"));
    }
    if (c instanceof JComponent) {
        JComponent component = (JComponent) c;
        Border scaledBorder = getScaledBorder(component, component.getBorder());
        if (scaledBorder != null) {
            component.setBorder(scaledBorder);
        }
    }
    if (c.isFontSet()) {
        // Special case: If we have a font smaller than the threshold for the given
        // scale factor, scale the font size.
        // This heuristics only handle a subset of font sizing, where the intent was
        // do set the font size to "small" in the .form file.
        float fontSize = c.getFont().getSize2D();
        // We assume a size < 9 would be too small at any dpi setting.
        float minFontSize = 9f * myScaleFactor;
        if (fontSize <= minFontSize) {
            c.setFont(c.getFont().deriveFont(scale(fontSize, "FontSize")));
        }
    }
    scaleMinimumSize(c);
    scaleMaximumSize(c);
    scalePreferredSize(c);
    if (c.getParent() != null && c.getParent().getLayout() != null && c.getParent().getLayout() instanceof AbstractLayout) {
        AbstractLayout abstractLayout = (AbstractLayout) c.getParent().getLayout();
        GridConstraints constraint = abstractLayout.getConstraintsForComponent(c);
        constraint.myPreferredSize.width = scale(constraint.myPreferredSize.width, "constraint.myPreferredSize.width");
        constraint.myPreferredSize.height = scale(constraint.myPreferredSize.height, "constraint.myPreferredSize.height");
        constraint.myMinimumSize.width = scale(constraint.myMinimumSize.width, "constraint.myMinimumSize.width");
        constraint.myMinimumSize.height = scale(constraint.myMinimumSize.height, "constraint.myMinimumSize.height");
        constraint.myMaximumSize.width = scale(constraint.myMaximumSize.width, "constraint.myMaximumSize.width");
        constraint.myMaximumSize.height = scale(constraint.myMaximumSize.height, "constraint.myMaximumSize.height");
    }
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) AbstractLayout(com.intellij.uiDesigner.core.AbstractLayout) EmptyBorder(javax.swing.border.EmptyBorder) TitledBorder(javax.swing.border.TitledBorder) Border(javax.swing.border.Border)

Example 9 with AbstractLayout

use of com.intellij.uiDesigner.core.AbstractLayout in project android by JetBrains.

the class FormScalingUtil method scaleLayoutManager.

private void scaleLayoutManager(LayoutManager layout) {
    if (layout instanceof AbstractLayout) {
        AbstractLayout abstractLayout = (AbstractLayout) layout;
        abstractLayout.setVGap(scale(abstractLayout.getVGap(), "VGap"));
        abstractLayout.setHGap(scale(abstractLayout.getHGap(), "VGap"));
        abstractLayout.setMargin(scale(abstractLayout.getMargin(), "Margin"));
    }
}
Also used : AbstractLayout(com.intellij.uiDesigner.core.AbstractLayout)

Aggregations

AbstractLayout (com.intellij.uiDesigner.core.AbstractLayout)9 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)2 JBLabel (com.intellij.ui.components.JBLabel)1 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)1 BorderLayout (java.awt.BorderLayout)1 CardLayout (java.awt.CardLayout)1 FlowLayout (java.awt.FlowLayout)1 Insets (java.awt.Insets)1 Border (javax.swing.border.Border)1 EmptyBorder (javax.swing.border.EmptyBorder)1 TitledBorder (javax.swing.border.TitledBorder)1