Package org.joshy.gfx.stage

Examples of org.joshy.gfx.stage.Stage


        return getString("menus.about");
    }

    @Override
    public void execute() throws Exception {
        final Stage stage = Stage.createStage();
        stage.setTitle("About Leonardo");
        Callback openLink = new org.joshy.gfx.event.Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
                OSUtil.openBrowser("http://leonardosketch.org/download-source/");
            }
        };
        Callback closeStage = new Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
                stage.hide();
            }
        };
       
        //leonardo sketch
        stage.setContent(new VFlexBox().setBoxAlign(VFlexBox.Align.Stretch)
                .add(new HFlexBox()
                        .add(new ImageBox().setImage(Main.class.getResource("resources/Turtle.png"))))
                //.add(new HFlexBox().add(new Label("Leonardo")).setId("aboutHeader"))
                //.add(new HFlexBox().add(new Linkbutton("http://leonardosketch.org/").onClicked(openLink)))
                .add(new HFlexBox().add(new Label("Leonardo is open source, BSD licensed."+
                        " It contains software from Apache, Twitter4J, Parboiled."+
                        " Fonts from The League Of Movable Type." +
                        " Icon by VisualPharm (Ivan Boyko).").setPrefWidth(370)))
                .add(new HFlexBox().add(new Linkbutton("Click for license info").onClicked(openLink)))
                .add(new HFlexBox()
                        .add(new Label("Version"))
                        .add(new Label(Main.releaseProperties.getProperty("org.joshy.sketch.build.version"))))
                .add(new HFlexBox()
                        .add(new Label("Build number"))
                        .add(new Label(Main.releaseProperties.getProperty("org.joshy.sketch.build.number"))))
                .add(new HFlexBox()
                        .add(new Label("Build date"))
                        .add(new Label(Main.releaseProperties.getProperty("org.joshy.sketch.build.date"))))
                .add(new Spacer(),1)
                .add(new HFlexBox().add(new Spacer(),1).add(new Button("Close").onClicked(closeStage)))
        );
        stage.setWidth(400);
        stage.setHeight(400);
        stage.centerOnScreen();
    }
