use of y.view.HitInfo in project binnavi by google.
the class CNodeClickedMiddleState 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()) {
return CHitNodesTransformer.changeNode(m_factory, event, hitInfo, m_node);
} else {
m_factory.createNodeExitState(m_node, event);
return CHitNodesTransformer.exitNode(m_factory, event, hitInfo, this);
}
}
use of y.view.HitInfo in project binnavi by google.
the class CNodeClickedRightState method mouseMoved.
@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
final double x = graph.getEditMode().translateX(event.getX());
final double y = graph.getEditMode().translateY(event.getY());
final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y);
if (hitInfo.hasHitNodes()) {
return CHitNodesTransformer.changeNode(m_factory, event, hitInfo, m_node);
} else {
m_factory.createNodeExitState(m_node, event);
return CHitNodesTransformer.exitNode(m_factory, event, hitInfo, this);
}
}
use of y.view.HitInfo in project binnavi by google.
the class CNodeDraggedLeftState method mouseReleased.
@Override
public IMouseStateChange mouseReleased(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()) {
return CHitNodesTransformer.changeNode(m_factory, event, hitInfo, m_node);
} else {
m_factory.createNodeExitState(m_node, event);
return CHitNodesTransformer.exitNode(m_factory, event, hitInfo, this);
}
}
use of y.view.HitInfo in project binnavi by google.
the class CMousePressedHandler method handleMousePressed.
public static IMouseStateChange handleMousePressed(final CStateFactory<?, ?> factory, final IMouseState defaultState, final AbstractZyGraph<?, ?> graph, final MouseEvent event) {
final double x = graph.getEditMode().translateX(event.getX());
final double y = graph.getEditMode().translateY(event.getY());
final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y);
if (hitInfo.hasHitNodes()) {
final Node n = hitInfo.getHitNode();
if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) {
return new CStateChange(factory.createNodePressedLeftState(n, event), true);
} else if (SwingUtilities.isRightMouseButton(event)) {
return new CStateChange(factory.createNodePressedRightState(n, event), true);
} else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
return new CStateChange(factory.createNodePressedMiddleState(n, event), false);
} else {
return new CStateChange(defaultState, true);
}
} else if (hitInfo.hasHitNodeLabels()) {
throw new IllegalStateException("yFiles Labels are not in use...");
} else if (hitInfo.hasHitEdges()) {
final Edge edge = hitInfo.getHitEdge();
if (SwingUtilities.isLeftMouseButton(event)) {
return new CStateChange(factory.createEdgePressedLeftState(edge, event), true);
} else if (SwingUtilities.isRightMouseButton(event)) {
return new CStateChange(factory.createEdgePressedRightState(edge, event), true);
} else {
return new CStateChange(defaultState, true);
}
} else if (hitInfo.hasHitEdgeLabels()) {
// {
return new CStateChange(defaultState, true);
// }
} else if (hitInfo.hasHitBends()) {
final Bend bend = hitInfo.getHitBend();
if (SwingUtilities.isLeftMouseButton(event)) {
return new CStateChange(factory.createBendPressedLeftState(bend, event), true);
} else {
return new CStateChange(defaultState, true);
}
} else if (hitInfo.hasHitPorts()) {
return new CStateChange(factory.createDefaultState(), true);
} else {
if (SwingUtilities.isLeftMouseButton(event)) {
return new CStateChange(factory.createBackgroundPressedLeftState(event), true);
} else if (SwingUtilities.isRightMouseButton(event)) {
return new CStateChange(factory.createBackgroundPressedRightState(event), true);
}
return new CStateChange(factory.createDefaultState(), true);
}
}
use of y.view.HitInfo in project binnavi by google.
the class CDefaultState 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()) {
return CHitNodesTransformer.enterNode(m_factory, event, hitInfo);
} else if (hitInfo.hasHitEdges()) {
return CHitEdgesTransformer.enterEdge(m_factory, event, hitInfo);
} else if (hitInfo.hasHitEdgeLabels()) {
return CHitEdgeLabelsTransformer.enterEdgeLabel(m_factory, event, hitInfo);
} else if (hitInfo.hasHitBends()) {
return CHitBendsTransformer.enterBend(m_factory, event, hitInfo);
} else if (hitInfo.hasHitPorts()) {
return new CStateChange(this, true);
} else {
return new CStateChange(this, true);
}
}
Aggregations