Example usage for java.awt Color DARK_GRAY

List of usage examples for java.awt Color DARK_GRAY

Introduction

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

Prototype

Color DARK_GRAY

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

Click Source Link

Document

The color dark gray.

Usage

From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java

@Override
protected JFreeChart createCandlestickChart() throws JRException {
    JFreeChart jfreeChart = super.createCandlestickChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    CandlestickRenderer renderer = (CandlestickRenderer) xyPlot.getRenderer();
    DefaultHighLowDataset dataset = (DefaultHighLowDataset) xyPlot.getDataset();
    @SuppressWarnings("unchecked")
    List<Paint> seriesPaints = (List<Paint>) getDefaultValue(defaultChartPropertiesMap,
            ChartThemesConstants.SERIES_COLORS);

    for (int i = 0; i < dataset.getSeriesCount(); i++) {

        renderer.setSeriesFillPaint(i, seriesPaints.get(i));
        renderer.setSeriesPaint(i, Color.DARK_GRAY);
    }//  www  .j av  a  2s .c  o  m
    return jfreeChart;
}

From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java

private TableCellEditor getCellEditor(final SwingTreeCol col) {
    return new DefaultCellEditor(new JComboBox()) {

        JComponent control;/*w  w  w. j  a v  a 2s . com*/

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
                final int row, final int column) {
            Component comp;
            ColumnType colType = col.getColumnType();
            if (colType == ColumnType.DYNAMIC) {
                colType = ColumnType.valueOf(extractDynamicColType(elements.toArray()[row], column));
            }

            final XulTreeCell cell = getRootChildren().getItem(row).getRow().getCell(column);
            switch (colType) {
            case CHECKBOX:
                final JCheckBox checkbox = new JCheckBox();
                final JTable tbl = table;
                checkbox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent event) {
                        SwingTree.this.table.setValueAt(checkbox.isSelected(), row, column);
                        tbl.getCellEditor().stopCellEditing();
                    }
                });

                control = checkbox;
                if (value instanceof String) {
                    checkbox.setSelected(((String) value).equalsIgnoreCase("true")); //$NON-NLS-1$
                } else if (value instanceof Boolean) {
                    checkbox.setSelected((Boolean) value);
                } else if (value == null) {
                    checkbox.setSelected(false);
                }
                if (isSelected) {
                    checkbox.setBackground(Color.LIGHT_GRAY);
                }
                comp = checkbox;
                checkbox.setEnabled(!cell.isDisabled());
                break;
            case EDITABLECOMBOBOX:
            case COMBOBOX:
                Vector val = (value != null && value instanceof Vector) ? (Vector) value : new Vector();
                final JComboBox comboBox = new JComboBox(val);

                if (isSelected) {
                    comboBox.setBackground(Color.LIGHT_GRAY);
                }

                if (colType == ColumnType.EDITABLECOMBOBOX) {

                    comboBox.setEditable(true);
                    final JTextComponent textComp = (JTextComponent) comboBox.getEditor().getEditorComponent();

                    textComp.addKeyListener(new KeyListener() {
                        private String oldValue = ""; //$NON-NLS-1$

                        public void keyPressed(KeyEvent e) {
                            oldValue = textComp.getText();
                        }

                        public void keyReleased(KeyEvent e) {
                            if (oldValue != null && !oldValue.equals(textComp.getText())) {
                                SwingTree.this.table.setValueAt(textComp.getText(), row, column);

                                oldValue = textComp.getText();
                            } else if (oldValue == null) {
                                // AWT error where sometimes the keyReleased is fired before keyPressed.
                                oldValue = textComp.getText();
                            } else {
                                logger.debug("Special key pressed, ignoring"); //$NON-NLS-1$
                            }
                        }

                        public void keyTyped(KeyEvent e) {
                        }
                    });

                    comboBox.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent event) {
                            // if(textComp.hasFocus() == false && comboBox.hasFocus()){
                            SwingTree.logger.debug("Setting ComboBox value from editor: " //$NON-NLS-1$
                                    + comboBox.getSelectedItem() + ", " + row + ", " + column); //$NON-NLS-1$ //$NON-NLS-2$

                            SwingTree.this.table.setValueAt(comboBox.getSelectedIndex(), row, column);
                            // }
                        }
                    });
                } else {
                    comboBox.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent event) {

                            SwingTree.logger.debug("Setting ComboBox value from editor: " //$NON-NLS-1$
                                    + comboBox.getSelectedItem() + ", " + row + ", " + column); //$NON-NLS-1$ //$NON-NLS-2$

                            SwingTree.this.table.setValueAt(comboBox.getSelectedIndex(), row, column);
                        }
                    });
                }

                control = comboBox;
                comboBox.setEnabled(!cell.isDisabled());
                comp = comboBox;
                break;
            case LABEL:
                JLabel lbl = new JLabel(cell.getLabel());
                comp = lbl;
                control = lbl;
                break;
            case CUSTOM:
                return new CustomCellEditorWrapper(cell, customEditors.get(col.getType()));
            default:
                final JTextField label = new JTextField((String) value);

                label.getDocument().addDocumentListener(new DocumentListener() {

                    public void changedUpdate(DocumentEvent arg0) {
                        SwingTree.this.table.setValueAt(label.getText(), row, column);
                    }

                    public void insertUpdate(DocumentEvent arg0) {
                        SwingTree.this.table.setValueAt(label.getText(), row, column);
                    }

                    public void removeUpdate(DocumentEvent arg0) {
                        SwingTree.this.table.setValueAt(label.getText(), row, column);
                    }

                });
                if (isSelected) {
                    label.setOpaque(true);
                    // label.setBackground(Color.LIGHT_GRAY);
                }

                control = label;
                comp = label;
                label.setEnabled(!cell.isDisabled());
                label.setDisabledTextColor(Color.DARK_GRAY);
                break;
            }

            return comp;
        }

        @Override
        public Object getCellEditorValue() {
            if (control instanceof JCheckBox) {
                return ((JCheckBox) control).isSelected();
            } else if (control instanceof JComboBox) {
                JComboBox box = (JComboBox) control;
                if (box.isEditable()) {
                    return ((JTextComponent) box.getEditor().getEditorComponent()).getText();
                } else {
                    return box.getSelectedIndex();
                }
            } else if (control instanceof JTextField) {
                return ((JTextField) control).getText();
            } else {
                return ((JLabel) control).getText();
            }
        }

    };

}

From source file:com.diversityarrays.kdxplore.specgroup.SpecimenGroupEditor.java

private JComponent createBottomComponent() {
    // =========/*from  w ww  .  ja  va2  s .  c o  m*/
    specimenTableModel = new SpecimenTableModel(null);
    specimenTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            exportSpecimenList.setEnabled(specimenTableModel.getRowCount() > 0);
        }
    });
    specimenTable = new JTable(specimenTableModel);

    specimenTable.setAutoCreateRowSorter(true);
    specimenTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                deleteSpecimenFromList.setEnabled(specimenTable.getSelectedRowCount() > 0);
            }
        }
    });
    //      specimenTableModel.addTableModelListener(new TableModelListener() {
    //            @Override
    //            public void tableChanged(TableModelEvent e) {
    //                fileDropTarget.setVisible(specimenTableModel.getRowCount() > 0);
    //            }
    //        });
    CompoundBorder border = new CompoundBorder(new LineBorder(Color.DARK_GRAY), new EmptyBorder(4, 2, 4, 2));
    fileDropTarget.setBorder(border);
    fileDropTarget.setBackground(Color.LIGHT_GRAY);
    //      fileDropTarget.setVisible(false);
    deleteSpecimenFromList.setEnabled(false);

    TitledTablePanel specimenTablePanel = new TitledTablePanel("Specimen", specimenTable,
            "Download from database,\n  Drag/drop Specimens or Drag/drop CSV File above");

    //      saveAction.setEnabled(false);
    //      downloadSpecimenList.setEnabled(false);
    exportSpecimenList.setEnabled(false);

    Box otherBox = Box.createHorizontalBox();
    otherBox.add(downloadSpecimensButton);
    otherBox.add(fileDropTarget);
    otherBox.add(Box.createHorizontalGlue());

    otherBox.add(new JButton(exportSpecimenList));
    otherBox.add(Box.createHorizontalGlue());
    otherBox.add(new JLabel("(local)"));
    otherBox.add(new JButton(deleteSpecimenFromList));

    JPanel containerPanel2 = new JPanel(new BorderLayout());
    containerPanel2.add(otherBox, BorderLayout.NORTH);
    containerPanel2.add(specimenTablePanel, BorderLayout.CENTER);

    fileDropTarget.setTransferHandler(flth);

    //        TableTransferHandler tth2 = TableTransferHandler.initialiseForCopySelectAll(specimenTable, true);
    //        ChainingTransferHandler cth = new ChainingTransferHandler(flth, genotypeTransferHandler, tth2);

    TransferHandler cth = genotypeTransferHandler;
    //        ChainingTH cth = new ChainingTH(genotypeTransferHandler, tth2);

    specimenTablePanel.scrollPane.setTransferHandler(cth);

    specimenTablePanel.setTransferHandler(cth);
    specimenTable.setTransferHandler(cth);
    specimenTable.setDragEnabled(true);

    return containerPanel2;
}

From source file:co.edu.eam.dinesoft.egresados.vista.gui.VentanaReportes.java

private void pintarPanel() {
    Color c1 = Color.DARK_GRAY;
    Color c2 = Color.white;
    VentanaReportes.jpColor jpmicolor = new VentanaReportes.jpColor(c1, c2);
    jpmicolor.setSize(this.getSize());
    jPPrincipal.add(jpmicolor);// w w w  .j  av a 2s .c o m

    Color c3 = Color.white;
    Color c4 = Color.DARK_GRAY;
    VentanaReportes.jpColor jpmicolor1 = new VentanaReportes.jpColor(c3, c4);
    jpmicolor1.setSize(this.getSize());
    jPReporteEgresados.add(jpmicolor1);
}

From source file:msi.gama.outputs.layers.ChartLayerStatement.java

public void updateseries(final IScope scope) throws GamaRuntimeException {
    // datas=dataswithoutlists;
    datasfromlists = new ArrayList<ChartData>();
    for (int dl = 0; dl < datalists.size(); dl++) {
        ChartDataList datalist = datalists.get(dl);

        Object val = datalist.valuelistexp.resolveAgainst(scope).value(scope);
        if (!(val instanceof GamaList)) {
            // GuiUtils.debug("chart list with no list...");
            return;
        }/*from  w ww .  ja v a 2 s  . com*/
        List<List> values = Cast.asList(scope, val);
        if (datalist.doreverse) {
            List tempvalues = Cast.asList(scope, val);
            values = new ArrayList<List>();
            if (tempvalues.get(0) instanceof GamaList) {
                IList nval = Cast.asList(scope, tempvalues.get(0));
                for (int j = 0; j < nval.size(); j++) {
                    List nl = new ArrayList();
                    nl.add(nval.get(j));
                    values.add(nl);
                }
            } else {
                // GuiUtils.debug("Reverse series but not list of list..." + tempvalues);
                return;

            }
            if (tempvalues.size() > 1) {
                for (int i = 1; i < tempvalues.size(); i++) {
                    if (tempvalues.get(i) instanceof GamaList) {
                        IList nval = Cast.asList(scope, tempvalues.get(i));
                        for (int j = 0; j < nval.size(); j++) {
                            // Cast.asList(scope, values.get(j)).add(nval.get(j));

                            values.get(j).add(nval.get(j));

                        }
                    } else {
                        // GuiUtils.debug("Reverse series but not list of list..." + tempvalues);
                        return;

                    }
                }
            }

            // GuiUtils.debug("New Values"+values);
        }

        List defaultnames = new ArrayList<String>();
        List defaultcolors = new ArrayList<GamaColor>();
        for (int i = 0; i < values.size() + 1; i++) {
            defaultnames.add("data" + i);
            // defaultcolors.add(GamaColor.array[i]);
            if (i < 10) {

                if (i == 0) {
                    defaultcolors.add(Cast.asColor(scope, Color.CYAN));
                }
                if (i == 1) {
                    defaultcolors.add(Cast.asColor(scope, Color.RED));
                }
                if (i == 2) {
                    defaultcolors.add(Cast.asColor(scope, Color.YELLOW));
                }
                if (i == 3) {
                    defaultcolors.add(Cast.asColor(scope, Color.GREEN));
                }
                if (i == 4) {
                    defaultcolors.add(Cast.asColor(scope, Color.BLUE));
                }
                if (i == 5) {
                    defaultcolors.add(Cast.asColor(scope, Color.PINK));
                }
                if (i == 6) {
                    defaultcolors.add(Cast.asColor(scope, Color.MAGENTA));
                }
                if (i == 7) {
                    defaultcolors.add(Cast.asColor(scope, Color.ORANGE));
                }
                if (i == 8) {
                    defaultcolors.add(Cast.asColor(scope, Color.LIGHT_GRAY));
                }
                if (i == 9) {
                    defaultcolors.add(Cast.asColor(scope, Color.DARK_GRAY));
                }
            }
            if (i >= 10) {
                if (i < GamaColor.colors.size()) {
                    defaultcolors.add(GamaColor.int_colors.values()[i]);
                } else {
                    defaultcolors.add(GamaColor.getInt(Random.opRnd(scope, 10000)));
                }
            }

        }

        if (datalist.colorlistexp != null) {
            Object valcol = datalist.colorlistexp.resolveAgainst(scope).value(scope);
            if (valcol instanceof GamaList) {
                for (int c = 0; c < ((GamaList) valcol).size(); c++) {
                    // if ( type == SERIES_CHART)
                    // defaultcolors.set(c+1, Cast.asColor(scope, ((GamaList)valcol).get(c)));
                    // else
                    defaultcolors.set(c, Cast.asColor(scope, ((GamaList) valcol).get(c)));

                }

            }
        }

        boolean dynamicseriesnames = false;
        List<String> seriesnames = new ArrayList();

        if (datalist.legendlistexp != null) {
            Object valc = datalist.legendlistexp.resolveAgainst(scope).value(scope);

            if (valc instanceof GamaList) {
                dynamicseriesnames = true;
                seriesnames = (GamaList) valc;
                for (int i = 0; i < Math.min(values.size(), seriesnames.size()); i++) {
                    defaultnames.set(i, seriesnames.get(i) + "(" + i + ")");
                    if (type == SERIES_CHART && ((XYPlot) chart.getPlot()).getDataset(i + 1) != null) {
                        if (((DefaultTableXYDataset) ((XYPlot) chart.getPlot()).getDataset(i + 1))
                                .getSeriesCount() > 0) {
                            ((DefaultTableXYDataset) ((XYPlot) chart.getPlot()).getDataset(i + 1)).getSeries(0)
                                    .setKey(seriesnames.get(i) + "(" + i + ")");
                        }

                    }
                }
                if (values.size() > seriesnames.size()) {
                    for (int i = seriesnames.size(); i < values.size(); i++) {
                        defaultnames.set(i, "(" + i + ")");
                    }
                }
            } else {
                for (int i = values.size(); i < values.size(); i++) {
                    defaultnames.set(i, "(" + i + ")");
                }
            }
        }

        int nbseries = values.size();
        // if ( type==SERIES_CHART ) nbseries++;
        // ChartData first=datas.get(0);
        if (type == HISTOGRAM_CHART) {
            ((DefaultCategoryDataset) dataset).clear();
        }
        if (type == PIE_CHART) {
            ((DefaultPieDataset) dataset).clear();
        }
        if (nbseries > datalist.previoussize) {

            for (int i = datalist.previoussize; i < nbseries; i++) {
                AbstractRenderer r;
                try {
                    r = datalist.renderer.getClass().newInstance();
                    if (XYLineAndShapeRenderer.class.isAssignableFrom(r.getClass())) {
                        ((XYLineAndShapeRenderer) r).setBaseShapesFilled(
                                ((XYLineAndShapeRenderer) datalist.renderer).getBaseShapesFilled());
                        ((XYLineAndShapeRenderer) r).setBaseShapesVisible(
                                ((XYLineAndShapeRenderer) datalist.renderer).getBaseShapesVisible());
                        ((XYLineAndShapeRenderer) r).setSeriesLinesVisible(0,
                                ((XYLineAndShapeRenderer) datalist.renderer).getSeriesLinesVisible(0));
                    }
                    ChartData newdata;
                    newdata = ChartDataListStatement.newChartData(scope, r,
                            Cast.asString(scope, defaultnames.get(i)),
                            Cast.asColor(scope, defaultcolors.get(i)), values.get(i));

                    datas.add(newdata);
                    datasfromlists.add(newdata);

                    if (type == SERIES_CHART || type == XY_CHART || type == SCATTER_CHART) {
                        final XYPlot plot = (XYPlot) chart.getPlot();
                        final String legend = newdata.getName();
                        // if (dataset==null)
                        // dataset = new XYDataset();
                        if (type == SERIES_CHART || type == XY_CHART) {
                            dataset = new DefaultTableXYDataset();
                            final XYSeries serie = new XYSeries(legend, false, false);
                            ((DefaultTableXYDataset) dataset).addSeries(serie);

                        } else {
                            dataset = new XYSeriesCollection();
                            final XYSeries serie = new XYSeries(legend, false, true);
                            ((XYSeriesCollection) dataset).addSeries(serie);

                        }
                        expressions_index.put(legend, datas.size() - 1);
                        plot.setRenderer(datas.size() - 1, (XYItemRenderer) newdata.getRenderer(), false);
                        final Color c = newdata.getColor();
                        plot.getRenderer(datas.size() - 1).setSeriesPaint(0, c);
                        // if ((i>0)||(type==XY_CHART))
                        plot.setDataset(datas.size() - 1, (XYDataset) dataset);
                        history.append(legend);
                        history.append(',');
                    }

                    if (type == HISTOGRAM_CHART) {
                        final CategoryPlot plot = (CategoryPlot) chart.getPlot();
                        int l = 0;
                        for (final ChartData e : datas) {
                            // String legend = e.getName();
                            // ((DefaultCategoryDataset) dataset).setValue(0d, new Integer(0), legend/* , legend
                            // */);

                            final String legend = e.getName();
                            if (!CategoryItemRenderer.class.isInstance(e.getRenderer())) {
                                e.renderer = new BarRenderer();
                            }
                            plot.setRenderer(l, (CategoryItemRenderer) e.getRenderer(), false);
                            final Color c = e.getColor();
                            plot.getRenderer(l).setSeriesPaint(0, c);
                            // plot.setDataset(i, (DefaultCategoryDataset) dataset);
                            // }
                            l++;
                            history.append(legend);
                            history.append(',');

                        }
                        if (history.length() > 0) {
                            history.deleteCharAt(history.length() - 1);
                        }
                        history.append(Strings.LN);
                        // plot.setDataset((DefaultCategoryDataset) dataset);

                    }
                    if (type == PIE_CHART) {
                        int l = 0;
                        // dataset = new DefaultPieDataset();
                        final PiePlot plot = (PiePlot) chart.getPlot();
                        for (final ChartData e : datas) {
                            final String legend = e.getName();
                            ((DefaultPieDataset) dataset).insertValue(l++, legend, null);
                            history.append(legend);
                            history.append(',');
                        }
                        if (history.length() > 0) {
                            history.deleteCharAt(history.length() - 1);
                        }
                        history.append(Strings.LN);
                        history.append(Strings.LN);
                        // plot.setDataset((DefaultPieDataset) dataset);
                        l = 0;
                        for (final ChartData e : datas) {
                            plot.setSectionPaint(l++, e.getColor());
                        }
                        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} ({2})"));
                        if (exploded) {
                            for (final Object c : ((DefaultPieDataset) dataset).getKeys()) {
                                plot.setExplodePercent((Comparable) c, 0.20);
                            }
                        }
                    }

                } catch (InstantiationException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
            datalist.previoussize = nbseries;
        }

        boolean dynamiccategorynames = false;
        List<String> categorynames = new ArrayList<String>();
        /*
         * if (datalist.categlistexp!=null)
         * {
         * Object valc=datalist.categlistexp.resolveAgainst(scope).value(scope);
         * if ((valc instanceof GamaList))
         * {
         * dynamiccategorynames=true;
         * categorynames=(GamaList)valc;
         * }
         *
         * if (type==HISTOGRAM_CHART)
         * {
         * for ( int i=0; i<values.size(); i++ ) {
         * GamaList x = new GamaList();
         * Object obj = values.get(i);
         * if ( obj instanceof GamaList ) {
         * x = (GamaList) obj;
         * // clearvalues=true;
         * if (dynamiccategorynames)
         * {
         * for (int j=0;j<x.length(scope);j++)
         * if (j<categorynames.size())
         * {
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope,
         * x.get(j)).doubleValue(),(String)defaultnames.get(i),categorynames.get(j).toString()+"("+j+")");
         * }
         * else
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope,
         * x.get(j)).doubleValue(),(String)defaultnames.get(i),"("+j+")");
         * }
         * else
         * {
         * for (int j=0;j<x.length(scope);j++)
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope,
         * x.get(j)).doubleValue(),(String)defaultnames.get(i), new Integer(j));
         *
         * }
         * } else {
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope, obj).doubleValue(), new
         * Integer(0),(String)defaultnames.get(i));
         * }
         * }
         * }
         * }
         */
        if (chart.getLegend() == null) {
            chart.addLegend(new LegendTitle(chart.getPlot()));
        }
        // LegendTitle legend = chart.getLegend();
        // GuiUtils.debug("dyncateg:"+defaultnames);
        // GuiUtils.debug("legend:"+legend);
        for (int i = 0; i < nbseries; i++) {
            ChartData first = datas.get(i);
            if (type == SERIES_CHART) {
                first = datas.get(i + 1);
            }
            first.lastvalue = values.get(i);

        }

    }
}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

/**
 *
 *///from  ww  w  . j ava 2 s  .c o  m
protected JFreeChart createDialChart() throws JRException {

    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

    GradientPaint gp = new GradientPaint(new Point(), Color.LIGHT_GRAY, new Point(), Color.BLACK, false);

    GradientPaint gp2 = new GradientPaint(new Point(), Color.GRAY, new Point(), Color.BLACK);

    // get data for diagrams
    DialPlot dialPlot = new DialPlot();
    //dialPlot.setView(0.0, 0.0, 1.0, 1.0);
    if (getDataset() != null) {
        dialPlot.setDataset((ValueDataset) getDataset());
    }
    StandardDialFrame dialFrame = new StandardDialFrame();
    //dialFrame.setRadius(0.60);
    //dialFrame.setBackgroundPaint(gp2);
    dialFrame.setForegroundPaint(gp2);
    dialPlot.setDialFrame(dialFrame);

    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialPlot.setBackground(db);
    StandardDialScale scale = null;
    int dialUnitScale = 1;
    Range range = convertRange(jrPlot.getDataRange());
    if (range != null) {
        double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));
        dialUnitScale = ChartThemesUtilities.getScale(bound);

        double lowerBound = ChartThemesUtilities.getTruncatedValue(range.getLowerBound(), dialUnitScale);
        double upperBound = ChartThemesUtilities.getTruncatedValue(range.getUpperBound(), dialUnitScale);

        scale = new StandardDialScale(lowerBound, upperBound, 225, -270, (upperBound - lowerBound) / 6, 15);
        if ((lowerBound == (int) lowerBound && upperBound == (int) upperBound
                && scale.getMajorTickIncrement() == (int) scale.getMajorTickIncrement()) || dialUnitScale > 1) {
            scale.setTickLabelFormatter(new DecimalFormat("#,##0"));
        } else if (dialUnitScale == 1) {

            scale.setTickLabelFormatter(new DecimalFormat("#,##0.0"));
        } else if (dialUnitScale <= 0) {
            scale.setTickLabelFormatter(new DecimalFormat("#,##0.00"));
        }

    } else {
        scale = new StandardDialScale();
    }
    scale.setTickRadius(0.9);
    scale.setTickLabelOffset(0.16);
    JRFont tickLabelFont = jrPlot.getTickLabelFont();
    Integer defaultBaseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
            ChartThemesConstants.BASEFONT_SIZE);
    Font themeTickLabelFont = getFont(
            (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT),
            tickLabelFont, defaultBaseFontSize);
    scale.setTickLabelFont(themeTickLabelFont);
    scale.setMajorTickStroke(new BasicStroke(1f));
    scale.setMinorTickStroke(new BasicStroke(0.3f));
    scale.setMajorTickPaint(Color.WHITE);
    scale.setMinorTickPaint(Color.WHITE);
    scale.setTickLabelsVisible(true);
    scale.setFirstTickLabelVisible(true);
    dialPlot.addScale(0, scale);

    List intervals = jrPlot.getIntervals();
    if (intervals != null && intervals.size() > 0) {
        int size = Math.min(3, intervals.size());
        int colorStep = 0;
        if (size > 3)
            colorStep = 255 / (size - 3);

        for (int i = 0; i < size; i++) {
            JRMeterInterval interval = (JRMeterInterval) intervals.get(i);
            Range intervalRange = convertRange(interval.getDataRange());
            double intervalLowerBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getLowerBound(),
                    dialUnitScale);
            double intervalUpperBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getUpperBound(),
                    dialUnitScale);

            Color color = i < 3 ? (Color) ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i)
                    : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0);

            ScaledDialRange dialRange = new ScaledDialRange(intervalLowerBound, intervalUpperBound,
                    interval.getBackgroundColor() == null ? color : interval.getBackgroundColor(), 12f);
            dialRange.setInnerRadius(0.41);
            dialRange.setOuterRadius(0.41);
            dialPlot.addLayer(dialRange);
        }
    }

    JRValueDisplay display = jrPlot.getValueDisplay();
    String displayVisibility = display != null && getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE)
            : "false";
    if (Boolean.parseBoolean(displayVisibility)) {
        ScaledDialValueIndicator dvi = new ScaledDialValueIndicator(0, dialUnitScale);
        dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        //         dvi.setFont(JRFontUtil.getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD));
        dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
        dvi.setPaint(Color.WHITE);

        String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
        if (pattern != null)
            dvi.setNumberFormat(new DecimalFormat(pattern));
        dvi.setRadius(0.15);
        dvi.setValueAnchor(RectangleAnchor.CENTER);
        dvi.setTextAnchor(TextAnchor.CENTER);
        //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale)));
        dialPlot.addLayer(dvi);
    }
    String label = getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL)
            : null;

    if (label != null) {
        JRFont displayFont = jrPlot.getValueDisplay().getFont();
        Font themeDisplayFont = getFont(
                (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT),
                displayFont, defaultBaseFontSize);
        if (dialUnitScale < 0)
            label = new MessageFormat(label)
                    .format(new Object[] { String.valueOf(Math.pow(10, dialUnitScale)) });
        else if (dialUnitScale < 3)
            label = new MessageFormat(label).format(new Object[] { "1" });
        else
            label = new MessageFormat(label)
                    .format(new Object[] { String.valueOf((int) Math.pow(10, dialUnitScale - 2)) });

        String[] textLines = label.split("\\n");
        for (int i = 0; i < textLines.length; i++) {
            DialTextAnnotation dialAnnotation = new DialTextAnnotation(textLines[i]);
            dialAnnotation.setFont(themeDisplayFont);
            dialAnnotation.setPaint(Color.WHITE);
            dialAnnotation.setRadius(Math.sin(Math.PI / 4.0) + i / 10.0);
            dialAnnotation.setAnchor(TextAnchor.CENTER);
            dialPlot.addLayer(dialAnnotation);
        }
    }

    //DialPointer needle = new DialPointer.Pointer();
    Paint paint = new Color(191, 48, 0);
    DialPointer needle = new ScaledDialPointer(dialUnitScale, paint, paint);

    needle.setVisible(true);
    needle.setRadius(0.91);
    dialPlot.addLayer(needle);

    DialCap cap = new DialCap();
    cap.setRadius(0.05);
    cap.setFillPaint(Color.DARK_GRAY);
    cap.setOutlinePaint(Color.GRAY);
    cap.setOutlineStroke(new BasicStroke(0.5f));
    dialPlot.setCap(cap);

    JFreeChart jfreeChart = new JFreeChart((String) evaluateExpression(getChart().getTitleExpression()), null,
            dialPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend().booleanValue());

    // Set all the generic options
    configureChart(jfreeChart, getPlot());

    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    return jfreeChart;

}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

/**
 *
 *///from  w  ww. ja v  a 2  s  . c o m
protected JFreeChart createCandlestickChart() throws JRException {
    JFreeChart jfreeChart = super.createCandlestickChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    CandlestickRenderer renderer = (CandlestickRenderer) xyPlot.getRenderer();
    DefaultHighLowDataset dataset = (DefaultHighLowDataset) xyPlot.getDataset();
    if (dataset != null) {
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            renderer.setSeriesFillPaint(i, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            renderer.setSeriesPaint(i, Color.DARK_GRAY);
        }
    }
    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java

@Override
protected JFreeChart createDialChart() throws JRException {

    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

    GradientPaint gp = new GradientPaint(new Point(), Color.LIGHT_GRAY, new Point(), Color.BLACK, false);

    GradientPaint gp2 = new GradientPaint(new Point(), Color.GRAY, new Point(), Color.BLACK);

    // get data for diagrams
    DialPlot dialPlot = new DialPlot();
    //dialPlot.setView(0.0, 0.0, 1.0, 1.0);
    if (getDataset() != null) {
        dialPlot.setDataset((ValueDataset) getDataset());
    }/*  w ww. j a  va2  s . co m*/
    StandardDialFrame dialFrame = new StandardDialFrame();
    //dialFrame.setRadius(0.60);
    //dialFrame.setBackgroundPaint(gp2);
    dialFrame.setForegroundPaint(gp2);
    dialPlot.setDialFrame(dialFrame);

    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialPlot.setBackground(db);
    StandardDialScale scale = null;
    int dialUnitScale = 1;
    Range range = convertRange(jrPlot.getDataRange());
    if (range != null) {
        double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));
        dialUnitScale = ChartThemesUtilities.getScale(bound);

        double lowerBound = ChartThemesUtilities.getTruncatedValue(range.getLowerBound(), dialUnitScale);
        double upperBound = ChartThemesUtilities.getTruncatedValue(range.getUpperBound(), dialUnitScale);
        int tickCount = jrPlot.getTickCount() != null && jrPlot.getTickCount() > 1 ? jrPlot.getTickCount() : 7;
        scale = new StandardDialScale(lowerBound, upperBound, 225, -270,
                (upperBound - lowerBound) / (tickCount - 1), 15);
        if ((lowerBound == (int) lowerBound && upperBound == (int) upperBound
                && scale.getMajorTickIncrement() == (int) scale.getMajorTickIncrement()) || dialUnitScale > 1) {
            scale.setTickLabelFormatter(
                    new DecimalFormat("#,##0", DecimalFormatSymbols.getInstance(getLocale())));
        } else if (dialUnitScale == 1) {

            scale.setTickLabelFormatter(
                    new DecimalFormat("#,##0.0", DecimalFormatSymbols.getInstance(getLocale())));
        } else if (dialUnitScale <= 0) {
            scale.setTickLabelFormatter(
                    new DecimalFormat("#,##0.00", DecimalFormatSymbols.getInstance(getLocale())));
        } else {
            // localizing the default tick label formatter
            scale.setTickLabelFormatter(
                    new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(getLocale())));
        }

    } else {
        scale = new StandardDialScale();

        // localizing the default tick label formatter
        scale.setTickLabelFormatter(new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(getLocale())));
    }
    scale.setTickRadius(0.9);
    scale.setTickLabelOffset(0.16);
    JRFont tickLabelFont = jrPlot.getTickLabelFont();
    Integer defaultBaseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
            ChartThemesConstants.BASEFONT_SIZE);
    Font themeTickLabelFont = getFont(
            (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT),
            tickLabelFont, defaultBaseFontSize);
    scale.setTickLabelFont(themeTickLabelFont);
    scale.setMajorTickStroke(new BasicStroke(1f));
    scale.setMinorTickStroke(new BasicStroke(0.3f));
    scale.setMajorTickPaint(Color.WHITE);
    scale.setMinorTickPaint(Color.WHITE);
    scale.setTickLabelsVisible(true);
    scale.setFirstTickLabelVisible(true);

    dialPlot.addScale(0, scale);

    List<JRMeterInterval> intervals = jrPlot.getIntervals();
    if (intervals != null && intervals.size() > 0) {
        int size = Math.min(3, intervals.size());
        int colorStep = 0;
        if (size > 3)
            colorStep = 255 / (size - 3);

        for (int i = 0; i < size; i++) {
            JRMeterInterval interval = intervals.get(i);
            Range intervalRange = convertRange(interval.getDataRange());
            double intervalLowerBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getLowerBound(),
                    dialUnitScale);
            double intervalUpperBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getUpperBound(),
                    dialUnitScale);

            Color color = i < 3 ? (Color) ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i)
                    : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0);

            ScaledDialRange dialRange = new ScaledDialRange(intervalLowerBound, intervalUpperBound,
                    interval.getBackgroundColor() == null ? color : interval.getBackgroundColor(), 12f);
            dialRange.setInnerRadius(0.41);
            dialRange.setOuterRadius(0.41);
            dialPlot.addLayer(dialRange);
        }
    }

    JRValueDisplay display = jrPlot.getValueDisplay();
    String displayVisibility = display != null && getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE)
            : "false";
    if (Boolean.parseBoolean(displayVisibility)) {
        ScaledDialValueIndicator dvi = new ScaledDialValueIndicator(0, dialUnitScale);
        dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        //         dvi.setFont(JRFontUtil.getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD));
        dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
        dvi.setPaint(Color.WHITE);

        String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
        if (pattern != null)
            dvi.setNumberFormat(new DecimalFormat(pattern, DecimalFormatSymbols.getInstance(getLocale())));
        dvi.setRadius(0.15);
        dvi.setValueAnchor(RectangleAnchor.CENTER);
        dvi.setTextAnchor(TextAnchor.CENTER);
        //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale)));
        dialPlot.addLayer(dvi);
    }
    String label = getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL)
            : null;

    if (label != null) {
        JRFont displayFont = jrPlot.getValueDisplay().getFont();
        Font themeDisplayFont = getFont(
                (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT),
                displayFont, defaultBaseFontSize);
        if (dialUnitScale < 0)
            label = new MessageFormat(label)
                    .format(new Object[] { String.valueOf(Math.pow(10, dialUnitScale)) });
        else if (dialUnitScale < 3)
            label = new MessageFormat(label).format(new Object[] { "1" });
        else
            label = new MessageFormat(label)
                    .format(new Object[] { String.valueOf((int) Math.pow(10, dialUnitScale - 2)) });

        String[] textLines = label.split("\\n");
        for (int i = 0; i < textLines.length; i++) {
            DialTextAnnotation dialAnnotation = new DialTextAnnotation(textLines[i]);
            dialAnnotation.setFont(themeDisplayFont);
            dialAnnotation.setPaint(Color.WHITE);
            dialAnnotation.setRadius(Math.sin(Math.PI / 4.0) + i / 10.0);
            dialAnnotation.setAnchor(TextAnchor.CENTER);
            dialPlot.addLayer(dialAnnotation);
        }
    }

    //DialPointer needle = new DialPointer.Pointer();
    Paint paint = new Color(191, 48, 0);
    DialPointer needle = new ScaledDialPointer(dialUnitScale, paint, paint);

    needle.setVisible(true);
    needle.setRadius(0.91);
    dialPlot.addLayer(needle);

    DialCap cap = new DialCap();
    cap.setRadius(0.05);
    cap.setFillPaint(Color.DARK_GRAY);
    cap.setOutlinePaint(Color.GRAY);
    cap.setOutlineStroke(new BasicStroke(0.5f));
    dialPlot.setCap(cap);

    JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null,
            dialPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend());

    // Set all the generic options
    configureChart(jfreeChart, getPlot());

    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    return jfreeChart;

}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java

@Override
protected JFreeChart createCandlestickChart() throws JRException {
    JFreeChart jfreeChart = super.createCandlestickChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    CandlestickRenderer renderer = (CandlestickRenderer) xyPlot.getRenderer();
    DefaultHighLowDataset dataset = (DefaultHighLowDataset) xyPlot.getDataset();
    if (dataset != null) {
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            renderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            renderer.setSeriesPaint(i, Color.DARK_GRAY);
        }/*from w  ww  . j  a  v  a  2s  .  c o m*/
    }
    return jfreeChart;
}

From source file:op.tools.SYSCalendar.java

public static Color getBGSHIFT(Byte shift) {
    if (shift == BHPTools.SHIFT_ON_DEMAND) {
        return GUITools.getColor(OPDE.getProps().getProperty("ON_DEMAND_BGSHIFT"));
    }/*w  w  w.  jav a  2s  .co m*/
    if (shift == BHPTools.SHIFT_OUTCOMES) {
        return Color.DARK_GRAY;
    }
    return GUITools.getColor(OPDE.getProps().getProperty(BHPTools.SHIFT_KEY_TEXT[shift] + "_BGSHIFT"));
}