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;
}
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());
}
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();
}
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;
}
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;
}
Aggregations