List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Cell pad
public Cell<T> pad(float top, float left, float bottom, float right)
From source file:at.highstreeto.xnllayoutparser.element.CellParser.java
License:Apache License
@Override public Actor load(Element element, LayoutParserContext context) throws LayoutParseException { Table table = (Table) context.getActorByElement(element.getParent().getParent()); Element child = element.getChild(0); Actor actor = context.getParsers().getParserByElementName(child).load(child, context); Cell<?> cell = table.add(actor); if (element.getAttributes().containsKey("fill")) { if ("x".equals(element.getAttribute("fill"))) { cell.fillX();/*from w ww .j a va 2s . c o m*/ } else if ("y".equals(element.getAttribute("fill"))) { cell.fillY(); } else if ("xy".equals(element.getAttribute("fill"))) { cell.fill(); } else { throw new LayoutParseException(); } } if (element.getAttributes().containsKey("expand")) { if ("x".equals(element.getAttribute("expand"))) { cell.expandX(); } else if ("y".equals(element.getAttribute("expand"))) { cell.expandY(); } else if ("xy".equals(element.getAttribute("expand"))) { cell.expand(); } else { throw new LayoutParseException(); } } // Combination of c (Center), t (Top), b (Bottom), l (Left), r (Right) if (element.getAttributes().containsKey("align")) { String[] parts = element.getAttribute("align").split(" "); for (String i : parts) { if ("c".equals(i)) { cell.center(); } else if ("t".equals(i)) { cell.top(); } else if ("b".equals(i)) { cell.bottom(); } else if ("l".equals(i)) { cell.left(); } else if ("r".equals(i)) { cell.right(); } } } // Padding - Format: Top Left Bottom Right if (element.getAttributes().containsKey("pad")) { String[] pads = element.getAttribute("pad").split(" "); if (pads.length == 4) { float top = Float.parseFloat(pads[0]); float right = Float.parseFloat(pads[1]); float bottom = Float.parseFloat(pads[2]); float left = Float.parseFloat(pads[3]); cell.pad(top, left, bottom, right); } else { throw new LayoutParseException(); } } if (element.getAttributes().containsKey("colspan")) { int colspan = Integer.parseInt(element.getAttribute("colspan")); cell.colspan(colspan); } return null; }
From source file:com.kotcrab.vis.ui.building.utilities.Padding.java
License:Apache License
/** * Allows to set Cell's padding with the Padding object, which has be done externally, as it's not part of * the standard libGDX API.//from w w w. j av a2 s.c om * @param cell will have the padding set according to the this object's data. * @return the given cell for chaining. */ public Cell<?> applyPadding(final Cell<?> cell) { cell.pad(top, left, bottom, right); return cell; }
From source file:com.kotcrab.vis.ui.building.utilities.Padding.java
License:Apache License
/** * Allows to set Cell's padding with the Padding object, which has be done externally, as it's not part of * the standard libGDX API.//from w w w . j a v a 2 s .c o m * @param padding contains data of padding sizes. * @param cell will have the padding set according to the given data. * @return the given cell for chaining. */ public static Cell<?> setPadding(final Padding padding, final Cell<?> cell) { return cell.pad(padding.getTop(), padding.getLeft(), padding.getBottom(), padding.getRight()); }