Example usage for java.awt Color RED

List of usage examples for java.awt Color RED

Introduction

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

Prototype

Color RED

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

Click Source Link

Document

The color red.

Usage

From source file:FindHullWindowLogic.java

static void drawPointsOnChart(JPanel panelWhenInside, ArrayList<Point2D> convexHull) {
    panelWhenInside.removeAll();//from w ww  .  j  a  v a 2  s .c  o  m
    panelWhenInside.setLayout(new java.awt.BorderLayout());
    XYSeries seriersAllPoints = new XYSeries("All points");
    addPointsToSeries(seriersAllPoints);

    int pairsNumber = 0;
    if (convexHull != null)
        pairsNumber = convexHull.size() - 1;
    XYSeries covnexHullDivideOnPiars[] = new XYSeries[pairsNumber];

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        covnexHullDivideOnPiars[i] = new XYSeries("Convex hull pair " + i);
    }

    if (convexHull != null) {
        divideOnPairsAndConvertConvexHullIntoSeries(covnexHullDivideOnPiars, convexHull);
    }

    // Add the seriersAllPoints to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(seriersAllPoints);

    for (int i = 0; i < covnexHullDivideOnPiars.length; i++) {
        dataset.addSeries(covnexHullDivideOnPiars[i]);
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart(null, // Title
            null, // x-axis Label
            null, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            false, // Use tooltips
            false // Configure chart to generate URLs?
    );

    final XYPlot plot = chart.getXYPlot();
    ChartPanel chartPanel = new ChartPanel(chart);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3));

    for (int i = 1; i <= covnexHullDivideOnPiars.length; i++) {
        renderer.setSeriesPaint(i, Color.red);
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesStroke(i, new BasicStroke(1.0f));
    }

    plot.setRenderer(renderer);

    panelWhenInside.add(chartPanel, BorderLayout.CENTER);
    panelWhenInside.validate();
}

From source file:com.uniteddev.Unity.Login.java

public static void setup() throws IOException, InterruptedException, FontFormatException {
    //fonts/*from  ww w  .java 2  s . co m*/
    roboto_thin = Font.createFont(Font.TRUETYPE_FONT, Unity.class.getResourceAsStream("/res/Roboto-Thin.ttf"));
    roboto_regular = Font.createFont(Font.TRUETYPE_FONT,
            Unity.class.getResourceAsStream("/res/Roboto-Regular.ttf"));
    // main
    window = new Window(Unity.title, Unity.favicon, Unity.background, 791, 527);
    release = new Label(Unity.release, Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12));
    server_lbl = new Label("Server:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12));
    server_stat_lbl = new Label("Offline", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 12));
    settingsButton = new Button();
    settingsButton.setImage("/res/gear.png");
    settingsButton.removeDecorations();
    settingsButton.addActionListener(new settingsButton_action());
    // splash screen
    update_lbl = new Label("Updating", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32));
    progress = new ProgressBar(new Color(255, 255, 255, 100), new Color(255, 255, 255, 255));
    progress.removeDecorations();
    progressText = new Label("Ready.", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    // login screen
    username = new TextField(prefs.get("username", ""), Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    password = new PasswordField(Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    username_lbl = new Label("Username:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    password_lbl = new Label("Password:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    loginButton = new Button("Login", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28));
    loginButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1));
    loginButton.center();
    loginButton.addActionListener(new loginButton_action());
    invalid_login_lbl = new Label("Invalid Login", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14));
    invalid_login_lbl.setVisible(false);
    // settings screen
    settings_lbl = new Label("Settings", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32));
    deleteButton = new Button();
    deleteButton.setImage("/res/recycle.png");
    deleteButton.removeDecorations();
    deleteButton.addActionListener(new deleteButton_action());
    ram_size = new TextField(prefs.get("ram_size", default_ram), Color.WHITE,
            roboto_regular.deriveFont(Font.PLAIN, 14));
    ram_lbl = new Label("RAM Usage (MB):", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    invalid_ram_lbl = new Label(Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14));
    invalid_ram_lbl.setVisible(false);
    saveButton = new Button("Save", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28));
    saveButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1));
    saveButton.center();
    saveButton.addActionListener(new saveButton_action());
    // sizing and layout
    release.setBounds(5, window.getHeight() - 50, 140, 20);
    server_lbl.setBounds(5, window.getHeight() - 50, 140, 20);
    server_stat_lbl.setBounds(45, window.getHeight() - 50, 200, 20);
    update_lbl.setBounds(115, 20, 320, 50);
    progress.setBounds(20, 75, 320, 10);
    progressText.setBounds(20, 90, 320, 20);
    username.setBounds(155, 30, 115, 20);
    password.setBounds(155, 60, 115, 20);
    username_lbl.setBounds(80, 30, 115, 20);
    password_lbl.setBounds(79, 60, 115, 20);
    loginButton.setBounds(110, 110, 140, 40);
    invalid_login_lbl.setBounds(135, 165, 140, 20);
    settingsButton.setBounds(window.getWidth() - 45, window.getHeight() - 65, 32, 32);
    settings_lbl.setBounds(115, 5, 320, 50);
    deleteButton.setBounds(155, 50, 32, 32);
    ram_size.setBounds(175, 90, 115, 20);
    ram_lbl.setBounds(60, 90, 115, 20);
    saveButton.setBounds(110, 125, 140, 40);
    // setup screens
    login_window = new Label();
    login_window.setBounds(216, 180, 360, 200);
    login_window.add(update_lbl);
    login_window.add(progress);
    login_window.add(progressText);
    login_window.add(username);
    login_window.add(password);
    login_window.add(username_lbl);
    login_window.add(password_lbl);
    login_window.add(loginButton);
    login_window.add(invalid_login_lbl);
    login_window.add(settings_lbl);
    login_window.add(deleteButton);
    login_window.add(ram_size);
    login_window.add(invalid_ram_lbl);
    login_window.add(ram_lbl);
    login_window.add(saveButton);
    // setup and show window
    window.addComponent(release);
    window.addComponent(server_lbl);
    window.addComponent(server_stat_lbl);
    window.addComponent(login_window);
    window.addComponent(settingsButton);
    window.getRootPane().setDefaultButton(loginButton);
    window.setLocationRelativeTo(null);
    release.setVisible(false);
    window.setVisible(true);
    start();
}

