Java 类org.apache.commons.collections15.Factory 实例源码

项目:cuttlefish    文件:CircleLayout.java   
@Override
public void initAlgo() {
    if (graphModel == null) {
        throw new RuntimeException(
                "The GraphModel for this layout cannot be null!");
    }

    graph = graphModel.getGraphVisible();

    circleNodeDataMap = LazyMap.decorate(
            new HashMap<Node, CircleNodeData>(),
            new Factory<CircleNodeData>() {
                public CircleNodeData create() {
                    return new CircleNodeData();
                }
            });

    nodeOrderedList = new ArrayList<Node>();
    for (Node n : graph.getNodes())
        nodeOrderedList.add(n);

    if (LayoutLoader.VERBOSE_LAYOUT)
        Cuttlefish.debug(this, "Layout initialized.");
}
项目:DoSeR-Disambiguation    文件:FinalEntityDisambiguatorGeneral.java   
@Override
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:DoSeR-Disambiguation    文件:Word2VecDisambiguatorGeneral.java   
@Override
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    for (SurfaceForm sf : repList) {
        SurfaceForm clone = (SurfaceForm) sf.clone();
        this.origList.add(clone);
    }

    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:DoSeR-Disambiguation    文件:Word2VecDisambiguator.java   
@Override
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    for (SurfaceForm sf : repList) {
        SurfaceForm clone = (SurfaceForm) sf.clone();
        this.origList.add(clone);
    }

    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:DoSeR-Disambiguation    文件:FinalEntityDisambiguation.java   
@Override
    public void setup() {
        this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
        this.edgeWeights = new HashMap<Edge, Number>();
        this.edgeFactory = new Factory<Integer>() {
            int i = 0;

            public Integer create() {
                return i++;
            }
        };

//      List<SurfaceForm> list = new LinkedList<SurfaceForm>();
//      for (SurfaceForm r : this.repList) {
//          list.add((SurfaceForm) r.clone());
//      }
//      Collections.sort(list);
//      this.repList = list;
        this.disambiguatedSurfaceForms = new BitSet(repList.size());
        for (int i = 0; i < repList.size(); i++) {
            if (repList.get(i).getCandidates().size() <= 1) {
                this.disambiguatedSurfaceForms.set(i);
            }
        }
        buildMainGraph();
    }
项目:DoSeR-Disambiguation    文件:AbstractWord2VecPageRank.java   
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    List<SurfaceForm> list = new LinkedList<SurfaceForm>();
    for (SurfaceForm r : this.repList) {
        list.add((SurfaceForm) r.clone());
    }
    Collections.sort(list);
    this.repList = list;
    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:VarJ    文件:PrototypeFactory.java   
/**
 * Factory method that performs validation.
 * <p/>
 * Creates a Factory that will return a clone of the same prototype object
 * each time the factory is used. The prototype will be cloned using one of these
 * techniques (in order):
 * <ul>
 * <li>public clone method
 * <li>public copy constructor
 * <li>serialization clone
 * <ul>
 *
 * @param prototype the object to clone each time in the factory
 * @return the <code>prototype</code> factory
 * @throws IllegalArgumentException if the prototype is null
 * @throws IllegalArgumentException if the prototype cannot be cloned
 */
public static <T> Factory<T> getInstance(T prototype) {
    if (prototype == null) {
        return ConstantFactory.NULL_INSTANCE;
    }
    try {
        Method method = prototype.getClass().getMethod("clone", null);
        return new PrototypeCloneFactory<T>(prototype, method);

    } catch (NoSuchMethodException ex) {
        try {
            prototype.getClass().getConstructor(new Class[]{prototype.getClass()});
            return new InstantiateFactory<T>((Class<T>) prototype.getClass(), new Class[]{prototype.getClass()}, new Object[]{prototype});

        } catch (NoSuchMethodException ex2) {
            if (prototype instanceof Serializable) {
                return new PrototypeSerializationFactory((Serializable) prototype);
            }
        }
    }
    throw new IllegalArgumentException("The prototype must be cloneable via a public clone method");
}
项目:VarJ    文件:InstantiateFactory.java   
/**
 * Factory method that performs validation.
 *
 * @param classToInstantiate the class to instantiate, not null
 * @param paramTypes         the constructor parameter types
 * @param args               the constructor arguments
 * @return a new instantiate factory
 */
