List of usage examples for com.google.common.primitives Floats stringConverter
@Beta public static Converter<String, Float> stringConverter()
From source file:com.googlecode.blaisemath.style.Styles.java
public static Stroke getStroke(AttributeSet style) { float strokeWidth = style.getFloat(Styles.STROKE_WIDTH, 1f); String dashes = style.getString(Styles.STROKE_DASHES, null); if (!Strings.isNullOrEmpty(dashes)) { Iterable<String> sDashes = Splitter.on(",").trimResults().split(dashes); try {//from w ww . ja v a2 s.c o m Iterable<Float> fDashes = Floats.stringConverter().convertAll(sDashes); float[] fArr = new float[Iterables.size(fDashes)]; int i = 0; for (Float f : fDashes) { fArr[i] = f == null ? 0f : f; i++; } return new BasicStroke(strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, fArr, 0.0f); } catch (NumberFormatException x) { Logger.getLogger(Styles.class.getName()).log(Level.WARNING, "Invalid dash pattern: " + dashes, x); } } return new BasicStroke(strokeWidth); }