Search in sources :

Example 16 with Unit

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

the class PlotOptionsFunnel method setNeckHeight.

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

Example 17 with Unit

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

the class PlotOptionsPie method setInnerSize.

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

Example 18 with Unit

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

the class PlotOptionsPyramid 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 19 with Unit

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

the class SizeSerializer method serialize.

@Override
public void serialize(String tmpValue, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
    SizeWithUnit sizeWithUnit = SizeWithUnit.parseStringSize(tmpValue);
    if (sizeWithUnit != null) {
        Unit unit = sizeWithUnit.getUnit();
        float size = sizeWithUnit.getSize();
        if (unit == Unit.PIXELS && size != -1.0f) {
            jsonGenerator.writeNumber(size);
        } else {
            jsonGenerator.writeObject(tmpValue);
        }
    }
}
Also used : SizeWithUnit(com.vaadin.server.SizeWithUnit) SizeWithUnit(com.vaadin.server.SizeWithUnit) Unit(com.vaadin.server.Sizeable.Unit)

Example 20 with Unit

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

the class YAxis 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