|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.bio.gui.sequence.HeadlessRenderContext
public class HeadlessRenderContext
A stand-alone SequenceRenderContext to make it easy to render to an image.
This class makes it very easy to render sequence information into an arbitrary graphics object without the need to fuss about with AWT or Swing components. You chose the width of the image and the region of the sequence to render. It will calculate the scale factor to ensure that the whole region of the sequence fits into that width. You can then use the context to render any number of SequenceRenderer instances to any Graphics2D instance you want, for example, to an image that's to be written out by a servlet.
HeadlessRenderContext ctxt = new HeadlessRenderContext( seq, // the sequence to render range, // a RangeLocation giving the block you want to render width // an int specifying the image width in pixles ); BufferedImage img = new BufferedImage( width, // image width (int) Math.ceil(seqRend.getDepth(ctxt), // calculated height BufferedImage.TYPE_INT_RGB // let's use RGB ); // set stuff up Graphics2D graph = img.createGraphics(); graph.setPaint(Color.WHITE); graph.fillRect(0, 0, img.getWidth(), img.getHeight()); // and now render the sequences sequenceRenderer.paint(graph, ctxt); // let's dump this out as a png ImageIO.write(image, "png", myFile);
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.biojava.bio.gui.sequence.SequenceRenderContext |
---|
SequenceRenderContext.Border |
Field Summary |
---|
Fields inherited from interface org.biojava.bio.gui.sequence.SequenceRenderContext |
---|
LAYOUT, REPAINT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Constructor Summary | |
---|---|
HeadlessRenderContext(Sequence seq,
RangeLocation range,
int width)
|
Method Summary | |
---|---|
int |
getDirection()
Gets the direction in which this context expects sequences to be rendered - HORIZONTAL or VERTICAL. |
FeatureHolder |
getFeatures()
The features to render. |
Font |
getFont()
Gets the Font attribute of the SequenceRenderContext object |
SequenceRenderContext.Border |
getLeadingBorder()
Gets the LeadingBorder attribute of the SequenceRenderContext object. |
RangeLocation |
getRange()
The range of the SymbolList to render. |
double |
getScale()
Gets the scale as pixels per Symbol |
SymbolList |
getSymbols()
The SymbolList that is currently rendered by this SequenceRenderContext. |
SequenceRenderContext.Border |
getTrailingBorder()
Gets the TrailingBorder attribute of the SequenceRenderContext object. |
int |
graphicsToSequence(double d)
Converts a graphical position into a sequence coordinate. |
int |
graphicsToSequence(Point2D point)
Converts a graphical position into a sequence coordinate. |
double |
sequenceToGraphics(int i)
Converts a sequence index into a graphical coordinate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HeadlessRenderContext(Sequence seq, RangeLocation range, int width)
Method Detail |
---|
public int getDirection()
SequenceRenderContext
getDirection
in interface SequenceRenderContext
public FeatureHolder getFeatures()
SequenceRenderContext
getFeatures
in interface SequenceRenderContext
public Font getFont()
SequenceRenderContext
getFont
in interface SequenceRenderContext
public SequenceRenderContext.Border getLeadingBorder()
SequenceRenderContext
getLeadingBorder
in interface SequenceRenderContext
public RangeLocation getRange()
SequenceRenderContext
getRange
in interface SequenceRenderContext
public double getScale()
SequenceRenderContext
getScale
in interface SequenceRenderContext
public SymbolList getSymbols()
SequenceRenderContext
getSymbols
in interface SequenceRenderContext
public SequenceRenderContext.Border getTrailingBorder()
SequenceRenderContext
getTrailingBorder
in interface SequenceRenderContext
public double sequenceToGraphics(int i)
SequenceRenderContext
sequenceToGraphics
in interface SequenceRenderContext
i
- Index within the sequence
public int graphicsToSequence(Point2D point)
SequenceRenderContext
graphicsToSequence
in interface SequenceRenderContext
point
- a point representing the position
public int graphicsToSequence(double d)
SequenceRenderContext
graphicsToSequence
in interface SequenceRenderContext
d
- A pixel position
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |