Search in sources :

Example 21 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaSWFAnimatorController method getFlamePanel.

private FlamePanel getFlamePanel() {
    if (flamePanel == null) {
        int width = swfAnimatorPreviewRootPanel.getWidth();
        int height = swfAnimatorPreviewRootPanel.getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        flamePanel = new FlamePanel(prefs, img, 0, 0, swfAnimatorPreviewRootPanel.getWidth(), this, null);
        ResolutionProfile resProfile = getResolutionProfile();
        flamePanel.setRenderWidth(resProfile.getWidth());
        flamePanel.setRenderHeight(resProfile.getHeight());
        flamePanel.setFocusable(true);
        swfAnimatorPreviewRootPanel.add(flamePanel, BorderLayout.CENTER);
        swfAnimatorPreviewRootPanel.getParent().validate();
        swfAnimatorPreviewRootPanel.repaint();
        flamePanel.requestFocusInWindow();
    }
    return flamePanel;
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) SimpleImage(org.jwildfire.image.SimpleImage) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel)

Example 22 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaSWFAnimatorController method updateMovieFields.

protected void updateMovieFields() {
    double framesPerSecond = swfAnimatorFramesPerSecondREd.getDoubleValue();
    ResolutionProfile resProfile = getResolutionProfile();
    int frameWidth = resProfile.getWidth();
    int frameHeight = resProfile.getHeight();
    for (int i = 0; i < globalScripts.size(); i++) {
        ScriptContainer container = globalScripts.get(i);
        currMovie.getGlobalScripts()[i] = getGlobalScriptFromUI(container.getScriptCmb(), container.getScriptREd());
    }
    for (int i = 0; i < xFormScripts.size(); i++) {
        ScriptContainer container = xFormScripts.get(i);
        currMovie.getxFormScripts()[i] = getXFormScriptFromUI(container.getScriptCmb(), container.getScriptREd());
    }
    currMovie.setFrameWidth(frameWidth);
    currMovie.setFrameHeight(frameHeight);
    currMovie.setQuality(getQualityProfile().getQuality());
    currMovie.setFramesPerSecond(framesPerSecond);
    currMovie.setMotionBlurLength(swfAnimatorMotionBlurLengthREd.getIntValue());
    currMovie.setMotionBlurTimeStep(swfAnimatorMotionBlurTimeStepREd.getDoubleValue());
    currMovie.setSequenceOutputType((SequenceOutputType) swfAnimatorOutputTypeCmb.getSelectedItem());
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile)

Example 23 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile 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 24 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaController method getFlamePanel.

