use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class FlameBrowserController method showImages.
private void showImages(List<FlameFlatNode> pFlames) {
cancelRenderThreads();
final int IMG_WIDTH = 160;
final int IMG_HEIGHT = 100;
final int OUTER_BORDER = 20;
final int INNER_BORDER = 10;
final int LABEL_HEIGHT = 12;
int maxPnlWidth = imagesPnl.getSize().width;
int cols = calcCols(IMG_WIDTH, OUTER_BORDER, INNER_BORDER, maxPnlWidth);
int rows = pFlames.size() / cols;
if (rows * cols < pFlames.size()) {
rows++;
}
int pnlWidth = 2 * OUTER_BORDER + (cols - 1) * INNER_BORDER + cols * IMG_WIDTH;
int pnlHeight = 2 * OUTER_BORDER + (rows - 1) * INNER_BORDER + rows * (IMG_HEIGHT + LABEL_HEIGHT);
imgRootPanel = new JPanel();
imgRootPanel.setLayout(null);
imgRootPanel.setSize(pnlWidth, pnlHeight);
imgRootPanel.setPreferredSize(new Dimension(pnlWidth, pnlHeight));
int flameIdx = 0;
pnlList = new ArrayList<ImagePanel>();
lblList = new ArrayList<JLabel>();
selectedPnl = -1;
int y = OUTER_BORDER;
List<RenderJobInfo> jobInfoLst = new ArrayList<RenderJobInfo>();
for (int r = 0; r < rows; r++) {
int x = OUTER_BORDER;
for (int c = 0; c < cols; c++) {
if (flameIdx < pFlames.size()) {
// image
final FlameFlatNode node = pFlames.get(flameIdx++);
ImagePanel imgPanel;
SimpleImage img = renderCache.getImage(node, IMG_WIDTH, IMG_HEIGHT);
if (img == null) {
img = new SimpleImage(IMG_WIDTH, IMG_HEIGHT);
img.fillBackground(0, 0, 0);
imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
jobInfoLst.add(new RenderJobInfo(imgPanel, node, IMG_WIDTH, IMG_HEIGHT, x, y));
} else {
imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
}
imgPanel.setImage(img);
imgPanel.setLocation(x, y);
imgPanel.setBorder(new LineBorder(deselectedCellColor, borderSize));
pnlList.add(imgPanel);
final int pnlIdx = pnlList.size() - 1;
imgPanel.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseClicked(java.awt.event.MouseEvent e) {
if (e.getClickCount() > 1 || e.getButton() != MouseEvent.BUTTON1) {
nodeToEditor(node);
}
}
@Override
public void mousePressed(MouseEvent e) {
selectCell(pnlIdx);
}
});
imgRootPanel.add(imgPanel);
// label with description
JLabel label = new JLabel();
label.setText(node.getCaption());
label.setSize(new Dimension(IMG_WIDTH, LABEL_HEIGHT));
label.setPreferredSize(new Dimension(IMG_WIDTH, LABEL_HEIGHT));
label.setLocation(new Point(x, y + IMG_HEIGHT));
label.setFont(new Font("Dialog", Font.BOLD, 10));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setVerticalAlignment(SwingConstants.CENTER);
imgRootPanel.add(label);
lblList.add(label);
//
x += IMG_WIDTH + INNER_BORDER;
} else {
break;
}
}
y += IMG_HEIGHT + INNER_BORDER + LABEL_HEIGHT;
}
selectedPnl = pnlList.size() > 0 ? 0 : -1;
selectCell(selectedPnl);
imagesScrollPane = new JScrollPane(imgRootPanel);
imagesScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
imagesScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
imagesPnl.add(imagesScrollPane, BorderLayout.CENTER);
if (jobInfoLst.size() > 0) {
startRenderThread(jobInfoLst);
}
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class FlamePreviewHelper method refreshThumbnail.
private void refreshThumbnail() {
Flame flame = flameHolder.getFlame();
List<FlameThumbnail> randomBatch = randomBatchHolder.getRandomBatch();
for (int i = 0; i < randomBatch.size(); i++) {
Flame bFlame = randomBatch.get(i).getFlame();
if (bFlame == flame) {
randomBatch.get(i).setPreview(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 FlamesGPURenderController 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();
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class TinaController method getFilterKernelPreviewPanel.
private ImagePanel getFilterKernelPreviewPanel() {
if (data.filterKernelPreviewPanel == null) {
int width = data.filterKernelPreviewRootPnl.getWidth();
int height = data.filterKernelPreviewRootPnl.getHeight();
SimpleImage img = new SimpleImage(width, height);
img.fillBackground(0, 0, 0);
data.filterKernelPreviewPanel = new ImagePanel(img, 0, 0, data.filterKernelPreviewRootPnl.getWidth());
data.filterKernelPreviewRootPnl.add(data.filterKernelPreviewPanel, BorderLayout.CENTER);
data.filterKernelPreviewRootPnl.getParent().validate();
}
return data.filterKernelPreviewPanel;
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class JWildfireApplet method refreshImagePanel.
private void refreshImagePanel() {
if (imageScrollPane != null) {
getImgMainPnl().remove(imageScrollPane);
imageScrollPane = null;
}
ImgSize size = getImgSize();
image = new SimpleImage(size.getWidth(), size.getHeight());
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);
getImgMainPnl().add(imageScrollPane, BorderLayout.CENTER);
getImgMainPnl().getParent().validate();
}
Aggregations