Search in sources :

Example 11 with ImagePanel

use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.

the class FlameBrowserController method deleteBtn_clicked.

public void deleteBtn_clicked() {
    FlameFlatNode node = getSelectedFlame();
    if (node != null) {
        try {
            if (StandardDialogs.confirm(rootPanel, "Do you really want to permanently delete this flame?")) {
                File file = new File(node.getFilename());
                if (!file.delete()) {
                    throw new Exception("Could not delete file");
                }
                node.setRemoved(false);
                ImagePanel pnl = pnlList.get(selectedPnl);
                SimpleImage img = pnl.getImage();
                TextTransformer txt = new TextTransformer();
                txt.setText1("(deleted)");
                txt.setAntialiasing(true);
                txt.setColor(Color.RED);
                txt.setMode(Mode.NORMAL);
                txt.setFontStyle(FontStyle.BOLD);
                txt.setFontName("Arial");
                txt.setFontSize(24);
                txt.setHAlign(HAlignment.CENTRE);
                txt.setVAlign(VAlignment.CENTRE);
                txt.transformImage(img);
                pnl.invalidate();
                pnl.repaint();
            }
        } catch (Exception ex) {
            errorHandler.handleError(ex);
        }
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) TextTransformer(org.jwildfire.transform.TextTransformer) File(java.io.File) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 12 with ImagePanel

use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.

the class FlameBrowserController method selectCell.

protected void selectCell(int pIndex) {
    for (int i = 0; i < pnlList.size(); i++) {
        ImagePanel pnl = pnlList.get(i);
        boolean sel = (i == pIndex);
        pnl.setBorder(new LineBorder(sel ? selectedCellColor : deselectedCellColor, borderSize));
    }
    imgRootPanel.invalidate();
    imgRootPanel.validate();
    selectedPnl = pIndex;
    enableControls();
}
Also used : LineBorder(javax.swing.border.LineBorder) Point(java.awt.Point) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 13 with ImagePanel

use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.

the class Launcher method loadImages.

private void loadImages() {
    frame.setTitle("Welcome to " + Tools.APP_TITLE + " " + Tools.APP_VERSION);
    // Load logo
    try {
        SimpleImage img = getImage(Tools.SPECIAL_VERSION ? "logo_special.png" : "logo.png");
        northPanel.setLayout(null);
        ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
        imgPanel.setPreferredSize(new Dimension(img.getImageWidth(), img.getImageHeight()));
        imgPanel.setLocation(Tools.SPECIAL_VERSION ? 7 : 107, 4);
        getNorthPanel().add(imgPanel);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    String imageFilename = "";
    try {
        if (Tools.SPECIAL_VERSION) {
            final int IMG_COUNT = 3;
            int imageIdx = (int) (Math.random() * IMG_COUNT) + 1;
            String id = String.valueOf(imageIdx);
            while (id.length() < 3) {
                id = "0" + id;
            }
            imageFilename = "special" + id + ".jpg";
        } else {
            final int IMG_COUNT = 101;
            int imageIdx = Tools.randomInt(IMG_COUNT) + 1;
            String id = String.valueOf(imageIdx);
            while (id.length() < 3) {
                id = "0" + id;
            }
            imageFilename = "image" + id + ".jpg";
        }
        SimpleImage img = getImage(imageFilename);
        imgDisplayPanel.setLayout(null);
        ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
        getImgDisplayPanel().add(imgPanel);
        // System.out.println(imgDisplayPanel.getSize().height + " " + imgDisplayPanel.getSize().width);
        imgPanel.setLayout(null);
    } catch (Throwable ex) {
        System.out.println(imageFilename);
        ex.printStackTrace();
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 14 with ImagePanel

use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.

the class IFlamesController method refreshImageLibrary.

private void refreshImageLibrary() {
    if (imageLibraryScrollPane != null) {
        imageLibraryPanel.remove(imageLibraryScrollPane);
        imageLibraryScrollPane = null;
    }
    int panelWidth = ImageThumbnail.IMG_WIDTH + 2 * ImageThumbnail.BORDER_SIZE;
    int panelHeight = 0;
    for (int i = 0; i < imageLibrary.size(); i++) {
        panelHeight += ImageThumbnail.BORDER_SIZE + imageLibrary.get(i).getPreview().getImageHeight();
    }
    JPanel batchPanel = new JPanel();
    batchPanel.setLayout(null);
    batchPanel.setSize(panelWidth, panelHeight);
    batchPanel.setPreferredSize(new Dimension(panelWidth, panelHeight));
    int yOff = ImageThumbnail.BORDER_SIZE;
    for (int i = 0; i < imageLibrary.size(); i++) {
        SimpleImage img = imageLibrary.get(i).getPreview();
        ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
        imgPanel.setImage(img);
        imgPanel.setLocation(ImageThumbnail.BORDER_SIZE, yOff);
        yOff += img.getImageHeight() + ImageThumbnail.BORDER_SIZE;
        imageLibrary.get(i).setImgPanel(imgPanel);
        final int idx = i;
        addRemoveImageFromLibraryButton(imgPanel, idx);
        imgPanel.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent e) {
                if (e.getClickCount() > 1 || e.getButton() != MouseEvent.BUTTON1) {
                    importFromImageLibrary(idx);
                }
            }
        });
        batchPanel.add(imgPanel);
    }
    imageLibraryScrollPane = new JScrollPane(batchPanel);
    imageLibraryScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    imageLibraryScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    imageLibraryPanel.add(imageLibraryScrollPane, BorderLayout.CENTER);
    imageLibraryScrollPane.validate();
    imageLibraryScrollPane.getParent().validate();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) MouseEvent(java.awt.event.MouseEvent) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 15 with ImagePanel

use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.

the class MeshGenController method refreshPreview.

protected void refreshPreview(boolean pFastPreview) {
    ImagePanel panel = getPreviewPanel();
    int width = panel.getWidth();
    int height = panel.getHeight();
    panel.setImage(renderPreviewImage(width, height, pFastPreview));
    previewRootPanel.repaint();
}
Also used : ImagePanel(org.jwildfire.swing.ImagePanel)

Aggregations

ImagePanel (org.jwildfire.swing.ImagePanel)30 SimpleImage (org.jwildfire.image.SimpleImage)24 Dimension (java.awt.Dimension)15 JPanel (javax.swing.JPanel)9 JScrollPane (javax.swing.JScrollPane)8 MouseEvent (java.awt.event.MouseEvent)6 Flame (org.jwildfire.create.tina.base.Flame)4 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)4 LineBorder (javax.swing.border.LineBorder)3 ResolutionProfile (org.jwildfire.base.ResolutionProfile)3 Font (java.awt.Font)2 Graphics (java.awt.Graphics)2 Point (java.awt.Point)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 JLabel (javax.swing.JLabel)2 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)2 TextTransformer (org.jwildfire.transform.TextTransformer)2 Color (java.awt.Color)1 Component (java.awt.Component)1