From source file:facturas.Facture.java

/**
 * Creates new form Facture//from www. j ava2  s .  co m
 */
public Facture() {
    initComponents();
    setIconImage(new ImageIcon(getClass().getResource("/Images/icono.png")).getImage());
    this.setTitle("Facture Application");
    this.setLocationRelativeTo(null);
    getRootPane().setDefaultButton(jButtonPrecioTotal);
    //Hacemos que los campos jText Field siguientes no puedan ser editables
    jTextFieldIva.setEditable(false);
    jTextFieldIva.setForeground(Color.BLUE);
    jTextFieldIva1.setEditable(false);
    jTextFieldIva1.setForeground(Color.BLUE);
    jTextFieldIva2.setEditable(false);
    jTextFieldIva2.setForeground(Color.BLUE);
    jTextFieldIva3.setEditable(false);
    jTextFieldIva3.setForeground(Color.BLUE);
    jTextFieldTotal.setEditable(false);
    jTextFieldTotal.setForeground(Color.BLUE);
    jTextFieldTotal1.setEditable(false);
    jTextFieldTotal1.setForeground(Color.BLUE);
    jTextFieldTotal2.setEditable(false);
    jTextFieldTotal2.setForeground(Color.BLUE);
    jTextFieldTotal3.setEditable(false);
    jTextFieldTotal3.setForeground(Color.BLUE);
    jTextFieldTotalPrice.setEditable(false);
    jTextFieldTotalPrice.setForeground(Color.RED);
    jTextFieldTotalPrice.setBackground(Color.LIGHT_GRAY);
}

