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:org.fhaes.FHRecorder.GraphicsPanel.java

/**
 * Recalculates the charts based on the latest sample
 * data/*from  w w  w.j a v  a 2 s  .c o m*/
 * @return
 */
private JFreeChart updateGraph() {
    try {
        NumberAxis rangeAxis = new NumberAxis();
        XYBarRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.BLUE);
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.configure();

        numEventsDataset = new SlidingCategoryDataset(getNumEventsDataset(), 0, NUM_COLUMNS);
        BarRenderer numEventsRenderer = new BarRenderer();
        numEventsRenderer.setSeriesPaint(0, Color.BLUE);
        plot = new CategoryPlot(numEventsDataset, new CategoryAxis("Event Years"), rangeAxis,
                numEventsRenderer);

        numSamplesDataset = new SlidingCategoryDataset(getNumSamplesDataset(), 0, NUM_COLUMNS);
        plot.setDataset(1, numSamplesDataset);
        LineAndShapeRenderer numSamplesRenderer = new LineAndShapeRenderer();
        numSamplesRenderer.setSeriesPaint(0, Color.RED);
        plot.setRenderer(1, numSamplesRenderer);

        numRecordersDataset = new SlidingCategoryDataset(getNumRecordersDataset(), 0, NUM_COLUMNS);
        plot.setDataset(2, numRecordersDataset);
        LineAndShapeRenderer numRecordersRenderer = new LineAndShapeRenderer();
        numRecordersRenderer.setSeriesPaint(0, Color.GREEN);
        plot.setRenderer(2, numRecordersRenderer);

        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

        updateVisibleYears(savedPercent);

        return new JFreeChart(plot);
    } catch (IllegalArgumentException e) {
        // Something was wrong with the file
    }
    return null;
}

From source file:oct.analysis.application.OCTSelection.java

public void drawSelection(Graphics g, int imageOffsetX, int imageOffsetY) {
    if (highlighted) {
        g.setColor(Color.pink);//  w  w  w  .j  a  v a  2  s.  c o m
    } else {
        g.setColor(Color.green);
    }
    //draw lines arround the area that is the selection
    int leftEdge = getSelectionLeftEdgeCoordinate();
    int rightEdge = getSelectionRightEdgeCoordinate();
    //        g.drawRect(imageOffsetX + leftEdge - 1, imageOffsetY + yPositionOnOct - 1, width + 2, height + 2);
    //draw left line
    g.drawLine(imageOffsetX + leftEdge - 1, imageOffsetY + yPositionOnOct, imageOffsetX + leftEdge - 1,
            imageOffsetY + yPositionOnOct + height - 1);
    //draw right line
    g.drawLine(imageOffsetX + rightEdge + 1, imageOffsetY + yPositionOnOct, imageOffsetX + rightEdge + 1,
            imageOffsetY + yPositionOnOct + height - 1);
    //draw top line
    g.drawLine(imageOffsetX + leftEdge, imageOffsetY + yPositionOnOct, imageOffsetX + rightEdge,
            imageOffsetY + yPositionOnOct);
    //draw bottom line
    g.drawLine(imageOffsetX + leftEdge, imageOffsetY + yPositionOnOct + height, imageOffsetX + rightEdge,
            imageOffsetY + yPositionOnOct + height);
    //draw button for interacting with the selection
    drawSelectButton(g, imageOffsetX, imageOffsetY);
    drawn = true;
}

From source file:com.unicauca.braim.braimclient.BraimGui.java

private void create_socket() {
    try {//from w ww  .ja v a  2  s .c  om
        socket = IO.socket(Util.server_url + Util.socket_port);
    } catch (URISyntaxException ex) {
        System.out.println("There is an error with node" + ex);
    }
    socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {

        @Override
        public void call(Object... args) {
            lbl_status.setText("Connected to Braim Server");
            lbl_status.setForeground(Color.GREEN);
            lbl_username.setText(currentUser.getUsername());
            enable_panels(true);
        }
    });
    socket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
        @Override
        public void call(Object... os) {
            System.out.println("Disconnected of Braim Server..");
            lbl_status.setText("Without Connection...");
            lbl_status.setForeground(Color.BLACK);
            enable_panels(false);
            lbl_username.setText("No user connected");
            menu_item_emo_device.setEnabled(true);

            //** Emotiv disconnection task generates a fatal error **
            //emotivTask.cancel(true);
            //emotivTask = null;
        }
    });
    socket.on("init_capture", new Emitter.Listener() {

        @Override
        public void call(Object... os) {
            menu_item_emo_device.setEnabled(false);
            (emotivTask = new EmotivEngineTask()).execute();
        }
    });

    try {
        Session session = client.POST_Session(currentUser.getId(), token.getAccess_token());
        socket.connect();
        String session_json = new Gson().toJson(session);
        socket.emit("register_session", session_json);
        lbl_session_id.setText(session.getId());
    } catch (IOException ex) {
        Logger.getLogger(BraimGui.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, ex.getMessage());
        socket.disconnect();
    }

}

From source file:JDAC.JDAC.java

public JDAC() {
    setTitle("JDAC");

    ImageIcon img = new ImageIcon("logo.png");
    setIconImage(img.getImage());//from   ww  w . j  a  v a  2 s .  com

    //setLayout(new FlowLayout());

    mDataset = createDataset("A");

    mChart = ChartFactory.createXYLineChart("Preview", "Time (ms)", "Value", mDataset, PlotOrientation.VERTICAL,
            false, true, false);

    mLastChart = ChartFactory.createXYLineChart("Last n values", "Time (ms)", "Value", createLastDataset("B"),
            PlotOrientation.VERTICAL, false, true, false);
    mChart.getXYPlot().getDomainAxis().setLowerMargin(0);
    mChart.getXYPlot().getDomainAxis().setUpperMargin(0);
    mLastChart.getXYPlot().getDomainAxis().setLowerMargin(0);
    mLastChart.getXYPlot().getDomainAxis().setUpperMargin(0);

    ChartPanel chartPanel = new ChartPanel(mChart);
    ChartPanel chartLastPanel = new ChartPanel(mLastChart);
    //chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) );

    XYPlot plot = mChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.GREEN);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    plot.setRenderer(renderer);

    XYPlot lastPlot = mLastChart.getXYPlot();
    XYLineAndShapeRenderer lastRenderer = new XYLineAndShapeRenderer();
    lastRenderer.setSeriesPaint(0, Color.RED);
    lastRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    lastPlot.setRenderer(lastRenderer);

    resetChartButton = new JButton("Reset");
    resetChartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetChart();
        }
    });

    mMenuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenu sensorMenu = new JMenu("Sensor");
    JMenu deviceMenu = new JMenu("Device");
    portSubMenu = new JMenu("Port");
    JMenu helpMenu = new JMenu("Help");

    serialStatusLabel = new JLabel("Disconnected");
    statusLabel = new JLabel("Ready");
    clearStatus = new LabelClear(statusLabel);
    clearStatus.resetTime();

    connectButton = new JMenuItem("Connect");
    disconnectButton = new JMenuItem("Disconnect");
    startButton = new JButton("Start");
    stopButton = new JButton("Stop");
    scanButton = new JMenuItem("Refresh port list");
    exportCSVButton = new JMenuItem("Export data to CSV");
    exportCSVButton.setAccelerator(KeyStroke.getKeyStroke("control S"));
    exportCSVButton.setMnemonic(KeyEvent.VK_S);
    exportPNGButton = new JMenuItem("Export chart to PNG");

    JPanel optionsPanel = new JPanel(new BorderLayout());

    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.setAccelerator(KeyStroke.getKeyStroke("control X"));
    exitItem.setMnemonic(KeyEvent.VK_X);

    JMenuItem aboutItem = new JMenuItem("About");
    JMenuItem helpItem = new JMenuItem("Help");
    JMenuItem quickStartItem = new JMenuItem("Quick start");

    lastSpinner = new JSpinner(new SpinnerNumberModel(10, 0, 1000, 1));

    ActionListener mSensorListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setSensor(e.getActionCommand());
        }
    };
    ButtonGroup sensorGroup = new ButtonGroup();
    JRadioButtonMenuItem tmpRadioButton = new JRadioButtonMenuItem("Temperature");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Distance");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Voltage");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Generic");
    tmpRadioButton.setSelected(true);
    setSensor("Generic");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);

    connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (selectedPortName == null) {
                setStatus("No port selected");
                return;
            }
            connect(selectedPortName);
        }
    });
    disconnectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            serialStatusLabel.setText("Disconnecting...");
            if (serialPort == null) {
                serialStatusLabel.setText("Disconnected");
                serialConnected = false;
                return;
            }

            stopCollect();
            disconnect();
        }
    });
    scanButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            searchForPorts();
        }
    });
    exportCSVButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveData();
        }
    });
    exportPNGButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            exportPNG();
        }
    });
    startButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            startCollect();
        }
    });
    stopButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            stopCollect();
        }
    });
    lastSpinner.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            numLastValues = (Integer) lastSpinner.getValue();
            updateLastTitle();
        }
    });
    updateLastTitle();
    exitItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    helpItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new HelpFrame();
        }
    });
    aboutItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutFrame();
        }
    });
    quickStartItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new StartFrame();
        }
    });

    fileMenu.add(exportCSVButton);
    fileMenu.add(exportPNGButton);
    fileMenu.addSeparator();
    fileMenu.add(exitItem);
    deviceMenu.add(connectButton);
    deviceMenu.add(disconnectButton);
    deviceMenu.addSeparator();
    deviceMenu.add(portSubMenu);
    deviceMenu.add(scanButton);
    helpMenu.add(quickStartItem);
    helpMenu.add(helpItem);
    helpMenu.add(aboutItem);

    mMenuBar.add(fileMenu);
    mMenuBar.add(sensorMenu);
    mMenuBar.add(deviceMenu);
    mMenuBar.add(helpMenu);

    JPanel controlsPanel = new JPanel();
    controlsPanel.add(startButton);
    controlsPanel.add(stopButton);
    controlsPanel.add(resetChartButton);
    optionsPanel.add(controlsPanel, BorderLayout.LINE_START);

    JPanel lastPanel = new JPanel(new FlowLayout());
    lastPanel.add(new JLabel("Shown values: "));
    lastPanel.add(lastSpinner);
    optionsPanel.add(lastPanel);

    JPanel serialPanel = new JPanel(new FlowLayout());
    serialPanel.add(serialStatusLabel);
    optionsPanel.add(serialPanel, BorderLayout.LINE_END);

    add(optionsPanel, BorderLayout.PAGE_START);

    JPanel mainPanel = new JPanel(new GridLayout(0, 2));
    mainPanel.add(chartPanel);
    mainPanel.add(chartLastPanel);
    add(mainPanel);

    add(statusLabel, BorderLayout.PAGE_END);
    setJMenuBar(mMenuBar);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            dispose();
        }
    });

    setSize(800, 800);
    pack();
    new StartFrame();

    //center on screen
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - getHeight()) / 2);
    setLocation(x, y);

    setVisible(true);
}

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

