Search in sources :

Example 26 with ImagePanel

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

the class TinaController method updateThumbnails.

public void updateThumbnails() {
    if (data.randomBatchScrollPane != null) {
        data.randomBatchPanel.remove(data.randomBatchScrollPane);
        data.randomBatchScrollPane = null;
    }
    int panelWidth = FlameThumbnail.IMG_WIDTH + 2 * FlameThumbnail.BORDER_SIZE;
    int panelHeight = (FlameThumbnail.IMG_HEIGHT + FlameThumbnail.BORDER_SIZE) * randomBatch.size();
    JPanel batchPanel = new JPanel();
    batchPanel.setLayout(null);
    batchPanel.setSize(panelWidth, panelHeight);
    batchPanel.setPreferredSize(new Dimension(panelWidth, panelHeight));
    for (int i = 0; i < randomBatch.size(); i++) {
        SimpleImage img = randomBatch.get(i).getPreview(3 * prefs.getTinaRenderPreviewQuality() / 4);
        // add it to the main panel
        ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
        imgPanel.setImage(img);
        imgPanel.setLocation(FlameThumbnail.BORDER_SIZE, i * FlameThumbnail.IMG_HEIGHT + (i + 1) * FlameThumbnail.BORDER_SIZE);
        randomBatch.get(i).setImgPanel(imgPanel);
        final int idx = i;
        addRemoveButton(imgPanel, idx);
        JCheckBox checkbox = addSelectCheckbox(imgPanel, idx);
        randomBatch.get(i).setSelectCheckbox(checkbox);
        imgPanel.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent e) {
                if (e.getClickCount() > 1 || e.getButton() != MouseEvent.BUTTON1) {
                    importFromRandomBatch(idx);
                }
            }
        });
        batchPanel.add(imgPanel);
    }
    data.randomBatchScrollPane = new JScrollPane(batchPanel);
    data.randomBatchScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    data.randomBatchScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    data.randomBatchPanel.add(data.randomBatchScrollPane, BorderLayout.CENTER);
    data.randomBatchPanel.validate();
}
Also used : JCheckBox(javax.swing.JCheckBox) 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 27 with ImagePanel

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

the class TinaController method refreshPaletteImg.

private void refreshPaletteImg() {
    try {
        if (getCurrLayer() != null) {
            ImagePanel[] panels = { getPalettePanel(), getColorChooserPalettePanel() };
            for (ImagePanel imgPanel : panels) {
                int width = imgPanel.getWidth();
                int height = imgPanel.getHeight();
                if (width >= 16 && height >= 4) {
                    if (getCurrLayer().getGradientMapFilename() != null && getCurrLayer().getGradientMapFilename().length() > 0) {
                        SimpleImage img = (SimpleImage) RessourceManager.getImage(getCurrLayer().getGradientMapFilename());
                        imgPanel.setImage(img, 0, 0, width, height);
                    } else {
                        SimpleImage img = new RGBPaletteRenderer().renderHorizPalette(getCurrLayer().getPalette(), width, height);
                        imgPanel.setImage(img);
                    }
                }
                imgPanel.getParent().validate();
                imgPanel.repaint();
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) RGBPaletteRenderer(org.jwildfire.create.tina.palette.RGBPaletteRenderer) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 28 with ImagePanel

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

the class TinaController method refreshFilterKernelPreviewImg.

protected void refreshFilterKernelPreviewImg() {
    try {
        if (getCurrFlame() != null) {
            ImagePanel imgPanel = getFilterKernelPreviewPanel();
            int width = imgPanel.getWidth();
            int height = imgPanel.getHeight();
            if (width >= 16 && height >= 4) {
                SimpleImage img = getFilterKernelVisualisationRenderer(data.filterKernelFlatPreviewBtn.isSelected()).createKernelVisualisation(width, height);
                imgPanel.setImage(img);
            }
            imgPanel.getParent().validate();
            imgPanel.repaint();
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 29 with ImagePanel

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

the class TinaController method getColorChooserPalettePanel.

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

Example 30 with ImagePanel

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

the class TinaInteractiveRendererController 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) XYZProjectedPoint(org.jwildfire.create.tina.base.XYZProjectedPoint) 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