public Pair<Integer, Integer> size() { if (size == null) { size = size(value, 0, 1); } return size; }
public CharSlicer(String value) { this.value = value; this.size = size(); }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }
/** * Create a new label element * * @param value the label value * @param minWidth the label minimum width * @throws IllegalArgumentException if the minimum width is negative */ public LabelElement(Object value, int minWidth) throws IllegalArgumentException { if (minWidth < 0) { throw new IllegalArgumentException("No negative min size allowed"); } // String s = String.valueOf(value); // Determine size CharSlicer slicer = new CharSlicer(s); Pair<Integer, Integer> size = slicer.size(); // this.value = s; this.minWidth = Math.min(size.getFirst(), minWidth); this.actualWidth = size.getFirst(); this.actualHeight = size.getSecond(); this.slicer = slicer; }
public Pair<Integer, Integer> size() { if (size == null) { size = size(value, 0, 1); } return size; }
public Pair<Integer, Integer> size() { if (size == null) { size = size(value, 0, 1); } return size; }
public CharSlicer(String value) { this.value = value; this.size = size(); }
public CharSlicer(String value) { this.value = value; this.size = size(); }
public Pair<Integer, Integer> size() { if (size == null) { size = size(value, 0, 1); } return size; }
public CharSlicer(String value) { this.value = value; this.size = size(); }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }
private static Pair<Integer, Integer> size(String s, int index, int height) { if (height < 1) { throw new IllegalArgumentException("A non positive height=" + height + " cannot be accepted"); } if (index < s.length()) { int pos = s.indexOf('\n', index); if (pos == -1) { return Pair.of(s.length() - index, height); } else { Pair<Integer, Integer> ret = size(s, pos + 1, height + 1); return new Pair<Integer, Integer>(Math.max(pos - index, ret.getFirst()), ret.getSecond()); } } else { return Pair.of(0, height); } }
public LabelElement(String value, int minWidth) { if (minWidth < 0) { throw new IllegalArgumentException("No negative min size allowed"); } // Determine size CharSlicer slicer = new CharSlicer(value); Pair<Integer, Integer> size = slicer.size(); // this.value = value; this.minWidth = Math.min(size.getFirst(), minWidth); this.actualWidth = size.getFirst(); this.actualHeight = size.getSecond(); this.slicer = slicer; }
/** * Create a new label element * * @param value the label value * @param minWidth the label minimum width * @throws IllegalArgumentException if the minimum width is negative */ public LabelElement(Object value, int minWidth) throws IllegalArgumentException { if (minWidth < 0) { throw new IllegalArgumentException("No negative min size allowed"); } // String s = String.valueOf(value); // Determine size CharSlicer slicer = new CharSlicer(s); Pair<Integer, Integer> size = slicer.size(); // this.value = s; this.minWidth = Math.min(size.getFirst(), minWidth); this.actualWidth = size.getFirst(); this.actualHeight = size.getSecond(); this.slicer = slicer; }
/** * Create a new label element * * @param value the label value * @param minWidth the label minimum width * @throws IllegalArgumentException if the minimum width is negative */ public LabelElement(Object value, int minWidth) throws IllegalArgumentException { if (minWidth < 0) { throw new IllegalArgumentException("No negative min size allowed"); } // String s = String.valueOf(value); // Determine size CharSlicer slicer = new CharSlicer(s); Pair<Integer, Integer> size = slicer.size(); // this.value = s; this.minWidth = Math.min(size.getFirst(), minWidth); this.actualWidth = size.getFirst(); this.actualHeight = size.getSecond(); this.slicer = slicer; }