org.emboss.jemboss.editor
Class SequenceJPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.emboss.jemboss.editor.SequenceJPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
GroutSequenceJPanel

public class SequenceJPanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener

Sequence panel for drawing a sequence or the sequence numbers

See Also:
Serialized Form

Nested Class Summary
(package private)  class SequenceJPanel.PopupListener
          Popup listener
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  int boundWidth
          boundary width around each residue
protected  int boundWidth2
          half boundary width (boundWidth/2)
private  java.awt.Color col
           
private  java.util.Hashtable colorTable
          colour scheme
private  boolean drawBlackBox
          draw a black box around residues
private  boolean drawColorBox
          colour the residues
protected  boolean drawNumber
          draw the sequence numbers
private  boolean drawSequence
          draw the sequence
private  java.awt.Font font
          font
private  int fontSize
          font size
private  boolean highlightPattern
          high light search pattern
protected  int interval
          sequence numbering interval
private  java.util.Vector observers
          observer panels in this group
private  java.lang.String padChar
          pad/gap character
private  java.lang.String pattern
          pattern to search for
private  javax.swing.JPopupMenu popup
          pop up menu
private  int pressedResidue
          residue number when pressed by mouse
private  boolean prettyPlot
          colour as per prettyplot
protected  int resWidth
          residue width
protected  Sequence seq
          sequence to display
protected  int seqHeight
          sequence height
private  int seqLength
          sequence length
protected  javax.swing.JComponent viewPane
          sequence alignment panel
private  int ypad
          sequence height pad
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SequenceJPanel(int interval, int seqLength)
          Constructor for sequence numbering
SequenceJPanel(Sequence seq, javax.swing.JComponent viewPane, boolean drawSequence, boolean drawBlackBox, boolean drawColorBox, java.util.Hashtable colorTable, int ypad)
          Constructor with default font size.
SequenceJPanel(Sequence seq, javax.swing.JComponent viewPane, boolean drawSequence, boolean drawBlackBox, boolean drawColorBox, java.util.Hashtable colorTable, int fontSize, int ypad)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Override actionPerformed for popup menu actions
protected  void attach(SequenceJPanel sjp)
          Attach sequence display to the same group
protected  void detach(SequenceJPanel sjp)
          Detach sequence display from this group
protected  void detachAll()
          Detach all sequence displays from this group
private  java.awt.Color getColor(java.lang.String s)
          Get a residue colour
 int getFontSize()
          Get the font size
 java.lang.String getName()
          Get the sequence name associated with this display
 void getNamePrintGraphic(java.awt.Graphics g2d)
          Render the sequence name graphic
private  java.util.Vector getPatternPositions(int istart, int istop, java.lang.String seqS)
          Find all occurences of the pattern in the sequence between the start and stop positions.
private  java.util.Vector getPatternPositions(int subseqStart, java.lang.String subseq)
          Find all occurences of the pattern in the sequence between the start and stop positions.
 java.awt.Dimension getPreferredSize()
          Get the preferred size dimension
 int getResidueWidth()
          Get the width of a residue
 int getSequenceHeight()
          Get the sequence panel height
 void getSequencePrintGraphic(java.awt.Graphics g2d, int MAXSEQNAME, int istart, int istop)
          Render the sequence graphic
 int getSequenceResidueWidth()
          Get the width of a residue
 int getSequenceWidth()
          Get the sequence panel width
 java.awt.Point getToolTipLocation(java.awt.event.MouseEvent e)
          Get the tool tip location
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
          Determine the tool tip to display
 void init()
          Add the mouse listener's
 boolean isPrettyPlot()
          Determine if using prettyplot display
protected  void notifyGroup(int res, int pressed)
          Update all observers
 void paintComponent(java.awt.Graphics g)
          Override paintComponent
