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:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java

private void setupPlotDrawing(XYPlot pPlot) {
    pPlot.setBackgroundPaint(Constants.DS_BACK_LIGHT);
    pPlot.setDomainGridlinePaint(Color.DARK_GRAY);
    pPlot.setRangeGridlinePaint(Color.DARK_GRAY);
    pPlot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    pPlot.setDomainCrosshairVisible(true);
    pPlot.setRangeCrosshairVisible(true);

    DateAxis axis = (DateAxis) pPlot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"));
}

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

@Override
protected JFreeChart createGanttChart() throws JRException {

    JFreeChart jfreeChart = super.createGanttChart();
    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
    categoryPlot.setDomainGridlinesVisible(true);
    categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryPlot.setDomainGridlineStroke(
            new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0));

    categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);

    categoryPlot.setRangeGridlinesVisible(true);
    categoryPlot.setRangeGridlineStroke(
            new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] { 1 }, 0));

    categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134);
    categoryPlot.getDomainAxis().setTickLabelsVisible(
            //barPlot.isShowTickLabels()
            true);/*from w  ww . ja v a 2s.com*/
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = (BarRenderer) categoryRenderer;
    barRenderer.setSeriesPaint(0, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3));
    barRenderer.setSeriesPaint(1, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0));
    CategoryDataset categoryDataset = categoryPlot.getDataset();
    if (categoryDataset != null) {
        for (int i = 0; i < categoryDataset.getRowCount(); i++) {
            barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont());
            barRenderer.setSeriesItemLabelsVisible(i, true);
        }
    }
    categoryPlot.setOutlinePaint(Color.DARK_GRAY);
    categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
    categoryPlot.setOutlineVisible(true);
    return jfreeChart;
}

From source file:com.vgi.mafscaling.MafCompare.java

/**
 * Initialize the contents of the frame.
 *///from ww  w  . j a va 2  s.c o m
