Example usage for com.jgoodies.forms.layout FormLayout getLayoutInfo

List of usage examples for com.jgoodies.forms.layout FormLayout getLayoutInfo

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout FormLayout getLayoutInfo.

Prototype

public LayoutInfo getLayoutInfo(Container parent) 

Source Link

Document

Computes and returns the horizontal and vertical grid origins.

Usage

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java

License:Apache License

@NotNull
@Override//w ww  .ja  v a2  s . c o  m
public ComponentDropLocation getDropLocation(@NotNull RadContainer container, @Nullable final Point location) {
    FormLayout formLayout = getFormLayout(container);
    if (formLayout.getRowCount() == 0 || formLayout.getColumnCount() == 0) {
        if (location != null) {
            Rectangle rc = new Rectangle(new Point(), container.getDelegee().getSize());
            return new FormFirstComponentInsertLocation(container, location, rc);
        }
    }
    final FormLayout.LayoutInfo layoutInfo = formLayout.getLayoutInfo(container.getDelegee());
    if (location != null && location.x > layoutInfo.getWidth()) {
        int row = findCell(layoutInfo.rowOrigins, location.y);
        if (row == -1) {
            return NoDropLocation.INSTANCE;
        }
        return new GridInsertLocation(container, row, getGridColumnCount(container) - 1,
                GridInsertMode.ColumnAfter);
    }
    if (location != null && location.y > layoutInfo.getHeight()) {
        int column = findCell(layoutInfo.columnOrigins, location.x);
        if (column == -1) {
            return NoDropLocation.INSTANCE;
        }
        return new GridInsertLocation(container, getGridRowCount(container) - 1, column,
                GridInsertMode.RowAfter);
    }

    if (container.getGridRowCount() == 1 && container.getGridColumnCount() == 1
            && getComponentAtGrid(container, 0, 0) == null) {
        final Rectangle rc = getGridCellRangeRect(container, 0, 0, 0, 0);
        if (location == null) {
            return new FormFirstComponentInsertLocation(container, rc, 0, 0);
        }
        return new FormFirstComponentInsertLocation(container, location, rc);
    }

    return super.getDropLocation(container, location);
}