Class Panel

All Implemented Interfaces:
HasLocalTransform, CloneableSmartAsset, Collidable, Savable, JmeCloneable, Cloneable
Direct Known Subclasses:
ColorChooser, Container, GridPanel, Label, ListBox, NLoadingSpinner, NVSpacer, OptionPanel, ProgressBar, RollupPanel, Selector, Slider, Spinner, TabbedPanel, TextField

public class Panel extends Node
A panel is the most basic GUI element consisting only of a background and insets. This is a convenient base class for every other GUI element as it sets up the proper relationships between Node, a GuiControl, and style attributes.

"Panels" are often thought about in 2D terms but the Lemur default Panel is not limited to 2D. It's behavior depends entirely on the background component, which could be a simple 2D quad using a QuadComponent or something more complicated that is fully 3D.

By default, Lemur GUI elements are setup so that their local translation determines the position of their top-left corner in x/y space. In other words, the y-axis acts a little differently than other axes in that it grows down instead of up. Within an element, the coordinate system is still the standard JME coordinate system. It's just how the elements are are arranged relative to their own local translation that is different. This makes multi-element layouts more sensible or consistent with other GUI libraries.

Note: the layout code currently assumes that rotation and scale are their default values.

  • Field Details

  • Constructor Details

    • Panel

      public Panel()
    • Panel

      public Panel(String style)
    • Panel

      public Panel(ElementId elementId)
    • Panel

      public Panel(ElementId elementId, String style)
    • Panel

      public Panel(float width, float height)
    • Panel

      public Panel(float width, float height, ElementId elementId, String style)
    • Panel

      public Panel(float width, float height, ColorRGBA backgroundColor)
    • Panel

      public Panel(float width, float height, ColorRGBA backgroundColor, String style)
    • Panel

      public Panel(float width, float height, String style)
    • Panel

      protected Panel(boolean applyStyles, float width, float height, ElementId elementId, String style)
    • Panel

      protected Panel(boolean applyStyles, ElementId elementId, String style)
      This is the constructure that subclasses should call as it allows them to bypass the default style application and apply styles themselves. In many cases, the default style processing will be fine but occasionally the subclasses may need to do some processing before style application. For example, if constructor paramaters will setup some components that a style would also define then it can create needless churn during construction if the styles are applied first. (Note: in reality, currently existing values are not checked during style application even though the design is that they should be. A solution for primitive values is still needed for this to work. FIXME) Subclasses that also want to be extension-friendly should consider providing a similar protected constructor.
  • Method Details

    • getElementId

      public ElementId getElementId()
    • getStyle

      public String getStyle()
    • setSize

      public void setSize(Vector3f size)
    • getSize

      public Vector3f getSize()
    • setPreferredSize

      @StyleAttribute(value="preferredSize", lookupDefault=false) public void setPreferredSize(Vector3f size)
    • getPreferredSize

      public Vector3f getPreferredSize()
    • addMouseListener

      public void addMouseListener(MouseListener l)
    • removeMouseListener

      public void removeMouseListener(MouseListener l)
    • initializeDefaultStyles

      public static void initializeDefaultStyles(Attributes attrs)
    • setBackground

      @StyleAttribute(value="background", lookupDefault=false) public void setBackground(GuiComponent bg)
    • getBackground

      public GuiComponent getBackground()
    • setBorder

      @StyleAttribute(value="border", lookupDefault=false) public void setBorder(GuiComponent bg)
    • getBorder

      public GuiComponent getBorder()
    • setInsets

      @StyleAttribute(value="insets", lookupDefault=false) public void setInsets(Insets3f i)
    • getInsets

      public Insets3f getInsets()
    • setInsetsComponent

      @StyleAttribute(value="insetsComponent", lookupDefault=false) public void setInsetsComponent(InsetsComponent ic)
    • getInsetsComponent

      public InsetsComponent getInsetsComponent()
    • setAlpha

      @StyleAttribute(value="alpha", lookupDefault=false) public void setAlpha(float alpha)
      Sets the alpha multiplier for all ColoredComponents in this panels component stack, including things like QuadBackgroundComponent, TextComponent, etc.. This can be used to generally fade a GUI element in or out as needed as long as its visuals are ColoredComponent compliant.
    • setAlpha

      public void setAlpha(float alpha, boolean recursive)
      Sets the alpha multiplier for all ColoredComponents in this panels component stack, including things like QuadBackgroundComponent, TextComponent, etc.. This can be used to generally fade a GUI element in or out as needed as long as its visuals are ColoredComponent compliant. If recursive is true then all child Spatials will also be checked and have their alpha set, and their children, and so on.
    • setChildAlpha

      protected void setChildAlpha(Spatial child, float alpha)
    • getAlpha

      public float getAlpha()
      Returns an estimate of the current alpha multiplier for the child components. It scans the component children and returns the first alpha value found.
    • getEffectControl

      protected EffectControl<Panel> getEffectControl()
      Provides convenient access to the EffectControl... that also hides the Java-generic voodoo necessary to get it without an unchecked warning.
    • runEffect

      public boolean runEffect(String effectName)
      Runs the specified effect if configured for this GUI element. If the effect referenced is on a channel that already has a running effect then that effect will be canceled and the new effect will be fastforwarded proportionally. This is to help facilitate reciprocal effects like open/close or activate/deactivate the undo one another and therefore if the previous effect is still running there may be less to do. This logic only happens if the effect has specified a channel. Otherwise all effects are run independently.
      Returns:
      True if the effect existed and was run. False if no effect was found.
    • addEffect

      public void addEffect(String effectName, Effect<? super Panel> effect)
      Adds the specified effect to this GUI element. Later calls to runEffect() will then be able to execute this effect.
    • removeEffect

      public Effect<? super Panel> removeEffect(String effectName)
      Removes a previously registered effect if it exists. Returns the removed effect if it existed.
    • hasEffect

      public boolean hasEffect(String effectName)
      Returns true if this GUI element has the specified effect configured.
    • setEffects

      @StyleAttribute(value="effects", lookupDefault=false) public void setEffects(Map<String,Effect<? super Panel>> map)
      Adds multiple effects at once through a stylable attribute.
    • getEffects

      public Map<String,Effect<? super Panel>> getEffects()
      Returns a read-only view of the entire map of effects for this GUI element.
    • toString

      public String toString()
      Description copied from class: Spatial
      Returns the Spatial's name followed by the class of the spatial
      Example: "MyNode (com.jme3.scene.Spatial)"
      Overrides:
      toString in class Spatial
      Returns:
      Spatial's name followed by the class of the Spatial