Example usage for java.awt Color orange

List of usage examples for java.awt Color orange

Introduction

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

Prototype

Color orange

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

Click Source Link

Document

The color orange.

Usage

From source file:whitebox.stats.Kriging.java

/**
 * Draw Semivariogram surface map and also draw the search are if
 * Anisotropic//from ww w  . j  a v a  2  s .  c  o  m
 *
 * @param Radius
 * @param AnIsotropic
 */
public void DrawSemivariogramSurface(double Radius, boolean AnIsotropic) {
    double[][] data = new double[3][BinSurface.length * BinSurface[0].length];
    int n = 0;
    double max = Double.MIN_VALUE;
    for (int i = 0; i < BinSurface.length; i++) {
        for (int j = 0; j < BinSurface[i].length; j++) {
            data[0][n] = BinSurface[i][j].GridHorDistance;
            data[1][n] = BinSurface[i][j].GridVerDistance;
            if ((Math.pow(data[0][n], 2) + Math.pow(data[1][n], 2)) <= Radius * Radius
                    && !Double.isNaN(BinSurface[i][j].Value)) {
                data[2][n] = BinSurface[i][j].Value;
                if (max < data[2][n]) {
                    max = data[2][n];
                }
            } else {
                data[2][n] = -1;
            }
            n++;
        }
    }
    DefaultXYZDataset dataset = new DefaultXYZDataset();
    dataset.addSeries("Value", data);
    NumberAxis xAxis = new NumberAxis();

    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBlockWidth(LagSize);
    renderer.setBlockHeight(LagSize);
    renderer.setBlockAnchor(RectangleAnchor.CENTER);

    LookupPaintScale paintScale = new LookupPaintScale(0, max, Color.white);
    double colorRange = max / 6;
    //double colorRange = 23013;
    paintScale.add(0.0, Color.blue);
    paintScale.add(1 * colorRange, Color.green);
    paintScale.add(2 * colorRange, Color.cyan);
    paintScale.add(3 * colorRange, Color.yellow);
    paintScale.add(4 * colorRange, Color.ORANGE);
    paintScale.add(5 * colorRange, Color.red);

    renderer.setPaintScale(paintScale);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.white);

    if (AnIsotropic) {
        CombinedRangeXYPlot combinedrangexyplot = new CombinedRangeXYPlot();
        XYSeries seriesT1 = new XYSeries("1");
        XYSeriesCollection AngleCollct = new XYSeriesCollection();

        double bw = BandWidth;
        double r = bw / Math.sin(Tolerance);
        if (r > Radius) {
            bw = Radius * Math.sin(Tolerance);
            r = Radius;
        }
        seriesT1.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance));

        if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) {
            if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) {
                double a = (1 + Math.pow(Math.tan(Angle), 2));
                double b = 2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2);
                double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2)
                        - Math.pow(Radius, 2);
                double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y1 = Math.tan(Angle) * (x1 + bw / Math.sin(Angle));
                double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y2 = Math.tan(Angle) * (x2 + bw / Math.sin(Angle));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));
                if (d1 < d2) {
                    seriesT1.add(x1, y1);
                } else {
                    seriesT1.add(x2, y2);
                }
            } else {
                double x1 = -bw * Math.sin(Angle);
                double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));

                if (d1 < d2) {
                    seriesT1.add(x1, y1);
                } else {
                    seriesT1.add(x1, y2);
                }
            }
        } else {
            double y1 = bw * Math.cos(Angle);
            double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
            double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));

            if (d1 < d2) {
                seriesT1.add(x1, y1);
            } else {
                seriesT1.add(x2, y1);
            }
        }

        AngleCollct.addSeries(seriesT1);

        XYSeries seriesT2 = new XYSeries("2");
        seriesT2.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance));
        seriesT2.add(0.0, 0.0);
        AngleCollct.addSeries(seriesT2);

        XYSeries seriesT3 = new XYSeries("3");
        seriesT3.add(Radius * Math.cos(Angle), Radius * Math.sin(Angle));
        seriesT3.add(0, 0);
        AngleCollct.addSeries(seriesT3);

        XYSeries seriesT4 = new XYSeries("4");
        seriesT4.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance));
        seriesT4.add(0, 0);
        AngleCollct.addSeries(seriesT4);

        XYSeries seriesT5 = new XYSeries("5");

        seriesT5.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance));
        if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) {
            if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) {
                double a = (1 + Math.pow(Math.tan(Angle), 2));
                double b = -2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2);
                double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2)
                        - Math.pow(Radius, 2);
                double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y1 = Math.tan(Angle) * (x1 - bw / Math.sin(Angle));
                double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y2 = Math.tan(Angle) * (x2 - bw / Math.sin(Angle));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));
                if (d1 < d2) {
                    seriesT5.add(x1, y1);
                } else {
                    seriesT5.add(x2, y2);
                }
            } else {
                double x1 = bw * Math.sin(Angle);
                double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));

                if (d1 < d2) {
                    seriesT5.add(x1, y1);
                } else {
                    seriesT5.add(x1, y2);
                }
            }
        } else {
            double y1 = -bw * Math.cos(Angle);
            double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
            double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));

            if (d1 < d2) {
                seriesT5.add(x1, y1);
            } else {
                seriesT5.add(x2, y1);
            }
        }
        AngleCollct.addSeries(seriesT5);
        plot.setDataset(1, AngleCollct);
        XYLineAndShapeRenderer lineshapRend = new XYLineAndShapeRenderer(true, false);
        for (int i = 0; i < AngleCollct.getSeriesCount(); i++) {
            //plot.getRenderer().setSeriesPaint(i , Color.BLUE);
            lineshapRend.setSeriesPaint(i, Color.BLACK);
        }
        plot.setRenderer(1, lineshapRend);
        combinedrangexyplot.add(plot);
    }
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    JFreeChart chart = new JFreeChart("Semivariogram Surface", plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);

    // create and display a frame...
    ChartFrame frame = new ChartFrame("", chart);
    frame.pack();
    //frame.setSize(100, 50);
    frame.setVisible(true);
}

From source file:net.liuxuan.device.VACVBS.JIF_DrawChart_vacvbs.java

/**
 * ?jfreechart//  w  w  w  .jav  a  2  s  . co m
 */
public void initChart() {
    ts_LP = new TimeSeries("LowPressure", Millisecond.class);
    ts_HP = new TimeSeries("HighPressure", Millisecond.class);
    ts_humidity = new TimeSeries("Humidity", Millisecond.class);
    ts_temprature = new TimeSeries("Temperature", Millisecond.class);
    ts_time = new TimeSeries("TestTime", Millisecond.class);
    ts_num = new TimeSeries("num", Millisecond.class);
    ts_reserved1 = new TimeSeries("reserved1", Millisecond.class);
    ts_reserved2 = new TimeSeries("reserved2", Millisecond.class);
    ts_reserved3 = new TimeSeries("reserved3", Millisecond.class);
    trcollection = new TimeSeriesCollection(ts_LP);

    trcollection.addSeries(ts_HP);

    trcollection2 = new TimeSeriesCollection(ts_humidity);

    trcollection2.addSeries(ts_temprature);

    //        trcollection2.addSeries(ts_num);
    //        trcollection2.addSeries(ts_time);
    //trcollection2.addSeries(ts_reserved1);
    //trcollection2.addSeries(ts_reserved2);
    //trcollection2.addSeries(ts_reserved3);

    //        timeseriescopylist.add(getTimeSeries(3).createCopy(0, getTimeSeries(3).getItemCount() - 1));
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("", "Time(s)", "PPM", trcollection,
            true, true, false);
    XYPlot xyplot = jfreechart.getXYPlot();

    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    Font fs = new Font("", Font.BOLD, 14);
    Font fs2 = new Font("", Font.BOLD, 12);

    XYLineAndShapeRenderer line0render = (XYLineAndShapeRenderer) xyplot.getRenderer(0);

    Color purple = new Color(139, 0, 255);

    line0render.setSeriesPaint(0, Color.blue);
    line0render.setSeriesPaint(1, Color.green);
    line0render.setSeriesPaint(2, Color.red);
    line0render.setSeriesPaint(3, purple);

    //        line0render.setSeriesPaint(3, Color.ORANGE);
    XYLineAndShapeRenderer line1render = new XYLineAndShapeRenderer();
    Color Rosered = new Color(230, 28, 100);
    line1render.setSeriesPaint(0, Color.cyan);
    line1render.setSeriesPaint(1, Rosered);
    line1render.setSeriesPaint(2, Color.orange);
    line1render.setSeriesPaint(3, Color.yellow);
    line1render.setBaseShapesVisible(false);
    xyplot.setRenderer(1, line1render);

    //??
    ValueAxis valueaxis = xyplot.getDomainAxis();

    //
    valueaxis.setLabelFont(fs);

    //
    valueaxis.setTickLabelFont(fs2);

    ValueAxis valueaxis2 = new NumberAxis("");
    valueaxis2.setLabelFont(fs);
    valueaxis2.setTickLabelFont(fs2);

    xyplot.setRangeAxis(1, valueaxis2);
    xyplot.setDataset(1, trcollection2);
    xyplot.mapDatasetToRangeAxis(1, 1);

    //??
    valueaxis.setAutoRange(true);
    //?? 7days
    //                valueaxis.setFixedAutoRange(604800000D);
    valueaxis = xyplot.getRangeAxis();

    valueaxis.setLabelFont(new Font("", Font.BOLD, 14));
    valueaxis.setLabelPaint(line0render.getSeriesPaint(0));
    valueaxis2.setLabelPaint(line1render.getSeriesPaint(0));

    jfreechart.getTitle().setFont(new Font("", Font.BOLD, 20));//
    jfreechart.getLegend().setItemFont(new Font("", Font.ITALIC, 15));
    xyplot.getRenderer(0).setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator("{1}, {2}",
            new SimpleDateFormat("MM-dd HH:mm:ss"), new DecimalFormat("0.0000")));
    xyplot.getRenderer(1).setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator("{1}, {2}",
            new SimpleDateFormat("MM-dd HH:mm:ss"), new DecimalFormat("0.0000")));
    chartPanel = new ChartPanel(jfreechart);

    initChartMenu();
    //        chartPanel.getPopupMenu().add(jmenuitem2);
    //        chartPanel.getPopupMenu().getPopupMenuListeners();

    chartPanel.setSize(950, 620);
    chartPanel.setPreferredSize(new Dimension(950, 620));
    jPanel_Show.add(chartPanel, BorderLayout.CENTER);
}

