Example usage for java.awt Color magenta

List of usage examples for java.awt Color magenta

Introduction

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

Prototype

Color magenta

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

Click Source Link

Document

The color magenta.

Usage

From source file:gdsc.smlm.ij.plugins.TraceDiffusion.java

/**
 * Fit the MSD using a linear fit that must pass through 0,0.
 * <p>//from   w  ww  .  j  a va2s . co m
 * Update the plot by adding the fit line.
 * 
 * @param x
 * @param y
 * @param title
 * @param plot
 * @return
 */
private double fitMSD(double[] x, double[] y, String title, Plot2 plot) {
    double D = 0;
    LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
    PointVectorValuePair lvmSolution;
    try {
        final LinearFunction function = new LinearFunction(x, y, settings.fitLength);
        double[] parameters = new double[] { function.guess() };
        lvmSolution = optimizer.optimize(new MaxIter(3000), new MaxEval(Integer.MAX_VALUE),
                new ModelFunctionJacobian(new MultivariateMatrixFunction() {
                    public double[][] value(double[] point) throws IllegalArgumentException {
                        return function.jacobian(point);
                    }
                }), new ModelFunction(function), new Target(function.getY()), new Weight(function.getWeights()),
                new InitialGuess(parameters));

        double ss = 0;
        double[] obs = function.getY();
        double[] exp = lvmSolution.getValue();
        for (int i = 0; i < obs.length; i++)
            ss += (obs[i] - exp[i]) * (obs[i] - exp[i]);

        D = lvmSolution.getPoint()[0] / 4;
        Utils.log("Linear fit (%d points) : Gradient = %s, D = %s um^2/s, SS = %f (%d evaluations)", obs.length,
                Utils.rounded(lvmSolution.getPoint()[0], 4), Utils.rounded(D, 4), ss,
                optimizer.getEvaluations());

        // Add the fit to the plot
        plot.setColor(Color.magenta);
        plot.drawLine(0, 0, x[x.length - 1], x[x.length - 1] * 4 * D);
        display(title, plot);
    } catch (TooManyIterationsException e) {
        Utils.log("Failed to fit : Too many iterations (%d)", optimizer.getIterations());
    } catch (ConvergenceException e) {
        Utils.log("Failed to fit : %s", e.getMessage());
    }
    return D;
}

From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link ColorEnum}.
 *//*from  w ww . j  a  va  2 s.  co m*/
public static Map getColorMap() {
    if (colorMap == null) {
        Map map = new HashMap(35);
        map.put(COLOR_BLACK, Color.black);
        map.put(COLOR_BLUE, Color.blue);
        map.put(COLOR_CYAN, Color.cyan);
        map.put(COLOR_DARK_GRAY, Color.darkGray);
        map.put(COLOR_GRAY, Color.gray);
        map.put(COLOR_GREEN, Color.green);
        map.put(COLOR_LIGHT_GRAY, Color.lightGray);
        map.put(COLOR_MAGENTA, Color.magenta);
        map.put(COLOR_ORANGE, Color.orange);
        map.put(COLOR_PINK, Color.pink);
        map.put(COLOR_RED, Color.red);
        map.put(COLOR_YELLOW, Color.yellow);
        map.put(COLOR_WHITE, Color.white);
        map.put(Color.black, COLOR_BLACK);
        map.put(Color.blue, COLOR_BLUE);
        map.put(Color.cyan, COLOR_CYAN);
        map.put(Color.darkGray, COLOR_DARK_GRAY);
        map.put(Color.gray, COLOR_GRAY);
        map.put(Color.green, COLOR_GREEN);
        map.put(Color.lightGray, COLOR_LIGHT_GRAY);
        map.put(Color.magenta, COLOR_MAGENTA);
        map.put(Color.orange, COLOR_ORANGE);
        map.put(Color.pink, COLOR_PINK);
        map.put(Color.red, COLOR_RED);
        map.put(Color.yellow, COLOR_YELLOW);
        map.put(Color.white, COLOR_WHITE);
        colorMap = Collections.unmodifiableMap(map);
    }

    return colorMap;
}

From source file:edu.harvard.mcz.imagecapture.PositionTemplateEditor.java

