Example usage for java.awt Color gray

List of usage examples for java.awt Color gray

Introduction

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

Prototype

Color gray

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

Click Source Link

Document

The color gray.

Usage

From source file:mil.tatrc.physiology.utilities.csv.plots.ActionEventPlotter.java

public void createGraph(PlotJob job, List<List<Double>> timeData, List<List<Double>> data,
        List<LogEvent> events, List<SEAction> actions) {
    CSVPlotTool plotTool = new CSVPlotTool(); //to leverage existing functions
    String title = job.name + "_";
    XYSeriesCollection dataSet = new XYSeriesCollection();
    double maxY = 0;
    double minY = Double.MAX_VALUE;
    for (int i = 0; i < timeData.size(); i++) {
        if (timeData.get(i) == null || data.get(i) == null) {
            job.bgColor = Color.white; //This hits when we have Expected data but NOT computed data
            continue;
        }/* ww w .java 2  s  .  c om*/

        title = title + job.headers.get(i) + "_";
        XYSeries dataSeries;
        if (job.isComparePlot) {
            if (timeData.size() > 1)
                dataSeries = plotTool.createXYSeries(i == 0 ? "Expected" : "Computed", timeData.get(i),
                        data.get(i));
            else //If we're comparing but only have one data list, expected is missing, so rename to computed
            {
                dataSeries = plotTool.createXYSeries("Computed", timeData.get(i), data.get(i));
            }
        } else
            dataSeries = plotTool.createXYSeries(job.headers.get(i), timeData.get(i), data.get(i));
        dataSet.addSeries(dataSeries);
        maxY = maxY < dataSeries.getMaxY() ? dataSeries.getMaxY() : maxY;
        minY = minY > dataSeries.getMinY() ? dataSeries.getMinY() : minY;
    }
    title = title + "vs_Time_Action_Event_Plot";

    //Override the constructed title if desired (usually for compare plots)
    if (job.titleOverride != null && !job.titleOverride.isEmpty()
            && !job.titleOverride.equalsIgnoreCase("None"))
        title = job.titleOverride;

    double rangeLength = maxY - minY;
    if (Math.abs(rangeLength) < 1e-6) {
        rangeLength = .01;
    }

    class AEEntry implements Comparable<AEEntry> {
        public String name;
        public List<Double> times = new ArrayList<Double>();
        public List<Double> YVals = new ArrayList<Double>();
        public String type = "";

        public int compareTo(AEEntry entry) {
            return times.get(0) < entry.times.get(0) ? -1 : times.get(0) > entry.times.get(0) ? 1 : 0;
        }
    }

    List<AEEntry> allActionsAndEvents = new ArrayList<AEEntry>();

    if (!job.skipAllEvents) {
        //Make points for each event
        //Treat each event like two points on the same vertical line
        for (LogEvent event : events) {
            boolean skip = false;

            for (String eventToSkip : job.eventOmissions) {
                if (event.text.contains(eventToSkip))
                    skip = true;
            }
            if (skip)
                continue;
            AEEntry entry = new AEEntry();

            entry.times.add(event.time.getValue());
            if (job.logAxis)
                entry.YVals.add(maxY);
            else if (job.forceZeroYAxisBound && maxY < 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(maxY + 0.15 * rangeLength);

            entry.times.add(event.time.getValue());
            if (job.logAxis)
                entry.YVals.add(minY);
            else if (job.forceZeroYAxisBound && minY > 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(minY - 0.15 * rangeLength);

            entry.name = event.text + "\r\nt=" + event.time.getValue();
            entry.type = "EVENT:";

            allActionsAndEvents.add(entry);
        }
    }

    if (!job.skipAllActions) {
        //Make similar entries for actions
        for (SEAction action : actions) {
            boolean skip = false;

            for (String actionToSkip : job.actionOmissions) {
                if (action.toString().contains(actionToSkip))
                    skip = true;
            }
            if (skip)
                continue;

            if (action.toString().contains("Advance Time"))
                continue;

            AEEntry entry = new AEEntry();

            entry.times.add(action.getScenarioTime().getValue());
            if (job.logAxis)
                entry.YVals.add(maxY);
            else if (job.forceZeroYAxisBound && maxY < 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(maxY + 0.15 * rangeLength);

            entry.times.add(action.getScenarioTime().getValue());
            if (job.logAxis)
                entry.YVals.add(minY);
            else if (job.forceZeroYAxisBound && minY > 0)
                entry.YVals.add(-.01);
            else
                entry.YVals.add(minY - 0.15 * rangeLength);

            entry.name = action.toString() + "\r\nt=" + action.getScenarioTime().getValue();
            entry.type = "ACTION:";

            allActionsAndEvents.add(entry);
        }
    }

    //Sort the list
    Collections.sort(allActionsAndEvents);

    //Add a series for each entry
    for (AEEntry entry : allActionsAndEvents) {
        dataSet.addSeries(plotTool.createXYSeries(entry.type + entry.name, entry.times, entry.YVals));
    }

    //If we have experimental data, try to load it and create a dataset for it
    XYSeriesCollection expDataSet = new XYSeriesCollection();
    if (job.experimentalData != null && !job.experimentalData.isEmpty()) {
        Map<String, List<Double>> expData = new HashMap<String, List<Double>>();
        List<String> expHeaders = new ArrayList<String>();

        try {
            CSVContents csv = new CSVContents(job.experimentalData);
            csv.abbreviateContents = 0;
            csv.readAll(expData);
            expHeaders = csv.getHeaders();
        } catch (Exception e) {
            Log.error("Unable to read experimental data");
        }

        if (!expData.isEmpty() && !expHeaders.isEmpty()) {
            List<Double> expTimeData = new ArrayList<Double>();
            expTimeData = expData.get("Time(s)");

            for (String h : expHeaders) //Will assume all headers from exp file will be on same Y axis vs time
            {
                if (h.equalsIgnoreCase("Time(s)"))
                    continue;

                expDataSet.addSeries(plotTool.createXYSeries("Experimental " + h, expTimeData, expData.get(h)));
            }
        }
    }

    //set labels
    String XAxisLabel = "Time(s)";
    String YAxisLabel = job.headers.get(0);

    JFreeChart chart = ChartFactory.createXYLineChart(
            job.titleOverride != null && job.titleOverride.equalsIgnoreCase("None") ? "" : title, // chart title
            XAxisLabel, // x axis label
            YAxisLabel, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    Log.info("Creating Graph " + title);
    XYPlot plot = (XYPlot) chart.getPlot();

    if (!job.logAxis) {
        // Determine Y range
        double resMax0 = maxY;
        double resMin0 = minY;
        if (Double.isNaN(resMax0) || Double.isNaN(resMin0))
            plot.getDomainAxis().setLabel("Range is NaN");
        if (DoubleUtils.isZero(resMin0))
            resMin0 = -0.000001;
        if (DoubleUtils.isZero(resMax0))
            resMax0 = 0.000001;
        if (job.forceZeroYAxisBound && resMin0 >= 0)
            resMin0 = -.000001;
        if (job.forceZeroYAxisBound && resMax0 <= 0)
            resMax0 = .000001;
        rangeLength = resMax0 - resMin0;
        ValueAxis yAxis = plot.getRangeAxis();
        if (rangeLength != 0)
            yAxis.setRange(resMin0 - 0.15 * rangeLength, resMax0 + 0.15 * rangeLength);//15% buffer so we can see top and bottom clearly           

        //Add another Y axis to the right side for easier reading
        ValueAxis rightYAxis = new NumberAxis();
        rightYAxis.setRange(yAxis.getRange());
        rightYAxis.setLabel("");

        //Override the bounds if desired
        try {
            if (job.Y1LowerBound != null) {
                yAxis.setLowerBound(job.Y1LowerBound);
                rightYAxis.setLowerBound(job.Y1LowerBound);
            }
            if (job.Y1UpperBound != null) {
                yAxis.setUpperBound(job.Y1UpperBound);
                rightYAxis.setUpperBound(job.Y1UpperBound);
            }
        } catch (Exception e) {
            Log.error(
                    "Couldn't set Y bounds. You probably tried to set a bound on an axis that doesn't exist.");
        }
        plot.setRangeAxis(0, yAxis);
        plot.setRangeAxis(1, rightYAxis);

    } else {
        double resMin = minY;
        double resMax = maxY;
        if (resMin <= 0.0)
            resMin = .00001;
        LogarithmicAxis yAxis = new LogarithmicAxis("Log(" + YAxisLabel + ")");
        LogarithmicAxis rightYAxis = new LogarithmicAxis("");
        yAxis.setLowerBound(resMin);
        rightYAxis.setLowerBound(resMin);
        yAxis.setUpperBound(resMax);
        rightYAxis.setUpperBound(resMax);

        //Override the bounds if desired
        try {
            if (job.Y1LowerBound != null) {
                yAxis.setLowerBound(job.Y1LowerBound);
                rightYAxis.setLowerBound(job.Y1LowerBound);
            }
            if (job.Y1UpperBound != null) {
                yAxis.setUpperBound(job.Y1UpperBound);
                rightYAxis.setUpperBound(job.Y1UpperBound);
            }
        } catch (Exception e) {
            Log.error(
                    "Couldn't set Y bounds. You probably tried to set a bound on an axis that doesn't exist.");
        }
        plot.setRangeAxis(0, yAxis);
        plot.setRangeAxis(1, rightYAxis);
    }

    //Override X bounds if desired
    try {
        if (job.X1LowerBound != null)
            plot.getDomainAxis(0).setLowerBound(job.X1LowerBound);
        if (job.X1UpperBound != null)
            plot.getDomainAxis(0).setUpperBound(job.X1UpperBound);
    } catch (Exception e) {
        Log.error("Couldn't set X bounds. You probably tried to set a bound on an axis that doesn't exist.");
    }

    //Override labels if desired
    if (job.X1Label != null && !plot.getDomainAxis(0).getLabel().contains("NaN"))
        plot.getDomainAxis(0).setLabel(job.X1Label.equalsIgnoreCase("None") ? "" : job.X1Label);
    if (job.Y1Label != null)
        plot.getRangeAxis(0).setLabel(job.Y1Label.equalsIgnoreCase("None") ? "" : job.Y1Label);

    //If we have experimental data, set up the renderer for it and add to plot
    if (expDataSet.getSeriesCount() != 0) {
        XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true); // Shapes only
        renderer1.setSeriesShape(0, ShapeUtilities.createDiamond(8));
        plot.setDataset(1, expDataSet);
        plot.setRenderer(1, renderer1);
        plot.mapDatasetToDomainAxis(1, 0);
        plot.mapDatasetToRangeAxis(1, 0);
    }

    formatAEPlot(job, chart);
    plot.setDomainGridlinesVisible(job.showGridLines);
    plot.setRangeGridlinesVisible(job.showGridLines);

    //Changing line widths and colors
    XYItemRenderer r = plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(2.0f);
    Color[] AEcolors = { Color.red, Color.green, Color.black, Color.magenta, Color.orange };
    Color[] dataColors = { Color.blue, Color.cyan, Color.gray, Color.black, Color.red };
    for (int i = 0, cIndex = 0; i < dataSet.getSeriesCount(); i++, cIndex++) {
        r.setSeriesStroke(i, wideLine);
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
        renderer.setBaseShapesVisible(false);
        if (cIndex > 4)
            cIndex = 0;
        if (i < job.headers.size()) //Our actual data
        {
            renderer.setSeriesFillPaint(i, dataColors[cIndex]);
            renderer.setSeriesPaint(i, dataColors[cIndex]);
        } else //actions and events in procession of other colors
        {
            renderer.setSeriesFillPaint(i, AEcolors[cIndex]);
            renderer.setSeriesPaint(i, AEcolors[cIndex]);
        }
    }
    //Special color and format changes for compare plots
    if (job.isComparePlot) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

        for (int i = 0; i < dataSet.getSeriesCount(); i++) {
            if (dataSet.getSeries(i).getKey().toString().equalsIgnoreCase("Expected")) {
                renderer.setSeriesStroke(//makes a dashed line
                        i, //argument below float[]{I,K} -> alternates between solid and opaque (solid for I, opaque for K)
                        new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                                new float[] { 15.0f, 30.0f }, 0.0f));
                renderer.setDrawSeriesLineAsPath(true);
                renderer.setUseFillPaint(true);
                renderer.setBaseShapesVisible(false);
                renderer.setSeriesFillPaint(i, Color.black);
                renderer.setSeriesPaint(i, Color.black);
            }
            if (dataSet.getSeries(i).getKey().toString().equalsIgnoreCase("Computed")) {
                renderer.setSeriesFillPaint(i, Color.red);
                renderer.setSeriesPaint(i, Color.red);
            }
            if (dataSet.getSeries(i).getKey().toString().startsWith("ACTION")) {
                renderer.setSeriesFillPaint(i, Color.green);
                renderer.setSeriesPaint(i, Color.green);
            }
            if (dataSet.getSeries(i).getKey().toString().startsWith("EVENT")) {
                renderer.setSeriesFillPaint(i, Color.blue);
                renderer.setSeriesPaint(i, Color.blue);
            }
        }
    }

    //Split the auto-generated legend into two legends, one for data and one for actions and events
    LegendItemCollection originalLegendCollection = plot.getLegendItems();
    final LegendItemCollection dataLegendCollection = new LegendItemCollection();
    int i;
    for (i = 0; i < job.headers.size() && i < originalLegendCollection.getItemCount(); i++) {
        if (originalLegendCollection.get(i).getLabel().startsWith("ACTION")
                || originalLegendCollection.get(i).getLabel().startsWith("EVENT"))
            break;
        dataLegendCollection.add(originalLegendCollection.get(i));
    }
    final LegendItemCollection remainingLegendCollection = new LegendItemCollection();
    for (; i < originalLegendCollection.getItemCount(); i++) {
        remainingLegendCollection.add(originalLegendCollection.get(i));
    }
    chart.removeLegend();
    LegendItemSource source = new LegendItemSource() {
        LegendItemCollection lic = new LegendItemCollection();
        {
            lic.addAll(dataLegendCollection);
        }

        public LegendItemCollection getLegendItems() {
            return lic;
        }
    };
    LegendTitle dataLegend = new LegendTitle(source);
    dataLegend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    dataLegend.setBorder(2, 2, 2, 2);
    dataLegend.setBackgroundPaint(Color.white);
    dataLegend.setPosition(RectangleEdge.TOP);
    dataLegend.setItemFont(new Font("SansSerif", Font.PLAIN, 22));
    chart.addLegend(dataLegend);

    source = new LegendItemSource() {
        LegendItemCollection lic = new LegendItemCollection();
        {
            lic.addAll(remainingLegendCollection);
        }

        public LegendItemCollection getLegendItems() {
            return lic;
        }
    };
    LegendTitle actionEventsLegend = new LegendTitle(source);
    actionEventsLegend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    actionEventsLegend.setBorder(2, 2, 2, 2);
    actionEventsLegend.setBackgroundPaint(Color.white);
    actionEventsLegend.setPosition(RectangleEdge.BOTTOM);
    actionEventsLegend.setItemFont(new Font("SansSerif", Font.PLAIN, 22));
    if (!job.hideAELegend && !job.removeAllLegends)
        chart.addLegend(actionEventsLegend);

    if (job.removeAllLegends)
        chart.removeLegend();

    int verticalPixels = 800 + 170 * (allActionsAndEvents.size() / 5);

    //This is a little hacky, but if we want only the legend, just extend Plot() and remove the draw functionality so it makes a blank plot
    class legendPlot extends Plot {
        public void draw(Graphics2D arg0, Rectangle2D arg1, Point2D arg2, PlotState arg3,
                PlotRenderingInfo arg4) {

        }

        public String getPlotType() {
            return null;
        }
    }
    //Then add the legend to that and throw away the original plot
    if (job.legendOnly) {
        chart = new JFreeChart("", null, new legendPlot(), false);
        chart.addLegend(actionEventsLegend);
    }

    try {
        FileUtils.createDirectory(job.outputDir);
        String filename = job.outputFilename == null
                ? job.outputDir + "/" + plotTool.MakeFileName(title) + ".jpg"
                : job.outputDir + "/" + job.outputFilename;
        if (!filename.endsWith(".jpg"))
            filename = filename + ".jpg";
        File JPGFile = new File(filename);
        if (job.imageHeight != null && job.imageWidth != null)
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, job.imageWidth, job.imageHeight);
        else if (!job.hideAELegend && !job.removeAllLegends)
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, verticalPixels);
        else
            ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, 800);
    } catch (IOException e) {
        Log.error(e.getMessage());
    }
}

