Search in sources :

Example 1 with Unit

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

the class YAxis method setTop.

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

Example 2 with Unit

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

the class PlotOptionsBubble method setMinSize.

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

Example 3 with Unit

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

the class PlotOptionsFunnel method setWidth.

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

Example 4 with Unit

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

the class PlotOptionsPie 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 5 with Unit

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

the class PlotOptionsPyramid 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)

Aggregations

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