Search in sources :

Example 11 with Unit

use of com.vaadin.server.Sizeable.Unit 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)

Example 12 with Unit

use of com.vaadin.server.Sizeable.Unit in project charts by vaadin.

the class PlotOptionsBubble method setMaxSize.

/**
 * Sets the maxSize 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 maxSize
 *            CSS style string representation
 */
public void setMaxSize(String maxSize) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(maxSize);
    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.");
        }
        setMaxSize(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setMaxSize(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Example 13 with Unit

use of com.vaadin.server.Sizeable.Unit in project charts by vaadin.

the class PlotOptionsErrorbar 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 14 with Unit

use of com.vaadin.server.Sizeable.Unit in project charts by vaadin.

the class PlotOptionsFunnel method setHeight.

/**
 * Sets the height 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 height
 *            CSS style string representation
 */
public void setHeight(String height) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(height);
    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.");
        }
        setHeight(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setHeight(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Example 15 with Unit

use of com.vaadin.server.Sizeable.Unit in project charts by vaadin.

the class PlotOptionsFunnel method setNeckWidth.

/**
 * Sets the neckWidth 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 neckWidth
 *            CSS style string representation
 */
public void setNeckWidth(String neckWidth) {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(neckWidth);
    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.");
        }
        setNeckWidth(sizeWithUnit.getSize(), sizeWithUnit.getUnit());
    } else {
        setNeckWidth(-1, Unit.PIXELS);
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Aggregations

Unit (com.vaadin.server.Sizeable.Unit)20 SizeWithUnit (com.vaadin.server.SizeWithUnit)19 Element (org.dom4j.Element)1