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

            }
        }

        // BASE PANEL
        {
            final UIPanel base = component.getBasePanel();

            base.setMargin(new Insets(0, 0, 0, 0));
            base.setPadding(new Insets(0, 0, 0, 0));

            final UIBorder border = new ImageBorder(
            // left
                    new SubTex(_sharedTex, 4, 17, 6, 29),
                    // right
                    new SubTex(_sharedTex, 30, 17, 6, 29),
                    // top
                    new SubTex(_sharedTex, 0, 0, 0, 0),
                    // bottom
                    new SubTex(_sharedTex, 10, 46, 20, 7),
                    // top left
                    null,
                    // top right
                    null,
                    // bottom left
                    new SubTex(_sharedTex, 4, 46, 6, 7),
                    // bottom right
                    new SubTex(_sharedTex, 30, 46, 6, 7));
            base.setBorder(border);
            final ColorRGBA top = new ColorRGBA(210 / 255f, 210 / 255f, 210 / 255f, 1);
            final ColorRGBA bottom = new ColorRGBA(244 / 255f, 244 / 255f, 244 / 255f, 1);
            final GradientBackdrop grad = new GradientBackdrop(top, top, bottom, bottom);
            base.setBackdrop(grad);
        }

        // STATUS BAR
        {
            final UIFrameStatusBar statusBar = component.getStatusBar();
View Full Code Here

        } else {
            knob.getKnobLabel().setIcon(new SubTex(_sharedTex, 69, 72, 14, 16));
            knob.setMargin(new Insets(1, 0, 1, 0));
        }

        final UIPanel back = component.getBackPanel();
        if (component.getOrientation() == Orientation.Horizontal) {
            final UIBorder border = new ImageBorder(
            // left
                    new SubTex(_sharedTex, 7, 85, 4, 7),
                    // right
                    new SubTex(_sharedTex, 33, 85, 4, 7),
                    // top
                    new SubTex(_sharedTex, 11, 79, 22, 6),
                    // bottom
                    new SubTex(_sharedTex, 11, 92, 22, 4),
                    // top left
                    new SubTex(_sharedTex, 7, 79, 4, 6),
                    // top right
                    new SubTex(_sharedTex, 33, 79, 4, 6),
                    // bottom left
                    new SubTex(_sharedTex, 7, 92, 4, 4),
                    // bottom right
                    new SubTex(_sharedTex, 33, 92, 4, 4));
            back.setBorder(border);
            back.setMinimumContentSize(1, 7);
        } else {
            final UIBorder border = new ImageBorder(
            // left
                    new SubTex(_sharedTex, 67, 97, 5, 19),
                    // right
                    new SubTex(_sharedTex, 80, 97, 5, 19),
                    // top
                    new SubTex(_sharedTex, 72, 91, 8, 6),
                    // bottom
                    new SubTex(_sharedTex, 72, 117, 8, 4),
                    // top left
                    new SubTex(_sharedTex, 67, 91, 5, 6),
                    // top right
                    new SubTex(_sharedTex, 80, 91, 5, 6),
                    // bottom left
                    new SubTex(_sharedTex, 67, 117, 5, 4),
                    // bottom right
                    new SubTex(_sharedTex, 80, 117, 5, 4));
            back.setBorder(border);
            back.setMinimumContentSize(8, 1);
        }
        back.setLayout(null);
        back.setBackdrop(new SolidBackdrop(ColorRGBA.WHITE));
    }
View Full Code Here

        hud = new UIHud();
        hud.setupInput(_canvas, _physicalLayer, _logicalLayer);

        // Set up the frames
        for (int i = 0; i < views.length; i++) {
            views[i] = new UIPanel();
            views[i].setLocalComponentSize(wside, hside);
            views[i].layout();
            hud.add(views[i]);
        }

        // Set up the panels
        for (int i = 0; i < COUNT; i++) {
            srcs[i] = new UIPanel(null) {
                @Override
                public boolean mousePressed(final com.ardor3d.input.MouseButton button,
                        final com.ardor3d.input.InputState state) {
                    if (zoom || this == zoomed) {
                        toggleZoom(this);
View Full Code Here

        }

        // ignore other clicks until we are done zooming...
        allowClicks = false;
        speed = 0;
        final UIPanel parent = ((UIPanel) uiPanel.getParent());

        if (zoom) {
            originX = parent.getHudX();
            originY = parent.getHudY();
            zoomed = uiPanel;
        } else {
            zoomed = null;
        }

        final int endY = 0, endX = (_canvas.getCanvasRenderer().getCamera().getWidth() - _canvas.getCanvasRenderer()
                .getCamera().getHeight()) / 2;

        // add an animator to do the zoom
        uiPanel.addController(new SpatialController<UIPanel>() {
            float ratio = zoom ? 0 : 1;
            float zSpeed = 1;

            public void update(final double time, final UIPanel caller) {
                // update ratio
                ratio += (zoom ? 1 : -1) * zSpeed * time;
                if (ratio >= 1.0f || ratio <= 0.0) {
                    if (ratio >= 1.0f) {
                        ratio = 1.0f;
                    } else {
                        ratio = 0;
                    }
                    zoom = !zoom;
                    caller.removeController(this);
                    allowClicks = true;
                }

                // use an scurve to smoothly zoom
                final float sCurve = MathUtils.scurve5(ratio);
                final float size = sCurve * (_canvas.getCanvasRenderer().getCamera().getHeight() - hside) + hside;
                parent.setLocalComponentSize((int) (size * hside / wside), (int) size);

                // use an scurve to smoothly shift origin
                parent.setHudXY(Math.round(MathUtils.lerp(sCurve, originX, endX)), Math.round(MathUtils.lerp(sCurve,
                        originY, endY)));

                parent.layout();
            }
        });
    }
View Full Code Here

                particleInWorld = worldCoordsCheck.isSelected();
                smoke.setParticlesInWorldCoords(particleInWorld);
            }
        });

        final UIPanel panel = new UIPanel(new RowLayout(false, true, false));
        panel.setPadding(new Insets(10, 20, 10, 20));
        panel.add(turnLabel);
        panel.add(turnSlider);
        panel.add(propelLabel);
        panel.add(propelSlider);
        panel.add(ageLabel);
        panel.add(ageSlider);
        panel.add(twoDimCheck);
        panel.add(worldCoordsCheck);

        frame.setContentPanel(panel);
        frame.pack();
        final Camera cam = _canvas.getCanvasRenderer().getCamera();
        frame.setLocalXY(cam.getWidth() - frame.getLocalComponentWidth(),
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.