List of usage examples for com.badlogic.gdx.graphics.g2d NinePatch NinePatch
public NinePatch(TextureRegion region, int left, int right, int top, int bottom)
From source file:CB_UI.GL_UI.Views.FieldNoteViewItem.java
License:Open Source License
@Override protected void Initial() { backheader = new NinePatch(Sprites.getSprite("listrec-header"), 8, 8, 8, 8); super.Initial(); }
From source file:CB_UI_Base.GL_UI.Controls.Dialog.java
License:Open Source License
public Dialog(CB_RectF rec, String Name) { super(rec, Name); DialogID = DialogCount++;/*from ww w. ja v a 2s. c o m*/ // ctor without title and footer mHeaderHeight = calcHeaderHeight(); mFooterHeight = mHeaderHeight; if (margin <= 0) margin = UI_Size_Base.that.getMargin(); try { if (Sprites.Dialog.get(DialogElement.footer.ordinal()) == null) return;// noch nicht initialisiert! } catch (Exception e) { return; } // noch nicht initialisiert! if (mTitle9patch == null || mHeader9patch == null || mCenter9patch == null || mFooter9patch == null || lastNightMode != CB_UI_Base_Settings.nightMode.getValue()) { // calcBase pW = (int) (Sprites.Dialog.get(DialogElement.footer.ordinal()).getWidth() / 8); mTitle9patch = new NinePatch(Sprites.Dialog.get(DialogElement.title.ordinal()), pW, (pW * 12 / 8), pW, pW); mHeader9patch = new NinePatch(Sprites.Dialog.get(DialogElement.header.ordinal()), pW, pW, pW, 3); mCenter9patch = new NinePatch(Sprites.Dialog.get(DialogElement.center.ordinal()), pW, pW, 1, 1); mFooter9patch = new NinePatch(Sprites.Dialog.get(DialogElement.footer.ordinal()), pW, pW, 3, pW); mTitleVersatz = pW; lastNightMode = CB_UI_Base_Settings.nightMode.getValue(); } leftBorder = mCenter9patch.getLeftWidth(); rightBorder = mCenter9patch.getRightWidth(); topBorder = mHeader9patch.getTopHeight(); bottomBorder = mFooter9patch.getBottomHeight(); innerWidth = getWidth() - leftBorder - rightBorder; innerHeight = getHeight() - topBorder - bottomBorder; reziseContentBox(); }
From source file:CB_UI_Base.GL_UI.Controls.GalleryBigItem.java
License:Open Source License
@Override protected void Initial() { if (!mBackIsInitial) { backSelect = new NinePatch(Sprites.getSprite("listrec-first"), 13, 13, 13, 13); mBackIsInitial = true;/*ww w. ja va 2 s .c o m*/ } }
From source file:CB_UI_Base.GL_UI.Controls.MultiToggleButton.java
License:Open Source License
@Override protected void render(Batch batch) { super.render(batch); // draw Button with Txt // Draw LED/*from ww w. ja va2 s . c o m*/ if (aktState != null) { if (led == null) { Sprite sprite = Sprites.ToggleBtn.get(2); int patch = (int) ((sprite.getWidth() / 2) - 5); led = new NinePatchDrawable(new NinePatch(sprite, patch, patch, 1, 1)); } float A = 0, R = 0, G = 0, B = 0; // Farbwerte der batch um diese wieder einzustellen, wenn ein ColorFilter angewandt wurde! Color c = batch.getColor(); A = c.a; R = c.r; G = c.g; B = c.b; GL.setBatchColor(aktState.color); if (led != null) led.draw(batch, 0, 0, getWidth(), getHeight()); batch.setColor(R, G, B, A); } }
From source file:CB_UI_Base.GL_UI.Controls.Spinner.java
License:Open Source License
@Override protected void Initial() { super.Initial(); if (triangle == null) { Sprite tr = Sprites.getSprite("spinner-triangle"); int patch = (int) tr.getWidth() / 2; triangle = new NinePatch(tr, 0, patch, patch, 0); }// w w w.j a v a2 s .c om this.setOnClickListener(new OnClickListener() { @Override public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) { if (mAdapter == null) return true; // kann nix anzeigen // show Menu to select Menu icm = new Menu("SpinnerSelection" + that.name); icm.addOnClickListener(new OnClickListener() { @Override public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) { int sel = ((MenuItem) v).getIndex(); setSelection(sel); if (mListener != null) mListener.selectionChanged(sel); return false; } }); for (int index = 0; index < mAdapter.getCount(); index++) { String text = mAdapter.getText(index); Drawable drawable = mAdapter.getIcon(index); icm.addItem(index, text, drawable, true); } if (prompt != null && !prompt.equalsIgnoreCase("")) { icm.setPrompt(prompt); } icm.Show(); return true; } }); }
From source file:CB_UI_Base.GL_UI.Sprites.java
License:Open Source License
/** * Load the Sprites from recourse//from w w w. ja v a 2 s .c o m */ public static void loadSprites(boolean reload) { if (!reload) setPath(CB_Skin.INSTANCE); if (LogIcons == null) LogIcons = new ArrayList<Sprite>(); synchronized (LogIcons) { LogIcons.clear(); LogIcons.add(getSprite("log0icon")); LogIcons.add(getSprite("log1icon")); LogIcons.add(getSprite("log2icon")); LogIcons.add(getSprite("log3icon")); LogIcons.add(getSprite("log4icon")); LogIcons.add(getSprite("log5icon")); LogIcons.add(getSprite("log6icon")); LogIcons.add(getSprite("log7icon")); LogIcons.add(getSprite("log8icon")); LogIcons.add(getSprite("log9icon")); LogIcons.add(getSprite("log10icon")); LogIcons.add(getSprite("log11icon")); LogIcons.add(getSprite("log12icon")); LogIcons.add(getSprite("log13icon")); LogIcons.add(getSprite("log14icon")); LogIcons.add(getSprite("log15icon")); LogIcons.add(getSprite("log16icon")); LogIcons.add(getSprite(IconName.TBPICKED.name())); LogIcons.add(getSprite(IconName.TBDROP.name())); LogIcons.add(getSprite(IconName.TBGRAB.name())); LogIcons.add(getSprite(IconName.TBDISCOVER.name())); LogIcons.add(getSprite(IconName.TBVISIT.name())); LogIcons.add(getSprite(IconName.TBNOTE.name())); } if (Compass == null) Compass = new ArrayList<Drawable>(); synchronized (Compass) { Compass.clear(); Compass.add(new SpriteDrawable(getSprite("compass-frame"))); Compass.add(new SpriteDrawable(getSprite("compass-scale"))); Compass.add(new SpriteDrawable(getSprite("compass-frame-small"))); Compass.add(new SpriteDrawable(getSprite("compass-scale-small"))); Compass.add(new SpriteDrawable(getSprite("compass_arrow"))); Compass.add(new SpriteDrawable(getSprite("sonne"))); Compass.add(new SpriteDrawable(getSprite("mond"))); } if (MapOverlay == null) MapOverlay = new ArrayList<Sprite>(); synchronized (MapOverlay) { MapOverlay.clear(); MapOverlay.add(getSprite("shaddowrect")); MapOverlay.add(getSprite("shaddowrect-selected")); MapOverlay.add(getSprite("deact")); MapOverlay.add(getSprite("cross")); // Live sprites with light blue color changed Color backColor = CB_UI_Base_Settings.LiveMapBackgroundColor.getValue(); Sprite live = getSprite("shaddowrect"); Sprite liveSelected = getSprite("shaddowrect-selected"); live.setColor(backColor); liveSelected.setColor(backColor); MapOverlay.add(live); MapOverlay.add(liveSelected); CB_UI_Base_Settings.LiveMapBackgroundColor.addChangedEventListener(new IChanged() { @Override public void isChanged() { Color backColor = CB_UI_Base_Settings.LiveMapBackgroundColor.getValue(); MapOverlay.get(4).setColor(backColor); MapOverlay.get(5).setColor(backColor); } }); } if (Arrows == null) Arrows = new ArrayList<Sprite>(); synchronized (Arrows) { float scale = UI_Size_Base.that.getScale(); Arrows.clear(); Arrows.add(getSprite("arrow-Compass")); // 0 Arrows.add(getSprite("arrow-Compass-Trans")); // 1 Arrows.add(getSprite("arrow-GPS")); // 2 Arrows.add(getSprite("arrow-GPS-Trans")); // 3 Arrows.add(getSprite("target-arrow")); // 4 Arrows.add(getSprite("track-line", scale)); // 5 Arrows.add(getSprite("arrow-down")); // 6 Arrows.add(getSprite("arrow-up")); // 7 Arrows.add(getSprite("arrow-left")); // 8 Arrows.add(getSprite("arrow-right")); // 9 Arrows.add(getSprite("track-point", scale)); // 10 Arrows.add(getSprite("ambilwarna-arrow-right")); // 11 Arrows.add(getSprite("ambilwarna-arrow-down")); // 12 Arrows.add(getSprite("draw-line", scale)); // 13 Arrows.add(getSprite("draw-point", scale)); // 14 Arrows.add(getSprite("arrow-Compass-car")); // 15 } if (MapStars == null) MapStars = new ArrayList<Sprite>(); synchronized (MapStars) { MapStars.clear(); MapStars.add(getSprite("stars0small")); MapStars.add(getSprite("stars0-5small")); MapStars.add(getSprite("stars1small")); MapStars.add(getSprite("stars1-5small")); MapStars.add(getSprite("stars2small")); MapStars.add(getSprite("stars2-5small")); MapStars.add(getSprite("stars3small")); MapStars.add(getSprite("stars3-5small")); MapStars.add(getSprite("stars4small")); MapStars.add(getSprite("stars4-5small")); MapStars.add(getSprite("stars5small")); } if (Stars == null) Stars = new SpriteList(); synchronized (Stars) { Stars.clear(); Stars.add(getSprite("stars0icon")); Stars.add(getSprite("stars0-5icon")); Stars.add(getSprite("stars1icon")); Stars.add(getSprite("stars1-5icon")); Stars.add(getSprite("stars2icon")); Stars.add(getSprite("stars2-5icon")); Stars.add(getSprite("stars3icon")); Stars.add(getSprite("stars3-5icon")); Stars.add(getSprite("stars4icon")); Stars.add(getSprite("stars4-5icon")); Stars.add(getSprite("stars5icon")); } if (Bubble == null) Bubble = new ArrayList<Sprite>(); synchronized (Bubble) { Bubble.clear(); Bubble.add(getSprite("Bubble")); Bubble.add(getSprite("Bubble-selected")); Bubble.add(getSprite("BubbleOverlay")); Bubble.add(getSprite("1to4bubble")); Bubble.add(getSprite("5bubble")); Bubble.add(getSprite("1to4bubble-flip")); Bubble.add(getSprite("5bubble-flip")); } if (ChkIcons == null) ChkIcons = new ArrayList<Sprite>(); synchronized (ChkIcons) { ChkIcons.clear(); ChkIcons.add(getSprite("check-off")); ChkIcons.add(getSprite("check-on")); } if (Dialog == null) Dialog = new ArrayList<Sprite>(); synchronized (Dialog) { Dialog.clear(); Dialog.add(getSprite("dialog-header")); Dialog.add(getSprite("dialog-center")); Dialog.add(getSprite("dialog-footer")); Dialog.add(getSprite("dialog-title")); Dialog.add(getSprite("menu-divider")); } if (ToggleBtn == null) ToggleBtn = new ArrayList<Sprite>(); synchronized (ToggleBtn) { ToggleBtn.clear(); ToggleBtn.add(getSprite(IconName.btnNormal.name())); ToggleBtn.add(getSprite("btn-pressed")); ToggleBtn.add(getSprite("toggle-led-gr")); } if (LiveBtn == null) LiveBtn = new ArrayList<Sprite>(); synchronized (LiveBtn) { LiveBtn.clear(); LiveBtn.add(getSprite("LiveEnabled")); LiveBtn.add(getSprite("LiveDisabled")); LiveBtn.add(getSprite("Live1")); LiveBtn.add(getSprite("Live2")); LiveBtn.add(getSprite("Live3")); LiveBtn.add(getSprite("Live4")); LiveBtn.add(getSprite("Live5")); LiveBtn.add(getSprite("Live6")); LiveBtn.add(getSprite("Live7")); LiveBtn.add(getSprite("Live8")); } Progress = getSprite("progress"); ambilwarna_hue = getSprite("ambilwarna-hue"); ambilwarna_cursor = getSprite("ambilwarna-cursor"); ambilwarna_target = getSprite("ambilwarna-target"); if (ZoomBtn == null) ZoomBtn = new ArrayList<Sprite>(); synchronized (ZoomBtn) { ZoomBtn.clear(); ZoomBtn.add(getSprite("day-btn-zoom-down-normal")); ZoomBtn.add(getSprite("day-btn-zoom-down-pressed")); ZoomBtn.add(getSprite("day-btn-zoom-down-disabled")); ZoomBtn.add(getSprite("day-btn-zoom-up-normal")); ZoomBtn.add(getSprite("day-btn-zoom-up-pressed")); ZoomBtn.add(getSprite("day-btn-zoom-up-disabled")); } ZoomValueBack = getSprite("zoom-back"); if (SizesIcons == null) SizesIcons = new SpriteList(); synchronized (SizesIcons) { SizesIcons.clear(); SizesIcons.add(getSprite("other")); SizesIcons.add(getSprite("micro")); SizesIcons.add(getSprite("small")); SizesIcons.add(getSprite("regular")); SizesIcons.add(getSprite("large")); } MapScale = new Drawable[3]; Sprite MS3 = getSprite("MapScale-3"); int patchMS3 = (int) Math.max((MS3.getWidth() / 10), 1); MapScale[0] = new NinePatchDrawable(new NinePatch(MS3, patchMS3, patchMS3, 0, 0)); Sprite MS4 = getSprite("MapScale-4"); int patchMS4 = (int) Math.max((MS4.getWidth() / 10), 1); MapScale[1] = new NinePatchDrawable(new NinePatch(MS4, patchMS4, patchMS4, 0, 0)); Sprite MS5 = getSprite("MapScale-5"); int patchMS5 = (int) Math.max((MS5.getWidth() / 10), 1); MapScale[2] = new NinePatchDrawable(new NinePatch(MS5, patchMS5, patchMS5, 0, 0)); loadButtonSprites(); createDrawables(); loaded = true; }
From source file:CB_UI_Base.GL_UI.Sprites.java
License:Open Source License
protected static void createDrawables() { patch = (Sprites.getSprite("activity-back").getWidth() > 60) ? 16 : 8; activityBackground = new NinePatchDrawable( new NinePatch(Sprites.getSprite("activity-back"), patch, patch, patch, patch)); activityBorderMask = new NinePatchDrawable( new NinePatch(Sprites.getSprite("activity-border"), patch, patch, patch, patch)); ListBack = new ColorDrawable(SkinBase.getThemedColor("background")); ButtonBack = new SpriteDrawable(getSprite("button-list-back")); AboutBack = new SpriteDrawable(getSprite("splash-back")); InfoBack = new NinePatchDrawable(new NinePatch(getSprite("InfoPanelBack"), patch, patch, patch, patch)); ProgressBack = new NinePatchDrawable(new NinePatch(ToggleBtn.get(0), patch, patch, patch, patch)); ProgressFill = new NinePatchDrawable( new NinePatch(Sprites.Progress, patch - 1, patch - 1, patch - 1, patch - 1)); ProgressDisabled = new NinePatchDrawable( new NinePatch(getSprite("progress-disabled"), patch - 1, patch - 1, patch - 1, patch - 1)); btn = new NinePatchDrawable( new NinePatch(Sprites.getSprite(IconName.btnNormal.name()), patch, patch, patch, patch)); btnPressed = new NinePatchDrawable( new NinePatch(Sprites.getSprite("btn-pressed"), patch, patch, patch, patch)); btnDisabled = new NinePatchDrawable( new NinePatch(Sprites.getSprite("btn-disabled"), patch, patch, patch, patch)); SliderPushed = new SpriteDrawable(getSprite("scrollbarPushedSlider")); // SliderBack = new SpriteDrawable(getThemedSprite(????)); Sprite tmpSlider = getSprite("scrollbarSlider"); int sliderPatch = (int) (tmpSlider.getWidth() / 4); Slider = new NinePatchDrawable( new NinePatch(tmpSlider, sliderPatch, sliderPatch, sliderPatch, sliderPatch)); chkOn = new SpriteDrawable(getSprite("check-on")); chkOff = new SpriteDrawable(getSprite("check-off")); chkOnDisabled = new SpriteDrawable(getSprite("check-disable")); chkOffDisabled = new SpriteDrawable(getSprite("check-off")); radioOn = new SpriteDrawable(getSprite("RadioButtonSet")); radioBack = new SpriteDrawable(getSprite("RadioButtonBack")); textFieldBackground = new NinePatchDrawable( new NinePatch(Sprites.getSprite("text-field-back"), patch, patch, patch, patch)); textFieldBackgroundFocus = new NinePatchDrawable( new NinePatch(Sprites.getSprite("text-field-back-focus"), patch, patch, patch, patch)); selection = new SpriteDrawable(getSprite("Selection")); selection_set = new SpriteDrawable(getSprite("Selection-set")); selection_left = new SpriteDrawable(getSprite("Selection-Left")); selection_right = new SpriteDrawable(getSprite("Selection-Right")); logo = new SpriteDrawable(getSprite("cachebox-logo")); copy = new SpriteDrawable(getSprite("tf-copy")); paste = new SpriteDrawable(getSprite("tf-paste")); cut = new SpriteDrawable(getSprite("tf-cut")); bar = new NinePatchDrawable(getThemedPatch("bar")); barSmall = new NinePatchDrawable(getThemedPatch("bar-small")); bar_0 = new SpriteDrawable(getSprite("bar-0")); barSmall_0 = new SpriteDrawable(getSprite("bar-small-0")); textFieldCursor = new NinePatchDrawable( new NinePatch(Sprites.getSprite("selection-input-icon"), 1, 1, 2, 2)); int hp = patch / 2; shaddowRec = new NinePatchDrawable(new NinePatch(Sprites.getSprite("shaddowrect"), hp, hp, hp, hp)); }
From source file:com.blindtigergames.werescrewed.graphics.TextureAtlas.java
License:Apache License
/** * 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.//from w w w.j a v a2 s . co m * * @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; }
From source file:com.bss.game.WorldRenderer.java
License:Apache License
public WorldRenderer(SpriteBatch batch, ShapeRenderer shapeRender, World world, OrthographicCamera guiCam) { this.world = world; this.cam = guiCam; this.cam.position.set(480 / 2, 800 / 2, 0); this.batch = batch; this.shapeRender = shapeRender; hook = new Sprite(Assets.hook2); hook.setOriginCenter();/*from w w w . ja v a2 s. c o m*/ slappy = new Sprite(Assets.slappySeal); greenHealth = new NinePatch(Assets.greenPatch, 0, 0, 0, 0); redHealth = new NinePatch(Assets.redPatch, 0, 0, 0, 0); }
From source file:com.gamejolt.mikykr5.ceidecpong.states.MainMenuState.java
License:Open Source License
@Override public void onAssetsLoaded() { TextButtonStyle textButtonStyle;// ww w.j av a2 s. c o m // Create the button backgrounds. menuButtonEnabledTexture = loader.getAsset("data/gfx/gui/Anonymous_Pill_Button_Yellow.png", Texture.class); menuButtonDisabledTexture = loader.getAsset("data/gfx/gui/Anonymous_Pill_Button_Cyan.png", Texture.class); menuButtonPressedTexture = loader.getAsset("data/gfx/gui/Anonymous_Pill_Button_Blue.png", Texture.class); menuButtonEnabled9p = new NinePatch(new TextureRegion(menuButtonEnabledTexture, 0, 0, menuButtonEnabledTexture.getWidth(), menuButtonEnabledTexture.getHeight()), 49, 49, 45, 45); menuButtonDisabled9p = new NinePatch(new TextureRegion(menuButtonDisabledTexture, 0, 0, menuButtonDisabledTexture.getWidth(), menuButtonDisabledTexture.getHeight()), 49, 49, 45, 45); menuButtonPressed9p = new NinePatch(new TextureRegion(menuButtonPressedTexture, 0, 0, menuButtonPressedTexture.getWidth(), menuButtonPressedTexture.getHeight()), 49, 49, 45, 45); // Create the buttons. textButtonStyle = new TextButtonStyle(); textButtonStyle.font = buttonFont; textButtonStyle.up = new NinePatchDrawable(menuButtonEnabled9p); textButtonStyle.checked = new NinePatchDrawable(menuButtonPressed9p); textButtonStyle.disabled = new NinePatchDrawable(menuButtonDisabled9p); textButtonStyle.fontColor = new Color(Color.BLACK); textButtonStyle.downFontColor = new Color(Color.WHITE); textButtonStyle.disabledFontColor = new Color(Color.BLACK); startButton = new TextButton("Start game", textButtonStyle); startButton.setText("Start game"); startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight()); quitButton = new TextButton("Quit", textButtonStyle); quitButton.setText("quit"); quitButtonBBox = new Rectangle(0, 0, quitButton.getWidth(), quitButton.getHeight()); // Set buttons. startButton.setPosition(-(startButton.getWidth() / 2), -(startButton.getHeight() / 2)); startButtonBBox.setPosition(startButton.getX(), startButton.getY()); quitButton.setPosition(-(quitButton.getWidth() / 2), (startButton.getY() - startButton.getHeight()) - 10); quitButtonBBox.setPosition(quitButton.getX(), quitButton.getY()); assetsLoaded = true; AsyncAssetLoader.freeInstance(); }