Example usage for java.awt Color darkGray

List of usage examples for java.awt Color darkGray

Introduction

In this page you can find the example usage for java.awt Color darkGray.

Prototype

Color darkGray

To view the source code for java.awt Color darkGray.

Click Source Link

Document

The color dark gray.

Usage

From source file:AlphaTest.java

/**
 * Draws vertical lines and labels to denote the various phases of the Alpha
 * function./*  w  ww  .  j  a va2s .  c o  m*/
 */
protected void drawPhases(Graphics g, long lMaxTime) {
    int nLoop = 1;

    if (m_Alpha.getLoopCount() > 0)
        nLoop = m_Alpha.getLoopCount();

    double curTime = 0;

    g.setColor(Color.darkGray);

    curTime += m_Alpha.getTriggerTime();
    drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

    curTime += m_Alpha.getPhaseDelayDuration();
    drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

    double startPhaseTime = 0;

    for (int nIteration = 0; nIteration < nLoop; nIteration++) {
        startPhaseTime = curTime;

        g.setColor(Color.black);
        drawGraphString(g, -1, "" + curTime, curTime * m_ScaleX, -20);
        g.setColor(Color.darkGray);

        if ((m_Alpha.getMode() & Alpha.INCREASING_ENABLE) != 0) {
            curTime += m_Alpha.getIncreasingAlphaRampDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

            curTime = startPhaseTime + m_Alpha.getIncreasingAlphaDuration()
                    - m_Alpha.getIncreasingAlphaRampDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

            curTime = startPhaseTime + m_Alpha.getIncreasingAlphaDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

            curTime += m_Alpha.getAlphaAtOneDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);
        }

        startPhaseTime = curTime;

        if ((m_Alpha.getMode() & Alpha.DECREASING_ENABLE) != 0) {
            curTime += m_Alpha.getDecreasingAlphaRampDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

            curTime = startPhaseTime + m_Alpha.getDecreasingAlphaDuration()
                    - m_Alpha.getDecreasingAlphaRampDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

            curTime = startPhaseTime + m_Alpha.getDecreasingAlphaDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);

            curTime += m_Alpha.getAlphaAtZeroDuration();
            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);
        }
    }

    g.setColor(Color.black);
}

From source file:CustomAlphaTest.java

protected void drawPhases(Graphics g, long lMaxTime) {
    double curTime = 0;

    g.setColor(Color.darkGray);

    int nLoop = 1;

    if (m_Alpha.getLoopCount() > 0)
        nLoop = m_Alpha.getLoopCount();//from  www  . j  av  a  2 s .  co  m

    for (int n = 0; n < nLoop; n++) {
        for (int nValue = 0; nValue < m_Alpha.getNumValues(); nValue++) {
            curTime = n * m_Alpha.getMaxTime() + m_Alpha.getTimeForValue(nValue);

            g.setColor(Color.black);
            drawGraphString(g, -1, "" + (curTime / 1000), curTime * m_ScaleX, -20);
            g.setColor(Color.darkGray);

            drawGraphLine(g, curTime * m_ScaleX, 0, curTime * m_ScaleX, m_nGraphMaxHeight);
        }
    }

    g.setColor(Color.black);
}

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates a line chart./*www  .ja va2  s.  co  m*/
 * 
 * @param title
 * @param categoryAxisLabel
 *            (X-Axis label)
 * @param valueAxisLabel
 *            (Y-Axis label)
 * @param dataset
 * @param includeZero
 *            True when zero shall be included to the axis range.
 * @return JfreeChart instance.
 */
public JFreeChart createLineChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean includeZero, boolean drawShapes) {
    JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            this.orientation, this.drawLegend, false, false);
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.025);
    domainAxis.setUpperMargin(0.025);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(includeZero);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.green);
    renderer.setSeriesPaint(3, Color.darkGray);
    renderer.setSeriesPaint(4, Color.yellow);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseShapesVisible(drawShapes);
    renderer.setBaseShapesFilled(true);
    return chart;
}

From source file:com.juanhg.icewalker.IceWalkerApplet.java

private void initSimulation() {

    Point2D[] nullArray = new Point2D[0];

    //Crear modelo
    model = new IceWalkerModel(F, mu, mud);

    chart = new Grafica(nullArray, "", "", "Coordenada X", "", false, Color.BLUE, 1f, false);
    chart.setRangeAxis(this.infXLimit, this.supXLimit, this.infYLimit, this.supYLimit);

    chart.agregarGrafica(model.getRopeToPerson(), "", Color.darkGray, 3f, true);
    chart.agregarGrafica(model.getRopeToBox(), "", Color.darkGray, 3f, true);
    paintEnergy();//  w ww.j a  va2 s  .com

    //Load Images
    backgroundImage = loadImage("background.png");
    boxImage = loadImage(box);
    pulleyImage = loadImage(pulley);
    baseImage = loadImage(base);
    person0Image = loadImage(person0);
    person1Image = loadImage(person1);
    person2Image = loadImage(person2);
    person3Image = loadImage(person3);
    person4Image = loadImage(person4);

    try {
        chart.setBackGroundImage(this.backgroundImage, 1);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    //Set Images  
    chart.deleteAnnotation(boxAnnotation);
    boxAnnotation = chart.setImageAtPoint(boxImage, model.getBoxPoint());
    chart.deleteAnnotation(personAnnotation);
    personAnnotation = chart.setImageAtPoint(getPersonImage(), model.getPersonPoint());
    chart.setImageAtPoint(baseImage, model.getBase());
    chart.setImageAtPoint(pulleyImage, model.getPulleyPoint());

    btnBanana.setEnabled(false);
    btnBurger.setEnabled(false);
    btnCarrot.setEnabled(false);
    btnCookie.setEnabled(false);

    //Actualize panels
    panelSimulation.actualizaGrafica(chart);
}

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates a line chart./*  www.j a v a 2 s.c om*/
 * 
 * @param title
 * @param categoryAxisLabel
 *            (X-Axis label)
 * @param valueAxisLabel
 *            (Y-Axis label)
 * @param dataset
 * @param includeZero
 *            True when zero shall be included to the axis range.
 * @return JfreeChart instance.
 */
public JFreeChart createXYLineChart(String title, String categoryAxisLabel, String valueAxisLabel,
        XYDataset dataset, boolean includeZero, boolean drawShapes) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            this.orientation, this.drawLegend, false, false);
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = chart.getXYPlot();
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.025);
    domainAxis.setUpperMargin(0.025);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(includeZero);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.green);
    renderer.setSeriesPaint(3, Color.darkGray);
    renderer.setSeriesPaint(4, Color.yellow);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseShapesVisible(drawShapes);
    renderer.setBaseShapesFilled(true);
    return chart;
}

From source file:base.BasePlayer.BedTable.java

