<commit_before>package com.mercury.platform.ui.manager;

import com.mercury.platform.shared.ConfigManager;
import com.mercury.platform.shared.FrameStates;
import com.mercury.platform.shared.events.EventRouter;
import com.mercury.platform.shared.events.custom.ChangedTradeModeEvent;
import com.mercury.platform.shared.events.custom.ShutdownApplication;
import com.mercury.platform.shared.events.custom.UILoadedEvent;
import com.mercury.platform.shared.pojo.FrameSettings;
import com.mercury.platform.ui.frame.ComponentFrame;
import com.mercury.platform.ui.frame.MovableComponentFrame;
import com.mercury.platform.ui.frame.impl.test.TestCasesFrame;
import com.mercury.platform.ui.frame.OverlaidFrame;
import com.mercury.platform.ui.frame.impl.*;
import com.mercury.platform.ui.frame.impl.util.TradeMode;
import com.mercury.platform.ui.frame.location.SetUpLocationCommander;
import com.mercury.platform.ui.frame.location.SetUpLocationFrame;
import com.mercury.platform.ui.misc.note.Note;
import com.mercury.platform.ui.misc.note.NotesLoader;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.*;
import java.util.List;

/**
 * Created by Константин on 18.01.2017.
 */
public class FramesManager {
    private static class FramesManagerHolder {
        static final FramesManager HOLDER_INSTANCE = new FramesManager();
    }
    public static FramesManager INSTANCE = FramesManagerHolder.HOLDER_INSTANCE;

    private Map<Class,OverlaidFrame> framesMap;
    private SetUpLocationCommander locationCommander;

