use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class TinaController method updateThumbnails.
public void updateThumbnails() {
if (data.randomBatchScrollPane != null) {
data.randomBatchPanel.remove(data.randomBatchScrollPane);
data.randomBatchScrollPane = null;
}
int panelWidth = FlameThumbnail.IMG_WIDTH + 2 * FlameThumbnail.BORDER_SIZE;
int panelHeight = (FlameThumbnail.IMG_HEIGHT + FlameThumbnail.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(FlameThumbnail.BORDER_SIZE, i * FlameThumbnail.IMG_HEIGHT + (i + 1) * FlameThumbnail.BORDER_SIZE);
randomBatch.get(i).setImgPanel(imgPanel);
final int idx = i;
addRemoveButton(imgPanel, idx);
JCheckBox checkbox = addSelectCheckbox(imgPanel, idx);
randomBatch.get(i).setSelectCheckbox(checkbox);
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);
}
data.randomBatchScrollPane = new JScrollPane(batchPanel);
data.randomBatchScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
data.randomBatchScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
data.randomBatchPanel.add(data.randomBatchScrollPane, BorderLayout.CENTER);
data.randomBatchPanel.validate();
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class TinaController method refreshPaletteImg.
private void refreshPaletteImg() {
try {
if (getCurrLayer() != null) {
ImagePanel[] panels = { getPalettePanel(), getColorChooserPalettePanel() };
for (ImagePanel imgPanel : panels) {
int width = imgPanel.getWidth();
int height = imgPanel.getHeight();
if (width >= 16 && height >= 4) {
if (getCurrLayer().getGradientMapFilename() != null && getCurrLayer().getGradientMapFilename().length() > 0) {
SimpleImage img = (SimpleImage) RessourceManager.getImage(getCurrLayer().getGradientMapFilename());
imgPanel.setImage(img, 0, 0, width, height);
} else {
SimpleImage img = new RGBPaletteRenderer().renderHorizPalette(getCurrLayer().getPalette(), width, height);
imgPanel.setImage(img);
}
}
imgPanel.getParent().validate();
imgPanel.repaint();
}
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class TinaController method refreshFilterKernelPreviewImg.
protected void refreshFilterKernelPreviewImg() {
try {
if (getCurrFlame() != null) {
ImagePanel imgPanel = getFilterKernelPreviewPanel();
int width = imgPanel.getWidth();
int height = imgPanel.getHeight();
if (width >= 16 && height >= 4) {
SimpleImage img = getFilterKernelVisualisationRenderer(data.filterKernelFlatPreviewBtn.isSelected()).createKernelVisualisation(width, height);
imgPanel.setImage(img);
}
imgPanel.getParent().validate();
imgPanel.repaint();
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class TinaController method getColorChooserPalettePanel.
private ImagePanel getColorChooserPalettePanel() {
if (data.colorChooserPalettePanel == null) {
int width = data.colorChooserPaletteImgPanel.getWidth();
int height = data.colorChooserPaletteImgPanel.getHeight();
SimpleImage img = new SimpleImage(width, height);
img.fillBackground(0, 0, 0);
data.colorChooserPalettePanel = new ImagePanel(img, 0, 0, data.colorChooserPaletteImgPanel.getWidth());
data.colorChooserPaletteImgPanel.add(data.colorChooserPalettePanel, BorderLayout.CENTER);
data.colorChooserPaletteImgPanel.getParent().validate();
}
return data.colorChooserPalettePanel;
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class TinaInteractiveRendererController method refreshImagePanel.
private void refreshImagePanel() {
if (imageScrollPane != null) {
imageRootPanel.remove(imageScrollPane);
imageScrollPane = null;
}
ResolutionProfile profile = getResolutionProfile();
int width = profile.getWidth();
int height = profile.getHeight();
if (quarterSizeButton.isSelected()) {
width /= 4;
height /= 4;
} else if (halveSizeButton.isSelected()) {
width /= 2;
height /= 2;
}
image = new SimpleImage(width, height);
image.getBufferedImg().setAccelerationPriority(1.0f);
image.fillBackground(prefs.getTinaRandomBatchBGColorRed(), prefs.getTinaRandomBatchBGColorGreen(), prefs.getTinaRandomBatchBGColorBlue());
ImagePanel imagePanel = new ImagePanel(image, 0, 0, image.getImageWidth());
imagePanel.setSize(image.getImageWidth(), image.getImageHeight());
imagePanel.setPreferredSize(new Dimension(image.getImageWidth(), image.getImageHeight()));
imageScrollPane = new JScrollPane(imagePanel);
imageScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
imageScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
imageRootPanel.add(imageScrollPane, BorderLayout.CENTER);
imageRootPanel.getParent().validate();
}
Aggregations