View Full Code Here


    public static void main(String ... args) throws Exception {
        Core.init();
        Core.getShared().defer(new Runnable() {
            public void run() {
                Stage stage = Stage.createStage();
                stage.setContent(new HSVColorPicker6());
                stage.setWidth(600);
                stage.setHeight(600);
                EventBus.getSystem().addListener(SystemMenuEvent.Quit, new Callback<Event>() {
                    public void call(Event event) throws Exception {
                        System.exit(0);
                    }
                });
View Full Code Here

    public static void main(String ... args) throws Exception {
        Core.init();
        Core.getShared().defer(new Runnable() {
            public void run() {
                final Stage stage = Stage.createStage();
                stage.setContent(new PatternBuilder());
                stage.setWidth(800);
                stage.setHeight(600);

                EventBus.getSystem().addListener(SystemMenuEvent.Quit, new Callback<Event>() {
                    public void call(Event event) throws Exception {
                        stage.hide();
                        System.exit(0);
                    }
                });

            }
View Full Code Here

        return "Make Link";
    }

    @Override
    public void execute() throws Exception {
        final Stage stage = Stage.createStage();
        final Iterable<? extends SNode> items = context.getSelection().items();
        VFlexBox box = new VFlexBox();
        for(Page page : context.getDocument().getPages()) {
            final String id = page.getId();
            Button bt = new Button(" " + page.getName());
            bt.onClicked(new Callback<ActionEvent>() {
                public void call(ActionEvent event) throws Exception {
                    stage.hide();
                    for(SNode node : items) {
                        node.setLinkTarget(id);
                    }
                }
            });
            box.add(bt);
        }
       
        Button cancel = new Button("cancel");
        cancel.onClicked(new Callback<ActionEvent>() {
            public void call(ActionEvent event) throws Exception {
                stage.hide();
            }
        });
        box.add(cancel);
        stage.setContent(box);
    }
View Full Code Here

        }
        if(newReleases.isEmpty()) {
            u.p("no new releases");
        } else {
            u.p("a new release!");
            final Stage stage = Stage.createStage();
            Callback<ActionEvent> dismiss = new Callback<ActionEvent>() {
                public void call(ActionEvent actionEvent) throws Exception {
                    stage.hide();
                }
            };
            Callback<ActionEvent> skipVersion = new Callback<ActionEvent>() {
                public void call(ActionEvent actionEvent) throws Exception {
                    stage.hide();
                }
            };
            Callback<ActionEvent> getUpdate = new Callback<ActionEvent>() {
                public void call(ActionEvent actionEvent) throws Exception {
                    stage.hide();
                    OSUtil.openBrowser(Settings.DOWNLOAD_URL);
                }
            };
            FlexBox box = new VFlexBox().setBoxAlign(VFlexBox.Align.Stretch);
            box.add(new Label("New Version Available!").setId("updates-header"));

            for(Elem release : newReleases) {
                u.p("build = " + release.attr("buildNumber"));
                u.p("date = " + release.attr("buildDate"));
                u.p("version = " + release.attr("version"));
                u.p("description = " + release.text());
                box.add(new Label("Version: " + release.attr("version")).setPrefWidth(200));
                box.add(new Label(release.text()).setPrefWidth(200));
            }
            box.add(new Spacer(),1);
            box.add(new HFlexBox()
                    .add(new Button("Get the Update").onClicked(getUpdate))
                    .add(new Button("Skip This Version").onClicked(skipVersion))
                    .add(new Button("Remind Me Later").onClicked(dismiss))
            );
            stage.setContent(box);
        }
    }
View Full Code Here

        return getString("preferences.settings").toString();
    }

    @Override
    public void execute() throws Exception {
        final Stage stage = Stage.createStage();
       
        //tracking checkbox
        boolean trackingEnabled = "true".equals(manager.settings.getProperty(Settings.TRACKING_PERMISSIONS));
        Checkbox trackingCheckbox = new Checkbox(getString("preferences.enable.analytics.tracking"));
        trackingCheckbox.setSelected(trackingEnabled);
        trackingCheckbox.onClicked(new Callback<ActionEvent>(){
                public void call(ActionEvent actionEvent) throws Exception {
                    Checkbox checkbox = (Checkbox) actionEvent.getSource();
                    Main.settings.setProperty(Settings.TRACKING_PERMISSIONS,""+checkbox.isSelected());
                }
            });

        //starting on translations
        //debug menu
        Checkbox debugMenuCheckbox = new Checkbox(getString("preferences.enable.debug.menu"));
        boolean debugMenuEnabled = "true".equals(manager.settings.getProperty(Settings.DEBUG_MENU));
        debugMenuCheckbox.setSelected(debugMenuEnabled);
        debugMenuCheckbox.onClicked(new Callback<ActionEvent>(){
            public void call(ActionEvent actionEvent) throws Exception {
                Checkbox checkbox = (Checkbox) actionEvent.getSource();
                Main.settings.setProperty(Settings.DEBUG_MENU,""+checkbox.isSelected());
            }
        });

        ArrayListModel<String> locale = new ArrayListModel<String>();
        locale.addAll(Localization.getSupportedLocales());
        Collections.sort(locale);
        final PopupMenuButton<String> localeChoice = new PopupMenuButton<String>();
        localeChoice.setModel(locale);
        if(Main.settings.containsKey(Settings.DEFAULT_LOCALE)) {
            int n = locale.indexOf(Main.settings.getProperty(Settings.DEFAULT_LOCALE));
            if(n >= 0) {
                localeChoice.setSelectedIndex(n);
            }
        }
        localeChoice.onClicked(new Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
            }
        });

        Callback<ActionEvent> closeAction = new Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
                stage.hide();
                String l = localeChoice.getModel().get(localeChoice.getSelectedIndex());
                Main.settings.setProperty(Settings.DEFAULT_LOCALE, l);
                Main.saveSettings();
                Localization.setCurrentLocale(l);
                Core.getShared().reloadSkins();
            }
        };


        TabPanel tab = new TabPanel();
        tab.add(getString("preferences.generalTab"),new VFlexBox().setBoxAlign(VFlexBox.Align.Left)
            .add(new HFlexBox()
                    .setBoxAlign(HFlexBox.Align.Baseline)
                    .add(trackingCheckbox)
                    .add(new Linkbutton(getString("misc.whatsthis")).onClicked(new Callback<ActionEvent>() {
                public void call(ActionEvent actionEvent) throws Exception {
                    OSUtil.openBrowser("http://code.google.com/p/leonardosketch/wiki/Tracking");
                }
            })))
            .add(new Label(getString("preferences.flickrCache")))
            .add(new Label(Main.FlickrSearchCache.getCacheDir().getAbsolutePath()).setColor(new FlatColor(0x606060)))
            .add(new Button(getString("preferences.deleteFlickrCache")).onClicked(clearFlickrCache))
        );
        tab.add(getString("preferences.advancedTab"), new VFlexBox().setBoxAlign(VFlexBox.Align.Stretch)
                .add(debugMenuCheckbox)
                .add(new Label(getString("preferences.preferredLocale")))
                .add(localeChoice)
                .add(new Label(getString("misc.changesAppliedLater").toString()))
        );

        stage.setContent(new VFlexBox().setBoxAlign(VFlexBox.Align.Stretch)
                .add(tab,1)
                .add(new HFlexBox().add(new Spacer(),1).add(new Button(getString("misc.close")).onClicked(closeAction)))
        );
    }
