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;
}
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());
}
}
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");
}
}
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"));
}
}
Aggregations