Example usage for java.awt Color cyan

List of usage examples for java.awt Color cyan

Introduction

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

Prototype

Color cyan

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

Click Source Link

Document

The color cyan.

Usage

From source file:sk.stuba.fiit.kvasnicka.topologyvisual.topology.Topology.java

/**
 * initialises JUNG stuff. here are all default plugins initialised
 *
 *//* ww w. j a v  a 2  s  .  c  o  m*/
public void initTopology() {
    logg.debug("init jung - creation");

    //vertex as icon
    Transformer<TopologyVertex, Paint> vpf = new PickableVertexPaintTransformer<TopologyVertex>(
            vv.getPickedVertexState(), Color.white, Color.yellow);
    vv.getRenderContext().setVertexFillPaintTransformer(vpf);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<TopologyEdge>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    final MyVertexIconShapeTransformer<TopologyVertex> vertexImageShapeFunction = new MyVertexIconShapeTransformer<TopologyVertex>();
    final DefaultVertexIconTransformer<TopologyVertex> vertexIconFunction = new VertexToIconTransformer<TopologyVertex>();

    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);

    //tooltips over the vertex
    vv.setVertexToolTipTransformer(new Transformer<TopologyVertex, String>() {
        @Override
        public String transform(TopologyVertex topologyVertex) {
            if (!PreferenciesHelper.isNodeTooltipName() && !PreferenciesHelper.isNodeTooltipDescription()) {
                return null;
            }
            StringBuilder sb = new StringBuilder("<html>");
            if (PreferenciesHelper.isNodeTooltipName()) {
                sb.append("<b>Name: </b>").append(topologyVertex.getName());
            }
            if (PreferenciesHelper.isNodeTooltipDescription()) {
                if (PreferenciesHelper.isNodeTooltipName()) {
                    sb.append("<br>");
                }
                sb.append("<b>Description: </b>").append(topologyVertex.getDescription());
            }
            sb.append("</html>");
            return sb.toString();
        }
    });
    vv.getRenderContext().setVertexLabelRenderer(new MyVertexLabelRenderer(Color.BLACK));
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S);
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<TopologyVertex, String>() {
        @Override
        public String transform(TopologyVertex v) {
            if (PreferenciesHelper.isShowNodeNamesInTopology()) {
                return v.getName();
            }
            return null;
        }
    });

    //picking support, so that vertices can be selected
    vv.setPickSupport(new ShapePickSupport<TopologyVertex, TopologyEdge>(vv));

    PickedState<TopologyVertex> pickedState = vv.getPickedVertexState();
    pickedState.addItemListener(
            new VertexPickedTopolCreationListener(vertexIconFunction, topolElementTopComponent, pickedState));

}

From source file:org.spiderplan.tools.visulization.GraphFrame.java

