Examples of HFlexBox


Examples of org.joshy.gfx.node.layout.HFlexBox

        public Iterable<Control> getControls() {
            List<Control> list = new ArrayList<Control>();

            if(propz.containsKey("text")) {
                HFlexBox text_row  = new HFlexBox();
                text_row.setBoxAlign(FlexBox.Align.Stretch);
                text_row.add(new Label("caption"));
                final Textbox tb = new Textbox((String) this.propz.get("text"));
                tb.onAction(new Callback<ActionEvent>() {
                    public void call(ActionEvent actionEvent) throws Exception {
                        propz.put("text",tb.getText());
                        context.redraw();
                    }
                });
                text_row.add(tb.setPrefWidth(100));
                list.add(text_row);
            }

            return list;
        }
View Full Code Here

Examples of org.joshy.gfx.node.layout.HFlexBox

                        }
                    }
                };
                popup.onClicked(clicked);
                dialog.setContent(new VFlexBox().add(
                        new HFlexBox().add(new Label("Preset:"),popup),
                        new HFlexBox().add(new Label("Width (px):"), width),
                        new HFlexBox().add(new Label("Height (px):"), height),
                        new HFlexBox().add(
                                new Button("Cancel")
                                    .onClicked(canceled),
                                new Button("Okay")
                                        .onClicked(okay))
                ));
View Full Code Here