private  boolean prettyDraw(int i, int ipos, int istop, java.lang.String res, int seqHeight, int resWidth, boolean leftResidue, java.awt.Graphics g)
           
 void setColorScheme(java.util.Hashtable colorHash)
          Set the colour scheme
 void setDefaultColorHashtable()
          Set a default colour scheme
 void setDrawBoxes(boolean drawBlackBox)
          Set whether to draw boxes around residues
 void setDrawColor(boolean drawColorBox)
          Set whether to colour residues
 void setFontSize(int size)
          Set the font size and set the size
 void setPrettyPlot(boolean prettyPlot)
          Set prettyplot display
 void setSequenceLength(int s)
          Set the sequence length
protected  void showPattern(java.lang.String pattern)
          Set pattern to high light
protected  void update(int resPos, int pressed)
          Implement update() for observers i.e.
protected  void viewPaneResize()
          Re-size the sequence alignment panel if the width of this sequence pane increases
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

col

private java.awt.Color col

seq

protected Sequence seq
sequence to display


fontSize

private int fontSize
font size


font

private java.awt.Font font
font


boundWidth

private int boundWidth
boundary width around each residue


boundWidth2

protected int boundWidth2
half boundary width (boundWidth/2)


resWidth

protected int resWidth
residue width


seqHeight

protected int seqHeight
sequence height


pressedResidue

private int pressedResidue
residue number when pressed by mouse


interval

protected int interval
sequence numbering interval


seqLength

private int seqLength
sequence length


ypad

private int ypad
sequence height pad


colorTable

private java.util.Hashtable colorTable
colour scheme


padChar

private java.lang.String padChar
pad/gap character


pattern

private java.lang.String pattern
pattern to search for


drawSequence

private boolean drawSequence
draw the sequence


drawBlackBox

private boolean drawBlackBox
draw a black box around residues


drawColorBox

private boolean drawColorBox
colour the residues


drawNumber

protected boolean drawNumber
draw the sequence numbers


prettyPlot

private boolean prettyPlot
colour as per prettyplot


highlightPattern

private boolean highlightPattern
high light search pattern


viewPane

protected javax.swing.JComponent viewPane
sequence alignment panel


popup

private javax.swing.JPopupMenu popup
pop up menu


observers

private java.util.Vector observers
observer panels in this group

Constructor Detail

SequenceJPanel

public SequenceJPanel(Sequence seq,
                      javax.swing.JComponent viewPane,
                      boolean drawSequence,
                      boolean drawBlackBox,
                      boolean drawColorBox,
                      java.util.Hashtable colorTable,
                      int fontSize,
                      int ypad)
Parameters:
seq - sequence to display
viewPane - sequence alignment panel
drawSequence - draw the sequence if true
drawBlackBox - draw a black box around residues
drawColorBox - colour the residues
colorTable - colour scheme
fontSize - font size
ypad - sequence height pad

SequenceJPanel

public SequenceJPanel(Sequence seq,
                      javax.swing.JComponent viewPane,
                      boolean drawSequence,
                      boolean drawBlackBox,
                      boolean drawColorBox,
                      java.util.Hashtable colorTable,
                      int ypad)
Constructor with default font size.

Parameters:
seq - sequence to display
viewPane - sequence alignment panel
drawSequence - draw the sequence if true
drawBlackBox - draw a black box around residues
drawColorBox - colour the residues
colorTable - colour scheme
ypad - sequence height pad

SequenceJPanel

public SequenceJPanel(int interval,
                      int seqLength)
Constructor for sequence numbering

Parameters:
interval - numbering interval
seqLength - length of the sequence
Method Detail

init

public void init()
Add the mouse listener's


update

protected void update(int resPos,
                      int pressed)
Implement update() for observers i.e. members of the same sequence group


attach

protected void attach(SequenceJPanel sjp)
Attach sequence display to the same group


detach

protected void detach(SequenceJPanel sjp)
Detach sequence display from this group


detachAll

protected void detachAll()
Detach all sequence displays from this group


notifyGroup

protected void notifyGroup(int res,
                           int pressed)
Update all observers


paintComponent

public void paintComponent(java.awt.Graphics g)
Override paintComponent

Parameters:
g - graphics

prettyDraw

