edu.mssm.crover.domain2d
Class Diagram

java.lang.Object
  |
  +--edu.mssm.crover.domain2d.Diagram

public class Diagram
extends java.lang.Object

A Diagram is the representation of a Domain2D_Annotation model. It encapsulates the logic needed to draw a complete diagram from the annotation node.


Field Summary
protected  DrawingSurface ds
           
protected  Domain2D first
           
protected  javax.swing.JFrame frame
           
 
Constructor Summary
Diagram()
          The default constructor builds a sequence called "nothing" and a Domain2D_Annotation which contains no domain.
Diagram(AnnotatedBioSequence s)
           
Diagram(AnnotatedBioSequence s, Domain2D_Annotation d2da)
           
 
Method Summary
protected  java.awt.Dimension computePreferredSize(java.awt.Component[] comps)
           
 void dispose()
          Dispose of this diagram.
protected  void enlargePreferredSize(java.awt.Dimension min_size, java.awt.geom.Point2D cpoint, double width, double height)
          Helps determine the size of this component.
 Domain2D getDomainById(java.lang.String id)
          Return the Domain which has this id.
 ResidueGlyphFactory getGlyphFactory()
           
 GlyphLink[] getGlyphLinks()
          Obtain the location of the residue glyphs on the page.
 java.awt.image.BufferedImage getImage()
          Returns the image corresponding to this diagram.
 Domain2D_Annotation getModel()
          Get the model represented by this diagram.
 Domain2D getRenderingEngine(int i)
          Returns the rendering engine for the ith SSR.
 ResidueGlyph getResidueGlyph(int position)
          Returns the ResidueGlyph corresponding to this position in this sequence.
 ResidueGlyphRenderingAttributes getResidueGlyphRenderingAttributes()
          Obtain the residue glyph rendering attributes.
 ResidueModelFactory getResidueModelFactory()
          Obtain the factory used for globally for residue model instanciation.
 DrawingSurface getSurface()
          Returns the DrawingSurface owned by this diagram.
 void inFrame(boolean inFrame)
          Install the diagram in a JFrame.
 boolean isFocusTraversable()
           
static void main(java.lang.String[] args)
          Tests various features of the Diagram class.
 void organize()
          Organizes the appearance of the diagram.
 void repaint()
          Repaint the diagram.
 void saveGIFImage(java.io.File output)
          Save this diagram as a GIF image file.
 void saveJPEGImage(java.io.File output)
          Save this diagram as a JPEG image file.
 void savePostScript(java.io.File output)
          Save this diagram as a PostScript file.
 void savePostScript(java.io.File output, int resolution, float width, float height)
          Save this diagram as a PostScript file.
 void setAnnotationsTranslator(AnnotationsToDrawings translator)
          Sets the annotation translator for this diagram.
 void setModel(Domain2D_Annotation m)
          Sets the model to be represented.
 void setSize(java.awt.Dimension d)
          Sets the size of the diagram.
 void setSize(int width, int height)
          Sets the size of the diagram.
 void setVisible(boolean show)
          Show or hide the diagram.
 void useRenderingAttributes(ResidueGlyphRenderingAttributes rgra)
          Use the specified rendering attributes when instanciating the resigue glyphs of the diagram.
 void useResidueModelFactory(ResidueModelFactory rmf)
          Use the specified factory for residue model instanciation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frame

protected javax.swing.JFrame frame

ds

protected DrawingSurface ds

first

protected Domain2D first
Constructor Detail

Diagram

public Diagram()
The default constructor builds a sequence called "nothing" and a Domain2D_Annotation which contains no domain. Use it to create an empty diagram before adding domains interactively and modifying the sequence.


Diagram

public Diagram(AnnotatedBioSequence s)

Diagram

public Diagram(AnnotatedBioSequence s,
               Domain2D_Annotation d2da)
Method Detail

setAnnotationsTranslator

public void setAnnotationsTranslator(AnnotationsToDrawings translator)
Sets the annotation translator for this diagram. The new translator will perform the translation the next time setModel() is invoked.


inFrame

public void inFrame(boolean inFrame)
Install the diagram in a JFrame.


isFocusTraversable

public boolean isFocusTraversable()

useResidueModelFactory

public void useResidueModelFactory(ResidueModelFactory rmf)
Use the specified factory for residue model instanciation. After this call, all the domain2d instanciated are instructed to use rmf. The default behaviour constist in the default for each domain2d. Typically, each domain is instanciated with a no-arg constructor, so they have little choice but instanciate a new Factory for their own use.


getResidueModelFactory

public ResidueModelFactory getResidueModelFactory()
Obtain the factory used for globally for residue model instanciation.

See Also:
useResidueModelFactory(edu.mssm.crover.domain2d.ResidueModelFactory)

getResidueGlyphRenderingAttributes