void drawScreen(Graphics g) {
    try {/*from www  . j  a  va 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:org.jfree.eastwood.ChartEngine.java

/**
 * Creates and returns a new <code>JFreeChart</code> instance that
 * reflects the specified parameters (which should be equivalent to
 * a parameter map returned by HttpServletRequest.getParameterMap() for
 * a valid URI for the Google Chart API.
 *
 * @param params  the parameters (<code>null</code> not permitted).
 * @param font    the font to use to draw titles, labels and legends.
 *
 * @return A chart corresponding to the specification in the supplied
 *         parameters./*from  w  ww.j a v a  2 s  .c  o  m*/
 */
public static JFreeChart buildChart(Map params, Font font) {
    if (params == null) {
        throw new IllegalArgumentException("Null 'params' argument.");
    }

    JFreeChart chart = null;

    // *** CHART TYPE **
    String[] chartType = (String[]) params.get("cht");
    int dataType = -1; // 0 = PieDataset; 1 = XYDataset; 2 = special

    // pie charts: 'p' and 'p3'
    if (chartType[0].equals("p")) {
        chart = createPieChart();
        dataType = 0;
    } else if (chartType[0].equals("p3")) {
        chart = createPieChart3D();
        dataType = 0;
    }
    // line chart: 'lc'
    else if (chartType[0].equals("lc")) {
        chart = createLineChart();
        dataType = 1;
    }
    // sparkline: 'ls'
    else if (chartType[0].equals("ls")) {
        chart = createSparklineChart();
        dataType = 1;
    }
    // xy chart: 'lxy'
    else if (chartType[0].equals("lxy")) {
        chart = createLineChart();
        dataType = 3;
    }
    // bar charts: 'bhs', 'bhg', 'bhs' and 'bhg'
    else if (chartType[0].equals("bhs")) {
        chart = createStackedBarChart(PlotOrientation.HORIZONTAL);
        dataType = 2;
    } else if (chartType[0].equals("bhg")) {
        chart = createBarChart(PlotOrientation.HORIZONTAL);
        dataType = 2;
    } else if (chartType[0].equals("bvs")) {
        chart = createStackedBarChart(PlotOrientation.VERTICAL);
        dataType = 2;
    } else if (chartType[0].equals("bvg")) {
        chart = createBarChart(PlotOrientation.VERTICAL);
        dataType = 2;
    } else if (chartType[0].equals("bhs3")) {
        chart = createStackedBarChart3D(PlotOrientation.HORIZONTAL);
        dataType = 2;
    } else if (chartType[0].equals("bhg3")) {
        chart = createBarChart3D(PlotOrientation.HORIZONTAL);
        dataType = 2;
    } else if (chartType[0].equals("bvs3")) {
        chart = createStackedBarChart3D(PlotOrientation.VERTICAL);
        dataType = 2;
    } else if (chartType[0].equals("bvg3")) {
        chart = createBarChart3D(PlotOrientation.VERTICAL);
        dataType = 2;
    }
    // scatter chart: 's'
    else if (chartType[0].equals("s")) {
        chart = createScatterChart();
        dataType = 4;
    } else if (chartType[0].equals("v")) {
        throw new RuntimeException("Venn diagrams not implemented.");
        // TODO: fix this.
    } else {
        throw new RuntimeException("Unknown chart type: " + chartType[0]);
    }

    chart.getPlot().setOutlineVisible(false);

    // *** CHART AXES ***
    List axes = new java.util.ArrayList();
    String[] axisStr = (String[]) params.get("chxt");
    if (axisStr != null) {
        if (chart.getPlot() instanceof XYPlot) {
            XYPlot plot = (XYPlot) chart.getPlot();
            processAxisStr(plot, axisStr[0], axes);
        } else if (chart.getPlot() instanceof CategoryPlot) {
            CategoryPlot plot = (CategoryPlot) chart.getPlot();
            if (plot.getOrientation() == PlotOrientation.VERTICAL) {
                processAxisStrV(plot, axisStr[0], axes);
            } else {
                processAxisStrH(plot, axisStr[0], axes);
            }
        }
    }

    // *** AXIS RANGES ***
    String[] axisRangeStr = (String[]) params.get("chxr");
    if (axisRangeStr != null) {
        String[] ranges = breakString(axisRangeStr[0], '|');
        for (int i = 0; i < ranges.length; i++) {
            int comma1 = ranges[i].indexOf(',');
            int comma2 = ranges[i].indexOf(',', comma1 + 1);
            int axisIndex = Integer.parseInt(ranges[i].substring(0, comma1));
            float lowerBound = Float.parseFloat(ranges[i].substring(comma1 + 1, comma2));
            float upperBound = Float.parseFloat(ranges[i].substring(comma2 + 1));
            Axis axis = (Axis) axes.get(axisIndex);
            if (axis instanceof GValueAxis) {
                GValueAxis gaxis = (GValueAxis) axis;
                gaxis.setLabelAxisStart(lowerBound);
                gaxis.setLabelAxisEnd(upperBound);
            }
        }
    }

    // *** AXIS LABELS ***
    String[] axisLabelStr = (String[]) params.get("chxl");
    if (axisLabelStr != null) {
        Pattern p = Pattern.compile("\\d+:\\|");
        Matcher m = p.matcher(axisLabelStr[0]);
        if (m.find()) {
            int keyStart = m.start();
            int labelStart = m.end();
            while (m.find(labelStart)) {
                String keyStr = axisLabelStr[0].substring(keyStart, labelStart - 2);
                int axisIndex = Integer.parseInt(keyStr);
                keyStart = m.start();
                String labelStr = axisLabelStr[0].substring(labelStart, keyStart - 1);
                String[] labels = breakString(labelStr, '|');
                GLabelledAxis axis = (GLabelledAxis) axes.get(axisIndex);
                axis.setTickLabels(Arrays.asList(labels));
                labelStart = m.end();
            }
            // process the final item
            String keyStr = axisLabelStr[0].substring(keyStart, labelStart - 2);
            String labelStr = axisLabelStr[0].substring(labelStart);
            int axisIndex = Integer.parseInt(keyStr);
            if (labelStr.endsWith("|")) {
                labelStr = labelStr.substring(0, labelStr.length() - 1);
            }
            String[] labels = breakString(labelStr, '|');
            GLabelledAxis axis = (GLabelledAxis) axes.get(axisIndex);
            axis.setTickLabels(Arrays.asList(labels));

        } else {
            throw new RuntimeException("No matching pattern!");
        }

    }

    // ** EXPLICIT AXIS LABEL POSITIONS
    String[] axisPositionStr = (String[]) params.get("chxp");
    if (axisPositionStr != null) {
        String[] positions = breakString(axisPositionStr[0], '|');
        for (int i = 0; i < positions.length; i++) {
            int c1 = positions[i].indexOf(',');
            int axisIndex = Integer.parseInt(positions[i].substring(0, c1));
            String remainingStr = positions[i].substring(c1 + 1);
            String[] valueStr = breakString(remainingStr, ',');
            List tickValues = new java.util.ArrayList(valueStr.length);
            Axis axis = (Axis) axes.get(axisIndex);
            if (axis instanceof GValueAxis) {
                GValueAxis gaxis = (GValueAxis) axes.get(axisIndex);
                for (int j = 0; j < valueStr.length; j++) {
                    float pos = Float.parseFloat(valueStr[j]);
                    tickValues.add(new Float(pos));
                }
                gaxis.setTickLabelPositions(tickValues);
            }
            // FIXME: what about a CategoryAxis?
        }
    }

    // *** CHART TITLE ***
    String[] titleStr = (String[]) params.get("chtt");
    if (titleStr != null) {
        // process the title
        String[] s = breakString(titleStr[0], '|');
        for (int i = 0; i < s.length; i++) {
            TextTitle t = new TextTitle(s[i].replace('+', ' '));
            t.setPaint(Color.darkGray);
            // Google seems to use 14pt fonts for titles and 12pt fonts for
            // all other text. Make sure this relationship remains.
            t.setFont(font.deriveFont(font.getSize2D() * 14f / 12f));
            chart.addSubtitle(t);
        }
        // and the font and colour
        String[] fontStr = (String[]) params.get("chts");
        if (fontStr != null) {
            int c1 = fontStr[0].indexOf(',');
            String colorStr = null;
            String fontSizeStr = null;
            if (c1 != -1) {
                colorStr = fontStr[0].substring(0, c1);
                fontSizeStr = fontStr[0].substring(c1 + 1);
            } else {
                colorStr = fontStr[0];
            }
            Color color = parseColor(colorStr);
            int size = 12;
            if (fontSizeStr != null) {
                size = Integer.parseInt(fontSizeStr);
            }
            for (int i = 0; i < chart.getSubtitleCount(); i++) {
                Title t = chart.getSubtitle(i);
                if (t instanceof TextTitle) {
                    TextTitle tt = (TextTitle) t;
                    tt.setPaint(color);
                    tt.setFont(font.deriveFont((float) size));
                }
            }
        }
    }

    // *** CHART DATA ***
    String[] dataStr = (String[]) params.get("chd");
    String scalingStr = null;
    if (dataStr.length > 0 && dataStr[0].startsWith("t:")) {
        // Only look at chds when text encoding is used
        String[] chds = (String[]) params.get("chds");
        if (chds != null && chds.length > 0) {
            scalingStr = chds[0];
        }
    }

    // we'll also process an optional second dataset that is provided as
    // an Eastwood extension...this isn't part of the Google Chart API
    String[] d2Str = (String[]) params.get("ewd2");

    // 'p' and 'p3' - create PieDataset
    if (dataType == 0) {
        PieDataset dataset = DataUtilities.parsePieDataset(dataStr[0], scalingStr);
        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setDataset(dataset);

        // ignore d2Str as there is currently no need for a second pie
        // dataset.
    }

    // 'lc' - create XYDataset
    else if (dataType == 1) {
        XYPlot plot = (XYPlot) chart.getPlot();
        XYDataset dataset = DataUtilities.parseXYDataset(dataStr[0], scalingStr);
        plot.setDataset(dataset);

        if (d2Str != null) { // an Eastwood extension
            XYDataset d2 = DataUtilities.parseXYDataset(d2Str[0], scalingStr);
            plot.setDataset(1, d2);
        }
    }

    // 'bhs', 'bhg', 'bvs', 'bvg'
    else if (dataType == 2) {
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        CategoryDataset dataset = DataUtilities.parseCategoryDataset(dataStr[0], scalingStr);
        plot.setDataset(dataset);

        if (d2Str != null) { // an Eastwood extension
            CategoryDataset d2 = DataUtilities.parseCategoryDataset(d2Str[0], scalingStr);
            plot.setDataset(1, d2);
        }
    }

    // 'lxy'
    else if (dataType == 3) {
        XYPlot plot = (XYPlot) chart.getPlot();
        XYDataset dataset = DataUtilities.parseXYDataset2(dataStr[0], scalingStr);
        plot.setDataset(dataset);

        if (d2Str != null) { // an Eastwood extension
            XYDataset d2 = DataUtilities.parseXYDataset2(d2Str[0], scalingStr);
            plot.setDataset(1, d2);
        }
    } else if (dataType == 4) {
        XYPlot plot = (XYPlot) chart.getPlot();
        XYSeriesCollection dataset = DataUtilities.parseScatterDataset(dataStr[0], scalingStr);
        if (dataset.getSeriesCount() > 1) {
            dataset.removeSeries(1);
        }
        plot.setDataset(dataset);
        if (d2Str != null) { // an Eastwood extension
            XYDataset d2 = DataUtilities.parseXYDataset2(d2Str[0], scalingStr);
            plot.setDataset(1, d2);
        }
    }

    if (chart.getPlot() instanceof XYPlot) {
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.getDomainAxis().setLabelFont(font);
        plot.getDomainAxis().setTickLabelFont(font);
        plot.getRangeAxis().setLabelFont(font);
        plot.getRangeAxis().setTickLabelFont(font);
    } else if (chart.getPlot() instanceof CategoryPlot) {
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.getDomainAxis().setLabelFont(font);
        plot.getDomainAxis().setTickLabelFont(font);
        plot.getRangeAxis().setLabelFont(font);
        plot.getRangeAxis().setTickLabelFont(font);
    }

    // *** CHART COLOURS ***
    String[] colorStr = (String[]) params.get("chco");
    if (colorStr != null) {
        Color[] colors = parseColors(colorStr[0]);
        if (dataType == 0) {
            PiePlot plot = (PiePlot) chart.getPlot();
            applyColorsToPiePlot(plot, colors);
        } else {
            AbstractRenderer renderer = null;
            if (chart.getPlot() instanceof CategoryPlot) {
                CategoryPlot plot = (CategoryPlot) chart.getPlot();
                renderer = (AbstractRenderer) plot.getRenderer();
                renderer.setBasePaint(colors[0]);
            } else if (chart.getPlot() instanceof XYPlot) {
                XYPlot plot = (XYPlot) chart.getPlot();
                renderer = (AbstractRenderer) plot.getRenderer();
                renderer.setBasePaint(colors[colors.length - 1]);
            }
            for (int i = 0; i < colors.length; i++) {
                renderer.setSeriesPaint(i, colors[i]);
            }
        }
    } else {
        Plot plot = chart.getPlot();
        if (plot instanceof PiePlot) {
            applyColorsToPiePlot((PiePlot) chart.getPlot(), new Color[] { new Color(255, 153, 0) });
        }
    }

    // *** CHART LINE STYLES ***
    String[] lineStr = (String[]) params.get("chls");
    if (lineStr != null && chart.getPlot() instanceof XYPlot) {
        Stroke[] strokes = parseLineStyles(lineStr[0]);
        XYPlot plot = (XYPlot) chart.getPlot();
        XYItemRenderer renderer = plot.getRenderer();
        for (int i = 0; i < strokes.length; i++) {
            renderer.setSeriesStroke(i, strokes[i]);
        }
        renderer.setBaseStroke(strokes[strokes.length - 1]);
    }

    // *** CHART GRID LINES
    if (dataType != 0) {
        String[] gridStr = (String[]) params.get("chg");
        if (gridStr != null) {
            processGridLinesSpec(gridStr[0], chart);
        }
    }

    // *** CHART LABELS
    if (dataType == 0) { // pie chart
        String[] labelStr = (String[]) params.get("chl");
        if (labelStr != null) {
            String[] s = breakString(labelStr[0], '|');
            List labels = Arrays.asList(s);
            PiePlot plot = (PiePlot) chart.getPlot();
            if (labels.size() > 0) {
                plot.setLabelGenerator(new GPieSectionLabelGenerator(labels));
                plot.setLabelFont(font);
                plot.setLabelPaint(Color.darkGray);
            }
        }
    }

    String[] legendStr = (String[]) params.get("chdl");
    if (legendStr != null) {
        // process the title
        String[] s = breakString(legendStr[0], '|');
        List labels = Arrays.asList(s);
        if (labels.size() > 0) {
            Plot p = chart.getPlot();
            if (p instanceof CategoryPlot) {
                CategoryPlot plot = (CategoryPlot) chart.getPlot();
                BarRenderer renderer = (BarRenderer) plot.getRenderer();
                renderer.setLegendItemLabelGenerator(new GSeriesLabelGenerator(labels));
                renderer.setBaseSeriesVisibleInLegend(false);
                for (int i = 0; i < labels.size(); i++) {
                    renderer.setSeriesVisibleInLegend(i, Boolean.TRUE);
                }
            } else if (p instanceof XYPlot) {
                XYPlot plot = (XYPlot) chart.getPlot();
                XYItemRenderer renderer = plot.getRenderer();
                renderer.setLegendItemLabelGenerator(new GSeriesLabelGenerator(labels));
                renderer.setBaseSeriesVisibleInLegend(false);
                for (int i = 0; i < labels.size(); i++) {
                    renderer.setSeriesVisibleInLegend(i, Boolean.TRUE);
                }
            } else if (p instanceof PiePlot) {
                PiePlot plot = (PiePlot) chart.getPlot();
                plot.setLegendLabelGenerator(new GPieSectionLabelGenerator(labels));
            }

            LegendTitle legend = new LegendTitle(chart.getPlot());
            RectangleEdge pos = RectangleEdge.RIGHT;
            String[] chdlp = (String[]) params.get("chdlp");
            if (chdlp != null) {
                if ("b".equals(chdlp[0])) {
                    pos = RectangleEdge.BOTTOM;
                } else if ("t".equals(chdlp[0])) {
                    pos = RectangleEdge.TOP;
                } else if ("l".equals(chdlp[0])) {
                    pos = RectangleEdge.LEFT;
                }
            }
            legend.setPosition(pos);
            legend.setItemFont(font);
            legend.setItemPaint(Color.darkGray);
            chart.addSubtitle(legend);
        }
    }

    // *** CHART MARKERS ***
    String[] markerStr = (String[]) params.get("chm");
    if (markerStr != null) {
        String[] markers = breakString(markerStr[0], '|');
        for (int i = 0; i < markers.length; i++) {
            addMarker(markers[i], chart);
        }
    }

    // *** CHART FILL ***/
    String[] fillStr = (String[]) params.get("chf");
    if (fillStr != null) {
        // process the 1 or 2 fill specs
        int i = fillStr[0].indexOf('|');
        if (i == -1) {
            processFillSpec(fillStr[0], chart);
        } else {
            String fs1 = fillStr[0].substring(0, i);
            String fs2 = fillStr[0].substring(i + 1);
            processFillSpec(fs1, chart);
            processFillSpec(fs2, chart);
        }
    }

    // process the 'ewtr' tag, if present
    processEWTR(params, chart);

    return chart;

}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView.java

@Override
public void refreshView(final ViewState state) {
    Rectangle visibleRect = null;
    if (this.tree != null) {
        visibleRect = this.tree.getVisibleRect();
    }/*from   w  ww  .j a  v  a2  s .co m*/

    this.removeAll();

    this.actionsMenu = this.createPopupMenu(state);

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("WORKFLOWS");
    for (ModelGraph graph : state.getGraphs()) {
        root.add(this.buildTree(graph, state));
    }
    tree = new JTree(root);
    tree.setShowsRootHandles(true);
    tree.setRootVisible(false);
    tree.add(this.actionsMenu);

    if (state.getSelected() != null) {
        // System.out.println("SELECTED: " + state.getSelected());
        TreePath treePath = this.getTreePath(root, state.getSelected());
        if (state.getCurrentMetGroup() != null) {
            treePath = this.getTreePath(treePath, state);
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_STATIC_METADATA))) {
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("static-metadata")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_PRECONDITIONS))) {
            if (treePath == null) {
                treePath = this.getTreePath(root, state.getSelected().getPreConditions());
            }
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("pre-conditions")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_POSTCONDITIONS))) {
            if (treePath == null) {
                treePath = this.getTreePath(root, state.getSelected().getPostConditions());
            }
            DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
            for (int i = 0; i < baseNode.getChildCount(); i++) {
                if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject()
                        .equals("post-conditions")) {
                    treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath());
                    break;
                }
            }
        }
        this.tree.expandPath(treePath);
        this.tree.setSelectionPath(treePath);
    }

    tree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            if (e.getPath().getLastPathComponent() instanceof DefaultMutableTreeNode) {
                DefaultTreeView.this.resetProperties(state);
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
                if (node.getUserObject() instanceof ModelGraph) {
                    state.setSelected((ModelGraph) node.getUserObject());
                    state.setCurrentMetGroup(null);
                    DefaultTreeView.this.notifyListeners();
                } else if (node.getUserObject().equals("static-metadata")
                        || node.getUserObject().equals("pre-conditions")
                        || node.getUserObject().equals("post-conditions")) {
                    state.setSelected((ModelGraph) ((DefaultMutableTreeNode) node.getParent()).getUserObject());
                    state.setCurrentMetGroup(null);
                    state.setProperty(EXPAND_STATIC_METADATA,
                            Boolean.toString(node.getUserObject().equals("static-metadata")));
                    state.setProperty(EXPAND_PRECONDITIONS,
                            Boolean.toString(node.getUserObject().equals("pre-conditions")));
                    state.setProperty(EXPAND_POSTCONDITIONS,
                            Boolean.toString(node.getUserObject().equals("post-conditions")));
                    DefaultTreeView.this.notifyListeners();
                } else if (node.getUserObject() instanceof ConcurrentHashMap) {
                    DefaultMutableTreeNode metNode = null;
                    String group = null;
                    Object[] path = e.getPath().getPath();
                    for (int i = path.length - 1; i >= 0; i--) {
                        if (((DefaultMutableTreeNode) path[i]).getUserObject() instanceof ModelGraph) {
                            metNode = (DefaultMutableTreeNode) path[i];
                            break;
                        } else if (((DefaultMutableTreeNode) path[i])
                                .getUserObject() instanceof ConcurrentHashMap) {
                            if (group == null) {
                                group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i])
                                        .getUserObject()).keySet().iterator().next();
                            } else {
                                group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i])
                                        .getUserObject()).keySet().iterator().next() + "/" + group;
                            }
                        }
                    }
                    ModelGraph graph = (ModelGraph) metNode.getUserObject();
                    state.setSelected(graph);
                    state.setCurrentMetGroup(group);
                    DefaultTreeView.this.notifyListeners();
                } else {
                    state.setSelected(null);
                    DefaultTreeView.this.notifyListeners();
                }
            }
        }

    });
    tree.setCellRenderer(new TreeCellRenderer() {

        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            if (node.getUserObject() instanceof String) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                JLabel label = new JLabel((String) node.getUserObject());
                label.setForeground(Color.blue);
                panel.add(label, BorderLayout.CENTER);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else if (node.getUserObject() instanceof ModelGraph) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                JLabel iconLabel = new JLabel(
                        ((ModelGraph) node.getUserObject()).getModel().getExecutionType() + ": ");
                iconLabel.setForeground(((ModelGraph) node.getUserObject()).getModel().getColor());
                iconLabel.setBackground(Color.white);
                JLabel idLabel = new JLabel(((ModelGraph) node.getUserObject()).getModel().getModelName());
                idLabel.setBackground(Color.white);
                panel.add(iconLabel, BorderLayout.WEST);
                panel.add(idLabel, BorderLayout.CENTER);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else if (node.getUserObject() instanceof ConcurrentHashMap) {
                JPanel panel = new JPanel();
                panel.setLayout(new BorderLayout());
                String group = (String) ((ConcurrentHashMap<String, String>) node.getUserObject()).keySet()
                        .iterator().next();
                JLabel nameLabel = new JLabel(group + " : ");
                nameLabel.setForeground(Color.blue);
                nameLabel.setBackground(Color.white);
                JLabel valueLabel = new JLabel(
                        ((ConcurrentHashMap<String, String>) node.getUserObject()).get(group));
                valueLabel.setForeground(Color.darkGray);
                valueLabel.setBackground(Color.white);
                panel.add(nameLabel, BorderLayout.WEST);
                panel.add(valueLabel, BorderLayout.EAST);
                panel.setBackground(selected ? Color.lightGray : Color.white);
                return panel;
            } else {
                return new JLabel();
            }
        }

    });
    tree.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3 && DefaultTreeView.this.tree.getSelectionPath() != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) DefaultTreeView.this.tree
                        .getSelectionPath().getLastPathComponent();
                if (node.getUserObject() instanceof String && !(node.getUserObject().equals("pre-conditions")
                        || node.getUserObject().equals("post-conditions"))) {
                    return;
                }
                orderSubMenu.setEnabled(node.getUserObject() instanceof ModelGraph
                        && !((ModelGraph) node.getUserObject()).isCondition()
                        && ((ModelGraph) node.getUserObject()).getParent() != null);
                DefaultTreeView.this.actionsMenu.show(DefaultTreeView.this.tree, e.getX(), e.getY());
            }
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });
    this.scrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    this.add(this.scrollPane, BorderLayout.CENTER);
    if (visibleRect != null) {
        this.tree.scrollRectToVisible(visibleRect);
    }

    this.revalidate();
}

From source file:base.BasePlayer.AminoTable.java

void drawScreen(Graphics g) {
    if (!isEnabled()) {
        return;//from  w w w  .  j  a v  a2 s. co  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:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates a line chart./*from  w  ww  .  j  a v  a  2s  . c  o  m*/
 * 
 * @param title
 * @param categoryAxisLabel
 *            (X-Axis label)
 * @param valueAxisLabel
 *            (Y-Axis label)
 * @param dataset
 * @param includeZero
 *            True when zero shall be included to the axis range.
 * @return JfreeChart instance.
 */
public JFreeChart createXYLineSplineChart(String title, String categoryAxisLabel, String valueAxisLabel,
        XYDataset dataset, boolean includeZero, boolean drawShapes) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            this.orientation, this.drawLegend, false, false);
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundAlpha(0.4f);
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.025);
    domainAxis.setUpperMargin(0.025);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(includeZero);
    plot.setRenderer(new XYSplineRenderer(100));
    XYSplineRenderer renderer = (XYSplineRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.green);
    renderer.setSeriesPaint(3, Color.darkGray);
    renderer.setSeriesPaint(4, Color.yellow);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseShapesVisible(drawShapes);
    renderer.setBaseShapesFilled(true);
    return chart;
}