View Full Code Here

            this.manager = main;
        }

        @Override
        public void execute() {
            final Stage dialog = Stage.createStage();
            dialog.setTitle("Set Background");
            dialog.setWidth(400);
            dialog.setHeight(300);

            Callback<ActionEvent> okayed = new Callback<ActionEvent>() {
                public void call(ActionEvent event) {
                    dialog.hide();
                }
            };

            FillPicker picker = new FillPicker(this.manager);
            Paint pt = ((SketchDocument) context.getDocument()).getBackgroundFill();
            picker.setSelectedFill(pt);
            EventBus.getSystem().addListener(picker,ChangedEvent.ObjectChanged, new Callback<ChangedEvent>() {
                public void call(ChangedEvent event) throws Exception {
                    Paint paint = (Paint) event.getValue();
                    SketchDocument doc = (SketchDocument) context.getDocument();
                    setBackgroundFill(paint, doc);
                    context.redraw();
                }
            });
            picker.setTranslateX(10);
            picker.setTranslateY(10);
            Panel panel = new Panel();
            panel.add(picker);
            Button okay = new Button("Close");
            okay.setTranslateX(200);
            okay.setTranslateY(200);
            okay.onClicked(okayed);
            panel.add(okay);
            dialog.setContent(panel);


        }
View Full Code Here

            this.context = context;
        }

        @Override
        public void execute() {
            final Stage dialog = Stage.createStage();
            dialog.setTitle("Document Size");
                final Textbox width = new Textbox(""+context.getDocument().getWidth());
                final Textbox height = new Textbox(""+context.getDocument().getHeight());
                Callback<ActionEvent> canceled = new Callback<ActionEvent>() {
                    public void call(ActionEvent event) {
                        dialog.hide();
                    }
                };
                Callback<ActionEvent> okay = new Callback<ActionEvent>() {
                    public void call(ActionEvent event) {
                        dialog.hide();
                        double dwidth = Double.parseDouble(width.getText());
                        double dheight = Double.parseDouble(height.getText());
                        SketchDocument doc = context.getDocument();
                        doc.setWidth(dwidth);
                        doc.setHeight(dheight);
                        context.redraw();
                    }
                };

                final PopupMenuButton popup = new PopupMenuButton();
                popup.setModel(new ArrayListModel<String>("16x16","1024x768"));
                Callback<ActionEvent> clicked = new Callback<ActionEvent>() {
                    public void call(ActionEvent event) {
                        switch(popup.getSelectedIndex()) {
                            case 0: width.setText("16"); height.setText("16"); break;
                            case 1: width.setText("1024"); height.setText("768"); break;
                        }
                    }
                };
                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))
                ));
            dialog.setWidth(400);
            dialog.setHeight(400);
        }
View Full Code Here

    public void show(Node node, double x, double y) {
        if(sharedContextMenu != null) {
            sharedContextMenu.setVisible(false);
            sharedLayer.remove(sharedContextMenu);
        }
        Stage stage = node.getParent().getStage();
        sharedLayer = stage.getPopupLayer();
        Point2D pt = NodeUtils.convertToScene(node, x, y);
        pt = NodeUtils.convertFromScene(sharedLayer,pt);
        setTranslateX(pt.getX()+2);
        setTranslateY(pt.getY());
        setVisible(true);
View Full Code Here

        startY = e.getY();

        if (popup == null) {
            popup = new GenericColorPickerPopup(this,200,100,true);
            popup.setVisible(false);
            Stage stage = getParent().getStage();
            stage.getPopupLayer().add(popup);
        }
        Point2D pt = NodeUtils.convertToScene(this, 0, getHeight());

        double x = pt.getX();
        double y = pt.getY();
View Full Code Here

TOP

Related Classes of org.joshy.gfx.stage.Stage

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.