Examples of ImageView


Examples of org.apache.pivot.wtk.ImageView

            image.getHeight());
    }

    @Override
    public int getBaseline(int width, int height) {
        ImageView imageView = (ImageView)getComponent();
        Image image = imageView.getImage();

        int baseline = -1;

        if (image != null) {
            baseline = image.getBaseline();
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

        return baseline;
    }

    @Override
    public void layout() {
        ImageView imageView = (ImageView)getComponent();
        Image image = imageView.getImage();

        if (image != null) {
            int width = getWidth();
            int height = getHeight();
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

        }
    }

    @Override
    public void paint(Graphics2D graphics) {
        ImageView imageView = (ImageView)getComponent();
        Image image = imageView.getImage();

        int width = getWidth();
        int height = getHeight();

        if (backgroundColor != null) {
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

                    private Point offset = null;
                    private LocalManifest content = null;

                    @Override
                    public boolean beginDrag(Component comp, int x, int y) {
                        ImageView imageView = (ImageView)comp;
                        this.image = imageView.getImage();

                        if (this.image != null) {
                            imageView.setImage((Image)null);
                            this.content = new LocalManifest();
                            this.content.putImage(this.image);
                            this.offset = new Point(x - (imageView.getWidth() - this.image.getWidth()) / 2,
                                y - (imageView.getHeight() - this.image.getHeight()) / 2);
                        }

                        return (this.image != null);
                    }

                    @Override
                    public void endDrag(Component comp, DropAction dropAction) {
                        if (dropAction == null) {
                            ImageView imageView = (ImageView)comp;
                            imageView.setImage(this.image);
                        }

                        this.image = null;
                        this.offset = null;
                        this.content = null;
                    }

                    @Override
                    public boolean isNative() {
                        return false;
                    }

                    @Override
                    public LocalManifest getContent() {
                        return this.content;
                    }

                    @Override
                    public Visual getRepresentation() {
                        return this.image;
                    }

                    @Override
                    public Point getOffset() {
                        return this.offset;
                    }

                    @Override
                    public int getSupportedDropActions() {
                        return DropAction.MOVE.getMask();
                    }
                };

                DropTarget imageDropTarget = new DropTarget() {
                    @Override
                    public DropAction dragEnter(Component comp, Manifest dragContent,
                        int supportedDropActions, DropAction userDropAction) {
                        DropAction dropAction = null;

                        ImageView imageView = (ImageView)comp;
                        if (imageView.getImage() == null
                            && dragContent.containsImage()
                            && DropAction.MOVE.isSelected(supportedDropActions)) {
                            dropAction = DropAction.MOVE;
                            comp.getStyles().put("backgroundColor", "#f0e68c");
                        }

                        return dropAction;
                    }

                    @Override
                    public void dragExit(Component comp) {
                        comp.getStyles().put("backgroundColor", null);
                    }

                    @Override
                    public DropAction dragMove(Component comp, Manifest dragContent,
                        int supportedDropActions, int x, int y, DropAction userDropAction) {
                        ImageView imageView = (ImageView)comp;
                        return (imageView.getImage() == null
                            && dragContent.containsImage() ? DropAction.MOVE : null);
                    }

                    @Override
                    public DropAction userDropActionChange(Component comp, Manifest dragContent,
                        int supportedDropActions, int x, int y, DropAction userDropAction) {
                        ImageView imageView = (ImageView)comp;
                        return (imageView.getImage() == null
                            && dragContent.containsImage() ? DropAction.MOVE : null);
                    }

                    @Override
                    public DropAction drop(Component comp, Manifest dragContent,
                        int supportedDropActions, int x, int y, DropAction userDropAction) {
                        DropAction dropAction = null;

                        ImageView imageView = (ImageView)comp;
                        if (imageView.getImage() == null
                            && dragContent.containsImage()) {
                            try {
                                imageView.setImage(dragContent.getImage());
                                dropAction = DropAction.MOVE;
                            } catch(IOException exception) {
                                System.err.println(exception);
                            }
                        }
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

            private Point offset = null;
            private LocalManifest content = null;

            @Override
            public boolean beginDrag(Component component, int x, int y) {
                ImageView imageView = (ImageView)component;
                image = imageView.getImage();

                if (image != null) {
                    imageView.setImage((Image)null);
                    content = new LocalManifest();
                    content.putImage(image);
                    offset = new Point(x - (imageView.getWidth() - image.getWidth()) / 2,
                        y - (imageView.getHeight() - image.getHeight()) / 2);
                }

                return (image != null);
            }

            @Override
            public void endDrag(Component component, DropAction dropAction) {
                if (dropAction == null) {
                    ImageView imageView = (ImageView)component;
                    imageView.setImage(image);
                }

                image = null;
                offset = null;
                content = null;
            }

            @Override
            public boolean isNative() {
                return false;
            }

            @Override
            public LocalManifest getContent() {
                return content;
            }

            @Override
            public Visual getRepresentation() {
                return image;
            }

            @Override
            public Point getOffset() {
                return offset;
            }

            @Override
            public int getSupportedDropActions() {
                return DropAction.MOVE.getMask();
            }
        };

        DropTarget imageDropTarget = new DropTarget() {
            @Override
            public DropAction dragEnter(Component component, Manifest dragContent,
                int supportedDropActions, DropAction userDropAction) {
                DropAction dropAction = null;

                ImageView imageView = (ImageView)component;
                if (imageView.getImage() == null
                    && dragContent.containsImage()
                    && DropAction.MOVE.isSelected(supportedDropActions)) {
                    dropAction = DropAction.MOVE;
                    component.getStyles().put("backgroundColor", IMAGE_VIEW_DROP_HIGHLIGHT_COLOR);
                }

                return dropAction;
            }

            @Override
            public void dragExit(Component component) {
                component.getStyles().put("backgroundColor", IMAGE_VIEW_BACKGROUND_COLOR);
            }

            @Override
            public DropAction dragMove(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                return (dragContent.containsImage() ? DropAction.MOVE : null);
            }

            @Override
            public DropAction userDropActionChange(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                return (dragContent.containsImage() ? DropAction.MOVE : null);
            }

            @Override
            public DropAction drop(Component component, Manifest dragContent,
                int supportedDropActions, int x, int y, DropAction userDropAction) {
                DropAction dropAction = null;

                if (dragContent.containsImage()) {
                    ImageView imageView = (ImageView)component;
                    try {
                        imageView.setImage(dragContent.getImage());
                        dropAction = DropAction.MOVE;
                    } catch(IOException exception) {
                        System.err.println(exception);
                    }
                }

                dragExit(component);

                return dropAction;
            }
        };

        ImageView imageView1 = new ImageView();
        imageView1.setImage(Image.load(getClass().getResource("go-home.png")));
        imageView1.getStyles().put("backgroundColor", IMAGE_VIEW_BACKGROUND_COLOR);
        imageView1.setDragSource(imageDragSource);
        imageView1.setDropTarget(imageDropTarget);

        frame1.setContent(imageView1);
        frame1.open(display);

        frame2.setTitle("Frame 2");
        frame2.setPreferredSize(160, 120);
        frame2.setLocation(180, 0);

        ImageView imageView2 = new ImageView();
        imageView2.getStyles().put("backgroundColor", IMAGE_VIEW_BACKGROUND_COLOR);
        imageView2.setDragSource(imageDragSource);
        imageView2.setDropTarget(imageDropTarget);

        frame2.setContent(imageView2);

        frame2.open(display);
    }
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

        Panorama panorama = new Panorama();
        frame1.setContent(panorama);
        frame1.setPreferredSize(240, 320);

        ImageView imageView = new ImageView();
        imageView.setImage(getClass().getResource("IMG_0767_2.jpg"));
        panorama.setView(imageView);
        frame1.open(display);

        BXMLSerializer bxmlSerializer = new BXMLSerializer();
        frame2 = new Frame((Component)bxmlSerializer.readObject(getClass().getResource("panorama_test.bxml")));
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

    @Override
    public void install(Component component) {
        super.install(component);

        ImageView imageView = (ImageView)component;
        imageView.getImageViewListeners().add(this);

        Image image = imageView.getImage();
        if (image != null) {
            image.getImageListeners().add(imageListener);
        }
    }
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

        }
    }

    @Override
    public int getPreferredWidth(int height) {
        ImageView imageView = (ImageView)getComponent();
        Image image = imageView.getImage();

        return (image == null) ? 0 : image.getWidth();
    }
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

        return (image == null) ? 0 : image.getWidth();
    }

    @Override
    public int getPreferredHeight(int width) {
        ImageView imageView = (ImageView)getComponent();
        Image image = imageView.getImage();

        return (image == null) ? 0 : image.getHeight();
    }
View Full Code Here

Examples of org.apache.pivot.wtk.ImageView

        return (image == null) ? 0 : image.getHeight();
    }

    @Override
    public Dimensions getPreferredSize() {
        ImageView imageView = (ImageView)getComponent();
        Image image = imageView.getImage();

        return (image == null) ? new Dimensions(0, 0) : new Dimensions(image.getWidth(),
            image.getHeight());
    }
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.