Search in sources :

Example 6 with SizeWithUnit

use of com.vaadin.server.SizeWithUnit in project charts by vaadin.

the class Pane method setSize.

/**
 * Sets the size using String presentation. String presentation is similar
 * to what is used in Cascading Style Sheets. Size can be pixels or
 * percentage, otherwise IllegalArgumentException is thrown. The empty
 * string ("") or null will unset the height and set the units to pixels.
 *
 * @param size
 *            CSS style string representation
 */
public void setSize(String size) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(size);
    if (sizeWithUnit != null) {
        Unit unit = sizeWithUnit.getUnit();
        if (!(unit.equals(Unit.PERCENTAGE) || unit.equals(Unit.PIXELS))) {
            throw new IllegalArgumentException(unit.toString() + "is not a valid unit for sizing. Only percentage and pixels are allowed.");
        }
        setSize(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setSize(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Example 7 with SizeWithUnit

use of com.vaadin.server.SizeWithUnit in project charts by vaadin.

the class PlotBand method setInnerRadius.

/**
 * Sets the innerRadius using String presentation. String presentation is
 * similar to what is used in Cascading Style Sheets. Size can be pixels or
 * percentage, otherwise IllegalArgumentException is thrown. The empty
 * string ("") or null will unset the height and set the units to pixels.
 *
 * @param innerRadius
 *            CSS style string representation
 */
public void setInnerRadius(String innerRadius) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(innerRadius);
    if (sizeWithUnit != null) {
        Unit unit = sizeWithUnit.getUnit();
        if (!(unit.equals(Unit.PERCENTAGE) || unit.equals(Unit.PIXELS))) {
            throw new IllegalArgumentException(unit.toString() + "is not a valid unit for sizing. Only percentage and pixels are allowed.");
        }
        setInnerRadius(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setInnerRadius(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Example 8 with SizeWithUnit

use of com.vaadin.server.SizeWithUnit in project charts by vaadin.

the class PlotBand method setThickness.

/**
 * Sets the thickness using String presentation. String presentation is
 * similar to what is used in Cascading Style Sheets. Size can be pixels or
 * percentage, otherwise IllegalArgumentException is thrown. The empty
 * string ("") or null will unset the height and set the units to pixels.
 *
 * @param thickness
 *            CSS style string representation
 */
public void setThickness(String thickness) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(thickness);
    if (sizeWithUnit != null) {
        Unit unit = sizeWithUnit.getUnit();
        if (!(unit.equals(Unit.PERCENTAGE) || unit.equals(Unit.PIXELS))) {
            throw new IllegalArgumentException(unit.toString() + "is not a valid unit for sizing. Only percentage and pixels are allowed.");
        }
        setThickness(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setThickness(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Example 9 with SizeWithUnit

use of com.vaadin.server.SizeWithUnit in project charts by vaadin.

the class PlotOptionsBoxplot method setWhiskerLength.

/**
 * Sets the whiskerLength using String presentation. String presentation is
 * similar to what is used in Cascading Style Sheets. Size can be pixels or
 * percentage, otherwise IllegalArgumentException is thrown. The empty
 * string ("") or null will unset the height and set the units to pixels.
 *
 * @param whiskerLength
 *            CSS style string representation
 */
public void setWhiskerLength(String whiskerLength) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(whiskerLength);
    if (sizeWithUnit != null) {
        Unit unit = sizeWithUnit.getUnit();
        if (!(unit.equals(Unit.PERCENTAGE) || unit.equals(Unit.PIXELS))) {
            throw new IllegalArgumentException(unit.toString() + "is not a valid unit for sizing. Only percentage and pixels are allowed.");
        }
        setWhiskerLength(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setWhiskerLength(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Example 10 with SizeWithUnit

use of com.vaadin.server.SizeWithUnit in project charts by vaadin.

the class PlotBand method setOuterRadius.

/**
 * Sets the outerRadius using String presentation. String presentation is
 * similar to what is used in Cascading Style Sheets. Size can be pixels or
 * percentage, otherwise IllegalArgumentException is thrown. The empty
 * string ("") or null will unset the height and set the units to pixels.
 *
 * @param outerRadius
 *            CSS style string representation
 */
public void setOuterRadius(String outerRadius) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(outerRadius);
    if (sizeWithUnit != null) {
        Unit unit = sizeWithUnit.getUnit();
        if (!(unit.equals(Unit.PERCENTAGE) || unit.equals(Unit.PIXELS))) {
            throw new IllegalArgumentException(unit.toString() + "is not a valid unit for sizing. Only percentage and pixels are allowed.");
        }
        setOuterRadius(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setOuterRadius(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Aggregations

SizeWithUnit (com.vaadin.server.SizeWithUnit)19 Unit (com.vaadin.server.Sizeable.Unit)19