use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class FlameBrowserController method deleteBtn_clicked.
public void deleteBtn_clicked() {
FlameFlatNode node = getSelectedFlame();
if (node != null) {
try {
if (StandardDialogs.confirm(rootPanel, "Do you really want to permanently delete this flame?")) {
File file = new File(node.getFilename());
if (!file.delete()) {
throw new Exception("Could not delete file");
}
node.setRemoved(false);
ImagePanel pnl = pnlList.get(selectedPnl);
SimpleImage img = pnl.getImage();
TextTransformer txt = new TextTransformer();
txt.setText1("(deleted)");
txt.setAntialiasing(true);
txt.setColor(Color.RED);
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();
}
} catch (Exception ex) {
errorHandler.handleError(ex);
}
}
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class FlameBrowserController method selectCell.
protected void selectCell(int pIndex) {
for (int i = 0; i < pnlList.size(); i++) {
ImagePanel pnl = pnlList.get(i);
boolean sel = (i == pIndex);
pnl.setBorder(new LineBorder(sel ? selectedCellColor : deselectedCellColor, borderSize));
}
imgRootPanel.invalidate();
imgRootPanel.validate();
selectedPnl = pIndex;
enableControls();
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class Launcher method loadImages.
private void loadImages() {
frame.setTitle("Welcome to " + Tools.APP_TITLE + " " + Tools.APP_VERSION);
// Load logo
try {
SimpleImage img = getImage(Tools.SPECIAL_VERSION ? "logo_special.png" : "logo.png");
northPanel.setLayout(null);
ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
imgPanel.setPreferredSize(new Dimension(img.getImageWidth(), img.getImageHeight()));
imgPanel.setLocation(Tools.SPECIAL_VERSION ? 7 : 107, 4);
getNorthPanel().add(imgPanel);
} catch (Exception ex) {
ex.printStackTrace();
}
String imageFilename = "";
try {
if (Tools.SPECIAL_VERSION) {
final int IMG_COUNT = 3;
int imageIdx = (int) (Math.random() * IMG_COUNT) + 1;
String id = String.valueOf(imageIdx);
while (id.length() < 3) {
id = "0" + id;
}
imageFilename = "special" + id + ".jpg";
} else {
final int IMG_COUNT = 101;
int imageIdx = Tools.randomInt(IMG_COUNT) + 1;
String id = String.valueOf(imageIdx);
while (id.length() < 3) {
id = "0" + id;
}
imageFilename = "image" + id + ".jpg";
}
SimpleImage img = getImage(imageFilename);
imgDisplayPanel.setLayout(null);
ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
getImgDisplayPanel().add(imgPanel);
// System.out.println(imgDisplayPanel.getSize().height + " " + imgDisplayPanel.getSize().width);
imgPanel.setLayout(null);
} catch (Throwable ex) {
System.out.println(imageFilename);
ex.printStackTrace();
}
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class IFlamesController method refreshImageLibrary.
private void refreshImageLibrary() {
if (imageLibraryScrollPane != null) {
imageLibraryPanel.remove(imageLibraryScrollPane);
imageLibraryScrollPane = null;
}
int panelWidth = ImageThumbnail.IMG_WIDTH + 2 * ImageThumbnail.BORDER_SIZE;
int panelHeight = 0;
for (int i = 0; i < imageLibrary.size(); i++) {
panelHeight += ImageThumbnail.BORDER_SIZE + imageLibrary.get(i).getPreview().getImageHeight();
}
JPanel batchPanel = new JPanel();
batchPanel.setLayout(null);
batchPanel.setSize(panelWidth, panelHeight);
batchPanel.setPreferredSize(new Dimension(panelWidth, panelHeight));
int yOff = ImageThumbnail.BORDER_SIZE;
for (int i = 0; i < imageLibrary.size(); i++) {
SimpleImage img = imageLibrary.get(i).getPreview();
ImagePanel imgPanel = new ImagePanel(img, 0, 0, img.getImageWidth());
imgPanel.setImage(img);
imgPanel.setLocation(ImageThumbnail.BORDER_SIZE, yOff);
yOff += img.getImageHeight() + ImageThumbnail.BORDER_SIZE;
imageLibrary.get(i).setImgPanel(imgPanel);
final int idx = i;
addRemoveImageFromLibraryButton(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) {
importFromImageLibrary(idx);
}
}
});
batchPanel.add(imgPanel);
}
imageLibraryScrollPane = new JScrollPane(batchPanel);
imageLibraryScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
imageLibraryScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
imageLibraryPanel.add(imageLibraryScrollPane, BorderLayout.CENTER);
imageLibraryScrollPane.validate();
imageLibraryScrollPane.getParent().validate();
}
use of org.jwildfire.swing.ImagePanel in project JWildfire by thargor6.
the class MeshGenController method refreshPreview.
protected void refreshPreview(boolean pFastPreview) {
ImagePanel panel = getPreviewPanel();
int width = panel.getWidth();
int height = panel.getHeight();
panel.setImage(renderPreviewImage(width, height, pFastPreview));
previewRootPanel.repaint();
}
Aggregations