Package com.ardor3d.extension.ui

Examples of com.ardor3d.extension.ui.UIPanel


                true);
        ts.setTexture(tex);
        box.setRenderState(ts);
        _root.attachChild(box);

        final UIPanel panel = makeWidgetPanel();

        final UIPanel panel2 = makeLoginPanel();

        final UIPanel panel3 = makeChatPanel();

        final UIPanel panel4 = makeClockPanel();

        final UIPanel panel5 = makeScrollPanel();

        final UITabbedPane pane = new UITabbedPane(TabPlacement.NORTH);
        pane.add(panel, "widgets");
        pane.add(panel2, "grid");
        pane.add(panel3, "chat");
View Full Code Here


        hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
        hud.setMouseManager(_mouseManager);
    }

    private UIPanel makeLoginPanel() {
        final UIPanel pLogin = new UIPanel(new GridLayout());
        final UILabel lHeader = new UILabel("Welcome! Log in to server xyz");
        lHeader.setLayoutData(new GridLayoutData(2, true, true));
        final UILabel lName = new UILabel("Name");
        final UITextField tfName = new UITextField();
        tfName.setText("player1");
        tfName.setLayoutData(GridLayoutData.WrapAndGrow);
        final UILabel lPassword = new UILabel("Password");
        final UIPasswordField tfPassword = new UIPasswordField();
        tfPassword.setLayoutData(GridLayoutData.WrapAndGrow);
        final UIButton btLogin = new UIButton("login");
        btLogin.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                System.out.println("login as user: " + tfName.getText() + " password: " + tfPassword.getText());
            }
        });
        pLogin.add(lHeader);
        pLogin.add(lName);
        pLogin.add(tfName);
        pLogin.add(lPassword);
        pLogin.add(tfPassword);
        pLogin.add(btLogin);
        return pLogin;
    }
View Full Code Here

        pLogin.add(btLogin);
        return pLogin;
    }

    private UIPanel makeChatPanel() {
        final UIPanel chatPanel = new UIPanel(new BorderLayout());
        final UIPanel bottomPanel = new UIPanel(new BorderLayout());
        bottomPanel.setLayoutData(BorderLayoutData.SOUTH);
        final UILabel dirLabel = new UILabel("Sample chat.  Try using markup like [b]text[/b]:");
        dirLabel.setLayoutData(BorderLayoutData.NORTH);
        final UITextArea historyArea = new UITextArea();
        historyArea.setStyledText(true);
        historyArea.setAlignment(Alignment.BOTTOM_LEFT);
        historyArea.setEditable(false);
        final UIScrollPanel scrollArea = new UIScrollPanel(historyArea);
        scrollArea.setLayoutData(BorderLayoutData.CENTER);
        final UITextField chatField = new UITextField();
        chatField.setLayoutData(BorderLayoutData.CENTER);
        final UIButton chatButton = new UIButton("SAY");
        chatButton.setLayoutData(BorderLayoutData.EAST);

        final ActionListener actionListener = new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                applyChat(historyArea, chatField);
            }
        };
        chatButton.addActionListener(actionListener);
        chatField.addActionListener(actionListener);

        bottomPanel.add(chatField);
        bottomPanel.add(chatButton);

        chatPanel.add(dirLabel);
        chatPanel.add(scrollArea);
        chatPanel.add(bottomPanel);
        return chatPanel;
