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:de.naoth.xabsleditor.graphpanel.AgentVisualizer.java

private void doSetGraph(final XABSLContext context, final String selectedNodeName, String selectedAgentName) {

    // build graph
    final DirectedGraph<XabslNode, XabslEdge> graph = new DirectedSparseGraph<XabslNode, XabslEdge>();
    selectedNode = createAgentGraph(context, graph, selectedNodeName, selectedAgentName);

    if (selectedAgentName == null) {
        layout = new SuperDAGLayout<XabslNode, XabslEdge>(graph);
    } else {//from   w  w  w  .  ja v a  2 s.  c  o m
        layout = new SuperDAGLayout<XabslNode, XabslEdge>(graph, 80, 120);
    }

    layout.initialize();

    if (scrollPane != null) {
        remove(scrollPane);
        scrollPane = null;
    }

    vv = new VisualizationViewer<XabslNode, XabslEdge>(layout);
    DefaultModalGraphMouse<XabslNode, XabslEdge> mouse = new DefaultModalGraphMouse<XabslNode, XabslEdge>();
    vv.setGraphMouse(mouse);

    // enable selecting the nodes
    mouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    // add external mouse listener
    if (externalMouseListener != null) {
        vv.addGraphMouseListener(externalMouseListener);
    }

    vv.getRenderContext().setVertexShapeTransformer(new VertexTransformer(graph));
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<XabslNode, String>() {

        @Override
        public String transform(XabslNode n) {
            return "<html><center>" + n.getName().replaceAll("_", "_<br>") + "</center></html>";
        }
    });
    vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<XabslNode, Paint>() {

        @Override
        public Paint transform(XabslNode n) {
            if (n == selectedNode) {
                return Color.green;
            }
            if (selectedNode != null && graph.getSuccessors(selectedNode).contains(n)) {
                return Color.red;
            }
            if (selectedNode != null && graph.getPredecessors(selectedNode).contains(n)) {
                return Color.orange;
            }
            if (graph.getOutEdges(n).size() == 0) {
                return Color.lightGray;
            }
            return Color.white;
        }
    });

    // label is placed in the center of the node
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<XabslNode, XabslEdge>());
    vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<XabslEdge, Paint>() {

        @Override
        public Paint transform(XabslEdge e) {
            if (selectedNode != null && graph.getSource(e) == selectedNode) {
                return Color.red;
            } else if (selectedNode != null && graph.getDest(e) == selectedNode) {
                return Color.ORANGE;
            } else {
                return Color.black;
            }
        }
    });

    // add to a zoomable container
    scrollPane = new GraphZoomScrollPane(vv);
    panelGraph.add(scrollPane, BorderLayout.CENTER);

    validate();

    fitGraphinPanel();
    recreateAgentSelector(context);
}

From source file:cytoscape.render.immed.GraphGraphicsTest.java

private long drawOldFull(Random rand) {
    final float nodeSizeFactor = 50f;
    float size = (float) canvasSize;

    long begin = System.nanoTime();
    for (int i = 0; i < numNodes; i++) {
        float x = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
        float y = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
        oldGraphGraphics.drawNodeFull((byte) (i % (int) OldGraphGraphics.s_last_shape), x, y,
                (x + (rand.nextFloat() * nodeSizeFactor)), (y + (rand.nextFloat() * nodeSizeFactor)),
                Color.blue, 1.0f + (i % 10), Color.yellow);
    }//from  w  ww.  j  a  v a2 s .c  o m
    long end = System.nanoTime();
    long nodeDur = end - begin;

    BasicStroke edgeStroke = new BasicStroke(1f);

    begin = System.nanoTime();
    for (int i = 0; i < numEdges; i++) {
        oldGraphGraphics.drawEdgeFull((byte) ((i % 7) - 8), rand.nextFloat() * (20f), Color.red,
                (byte) ((i % 7) - 8), rand.nextFloat() * (20f), Color.orange,
                rand.nextFloat() * (rand.nextBoolean() ? size : -size),
                rand.nextFloat() * (rand.nextBoolean() ? size : -size), oldGraphGraphics.m_noAnchors,
                rand.nextFloat() * (rand.nextBoolean() ? size : -size),
                rand.nextFloat() * (rand.nextBoolean() ? size : -size), 1f, Color.green, 0f);
    }
    end = System.nanoTime();

    long duration = (end - begin) + nodeDur;

    //      try {
    //         ImageIO.write(image,"PNG",new File("/tmp/homer-old-" + rand.nextInt(100) + ".png"));
    //      } catch (IOException ioe) { ioe.printStackTrace(); }
    return duration;
}