public static <T> Factory<T> getInstance(Class<T> classToInstantiate, Class[] paramTypes, Object[] args) {
    if (classToInstantiate == null) {
        throw new IllegalArgumentException("Class to instantiate must not be null");
    }
    if (((paramTypes == null) && (args != null)) || ((paramTypes != null) && (args == null)) || ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
        throw new IllegalArgumentException("Parameter types must match the arguments");
    }

    if (paramTypes == null || paramTypes.length == 0) {
        return new InstantiateFactory<T>(classToInstantiate);
    } else {
        paramTypes = (Class[]) paramTypes.clone();
        args = (Object[]) args.clone();
        return new InstantiateFactory<T>(classToInstantiate, paramTypes, args);
    }
}
项目:SEWOL    文件:RoleGraphViewer.java   
/** Creates a new instance of SimpleGraphView */
public RoleGraphViewer() {
    // Graph<V, E> where V is the type of the vertices and E is the type of
    // the edges
    g = new SparseMultigraph<Integer, String>();
    nodeCount = 0;
    edgeCount = 0;
    vertexFactory = new Factory<Integer>() { // My vertex factory
        public Integer create() {
            return nodeCount++;
        }
    };
    edgeFactory = new Factory<String>() { // My edge factory
        public String create() {
            return "E" + edgeCount++;
        }
    };
}
项目:DoSeR    文件:FinalEntityDisambiguatorGeneral.java   
@Override
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:DoSeR    文件:Word2VecDisambiguatorGeneral.java   
@Override
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    for (SurfaceForm sf : repList) {
        SurfaceForm clone = (SurfaceForm) sf.clone();
        this.origList.add(clone);
    }

    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:DoSeR    文件:Word2VecDisambiguator.java   
@Override
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    for (SurfaceForm sf : repList) {
        SurfaceForm clone = (SurfaceForm) sf.clone();
        this.origList.add(clone);
    }

    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:DoSeR    文件:FinalEntityDisambiguation.java   
@Override
    public void setup() {
        this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
        this.edgeWeights = new HashMap<Edge, Number>();
        this.edgeFactory = new Factory<Integer>() {
            int i = 0;

            public Integer create() {
                return i++;
            }
        };

//      List<SurfaceForm> list = new LinkedList<SurfaceForm>();
//      for (SurfaceForm r : this.repList) {
//          list.add((SurfaceForm) r.clone());
//      }
//      Collections.sort(list);
//      this.repList = list;
        this.disambiguatedSurfaceForms = new BitSet(repList.size());
        for (int i = 0; i < repList.size(); i++) {
            if (repList.get(i).getCandidates().size() <= 1) {
                this.disambiguatedSurfaceForms.set(i);
            }
        }
        buildMainGraph();
    }
项目:DoSeR    文件:AbstractWord2VecPageRank.java   
public void setup() {
    this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
    this.edgeWeights = new HashMap<Edge, Number>();
    this.edgeFactory = new Factory<Integer>() {
        int i = 0;

        public Integer create() {
            return i++;
        }
    };

    List<SurfaceForm> list = new LinkedList<SurfaceForm>();
    for (SurfaceForm r : this.repList) {
        list.add((SurfaceForm) r.clone());
    }
    Collections.sort(list);
    this.repList = list;
    this.disambiguatedSurfaceForms = new BitSet(repList.size());
    for (int i = 0; i < repList.size(); i++) {
        if (repList.get(i).getCandidates().size() <= 1) {
            this.disambiguatedSurfaceForms.set(i);
        }
    }
    buildMainGraph();
}
项目:netTransformer    文件:GraphViewerPanelManager.java   
public GraphViewerPanelManager(TopologyManagerFrame frame, String projectType, File projectPath, TopologyViewerConfigManager viewerConfigPath,
                               File graphmlFile, Factory<G> factory, JTabbedPane tabbedPane,
                               GraphType graphType, GraphViewerPanelFactory graphViewerPanelFactory) throws Exception {
    this.frame = frame;
    this.projectPath = projectPath;
    this.graphType = graphType;
    this.viewerConfigManager = viewerConfigPath;
    versionDir = new File(new File(graphmlFile.getParent()).getParent());
   // TODO remove this Hardcode
    this.deviceXmlPath = versionDir;
    this.graphmlFileName = graphmlFile;
    this.factory = factory;
    this.tabbedPane = tabbedPane;
    entireGraph = factory.create();
    viewerConfig = viewerConfigManager.getTopologyViewerConfType();
    this.layout="FRLayout";
    this.graphViewerPanelFactory = graphViewerPanelFactory;
}
项目:BfROpenLab    文件:Lattice2DGenerator.java   
/**
 * Creates a generator of {@code row_count} x {@code col_count} lattices 
 * with the specified parameters.
 * 
 * @param graph_factory used to create the {@code Graph} for the lattice
 * @param vertex_factory used to create the lattice vertices
 * @param edge_factory used to create the lattice edges
 * @param row_count the number of rows in the lattice
 * @param col_count the number of columns in the lattice
 * @param isToroidal if true, the created lattice wraps from top to bottom and left to right
 */
public Lattice2DGenerator(Factory<? extends Graph<V,E>> graph_factory, Factory<V> vertex_factory, 
        Factory<E> edge_factory, int row_count, int col_count, boolean isToroidal)
{
    if (row_count < 2 || col_count < 2)
    {
        throw new IllegalArgumentException("Row and column counts must each be at least 2.");
    }

    this.row_count = row_count;
    this.col_count = col_count;
    this.is_toroidal = isToroidal;
    this.graph_factory = graph_factory;
    this.vertex_factory = vertex_factory;
    this.edge_factory = edge_factory;
    this.is_directed = (graph_factory.create().getDefaultEdgeType() == EdgeType.DIRECTED);
}
项目:BfROpenLab    文件:BarabasiAlbertGenerator.java   
/**
 * Constructs a new instance of the generator.
 * @param init_vertices     number of unconnected 'seed' vertices that the graph should start with
 * @param numEdgesToAttach the number of edges that should be attached from the
 * new vertex to pre-existing vertices at each time step
 * @param directed  specifies whether the graph and edges to be created should be directed or not
 * @param parallel  specifies whether the algorithm permits parallel edges
 * @param seed  random number seed
 */
public BarabasiAlbertGenerator(Factory<Graph<V,E>> graphFactory,
        Factory<V> vertexFactory, Factory<E> edgeFactory, 
        int init_vertices, int numEdgesToAttach, 
        int seed, Set<V> seedVertices)
{
    assert init_vertices > 0 : "Number of initial unconnected 'seed' vertices " + 
                "must be positive";
    assert numEdgesToAttach > 0 : "Number of edges to attach " +
                "at each time step must be positive";

    mNumEdgesToAttachPerStep = numEdgesToAttach;
    mRandom = new Random(seed);
    this.graphFactory = graphFactory;
    this.vertexFactory = vertexFactory;
    this.edgeFactory = edgeFactory;
    this.init_vertices = init_vertices;
    initialize(seedVertices);
}
项目:BfROpenLab    文件:ErdosRenyiGenerator.java   
/**
    *
    * @param numVertices number of vertices graph should have
    * @param p Connection's probability between 2 vertices
    */
public ErdosRenyiGenerator(Factory<UndirectedGraph<V,E>> graphFactory,
        Factory<V> vertexFactory, Factory<E> edgeFactory,
        int numVertices,double p)
   {
       if (numVertices <= 0) {
           throw new IllegalArgumentException("A positive # of vertices must be specified.");
       }
       mNumVertices = numVertices;
       if (p < 0 || p > 1) {
           throw new IllegalArgumentException("p must be between 0 and 1.");
       }
       this.graphFactory = graphFactory;
       this.vertexFactory = vertexFactory;
       this.edgeFactory = edgeFactory;
       mEdgeConnectionProbability = p;
       mRandom = new Random();
}
项目:BfROpenLab    文件:DirectionTransformer.java   
/**
 * Transforms <code>graph</code> (which may be of any directionality)
 * into an undirected graph. (This may be useful for
 * visualization tasks).
 * Specifically:
 * <ul>
 * <li/>Vertices are copied from <code>graph</code>.
 * <li/>Directed edges are 'converted' into a single new undirected edge in the new graph.
 * <li/>Each undirected edge (if any) in <code>graph</code> is 'recreated' with a new undirected edge in the new
 * graph if <code>create_new</code> is true, or copied from <code>graph</code> otherwise.
 * </ul>
 * 
 * @param graph     the graph to be transformed
 * @param create_new specifies whether existing undirected edges are to be copied or recreated
 * @param graph_factory used to create the new graph object
 * @param edge_factory used to create new edges
 * @return          the transformed <code>Graph</code>
 */
