Clase de la Librería

El punto de acceso a la librería JAR es una clase que extiende de Library. La función principal de la librería es mostrar las herramientas que están disponibles en la misma; en la mayoría de los casos, las herramientas son todas las herramientas que añaden los diferentes componentes que han sido definidos, es decir, instancias de la clase AddTool que trabaja con diferentes factorías de componentes.

Components

package com.cburch.incr;

import java.util.Arrays;
import java.util.List;

import com.cburch.logisim.tools.AddTool;
import com.cburch.logisim.tools.Library;
import com.cburch.logisim.tools.Tool;

/** The library of components that the user can access. */
public class Components extends Library {
    /** The list of all tools contained in this library. Technically,
     * libraries contain tools, which is a slightly more general concept
     * than component classes; practically speaking, though, there
     * shouldn't be much reason to invent tools beyond new instances of
     * AddTool.
     */
    private List tools;
    
    /** Constructs an instance of this library. This constructor is how
     * Logisim accesses first when it opens the JAR file: It looks for
     * a no-arguments constructor method of the user-designated class.
     */
    public Components() {
        tools = Arrays.asList(new Tool[] {
                new AddTool(ByteIncrementerFactory.instance),
                new AddTool(IncrementerFactory.instance),
                new AddTool(SimpleCounterFactory.instance),
                new AddTool(Counter.factory),
        });
    }
    
    /** Returns the standard name of the library. Actually, this string
     * won't be used by Logisim. */
    public String getName() {
        return Components.class.getName();
    }
    
    /** Returns the name of the library that the user will see. */ 
    public String getDisplayName() {
        return "Increment";
    }
    
    /** Returns a list of all the tools available in this library. */
    public List getTools() {
        return tools;
    }
}

Siguiente: Incrementador General.