Ignore:
Timestamp:
05/10/18 16:04:51 (6 years ago)
Author:
davidb
Message:

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/agents/MelodySearch.java

    r903 r1102  
    11package org.apollo.agents;
    22
    3 import java.awt.Color;
    43import java.io.File;
    54import java.io.FileNotFoundException;
     
    109
    1110import javax.sound.sampled.AudioFormat;
    12 import javax.swing.SwingUtilities;
    1311
    1412import org.apollo.ApolloSystem;
     
    2624import org.apollo.widgets.TrackWidgetCommons;
    2725import org.expeditee.agents.SearchAgent;
     26import org.expeditee.core.Colour;
     27import org.expeditee.gui.DisplayController;
    2828import org.expeditee.gui.Frame;
    29 import org.expeditee.gui.FrameGraphics;
    3029import org.expeditee.gui.FrameIO;
    31 import org.expeditee.settings.UserSettings;
    3230import org.expeditee.settings.folders.FolderSettings;
    3331import org.expeditee.items.Item;
    3432import org.expeditee.items.ItemUtils;
    35 import org.expeditee.items.widgets.InteractiveWidget;
     33import org.expeditee.items.widgets.Widget;
    3634import org.expeditee.items.widgets.WidgetCorner;
    3735import org.expeditee.items.widgets.WidgetEdge;
     
    4240 * Uses meldex. Thanks David Bainbridge.
    4341 *
    44  * The agent runs a querry on the given track widget that launched it.
     42 * The agent runs a query on the given track widget that launched it.
    4543 * If the track launches it it does a full search for all tracks on the current frameset.
    4644 *
     
    9694         */
    9795        @Override
    98         public boolean initialise(Frame frame, Item item) {
     96        public boolean initialise(Frame frame, Item item)
     97        {
    9998                if (!super.initialise(frame, item)) return false;
    10099               
     
    104103                if (item != null) {
    105104                       
    106                         InteractiveWidget iw = null;
     105                        Widget iw = null;
    107106                       
    108107                        if (item instanceof WidgetCorner) {
     
    162161                               
    163162                                if (querryMelody == null) { // abort - failed to get audio
    164                                         SwingUtilities.invokeLater(new ExpediteeMessageBayFeedback(
    165                                                         "Melody search aborted: Failed to load tracks audio"));
     163                                        overwriteMessage("Melody search aborted: Failed to load tracks audio");
    166164                                        _results.addText("Melody search aborted: querry data not good enough to search with",
    167                                                         Color.RED, null, null, false);
     165                                                        Colour.RED, null, null, false);
    168166                                        _results.addText("Click here for help on melody searches",
    169                                                         new Color(0, 180, 0), ApolloSystem.HELP_MELODYSEARCH_FRAMENAME, null, false);
     167                                                        Colour.FromRGB255(0, 180, 0), ApolloSystem.HELP_MELODYSEARCH_FRAMENAME, null, false);
    170168                                       
    171169                                        _results.save();
     
    186184                               
    187185                                if (querryMelody == null) { // abort - failed to get audio
    188                                         SwingUtilities.invokeLater(new ExpediteeMessageBayFeedback(
    189                                                         "Melody search aborted: Failed to proccess querry data"));
    190                                         _results.addText("Melody search aborted: querry data not good enough to search with", Color.RED, null, null, false);
     186                                        overwriteMessage("Melody search aborted: Failed to proccess querry data");
     187                                        _results.addText("Melody search aborted: querry data not good enough to search with", Colour.RED, null, null, false);
    191188                                        _results.addText("Click here for help on melody searches",
    192                                                         new Color(0, 180, 0), ApolloSystem.HELP_MELODYSEARCH_FRAMENAME, null, false);
     189                                                        Colour.FromRGB255(0, 180, 0), ApolloSystem.HELP_MELODYSEARCH_FRAMENAME, null, false);
    193190                                        _results.save();
    194191                                        return null;
     
    240237                                        if(!results.isEmpty()) {
    241238                                                _results.addText(frameName + "(" + results.size() + ")", null, frameName, null, false);
    242                                                 FrameGraphics.requestRefresh(true);
     239                                                DisplayController.requestRefresh(true);
    243240                                        }
    244241                                       
     
    395392
    396393                                if (melodyScores.isEmpty() || melodyScores.get(0).getScore() > threshold) {
    397                                         _results.addText("No matches", Color.RED, null, null, false);
     394                                        _results.addText("No matches", Colour.RED, null, null, false);
    398395                                        _results.addText("Click here to find out how to improve your melody searches",
    399                                                         new Color(0, 180, 0), ApolloSystem.HELP_MELODYSEARCH_FRAMENAME, null, false);
     396                                                        Colour.FromRGB255(0, 180, 0), ApolloSystem.HELP_MELODYSEARCH_FRAMENAME, null, false);
    400397                                } else {
    401398                                       
     
    426423                       
    427424                        if (_stop) {
    428                                 _results.addText("Search cancelled", Color.RED, null, null, false);
     425                                _results.addText("Search cancelled", Colour.RED, null, null, false);
    429426                        }
    430427                       
     
    444441               
    445442        }
    446        
    447 
    448        
    449443       
    450444        /**
     
    470464
    471465        }
    472        
    473         /**
    474          * Safely outputs a message on the messagebay .. if ran on swing thread.
    475          * @author Brook Novak
    476          *
    477          */
    478         private class ExpediteeMessageBayFeedback implements Runnable {
    479                
    480                 String feedbackMessage;
    481                
    482                 public ExpediteeMessageBayFeedback(String feedbackMessage) {
    483                         assert(feedbackMessage != null);
    484                         this.feedbackMessage = feedbackMessage;
    485                 }
    486                
    487                
    488                 public void run() {
    489                         assert(feedbackMessage != null);
    490                         overwriteMessage(feedbackMessage);
    491                 }
    492         }
    493        
    494        
    495466}
Note: See TracChangeset for help on using the changeset viewer.