Search in sources :

Example 21 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class DancingFractalsController method getPoolPreviewFlamePanel.

private FlamePanel getPoolPreviewFlamePanel() {
    if (poolFlamePreviewFlamePanel == null && poolFlamePreviewPnl != null) {
        int width = poolFlamePreviewPnl.getWidth();
        int height = poolFlamePreviewPnl.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        poolFlamePreviewFlamePanel = new FlamePanel(prefs, img, 0, 0, poolFlamePreviewPnl.getWidth(), poolFlameHolder, null);
        poolFlamePreviewFlamePanel.setRenderWidth(640);
        poolFlamePreviewFlamePanel.setRenderHeight(480);
        poolFlamePreviewFlamePanel.setDrawTriangles(false);
        poolFlamePreviewPnl.add(poolFlamePreviewFlamePanel, BorderLayout.CENTER);
        poolFlamePreviewPnl.getParent().validate();
        poolFlamePreviewPnl.repaint();
    }
    return poolFlamePreviewFlamePanel;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel)

Example 22 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class FlameBrowserController method transferFlameToFolder.

private void transferFlameToFolder(boolean bMove) {
    FlameFlatNode node = getSelectedFlame();
    if (node != null) {
        try {
            JFileChooser chooser = new JFileChooser();
            chooser = new JFileChooser();
            chooser.setDialogTitle("Specify destination-directory");
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            File srcFile = new File(node.getFilename());
            File preselected = lastCopyToDrawer != null ? new File(lastCopyToDrawer, srcFile.getName()) : new File(srcFile.getName());
            chooser.setSelectedFile(preselected);
            if (chooser.showOpenDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
                lastCopyToDrawer = chooser.getSelectedFile().getParentFile();
                File dstFile = chooser.getSelectedFile();
                if (bMove) {
                    Files.move(srcFile.toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
                    node.setRemoved(true);
                } else {
                    Files.copy(srcFile.toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
                }
                ImagePanel pnl = pnlList.get(selectedPnl);
                SimpleImage img = pnl.getImage();
                TextTransformer txt = new TextTransformer();
                txt.setText1(bMove ? "(moved)" : "(copied)");
                txt.setAntialiasing(true);
                txt.setColor(bMove ? Color.RED : Color.GRAY);
                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();
                enableControls();
            }
        } catch (Exception ex) {
            errorHandler.handleError(ex);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) SimpleImage(org.jwildfire.image.SimpleImage) TextTransformer(org.jwildfire.transform.TextTransformer) File(java.io.File) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 23 with SimpleImage

use of org.jwildfire.image.SimpleImage 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 24 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class BatchRendererController method getBatchPreviewFlamePanel.

private FlamePanel getBatchPreviewFlamePanel() {
    if (batchPreviewFlamePanel == null) {
        int width = data.batchPreviewRootPanel.getWidth();
        int height = data.batchPreviewRootPanel.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        batchPreviewFlamePanel = new FlamePanel(prefs, img, 0, 0, data.batchPreviewRootPanel.getWidth(), getBatchRenderPreviewFlameHolder(), null);
        ResolutionProfile resProfile = getBatchRenderResolutionProfile();
        batchPreviewFlamePanel.setRenderWidth(resProfile.getWidth());
        batchPreviewFlamePanel.setRenderHeight(resProfile.getHeight());
        batchPreviewFlamePanel.setDrawTriangles(false);
        data.batchPreviewRootPanel.add(batchPreviewFlamePanel, BorderLayout.CENTER);
        data.batchPreviewRootPanel.getParent().validate();
        data.batchPreviewRootPanel.repaint();
    }
    return batchPreviewFlamePanel;
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel)

Example 25 with SimpleImage

use of org.jwildfire.image.SimpleImage in project JWildfire by thargor6.

the class BatchRendererController method renderBatchJobsTableClicked.

public void renderBatchJobsTableClicked() {
    FlamePanel imgPanel = getBatchPreviewFlamePanel();
    Rectangle bounds = imgPanel.getImageBounds();
    int width = bounds.width;
    int height = bounds.height;
    Flame flame = getBatchRenderPreviewFlameHolder().getFlame();
    if (width >= 16 && height >= 16) {
        RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
        if (flame != null) {
            double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
            double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
            flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
            flame.setWidth(info.getImageWidth());
            flame.setHeight(info.getImageHeight());
            FlameRenderer renderer = new FlameRenderer(flame, prefs, data.toggleTransparencyButton.isSelected(), false);
            flame.setSampleDensity(prefs.getTinaRenderRealtimeQuality());
            flame.setSpatialFilterRadius(0.0);
            RenderedFlame res = renderer.renderFlame(info);
            imgPanel.setImage(res.getImage());
        } else {
            imgPanel.setImage(new SimpleImage(width, height));
        }
    }
    data.batchPreviewRootPanel.invalidate();
    data.batchPreviewRootPanel.validate();
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) Rectangle(java.awt.Rectangle) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Aggregations

SimpleImage (org.jwildfire.image.SimpleImage)174 Pixel (org.jwildfire.image.Pixel)37 ImagePanel (org.jwildfire.swing.ImagePanel)24 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)20 Dimension (java.awt.Dimension)18 Flame (org.jwildfire.create.tina.base.Flame)17 File (java.io.File)16 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)16 ArrayList (java.util.ArrayList)14 Rectangle (java.awt.Rectangle)12 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)12 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)12 Graphics (java.awt.Graphics)10 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)10 WFImage (org.jwildfire.image.WFImage)9 ImageReader (org.jwildfire.io.ImageReader)9 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)8 ResolutionProfile (org.jwildfire.base.ResolutionProfile)8 Color (java.awt.Color)7