From source file:org.jfree.chart.demo.SurveyResultsDemo1.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart(null, null, null, categorydataset,
            PlotOrientation.HORIZONTAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "Figure 7 | I. Resources - The site offers users relevant, informative and educational resources");
    texttitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
    texttitle.setBackgroundPaint(Color.red);
    texttitle.setPaint(Color.white);
    jfreechart.setTitle(texttitle);/*  w w w.j  a v  a  2 s  .c  o m*/
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setOutlinePaint(null);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryplot.setDomainGridlineStroke(new BasicStroke(0.5F));
    categoryplot.setDomainGridlinePaint(Color.black);
    categoryplot.setRangeGridlinesVisible(false);
    categoryplot.clearRangeMarkers();
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setVisible(false);
    categoryaxis.setCategoryMargin(0.5D);
    categoryplot.getRangeAxis().setVisible(false);
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setSeriesPaint(0, new Color(156, 164, 74));
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelFont(new Font("SansSerif", 1, 10));
    ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
    CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("1. White papers are available.",
            "Category 1", 0.0D);
    categorytextannotation.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation);
    CategoryTextAnnotation categorytextannotation1 = new CategoryTextAnnotation(
            "2. White papers enhance users understanding of the firm and its expertise.", "Category 2", 0.0D);
    categorytextannotation1.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation1.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation1);
    CategoryTextAnnotation categorytextannotation2 = new CategoryTextAnnotation(
            "3. White papers are relevant to the firm's prospects and clients.", "Category 3", 0.0D);
    categorytextannotation2.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation2.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation2);
    CategoryTextAnnotation categorytextannotation3 = new CategoryTextAnnotation(
            "4. White papers are relevant to the firm's positioning.", "Category 4", 0.0D);
    categorytextannotation3.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation3.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation3);
    CategoryTextAnnotation categorytextannotation4 = new CategoryTextAnnotation(
            "5. Case studies are available.", "Category 5", 0.0D);
    categorytextannotation4.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation4.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation4);
    CategoryTextAnnotation categorytextannotation5 = new CategoryTextAnnotation(
            "6. Case studies enhance users understanding of the firm and its expertise.", "Category 6", 0.0D);
    categorytextannotation5.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation5.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation5.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation5);
    CategoryTextAnnotation categorytextannotation6 = new CategoryTextAnnotation(
            "7. Case studies are relevant to the firm's prospects and clients.", "Category 7", 0.0D);
    categorytextannotation6.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation6.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation6.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation6);
    CategoryTextAnnotation categorytextannotation7 = new CategoryTextAnnotation(
            "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0D);
    categorytextannotation7.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation7.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation7.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation7);
    CategoryTextAnnotation categorytextannotation8 = new CategoryTextAnnotation(
            "9. Case studies are available.", "Category 9", 0.0D);
    categorytextannotation8.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation8.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation8.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation8);
    CategoryTextAnnotation categorytextannotation9 = new CategoryTextAnnotation(
            "10. Case studies enhance users understanding of the firm and its expertise.", "Category 10", 0.0D);
    categorytextannotation9.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation9.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation9.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation9);
    CategoryTextAnnotation categorytextannotation10 = new CategoryTextAnnotation(
            "11. Case studies are relevant to the firm's prospects and clients.", "Category 11", 0.0D);
    categorytextannotation10.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation10.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation10.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation10);
    CategoryTextAnnotation categorytextannotation11 = new CategoryTextAnnotation(
            "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0D);
    categorytextannotation11.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation11.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation11.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation11);
    CategoryTextAnnotation categorytextannotation12 = new CategoryTextAnnotation(
            "13. Users can easily access resources based on viewer interest.", "Category 13", 0.0D);
    categorytextannotation12.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation12.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation12.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation12);
    CategoryTextAnnotation categorytextannotation13 = new CategoryTextAnnotation(
            "14. Access to additional hyperlinks enhances users's ability to find relevant information.",
            "Category 14", 0.0D);
    categorytextannotation13.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation13.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation13.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation13);
    CategoryTextAnnotation categorytextannotation14 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.",
            "Overall", 0.0D);
    categorytextannotation14.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation14.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation14.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation14);
    return jfreechart;
}

From source file:Main.java