Examples of org.joshy.gfx.node.layout.HFlexBox

        selected = false;


        EventBus.getSystem().addListener(Selection.SelectionChangeEvent.Changed, selectionCallback);

        defaultProperties = new HFlexBox().setBoxAlign(Align.Baseline);

        add(defaultProperties);
        defaultProperties.add(new Label("Name:").setFont(Font.name("OpenSans").size(12).resolve()));
        nameBox =  new Textbox("").setHintText("unset");
        nameBox.setPrefWidth(100);
        nameBox.onAction(new Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
                if(manager.propMan.isClassAvailable(SNode.class)) {
                    PropertyManager.Property prop = manager.propMan.getProperty("id");
                    prop.setValue(nameBox.getText());
                }
            }
        });
        defaultProperties.add(nameBox,1);

        shapeProperties = new HFlexBox().setBoxAlign(HFlexBox.Align.Baseline);
        add(shapeProperties);
        shapeProperties.setVisible(false);

        fillButton = new FillPicker(this.manager);
        fillButton.setContext(context);
        EventBus.getSystem().addListener(fillButton,ChangedEvent.ObjectChanged, fillButtonCallback);

        strokeColorButton = new SwatchColorPicker();
        EventBus.getSystem().addListener(ChangedEvent.ColorChanged, colorChangeCallback);
        shapeProperties.add(fillButton);
        shapeProperties.add(strokeColorButton);


        setupShadowProperties();

        strokeWidthSlider = new Slider(false);
        strokeWidthSlider.setMin(0);
        strokeWidthSlider.setMax(20);
        strokeWidthSlider.setValue(3);
        EventBus.getSystem().addListener(strokeWidthSlider, ChangedEvent.DoubleChanged, strokeWidthCallback);
        strokeWidthLabel = new Label(getString("toolbar.stroke")+": " + 3);
        shapeProperties.add(strokeWidthLabel);
        shapeProperties.add(strokeWidthSlider);

        fillOpacitySlider = new Slider(false).setMin(0).setMax(100).setValue(100);
        EventBus.getSystem().addListener(fillOpacitySlider, ChangedEvent.DoubleChanged, fillOpacityCallback);
        fillOpacityLabel = new Label(getString("toolbar.opacity")+": "+df.format(0));
        shapeProperties.add(fillOpacityLabel);
        shapeProperties.add(fillOpacitySlider);





        fontProperties = new HFlexBox().setBoxAlign(HFlexBox.Align.Baseline);
        add(fontProperties);

        fontSizeLabel = new Label(getString("toolbar.fontSize")+":");
        fontProperties.add(fontSizeLabel);

        fontSizeSlider = new Slider(false);
        fontSizeSlider.setMin(8);
        fontSizeSlider.setMax(500);
        fontSizeSlider.setValue(24);
        EventBus.getSystem().addListener(fontSizeSlider, ChangedEvent.DoubleChanged, fontSizeCallback);
        fontProperties.add(fontSizeSlider);

        fontPicker = new PopupMenuButton<String>();
        fontPicker.setModel(new ListModel<String>() {
            public String get(int i) {
                return Main.getDatabase().getAllFonts().get(i).getName();
            }

            public int size() {
                return Main.getDatabase().getAllFonts().size();
            }
        });
        EventBus.getSystem().addListener(fontPicker, SelectionEvent.Changed, new Callback<SelectionEvent>(){
            public void call(SelectionEvent event) {
                if(manager.propMan.isClassAvailable(SText.class)) {
                    int index = event.getView().getSelectedIndex();
                    String fontname = Main.getDatabase().getAllFonts().get(index).getName();
                    manager.propMan.getProperty("fontName").setValue(fontname);
                    context.redraw();
                }
            }
        });
        fontProperties.add(fontPicker);

        fontBoldButton = new Togglebutton("B");
        fontBoldButton.onClicked(fontBoldCallback);
        fontProperties.add(fontBoldButton);

        fontItalicButton = new Togglebutton("I");
        fontItalicButton.onClicked(fontItalicCallback);
        fontProperties.add(fontItalicButton);

        fontAlignLeft = new TIB("cr22-action-text_left.png", new SAction(){
            @Override
            public void execute() throws Exception {
                if(manager.propMan.isClassAvailable(SText.class)) {
                    manager.propMan.getProperty("halign").setValue(SText.HAlign.Left);
                }
            }
        });
        fontAlignHCenter = new TIB("cr22-action-text_center.png", new SAction(){
            @Override
            public void execute() throws Exception {
                if(manager.propMan.isClassAvailable(SText.class)) {
                    manager.propMan.getProperty("halign").setValue(SText.HAlign.Center);
                }
            }
        });
        fontAlignRight = new TIB("cr22-action-text_right.png", new SAction(){
            @Override
            public void execute() throws Exception {
                if(manager.propMan.isClassAvailable(SText.class)) {
                    manager.propMan.getProperty("halign").setValue(SText.HAlign.Right);
                }
            }
        });
        fontProperties.add(fontAlignLeft,fontAlignHCenter,fontAlignRight);
        fontAlignGroup = new ToggleGroup();
        fontAlignGroup.add(fontAlignLeft).add(fontAlignHCenter).add(fontAlignRight);
        fontAlignGroup.setSelectedButton(fontAlignLeft);
        EventBus.getSystem().addListener(fontAlignGroup, ActionEvent.Action, new Callback<ActionEvent>(){
            public void call(ActionEvent actionEvent) throws Exception {
                if(manager.propMan.isClassAvailable(SText.class)) {
                    if(fontAlignGroup.getSelectedButton() == fontAlignLeft) {
                        manager.propMan.getProperty("halign").setValue(SText.HAlign.Left);
                    }
                    if(fontAlignGroup.getSelectedButton() == fontAlignHCenter) {
                        manager.propMan.getProperty("halign").setValue(SText.HAlign.Center);
                    }
                    if(fontAlignGroup.getSelectedButton() == fontAlignRight) {
                        manager.propMan.getProperty("halign").setValue(SText.HAlign.Right);
                    }
                    context.redraw();
                }
            }
        });

        fontWrap = new Checkbox("wrap");
        fontWrap.onClicked(new Callback<ActionEvent>() {
            public void call(ActionEvent event) throws Exception {
                if(manager.propMan.isClassAvailable(SText.class)) {
                    manager.propMan.getProperty("wrapText").setValue(fontWrap.isSelected());
                    context.redraw();
                }
            }
        });
        fontProperties.add(fontWrap);

        arrowHeadEnd = new PopupMenuButton<SArrow.HeadEnd>();
        arrowHeadEnd.setModel(ListView.createModel(SArrow.HeadEnd.values()));
        add(arrowHeadEnd);
        arrowHeadEnd.setVisible(false);
        EventBus.getSystem().addListener(arrowHeadEnd, SelectionEvent.Changed, arrowHeadCallback);


        groupPropertiesEditor = new HFlexBox()
                .add(new IB("align-horizontal-left.png", new NodeActions.AlignLeft(context)))
                .add(new IB("align-horizontal-center.png", new NodeActions.AlignCenterH(context)))
                .add(new IB("align-horizontal-right.png", new NodeActions.AlignRight(context)))
                .add(new IB("align-vertical-bottom.png", new NodeActions.AlignBottom(context)))
                .add(new IB("align-vertical-center.png", new NodeActions.AlignCenterV(context)))
                .add(new IB("align-vertical-top.png", new NodeActions.AlignTop(context)))
                ;
        add(groupPropertiesEditor);
        groupPropertiesEditor.setVisible(false);
        booleanPropsEditor = new HFlexBox()
                .add(new Button(getString("menus.add")).onClicked(new Callback<ActionEvent>() {
                    public void call(ActionEvent actionEvent) throws Exception {
                        new BooleanGeometry.Union(context).execute();
                    }
                }))
