Example usage for java.awt Color green

List of usage examples for java.awt Color green

Introduction

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

Prototype

Color green

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

Click Source Link

Document

The color green.

Usage

From source file:edu.dlnu.liuwenpeng.render.CandlestickRenderer.java

/**    
* Creates a new renderer for candlestick charts.    
* <P>    /*from  ww w . j ava  2 s  .  c  o  m*/
* Use -1 for the candle width if you prefer the width to be calculated    
* automatically.    
*    
* @param candleWidth  the candle width.    
* @param drawVolume  a flag indicating whether or not volume bars should    
*                    be drawn.    
* @param toolTipGenerator  the tool tip generator. <code>null</code> is    
*                          none.    
*/
public CandlestickRenderer(double candleWidth, boolean drawVolume, XYToolTipGenerator toolTipGenerator) {
    super();
    setBaseToolTipGenerator(toolTipGenerator);
    this.candleWidth = candleWidth;
    this.drawVolume = drawVolume;
    this.volumePaint = Color.gray;
    this.upPaint = Color.green;
    this.downPaint = Color.red;
    this.useOutlinePaint = false; // false preserves the old behaviour    
                                  // prior to introducing this flag    
}

From source file:ReportGen.java

private void defaultPreview() throws NumberFormatException {

    tableModel = (DefaultTableModel) dataTable.getModel();
    tableModel.getDataVector().removeAllElements();
    tableModel.fireTableDataChanged();/* ww w . j a va 2 s. co m*/
    String str[] = { "X", "Y" };
    tableModel.setColumnIdentifiers(str);

    exportcounttableexcel.setEnabled(false);
    exportcounttablepdf.setEnabled(false);
    //        exportgraphtoimage.setEnabled(false);

    ChartPanel chartPanel;
    displaypane.removeAll();
    displaypane.revalidate();
    displaypane.repaint();
    displaypane.setLayout(new BorderLayout());
    //row
    String series1 = "Results";
    //column
    String values[] = { "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" };
    int value[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    for (int i = 0; i < values.length; i++) {
        tableModel.addRow(new Object[] { values[i], value[i] });
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int c = 0; c < value.length; c++) {
        dataset.addValue(value[c], series1, values[c]);
    }

    chart = ChartFactory.createBarChart("181 North Place Residences Graph", // chart title
            "Default", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    final org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    chartPanel = new ChartPanel(chart);
    displaypane.add(chartPanel, BorderLayout.CENTER);
}

From source file:edu.umn.cs.spatialHadoop.OperationsParams.java

public static Color getColor(Configuration conf, String key, Color defaultValue) {
    String colorName = conf.get(key);
    if (colorName == null)
        return defaultValue;

    colorName = colorName.toLowerCase();
    Color color = defaultValue;//w w  w.  j av a2s  .  com
    if (colorName.equals("red")) {
        color = Color.RED;
    } else if (colorName.equals("pink")) {
        color = Color.PINK;
    } else if (colorName.equals("blue")) {
        color = Color.BLUE;
    } else if (colorName.equals("cyan")) {
        color = Color.CYAN;
    } else if (colorName.equals("green")) {
        color = Color.GREEN;
    } else if (colorName.equals("black")) {
        color = Color.BLACK;
    } else if (colorName.equals("white")) {
        color = Color.WHITE;
    } else if (colorName.equals("gray")) {
        color = Color.GRAY;
    } else if (colorName.equals("yellow")) {
        color = Color.YELLOW;
    } else if (colorName.equals("orange")) {
        color = Color.ORANGE;
    } else if (colorName.equals("none")) {
        color = new Color(0, 0, 255, 0);
    } else if (colorName.matches("#[a-zA-Z0-9]{8}")) {
        String redHex = colorName.substring(1, 2);
        String greenHex = colorName.substring(3, 4);
        String blueHex = colorName.substring(5, 6);
        String opacityHex = colorName.substring(7, 8);
        int red = Integer.parseInt(redHex, 16);
        int green = Integer.parseInt(greenHex, 16);
        int blue = Integer.parseInt(blueHex, 16);
        int opacity = Integer.parseInt(opacityHex, 16);
        color = new Color(red, green, blue, opacity);
    } else {
        LOG.warn("Does not understand the color '" + conf.get(key) + "'");
    }

    return color;
}

From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java

private void setArtistsChart() {
    DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedArtists(10));
    JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ARTIST_MOST_PLAYED"), null,
            null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
    chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0,
            200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR));
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    NumberAxis axis = new NumberAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
    chart.getCategoryPlot().setRangeAxis(axis);
    chart.getCategoryPlot().setForegroundAlpha(0.6f);
    chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN);

    ((StatsDialog) frameControlled).getArtistsChart()
            .setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:convcao.com.caoAgent.convcaoNeptusInteraction.java

@Override
public void paint(Graphics2D g, StateRenderer2D renderer) {
    Point2D center = renderer.getScreenPosition(coords.squareCenter);
    double width = renderer.getZoom() * coords.cellWidth * coords.numCols;
    double height = renderer.getZoom() * coords.cellWidth * coords.numRows;
    g.setColor(new Color(0, 0, 255, 64));
    g.translate(center.getX(), center.getY());
    g.rotate(-renderer.getRotation());// ww  w.  j av a 2s .c om
    g.fill(new Rectangle2D.Double(-width / 2, -height / 2, width, height));
    g.rotate(renderer.getRotation());
    g.translate(-center.getX(), -center.getY());

    if (!active)
        return;

    g.setColor(Color.orange);
    int pos = 50;
    for (String v : nameTable.values()) {
        g.drawString(v + ": " + depths.get(v) + "m", 15, pos);
        pos += 20;
    }

    for (String vehicle : nameTable.values()) {
        LocationType src = positions.get(vehicle);
        LocationType dst = destinations.get(vehicle);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());
        float dash[] = { 4.0f };
        g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, dash, 0.0f));
        g.draw(new Line2D.Double(renderer.getScreenPosition(src), renderer.getScreenPosition(dst)));

        Point2D dstPt = renderer.getScreenPosition(dst);

        if (!arrived.get(vehicle))
            g.setColor(Color.red.darker());
        else
            g.setColor(Color.green.darker());

        g.fill(new Ellipse2D.Double(dstPt.getX() - 4, dstPt.getY() - 4, 8, 8));
    }
}

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

public void run(String arg) {
    if (!showDialog())
        return;//from  ww w  . j av a2 s  . co  m

    int totalSteps = settings.seconds * settings.stepsPerSecond;

    final double conversionFactor = 1000000.0 / (settings.pixelPitch * settings.pixelPitch);

    // Diffusion rate is um^2/sec. Convert to pixels per simulation frame.
    final double diffusionRateInPixelsPerSecond = settings.diffusionRate * conversionFactor;
    final double diffusionRateInPixelsPerStep = diffusionRateInPixelsPerSecond / settings.stepsPerSecond;

    Utils.log(TITLE + " : D = %s um^2/sec", Utils.rounded(settings.diffusionRate, 4));
    Utils.log("Mean-displacement per dimension = %s nm/sec",
            Utils.rounded(1e3 * ImageModel.getRandomMoveDistance(settings.diffusionRate), 4));

    // Convert diffusion co-efficient into the standard deviation for the random walk
    final double diffusionSigma = ImageModel.getRandomMoveDistance(diffusionRateInPixelsPerStep);
    Utils.log("Simulation step-size = %s nm", Utils.rounded(settings.pixelPitch * diffusionSigma, 4));

    // Move the molecules and get the diffusion rate
    IJ.showStatus("Simulating ...");
    final long start = System.nanoTime();
    RandomGenerator random = new Well19937c(System.currentTimeMillis() + System.identityHashCode(this));
    Statistics[] stats2D = new Statistics[totalSteps];
    Statistics[] stats3D = new Statistics[totalSteps];
    for (int j = 0; j < totalSteps; j++) {
        stats2D[j] = new Statistics();
        stats3D[j] = new Statistics();
    }
    SphericalDistribution dist = new SphericalDistribution(settings.confinementRadius / settings.pixelPitch);
    Statistics asymptote = new Statistics();
    for (int i = 0; i < settings.particles; i++) {
        if (i % 16 == 0)
            IJ.showProgress(i, settings.particles);

        MoleculeModel m = new MoleculeModel(i, new double[3]);
        if (useConfinement) {
            // Note: When using confinement the average displacement should asymptote
            // at the average distance of a point from the centre of a ball. This is 3r/4.
            // See: http://answers.yahoo.com/question/index?qid=20090131162630AAMTUfM
            // The equivalent in 2D is 2r/3. However although we are plotting 2D distance
            // this is a projection of the 3D position onto the plane and so the particles
            // will not be evenly spread (there will be clustering at centre caused by the
            // poles)
            for (int j = 0; j < totalSteps; j++) {
                double[] xyz = m.getCoordinates();
                double[] originalXyz = Arrays.copyOf(xyz, 3);
                for (int n = confinementAttempts; n-- > 0;) {
                    if (settings.useGridWalk)
                        m.walk(diffusionSigma, random);
                    else
                        m.move(diffusionSigma, random);
                    if (!dist.isWithin(m.getCoordinates())) {
                        // Reset position
                        for (int k = 0; k < 3; k++)
                            xyz[k] = originalXyz[k];
                    } else {
                        // The move was allowed
                        break;
                    }
                }

                stats2D[j].add(squared(m.getCoordinates()));
                stats3D[j].add(distance2(m.getCoordinates()));
            }
            asymptote.add(distance(m.getCoordinates()));
        } else {
            if (settings.useGridWalk) {
                for (int j = 0; j < totalSteps; j++) {
                    m.walk(diffusionSigma, random);
                    stats2D[j].add(squared(m.getCoordinates()));
                    stats3D[j].add(distance2(m.getCoordinates()));
                }
            } else {
                for (int j = 0; j < totalSteps; j++) {
                    m.move(diffusionSigma, random);
                    stats2D[j].add(squared(m.getCoordinates()));
                    stats3D[j].add(distance2(m.getCoordinates()));
                }
            }
        }

        // Debug: record all the particles so they can be analysed
        // System.out.printf("%f %f %f\n", m.getX(), m.getY(), m.getZ());
    }
    final double time = (System.nanoTime() - start) / 1000000.0;

    IJ.showStatus("Analysing results ...");
    IJ.showProgress(1);

    if (showDiffusionExample) {
        showExample(totalSteps, diffusionSigma, random);
    }

    // Plot a graph of mean squared distance
    double[] xValues = new double[stats2D.length];
    double[] yValues2D = new double[stats2D.length];
    double[] yValues3D = new double[stats3D.length];
    double[] upper = new double[stats2D.length];
    double[] lower = new double[stats2D.length];
    final CurveFitter<Parametric> fitter2D = new CurveFitter<Parametric>(new LevenbergMarquardtOptimizer());
    final CurveFitter<Parametric> fitter3D = new CurveFitter<Parametric>(new LevenbergMarquardtOptimizer());
    Statistics gradient2D = new Statistics();
    Statistics gradient3D = new Statistics();
    final int firstN = (useConfinement) ? fitN : totalSteps;
    for (int j = 0; j < totalSteps; j++) {
        // Convert steps to seconds
        xValues[j] = (double) (j + 1) / settings.stepsPerSecond;

        // Convert values in pixels^2 to um^2
        final double mean = stats2D[j].getMean() / conversionFactor;
        final double sd = stats2D[j].getStandardDeviation() / conversionFactor;
        yValues2D[j] = mean;
        yValues3D[j] = stats3D[j].getMean() / conversionFactor;
        upper[j] = mean + sd;
        lower[j] = mean - sd;

        if (j < firstN) {
            fitter2D.addObservedPoint(xValues[j], yValues2D[j]);
            gradient2D.add(yValues2D[j] / xValues[j]);
            fitter3D.addObservedPoint(xValues[j], yValues3D[j]);
            gradient3D.add(yValues3D[j] / xValues[j]);
        }
    }

    // TODO - Fit using the equation for 2D confined diffusion:
    // MSD = 4s^2 + R^2 (1 - 0.99e^(-1.84^2 Dt / R^2)
    // s = localisation precision
    // R = confinement radius
    // D = 2D diffusion coefficient
    // t = time

    // Do linear regression to get diffusion rate
    final double[] init2D = { 0, 1 / gradient2D.getMean() }; // a - b x
    final double[] best2D = fitter2D.fit(new PolynomialFunction.Parametric(), init2D);
    final PolynomialFunction fitted2D = new PolynomialFunction(best2D);

    final double[] init3D = { 0, 1 / gradient3D.getMean() }; // a - b x
    final double[] best3D = fitter3D.fit(new PolynomialFunction.Parametric(), init3D);
    final PolynomialFunction fitted3D = new PolynomialFunction(best3D);

    // Create plot
    String title = TITLE;
    Plot2 plot = new Plot2(title, "Time (seconds)", "Mean-squared Distance (um^2)", xValues, yValues2D);
    double[] limits = Maths.limits(upper);
    limits = Maths.limits(limits, lower);
    limits = Maths.limits(limits, yValues3D);
    plot.setLimits(0, totalSteps / settings.stepsPerSecond, limits[0], limits[1]);
    plot.setColor(Color.blue);
    plot.addPoints(xValues, lower, Plot2.LINE);
    plot.addPoints(xValues, upper, Plot2.LINE);
    plot.setColor(Color.magenta);
    plot.addPoints(xValues, yValues3D, Plot2.LINE);
    plot.setColor(Color.red);
    plot.addPoints(new double[] { xValues[0], xValues[xValues.length - 1] },
            new double[] { fitted2D.value(xValues[0]), fitted2D.value(xValues[xValues.length - 1]) },
            Plot2.LINE);
    plot.setColor(Color.green);
    plot.addPoints(new double[] { xValues[0], xValues[xValues.length - 1] },
            new double[] { fitted3D.value(xValues[0]), fitted3D.value(xValues[xValues.length - 1]) },
            Plot2.LINE);
    plot.setColor(Color.black);

    Utils.display(title, plot);

    // For 2D diffusion: d^2 = 4D
    // where: d^2 = mean-square displacement

    double D = best2D[1] / 4.0;
    String msg = "2D Diffusion rate = " + Utils.rounded(D, 4) + " um^2 / sec (" + Utils.timeToString(time)
            + ")";
    IJ.showStatus(msg);
    Utils.log(msg);

    D = best3D[1] / 6.0;
    Utils.log("3D Diffusion rate = " + Utils.rounded(D, 4) + " um^2 / sec (" + Utils.timeToString(time) + ")");

    if (useConfinement)
        Utils.log("3D asymptote distance = %s nm (expected %.2f)",
                Utils.rounded(asymptote.getMean() * settings.pixelPitch, 4),
                3 * settings.confinementRadius / 4);
}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java

