Examples of STAGE


Examples of org.joshy.gfx.stage.Stage

    public void doLayout() {
        if(selected) {
            Bounds bounds = selection.calculateBounds();
            bounds = context.getSketchCanvas().transformToDrawing(bounds);
            bounds = NodeUtils.convertToScene(context.getSketchCanvas(),bounds);
            Stage stage = this.getStage();

            double x = bounds.getX();
            double y = bounds.getY() + bounds.getHeight()+20;
            double h = stage.getContent().getVisualBounds().getHeight();
            double w = stage.getContent().getVisualBounds().getWidth();
            double bottom = y + this.getHeight();

            //if to low then put above the item
            if(bottom > h-140) {
                //the 130 above is to account for the height of the fill picker
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

    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 ColorPickerPanel());
                EventBus.getSystem().addListener(SystemMenuEvent.Quit,new Callback<Event>() {
                    public void call(Event event) throws Exception {
                        System.exit(0);
                    }
                });
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

    @Override
    protected void setPressed(boolean pressed) {
        super.setPressed(pressed);
        if (pressed) {
            if (!popupadded) {
                Stage stage = getParent().getStage();
                stage.getPopupLayer().add(popup);
            }
            Point2D pt = NodeUtils.convertToScene(this, 0, getHeight());
            popup.setTranslateX(Math.round(Math.max(pt.getX(), 0)));
            popup.setTranslateY(Math.round(Math.max(pt.getY(), 0)));
            popup.setVisible(true);
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

        });
        Button createButton = new Button("create new");
        createButton.onClicked(new Callback<ActionEvent>() {
            public void call(ActionEvent event) throws Exception {
                final PatternBuilder builder = new PatternBuilder();
                final Stage stage = Stage.createStage();
                Callback<ActionEvent> closeAction = new Callback<ActionEvent>() {
                    public void call(ActionEvent event) throws Exception {
                        PatternPaint pattern = builder.getPattern();
                        manager.patternManager.addPattern(pattern);
                        stage.hide();
                    }
                };
                Callback<ActionEvent> cancelAction = new Callback<ActionEvent>() {
                    public void call(ActionEvent event) throws Exception {
                        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);
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

            e.printStackTrace();
        }
    }

    private void showConfigDialog() {
        final Stage stage = Stage.createStage();
        stage.setTitle("Share with Twitter");
        GridBox grid = new GridBox()
                .createColumn(30, GridBox.Align.Left)
                .createColumn(300, GridBox.Align.Left)
                ;
        stage.setWidth(400);
        stage.setHeight(280);
        final Radiobutton selected = new Radiobutton("Just selected shapes");
        final Radiobutton contents = new Radiobutton("Page contents (just big enough for the content)");
        final Radiobutton page = new Radiobutton("Entire page (clipped at page edges)");
        final Checkbox includeStamp = new Checkbox("include 'handcrafted with LeonardoSketch.org' in lower left");
        includeStamp.setSelected(true);

        final ToggleGroup tg = new ToggleGroup();
        tg.add(selected)
                .add(contents)
                .add(page);
        tg.setSelectedButton(page);

        grid.addControl(new Label("Share:"));
        grid.addControl(selected);
        grid.nextRow();
        grid.addControl(new Spacer());
        grid.addControl(contents);
        grid.nextRow();
        grid.addControl(new Spacer());
        grid.addControl(page);
        grid.nextRow();
        grid.nextRow();
        grid.addControl(includeStamp);
        grid.nextRow();
        Button cancelButton = new Button("cancel");
        cancelButton.onClicked(new Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
                stage.hide();
            }
        });
        grid.addControl(cancelButton);
        Button continueButton = new Button("continue");
        continueButton.onClicked(new Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
                stage.hide();
                final File file = File.createTempFile("foo", ".png");
                file.deleteOnExit();

                CanvasDocument doc = context.getDocument();
                if(doc instanceof SketchDocument) {
                    SketchDocument sdoc = (SketchDocument) doc;
                    SavePNGAction save = new SavePNGAction(null);
                    VectorDocContext vdc = (VectorDocContext) context;
                    save.includeBackground = true;
                    if(includeStamp.isSelected()) {
                        save.includeStamp = true;
                    }
                    if(tg.getSelectedButton() == page) {
                        save.includeDocumentBounds = true;
                    }
                    if(tg.getSelectedButton() == selected) {
                        SavePNGAction.exportFragment(file, (Iterable<SNode>) vdc.getSelection().items());
                    } else {
                        save.export(file, sdoc);
                    }
                }
                if(doc instanceof PixelDocument) {
                    SavePNGAction save = new SavePNGAction(null);
                    save.exportStatic(file, (PixelDocument) doc);
                }

                requestMessage(file);
            }
        });
        grid.addControl(continueButton);
        stage.setContent(grid);
    }
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

        addButton.onClicked(new Callback<ActionEvent>() {
            public void call(ActionEvent actionEvent) throws Exception {
                if(!palettes.get(switcher.getSelectedIndex()).isEditable()) {
                    return;
                }
                final Stage dialog = Stage.createStage();
                dialog.setTitle("Color");

                final ColorPickerPanel picker = new ColorPickerPanel();

                Callback<ActionEvent> okay = new Callback<ActionEvent>() {
                    public void call(ActionEvent event) {
                        FlatColor color = picker.getColor();
                        manager.colorManager.addSwatch(color);
                        dialog.hide();
                    }
                };
                Callback<ActionEvent> canceled = new Callback<ActionEvent>() {
                    public void call(ActionEvent event) {
                        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) {
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

                    final String url = requestToken.getAuthorizationURL();

                    final Textbox pin = new Textbox("");
                    pin.setPrefWidth(50);
                    pin.setWidth(50);
                    final Stage stage = Stage.createStage();
                    stage.setContent(
                            new GridBox()
                                    .createColumn(50,GridBox.Align.Right)
                                    .createColumn(50,GridBox.Align.Fill)
                                    .addControl(new Label(getString("twitterAuthDialog.text1")))
                                    .addControl(new Label(getString("twitterAuthDialog.text2")))
                                    .nextRow()
                                    .addControl(new Spacer())
                                    .addControl(new Button("Goto Twitter.com").onClicked(new Callback<ActionEvent>() {
                                        public void call(ActionEvent event) {
                                            OSUtil.openBrowser(url);
                                        }
                                    }))
                                    .nextRow()
                                    .addControl(new Label("PIN"))
                                    .addControl(pin)
                                    .nextRow()
                                    .addControl(new Button(getString("dialog.cancel")).onClicked(new Callback<ActionEvent>(){
                                        public void call(ActionEvent event) {
                                            stage.hide();
                                        }
                                    }))
                                    .addControl(new Button(getString("twitterAuthDialog.authenticate")).onClicked(new Callback<ActionEvent>(){
                                        public void call(ActionEvent event) {
                                            stage.hide();
                                            try {
                                                String pinText = pin.getText();
                                                //u.p("using pin text " + pinText);
                                                AccessToken accessToken = twitter.getOAuthAccessToken(requestToken,pinText);
                                                context.getSettings().setProperty(TWITTER_TOKEN,accessToken.getToken());
                                                context.getSettings().setProperty(TWITTER_TOKEN_SECRET,accessToken.getTokenSecret());
                                            } catch (TwitterException e) {
                                                e.printStackTrace();
                                                StandardDialog.showError("Twitter authentication failed.\nPlease try again.");
                                            }
                                        }
                                    }))
                    );
                    stage.setWidth(400);
                    stage.setHeight(200);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                } catch (URISyntaxException e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                }

                Stage stage = Stage.createStage();
                stage.setContent(new ColorPickerPanel(250,200));
                EventBus.getSystem().addListener(SystemMenuEvent.Quit, new Callback<Event>() {
                    public void call(Event event) throws Exception {
                        System.exit(0);
                    }
                });
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

            System.out.println("frob: " + frob);
            final URL url = authInterface.buildAuthenticationUrl(Permission.DELETE, frob);
            System.out.println("Press return after you granted access at this URL:");
            System.out.println(url.toExternalForm());

            final Stage stage = Stage.createStage();
            stage.setContent(
                new GridBox()
                    .createColumn(50,GridBox.Align.Right)
                    .createColumn(50,GridBox.Align.Fill)
                    .addControl(new Label("Please visit Flickr and grant Leo access to your account"))
                    .nextRow()
                    .addControl(new Spacer())
                    .addControl(new Button("Goto Flickr").onClicked(new Callback<ActionEvent>() {
                        public void call(ActionEvent event) {
                            OSUtil.openBrowser(url.toExternalForm());
                        }
                    }))
                    .nextRow()
                    .addControl(new Button(getString("dialog.cancel")).onClicked(new Callback<ActionEvent>(){
                        public void call(ActionEvent event) {
                            stage.hide();
                        }
                    }))
                    .addControl(new Button("Continue >").onClicked(new Callback<ActionEvent>(){
                        public void call(ActionEvent event) {
                            stage.hide();
                            try {
                                Auth auth = authInterface.getToken(frob);
                                System.out.println("Authentication success");
                                // This token can be used until the user revokes it.
                                System.out.println("Token: " + auth.getToken());
                                String user_token = auth.getToken();
                                ChangeFlickrSettingsAction.this.context.getSettings().setProperty(FLICKR_USER_TOKEN,user_token);
                                String user_id = auth.getUser().getId();
                                ChangeFlickrSettingsAction.this.context.getSettings().setProperty(FLICKR_USER_ID,user_id);
                                System.out.println("nsid: " + auth.getUser().getId());
                                System.out.println("Realname: " + auth.getUser().getRealName());
                                System.out.println("Username: " + auth.getUser().getUsername());
                                System.out.println("Permission: " + auth.getPermission().getType());
                            } catch (FlickrException e) {
                                System.out.println("Authentication failed");
                                e.printStackTrace();
                            } catch (SAXException e) {
                                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                            } catch (IOException e) {
                                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                            }
                        }
                    }))
            );
            stage.setWidth(400);
            stage.setHeight(200);
        }
View Full Code Here

Examples of org.joshy.gfx.stage.Stage

    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 HSVColorPicker(null,150,150));
            }
        });

    }
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.