From source file:com.planetmayo.debrief.satc_rcp.views.SpatialView.java

private void plotTargetSolution(List<State> solution) {
    // ok, get the target solution data
    if (_settings.isShowTargetSolution()) {
        Coordinate[] coords = new Coordinate[solution.size()];
        int ctr = 0;
        for (Iterator<State> iterator = solution.iterator(); iterator.hasNext();) {
            State thisState = (State) iterator.next();
            Coordinate coord = new Coordinate(thisState.getLocation().getY(), thisState.getLocation().getX());
            coords[ctr++] = coord;//from  ww w .ja v  a 2 s .c o m
        }
        plotTheseCoordsAsALine("Solution", coords, Color.ORANGE);

        // get the series num
        int num = _myData.getSeriesCount() - 1;
        _renderer.setSeriesStroke(num, new BasicStroke(3));

    }
}

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

private static JFreeChart createWaterfallChart(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);

    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    WaterfallBarRenderer renderer = new WaterfallBarRenderer();
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
                TextAnchor.CENTER, Math.PI / 2.0);
        renderer.setBasePositiveItemLabelPosition(position);
        renderer.setBaseNegativeItemLabelPosition(position);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0);
        renderer.setBasePositiveItemLabelPosition(position);
        renderer.setBaseNegativeItemLabelPosition(position);
    }/*w w w.  j  a  v  a2s .  c om*/
    if (tooltips) {
        StandardCategoryToolTipGenerator generator = new StandardCategoryToolTipGenerator();
        renderer.setBaseToolTipGenerator(generator);
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.clearRangeMarkers();
    Marker baseline = new ValueMarker(0.0);
    baseline.setPaint(Color.black);
    plot.addRangeMarker(baseline, Layer.FOREGROUND);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart("Waterfall Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    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));
    //        AbstractRenderer#setSeriesPaint(int, Paint) are ignored;
    //        renderer.setSeriesPaint(0, gp0);
    //        renderer.setSeriesPaint(1, gp1);
    //        renderer.setSeriesPaint(2, gp2);

    //??
    renderer.setFirstBarPaint(gp0);
    renderer.setLastBarPaint(gp2);
    renderer.setPositiveBarPaint(Color.orange);
    renderer.setNegativeBarPaint(Color.cyan);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;

}

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

private void updateSeeingCategory(double seeing) {
    if (seeing < 0.8) {
        categoryField.setText("GOOD");
        categoryField.setBackground(Color.green);
    } else if (seeing < 1.3) {
        categoryField.setText("AVERAGE");
        categoryField.setBackground(Color.orange);
    } else if (seeing < 2.0) {
        categoryField.setText("POOR");
        categoryField.setBackground(Color.red);
    } else {/*w  w  w  . j  av a 2s. co m*/
        categoryField.setText("USABLE");
        categoryField.setBackground(Color.cyan.darker());
    }
}

From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java

/**
 * This lays the layers over each other/*from w w w.  j  a  v a2s.  c  o m*/
 * @param chart
 */
private void renderLayeredBarChart(JFreeChart chart) {
    //      get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setRowRenderingOrder(SortOrder.DESCENDING);

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

    // disable bar outlines...
    final LayeredBarRenderer renderer = (LayeredBarRenderer) 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.black);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.black);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.black);
    final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.orange, 0.0f, 0.0f, Color.black);

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setSeriesPaint(3, gp3);

}

From source file:org.mathIT.gui.GraphViewer.java

/**
 * Gets relevance clusters for this graph and marks them in the canvas. 
 *///from   w  w w  . j a va  2 s.  c  o m
private void displayRelevanceClusters() {
    ArrayList<OrderedSet<Integer>> list = invokerGraph.getRelevanceClusters().getClusters();

    // Change the vertex color palette to mark the most relevant vertices red:
    palette = new java.awt.Color[] { java.awt.Color.YELLOW, // category 0
            java.awt.Color.BLUE, // category 1
            java.awt.Color.GREEN, // category 2
            java.awt.Color.MAGENTA, // category 3 
            java.awt.Color.RED, // category 4
            java.awt.Color.ORANGE, java.awt.Color.CYAN, java.awt.Color.LIGHT_GRAY, java.awt.Color.PINK,
            java.awt.Color.BLACK };

    // add a listener for ToolTips
    canvas.setVertexToolTipTransformer(new ToStringLabeller<V>() {
        /* (non-Javadoc)
         * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object)
         */
        @Override
        @SuppressWarnings("unchecked")
        public String transform(V v) {
            if (v instanceof Graph) {
                return ((Graph<V>) v).getVertices().toString();
            }
            //return super.transform((V) v);
            return "Network relevance: "
                    + org.mathIT.util.Formats.O_DOT_A3.format(invokerGraph.getRelevance(v.getIndex()));
        }
    });
    // ---- Vertex color: ----
    canvas.getRenderer().setVertexRenderer(new VertexFillColor(list));
    canvas.repaint();
}

From source file:com.voterData.graph.Graph.java