/**
 * Draw boxes delimiting the various parts of the template on the current image.
 * Public so that it can be invoked from ButtonEditor().
 *//*  ww  w .ja v  a2s  .  co m*/
public void drawLayers() {
    // draw the image bounds in black.
    if (template != null) {
        imagePanelForDrawing.clearOverlay();
        imagePanelForDrawing.drawBox(new Dimension(0, 0), template.getImageSize(), Color.BLACK,
                new BasicStroke(2F));
        // draw each template layer in a distinct color (keyed to UI text).
        imagePanelForDrawing.drawBox(template.getBarcodeULPosition(), template.getBarcodeSize(), Color.RED);
        imagePanelForDrawing.drawBox(template.getTextPosition(), template.getTextSize(), Color.BLUE);
        imagePanelForDrawing.drawBox(template.getSpecimenPosition(), template.getSpecimenSize(), Color.ORANGE);
        imagePanelForDrawing.drawBox(template.getUTLabelsPosition(), template.getUTLabelsSize(), Color.CYAN);
        imagePanelForDrawing.drawBox(template.getLabelPosition(), template.getLabelSize(), Color.MAGENTA);
        imagePanelForDrawing.drawBox(template.getUtBarcodePosition(), template.getUtBarcodeSize(), Color.BLACK);
    }
}

From source file:uk.ac.ucl.chem.ccs.clinicalgui.DisplayJobPanel.java

private void updateState() {

    switch (ajo.getState()) {
    case AHEJobObject.AHE_PREPARING:
        jobStatus.setForeground(Color.BLUE);
        jobStatus.setText("AHE PREPARING");
        break;//from  w w w.  ja  v  a  2 s  . co  m

    case AHEJobObject.AHE_FILES_STAGED:
        jobStatus.setForeground(Color.ORANGE);
        jobStatus.setText("AHE FILES STAGED");
        break;

    case AHEJobObject.AHE_JOB_BUILT:
        jobStatus.setForeground(Color.YELLOW);
        jobStatus.setText("AHE JOB BUILT");
        break;

    case AHEJobObject.GRIDSAM_PENDING:
        jobStatus.setForeground(Color.MAGENTA);
        jobStatus.setText("AHE PENDING");
        break;

    case AHEJobObject.GRIDSAM_STAGING_IN:
        jobStatus.setForeground(new Color(92, 201, 151));
        jobStatus.setText("AHE STAGING IN");
        break;

    case AHEJobObject.GRIDSAM_STAGED_IN:
        jobStatus.setForeground(new Color(1, 240, 242));
        jobStatus.setText("AHE STAGED IN");
        break;

    case AHEJobObject.GRIDSAM_STAGING_OUT:
        jobStatus.setForeground(new Color(188, 140, 217));
        jobStatus.setText("AHE STAGING OUT");
        break;

    case AHEJobObject.GRIDSAM_STAGED_OUT:
        jobStatus.setForeground(new Color(135, 90, 133));
        jobStatus.setText("AHE PREPARING");
        break;

    case AHEJobObject.GRIDSAM_ACTIVE:
        jobStatus.setForeground(new Color(207, 165, 92));
        jobStatus.setText("AHE ACTIVE");
        break;

    case AHEJobObject.GRIDSAM_EXECUTED:
        jobStatus.setForeground(new Color(127, 124, 133));
        jobStatus.setText("AHE EXECUTED");
        break;

    case AHEJobObject.GRIDSAM_FAILED:
        jobStatus.setForeground(Color.RED);
        jobStatus.setText("AHE FAILED");
        if (pollingButton.getText().equals("Stop Polling")) {
            pollTimer.stop();
            pollingButton.setText("Start Polling");
        }
        break;

    case AHEJobObject.GRIDSAM_DONE:
        jobStatus.setForeground(Color.GREEN);
        jobStatus.setText("AHE DONE");
        if (pollingButton.getText().equals("Stop Polling")) {
            pollTimer.stop();
            pollingButton.setText("Start Polling");
        }

        break;

    case AHEJobObject.GRIDSAM_TERMINATING:
        jobStatus.setForeground(new Color(242, 52, 154));
        jobStatus.setText("AHE TERMINATING");
        break;

    case AHEJobObject.GRIDSAM_TERMINATED:
        jobStatus.setForeground(new Color(76, 67, 20));
        jobStatus.setText("AHE TERMINATED");
        if (pollingButton.getText().equals("Stop Polling")) {
            pollTimer.stop();
            pollingButton.setText("Start Polling");
        }
        break;

    case AHEJobObject.GRIDSAM_UNDEFINED:
        jobStatus.setForeground(new Color(89, 9, 54));
        jobStatus.setText("AHE UNDEFINED");
        if (pollingButton.getText().equals("Stop Polling")) {
            pollTimer.stop();
            pollingButton.setText("Start Polling");
        }
        break;

    }

    if (AHEJobObject.GRIDSAM_PENDING <= ajo.getState() && ajo.getState() <= AHEJobObject.GRIDSAM_EXECUTED) {
        teminateJob.setEnabled(true);
    } else {
        teminateJob.setEnabled(false);
    }

    if (AHEJobObject.GRIDSAM_FAILED <= ajo.getState() && ajo.getState() <= AHEJobObject.GRIDSAM_UNDEFINED) {
        updateStatus.setEnabled(false);
        pollingButton.setText("Start Polling");
        pollingButton.setEnabled(false);
    } else {
        updateStatus.setEnabled(true);
    }

    if (ajo.getState() == AHEJobObject.AHE_JOB_BUILT) {
        updateStatus.setText("Start Job");
    } else {
        updateStatus.setText("Update Job");
    }

    if (ajo.getState() == AHEJobObject.GRIDSAM_DONE || ajo.getState() == AHEJobObject.GRIDSAM_STAGED_OUT) {
        downloadButton.setEnabled(true);
    } else {
        downloadButton.setEnabled(false);
    }

}