From source file:base.BasePlayer.BedCanvas.java

void drawSidebar() {

    buf.setColor(Draw.sidecolor.darker());
    buf.fillRect(0, 0, Main.sidebarWidth - 4, this.getHeight());
    //   buf.setColor(Draw.softColor);
    //   buf.fillRect(0, 0, Main.sidebarWidth, this.getHeight());
    buf.setColor(Color.black);/*from   w  ww .  ja v  a  2  s  . c om*/

    if (bedTrack.size() > 0) {
        //   buf.setStroke(Draw.doubleStroke);
        overlapping = false;
        for (int i = 0; i < bedTrack.size(); i++) {
            if (!buf.getColor().equals(Color.black)) {
                buf.setColor(Color.black);
            }
            if (i == 0) {
                trackstart = Main.defaultFontSize;
                trackheight = (int) (trackDivider.get(i) * this.getHeight());
            } else {

                trackstart = Main.defaultFontSize + (int) (trackDivider.get(i - 1) * this.getHeight());
                trackheight = (int) (trackDivider.get(i) * this.getHeight())
                        - (int) (trackDivider.get(i - 1) * this.getHeight());
            }

            if (bedTrack.get(i).file != null) {

                buf.drawString(bedTrack.get(i).file.getName(), 10, trackstart);
            } else {

                buf.drawString(FilenameUtils.getName(bedTrack.get(i).url.getFile()), 10, trackstart);
            }

            if (trackheight > Main.defaultFontSize + Main.defaultFontSize
                    + (int) (Main.defaultFontSize * 1.4)) {

                if ((int) bedTrack.get(i).playbox.y != trackstart + Main.defaultFontSize) {

                    bedTrack.get(i).playbox.setBounds(10, trackstart + Main.defaultFontSize,
                            (int) (Main.defaultFontSize * 1.4), (int) (Main.defaultFontSize * 1.4));
                    bedTrack.get(i).playTriangle.reset();
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x + (Main.defaultFontSize / 5),
                            bedTrack.get(i).playbox.y + (Main.defaultFontSize / 5));
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x + (Main.defaultFontSize / 5), bedTrack.get(i).playbox.y
                                    + (bedTrack.get(i).playbox.width - (Main.defaultFontSize / 5)));
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x
                                    + (bedTrack.get(i).playbox.width - (Main.defaultFontSize / 5)),
                            bedTrack.get(i).playbox.y + bedTrack.get(i).playbox.height / 2);
                    bedTrack.get(i).graphBox.setBounds(
                            bedTrack.get(i).playbox.x + (int) (Main.defaultFontSize * 1.4)
                                    + Main.defaultFontSize,
                            trackstart + Main.defaultFontSize, (int) (Main.defaultFontSize * 1.4),
                            (int) (Main.defaultFontSize * 1.4));
                    if (bedTrack.get(i).settingsButton == null) {
                        bedTrack.get(i).settingsButton = new Rectangle();
                    }
                    bedTrack.get(i).settingsButton.setBounds(
                            Main.sidebarWidth - (int) (this.remoBox.width * (1.8)) - 4,
                            trackstart - Main.defaultFontSize, (int) (this.remoBox.width * (1.5)) + 2,
                            (int) (this.remoBox.height * (1.5)));

                }
                if (bedTrack.get(i).settingsButton == null) {
                    bedTrack.get(i).settingsButton = new Rectangle();
                }
                if (bedTrack.get(i).settingsButton.y == 0
                        || bedTrack.get(i).settingsButton.x != Main.sidebarWidth
                                - (int) (this.remoBox.width * (1.8))
                        || bedTrack.get(i).settingsButton.width != (int) (this.remoBox.width * (1.5)) + 2) {
                    bedTrack.get(i).settingsButton.setBounds(
                            Main.sidebarWidth - (int) (this.remoBox.width * (1.8)),
                            trackstart - Main.defaultFontSize - 4, (int) (this.remoBox.width * (1.5)) + 2,
                            (int) (this.remoBox.height * (1.5)));

                }
                if (Main.varsamples > 0 || FileRead.caller) {
                    if (bedTrack.get(i).getCurrent() != null
                            || (!bedTrack.get(i).small || bedTrack.get(i).getZoomlevel() != null)) {
                        buf.setColor(Color.white);
                        buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x - 1,
                                bedTrack.get(i).playbox.getBounds().y - 1,
                                bedTrack.get(i).playbox.getBounds().width,
                                bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        buf.setColor(Color.gray);
                        buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x + 1,
                                bedTrack.get(i).playbox.getBounds().y + 1,
                                bedTrack.get(i).playbox.getBounds().width,
                                bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        if (sideMouseRect.intersects(bedTrack.get(i).playbox)) {
                            overlapping = true;
                            if (getCursor().getType() != Cursor.HAND_CURSOR) {
                                selectedPlay = i;
                                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                            }
                            buf.setColor(Color.white);
                            //   buf.drawRect(bedTrack.get(i).playbox.getBounds().x-1,bedTrack.get(i).playbox.getBounds().y-1,bedTrack.get(i).playbox.getBounds().width+1, bedTrack.get(i).playbox.getBounds().height+1);
                            buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x,
                                    bedTrack.get(i).playbox.getBounds().y,
                                    bedTrack.get(i).playbox.getBounds().width,
                                    bedTrack.get(i).playbox.getBounds().height, 2, 2);

                        } else {
                            buf.setColor(Draw.sidecolor);
                            buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x,
                                    bedTrack.get(i).playbox.getBounds().y,
                                    bedTrack.get(i).playbox.getBounds().width,
                                    bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        }
                        if (bedTrack.get(i).intersect) {
                            buf.setColor(Draw.greenColor);
                            buf.fillRect(bedTrack.get(i).playTriangle.getBounds().x,
                                    bedTrack.get(i).playTriangle.getBounds().y,
                                    bedTrack.get(i).playTriangle.getBounds().width,
                                    bedTrack.get(i).playTriangle.getBounds().height);
                        } else {
                            buf.setColor(Draw.redColor);
                            buf.fillPolygon(bedTrack.get(i).playTriangle);
                        }
                    }
                }

                if (bedTrack.get(i).hasvalues) {

                    if (bedTrack.get(i).getCurrent() != null || !bedTrack.get(i).small) {
                        buf.setColor(Color.lightGray);
                        buf.fillRect(bedTrack.get(i).graphBox.getBounds().x,
                                bedTrack.get(i).graphBox.getBounds().y,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height);
                        buf.setColor(Color.white);
                        buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x - 1,
                                bedTrack.get(i).graphBox.getBounds().y - 1,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        buf.setColor(Color.gray);
                        buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x + 1,
                                bedTrack.get(i).graphBox.getBounds().y + 1,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        if (sideMouseRect.intersects(bedTrack.get(i).graphBox)) {
                            overlapping = true;
                            if (getCursor().getType() != Cursor.HAND_CURSOR) {
                                selectedPlay = i;
                                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                            }
                            buf.setColor(Color.white);
                            //   buf.drawRect(bedTrack.get(i).graphBox.getBounds().x-1,bedTrack.get(i).graphBox.getBounds().y-1,bedTrack.get(i).graphBox.getBounds().width+1, bedTrack.get(i).graphBox.getBounds().height+1);
                            buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y,
                                    bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().height, 2, 2);

                        } else {
                            buf.setColor(Draw.sidecolor);
                            buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y,
                                    bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        }
                        if (bedTrack.get(i).graph) {
                            buf.setColor(Draw.greenColor);
                            buf.drawLine(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66));
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66),
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4);
                            buf.drawLine(
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);

                        } else {
                            buf.setColor(Draw.redColor);
                            buf.drawLine(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66));
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66),
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4);
                            buf.drawLine(
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);

                        }
                        /*if(sideMouseRect.intersects(bedTrack.get(i).graphBox)) {
                                   
                           overlapping = true;
                           selectedPlay = i;
                           if(getCursor().getType() != Cursor.HAND_CURSOR) {
                                      
                              setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                           }   
                           buf.setColor(Color.white);
                           buf.drawRect(bedTrack.get(i).graphBox.getBounds().x-1,bedTrack.get(i).graphBox.getBounds().y-1,bedTrack.get(i).graphBox.getBounds().width+1, bedTrack.get(i).graphBox.getBounds().height+1);
                                   
                        }*/
                    }
                }
            }
            if (trackheight > bedTrack.get(i).settingsButton.height) {
                /*if(this.sideMouseRect.intersects(bedTrack.get(i).settingsButton)) {                        
                   buf.setColor(Color.white);
                }
                else {         
                           
                }*/
                buf.setColor(Draw.sidecolor.darker());
                buf.fillRect(bedTrack.get(i).settingsButton.x, bedTrack.get(i).settingsButton.y,
                        bedTrack.get(i).settingsButton.width, bedTrack.get(i).settingsButton.height);
                buf.drawImage(Main.settingsIcon.getImage(),
                        Main.sidebarWidth - (int) (this.remoBox.width * (1.8)) - 4,
                        trackstart - Main.defaultFontSize, (int) (this.remoBox.width * (1.5)),
                        (int) (this.remoBox.height * (1.5)), this);
            }
        }

        if (!overlapping && !resizer) {

            if (getCursor().getType() != Cursor.DEFAULT_CURSOR) {

                selectedPlay = -1;
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        }
        if (sidebar) {
            buf.setColor(Color.black);

            if (sidebar && sideMouseRect.intersects(this.remoBox)) {
                //   buf.setStroke(Draw.doubleStroke);
                removeTrack = hoverIndex;
                buf.setColor(Color.white);
                buf.fillRect(this.remoBox.x - 2, this.remoBox.y - 1, this.remoBox.width + 2,
                        this.remoBox.height + 2);
            } else {
                removeTrack = -1;
                if (this.remoBox.getBounds().x != Main.sidebarWidth - (Main.defaultFontSize + 10) - 4
                        || this.remoBox.getBounds().y != (int) (trackDivider.get(hoverIndex) * this.getHeight())
                                - (Main.defaultFontSize + 6)) {
                    this.remoBox.setBounds(Main.sidebarWidth - (Main.defaultFontSize + 10) - 4,
                            (int) (trackDivider.get(hoverIndex) * this.getHeight())
                                    - (Main.defaultFontSize + 6),
                            Main.defaultFontSize + 3, Main.defaultFontSize + 3);
                }
                /*   if(this.remoBox.getBounds().y != (int)(trackDivider.get(hoverIndex)*this.getHeight())-11|| this.remoBox.getBounds().x != Main.sidebarWidth-11) {
                      this.remoBox.setBounds(Main.sidebarWidth-11, (int)(trackDivider.get(hoverIndex)*this.getHeight())-11, 8, 8);
                   }*/
            }

            buf.setColor(Color.black);
            buf.drawRect(this.remoBox.x, this.remoBox.y, this.remoBox.width, this.remoBox.height);
            buf.drawLine(this.remoBox.x, this.remoBox.y, this.remoBox.x + this.remoBox.width,
                    this.remoBox.y + (int) this.remoBox.getHeight());
            buf.drawLine(this.remoBox.x, this.remoBox.y + (int) this.remoBox.getHeight(),
                    this.remoBox.x + this.remoBox.width, this.remoBox.y);

        }
        buf.setStroke(Draw.doubleStroke);
        buf.setColor(Color.gray);
        buf.drawLine(Main.sidebarWidth - 5, 0, Main.sidebarWidth - 5, this.getHeight());
        buf.drawLine(1, 0, 1, this.getHeight());
        buf.setColor(Color.lightGray);
        buf.drawLine(3, 0, 3, this.getHeight());
        buf.drawLine(Main.sidebarWidth - 7, 0, Main.sidebarWidth - 7, this.getHeight());
        buf.setStroke(Draw.basicStroke);
    }

}

