use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class MutaGenController method drawSelectedSet.
public void drawSelectedSet() {
Dimension imgSize = calcImageSize();
MutationSet selectedSet = mutationList.get(selectedGenerationIdx);
int rows = selectedSet.getRows();
int cols = selectedSet.getCols();
initProgress(rows, cols);
int step = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
Flame mutation = selectedSet.getFlame(i, j).makeCopy();
Flame morphed = createWeightedFlame(selectedSet.getBaseFlame(), mutation);
SimpleImage renderedImg = renderFlame(morphed, imgSize, false);
ImagePanel pnl = imagePanels[i][j];
pnl.setImage(renderedImg);
showProgress(++step);
pnl.invalidate();
try {
Graphics g = pnl.getGraphics();
if (g != null) {
pnl.paint(g);
}
} catch (Throwable ex) {
ex.printStackTrace();
}
}
}
enableControls();
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class MutaGenController method selectCell.
protected void selectCell(int pRow, int pCol) {
createImagePanels();
final Color selColor = new Color(65, 63, 147);
final Color deSelColor = new Color(0, 0, 0);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
ImagePanel pnl = imagePanels[i][j];
boolean sel = i == pRow && j == pCol;
((JPanel) pnl.getParent()).setBorder(new LineBorder(sel ? selColor : deSelColor, sel ? 5 : 1));
}
}
selRow = pRow;
selCol = pCol;
enableControls();
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class IFlamesController method refreshFlameLibrary.
private void refreshFlameLibrary() {
if (flameLibraryScrollPane != null) {
flameLibraryPanel.remove(flameLibraryScrollPane);
flameLibraryScrollPane = null;
}
int panelWidth = FlameThumbnail.IMG_WIDTH + 2 * FlameThumbnail.BORDER_SIZE;
int panelHeight = (FlameThumbnail.IMG_HEIGHT + FlameThumbnail.BORDER_SIZE) * flameLibrary.size();
JPanel batchPanel = new JPanel();
batchPanel.setLayout(null);
batchPanel.setSize(panelWidth, panelHeight);
batchPanel.setPreferredSize(new Dimension(panelWidth, panelHeight));
for (int i = 0; i < flameLibrary.size(); i++) {
SimpleImage img = flameLibrary.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);
flameLibrary.get(i).setImgPanel(imgPanel);
final int idx = i;
addRemoveFlameFromLibraryButton(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) {
importFromFlameLibrary(idx);
}
}
});
batchPanel.add(imgPanel);
}
flameLibraryScrollPane = new JScrollPane(batchPanel);
flameLibraryScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
flameLibraryScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
flameLibraryPanel.add(flameLibraryScrollPane, BorderLayout.CENTER);
flameLibraryScrollPane.validate();
flameLibraryScrollPane.getParent().validate();
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class DancingFractalsController method getGraph1Panel.
private ImagePanel getGraph1Panel() {
if (graph1Panel == null && graph1RootPanel != null) {
int width = graph1RootPanel.getWidth();
int height = graph1RootPanel.getHeight();
SimpleImage img = new SimpleImage(width, height);
img.fillBackground(0, 0, 0);
graph1Panel = new ImagePanel(img, 0, 0, graph1RootPanel.getWidth());
graph1RootPanel.add(graph1Panel, BorderLayout.CENTER);
graph1RootPanel.getParent().validate();
graph1RootPanel.repaint();
}
return graph1Panel;
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class FlameBrowserController method transferFlameToFolder.
private void transferFlameToFolder(boolean bMove) {
FlameFlatNode node = getSelectedFlame();
if (node != null) {
try {
JFileChooser chooser = new JFileChooser();
chooser = new JFileChooser();
chooser.setDialogTitle("Specify destination-directory");
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
File srcFile = new File(node.getFilename());
File preselected = lastCopyToDrawer != null ? new File(lastCopyToDrawer, srcFile.getName()) : new File(srcFile.getName());
chooser.setSelectedFile(preselected);
if (chooser.showOpenDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
lastCopyToDrawer = chooser.getSelectedFile().getParentFile();
File dstFile = chooser.getSelectedFile();
if (bMove) {
Files.move(srcFile.toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
node.setRemoved(true);
} else {
Files.copy(srcFile.toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
ImagePanel pnl = pnlList.get(selectedPnl);
SimpleImage img = pnl.getImage();
TextTransformer txt = new TextTransformer();
txt.setText1(bMove ? "(moved)" : "(copied)");
txt.setAntialiasing(true);
txt.setColor(bMove ? Color.RED : Color.GRAY);
txt.setMode(Mode.NORMAL);
txt.setFontStyle(FontStyle.BOLD);
txt.setFontName("Arial");
txt.setFontSize(24);
txt.setHAlign(HAlignment.CENTRE);
txt.setVAlign(VAlignment.CENTRE);
txt.transformImage(img);
pnl.invalidate();
pnl.repaint();
enableControls();
}
} catch (Exception ex) {
errorHandler.handleError(ex);
}
}
}
Aggregations