From source file:net.sf.mzmine.modules.visualization.ida.IDAVisualizerWindow.java

/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 *//*w ww .j  a  va2  s.  com*/
public void actionPerformed(ActionEvent event) {

    String command = event.getActionCommand();

    if (command.equals("SHOW_SPECTRUM")) {
        CursorPosition pos = getCursorPosition();
        if (pos != null) {
            SpectraVisualizerModule.showNewSpectrumWindow(pos.getDataFile(), pos.getScanNumber());
        }
    }

    if (command.equals("SETUP_AXES")) {
        AxesSetupDialog dialog = new AxesSetupDialog(this, IDAPlot.getXYPlot());
        dialog.setVisible(true);
    }

    if (command.equals("SHOW_DATA_POINTS")) {
        IDAPlot.switchDataPointsVisible();
    }

    if (command.equals("SWITCH_TOOLTIPS")) {
        if (tooltipMode) {
            IDAPlot.showPeaksTooltips(false);
            toolBar.setTooltipButton(false);
            tooltipMode = false;
        } else {
            IDAPlot.showPeaksTooltips(true);
            toolBar.setTooltipButton(true);
            tooltipMode = true;
        }
    }

    if (command.equals("FIND_SPECTRA")) {

        // Parameters
        final DoubleParameter inputMZ = new DoubleParameter("Ion m/z", "m/z value of ion to search for.");

        final MZToleranceParameter inputMZTolerance = new MZToleranceParameter();

        final DoubleParameter inputIntensity = new DoubleParameter("Min. ion intensity",
                "Only ions with intensities above this value will be searched for.");

        final BooleanParameter inputNL = new BooleanParameter("Neutral Loss",
                "If selected, the ion to be searched for will be a neutral loss ion.\nIn this case, only ions above the min. intensity will be examined.",
                false);

        final ComboParameter<Colors> inputColors = new ComboParameter<Colors>("Color",
                "The color which the data points will be marked with.", Colors.values());

        Parameter<?>[] parameters = new Parameter<?>[5];
        parameters[0] = inputMZ;
        parameters[1] = inputMZTolerance;
        parameters[2] = inputIntensity;
        parameters[3] = inputNL;
        parameters[4] = inputColors;

        final ParameterSet parametersSearch = new SimpleParameterSet(parameters);
        ExitCode exitCode = parametersSearch.showSetupDialog(this, true);

        if (exitCode != ExitCode.OK)
            return;

        double searchMZ = parametersSearch.getParameter(inputMZ).getValue();
        MZTolerance searchMZTolerance = parametersSearch.getParameter(inputMZTolerance).getValue();
        double minIntensity = parametersSearch.getParameter(inputIntensity).getValue();
        boolean neutralLoss = parametersSearch.getParameter(inputNL).getValue();

        Color highligtColor = Color.red;
        ;
        if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.green)) {
            highligtColor = Color.green;
        }
        if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.blue)) {
            highligtColor = Color.blue;
        }

        // Find and highlight spectra with specific ion
        dataset.highlightSpectra(searchMZ, searchMZTolerance, minIntensity, neutralLoss, highligtColor);

        // Add legend entry
        LegendItemCollection chartLegend = IDAPlot.getXYPlot().getLegendItems();
        chartLegend.add(new LegendItem("Ion: " + searchMZ, "",
                "MS/MS spectra which contain the " + searchMZ + " ion\nTolerance: "
                        + searchMZTolerance.toString() + "\nMin intensity: " + minIntensity,
                "", new Ellipse2D.Double(0, 0, 7, 7), highligtColor));
        IDAPlot.getXYPlot().setFixedLegendItems(chartLegend);
    }

}

