Search in sources :

Example 21 with ImagePanel

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

the class TinaSWFAnimatorController method updateThumbnails.

public void updateThumbnails() {
    if (randomBatchScrollPane != null) {
        randomBatchPanel.remove(randomBatchScrollPane);
        randomBatchScrollPane = null;
    }
    int panelWidth = IMG_WIDTH * IMG_COUNT + 2 * BORDER_SIZE;
    int panelHeight = (IMG_HEIGHT + 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(BORDER_SIZE, i * IMG_HEIGHT + (i + 1) * BORDER_SIZE);
        randomBatch.get(i).setImgPanel(imgPanel);
        final int idx = i;
        addRemoveButton(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) {
                    importFromRandomBatch(idx);
                }
            }
        });
        batchPanel.add(imgPanel);
    }
    randomBatchScrollPane = new JScrollPane(batchPanel);
    randomBatchScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    randomBatchScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    randomBatchPanel.add(randomBatchScrollPane, BorderLayout.CENTER);
    randomBatchPanel.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 22 with ImagePanel

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

the class TinaSWFAnimatorController method clearCurrentPreview.

private void clearCurrentPreview() {
    for (int i = 0; i < randomBatch.size(); i++) {
        FlameMovie bMovie = randomBatch.get(i).getMovie();
        if (bMovie == currMovie) {
            randomBatch.get(i).preview = null;
            ImagePanel pnl = randomBatch.get(i).getImgPanel();
            if (pnl != null) {
                pnl.replaceImage(randomBatch.get(i).getPreview(prefs.getTinaRenderPreviewQuality() / 2));
                pnl.repaint();
            }
            break;
        }
    }
}
Also used : FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 23 with ImagePanel

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

the class TinaSWFAnimatorController method replacePartBtn_clicked.

protected void replacePartBtn_clicked(FlameMoviePart pPart) {
    Flame flame = parentCtrl.getCurrFlame();
    if (flame != null) {
        pPart.setFlame(flame);
        int idx = currMovie.getParts().indexOf(pPart);
        if (idx >= 0) {
            JPanel pnl = flamePartPanelList.get(idx);
            for (Component cmp : pnl.getComponents()) {
                if (cmp instanceof ImagePanel) {
                    ImagePanel imgPnl = (ImagePanel) cmp;
                    int width = imgPnl.getBounds().width;
                    int height = imgPnl.getBounds().height;
                    SimpleImage img = createPartPreview(pPart, width, height);
                    imgPnl.setImage(img, imgPnl.getBounds().x, imgPnl.getBounds().y, width);
                    imgPnl.invalidate();
                    imgPnl.validate();
                    pnl.getParent().repaint();
                    break;
                }
            }
        }
        previewFlameImage();
        clearCurrentPreview();
        updateThumbnails();
    }
}
Also used : JPanel(javax.swing.JPanel) SimpleImage(org.jwildfire.image.SimpleImage) Component(java.awt.Component) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 24 with ImagePanel

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

the class TinaSWFAnimatorController method addFlameToFlamePanel.