/**
 * @param graph//from  w  w  w.  jav  a2s .c  o  m
 * @param history optional history of the graph
 * @param title 
 * @param lC the layout
 * @param edgeLabels map from edges to string labels
 * @param w width of the window
 * @param h height of the window
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public GraphFrame(AbstractTypedGraph<V, E> graph, Vector<AbstractTypedGraph<V, E>> history, String title,
        LayoutClass lC, Map<E, String> edgeLabels, int w, int h) {
    super(title);
    this.edgeLabels = edgeLabels;
    this.g = new ObservableGraph<V, E>(graph);
    this.g.addGraphEventListener(this);

    this.defaultEdgeType = this.g.getDefaultEdgeType();

    this.layoutClass = lC;

    this.history = history;

    this.setLayout(lC);

    layout.setSize(new Dimension(w, h));

    try {
        Relaxer relaxer = new VisRunner((IterativeContext) layout);
        relaxer.stop();
        relaxer.prerelax();
    } catch (java.lang.ClassCastException e) {
    }

    //      Layout<V,E> staticLayout = new StaticLayout<V,E>(g, layout);
    //      Layout<V,E> staticLayout = new SpringLayout<V, E>(g);

    vv = new VisualizationViewer<V, E>(layout, new Dimension(w, h));

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().setBackground(java.awt.Color.lightGray);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 10));

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>());
    vv.setForeground(Color.black);

    graphMouse = new EditingModalGraphMouse<V, E>(vv.getRenderContext(), null, null);
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    //        vv.getRenderContext().setEd
    vv.getRenderContext().setEdgeLabelTransformer(this);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<E>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.addComponentListener(new ComponentAdapter() {

        /**
         * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentResized(ComponentEvent arg0) {
            super.componentResized(arg0);
            layout.setSize(arg0.getComponent().getSize());
        }
    });

    getContentPane().add(vv);

    /**
     * Create simple container for stuff on SOUTH border of this JFrame
     */
    Container c = new Container();
    c.setLayout(new FlowLayout());
    c.setBackground(java.awt.Color.lightGray);
    c.setFont(new Font("Serif", Font.PLAIN, 10));

    /**
     * Button to dump jpeg
     */
    dumpJPEG = new JButton("Dump");
    dumpJPEG.addActionListener(this);
    dumpJPEG.setName("Dump");
    c.add(dumpJPEG);

    /**
     * Button that creates offspring frame for selected vertices
     */
    subGraphButton = new JButton("Subgraph");
    subGraphButton.addActionListener(this);
    subGraphButton.setName("Subgraph");
    c.add(subGraphButton);

    subGraphDepthLabel = new JLabel("Depth");
    c.add(subGraphDepthLabel);
    subGraphDepth = new JTextField("0", 2);
    subGraphDepth.setHorizontalAlignment(SwingConstants.CENTER);
    subGraphDepth.setToolTipText("Depth of sub-graph created from selected nodes.");
    c.add(subGraphDepth);

    /**
     * Button that switches mouse mode
     */
    switchMode = new JButton("Transformation");
    switchMode.addActionListener(this);
    switchMode.setName("SwitchMode");
    c.add(switchMode);

    /**
     * ComboBox for Layout selection:
     */
    JComboBox layoutList;
    if (graph instanceof Forest) {
        String[] layoutStrings = { "Static", "Circle", "DAG", "Spring", "Spring2", "FR", "FR2", "Baloon",
                "ISOM", "KK", "PolarPoint", "RadialTree", "Tree" };
        layoutList = new JComboBox(layoutStrings);
    } else {
        String[] layoutStrings = { "Static", "Circle", "DAG", "Spring", "Spring2", "FR", "FR2", "ISOM", "KK",
                "PolarPoint" };
        layoutList = new JComboBox(layoutStrings);
    }

    layoutList.setSelectedIndex(5);
    layoutList.addActionListener(this);
    layoutList.setName("SelectLayout");
    c.add(layoutList);

    /**
     * Add container to layout
     */
    c.setVisible(true);
    getContentPane().add(c, BorderLayout.SOUTH);

    /**
     * Setup history scroll bar
     */
    if (history != null) {
        historySlider = new JSlider(0, history.size() - 1, history.size() - 1);
        historySlider.addChangeListener(this);
        historySlider.setMajorTickSpacing(10);
        historySlider.setMinorTickSpacing(1);
        historySlider.setPaintTicks(true);
        historySlider.setPaintLabels(true);

        historySlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
        Font font = new Font("Serif", Font.ITALIC, 15);
        historySlider.setFont(font);

        getContentPane().add(historySlider, BorderLayout.NORTH);

    }
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.pack();
    this.setVisible(true);
}

From source file:pe.egcc.eureka.app.view.RepoResumen.java

private Object crearImagen(List<Map<String, ?>> lista) {

    //datos del grfico
    String moneda = null;//from  www .  j a  v a  2s . c  o  m
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Map<String, ?> map : lista) {
        double importe = Double.parseDouble(map.get("IMPORTE").toString());
        moneda = map.get("MONENOMBRE").toString();
        String accion = map.get("ACCION").toString();
        dataset.addValue(importe, moneda, accion);
    }

    JFreeChart graficoBarras = ChartFactory.createBarChart("RESUMEN DE MOVIMIENTOS", //Ttulo de la grfica
            "TIPOS DE MOVIMIENTOS", //leyenda Eje horizontal
            "MILES DE " + moneda, //leyenda Eje vertical
            dataset, //datos
            PlotOrientation.VERTICAL, //orientacin
            true, //incluir leyendas
            true, //mostrar tooltips
            true);

    graficoBarras.setBackgroundPaint(Color.LIGHT_GRAY);

    CategoryPlot plot = (CategoryPlot) graficoBarras.getPlot();
    plot.setBackgroundPaint(Color.CYAN); //fondo del grafico
    plot.setDomainGridlinesVisible(true);//lineas de rangos, visibles
    plot.setRangeGridlinePaint(Color.BLACK);//color de las lineas de rangos

    // Crear imagen
    BufferedImage imagen = graficoBarras.createBufferedImage(500, 300);
    return imagen;
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void prepareJFreeBarChart(JFreeChart jfchart, List<PropertyBook> listOfPropertties,
        CategoryDataset categoryModel) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    categoryPlot.getRangeAxis().resizeRange(1.2);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(false);
    for (int i = 0; i < listOfPropertties.size(); i++) {
        renderer.setSeriesStroke(i, new BasicStroke(1));
    }//from   w w w  . ja  v a2  s  .  c o  m
    for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) {
        String label = (String) categoryModel.getColumnKey(i);
        CategoryMarker marker = new CategoryMarker(label);
        marker.setLabel("");
        marker.setPaint(Color.cyan);
        marker.setOutlinePaint(Color.cyan);
        marker.setAlpha(0.1f);
        marker.setLabelAnchor(RectangleAnchor.TOP);
        marker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
        marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
        categoryPlot.addDomainMarker(marker, Layer.BACKGROUND);
    }
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setItemMargin(.1);
    renderer.setBarPainter(new StandardBarPainter());

}

From source file:gov.nih.nci.caintegrator.common.Cai2Util.java

/**
 * Used by classes to retrieve a color based on a number from a ten color palette.
 * (1-10) are colors and anything else returns black.
 * @param colorNumber - number to use./* w w  w  . j a  v a  2  s .co  m*/
 * @return - Color object for that number.
 */