public ResidueGlyphRenderingAttributes getResidueGlyphRenderingAttributes()
Obtain the residue glyph rendering attributes.

See Also:
#

useRenderingAttributes

public void useRenderingAttributes(ResidueGlyphRenderingAttributes rgra)
Use the specified rendering attributes when instanciating the resigue glyphs of the diagram.

See Also:
ResidueGlyph, ResidueGlyphRenderingAttributes

dispose

public void dispose()
Dispose of this diagram. Clean all the references associated with this instance so that the instance can eventually be garbage collected. Forgetting to call this method leads to memory leaks..


getModel

public Domain2D_Annotation getModel()
Get the model represented by this diagram.

See Also:
setModel()

getDomainById

public Domain2D getDomainById(java.lang.String id)
Return the Domain which has this id.

Returns:
the Domain2D instance which has this ID, or null if none has been found in this DS.

setModel

public void setModel(Domain2D_Annotation m)
Sets the model to be represented. ResidueModelFactory and ResidueGlyphRenderingAttributes are taken into account when instanciating the engine only when both values have been provided.


setSize

public void setSize(java.awt.Dimension d)
Sets the size of the diagram.


setSize

public void setSize(int width,
                    int height)
Sets the size of the diagram.


getSurface

public DrawingSurface getSurface()
Returns the DrawingSurface owned by this diagram.


saveJPEGImage

public void saveJPEGImage(java.io.File output)
                   throws java.io.IOException
Save this diagram as a JPEG image file. Any code that uses this methods is not portable. The JPEG image file is created using a Sun extension (com.sun.image.codec.jpeg).

java.io.IOException

saveGIFImage

public void saveGIFImage(java.io.File output)
                  throws java.io.IOException
Save this diagram as a GIF image file.

java.io.IOException

getImage

public java.awt.image.BufferedImage getImage()
Returns the image corresponding to this diagram. Rembember to call flush() on the returned image when it is no longer needed.


savePostScript

public void savePostScript(java.io.File output,
                           int resolution,
                           float width,
                           float height)
                    throws java.io.IOException
Save this diagram as a PostScript file. This alternative savePostScript method provides a way to pass information about the resolution of the printer the driver of which will be used to render the diagram as a PostScript file. The width and height of the resulting diagram, according to the resolution of the driver, can be provided.

Parameters:
resolution - Number of dots per inch (DPI) the driver of this Printer will generate.
width - Choosen width for diagram on the page.
height - Choosen height for diagram on the page.
java.io.IOException

savePostScript

public void savePostScript(java.io.File output)
                    throws java.io.IOException
Save this diagram as a PostScript file. Currently, the output parameter is ignored. There is no way with Java2 to do any kind of batch printing. The default resolution is 600 DPI, the default width is 10cm, and no height is provided, so it is adjusted depending on the aspect ratio the diagram has and the width which is specified.

java.io.IOException

computePreferredSize

protected java.awt.Dimension computePreferredSize(java.awt.Component[] comps)

enlargePreferredSize

protected void enlargePreferredSize(java.awt.Dimension min_size,
                                    java.awt.geom.Point2D cpoint,
                                    double width,
                                    double height)
Helps determine the size of this component. Call this method for each component position (cpoint) with the width and height of each chid and the current dimension required to render the domain. Before presenting the first component the dimension can be (0,0) thus allowing to determine the preferred size of the domain when rendering the components with their positions and size.


organize

public void organize()
Organizes the appearance of the diagram. Determines the size of the diagram and packs the elements. Moves the first SSR were its position allow to see all the other SSRs in the visible x>0, y>0 region of the plane. Finally, intializes the residueNumberingDrawing instance.


getGlyphLinks

public GlyphLink[] getGlyphLinks()
Obtain the location of the residue glyphs on the page. Also return GlyphLink for each ProteinSegmentDomain, child of the DrawingSurface, which has an associated URL.

Throws:
java.lang.InternalError - Thrown when the diagram was not provided with a ResidueModelFactory.

getResidueGlyph

public ResidueGlyph getResidueGlyph(int position)
Returns the ResidueGlyph corresponding to this position in this sequence.

Returns:
The residue glyph or null if none is found.

repaint

public void repaint()
Repaint the diagram.


getRenderingEngine

public Domain2D getRenderingEngine(int i)
                            throws Domain2D_Annotation.BadDomain2DRenderingClass
Returns the rendering engine for the ith SSR. The engine is obtained from the model rendering info's getRenderingEngine(..) full parameter version.

Domain2D_Annotation.BadDomain2DRenderingClass

setVisible

public void setVisible(boolean show)
Show or hide the diagram. When the diagram has been installed in a JFrame, it can be made visible or hidden with this metod.

See Also:
java.awt.JFrame#setVisible

getGlyphFactory

public ResidueGlyphFactory getGlyphFactory()

main

public static void main(java.lang.String[] args)
Tests various features of the Diagram class.



Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.