Hi, im always glad to share my stuff, lol, just copy this classes and let me know if theres any problem. i think you have to change the imports because i have them in different folders.
And maybe i lied a little, theres 9 classes to make the JoystickPanel to work and 6 more classes for the AnalogSliderPanel, ill share first the JoystickPanel because of the limit of the text here
here is the JoystickPanel class
package com.Capuchin.Panels;
import com.Capuchin.Layouts.JoystickLayout;
import com.Capuchin.Listeners.DragListener;
import com.Capuchin.Listeners.JoystickListener;
import com.Capuchin.Listeners.Move;
import com.jme3.math.Vector2f;
import com.simsilica.lemur.event.CursorEventControl;
import com.simsilica.lemur.style.ElementId;
/**
*
* @author Pankey
*/
public class JoystickPanel extends DropPanel{
public static final String ELEMENT_ID = "joystick";
public static final String STICK_ELEMENT_ID = "stick";
protected StickPanel AnalogStick ;
protected DragListener listener ;
protected static int s = 0 ;
protected Move move;
protected float stickPos=0;
public JoystickPanel(String style) {
this(null,Move.All,false,new ElementId(ELEMENT_ID),style);
}
public JoystickPanel(Move move,String style) {
this(null,move,false,new ElementId(ELEMENT_ID),style);
}
public JoystickPanel(String name, String style) {
this(null,Move.All,false,new ElementId(ELEMENT_ID), style);
}
public JoystickPanel( boolean behind,String style) {
this(null,Move.All,behind,new ElementId(ELEMENT_ID),style);
}
public JoystickPanel(Move move, boolean behind,String style) {
this(null,move,behind,new ElementId(ELEMENT_ID),style);
}
public JoystickPanel(String name, boolean behind,String style) {
this(null,Move.All,behind,new ElementId(ELEMENT_ID), style);
}
public JoystickPanel(String name,Move move, boolean behind,ElementId elementid, String style) {
super(true,elementid,style);
if(name == null){
this.setName("JoystickPanel"+String.valueOf(s));
s++;
}else{
this.setName(name);
}
this.move =move;
this.AnalogStick = new StickPanel(elementid.child(STICK_ELEMENT_ID),style);
this.AnalogStick.setName("analogstick");
JoystickListener jcol = new JoystickListener(this.move,this.AnalogStick,behind);
CursorEventControl.addListenersToSpatial(this, jcol);
this.listener = jcol;
setLayout(new JoystickLayout());
this.addChild(this.AnalogStick,"buttonAnalogSlider");
this.AnalogStick.setAlpha(0);
}
public void removeListener() {
CursorEventControl.removeListenersFromSpatial(this, this.listener);
}
public StickPanel getJoystick() {
return this.AnalogStick;
}
public boolean isDragging() {
return this.listener.isDragging();
}
public Vector2f getDragLocalTranslation() {
return this.listener.getDragLocalTranslation();
}
}
here is the JoystickLayout class
package com.Capuchin.Layouts;
import com.Capuchin.Panels.StickPanel;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.simsilica.lemur.component.AbstractGuiComponent;
import com.simsilica.lemur.core.GuiLayout;
import java.util.Collection;
/**
*
* @author Pankey
*/
public class JoystickLayout extends AbstractGuiComponent
implements DragDropLayout, Cloneable{
private StickPanel StickContainer = null ;
public JoystickLayout(){
}
@Override
public void calculatePreferredSize(Vector3f size) {
}
@Override
public void reshape(Vector3f pos, Vector3f size) {
this.StickContainer.setGuiSize( this.StickContainer,this.StickContainer.getGuiSize() );
}
@Override
public <T extends Node> T addChild(T n, Object... constraints) {
if(constraints != null){
if(constraints.length > 0){
if(constraints[0] instanceof String){
String s = (String) constraints[0];
if(s.equals("buttonAnalogSlider")){
this.StickContainer= (StickPanel) n;
this.getNode().attachChild(n);
}
}
}
}
return n;
}
@Override
public void removeChild(Node n) {
}
@Override
public Collection<Node> getChildren() {
return null;
}
@Override
public void clearChildren() {
}
@Override
public GuiLayout clone() {
return new JoystickLayout();
}
@Override
public <T extends Node> T replaceChild(T t, Vector3f dropPosition, Object... os) {
return null;
}
}
here is the StickPanel class, this class is really small, and could have use a Panel class but i intend to write some styles for this later
package com.Capuchin.Panels;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.style.ElementId;
import com.simsilica.lemur.style.Styles;
/**
*
* @author Pankey
*/
public class StickPanel extends DropPanel{
public static final String ELEMENT_ID = "stick";
public StickPanel(ElementId elementId, String style){
this(true,elementId,style);
}
protected StickPanel(boolean applyStyles, ElementId elementId, String style){
super(false,elementId,style);
if( applyStyles ) {
Styles styles = GuiGlobals.getInstance().getStyles();
styles.applyStyles(this, elementId, style);
}
}
}
here is the DragListener interface
package com.Capuchin.Listeners;
import com.jme3.math.Vector2f;
import com.simsilica.lemur.Command;
import com.simsilica.lemur.event.CursorListener;
/**
*
* @author Pankey
*/
public interface DragListener<T extends DragListener> extends CursorListener{
public boolean isDragging();
public Vector2f getDragLocalTranslation();
public Vector2f getStartDragLocalTranslation();
public Vector2f getDragWorldTranslation();
public Vector2f getStartDragWorldTranslation();
public void addDraggCommand(Command<T> list);
}
here is the JoystickListener class
package com.Capuchin.Listeners;
import com.Capuchin.Panels.JoystickPanel;
import com.Capuchin.Panels.StickPanel;
import com.jme3.input.MouseInput;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Spatial;
import com.jme3.util.SafeArrayList;
import com.simsilica.lemur.Command;
import com.simsilica.lemur.event.CursorButtonEvent;
import com.simsilica.lemur.event.CursorMotionEvent;
/**
*
* @author Pankey
*/
public class JoystickListener implements DragListener<JoystickListener>{
private Vector2f drag = null;
private Vector2f draging = null;
private Vector3f basePosition;
private Vector2f current = null;
private Vector3f worldPosition;
private Move move;
private StickPanel stick;
private boolean behind=true;
public SafeArrayList<Command> onDraggCommand;
public JoystickListener(StickPanel stick, boolean behind) {
this(Move.All, stick,behind);
}
public JoystickListener(Move move,StickPanel stick, boolean behind) {
this.move = move;
this.stick = stick;
this.behind = behind;
this.onDraggCommand = new SafeArrayList<Command>(Command.class);
}
@Override
public boolean isDragging() {
return this.drag != null;
}
@Override
public Vector2f getStartDragLocalTranslation() {
return new Vector2f(basePosition.x , basePosition.y);
}
@Override
public Vector2f getDragWorldTranslation() {
return current;
}
@Override
public Vector2f getStartDragWorldTranslation() {
return drag;
}
@Override
public Vector2f getDragLocalTranslation() {
if(isDragging()){
return draging;
}
return new Vector2f();
}
public void setMove(Move move) {
this.move =move;
}
public Move getMove() {
return this.move;
}
protected void startDrag( CursorButtonEvent event, Spatial target, Spatial capture ) {
drag = new Vector2f(event.getX(), event.getY());
basePosition = stick.getLocalTranslation().clone();
worldPosition = capture.getWorldTranslation().clone();
event.setConsumed();
}
protected void endDrag( CursorButtonEvent event, Spatial target, Spatial capture ) {
drag = null;
basePosition = null;
worldPosition = null;
draging.set(0, 0);
this.stick.setAlpha(0);
}
@Override
public void cursorButtonEvent( CursorButtonEvent event, Spatial target, Spatial capture ) {
if( event.getButtonIndex() != MouseInput.BUTTON_LEFT )
return;
if( event.isPressed() ) {
startDrag(event, target, capture);
} else {
if( drag != null ) {
endDrag(event, target, capture);
}
}
}
@Override
public void cursorMoved( CursorMotionEvent event, Spatial target, Spatial capture ) {
if( drag == null || capture == null )
return;
JoystickPanel joyPanel;
if(capture instanceof JoystickPanel){
joyPanel = (JoystickPanel)capture;
}else{
return;
}
ViewPort vp = event.getViewPort();
Camera cam = vp.getCamera();
if( cam.isParallelProjection() || capture.getQueueBucket() == RenderQueue.Bucket.Gui ) {
current = new Vector2f(event.getX(), event.getY());
Vector2f delta = current.subtract(drag);
Vector2f stickextra = drag.subtract(this.worldPosition.x,this.worldPosition.y).subtract((joyPanel.getPreferredSize().x*this.stick.getGuiSize().x)/200, -(joyPanel.getPreferredSize().y*this.stick.getGuiSize().y)/200);
// Make sure if Z has changed that it is applied to base
basePosition.z = capture.getLocalTranslation().z;
if(this.move == Move.All){
draging=new Vector2f(delta.x, delta.y);
}
if(this.move == Move.Not){
draging=new Vector2f(-delta.x, -delta.y);
}
if(this.move == Move.X){
draging=new Vector2f(delta.x, 0);
}
if(this.move == Move.Y){
draging=new Vector2f(0, delta.y);
}
if(this.move == Move.NotX){
draging=new Vector2f(-delta.x, -delta.y);
}
if(this.move == Move.NotY){
draging=new Vector2f(0, -delta.y);
}
if(this.move == Move.MixXY){
draging=new Vector2f(delta.y, delta.x);
}
if(this.move == Move.MixNotXY){
draging=new Vector2f(-delta.y, -delta.x);
}
Vector3f baseP = null;
if(this.behind){
baseP = new Vector3f(this.draging.x+stickextra.x, this.draging.y+stickextra.y, -0.1f);
}else{
baseP = new Vector3f(this.draging.x+stickextra.x, this.draging.y+stickextra.y, 0.1f);
}
//Vector3f baseP = this.basePosition.add(this.draging.x, this.draging.y, -0.1f);
this.stick.setLocalTranslation(baseP);
this.stick.setAlpha(1);
}
}
@Override
public void cursorEntered(CursorMotionEvent event, Spatial target, Spatial capture) {
}
@Override
public void cursorExited(CursorMotionEvent event, Spatial target, Spatial capture) {
}
@Override
public void addDraggCommand(Command<JoystickListener> list) {
this.onDraggCommand.add(list);
}
public void loadDraggCommands() {
for(int x=0; x < this.onDraggCommand.size(); x++){
this.onDraggCommand.get(x).execute(this);
}
}
}
here is the Move enum class
package com.Capuchin.Listeners;
/**
*
* @author Pankey
*/
public enum Move {
All,
Not,
X,
Y,
Z,
NotX,
NotY,
NotZ,
MixXY,
MixNotXY;
}
here is the ScreenGuiUtils class
package com.Capuchin.Utils;
import com.jme3.app.Application;
import com.jme3.asset.AssetManager;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.math.Vector4f;
import com.jme3.system.AppSettings;
/**
*
* @author Pankey
*/
public class ScreenGuiUtils {
private final AppSettings settings;
private final AssetManager assets;
private static ScreenGuiUtils guiUtils = null;
public ScreenGuiUtils(Application app){
this.assets = app.getAssetManager();
this.settings = app.getContext().getSettings();
}
public static void initialize(Application app){
ScreenGuiUtils.guiUtils = new ScreenGuiUtils(app);
}
public static ScreenGuiUtils getScreenGuiUtils(){
if(ScreenGuiUtils.guiUtils == null){
return null;
}
return ScreenGuiUtils.guiUtils;
}
public Vector2f getScreenSize(){
return new Vector2f(settings.getWidth(),settings.getHeight());
}
public float QuadX(float x){
return setSize(new Vector2f(x,0)).getX();
}
public float QuadY(float y){
return setSize(new Vector2f(0,y)).getY();
}
public Vector3f setSize(float x,float y,float z){
return new Vector3f(QuadX(x),QuadY(y),z);
}
public Vector2f setSize(float x,float y){
return setSize(new Vector2f(x,y));
}
public Vector2f setSize(Vector2f vec){
return setSize(vec, 100);
}
public Vector2f setSize(Vector2f vec,float rel){
float x = ((settings.getWidth()/rel)*vec.getX());
float y = ((settings.getHeight()/rel)*vec.getY());
return new Vector2f(x,y);
}
public Vector2f setSize(float width,float height,float x,float y){
return this.setSize(width, height, new Vector2f(x,y),100);
}
public Vector2f setSize(float width,float height,Vector2f vec,float rel){
float x = ((width/rel)*vec.getX());
float y = ((height/rel)*vec.getY());
return new Vector2f(x,y);
}
public Vector3f setSize(float width,float height,float x,float y,float z){
return this.setSize(width, height, new Vector3f(x,y,z),100);
}
public Vector3f setSize(float width,float height,Vector3f vec,float rel){
return this.setSize(new Vector3f(width,height,1), vec, rel);
}
public Vector3f setSize(Vector3f vec){
return this.setSize(vec, 100);
}
public Vector3f setSize(Vector3f vec,float rel){
float x = ((settings.getWidth()/rel)*vec.getX());
float y = ((settings.getHeight()/rel)*vec.getY());
return new Vector3f(x,y,vec.z);
}
public Vector3f setSize(Vector3f size,Vector3f vec,float rel){
float x = ((size.x/rel)*vec.getX());
float y = ((size.y/rel)*vec.getY());
return new Vector3f(x,y,vec.z);
}
public Vector3f setLeftTopSize(float x,float y,float z){
return this.setLeftTopSize(settings.getWidth(), settings.getHeight(), new Vector3f(x,y,z),100);
}
public Vector3f setLeftTopSize(float width,float height,float x,float y,float z){
return this.setLeftTopSize(width, height, new Vector3f(x,y,z),100);
}
public Vector3f setLeftTopSize(float width,float height,Vector3f vec,float rel){
float x = ((width/rel)*vec.getX());
float y = ((height/rel)*vec.getY());
return new Vector3f(x,-y,vec.z);
}
public Vector3f setLeftTopSize(Vector3f size,Vector3f vec,float rel){
float x = ((size.x/rel)*vec.getX());
float y = ((size.y/rel)*vec.getY());
return new Vector3f(x,-y,vec.z);
}
public Vector3f setLeftTopSizeYFlip(Vector3f size,Vector3f vec,float rel){
float x = ((size.x/rel)*vec.getX());
float y = ((size.y/rel)*vec.getY());
return new Vector3f(x,y,vec.z);
}
public float setMiddlePosX(float x){
return setMiddlePos(new Vector3f(x,0,0),0,0,100).getX();
}
public float setMiddlePosY(float y){
return setMiddlePos(new Vector3f(0,y,0),0,0,100).getY();
}
public float setMiddlePosZ(float z){
return setMiddlePos(new Vector3f(0,0,z),0,0,100).getZ();
}
public Vector2f setMiddlePos(float x,float y){
return new Vector2f(setMiddlePosX(x),setMiddlePosY(y));
}
public Vector3f setMiddlePos(float x,float y,float z){
return setMiddlePos(new Vector3f(x,y,z),0,0,100);
}
public Vector3f setMiddlePos(float x,float y,float z,float width,float height){
return setMiddlePos(new Vector3f(x,y,z),width,height,100);
}
public Vector3f setMiddlePos(Vector3f vec){
return setMiddlePos(vec,0,0,100);
}
public Vector3f setMiddlePos(Vector3f vec,float width,float height){
return setMiddlePos(vec,width,height,100);
}
public Vector3f setMiddlePos(Vector3f vec,float width,float height,float rel){
float x = ((settings.getWidth()/2)-(width/2))+(((settings.getWidth()/2)/(rel))*vec.getX());
float y = ((settings.getHeight()/2)-(height/2))+(((settings.getHeight()/2)/(rel))*vec.getY());
return new Vector3f(x,y,vec.getZ());
}
public float setCenter_From_RawPosZ(float z){
return setCenter_From_RawPos(new Vector3f(0,0,z),0,0,100).getZ();
}
public float setCenter_From_RawPosY(float y){
return setCenter_From_RawPos(new Vector3f(0,y,0),0,0,100).getY();
}
public float setCenter_From_RawPosX(float x){
return setCenter_From_RawPos(new Vector3f(x,0,0),0,0,100).getX();
}
public Vector3f setCenter_From_RawPos(float x,float y,float z){
return setCenter_From_RawPos(new Vector3f(x,y,z),0,0,100);
}
public Vector3f setCenter_From_RawPos(Vector3f vec,float width,float height){
return setCenter_From_RawPos(vec,width,height,100);
}
public Vector3f setCenter_From_RawPos(Vector3f vec,float width,float height,float rel){
float x = (vec.getX()-((settings.getWidth()/2)-(width/2)))/((settings.getWidth()/2)/(rel));
float y = (vec.getY()-((settings.getHeight()/2)-(height/2)))/((settings.getHeight()/2)/(rel));
return new Vector3f(x,y,vec.getZ());
}
public float setLeftTopPosX(float x){
return setLeftTopPos(new Vector3f(x,0,0),0,0,100).getX();
}
public float setLeftTopPosY(float y){
return setLeftTopPos(new Vector3f(0,y,0),0,0,100).getY();
}
public float setLeftTopPosZ(float z){
return setLeftTopPos(new Vector3f(0,0,z),0,0,100).getZ();
}
public Vector2f setLeftTopPos(float x,float y){
return new Vector2f(setLeftTopPosX(x),setLeftTopPosY(y));
}
public Vector3f setLeftTopPos(float x,float y,float z){
return setLeftTopPos(new Vector3f(x,y,z),0,0,100);
}
public Vector3f setLeftTopPos(Vector3f vec){
return setLeftTopPos(vec,0,0,100);
}
public Vector3f setLeftTopPos(Vector3f vec,float width,float height){
return setLeftTopPos(vec,width,height,100);
}
public Vector3f setLeftTopPos(Vector3f vec,float width,float height,float rel){
float x = -(width/2) + (((settings.getWidth())/(rel))*vec.getX());
float y = ((settings.getHeight())-(height/2))-(((settings.getHeight())/(rel))*vec.getY());
return new Vector3f(x,y,vec.getZ());
}
public float setLeftTop_From_RawPosZ(float z){
return setLeftTop_From_RawPos(new Vector3f(0,0,z),0,0,100).getZ();
}
public float setLeftTop_From_RawPosY(float y){
return setLeftTop_From_RawPos(new Vector3f(0,y,0),0,0,100).getY();
}
public float setLeftTop_From_RawPosX(float x){
return setLeftTop_From_RawPos(new Vector3f(x,0,0),0,0,100).getX();
}
public Vector3f setLeftTop_From_RawPos(float x,float y,float z){
return setLeftTop_From_RawPos(new Vector3f(x,y,z),0,0,100);
}
public Vector3f setLeftTop_From_RawPos(Vector3f vec,float width,float height){
return setLeftTop_From_RawPos(vec,width,height,100);
}
public Vector3f setLeftTop_From_RawPos(Vector3f vec,float width,float height,float rel){
float x = (vec.getX()-(-(width/2)))/((settings.getWidth())/(rel));
float y = (vec.getY()-((settings.getHeight())-(height/2)))/((settings.getHeight())/(rel));
return new Vector3f(x,y,vec.getZ());
}
public boolean isInsideViewPort(Vector4f viewport , Vector2f cursor){
return ( viewport.x <= cursor.x ) &&
( viewport.y >= cursor.x ) &&
( viewport.z <= cursor.y ) &&
( viewport.w >= cursor.y );
}
public boolean isViewPorFullSize(Vector4f viewport){
return viewport.x==0.00f &&
viewport.y==1.00f &&
viewport.z==0.00f &&
viewport.w==1.00f;
}
public Vector2f getViewPortPosition(Vector2f cursor){
float x = cursor.getX()/settings.getWidth();
float y = cursor.getY()/settings.getHeight();
return new Vector2f(x,y);
}
public AppSettings getSettings(){
return settings;
}
public int getScreenHeight(){
return settings.getHeight();
}
public int getScreenWidth(){
return settings.getWidth();
}
}
here is the DropPanel class
package com.Capuchin.Panels;
import com.Capuchin.Layouts.DragDropLayout;
import com.Capuchin.Utils.ScreenGuiUtils;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.Panel;
import com.simsilica.lemur.core.GuiControl;
import com.simsilica.lemur.style.ElementId;
import com.simsilica.lemur.style.StyleAttribute;
import com.simsilica.lemur.style.Styles;
/**
*
* @author Pankey
*/
public class DropPanel extends Panel{
protected Vector3f guiSize;
protected Vector3f guiTranslation;
public static final String ELEMENT_ID = "droppanel";
protected DropPanel(boolean applyStyles, ElementId elementId, String style){
super(false,elementId,style);
if( applyStyles ) {
Styles styles = GuiGlobals.getInstance().getStyles();
styles.applyStyles(this, elementId, style);
}
}
public <T extends Node> T addChild( T child, Object... constraints ) {
return getLayout().addChild(child, constraints);
}
public void removeChild( Node child ) {
getLayout().removeChild(child);
}
public void clearChildren() {
getLayout().clearChildren();
}
@Override
public Spatial detachChildAt( int index ) {
Spatial child = getChild(index);
// See if this child is managed by the layout
if( child instanceof Node && getLayout().getChildren().contains((Node)child) ) {
removeChild((Node)child);
return child;
} else {
// Just let the superclass do its thing with the
// unmanaged child
return super.detachChildAt(index);
}
}
public void setLayout( DragDropLayout layout ) {
getControl(GuiControl.class).setLayout(layout);
}
public DragDropLayout getLayout() {
return getControl(GuiControl.class).getLayout();
}
public void setGuiTranslation(Node object,Vector3f localTranslation) {
if(ScreenGuiUtils.getScreenGuiUtils() == null){
return;
}
if(object.getParent() != null){
if(object.getParent() instanceof Panel){
Vector3f size = ((Panel)object.getParent()).getPreferredSize().clone();
if(size==null){
object.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(localTranslation));
}else{
if(size.equals(Vector3f.ZERO)){
object.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(localTranslation));
}else{
//System.out.println(size);
//System.out.println(ScreenGuiUtils.getScreenGuiUtils().setLeftTopSize(size,localTranslation,100));
object.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopSize(size,localTranslation,100));
}
}
}else{
object.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(localTranslation));
}
}else{
object.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(localTranslation));
}
}
public void setLocalGuiTranslation(float x,float y,float z) {
if(ScreenGuiUtils.getScreenGuiUtils() == null){
return;
}
if(this.parent != null){
if(this.parent instanceof Panel){
Vector3f size = ((Panel)this.parent).getPreferredSize().clone();
if(size==null){
this.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(x,y,z));
}else{
if(size.equals(Vector3f.ZERO)){
this.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(x,y,z));
}else{
this.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopSize(size.x,size.y,x,y,z));
}
}
}else{
this.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(x,y,z));
}
}else{
this.setLocalTranslation(ScreenGuiUtils.getScreenGuiUtils().setLeftTopPos(x,y,z));
}
}
@StyleAttribute(value="guiTranslation", lookupDefault=false)
public void setLocalGuiTranslation(Vector3f localTranslation) {
this.guiTranslation = localTranslation;
this.setGuiTranslation(this, localTranslation);
}
public Vector3f getLocalGuiTranslation(){
return this.guiTranslation;
}
@Override
@StyleAttribute(value="localTranslation", lookupDefault=false)
public void setLocalTranslation(Vector3f localTranslation) {
super.setLocalTranslation(localTranslation);
}
public void setGuiSize(Panel object,Vector3f size) {
if(ScreenGuiUtils.getScreenGuiUtils() == null){
return;
}
if(this.parent != null){
if(this.parent instanceof Panel){
Vector3f parentsize = ((Panel)object.getParent()).getSize().clone();
if(parentsize==null){
object.setSize(ScreenGuiUtils.getScreenGuiUtils().setSize(size,100));
}else{
object.setSize(ScreenGuiUtils.getScreenGuiUtils().setSize(parentsize,size,100));
}
}else{
object.setSize(ScreenGuiUtils.getScreenGuiUtils().setSize(size,100));
}
}else{
object.setPreferredSize(ScreenGuiUtils.getScreenGuiUtils().setSize(size,100));
}
}
@StyleAttribute(value="guiSize", lookupDefault=false)
public void setLocalGuiSize(Vector3f size) {
this.guiSize = size;
this.setGuiSize(this,size);
}
public Vector3f getGuiSize() {
return this.guiSize;
}
public <T extends Node> T replaceChild(T child,Vector3f localTranslation, Object... os) {
return this.getLayout().replaceChild(child, localTranslation, os);
}
@Override
public String toString() {
return getClass().getName() + "[layout=" + getLayout() + ", elementId=" + getElementId() + "]";
}
}
here is the DragDropLayout class
package com.Capuchin.Layouts;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.simsilica.lemur.core.GuiLayout;
/**
*
* @author Pankey
*/
public interface DragDropLayout extends GuiLayout{
public <T extends Node> T replaceChild(T t,Vector3f dropPosition, Object... os);
}