source: java/main/src/main/java/com/framsticks/gui/ImageProvider.java @ 84

Last change on this file since 84 was 84, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • simplification of entities management model
  • cleanup around params (improve hierarchy)
  • migrate from JUnit to TestNG
  • introduce FEST to automatically test GUI
  • improve slider control
  • loosen synchronization between gui tree and backend representation
  • and many other bug fixes

NOTICE:

  • a great many of lines is changed only because of substituting spaces with tabs

CHANGELOG (oldest changes at the bottom):

Some cleaning after fix found.

Fix bug with tree.

More changes with TreeNodes?.

Finally fix issue with tree.

Improve gui tree management.

Decouple update of values from fetch request in gui.

Minor changes.

Minor changes.

Minor change.

Change Path construction wording.

More fixes to SliderControl?.

Fix SliderControl?.

Fix SliderControl?.

Minor improvement.

Several changes.

Make NumberParam? a generic class.

Add robot to the gui test.

Setup common testing logging configuration.

Remove Parameters class.

Remove entityOwner from Parameters.

Move name out from Parameters class.

Move configuration to after the construction.

Simplify observers and endpoints.

Remove superfluous configureEntity overrides.

Add dependency on fest-swing-testng.

Use FEST for final print test.

Use FEST for more concise and readable assertions.

Divide test of F0Parser into multiple methods.

Migrate to TestNG

Minor change.

Change convention from LOGGER to log.

Fix reporting of errors during controls filling.

Bound maximal height of SliderControl?.

Minor improvements.

Improve tooltips for controls.

Also use Delimeted in more places.

Move static control utilities to Gui.

Rename package gui.components to controls.

Some cleaning in controls.

Improve Param classes placing.

Move ValueParam?, PrimitiveParam? and CompositeParam? one package up.

Improve ParamBuilder?.

Move getDef to ValueParam? and PrimitiveParam?.

Move getMax and getDef to ValueParam?.

Move getMin to ValueParam?.

Upgrade to laters apache commons versions.

Use filterInstanceof extensively.

Add instanceof filters.

Make ValueParam? in many places of Param.

Place assertions about ValueParam?.

Add ValueParam?

Rename ValueParam? to PrimitiveParam?

Minor changes.

Several improvements to params types.

Add NumberParam?.

Add TextControl? component.

Add .swp files to .gitignore

Greatly improved slider component.

Some improvements.

Make Param.reassign return also a state.

Add IterableIterator?.

Several changes.

  • Move util classes to better packages.
  • Remove warnings from eclim.

Several improvements.

Fix bug with BooleanParam?.

Some experiments with visualization.

Another fix to panel management.

Improve panel management.

Some refactorization around panels.

Add root class for panel.

File size: 3.2 KB
Line 
1/**
2 *
3 */
4package com.framsticks.gui;
5
6import org.apache.log4j.Logger;
7
8import javax.swing.*;
9import java.util.HashMap;
10import java.util.LinkedHashMap;
11
12/**
13 * Class provides icons images.
14 */
15public class ImageProvider {
16
17    private final static Logger log = Logger.getLogger(ImageProvider.class.getName());
18
19
20    /**
21         * HashMap stores icons. Key is icon path, Value is icon.
22         */
23        private static HashMap<String, ImageIcon> icons = new LinkedHashMap<String, ImageIcon>();
24
25        public static final String IMAGE = "image.png";
26        public static final String LOGO = "logo.png";
27
28        //public static final String FOLDER_OPEN = "folder_open.png";
29        //public static final String FOLDER_CLOSED = "folder_close.png";
30        //public static final String NODE = "node.png";
31
32        public static final String SERVER = "server.png";
33
34        public static final String CLI = "cli.png";
35        public static final String EVENT = "event.png";
36        public static final String SIMULATOR = "simulator.png";
37
38        public static final String WORLD = "World.png";
39        public static final String GENEPOOLS = "genepools.png";
40        public static final String GENEPOOLS_GROUP = "genepoolsgroup.png";
41        public static final String POPULATIONS = "populations.png";
42        public static final String POPULATION_GROUP = "populationgroup.png";
43        public static final String STATISTIC = "statistic.png";
44        public static final String EXPERIMENT = "experiment.png";
45
46        public static final String CREATURES_GROUP = "CreaturesGroup.png";
47        public static final String CREATURE = "Creature.png";
48
49        public static final String GENOTYPES_GROUP = "GenotypeGroup.png";
50        public static final String GENOTYPES = "Genotype.png";
51
52        public static final String JOINT_GROUP = "l_Joint.png";
53        public static final String JOINT = "Joint.png";
54        public static final String MECH_JOINT_GROUP = "l_MechJoint.png";
55        public static final String MECH_JOINT = "MechJoint.png";
56        public static final String PART_GROUP = "l_Part.png";
57        public static final String PART = "Part.png";
58        public static final String MECH_PART_GROUP = "l_MechPart.png";
59        public static final String MECH_PART = "MechPart.png";
60        public static final String NEURON_GROUP = "l_Neuro.png";
61        public static final String NEURON = "Neuro.png";
62        public static final String NEURON_DEF_GROUP = "l_NeuroDef.png";
63        public static final String NEURON_DEF = "NeuroDef.png";
64
65        public static final String FAVORITES = "stats.png";
66        public static final String FAVORITE_FIELDS = "FavouriteFields.png";
67
68        public static final String SIM_START = "sim_start.png";
69        public static final String SIM_STEP = "sim_step.png";
70        public static final String SIM_STOP = "sim_stop.png";
71
72        /**
73         * Loads image icon with the given getName(path).
74         *
75         * @param imageName Name of the image(including extension) which will be loaded.
76         * @return Loaded image.
77         */
78        public static ImageIcon loadImage(final String imageName) {
79                if (icons.containsKey(imageName)) {
80                        return icons.get(imageName);
81                }
82        String resourceName = "/shared/res/network/" + imageName;
83                try {
84            ImageIcon icon = new ImageIcon(ImageProvider.class.getResource(resourceName));
85                        icons.put(imageName, icon);
86            return icon;
87                } catch (Exception ignored) {
88            log.error("failed to read icon: " + resourceName);
89                }
90                return null;
91        }
92}
Note: See TracBrowser for help on using the repository browser.