public static Color getBasicColor(int colorNumber) {
    switch (colorNumber) {
    case 1:
        return Color.GREEN;
    case 2:
        return Color.BLUE;
    case 3:
        return Color.RED;
    case 4:
        return Color.CYAN;
    case 5:
        return Color.DARK_GRAY;
    case 6:
        return Color.YELLOW;
    case 7:
        return Color.LIGHT_GRAY;
    case 8:
        return Color.MAGENTA;
    case 9:
        return Color.ORANGE;
    case 10:
        return Color.PINK;
    default:
        return Color.BLACK;
    }
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleSettingsFactory.java

/**
 *
 *//*  w  w  w.j  ava  2  s . c  o m*/
public static final ChartThemeSettings createChartThemeSettings() {
    ChartThemeSettings settings = new ChartThemeSettings();

    ChartSettings chartSettings = settings.getChartSettings();
    chartSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    chartSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png"));
    chartSettings.setBackgroundImageAlignment(new Integer(Align.TOP_RIGHT));
    chartSettings.setBackgroundImageAlpha(new Float(1f));
    chartSettings.setBorderVisible(Boolean.TRUE);
    chartSettings.setBorderPaint(new ColorProvider(Color.GREEN));
    chartSettings.setBorderStroke(new BasicStroke(1f));
    chartSettings.setAntiAlias(Boolean.TRUE);
    chartSettings.setTextAntiAlias(Boolean.TRUE);
    chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings titleSettings = settings.getTitleSettings();
    titleSettings.setShowTitle(Boolean.TRUE);
    titleSettings.setPosition(EdgeEnum.TOP);
    titleSettings.setForegroundPaint(new ColorProvider(Color.black));
    titleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    titleSettings.getFont().setBold(Boolean.TRUE);
    titleSettings.getFont().setFontSize(22);
    titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    titleSettings.setVerticalAlignment(VerticalAlignment.TOP);
    titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    TitleSettings subtitleSettings = settings.getSubtitleSettings();
    subtitleSettings.setShowTitle(Boolean.TRUE);
    subtitleSettings.setPosition(EdgeEnum.TOP);
    subtitleSettings.setForegroundPaint(new ColorProvider(Color.red));
    subtitleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    subtitleSettings.getFont().setBold(Boolean.TRUE);
    subtitleSettings.setHorizontalAlignment(HorizontalAlignment.LEFT);
    subtitleSettings.setVerticalAlignment(VerticalAlignment.CENTER);
    subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    LegendSettings legendSettings = settings.getLegendSettings();
    legendSettings.setShowLegend(Boolean.TRUE);
    legendSettings.setPosition(EdgeEnum.BOTTOM);
    legendSettings.setForegroundPaint(new ColorProvider(Color.black));
    legendSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    legendSettings.getFont().setBold(Boolean.TRUE);
    legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER);
    legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM);
    //FIXMETHEME legendSettings.setBlockFrame();
    legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));

    PlotSettings plotSettings = settings.getPlotSettings();
    plotSettings.setOrientation(PlotOrientation.VERTICAL);
    //      plotSettings.setForegroundAlpha(new Float(0.5f));
    plotSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue));
    //      plotSettings.setBackgroundAlpha(new Float(0.5f));
    plotSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png"));
    plotSettings.setBackgroundImageAlpha(new Float(0.5f));
    plotSettings.setBackgroundImageAlignment(new Integer(Align.NORTH_WEST));
    plotSettings.setLabelRotation(new Double(0));
    plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4));
    plotSettings.setOutlineVisible(Boolean.TRUE);
    plotSettings.setOutlinePaint(new ColorProvider(Color.red));
    plotSettings.setOutlineStroke(new BasicStroke(1f));
    plotSettings.setSeriesColorSequence(COLORS);
    //      plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS);
    plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER);
    plotSettings.setSeriesStrokeSequence(STROKES);
    plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES);
    plotSettings.setDomainGridlineVisible(Boolean.TRUE);
    plotSettings.setDomainGridlinePaint(new ColorProvider(Color.DARK_GRAY));
    plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f));
    plotSettings.setRangeGridlineVisible(Boolean.TRUE);
    plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK));
    plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f));
    plotSettings.getTickLabelFont().setFontName("Courier");
    plotSettings.getTickLabelFont().setBold(Boolean.TRUE);
    plotSettings.getTickLabelFont().setFontSize(10);
    plotSettings.getDisplayFont().setFontName("Arial");
    plotSettings.getDisplayFont().setBold(Boolean.TRUE);
    plotSettings.getDisplayFont().setFontSize(12);

    AxisSettings domainAxisSettings = settings.getDomainAxisSettings();
    domainAxisSettings.setVisible(Boolean.TRUE);
    domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT);
    domainAxisSettings.setLinePaint(new ColorProvider(Color.green));
    domainAxisSettings.setLineStroke(new BasicStroke(1f));
    domainAxisSettings.setLineVisible(Boolean.TRUE);
    //      domainAxisSettings.setLabel("Domain Axis");
    domainAxisSettings.setLabelAngle(new Double(0.0));
    domainAxisSettings.setLabelPaint(new ColorProvider(Color.magenta));
    domainAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    domainAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    domainAxisSettings.getLabelFont().setFontSize(12);
    domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    domainAxisSettings.setLabelVisible(Boolean.TRUE);
    domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan));
    domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE);
    domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE);
    domainAxisSettings.getTickLabelFont().setFontName("Arial");
    domainAxisSettings.getTickLabelFont().setFontSize(10);
    domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    domainAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    domainAxisSettings.setTickMarksInsideLength(new Float(0.1f));
    domainAxisSettings.setTickMarksOutsideLength(new Float(0.2f));
    domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.ORANGE));
    domainAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    domainAxisSettings.setTickMarksVisible(Boolean.TRUE);
    domainAxisSettings.setTickCount(new Integer(5));

    AxisSettings rangeAxisSettings = settings.getRangeAxisSettings();
    rangeAxisSettings.setVisible(Boolean.TRUE);
    rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT);
    rangeAxisSettings.setLinePaint(new ColorProvider(Color.yellow));
    rangeAxisSettings.setLineStroke(new BasicStroke(1f));
    rangeAxisSettings.setLineVisible(Boolean.TRUE);
    //      rangeAxisSettings.setLabel("Range Axis");
    rangeAxisSettings.setLabelAngle(new Double(Math.PI / 2.0));
    rangeAxisSettings.setLabelPaint(new ColorProvider(Color.green));
    rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getLabelFont().setFontName("Comic Sans MS");
    rangeAxisSettings.getLabelFont().setFontSize(12);
    rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1));
    rangeAxisSettings.setLabelVisible(Boolean.TRUE);
    rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink));
    rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE);
    rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE);
    rangeAxisSettings.getTickLabelFont().setFontName("Arial");
    rangeAxisSettings.getTickLabelFont().setFontSize(10);
    rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5));
    rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE);
    rangeAxisSettings.setTickMarksInsideLength(new Float(0.2f));
    rangeAxisSettings.setTickMarksOutsideLength(new Float(0.1f));
    rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black));
    rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f));
    rangeAxisSettings.setTickMarksVisible(Boolean.TRUE);
    rangeAxisSettings.setTickCount(new Integer(6));

    return settings;
}

