/** Returns the first region found with the specified name as a {@link NinePatch}. The region must have been packed with * ninepatch splits. This method uses string comparison to find the region and constructs a new ninepatch, so the result should * be cached rather than calling this method multiple times. * @return The ninepatch, or null. */ public NinePatch createPatch (String name) { for (int i = 0, n = regions.size; i < n; i++) { AtlasRegion region = regions.get(i); if (region.name.equals(name)) { int[] splits = region.splits; if (splits == null) throw new IllegalArgumentException("Region does not have ninepatch splits: " + name); NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); if (region.pads != null) patch.setPadding(region.pads[0], region.pads[1], region.pads[2], region.pads[3]); return patch; } } return null; }
/** Returns the first region found with the specified name as a {@link NinePatch}. The region must have been packed with * ninepatch splits. This method uses string comparison to find the region and constructs a new ninepatch, so the result should * be cached rather than calling this method multiple times. * @return The ninepatch, or null. */ public NinePatch createPatch (String name) { for (int i = 0, n = regions.size; i < n; i++) { AtlasRegion region = regions.get(i); if (region.name.equals(name)) { int[] splits = region.splits; if (splits == null) throw new IllegalArgumentException("Region does not have ninepatch splits: " + name); NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); if (region.pads != null) patch.setPadding(region.pads[0], region.pads[1], region.pads[2], region.pads[3]); return patch; } } return null; }
/** Returns a registered ninepatch. If no ninepatch is found but a region exists with the name, a ninepatch is created from the * region and stored in the skin. If the region is an {@link AtlasRegion} then the {@link AtlasRegion#splits} are used, * otherwise the ninepatch will have the region as the center patch. */ public NinePatch getPatch (String name) { NinePatch patch = optional(name, NinePatch.class); if (patch != null) return patch; try { TextureRegion region = getRegion(name); if (region instanceof AtlasRegion) { int[] splits = ((AtlasRegion)region).splits; if (splits != null) { patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); int[] pads = ((AtlasRegion)region).pads; if (pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]); } } if (patch == null) patch = new NinePatch(region); add(name, patch, NinePatch.class); return patch; } catch (GdxRuntimeException ex) { throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name); } }
/** Returns a registered ninepatch. If no ninepatch is found but a region exists with the name, a ninepatch is created from the * region and stored in the skin. If the region is an {@link AtlasRegion} then the {@link AtlasRegion#splits} are used, * otherwise the ninepatch will have the region as the center patch. */ public NinePatch getPatch (String name) { NinePatch patch = optional(name, NinePatch.class); if (patch != null) return patch; try { TextureRegion region = getRegion(name); if (region instanceof AtlasRegion) { int[] splits = ((AtlasRegion)region).splits; if (splits != null) { patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); int[] pads = ((AtlasRegion)region).pads; if (pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]); } } if (patch == null) patch = new NinePatch(region); add(name, patch, NinePatch.class); return patch; } catch (GdxRuntimeException ex) { throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name); } }
/** Returns the first region found with the specified name as a {@link NinePatch}. The region must have been packed with * ninepatch splits. This method uses string comparison to find the region and constructs a new ninepatch, so the result should * be cached rather than calling this method multiple times. * @return The ninepatch, or null. */ public NinePatch createPatch (String name) { for (int i = 0, n = regions.size; i < n; i++) { AtlasRegion region = regions.get(i); if (region.name.equals(name)) { int[] splits = region.splits; if (splits == null) throw new IllegalArgumentException("Region does not have ninepatch splits: " + name); NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); if (region.pads != null) patch.setPadding(region.pads[0], region.pads[1], region.pads[2], region.pads[3]); return patch; } } return null; }
/** Returns a registered ninepatch. If no ninepatch is found but a region exists with the name, a ninepatch is created from the * region and stored in the skin. If the region is an {@link AtlasRegion} then the {@link AtlasRegion#splits} are used, * otherwise the ninepatch will have the region as the center patch. */ public NinePatch getPatch (String name) { NinePatch patch = optional(name, NinePatch.class); if (patch != null) return patch; try { TextureRegion region = getRegion(name); if (region instanceof AtlasRegion) { int[] splits = ((AtlasRegion)region).splits; if (splits != null) { patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]); int[] pads = ((AtlasRegion)region).pads; if (pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]); } } if (patch == null) patch = new NinePatch(region); add(name, patch, NinePatch.class); return patch; } catch (GdxRuntimeException ex) { throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name); } }