From source file:sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();/* w  w  w  .  j a  va 2 s. c om*/
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null)
                startMovie();
            else
                stopMovie();
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            if (newValue > MAXIMUM_SCALE)
                newValue = currentValue;
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();/*from   ww  w.  j av  a 2  s .co  m*/
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null) {
                startMovie();
            } else {
                stopMovie();
            }
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            if (newValue > MAXIMUM_SCALE) {
                newValue = currentValue;
            }
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

/**
Add max min bar. Mainly used to show precipitation that has max and min values
* @param timeBase/*from   w  w  w. j  av a2s  .c  o  m*/
* @param title
* @param maxMinTimeSeriesEnabler
* @param maxColor
* @param minColor 
*/
public void addMaxMinPercipitationBars(TimeBase timeBase, String title, NumberPhenomenon max,
        NumberPhenomenon min, Color maxColor, Color minColor) {

    XYDataset maxDataset = max.getTimeSeries(title, timeBase);
    XYDataset minDataset = min.getTimeSeries(title, timeBase);
    if (maxDataset.getSeriesCount() > 0 && minDataset.getSeriesCount() > 0 && maxDataset.getItemCount(0) > 0
            && minDataset.getItemCount(0) > 0) {

        double margin = 0.2;
        double maxPrecipitation = max.getMaxValue();

        addBarChart(minDataset, "min", minColor, margin, maxPrecipitation);
        showBarValuesOnBottom(plotIndex - 1, 1D);

        rangeAxisIndex--;

        addBarChart(maxDataset, "max", maxColor, margin, maxPrecipitation);
        showBarValuesOnTop(plotIndex - 1, 6D);

        plot.getRangeAxis(getRangeAxisIndex() - 1).setVisible(false);

        final Marker marker = new ValueMarker(0);
        marker.setPaint(Color.GRAY);
        marker.setStroke(new BasicStroke(1));
        plot.addRangeMarker(getRangeAxisIndex() - 1, marker, Layer.BACKGROUND);
    }
}

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * Initializes a new instance of the GraphPanel class.
 *//*www . j  a  v a  2s .  c  om*/