From source file:com.joey.software.Tools.AScanViewerTool.java

public void setAScan(float[] aData, int pos) {
    {/*from  ww  w  . j  a v  a  2 s  . c  om*/

        if (aData.length != aScanData.length) {
            xData = new float[aData.length];
            maxData = new float[aData.length];
            minData = new float[aData.length];
        }

        for (int i = 0; i < xData.length; i++) {
            xData[i] = xDataMin + (xDataMax - xDataMin) * (i / ((float) xData.length - 1));
        }

        aScanData = aData;

        XYSeriesCollection datCol1 = PlotingToolkit.getCollection(xData, aScanData, "Data");

        XYSeriesCollection datCol2 = PlotingToolkit.getCollection(new float[] { xData[pos] },
                new float[] { aScanData[pos] }, "Data");

        previewPlot.getXYPlot().setDataset(0, datCol1);
        previewPlot.getXYPlot().setDataset(3, datCol2);

        XYLineAndShapeRenderer dataRender1 = new XYLineAndShapeRenderer(true, false);
        XYLineAndShapeRenderer dataRender2 = new XYLineAndShapeRenderer(false, true);

        dataRender1.setSeriesPaint(0, Color.CYAN);
        dataRender2.setSeriesPaint(0, Color.RED);

        previewPlot.getXYPlot().setRenderer(0, dataRender1);
        previewPlot.getXYPlot().setRenderer(3, dataRender2);
    }

    /*
     * Log Data
     */
    {
        logData = aScanData.clone();

        for (int i = 0; i < logData.length; i++) {
            if (logData[i] < 0.0001f) {
                logData[i] += 0.0001f;
            }

            logData[i] = (float) Math.log(logData[i]);
        }

        XYSeriesCollection logCol = PlotingToolkit.getCollection(xData, logData, "Data");
        XYSeriesCollection datCol2 = PlotingToolkit.getCollection(new float[] { xData[pos] },
                new float[] { logData[pos] }, "Data");

        dataPlot.getXYPlot().setDataset(0, logCol);
        dataPlot.getXYPlot().setDataset(3, datCol2);
        // Set the rendering
        XYLineAndShapeRenderer dataRender = new XYLineAndShapeRenderer(true, false);
        XYLineAndShapeRenderer dataRender2 = new XYLineAndShapeRenderer(false, true);
        dataRender2.setSeriesPaint(0, Color.RED);
        dataRender.setSeriesPaint(0, Color.CYAN);
        dataPlot.getXYPlot().setRenderer(0, dataRender);
        dataPlot.getXYPlot().setRenderer(3, dataRender2);
    }
}

