Search in sources :

Example 21 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel in project JWildfire by thargor6.

the class MeshGenController method removeFlamePanel.

private void removeFlamePanel(JPanel pRootPanel) {
    FlamePanel flamePanel = flamepanels.get(pRootPanel);
    if (flamePanel != null) {
        pRootPanel.remove(flamePanel);
        flamepanels.remove(pRootPanel);
    }
}
Also used : FlamePanel(org.jwildfire.create.tina.swing.flamepanel.FlamePanel)

Example 22 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel 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 23 with FlamePanel

use of org.jwildfire.create.tina.swing.flamepanel.FlamePanel 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)

Aggregations

FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)23 SimpleImage (org.jwildfire.image.SimpleImage)20 Rectangle (java.awt.Rectangle)9 Flame (org.jwildfire.create.tina.base.Flame)9 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)9 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)9 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)9 ResolutionProfile (org.jwildfire.base.ResolutionProfile)5 FlamePanelConfig (org.jwildfire.create.tina.swing.flamepanel.FlamePanelConfig)3 Point (java.awt.Point)2 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)2 DrawFocusPointFlameRenderer (org.jwildfire.create.tina.render.DrawFocusPointFlameRenderer)2 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 MouseEvent (java.awt.event.MouseEvent)1 MouseWheelEvent (java.awt.event.MouseWheelEvent)1 MouseWheelListener (java.awt.event.MouseWheelListener)1 EmptyBorder (javax.swing.border.EmptyBorder)1 Prefs (org.jwildfire.base.Prefs)1 ComposeTransformer (org.jwildfire.transform.ComposeTransformer)1