From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java

private void initColorModels() {
    for (int j = 0; j <= 1; j++) {
        final int palSize = 256;
        final byte[] r = new byte[palSize];
        final byte[] g = new byte[palSize];
        final byte[] b = new byte[palSize];
        final byte[] a = new byte[palSize];
        r[0] = (byte) backgroundColor.getRed();
        g[0] = (byte) backgroundColor.getGreen();
        b[0] = (byte) backgroundColor.getBlue();
        a[0] = (byte) backgroundColor.getAlpha();

        final Palette pal = new Palette("Rainbow", new Color[] { Color.black, Color.blue, Color.cyan,
                Color.green, Color.yellow, Color.orange, Color.red });
        for (int i = 1; i < 256; ++i) {
            float value = i / 255f;
            if (j == 0)
                value = (255 - i) / 255f;
            Color c = pal.lookupColor(value);
            r[i] = (byte) c.getRed();
            g[i] = (byte) c.getGreen();
            b[i] = (byte) c.getBlue();
            a[i] = (byte) 255;
        }/* w ww.  ja v  a  2  s .  c  om*/

        if (j == 0) {
            toggledColorModel = new IndexColorModel(8, palSize, r, g, b, a);
        } else {
            untoggledColorModel = new IndexColorModel(8, palSize, r, g, b, a);
        }
    }
}

From source file:com.mxgraph.examples.swing.chart.BarChartDemo1.java

public static JFreeChart createChart1(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("", // chart title
            "X-value", // domain axis label
            "Y-value", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//  w w  w  . j av  a2s  . c o m

    // 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 = (CategoryPlot) chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setCategoryMargin(0.1);//
    categoryAxis.setUpperMargin(0.02);
    categoryAxis.setLowerMargin(0.02);

    // ******************************************************************
    //  More than 150 demo applications are included with the JFreeChart
    //  Developer Guide...for more information, see:
    //
    //  >   http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.10);
    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    // 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.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setItemLabelAnchorOffset(10D);
    renderer.setItemLabelFont(new Font("", Font.PLAIN, 12));
    renderer.setItemLabelsVisible(true);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 180));

    // OPTIONAL CUSTOMISATION COMPLETED.      

    chart.getTitle().setFont(new Font("", Font.BOLD, 16));//

    //
    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    //
    domainAxis.setTickLabelFont(new Font("", Font.PLAIN, 10));

    //
    rangeAxis.setLabelFont(new Font("", Font.BOLD, 15));

    chart.getLegend().setItemFont(new Font("", Font.BOLD, 15));

    /**
     *  chart.getTitle().setFont(new Font("",Font.BOLD,20));//
            
    //
    domainAxis.setLabelFont(new Font("",Font.BOLD,14));
    //
    domainAxis.setTickLabelFont(new Font("",Font.BOLD,12));
    //
    rangeAxis.setLabelFont(new Font("",Font.BOLD,15));
            
    chart.getLegend().setItemFont(new Font("", Font.BOLD, 15));
     */
    return chart;

}

From source file:net.fenyo.gnetwatch.GUI.GenericSrcComponent.java

/**
 * Paints the chart.//from   w  w w. j  a va2s.c  om
 * @param now current time.
 * @return void.
 */
