com.github.gv2011.util.swing.imp.builder.Gap Maven / Gradle / Ivy
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