/** * makes cursor hand if at the end of an exon using mouses position, does not change pos or tier * variable */ public void mouseMoved(MouseEvent e) { // setPos sets the pos variable to the mouse position, cant do this // because on right click menu want to preserve the pos clicked on // and setPos here changes pos if user moves mouse after right click // setPos (e.getX(), e.getY()); // moveMouseTier and moveMousePos can differ from this.tier and pos int mouseMoveTier = baseEditorPanel.getTierForPixelPosition(e.getY()); // SeqAlignPanel int mouseMovePos = calculatePosition(e.getX(), e.getY()); // make the cursor a hand if it is at the end of a feature int type = baseEditorPanel.getBoundaryType(mouseMovePos, mouseMoveTier); if (type == baseEditorPanel.NO_BOUNDARY) baseEditorPanel.setCursor(Cursor.getDefaultCursor()); else baseEditorPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); }
/** * Right mouse: highlight base. Left mouse: figure dragType, dragFeature, dragStartPos, * startDragTier */ public void mousePressed(MouseEvent e) { setPos(e.getX(), e.getY()); // show base at right mouse click highlighted (on release - popup menu) if (MouseButtonEvent.isRightMouseClickNoShift(e)) { BaseRenderer rend = baseEditorPanel.getRendererAt(tier); if (rend instanceof SelectableDNARenderer) { ((SelectableDNARenderer) rend).setTargetPos(pos, tier); baseEditorPanel.repaint(); return; } } if (!MouseButtonEvent.isLeftMouseClick(e)) return; if (dragStartPos == -1) { if (e.isControlDown()) dragType = baseEditorPanel.SEQ_SELECT_DRAG; else dragType = baseEditorPanel.getBoundaryType(pos, tier); dragFeature = baseEditorPanel.getFeatureAtPosition(pos, tier); dragStartPos = pos; startPos = pos; startDragTier = tier; if (dragFeature == null && ((dragType != baseEditorPanel.SEQ_SELECT_DRAG) || startDragTier > baseEditorPanel.getTierCount() || startDragTier < 3)) { resetDragState(); return; } if (dragType == baseEditorPanel.START_BOUNDARY) { /* the 5 prime edge of the feature (exon) can be moved within limits. These are no farther in the 3prime direction than the end of the feature and no farther in the 5prime direction than the beginning (5prime) of the preceding intron */ limit_3prime = (int) dragFeature.getEnd(); int lowBound = baseEditorPanel.basePairToPos(dragFeature.getStart()); // subtract one to move into the preceding intron double[] lowRange = baseEditorPanel.getRangeAtPosition(tier, lowBound - 1); if (lowRange[0] < 0) limit_5prime = baseEditorPanel.posToBasePair(0); else limit_5prime = baseEditorPanel.posToBasePair((int) lowRange[0]); baseEditorPanel.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); } else if (dragType == baseEditorPanel.END_BOUNDARY) { limit_5prime = (int) dragFeature.getStart(); int highBound = baseEditorPanel.basePairToPos((int) dragFeature.getEnd()); double[] highRange = baseEditorPanel.getRangeAtPosition(tier, highBound + 1); SequenceI seq = baseEditorPanel.getSequenceForTier(tier); if (highRange[1] > seq.getLength()) limit_3prime = baseEditorPanel.posToBasePair(seq.getLength()); else limit_3prime = baseEditorPanel.posToBasePair((int) highRange[1]); baseEditorPanel.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); } else if (dragType == baseEditorPanel.SEQ_SELECT_DRAG) { baseEditorPanel.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); baseEditorPanel.setSelectBeginPos(pos); baseEditorPanel.setSelectCurrentPos(pos); } } }