public static <V,E> UndirectedGraph<V,E> toUndirected(Graph<V,E> graph, 
        Factory<UndirectedGraph<V,E>> graph_factory,
        Factory<E> edge_factory, boolean create_new)
{
    UndirectedGraph<V,E> out = graph_factory.create();

    for (V v : graph.getVertices())
        out.addVertex(v);

    for (E e : graph.getEdges())
    {
        Pair<V> endpoints = graph.getEndpoints(e);
        V v1 = endpoints.getFirst();
        V v2 = endpoints.getSecond();
        E to_add;
        if (graph.getEdgeType(e) == EdgeType.DIRECTED || create_new)
            to_add = edge_factory.create();
        else
            to_add = e;
        out.addEdge(to_add, v1, v2, EdgeType.UNDIRECTED);
    }
    return out;
}
项目:BfROpenLab    文件:PajekNetReader.java   
@SuppressWarnings("unchecked")
protected E createAddEdge(StringTokenizer st, V v1, 
        EdgeType directed, Graph<V,E> g, List<V> id, Factory<E> edge_factory)
{
    int vid2 = Integer.parseInt(st.nextToken()) - 1;
    V v2;
    if (id != null)
      v2 = id.get(vid2);
    else
      v2 = (V)new Integer(vid2);
    E e = edge_factory.create();

    // don't error-check this: let the graph implementation do whatever it's going to do 
    // (add the edge, replace the existing edge, throw an exception--depends on the graph implementation)
    g.addEdge(e, v1, v2, directed);
    return e;
}
项目:ODL    文件:Lattice2DGenerator.java   
/**
 * Creates a generator of {@code row_count} x {@code col_count} lattices 
 * with the specified parameters.
 * 
 * @param graph_factory used to create the {@code Graph} for the lattice
 * @param vertex_factory used to create the lattice vertices
 * @param edge_factory used to create the lattice edges
 * @param row_count the number of rows in the lattice
 * @param col_count the number of columns in the lattice
 * @param isToroidal if true, the created lattice wraps from top to bottom and left to right
 */
public Lattice2DGenerator(Factory<? extends Graph<V,E>> graph_factory, Factory<V> vertex_factory, 
        Factory<E> edge_factory, int row_count, int col_count, boolean isToroidal)
{
    if (row_count < 2 || col_count < 2)
    {
        throw new IllegalArgumentException("Row and column counts must each be at least 2.");
    }

    this.row_count = row_count;
    this.col_count = col_count;
    this.is_toroidal = isToroidal;
    this.graph_factory = graph_factory;
    this.vertex_factory = vertex_factory;
    this.edge_factory = edge_factory;
    this.is_directed = (graph_factory.create().getDefaultEdgeType() == EdgeType.DIRECTED);
}
项目:ODL    文件:BarabasiAlbertGenerator.java   
/**
 * Constructs a new instance of the generator.
 * @param init_vertices     number of unconnected 'seed' vertices that the graph should start with
 * @param numEdgesToAttach the number of edges that should be attached from the
 * new vertex to pre-existing vertices at each time step
 * @param directed  specifies whether the graph and edges to be created should be directed or not
 * @param parallel  specifies whether the algorithm permits parallel edges
 * @param seed  random number seed
 */
public BarabasiAlbertGenerator(Factory<Graph<V,E>> graphFactory,
        Factory<V> vertexFactory, Factory<E> edgeFactory, 
        int init_vertices, int numEdgesToAttach, 
        int seed, Set<V> seedVertices)
{
    assert init_vertices > 0 : "Number of initial unconnected 'seed' vertices " + 
                "must be positive";
    assert numEdgesToAttach > 0 : "Number of edges to attach " +
                "at each time step must be positive";

    mNumEdgesToAttachPerStep = numEdgesToAttach;
    mRandom = new Random(seed);
    this.graphFactory = graphFactory;
    this.vertexFactory = vertexFactory;
    this.edgeFactory = edgeFactory;
    this.init_vertices = init_vertices;
    initialize(seedVertices);
}
项目:ODL    文件:ErdosRenyiGenerator.java   
/**
    *
    * @param numVertices number of vertices graph should have
    * @param p Connection's probability between 2 vertices
    */