From source file:lectorarchivos.VerCSV.java

public static void mostrarGrafica(JTable jTableInfoCSV) {
    //Fuente de datos
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //Recorremos la columna del consumo de la tabla
    for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) {
        if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0)
            dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo",
                    jTableInfoCSV.getValueAt(i, 0).toString());
    }//from w ww  .j  a va2 s  . c  o  m

    //Creando el grfico
    JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.cyan);
    chart.getTitle().setPaint(Color.black);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();

    //Cambiar color de barras
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
    barRenderer.setSeriesPaint(0, Color.decode("#5882FA"));

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("CONSUMO", chart);
    frame.pack();
    frame.getChartPanel().setMouseZoomable(false);
    frame.setVisible(true);

    panel.add(frame);

}

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

/**
 * Paints the chart.//from w w  w.j  a  v a 2s .  com
 * @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:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java

private JTable createTable(final ViewState state) {
    JTable table;/*  w w  w  .  j a  v  a2  s  .  co m*/
    final ModelGraph selected = state.getSelected();
    if (selected != null) {
        final Vector<Vector<String>> rows = new Vector<Vector<String>>();
        ConcurrentHashMap<String, String> keyToGroupMap = new ConcurrentHashMap<String, String>();
        Metadata staticMet = selected.getModel().getStaticMetadata();
        Metadata inheritedMet = selected.getInheritedStaticMetadata(state);
        Metadata completeMet = new Metadata();
        if (staticMet != null) {
            completeMet.replaceMetadata(staticMet.getSubMetadata(state.getCurrentMetGroup()));
        }
        if (selected.getModel().getExtendsConfig() != null) {
            for (String configGroup : selected.getModel().getExtendsConfig()) {
                Metadata extendsMetadata = state.getGlobalConfigGroups().get(configGroup).getMetadata()
                        .getSubMetadata(state.getCurrentMetGroup());
                for (String key : extendsMetadata.getAllKeys()) {
                    if (!completeMet.containsKey(key)) {
                        keyToGroupMap.put(key, configGroup);
                        completeMet.replaceMetadata(key, extendsMetadata.getAllMetadata(key));
                    }
                }
            }
        }
        if (inheritedMet != null) {
            Metadata inheritedMetadata = inheritedMet.getSubMetadata(state.getCurrentMetGroup());
            for (String key : inheritedMetadata.getAllKeys()) {
                if (!completeMet.containsKey(key)) {
                    keyToGroupMap.put(key, "__inherited__");
                    completeMet.replaceMetadata(key, inheritedMetadata.getAllMetadata(key));
                }
            }
        }
        List<String> keys = completeMet.getAllKeys();
        Collections.sort(keys);
        for (String key : keys) {
            if (key.endsWith("/envReplace")) {
                continue;
            }
            String values = StringUtils.join(completeMet.getAllMetadata(key), ",");
            Vector<String> row = new Vector<String>();
            row.add(keyToGroupMap.get(key));
            row.add(key);
            row.add(values);
            row.add(Boolean.toString(Boolean.parseBoolean(completeMet.getMetadata(key + "/envReplace"))));
            rows.add(row);
        }
        table = new JTable();// rows, new Vector<String>(Arrays.asList(new
                             // String[] { "key", "values", "envReplace" })));
        table.setModel(new AbstractTableModel() {
            public String getColumnName(int col) {
                switch (col) {
                case 0:
                    return "group";
                case 1:
                    return "key";
                case 2:
                    return "values";
                case 3:
                    return "envReplace";
                default:
                    return null;
                }
            }

            public int getRowCount() {
                return rows.size() + 1;
            }

            public int getColumnCount() {
                return 4;
            }

            public Object getValueAt(int row, int col) {
                if (row >= rows.size()) {
                    return null;
                }
                String value = rows.get(row).get(col);
                if (value == null && col == 3) {
                    return "false";
                }
                if (value == null && col == 0) {
                    return "__local__";
                }
                return value;
            }

            public boolean isCellEditable(int row, int col) {
                if (row >= rows.size()) {
                    return selected.getModel().getStaticMetadata().containsGroup(state.getCurrentMetGroup());
                }
                if (col == 0) {
                    return false;
                }
                String key = rows.get(row).get(1);
                return key == null || (selected.getModel().getStaticMetadata() != null
                        && selected.getModel().getStaticMetadata().containsKey(getKey(key, state)));
            }

            public void setValueAt(Object value, int row, int col) {
                if (row >= rows.size()) {
                    Vector<String> newRow = new Vector<String>(
                            Arrays.asList(new String[] { null, null, null, null }));
                    newRow.add(col, (String) value);
                    rows.add(newRow);
                } else {
                    Vector<String> rowValues = rows.get(row);
                    rowValues.add(col, (String) value);
                    rowValues.remove(col + 1);
                }
                this.fireTableCellUpdated(row, col);
            }

        });
        MyTableListener tableListener = new MyTableListener(state);
        table.getModel().addTableModelListener(tableListener);
        table.getSelectionModel().addListSelectionListener(tableListener);
    } else {
        table = new JTable(new Vector<Vector<String>>(),
                new Vector<String>(Arrays.asList(new String[] { "key", "values", "envReplace" })));
    }

    // table.setFillsViewportHeight(true);
    table.setSelectionBackground(Color.cyan);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableCellRenderer cellRenderer = new TableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            JLabel field = new JLabel((String) value);
            if (column == 0) {
                field.setForeground(Color.gray);
            } else {
                if (isSelected) {
                    field.setBorder(new EtchedBorder(1));
                }
                if (table.isCellEditable(row, 1)) {
                    field.setForeground(Color.black);
                } else {
                    field.setForeground(Color.gray);
                }
            }
            return field;
        }

    };
    TableColumn groupCol = table.getColumnModel().getColumn(0);
    groupCol.setPreferredWidth(75);
    groupCol.setCellRenderer(cellRenderer);
    TableColumn keyCol = table.getColumnModel().getColumn(1);
    keyCol.setPreferredWidth(200);
    keyCol.setCellRenderer(cellRenderer);
    TableColumn valuesCol = table.getColumnModel().getColumn(2);
    valuesCol.setPreferredWidth(300);
    valuesCol.setCellRenderer(cellRenderer);
    TableColumn envReplaceCol = table.getColumnModel().getColumn(3);
    envReplaceCol.setPreferredWidth(75);
    envReplaceCol.setCellRenderer(cellRenderer);

    table.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3 && DefaultPropView.this.table.getSelectedRow() != -1) {
                int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition());
                String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state);
                Metadata staticMet = state.getSelected().getModel().getStaticMetadata();
                override.setVisible(staticMet == null || !staticMet.containsKey(key));
                delete.setVisible(staticMet != null && staticMet.containsKey(key));
                tableMenu.show(DefaultPropView.this.table, e.getX(), e.getY());
            }
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });

    return table;
}