From source file:gdsc.smlm.ij.plugins.TraceDiffusion.java

/**
 * Fit the jump distance histogram using a cumulative sum as detailed in
 * <p>/*  w  w w.ja  va 2s .  co  m*/
 * Update the plot by adding the fit line.
 * 
 * @param jumpDistances
 * @param jdHistogram
 * @param title
 * @param plot
 * @return
 */
private double[][] fitJumpDistance(StoredDataStatistics jumpDistances, double[][] jdHistogram, String title,
        Plot2 plot) {
    final double meanDistance = Math.sqrt(jumpDistances.getMean()) * 1e3;
    final double beta = meanDistance / precision;
    Utils.log(
            "Jump Distance analysis : N = %d, Time = %d frames (%s seconds). Mean Distance = %s nm, Precision = %s nm, Beta = %s",
            jumpDistances.getN(), settings.jumpDistance, Utils.rounded(settings.jumpDistance * exposureTime, 4),
            Utils.rounded(meanDistance, 4), Utils.rounded(precision, 4), Utils.rounded(beta, 4));
    int n = 0;
    int N = 10;
    double[] SS = new double[N];
    Arrays.fill(SS, -1);
    double[] ic = new double[N];
    Arrays.fill(ic, Double.POSITIVE_INFINITY);
    double[][] coefficients = new double[N][];
    double[][] fractions = new double[N][];
    double[][] fitParams = new double[N][];
    double bestIC = Double.POSITIVE_INFINITY;
    int best = -1;

    // Guess the D
    final double estimatedD = jumpDistances.getMean() / 4;
    Utils.log("Estimated D = %s um^2/s", Utils.rounded(estimatedD, 4));

    // Fit using a single population model
    LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
    try {
        final JumpDistanceFunction function = new JumpDistanceFunction(jdHistogram[0], jdHistogram[1],
                estimatedD);
        PointVectorValuePair lvmSolution = optimizer.optimize(new MaxIter(3000), new MaxEval(Integer.MAX_VALUE),
                new ModelFunctionJacobian(new MultivariateMatrixFunction() {
                    public double[][] value(double[] point) throws IllegalArgumentException {
                        return function.jacobian(point);
                    }
                }), new ModelFunction(function), new Target(function.getY()), new Weight(function.getWeights()),
                new InitialGuess(function.guess()));

        fitParams[n] = lvmSolution.getPointRef();
        SS[n] = calculateSumOfSquares(function.getY(), lvmSolution.getValueRef());
        ic[n] = Maths.getInformationCriterion(SS[n], function.x.length, 1);
        coefficients[n] = fitParams[n];
        fractions[n] = new double[] { 1 };

        Utils.log("Fit Jump distance (N=%d) : D = %s um^2/s, SS = %f, IC = %s (%d evaluations)", n + 1,
                Utils.rounded(fitParams[n][0], 4), SS[n], Utils.rounded(ic[n], 4), optimizer.getEvaluations());

        bestIC = ic[n];
        best = 0;

        addToPlot(function, fitParams[n], jdHistogram, title, plot, Color.magenta);
    } catch (TooManyIterationsException e) {
        Utils.log("Failed to fit : Too many iterations (%d)", optimizer.getIterations());
    } catch (ConvergenceException e) {
        Utils.log("Failed to fit : %s", e.getMessage());
    }

    n++;

    // Fit using a mixed population model. 
    // Vary n from 2 to N. Stop when the fit fails or the fit is worse.
    int bestMulti = -1;
    double bestMultiIC = Double.POSITIVE_INFINITY;
    while (n < N) {
        // Uses a weighted sum of n exponential functions, each function models a fraction of the particles.
        // An LVM fit cannot restrict the parameters so the fractions do not go below zero.
        // Use the CMEASOptimizer which supports bounded fitting.

        MixedJumpDistanceFunctionMultivariate mixedFunction = new MixedJumpDistanceFunctionMultivariate(
                jdHistogram[0], jdHistogram[1], estimatedD, n + 1);

        double[] lB = mixedFunction.getLowerBounds();
        double[] uB = mixedFunction.getUpperBounds();
        SimpleBounds bounds = new SimpleBounds(lB, uB);

        int maxIterations = 2000;
        double stopFitness = 0; //Double.NEGATIVE_INFINITY;
        boolean isActiveCMA = true;
        int diagonalOnly = 20;
        int checkFeasableCount = 1;
        RandomGenerator random = new Well19937c();
        boolean generateStatistics = false;
        ConvergenceChecker<PointValuePair> checker = new SimpleValueChecker(1e-6, 1e-10);
        // The sigma determines the search range for the variables. It should be 1/3 of the initial search region.
        double[] s = new double[lB.length];
        for (int i = 0; i < s.length; i++)
            s[i] = (uB[i] - lB[i]) / 3;
        OptimizationData sigma = new CMAESOptimizer.Sigma(s);
        OptimizationData popSize = new CMAESOptimizer.PopulationSize(
                (int) (4 + Math.floor(3 * Math.log(mixedFunction.x.length))));

        // Iterate this for stability in the initial guess
        CMAESOptimizer opt = new CMAESOptimizer(maxIterations, stopFitness, isActiveCMA, diagonalOnly,
                checkFeasableCount, random, generateStatistics, checker);

        int evaluations = 0;
        PointValuePair constrainedSolution = null;

        for (int i = 0; i <= settings.fitRestarts; i++) {
            // Try from the initial guess
            try {
                PointValuePair solution = opt.optimize(new InitialGuess(mixedFunction.guess()),
                        new ObjectiveFunction(mixedFunction), GoalType.MINIMIZE, bounds, sigma, popSize,
                        new MaxIter(maxIterations), new MaxEval(maxIterations * 2));
                if (constrainedSolution == null || solution.getValue() < constrainedSolution.getValue()) {
                    evaluations = opt.getEvaluations();
                    constrainedSolution = solution;
                    //Utils.log("[%da] Fit Jump distance (N=%d) : SS = %f (%d evaluations)", i, n + 1,
                    //      solution.getValue(), evaluations);
                }
            } catch (TooManyEvaluationsException e) {
            }

            if (constrainedSolution == null)
                continue;

            // Try from the current optimum
            try {
                PointValuePair solution = opt.optimize(new InitialGuess(constrainedSolution.getPointRef()),
                        new ObjectiveFunction(mixedFunction), GoalType.MINIMIZE, bounds, sigma, popSize,
                        new MaxIter(maxIterations), new MaxEval(maxIterations * 2));
                if (constrainedSolution == null || solution.getValue() < constrainedSolution.getValue()) {
                    evaluations = opt.getEvaluations();
                    constrainedSolution = solution;
                    //Utils.log("[%db] Fit Jump distance (N=%d) : SS = %f (%d evaluations)", i, n + 1,
                    //      solution.getValue(), evaluations);
                }
            } catch (TooManyEvaluationsException e) {
            }
        }

        if (constrainedSolution == null) {
            Utils.log("Failed to fit N=%d", n + 1);
            break;
        }

        fitParams[n] = constrainedSolution.getPointRef();
        SS[n] = constrainedSolution.getValue();

        // TODO - Try a bounded BFGS optimiser

        // Try and improve using a LVM fit
        final MixedJumpDistanceFunctionGradient mixedFunctionGradient = new MixedJumpDistanceFunctionGradient(
                jdHistogram[0], jdHistogram[1], estimatedD, n + 1);

        PointVectorValuePair lvmSolution;
        try {
            lvmSolution = optimizer.optimize(new MaxIter(3000), new MaxEval(Integer.MAX_VALUE),
                    new ModelFunctionJacobian(new MultivariateMatrixFunction() {
                        public double[][] value(double[] point) throws IllegalArgumentException {
                            return mixedFunctionGradient.jacobian(point);
                        }
                    }), new ModelFunction(mixedFunctionGradient), new Target(mixedFunctionGradient.getY()),
                    new Weight(mixedFunctionGradient.getWeights()), new InitialGuess(fitParams[n]));
            double ss = calculateSumOfSquares(mixedFunctionGradient.getY(), lvmSolution.getValue());
            // All fitted parameters must be above zero
            if (ss < SS[n] && Maths.min(lvmSolution.getPoint()) > 0) {
                //Utils.log("  Re-fitting improved the SS from %s to %s (-%s%%)", Utils.rounded(SS[n], 4),
                //      Utils.rounded(ss, 4), Utils.rounded(100 * (SS[n] - ss) / SS[n], 4));
                fitParams[n] = lvmSolution.getPoint();
                SS[n] = ss;
                evaluations += optimizer.getEvaluations();
            }
        } catch (TooManyIterationsException e) {
            //Utils.log("Failed to re-fit : Too many evaluations (%d)", optimizer.getEvaluations());
        } catch (ConvergenceException e) {
            //Utils.log("Failed to re-fit : %s", e.getMessage());
        }

        // Since the fractions must sum to one we subtract 1 degree of freedom from the number of parameters
        ic[n] = Maths.getInformationCriterion(SS[n], mixedFunction.x.length, fitParams[n].length - 1);

        double[] d = new double[n + 1];
        double[] f = new double[n + 1];
        double sum = 0;
        for (int i = 0; i < d.length; i++) {
            f[i] = fitParams[n][i * 2];
            sum += f[i];
            d[i] = fitParams[n][i * 2 + 1];
        }
        for (int i = 0; i < f.length; i++)
            f[i] /= sum;
        // Sort by coefficient size
        sort(d, f);
        coefficients[n] = d;
        fractions[n] = f;

        Utils.log("Fit Jump distance (N=%d) : D = %s um^2/s (%s), SS = %f, IC = %s (%d evaluations)", n + 1,
                format(d), format(f), SS[n], Utils.rounded(ic[n], 4), evaluations);

        boolean valid = true;
        for (int i = 0; i < f.length; i++) {
            // Check the fit has fractions above the minimum fraction
            if (f[i] < minFraction) {
                Utils.log("Fraction is less than the minimum fraction: %s < %s", Utils.rounded(f[i]),
                        Utils.rounded(minFraction));
                valid = false;
                break;
            }
            // Check the coefficients are different
            if (i + 1 < f.length && d[i] / d[i + 1] < minDifference) {
                Utils.log("Coefficients are not different: %s / %s = %s < %s", Utils.rounded(d[i]),
                        Utils.rounded(d[i + 1]), Utils.rounded(d[i] / d[i + 1]), Utils.rounded(minDifference));
                valid = false;
                break;
            }
        }

        if (!valid)
            break;

        // Store the best model
        if (bestIC > ic[n]) {
            bestIC = ic[n];
            best = n;
        }

        // Store the best multi model
        if (bestMultiIC < ic[n]) {
            break;
        }

        bestMultiIC = ic[n];
        bestMulti = n;

        n++;
    }

    // Add the best fit to the plot and return the parameters.
    if (bestMulti > -1) {
        Function function = new MixedJumpDistanceFunctionMultivariate(jdHistogram[0], jdHistogram[1], 0,
                bestMulti + 1);
        addToPlot(function, fitParams[bestMulti], jdHistogram, title, plot, Color.yellow);
    }

    if (best > -1) {
        Utils.log("Best fit achieved using %d population%s: D = %s um^2/s, Fractions = %s", best + 1,
                (best == 0) ? "" : "s", format(coefficients[best]), format(fractions[best]));
    }

    return (best > -1) ? new double[][] { coefficients[best], fractions[best] } : null;
}

