use of com.intellij.vcs.log.graph.api.elements.GraphNode in project intellij-community by JetBrains.
the class ColorGetterByLayoutIndex method getColorId.
public int getColorId(@NotNull GraphElement element) {
int upNodeIndex, downNodeIndex;
if (element instanceof GraphNode) {
upNodeIndex = ((GraphNode) element).getNodeIndex();
downNodeIndex = upNodeIndex;
} else {
GraphEdge edge = (GraphEdge) element;
NormalEdge normalEdge = LinearGraphUtils.asNormalEdge(edge);
if (normalEdge != null) {
upNodeIndex = normalEdge.up;
downNodeIndex = normalEdge.down;
} else {
upNodeIndex = LinearGraphUtils.getNotNullNodeIndex(edge);
downNodeIndex = upNodeIndex;
}
}
int upLayoutIndex = getLayoutIndex(upNodeIndex);
int downLayoutIndex = getLayoutIndex(downNodeIndex);
CommitId headCommitId = getOneOfHeads(upNodeIndex);
if (upLayoutIndex != downLayoutIndex) {
return myColorManager.getColorOfFragment(headCommitId, Math.max(upLayoutIndex, downLayoutIndex));
}
if (upLayoutIndex == myPermanentGraphInfo.getPermanentGraphLayout().getLayoutIndex(getHeadNodeId(upNodeIndex))) {
return myColorManager.getColorOfBranch(headCommitId);
} else {
return myColorManager.getColorOfFragment(headCommitId, upLayoutIndex);
}
}
use of com.intellij.vcs.log.graph.api.elements.GraphNode in project intellij-community by JetBrains.
the class GraphElementComparatorByLayoutIndex method compare.
@Override
public int compare(@NotNull GraphElement o1, @NotNull GraphElement o2) {
if (o1 instanceof GraphEdge && o2 instanceof GraphEdge) {
GraphEdge edge1 = (GraphEdge) o1;
GraphEdge edge2 = (GraphEdge) o2;
NormalEdge normalEdge1 = asNormalEdge(edge1);
NormalEdge normalEdge2 = asNormalEdge(edge2);
if (normalEdge1 == null)
return -compare2(edge2, new GraphNode(getNotNullNodeIndex(edge1)));
if (normalEdge2 == null)
return compare2(edge1, new GraphNode(getNotNullNodeIndex(edge2)));
if (normalEdge1.up == normalEdge2.up) {
if (getLayoutIndex(normalEdge1.down) != getLayoutIndex(normalEdge2.down)) {
return getLayoutIndex(normalEdge1.down) - getLayoutIndex(normalEdge2.down);
} else {
return normalEdge1.down - normalEdge2.down;
}
}
if (normalEdge1.up < normalEdge2.up) {
return compare2(edge1, new GraphNode(normalEdge2.up));
} else {
return -compare2(edge2, new GraphNode(normalEdge1.up));
}
}
if (o1 instanceof GraphEdge && o2 instanceof GraphNode)
return compare2((GraphEdge) o1, (GraphNode) o2);
if (o1 instanceof GraphNode && o2 instanceof GraphEdge)
return -compare2((GraphEdge) o2, (GraphNode) o1);
// both GraphNode
assert false;
return 0;
}
use of com.intellij.vcs.log.graph.api.elements.GraphNode in project intellij-community by JetBrains.
the class LinearFragmentGenerator method getRelativeFragment.
@Nullable
public GraphFragment getRelativeFragment(@NotNull GraphElement element) {
int upNodeIndex;
int downNodeIndex;
if (element instanceof GraphNode) {
upNodeIndex = ((GraphNode) element).getNodeIndex();
downNodeIndex = upNodeIndex;
} else {
NormalEdge graphEdge = LinearGraphUtils.asNormalEdge(((GraphEdge) element));
if (graphEdge == null)
return null;
upNodeIndex = graphEdge.up;
downNodeIndex = graphEdge.down;
}
for (int i = 0; i < MAX_SEARCH_SIZE; i++) {
GraphFragment graphFragment = getDownFragment(upNodeIndex);
if (graphFragment != null && graphFragment.downNodeIndex >= downNodeIndex)
return graphFragment;
List<Integer> upNodes = myLinearGraph.getNodes(upNodeIndex, UP);
if (upNodes.size() != 1) {
break;
}
upNodeIndex = upNodes.get(0);
}
return null;
}
use of com.intellij.vcs.log.graph.api.elements.GraphNode in project intellij-community by JetBrains.
the class PrintElementManagerImpl method isSelected.
@Override
public boolean isSelected(@NotNull PrintElementWithGraphElement printElement) {
if (printElement.equals(mySelectedPrintElement))
return true;
GraphElement graphElement = printElement.getGraphElement();
if (graphElement instanceof GraphNode) {
int nodeId = myLinearGraph.getNodeId(((GraphNode) graphElement).getNodeIndex());
return mySelectedNodeIds.contains(nodeId);
}
if (graphElement instanceof GraphEdge) {
GraphEdge edge = (GraphEdge) graphElement;
boolean selected = edge.getTargetId() == null || mySelectedNodeIds.contains(edge.getTargetId());
selected &= edge.getUpNodeIndex() == null || mySelectedNodeIds.contains(myLinearGraph.getNodeId(edge.getUpNodeIndex()));
selected &= edge.getDownNodeIndex() == null || mySelectedNodeIds.contains(myLinearGraph.getNodeId(edge.getDownNodeIndex()));
return selected;
}
return false;
}
use of com.intellij.vcs.log.graph.api.elements.GraphNode in project intellij-community by JetBrains.
the class CollapsedController method convertToDelegate.
@Nullable
public static GraphElement convertToDelegate(@NotNull GraphElement graphElement, CollapsedGraph collapsedGraph) {
if (graphElement instanceof GraphEdge) {
Integer upIndex = ((GraphEdge) graphElement).getUpNodeIndex();
Integer downIndex = ((GraphEdge) graphElement).getDownNodeIndex();
if (upIndex != null && downIndex != null && collapsedGraph.isMyCollapsedEdge(upIndex, downIndex))
return null;
Integer convertedUpIndex = upIndex == null ? null : collapsedGraph.convertToDelegateNodeIndex(upIndex);
Integer convertedDownIndex = downIndex == null ? null : collapsedGraph.convertToDelegateNodeIndex(downIndex);
return new GraphEdge(convertedUpIndex, convertedDownIndex, ((GraphEdge) graphElement).getTargetId(), ((GraphEdge) graphElement).getType());
} else if (graphElement instanceof GraphNode) {
return new GraphNode(collapsedGraph.convertToDelegateNodeIndex((((GraphNode) graphElement).getNodeIndex())), ((GraphNode) graphElement).getType());
}
return null;
}
Aggregations