Search in sources :

Example 6 with ImagePanel

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

the class FlameBrowserController method showImages.

private void showImages(List<FlameFlatNode> pFlames) {
    cancelRenderThreads();
    final int IMG_WIDTH = 160;
    final int IMG_HEIGHT = 100;
    final int OUTER_BORDER = 20;
    final int INNER_BORDER = 10;
    final int LABEL_HEIGHT = 12;
    int maxPnlWidth = imagesPnl.getSize().width;
    int cols = calcCols(IMG_WIDTH, OUTER_BORDER, INNER_BORDER, maxPnlWidth);
    int rows = pFlames.size() / cols;
    if (rows * cols < pFlames.size()) {
        rows++;
    }
    int pnlWidth = 2 * OUTER_BORDER + (cols - 1) * INNER_BORDER + cols * IMG_WIDTH;
    int pnlHeight = 2 * OUTER_BORDER + (rows - 1) * INNER_BORDER + rows * (IMG_HEIGHT + LABEL_HEIGHT);
    imgRootPanel = new JPanel();
    imgRootPanel.setLayout(null);
    imgRootPanel.setSize(pnlWidth, pnlHeight);
    imgRootPanel.setPreferredSize(new Dimension(pnlWidth, pnlHeight));
    int flameIdx = 0;
    pnlList = new ArrayList<ImagePanel>();
    lblList = new ArrayList<JLabel>();
    selectedPnl = -1;
    int y = OUTER_BORDER;
    List<RenderJobInfo> jobInfoLst = new ArrayList<RenderJobInfo>();
    for (int r = 0; r < rows; r++) {
        int x = OUTER_BORDER;
        for (int c = 0; c < cols; c++) {
            if (flameIdx < pFlames.size()) {
                // image
                final FlameFlatNode node = pFlames.get(flameIdx++);
                ImagePanel imgPanel;
                SimpleImage img = renderCache.getImage(node, IMG_WIDTH, IMG_HEIGHT);
                if (img == null) {
                    img = new SimpleImage(IMG_WIDTH, IMG_HEIGHT);
                    img.fillBackground(0, 0, 0);
                    imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
                    jobInfoLst.add(new RenderJobInfo(imgPanel, node, IMG_WIDTH, IMG_HEIGHT, x, y));
                } else {
                    imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
                }
                imgPanel.setImage(img);
                imgPanel.setLocation(x, y);
                imgPanel.setBorder(new LineBorder(deselectedCellColor, borderSize));
                pnlList.add(imgPanel);
                final int pnlIdx = pnlList.size() - 1;
                imgPanel.addMouseListener(new java.awt.event.MouseAdapter() {

                    @Override
                    public void mouseClicked(java.awt.event.MouseEvent e) {
                        if (e.getClickCount() > 1 || e.getButton() != MouseEvent.BUTTON1) {
                            nodeToEditor(node);
                        }
                    }

                    @Override
                    public void mousePressed(MouseEvent e) {
                        selectCell(pnlIdx);
                    }
                });
                imgRootPanel.add(imgPanel);
                // label with description
                JLabel label = new JLabel();
                label.setText(node.getCaption());
                label.setSize(new Dimension(IMG_WIDTH, LABEL_HEIGHT));
                label.setPreferredSize(new Dimension(IMG_WIDTH, LABEL_HEIGHT));
                label.setLocation(new Point(x, y + IMG_HEIGHT));
                label.setFont(new Font("Dialog", Font.BOLD, 10));
                label.setHorizontalAlignment(SwingConstants.CENTER);
                label.setVerticalAlignment(SwingConstants.CENTER);
                imgRootPanel.add(label);
                lblList.add(label);
                // 
                x += IMG_WIDTH + INNER_BORDER;
            } else {
                break;
            }
        }
        y += IMG_HEIGHT + INNER_BORDER + LABEL_HEIGHT;
    }
    selectedPnl = pnlList.size() > 0 ? 0 : -1;
    selectCell(selectedPnl);
    imagesScrollPane = new JScrollPane(imgRootPanel);
    imagesScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    imagesScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    imagesPnl.add(imagesScrollPane, BorderLayout.CENTER);
    if (jobInfoLst.size() > 0) {
        startRenderThread(jobInfoLst);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) LineBorder(javax.swing.border.LineBorder) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Point(java.awt.Point) Point(java.awt.Point) MouseEvent(java.awt.event.MouseEvent) Font(java.awt.Font) SimpleImage(org.jwildfire.image.SimpleImage) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 7 with ImagePanel

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

the class FlamePreviewHelper method refreshThumbnail.

private void refreshThumbnail() {
    Flame flame = flameHolder.getFlame();
    List<FlameThumbnail> randomBatch = randomBatchHolder.getRandomBatch();
    for (int i = 0; i < randomBatch.size(); i++) {
        Flame bFlame = randomBatch.get(i).getFlame();
        if (bFlame == flame) {
            randomBatch.get(i).setPreview(null);
            ImagePanel pnl = randomBatch.get(i).getImgPanel();
            if (pnl != null) {
                pnl.replaceImage(randomBatch.get(i).getPreview(prefs.getTinaRenderPreviewQuality() / 2));
                pnl.repaint();
            }
            break;
        }
    }
}
Also used : XYZProjectedPoint(org.jwildfire.create.tina.base.XYZProjectedPoint) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 8 with ImagePanel

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

the class FlamesGPURenderController method refreshImagePanel.

private void refreshImagePanel() {
    if (imageScrollPane != null) {
        imageRootPanel.remove(imageScrollPane);
        imageScrollPane = null;
    }
    ResolutionProfile profile = getResolutionProfile();
    int width = profile.getWidth();
    int height = profile.getHeight();
    if (quarterSizeButton.isSelected()) {
        width /= 4;
        height /= 4;
    } else if (halveSizeButton.isSelected()) {
        width /= 2;
        height /= 2;
    }
    image = new SimpleImage(width, height);
    image.getBufferedImg().setAccelerationPriority(1.0f);
    image.fillBackground(prefs.getTinaRandomBatchBGColorRed(), prefs.getTinaRandomBatchBGColorGreen(), prefs.getTinaRandomBatchBGColorBlue());
    ImagePanel imagePanel = new ImagePanel(image, 0, 0, image.getImageWidth());
    imagePanel.setSize(image.getImageWidth(), image.getImageHeight());
    imagePanel.setPreferredSize(new Dimension(image.getImageWidth(), image.getImageHeight()));
    imageScrollPane = new JScrollPane(imagePanel);
    imageScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    imageScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    imageRootPanel.add(imageScrollPane, BorderLayout.CENTER);
    imageRootPanel.getParent().validate();
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) JScrollPane(javax.swing.JScrollPane) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 9 with ImagePanel

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

the class TinaController method getFilterKernelPreviewPanel.

private ImagePanel getFilterKernelPreviewPanel() {
    if (data.filterKernelPreviewPanel == null) {
        int width = data.filterKernelPreviewRootPnl.getWidth();
        int height = data.filterKernelPreviewRootPnl.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        data.filterKernelPreviewPanel = new ImagePanel(img, 0, 0, data.filterKernelPreviewRootPnl.getWidth());
        data.filterKernelPreviewRootPnl.add(data.filterKernelPreviewPanel, BorderLayout.CENTER);
        data.filterKernelPreviewRootPnl.getParent().validate();
    }
    return data.filterKernelPreviewPanel;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 10 with ImagePanel

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

the class JWildfireApplet method refreshImagePanel.

private void refreshImagePanel() {
    if (imageScrollPane != null) {
        getImgMainPnl().remove(imageScrollPane);
        imageScrollPane = null;
    }
    ImgSize size = getImgSize();
    image = new SimpleImage(size.getWidth(), size.getHeight());
    image.fillBackground(prefs.getTinaRandomBatchBGColorRed(), prefs.getTinaRandomBatchBGColorGreen(), prefs.getTinaRandomBatchBGColorBlue());
    ImagePanel imagePanel = new ImagePanel(image, 0, 0, image.getImageWidth());
    imagePanel.setSize(image.getImageWidth(), image.getImageHeight());
    imagePanel.setPreferredSize(new Dimension(image.getImageWidth(), image.getImageHeight()));
    imageScrollPane = new JScrollPane(imagePanel);
    imageScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    imageScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    getImgMainPnl().add(imageScrollPane, BorderLayout.CENTER);
    getImgMainPnl().getParent().validate();
}
Also used : JScrollPane(javax.swing.JScrollPane) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) 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