public ErdosRenyiGenerator(Factory<UndirectedGraph<V,E>> graphFactory,
        Factory<V> vertexFactory, Factory<E> edgeFactory,
        int numVertices,double p)
   {
       if (numVertices <= 0) {
           throw new IllegalArgumentException("A positive # of vertices must be specified.");
       }
       mNumVertices = numVertices;
       if (p < 0 || p > 1) {
           throw new IllegalArgumentException("p must be between 0 and 1.");
       }
       this.graphFactory = graphFactory;
       this.vertexFactory = vertexFactory;
       this.edgeFactory = edgeFactory;
       mEdgeConnectionProbability = p;
       mRandom = new Random();
}
项目:ODL    文件:DirectionTransformer.java   
/**
 * Transforms <code>graph</code> (which may be of any directionality)
 * into an undirected graph. (This may be useful for
 * visualization tasks).
 * Specifically:
 * <ul>
 * <li/>Vertices are copied from <code>graph</code>.
 * <li/>Directed edges are 'converted' into a single new undirected edge in the new graph.
 * <li/>Each undirected edge (if any) in <code>graph</code> is 'recreated' with a new undirected edge in the new
 * graph if <code>create_new</code> is true, or copied from <code>graph</code> otherwise.
 * </ul>
 * 
 * @param graph     the graph to be transformed
 * @param create_new specifies whether existing undirected edges are to be copied or recreated
 * @param graph_factory used to create the new graph object
 * @param edge_factory used to create new edges
 * @return          the transformed <code>Graph</code>
 */