View Full Code Here

        }
    }

    private UIPanel makeWidgetPanel() {

        final UIPanel panel = new UIPanel();
        panel.setForegroundColor(ColorRGBA.DARK_GRAY);
        panel.setLayout(new BorderLayout());

        final UIButton button = new UIButton("Button A");
        final Texture tex = TextureManager.load("images/ardor3d_white_256.jpg", Texture.MinificationFilter.Trilinear,
                false);
        button.setIcon(new SubTex(tex));
        button.setIconDimensions(new Dimension(26, 26));
        button.setGap(10);
        button.setLayoutData(BorderLayoutData.NORTH);
        button.setTooltipText("This is a tooltip!");
        panel.add(button);

        final RowLayout rowLay = new RowLayout(false, false, false);
        final UIPanel centerPanel = new UIPanel(rowLay);
        centerPanel.setLayoutData(BorderLayoutData.CENTER);
        panel.add(centerPanel);

        final UICheckBox check1 = new UICheckBox("Hello\n(disabled)");
        check1.setSelected(true);
        check1.setEnabled(false);
        centerPanel.add(check1);
        final UICheckBox check2 = new UICheckBox("World");
        centerPanel.add(check2);

        final ButtonGroup group = new ButtonGroup();
        final UIRadioButton radio1 = new UIRadioButton();
        radio1.setButtonText("option [i]A[/i]", true);
        radio1.setGroup(group);
        centerPanel.add(radio1);
        final UIRadioButton radio2 = new UIRadioButton();
        radio2.setButtonText("option [c=#f00]B[/c]", true);
        radio2.setGroup(group);
        centerPanel.add(radio2);

        final UISlider slider = new UISlider(Orientation.Horizontal, 0, 12, 0);
        slider.setSnapToValues(true);
        slider.setMinimumContentWidth(100);

        final UILabel lSliderValue = new UILabel("0");
        lSliderValue.setLayoutData(GridLayoutData.SpanAndWrap(2));
        slider.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                lSliderValue.setText(String.valueOf(slider.getValue()));
            }
        });
        centerPanel.add(slider);
        centerPanel.add(lSliderValue);

        final UIComboBox combo = new UIComboBox(new DefaultComboBoxModel("alpha", "beta", "gamma", "delta"));
        combo.setLocalComponentWidth(120);
        combo.addSelectionListener(new SelectionListener<UIComboBox>() {
            @Override
            public void selectionChanged(final UIComboBox component, final Object newValue) {
                System.out.println("New combo value: " + newValue);
            }
        });
        centerPanel.add(combo);

        final UIProgressBar bar = new UIProgressBar("Loading: ", true);
        bar.setPercentFilled(0);
        bar.setLocalComponentWidth(250);
        bar.setMaximumContentWidth(bar.getContentWidth());
        bar.addController(new SpatialController<UIProgressBar>() {
            @Override
            public void update(final double time, final UIProgressBar caller) {
                caller.setPercentFilled(_timer.getTimeInSeconds() / 15);
            }
        });
        centerPanel.add(bar);
        return panel;
    }
View Full Code Here

        centerPanel.add(bar);
        return panel;
    }

    private UIPanel makeClockPanel() {
        final UIPanel clockPanel = new UIPanel();
        final MultiImageBackdrop multiImgBD = new MultiImageBackdrop(ColorRGBA.BLACK_NO_ALPHA);
        clockPanel.setBackdrop(multiImgBD);

        final Texture clockTex = TextureManager.load("images/clock.png", Texture.MinificationFilter.Trilinear, false);

        final TransformedSubTex clockBack = new TransformedSubTex(new SubTex(clockTex, 64, 65, 446, 446));

        final double scale = .333;
        clockBack.setPivot(new Vector2(.5, .5));
        clockBack.getTransform().setScale(scale);
        clockBack.setAlignment(Alignment.MIDDLE);
        clockBack.setPriority(0);
        multiImgBD.addImage(clockBack);

        final TransformedSubTex hour = new TransformedSubTex(new SubTex(clockTex, 27, 386, 27, 126));
        hour.setPivot(new Vector2(.5, 14 / 126f));
        hour.getTransform().setScale(scale);
        hour.setAlignment(Alignment.MIDDLE);
        hour.setPriority(1);
        multiImgBD.addImage(hour);

        final TransformedSubTex minute = new TransformedSubTex(new SubTex(clockTex, 0, 338, 27, 174));
        minute.setPivot(new Vector2(.5, 14 / 174f));
        minute.getTransform().setScale(scale);
        minute.setAlignment(Alignment.MIDDLE);
        minute.setPriority(2);
        multiImgBD.addImage(minute);

        clockPanel.addController(new SpatialController<Spatial>() {
            public void update(final double time, final Spatial caller) {
                final double angle1 = _timer.getTimeInSeconds() % MathUtils.TWO_PI;
                final double angle2 = (_timer.getTimeInSeconds() / 12.) % MathUtils.TWO_PI;

                minute.getTransform().setRotation(new Quaternion().fromAngleAxis(angle1, Vector3.NEG_UNIT_Z));
                hour.getTransform().setRotation(new Quaternion().fromAngleAxis(angle2, Vector3.NEG_UNIT_Z));
                clockPanel.fireComponentDirty();
            };
        });

        return clockPanel;
    }
