All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.gv2011.util.swing.imp.builder.Gap Maven / Gradle / Ivy

There is a newer version: 0.14
Show newest version
package com.github.gv2011.util.swing.imp.builder;

import static com.github.gv2011.util.swing.imp.builder.Orientation.HORIZONTAL;
import static com.github.gv2011.util.swing.imp.builder.Orientation.VERTICAL;

import javax.swing.JComponent;

import com.github.gv2011.util.icol.ICollections;
import com.github.gv2011.util.icol.IMap;
import com.github.gv2011.util.icol.Opt;

final class Gap extends Block{

  private final IMap flexibilities;

  Gap(final short size, final Orientation rigid) {
    flexibilities = ICollections.mapBuilder()
      .put(rigid, new Elasticity(size))
      .put(rigid.other(), Elasticity.FLEX)
      .build()
    ;
  }

  Gap(final Elasticity horizontal, final Elasticity vertical) {
    flexibilities = ICollections.mapBuilder()
      .put(HORIZONTAL, horizontal)
      .put(VERTICAL,   vertical)
      .build()
    ;
  }

  @Override
  Opt component() {
    return Opt.empty();
  }

  @Override
  public Elasticity elasticity(final Orientation orientation) {
    return flexibilities.get(orientation);
  }

  @Override
  public void reset() {}

  @Override
  public String toString() {
    return "G("+elasticity(HORIZONTAL)+"/"+elasticity(VERTICAL)+")";
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy