use of y.base.Edge in project binnavi by google.
the class CBendEnterState method mouseMoved.
@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
final double x = m_graph.getEditMode().translateX(event.getX());
final double y = m_graph.getEditMode().translateY(event.getY());
final HitInfo hitInfo = m_graph.getGraph().getHitInfo(x, y);
if (hitInfo.hasHitNodes()) {
m_factory.createBendExitState(m_bend, event);
return CHitNodesTransformer.enterNode(m_factory, event, hitInfo);
} else if (hitInfo.hasHitNodeLabels()) {
throw new IllegalStateException();
} else if (hitInfo.hasHitEdges()) {
final Edge e = hitInfo.getHitEdge();
m_factory.createBendExitState(m_bend, event);
return new CStateChange(m_factory.createEdgeEnterState(e, event), true);
} else if (hitInfo.hasHitEdgeLabels()) {
final EdgeLabel l = hitInfo.getHitEdgeLabel();
m_factory.createBendExitState(m_bend, event);
return new CStateChange(m_factory.createEdgeLabelEnterState(l, event), true);
} else if (hitInfo.hasHitBends()) {
return CHitBendsTransformer.changeBend(m_factory, event, hitInfo, m_bend);
} else if (hitInfo.hasHitPorts()) {
return new CStateChange(this, true);
} else {
return new CStateChange(m_factory.createBendExitState(m_bend, event), true);
}
}
use of y.base.Edge in project binnavi by google.
the class ProximityNodeCreator method insertProximityEdge.
/**
* Inserts a proximity edge between two nodes. One of the two input nodes must be a proximity
* browsing node or an exception is thrown.
*
* @param graph The graph where the node is inserted.
* @param sourceNode The source node of the edge.
* @param targetNode The target node of the edge.
*
* @return The inserted edge.
*/
public static ZyInfoEdge insertProximityEdge(final Graph2D graph, final ZyGraphNode<?> sourceNode, final ZyGraphNode<?> targetNode) {
Preconditions.checkNotNull(graph, "Graph argument can not be null");
Preconditions.checkNotNull(sourceNode, "Source node argument can not be null");
Preconditions.checkNotNull(targetNode, "Target node argument can not be null");
Preconditions.checkArgument((sourceNode instanceof ZyProximityNode<?>) || (targetNode instanceof ZyProximityNode<?>), "One of the two arguments must be a proximity browsing node");
final ZyEdgeRealizer<ZyInfoEdge> r = new ZyEdgeRealizer<ZyInfoEdge>(new ZyLabelContent(null), null);
r.setLineType(LineType.LINE_2);
final Edge edge = graph.createEdge(sourceNode.getNode(), targetNode.getNode(), r);
final ZyInfoEdge infoEdge = new ZyInfoEdge(sourceNode, targetNode, edge, r);
final ZyEdgeData<ZyInfoEdge> data = new ZyEdgeData<ZyInfoEdge>(infoEdge);
r.setUserData(data);
return infoEdge;
}
use of y.base.Edge in project binnavi by google.
the class CBendClickedLeftState method mouseMoved.
@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> g) {
final double x = g.getEditMode().translateX(event.getX());
final double y = g.getEditMode().translateY(event.getY());
final HitInfo hitInfo = g.getGraph().getHitInfo(x, y);
if (hitInfo.hasHitNodes()) {
m_factory.createBendExitState(m_bend, event);
return CHitNodesTransformer.enterNode(m_factory, event, hitInfo);
} else if (hitInfo.hasHitNodeLabels()) {
throw new IllegalStateException();
} else if (hitInfo.hasHitEdges()) {
m_factory.createBendExitState(m_bend, event);
final Edge e = hitInfo.getHitEdge();
return new CStateChange(m_factory.createEdgeEnterState(e, event), true);
} else if (hitInfo.hasHitEdgeLabels()) {
m_factory.createBendExitState(m_bend, event);
final EdgeLabel l = hitInfo.getHitEdgeLabel();
return new CStateChange(m_factory.createEdgeLabelEnterState(l, event), true);
} else if (hitInfo.hasHitBends()) {
return CHitBendsTransformer.changeBend(m_factory, event, hitInfo, m_bend);
} else if (hitInfo.hasHitPorts()) {
return new CStateChange(this, true);
} else {
m_factory.createBendExitState(m_bend, event);
return new CStateChange(this, true);
}
}
use of y.base.Edge in project binnavi by google.
the class ZyNodeRealizer method scalePortCoordinates.
protected void scalePortCoordinates(final Node node, final double wOld, final double wNew, final double hOld, final double hNew) {
final Graph2D graph = (Graph2D) node.getGraph();
final double wScaling = wOld > 0 ? wNew / wOld : 1.0d;
final double hScaling = hOld > 0 ? hNew / hOld : 1.0d;
for (Edge e = node.firstOutEdge(); e != null; e = e.nextOutEdge()) {
final EdgeRealizer er = graph.getRealizer(e);
final Port port = er.getSourcePort();
final double px = port.getOffsetX() * wScaling;
final double py = port.getOffsetY() * hScaling;
port.setOffsets(px, py);
graph.setSourcePointRel(e, new YPoint(px, py));
}
for (Edge e = node.firstInEdge(); e != null; e = e.nextInEdge()) {
final EdgeRealizer er = graph.getRealizer(e);
final Port port = er.getTargetPort();
final double px = port.getOffsetX() * wScaling;
final double py = port.getOffsetY() * hScaling;
port.setOffsets(px, py);
graph.setTargetPointRel(e, new YPoint(px, py));
}
}
use of y.base.Edge in project binnavi by google.
the class TypeDependenceGraph method deleteMember.
// Deletes all member relations from the graph.
private ImmutableSet<BaseType> deleteMember(final BaseType containingType, final BaseType memberType) {
final Node containingTypeNode = containedRelationMap.get(containingType);
final Node memberTypeNode = containedRelationMap.get(memberType);
final Edge memberEdge = memberTypeNode.getEdgeTo(containingTypeNode);
containedRelation.removeEdge(memberEdge);
return determineDependentTypes(containingType);
}
Aggregations