private void addFlameToFlamePanel(final FlameMoviePart pPart) {
    final int PANEL_HEIGHT = 240;
    final int LABEL_WIDTH = 96;
    final int FIELD_WIDTH = 66;
    final int FIELD_HEIGHT = 24;
    final int LABEL_HEIGHT = 24;
    final int BUTTON_WIDTH = 48;
    final int BORDER_SIZE = 8;
    int imageHeight = PANEL_HEIGHT - (4 * FIELD_HEIGHT + 5 * BORDER_SIZE);
    ResolutionProfile resProfile = getResolutionProfile();
    int imageWidth = (int) (imageHeight * resProfile.getAspect() + 0.5);
    int panelWidth = LABEL_WIDTH + FIELD_WIDTH + 2 * BORDER_SIZE;
    int xOff = 0;
    if (imageWidth > 16 && imageHeight > 16) {
        int imageWidthPlusBorder = imageWidth + 2 * BORDER_SIZE;
        if (imageWidthPlusBorder > panelWidth) {
            xOff = (imageWidthPlusBorder - panelWidth) / 2;
            panelWidth = imageWidthPlusBorder;
        }
    }
    JPanel panel = new JPanel();
    panel.setPreferredSize(new Dimension(panelWidth, PANEL_HEIGHT));
    panel.setSize(new Dimension(panelWidth, PANEL_HEIGHT));
    panel.setLayout(null);
    panel.setLocation(0, 0);
    if (imageWidth > 16 && imageHeight > 16 && pPart.getFlame() != null) {
        SimpleImage img = createPartPreview(pPart, imageWidth, imageHeight);
        ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
        imgPanel.setImage(img);
        imgPanel.setLocation(BORDER_SIZE, BORDER_SIZE);
        panel.add(imgPanel);
    }
    int yOff = 2 * BORDER_SIZE + imageHeight;
    {
        JLabel framesLbl = new JLabel("Duration (frames)");
        framesLbl.setBounds(xOff + BORDER_SIZE, yOff, LABEL_WIDTH, LABEL_HEIGHT);
        panel.add(framesLbl);
        final JWFNumberField framesField = new JWFNumberField();
        framesField.setOnlyIntegers(true);
        framesField.setValue(pPart.getFrameCount());
        framesField.setHasMinValue(true);
        framesField.setFont(new Font("Dialog", Font.PLAIN, 10));
        framesField.setMinValue(1.0);
        framesField.setBounds(xOff + BORDER_SIZE + LABEL_WIDTH, yOff, FIELD_WIDTH, FIELD_HEIGHT);
        framesField.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                framesFieldChanged(framesField, pPart);
            }
        });
        panel.add(framesField);
    }
    yOff += FIELD_HEIGHT;
    {
        JLabel framesMorphLbl = new JLabel("Morph (frames)");
        framesMorphLbl.setBounds(xOff + BORDER_SIZE, yOff, LABEL_WIDTH, LABEL_HEIGHT);
        panel.add(framesMorphLbl);
        final JWFNumberField framesMorphField = new JWFNumberField();
        framesMorphField.setOnlyIntegers(true);
        framesMorphField.setHasMinValue(true);
        framesMorphField.setMinValue(0.0);
        framesMorphField.setFont(new Font("Dialog", Font.PLAIN, 10));
        framesMorphField.setValue(pPart.getFrameMorphCount());
        framesMorphField.setBounds(xOff + BORDER_SIZE + LABEL_WIDTH, yOff, FIELD_WIDTH, FIELD_HEIGHT);
        framesMorphField.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                framesMorphFieldChanged(framesMorphField, pPart);
            }
        });
        panel.add(framesMorphField);
    }
    yOff += FIELD_HEIGHT;
    {
        JLabel morphTypeLbl = new JLabel("Morph type");
        morphTypeLbl.setBounds(xOff + BORDER_SIZE, yOff, LABEL_WIDTH, LABEL_HEIGHT);
        panel.add(morphTypeLbl);
        final JComboBox morphTypeCmb = new JComboBox();
        morphTypeCmb.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                morpthTypeChanged(morphTypeCmb, pPart);
            }
        });
        morphTypeCmb.setSize(new Dimension(125, 22));
        morphTypeCmb.setFont(new Font("Dialog", Font.PLAIN, 10));
        boolean oldNoRefresh = noRefresh;
        try {
            noRefresh = true;
            morphTypeCmb.addItem(FlameMorphType.FADE);
            morphTypeCmb.addItem(FlameMorphType.MORPH);
        } finally {
            noRefresh = oldNoRefresh;
        }
        morphTypeCmb.setSelectedItem(pPart.getFlameMorphType());
        morphTypeCmb.setBounds(xOff + BORDER_SIZE + LABEL_WIDTH, yOff, FIELD_WIDTH, FIELD_HEIGHT);
        panel.add(morphTypeCmb);
    }
    yOff += FIELD_HEIGHT;
    int btnOff = BORDER_SIZE;
    {
        JButton editButton = new JButton("E");
        editButton.setBounds(btnOff, yOff, BUTTON_WIDTH, FIELD_HEIGHT);
        editButton.setFont(new Font("Dialog", Font.BOLD, 10));
        editButton.setToolTipText("Edit flame");
        editButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                editPartBtn_clicked(pPart);
            }
        });
        panel.add(editButton);
        btnOff += BUTTON_WIDTH + 1;
    }
    {
        JButton replaceButton = new JButton("R");
        replaceButton.setBounds(btnOff, yOff, BUTTON_WIDTH, FIELD_HEIGHT);
        replaceButton.setFont(new Font("Dialog", Font.BOLD, 10));
        replaceButton.setToolTipText("Replace flame with flame from editor");
        replaceButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                replacePartBtn_clicked(pPart);
            }
        });
        panel.add(replaceButton);
        btnOff += BUTTON_WIDTH + 1;
    }
    {
        JButton delButton = new JButton("D");
        delButton.setBounds(btnOff, yOff, BUTTON_WIDTH, FIELD_HEIGHT);
        delButton.setFont(new Font("Dialog", Font.BOLD, 10));
        delButton.setToolTipText("Remove flame from movie");
        delButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                deletePartBtn_clicked(pPart);
            }
        });
        panel.add(delButton);
        btnOff += BUTTON_WIDTH + 1;
    }
    JRadioButton selectButton;
    {
        selectButton = new JRadioButton("");
        selectButton.setBounds(btnOff, yOff, FIELD_WIDTH + 1, FIELD_HEIGHT);
        selectButton.setFont(new Font("Dialog", Font.PLAIN, 10));
        selectButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                enableControls();
            }
        });
        selectButton.setSelected(flamePartRadioButtonList.size() == 0);
        panel.add(selectButton);
        swfAnimatorFlamesButtonGroup.add(selectButton);
    }
    swfAnimatorFlamesPanel.add(panel);
    flamePartPanelList.add(panel);
    flamePartRadioButtonList.add(selectButton);
    swfAnimatorFlamesPanel.getParent().validate();
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) JComboBox(javax.swing.JComboBox) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Font(java.awt.Font) ChangeEvent(javax.swing.event.ChangeEvent) SimpleImage(org.jwildfire.image.SimpleImage) ChangeListener(javax.swing.event.ChangeListener) ItemListener(java.awt.event.ItemListener) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 25 with ImagePanel

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

the class TinaController method getPalettePanel.

private ImagePanel getPalettePanel() {
    if (data.palettePanel == null) {
        int width = data.paletteImgPanel.getWidth();
        int height = data.paletteImgPanel.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        data.palettePanel = new ImagePanel(img, 0, 0, data.paletteImgPanel.getWidth());
        data.paletteImgPanel.add(data.palettePanel, BorderLayout.CENTER);
        data.paletteImgPanel.getParent().validate();
    }
    return data.palettePanel;
}
Also used : SimpleImage(org.jwildfire.image.SimpleImage) 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