private static JFreeChart createStackedBarChart3D(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createStackedBarChart3D("StackedBar Chart 3D Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/* w ww .jav a  2 s  .com*/

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer renderer = (BarRenderer) plot.getRenderer();

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    return chart;

}

From source file:net.sf.mzmine.desktop.impl.projecttree.ProjectTreeMouseHandler.java

public void actionPerformed(ActionEvent e) {

    String command = e.getActionCommand();

    // Actions for raw data files

    if (command.equals("SHOW_TIC")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        TICVisualizerModule.setupNewTICVisualizer(selectedFiles);
    }/*from  w  w w  . j a v  a  2s  . c  o  m*/

    if (command.equals("SHOW_SPECTRUM")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        SpectraVisualizerModule module = MZmineCore.getModuleInstance(SpectraVisualizerModule.class);
        ParameterSet parameters = MZmineCore.getConfiguration()
                .getModuleParameters(SpectraVisualizerModule.class);
        parameters.getParameter(SpectraVisualizerParameters.dataFiles)
                .setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
        MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
        if (exitCode == ExitCode.OK)
            module.runModule(project, parameters, new ArrayList<Task>());
    }

    if (command.equals("SHOW_IDA")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        IDAVisualizerModule.showIDAVisualizerSetupDialog(selectedFiles[0]);

    }

    if (command.equals("SHOW_2D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        TwoDVisualizerModule.show2DVisualizerSetupDialog(selectedFiles[0]);
    }

    if (command.equals("SHOW_3D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        ThreeDVisualizerModule.setupNew3DVisualizer(selectedFiles[0]);
    }

    if (command.equals("SORT_FILES")) {
        // save current selection
        TreePath savedSelection[] = tree.getSelectionPaths();
        RawDataFile selectedFiles[] = tree.getSelectedObjects(RawDataFile.class);
        OrderDataFilesModule module = MZmineCore.getModuleInstance(OrderDataFilesModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(OrderDataFilesModule.class);
        params.getParameter(OrderDataFilesParameters.dataFiles)
                .setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }

    if (command.equals("REMOVE_EXTENSION")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        for (RawDataFile file : selectedFiles) {
            file.setName(FilenameUtils.removeExtension(file.toString()));
        }
        tree.updateUI();
    }

    if (command.equals("REMOVE_FILE")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        PeakList allPeakLists[] = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
        for (RawDataFile file : selectedFiles) {
            for (PeakList peakList : allPeakLists) {
                if (peakList.hasRawDataFile(file)) {
                    String msg = "Cannot remove file " + file.getName()
                            + ", because it is present in the peak list " + peakList.getName();
                    MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), msg);
                    return;
                }
            }
            MZmineCore.getProjectManager().getCurrentProject().removeFile(file);
        }
    }

    // Actions for scans

    if (command.equals("SHOW_SCAN")) {
        Scan selectedScans[] = tree.getSelectedObjects(Scan.class);
        for (Scan scan : selectedScans) {
            SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
        }
    }

    if (command.equals("SHOW_MASSLIST")) {
        MassList selectedMassLists[] = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            SpectraVisualizerWindow window = SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(),
                    scan.getScanNumber());
            MassListDataSet dataset = new MassListDataSet(massList);
            window.addDataSet(dataset, Color.green);
        }
    }

    if (command.equals("REMOVE_MASSLIST")) {
        MassList selectedMassLists[] = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            scan.removeMassList(massList);
        }
    }

    if (command.equals("REMOVE_ALL_MASSLISTS")) {
        MassList selectedMassLists[] = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            String massListName = massList.getName();
            RawDataFile dataFiles[] = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
            for (RawDataFile dataFile : dataFiles) {
                int scanNumbers[] = dataFile.getScanNumbers();
                for (int scanNum : scanNumbers) {
                    Scan scan = dataFile.getScan(scanNum);
                    MassList ml = scan.getMassList(massListName);
                    if (ml != null)
                        scan.removeMassList(ml);
                }
            }
        }
    }

    // Actions for peak lists

    if (command.equals("SHOW_PEAKLIST_TABLES")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            PeakListTableModule.showNewPeakListVisualizerWindow(peakList);
        }
    }

    if (command.equals("SHOW_PEAKLIST_INFO")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            InfoVisualizerModule.showNewPeakListInfo(peakList);
        }
    }

    if (command.equals("SHOW_SCATTER_PLOT")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            ScatterPlotVisualizerModule.showNewScatterPlotWindow(peakList);
        }
    }

    if (command.equals("SORT_PEAKLISTS")) {
        // save current selection
        TreePath savedSelection[] = tree.getSelectionPaths();
        PeakList selectedPeakLists[] = tree.getSelectedObjects(PeakList.class);
        OrderPeakListsModule module = MZmineCore.getModuleInstance(OrderPeakListsModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(OrderPeakListsModule.class);
        params.getParameter(OrderPeakListsParameters.peakLists)
                .setValue(PeakListsSelectionType.SPECIFIC_PEAKLISTS, selectedPeakLists);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }

    if (command.equals("REMOVE_PEAKLIST")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists)
            MZmineCore.getProjectManager().getCurrentProject().removePeakList(peakList);
    }

    // Actions for peak list rows

    if (command.equals("SHOW_PEAK_SUMMARY")) {
        PeakListRow[] selectedRows = tree.getSelectedObjects(PeakListRow.class);
        for (PeakListRow row : selectedRows) {
            PeakSummaryVisualizerModule.showNewPeakSummaryWindow(row);
        }
    }

}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo1.java

protected JFreeChart createLegend(CategoryDataset dataset) {
    domainLabel = "Category";
    rangeLabel = "Value";
    //  JFreeChart chart = ChartFactory.createAreaChart(
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/*from w w w .j  a v  a2 s  . c  o  m*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = chart.getCategoryPlot();

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    // renderer.setDrawOutlines(true);
    // renderer.setUseFillPaint(true);
    // renderer.setFillPaint(Color.white);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    return chart;

}

From source file:lospolloshermanos.BarChart.java

/**
 * Creates a sample chart.//  w w w  .j av  a  2 s.co  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = null;
    if (Title.equals("Categories")) {
        chart = ChartFactory.createBarChart("Sales Chart for Categories vs Quantity", // chart title
                "Categories", // domain axis label
                "Quantity", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
    } else if (Title.equals("Categories 2")) {
        chart = ChartFactory.createBarChart("Sales Chart for Categories Vs Total Amount", // chart title
                "Categories", // domain axis label
                "Sub Total", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
    } else if (Title.equals("Items")) {
        chart = ChartFactory.createBarChart("Top 5 items vs Quantity sales ", // chart title
                "Items", // domain axis label
                "Quantity", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
    } else if (Title.equals("Items 2")) {
        chart = ChartFactory.createBarChart("Top 5 items vs Quantity sales ", // chart title
                "Items", // domain axis label
                "Sub Total", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
    } else if (Title.equals("Ratings")) {
        chart = ChartFactory.createBarChart("Ratings ", // chart title
                "Type", // domain axis label
                "Rating Value", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips?
                false // URLs?
        );
    }

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}