📄 groutgraphicsequencecollection.java
字号:
XBox.add(gs); XBox.add(Box.createHorizontalGlue()); seqBox.add(XBox,index); gs.setToolTipText(""); //enable tooltip display SequenceNameJButton snj = new SequenceNameJButton(seq,ypad); graphicName.add(index,snj); XBox = new Box(BoxLayout.X_AXIS); XBox.add(Box.createHorizontalGlue()); XBox.add(snj); seqNameBox.add(XBox,index); if(seq.getLength()>MAXSEQLENGTH) MAXSEQLENGTH = seq.getLength(); Dimension actual = gs.getMaximumSize(); int slen = gs.getResidueWidth()*(int)(MAXSEQLENGTH*1.2); gs.setMaximumSize(new Dimension(slen,(int)actual.getHeight())); } /** * * Add a sequence to the sequence collection display and * to the collection of sequences (seqs) with a specified * y-padding. * @param seq sequence to add to the editor display * @param addToSequences true to add seq to the vector of sequences * @param ypad sequence panel height padding * @param fontSize font size * */ protected void addSequence(Sequence seq, boolean addToSequences, int ypad, int fontSize) { if(addToSequences) seqs.add(seq); GroutSequenceJPanel gs = new GroutSequenceJPanel(seq,this, drawSequence,drawBlackBox,drawColorBox, colorScheme,fontSize,ypad); // System.out.println("adding new2 gs = " + gs); graphicSequence.add(gs); // for(int i = 0; i < graphicSequence.size(); ++i) // { // System.out.println("graphicSequence.elementAt(" + i + ") = " + graphicSequence.elementAt(i)); // } Box XBox = new Box(BoxLayout.X_AXIS); XBox.add(gs); XBox.add(Box.createHorizontalGlue()); seqBox.add(XBox); gs.setToolTipText(""); //enable tooltip display SequenceNameJButton snj = new SequenceNameJButton(seq,ypad); graphicName.add(snj); XBox = new Box(BoxLayout.X_AXIS); XBox.add(Box.createHorizontalGlue()); XBox.add(snj); seqNameBox.add(XBox); if(seq.getLength()>MAXSEQLENGTH) MAXSEQLENGTH = seq.getLength(); Dimension actual = gs.getMaximumSize(); int slen = gs.getResidueWidth()*(int)(MAXSEQLENGTH*1.2); gs.setMaximumSize(new Dimension(slen,(int)actual.getHeight())); } /** * * Moves the view position to this residue * * @param position the position to view * */ public void setPosition(int position) { int extent = jspSequence.getHorizontalScrollBar().getVisibleAmount(); int residueWidth = ((SequenceJPanel)graphicSequence.elementAt(0)) .getResidueWidth(); int bottom = (position * residueWidth) - extent / 2; if(bottom < 0) { bottom = 0; } // System.out.println("GroutGraphicSequenceCollection setPosition to " + bottom); // System.out.println("position2 = " + position + " residueWidth = " + residueWidth + " extent = " + extent + " (position * residueWidth) = " + (position * residueWidth) + " extent / 2 = " + extent / 2); jspSequence.getHorizontalScrollBar().setValue(bottom); } private void addResidue() { int resPos = 1; int pressedResidue = 0; String padChar = new String("-"); for(int i = 0; i< graphicSequence.size(); ++i) { SequenceJPanel seqP = ((SequenceJPanel) graphicSequence.elementAt(i)); // System.out.println("seqP = " + seqP + " seqP.seq = " + seqP.seq); if(seqP.seq != null) { // System.out.println("seqP.seq.getSequence() = " + seqP.seq.getSequence()); String seqS = seqP.seq.getSequence(); // System.out.println("seqS = " + seqS); if(resPos == pressedResidue+1 && resPos > 0) { seqP.seq.insertResidue(padChar,pressedResidue); setMaxSequenceLength(seqP.seq.getLength()); // seqP.pressedResidue = pressedResidue+1; seqP.paintComponent(getGraphics()); seqP.viewPaneResize(); } } } } /** * * Override for scrollable interface * */ public int getScrollableBlockIncrement(Rectangle r, int orientation, int direction) { return 60; } /** * * Override for scrollable interface * */ public int getScrollableUnitIncrement(Rectangle r, int orientation, int direction) { if(graphicSequence.elementAt(0) != null) { return ((SequenceJPanel)graphicSequence.elementAt(0)) .getResidueWidth(); } else { return 18; } } public synchronized void addGroutGraphicSequenceCollectionListener(GroutGraphicSequenceCollectionListener listener) { // System.out.println("adding to " + targets + " = " + listener); if(targets == null) { targets = new Vector(); } targets.addElement(listener); } public synchronized void removeGroutGraphicSequenceCollectionListener(GroutGraphicSequenceCollectionListener listener) { targets.removeElement(listener); } protected void notifyTargets(String propertyName, Object oldValue, Object newValue) { // System.out.println("notifyTargets = " + targets.size()); Vector l; GroutGraphicSequenceCollectionEvent s = new GroutGraphicSequenceCollectionEvent((Object) this, propertyName, oldValue, newValue); synchronized(this) { l = (Vector) targets.clone(); } for (int i = 0; i < l.size(); i++) { GroutGraphicSequenceCollectionListener sl = (GroutGraphicSequenceCollectionListener) l.elementAt(i); // System.out.println(propertyName + " changed in " + sl); sl.groutGraphicSequenceCollectionChanged(s); } } public void adjustmentValueChanged(AdjustmentEvent evt) { // System.out.println("result = " + evt + " graphicSequence.size() = " + graphicSequence.size()); if(graphicSequence.size() > 0) { int bottom = jspSequence.getHorizontalScrollBar().getValue(); int extent = jspSequence.getHorizontalScrollBar().getVisibleAmount(); int residueWidth = ((SequenceJPanel)graphicSequence.elementAt(0)) .getResidueWidth(); int middlePosition = (bottom + (extent / 2)) / residueWidth; notifyTargets("sequencePositionChanged", new Integer(0), new Integer(middlePosition)); } } protected void drawNumber() { // System.out.println("drawNumber zdgtja"); numberDraw = new GroutSequenceJPanel(10,MAXSEQLENGTH); // System.out.println("numberDraw = " + numberDraw); addGroutGraphicSequenceCollectionListener(((GroutSequenceJPanel) numberDraw)); graphicSequence.add(numberDraw); for(int i = 0; i < graphicSequence.size(); ++i) { // System.out.println("dn graphicSequence.elementAt(" + i + ") = " + graphicSequence.elementAt(i)); } Box XBox = new Box(BoxLayout.X_AXIS); XBox.add(numberDraw); XBox.add(Box.createHorizontalGlue()); seqBox.add(XBox); setNumberSize(); SequenceNameJButton snjBlank = new SequenceNameJButton(new Sequence(" "),0); graphicName.add(snjBlank); seqNameBox.add(snjBlank); } public int setSize() { Dimension size = getPreferredSize(); size.height = numberDraw.seqHeight * graphicSequence.size(); setPreferredSize(size); return size.height; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -