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