// AWT thread
// AWT thread << sync_value_per_vinterval << events
public void paintChart(final long now) {
    backing_g.setClip(axis_margin_left + 1, axis_margin_top,
            dimension.width - axis_margin_left - axis_margin_right - 1,
            dimension.height - axis_margin_top - axis_margin_bottom);

    synchronized (events) {
        final int npoints = events.size();
        final int point_x[] = new int[npoints];
        final int point_y[] = new int[npoints];
        final int point_y1[] = new int[npoints];
        final int point_y2[] = new int[npoints];
        final int point_y3[] = new int[npoints];
        final int point_y4[] = new int[npoints];
        final int point_y5[] = new int[npoints];
        final int point_y6[] = new int[npoints];
        final int point_y7[] = new int[npoints];
        final int point_y8[] = new int[npoints];
        final int point_y9[] = new int[npoints];
        final int point_y10[] = new int[npoints];

        final long time_to_display = now - now % _getDelayPerInterval();
        final int pixels_offset = (pixels_per_interval * (int) (now % _getDelayPerInterval()))
                / (int) _getDelayPerInterval();
        final int last_interval_pos = dimension.width - axis_margin_right - pixels_offset;

        for (int i = 0; i < events.size(); i++) {
            final EventGenericSrc event = (EventGenericSrc) events.get(i);
            final long xpos = ((long) last_interval_pos)
                    + (((long) pixels_per_interval) * (event.getDate().getTime() - time_to_display))
                            / _getDelayPerInterval();
            if (xpos < -1000)
                point_x[i] = -1000;
            else if (xpos > 1000 + dimension.width)
                point_x[i] = 1000 + dimension.width;
            else
                point_x[i] = (int) xpos;

            // cast to double to avoid overflow on int that lead to wrong results
            point_y[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getIntValue() / value_per_vinterval);
            point_y1[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue1() / value_per_vinterval);
            point_y2[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue2() / value_per_vinterval);
            point_y3[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue3() / value_per_vinterval);
            point_y4[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue4() / value_per_vinterval);
            point_y5[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue5() / value_per_vinterval);
            point_y6[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue6() / value_per_vinterval);
            point_y7[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue7() / value_per_vinterval);
            point_y8[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue8() / value_per_vinterval);
            point_y9[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue9() / value_per_vinterval);
            point_y10[i] = (int) (dimension.height - axis_margin_bottom
                    - pixels_per_vinterval * (double) event.getValue10() / value_per_vinterval);
        }

        backing_g.setColor(Color.GREEN);
        backing_g.drawPolyline(point_x, point_y, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y[i] - 2, 4, 4);

        backing_g.setColor(Color.WHITE);
        backing_g.drawPolyline(point_x, point_y1, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y1[i] - 2, 4, 4);

        backing_g.setColor(Color.BLUE);
        backing_g.drawPolyline(point_x, point_y2, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y2[i] - 2, 4, 4);

        backing_g.setColor(Color.GRAY);
        backing_g.drawPolyline(point_x, point_y3, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y3[i] - 2, 4, 4);

        backing_g.setColor(Color.YELLOW);
        backing_g.drawPolyline(point_x, point_y4, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y4[i] - 2, 4, 4);

        backing_g.setColor(Color.ORANGE);
        backing_g.drawPolyline(point_x, point_y5, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y5[i] - 2, 4, 4);

        backing_g.setColor(Color.CYAN);
        backing_g.drawPolyline(point_x, point_y6, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y6[i] - 2, 4, 4);

        backing_g.setColor(Color.MAGENTA);
        backing_g.drawPolyline(point_x, point_y7, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y7[i] - 2, 4, 4);

        backing_g.setColor(Color.LIGHT_GRAY);
        backing_g.drawPolyline(point_x, point_y8, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y8[i] - 2, 4, 4);

        backing_g.setColor(Color.PINK);
        backing_g.drawPolyline(point_x, point_y9, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y9[i] - 2, 4, 4);

        backing_g.setColor(Color.RED);
        backing_g.drawPolyline(point_x, point_y10, events.size());
        for (int i = 0; i < events.size(); i++)
            backing_g.drawRect(point_x[i] - 2, point_y10[i] - 2, 4, 4);

        int cnt = 1;
        int cnt2 = 1;
        if (events.size() > 0)
            for (final String str : ((EventGenericSrc) events.get(0)).getUnits().split(";")) {
                if (str.length() > 0) {
                    switch (cnt) {
                    case 1:
                        backing_g.setColor(Color.WHITE);
                        break;
                    case 2:
                        backing_g.setColor(Color.BLUE);
                        break;
                    case 3:
                        backing_g.setColor(Color.GRAY);
                        break;
                    case 4:
                        backing_g.setColor(Color.YELLOW);
                        break;
                    case 5:
                        backing_g.setColor(Color.ORANGE);
                        break;
                    case 6:
                        backing_g.setColor(Color.CYAN);
                        break;
                    case 7:
                        backing_g.setColor(Color.MAGENTA);
                        break;
                    case 8:
                        backing_g.setColor(Color.LIGHT_GRAY);
                        break;
                    case 9:
                        backing_g.setColor(Color.PINK);
                        break;
                    case 10:
                        backing_g.setColor(Color.RED);
                        break;
                    }
                    backing_g.fillRect(dimension.width - axis_margin_right - 150, 50 - 5 + 13 * cnt2, 20, 3);

                    backing_g.setColor(Color.WHITE);
                    backing_g.drawString(str, dimension.width - axis_margin_right - 150 + 22, 50 + 13 * cnt2);

                    cnt2++;
                }
                cnt++;
            }

        backing_g.setClip(null);
    }
}