public static <V,E> UndirectedGraph<V,E> toUndirected(Graph<V,E> graph, 
        Factory<UndirectedGraph<V,E>> graph_factory,
        Factory<E> edge_factory, boolean create_new)
{
    UndirectedGraph<V,E> out = graph_factory.create();

    for (V v : graph.getVertices())
        out.addVertex(v);

    for (E e : graph.getEdges())
    {
        Pair<V> endpoints = graph.getEndpoints(e);
        V v1 = endpoints.getFirst();
        V v2 = endpoints.getSecond();
        E to_add;
        if (graph.getEdgeType(e) == EdgeType.DIRECTED || create_new)
            to_add = edge_factory.create();
        else
            to_add = e;
        out.addEdge(to_add, v1, v2, EdgeType.UNDIRECTED);
    }
    return out;
}
项目:org.datagr4m    文件:GraphMLReadWrite.java   
public void read(Graph<V,E> graph, String file, Factory<V> vf, Factory<E> ef) throws ParserConfigurationException, SAXException, IOException{
  //Step 1 we make a new GraphML Reader. We want an Undirected Graph of type node and edge.
    GraphMLReader<Graph<V,E>, V,E> gmlr = new GraphMLReader<Graph<V,E>, V,E>(vf, ef);

    //Here we read in our graph. filename is our .graphml file, and graph is where we will store our graph.
    gmlr.load(file, graph);

    BidiMap<V, String> vertex_ids = gmlr.getVertexIDs();  //The vertexIDs are stored in a BidiMap.
    Map<String, GraphMLMetadata<V>> vertex_color = gmlr.getVertexMetadata(); //Our vertex Metadata is stored in a map.
    Map<String, GraphMLMetadata<E>> edge_meta = gmlr.getEdgeMetadata(); // Our edge Metadata is stored in a map.

    // Here we iterate through our vertices, n, and we set the value and the color of our nodes from the data we have
    // in the vertex_ids map and vertex_color map.
    for (V n : graph.getVertices())
    {
        //n.setValue(vertex_ids.get(n)); //Set the value of the node to the vertex_id which was read in from the GraphML Reader.
        //n.setColor(vertex_color.get("d0").transformer.transform(n)); // Set the color, which we get from the Map vertex_color.            //Let's print out the data so we can get a good understanding of what we've got going on.
        //System.out.println("ID: "+n.getID()+", Value: "+n.getValue()+", Color: "+n.getColor());
    }
     // Just as we added the vertices to the graph, we add the edges as well.
    for (E e : graph.getEdges())
    {
        //e.setValue(edge_meta.get("d1").transformer.transform(e)); //Set the edge's value.
        //System.out.println("Edge ID: "+e.getID());
    }
}
项目:nubisave    文件:NubisaveEditor.java   
protected PluggableGraphMouse createPluggableGraphMouse(RenderContext<NubiSaveVertex,NubiSaveEdge> rc,
                Factory<AbstractNubisaveComponent> vertexFactory, Factory<? extends NubiSaveEdge> edgeFactory, DataVertexEdgeFactory dataVertexEdgeFactory) {
    PluggableGraphMouse graphMouse = new PluggableGraphMouse();
    VertexPicker<NubiSaveVertex, NubiSaveEdge> pickingPlugin = new VertexPicker<NubiSaveVertex, NubiSaveEdge>();
    TranslatingGraphMousePlugin translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
    ScalingGraphMousePlugin scalingPlugin = new ScalingGraphMousePlugin(new ViewScalingControl(), 0, 1.1f, 1/1.1f);
    PopupEditor popupEditingPlugin = new PopupEditor(edgeFactory);
    StorageServicePicker<NubiSaveVertex, NubiSaveEdge> storageServicePickingPlugin = new StorageServicePicker<NubiSaveVertex, NubiSaveEdge>();

    ExtensibleNubisaveComponentMousePlugin extendablePlugin = new ExtensibleNubisaveComponentMousePlugin(vertexFactory, edgeFactory);
    extendablePlugin.addEventListener(new AbstractNubiSaveComponentCreator(vv, graph, vertexFactory));
    extendablePlugin.addEventListener(new ToggleActivateNubisaveComponentOnDoubleClick(vv, graph));
    extendablePlugin.addEventListener(new PreventEdgeCreationForRestrictedPorts(vv, graph));
    extendablePlugin.addEventListener(new DataVertexEdgeCreator(vv, graph, dataVertexEdgeFactory));
    extendablePlugin.addEventListener(new AbstractNubisaveComponentEdgeCreator(vv, graph, (WeightedNubisaveVertexEdgeFactory) edgeFactory));

    graphMouse.add(scalingPlugin);
    graphMouse.add(extendablePlugin);
    graphMouse.add(storageServicePickingPlugin);
    graphMouse.add(translatingPlugin);
    graphMouse.add(popupEditingPlugin);
    return graphMouse;
}
项目:alevin-svn2    文件:MyLA.java   
@Override
public Factory<MyE> getEdgeFactory() {
    return new Factory<MyE>() {
        @Override
        public MyE create() {
            return new MyEA();
        }
    };
}
项目:alevin-svn2    文件:MyLB.java   
@Override
public Factory<MyE> getEdgeFactory() {
    return new Factory<MyE>() {
        @Override
        public MyE create() {
            return new MyEB();
        }
    };
}
项目:alevin-svn2    文件:VirtualNetwork.java   
@Override
public Factory<VirtualLink> getEdgeFactory() {
    return new Factory<VirtualLink>() {
        @Override
        public VirtualLink create() {
            return new VirtualLink(layer);
        }
    };
}
项目:alevin-svn2    文件:SubstrateNetwork.java   
@Override
public Factory<SubstrateLink> getEdgeFactory() {
    return new Factory<SubstrateLink>() {
        @Override
        public SubstrateLink create() {
            return new SubstrateLink();
        }
    };
}
项目:alevin-svn2    文件:MyEditingPopupGraphMousePlugin.java   
public MyEditingPopupGraphMousePlugin(final LayerViewer<V, E> vv, Scenario scenario) {
    super(InputEvent.BUTTON3_MASK, new Factory<V>() {
        private final int layer = vv.getLayer().getLayer();

        @SuppressWarnings("unchecked")
        @Override
        public V create() {
            if (layer > 0)
                return (V) new VirtualNode(layer);
            else
                return (V) new SubstrateNode();
        }
    }, new Factory<E>() {
        private final int layer = vv.getLayer().getLayer();

        @SuppressWarnings("unchecked")
        @Override
        public E create() {
            if (layer > 0)
                return (E) new VirtualLink(layer);
            else
                return (E) new SubstrateLink();
        }
    });

    this.scenario = scenario;
    this.vv = vv;
}
项目:kdxplore    文件:DefaultDALClientProvider.java   
@Override
public DalResponse performUpload(String command,
        Map<String, String> postParameters,
        Factory<InputStream> streamFactory)
        throws DalResponseException, IOException {
    return wrapped
            .performUpload(command, postParameters, streamFactory);
}
项目:VarJ    文件:LazyMap.java   
/**
 * Constructor that wraps (not copies).
 *
 * @param map     the map to decorate, must not be null
 * @param factory the factory to use, must not be null
 * @throws IllegalArgumentException if map or factory is null
 */