public GraphPanel() {

    subplotMap.put(ChartPlotOptions.GPS,
            new GraphPanelPlotLabels(rb.getString("chart.gps"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.RADIO,
            new GraphPanelPlotLabels(rb.getString("chart.radio"), createRadioPlot(), 2));
    subplotMap.put(ChartPlotOptions.BLUETOOTH,
            new GraphPanelPlotLabels(rb.getString("chart.bluetooth"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.CAMERA,
            new GraphPanelPlotLabels(rb.getString("chart.camera"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.SCREEN,
            new GraphPanelPlotLabels(rb.getString("chart.screen"), createBarPlot(new Color(34, 177, 76)), 1));
    subplotMap.put(ChartPlotOptions.BATTERY,
            new GraphPanelPlotLabels(rb.getString("chart.battery"), createBatteryPlot(), 2));
    subplotMap.put(ChartPlotOptions.WAKELOCK,
            new GraphPanelPlotLabels(rb.getString("chart.wakelock"), createWakelockStatePlot(), 1));
    subplotMap.put(ChartPlotOptions.WIFI,
            new GraphPanelPlotLabels(rb.getString("chart.wifi"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.ALARM,
            new GraphPanelPlotLabels(rb.getString("chart.alarm"), createAlarmPlot(), 2));
    subplotMap.put(ChartPlotOptions.NETWORK_TYPE,
            new GraphPanelPlotLabels(rb.getString("chart.networkType"), createBarPlot(Color.gray), 1));
    subplotMap.put(ChartPlotOptions.THROUGHPUT,
            new GraphPanelPlotLabels(rb.getString("chart.throughput"), createThroughputPlot(), 2));
    subplotMap.put(ChartPlotOptions.BURSTS,
            new GraphPanelPlotLabels(rb.getString("chart.bursts"), createBurstPlot(), 1));
    subplotMap.put(ChartPlotOptions.USER_INPUT,
            new GraphPanelPlotLabels(rb.getString("chart.userInput"), createUserEventPlot(), 1));
    subplotMap.put(ChartPlotOptions.RRC,
            new GraphPanelPlotLabels(rb.getString("chart.rrc"), createRrcPlot(), 1));
    subplotMap.put(ChartPlotOptions.CPU,
            new GraphPanelPlotLabels(rb.getString("chart.cpu"), createCpuPlot(), 1));

    this.pp = new PacketPlots();
    subplotMap.put(ChartPlotOptions.UL_PACKETS,
            new GraphPanelPlotLabels(rb.getString("chart.ul"), pp.getUlPlot(), 1));
    subplotMap.put(ChartPlotOptions.DL_PACKETS,
            new GraphPanelPlotLabels(rb.getString("chart.dl"), pp.getDlPlot(), 1));

    this.axis = new NumberAxis();
    this.axis.setStandardTickUnits(UNITS);
    this.axis.setRange(new Range(0, DEFAULT_TIMELINE));
    this.axis.setLowerBound(0);

    this.axis.setAutoTickUnitSelection(true);
    this.axis.setTickMarkInsideLength(1);
    this.axis.setTickMarkOutsideLength(1);

    this.axis.setMinorTickMarksVisible(true);
    this.axis.setMinorTickMarkInsideLength(2f);
    this.axis.setMinorTickMarkOutsideLength(2f);
    this.axis.setTickMarkInsideLength(4f);
    this.axis.setTickMarkOutsideLength(4f);

    this.axisLabel = new JLabel(rb.getString("chart.timeline"));
    this.axisLabel.setHorizontalAlignment(SwingConstants.CENTER);

    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(200, 310));
    this.add(getZoomSavePanel(), BorderLayout.EAST);
    this.add(getPane(), BorderLayout.CENTER);
    this.add(getLabelsPanel(), BorderLayout.WEST);

    setChartOptions(UserPreferences.getInstance().getChartPlotOptions());
}

From source file:com.xmage.launcher.XMageLauncher.java

private void disableButtons() {
    btnLaunchClient.setEnabled(false);//from w  w w.j a va 2s.  c  o  m
    btnLaunchClient.setForeground(Color.GRAY);
    btnLaunchClientServer.setEnabled(false);
    btnLaunchClientServer.setForeground(Color.GRAY);
    btnLaunchServer.setEnabled(false);
    btnLaunchServer.setForeground(Color.GRAY);
    btnUpdate.setEnabled(false);
    btnUpdate.setForeground(Color.GRAY);
    btnCheck.setEnabled(false);
    btnCheck.setForeground(Color.GRAY);
}

From source file:bicat.gui.GraphicPane.java

public static JFreeChart myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double[] marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/*from www  .j  ava  2 s .c o m*/
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    for (int i = 0; i < marker.length; i++) {
        ValueMarker vm = new ValueMarker(marker[i]);
        vm.setPaint(Color.GRAY.brighter());
        // plot.addRangeMarker(vm, Layer.FOREGROUND);
        // //.setPaint(Color.PINK));
        plot.addDomainMarker(vm, Layer.FOREGROUND);
    }

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

From source file:ngat.opsgui.xcomp.SeeingPanel2.java

public void photomUpdate(SkyModelExtinctionUpdate se) {
    String photomStr = "UNKNOWN";
    Color color = Color.gray;

    if (se.getExtinction() <= 0.5) {
        photomStr = "PHOTOM";
        color = Color.green;/*from  w w w.  j a v  a 2 s .c om*/
    } else {
        photomStr = "SPECTRO";
        color = Color.red;
    }
    photomField.setText(photomStr);
    photomField.setBackground(color);
}

From source file:base.BasePlayer.AminoTable.java

void drawScreen(Graphics g) {
    if (!isEnabled()) {
        return;/* w  w w .  j av a 2  s.  c o  m*/
    }

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

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

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

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

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

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

            continue;
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    }

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

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

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

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

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

                    }

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

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

                        } else {

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

                        }
                    }

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

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

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

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

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

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

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

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

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

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

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

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

                                    }
                                }

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

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

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

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

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

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

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

                                }
                            }
                        }
                    }

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

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

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

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

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

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

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

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

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

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

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

                    }

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

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

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

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

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

}