public static JFreeChart getRaceDistbn2012(Map<String, Double> dataMap) {
    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    for (String key : dataMap.keySet()) {
        if (key.equals("A_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Asian", "REP");
        } else if (key.equals("B_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "REP");
        } else if (key.equals("I_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "REP");
        } else if (key.equals("O_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Other", "REP");
        } else if (key.equals("M_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "REP");
        } else if (key.equals("U_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "REP");
        } else if (key.equals("W_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "White", "REP");
        } else if (key.equals("A_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Asian", "DEM");
        } else if (key.equals("B_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "DEM");
        } else if (key.equals("I_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "DEM");
        } else if (key.equals("O_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Other", "DEM");
        } else if (key.equals("M_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "DEM");
        } else if (key.equals("U_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "DEM");
        } else if (key.equals("W_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "White", "DEM");
        } else if (key.equals("A_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Asian", "UNA");
        } else if (key.equals("B_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "UNA");
        } else if (key.equals("I_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "UNA");
        } else if (key.equals("O_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Other", "UNA");
        } else if (key.equals("M_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "UNA");
        } else if (key.equals("U_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "UNA");
        } else if (key.equals("W_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "White", "UNA");
        }/*from  w w w  .j a  v a2 s .co m*/
    }

    JFreeChart jfreechart = ChartFactory.createBarChart("Race Distribution - 2012", "Party", "% of votes",
            defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    BarRenderer renderer = (BarRenderer) categoryplot.getRenderer();

    renderer.setDrawBarOutline(false);
    renderer.setSeriesPaint(0, Color.cyan);
    renderer.setSeriesPaint(1, Color.pink);
    renderer.setSeriesPaint(2, Color.red);
    renderer.setSeriesPaint(3, Color.orange);
    renderer.setSeriesPaint(4, Color.green);
    renderer.setSeriesPaint(5, Color.yellow);
    renderer.setSeriesPaint(6, Color.magenta);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator());
    renderer.setItemLabelsVisible(true);
    categoryplot.setRenderer(renderer);

    return jfreechart;

}

From source file:de.xirp.chart.ChartManager.java

/**
 * Sets some values on the given/* w  w w.j ava2 s  .c o m*/
 * {@link org.jfree.chart.plot.XYPlot} corresponding to some
 * options of the {@link de.xirp.chart.ChartOptions}
 * field. <br>
 * <br>
 * If <code>options.is(OptionName.SHOW_THRESHOLD)</code> is
 * <code>true</code> a threshold line is painted to the chart
 * using the <code>threshold</code> field. <br>
 * <br>
 * If <code>options.is(OptionName.USE_RELATIVE)</code> is
 * <code>true</code> the date axis of the plot gets a title
 * indicating that relative values are used. If the flag is
 * <code>false</code> the plot gets a title indicating that
 * absolute values are used.
 * 
 * @param plot
 *            The plot to alter.
 * @param start
 *            The start time.
 * @see de.xirp.chart.ChartOptions
 * @see org.jfree.chart.plot.XYPlot
 */
private static void setXYPlot(XYPlot plot, Date start) {
    plot.setNoDataMessage(NO_DATA_AVAILABLE);

    if (options.is(OptionName.SHOW_THRESHOLD)) {
        Marker marker = new ValueMarker(threshold);
        marker.setPaint(Color.orange);
        marker.setAlpha(0.8f);
        plot.addRangeMarker(marker);
    }

    if (options.is(OptionName.USE_RELATIVE)) {
        DateAxis axis = new DateAxis(I18n.getString("ChartManager.text.relativeTime")); //$NON-NLS-1$
        RelativeDateFormat rdf = new RelativeDateFormat(start);
        axis.setDateFormatOverride(rdf);
        plot.setDomainAxis(axis);
    } else {
        plot.setDomainAxis(new DateAxis(I18n.getString("ChartManager.text.absoluteTime"))); //$NON-NLS-1$
    }
}

From source file:pcd3.View.java

private void pilihGambarCitraMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pilihGambarCitraMouseClicked
    final String path = "./Citra Images/form.1";

    javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();
    chooser.setCurrentDirectory(new File(path));

    chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
        public final static String jpeg = "jpeg";
        public final String jpg = "jpg";
        public final String gif = "gif";
        public final String tiff = "tiff";
        public final String tif = "tif";
        public final String png = "png";

        /*Get the extension of a file.*/
        public String getExtension(java.io.File f) {
            String ext = null;//from   w w w. ja  v a2  s  .com
            String s = f.getName();
            int i = s.lastIndexOf('.');

            if (i > 0 && i < s.length() - 1) {
                ext = s.substring(i + 1).toLowerCase();
            }
            return ext;
        }

        @Override
        public String getDescription() {
            return "All Images extensions (jpg, gif, tiff, tif, png)";
        }

        @Override
        public boolean accept(java.io.File f) {
            if (f.isDirectory()) {
                return true;
            }

            String extension = getExtension(f);
            if (extension != null) {
                return extension.equals(tiff) || extension.equals(tif) || extension.equals(gif)
                        || extension.equals(jpeg) || extension.equals(jpg) || extension.equals(png);
            }

            return false;
        }
    });

    if (chooser.showDialog(this, "  Open  ") == javax.swing.JFileChooser.APPROVE_OPTION) {
        java.io.File file = chooser.getSelectedFile();
        String filePath = file.toString();
        try {
            final BufferedImage bimg = ImageIO.read(new File(filePath));
            namaCitra.setText("Nama Citra : " + file.getName());
            Thread t = new Thread() {
                @Override
                public void run() {
                    imageFormSiji.setImage(bimg);
                    imageFormSiji.imageToGray(1);
                    imageFormSiji.setHistogram();
                    int jumlah = 0;
                    DefaultCategoryDataset chartBarAwal = new DefaultCategoryDataset();
                    DefaultCategoryDataset chartBarHasil = new DefaultCategoryDataset();
                    //barChartData.setva
                    for (int i = 0; i < imageFormSiji.getHistogram().size(); i++) {
                        System.out.println(imageFormSiji.getHistogram().get(i).getRgb() + " = "
                                + imageFormSiji.getHistogram().get(i).getJumlah() + " = "
                                + imageFormSiji.getHistogram().get(i).getJumlahKumulatif() + " = "
                                + imageFormSiji.getHistogram().get(i).getHasilEkualisasi());
                        jumlah += imageFormSiji.getHistogram().get(i).getJumlah();
                        chartBarAwal.setValue(imageFormSiji.getHistogram().get(i).getJumlah(), "aha",
                                "" + imageFormSiji.getHistogram().get(i).getRgb());
                        chartBarHasil.setValue(imageFormSiji.getHistogram().get(i).getHasilEkualisasi(), "aha",
                                "" + imageFormSiji.getHistogram().get(i).getRgb());
                    }

                    JFreeChart chartSiji = ChartFactory.createBarChart("Histogam Citra Awal", "RGB", "Jumlah",
                            chartBarAwal, PlotOrientation.VERTICAL, false, true, false);
                    JFreeChart chartLoro = ChartFactory.createBarChart("Histogram Citra Ekualisasi", "RGB",
                            "Jumlah", chartBarHasil, PlotOrientation.VERTICAL, false, true, false);
                    CategoryPlot categoryPlotSiji = chartSiji.getCategoryPlot();
                    CategoryPlot categoryPlotLoro = chartLoro.getCategoryPlot();
                    categoryPlotSiji.setRangeGridlinePaint(Color.orange);
                    categoryPlotLoro.setRangeGridlinePaint(Color.orange);

                    ChartPanel cpanelSiji = new ChartPanel(chartSiji);
                    ChartPanel cpanelLoro = new ChartPanel(chartLoro);
                    chartAwal.removeAll();
                    chartAwal.add(cpanelSiji);
                    chartAwal.validate();

                    chartEkualisasi.removeAll();
                    chartEkualisasi.add(cpanelLoro);
                    chartEkualisasi.validate();

                    System.out.println("Jumlah = " + jumlah);
                    citraLabel.setText("");
                    citraGrayLabel.setText("");
                    citraEkualisasi.setText("");
                    citraLabel.setIcon(new ImageIcon(bimg.getScaledInstance(230, 230, 0)));
                    //resetCitra();
                    ukuranCitra.setText("Ukuran Citra : " + imageFormSiji.getTinggi() + " x "
                            + imageFormSiji.getLebar() + "");
                    imageFormSiji.setSmoothingImage();
                    imageFormSiji.setSharpeningImage();
                    citraEkualisasi.setIcon(
                            new ImageIcon(imageFormSiji.getEqualImage().getScaledInstance(230, 230, 0)));
                    citraGrayLabel.setIcon(
                            new ImageIcon(imageFormSiji.getGrayImage().getScaledInstance(230, 230, 0)));
                    citraSmoothingHasil.setIcon(new ImageIcon(imageFormSiji.getSmoothingImage()));
                    citraSharpheningHasil.setIcon(new ImageIcon(imageFormSiji.getSharpeningImage()));
                }
            };
            t.start();

        } catch (IOException e) {
            javax.swing.JOptionPane.showMessageDialog(this, "File Tidak Ditemukan " + e);
        }
    }
}