From source file:jtrace.Scene.java

/**
 * Add a set of axes to an image.  If the object parameter is not null,
 * the axes corresponding to the object's coordinate system are drawn.
 * //from   w w w  .ja v a 2  s  .  c o  m
 * @param image Image generated using scene's camera
 * @param object (Possibly null) object
 */
private void renderAxes(BufferedImage image, SceneObject object) {

    Graphics gr = image.getGraphics();
    int[] origin, xhat, yhat, zhat;

    if (object == null) {
        origin = camera.getPixel(image.getWidth(), image.getHeight(), Vector3D.ZERO);
        xhat = camera.getPixel(image.getWidth(), image.getHeight(), Vector3D.PLUS_I);
        yhat = camera.getPixel(image.getWidth(), image.getHeight(), Vector3D.PLUS_J);
        zhat = camera.getPixel(image.getWidth(), image.getHeight(), Vector3D.PLUS_K);
    } else {
        origin = camera.getPixel(image.getWidth(), image.getHeight(),
                object.objectToSceneVector(Vector3D.ZERO));
        xhat = camera.getPixel(image.getWidth(), image.getHeight(),
                object.objectToSceneVector(Vector3D.PLUS_I));
        yhat = camera.getPixel(image.getWidth(), image.getHeight(),
                object.objectToSceneVector(Vector3D.PLUS_J));
        zhat = camera.getPixel(image.getWidth(), image.getHeight(),
                object.objectToSceneVector(Vector3D.PLUS_K));
    }

    String objName;
    if (object == null)
        objName = "";
    else
        objName = "(" + object.getClass().getSimpleName() + ")";

    gr.setColor(Color.red);
    gr.drawLine(origin[0], origin[1], xhat[0], xhat[1]);
    gr.setColor(Color.white);
    gr.drawString("x " + objName, xhat[0], xhat[1]);

    gr.setColor(Color.green);
    gr.drawLine(origin[0], origin[1], yhat[0], yhat[1]);
    gr.setColor(Color.white);
    gr.drawString("y " + objName, yhat[0], yhat[1]);

    gr.setColor(Color.blue);
    gr.drawLine(origin[0], origin[1], zhat[0], zhat[1]);
    gr.setColor(Color.white);
    gr.drawString("z " + objName, zhat[0], zhat[1]);
}

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

private static JFreeChart createChart3(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("Public Opinion : Torture of Prisoners",
            "Country", "%", categorydataset, PlotOrientation.HORIZONTAL, false, true, false);
    jfreechart.getTitle().setMargin(2D, 0.0D, 0.0D, 0.0D);
    TextTitle texttitle = new TextTitle("Source: http://news.bbc.co.uk/1/hi/world/6063386.stm",
            new Font("Dialog", 0, 11));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    texttitle.setMargin(0.0D, 0.0D, 4D, 4D);
    jfreechart.addSubtitle(texttitle);// w  ww  . j a v a  2  s. c o  m
    TextTitle texttitle1 = new TextTitle("(*) Across 27,000 respondents in 25 countries",
            new Font("Dialog", 0, 11));
    texttitle1.setPosition(RectangleEdge.BOTTOM);
    texttitle1.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    texttitle1.setMargin(4D, 0.0D, 2D, 4D);
    jfreechart.addSubtitle(texttitle1);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    LegendItemCollection legenditemcollection = new LegendItemCollection();
    legenditemcollection.add(new LegendItem("Against all torture", null, null, null,
            new java.awt.geom.Rectangle2D.Double(-6D, -3D, 12D, 6D), Color.green));
    legenditemcollection.add(new LegendItem("Some degree permissible", null, null, null,
            new java.awt.geom.Rectangle2D.Double(-6D, -3D, 12D, 6D), Color.red));
    categoryplot.setFixedLegendItems(legenditemcollection);
    categoryplot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D));
    LegendTitle legendtitle = new LegendTitle(categoryplot);
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(legendtitle);
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.0D);
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    Color color = new Color(0, 0, 0, 0);
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, color);
    barrenderer.setSeriesPaint(2, gradientpaint1);
    return jfreechart;
}

From source file:es.urjc.ia.fia.genericSearch.statistics.JUNGStatistics.java

@Override
public void showStatistics() {

    // Layout: tree and radial
    treeLayout = new TreeLayout<AuxVertex, ACTION>(this.tree, 35, 100);
    radialLayout = new RadialTreeLayout<AuxVertex, ACTION>(this.tree, 35, 130);

    radialLayout.setSize(new Dimension(200 * (this.tree.getHeight() + 1), 200 * (this.tree.getHeight() + 1)));

    // The BasicVisualizationServer<V,E> is parameterized by the edge types
    vv = new VisualizationViewer<AuxVertex, ACTION>(treeLayout);
    vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size
    vv.setBackground(Color.white); // Background color

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<AuxVertex>());
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>());

    // Setup up a new vertex to paint transformer
    Transformer<AuxVertex, Paint> vertexPaint = new Transformer<AuxVertex, Paint>() {
        @Override/*from  w w  w.j  av a2 s  . c  o  m*/
        public Paint transform(AuxVertex arg0) {
            if (arg0.getState().isSolution() && arg0.isExplored()) {
                return Color.GREEN;
            } else if (arg0.isExplored()) {
                return Color.CYAN;
            } else if (arg0.isDuplicated()) {
                return Color.GRAY;
            } else {
                return Color.WHITE;
            }
        }
    };

    // Tooltip for vertex
    Transformer<AuxVertex, String> toolTipsState = new Transformer<AuxVertex, String>() {

        @Override
        public String transform(AuxVertex arg0) {
            String sortInfo = "";
            if (arg0.isExplored()) {
                if (arg0.getState().isSolution() && arg0.isExplored()) {
                    sortInfo = "<u><i>Solution state " + arg0.getExplored() + "</i></u>";
                } else {
                    sortInfo = "<u><i>Explored state " + arg0.getExplored() + "</i></u>";
                }
            } else if (arg0.isDuplicated()) {
                sortInfo = "<u><i>Duplicated state </i></u>";
            } else {
                sortInfo = "<u><i>Unexplored state</i></u>";
            }
            return "<html><p>" + sortInfo + "</p>" + "<p>State: " + arg0.getState().toString() + "</p>"
                    + "<p>Cost: " + arg0.getState().getSolutionCost() + "</p></html>";
        }

    };
    vv.setVertexToolTipTransformer(toolTipsState);

    // Tooltip for edge
    Transformer<ACTION, String> toolTipsAction = new Transformer<ACTION, String>() {

        @Override
        public String transform(ACTION arg0) {
            return "Cost: " + arg0.cost();
        }

    };
    vv.setEdgeToolTipTransformer(toolTipsAction);

    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<ACTION>());

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

    // Create a graph mouse and add it to the visualization component
    DefaultModalGraphMouse<State<ACTION>, ACTION> gm = new DefaultModalGraphMouse<State<ACTION>, ACTION>();
    gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    vv.setGraphMouse(gm);
    vv.addKeyListener(gm.getModeKeyListener());

    JFrame vFrame = new JFrame("Statistics Tree View");
    vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    /*
    vFrame.getContentPane().add(vv);
    vFrame.pack();
    vFrame.setVisible(true);
    */

    rings = new Rings();
    Container content = vFrame.getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.addItemListener(gm.getModeListener());
    gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Radial");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv, treeLayout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv,
                        radialLayout, treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    /*
     * Statistics 
     */
    JLabel stats = new JLabel();
    long totalTime = endTime.getTime() - initTime.getTime();
    stats.setText("<html>" + "<b>Total States:</b> " + this.totalStates + "<br>" + "<b>Explored States:</b> "
            + this.explorerStates + "<br>" + "<b>Duplicated States (detected):</b> " + this.duplicatedStates
            + "<br>" + "<b>Solution States:</b> " + this.solutionStates + "<br>" + "<b>Total time: </b>"
            + totalTime + " milliseconds" + "</html>");

    JPanel legend = new JPanel();
    legend.setLayout(new BoxLayout(legend, BoxLayout.Y_AXIS));

    JLabel len = new JLabel("<html><b>Lengend</b></html>");
    JLabel lexpl = new JLabel("Explored state");
    lexpl.setBackground(Color.CYAN);
    lexpl.setOpaque(true);
    JLabel lune = new JLabel("Unexplored state");
    lune.setBackground(Color.WHITE);
    lune.setOpaque(true);
    JLabel ldupl = new JLabel("Duplicated state");
    ldupl.setBackground(Color.GRAY);
    ldupl.setOpaque(true);
    JLabel lsol = new JLabel("Solution state");
    lsol.setBackground(Color.GREEN);
    lsol.setOpaque(true);

    legend.add(len);
    legend.add(lexpl);
    legend.add(lune);
    legend.add(ldupl);
    legend.add(lsol);

    JPanel controls = new JPanel();
    controls.add(stats);
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    //controls.add(modeBox);
    controls.add(legend);

    content.add(controls, BorderLayout.SOUTH);

    vFrame.pack();
    vFrame.setVisible(true);
}