From source file:biogenesis.Organism.java

private static int getTypeColor(Color c) {
    if (c.equals(Color.RED) || c.equals(Utils.ColorDARK_RED))
        return RED;
    if (c.equals(Color.GREEN) || c.equals(Utils.ColorDARK_GREEN))
        return GREEN;
    if (c.equals(Color.CYAN) || c.equals(Utils.ColorDARK_CYAN))
        return CYAN;
    if (c.equals(Color.BLUE) || c.equals(Utils.ColorDARK_BLUE))
        return BLUE;
    if (c.equals(Color.MAGENTA) || c.equals(Utils.ColorDARK_MAGENTA))
        return MAGENTA;
    if (c.equals(Color.PINK) || c.equals(Utils.ColorDARK_PINK))
        return PINK;
    if (c.equals(Color.ORANGE) || c.equals(Utils.ColorDARK_ORANGE))
        return ORANGE;
    if (c.equals(Color.WHITE) || c.equals(Utils.ColorDARK_WHITE))
        return WHITE;
    if (c.equals(Color.GRAY) || c.equals(Utils.ColorDARK_GRAY))
        return GRAY;
    if (c.equals(Color.YELLOW) || c.equals(Utils.ColorDARK_YELLOW))
        return YELLOW;
    if (c.equals(Utils.ColorBROWN))
        return BROWN;
    return NOCOLOR;
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private static Color parseColor(String color) {
    if (color != null) {
        if (color.trim().startsWith("#")) {
            // HTML colors (#FFFFFF format)
            return new Color(Integer.parseInt(color.substring(1), 16));
        } else if (color.trim().startsWith("rgb")) {
            // HTML colors (rgb(255, 255, 255) format)
            String values = color.substring(color.indexOf("(") + 1, color.indexOf(")"));
            String rgb[] = values.split(",");
            return new Color(Integer.parseInt(rgb[0].trim()), Integer.parseInt(rgb[1].trim()),
                    Integer.parseInt(rgb[2].trim()));
        } else {// w  w w .  j  av  a2  s. co  m
            // Colors by name
            if (color.equalsIgnoreCase("black"))
                return Color.black;
            if (color.equalsIgnoreCase("grey"))
                return Color.gray;
            if (color.equalsIgnoreCase("yellow"))
                return Color.yellow;
            if (color.equalsIgnoreCase("green"))
                return Color.green;
            if (color.equalsIgnoreCase("blue"))
                return Color.blue;
            if (color.equalsIgnoreCase("red"))
                return Color.red;
            if (color.equalsIgnoreCase("orange"))
                return Color.orange;
            if (color.equalsIgnoreCase("cyan"))
                return Color.cyan;
            if (color.equalsIgnoreCase("magenta"))
                return Color.magenta;
            if (color.equalsIgnoreCase("darkgray"))
                return Color.darkGray;
            if (color.equalsIgnoreCase("lightgray"))
                return Color.lightGray;
            if (color.equalsIgnoreCase("pink"))
                return Color.pink;
            if (color.equalsIgnoreCase("white"))
                return Color.white;
        }
    }
    LOG.info("Unable to parse body background-color (color:" + color + "). Assuming white.");
    return Color.white;
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

public static Color parseColor(String color) {
    if (color != null) {
        if (color.trim().startsWith("#")) {
            // HTML colors (#FFFFFF format)
            return new Color(Integer.parseInt(color.substring(1), 16));
        } else if (color.trim().startsWith("rgb")) {
            // HTML colors (rgb(255, 255, 255) format)
            String values = color.substring(color.indexOf("(") + 1, color.indexOf(")"));
            String rgb[] = values.split(",");
            return new Color(Integer.parseInt(rgb[0].trim()), Integer.parseInt(rgb[1].trim()),
                    Integer.parseInt(rgb[2].trim()));
        } else {//from   w  w w. j  a  v a  2s.c o m
            // Colors by name
            if (color.equalsIgnoreCase("black"))
                return Color.black;
            if (color.equalsIgnoreCase("grey"))
                return Color.gray;
            if (color.equalsIgnoreCase("yellow"))
                return Color.yellow;
            if (color.equalsIgnoreCase("green"))
                return Color.green;
            if (color.equalsIgnoreCase("blue"))
                return Color.blue;
            if (color.equalsIgnoreCase("red"))
                return Color.red;
            if (color.equalsIgnoreCase("orange"))
                return Color.orange;
            if (color.equalsIgnoreCase("cyan"))
                return Color.cyan;
            if (color.equalsIgnoreCase("magenta"))
                return Color.magenta;
            if (color.equalsIgnoreCase("darkgray"))
                return Color.darkGray;
            if (color.equalsIgnoreCase("lightgray"))
                return Color.lightGray;
            if (color.equalsIgnoreCase("pink"))
                return Color.pink;
            if (color.equalsIgnoreCase("white"))
                return Color.white;
        }
    }
    log.info("Unable to parse body background-color (color:" + color + "). Assuming white.");
    return Color.white;
}

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

/**
 * Sets rendering color for all different network type data series. 
 * @param renderer Renderer for the data series
 * @param dataSeries Data series/*  w  w  w. ja va 2  s  .  co m*/
 */
static void setRenderingColorForDataSeries(XYItemRenderer renderer,
        final XYIntervalSeriesCollection dataSeries) {
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.none), Color.WHITE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.LTE), Color.RED);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.WIFI), Color.BLUE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.UMTS), Color.PINK);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.ETHERNET), Color.BLACK);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSDPA), Color.YELLOW);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPA), Color.ORANGE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPAP), Color.MAGENTA);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSUPA), Color.CYAN);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.GPRS), Color.GRAY);
}

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