protected LazyMap(Map<K, V> map, Factory<V> factory) {
    super(map);
    if (factory == null) {
        throw new IllegalArgumentException("Factory must not be null");
    }
    this.transformer = new FactoryTransformer<K, V>(factory);
}
项目:VarJ    文件:LazyList.java   
/**
 * Constructor that wraps (not copies).
 *
 * @param list    the list to decorate, must not be null
 * @param factory the factory to use for creation, must not be null
 * @throws IllegalArgumentException if list or factory is null
 */
protected LazyList(List<E> list, Factory<? extends E> factory) {
    super(list);
    if (factory == null) {
        throw new IllegalArgumentException("Factory must not be null");
    }
    this.factory = factory;
}
项目:VarJ    文件:ConstantFactory.java   
/**
 * Factory method that performs validation.
 *
 * @param constantToReturn the constant object to return each time in the factory
 * @return the <code>constant</code> factory.
 */
public static <T> Factory<T> getInstance(T constantToReturn) {
    if (constantToReturn == null) {
        return NULL_INSTANCE;
    }
    return new ConstantFactory<T>(constantToReturn);
}
项目:vizardous    文件:MatrixFile.java   
/**
 * Constructs MatrixFile instance. If weightKey is not null then, it will
 * attempt to use that key to store and retreive weights from the edges'
 * UserData.
 */
public MatrixFile(Map<E, Number> weightKey, Factory<? extends Graph<V, E>> graphFactory,
        Factory<V> vertexFactory, Factory<E> edgeFactory) {

    mWeightKey = weightKey;
    this.graphFactory = graphFactory;
    this.vertexFactory = vertexFactory;
    this.edgeFactory = edgeFactory;
}
项目:NetworkVisualizer    文件:Vertex.java   
public static Factory<Vertex> getFactory() {
    return new Factory<Vertex>() {
        public Vertex create() {
            return new Vertex();
        }
    };
}
项目:NetworkVisualizer    文件:Edge.java   
public static Factory<Edge> getFactory() {
    return new Factory<Edge>() {
           public Edge create() {
               return new Edge();
           }
       };
}
项目:netTransformer    文件:MyGraphMLReader.java   
/**
 * Creates a <code>GraphMLReader</code> instance with the specified
 * vertex and edge factories.
 *
 * @param vertex_factory the vertex factory to use to create vertex objects
 * @param edge_factory the edge factory to use to create edge objects
 * @throws ParserConfigurationException
 * @throws SAXException
 */
public MyGraphMLReader(Factory<V> vertex_factory,
                       Factory<E> edge_factory)
    throws ParserConfigurationException, SAXException
{
    current_vertex = null;
    current_edge = null;

    SAXParserFactory factory = SAXParserFactory.newInstance();
    saxp = factory.newSAXParser();

    current_states = new LinkedList<TagState>();

    tag_state = new DualHashBidiMap<String, TagState>();
    tag_state.put("node", TagState.VERTEX);
    tag_state.put("edge", TagState.EDGE);
    tag_state.put("hyperedge", TagState.HYPEREDGE);
    tag_state.put("endpoint", TagState.ENDPOINT);
    tag_state.put("graph", TagState.GRAPH);
    tag_state.put("data", TagState.DATA);
    tag_state.put("key", TagState.KEY);
    tag_state.put("desc", TagState.DESC);
    tag_state.put("default", TagState.DEFAULT_KEY);
    tag_state.put("graphml", TagState.GRAPHML);

    this.key_type = KeyType.NONE;

    this.vertex_factory = vertex_factory;
    this.edge_factory = edge_factory;
}
项目:netTransformer    文件:MyGraphMLReader.java   
/**
 * Returns a list of the graphs parsed from the specified reader, as created by
 * the specified factory.
 * @throws IOException
 */
public List<G> loadMultiple(Reader reader, Factory<G> graph_factory)
    throws IOException
{
    this.graph_factory = graph_factory;
    initializeData();
    clearData();
    parse(reader);

    return graphs;
}