From source file:net.sf.profiler4j.console.ProjectDialog.java

/**
 * This method initializes rulesTable//w  w  w. j a va 2 s  .co  m
 * 
 * @return javax.swing.JTable
 */
private JTable getRulesTable() {
    if (rulesTable == null) {
        rulesTable = new JTable();
        rulesTable.setModel(ruleTableModel);
        rulesTable.setRowMargin(4);
        rulesTable.setRowHeight(24);
        rulesTable.setFont(new Font("Monospaced", Font.PLAIN, 14));
        TableColumn c;

        c = rulesTable.getColumnModel().getColumn(0);
        c.setMinWidth(300);

        c = rulesTable.getColumnModel().getColumn(1);
        c.setMinWidth(80);
        c.setMaxWidth(80);

        JComboBox editorCb = new JComboBox();
        for (Rule.Action a : Rule.Action.values()) {
            editorCb.addItem(a);
        }
        c.setCellEditor(new DefaultCellEditor(editorCb));
        c.setCellRenderer(new DefaultTableCellRenderer() {
            Font font = new Font("Monospaced", Font.BOLD, 13);

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                    boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                Rule.Action r = (Rule.Action) value;
                setHorizontalAlignment(CENTER);
                setFont(font);
                if (r == Rule.Action.ACCEPT) {
                    setBackground(Color.GREEN);
                } else {
                    setBackground(Color.RED);
                }
                if (isSelected) {
                    setForeground(Color.YELLOW);
                } else {
                    setForeground(Color.BLACK);
                }
                return this;
            }
        });

    }
    return rulesTable;
}