[Biojava-l] DistributionLogo help
xjw2101 at columbia.edu
xjw2101 at columbia.edu
Tue Jun 29 10:49:07 EDT 2004
Thomas,
Seems the version is different from mine. In my version
DistributionLogo is extension of Component and there are no
setRenderingHints(hints) or setPreferedSize() methods.
Xuegong
--- Thomas Down <td2 at sanger.ac.uk> wrote:
>
> On 28 Jun 2004, at 21:44, xjw2101 at columbia.edu
> wrote:
>
> >
> >
> > I am trying to use DistributionLogo class to
> represent a PSSM for a
> > transcription factor. I can generate
> DistributionLogos for each
> > position but can't merge them together to form a
> nice looking
> > single logo to be displayed on a panel.
> Basically,I don't know how
> > to control the color or the size. can someone show
> me how this
> > class works or give me some sample code of how
> this class works?
>
> Hi Xuegong,
>
> I generally use the following code, which creates a
> row of
> DistributionLogo objects, for displaying a BioJava
> WeightMatrix (i.e.
> PSSM) objects. Can this be adapted to do what you
> want?
>
> Thomas.
>
>
>
> import java.awt.*;
>
> import javax.swing.*;
>
> import org.biojava.bio.*;
> import org.biojava.bio.dist.Distribution;
> import org.biojava.bio.dp.WeightMatrix;
> import org.biojava.bio.gui.*;
>
> public class WMPanel extends JPanel {
> private WeightMatrix wm;
> private DistributionLogo[] logos;
>
> public WMPanel(WeightMatrix wm) {
> super();
> this.wm = wm;
> setBackground(Color.white);
>
> RenderingHints hints = new
> RenderingHints(RenderingHints.KEY_ANTIALIASING,
> RenderingHints.VALUE_ANTIALIAS_ON);
>
> try {
> setLayout(new GridLayout(1,
> wm.columns()));
> logos = new
> DistributionLogo[wm.columns()];
> for (int pos = 0; pos < wm.columns();
> ++pos) {
> Distribution dist =
> wm.getColumn(pos);
> DistributionLogo dl = new
> DistributionLogo();
> dl.setRenderingHints(hints);
> dl.setBackground(Color.white);
> dl.setOpaque(true);
> dl.setDistribution(dist);
> dl.setPreferredSize(new
> Dimension(40, 50));
> dl.setLogoPainter(new
> TextLogoPainter());
> dl.setStyle(new DNAStyle());
> add(dl);
> logos[pos] = dl;
> }
> } catch (BioException ex) {
> throw new BioError(ex);
> }
> }
>
> public static void wmViewer(WeightMatrix wm,
> String message)
> {
> WMPanel wmv = new WMPanel(wm);
> JFrame frame = new JFrame("Weight matrix
> viewer" + ((message ==
> null) ? "" : (" (" + message + ")")));
> frame.getContentPane().add(wmv);
> frame.pack();
> frame.setVisible(true);
> }
> }
>
>
More information about the Biojava-l
mailing list