private void initialize() {
    try {
        ImageIcon tableImage = new ImageIcon(getClass().getResource("/table.jpg"));
        setTitle(Title);
        setIconImage(tableImage.getImage());
        setBounds(100, 100, 621, 372);
        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        setSize(Config.getCompWindowSize());
        setLocation(Config.getCompWindowLocation());
        setLocationRelativeTo(null);
        setVisible(false);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                Utils.clearTable(origMafTable);
                Utils.clearTable(newMafTable);
                Utils.clearTable(compMafTable);
                Config.setCompWindowSize(getSize());
                Config.setCompWindowLocation(getLocation());
                origMafData.clear();
                newMafData.clear();
            }
        });

        JPanel dataPanel = new JPanel();
        GridBagLayout gbl_dataPanel = new GridBagLayout();
        gbl_dataPanel.columnWidths = new int[] { 0, 0, 0 };
        gbl_dataPanel.rowHeights = new int[] { RowHeight, RowHeight, RowHeight, RowHeight, RowHeight, 0 };
        gbl_dataPanel.columnWeights = new double[] { 0.0, 0.0, 0.0 };
        gbl_dataPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
        dataPanel.setLayout(gbl_dataPanel);
        getContentPane().add(dataPanel);

        JLabel origLabel = new JLabel(origMaf);
        GridBagConstraints gbc_origLabel = new GridBagConstraints();
        gbc_origLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_origLabel.insets = new Insets(1, 1, 1, 5);
        gbc_origLabel.weightx = 0;
        gbc_origLabel.weighty = 0;
        gbc_origLabel.gridx = 0;
        gbc_origLabel.gridy = 0;
        gbc_origLabel.gridheight = 2;
        dataPanel.add(origLabel, gbc_origLabel);

        JLabel newLabel = new JLabel(newMaf);
        GridBagConstraints gbc_newLabel = new GridBagConstraints();
        gbc_newLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_newLabel.insets = new Insets(1, 1, 1, 5);
        gbc_newLabel.weightx = 0;
        gbc_newLabel.weighty = 0;
        gbc_newLabel.gridx = 0;
        gbc_newLabel.gridy = 2;
        gbc_newLabel.gridheight = 2;
        dataPanel.add(newLabel, gbc_newLabel);

        JLabel compLabel = new JLabel("Change");
        GridBagConstraints gbc_compLabel = new GridBagConstraints();
        gbc_compLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_compLabel.insets = new Insets(1, 1, 1, 5);
        gbc_compLabel.weightx = 0;
        gbc_compLabel.weighty = 0;
        gbc_compLabel.gridx = 0;
        gbc_compLabel.gridy = 4;
        dataPanel.add(compLabel, gbc_compLabel);

        JLabel origVoltLabel = new JLabel("volt");
        GridBagConstraints gbc_origVoltLabel = new GridBagConstraints();
        gbc_origVoltLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_origVoltLabel.insets = new Insets(1, 1, 1, 5);
        gbc_origVoltLabel.weightx = 0;
        gbc_origVoltLabel.weighty = 0;
        gbc_origVoltLabel.gridx = 1;
        gbc_origVoltLabel.gridy = 0;
        dataPanel.add(origVoltLabel, gbc_origVoltLabel);

        JLabel origGsLabel = new JLabel(" g/s");
        GridBagConstraints gbc_origGsLabel = new GridBagConstraints();
        gbc_origGsLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_origGsLabel.insets = new Insets(1, 1, 1, 5);
        gbc_origGsLabel.weightx = 0;
        gbc_origGsLabel.weighty = 0;
        gbc_origGsLabel.gridx = 1;
        gbc_origGsLabel.gridy = 1;
        dataPanel.add(origGsLabel, gbc_origGsLabel);

        JLabel newVoltLabel = new JLabel("volt");
        GridBagConstraints gbc_newVoltLabel = new GridBagConstraints();
        gbc_newVoltLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_newVoltLabel.insets = new Insets(1, 1, 1, 5);
        gbc_newVoltLabel.weightx = 0;
        gbc_newVoltLabel.weighty = 0;
        gbc_newVoltLabel.gridx = 1;
        gbc_newVoltLabel.gridy = 2;
        dataPanel.add(newVoltLabel, gbc_newVoltLabel);

        JLabel newGsLabel = new JLabel(" g/s");
        GridBagConstraints gbc_newGsLabel = new GridBagConstraints();
        gbc_newGsLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_newGsLabel.insets = new Insets(1, 1, 1, 5);
        gbc_newGsLabel.weightx = 0;
        gbc_newGsLabel.weighty = 0;
        gbc_newGsLabel.gridx = 1;
        gbc_newGsLabel.gridy = 3;
        dataPanel.add(newGsLabel, gbc_newGsLabel);

        JLabel compPctLabel = new JLabel(" %  ");
        GridBagConstraints gbc_compPctLabel = new GridBagConstraints();
        gbc_compPctLabel.anchor = GridBagConstraints.PAGE_START;
        gbc_compPctLabel.insets = new Insets(1, 1, 1, 5);
        gbc_compPctLabel.weightx = 0;
        gbc_compPctLabel.weighty = 0;
        gbc_compPctLabel.gridx = 1;
        gbc_compPctLabel.gridy = 4;
        dataPanel.add(compPctLabel, gbc_compPctLabel);

        JPanel tablesPanel = new JPanel();
        GridBagLayout gbl_tablesPanel = new GridBagLayout();
        gbl_tablesPanel.columnWidths = new int[] { 0 };
        gbl_tablesPanel.rowHeights = new int[] { 0, 0, 0 };
        gbl_tablesPanel.columnWeights = new double[] { 0.0 };
        gbl_tablesPanel.rowWeights = new double[] { 0.0, 0.0, 1.0 };
        tablesPanel.setLayout(gbl_tablesPanel);

        JScrollPane mafScrollPane = new JScrollPane(tablesPanel);
        mafScrollPane.setMinimumSize(new Dimension(1600, 107));
        mafScrollPane.getHorizontalScrollBar().setMaximumSize(new Dimension(20, 20));
        mafScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        mafScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        GridBagConstraints gbc_mafScrollPane = new GridBagConstraints();
        gbc_mafScrollPane.weightx = 1.0;
        gbc_mafScrollPane.anchor = GridBagConstraints.PAGE_START;
        gbc_mafScrollPane.fill = GridBagConstraints.HORIZONTAL;
        gbc_mafScrollPane.gridx = 2;
        gbc_mafScrollPane.gridy = 0;
        gbc_mafScrollPane.gridheight = 5;
        dataPanel.add(mafScrollPane, gbc_mafScrollPane);

        origMafTable = new JTable();
        origMafTable.setColumnSelectionAllowed(true);
        origMafTable.setCellSelectionEnabled(true);
        origMafTable.setBorder(new LineBorder(new Color(0, 0, 0)));
        origMafTable.setRowHeight(RowHeight);
        origMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        origMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        origMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount));
        origMafTable.setTableHeader(null);
        Utils.initializeTable(origMafTable, ColumnWidth);
        GridBagConstraints gbc_origMafTable = new GridBagConstraints();
        gbc_origMafTable.anchor = GridBagConstraints.PAGE_START;
        gbc_origMafTable.insets = new Insets(0, 0, 0, 0);
        gbc_origMafTable.fill = GridBagConstraints.HORIZONTAL;
        gbc_origMafTable.weightx = 1.0;
        gbc_origMafTable.weighty = 0;
        gbc_origMafTable.gridx = 0;
        gbc_origMafTable.gridy = 0;
        tablesPanel.add(origMafTable, gbc_origMafTable);
        excelAdapter.addTable(origMafTable, false, false, false, false, true, false, true, false, true);

        newMafTable = new JTable();
        newMafTable.setColumnSelectionAllowed(true);
        newMafTable.setCellSelectionEnabled(true);
        newMafTable.setBorder(new LineBorder(new Color(0, 0, 0)));
        newMafTable.setRowHeight(RowHeight);
        newMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        newMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        newMafTable.setModel(new DefaultTableModel(2, MafTableColumnCount));
        newMafTable.setTableHeader(null);
        Utils.initializeTable(newMafTable, ColumnWidth);
        GridBagConstraints gbc_newMafTable = new GridBagConstraints();
        gbc_newMafTable.anchor = GridBagConstraints.PAGE_START;
        gbc_newMafTable.insets = new Insets(0, 0, 0, 0);
        gbc_newMafTable.fill = GridBagConstraints.HORIZONTAL;
        gbc_newMafTable.weightx = 1.0;
        gbc_newMafTable.weighty = 0;
        gbc_newMafTable.gridx = 0;
        gbc_newMafTable.gridy = 1;
        tablesPanel.add(newMafTable, gbc_newMafTable);
        excelAdapter.addTable(newMafTable, false, false, false, false, false, false, false, false, true);

        compMafTable = new JTable();
        compMafTable.setColumnSelectionAllowed(true);
        compMafTable.setCellSelectionEnabled(true);
        compMafTable.setBorder(new LineBorder(new Color(0, 0, 0)));
        compMafTable.setRowHeight(RowHeight);
        compMafTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        compMafTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        compMafTable.setModel(new DefaultTableModel(1, MafTableColumnCount));
        compMafTable.setTableHeader(null);
        Utils.initializeTable(compMafTable, ColumnWidth);
        NumberFormatRenderer numericRenderer = new NumberFormatRenderer();
        numericRenderer.setFormatter(new DecimalFormat("0.000"));
        compMafTable.setDefaultRenderer(Object.class, numericRenderer);
        GridBagConstraints gbc_compMafTable = new GridBagConstraints();
        gbc_compMafTable.anchor = GridBagConstraints.PAGE_START;
        gbc_compMafTable.insets = new Insets(0, 0, 0, 0);
        gbc_compMafTable.fill = GridBagConstraints.HORIZONTAL;
        gbc_compMafTable.weightx = 1.0;
        gbc_compMafTable.weighty = 0;
        gbc_compMafTable.gridx = 0;
        gbc_compMafTable.gridy = 2;
        tablesPanel.add(compMafTable, gbc_compMafTable);
        compExcelAdapter.addTable(compMafTable, false, true, false, false, false, true, true, false, true);

        TableModelListener origTableListener = new TableModelListener() {
            public void tableChanged(TableModelEvent tme) {
                if (tme.getType() == TableModelEvent.UPDATE) {
                    int colCount = origMafTable.getColumnCount();
                    Utils.ensureColumnCount(colCount, newMafTable);
                    Utils.ensureColumnCount(colCount, compMafTable);
                    origMafData.clear();
                    String origY, origX, newY;
                    for (int i = 0; i < colCount; ++i) {
                        origY = origMafTable.getValueAt(1, i).toString();
                        if (Pattern.matches(Utils.fpRegex, origY)) {
                            origX = origMafTable.getValueAt(0, i).toString();
                            if (Pattern.matches(Utils.fpRegex, origX))
                                origMafData.add(Double.valueOf(origX), Double.valueOf(origY), false);
                            newY = newMafTable.getValueAt(1, i).toString();
                            if (Pattern.matches(Utils.fpRegex, newY))
                                compMafTable.setValueAt(
                                        ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i);
                        } else
                            break;
                    }
                    origMafData.fireSeriesChanged();
                }
            }
        };

        TableModelListener newTableListener = new TableModelListener() {
            public void tableChanged(TableModelEvent tme) {
                if (tme.getType() == TableModelEvent.UPDATE) {
                    int colCount = newMafTable.getColumnCount();
                    Utils.ensureColumnCount(colCount, origMafTable);
                    Utils.ensureColumnCount(colCount, compMafTable);
                    newMafData.clear();
                    String newY, newX, origY;
                    for (int i = 0; i < colCount; ++i) {
                        newY = newMafTable.getValueAt(1, i).toString();
                        if (Pattern.matches(Utils.fpRegex, newY)) {
                            newX = newMafTable.getValueAt(0, i).toString();
                            if (Pattern.matches(Utils.fpRegex, newX))
                                newMafData.add(Double.valueOf(newX), Double.valueOf(newY), false);
                            origY = origMafTable.getValueAt(1, i).toString();
                            if (Pattern.matches(Utils.fpRegex, origY))
                                compMafTable.setValueAt(
                                        ((Double.valueOf(newY) / Double.valueOf(origY)) - 1.0) * 100.0, 0, i);
                        } else
                            break;
                    }
                    newMafData.fireSeriesChanged();
                }
            }
        };

        origMafTable.getModel().addTableModelListener(origTableListener);
        newMafTable.getModel().addTableModelListener(newTableListener);

        Action action = new AbstractAction() {
            private static final long serialVersionUID = 8148393537657380215L;

            public void actionPerformed(ActionEvent e) {
                TableCellListener tcl = (TableCellListener) e.getSource();
                if (Pattern.matches(Utils.fpRegex, compMafTable.getValueAt(0, tcl.getColumn()).toString())) {
                    if (Pattern.matches(Utils.fpRegex,
                            origMafTable.getValueAt(1, tcl.getColumn()).toString())) {
                        double corr = Double.valueOf(compMafTable.getValueAt(0, tcl.getColumn()).toString())
                                / 100.0 + 1.0;
                        newMafTable.setValueAt(
                                Double.valueOf(origMafTable.getValueAt(1, tcl.getColumn()).toString()) * corr,
                                1, tcl.getColumn());
                    }
                } else
                    compMafTable.setValueAt(tcl.getOldValue(), 0, tcl.getColumn());
            }
        };

        setCompMafCellListener(new TableCellListener(compMafTable, action));

        // CHART

        JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL,
                false, true, false);
        chart.setBorderVisible(true);
        chartPanel = new ChartPanel(chart, true, true, true, true, true);
        chartPanel.setAutoscrolls(true);

        GridBagConstraints gbl_chartPanel = new GridBagConstraints();
        gbl_chartPanel.anchor = GridBagConstraints.PAGE_START;
        gbl_chartPanel.fill = GridBagConstraints.BOTH;
        gbl_chartPanel.insets = new Insets(1, 1, 1, 1);
        gbl_chartPanel.weightx = 1.0;
        gbl_chartPanel.weighty = 1.0;
        gbl_chartPanel.gridx = 0;
        gbl_chartPanel.gridy = 5;
        gbl_chartPanel.gridheight = 1;
        gbl_chartPanel.gridwidth = 3;
        dataPanel.add(chartPanel, gbl_chartPanel);

        XYSplineRenderer lineRenderer = new XYSplineRenderer(3);
        lineRenderer.setUseFillPaint(true);
        lineRenderer.setBaseToolTipGenerator(
                new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                        new DecimalFormat("0.00"), new DecimalFormat("0.00")));

        Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f);
        lineRenderer.setSeriesStroke(0, stroke);
        lineRenderer.setSeriesStroke(1, stroke);
        lineRenderer.setSeriesPaint(0, new Color(201, 0, 0));
        lineRenderer.setSeriesPaint(1, new Color(0, 0, 255));
        lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5));
        lineRenderer.setSeriesShape(1, ShapeUtilities.createDownTriangle((float) 2.5));
        lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() {
            private static final long serialVersionUID = -4045338273187150888L;

            public String generateLabel(XYDataset dataset, int series) {
                XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series);
                return xys.getDescription();
            }
        });

        NumberAxis mafvDomain = new NumberAxis(XAxisName);
        mafvDomain.setAutoRangeIncludesZero(false);
        mafvDomain.setAutoRange(true);
        mafvDomain.setAutoRangeStickyZero(false);
        NumberAxis mafgsRange = new NumberAxis(YAxisName);
        mafgsRange.setAutoRangeIncludesZero(false);
        mafgsRange.setAutoRange(true);
        mafgsRange.setAutoRangeStickyZero(false);

        XYSeriesCollection lineDataset = new XYSeriesCollection();
        origMafData.setDescription(origMaf);
        newMafData.setDescription(newMaf);
        lineDataset.addSeries(origMafData);
        lineDataset.addSeries(newMafData);

        XYPlot plot = chart.getXYPlot();
        plot.setRangePannable(true);
        plot.setDomainPannable(true);
        plot.setDomainGridlinePaint(Color.DARK_GRAY);
        plot.setRangeGridlinePaint(Color.DARK_GRAY);
        plot.setBackgroundPaint(new Color(224, 224, 224));

        plot.setDataset(0, lineDataset);
        plot.setRenderer(0, lineRenderer);
        plot.setDomainAxis(0, mafvDomain);
        plot.setRangeAxis(0, mafgsRange);
        plot.mapDatasetToDomainAxis(0, 0);
        plot.mapDatasetToRangeAxis(0, 0);

        LegendTitle legend = new LegendTitle(plot.getRenderer());
        legend.setItemFont(new Font("Arial", 0, 10));
        legend.setPosition(RectangleEdge.TOP);
        chart.addLegend(legend);

    } catch (Exception e) {
        logger.error(e);
    }
}

From source file:org.photovault.swingui.PhotoCollectionThumbView.java

private void paintThumbnail(Graphics2D g2, PhotoInfo photo, int startx, int starty, boolean isSelected) {
    log.debug("paintThumbnail entry " + photo.getUuid());
    long startTime = System.currentTimeMillis();
    long thumbReadyTime = 0;
    long thumbDrawnTime = 0;
    long endTime = 0;
    // Current position in which attributes can be drawn
    int ypos = starty + rowHeight / 2;
    boolean useOldThumbnail = false;

    Thumbnail thumbnail = null;//ww  w. j a  va  2  s.  com
    log.debug("finding thumb");
    boolean hasThumbnail = photo.hasThumbnail();
    log.debug("asked if has thumb");
    if (hasThumbnail) {
        log.debug("Photo " + photo.getUuid() + " has thumbnail");
        thumbnail = photo.getThumbnail();
        log.debug("got thumbnail");
    } else {
        /*
         Check if the thumbnail has been just invalidated. If so, use the 
         old one until we get the new thumbnail created.
         */
        thumbnail = photo.getOldThumbnail();
        if (thumbnail != null) {
            useOldThumbnail = true;
        } else {
            // No success, use default thumnail.
            thumbnail = Thumbnail.getDefaultThumbnail();
        }

        // Inform background task scheduler that we have some work to do
        ctrl.getBackgroundTaskScheduler().registerTaskProducer(this, TaskPriority.CREATE_VISIBLE_THUMBNAIL);
    }
    thumbReadyTime = System.currentTimeMillis();

    log.debug("starting to draw");
    // Find the position for the thumbnail
    BufferedImage img = thumbnail.getImage();
    if (img == null) {
        thumbnail = Thumbnail.getDefaultThumbnail();
        img = thumbnail.getImage();
    }

    float scaleX = ((float) thumbWidth) / ((float) img.getWidth());
    float scaleY = ((float) thumbHeight) / ((float) img.getHeight());
    float scale = Math.min(scaleX, scaleY);
    int w = (int) (img.getWidth() * scale);
    int h = (int) (img.getHeight() * scale);

    int x = startx + (columnWidth - w) / (int) 2;
    int y = starty + (rowHeight - h) / (int) 2;

    log.debug("drawing thumbnail");

    // Draw shadow
    int offset = isSelected ? 2 : 0;
    int shadowX[] = { x + 3 - offset, x + w + 1 + offset, x + w + 1 + offset };
    int shadowY[] = { y + h + 1 + offset, y + h + 1 + offset, y + 3 - offset };
    GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, shadowX.length);
    polyline.moveTo(shadowX[0], shadowY[0]);
    for (int index = 1; index < shadowX.length; index++) {
        polyline.lineTo(shadowX[index], shadowY[index]);
    }
    ;
    BasicStroke shadowStroke = new BasicStroke(4.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
    Stroke oldStroke = g2.getStroke();
    g2.setStroke(shadowStroke);
    g2.setColor(Color.DARK_GRAY);
    g2.draw(polyline);
    g2.setStroke(oldStroke);

    // Paint thumbnail
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g2.drawImage(img, new AffineTransform(scale, 0f, 0f, scale, x, y), null);
    if (useOldThumbnail) {
        creatingThumbIcon.paintIcon(this, g2,
                startx + (columnWidth - creatingThumbIcon.getIconWidth()) / (int) 2,
                starty + (rowHeight - creatingThumbIcon.getIconHeight()) / (int) 2);
    }
    log.debug("Drawn, drawing decorations");
    if (isSelected) {
        Stroke prevStroke = g2.getStroke();
        Color prevColor = g2.getColor();
        g2.setStroke(new BasicStroke(3.0f));
        g2.setColor(Color.BLUE);
        g2.drawRect(x, y, w, h);
        g2.setColor(prevColor);
        g2.setStroke(prevStroke);
    }

    thumbDrawnTime = System.currentTimeMillis();

    boolean drawAttrs = (thumbWidth >= 100);
    if (drawAttrs) {
        // Increase ypos so that attributes are drawn under the image
        ypos += ((int) h) / 2 + 3;

        // Draw the attributes

        // Draw the qualoity icon to the upper left corner of the thumbnail
        int quality = photo.getQuality();
        if (showQuality && quality != 0) {
            int qx = startx + (columnWidth - quality * starIcon.getIconWidth()) / (int) 2;
            for (int n = 0; n < quality; n++) {
                starIcon.paintIcon(this, g2, qx, ypos);
                qx += starIcon.getIconWidth();
            }
            ypos += starIcon.getIconHeight();
        }
        ypos += 6;

        if (photo.getRawSettings() != null) {
            // Draw the "RAW" icon
            int rx = startx + (columnWidth + w - rawIcon.getIconWidth()) / (int) 2 - 5;
            int ry = starty + (columnWidth - h - rawIcon.getIconHeight()) / (int) 2 + 5;
            rawIcon.paintIcon(this, g2, rx, ry);
        }
        if (photo.getHistory().getHeads().size() > 1) {
            // Draw the "unresolved conflicts" icon
            int rx = startx + (columnWidth + w - 10) / (int) 2 - 20;
            int ry = starty + (columnWidth - h - 10) / (int) 2;
            g2.setColor(Color.RED);
            g2.fillRect(rx, ry, 10, 10);
        }

        Color prevBkg = g2.getBackground();
        if (isSelected) {
            g2.setBackground(Color.BLUE);
        } else {
            g2.setBackground(this.getBackground());
        }
        Font attrFont = new Font("Arial", Font.PLAIN, 10);
        FontRenderContext frc = g2.getFontRenderContext();
        if (showDate && photo.getShootTime() != null) {
            FuzzyDate fd = new FuzzyDate(photo.getShootTime(), photo.getTimeAccuracy());

            String dateStr = fd.format();
            TextLayout txt = new TextLayout(dateStr, attrFont, frc);
            // Calculate the position for the text
            Rectangle2D bounds = txt.getBounds();
            int xpos = startx + ((int) (columnWidth - bounds.getWidth())) / 2 - (int) bounds.getMinX();
            g2.clearRect(xpos - 2, ypos - 2, (int) bounds.getWidth() + 4, (int) bounds.getHeight() + 4);
            txt.draw(g2, xpos, (int) (ypos + bounds.getHeight()));
            ypos += bounds.getHeight() + 4;
        }
        String shootPlace = photo.getShootingPlace();
        if (showPlace && shootPlace != null && shootPlace.length() > 0) {
            TextLayout txt = new TextLayout(photo.getShootingPlace(), attrFont, frc);
            // Calculate the position for the text
            Rectangle2D bounds = txt.getBounds();
            int xpos = startx + ((int) (columnWidth - bounds.getWidth())) / 2 - (int) bounds.getMinX();

            g2.clearRect(xpos - 2, ypos - 2, (int) bounds.getWidth() + 4, (int) bounds.getHeight() + 4);
            txt.draw(g2, xpos, (int) (ypos + bounds.getHeight()));
            ypos += bounds.getHeight() + 4;
        }
        g2.setBackground(prevBkg);
    }
    endTime = System.currentTimeMillis();
    log.debug("paintThumbnail: exit " + photo.getUuid());
    log.debug("Thumb fetch " + (thumbReadyTime - startTime) + " ms");
    log.debug("Thumb draw " + (thumbDrawnTime - thumbReadyTime) + " ms");
    log.debug("Deacoration draw " + (endTime - thumbDrawnTime) + " ms");
    log.debug("Total " + (endTime - startTime) + " ms");
}

From source file:com.emental.mindraider.ui.graph.spiders.SpidersGraph.java

/**
 * Create an object node from the given node descriptor.
 *
 * @param nodeDescriptor//from w  w  w  .j  av  a2s.c o  m
 *            the node descriptor
 * @return the Node object
 */
public Node createObjectNode(NodeDescriptor nodeDescriptor) {
    Image icon = null;
    if (StringUtils.isNotEmpty(nodeDescriptor.getUri())
            && !MindRaiderVocabulary.isMindRaiderResourceUri(nodeDescriptor.getUri())) {
        // forbid openning of local resources for now
        icon = IconsRegistry.getImage("launch.png");
    }

    Node node = new Node(nodeDescriptor.getId(), render.getObjectNodeType(), render.getObjectBackColor(),
            nodeDescriptor.getLabel(), icon);
    node.setURL(nodeDescriptor.getUri());

    node.setTextColor(render.getObjectTextColor());
    node.setNodeBackSelectColor(render.getObjectSelectBackColor());
    node.setNodeBorderInactiveColor(render.getNodeInactiveBorder());

    node.setNodeBackHilightColor(render.getObjectHilightBackColor());

    // TODO change - just experiment of node drawing
    node.BORDER_INACTIVE_COLOR = Color.DARK_GRAY;
    node.BORDER_MOUSE_OVER_COLOR = Color.WHITE;

    return node;
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

private Box createRationaliserPanel(final String name, final RationaliserJList rjlist) {

    int preferredHeight = 500; //change accordingly
    int preferredWidth = 500;

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension size = tk.getScreenSize();
    int textboxHeight = 10; //change accordingly
    int textboxWidth = size.width;

    Box box = Box.createVerticalBox();
    box.add(new JLabel(name));

    JTextField searchField = new JTextField(20); //Search field on top
    /* We don't want this textfield's height to expand when
     * the Rationaliser is dragged to exapnd. So we set it's
     * height to what we want and the width to the width of
     * the screen  /*w w w . jav  a 2  s .c  o  m*/
     */
    searchField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    rjlist.installJTextField(searchField);
    box.add(searchField);

    JScrollPane scrollPane = new JScrollPane(); //scroll pane
    scrollPane.setViewportView(rjlist);
    scrollPane.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
    box.add(scrollPane);

    TitledBorder sysidBorder = BorderFactory.createTitledBorder("Systematic IDs"); //systematic ID box
    sysidBorder.setTitleColor(Color.DARK_GRAY);

    final JTextArea idField = new JTextArea(1, 1);
    idField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    idField.setEditable(false);
    idField.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    idField.setForeground(Color.DARK_GRAY);
    JScrollPane scroll = new JScrollPane(idField);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    Box sysidBox = Box.createVerticalBox();
    sysidBox.add(scroll /*idField*/);
    sysidBox.setBorder(sysidBorder);
    box.add(sysidBox);

    rjlist.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            Term highlightedTerm = (Term) rjlist.getSelectedValue();
            if (highlightedTerm != null) {
                /* For each list, call the relevant methods
                 * to get the systematic IDs. Then for the
                 * right list, add the term name in the
                 * text box below
                 */
                if (name.equals(FROM_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, selectedTaxons)));
                } else if (name.equals(TO_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, null)));
                    /* We allow the user to edit the term name */
                    textField.setText(highlightedTerm.getName());
                }

            }
        }
    });

    return box;

}

From source file:srvclientmonitor.frmMain.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    JPanel panel = new JPanel();
    getContentPane().add(panel);/*from w ww.j a va2  s.co m*/
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    //DefaultPieDataset data = new DefaultPieDataset();  //Para el Grafico PIE

    data.addValue(20, "OSP", "HOY");
    data.addValue(99, "ETL", "HOY");
    data.addValue(25, "LOR", "HOY");
    data.addValue(12, "MOV", "HOY");

    // Creando el Grafico
    //JFreeChart chart = ChartFactory.createPieChart(
    //JFreeChart chart = ChartFactory.createBarChart("Ejemplo Rapido de Grafico en un ChartFrame", "Mes", "Valor", data);

    JFreeChart chart = ChartFactory.createBarChart("", "", "", data, PlotOrientation.VERTICAL, false, false,
            false);
    chart.setBackgroundPaint(Color.BLACK);
    chart.setTitle("");

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangePannable(true);
    plot.setRangeGridlinesVisible(false);
    plot.setBackgroundAlpha(1);
    plot.setBackgroundPaint(Color.BLACK);
    plot.setForegroundAlpha(1);
    plot.setDomainCrosshairPaint(Color.WHITE);
    plot.setNoDataMessagePaint(Color.WHITE);
    plot.setOutlinePaint(Color.WHITE);
    plot.setRangeCrosshairPaint(Color.WHITE);
    plot.setRangeMinorGridlinePaint(Color.WHITE);
    plot.setRangeZeroBaselinePaint(Color.WHITE);

    //        Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //        plot.setBackgroundPaint(p);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelPaint(Color.WHITE);
    rangeAxis.setAxisLinePaint(Color.WHITE);
    rangeAxis.setTickLabelPaint(Color.WHITE);
    rangeAxis.setVerticalTickLabels(true);

    //ChartUtilities.applyCurrentTheme(chart);

    // Crear el Panel del Grafico con ChartPanel
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setSize(300, 150);
    chartPanel.setBackground(Color.BLACK);
    chartPanel.setOpaque(false);
    chartPanel.setDomainZoomable(true);
    this.jPanel1.setSize(300, 200);
    this.jPanel1.setBackground(Color.DARK_GRAY);
    this.jPanel1.add(chartPanel);

}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

public void addDomainMarkers(Date start, Date stop, TimeZone timeZone, Locale locale) {
    if (!addedDomainMarkers) {
        //make a one hour by one hour time list
        //The reason is that not all the data are hour by hour
        //domainMarkers will not mark labels when no date at clock 00:00

        List<Date> time = getTimeHourByHour(start, stop);
        // set the markers
        Map<Long, String> domainMarkers = getDomainMarkersWithLabel(time, timeZone, locale);
        for (Map.Entry<Long, String> entry : domainMarkers.entrySet()) {
            Long timeInMilli = entry.getKey();
            String label = entry.getValue();
            final Marker originalEnd = new ValueMarker(timeInMilli);
            originalEnd.setPaint(Color.DARK_GRAY);
            originalEnd.setStroke(new BasicStroke(1.0f));
            originalEnd.setLabel(label);//Arial Hebrew, SansSerif
            originalEnd.setLabelFont(new Font("Arial", Font.PLAIN, 14));
            originalEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
            originalEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT);
            plot.addDomainMarker(originalEnd, Layer.BACKGROUND);
            setAddedDomainMarkers(true);
        }/*from   w ww  .ja  va  2s  . c o  m*/

    }
}

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

/**
 *
 */// w  ww  .java 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();
    List seriesPaints = (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);

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

        renderer.setSeriesFillPaint(i, (Paint) seriesPaints.get(i));
        renderer.setSeriesPaint(i, Color.DARK_GRAY);
    }
    return jfreeChart;
}

From source file:au.com.gaiaresources.bdrs.controller.test.TestDataCreator.java

private byte[] createImage(int width, int height, String text) throws IOException {
    if (width < 0) {
        width = random.nextInt(DEFAULT_MAX_IMAGE_WIDTH - DEFAULT_MIN_IMAGE_WIDTH) + DEFAULT_MIN_IMAGE_WIDTH;
    }//www .  j ava 2 s.  c  o  m
    if (height < 0) {
        height = random.nextInt(DEFAULT_MAX_IMAGE_HEIGHT - DEFAULT_MIN_IMAGE_HEIGHT) + DEFAULT_MIN_IMAGE_HEIGHT;
    }

    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2 = (Graphics2D) img.getGraphics();
    g2.setBackground(new Color(220, 220, 220));

    Dimension size;
    float fontSize = g2.getFont().getSize();
    // Make the text as large as possible.
    do {
        g2.setFont(g2.getFont().deriveFont(fontSize));
        FontMetrics metrics = g2.getFontMetrics(g2.getFont());
        int hgt = metrics.getHeight();
        int adv = metrics.stringWidth(text);
        size = new Dimension(adv + 2, hgt + 2);
        fontSize = fontSize + 1f;
    } while (size.width < Math.round(0.9 * width) && size.height < Math.round(0.9 * height));

    g2.setColor(Color.DARK_GRAY);
    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2.drawString(text, (width - size.width) / 2, (height - size.height) / 2);
    g2.setColor(Color.LIGHT_GRAY);
    g2.drawRect(0, 0, width - 1, height - 1);

    ByteArrayOutputStream baos = new ByteArrayOutputStream(width * height);
    ImageIO.write(img, "png", baos);
    baos.flush();
    byte[] rawBytes = baos.toByteArray();
    baos.close();

    return rawBytes;
}