    private FramesManager() {
        framesMap = new HashMap<>();
        locationCommander = new SetUpLocationCommander();
    }
    public void start(){
        createTrayIcon();

        OverlaidFrame incMessageFrame = new IncMessageFrame();
        framesMap.put(IncMessageFrame.class,incMessageFrame);
        OverlaidFrame taskBarFrame = new TaskBarFrame();
//        OverlaidFrame itemsMeshFrame = new ItemsGridFrame();
//        framesMap.put(ItemsGridFrame.class,itemsMeshFrame);

        locationCommander.addFrame((MovableComponentFrame) incMessageFrame);
        locationCommander.addFrame((MovableComponentFrame) taskBarFrame);
//        locationCommander.addFrame((MovableComponentFrame) itemsMeshFrame);
        NotesLoader notesLoader = new NotesLoader();

        List<Note> notesOnFirstStart = notesLoader.getNotesOnFirstStart();
        framesMap.put(NotesFrame.class, new NotesFrame(notesOnFirstStart, NotesFrame.NotesType.INFO));
        List<Note> patchNotes = notesLoader.getPatchNotes();
        if(ConfigManager.INSTANCE.isShowPatchNotes() && patchNotes.size() != 0){
            NotesFrame patchNotesFrame = new NotesFrame(patchNotes,NotesFrame.NotesType.PATCH);
            patchNotesFrame.init();
        }
        framesMap.put(HistoryFrame.class,new HistoryFrame());
        framesMap.put(SettingsFrame.class,new SettingsFrame());
        framesMap.put(TestCasesFrame.class,new TestCasesFrame());
        framesMap.put(TooltipFrame.class,new TooltipFrame());
        framesMap.put(NotificationFrame.class,new NotificationFrame());
        framesMap.put(DonationAlertFrame.class,new DonationAlertFrame());
//        framesMap.put(ChatScannerFrame.class,new ChatScannerFrame());
        framesMap.put(UpdateReadyFrame.class,new UpdateReadyFrame());
        framesMap.put(TaskBarFrame.class,taskBarFrame);
        framesMap.put(SetUpLocationFrame.class,new SetUpLocationFrame());

        framesMap.forEach((k,v)->{
            v.init();
        });

        int decayTime = ConfigManager.INSTANCE.getDecayTime();
        int maxOpacity = ConfigManager.INSTANCE.getMaxOpacity();
        int minOpacity = ConfigManager.INSTANCE.getMinOpacity();
        framesMap.forEach((k,frame) -> {
            if(frame instanceof ComponentFrame) {
                if (decayTime > 0) {
                    ((ComponentFrame)frame).enableHideEffect(decayTime, minOpacity, maxOpacity);
                } else {
                    ((ComponentFrame)frame).disableHideEffect();
                    frame.setOpacity(maxOpacity / 100f);
                }
            }
        });
        TradeMode tradeMode = TradeMode.valueOf(ConfigManager.INSTANCE.getTradeMode());
        switch (tradeMode){
            case DEFAULT:{
                EventRouter.INSTANCE.fireEvent(new ChangedTradeModeEvent.ToDefaultTradeModeEvent());
                break;
            }
            case SUPER:{
                EventRouter.INSTANCE.fireEvent(new ChangedTradeModeEvent.ToSuperTradeModeEvent());
                break;
            }
        }
        EventRouter.INSTANCE.fireEvent(new UILoadedEvent());
    }
    public void showFrame(Class frameClass){
        framesMap.get(frameClass).showComponent();
    }
    public void preShowFrame(Class frameClass){
        framesMap.get(frameClass).setPrevState(FrameStates.SHOW);
    }
    public void hideFrame(Class frameClass){
        framesMap.get(frameClass).hideComponent();
    }
    public void hideOrShowFrame(Class frameClass){
        OverlaidFrame frame = framesMap.get(frameClass);
        if(frame != null && frame.isVisible()){
            hideFrame(frameClass);
        }else {<commit_msg>Removed trash code<commit_after>package com.mercury.platform.ui.manager;

import com.mercury.platform.shared.ConfigManager;
import com.mercury.platform.shared.FrameStates;
import com.mercury.platform.shared.events.EventRouter;
import com.mercury.platform.shared.events.custom.ChangedTradeModeEvent;
import com.mercury.platform.shared.events.custom.ShutdownApplication;
import com.mercury.platform.shared.events.custom.UILoadedEvent;
import com.mercury.platform.shared.pojo.FrameSettings;
import com.mercury.platform.ui.frame.ComponentFrame;
import com.mercury.platform.ui.frame.MovableComponentFrame;
import com.mercury.platform.ui.frame.impl.test.TestCasesFrame;
import com.mercury.platform.ui.frame.OverlaidFrame;
import com.mercury.platform.ui.frame.impl.*;
import com.mercury.platform.ui.frame.impl.util.TradeMode;
import com.mercury.platform.ui.frame.location.SetUpLocationCommander;
import com.mercury.platform.ui.frame.location.SetUpLocationFrame;
import com.mercury.platform.ui.misc.note.Note;
import com.mercury.platform.ui.misc.note.NotesLoader;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.*;
import java.util.List;

/**
 * Created by Константин on 18.01.2017.
 */
public class FramesManager {
    private static class FramesManagerHolder {
        static final FramesManager HOLDER_INSTANCE = new FramesManager();
    }
    public static FramesManager INSTANCE = FramesManagerHolder.HOLDER_INSTANCE;

    private Map<Class,OverlaidFrame> framesMap;
    private SetUpLocationCommander locationCommander;

    private FramesManager() {
        framesMap = new HashMap<>();
        locationCommander = new SetUpLocationCommander();
    }
    public void start(){
        createTrayIcon();

        OverlaidFrame incMessageFrame = new IncMessageFrame();
        framesMap.put(IncMessageFrame.class,incMessageFrame);
        OverlaidFrame taskBarFrame = new TaskBarFrame();
//        OverlaidFrame itemsMeshFrame = new ItemsGridFrame();
//        framesMap.put(ItemsGridFrame.class,itemsMeshFrame);

        locationCommander.addFrame((MovableComponentFrame) incMessageFrame);
        locationCommander.addFrame((MovableComponentFrame) taskBarFrame);
//        locationCommander.addFrame((MovableComponentFrame) itemsMeshFrame);
        NotesLoader notesLoader = new NotesLoader();

        List<Note> notesOnFirstStart = notesLoader.getNotesOnFirstStart();
        framesMap.put(NotesFrame.class, new NotesFrame(notesOnFirstStart, NotesFrame.NotesType.INFO));
        List<Note> patchNotes = notesLoader.getPatchNotes();
        if(ConfigManager.INSTANCE.isShowPatchNotes() && patchNotes.size() != 0){
            NotesFrame patchNotesFrame = new NotesFrame(patchNotes,NotesFrame.NotesType.PATCH);
            patchNotesFrame.init();
        }
        framesMap.put(HistoryFrame.class,new HistoryFrame());
        framesMap.put(SettingsFrame.class,new SettingsFrame());
        framesMap.put(TestCasesFrame.class,new TestCasesFrame());
        framesMap.put(TooltipFrame.class,new TooltipFrame());
        framesMap.put(NotificationFrame.class,new NotificationFrame());
        framesMap.put(DonationAlertFrame.class,new DonationAlertFrame());
//        framesMap.put(ChatScannerFrame.class,new ChatScannerFrame());
        framesMap.put(UpdateReadyFrame.class,new UpdateReadyFrame());
        framesMap.put(TaskBarFrame.class,taskBarFrame);
        framesMap.put(SetUpLocationFrame.class,new SetUpLocationFrame());

        framesMap.forEach((k,v)->{
            v.init();
        });

        int decayTime = ConfigManager.INSTANCE.getDecayTime();
        int maxOpacity = ConfigManager.INSTANCE.getMaxOpacity();
        int minOpacity = ConfigManager.INSTANCE.getMinOpacity();
        framesMap.forEach((k,frame) -> {
            if(frame instanceof ComponentFrame) {
                if (decayTime > 0) {
                    ((ComponentFrame)frame).enableHideEffect(decayTime, minOpacity, maxOpacity);
                } else {
                    ((ComponentFrame)frame).disableHideEffect();
                    frame.setOpacity(maxOpacity / 100f);
                }
            }
        });
        EventRouter.INSTANCE.fireEvent(new UILoadedEvent());
    }
    public void showFrame(Class frameClass){
        framesMap.get(frameClass).showComponent();
    }
    public void preShowFrame(Class frameClass){
        framesMap.get(frameClass).setPrevState(FrameStates.SHOW);
    }
    public void hideFrame(Class frameClass){
        framesMap.get(frameClass).hideComponent();
    }
    public void hideOrShowFrame(Class frameClass){
        OverlaidFrame frame = framesMap.get(frameClass);
        if(frame != null && frame.isVisible()){
            hideFrame(frameClass);
        }else {
{'fraction_non_alphanumeric': 0.1058565299810436, 'fraction_numerical': 0.0025940337224383916, 'mean_word_length': 3.497083894122925, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6080114', 'n_tokens_mistral': 2843, 'n_tokens_neox': 2794, 'n_words': 425}