Search in sources :

Example 1 with ImagePanel

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

the class MutaGenController method drawSelectedSet.

public void drawSelectedSet() {
    Dimension imgSize = calcImageSize();
    MutationSet selectedSet = mutationList.get(selectedGenerationIdx);
    int rows = selectedSet.getRows();
    int cols = selectedSet.getCols();
    initProgress(rows, cols);
    int step = 0;
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            Flame mutation = selectedSet.getFlame(i, j).makeCopy();
            Flame morphed = createWeightedFlame(selectedSet.getBaseFlame(), mutation);
            SimpleImage renderedImg = renderFlame(morphed, imgSize, false);
            ImagePanel pnl = imagePanels[i][j];
            pnl.setImage(renderedImg);
            showProgress(++step);
            pnl.invalidate();
            try {
                Graphics g = pnl.getGraphics();
                if (g != null) {
                    pnl.paint(g);
                }
            } catch (Throwable ex) {
                ex.printStackTrace();
            }
        }
    }
    enableControls();
}
Also used : Graphics(java.awt.Graphics) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 2 with ImagePanel

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

the class MutaGenController method selectCell.

protected void selectCell(int pRow, int pCol) {
    createImagePanels();
    final Color selColor = new Color(65, 63, 147);
    final Color deSelColor = new Color(0, 0, 0);
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            ImagePanel pnl = imagePanels[i][j];
            boolean sel = i == pRow && j == pCol;
            ((JPanel) pnl.getParent()).setBorder(new LineBorder(sel ? selColor : deSelColor, sel ? 5 : 1));
        }
    }
    selRow = pRow;
    selCol = pCol;
    enableControls();
}
Also used : JPanel(javax.swing.JPanel) Color(java.awt.Color) LineBorder(javax.swing.border.LineBorder) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 3 with ImagePanel

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

the class IFlamesController method refreshFlameLibrary.

private void refreshFlameLibrary() {
    if (flameLibraryScrollPane != null) {
        flameLibraryPanel.remove(flameLibraryScrollPane);
        flameLibraryScrollPane = null;
    }
    int panelWidth = FlameThumbnail.IMG_WIDTH + 2 * FlameThumbnail.BORDER_SIZE;
    int panelHeight = (FlameThumbnail.IMG_HEIGHT + FlameThumbnail.BORDER_SIZE) * flameLibrary.size();
    JPanel batchPanel = new JPanel();
    batchPanel.setLayout(null);
    batchPanel.setSize(panelWidth, panelHeight);
    batchPanel.setPreferredSize(new Dimension(panelWidth, panelHeight));
    for (int i = 0; i < flameLibrary.size(); i++) {
        SimpleImage img = flameLibrary.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);
        flameLibrary.get(i).setImgPanel(imgPanel);
        final int idx = i;
        addRemoveFlameFromLibraryButton(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) {
                    importFromFlameLibrary(idx);
                }
            }
        });
        batchPanel.add(imgPanel);
    }
    flameLibraryScrollPane = new JScrollPane(batchPanel);
    flameLibraryScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    flameLibraryScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    flameLibraryPanel.add(flameLibraryScrollPane, BorderLayout.CENTER);
    flameLibraryScrollPane.validate();
    flameLibraryScrollPane.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 4 with ImagePanel

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

the class DancingFractalsController method getGraph1Panel.

private ImagePanel getGraph1Panel() {
    if (graph1Panel == null && graph1RootPanel != null) {
        int width = graph1RootPanel.getWidth();
        int height = graph1RootPanel.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        graph1Panel = new ImagePanel(img, 0, 0, graph1RootPanel.getWidth());
        graph1RootPanel.add(graph1Panel, BorderLayout.CENTER);
        graph1RootPanel.getParent().validate();
        graph1RootPanel.repaint();
    }
    return graph1Panel;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 5 with ImagePanel

use of org.jwildfire.swing.ImagePanel 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)

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