package org.cytoscape.view.model.internal.model.snapshot;

import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.SnapshotEdgeInfo;
import org.cytoscape.view.model.View;
import org.cytoscape.view.model.internal.model.CyEdgeViewImpl;
import org.cytoscape.view.model.internal.model.VPStore;

public class CyEdgeViewSnapshotImpl extends CyViewSnapshotBase<CyEdge> implements SnapshotEdgeInfo {
	
	private final CyNetworkViewSnapshotImpl parent;

	public CyEdgeViewSnapshotImpl(CyNetworkViewSnapshotImpl parent, CyEdgeViewImpl view) {
		super(view.getSUID());
		this.parent = parent;
	}
	
	@Override
	public CyNetworkViewSnapshotImpl getNetworkSnapshot() {
		return parent;
	}
	
	private CyEdgeViewImpl getEdgeView() {
		return parent.getMutableNetworkView().getEdgeView(getSUID());
	}
	
	@Override
	public Long getModelSUID() {
		return getEdgeView().getModel().getSUID();
	}

	@Override
	public long getSourceViewSUID() {
		return getEdgeView().getSourceSuid();
	}

	@Override
	public long getTargetViewSUID() {
		return getEdgeView().getTargetSuid();
	}

	@Override
	public boolean isDirected() {
		return getEdgeView().isDirected();
	}

	@Override
	public View<CyNode> getSourceNodeView() {
		return getNetworkSnapshot().getNodeView(getSourceViewSUID());
	}

	@Override
	public View<CyNode> getTargetNodeView() {
		return getNetworkSnapshot().getNodeView(getTargetViewSUID());
	}
	
	@Override
	public VPStore getVPStore() {
		return getNetworkSnapshot().edgeVPs;
	}
	
}

@@ -481,16 +481,157 @@
  parent;
+%0A%09// Its ok to have a reference to the mutable view object as long as we don't follow its parent pointer.%0A%09private final CyEdgeViewImpl view;
 %0A%0A%09publi
@@ -757,24 +757,44 @@
 t = parent;%0A
+%09%09this.view = view;%0A
 %09%7D%0A%09%0A%09@Overr
@@ -880,117 +880,8 @@
 %7D%0A%09%0A
-%09private CyEdgeViewImpl getEdgeView() %7B%0A%09%09return parent.getMutableNetworkView().getEdgeView(getSUID());%0A%09%7D%0A%09%0A
 %09@Ov
@@ -922,37 +922,28 @@
  %7B%0A%09%09return 
-getEdgeV
+v
 iew
-()
 .getModel().
@@ -1008,37 +1008,28 @@
  %7B%0A%09%09return 
-getEdgeV
+v
 iew
-()
 .getSourceSu
@@ -1093,29 +1093,20 @@
 %09return 
-getEdgeV
+v
 iew
-()
 .getTarg
@@ -1174,21 +1174,12 @@
 urn 
-getEdgeV
+v
 iew
-()
 .isD

Revert previous commit to CyEdgeViewSnapshotImpl, was causing NPE in renderer.