View Full Code Here

    protected void initExample() {
        _canvas.setTitle("Rotating UI Example");

        UIComponent.setUseTransparency(true);

        final UIPanel panel = makePanel();

        final UIFrame frame = new UIFrame("Sample");
        frame.setContentPanel(panel);
        frame.updateMinimumSizeFromContents();
        frame.layout();
View Full Code Here

        frame.setLocationRelativeTo(_canvas.getCanvasRenderer().getCamera());
    }

    private UIPanel makePanel() {

        final UIPanel panel = new UIPanel();
        panel.setForegroundColor(ColorRGBA.DARK_GRAY);
        panel.setLayout(new RowLayout(true));

        final UILabel staticLabel = new UILabel("Hello World");
        staticLabel.setBackdrop(new SolidBackdrop(ColorRGBA.CYAN));
        staticLabel.setLayoutData(BorderLayoutData.CENTER);
        panel.add(staticLabel);

        final UICheckBox rotatingLabel = new UICheckBox("Look at me! :)");
        rotatingLabel.setBackdrop(new SolidBackdrop(ColorRGBA.GREEN));
        rotatingLabel.setRotation(new Matrix3().fromAngleNormalAxis(45 * MathUtils.DEG_TO_RAD, new Vector3(0, 0, 1)));
        panel.add(rotatingLabel);

        final Matrix3 rotate = new Matrix3();
        final Vector3 axis = new Vector3(0, 0, 1);
        rotatingLabel.addController(new SpatialController<UICheckBox>() {
            double angle = 0;

            public void update(final double time, final UICheckBox caller) {
                angle += time * 10;
                angle %= 360;
                rotate.fromAngleNormalAxis(angle * MathUtils.DEG_TO_RAD, axis);
                caller.setRotation(rotate);
                caller.fireComponentDirty();
                panel.layout();
            }
        });
        rotatingLabel.setLayoutData(BorderLayoutData.NORTH);

        return panel;
View Full Code Here

                moveLight = rotateLight.isSelected();
                updateText();
            }
        });

        final UIPanel panel = new UIPanel(new RowLayout(false, true, false));
        panel.setPadding(new Insets(10, 20, 10, 20));
        panel.add(distLabel);
        panel.add(distSlider);
        panel.add(updateCamera);
        panel.add(rotateLight);

        frame.setContentPanel(panel);
        frame.pack();
        final Camera cam = _canvas.getCanvasRenderer().getCamera();
        frame.setLocalXY(cam.getWidth() - frame.getLocalComponentWidth(),
View Full Code Here

        frameRateLabel.setForegroundColor(ColorRGBA.WHITE);
        hud.add(frameRateLabel);

        final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));

        final UIPanel basePanel = optionsFrame.getContentPanel();
        basePanel.setLayout(new AnchorLayout());

        runWalkButton = new UIButton("Start running...");
        runWalkButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
        runWalkButton.addActionListener(new ActionListener() {
            boolean walk = true;

            public void actionPerformed(final ActionEvent event) {
                if (!walk) {
                    if (manager.getBaseAnimationLayer().doTransition("walk")) {
                        runWalkButton.setButtonText("Start running...");
                        walk = true;
                    }
                } else {
                    if (manager.getBaseAnimationLayer().doTransition("run")) {
                        runWalkButton.setButtonText("Start walking...");
                        walk = false;
                    }
                }
            }
        });
        basePanel.add(runWalkButton);

        punchButton = new UIButton("PUNCH!");
        punchButton
                .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
        punchButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                manager.findAnimationLayer("punch").setCurrentState("punch_right", true);
                punchButton.setEnabled(false);
            }
        });
        basePanel.add(punchButton);

        headCheck = new UICheckBox("Procedurally turn head");
        headCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, punchButton, Alignment.BOTTOM_LEFT, 0, -5));
        headCheck.setSelected(true);
        headCheck.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent event) {
                manager.getValuesStore().put("head_blend", headCheck.isSelected() ? 1.0 : 0.0);
            }
        });
        basePanel.add(headCheck);

        final UICheckBox gpuSkinningCheck = new UICheckBox("Use GPU skinning");
        gpuSkinningCheck
                .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, headCheck, Alignment.BOTTOM_LEFT, 0, -5));
        gpuSkinningCheck.setSelected(false);
        gpuSkinningCheck.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                _root.acceptVisitor(new Visitor() {
                    @Override
                    public void visit(final Spatial spatial) {
                        if (spatial instanceof SkinnedMesh) {
                            final SkinnedMesh skinnedSpatial = (SkinnedMesh) spatial;
                            if (gpuSkinningCheck.isSelected()) {
                                skinnedSpatial.setGPUShader(gpuShader);
                                skinnedSpatial.setUseGPU(true);
                            } else {
                                skinnedSpatial.setGPUShader(null);
                                skinnedSpatial.clearRenderState(StateType.GLSLShader);
                                skinnedSpatial.setUseGPU(false);
                            }
                        }
                    }
                }, true);
            }
        });
        basePanel.add(gpuSkinningCheck);

        final UICheckBox vboCheck = new UICheckBox("Use VBO");
        vboCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, gpuSkinningCheck, Alignment.BOTTOM_LEFT, 0, -5));
        vboCheck.setSelected(false);
        vboCheck.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                skNode.getSceneHints().setDataMode(vboCheck.isSelected() ? DataMode.VBO : DataMode.Arrays);
                gpuShader.setUseAttributeVBO(vboCheck.isSelected());
            }
        });
        basePanel.add(vboCheck);

        final UICheckBox skeletonCheck = new UICheckBox("Show skeleton");
        final UICheckBox boneLabelCheck = new UICheckBox("Show joint labels");
        skeletonCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, vboCheck, Alignment.BOTTOM_LEFT, 0, -5));
        skeletonCheck.setSelected(showSkeleton);
        skeletonCheck.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent event) {
                showSkeleton = skeletonCheck.isSelected();
                boneLabelCheck.setEnabled(showSkeleton);
            }
        });
        basePanel.add(skeletonCheck);

        boneLabelCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, skeletonCheck, Alignment.BOTTOM_LEFT, 0,
                -5));
        boneLabelCheck.setSelected(false);
        boneLabelCheck.setEnabled(showSkeleton);
        boneLabelCheck.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent event) {
                showJointLabels = boneLabelCheck.isSelected();
            }
        });
        basePanel.add(boneLabelCheck);

        optionsFrame.updateMinimumSizeFromContents();
        optionsFrame.layout();
        optionsFrame.pack();
