BioLegato 0.7.3 GDE plugin

org.biolegato.gdesupport.canvas.data
Class GDEModel

java.lang.Object
  extended by org.biolegato.gdesupport.canvas.data.GDEModel
All Implemented Interfaces:
java.awt.datatransfer.Transferable, CellListener

public class GDEModel
extends java.lang.Object
implements CellListener, java.awt.datatransfer.Transferable

The internal document format for BioLegato.

This document is structured as a linked list of sequences. Each character has an offset based on its position within the list and it's position within its containing sequence. Sequences start at 0 (first character in the first sequence in the list, and end with the last character in the last sequence within the list.

Author:
Graham Alvare, Brian Fristensky

Field Summary
static java.awt.datatransfer.DataFlavor seqDocFlavour
          A data flavour representing the Dataset data type.
 
Constructor Summary
GDEModel()
          Creates a new instance of Dataset
 
Method Summary
 void addListener(GDEModelListener listener)
          Adds a listener object to the data container.
 boolean addSequence(int y, Cell seq)
          Adds a sequence to the data container.
 void addSequences(Cell[] list)
           
 boolean delete(int col, int line, int cols)
          Removes text from the document.
 boolean delete(int col, int line, int cols, int lines)
          Removes text from the document.
protected  void finalize()
          Finalizes the object - removes all references to itself
 Cell get(int number)
          Retrieves a sequence object from the Dataset specified by its line line.
 java.util.List<java.lang.Integer> getgroup(java.lang.Integer groupNumber)
           
 int getLineCount()
          Returns the number of lines in the document.
 int getLineLength(int line)
          Retrieves the length of a line in the document.
 int getLongestLine()
          Returns the length of the longest line in the data container
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavour)
          Translates the Dataset to the given format
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          Dictates what formats the Dataset can be converted to.
 void group(int[] sequences)
           
 boolean insert(int col, int line, java.lang.String string)
          Inserts a string into the document on a given line.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavour)
          Dictates whether a given format is supported for conversion
 void removeListener(GDEModelListener listener)
          Adds a listener object to the data container.
 void removeSequences(int[] lineNumbers)
          Removes an array of sequences from the data container.
 void sequenceChanged(Cell sequence, java.lang.String key)
          Called when a field in a sequence is modified.
 Cell[] toArray()
           
 void ungroup(int[] sequences)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

seqDocFlavour

public static final java.awt.datatransfer.DataFlavor seqDocFlavour
A data flavour representing the Dataset data type.

Constructor Detail

GDEModel

public GDEModel()
Creates a new instance of Dataset

Method Detail

addSequence

public boolean addSequence(int y,
                           Cell seq)
Adds a sequence to the data container. This function calls all listeners.

Parameters:
lineNumber - is the line number to insert the sequence.
seq - is the sequence to insert.
Returns:
true if the insertion was successful, otherwise false.

removeSequences

public void removeSequences(int[] lineNumbers)
Removes an array of sequences from the data container.

Parameters:
lineNumbers - the line numbers to remove.

insert

public boolean insert(int col,
                      int line,
                      java.lang.String string)
Inserts a string into the document on a given line.

Parameters:
col - the offset in the object in the dataset to insert the text.
x - the x-co-ordinate to insert the string.
line - the line-co-ordinate to insert the string.
string - the text to insert.
Returns:
true if the insertion was successful, otherwise false.

delete

public boolean delete(int col,
                      int line,
                      int cols)
Removes text from the document.

This method will delete line endings and sequences as well as individual characters from the document.

NOTE: ALL DELETIONS ARE PERFORMED AS FOLLOWS:
Cell[0]: ggggaaaa
....
Cell[3]: cccctttt
delete(4, 0, 4, 3);
Result: gggg .... cccc

Parameters:
col - the X-offset/column number to start the deletion from.
line - the Y-offset/line number to delete characters from.
cols - the width of the deletion (measured in characters along the X-axis).
Returns:
true if the deletion was successful, otherwise false.

delete

public boolean delete(int col,
                      int line,
                      int cols,
                      int lines)
Removes text from the document.

This method will delete line endings and sequences as well as individual characters from the document.

NOTE: ALL DELETIONS ARE PERFORMED AS FOLLOWS:
Cell[0]: ggggaaaa
....
Cell[3]: cccctttt
delete(4, 0, 4, 3);
Result: gggg .... cccc

Parameters:
col - the X-offset/column number to start the deletion from.
line - the Y-offset/line number to delete characters from.
w - the width of the deletion (measured in characters along the X-axis).
lines - the height of the deletion (measured in sequences along the Y-axis).
Returns:
true if the deletion was successful, otherwise false.

get

public Cell get(int number)
Retrieves a sequence object from the Dataset specified by its line line.

Parameters:
number - the line line to retreive the sequence.
Returns:
the sequence.

getLineCount

public int getLineCount()
Returns the number of lines in the document.

Returns:
the number of lines in the document.

getLineLength

public int getLineLength(int line)
Retrieves the length of a line in the document.

Parameters:
line - the line line to find the length of.
Returns:
the length of the line (in characters).

getLongestLine

public int getLongestLine()
Returns the length of the longest line in the data container

Returns:
the length of the longest line

addListener

public void addListener(GDEModelListener listener)
Adds a listener object to the data container.

Parameters:
listener - the listener to add.

removeListener

public void removeListener(GDEModelListener listener)
Adds a listener object to the data container.

Parameters:
listener - the listener to add.

sequenceChanged

public void sequenceChanged(Cell sequence,
                            java.lang.String key)
Called when a field in a sequence is modified.

Specified by:
sequenceChanged in interface CellListener
Parameters:
sequence - the sequence modified.
key - the key of the modified field in the sequence.

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Dictates what formats the Dataset can be converted to.

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable
Returns:
an array of supported formats

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavour)
Dictates whether a given format is supported for conversion

Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable
Parameters:
flavour - the flavour to test for compatability
Returns:
true if the format is supported

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavour)
                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                        java.io.IOException
Translates the Dataset to the given format

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Parameters:
flavour - the data flavour to use for translation
Returns:
the translated object
Throws:
java.awt.datatransfer.UnsupportedFlavorException - if the SeqDatasetnnot be translated into the requested data flavour
java.io.IOException - if there is a problem with I/O during the translation

finalize

protected void finalize()
Finalizes the object - removes all references to itself

Overrides:
finalize in class java.lang.Object

group

public void group(int[] sequences)

ungroup

public void ungroup(int[] sequences)

getgroup

public java.util.List<java.lang.Integer> getgroup(java.lang.Integer groupNumber)

addSequences

public void addSequences(Cell[] list)

toArray

public Cell[] toArray()

BioLegato 0.7.3 GDE plugin

Copyright © 2008-2010 University of Manitoba.