Changeset c4faca2


Ignore:
Timestamp:
Aug 3, 2010, 2:06:28 PM (8 years ago)
Author:
Michael Seifert <mseifert@…>
Branches:
master
Children:
7ac6484
Parents:
b1df941
Message:

Modules can now specify replay renderers for a specified replay format. These renderers are loaded as needed.

Files:
2 added
2 edited
3 moved

Legend:

Unmodified
Added
Removed
  • gui.swing/src/main/java/de/erichseifert/warp/gui/swing/ReplayParserGUI.java

    rb1df941 rc4faca2  
    9292import de.erichseifert.warp.core.ui.WARPUI;
    9393import de.erichseifert.warp.core.util.FileUtil;
     94import de.erichseifert.warp.gui.swing.renderers.DefaultPlayerRenderer;
     95import de.erichseifert.warp.gui.swing.renderers.ReplayRendererFactory;
    9496
    9597
     
    206208        private final APMRenderer apmRenderer;
    207209        private final JTabbedPane infoDisplay;
    208         private final DefaultReplayRenderer<Replay> replayRenderer;
     210        private final Map<Class<? extends Replay>, ItemRenderer<Replay>> replayRendererCache;
    209211        private final DefaultTableModel replayTableModel;
    210212        private final JTable replayTable;
     
    218220        private File parsedDir;
    219221        private Replay selectedReplay;
     222        private ItemRenderer<Replay> replayRenderer;
    220223
    221224        /**
     
    438441                                if (selectionIndex == 0) {
    439442                                        if (infoDisplay.getComponentAt(0) == null && selectedReplay != null) {
     443                                                Class<? extends Replay> replayClass = selectedReplay.getClass();
     444                                                replayRenderer = replayRendererCache.get(replayClass);
     445                                                if (replayRenderer == null) {
     446                                                        replayRenderer = (ItemRenderer<Replay>) ReplayRendererFactory.getInstance().getReplayRenderer(replayClass);
     447                                                        replayRendererCache.put(replayClass, replayRenderer);
     448                                                }
    440449                                                infoDisplay.setComponentAt(0, replayRenderer.getRendererComponent(selectedReplay));
    441450                                        }
     
    458467                getContentPane().add(splitPane, BorderLayout.CENTER);
    459468
    460                 // Left side: Replay renderer
    461                 // TODO: Retrieve renderer according to the replay that needs to be displayed
    462                 replayRenderer = new DefaultReplayRenderer<Replay>();
     469                // Left side: Replay renderer (dynamically initialized depending on replay class)
     470                replayRendererCache = new HashMap<Class<? extends Replay>, ItemRenderer<Replay>>();
    463471
    464472                // Right side: Replay list
  • gui.swing/src/main/java/de/erichseifert/warp/gui/swing/renderers/DefaultChatRenderer.java

    rb1df941 rc4faca2  
    2020 */
    2121
    22 package de.erichseifert.warp.gui.swing;
     22package de.erichseifert.warp.gui.swing.renderers;
    2323
    2424import java.awt.BorderLayout;
     
    3838import de.erichseifert.warp.core.Player;
    3939import de.erichseifert.warp.core.util.GUIUtil;
     40import de.erichseifert.warp.gui.swing.ItemRenderer;
    4041
    4142public class DefaultChatRenderer<T extends Player> implements ItemRenderer<Collection<? extends Player>> {
  • gui.swing/src/main/java/de/erichseifert/warp/gui/swing/renderers/DefaultPlayerRenderer.java

    rb1df941 rc4faca2  
    2020 */
    2121
    22 package de.erichseifert.warp.gui.swing;
     22package de.erichseifert.warp.gui.swing.renderers;
    2323
    2424import java.awt.Component;
     
    4444import de.erichseifert.warp.core.Player;
    4545import de.erichseifert.warp.core.util.GUIUtil;
     46import de.erichseifert.warp.gui.swing.ItemRenderer;
     47import de.erichseifert.warp.gui.swing.VisibilityChangeEvent;
     48import de.erichseifert.warp.gui.swing.VisibilityChangeListener;
    4649
    4750public class DefaultPlayerRenderer<T extends Player> implements ItemRenderer<T> {
  • gui.swing/src/main/java/de/erichseifert/warp/gui/swing/renderers/DefaultReplayRenderer.java

    rb1df941 rc4faca2  
    2020 */
    2121
    22 package de.erichseifert.warp.gui.swing;
     22package de.erichseifert.warp.gui.swing.renderers;
    2323
    2424import java.awt.BorderLayout;
     
    3434import de.erichseifert.warp.core.Player;
    3535import de.erichseifert.warp.core.Replay;
     36import de.erichseifert.warp.gui.swing.ItemRenderer;
     37import de.erichseifert.warp.gui.swing.VisibilityChangeEvent;
     38import de.erichseifert.warp.gui.swing.VisibilityChangeListener;
    3639
    3740public class DefaultReplayRenderer<T extends Replay> implements ItemRenderer<T> {
  • sc2replay/src/main/java/de/erichseifert/warp/sc2replay/renderers/SC2ReplayRenderer.java

    rb1df941 rc4faca2  
    3232
    3333import de.erichseifert.warp.core.Player;
    34 import de.erichseifert.warp.gui.swing.DefaultReplayRenderer;
    3534import de.erichseifert.warp.gui.swing.VisibilityChangeEvent;
    3635import de.erichseifert.warp.gui.swing.VisibilityChangeListener;
     36import de.erichseifert.warp.gui.swing.renderers.DefaultReplayRenderer;
    3737import de.erichseifert.warp.sc2replay.SC2Replay;
    3838
Note: See TracChangeset for help on using the changeset viewer.