private boolean prettyDraw(int i,
                           int ipos,
                           int istop,
                           java.lang.String res,
                           int seqHeight,
                           int resWidth,
                           boolean leftResidue,
                           java.awt.Graphics g)
Parameters:
i - residue number
ipos - x position
res - residue
seqHeight - sequence height
resWidth - sequence width
leftResidue - true if the left residue is an identical match
g - graphics

getPatternPositions

private java.util.Vector getPatternPositions(int istart,
                                             int istop,
                                             java.lang.String seqS)
Find all occurences of the pattern in the sequence between the start and stop positions. Returning all positions of these in a vector.

Parameters:
istart - start search from
istop - stop search from
seqS - sequence string to search
Returns:
vector of all positions which match

getPatternPositions

private java.util.Vector getPatternPositions(int subseqStart,
                                             java.lang.String subseq)
Find all occurences of the pattern in the sequence between the start and stop positions. Returning all positions of these in a vector.

Parameters:
subseqStart - index of the start of the (sub)sequence
subseq - sequence string to search
Returns:
vector of all positions which match

showPattern

protected void showPattern(java.lang.String pattern)
Set pattern to high light

Parameters:
pattern - pattern to high light

setPrettyPlot

public void setPrettyPlot(boolean prettyPlot)
Set prettyplot display

Parameters:
prettyPlot - true if the prettyplot display is to be used

isPrettyPlot

public boolean isPrettyPlot()
Determine if using prettyplot display

Returns:
true if the prettyplot display is to be used

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Determine the tool tip to display

Parameters:
e - mouse event
Returns:
tool tip

getToolTipLocation

public java.awt.Point getToolTipLocation(java.awt.event.MouseEvent e)
Get the tool tip location

Parameters:
e - mouse event
Returns:
point on the display

getColor

private java.awt.Color getColor(java.lang.String s)
Get a residue colour

Parameters:
s - residue
Returns:
colour of the residue s

setDefaultColorHashtable

public void setDefaultColorHashtable()
Set a default colour scheme


setDrawBoxes

public void setDrawBoxes(boolean drawBlackBox)
Set whether to draw boxes around residues

Parameters:
drawBlackBox - true to draw boxes

setDrawColor

public void setDrawColor(boolean drawColorBox)
Set whether to colour residues

Parameters:
drawColorBox - true to colour residues

setFontSize

public void setFontSize(int size)
Set the font size and set the size

Parameters:
size - font size

getResidueWidth

public int getResidueWidth()
Get the width of a residue

Returns:
residue width

setColorScheme

public void setColorScheme(java.util.Hashtable colorHash)
Set the colour scheme

Parameters:
colorHash - colour scheme to use

getFontSize

public int getFontSize()
Get the font size

Returns:
font size

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get the preferred size dimension

Returns:
preferred dimension for this component

viewPaneResize

protected void viewPaneResize()
Re-size the sequence alignment panel if the width of this sequence pane increases


getSequenceHeight

public int getSequenceHeight()
Get the sequence panel height

Returns:
sequence height

getSequenceWidth

public int getSequenceWidth()
Get the sequence panel width

Returns:
sequence width

getSequenceResidueWidth

public int getSequenceResidueWidth()
Get the width of a residue

Returns:
residue width

setSequenceLength

public void setSequenceLength(int s)
Set the sequence length

Parameters:
s - sequence length

getName

public java.lang.String getName()
Get the sequence name associated with this display

Returns:
sequence name

getNamePrintGraphic

public void getNamePrintGraphic(java.awt.Graphics g2d)
Render the sequence name graphic

Parameters:
g2d - graphic

getSequencePrintGraphic

public void getSequencePrintGraphic(java.awt.Graphics g2d,
                                    int MAXSEQNAME,
                                    int istart,
                                    int istop)
Render the sequence graphic

Parameters:
g2d - graphic
MAXSEQNAME - maximum size for a sequence name
istart - sequence start position for graphic
istop - sequence stop position for graphic

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Override actionPerformed for popup menu actions

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - action event