/**
 * Creates a sample chart.//from ww  w.j a va  2 s  . c om
 * 
 * @param dataset  the dataset.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            !legendPanelOn, // include legend
            true, false);

    chart.setBackgroundPaint(Color.lightGray);

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

    CategoryItemRenderer renderer = new CustomBarRenderer(new Paint[] { Color.red, Color.blue, Color.green,
            Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue });
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER,
            45.0);
    renderer.setBasePositiveItemLabelPosition(p);
    plot.setRenderer(renderer);

    CategoryMarker marker = new CategoryMarker("Category 3");
    marker.setLabel("Special");
    marker.setPaint(new Color(0xDD, 0xFF, 0xDD, 0x80));
    marker.setAlpha(0.5f);
    marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
    plot.addDomainMarker(marker, Layer.BACKGROUND);

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

    BarRenderer seriesRenderer = (BarRenderer) plot.getRenderer();
    seriesRenderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;

}

From source file:umontreal.iro.lecuyer.charts.SSJCategorySeriesCollection.java

protected static String detectXColorClassic(Color color) {
    String retour = null;/*w  w  w .ja  v a 2 s  .  co m*/

    int red = color.getRed();
    int green = color.getGreen();
    int blue = color.getBlue();

    // On utilise pas la method Color.equals(Color ) car on ne veut pas tester le parametre de transparence : Alpha
    if (red == Color.GREEN.getRed() && blue == Color.GREEN.getBlue() && green == Color.GREEN.getGreen())
        return "green";
    else if (red == Color.RED.getRed() && blue == Color.RED.getBlue() && green == Color.RED.getGreen())
        return "red";
    else if (red == Color.WHITE.getRed() && blue == Color.WHITE.getBlue() && green == Color.WHITE.getGreen())
        return "white";
    else if (red == Color.GRAY.getRed() && blue == Color.GRAY.getBlue() && green == Color.GRAY.getGreen())
        return "gray";
    else if (red == Color.BLACK.getRed() && blue == Color.BLACK.getBlue() && green == Color.BLACK.getGreen())
        return "black";
    else if (red == Color.YELLOW.getRed() && blue == Color.YELLOW.getBlue() && green == Color.YELLOW.getGreen())
        return "yellow";
    else if (red == Color.MAGENTA.getRed() && blue == Color.MAGENTA.getBlue()
            && green == Color.MAGENTA.getGreen())
        return "magenta";
    else if (red == Color.CYAN.getRed() && blue == Color.CYAN.getBlue() && green == Color.CYAN.getGreen())
        return "cyan";
    else if (red == Color.BLUE.getRed() && blue == Color.BLUE.getBlue() && green == Color.BLUE.getGreen())
        return "blue";
    else if (red == Color.DARK_GRAY.getRed() && blue == Color.DARK_GRAY.getBlue()
            && green == Color.DARK_GRAY.getGreen())
        return "darkgray";
    else if (red == Color.LIGHT_GRAY.getRed() && blue == Color.LIGHT_GRAY.getBlue()
            && green == Color.LIGHT_GRAY.getGreen())
        return "lightgray";
    else if (red == Color.ORANGE.getRed() && blue == Color.ORANGE.getBlue() && green == Color.ORANGE.getGreen())
        return "orange";
    else if (red == Color.PINK.getRed() && blue == Color.PINK.getBlue() && green == Color.PINK.getGreen())
        return "pink";

    if (red == 192 && blue == 128 && green == 64)
        return "brown";
    else if (red == 128 && blue == 128 && green == 0)
        return "olive";
    else if (red == 128 && blue == 0 && green == 128)
        return "violet";
    else if (red == 192 && blue == 0 && green == 64)
        return "purple";
    else
        return null;
}

