Difference for src/cfeditor/CFilterControl.java from version 1.1 to 1.2


version 1.1 version 1.2
Line 6
 
Line 6
  */   */
 package cfeditor;  package cfeditor;
   
   import javax.swing.JComponent;
   import javax.swing.JMenu;
   
   import cfeditor.filter.ConfigEvent;
   import cfeditor.filter.ConfigListener;
   import cfeditor.filter.Filter;
   import cfeditor.filter.NamedFilterConfig;
   import cfeditor.filter.NamedFilterEvent;
 import cfeditor.filter.NamedFilterList;  import cfeditor.filter.NamedFilterList;
   import cfeditor.filter.NamedFilterListener;
   import cfeditor.menu.BasicMenuEntry;
   import cfeditor.menu.MenuEntry;
   
 /**  /**
  * @author tchize   * @author tchize
Line 26
 
Line 37
  * this path the wall and the floor filters, only walls and floors will be shown.   * this path the wall and the floor filters, only walls and floors will be shown.
  */   */
  //TODO allow implementation of own filter   //TODO allow implementation of own filter
 public class CFilterControl {  public class CFilterControl implements NamedFilterListener, ConfigListener{
   
     public static final int MAX_HIGHLIGHT= 3;      public static final int MAX_HIGHLIGHT= 3;
     private boolean filterOut = false;      private boolean filterOut = false;
     private boolean highLight[];      private boolean highLight[];
     private NamedFilterList filterOutList;      private static NamedFilterList filterList = NamedFilterList.getDefaultList();
     private NamedFilterList highLightList[];      private NamedFilterConfig filterOutConfig;
       private NamedFilterConfig highLightConfig[];
     private boolean highLightResult[];      private boolean highLightResult[];
     private CMapControl map;      private CMapControl map;
     private static CFilterControl defaultFilter = new CFilterControl(null);       private static CFilterControl defaultFilter = new CFilterControl(null);
Line 43
 
Line 55
     public CFilterControl(CMapControl map) {      public CFilterControl(CMapControl map) {
  super();   super();
         highLight = new boolean[]{false,false,false};          highLight = new boolean[]{false,false,false};
         filterOutList= new NamedFilterList();          filterOutConfig= (NamedFilterConfig)filterList.createConfig();
         highLightList= new NamedFilterList[]          highLightConfig= new NamedFilterConfig[]
             {new NamedFilterList(),new NamedFilterList(),new NamedFilterList()};              {(NamedFilterConfig)filterList.createConfig(),
                (NamedFilterConfig)filterList.createConfig(),
                (NamedFilterConfig)filterList.createConfig()};
         highLightResult = new boolean[3];          highLightResult = new boolean[3];
           filterOutConfig.addConfigChangeListener(this);
           for (int i=0;i<MAX_HIGHLIGHT;i++){
               highLightConfig[i].addConfigChangeListener(this);   
           }
         this.map=map;          this.map=map;
  }   }
     public static CFilterControl getDefaultFilter(){return defaultFilter;}      public static CFilterControl getDefaultFilter(){return defaultFilter;}
   
     /*-------------- Config part -------------------*/      public BasicMenuEntry createMenuEntry(){
  /**          return new FilterControlMenuEntry();
  * @return true if filterOut is enabled, false otherwise.  
  */  
  public boolean isFilterOut() {  
  return filterOut;  
  }  
  /**  
      * (dis)enable the fileterOut.  
  * @param b true to enable filterOut, false Otherwise.  
  */  
  public void setFilterOut(boolean b) {  
  filterOut = b;  
         if (map!=null)  
             map.repaint();  
  }  
     /**  
      * tell wether an highlight path is enable.  
      * @param path the path number (currently 0..2)  
      * @return true if highlight filter is enabled, false otherwise.  
      */  
     public boolean isHighLight(int path){  
         return highLight[path];  
     }  
     /**  
      * Set wether to activate a specific highlight path or not  
      * @param path the path number (currently 0..2)  
      * @param b true if highlight filter is to be enabled, false otherwise.  
      */  
     public void setHighLight(int path, boolean b){  
         highLight[path]=b;  
         if (map!=null)  
             map.repaint();  
     }  
     public String[] getFilterOutFilters(){  
         return filterOutList.getFilters();  
     }  
     public String[] getHighLightFilters(int path){  
         return highLightList[path].getFilters();  
     }  
     public boolean isFilterOutFilterEnabled(String name){  
         return filterOutList.isFilterEnabled(name);  
     }  
     public boolean isHighLightFilterEnabled(int path, String name){  
         return highLightList[path].isFilterEnabled(name);  
     }  
     public void setFilterOutFilterEnabled(String name, boolean b){  
         filterOutList.setFilterEnabled(name,b);  
         if (isFilterOut() && (map!=null))  
             map.repaint();  
     }  
     public void setHighLightFilterEnabled(int path, String name, boolean b){  
         highLightList[path].setFilterEnabled(name,b);  
         /*repaint if needed*/  
         if (isHighLight(path) && (map!=null))  
             map.repaint();  
     }       
     public void setHighLightFilterInverted(int path, boolean b){  
         highLightList[path].setInverted(b);  
         /*repaint if needed*/  
         if (isHighLight(path) && (map!=null))  
             map.repaint();  
     }       
     public boolean isHighLightFilterInverted(int path){  
         return highLightList[path].isInverted();  
     }       
     public void setFilterOutFilterInverted(boolean b){  
         filterOutList.setInverted(b);  
         if (isFilterOut() && (map!=null))  
             map.repaint();  
     }       
     public boolean isFilterOutFilterInverted(){  
         return filterOutList.isInverted();  
     }      }
      
     /* ---------- use part --------------*/      /* ---------- use part --------------*/
     public void newSquare(){      public void newSquare(){
         for (int i = 0;i<highLightList.length;i++){          for (int i = 0;i<MAX_HIGHLIGHT;i++){
             highLightList[i].reset();              filterList.reset(highLightConfig[i]);
             highLightResult[i]=false;              highLightResult[i]=false;
         }          }
     }      }
     public boolean highLightedSquare(int path){      public boolean highLightedSquare(int path){
         if (highLight[path]){          if (highLightConfig[path].isEnabled()){
             return highLightResult[path];               return highLightResult[path];
         }          }
         return false;          return false;
     }      }
     public void objectInSquare(ArchObject o){      public void objectInSquare(ArchObject o){
         for (int i=0;i<3;i++){          for (int i=0;i<3;i++){
             if (!highLight[i])              if (!highLightConfig[i].isEnabled())
                 continue; /*matching system not activated*/                  continue; /*matching system not activated*/
             if (highLightResult[i])              if (highLightResult[i])
                 continue;                  continue;
             highLightResult[i]=highLightList[i].match(o);                      highLightResult[i]=filterList.match(highLightConfig[i],o);       
         }          }
     }      }
     public boolean canShow(ArchObject o){      public boolean canShow(ArchObject o){
         if (!filterOut)          if (!filterOutConfig.isEnabled())
             return true;              return true;
         filterOutList.reset();          filterList.reset(filterOutConfig);
         if (filterOutList.hasGlobalMatch()){          if (filterList.hasGlobalMatch(filterOutConfig)){
             filterOutList.match(o);              filterList.match(filterOutConfig,o);
             return !filterOutList.reset();              return !filterList.reset(filterOutConfig);
         }          }
         else          else
             return !filterOutList.match(o);              return !filterList.match(filterOutConfig,o);
     }      }
          
       public void nameFilterChanged(NamedFilterEvent event) {
           // TODO Auto-generated method stub
   
       }
       public void configChanged(ConfigEvent e) {
           if (map!=null)
               map.repaint();
           else{
                CMapControl[] maps = CMainControl.getInstance().getOpenedMaps();
                for (int i=0;i<maps.length;i++){
                    maps[i].repaint(); 
                }
           }
       }
       private class FilterControlMenuEntry extends BasicMenuEntry{
          
           public FilterControlMenuEntry() {
           super("<<set me>>");
    }
    protected void update() {
    // nothing to do
    }
    protected void updateItem(JComponent item) {
               // nothing to do
    }
    public JComponent getMenuBarComponent() {
               JMenu menu = new JMenu(getName());
               BasicMenuEntry outEntry = filterList.createMenuEntry(filterOutConfig);
               outEntry.setName("Filter view");
               JComponent out = outEntry.getMenuItemComponent();
               menu.add(out);
               menu.addSeparator();
               for (int i = 0; i<MAX_HIGHLIGHT;i++){
                   BasicMenuEntry bme = filterList.createMenuEntry(highLightConfig[i]);
                   bme.setName("Highlight "+i);
                   JComponent hl = bme.getMenuItemComponent();
                   menu.add(hl);
               }
               return menu;
    }
    public JComponent getMenuItemComponent() {
    return getMenuBarComponent();
    }
    public JComponent getToolbarComponent() {
    return null;
    }
   }
      
    public boolean addFilter(String name, Filter f) {
    return filterList.addFilter(name, f);
    }
    public boolean removeFilter(String name) {
    return filterList.removeFilter(name);
    }
 }  }


Legend:
line(s) removed in v.1.1 
line(s) changed
 line(s) added in v.1.2

File made using version 1.96 of cvs2html by leaf at 2006-02-21 19:45