Effect
Demand analysis of design ideas
Image browsing, up/down, zoom out and other basic functions. Features you can continue to expand: thumbnails, rotations, brush changes, and more. In addition, the scaling implementation is relatively simple, so there is distortion. Design such software functions can refer to ACDSee or IrfanView and other viewing software.
Knowledge points
1. File filtering, File io:filefilter
2. File dialog box:jfilechooser(add File Filtering function)
3. Browser Main interface:jtoolbar/jmenubar/JScrollPane
4. Response event:actionlistener/abstractaction
5. Display Image:ImageIcon
Design Patterns
1. Singleton: The Business Processing class is not a stateless Java object, but rather holds the information such as the Browse directory, scale, and so on.
Specific code:
Public Static Viewerservice getinstance () { if (null = = Service) {new Viewerservice (); } return service; }
2. Reflection: Create an instance by reflection, avoid if...else if.....else..., enhance the extensibility of the program.
Specific code:
1 PrivateAction getaction (String actionname) {2 Try {3 if( This. Action = =NULL) {4Action action = (action) class.forname ("crazyit.action." +5 actionname). newinstance ();6 This. Action =Action;7 }8 return This. Action;9}Catch(Exception e) {Ten return NULL; One } A}
Summarize
In the practice of in-depth study, it is important in the actual process of careful study of documents , accumulate experience, write performance (algorithm) good, design (mode) reasonable program.
Source
Https://github.com/zhaoyu1995/CrazyJava/tree/master/ImageViewer
Java Development Picture Browser--record