Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

In this page you can find the example usage for java.awt Cursor getPredefinedCursor.

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

From source file:base.BasePlayer.ClusterTable.java

void drawScreen(Graphics g) {
    try {/*from  w ww. j  a v  a  2  s  . c  o m*/

        buf.setColor(Color.black);
        buf.fillRect(0, 0, this.getWidth(), tablescroll.getViewport().getHeight());
        genemutcount = 0;
        hoverVar = null;
        hoverSample = -1;
        headerHover = -1;
        geneHeaderHover = -1;

        if (!mouseDrag) {
            resizeColumn = -1;
        }
        if (Main.drawCanvas.clusterNodes != null) {
            firstrow = tablescroll.getVerticalScrollBar().getValue() / rowHeight - 1
                    - Main.drawCanvas.clusterNodes.size();

            if (firstrow < 0) {
                firstrow = 0;
            }
            for (int i = 0; i < Main.drawCanvas.clusterNodes.size(); i++) {
                dot = false;

                if ((i + 1 + samplecount + Main.drawCanvas.clusterNodes.size()) * rowHeight < tablescroll
                        .getVerticalScrollBar().getValue()) {
                    continue;
                }

                if (i * rowHeight > tablescroll.getVerticalScrollBar().getValue()
                        + tablescroll.getViewport().getHeight()) {
                    break;
                }

                if (mouseY >= (rowHeight * (i + genemutcount + 1))
                        && mouseY < (rowHeight * (i + genemutcount + 2))) {
                    hoverNode = Main.drawCanvas.clusterNodes.get(i);
                }
                try {
                    buf.setColor(Color.darkGray);
                    buf.drawLine(4,
                            (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue()
                                    + 3,
                            this.getWidth(), (rowHeight * (i + genemutcount + 1))
                                    - tablescroll.getVerticalScrollBar().getValue() + 3);

                    buf.setColor(linecolor);
                    cluster = Main.drawCanvas.clusterNodes.get(i);
                    if (cluster.varnodes.get(0).getTranscripts() != null) {
                        if (!chrom.equals(cluster.varnodes.get(0).getTranscripts().get(0).getChrom())) {
                            chrom = cluster.varnodes.get(0).getTranscripts().get(0).getChrom();
                        }
                    } else {
                        if (!chrom.equals(cluster.varnodes.get(0).getExons().get(0).transcript.getChrom())) {
                            chrom = cluster.varnodes.get(0).getExons().get(0).transcript.getChrom();
                        }
                    }

                    for (int c = 0; c < header.size(); c++) {

                        if (Main.drawCanvas.clusterNodes.get(i).equals(hoverNode)
                                || Main.drawCanvas.clusterNodes.get(i).equals(selectedNode)) {

                            buf.setColor(Color.yellow);
                        } else {
                            buf.setColor(Color.white);
                        }

                        if (c == 0) {

                            buf.drawString("" + cluster.ID, (int) header.get(c)[1] + 5,
                                    (rowHeight * (i + 1 + genemutcount))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                        } else if (c == 1) {
                            buf.drawString("" + cluster.nodecount, (int) header.get(c)[1] + 5,
                                    (rowHeight * (i + 1 + genemutcount))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                        } else if (c == 2) {
                            buf.drawString("" + cluster.width, (int) header.get(c)[1] + 5,
                                    (rowHeight * (i + 1 + genemutcount))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                        } else if (c == 3) {
                            buf.drawString(
                                    chrom + ":"
                                            + MethodLibrary.formatNumber(cluster.varnodes.get(0).getPosition()),
                                    (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                        } else if (c == 4) {
                            buf.drawString(
                                    "" + MethodLibrary.round((cluster.nodecount / (double) cluster.width), 4),
                                    (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                        } else if (c == 5) {
                            if (cluster.varnodes.get(0).getExons() != null) {

                                if (cluster.varnodes.get(0).coding) {
                                    buf.setColor(Color.red);
                                    buf.drawString(
                                            cluster.varnodes.get(0).getExons().get(0).getTranscript()
                                                    .getGenename() + " (Coding)",
                                            (int) header.get(c)[1] + 5,
                                            (rowHeight * (i + 1 + genemutcount))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);

                                } else {
                                    buf.setColor(Color.lightGray);
                                    buf.drawString(
                                            cluster.varnodes.get(0).getExons().get(0).getTranscript()
                                                    .getGenename() + " (UTR)",
                                            (int) header.get(c)[1] + 5,
                                            (rowHeight * (i + 1 + genemutcount))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);

                                }
                            } else if (cluster.varnodes.get(0).isInGene()) {
                                buf.setColor(Color.lightGray);
                                buf.drawString(
                                        cluster.varnodes.get(0).getTranscripts().get(0).getGenename()
                                                + " (Intronic)",
                                        (int) header.get(c)[1] + 5, (rowHeight * (i + 1 + genemutcount))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            } else {
                                buf.setColor(Color.gray);
                                if (!cluster.varnodes.get(0).getTranscripts().get(0)
                                        .equals(cluster.varnodes.get(0).getTranscripts().get(1))) {
                                    buf.drawString(
                                            cluster.varnodes.get(0).getTranscripts().get(0).getGenename()
                                                    + " ... "
                                                    + cluster.varnodes
                                                            .get(0).getTranscripts().get(1).getGenename(),
                                            (int) header.get(c)[1] + 5,
                                            (rowHeight * (i + 1 + genemutcount))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);

                                } else {
                                    if (cluster.varnodes.get(0).getTranscripts().get(0)
                                            .getEnd() > cluster.varnodes.get(0).getPosition()) {
                                        buf.drawString(
                                                " ... " + cluster.varnodes
                                                        .get(0).getTranscripts().get(0).getGenename(),
                                                (int) header.get(c)[1] + 5,
                                                (rowHeight * (i + 1 + genemutcount))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                    } else {
                                        buf.drawString(
                                                cluster.varnodes.get(0).getTranscripts().get(0).getGenename()
                                                        + " ... ",
                                                (int) header.get(c)[1] + 5,
                                                (rowHeight * (i + 1 + genemutcount))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);

                                    }
                                }
                            }
                        } else if (c == 6) {

                            if (cluster.varnodes.get(0).getBedHits() != null) {
                                bedarray = MethodLibrary.makeTrackArray(cluster.varnodes.get(0), null);
                                for (int b = 0; b < bedarray.length; b++) {
                                    buf.setColor(Color.black);
                                    if (b == bedarray.length - 1) {
                                        buf.fillRect((int) header.get(c + b)[1] + 1,
                                                (rowHeight * (i + genemutcount + 1))
                                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                this.getWidth() - (int) header.get(c + b)[1], rowHeight - 1);
                                    } else {
                                        buf.fillRect((int) header.get(c + b)[1] + 1,
                                                (rowHeight * (i + genemutcount + 1))
                                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                (int) header.get(c + b)[2], rowHeight - 1);

                                    }
                                    buf.setColor(Color.white);
                                    if (bedarray[b] != null) {
                                        buf.drawString(bedarray[b].toString(), (int) header.get(c + b)[1] + 5,
                                                (rowHeight * (i + 1 + genemutcount))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);

                                    }
                                }
                            }
                        }
                        if (c < header.size() - 1 - Main.bedCanvas.bedTrack.size()) {
                            buf.setColor(Color.black);
                            buf.fillRect((int) header.get(c + 1)[1] + 1,
                                    (rowHeight * (i + genemutcount + 1))
                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                    (int) header.get(c + 1)[2], rowHeight - 1);

                        }
                    }
                    buf.setColor(Color.darkGray);
                    buf.drawLine(3, rowHeight + 3, 3, (rowHeight * (i + genemutcount + 2))
                            - tablescroll.getVerticalScrollBar().getValue() + 3);

                    for (int r = 0; r < header.size(); r++) {
                        buf.drawLine((int) header.get(r)[1],
                                (rowHeight * (i + genemutcount + 1))
                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                (int) header.get(r)[1], (rowHeight * (i + genemutcount + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 3);
                    }
                    if (selectedNode != null && selectedNode.equals(cluster)) {

                        hoverSample = -1;
                        genemutcount = aminoarray.size() + 1;
                        listAdd = 1;
                        buf.drawLine(20,
                                (rowHeight * (i + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue()
                                        + 3,
                                this.getWidth(), (rowHeight * (i + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 3);
                        drawGeneheader((rowHeight * (i + listAdd + 1))
                                - tablescroll.getVerticalScrollBar().getValue() + 3);

                        for (int s = 0; s < aminoarray.size(); s++) {

                            buf.setColor(Color.darkGray);
                            buf.drawLine(21,
                                    (rowHeight * (i + s + listAdd + 3))
                                            - tablescroll.getVerticalScrollBar().getValue() + 3,
                                    this.getWidth(), (rowHeight * (i + s + listAdd + 3))
                                            - tablescroll.getVerticalScrollBar().getValue() + 3);

                            if (mouseY >= (rowHeight * (i + s + listAdd + 2))
                                    && mouseY < (rowHeight * (i + s + listAdd + 3))) {
                                hoverNode = null;
                                hoverVar = aminoarray.get(s).getNode();
                                hoverString = aminoarray.get(s).getRow();
                                buf.setColor(Color.white);

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                .getSample().getIndex();
                                        break;
                                    }
                                }
                            } else {
                                if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("nonsense")) {
                                    buf.setColor(Color.red);
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("missense")) {
                                    buf.setColor(Color.yellow);
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("synonymous")) {
                                    buf.setColor(Color.green);
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("UTR")) {
                                    buf.setColor(Color.lightGray);
                                } else {
                                    buf.setColor(Color.gray);
                                }
                            }
                            if (!aminoarray.get(s).getRow()[1].equals("1")) {

                                buf.drawString("Multiple", 24, (rowHeight * (i + s + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                            } else {
                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {

                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {

                                        buf.drawString(
                                                aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                        .getSample().getName(),
                                                24,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                        break;
                                    }
                                }

                            }

                            if (hoverVar != null && hoverString.equals(aminoarray.get(s).getRow())) {
                                //TODO
                                textcolor = Color.white;

                            } else {
                                if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("nonsense")) {
                                    textcolor = Color.red;
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("missense")) {
                                    textcolor = Color.yellow;
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("synonymous")) {
                                    textcolor = Color.green;
                                } else if (aminoarray.get(s).getRow()[3].contains("UTR")) {
                                    textcolor = Color.lightGray;
                                } else {
                                    textcolor = Color.gray;
                                }
                            }
                            for (int h = 1; h < 4; h++) {
                                buf.setColor(Color.black);
                                buf.fillRect((int) geneheader.get(h)[1] + 10,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + 4,
                                        (int) geneheader.get(h)[2], rowHeight - 1);
                                buf.setColor(textcolor);
                                buf.drawString(aminoarray.get(s).getRow()[h], (int) geneheader.get(h)[1] + 14,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            }

                            if (aminoarray.get(s).getRow()[1].equals("1")) {
                                buf.setColor(Color.black);
                                buf.fillRect((int) geneheader.get(4)[1] + 10,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + 4,
                                        this.getWidth(), rowHeight - 1);
                                buf.setColor(textcolor);

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                .isHomozygous()) {
                                            buf.drawString(
                                                    "Hom (" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                            .get(0).getCalls() + "/"
                                                            + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                                    .get(0).getCoverage()
                                                            + ")",
                                                    (int) geneheader.get(4)[1] + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            if (Control.controlData.controlsOn) {
                                                cases = 2;
                                                casefreq = 2 / (double) (Main.varsamples * 2);
                                            }
                                        } else {
                                            buf.drawString(
                                                    "Het (" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                            .get(0).getCalls() + "/"
                                                            + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                                    .get(0).getCoverage()
                                                            + ")",
                                                    (int) geneheader.get(4)[1] + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            if (Control.controlData.controlsOn) {
                                                cases = 1;
                                                casefreq = 1 / (double) (Main.varsamples * 2);
                                            }

                                        }
                                        buf.setColor(Color.black);
                                        buf.fillRect((int) geneheader.get(5)[1] + 1,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                this.getWidth(), rowHeight - 1);
                                        buf.setColor(textcolor);
                                        buf.drawString(
                                                "" + aminoarray.get(s).getNode().vars
                                                        .get(v).getValue().get(0).getQuality(),
                                                (int) geneheader.get(5)[1] + 14,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);

                                    }
                                }
                            }

                            if (Control.controlData.controlsOn) {
                                cases = 0;
                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                .isHomozygous()) {
                                            cases += Integer.parseInt(aminoarray.get(s).getRow()[1]) * 2;
                                        } else {
                                            cases += Integer.parseInt(aminoarray.get(s).getRow()[1]);
                                        }
                                    }
                                }
                                casefreq = cases / (double) (Main.varsamples * 2);
                            }

                            buf.setColor(textcolor);
                            buf.drawString(aminoarray.get(s).getRow()[4], (int) geneheader.get(6)[1] + 14,
                                    (rowHeight * (i + s + listAdd + 2))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            if (Control.controlData.controlsOn) {
                                buf.setColor(textcolor);

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        vararray = aminoarray.get(s).getNode().vars.get(v).getValue();
                                        controlarray = new SampleNode[Control.controlData.fileArray.size()];
                                        if (vararray.get(vararray.size() - 1).alleles != null) {

                                            for (int e = vararray.size() - 1; e > 0; e--) {

                                                if (vararray.get(e).alleles == null) {
                                                    break;
                                                }
                                                controlarray[vararray.get(e).getControlSample()
                                                        .getIndex()] = vararray.get(e);

                                            }
                                        }
                                        for (int e = 0; e < controlarray.length; e++) {
                                            if (Control.controlData.fileArray.get(e).controlOn) {
                                                if (controlarray[e] == null) {
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString("0",
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString("-",
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);

                                                } else {
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString(
                                                            "" + MethodLibrary.round(controlarray[e].alleles
                                                                    / (double) controlarray[e].allelenumber, 2),
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString("" + MethodLibrary
                                                            .round(casefreq / (controlarray[e].alleles
                                                                    / (double) controlarray[e].allelenumber), 2)
                                                            + " (p="
                                                            + MethodLibrary.round(
                                                                    VariantHandler.table.fe.getRightTailedP(
                                                                            cases, Main.varsamples * 2 - cases,
                                                                            controlarray[e].alleles,
                                                                            controlarray[e].allelenumber
                                                                                    - controlarray[e].alleles),
                                                                    2)
                                                            + ")",
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);
                                                }
                                            } else {
                                                buf.setColor(Color.black);
                                                buf.fillRect(
                                                        (int) geneheader.get(this.geneheaderlength + e * 2)[1]
                                                                + 11,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        this.getWidth(), rowHeight - 1);
                                                buf.setColor(Color.darkGray);
                                                buf.drawString("Apply controls",
                                                        (int) geneheader.get(this.geneheaderlength + e * 2)[1]
                                                                + 14,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);
                                                buf.setColor(Color.black);
                                                buf.fillRect(
                                                        (int) geneheader
                                                                .get(this.geneheaderlength + e * 2 + 1)[1] + 11,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        this.getWidth(), rowHeight - 1);
                                                buf.setColor(Color.darkGray);
                                                buf.drawString("-",
                                                        (int) geneheader
                                                                .get(this.geneheaderlength + e * 2 + 1)[1] + 14,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);

                                            }
                                        }
                                    }
                                }
                            } else {
                                buf.setColor(Color.darkGray);

                                for (int e = geneheaderlength; e < geneheader.size(); e++) {
                                    if (geneheader.get(e)[0] instanceof ControlFile) {
                                        buf.drawString("Apply controls", (int) geneheader.get(e)[1] + 14,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                    }
                                }
                                buf.setColor(Color.lightGray);
                            }
                            vararray = null;
                            if (Main.bedCanvas.bedOn) {
                                for (int a = 0; a < aminoarray.size(); a++) {
                                    bedarray = MethodLibrary.makeTrackArray(aminoarray.get(a).getNode(),
                                            aminoarray.get(a).getRow()[5]);
                                    if (bedarray != null) {
                                        for (int b = 0; b < bedarray.length; b++) {
                                            buf.setColor(Color.black);
                                            if (b == bedarray.length - 1) {
                                                buf.fillRect(
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + b)[1] + 12,
                                                        (rowHeight * (i + a + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        this.getWidth() - (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + b)[1],
                                                        rowHeight - 1);
                                            } else {
                                                buf.fillRect(
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + b)[1] + 12,
                                                        (rowHeight * (i + a + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + b)[2],
                                                        rowHeight - 1);
                                            }
                                            buf.setColor(Color.white);
                                            if (bedarray[b] != null) {
                                                buf.drawString(bedarray[b].toString(),
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + b)[1] + 14,
                                                        (rowHeight * (i + a + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);

                                            }
                                        }
                                    }
                                }
                            }
                            buf.setColor(Color.darkGray);
                            for (int j = 0; j < geneheader.size(); j++) {

                                buf.drawLine((int) geneheader.get(j)[1] + 11,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + 4,
                                        (int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + listAdd + 3))
                                                - tablescroll.getVerticalScrollBar().getValue() + 3);
                            }
                            if (selectedVar != null && selectedString.equals(aminoarray.get(s).getRow())
                                    && Integer.parseInt(selectedString[1]) > 1) {
                                //hoverSample = -1;
                                pointer = 0;
                                //TODO

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(selectedString[5])) {

                                        for (int l = 0; l < aminoarray.get(s).getNode().vars.get(v).getValue()
                                                .size(); l++) {
                                            if (aminoarray.get(s).getNode().vars.get(v).getValue()
                                                    .get(l).alleles != null) {
                                                break;
                                            }
                                            if (mouseY > (rowHeight * (i + s + pointer + 4))
                                                    && mouseY < (rowHeight * (i + s + pointer + 5))) {
                                                textcolor = Color.white;

                                                hoverVar = aminoarray.get(s).getNode();
                                                hoverString = aminoarray.get(s).getRow();
                                                hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue()
                                                        .get(l).getSample().getIndex();
                                            } else {
                                                textcolor = Color.lightGray;
                                            }

                                            //   if(aminoarray.get(s).getNode().getSamples().get(l).getVariation().equals(selectedString[5])) {                           
                                            buf.setColor(textcolor);
                                            buf.drawString(
                                                    aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                                            .getSample().getName(),
                                                    30,
                                                    (rowHeight * (i + s + pointer + 4))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            pointer++;
                                            //   }   

                                            buf.setColor(Color.black);
                                            buf.fillRect((int) geneheader.get(4)[1] + 10,
                                                    (rowHeight * (i + s + pointer + 3))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);
                                            if (aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                                    .isHomozygous()) {
                                                buf.drawString(
                                                        "Hom (" + aminoarray.get(s).getNode().vars.get(v)
                                                                .getValue().get(l).getCalls() + "/"
                                                                + aminoarray.get(s).getNode().vars.get(v)
                                                                        .getValue().get(l).getCoverage()
                                                                + ")",
                                                        (int) geneheader.get(4)[1] + 14,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);

                                            } else {
                                                buf.drawString(
                                                        "Het (" + aminoarray.get(s).getNode().vars.get(v)
                                                                .getValue().get(l).getCalls() + "/"
                                                                + aminoarray.get(s).getNode().vars.get(v)
                                                                        .getValue().get(l).getCoverage()
                                                                + ")",
                                                        (int) geneheader.get(4)[1] + 14,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);
                                            }

                                            buf.setColor(Color.black);
                                            buf.fillRect((int) geneheader.get(5)[1] + 10,
                                                    (rowHeight * (i + s + pointer + 3))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);
                                            buf.drawString(
                                                    "" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                            .get(l).getQuality(),
                                                    (int) geneheader.get(5)[1] + 14,
                                                    (rowHeight * (i + s + pointer + 3))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            buf.setColor(Color.darkGray);
                                            for (int j = 4; j < 7; j++) {

                                                buf.drawLine((int) geneheader.get(j)[1] + 11,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue(),
                                                        (int) geneheader.get(j)[1] + 11,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight + 2);
                                            }

                                        }
                                    }
                                }
                                listAdd = Integer.parseInt(selectedString[1]) + 1;
                                genemutcount = aminoarray.size() + listAdd;
                                buf.setColor(Color.darkGray);
                                buf.drawLine(21,
                                        (rowHeight * (i + s + listAdd + 3))
                                                - tablescroll.getVerticalScrollBar().getValue() + 3,
                                        this.getWidth(), (rowHeight * (i + s + listAdd + 3))
                                                - tablescroll.getVerticalScrollBar().getValue() + 3);

                            }

                        }
                    }

                } catch (Exception e) {
                    ErrorLog.addError(e.getStackTrace());
                    e.printStackTrace();
                }

            }
            buf.setColor(Color.darkGray);
            buf.drawLine(4,
                    (rowHeight * (Main.drawCanvas.clusterNodes.size() + genemutcount + 1))
                            - tablescroll.getVerticalScrollBar().getValue() + 3,
                    this.getWidth(), (rowHeight * (Main.drawCanvas.clusterNodes.size() + genemutcount + 1))
                            - tablescroll.getVerticalScrollBar().getValue() + 3);

        }
        drawHeader();

        if (headerHover == -1 && geneHeaderHover == -1) {

            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        } else {
            if (resizeColumn == -1) {
                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            } else {
                setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
            }
        }

        g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:base.BasePlayer.BedTable.java

void drawScreen(Graphics g) {
    try {/*from w w  w. j av  a  2s  . c  o m*/
        buf.setColor(Color.black);

        buf.fillRect(0, 0, this.getWidth(), this.getHeight());
        if (width != this.getWidth()) {
            width = this.getWidth();
            createPolygon();
            resizeTable();
        }

        genemutcount = 0;
        if (!bedtrack.intersect) {
            buf.setColor(Color.white);
            buf.drawString("Press play on bed track to annotate variants", 5, 40);
        } else if (getTableSize() > 0) {

            hoverVar = null;
            hoverSample = -1;
            headerHover = -1;
            geneHeaderHover = -1;
            if (!mouseDrag) {
                resizeColumn = -1;
            }

            if (aminoarray == null) {
                aminoarray = new ArrayList<AminoEntry>();
            }

            firstrow = tablescroll.getVerticalScrollBar().getValue() / rowHeight - samplecount - listAdd
                    - aminoarray.size();

            if (firstrow < 0) {
                firstrow = 0;
            }
            for (int i = firstrow; i < bedarray.size(); i++) {
                dot = false;

                if ((i + 1 + samplecount + listAdd + aminoarray.size()) * rowHeight < tablescroll
                        .getVerticalScrollBar().getValue()) {

                    continue;
                }

                if (i * rowHeight > tablescroll.getVerticalScrollBar().getValue()
                        + tablescroll.getViewport().getHeight()) {

                    break;
                }

                if (mouseY >= (rowHeight * (i + genemutcount + 1))
                        && mouseY < (rowHeight * (i + genemutcount + 2))) {
                    hoverNode = bedarray.get(i);
                }

                try {
                    buf.setColor(Color.darkGray);
                    buf.drawLine(4,
                            (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue()
                                    + 3,
                            this.getWidth(), (rowHeight * (i + genemutcount + 1))
                                    - tablescroll.getVerticalScrollBar().getValue() + 3);

                    if (bedarray.get(i).equals(hoverNode) || bedarray.get(i).equals(selectedNode)) {
                        buf.setColor(Color.yellow);
                    } else {
                        buf.setColor(Color.white);
                    }

                    if (bedarray.get(i).getTrack().hasvalues) {
                        buf.drawString(
                                (i + 1) + ".  " + MethodLibrary.shortString(bedarray.get(i).name, 10) + "="
                                        + MethodLibrary.round(bedarray.get(i).value, 3),
                                5, (rowHeight * (i + 1 + genemutcount))
                                        - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                    } else {
                        buf.drawString((i + 1) + ".  " + MethodLibrary.shortString(bedarray.get(i).name, 10), 5,
                                (rowHeight * (i + 1 + genemutcount))
                                        - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                    }
                    buf.setColor(Color.black);
                    buf.fillRect(
                            headerlengths[1][0] + 1, (rowHeight * (i + genemutcount + 1))
                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                            headerlengths[1][1], rowHeight - 1);

                    if (bedarray.get(i).equals(hoverNode) || bedarray.get(i).equals(selectedNode)) {
                        buf.setColor(Color.yellow);
                    } else {
                        buf.setColor(Color.white);
                    }
                    mutcountbuffer = new StringBuffer("" + bedarray.get(i).mutations + " ");
                    buf.drawString(mutcountbuffer.toString(), headerlengths[1][0] + 5,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);
                    //      lastpos = Integer.toString(bedarray.get(i).mutations).length() +2;
                    //TODO      textWidth = (int)fm.getStringBounds("", buf).getWidth();

                    //   textWidth = (int)fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                    //   buf.drawString("  ", headerlengths[1][0]+5+textWidth, (rowHeight*(i+1+genemutcount))-tablescroll.getVerticalScrollBar().getValue()+rowHeight);      

                    //   buf.setColor(Color.gray);
                    //   textWidth = (int)fm.getStringBounds(mutcountbuffer.toString() , buf).getWidth();
                    //   buf.drawString(" " +bedarray.get(i).varnodes.size() +" samples",  headerlengths[1][0]+5+textWidth, (rowHeight*(i+1+genemutcount))-tablescroll.getVerticalScrollBar().getValue()+rowHeight);      

                    buf.setColor(Color.black);
                    buf.fillRect(
                            headerlengths[2][0] + 1, (rowHeight * (i + genemutcount + 1))
                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                            this.getWidth(), rowHeight - 1);

                    if (bedarray.get(i).equals(hoverNode) || bedarray.get(i).equals(selectedNode)) {
                        buf.setColor(Color.yellow);
                    } else {
                        buf.setColor(Color.white);
                    }

                    buf.drawString(
                            bedarray.get(i).getChrom() + ":"
                                    + MethodLibrary.formatNumber(bedarray.get(i).getPosition() + 1) + "-"
                                    + MethodLibrary.formatNumber(
                                            bedarray.get(i).getPosition() + 1 + bedarray.get(i).getLength()),
                            headerlengths[2][0] + 5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                    buf.setColor(Color.black);
                    buf.fillRect(
                            headerlengths[3][0] + 1, (rowHeight * (i + genemutcount + 1))
                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                            this.getWidth(), rowHeight - 1);

                    if (bedarray.get(i).equals(hoverNode) || bedarray.get(i).equals(selectedNode)) {

                        buf.setColor(Color.yellow);
                    } else {
                        buf.setColor(Color.white);
                    }

                    buf.drawString(MethodLibrary.formatNumber(bedarray.get(i).getLength()),
                            headerlengths[3][0] + 5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                    buf.setColor(Color.black);
                    buf.fillRect(
                            headerlengths[4][0] + 1, (rowHeight * (i + genemutcount + 1))
                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                            this.getWidth(), rowHeight - 1);

                    if (bedarray.get(i).equals(hoverNode) || bedarray.get(i).equals(selectedNode)) {

                        buf.setColor(Color.yellow);
                    } else {
                        buf.setColor(Color.white);
                    }

                    buf.drawString("" + MethodLibrary
                            .round((bedarray.get(i).mutations / (double) bedarray.get(i).getLength()) * 100, 4),
                            headerlengths[4][0] + 5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                    buf.setColor(Color.black);
                    buf.fillRect(
                            headerlengths[5][0] + 1, (rowHeight * (i + genemutcount + 1))
                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                            this.getWidth(), rowHeight - 1);

                    if (bedarray.get(i).equals(hoverNode) || bedarray.get(i).equals(selectedNode)) {

                        buf.setColor(Color.yellow);
                    } else {
                        buf.setColor(Color.white);
                    }
                    firstvisible = 0;
                    if (bedarray.get(i).varnodes != null) {

                        for (int f = 0; f < bedarray.get(i).varnodes.size(); f++) {
                            if (!Main.drawCanvas.hideNode(bedarray.get(i).varnodes.get(f))) {
                                firstvisible = f;
                                break;
                            }
                        }
                        if (bedarray.get(i).varnodes.get(firstvisible).getExons() != null) {

                            if (bedarray.get(i).varnodes.get(firstvisible).coding) {
                                buf.setColor(Color.red);
                                buf.drawString(
                                        bedarray.get(i).varnodes.get(firstvisible).getExons().get(0)
                                                .getTranscript().getGenename() + " (Coding)",
                                        headerlengths[5][0] + 5, (rowHeight * (i + 1 + genemutcount))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            } else {
                                buf.setColor(Color.lightGray);
                                buf.drawString(
                                        bedarray.get(i).varnodes.get(firstvisible).getExons().get(0)
                                                .getTranscript().getGenename() + " (UTR)",
                                        headerlengths[5][0] + 5, (rowHeight * (i + 1 + genemutcount))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            }
                        } else if (bedarray.get(i).varnodes.get(firstvisible).isInGene()) {

                            buf.setColor(Color.lightGray);
                            buf.drawString(
                                    bedarray.get(i).varnodes.get(firstvisible).getTranscripts().get(0)
                                            .getGenename() + " (Intronic)",
                                    headerlengths[5][0] + 5, (rowHeight * (i + 1 + genemutcount))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                        } else {
                            buf.setColor(Color.gray);

                            if (!bedarray.get(i).varnodes.get(firstvisible).getTranscripts().get(0).equals(
                                    bedarray.get(i).varnodes.get(firstvisible).getTranscripts().get(1))) {

                                buf.drawString(
                                        bedarray.get(i).varnodes.get(firstvisible).getTranscripts().get(0)
                                                .getGenename()
                                                + " ... "
                                                + bedarray.get(i).varnodes.get(firstvisible).getTranscripts()
                                                        .get(1).getGenename(),
                                        headerlengths[5][0] + 5, (rowHeight * (i + 1 + genemutcount))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            } else {
                                if (bedarray.get(i).varnodes.get(firstvisible).getTranscripts().get(0)
                                        .getEnd() > bedarray.get(i).varnodes.get(firstvisible).getPosition()) {

                                    buf.drawString(
                                            " ... " + bedarray.get(i).varnodes.get(firstvisible)
                                                    .getTranscripts().get(0).getGenename(),
                                            headerlengths[5][0] + 5,
                                            (rowHeight * (i + 1 + genemutcount))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);
                                } else {
                                    buf.drawString(
                                            bedarray.get(i).varnodes.get(firstvisible).getTranscripts().get(0)
                                                    .getGenename() + " ... ",
                                            headerlengths[5][0] + 5,
                                            (rowHeight * (i + 1 + genemutcount))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);

                                }
                            }
                        }
                    }

                    buf.setColor(Color.darkGray);
                    buf.drawLine(3, rowHeight + 3, 3, (rowHeight * (i + genemutcount + 2))
                            - tablescroll.getVerticalScrollBar().getValue() + 3);

                    for (int r = 0; r < headerlengths.length; r++) {
                        buf.drawLine(headerlengths[r][0],
                                (rowHeight * (i + genemutcount + 1))
                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                headerlengths[r][0], (rowHeight * (i + genemutcount + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 3);
                    }

                    if (selectedNode != null && selectedNode.equals(bedarray.get(i))) {

                        hoverSample = -1;
                        genemutcount = aminoarray.size() + 1;
                        listAdd = 1;
                        buf.drawLine(20,
                                (rowHeight * (i + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue()
                                        + 3,
                                this.getWidth(), (rowHeight * (i + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 3);
                        drawGeneheader((rowHeight * (i + listAdd + 1))
                                - tablescroll.getVerticalScrollBar().getValue() + 3);

                        for (int s = 0; s < aminoarray.size(); s++) {

                            buf.setColor(Color.darkGray);
                            buf.drawLine(21,
                                    (rowHeight * (i + s + listAdd + 3))
                                            - tablescroll.getVerticalScrollBar().getValue() + 3,
                                    this.getWidth(), (rowHeight * (i + s + listAdd + 3))
                                            - tablescroll.getVerticalScrollBar().getValue() + 3);

                            if (mouseY >= (rowHeight * (i + s + listAdd + 2))
                                    && mouseY < (rowHeight * (i + s + listAdd + 3))) {
                                hoverNode = null;
                                hoverVar = aminoarray.get(s).getNode();
                                hoverString = aminoarray.get(s).getRow();
                                buf.setColor(Color.white);

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                .getSample().getIndex();
                                        break;
                                    }
                                }

                            } else {
                                if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("nonsense")) {
                                    buf.setColor(Color.red);
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("missense")) {
                                    buf.setColor(Color.yellow);
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("synonymous")) {
                                    buf.setColor(Color.green);
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("UTR")) {
                                    buf.setColor(Color.lightGray);
                                } else {
                                    buf.setColor(Color.gray);
                                }
                            }
                            if (!aminoarray.get(s).getRow()[1].equals("1")) {

                                buf.drawString("Multiple", 24, (rowHeight * (i + s + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                            } else {
                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {

                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {

                                        buf.drawString(
                                                aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                        .getSample().getName(),
                                                24,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                        break;
                                    }
                                }

                            }

                            if (hoverVar != null && hoverString.equals(aminoarray.get(s).getRow())) {
                                //TODO
                                textcolor = Color.white;

                            } else {
                                if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("nonsense")) {
                                    textcolor = Color.red;
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("missense")) {
                                    textcolor = Color.yellow;
                                } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3])
                                        .equals("synonymous")) {
                                    textcolor = Color.green;
                                } else if (aminoarray.get(s).getRow()[3].contains("UTR")) {
                                    textcolor = Color.lightGray;
                                } else {
                                    textcolor = Color.gray;
                                }
                            }
                            for (int h = 1; h < 4; h++) {
                                buf.setColor(Color.black);
                                buf.fillRect((int) geneheader.get(h)[1] + 10,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + 4,
                                        (int) geneheader.get(h)[2], rowHeight - 1);
                                buf.setColor(textcolor);
                                buf.drawString(aminoarray.get(s).getRow()[h], (int) geneheader.get(h)[1] + 14,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            }

                            if (aminoarray.get(s).getRow()[1].equals("1")) {
                                buf.setColor(Color.black);
                                buf.fillRect((int) geneheader.get(4)[1] + 10,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + 4,
                                        this.getWidth(), rowHeight - 1);
                                buf.setColor(textcolor);

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                .isHomozygous()) {
                                            buf.drawString(
                                                    "Hom (" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                            .get(0).getCalls() + "/"
                                                            + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                                    .get(0).getCoverage()
                                                            + ")",
                                                    (int) geneheader.get(4)[1] + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            if (Control.controlData.controlsOn) {
                                                cases = 2;
                                                casefreq = 2 / (double) (Main.varsamples * 2);
                                            }
                                        } else {
                                            buf.drawString(
                                                    "Het (" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                            .get(0).getCalls() + "/"
                                                            + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                                    .get(0).getCoverage()
                                                            + ")",
                                                    (int) geneheader.get(4)[1] + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            if (Control.controlData.controlsOn) {
                                                cases = 1;
                                                casefreq = 1 / (double) (Main.varsamples * 2);
                                            }

                                        }
                                        buf.setColor(Color.black);
                                        buf.fillRect((int) geneheader.get(5)[1] + 1,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                this.getWidth(), rowHeight - 1);
                                        buf.setColor(textcolor);
                                        buf.drawString(
                                                "" + aminoarray.get(s).getNode().vars
                                                        .get(v).getValue().get(0).getQuality(),
                                                (int) geneheader.get(5)[1] + 14,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);

                                    }
                                }
                            }

                            if (Control.controlData.controlsOn) {
                                cases = 0;
                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                .isHomozygous()) {
                                            cases += Integer.parseInt(aminoarray.get(s).getRow()[1]) * 2;
                                        } else {
                                            cases += Integer.parseInt(aminoarray.get(s).getRow()[1]);
                                        }
                                    }
                                }
                                casefreq = cases / (double) (Main.varsamples * 2);
                            }

                            buf.setColor(textcolor);
                            buf.drawString(aminoarray.get(s).getRow()[4], (int) geneheader.get(6)[1] + 14,
                                    (rowHeight * (i + s + listAdd + 2))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            if (Control.controlData.controlsOn) {
                                buf.setColor(textcolor);

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(aminoarray.get(s).getRow()[5])) {
                                        vararray = aminoarray.get(s).getNode().vars.get(v).getValue();
                                        controlarray = new SampleNode[Control.controlData.fileArray.size()];
                                        if (vararray.get(vararray.size() - 1).alleles != null) {

                                            for (int e = vararray.size() - 1; e > 0; e--) {

                                                if (vararray.get(e).alleles == null) {
                                                    break;
                                                }
                                                controlarray[vararray.get(e).getControlSample()
                                                        .getIndex()] = vararray.get(e);

                                            }
                                        }
                                        for (int e = 0; e < controlarray.length; e++) {
                                            if (Control.controlData.fileArray.get(e).controlOn) {
                                                if (controlarray[e] == null) {
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString("0",
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString("-",
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);

                                                } else {
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString(
                                                            "" + MethodLibrary.round(controlarray[e].alleles
                                                                    / (double) controlarray[e].allelenumber, 2),
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2)[1] + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);
                                                    buf.setColor(Color.black);
                                                    buf.fillRect(
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 11,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue() + 4,
                                                            this.getWidth(), rowHeight - 1);
                                                    buf.setColor(textcolor);
                                                    buf.drawString("" + MethodLibrary
                                                            .round(casefreq / (controlarray[e].alleles
                                                                    / (double) controlarray[e].allelenumber), 2)
                                                            + " (p="
                                                            + MethodLibrary.round(
                                                                    VariantHandler.table.fe.getRightTailedP(
                                                                            cases, Main.varsamples * 2 - cases,
                                                                            controlarray[e].alleles,
                                                                            controlarray[e].allelenumber
                                                                                    - controlarray[e].alleles),
                                                                    2)
                                                            + ")",
                                                            (int) geneheader
                                                                    .get(this.geneheaderlength + e * 2 + 1)[1]
                                                                    + 14,
                                                            (rowHeight * (i + s + listAdd + 2)) - tablescroll
                                                                    .getVerticalScrollBar().getValue()
                                                                    + rowHeight);

                                                }
                                            } else {
                                                buf.setColor(Color.black);
                                                buf.fillRect(
                                                        (int) geneheader.get(this.geneheaderlength + e * 2)[1]
                                                                + 11,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        this.getWidth(), rowHeight - 1);
                                                buf.setColor(Color.darkGray);
                                                buf.drawString("Apply controls",
                                                        (int) geneheader.get(this.geneheaderlength + e * 2)[1]
                                                                + 14,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);
                                                buf.setColor(Color.black);
                                                buf.fillRect(
                                                        (int) geneheader
                                                                .get(this.geneheaderlength + e * 2 + 1)[1] + 11,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        this.getWidth(), rowHeight - 1);
                                                buf.setColor(Color.darkGray);
                                                buf.drawString("-",
                                                        (int) geneheader
                                                                .get(this.geneheaderlength + e * 2 + 1)[1] + 14,
                                                        (rowHeight * (i + s + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);

                                            }

                                        }

                                    }
                                }

                            } else {
                                buf.setColor(Color.darkGray);

                                for (int e = geneheaderlength; e < geneheader.size(); e++) {
                                    if (geneheader.get(e)[0] instanceof ControlFile) {
                                        buf.drawString("Apply controls", (int) geneheader.get(e)[1] + 14,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                    }
                                }
                                buf.setColor(Color.lightGray);
                            }
                            vararray = null;
                            if (Main.bedCanvas.bedOn) {

                                for (int a = 0; a < aminoarray.size(); a++) {

                                    StringBuffer[] bedarraytemp = MethodLibrary.makeTrackArray(
                                            aminoarray.get(a).getNode(), aminoarray.get(a).getRow()[5]);
                                    if (bedarraytemp != null) {
                                        int h = 0;
                                        for (int b = 0; b < bedarraytemp.length; b++) {
                                            if (b == bedtrack.trackIndex) {
                                                continue;
                                            }
                                            buf.setColor(Color.black);
                                            if (b == bedarraytemp.length - 1) {
                                                buf.fillRect(
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + h)[1] + 12,
                                                        (rowHeight * (i + a + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        this.getWidth() - (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + h)[1],
                                                        rowHeight - 1);
                                            } else {
                                                buf.fillRect(
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + h)[1] + 12,
                                                        (rowHeight * (i + a + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + 4,
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + h)[2],
                                                        rowHeight - 1);
                                            }
                                            buf.setColor(Color.white);
                                            if (bedarraytemp[b] != null) {
                                                buf.drawString(bedarraytemp[b].toString(),
                                                        (int) geneheader.get(geneheaderlength
                                                                + Control.controlData.fileArray.size() * 2
                                                                + h)[1] + 14,
                                                        (rowHeight * (i + a + listAdd + 2))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);

                                            }
                                            h++;

                                            //   buf.drawLine((int)geneheader.get(geneheaderlength+Control.controlData.fileArray.size()*2+h)[1], (rowHeight*(i+a+listAdd+2))-tablescroll.getVerticalScrollBar().getValue()+4, (int)geneheader.get(geneheaderlength+Control.controlData.fileArray.size()*2+h)[1], (rowHeight*(i+a+listAdd+2))-tablescroll.getVerticalScrollBar().getValue()+10);   

                                        }
                                    }
                                }
                            }

                            buf.setColor(Color.darkGray);
                            for (int j = 0; j < geneheader.size(); j++) {
                                buf.drawLine((int) geneheader.get(j)[1] + 11,
                                        (rowHeight * (i + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + 4,
                                        (int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + listAdd + 3))
                                                - tablescroll.getVerticalScrollBar().getValue() + 3);
                            }
                            if (selectedVar != null && selectedString.equals(aminoarray.get(s).getRow())
                                    && Integer.parseInt(selectedString[1]) > 1) {
                                //hoverSample = -1;
                                pointer = 0;
                                //TODO

                                for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                            .equals(selectedString[5])) {

                                        for (int l = 0; l < aminoarray.get(s).getNode().vars.get(v).getValue()
                                                .size(); l++) {
                                            if (aminoarray.get(s).getNode().vars.get(v).getValue()
                                                    .get(l).alleles != null) {
                                                break;
                                            }
                                            if (mouseY > (rowHeight * (i + s + pointer + 4))
                                                    && mouseY < (rowHeight * (i + s + pointer + 5))) {
                                                textcolor = Color.white;

                                                hoverVar = aminoarray.get(s).getNode();
                                                hoverString = aminoarray.get(s).getRow();
                                                hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue()
                                                        .get(l).getSample().getIndex();
                                            } else {
                                                textcolor = Color.lightGray;
                                            }

                                            //   if(aminoarray.get(s).getNode().getSamples().get(l).getVariation().equals(selectedString[5])) {                           
                                            buf.setColor(textcolor);
                                            buf.drawString(
                                                    aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                                            .getSample().getName(),
                                                    30,
                                                    (rowHeight * (i + s + pointer + 4))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            pointer++;
                                            //   }   

                                            buf.setColor(Color.black);
                                            buf.fillRect((int) geneheader.get(4)[1] + 10,
                                                    (rowHeight * (i + s + pointer + 3))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);
                                            if (aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                                    .isHomozygous()) {
                                                buf.drawString(
                                                        "Hom (" + aminoarray.get(s).getNode().vars.get(v)
                                                                .getValue().get(l).getCalls() + "/"
                                                                + aminoarray.get(s).getNode().vars.get(v)
                                                                        .getValue().get(l).getCoverage()
                                                                + ")",
                                                        (int) geneheader.get(4)[1] + 14,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);

                                            } else {
                                                buf.drawString(
                                                        "Het (" + aminoarray.get(s).getNode().vars.get(v)
                                                                .getValue().get(l).getCalls() + "/"
                                                                + aminoarray.get(s).getNode().vars.get(v)
                                                                        .getValue().get(l).getCoverage()
                                                                + ")",
                                                        (int) geneheader.get(4)[1] + 14,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight);
                                            }

                                            buf.setColor(Color.black);
                                            buf.fillRect((int) geneheader.get(5)[1] + 10,
                                                    (rowHeight * (i + s + pointer + 3))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);
                                            buf.drawString(
                                                    "" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                            .get(l).getQuality(),
                                                    (int) geneheader.get(5)[1] + 14,
                                                    (rowHeight * (i + s + pointer + 3))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            buf.setColor(Color.darkGray);
                                            for (int j = 4; j < 7; j++) {

                                                buf.drawLine((int) geneheader.get(j)[1] + 11,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue(),
                                                        (int) geneheader.get(j)[1] + 11,
                                                        (rowHeight * (i + s + pointer + 3))
                                                                - tablescroll.getVerticalScrollBar().getValue()
                                                                + rowHeight + 2);
                                            }

                                        }
                                    }
                                }
                                listAdd = Integer.parseInt(selectedString[1]) + 1;
                                genemutcount = aminoarray.size() + listAdd;
                                buf.setColor(Color.darkGray);
                                buf.drawLine(21,
                                        (rowHeight * (i + s + listAdd + 3))
                                                - tablescroll.getVerticalScrollBar().getValue() + 3,
                                        this.getWidth(), (rowHeight * (i + s + listAdd + 3))
                                                - tablescroll.getVerticalScrollBar().getValue() + 3);

                            }

                        }
                    }
                } catch (Exception e) {
                    ErrorLog.addError(e.getStackTrace());
                    e.printStackTrace();
                }

            }
            buf.setColor(Color.darkGray);
            buf.drawLine(4,
                    (rowHeight * (bedarray.size() + genemutcount + 1))
                            - tablescroll.getVerticalScrollBar().getValue() + 3,
                    this.getWidth(), (rowHeight * (bedarray.size() + genemutcount + 1))
                            - tablescroll.getVerticalScrollBar().getValue() + 3);

        }
        drawHeader();

        if (headerHover == -1 && geneHeaderHover == -1) {

            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        } else {
            if (resizeColumn == -1) {
                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            } else {
                setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
            }
        }
        g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.codesourcery.jasm16.ide.ui.views.SourceCodeView.java

protected final void clearUnderlineHighlight() {
    final Runnable r = new Runnable() {

        @Override/*  w  ww .j  a  v  a 2  s.c  o m*/
        public void run() {
            if (currentUnderlineHighlight != null) {
                editorPane.getHighlighter().removeHighlight(currentUnderlineHighlight);
                currentUnderlineHighlight = null;
                editorPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                editorPane.repaint();
            }
        }
    };
    UIUtils.invokeLater(r);
}

From source file:base.BasePlayer.AminoTable.java

void drawScreen(Graphics g) {
    if (!isEnabled()) {
        return;//from   w ww.j a  v  a2 s. c  o m
    }

    buf.setColor(Color.black);
    buf.fillRect(0, 0, VariantHandler.tableScroll.getViewport().getWidth(),
            tablescroll.getViewport().getHeight());

    if (VariantHandler.writetofile.isSelected()) {
        buf.setColor(Color.white);
        if (FileRead.output != null && Main.drawCanvas.loading && Draw.variantcalculator) {
            buf.drawString("Writing results to " + FileRead.outputName, 10, 20);
        } else {
            buf.drawString("Press annotate to write results straight to file", 10, 20);
        }
        g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null);
        return;
    }
    //Header Draw   

    genemutcount = 0;
    hoverVar = null;
    hoverSample = -1;
    headerHover = -1;
    geneHeaderHover = -1;

    if (!mouseDrag) {
        resizeColumn = -1;
    }
    firstrow = tablescroll.getVerticalScrollBar().getValue() / rowHeight - samplecount - listAdd
            - aminoarray.size();

    if (firstrow < 0) {
        firstrow = 0;
    }
    for (int i = 0; i < genearray.size(); i++) {
        dot = false;

        if ((i + 1 + samplecount + aminoarray.size() + listAdd) * rowHeight < tablescroll.getVerticalScrollBar()
                .getValue()) {

            continue;
        }

        if (i * rowHeight > tablescroll.getVerticalScrollBar().getValue()
                + tablescroll.getViewport().getHeight()) {
            break;
        }

        if (mouseY >= (rowHeight * (i + genemutcount + 1)) && mouseY < (rowHeight * (i + genemutcount + 2))) {
            hoverNode = genearray.get(i);
        }

        try {
            buf.setColor(Color.darkGray);
            buf.drawLine(4,
                    (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3,
                    this.getWidth(),
                    (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3);

            if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) {
                buf.setColor(Color.yellow);
            } else {
                buf.setColor(Color.white);
            }
            textWidth = (int) fm.getStringBounds("" + (i + 1) + ".  " + genearray.get(i).getName(), buf)
                    .getWidth();
            if (genearray.get(i).intergenic) {
                if (genearray.get(i).varnodes.get(0).getTranscripts() == null) {
                    buf.drawString((i + 1) + ".  " + genearray.get(i).getName(), 5,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);

                } else if (genearray.get(i).varnodes.get(0).getTranscripts().size() == 2) {

                    buf.drawString(
                            (i + 1) + ".  " + genearray.get(i).getName() + " ... "
                                    + genearray.get(i).varnodes.get(0).getTranscripts().get(1).getGenename(),
                            5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                } else if (genearray.get(i).varnodes.get(0).getPosition() < genearray.get(i).getStart()) {
                    buf.drawString((i + 1) + ".  " + " ... " + genearray.get(i).getName(), 5,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);

                } else {
                    buf.drawString((i + 1) + ".  " + genearray.get(i).getName() + " ... ", 5,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);

                }
            } else {
                buf.drawString((i + 1) + ".  " + genearray.get(i).getName(), 5,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
            }
            buf.setColor(Color.black);
            buf.fillRect((int) (headerlengths[1][0] + 1),
                    (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4,
                    (int) (headerlengths[1][1]), rowHeight - 1);

            if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) {
                buf.setColor(Color.yellow);
            } else {
                buf.setColor(Color.white);
            }

            mutcountbuffer = new StringBuffer("" + genearray.get(i).mutations + " (");
            buf.drawString(mutcountbuffer.toString(), (int) (headerlengths[1][0] + 5),
                    (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                            + rowHeight);

            if (genearray.get(i).nonsense > 0) {
                buf.setColor(Color.red);
                textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                buf.drawString("" + genearray.get(i).nonsense, (int) (headerlengths[1][0]) + 5 + textWidth,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
                mutcountbuffer.append(genearray.get(i).nonsense);
                dot = true;
            }
            if (genearray.get(i).missense > 0) {

                if (dot) {
                    buf.setColor(Color.white);
                    textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                    buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);
                    mutcountbuffer.append(", ");
                }

                textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                buf.setColor(Color.yellow);
                buf.drawString("" + genearray.get(i).missense, (int) (headerlengths[1][0]) + 5 + textWidth,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
                mutcountbuffer.append(genearray.get(i).missense);
                dot = true;
            }
            if (genearray.get(i).synonymous > 0) {

                if (dot) {
                    buf.setColor(Color.white);
                    textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                    buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);
                    mutcountbuffer.append(", ");
                }
                textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                buf.setColor(Color.green);
                buf.drawString("" + genearray.get(i).synonymous, (int) (headerlengths[1][0]) + 5 + textWidth,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
                mutcountbuffer.append(genearray.get(i).synonymous);
                dot = true;
            }
            if (genearray.get(i).utr > 0) {

                if (dot) {
                    buf.setColor(Color.white);
                    textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                    buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);
                    mutcountbuffer.append(", ");
                }
                buf.setColor(Color.lightGray);
                textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                buf.drawString("" + genearray.get(i).utr, (int) (headerlengths[1][0]) + 5 + textWidth,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
                mutcountbuffer.append(genearray.get(i).utr);
                dot = true;
            }
            if (genearray.get(i).intronic > 0) {

                if (dot) {
                    buf.setColor(Color.white);
                    textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                    buf.drawString(", ", (int) (headerlengths[1][0]) + 5 + textWidth,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);
                    mutcountbuffer.append(", ");
                }
                buf.setColor(Color.gray);
                textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                buf.drawString("" + genearray.get(i).intronic, (int) (headerlengths[1][0]) + 5 + textWidth,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
                mutcountbuffer.append(genearray.get(i).intronic);
                dot = true;
            }
            if (genearray.get(i).intergenic) {

                buf.setColor(Color.gray);
                textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
                buf.drawString("" + genearray.get(i).mutations, (int) (headerlengths[1][0]) + 5 + textWidth,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
                mutcountbuffer.append("" + genearray.get(i).mutations);
            }
            buf.setColor(Color.white);
            textWidth = (int) fm.getStringBounds(mutcountbuffer.toString(), buf).getWidth();
            buf.drawString(") ", (int) (headerlengths[1][0]) + 5 + textWidth,
                    (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                            + rowHeight);

            buf.setColor(Color.gray);
            textWidth = (int) fm.getStringBounds(mutcountbuffer.toString() + ") ", buf).getWidth();
            if (genearray.get(i).samples.size() == 1) {
                buf.drawString(" 1 sample", (int) (headerlengths[1][0]) + 5 + textWidth,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);

            } else {
                buf.drawString(" " + genearray.get(i).samples.size() + " samples",
                        (int) (headerlengths[1][0]) + 5 + textWidth, (rowHeight * (i + 1 + genemutcount))
                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
            }
            buf.setColor(Color.black);
            buf.fillRect((int) (headerlengths[2][0]) + 1,
                    (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4,
                    this.getWidth(), rowHeight - 1);

            if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) {
                buf.setColor(Color.yellow);
            } else {
                buf.setColor(Color.white);
            }
            if (genearray.get(i).intergenic) {
                if (genearray.get(i).varnodes.get(0).getTranscripts() == null) {
                    buf.drawString(genearray.get(i).getChrom(), (int) (headerlengths[2][0]) + 5,
                            (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);

                } else if (genearray.get(i).varnodes.get(0).getTranscripts().size() == 2) {
                    buf.drawString(
                            genearray.get(i).getChrom() + ":"
                                    + MethodLibrary.formatNumber(genearray.get(i).getEnd()) + "-"
                                    + MethodLibrary.formatNumber(genearray.get(i).varnodes.get(0)
                                            .getTranscripts().get(1).getStart()),
                            (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                } else if (genearray.get(i).varnodes.get(0).getPosition() < genearray.get(i).getStart()) {
                    buf.drawString(
                            genearray.get(i).getChrom() + ":1-"
                                    + MethodLibrary.formatNumber(genearray.get(i).varnodes.get(0)
                                            .getTranscripts().get(1).getStart()),
                            (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                } else {
                    buf.drawString(
                            genearray.get(i).getChrom() + ":"
                                    + MethodLibrary.formatNumber(genearray.get(i).getEnd()) + "-end",
                            (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                }
            } else {
                buf.drawString(
                        genearray.get(i).getChrom() + ":"
                                + MethodLibrary.formatNumber(genearray.get(i).getStart()) + "-"
                                + MethodLibrary.formatNumber(genearray.get(i).getEnd()),
                        (int) (headerlengths[2][0]) + 5, (rowHeight * (i + 1 + genemutcount))
                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
            }
            buf.setColor(Color.black);
            buf.fillRect((int) (headerlengths[3][0]) + 1,
                    (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue() + 4,
                    this.getWidth(), rowHeight - 1);

            if (genearray.get(i).equals(hoverNode) || genearray.get(i).equals(selectedNode)) {

                buf.setColor(Color.yellow);
            } else {
                buf.setColor(Color.white);
            }
            if (genearray.get(i).intergenic) {
                if (genearray.get(i).varnodes.get(0).getTranscripts() == null) {
                    buf.drawString("-", (int) (headerlengths[3][0]) + 5, (rowHeight * (i + 1 + genemutcount))
                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                } else if (genearray.get(i).varnodes.get(0).getTranscripts().size() == 2) {
                    buf.drawString(
                            genearray.get(i).getDescription() + ";"
                                    + genearray.get(i).varnodes.get(0).getTranscripts().get(1).getGene()
                                            .getDescription(),
                            (int) (headerlengths[3][0]) + 5, (rowHeight * (i + 1 + genemutcount))
                                    - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                }
            } else {
                buf.drawString(genearray.get(i).getDescription(), (int) (headerlengths[3][0]) + 5,
                        (rowHeight * (i + 1 + genemutcount)) - tablescroll.getVerticalScrollBar().getValue()
                                + rowHeight);
            }
            buf.setColor(Color.darkGray);
            buf.drawLine(3, rowHeight + 3, 3,
                    (rowHeight * (i + genemutcount + 2)) - tablescroll.getVerticalScrollBar().getValue() + 3);

            for (int r = 0; r < headerlengths.length; r++) {
                buf.drawLine((int) (headerlengths[r][0]),
                        (rowHeight * (i + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue()
                                + 4,
                        (int) (headerlengths[r][0]), (rowHeight * (i + genemutcount + 2))
                                - tablescroll.getVerticalScrollBar().getValue() + 3);
            }

            if (selectedNode != null && selectedNode.equals(genearray.get(i))) {

                hoverSample = -1;
                genemutcount = aminoarray.size() + 1;
                listAdd = 1;
                //      buf.drawLine(10, (rowHeight*(i+listAdd+2))-tablescroll.getVerticalScrollBar().getValue()+3, this.getWidth(), (rowHeight*(i+listAdd+2))-tablescroll.getVerticalScrollBar().getValue()+3);   
                drawGeneheader(
                        (rowHeight * (i + listAdd + 1)) - tablescroll.getVerticalScrollBar().getValue() + 3);

                for (int s = 0; s < aminoarray.size(); s++) {

                    buf.setColor(Color.darkGray);
                    buf.drawLine(21,
                            (rowHeight * (i + s + listAdd + 3)) - tablescroll.getVerticalScrollBar().getValue()
                                    + 3,
                            this.getWidth(), (rowHeight * (i + s + listAdd + 3))
                                    - tablescroll.getVerticalScrollBar().getValue() + 3);
                    if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]).equals("nonsense")) {

                        textcolor = Color.red;
                    } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]).equals("missense")) {

                        textcolor = Color.yellow;
                    } else if (MethodLibrary.aminoEffect(aminoarray.get(s).getRow()[3]).equals("synonymous")) {
                        textcolor = Color.green;
                    } else if (aminoarray.get(s).getRow()[3].contains("UTR")) {
                        textcolor = Color.lightGray;
                    } else {

                        textcolor = Color.gray;
                    }
                    buf.setColor(textcolor);
                    if (mouseY >= (rowHeight * (i + s + listAdd + 2))
                            && mouseY < (rowHeight * (i + s + listAdd + 3))) {
                        hoverNode = null;
                        hoverVar = aminoarray.get(s).getNode();
                        hoverString = aminoarray.get(s).getRow();
                        buf.setColor(Color.white);
                        hoverSample = -1;

                        if (aminoarray.get(s).getRow()[1].equals("1")) {
                            for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                        .equals(aminoarray.get(s).getRow()[5])) {

                                    hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                            .getSample().getIndex();
                                    hoverSampleNode = aminoarray.get(s).getNode().vars.get(v).getValue().get(0);
                                    hoverBase = aminoarray.get(s).getRow()[5];
                                    break;
                                }
                            }
                        }
                        //      hoverSample = -1;

                    }

                    if (!aminoarray.get(s).getRow()[1].equals("1")) {
                        buf.drawString("Multiple", 24, (rowHeight * (i + s + listAdd + 2))
                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                    } else {
                        for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {

                            if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                    .equals(aminoarray.get(s).getRow()[5])) {

                                buf.drawString(
                                        aminoarray.get(s).getNode().vars.get(v).getValue().get(0).getSample()
                                                .getName(),
                                        24, (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                                break;
                            }
                        }
                    }

                    if (hoverVar != null && hoverString.equals(aminoarray.get(s).getRow())) {
                        //TODO
                        textcolor = Color.white;

                    }

                    for (int h = 1; h < 4; h++) {
                        buf.setColor(Color.black);
                        buf.fillRect((int) geneheader.get(h)[1] + 10,
                                (rowHeight * (i + s + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                (int) geneheader.get(h)[2], rowHeight - 1);
                        buf.setColor(textcolor);
                        if (h == 3) {
                            if (aminoarray.get(s).getRow()[5].length() == 1) {
                                buf.drawString(
                                        Main.getBase.get(aminoarray.get(s).getNode().getRefBase()) + ">"
                                                + aminoarray.get(s).getRow()[5],
                                        (int) geneheader.get(h)[1] + 14, (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                            } else {
                                buf.drawString(aminoarray.get(s).getRow()[5], (int) geneheader.get(h)[1] + 14,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            }
                            buf.setColor(Color.black);
                            buf.fillRect((int) geneheader.get(4)[1] + 10,
                                    (rowHeight * (i + s + listAdd + 2))
                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                    (int) geneheader.get(4)[2], rowHeight - 1);
                            buf.setColor(textcolor);
                            buf.drawString(aminoarray.get(s).getRow()[h], (int) geneheader.get(4)[1] + 14,
                                    (rowHeight * (i + s + listAdd + 2))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                        } else {

                            buf.drawString(aminoarray.get(s).getRow()[h], (int) geneheader.get(h)[1] + 14,
                                    (rowHeight * (i + s + listAdd + 2))
                                            - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                        }
                    }

                    if (aminoarray.get(s).getRow()[1].equals("1")) {
                        buf.setColor(Color.black);
                        buf.fillRect((int) geneheader.get(5)[1] + 10,
                                (rowHeight * (i + s + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                (int) geneheader.get(5)[2], rowHeight - 1);
                        buf.setColor(textcolor);

                        for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                            if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                    .equals(aminoarray.get(s).getRow()[5])) {
                                if (aminoarray.get(s).getNode().vars.get(v).getValue().get(0).isHomozygous()) {
                                    buf.drawString(
                                            "Hom (" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                    .getCalls() + "/"
                                                    + aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                            .getCoverage()
                                                    + ")",
                                            (int) geneheader.get(5)[1] + 14,
                                            (rowHeight * (i + s + listAdd + 2))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);
                                    if (Control.controlData.controlsOn) {
                                        cases = 2;
                                        casefreq = 2 / (double) (Main.varsamples * 2 - 2);
                                    }
                                } else {
                                    buf.drawString(
                                            "Het (" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                    .getCalls() + "/"
                                                    + aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                            .getCoverage()
                                                    + ")",
                                            (int) geneheader.get(5)[1] + 14,
                                            (rowHeight * (i + s + listAdd + 2))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);
                                    if (Control.controlData.controlsOn) {
                                        cases = 1;
                                        casefreq = 1 / (double) (Main.varsamples * 2 - 1);
                                    }

                                }
                                buf.setColor(Color.black);
                                buf.fillRect((int) geneheader.get(6)[1] + 10,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + 4,
                                        this.getWidth(), rowHeight - 1);
                                buf.setColor(textcolor);
                                buf.drawString(
                                        "" + aminoarray.get(s).getNode().vars.get(v).getValue().get(0)
                                                .getQuality(),
                                        (int) geneheader.get(6)[1] + 14, (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);

                            }
                        }
                    } else {
                        //TODO piirra mustat boksit
                        buf.setColor(Color.black);
                        buf.fillRect((int) geneheader.get(5)[1] + 10,
                                (rowHeight * (i + s + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                this.getWidth(), rowHeight - 1);

                        if (Control.controlData.controlsOn) {
                            cases = 0;

                            for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                                if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                        .equals(aminoarray.get(s).getRow()[5])) {
                                    for (int j = 0; j < aminoarray.get(s).getNode().vars.get(v).getValue()
                                            .size(); j++) {
                                        if (aminoarray.get(s).getNode().vars.get(v).getValue()
                                                .get(j).alleles != null) {
                                            continue;
                                        }
                                        if (aminoarray.get(s).getNode().vars.get(v).getValue().get(j)
                                                .isHomozygous()) {
                                            cases += 2;
                                        } else {
                                            cases += 1;
                                        }
                                    }
                                }
                            }
                            casefreq = cases / (double) (Main.varsamples * 2 - cases);

                        }
                    }
                    buf.setColor(textcolor);
                    buf.drawString(aminoarray.get(s).getRow()[4], (int) geneheader.get(7)[1] + 14,
                            (rowHeight * (i + s + listAdd + 2)) - tablescroll.getVerticalScrollBar().getValue()
                                    + rowHeight);
                    //      buf.setColor(Color.black);

                    if (Control.controlData.controlsOn) {
                        buf.setColor(textcolor);

                        for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                            if (aminoarray.get(s).getNode().vars.get(v).getKey()
                                    .equals(aminoarray.get(s).getRow()[5])) {
                                vararray = aminoarray.get(s).getNode().vars.get(v).getValue();
                                controlarray = new SampleNode[Control.controlData.fileArray.size()];
                                if (vararray.get(vararray.size() - 1).alleles != null) {

                                    for (int e = vararray.size() - 1; e > 0; e--) {

                                        if (vararray.get(e).alleles == null) {
                                            break;
                                        }

                                        controlarray[vararray.get(e).getControlSample().getIndex()] = vararray
                                                .get(e);

                                    }
                                }

                                for (int e = 0; e < controlarray.length; e++) {
                                    if (Control.controlData.fileArray.get(e).controlOn) {
                                        if (controlarray[e] == null) {
                                            buf.setColor(Color.black);
                                            buf.fillRect(
                                                    (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 11,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);
                                            buf.drawString("0",
                                                    (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            buf.setColor(Color.black);
                                            buf.fillRect(
                                                    (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1]
                                                            + 11,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);
                                            buf.drawString("-",
                                                    (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1]
                                                            + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);

                                        } else {
                                            buf.setColor(Color.black);
                                            buf.fillRect(
                                                    (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 11,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);
                                            buf.drawString(
                                                    "" + MethodLibrary.round(controlarray[e].alleles
                                                            / (double) controlarray[e].allelenumber, 5),
                                                    (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);
                                            buf.setColor(Color.black);
                                            buf.fillRect(
                                                    (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1]
                                                            + 11,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                    this.getWidth(), rowHeight - 1);
                                            buf.setColor(textcolor);

                                            buf.drawString(
                                                    "" + MethodLibrary.round(casefreq / (controlarray[e].alleles
                                                            / (double) (controlarray[e].allelenumber
                                                                    - controlarray[e].alleles)),
                                                            2) + " (p="
                                                            + MethodLibrary.round(
                                                                    fe.getRightTailedP(cases,
                                                                            Main.varsamples * 2 - cases,
                                                                            controlarray[e].alleles,
                                                                            controlarray[e].allelenumber
                                                                                    - controlarray[e].alleles),
                                                                    2)
                                                            + ")",
                                                    (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1]
                                                            + 14,
                                                    (rowHeight * (i + s + listAdd + 2))
                                                            - tablescroll.getVerticalScrollBar().getValue()
                                                            + rowHeight);

                                        }
                                    } else {
                                        buf.setColor(Color.black);
                                        buf.fillRect(
                                                (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 11,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                this.getWidth(), rowHeight - 1);
                                        buf.setColor(Color.darkGray);
                                        buf.drawString("Apply controls",
                                                (int) geneheader.get(this.geneheaderlength + e * 2)[1] + 14,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                        buf.setColor(Color.black);
                                        buf.fillRect(
                                                (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 11,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                                this.getWidth(), rowHeight - 1);
                                        buf.setColor(Color.darkGray);
                                        buf.drawString("-",
                                                (int) geneheader.get(this.geneheaderlength + e * 2 + 1)[1] + 14,
                                                (rowHeight * (i + s + listAdd + 2))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                    }
                                }
                            }
                        }
                    } else {
                        buf.setColor(Color.darkGray);

                        for (int e = geneheaderlength; e < geneheader.size(); e++) {
                            if (geneheader.get(e)[0] instanceof ControlFile) {
                                buf.drawString("Apply controls", (int) geneheader.get(e)[1] + 14,
                                        (rowHeight * (i + s + listAdd + 2))
                                                - tablescroll.getVerticalScrollBar().getValue() + rowHeight);
                            }
                        }
                        buf.setColor(Color.lightGray);
                    }
                    vararray = null;
                    //if(Main.bedCanvas.bedOn) {               

                    for (int a = 0; a < aminoarray.size(); a++) {

                        bedarray = MethodLibrary.makeTrackArray(aminoarray.get(a).getNode(),
                                aminoarray.get(a).getRow()[5]);
                        if (bedarray != null) {
                            for (int b = 0; b < bedarray.length; b++) {
                                buf.setColor(Color.black);
                                if (b == bedarray.length - 1) {
                                    buf.fillRect(
                                            (int) geneheader.get(geneheaderlength
                                                    + Control.controlData.fileArray.size() * 2 + b)[1] + 12,
                                            (rowHeight * (i + a + listAdd + 2))
                                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                                            this.getWidth() - (int) geneheader.get(geneheaderlength
                                                    + Control.controlData.fileArray.size() * 2 + b)[1],
                                            rowHeight - 1);
                                } else {
                                    buf.fillRect(
                                            (int) geneheader.get(geneheaderlength
                                                    + Control.controlData.fileArray.size() * 2 + b)[1] + 12,
                                            (rowHeight * (i + a + listAdd + 2))
                                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                                            (int) geneheader.get(geneheaderlength
                                                    + Control.controlData.fileArray.size() * 2 + b)[2],
                                            rowHeight - 1);
                                }
                                buf.setColor(Color.white);
                                if (bedarray[b] != null) {
                                    buf.drawString(bedarray[b].toString(),
                                            (int) geneheader.get(geneheaderlength
                                                    + Control.controlData.fileArray.size() * 2 + b)[1] + 14,
                                            (rowHeight * (i + a + listAdd + 2))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);

                                }
                            }
                        }
                    }

                    /*if(c < header.size()-1-Main.bedCanvas.bedTrack.size()) {
                       buf.setColor(Color.black);
                       buf.fillRect((int)header.get(c+1)[1]+1, (rowHeight*(i+genemutcount+1))-tablescroll.getVerticalScrollBar().getValue()+4, (int)header.get(c)[2], rowHeight-1);   
                                 
                    }*/
                    //   }

                    buf.setColor(Color.darkGray);
                    for (int j = 0; j < geneheader.size(); j++) {

                        buf.drawLine((int) geneheader.get(j)[1] + 11,
                                (rowHeight * (i + s + listAdd + 2))
                                        - tablescroll.getVerticalScrollBar().getValue() + 4,
                                (int) geneheader.get(j)[1] + 11, (rowHeight * (i + s + listAdd + 3))
                                        - tablescroll.getVerticalScrollBar().getValue() + 3);
                    }
                    if (selectedVar != null && selectedString.equals(aminoarray.get(s).getRow())
                            && Integer.parseInt(selectedString[1]) > 1) {
                        pointer = 0;
                        //TODO

                        for (int v = 0; v < aminoarray.get(s).getNode().vars.size(); v++) {
                            if (aminoarray.get(s).getNode().vars.get(v).getKey().equals(selectedString[5])) {

                                for (int l = 0; l < aminoarray.get(s).getNode().vars.get(v).getValue()
                                        .size(); l++) {
                                    if (aminoarray.get(s).getNode().vars.get(v).getValue()
                                            .get(l).alleles != null) {
                                        break;
                                    }
                                    if (aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                            .getSample().annotation) {
                                        continue;
                                    }
                                    if (mouseY > (rowHeight * (i + s + pointer + 4))
                                            && mouseY < (rowHeight * (i + s + pointer + 5))) {
                                        textcolor = Color.white;

                                        hoverVar = aminoarray.get(s).getNode();
                                        hoverString = aminoarray.get(s).getRow();
                                        hoverSample = aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                                .getSample().getIndex();
                                        hoverSampleNode = aminoarray.get(s).getNode().vars.get(v).getValue()
                                                .get(l);
                                        hoverBase = aminoarray.get(s).getRow()[5];
                                    } else {
                                        textcolor = Color.lightGray;
                                    }

                                    //   if(aminoarray.get(s).getNode().getSamples().get(l).getVariation().equals(selectedString[5])) {                           
                                    buf.setColor(textcolor);
                                    buf.drawString(
                                            aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                                    .getSample().getName(),
                                            30,
                                            (rowHeight * (i + s + pointer + 4))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);
                                    pointer++;
                                    //   }   

                                    buf.setColor(Color.black);
                                    buf.fillRect((int) geneheader.get(5)[1] + 10,
                                            (rowHeight * (i + s + pointer + 3))
                                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                                            this.getWidth(), rowHeight - 1);
                                    buf.setColor(textcolor);
                                    if (aminoarray.get(s).getNode().vars.get(v).getValue().get(l)
                                            .isHomozygous()) {
                                        buf.drawString(
                                                "Hom (" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                        .get(l).getCalls() + "/"
                                                        + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                                .get(l).getCoverage()
                                                        + ")",
                                                (int) geneheader.get(5)[1] + 14,
                                                (rowHeight * (i + s + pointer + 3))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);

                                    } else {
                                        buf.drawString(
                                                "Het (" + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                        .get(l).getCalls() + "/"
                                                        + aminoarray.get(s).getNode().vars.get(v).getValue()
                                                                .get(l).getCoverage()
                                                        + ")",
                                                (int) geneheader.get(5)[1] + 14,
                                                (rowHeight * (i + s + pointer + 3))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight);
                                    }
                                    buf.setColor(Color.black);
                                    buf.fillRect((int) geneheader.get(6)[1] + 10,
                                            (rowHeight * (i + s + pointer + 3))
                                                    - tablescroll.getVerticalScrollBar().getValue() + 4,
                                            this.getWidth(), rowHeight - 1);
                                    buf.setColor(textcolor);
                                    buf.drawString(
                                            "" + aminoarray.get(s).getNode().vars
                                                    .get(v).getValue().get(l).getQuality(),
                                            (int) geneheader.get(6)[1] + 14,
                                            (rowHeight * (i + s + pointer + 3))
                                                    - tablescroll.getVerticalScrollBar().getValue()
                                                    + rowHeight);
                                    buf.setColor(Color.darkGray);
                                    for (int j = 5; j < 7; j++) {

                                        buf.drawLine((int) geneheader.get(j)[1] + 11,
                                                (rowHeight * (i + s + pointer + 3))
                                                        - tablescroll.getVerticalScrollBar().getValue(),
                                                (int) geneheader.get(j)[1] + 11,
                                                (rowHeight * (i + s + pointer + 3))
                                                        - tablescroll.getVerticalScrollBar().getValue()
                                                        + rowHeight + 2);
                                    }
                                }
                            }

                        }
                        listAdd = Integer.parseInt(selectedString[1]) + 1;
                        genemutcount = aminoarray.size() + listAdd;
                        buf.setColor(Color.darkGray);
                        buf.drawLine(21,
                                (rowHeight * (i + s + listAdd + 3))
                                        - tablescroll.getVerticalScrollBar().getValue() + 3,
                                this.getWidth(), (rowHeight * (i + s + listAdd + 3))
                                        - tablescroll.getVerticalScrollBar().getValue() + 3);

                    }

                }
            }
        } catch (Exception e) {
            ErrorLog.addError(e.getStackTrace());
            e.printStackTrace();
        }

    }
    buf.setColor(Color.darkGray);
    buf.drawLine(4,
            (rowHeight * (genearray.size() + genemutcount + 1)) - tablescroll.getVerticalScrollBar().getValue()
                    + 3,
            this.getWidth(), (rowHeight * (genearray.size() + genemutcount + 1))
                    - tablescroll.getVerticalScrollBar().getValue() + 3);

    drawHeader();
    if (headerHover == -1 && geneHeaderHover == -1) {

        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } else {
        if (resizeColumn == -1) {
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        } else {
            setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
        }
    }

    g.drawImage(bufImage, 0, tablescroll.getVerticalScrollBar().getValue(), null);

}

From source file:de.codesourcery.jasm16.ide.ui.views.SourceCodeView.java

protected final void underlineLocation(final ITextRegion region) {
    if (region == null) {
        throw new IllegalArgumentException("region must not be NULL.");
    }/*from w w w  . j  a va 2s .co  m*/

    Runnable r = new Runnable() {
        @Override
        public void run() {
            try {
                if (currentUnderlineHighlight == null) {
                    currentUnderlineHighlight = editorPane.getHighlighter().addHighlight(
                            region.getStartingOffset(), region.getEndOffset(),
                            new UnderlineHighlightPainter(Color.BLUE, 1));
                } else {
                    editorPane.getHighlighter().changeHighlight(currentUnderlineHighlight,
                            region.getStartingOffset(), region.getEndOffset());
                }
                editorPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                editorPane.repaint();
            } catch (BadLocationException e) {
                LOG.error("underlineLocation(): Bad location " + region, e);
            }
        }
    };
    UIUtils.invokeLater(r);
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#onDataObjectSave(DataObject, DataObject, int)
 *//*  w  w  w  . j  a v a  2  s.  c o m*/
public void onDataObjectSave(DataObject data, DataObject parent, int operation) {
    int state = model.getState();
    if (operation == REMOVE_OBJECT && state != SAVE)
        throw new IllegalStateException("This method can only be " + "invoked in the SAVE state");
    switch (state) {
    case DISCARDED:
        throw new IllegalStateException("This method cannot be " + "invoked in the DISCARDED state");
    }
    if (data == null)
        throw new IllegalArgumentException("No data object. ");
    switch (operation) {
    case CREATE_OBJECT:
    case UPDATE_OBJECT:
    case REMOVE_OBJECT:
        break;
    default:
        throw new IllegalArgumentException("Save operation not " + "supported.");
    }
    //removeEditor(); //remove the currently selected editor.
    if (operation == REMOVE_OBJECT) {
        model.setState(READY);
        fireStateChange();
    }
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    Browser browser = null;
    if (operation == CREATE_OBJECT) {
        if (parent == null) {
            if ((data instanceof ProjectData) || (data instanceof DatasetData))
                browser = model.getBrowser(Browser.PROJECTS_EXPLORER);
            else if (data instanceof ScreenData)
                browser = model.getBrowser(Browser.SCREENS_EXPLORER);
            else if (data instanceof TagAnnotationData)
                browser = model.getBrowser(Browser.TAGS_EXPLORER);
        }
        if (browser != null) {
            model.setSelectedBrowser(browser);
            view.addBrowser(browser);
            removeEditor();
        }
    }
    browser = model.getSelectedBrowser();
    if (browser != null && operation != UPDATE_OBJECT)
        browser.refreshTree(null, null);
    if (operation == REMOVE_OBJECT || operation == CREATE_OBJECT) {
        DataBrowserFactory.discardAll();
        view.removeAllFromWorkingPane();
    }
    if (operation == UPDATE_OBJECT && browser != null) {
        browser.accept(new UpdateVisitor(browser, data));
        browser.getUI().repaint();
    }
    setStatus(false, "", true);
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:ffx.ui.MainPanel.java

/**
 * Opens a file from the PDB//from w  ww .  java2 s  . c  om
 */
public void openFromPDB() {
    if (openThread != null && openThread.isAlive()) {
        return;
    }
    String code = JOptionPane.showInputDialog("Enter the PDB Identifier (4 characters)", "");
    if (code == null) {
        return;
    }
    code = code.toLowerCase().trim();
    if (code == null || code.length() != 4) {
        return;
    }
    String fileName = code + ".pdb";
    String path = getPWD().getAbsolutePath();
    File pdbFile = new File(path + File.separatorChar + fileName);
    CompositeConfiguration properties = Keyword.loadProperties(pdbFile);
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    FFXSystem newSystem = new FFXSystem(pdbFile, "PDB", properties);
    newSystem.setForceField(forceField);
    if (!pdbFile.exists()) {
        String fromURL = pdbForID(code);
        pdbFile = downloadURL(fromURL);
        if (pdbFile == null || !pdbFile.exists()) {
            return;
        }
    } else {
        String message = String.format(" Reading the local copy of the PDB file %s.", pdbFile);
        logger.info(message);
    }
    PDBFilter pdbFilter = new PDBFilter(pdbFile, newSystem, forceField, properties);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    UIFileOpener openFile = new UIFileOpener(pdbFilter, this);
    if (fileOpenerThreads > 0) {
        openFile.setNThreads(fileOpenerThreads);
    }
    openThread = new Thread(openFile);
    openThread.start();
    setPanel(GRAPHICS);
}

From source file:op.care.bhp.PnlBHP.java

private java.util.List<Component> addFilter() {
    java.util.List<Component> list = new ArrayList<Component>();

    jdcDatum = new JDateChooser(new Date());
    jdcDatum.setFont(new Font("Arial", Font.PLAIN, 18));
    jdcDatum.setMinSelectableDate(BHPTools.getMinDatum(resident));

    jdcDatum.setBackground(Color.WHITE);
    jdcDatum.addPropertyChangeListener(new PropertyChangeListener() {
        @Override/*from w ww .  j  av a2 s.c om*/
        public void propertyChange(PropertyChangeEvent evt) {
            if (initPhase) {
                return;
            }
            if (evt.getPropertyName().equals("date")) {
                reloadDisplay();
            }
        }
    });
    list.add(jdcDatum);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(Color.WHITE);
    buttonPanel.setLayout(new HorizontalLayout(5));
    buttonPanel.setBorder(new EmptyBorder(0, 0, 0, 0));

    JButton homeButton = new JButton(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start.png")));
    homeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            jdcDatum.setDate(jdcDatum.getMinSelectableDate());
        }
    });
    homeButton.setPressedIcon(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start_pressed.png")));
    homeButton.setBorder(null);
    homeButton.setBorderPainted(false);
    homeButton.setOpaque(false);
    homeButton.setContentAreaFilled(false);
    homeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    JButton backButton = new JButton(
            new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back.png")));
    backButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DateMidnight current = new DateMidnight(jdcDatum.getDate());
            DateMidnight min = new DateMidnight(jdcDatum.getMinSelectableDate());
            if (current.equals(min)) {
                return;
            }
            jdcDatum.setDate(SYSCalendar.addDate(jdcDatum.getDate(), -1));
        }
    });
    backButton
            .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back_pressed.png")));
    backButton.setBorder(null);
    backButton.setBorderPainted(false);
    backButton.setOpaque(false);
    backButton.setContentAreaFilled(false);
    backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    JButton fwdButton = new JButton(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play.png")));
    fwdButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DateMidnight current = new DateMidnight(jdcDatum.getDate());
            if (current.equals(new DateMidnight())) {
                return;
            }
            jdcDatum.setDate(SYSCalendar.addDate(jdcDatum.getDate(), 1));
        }
    });
    fwdButton
            .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play_pressed.png")));
    fwdButton.setBorder(null);
    fwdButton.setBorderPainted(false);
    fwdButton.setOpaque(false);
    fwdButton.setContentAreaFilled(false);
    fwdButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    JButton endButton = new JButton(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end.png")));
    endButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            jdcDatum.setDate(new Date());
        }
    });
    endButton.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end_pressed.png")));
    endButton.setBorder(null);
    endButton.setBorderPainted(false);
    endButton.setOpaque(false);
    endButton.setContentAreaFilled(false);
    endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    buttonPanel.add(homeButton);
    buttonPanel.add(backButton);
    buttonPanel.add(fwdButton);
    buttonPanel.add(endButton);

    list.add(buttonPanel);

    //        panelFilter.setContentPane(labelPanel);

    return list;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerComponent.java

/**
 * Implemented as specified by the {@link TreeViewer} interface.
 * @see TreeViewer#onOrphanDataObjectCreated(DataObject, int)
 *///from www .ja  v  a 2  s .c  o  m
public void onOrphanDataObjectCreated(DataObject data) {
    view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Browser browser = model.getSelectedBrowser();
    if (browser != null)
        browser.onOrphanDataObjectCreated(data);

    setStatus(false, "", true);
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * An action for when a row is selected in the table
 *///from   ww  w.j  a  v  a2  s.  co  m
private void MessageListSelected(ListSelectionEvent evt) {
    if (!evt.getValueIsAdjusting()) {
        int row = getSelectedMessageIndex();

        if (row >= 0) {
            // Cancel all pretty printing tasks
            for (Future<Void> worker : prettyPrintWorkers) {
                worker.cancel(true);
            }
            prettyPrintWorkers.clear();

            parent.setVisibleTasks(parent.messageTasks, parent.messagePopupMenu, 6, 6, true);
            parent.setVisibleTasks(parent.messageTasks, parent.messagePopupMenu, 7, -1, isChannelDeployed);

            this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            // Get the table node
            MessageBrowserTableNode messageNode = (MessageBrowserTableNode) messageTreeTable.getPathForRow(row)
                    .getLastPathComponent();

            if (messageNode.isNodeActive()) {
                // Get the messageId from the message node
                Long messageId = messageNode.getMessageId();
                // Get the metaDataId from the message node
                Integer metaDataId = messageNode.getMetaDataId();

                // Attempt to get the message from the message cache
                Message message = messageCache.get(messageId);
                List<Attachment> attachments = attachmentCache.get(messageId);

                // If the message is not in the cache, retrieve it from the server
                if (message == null) {
                    try {
                        message = parent.mirthClient.getMessageContent(channelId, messageId,
                                selectedMetaDataIds);
                        // If the message was not found (ie. it may have been deleted during the request), do nothing
                        if (message == null || message.getConnectorMessages().size() == 0) {
                            clearDescription(
                                    "Could not retrieve message content. The message may have been deleted.");
                            this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                            return;
                        }

                        attachments = parent.mirthClient.getAttachmentsByMessageId(channelId, messageId, false);
                    } catch (Throwable t) {
                        if (t.getMessage().contains("Java heap space")) {
                            parent.alertError(parent,
                                    "There was an out of memory error when trying to retrieve message content.\nIncrease your heap size and try again.");
                        } else if (t instanceof RequestAbortedException) {
                            // The client is no longer waiting for the message content request
                        } else {
                            parent.alertThrowable(parent, t);
                        }
                        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                        return;
                    }
                    // Add the retrieved message to the message cache
                    messageCache.put(messageId, message);
                    attachmentCache.put(messageId, attachments);
                }

                ConnectorMessage connectorMessage = message.getConnectorMessages().get(metaDataId);

                if (connectorMessage != null) {
                    // Update the message tabs
                    updateDescriptionMessages(connectorMessage);
                    // Update the mappings tab
                    updateDescriptionMappings(connectorMessage);
                    // Update the attachments tab
                    updateAttachmentsTable(messageId);
                    // Update the errors tab
                    updateDescriptionErrors(connectorMessage);
                    // Show relevant tabs. Not using errorCode here just in case for some reason there are errors even though errorCode is 0
                    updateDescriptionTabs(connectorMessage.getProcessingError() != null
                            || connectorMessage.getPostProcessorError() != null
                            || connectorMessage.getResponseError() != null, attachments.size() > 0);
                    updateMessageRadioGroup();

                    if (attachmentTable == null || attachmentTable.getSelectedRow() == -1
                            || descriptionTabbedPane.indexOfTab("Attachments") == -1) {
                        parent.setVisibleTasks(parent.messageTasks, parent.messagePopupMenu, 9, 10, false);
                    }
                }
            } else {
                clearDescription(null);
            }

            this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

        }
    }
}