@Override
public FlamePanel getFlamePanel() {
    if (flamePanel == null) {
        int width = centerPanel.getParent().getWidth();
        int height = centerPanel.getParent().getHeight();
        SimpleImage img = new SimpleImage(width, height);
        img.fillBackground(0, 0, 0);
        flamePanel = new FlamePanel(prefs, img, 0, 0, centerPanel.getParent().getWidth(), this, this);
        flamePanel.getConfig().setWithColoredTransforms(prefs.isTinaEditorControlsWithColor());
        flamePanel.getConfig().setProgressivePreview(prefs.isTinaEditorProgressivePreview());
        flamePanel.setFlamePanelTriangleMode(prefs.getTinaEditorControlsStyle());
        flamePanel.importOptions(prevFlamePanel);
        prevFlamePanel = null;
        flamePanel.setUndoManagerHolder(this);
        ResolutionProfile resProfile = getResolutionProfile();
        flamePanel.setRenderWidth(resProfile.getWidth());
        flamePanel.setRenderHeight(resProfile.getHeight());
        flamePanel.setFocusable(true);
        flamePanel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {

            @Override
            public void mouseDragged(MouseEvent e) {
                flamePanel_mouseDragged(e);
                dragging = true;
            }
        });
        flamePanel.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                flamePanel_mousePressed(e);
            }

            @Override
            public void mouseClicked(java.awt.event.MouseEvent e) {
                flamePanel_mouseClicked(e);
                flamePanel.requestFocusInWindow();
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                if (dragging) {
                    refreshFlameImage(true, false, 1, true, false);
                    flamePanel_mouseReleased(e);
                }
                dragging = false;
            }
        });
        flamePanel.addMouseWheelListener(new MouseWheelListener() {

            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                flamePanel_mouseWheelEvent(e);
            }
        });
        flamePanel.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                if (keypressing) {
                    return;
                }
                keypressing = true;
                try {
                    // || e.isAltGraphDown());
                    boolean altPressed = e.isAltDown();
                    boolean shiftPressed = e.isShiftDown();
                    boolean ctrlPressed = e.isControlDown();
                    switch(e.getKeyCode()) {
                        // left
                        case 37:
                            if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.MOVE_TRIANGLE) {
                                if (altPressed) {
                                    xForm_rotateLeft();
                                } else if (ctrlPressed) {
                                    xForm_moveLeft(0.1);
                                } else if (shiftPressed) {
                                    xForm_moveLeft(10.0);
                                } else {
                                    xForm_moveLeft(1.0);
                                }
                            } else if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.GRADIENT) {
                                gradientMarker_move(0, -1);
                            }
                            break;
                        // right
                        case 39:
                            if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.MOVE_TRIANGLE) {
                                if (altPressed) {
                                    xForm_rotateRight();
                                } else if (ctrlPressed) {
                                    xForm_moveRight(0.1);
                                } else if (shiftPressed) {
                                    xForm_moveRight(10.0);
                                } else {
                                    xForm_moveRight(1.0);
                                }
                            } else if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.GRADIENT) {
                                gradientMarker_move(0, 1);
                            }
                            break;
                        // up
                        case 38:
                            if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.MOVE_TRIANGLE) {
                                if (altPressed) {
                                    xForm_enlarge();
                                } else if (ctrlPressed) {
                                    xForm_moveUp(0.1);
                                } else if (shiftPressed) {
                                    xForm_moveUp(10.0);
                                } else {
                                    xForm_moveUp(1.0);
                                }
                            } else if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.GRADIENT) {
                                gradientMarker_move(1, 1);
                            }
                            break;
                        // down
                        case 40:
                            if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.MOVE_TRIANGLE) {
                                if (altPressed) {
                                    xForm_shrink();
                                } else if (ctrlPressed) {
                                    xForm_moveDown(0.1);
                                } else if (shiftPressed) {
                                    xForm_moveDown(10.0);
                                } else {
                                    xForm_moveDown(1.0);
                                }
                            } else if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.GRADIENT) {
                                gradientMarker_move(1, -1);
                            }
                            break;
                        // 1
                        case 49:
                            if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.GRADIENT) {
                                gradientMarker_selectColor(0);
                            }
                            break;
                        // 1
                        case 50:
                            if (flamePanel.getConfig().getMouseDragOperation() == MouseDragOperation.GRADIENT) {
                                gradientMarker_selectColor(1);
                            }
                            break;
                    }
                } finally {
                    flamePanel.requestFocus();
                    keypressing = false;
                }
            }
        });
        flamePanel.setSelectedXForm(getCurrXForm());
        if (firstFlamePanel) {
            try {
                centerPanel.getParent().remove(0);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            firstFlamePanel = false;
        }
        centerPanel.add(flamePanel, BorderLayout.CENTER);
        centerPanel.getParent().validate();
        centerPanel.repaint();
        flamePanel.requestFocusInWindow();
    }
    return flamePanel;
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) MouseEvent(java.awt.event.MouseEvent) KeyAdapter(java.awt.event.KeyAdapter) FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel) MouseWheelListener(java.awt.event.MouseWheelListener) MouseEvent(java.awt.event.MouseEvent) KeyEvent(java.awt.event.KeyEvent) MouseWheelEvent(java.awt.event.MouseWheelEvent) SimpleImage(org.jwildfire.image.SimpleImage)

Example 25 with ResolutionProfile

use of org.jwildfire.base.ResolutionProfile in project JWildfire by thargor6.

the class TinaController method generateExportFlame.

private Flame generateExportFlame(Flame pFlame) {
    Flame res = pFlame.makeCopy();
    ResolutionProfile resProfile = getResolutionProfile();
    double wScl = (double) resProfile.getWidth() / (double) res.getWidth();
    double hScl = (double) resProfile.getHeight() / (double) res.getHeight();
    res.setPixelsPerUnit((wScl + hScl) * 0.5 * res.getPixelsPerUnit());
    res.setWidth(resProfile.getWidth());
    res.setHeight(resProfile.getHeight());
    return res;
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Aggregations

ResolutionProfile (org.jwildfire.base.ResolutionProfile)29 SimpleImage (org.jwildfire.image.SimpleImage)8 Flame (org.jwildfire.create.tina.base.Flame)7 QualityProfile (org.jwildfire.base.QualityProfile)6 ArrayList (java.util.ArrayList)5 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)5 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)5 Dimension (java.awt.Dimension)3 Point (java.awt.Point)3 File (java.io.File)3 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)3 ImagePanel (org.jwildfire.swing.ImagePanel)3 JFileChooser (javax.swing.JFileChooser)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 Test (org.junit.Test)2 Layer (org.jwildfire.create.tina.base.Layer)2 XForm (org.jwildfire.create.tina.base.XForm)2 HeadlessBatchRendererController (org.jwildfire.create.tina.batch.HeadlessBatchRendererController)2 Job (org.jwildfire.create.tina.batch.Job)2