From source file:ala.soils2sat.DrawingUtils.java

public static Rectangle drawString(Graphics g, Font font, String text, int x, int y, int width, int height,
        int align, boolean wrap) {
    g.setFont(font);/*from www  . j a va 2 s. co m*/
    FontMetrics fm = g.getFontMetrics(font);

    setPreferredAliasingMode(g);

    Rectangle ret = new Rectangle(0, 0, 0, 0);

    if (text == null) {
        return ret;
    }
    String[] alines = text.split("\\n");
    ArrayList<String> lines = new ArrayList<String>();
    for (String s : alines) {
        if (wrap && fm.stringWidth(s) > width) {
            // need to split this up into multiple lines...
            List<String> splitLines = wrapString(s, fm, width);
            lines.addAll(splitLines);
        } else {
            lines.add(s);
        }
    }
    int numlines = lines.size();
    while (fm.getHeight() * numlines > height) {
        numlines--;
    }
    if (numlines > 0) {
        int maxwidth = 0;
        int minxoffset = y + width;
        int totalheight = (numlines * fm.getHeight());

        int linestart = ((height / 2) - (totalheight / 2));

        if (!wrap) {
            ret.y = y + linestart;
        } else {
            ret.y = y;
            linestart = 0;
        }
        for (int idx = 0; idx < numlines; ++idx) {
            String line = lines.get(idx);
            int stringWidth = fm.stringWidth(line);
            // the width of the label depends on the font :
            // if the width of the label is larger than the item
            if (stringWidth > 0 && width < stringWidth) {
                // We have to truncate the label
                line = clipString(null, fm, line, width);
                stringWidth = fm.stringWidth(line);
            }

            int xoffset = 0;
            int yoffset = linestart + fm.getHeight() - fm.getDescent();
            if (align == TEXT_ALIGN_RIGHT) {
                xoffset = (width - stringWidth);
            } else if (align == TEXT_ALIGN_CENTER) {
                xoffset = (int) Math.round((double) (width - stringWidth) / (double) 2);
            }

            if (xoffset < minxoffset) {
                minxoffset = xoffset;
            }
            g.drawString(line, x + xoffset, y + yoffset);
            if (stringWidth > maxwidth) {
                maxwidth = stringWidth;
            }
            linestart += fm.getHeight();
        }

        ret.width = maxwidth;
        ret.height = totalheight;
        ret.x = x + minxoffset;

        // Debug only...
        if (DEBUG) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.setStroke(new BasicStroke(1));
            g.setColor(Color.blue);
            g.drawRect(ret.x, ret.y, ret.width, ret.height);
            g.setColor(Color.green);
            g.drawRect(x, y, width, height);
        }

        return ret;
    }
    return ret;
}

From source file:com.robertolosanno.cdt_maven.Cdt.java

public Cdt() {
    //Ontologia//from  w ww  . jav  a2s  .  c om
    OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    loadModel(m);
    ExtendedIterator<OntClass> iter = m.listHierarchyRootClasses();

    // create a simple graph
    graph = new DelegateTree<String, String>();

    createTree(iter);

    //Vincoli
    System.out.println("--- CONSTRAINTS ---");
    ExtendedIterator<ObjectProperty> iterProp = m.listObjectProperties();
    while (iterProp.hasNext()) {
        ObjectProperty objProp = iterProp.next();
        plotConstraint(objProp);
    }

    treeLayout = new TreeLayout<String, String>(graph);
    vv = new VisualizationViewer<String, String>(treeLayout, new Dimension(1200, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));

    //***************** MODIFICA COLORE VERTICE ************************
    Transformer<String, Paint> vertexColor = new Transformer<String, Paint>() {
        public Paint transform(String s) {
            String[] ss = s.split("#");
            String type = ss[1];
            if (type.equals("root"))
                return Color.lightGray;
            if (type.equals("dim"))
                return Color.BLACK;
            if (type.equals("val"))
                return Color.WHITE;
            if (type.equals("par_val"))
                return Color.WHITE;
            if (type.equals("par_dim"))
                return Color.WHITE;

            return Color.GREEN;
        }
    };
    vv.getRenderContext().setVertexFillPaintTransformer(vertexColor);

    //**************** MODIFICA FORMA VERTICE ***************************

    //Dati per creare un triangolo (lo creaiamo attraverso la classe Polygon)
    final int[] xShape = new int[4];
    final int[] yShape = new int[4];
    final int nShape; // count of points
    // Make a shape
    xShape[0] = -10;
    xShape[1] = 0;
    xShape[2] = 10;
    yShape[0] = 0;
    yShape[1] = 20;
    yShape[2] = 0;
    nShape = 3;

    Transformer<String, Shape> vertexShape = new Transformer<String, Shape>() {
        private final Shape[] styles = { new Rectangle(-10, -10, 20, 20),
                new Ellipse2D.Double(-10, -10, 20, 20), new Polygon(xShape, yShape, nShape) //Triangolo

        };

        @Override
        public Shape transform(String i) {
            String[] type = i.split("#");
            if (type[1].equals("par_val")) {
                return styles[0];
            } else if (type[1].equals("par_dim")) {
                return styles[2];
            } else {
                return styles[1];
            }
        }
    };
    vv.getRenderContext().setVertexShapeTransformer(vertexShape);

    //                          vv.getRenderer().setVertexRenderer(new MyRenderer());

    //**************** MODIFICA FONT LABEL ***************************
    vv.getRenderContext().setVertexFontTransformer(new Transformer<String, Font>() {

        @Override
        public Font transform(String arg0) {
            Font font = new Font("Arial Unicode MS", Font.PLAIN, 11);
            return font;
        }
    });

    // ********************** POSIZIONA LA LABEL SOTTO IL VERTICE ****************************
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S);

    //******************** RIMUOVE DAL TESTO DELLA LABEL DEL VERTICE IL TIPO DI VERTICE ************************

    Transformer<String, String> transformer = new Transformer<String, String>() {
        @Override
        public String transform(String arg0) {
            String[] node = arg0.split("#");
            return node[0];
        }
    };

    vv.getRenderContext().setVertexLabelTransformer(transformer);

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

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

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        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());
        }
    });

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

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);
    controls.add(modeBox);

    content.add(controls, BorderLayout.SOUTH);
}

From source file:giaodien.tongquan.TongQuan.java

public void GraphTongDoanhThu() throws SQLException {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    PreparedStatement doanhthu = con.prepareStatement(
            "SELECT sum(TONGTIEN) as DoanhThu, day(date(THOIGIAN)) As Ngay FROM shop.hoadonbanhang where month(date(THOIGIAN))= "
                    + thang + " group by day(date(THOIGIAN)) ");
    ResultSet rsdoanhthu = doanhthu.executeQuery();
    while (rsdoanhthu.next()) {

        doanhthutrongngay = rsdoanhthu.getInt("DoanhThu");
        ngay = rsdoanhthu.getString("Ngay");

        dataset.setValue(doanhthutrongngay, "", ngay);
    }/*from  w  w w  . j a  va  2s . c o  m*/

    JFreeChart chart = ChartFactory.createBarChart3D(null, null, "VN?", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    CategoryPlot catePlot = chart.getCategoryPlot();
    catePlot.setRangeGridlinePaint(Color.BLACK);

    //set  bar chart color

    ((BarRenderer) catePlot.getRenderer()).setBarPainter(new StandardBarPainter());

    BarRenderer r = (BarRenderer) chart.getCategoryPlot().getRenderer();
    r.setSeriesPaint(0, Color.GREEN);

    ChartPanel chartpanel = new ChartPanel(chart);
    graph.removeAll();
    graph.add(chartpanel, BorderLayout.CENTER);
    graph.setBackground(getBackground());
    graph.validate();

}

From source file:net.sf.dynamicreports.test.jasper.chart.ChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from w  ww.  j  av a  2s  .  c  om*/

    chartCountTest("summary.chart1", 1);
    JFreeChart chart = getChart("summary.chart1", 0);

    TextTitle title = chart.getTitle();
    Assert.assertEquals("title", "title", title.getText());
    Assert.assertEquals("title color", Color.BLUE, title.getPaint());
    Assert.assertEquals("title font", new Font("Arial", Font.BOLD, 10), title.getFont());
    Assert.assertEquals("title position", RectangleEdge.RIGHT, title.getPosition());

    TextTitle subtitle = (TextTitle) chart.getSubtitle(1);
    Assert.assertEquals("subtitle", "subtitle", subtitle.getText());
    Assert.assertEquals("subtitle color", Color.CYAN, subtitle.getPaint());
    Assert.assertEquals("subtitle font", new Font("Arial", Font.PLAIN, 10), subtitle.getFont());

    LegendTitle legend = (LegendTitle) chart.getSubtitle(0);
    Assert.assertEquals("legend color", Color.BLUE, legend.getItemPaint());
    Assert.assertEquals("legend backgroundcolor", Color.LIGHT_GRAY, legend.getBackgroundPaint());
    Assert.assertEquals("legend font", new Font("Courier New", Font.PLAIN, 10), legend.getItemFont());
    Assert.assertEquals("legend position", RectangleEdge.LEFT, legend.getPosition());

    chartCountTest("summary.chart2", 1);
    chart = getChart("summary.chart2", 0);
    Assert.assertNull("legend", chart.getLegend());
    Assert.assertEquals("plot orientation", PlotOrientation.HORIZONTAL,
            chart.getCategoryPlot().getOrientation());
    Assert.assertEquals("plot series colors", Color.BLUE, chart.getPlot().getDrawingSupplier().getNextPaint());
    Assert.assertEquals("plot series colors", Color.GREEN, chart.getPlot().getDrawingSupplier().getNextPaint());
    Assert.assertEquals("plot series colors", Color.RED, chart.getPlot().getDrawingSupplier().getNextPaint());
}