Package org.gephi.data.attributes.model

Examples of org.gephi.data.attributes.model.IndexedAttributeModel


    private IndexedAttributeModel model;

    @Before
    public void setUp() {
        model = new IndexedAttributeModel();
        AttributeTableImpl nodeTableImpl = model.getNodeTable();
        nodeTableImpl.addColumn("id", "Identifier", AttributeType.INT, AttributeOrigin.DATA, new Integer(0));
        nodeTableImpl.addColumn("url", AttributeType.STRING);
        nodeTableImpl.addColumn("position", "Position&<>\"'$*", AttributeType.FLOAT, AttributeOrigin.PROPERTY, new Float(0));
        nodeTableImpl.addColumn("cats", "Catégories", AttributeType.LIST_STRING, AttributeOrigin.DATA, new StringList("a,b,c,d"));
View Full Code Here


            XMLStreamWriter writer = createWriter(stringWriter);
            serializer.writeModel(writer, model);
            writer.close();
            String s1 = stringWriter.toString();
            System.out.println(s1);
            IndexedAttributeModel model2 = new IndexedAttributeModel();
            StringReader stringReader = new StringReader(s1);
            XMLStreamReader reader = createReader(stringReader);
            serializer.readModel(reader, model2);
            stringWriter = new StringWriter();
            writer = createWriter(stringWriter);
View Full Code Here

    private int countEvents = 0;
    private int countElements = 0;

    @Test
    public void testEventsPerformance() {
        IndexedAttributeModel attModel = new IndexedAttributeModel();
        attModel.addAttributeListener(new AttributeListener() {

            public void attributesChanged(AttributeEvent event) {
                if(event.is(AttributeEvent.EventType.SET_VALUE)) {
                    countEvents++;
                    countElements+=event.getData().getTouchedValues().length;
                }
            }
        });

        //Add table
        AttributeTableImpl table = new AttributeTableImpl(attModel, "table");
        attModel.addTable(table);

        //Add Column
        AttributeColumnImpl col = table.addColumn("test", AttributeType.DOUBLE);

        AttributeRowImpl r1 = attModel.getFactory().newRowForTable("table", 1.0);
        AttributeRowImpl r2 = attModel.getFactory().newRowForTable("table", 1.0);

        for(int i=0;i<1000000;i++) {
            r1.setValue(col.getIndex(), Math.random());
            r2.setValue(col.getIndex(), Math.random());
        }
View Full Code Here

        System.out.println("Number events: "+countEvents+"  with "+countElements+" elements touched");
    }

    @Test
    public void testEvents() {
        IndexedAttributeModel attModel = new IndexedAttributeModel();
        EventCollector eventCollector = new EventCollector();
        attModel.addAttributeListener(eventCollector);

        //Add table
        AttributeTableImpl table = new AttributeTableImpl(attModel, "table");
        attModel.addTable(table);

        //Add Column
        AttributeColumnImpl col = table.addColumn("test", AttributeType.STRING);

        //Create objects
        Object o1 = new Object() {

            @Override
            public String toString() {
                return "o1";
            }
        };
        Object o2 = new Object() {

            @Override
            public String toString() {
                return "o2";
            }
        };
        AttributeRowImpl r1 = attModel.getFactory().newRowForTable("table", o1);
        AttributeRowImpl r2 = attModel.getFactory().newRowForTable("table", o2);

        //Set values
        r1.setValue(col, "value 1");
        r2.setValue(col, "value 2");
View Full Code Here

            }
        }
    }

    public void readXML(XMLStreamReader reader, Workspace workspace) {
        IndexedAttributeModel model = workspace.getLookup().lookup(IndexedAttributeModel.class);
        if (model == null) {
            model = new IndexedAttributeModel();
            workspace.add(model);
        }
        AttributeModelSerializer serializer = new AttributeModelSerializer();
        try {
            serializer.readModel(reader, model);
View Full Code Here

        projectController.addWorkspaceListener(new WorkspaceListener() {

            public void initialize(Workspace workspace) {
                AttributeModel m = workspace.getLookup().lookup(AttributeModel.class);
                if (m == null) {
                    workspace.add(new IndexedAttributeModel());
                }
            }

            public void select(Workspace workspace) {
            }

            public void unselect(Workspace workspace) {
            }

            public void close(Workspace workspace) {
            }

            public void disable() {
            }
        });
        if (projectController.getCurrentProject() != null) {
            for (Workspace workspace : projectController.getCurrentProject().getLookup().lookup(WorkspaceProvider.class).getWorkspaces()) {
                AttributeModel m = workspace.getLookup().lookup(AttributeModel.class);
                if (m == null) {
                    workspace.add(new IndexedAttributeModel());
                }
            }
        }
    }
View Full Code Here

        if (workspace != null) {
            AttributeModel model = workspace.getLookup().lookup(AttributeModel.class);
            if (model != null) {
                return model;
            }
            model = new IndexedAttributeModel();
            workspace.add(model);
            return model;
        }
        return null;
    }
View Full Code Here

    public AttributeModel getModel(Workspace workspace) {
        AttributeModel model = workspace.getLookup().lookup(AttributeModel.class);
        if (model != null) {
            return model;
        }
        model = new IndexedAttributeModel();
        workspace.add(model);
        return model;
    }
View Full Code Here

        projectController.addWorkspaceListener(new WorkspaceListener() {

            public void initialize(Workspace workspace) {
                AttributeModel m = workspace.getLookup().lookup(AttributeModel.class);
                if (m == null) {
                    workspace.add(new IndexedAttributeModel(workspace));
                }
            }

            public void select(Workspace workspace) {
            }

            public void unselect(Workspace workspace) {
            }

            public void close(Workspace workspace) {
            }

            public void disable() {
            }
        });
        if (projectController.getCurrentProject() != null) {
            for (Workspace workspace : projectController.getCurrentProject().getLookup().lookup(WorkspaceProvider.class).getWorkspaces()) {
                AttributeModel m = workspace.getLookup().lookup(AttributeModel.class);
                if (m == null) {
                    workspace.add(new IndexedAttributeModel(workspace));
                }
            }
        }
    }
View Full Code Here

        if (workspace != null) {
            AttributeModel model = workspace.getLookup().lookup(AttributeModel.class);
            if (model != null) {
                return model;
            }
            model = new IndexedAttributeModel(workspace);
            workspace.add(model);
            return model;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.gephi.data.attributes.model.IndexedAttributeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.