public Main() {
    Container content = getContentPane();
    content.setLayout(new FlowLayout());
    JLabel jl = new JLabel("          Calculator                ");
    textField = new JTextField(15);
    num1 = new JButton(" 1 ");
    num2 = new JButton(" 2 ");
    num3 = new JButton(" 3 ");
    num4 = new JButton(" 4 ");
    num5 = new JButton(" 5 ");
    num6 = new JButton(" 6 ");
    num7 = new JButton(" 7 ");
    num8 = new JButton(" 8 ");
    num9 = new JButton(" 9 ");
    num0 = new JButton(" 0 ");
    add = new JButton(" + ");
    sub = new JButton("  -  ");
    div = new JButton("  / ");
    mult = new JButton(" *  ");
    equalto = new JButton(" = ");
    exit = new JButton("    Exit     ");
    point = new JButton("  . ");
    reset = new JButton("C");
    reset.setBackground(Color.RED);
    num1.addActionListener(this);
    num2.addActionListener(this);
    num3.addActionListener(this);
    num4.addActionListener(this);
    num5.addActionListener(this);
    num6.addActionListener(this);
    num7.addActionListener(this);
    num8.addActionListener(this);
    num9.addActionListener(this);
    num0.addActionListener(this);
    add.addActionListener(this);
    sub.addActionListener(this);
    mult.addActionListener(this);
    div.addActionListener(this);
    equalto.addActionListener(this);
    exit.addActionListener(this);
    point.addActionListener(this);
    reset.addActionListener(this);
    content.add(jl);//from www  . ja v  a2  s  .co m
    content.add(textField);
    content.add(num1);
    content.add(num2);
    content.add(num3);
    content.add(add);
    content.add(num4);
    content.add(num5);
    content.add(num6);
    content.add(sub);
    content.add(num7);
    content.add(num8);
    content.add(num9);
    content.add(div);
    content.add(num0);
    content.add(point);
    content.add(mult);
    content.add(equalto);
    content.add(reset);
    content.add(exit);
}

From source file:org.jfree.chart.demo.MemoryUsageDemo.java

public MemoryUsageDemo(int i) {
    super(new BorderLayout());
    total = new TimeSeries("Total Memory");
    total.setMaximumItemAge(i);//from   w  ww  .ja  va  2s .  co m
    free = new TimeSeries("Free Memory");
    free.setMaximumItemAge(i);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(total);
    timeseriescollection.addSeries(free);
    DateAxis dateaxis = new DateAxis("Time");
    NumberAxis numberaxis = new NumberAxis("Memory");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberaxis.setLabelFont(new Font("SansSerif", 0, 14));
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.red);
    xylineandshaperenderer.setSeriesPaint(1, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F, 0, 2));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart jfreechart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), xyplot, true);
    jfreechart.setBackgroundPaint(Color.white);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(chartpanel);
}

From source file:juicebox.tools.utils.juicer.apa.APAPlotter.java

/**
 * Method for plotting apa data//from   w w w  . j a  v  a 2  s.  c  o  m
 *
 * @param data       for heat map
 * @param axesRange  initial values and increments to annotate axes [x0, dx, y0, dy]
 * @param outputFile where image will saved
 */
public static void plot(RealMatrix data, int[] axesRange, File outputFile, String title) {

    APARegionStatistics apaStats = new APARegionStatistics(data);
    DecimalFormat df = new DecimalFormat("0.000");
    title += ", P2LL = " + df.format(apaStats.getPeak2LL());

    // initialize heat map
    HeatChart map = new HeatChart(data.getData());
    map.setLowValueColour(Color.WHITE);
    map.setHighValueColour(Color.RED);
    map.setXValues(axesRange[0], axesRange[1]);
    map.setYValues(axesRange[2], axesRange[3]);
    map.setTitle(title);

    try {
        // calculate dimensions for plot wrapper
        initializeSizes(map);

        // create blank white image
        BufferedImage apaImage = new BufferedImage(fullWidth, fullHeight, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = apaImage.createGraphics();
        g2.setBackground(Color.WHITE);
        g2.fillRect(0, 0, fullWidth, fullHeight);

        // plot in heat map, color bar, etc
        g2.drawImage(map.getChartImage(), 0, 0, heatmapWidth, fullHeight, null);
        drawHeatMapBorder(g2, map);
        plotColorScaleBar(g2);
        plotColorScaleValues(g2, map);

        // top left, top right, bottom left, bottom right values (from apa)

        drawCornerRegions(g2, map, new Dimension(APA.regionWidth, APA.regionWidth),
                apaStats.getRegionCornerValues());

        // save data
        ImageIO.write(apaImage, "png", outputFile);

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

From source file:com.crunchify.jsp.servlet.BarServlet.java

public JFreeChart getChart() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(15, "1", "451");
    dataset.addValue(12, "1", "851");
    dataset.addValue(10, "2", "362");
    dataset.addValue(5, "2", "142");

    JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 3", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            false, // include legend
            true, false);/*from w  w w .ja  v a2 s.c  o  m*/

    chart.setBackgroundPaint(Color.lightGray);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setNoDataMessage("NO DATA!");

    CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green,
            Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue });

    renderer.setItemLabelsVisible(true);
    ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER,
            45.0);
    renderer.setPositiveItemLabelPosition(p);
    plot.setRenderer(renderer);

    // change the margin at the top of the range axis...
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    return chart;

}

