Package pivot.wtk.media

Examples of pivot.wtk.media.Image


        // Images
        imageView.setDragSource(new DragSource() {
            private LocalManifest content = null;

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

                if (image != null) {
                    content = new LocalManifest();
                    content.putImage(image);
                }

                return (content != null);
            }

            public void endDrag(Component component, DropAction dropAction) {
                content = null;
            }

            public boolean isNative() {
                return true;
            }

            public LocalManifest getContent() {
                return content;
            }

            public Visual getRepresentation() {
                return null;
            }

            public Point getOffset() {
                return null;
            }

            public int getSupportedDropActions() {
                return DropAction.COPY.getMask();
            }
        });

        imageView.setDropTarget(new DropTarget() {
            public DropAction dragEnter(Component component, Manifest dragContent,
                int supportedDropActions, DropAction userDropAction) {
                DropAction dropAction = null;

                if (dragContent.containsImage()
                    && DropAction.COPY.isSelected(supportedDropActions)) {
                    dropAction = DropAction.COPY;
                }

                return dropAction;
            }

            public void dragExit(Component component) {
            }

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

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

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

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

                dragExit(component);

                return dropAction;
            }
        });

        copyImageButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Image image = imageView.getImage();
                if (image != null) {
                    LocalManifest clipboardContent = new LocalManifest();
                    clipboardContent.putImage(image);
                    Clipboard.setContent(clipboardContent);
                }
View Full Code Here


    public void setB(Image b) {
        this.b = b;
    }

    public void setB(URL bURL) {
        Image b = (Image)ApplicationContext.getResourceCache().get(bURL);

        if (b == null) {
            b = Image.load(bURL);
            ApplicationContext.getResourceCache().put(bURL, b);
        }
View Full Code Here

                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
                URL imageURL = classLoader.getResource("pivot/tutorials/" + item);

                // If the image has not been added to the resource cache yet,
                // add it
                Image image = (Image)ApplicationContext.getResourceCache().get(imageURL);

                if (image == null) {
                    image = Image.load(imageURL);
                    ApplicationContext.getResourceCache().put(imageURL, image);
                }
View Full Code Here

                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
                URL imageURL = classLoader.getResource(imageName);

                // If the image has not been added to the resource cache yet,
                // add it
                Image image = (Image)ApplicationContext.getResourceCache().get(imageURL);

                if (image == null) {
                    image = Image.load(imageURL);
                    ApplicationContext.getResourceCache().put(imageURL, image);
                }

                // Update the image
                menuImageView.setImage(image);
            }
        };

        ListView iconListView = (ListView)wtkxSerializer.getObjectByName("lists.iconListView");
        iconListView.setItemDisabled(3, true);
        iconListView.setItemDisabled(4, true);

        ListView checkedListView = (ListView)wtkxSerializer.getObjectByName("lists.checkedListView");
        checkedListView.setItemChecked(0, true);
        checkedListView.setItemChecked(2, true);
        checkedListView.setItemChecked(3, true);

        menuImageView = (ImageView)wtkxSerializer.getObjectByName("menus.imageView");
        menuImageView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener() {
            public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
                if (button == Mouse.Button.RIGHT) {
                    menuPopup.open(display, component.mapPointToAncestor(display, x, y));
                }

                return false;
            }

            public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
                return false;
            }

            public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
                return false;
            }
        });

        // Spinners
        Spinner numericSpinner = (Spinner)wtkxSerializer.getObjectByName("spinners.numericSpinner");
        initializeNumericSpinner(numericSpinner);

        Spinner dateSpinner = (Spinner)wtkxSerializer.getObjectByName("spinners.dateSpinner");
        initializeDateSpinner(dateSpinner);

        // Sliders
        SliderValueListener sliderValueListener = new SliderValueListener() {
            public void valueChanged(Slider slider, int previousValue) {
                Color color = new Color(redSlider.getValue(), greenSlider.getValue(),
                    blueSlider.getValue());
                colorBorder.getStyles().put("backgroundColor", color);
            }
        };

        redSlider = (Slider)wtkxSerializer.getObjectByName("spinners.redSlider");
        redSlider.getSliderValueListeners().add(sliderValueListener);

        greenSlider = (Slider)wtkxSerializer.getObjectByName("spinners.greenSlider");
        greenSlider.getSliderValueListeners().add(sliderValueListener);

        blueSlider = (Slider)wtkxSerializer.getObjectByName("spinners.blueSlider");
        blueSlider.getSliderValueListeners().add(sliderValueListener);

        Color color = new Color(redSlider.getValue(), greenSlider.getValue(),
            blueSlider.getValue());
        colorBorder = (Border)wtkxSerializer.getObjectByName("spinners.colorBorder");
        colorBorder.getStyles().put("backgroundColor", color);

        sortableTableView = (TableView)wtkxSerializer.getObjectByName("tables.sortableTableView");
        sortableTableViewHeader = (TableViewHeader)wtkxSerializer.getObjectByName("tables.sortableTableViewHeader");
        customTableView = (TableView)wtkxSerializer.getObjectByName("tables.customTableView");
        initializeTableViews();

        DragSource imageDragSource = new DragSource() {
            private Image image = null;
            private Point offset = null;
            private LocalManifest content = null;

            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);
            }