View Full Code Here

Examples of org.joshy.gfx.node.layout.HFlexBox

                        stage.hide();
                    }
                };
                stage.setContent(new VFlexBox()
                        .add(builder, 1)
                        .add(new HFlexBox()
                                .add(new Button("cancel").onClicked(cancelAction), 0)
                                .add(new Button("save").onClicked(closeAction), 0)
                                ,0)
                );
                stage.setWidth(600);
                stage.setHeight(350);
                stage.centerOnScreen();
            }
        });
        VFlexBox vbox = new VFlexBox();
        vbox.setBoxAlign(FlexBox.Align.Stretch);
        vbox.setFill(FlatColor.GRAY);
        vbox.add(patternList, 1);
        vbox.add(new HFlexBox().add(addButton).add(createButton));
        panel.add("Patterns", vbox);
    }
View Full Code Here

Examples of org.joshy.gfx.node.layout.HFlexBox

                        dialog.hide();
                    }
                };
                dialog.setContent(new VFlexBox()
                        .add(picker)
                        .add(new HFlexBox()
                                .add(new Button("okay").onClicked(okay))
                                .add(new Button("cancel").onClicked(canceled))
                        )
                );
                dialog.setWidth(400);
                dialog.setHeight(370);
                dialog.centerOnScreen();
            }
        });

        switcher.setTextRenderer(new ListView.TextRenderer() {
            public String toString(SelectableControl selectableControl, Object palette, int i) {
                if(palette instanceof Palette) {
                    return ((Palette)palette).getName();
                } else {
                    return "foo";
                }
            }
        });

        EventBus.getSystem().addListener(switcher, SelectionEvent.Changed, new Callback<SelectionEvent>() {
            public void call(SelectionEvent selectionEvent) throws Exception {
                int n = selectionEvent.getView().getSelectedIndex();
                manager.colorManager.setCurrentPalette(palettes.get(n));
                colorList.setModel(manager.colorManager.getSwatchModel());
            }
        });

        VFlexBox vbox = new VFlexBox();
        vbox.setFill(FlatColor.GRAY);
        vbox.add(colorList, 1);
        vbox.add(new HFlexBox().add(addButton).add(switcher));
        vbox.setBoxAlign(FlexBox.Align.Stretch);
        panel.add("Swatches", vbox);
    }
View Full Code Here

Examples of org.joshy.gfx.node.layout.HFlexBox

        scrollPane.setHorizontalVisiblePolicy(ScrollPane.VisiblePolicy.Never);
        scrollPane.setContent(photoList);
        searchBox = new Textbox();
        searchBox.setHintText(getString("sidebar.flickr.search.hint"));
        searchBox.onAction(doSearch);
        Control box = new HFlexBox()
                .setBoxAlign(HFlexBox.Align.Baseline)
                .add(searchBox,1)
                .add(new Button(getString("sidebar.search")).onClicked(doSearch),0)
                ;
View Full Code Here