From source file:de.berlios.statcvs.xml.report.AuthorsActivityChart.java

public AuthorsActivityChart(CvsContent content, ReportSettings settings) {
    super(settings, "activity.png", I18n.tr("Author Activity"), null, "%");

    CategoryPlot plot = getChart().getCategoryPlot();
    plot.getRenderer().setSeriesPaint(REMOVING, Color.red);
    plot.getRenderer().setSeriesPaint(CHANGING, Color.yellow);
    plot.getRenderer().setSeriesPaint(ADDING, Color.green);
    plot.getRangeAxis().setUpperBound(100);

    Collection auts = content.getAuthors();
    Iterator it = auts.iterator();
    while (it.hasNext()) {
        Author author = (Author) it.next();
        authors.add(author.getName());/*from  ww  w. ja  v a 2s.c  om*/
    }
    Collections.sort(authors);
    double[][] categories;
    categories = new double[3][authors.size()];
    for (int j = 0; j < authors.size(); j++) {
        categories[REMOVING][j] = 0;
        categories[CHANGING][j] = 0;
        categories[ADDING][j] = 0;
    }

    Iterator revIt = settings.getRevisionIterator(content);
    CommitListBuilder commitList = new CommitListBuilder(revIt);
    List commits = commitList.createCommitList();
    Iterator commitIt = commits.iterator();
    while (commitIt.hasNext()) {
        Commit commit = (Commit) commitIt.next();
        Set commitRevList = commit.getRevisions();
        Iterator commitRevIt = commitRevList.iterator();
        int author = authors.indexOf(commit.getAuthor().getName());
        int linesAdded = 0;
        int linesRemoved = 0;
        while (commitRevIt.hasNext()) {
            CvsRevision revision = (CvsRevision) commitRevIt.next();
            linesAdded += revision.getNewLines();
            linesRemoved += revision.getNewLines() - revision.getReplacedLines();
        }
        if (linesAdded == linesRemoved) {
            categories[CHANGING][author] += linesAdded;
        }
        if (linesAdded < linesRemoved) {
            categories[CHANGING][author] += linesAdded;
            categories[REMOVING][author] += linesRemoved - linesAdded;
        }
        if (linesAdded > linesRemoved) {
            categories[ADDING][author] += linesAdded - linesRemoved;
            categories[CHANGING][author] += linesRemoved;
        }
    }

    for (int i = 0; i < authors.size(); i++) {
        double maxLines = categories[REMOVING][i] + categories[CHANGING][i] + categories[ADDING][i];
        for (int k = 0; k < 3; k++) {
            categories[k][i] *= (100 / maxLines);
            dataset.addValue(categories[k][i], topics[k], (String) authors.get(i));
        }
    }
    setup(true);
}

From source file:org.mc.okapi.Plot.java

public Plot(double[] X, double[] Y, String xLab, String yLab, String seriesName, String applicationTitle,
        String chartTitle) {/*from w w  w  .j a va2  s .  co  m*/
    super(applicationTitle);

    XYSeries series = new XYSeries(seriesName);

    for (int i = 0; i < X.length; i++) {
        series.add(X[i], Y[i]);
    }
    // create a dataset...
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    // based on the dataset we create the chart        
    JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, xLab, yLab, dataset, PlotOrientation.VERTICAL,
            true, rootPaneCheckingEnabled, rootPaneCheckingEnabled);
    Shape cross = ShapeUtilities.createDiagonalCross(3, 1);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesShape(0, cross);
    renderer.setSeriesPaint(0, Color.red);

    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    setIconImage(Toolkit.getDefaultToolkit().getImage("images/ico/extra/science_32.png"));

    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}