Skip to content

Commit

Permalink
Use GraphView instead of Graph for graph table rows
Browse files Browse the repository at this point in the history
  • Loading branch information
mbastian committed Nov 8, 2011
1 parent d4045a2 commit 318cd1a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
Expand Up @@ -43,6 +43,7 @@ Development and Distribution License("CDDL") (collectively, the

import org.gephi.graph.api.EdgeData;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.GraphView;
import org.gephi.graph.api.NodeData;

/**
Expand Down Expand Up @@ -75,7 +76,7 @@ public interface AttributeRowFactory {
* @return a newly created row for the graph table
* @see AttributeModel#getGraphTable()
*/
public AttributeRow newGraphRow(Graph graph);
public AttributeRow newGraphRow(GraphView graphView);

/**
* Returns a new row for the given <code>tableName</code>, or <code>null</code>
Expand Down
Expand Up @@ -48,7 +48,7 @@ Development and Distribution License("CDDL") (collectively, the
import org.gephi.data.attributes.api.AttributeValueFactory;
import org.gephi.data.attributes.api.AttributeValue;
import org.gephi.graph.api.EdgeData;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.GraphView;
import org.gephi.graph.api.NodeData;

/**
Expand Down Expand Up @@ -86,8 +86,8 @@ public AttributeRowImpl newEdgeRow(EdgeData edgeData) {
return new AttributeRowImpl(model.getEdgeTable(), edgeData);
}

public AttributeRow newGraphRow(Graph graph) {
return new AttributeRowImpl(model.getGraphTable(), graph);
public AttributeRow newGraphRow(GraphView graphView) {
return new AttributeRowImpl(model.getGraphTable(), graphView);
}

public AttributeRowImpl newRowForTable(String tableName, Object object) {
Expand Down
6 changes: 3 additions & 3 deletions DHNSGraph/src/org/gephi/graph/dhns/core/GraphFactoryImpl.java
Expand Up @@ -45,8 +45,8 @@ Development and Distribution License("CDDL") (collectively, the
import org.gephi.data.attributes.api.AttributeRowFactory;
import org.gephi.graph.api.Attributes;
import org.gephi.graph.api.EdgeData;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.GraphFactory;
import org.gephi.graph.api.GraphView;
import org.gephi.graph.api.Node;
import org.gephi.graph.api.NodeData;
import org.gephi.graph.api.TextData;
Expand Down Expand Up @@ -92,11 +92,11 @@ public AttributeRow newEdgeAttributes(EdgeData edgeData) {
return attributesFactory.newEdgeRow(edgeData);
}

public AttributeRow newGraphAttributes(Graph graph) {
public AttributeRow newGraphAttributes(GraphView graphView) {
if (attributesFactory == null) {
return null;
}
return attributesFactory.newGraphRow(graph);
return attributesFactory.newGraphRow(graphView);
}

public TextData newTextData() {
Expand Down
9 changes: 8 additions & 1 deletion DHNSGraph/src/org/gephi/graph/dhns/core/GraphViewImpl.java
Expand Up @@ -38,10 +38,11 @@ Development and Distribution License("CDDL") (collectively, the
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
*/
package org.gephi.graph.dhns.core;

import java.util.WeakHashMap;
import org.gephi.data.attributes.api.AttributeRow;
import org.gephi.graph.api.GraphView;
import org.gephi.graph.dhns.graph.AbstractGraphImpl;

Expand All @@ -55,6 +56,7 @@ public class GraphViewImpl implements GraphView {
private final int viewId;
private final TreeStructure structure;
private final StructureModifier structureModifier;
private final AttributeRow attributeRow;
private int nodesEnabled;
private int edgesCountTotal;
private int mutualEdgesTotal;
Expand All @@ -70,6 +72,7 @@ public GraphViewImpl(Dhns dhns, int viewId) {
this.viewId = viewId;
this.structure = new TreeStructure(this);
this.structureModifier = new StructureModifier(dhns, this);
this.attributeRow = dhns.factory().newGraphAttributes(this);
}

public void addGraphReference(AbstractGraphImpl graph) {
Expand Down Expand Up @@ -221,4 +224,8 @@ public void setMutualMetaEdgesTotal(int mutualMetaEdgesTotal) {
public Dhns getGraphModel() {
return dhns;
}

public AttributeRow getAttributes() {
return attributeRow;
}
}
Expand Up @@ -67,8 +67,7 @@ Development and Distribution License("CDDL") (collectively, the
public abstract class HierarchicalGraphImpl extends AbstractGraphImpl implements HierarchicalGraph {

protected final Predicate<AbstractNode> enabledNodePredicate;
protected final AttributeRow attributeRow;


public HierarchicalGraphImpl(Dhns dhns, GraphViewImpl view) {
super(dhns, view);
enabledNodePredicate = new Predicate<AbstractNode>() {
Expand All @@ -77,7 +76,6 @@ public boolean evaluate(AbstractNode element) {
return element.isEnabled();
}
};
this.attributeRow = dhns.factory().newGraphAttributes(this);
}

public abstract HierarchicalGraphImpl copy(Dhns dhns, GraphViewImpl view);
Expand Down Expand Up @@ -439,6 +437,6 @@ public void flatten() {
}

public Attributes getAttributes() {
return attributeRow;
return view.getAttributes();
}
}

0 comments on commit 318cd1a

Please sign in to comment.