List of usage examples for com.jgoodies.forms.layout FormSpec getSize
public final Size getSize()
From source file:com.intellij.uiDesigner.radComponents.FormLayoutColumnProperties.java
License:Apache License
public void showProperties(final RadContainer container, final boolean row, final int[] selectedIndices) { if (mySaving) return;//w ww .ja v a 2 s .c o m if (selectedIndices.length == 1) { showControls(true); myShowing = true; try { myLayout = (FormLayout) container.getLayout(); myIndex = selectedIndices[0] + 1; myIsRow = row; myTitleLabel.setText(myIsRow ? UIDesignerBundle.message("title.row.properties", myIndex) : UIDesignerBundle.message("title.column.properties", myIndex)); myLeftRadioButton.setText(row ? UIDesignerBundle.message("alignment.top") : UIDesignerBundle.message("alignment.left")); myRightRadioButton.setText(row ? UIDesignerBundle.message("alignment.bottom") : UIDesignerBundle.message("alignment.right")); mySizePanel.setBorder( IdeBorderFactory.createTitledBorder(myIsRow ? UIDesignerBundle.message("title.height") : UIDesignerBundle.message("title.width"), true)); FormSpec formSpec = row ? myLayout.getRowSpec(myIndex) : myLayout.getColumnSpec(myIndex); showAlignment(formSpec.getDefaultAlignment()); showSize(formSpec.getSize()); if (formSpec.getResizeWeight() < 0.01) { myGrowCheckBox.setSelected(false); myGrowSpinner.setValue(1.0); } else { myGrowCheckBox.setSelected(true); myGrowSpinner.setValue(formSpec.getResizeWeight()); } } finally { myShowing = false; } } else { showControls(false); if (selectedIndices.length > 1) { myTitleLabel.setText(myIsRow ? UIDesignerBundle.message("title.multiple.rows.selected") : UIDesignerBundle.message("title.multiple.columns.selected")); } else { myTitleLabel.setText(myIsRow ? UIDesignerBundle.message("title.no.rows.selected") : UIDesignerBundle.message("title.no.columns.selected")); } } }
From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java
License:Apache License
private static ConstantSize scaleSize(final FormSpec rowSpec, final RadContainer container, final int newPx) { if (rowSpec.getSize() instanceof ConstantSize) { ConstantSize oldSize = (ConstantSize) rowSpec.getSize(); int oldPx = oldSize.getPixelSize(container.getDelegee()); double newValue = Math.round(oldSize.getValue() * newPx / oldPx * 10) / 10; return new ConstantSize(newValue, oldSize.getUnit()); }/*from w w w .j a v a2 s . c o m*/ return new ConstantSize(newPx, ConstantSize.PIXEL); }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.FormDimensionInfo.java
License:Open Source License
/** * Converts this {@link FormDimensionInfo} (with constant size in pixels) into nearest gap * template with size difference not more than given delta. *///from w ww . j a va 2 s . c o m public void convertToNearestGap(int maxDelta) throws Exception { // prepare size of this dimension in pixels int thisPixels; { Assert.isNotNull(m_size.getConstantSize()); Assert.isTrue(m_size.getConstantSize().getUnit() == ConstantSize.PIXEL); thisPixels = (int) m_size.getConstantSize().getValue(); } // int minDelta = Integer.MAX_VALUE; Field minField = null; // Field[] fields = FormDimensionUtils.getTemplateFields(); for (int i = 0; i < fields.length; i++) { Field field = fields[i]; // check for type if (m_horizontal && !ColumnSpec.class.isAssignableFrom(field.getType())) { continue; } if (!m_horizontal && !RowSpec.class.isAssignableFrom(field.getType())) { continue; } // check for constant size int sizeInPixels; { FormSpec formSpec = (FormSpec) field.get(null); if (!(formSpec.getSize() instanceof ConstantSize)) { continue; } if (formSpec.getResizeWeight() != FormSpec.NO_GROW) { continue; } ConstantSize constantSize = (ConstantSize) formSpec.getSize(); sizeInPixels = constantSize.getPixelSize(FormSizeConstantInfo.m_toolkitComponent); } // check that size in range int delta = Math.abs(sizeInPixels - thisPixels); if (delta <= maxDelta && delta < minDelta) { minDelta = delta; minField = field; } } // set found gap if (minField != null) { setFormSpec((FormSpec) minField.get(null)); } }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.FormDimensionInfo.java
License:Open Source License
/** * Updates {@link FormDimensionInfo} model using {@link FormSpec}. *//* ww w . j a va2 s . com*/ private void setFormSpec(FormSpec spec) throws Exception { m_size = new FormSizeInfo(spec.getSize(), m_horizontal); m_alignment = spec.getDefaultAlignment(); m_weight = spec.getResizeWeight(); }
From source file:org.eclipse.wb.internal.swing.FormLayout.model.FormDimensionUtils.java
License:Open Source License
/** * @return <code>true</code> if two {@link FormSpec} objects are equal. *///w w w. j a va 2s .co m public static boolean equals(FormSpec a, FormSpec b) { if (a.getClass() == b.getClass()) { return a.getDefaultAlignment() == b.getDefaultAlignment() && a.getResizeWeight() == b.getResizeWeight() && a.getSize().equals(b.getSize()); } return false; }