public final class SequenceCanvas
extends org.biolegato.main.DataCanvas
implements javax.swing.event.ListSelectionListener
The BioLegato sequence-based canvas class (based on GDE).
Add anything that might cause problems or complicate the modification of this class in general within this section!
Some special things to watch out for when editing the SequenceCanvas object:
The properties for BioLegato contains an optional property called readonly, that should do, as the name implies, write-protect the data. The 'editable' constant stores the opposite value of the readonly property. To ensure that this happens, when programming you must wrap all methods that involve canvas manipulation with the following:
if (editable) {
// CODE goes in here (readonly status is OFF)
}
You must handle that there can be up to two text panes at any given time.
Because the canvas can be split into two separate text panes, any methods which interact with the primary text pane (dataCollector), should also be able to interact with the secondary/alternate text pane (altDataCollector). If this is not done, coding may introduce unforseen bugs into the code.
IMPORTANT: Also note that if there is no secondary/alternate canvas being used (i.e. the text canvas has not yet been "Split" into two text panes), the variable "altDataCollector" will be null. Your code must also handle this situation by not interacting with altDataCollector unless it is not null.
IMPORTANT: Also be sure to look at the code for splitAction and joinAction whenever you modify the variable dataCollector. This is because these two action commands contain the code to construct and destruct the alternate text pane (altDataCollector).
See selectionMade and valueChanged methods
javax.swing.JApplet.AccessibleJApplet
java.applet.Applet.AccessibleApplet
Modifier and Type | Field and Description |
---|---|
javax.swing.AbstractAction |
changeCaseAction
The "Change case" menu item action.
|
java.util.List<ColourMask> |
colourMasks
The list of all colour masks loaded in the system.
|
javax.swing.AbstractAction |
copyAct
The "Copy" menu item action.
|
javax.swing.AbstractAction |
cutAct
The "Cut" menu item action.
|
static java.awt.Font |
DEFAULT_FONT
The default font for the canvas (12pt monospaced).
|
ColourMask |
DEFAULT_MASK
The default colour mask for BioLegato.
|
javax.swing.AbstractAction |
joinAction
Action for joining a split text area back into one text area.
|
javax.swing.AbstractAction |
openAction
The "Open..." menu item action.
|
javax.swing.AbstractAction |
pasteAct
The "Paste" menu item action.
|
javax.swing.AbstractAction |
propertiesAction
The "Properties..." menu item action.
|
javax.swing.AbstractAction |
saveAsAction
The "Save ALL As..." menu item action.
|
ABOUT_MENUITEM, EMPTY_STRING, EXIT_MENUITEM, NAME, properties
accessibleContext, rootPane, rootPaneCheckingEnabled
Constructor and Description |
---|
SequenceCanvas()
Creates a new instance of a SequenceCanvas.
|
SequenceCanvas(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> props)
Creates a new instance of a SequenceCanvas.
|
Modifier and Type | Method and Description |
---|---|
void |
copyClipboard()
Copies the currently selected sequences or text from the sequence canvas
to the clipboard.
|
void |
cursorChange(int column,
int row)
This method receives cursor updates for use in the status bar, and
updates the row and column number displayed in the sequence canvas's
status bar.
|
java.awt.Component |
display()
Displays the canvas.
|
ColourMask |
getDefaultMask()
Load the default colour masks into BioLegato (this was the only way I was
able to get the default colour mask to load properly and efficiently).
|
java.lang.String |
getPluginName()
Deprecated.
vestigial code from a previous BioLegato framework structure.
|
void |
insertionMode(boolean mode)
Thie method receives insertion mode change updates for use in the status
bar.
|
static void |
main(java.lang.String[] args)
Starts a new instance of BioLegato, using the sequence canvas.
|
void |
pasteClipboard()
Pastes the current contents of the clipboard (null if empty) into the
canvas at the current cursor position (within either the text area or
the sequence list).
|
void |
readFile(java.lang.String formatString,
java.io.Reader in,
boolean overwrite,
boolean forceall)
Reads a data into the canvas.
|
void |
selectionMade(SequenceTextArea source)
Manages mutual exclusion between the textareas and the list
This method listens to the sequence text area, and deselects any
sequences in the sequence list, and the other text area (if the text area
is split), whenever something is selected in one of the sequence text
areas.
|
static void |
textLengthChanged(int x,
int y,
int length)
Coordinates text length changes between split text areas.
|
void |
updateFont(int size,
boolean bold)
Updates the font for the Sequence canvas and its sub-objects
|
void |
valueChanged(javax.swing.event.ListSelectionEvent e)
This method listens to the sequence list, and deselects any text in the
sequence text area(s) whenever something is selected in the sequence
list.
|
void |
writeFile(DataFormat format,
java.lang.Appendable out,
boolean forceall)
Writes data out from the canvas.
|
void |
writeFile(java.lang.String formatString,
java.lang.Appendable out,
boolean forceall)
Writes data out from the canvas to an Appendable object.
|
addMenuHeading, addMenuHeading, createJFrame, error, getJFrame, getProperty, init, message, testNumber, warning
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public final javax.swing.AbstractAction openAction
public final javax.swing.AbstractAction saveAsAction
DataFormat
public final javax.swing.AbstractAction propertiesAction
SequenceCanvasProperties
public final javax.swing.AbstractAction cutAct
The "Cut" menu item action. This action will copy any content currently selected in the canvas to the clipboard, and then delete that selected content. This behaviour is identical to the "Cut" action in most word processor programs (e.g. Office, OpenOffice, etc.)
Please note that this method will not work if the read only property is set. This method will check the readonly property by checking the editable field. If the editable field is set to false this method will not paste or execute any further code.
public final javax.swing.AbstractAction copyAct
copyClipboard()
public final javax.swing.AbstractAction pasteAct
The "Paste" menu item action. This action will delete any currently selected content, and then write the content in the clipboard (if any) to the canvas. This behaviour is almost identical to the "Paste" action in most word processor programs (e.g. Office, OpenOffice, etc.) with only the odd minor differences due to this being a sequence canvas.
Please note that this method will not work if the read only property is set. This method will check the readonly property by checking the editable field. If the editable field is set to false this method will not paste or execute any further code.
pasteClipboard()
public final javax.swing.AbstractAction changeCaseAction
The "Change case" menu item action. This action will call the change case method of either the sequence list or text area (depending on which object - the list of text area - was used last). In turn, the case of any selected string will be changed, according to the rules outlined in either changeCase method (these rules should be the same for both!)
Please see either the sequence list or sequence text area's changeCase function for further details.
public final javax.swing.AbstractAction joinAction
public static final java.awt.Font DEFAULT_FONT
public final java.util.List<ColourMask> colourMasks
public final ColourMask DEFAULT_MASK
getDefaultMask()
public SequenceCanvas()
public SequenceCanvas(java.util.Map<? extends java.lang.Object,? extends java.lang.Object> props)
props
- the BioLegato properties to initialize the canvas with.
This parameter is ignored if null.public static void main(java.lang.String[] args)
args
- the command line arguments for BioLegato.public java.lang.String getPluginName()
getPluginName
in class org.biolegato.main.DataCanvas
public void cursorChange(int column, int row)
column
- the new column number/X-coordinate of the cursor within the
sequence text area.row
- the new row number/Y-coordinate of the cursor within the
sequence text area.public void insertionMode(boolean mode)
mode
- the new insertion mode status for the sequence text area.insertStatus
,
SequenceTextArea.insertionMode(boolean)
public void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged
in interface javax.swing.event.ListSelectionListener
evt
- this parameter is currently ignored by this method.SequenceCanvasObject
,
groupMI
,
ungroupMI
,
getInfoMI
,
SequenceList.groupAction
,
SequenceList.ungroupAction
,
SequenceList.getInfoAction
,
SequenceTextArea.clearSelection()
public void selectionMade(SequenceTextArea source)
source
- the source of the event -- this is used to differentiate
between the main and alternate canvas, when the canvas is
split in two.SequenceCanvasObject
,
groupMI
,
ungroupMI
,
getInfoMI
,
SequenceList.groupAction
,
SequenceList.ungroupAction
,
SequenceList.getInfoAction
,
JList.clearSelection()
public static void textLengthChanged(int x, int y, int length)
x
- the text X-coordinate (column) the change occurred.y
- the text Y-coordinate (row) the change occurred.length
- the length of text length changed (can be negative).public final void updateFont(int size, boolean bold)
size
- the new font sizebold
- whether to bold the fontpublic void writeFile(java.lang.String formatString, java.lang.Appendable out, boolean forceall) throws java.io.IOException
writeFile
in interface org.biopcd.parser.PCDIO
formatString
- the file format to use for writing the file.out
- the "file" (or stream) to write out to.forceall
- write the entire contents of the canvas
instead of just the currently selected
sequences in the canvas.java.io.IOException
- if an error occurs while writingDataFormat.getFormat(java.lang.String)
public void writeFile(DataFormat format, java.lang.Appendable out, boolean forceall) throws java.io.IOException
format
- the file format to use for writing the file.out
- the "file" (or stream) to write out to.forceall
- write the entire contents of the canvas
instead of just the currently selected
sequences in the canvas.java.io.IOException
- if an error occurs while writingDataFormat.autodetect(java.util.Scanner)
,
DataFormat.convertTo(java.lang.Appendable, org.biolegato.sequence.data.Dataset, int)
,
SequenceCanvasObject.writeOut(org.biolegato.sequence.data.DataFormat, java.lang.Appendable)
public void readFile(java.lang.String formatString, java.io.Reader in, boolean overwrite, boolean forceall) throws java.io.IOException
readFile
in interface org.biopcd.parser.PCDIO
formatString
- the file format to use for parsing the file. If the
string "" is passed, the PCDIO object should auto-
detect the format of the data.in
- the "file" (or stream) to read in from.overwrite
- whether to overwrite the currently selected
data in the current canvas with the data
being imported by this function/method.java.io.IOException
- if an error occurs while readingDataFormat.getFormat(java.lang.String)
public java.awt.Component display()
display
in class org.biolegato.main.DataCanvas
mainDisplay
public void pasteClipboard()
public void copyClipboard()
public ColourMask getDefaultMask()
Copyright © 2008-2022 University of Manitoba.