View Full Code Here

        frameRateLabel.setForegroundColor(ColorRGBA.WHITE);
        hud.add(frameRateLabel);

        final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));

        final UIPanel basePanel = optionsFrame.getContentPanel();
        basePanel.setLayout(new AnchorLayout());

        final UIButton loadSceneButton = new UIButton("Load next scene");
        loadSceneButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
        loadSceneButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                final File file = daeFiles.get(fileIndex);
                try {
                    loadColladaModel(new URLResourceSource(file.toURI().toURL()));
                    t1.setText(file.getName());
                } catch (final MalformedURLException e) {
                    e.printStackTrace();
                }
                fileIndex = (fileIndex + 1) % daeFiles.size();
            }
        });
        basePanel.add(loadSceneButton);

        final UICheckBox skinCheck = new UICheckBox("Show skin mesh");
        skinCheck
                .setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, loadSceneButton, Alignment.BOTTOM_LEFT, 0, -5));
        skinCheck.setSelected(true);
        skinCheck.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                colladaNode.getSceneHints().setCullHint(skinCheck.isSelected() ? CullHint.Dynamic : CullHint.Always);
            }
        });
        basePanel.add(skinCheck);

        final UICheckBox skeletonCheck = new UICheckBox("Show skeleton");
        final UICheckBox boneLabelCheck = new UICheckBox("Show joint labels");
        skeletonCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, skinCheck, Alignment.BOTTOM_LEFT, 0, -5));
        skeletonCheck.setSelected(showSkeleton);
        skeletonCheck.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                showSkeleton = skeletonCheck.isSelected();
                boneLabelCheck.setEnabled(showSkeleton);
            }
        });
        basePanel.add(skeletonCheck);

        boneLabelCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, skeletonCheck, Alignment.BOTTOM_LEFT, 0,
                -5));
        boneLabelCheck.setSelected(false);
        boneLabelCheck.setEnabled(showSkeleton);
        boneLabelCheck.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                showJointLabels = boneLabelCheck.isSelected();
            }
        });
        basePanel.add(boneLabelCheck);

        optionsFrame.updateMinimumSizeFromContents();
        optionsFrame.layout();
        optionsFrame.pack();
View Full Code Here

TOP

Related Classes of com.ardor3d.extension.ui.UIPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.