View Full Code Here

        titleLabel.setText(title);
    }

    @Override
    public void iconChanged(Window window, Image previousIcon) {
        Image icon = window.getIcon();
        iconImageView.setDisplayable(icon != null);
        iconImageView.setImage(icon);
    }
View Full Code Here

            default: {
                throw new IllegalArgumentException();
            }
        }

        Image messageIcon = null;

        if (messageIconName != null) {
            URL location = getClass().getResource(messageIconName);
            messageIcon = (Image)ApplicationContext.getResourceCache().get(location);
View Full Code Here

            default: {
                throw new IllegalArgumentException();
            }
        }

        Image smallMessageIcon = null;

        if (smallMessageIconName != null) {
            URL location = getClass().getResource(smallMessageIconName);
            smallMessageIcon = (Image)ApplicationContext.getResourceCache().get(location);
View Full Code Here

                    columnWidth, height - 1);
                dataRenderer.paint(rendererGraphics);
                rendererGraphics.dispose();

                // Draw the sort image
                Image sortImage = null;
                SortDirection sortDirection = column.getSortDirection();

                if (sortDirection != null) {
                    switch (sortDirection) {
                        case ASCENDING: {
                            sortImage = sortAscendingImage;
                            break;
                        }

                        case DESCENDING: {
                            sortImage = sortDescendingImage;
                            break;
                        }
                    }
                }

                if (sortImage != null) {
                    int sortImageMargin = sortImage.getWidth()
                    + SORT_INDICATOR_PADDING * 2;

                    if (columnWidth >= dataRenderer.getPreferredWidth(-1) + sortImageMargin) {
                        Graphics2D sortImageGraphics = (Graphics2D)graphics.create();
                        sortImageGraphics.translate(cellX + columnWidth - sortImageMargin,
                            (height - sortImage.getHeight()) / 2);
                        sortImage.paint(sortImageGraphics);
                        sortImageGraphics.dispose();
                    }
                }

                // Draw the divider
View Full Code Here

        @Override
        public void validate() {
            if (!isValid()) {
                ImageNode imageNode = (ImageNode)getNode();
                Image image = imageNode.getImage();

                if (image == null) {
                    setSize(0, 0);
                } else {
                    setSize(image.getWidth(), image.getHeight());
                }

                super.validate();
            }
        }
View Full Code Here

            }
        }

        public void paint(Graphics2D graphics) {
            ImageNode imageNode = (ImageNode)getNode();
            Image image = imageNode.getImage();

            if (image != null) {
                image.paint(graphics);
            }
        }
View Full Code Here

TOP

Related Classes of pivot.wtk.media.Image

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.