use of org.cytoscape.ding.ViewChangeEdit in project cytoscape-impl by cytoscape.
the class InnerCanvas method toggleSelectedEdge.
private int toggleSelectedEdge(long chosenEdge, MouseEvent e) {
int chosenEdgeSelected = 0;
final boolean wasSelected = m_view.getDEdgeView(chosenEdge).isSelected();
// Linux users should use Ctrl-Alt since many window managers capture Alt-drag to move windows
if ((e.isAltDown()) && ((m_lastRenderDetail & GraphRenderer.LOD_EDGE_ANCHORS) != 0)) {
m_view.m_selectedAnchors.empty();
m_ptBuff[0] = m_lastXMousePos;
m_ptBuff[1] = m_lastYMousePos;
m_view.xformComponentToNodeCoords(m_ptBuff);
// Store current handle list
m_undoable_edit = new ViewChangeEdit(m_view, ViewChangeEdit.SavedObjs.SELECTED_EDGES, "Add Edge Handle", serviceRegistrar);
final Point2D newHandlePoint = new Point2D.Float((float) m_ptBuff[0], (float) m_ptBuff[1]);
DEdgeView edgeView = m_view.getDEdgeView(chosenEdge);
Bend defaultBend = edgeView.getDefaultValue(BasicVisualLexicon.EDGE_BEND);
if (edgeView.getVisualProperty(BasicVisualLexicon.EDGE_BEND) == defaultBend) {
if (defaultBend instanceof BendImpl)
edgeView.setLockedValue(BasicVisualLexicon.EDGE_BEND, new BendImpl((BendImpl) defaultBend));
else
edgeView.setLockedValue(BasicVisualLexicon.EDGE_BEND, new BendImpl());
}
DEdgeView ev = m_view.getDEdgeView(chosenEdge);
final int chosenInx = ev.addHandlePoint(newHandlePoint);
m_view.m_selectedAnchors.insert(((chosenEdge) << 6) | chosenInx);
}
// Ignore Ctrl if Alt is down so that Ctrl-Alt can be used for edge bends without side effects
if (wasSelected && (e.isShiftDown() || (isControlOrMetaDown(e) && !e.isAltDown()))) {
// ((DEdgeView) m_view.getDEdgeView(chosenEdge)).unselectInternal();
chosenEdgeSelected = -1;
} else if (!wasSelected) {
// ((DEdgeView) m_view.getDEdgeView(chosenEdge)).selectInternal(false);
chosenEdgeSelected = 1;
if ((m_lastRenderDetail & GraphRenderer.LOD_EDGE_ANCHORS) != 0) {
m_ptBuff[0] = m_lastXMousePos;
m_ptBuff[1] = m_lastYMousePos;
m_view.xformComponentToNodeCoords(m_ptBuff);
final LongEnumerator hits = m_view.m_spacialA.queryOverlap((float) m_ptBuff[0], (float) m_ptBuff[1], (float) m_ptBuff[0], (float) m_ptBuff[1], null, 0, false);
if (hits.numRemaining() > 0) {
final long hit = hits.nextLong();
if (m_view.m_selectedAnchors.count(hit) == 0)
m_view.m_selectedAnchors.insert(hit);
}
}
}
m_button1NodeDrag = true;
m_view.setContentChanged();
return chosenEdgeSelected;
}
use of org.cytoscape.ding.ViewChangeEdit in project cytoscape-impl by cytoscape.
the class InnerCanvas method toggleChosenAnchor.
private void toggleChosenAnchor(long chosenAnchor, MouseEvent e) {
final long edge = chosenAnchor >>> 6;
DEdgeView ev = m_view.getDEdgeView(edge);
// Linux users should use Ctrl-Alt since many window managers capture Alt-drag to move windows
if (e.isAltDown()) {
// Remove handle
final int anchorInx = (int) (chosenAnchor & 0x000000000000003f);
// Save remove handle
m_undoable_edit = new ViewChangeEdit(m_view, ViewChangeEdit.SavedObjs.SELECTED_EDGES, "Remove Edge Handle", serviceRegistrar);
if (!ev.isValueLocked(BasicVisualLexicon.EDGE_BEND)) {
Bend defaultBend = ev.getDefaultValue(BasicVisualLexicon.EDGE_BEND);
if (ev.getVisualProperty(BasicVisualLexicon.EDGE_BEND) == defaultBend) {
ev.setLockedValue(BasicVisualLexicon.EDGE_BEND, new BendImpl((BendImpl) defaultBend));
} else {
ev.setLockedValue(BasicVisualLexicon.EDGE_BEND, new BendImpl((BendImpl) ev.getBend()));
}
}
ev.removeHandle(anchorInx);
m_button1NodeDrag = false;
m_lod[0].setDrawEdges(true);
// final GraphViewChangeListener listener = m_view.m_lis[0];
// listener.graphViewChanged(new GraphViewEdgesSelectedEvent(m_view, DGraphView.makeList(ev.getCyEdge())));
} else {
final boolean wasSelected = m_view.m_selectedAnchors.count(chosenAnchor) > 0;
// Ignore Ctrl if Alt is down so that Ctrl-Alt can be used for edge bends without side effects
if (wasSelected && (e.isShiftDown() || (isControlOrMetaDown(e) && !e.isAltDown()))) {
m_view.m_selectedAnchors.delete(chosenAnchor);
} else if (!wasSelected) {
if (!e.isShiftDown() && !(isControlOrMetaDown(e) && !e.isAltDown()))
m_view.m_selectedAnchors.empty();
m_view.m_selectedAnchors.insert(chosenAnchor);
}
m_button1NodeDrag = true;
}
m_view.setContentChanged();
}
Aggregations