Java tutorial
/* * Copyright 2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.mwplay.cocostudio.ui.parser.group; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import net.mwplay.cocostudio.ui.CocoStudioUIEditor; import net.mwplay.cocostudio.ui.model.ObjectData; import net.mwplay.cocostudio.ui.model.Size; import net.mwplay.cocostudio.ui.parser.GroupParser; /** * tip ??, Cocostudio??, */ public class CCPanel extends GroupParser { @Override public String getClassName() { return "PanelObjectData"; } @Override public Actor parse(CocoStudioUIEditor editor, ObjectData widget) { Table table = new Table(); Size size = widget.getSize(); if (widget.getComboBoxIndex() == 0) { // } else if (widget.getComboBoxIndex() == 1 && widget.getBackColorAlpha() != 0) {// ? Pixmap pixmap = new Pixmap((int) size.getX(), (int) size.getY(), Format.RGBA8888); pixmap.setColor(editor.getColor(widget.getSingleColor(), widget.getBackColorAlpha())); pixmap.fill(); Drawable d = new TextureRegionDrawable(new TextureRegion(new Texture(pixmap))); table.setBackground(d); pixmap.dispose(); } if (widget.getFileData() != null) {// Panel?!!. Drawable tr = editor.findDrawable(widget, widget.getFileData()); if (tr != null) { Image bg = new Image(tr); bg.setPosition((size.getX() - bg.getWidth()) / 2, (size.getY() - bg.getHeight()) / 2); // bg.setFillParent(true); bg.setTouchable(Touchable.disabled); table.addActor(bg); } } table.setClip(widget.isClipAble()); return table; } }