Show a progress dialog while waiting for a long-running AI Analysis to complet

This commit is contained in:
Bane Stojkovic
2026-08-06 15:44:45 +02:00
parent 02237c9255
commit c37a2b8310
5 changed files with 281 additions and 204 deletions
@@ -1,80 +1,84 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core.images;
import org.apache.log4j.Logger;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
/**
* Loads image resources as Icons.
*
* @author Branislav Stojkovic
*/
public enum IconLoader {
Delete("delete.png"), Add("add.png"), FolderOut("folder_out.png"), Garbage("garbage.png"), DiskBlue("disk_blue.png"), SaveAs(
"save_as.png"), Exit("exit.png"), DocumentPlainYellow("document_plain_yellow.png"), PhotoScenery(
"photo_scenery.png"), LightBulbOn("lightbulb_on.png"), LightBulbOff("lightbulb_off.png"), NotebookAdd(
"notebook_add.png"), FormGreen("form_green.png"), Gears("gears.png"), About("about.png"), WindowColors(
"window_colors.png"), WindowGear("window_gear.png"), NavigateCheck("navigate_check.png"), Undo("undo.png"), Error(
"error.png"), Warning("warning.png"), ZoomSmall("zoom_small.png"), MoveSmall("move_small.png"), Print("print.png"), PDF(
"pdf.png"), Excel("excel.png"), CSV("csv.png"), HTML("html.png"), Image("image.png"), Cut("cut.png"), Copy(
"copy.png"), Paste("paste.png"), Selection("selection.png"), BOM("bom.png"), BlackBoard("blackboard.png"), IdCard(
"id_card.png"), IdCardAdd("id_card_add.png"), Chest("chest.png"), Upload("upload.png"), Wrench("wrench.png"), Group(
"group.png"), Ungroup("ungroup.png"), TraceMask("trace_mask.png"), Faq("faq.png"), Component("component.png"), Plugin(
"plugin.png"), Manual("manual.png"), Donate("donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
"edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png"), Pens("pens.png"), Sort("sort.png"), ElementsSelection(
"elements_selection.png"), Schaller("schaller.png");
protected String name;
private IconLoader(String name) {
this.name = name;
}
public Icon getIcon() {
java.net.URL imgURL = getClass().getResource("/diylc-core-images/" + name);
if (imgURL != null) {
return new ImageIcon(imgURL, name);
} else {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
return null;
}
}
public Image getImage() {
BufferedImage img = null;
try {
img = ImageIO.read(getClass().getResourceAsStream("/diylc-core-images/" + name));
} catch (IOException e) {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
}
return img;
}
}
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core.images;
import org.apache.log4j.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
* Loads image resources as Icons.
*
* @author Branislav Stojkovic
*/
public enum IconLoader {
About("about.png"), Add("add.png"), BOM("bom.png"), Back("back.png"), BlackBoard(
"blackboard.png"), Bug("bug.png"), CSV("csv.png"), Chest("chest.png"), Component(
"component.png"), Copy("copy.png"), Cut("cut.png"), Delete("delete.png"), DiskBlue(
"disk_blue.png"), DocumentEdit("document_edit.png"), DocumentPlainYellow(
"document_plain_yellow.png"), Donate("donate.png"), EditComponent(
"edit_component.png"), ElementsSelection("elements_selection.png"), Error("error.png"), Excel(
"excel.png"), Exit("exit.png"), Faq("faq.png"), FolderOut("folder_out.png"), FormGreen(
"form_green.png"), Front("front.png"), Garbage("garbage.png"), Gears("gears.png"), Group(
"group.png"), HTML("html.png"), IconLarge("icon_large.png"), IconMedium(
"icon_medium.png"), IconSmall("icon_small.png"), IdCard("id_card.png"), IdCardAdd(
"id_card_add.png"), Image("image.png"), LightBulbOff("lightbulb_off.png"), LightBulbOn(
"lightbulb_on.png"), Manual("manual.png"), MoveSmall("move_small.png"), NavigateCheck(
"navigate_check.png"), NotebookAdd("notebook_add.png"), PDF("pdf.png"), Paste(
"paste.png"), Pens("pens.png"), PhotoScenery("photo_scenery.png"), Plugin(
"plugin.png"), Print("print.png"), SaveAs("save_as.png"), Schaller("schaller.png"), Selection(
"selection.png"), Size("size.png"), Sort("sort.png"), TraceMask("trace_mask.png"), Undo(
"undo.png"), Ungroup("ungroup.png"), Upload("upload.png"), Warning(
"warning.png"), WindowColors("window_colors.png"), WindowGear("window_gear.png"), Wrench(
"wrench.png"), ZoomSmall("zoom_small.png");
protected String name;
private IconLoader(String name) {
this.name = name;
}
public Icon getIcon() {
java.net.URL imgURL = getClass().getResource("/diylc-core-images/" + name);
if (imgURL != null) {
return new ImageIcon(imgURL, name);
} else {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
return null;
}
}
public Image getImage() {
BufferedImage img = null;
try {
img = ImageIO.read(getClass().getResourceAsStream("/diylc-core-images/" + name));
} catch (IOException e) {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
}
return img;
}
}
@@ -388,5 +388,21 @@
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>6</major>
<minor>3</minor>
<build>0</build>
</versionNumber>
<releaseDate>2026-08-06 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Show a progress dialog while waiting for a long-running AI Analysis to complete</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
</a>
</java.util.Arrays_-ArrayList>
@@ -1,10 +1,6 @@
package org.diylc.swing.actions.analyze;
import org.diylc.common.INetlistAnalyzer;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ITask;
import org.diylc.netlist.Netlist;
import org.diylc.netlist.Summary;
import org.diylc.swing.ISwingUI;
import org.diylc.swingframework.TextDialog;
import org.diylc.utils.IconLoader;
@@ -12,13 +8,40 @@ import org.diylc.utils.IconLoader;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.List;
import java.util.Optional;
public class AiAnalyzeAction extends AbstractAction {
private static final long serialVersionUID = 1L;
private static final String[] WAITING_MESSAGES = {
"The AI is analyzing your circuit. This might take a little while...",
"Please wait while the AI processes your schematic...",
"AI analysis in progress. Grab a coffee, this could take a minute...",
"The AI is examining your components. This will take some time...",
"Sending your circuit to the AI. Please be patient...",
"The AI is working on your layout. This may take a moment...",
"Hold tight! The AI is taking a deep dive into your circuit...",
"AI review is underway. This process takes a little while...",
"The AI is evaluating your design. Thanks for your patience...",
"Analyzing your circuit with AI. This is a complex task and will take some time...",
"The AI is currently inspecting your schematic. This could take a while...",
"Please hold while the AI computes your circuit analysis...",
"AI processing started. This operation may take several seconds...",
"The AI is reviewing your layout. This might take a bit of time...",
"Circuit analysis by AI in progress. Please wait a moment...",
"The AI is carefully examining your design. This will take a while...",
"Running AI diagnostics on your circuit. Please be patient...",
"The AI is generating your analysis. This process can take some time...",
"Your schematic is being analyzed by the AI. This may take a little while...",
"AI is hard at work on your circuit. Thanks for waiting...",
"The AI is analyzing your circuit. Please hold while it makes sure no magic smoke escapes...",
"Sending your schematic to the AI. This might take a while, AI needs its coffee too...",
"The AI is working on your layout. It takes time to translate circuits into binary poetry...",
"Hold tight! The AI is calculating the optimal path of least resistance...",
"AI review is underway. This could take a minute, depending on how tangled your wires are..."
};
private IPlugInPort plugInPort;
private ISwingUI swingUI;
@@ -33,30 +56,48 @@ public class AiAnalyzeAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
swingUI.executeBackgroundTask(new ITask<String>() {
String message = WAITING_MESSAGES[(int) (Math.random() * WAITING_MESSAGES.length)];
JOptionPane optionPane = new JOptionPane(message,
JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, IconLoader.BrainBig.getIcon(),
new Object[] {"Cancel"});
JDialog dialog = optionPane.createDialog(swingUI.getOwnerFrame(), "AI Circuit Analyzer");
dialog.setModal(true);
SwingWorker<String, Void> worker = new SwingWorker<String, Void>() {
@Override
public String doInBackground() throws Exception {
protected String doInBackground() throws Exception {
return plugInPort.getChatbotService().analyzeCircuit();
}
@Override
public void failed(Exception e) {
String message =
Optional.ofNullable(e.getCause()).map(Throwable::getMessage).orElse(e.getMessage());
swingUI.showMessage(message, "AI Circuit Analyzer", ISwingUI.ERROR_MESSAGE);
}
@Override
public void complete(String res) {
if (res == null || res.isEmpty()) {
swingUI.showMessage("The generated analysis is empty, nothing to show.",
"AI Circuit Analyzer", ISwingUI.INFORMATION_MESSAGE);
protected void done() {
dialog.dispose();
if (isCancelled()) {
return;
}
new TextDialog(swingUI.getOwnerFrame().getRootPane(), res, "AI Circuit Analyzer",
new Dimension(800, 600)).setVisible(true);
try {
String res = get();
if (res == null || res.isEmpty()) {
swingUI.showMessage("The generated analysis is empty, nothing to show.",
"AI Circuit Analyzer", ISwingUI.INFORMATION_MESSAGE);
return;
}
new TextDialog(swingUI.getOwnerFrame().getRootPane(), res, "AI Circuit Analyzer",
new Dimension(800, 600)).setVisible(true);
} catch (Exception ex) {
String message =
Optional.ofNullable(ex.getCause()).map(Throwable::getMessage).orElse(ex.getMessage());
swingUI.showMessage(message, "AI Circuit Analyzer", ISwingUI.ERROR_MESSAGE);
}
}
}, true);
};
worker.execute();
dialog.setVisible(true);
if (!worker.isDone()) {
worker.cancel(true);
}
}
}
@@ -1,103 +1,119 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.utils;
import org.apache.log4j.Logger;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
/**
* Loads image resources as Icons.
*
* @author Branislav Stojkovic
*/
public enum IconLoader {
Delete("delete.png"), Add("add.png"), FolderOut("folder_out.png"), Garbage("garbage.png"), DiskBlue("disk_blue.png"), SaveAs(
"save_as.png"), Exit("exit.png"), DocumentPlainYellow("document_plain_yellow.png"), PhotoScenery(
"photo_scenery.png"), LightBulbOn("lightbulb_on.png"), LightBulbOff("lightbulb_off.png"), NotebookAdd(
"notebook_add.png"), FormGreen("form_green.png"), Gears("gears.png"), About("about.png"), WindowColors(
"window_colors.png"), WindowGear("window_gear.png"), NavigateCheck("navigate_check.png"), Undo("undo.png"), Error(
"error.png"), Warning("warning.png"), ZoomSmall("zoom_small.png"), MoveSmall("move_small.png"), Print("print.png"), PDF(
"pdf.png"), Excel("excel.png"), CSV("csv.png"), HTML("html.png"), Image("image.png"), Cut("cut.png"), Copy(
"copy.png"), Paste("paste.png"), Selection("selection.png"), BOM("bom.png"), BlackBoard("blackboard.png"), IdCard(
"id_card.png"), IdCardAdd("id_card_add.png"), Chest("chest.png"), Upload("upload.png"), Wrench("wrench.png"), Group(
"group.png"), Ungroup("ungroup.png"), TraceMask("trace_mask.png"), Faq("faq.png"), Component("component.png"), Plugin(
"plugin.png"), Manual("manual.png"), Donate("donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
"edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png"), Pens("pens.png"), Sort("sort.png"), ElementsSelection(
"elements_selection.png"), BranchAdd("branch_add.png"), BriefcaseAdd("briefcase_add.png"), BriefcaseInto(
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW("rotate_ccw.png"), ElementInto("element_into.png"), Arrow(
"arrow.png"), Cloud("cloud.png"), CloudUp("cloud_up.png"), CloudGear("cloud_gear.png"), IdCardEdit(
"id_card_edit.png"), KeyEdit("key_edit.png"), Find("find.png"), Dashboard("dashboard.png"), DataFind(
"data_find.png"), CloudDownload("cloud_download.png"), CloudDelete("cloud_delete.png"), CloudEdit(
"cloud_edit.png"), CloudUpload("cloud_upload.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue(
"nav_right_blue.png"), MissingImage("missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait(
"cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png"), Messages(
"messages.png"), SearchBox("search-box.png"), Screwdriver("screwdriver.png"), Hammer("hammer.png"), FlipHorizontal(
"flip_horizontal.png"), FlipVertical("flip_vertical.png"), MagicWand("magic_wand.png"), PinGrey("pin_grey.png"), PinGreen(
"pin_green.png"), CoffeebeanEdit("coffeebean_edit.png"), ApplicationEdit("application_edit.png"), ComponentAdd(
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png"), FitToSize("fit_to_size.png"), DocumentsGear(
"documents_gear.png"), SplashResistor("splash_resistor.png"), SplashCeramic("splash_ceramic.png"), SplashElectrolytic(
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png"), ScrollInformation("scroll_information.png"),
Node("node.png"), Web("web.png"), Guitar("guitar.png"), Scientist("scientist.png"), StarGrey("star_grey.png"), StarBlue("star_blue.png"),
JarBeanInto("jar_bean_into.png"), GraphEdgeDirected("graph_edge_directed.png"), LaserPointer("laserpointer.png"), TapeMeasure("tape_measure1.png"),
Elements("elements1.png"), GraphNodes("graph_nodes.png"), User("user1.png"), FlexibleLeads("flexible_leads.png"), Pads("pads.png"), Lock("lock.png"),
Unlock("lock_open.png"), Earth("earth.png"), Loadline("loadline.png"), LoadlineAdd("loadline_add.png"), SnapToGrid("snap_to_grid.png"),
SnapToComponents("snap_to_components.png"), SnapToNone("snap_to_none.png"), TraceProximity("trace_proximity.png"),
ComponentLarge("component_large.png"), ImportNetlist("import_netlist.png"), SplashIC("splash_ic.png"),
ComponentPreferences("component_preferences.png"), ComponentReplace("component_replace.png"), Barcode("barcode.png"),
DocumentGerber("document_gerber.png"), DocumentX2("document_x2.png"), Export("export.png"), Multimeter("multimeter.png"),
Patreon("patreon.png"), Brain("brain.png"), Tables("tables.png"), Silkscreen("silkscreen.png"),
Project("project.png"), DocumentInfo("document_info.png");
protected String name;
private IconLoader(String name) {
this.name = name;
}
public Icon getIcon() {
java.net.URL imgURL = getClass().getResource("/diylc-swing-images/" + name);
if (imgURL != null) {
return new ImageIcon(imgURL, name);
} else {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
return null;
}
}
public Image getImage() {
BufferedImage img = null;
try {
img = ImageIO.read(getClass().getResourceAsStream("/diylc-swing-images/" + name));
} catch (IOException e) {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
}
return img;
}
}
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.utils;
import org.apache.log4j.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
* Loads image resources as Icons.
*
* @author Branislav Stojkovic
*/
public enum IconLoader {
About("about.png"), Add("add.png"), ApplicationEdit("application_edit.png"), Arrow(
"arrow.png"), BOM("bom.png"), Back("back.png"), Barcode("barcode.png"), BlackBoard(
"blackboard.png"), Brain("brain.png"), BrainBig("brain_big.png"), BranchAdd(
"branch_add.png"), BriefcaseAdd("briefcase_add.png"), BriefcaseInto(
"briefcase_into.png"), Bug("bug.png"), CSV("csv.png"), Chest("chest.png"), Cloud(
"cloud.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudDelete(
"cloud_delete.png"), CloudDownload("cloud_download.png"), CloudEdit(
"cloud_edit.png"), CloudGear("cloud_gear.png"), CloudUp("cloud_up.png"), CloudUpload(
"cloud_upload.png"), CloudWait("cloud_wait.png"), CoffeebeanEdit(
"coffeebean_edit.png"), Component("component.png"), ComponentAdd(
"component_add.png"), ComponentLarge("component_large.png"), ComponentPreferences(
"component_preferences.png"), ComponentReplace("component_replace.png"), Copy(
"copy.png"), Cut("cut.png"), Dashboard("dashboard.png"), DataFind("data_find.png"), Delete(
"delete.png"), DiskBlue("disk_blue.png"), DocumentEdit("document_edit.png"), DocumentGerber(
"document_gerber.png"), DocumentInfo("document_info.png"), DocumentPlain(
"document_plain.png"), DocumentPlainYellow("document_plain_yellow.png"), DocumentX2(
"document_x2.png"), DocumentsGear("documents_gear.png"), Donate("donate.png"), Download(
"download.png"), Earth("earth.png"), EditComponent("edit_component.png"), ElementInto(
"element_into.png"), Elements("elements1.png"), ElementsSelection(
"elements_selection.png"), Error("error.png"), Excel("excel.png"), Exit("exit.png"), Export(
"export.png"), Eye("eye.png"), Faq("faq.png"), Find("find.png"), FitToSize(
"fit_to_size.png"), FlexibleLeads("flexible_leads.png"), FlipHorizontal(
"flip_horizontal.png"), FlipVertical("flip_vertical.png"), FolderOut(
"folder_out.png"), FormGreen("form_green.png"), Front("front.png"), Garbage(
"garbage.png"), Gears("gears.png"), GraphEdgeDirected("graph_edge_directed.png"), GraphNodes(
"graph_nodes.png"), Group("group.png"), Guitar("guitar.png"), HTML("html.png"), Hammer(
"hammer.png"), Help("help2.png"), History("history.png"), IconLarge(
"icon_large.png"), IconMedium("icon_medium.png"), IconSmall("icon_small.png"), IdCard(
"id_card.png"), IdCardAdd("id_card_add.png"), IdCardEdit("id_card_edit.png"), Image(
"image.png"), ImportNetlist("import_netlist.png"), JarBeanInto("jar_bean_into.png"), KeyEdit(
"key_edit.png"), LaserPointer("laserpointer.png"), LightBulbOff(
"lightbulb_off.png"), LightBulbOn("lightbulb_on.png"), Loadline("loadline.png"), LoadlineAdd(
"loadline_add.png"), Lock("lock.png"), MagicWand("magic_wand.png"), Manual(
"manual.png"), Megaphone("megaphone.png"), Messages("messages.png"), MissingImage(
"missing_image.png"), MoveSmall("move_small.png"), Multimeter("multimeter.png"), NavLeftBlue(
"nav_left_blue.png"), NavRightBlue("nav_right_blue.png"), NavigateCheck(
"navigate_check.png"), Node("node.png"), NotebookAdd("notebook_add.png"), PDF(
"pdf.png"), Pads("pads.png"), Paste("paste.png"), Patreon("patreon.png"), Pens(
"pens.png"), PhotoScenery("photo_scenery.png"), PinGreen("pin_green.png"), PinGrey(
"pin_grey.png"), Plugin("plugin.png"), Print("print.png"), Project("project.png"), RotateCCW(
"rotate_ccw.png"), RotateCW("rotate_cw.png"), SaveAs("save_as.png"), Scientist(
"scientist.png"), Screwdriver("screwdriver.png"), ScrollInformation(
"scroll_information.png"), SearchBox("search-box.png"), Selection(
"selection.png"), Silkscreen("silkscreen.png"), Size("size.png"), SnapToComponents(
"snap_to_components.png"), SnapToGrid("snap_to_grid.png"), SnapToNone(
"snap_to_none.png"), Sort("sort.png"), Spinning("spinning.gif"), Splash(
"splash.png"), SplashCeramic("splash_ceramic.png"), SplashElectrolytic(
"splash_electrolytic.png"), SplashFilm("splash_film.png"), SplashIC(
"splash_ic.png"), SplashResistor("splash_resistor.png"), StarBlue("star_blue.png"), StarGrey(
"star_grey.png"), Tables("tables.png"), TapeMeasure("tape_measure1.png"), TraceMask(
"trace_mask.png"), TraceProximity("trace_proximity.png"), Undo("undo.png"), Ungroup(
"ungroup.png"), Unlock("lock_open.png"), Upload("upload.png"), User("user1.png"), Warning(
"warning.png"), Web("web.png"), WindowColors("window_colors.png"), WindowGear(
"window_gear.png"), Wrench("wrench.png"), ZoomSmall("zoom_small.png");
protected String name;
private IconLoader(String name) {
this.name = name;
}
public Icon getIcon() {
java.net.URL imgURL = getClass().getResource("/diylc-swing-images/" + name);
if (imgURL != null) {
return new ImageIcon(imgURL, name);
} else {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
return null;
}
}
public Image getImage() {
BufferedImage img = null;
try {
img = ImageIO.read(getClass().getResourceAsStream("/diylc-swing-images/" + name));
} catch (IOException e) {
Logger.getLogger(IconLoader.class).error("Couldn't find file: " + name);
}
return img;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB