Example usage for com.jgoodies.forms.factories CC xyw

List of usage examples for com.jgoodies.forms.factories CC xyw

Introduction

In this page you can find the example usage for com.jgoodies.forms.factories CC xyw.

Prototype

public static CellConstraints xyw(int col, int row, int colSpan, String encodedAlignments) 

Source Link

Document

Sets the column, row, width, and height; decodes the horizontal and vertical alignments from the given string.

Usage

From source file:edu.udo.scaffoldhunter.view.scaffoldtree.config.SinglePropertyPanel.java

License:Open Source License

/**
 * Create a new SinglePropertyPanel with the specified mapping as a model.
 * The profile is used to obtain database values where necessary.
 * <p>//from w w w. ja  va2  s.  c  om
 * In general the profile should be the profile of the currently active
 * user.
 * 
 * @param mapping
 *            this panel's model
 * @param profile
 *            the profile which <i>owns</code> the mapping
 * @param db
 */
public SinglePropertyPanel(ConfigMapping mapping, Profile profile, DbManager db, Subset subset) {
    super(new FormLayout("max(100dlu;p), 3dlu, p, p:g",
            "p, 3dlu, p, 3dlu, p, 3dlu, p, 5dlu, p, 3dlu, p, 5dlu, f:p:g"));
    if (!SUPPORTED.contains(mapping.getVisualFeature()))
        throw new IllegalArgumentException(mapping.getVisualFeature().name() + " not supported");

    this.mapping = mapping;
    this.profile = profile;
    this.type = determineType(mapping.getVisualFeature());
    this.db = db;
    this.subset = subset;

    // build and add comboBoxes for property selection
    this.propertySelection = buildPropertySelection();
    this.functionSelection = buildFunctionSelection();
    this.cumulative = buildCumulativeCB();

    add(new JLabel(_("Model.PropertyDefinition") + ":"), CC.xy(1, 1));
    add(propertySelection, CC.xy(1, 3));
    functionSelectionLabel = new JLabel(_("Model.AccumulationFunction") + ":");
    add(functionSelectionLabel, CC.xy(3, 1));
    add(functionSelection, CC.xy(3, 3));

    add(cumulative, CC.xy(1, 5));

    // build checkBox to differentiate between global bounds and subset bounds
    subsetBounds = new JCheckBox(_("Model.SubsetForBorders"));
    subsetBounds.setSelected(mapping.isSubsetForBounds());
    subsetBounds.setActionCommand(BOUNDS_CHECK_COMMAND);
    subsetBounds.addActionListener(this);
    add(subsetBounds, CC.xy(1, 7));

    // build and add Radio buttons for interval/gradient toggle if needed
    if (type.containsAll(EnumSet.of(PanelType.INTERVAL, PanelType.GRADIENT))) {
        ButtonGroup g = new ButtonGroup();
        gradient = buildGradientToggle(g);
        interval = buildIntervalToggle(g);

        add(gradient, CC.xy(1, 9));
        add(interval, CC.xy(1, 11));
    }

    add(intervalGradientContainer, CC.xyw(1, 13, 4, "c, f"));
    // build interval/gradient panel if needed
    if (type.contains(PanelType.INTERVAL)) {
        intervalPanel = new IntervalPanel(type.contains(PanelType.COLOR), mapping);
        intervalGradientContainer.add(intervalPanel, MappingType.Interval.name());
    } else {
        intervalPanel = null;
    }
    if (type.contains(PanelType.GRADIENT)) {
        GradientPanel gradientPanel = new GradientPanel(type.contains(PanelType.COLOR), mapping);
        intervalGradientContainer.add(gradientPanel, MappingType.Gradient.name());
    }

    // set selection and show
    switch (mapping.getMappingType()) {
    case Gradient:
        if (gradient != null)
            gradient.setSelected(true);
        break;
    case Interval:
        if (interval != null)
            interval.setSelected(true);
    default:
    }
    intervalGradientLayout.show(intervalGradientContainer, mapping.getMappingType().name());

    // set preferred size based on the accumulation
    // chooser being visible
    functionSelection.setVisible(true);
    setPreferredSize(getPreferredSize());
    checkAccumulationFunctionVisible();
}