Examples of org.joshy.gfx.node.layout.HFlexBox

        db = AssetDB.getInstance();

        VFlexBox vbox = new VFlexBox();
        vbox.setBoxAlign(FlexBox.Align.Stretch);

        HFlexBox toolbar = new HFlexBox();
        toolbar.add(new Button("Add"));
        toolbar.add(new Button("New List"));
        toolbar.add(new Button("Delete"));
        toolbar.add(new Button("Table View"));
        toolbar.add(new Button("Thumb View"));

        toolbar.add(new Textbox("").setHintText("search").setWidth(100),1.0);
        vbox.add(toolbar);


        HFlexBox main = new HFlexBox();
        main.setBoxAlign(FlexBox.Align.Stretch);
        Query library = new Query("LIBRARY","----");
        library.setSelectable(false);
        all = new LibraryQuery("Everything","*",0,1);
        Query fonts = new Query("Fonts",AssetDB.FONT,6,2);
        Query symbols = new Query("Symbols",AssetDB.SYMBOLSET,4,0);
        Query textures = new Query("Textures",AssetDB.PATTERN,10,0);
        Query gradients = new Query("Gradients","gradient",19,1);
        Query images = new Query("Images","image",19,2);
        Query palettes = new Query("Palettes",AssetDB.PALETTE,4,5);
        final Query staticList = new Query("LISTS","----");
        staticList.setSelectable(false);

        sidebarList = new ListView<Query>();
        ArrayListModel<Query> sidebarModel = new ArrayListModel<Query>();
        sidebarModel.add(library);
        sidebarModel.add(all);
        sidebarModel.add(staticList);
        sidebarModel.add(fonts);
        sidebarModel.add(symbols);
        sidebarModel.add(textures);
        sidebarModel.add(gradients);
        sidebarModel.add(images);
        sidebarModel.add(palettes);
        sidebarList.setModel(sidebarModel);

        sidebarList.setRenderer(new ListView.ItemRenderer<assetmanager.Query>() {
            public void draw(GFX gfx, ListView listView, Query query, int i, double x, double y, double w, double h) {
                if(query == null) return;
                if(!query.isSelectable()) {
                    gfx.setPaint(FlatColor.GRAY);
                    gfx.fillRect(x, y, w, h);
                    gfx.setPaint(FlatColor.BLACK);
                    Font.drawCenteredVertically(gfx, query.getName(), Font.DEFAULT, x, y, w, h, false);
                    return;
                }

                gfx.setPaint(FlatColor.WHITE);
                if(listView.getSelectedIndex() == i) {
                    gfx.setPaint(FlatColor.BLUE);
                }
                gfx.fillRect(x, y, w, h);
                gfx.setPaint(FlatColor.BLACK);
                if(listView.getSelectedIndex() == i) {
                    gfx.setPaint(FlatColor.WHITE);
                }
                Font.drawCenteredVertically(gfx, query.getName(), Font.DEFAULT, x, y, w, h, false);
            }
        });


        EventBus.getSystem().addListener(sidebarList, SelectionEvent.Changed, new Callback<SelectionEvent>() {
            public void call(SelectionEvent selectionEvent) throws Exception {
                Query query = sidebarList.getModel().get(sidebarList.getSelectedIndex());
                if(query == null || !query.isSelectable()) return;
                tableView.setModel(new AssetTableModel(query.execute(db)));

            }
        });

        tableView = new TableView<Asset,String>();
        /*
        tableView.setSorter(new TableView.Sorter() {
            public Comparator createComparator(TableView.TableModel tableModel, int col, TableView.SortOrder sortOrder) {
                return Collator.getInstance();
            }
        });
        */
        tableView.setModel(new AssetTableModel(new ArrayList<Asset>()));
        tableView.setRenderer(new TableView.DataRenderer<assetmanager.Asset>() {
            public void draw(GFX gfx, TableView tableView, Asset asset, int row, int column, double x, double y, double w, double h) {
                if(asset == null) return;
                gfx.setPaint(FlatColor.WHITE);
                gfx.fillRect(x,y,w,h);
                gfx.setPaint(FlatColor.BLACK);
                if(column == 0) {
                    Font.drawCenteredVertically(gfx, asset.getName(), Font.DEFAULT, x, y, w, h, false);
                }
                if(column == 1) {
                    Font.drawCenteredVertically(gfx, asset.getKind(), Font.DEFAULT, x, y, w, h, false);
                }
                if(column == 2) {
                    Image img = null;
                    if(asset.getKind().equals(AssetDB.PATTERN)) {
                        img = RenderUtil.patternToImage(asset);
                    }
                    if(asset.getKind().equals(AssetDB.PALETTE)) {
                        img = RenderUtil.toImage((Palette)asset);
                    }
                    if(asset.getKind().equals(AssetDB.FONT)) {
                        img = RenderUtil.fontToImage(asset);
                    }
                    if(img != null) {
                        Bounds oldClip = gfx.getClipRect();
                        gfx.setClipRect(new Bounds(x,y,w,h));
                        gfx.drawImage(img,x,y);
                        gfx.setClipRect(oldClip);
                    }
                }
            }
        });
        main.add(new ScrollPane(sidebarList).setPrefWidth(200));
        main.add(new ScrollPane(tableView).setPrefWidth(200),1.0);
        vbox.add(main,1.0);
        return vbox;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.