private Component secondComponent;
- private int pos = 50;
+ private float pos = 50;
private int posUnit = UNITS_PERCENTAGE;
*
* @param pos
* the new size of the first region in the unit that was last
- * used (default is percentage)
+ * used (default is percentage). Fractions are only allowed when
+ * unit is percentage.
*/
- public void setSplitPosition(int pos) {
+ public void setSplitPosition(float pos) {
setSplitPosition(pos, posUnit, true, false);
}
*
* @param pos
* the new size of the region in the unit that was last used
- * (default is percentage)
+ * (default is percentage). Fractions are only allowed when unit
+ * is percentage.
+ *
* @param reverse
* if set to true the split splitter position is measured by the
* second region else it is measured by the first region
*/
- public void setSplitPosition(int pos, boolean reverse) {
+ public void setSplitPosition(float pos, boolean reverse) {
setSplitPosition(pos, posUnit, true, reverse);
}
* Moves the position of the splitter with given position and unit.
*
* @param pos
- * size of the first region
+ * the new size of the first region. Fractions are only allowed
+ * when unit is percentage.
* @param unit
* the unit (from {@link Sizeable}) in which the size is given.
*/
- public void setSplitPosition(int pos, int unit) {
+ public void setSplitPosition(float pos, int unit) {
setSplitPosition(pos, unit, true, false);
}
* Moves the position of the splitter with given position and unit.
*
* @param pos
- * size of the first region
+ * the new size of the first region. Fractions are only allowed
+ * when unit is percentage.
* @param unit
* the unit (from {@link Sizeable}) in which the size is given.
* @param reverse
* second region else it is measured by the first region
*
*/
- public void setSplitPosition(int pos, int unit, boolean reverse) {
+ public void setSplitPosition(float pos, int unit, boolean reverse) {
setSplitPosition(pos, unit, true, reverse);
}
*
* @return position of the splitter
*/
- public int getSplitPosition() {
+ public float getSplitPosition() {
return pos;
}
* Moves the position of the splitter.
*
* @param pos
- * the new size of the first region
+ * the new size of the first region. Fractions are only allowed
+ * when unit is percentage.
* @param unit
* the unit (from {@link Sizeable}) in which the size is given.
* @param repaintNotNeeded
* position info has come from the client side, thus it already
* knows the position.
*/
- private void setSplitPosition(int pos, int unit, boolean repaintNeeded,
+ private void setSplitPosition(float pos, int unit, boolean repaintNeeded,
boolean reverse) {
if (unit != UNITS_PERCENTAGE && unit != UNITS_PIXELS) {
throw new IllegalArgumentException(
"Only percentage and pixel units are allowed");
}
+ if (unit != UNITS_PERCENTAGE) {
+ pos = Math.round(pos);
+ }
this.pos = pos;
posUnit = unit;
posReversed = reverse;
super.changeVariables(source, variables);
if (variables.containsKey("position") && !isLocked()) {
- Integer newPos = (Integer) variables.get("position");
+ Float newPos = (Float) variables.get("position");
setSplitPosition(newPos, posUnit, posReversed);
}