private static void populateBurstPlot(XYPlot plot, TraceData.Analysis analysis) {

    final XYIntervalSeriesCollection burstDataCollection = new XYIntervalSeriesCollection();
    if (analysis != null) {

        Map<BurstCategory, XYIntervalSeries> seriesMap = new EnumMap<BurstCategory, XYIntervalSeries>(
                BurstCategory.class);
        final Map<BurstCategory, List<Burst>> burstMap = new HashMap<BurstCategory, List<Burst>>();
        for (BurstCategory eventType : BurstCategory.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            burstDataCollection.addSeries(series);
            burstMap.put(eventType, new ArrayList<Burst>());
        }//from w  ww  . java2s. c  o  m
        final List<Burst> burstStates = analysis.getBurstInfos();
        Iterator<Burst> iter = burstStates.iterator();
        while (iter.hasNext()) {
            Burst currEvent = iter.next();
            if (currEvent != null) {
                BurstCategory burstState = currEvent.getBurstCategory();
                if (burstState != null) {
                    seriesMap.get(burstState).add(currEvent.getBeginTime(), currEvent.getBeginTime(),
                            currEvent.getEndTime(), 0.5, 0, 1);
                    burstMap.get(burstState).add(currEvent);
                }
            }
        }

        Color myGreen = new Color(34, 177, 76);
        Color lightGreen = new Color(134, 232, 162);

        XYItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_PROTOCOL), Color.blue);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_LOSS_OR_DUP), Color.black);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.USER_INPUT), myGreen);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SCREEN_ROTATION), lightGreen);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CLIENT_APP), Color.red);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SERVER_NET_DELAY), Color.yellow);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.LONG), Color.gray);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.PERIODICAL), Color.magenta);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CPU), Color.cyan);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.UNKNOWN), Color.darkGray);

        // Assign ToolTip to renderer
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                BurstCategory eventType = (BurstCategory) burstDataCollection.getSeries(series).getKey();
                Burst b = burstMap.get(eventType).get(item);
                final String PREFIX = "BurstCategory.";
                return MessageFormat.format(rb.getString(PREFIX + eventType.ordinal()), b.getPackets().size(),
                        b.getBurstBytes(), b.getBurstThroughPut());
            }
        });

    }

    plot.setDataset(burstDataCollection);
}